akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			int x = scan.nextInt();
			int y = scan.nextInt();
			int s = scan.nextInt();
			if (x == 0 && y == 0 && s == 0) break;
			int maxval = 0;
			for (int i = 1; i < s; i++) {
				for (int j = i; j < s; j++) {
					int sum = (i * (100 + x) / 100) + (j * (100 + x) / 100);
					if (sum != s) continue;
					int val = (i * (100 + y) / 100) + (j * (100 + y) / 100);
					if (maxval < val) maxval = val;
				}
			}
			System.out.println(maxval);
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 29248
def incriment(w, h, x, y, r)
	maxw = w - r
	maxh = h - r
	if (maxw >= x && r <= x && maxh >= y && r <= y)
		return 'Yes'
	else
		return 'No'
	end
end

input = gets.chomp
w, h, x, y, r = input.split(' ').map(&:to_i)
puts incriment(w, h, x, y, r)

Measured memory_bytes: 8680
#include <bits/stdc++.h>

using namespace std;

string s;

int n, k;

int main()
{
    ios::sync_with_stdio(false); cin.tie(0);
    cin >> n >> k >> s, --k;
    s[k] = (s[k] - 'A') + 'a';
    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int N;
    cin >> N;

    vector<int>V(N), C(N);
    for(int i=0;i<N;i++) cin >> V.at(i);
    for(int i=0;i<N;i++) cin >> C.at(i);

    int X=0,Y=0;
    for(int i=0;i<N;i++){
        if(V.at(i)>C.at(i)){
            X+=V.at(i);
            Y+=C.at(i);
        }
    }

    cout << X-Y << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <math.h>
using namespace std;
typedef long long ll;
//#define ll long long
const ll N = 2009;
const ll maxn = 1e5 + 20;
const ll mod = 1000000007;
//ll inv[maxn], vis[maxn], dis[maxn], head[maxn];
ll fac[maxn], a[maxn], q[maxn], b[maxn], c[maxn], pre[maxn];
vector<ll> vec;
//typedef pair<ll, ll> p;
//priority_queue<p, vector<p>, greater<p> > m;
ll sum[maxn];
ll max(ll a, ll b) { return a > b ? a : b; }
ll min(ll a, ll b) { return a < b ? a : b; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }
map<ll, ll> mp;
ll ksm(ll a, ll b)
{
    a %= mod;
    ll ans = 1ll;
    while (b)
    {
        if (b & 1)
            ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1ll;
    }
    return ans;
}
ll lowbit(ll x)
{
    return x & (-x);
}
int dp[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, ans = 1, x, res;
    cin >> n;
    for (ll i = 1; i <= n; i++)
        cin >> a[i], mp[a[i]]++;
    sort(a + 1, a + 1 + n);
    for (ll i = 1; i <= n; i++)
    {
        int fla = 0, res;
        for (ll j = 1; j <= n; j += mp[a[j]])
        {
            if (i == j && mp[a[i]] == 1)
                continue;
            if (!fla)
                fla = 1, res = a[j];
            res = gcd(res, a[j]);
            if (res == 1)
                break;
        }
        ans = max(ans, res);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4376
#include <cstdio>
#include <algorithm>
int N, RMQ[11][2001], LOG[2001], X;
long long O = 1LL << 60;
inline int query(int l, int r)
{
	int Log = LOG[r - l + 1];
	return std::min(RMQ[Log][l], RMQ[Log][r - (1 << Log) + 1]);
}
int main()
{
	scanf("%d%d", &N, &X);
	for (int i = 1; i <= N; i++)
		scanf("%d", RMQ[0] + i);
	for (int i = 2; i <= N; i++)
		LOG[i] = LOG[i >> 1] + 1;
	for (int i = 1, k = 1; k + k <= N; i++, k <<= 1)
		for (int j = 1; j <= N - k - k + 1; j++)
			RMQ[i][j] = std::min(RMQ[i - 1][j], RMQ[i - 1][j + k]);
	for (int i = 0; i < N; i++)
	{
		long long S = (long long)X * i;
		for (int j = i + 1; j <= N; j++)
			S += query(j - i, j);
		for (int j = 1; j <= i; j++)
			S += std::min(query(N + j - i, N), query(1, j));
		O = std::min(O, S);
	}
	printf("%lld\n", O);
	return 0;
}


Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
arr = Array.new
arr2 = Array.new
n.times do
    arr.push(gets.split.map(&:to_i))
end
m.times do
    arr2.push(gets.to_i)
end
n.times do |i|
    sum = 0
    m.times do |j|
        sum += arr[i][j] * arr2[j]
    end
    p sum
end

Measured memory_bytes: 8908
// This amazing code is by Eric Sunli Chen.
#include<bits/stdc++.h>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=1e9+7;
int qpow(int x,int y){int ret=1;do{if(y&1)ret=1ll*ret*x%mod;x=1ll*x*x%mod;}while(y>>=1);return ret;}

int dp[25111][411],n,m,k,a[30111];
int last[444];

int main()
{
	get3(n,k,m);
	for(int i=1;i<=m;i++)get1(a[i]);
	
	int ans=n-m+1,mx=0;for(int i=1;i<=n-m;i++)ans=1ll*ans*k%mod;
	for(int i=1;i<=m;i++)
	{
		mx=max(mx,last[a[i]]);
		if(i-mx==k)
		{
			printendl(ans);
			return 0;
		}
		last[a[i]]=i;
	}
	
	for(int i=1;i<k;i++)dp[0][i]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<k;j++)dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
		for(int j=1;j<k;j++)dp[i][j]=(dp[i][j]+1ll*dp[i-1][j+1]*(k-j))%mod;
	}
	
	int ml=0,mr=0;
	memset(last,0,sizeof(last));
	for(int i=1;i<=m;i++)
	{
		if(last[a[i]])
		{
			ml=i-1;
			break;
		}
		last[a[i]]=i;
	}
	memset(last,0,sizeof(last));
	for(int i=m;i>=1;i--)
	{
		if(last[a[i]])
		{
			mr=m-i;
			break;
		}
		last[a[i]]=i;
	}
	if(ml)
	{
		for(int i=0;i<=n-m;i++)ans=(ans-1ll*dp[i][ml]*dp[n-m-i][mr]%mod+mod)%mod;
		printendl(ans);
	}
	else
	{
		for(int i=0;i<=n-m;i++)
		{
			int prod=1;
			for(int j=0;j<=n-m-i;j++)
			{
				if(m+j==k)break;
				int coef=1ll*prod*dp[i][m+j]%mod;
				if(i+m+j!=n)coef=1ll*coef*(dp[n-m-i-j][m+j]-1ll*(k-m-j)*dp[n-m-i-j-1][m+j+1]%mod+mod)%mod;
				ans=(ans-coef+mod)%mod;
				prod=1ll*prod*(k-m-j)%mod;
			}
		}
		printendl(ans);
	}
	return 0;
}

Measured memory_bytes: 40448
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<cfloat>
#include<cmath>
#include<map>
#include<complex>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

typedef unsigned int uint;
typedef long long ll;

using namespace std;

#define MAX (100000000)

int main(){
  int n;
  while(scanf("%d",&n), n){
    int m;
    vector<bool> f(n, false);
    vector<vector<int> > g(n, vector<int>(n, MAX));
    int ans = 0;
    scanf("%d",&m);
    REP(i,m){
      int a,b,c;
      scanf("%d,%d,%d",&a,&b,&c); c/=100;
      g[a][b] = g[b][a] = c - 1;
    }
    f[0] = true;
    REP(k, n-1){
      int a,b,s;
      s = MAX;
      REP(i, n) REP(j, n) if(f[i] != f[j]){
        if(s > g[i][j]){
          a = i; b = j; s = g[i][j];
        }
      }
      f[a] = f[b] = true;
      ans += s;
    }
    printf("%d\n",ans);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <fstream>
#include <vector>
#include <algorithm>
#include <utility>
#include <set>
#include <queue>
#include <map>
#include <cmath>
#include <numeric>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

const long long mod = 1e9 + 7;

int main() {
    
    
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    
    sort(v.begin(), v.end());
    
    ll ma = v[n - 1];
    ll mi = v[0];
    for (int i = 1; i < n - 1; ++i)
    {
        if (v[i] > 0)
        {
            mi -= v[i];
        }
        else
        {
            ma -= v[i];
        }
    }
    
    ll ret = ma - mi;
    
    cout << ret << endl;
    ma = v[n - 1];
    mi = v[0];
    for (int i = 1; i < n - 1; ++i)
    {
        if (v[i] > 0)
        {
            cout << mi << " " << v[i] << endl;
            mi -= v[i];
        }
        else
        {
            cout << ma << " " << v[i] << endl;
            ma -= v[i];
        }
    }
    
    cout << ma << " " << mi << endl;
    
    return 0;
}

Measured memory_bytes: 2688
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//17:00~

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int n,a=2;cin>>n;
	while(a*2<=n){a*=2;}
	cout<<a<<endl;
	return 0;
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> V(N);
    rep(i,0,N)cin >> V[i];
    sort(V.begin(), V.end());
    ll ans = 0;
    rep(i,0,N - K){
        ans += V[i];

    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
  string S;
  cin >> S;
  int count = 0;
  int ans = 0;
  for(int i=0; i<S.length(); ++i){
    if(S[i]=='A'||S[i]=='C'||S[i]=='G'||S[i]=='T') ++count;
    else{
      count = 0;
    }
    ans = max(ans, count);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3612
N = int(input())
c = 0
for  i in range(1,N+1):
  if i % 2 == 0:
    continue
  li = []
  if i < 10:
    continue
  else:
    k = i
    for j in range(2,int(i**(0.5)+3)):
      d = 1
      while k % j == 0:
        k = k/j
        d += 1
      if d != 1:
        li.append(d)
    ss = 1
    for x in li:
      ss *= x
    if ss == 8:
      #print(i)
      c += 1
    
print(c)


Measured memory_bytes: 3060
from collections import defaultdict


s = input()[::-1]
cntr = defaultdict(int)
cntr[0] += 1
tens = 1
n = 0
for c in s:
    n += tens * int(c) % 2019
    n %= 2019
    cntr[n] += 1
    tens = tens * 10 % 2019

ans = 0
for v in cntr.values():
    if v > 1:
        ans += v * (v - 1) // 2
print(ans)


Measured memory_bytes: 9520
#include<bits/stdc++.h>
using namespace std;

#define Ff(i,a,b) for(i=a;i<b;i++)
#define Fb(i,a,b) for(i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define mp make_pair
#define PI 2*asin(1)
#define all(x) x.begin(),x.end()
#define trav(x) for(auto& i:x)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define spc ' '

typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<long long> vll;
typedef map<int, int> mi;
typedef map<long long, long long> mll;
typedef unordered_map<int, int> umi;
typedef unordered_map<long long, long long> umll;
typedef set<int> si;
typedef set<long long> sll;
typedef unordered_set<int> usi;
typedef unordered_set<long long> usll;

// #define int long long

void sub() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
}


void solve() {
	string s, t;
	cin >> s >> t;
	int i, j;
	int n = s.length();
	int m = t.length();
	int c = 0, min = INT_MAX;
	Ff(i, 0, n - m + 1) {
		c = 0;
		Ff(j, 0, m) {
			if (s[i + j] != t[j])
				c++;
		}
		if (c < min)min = c;
		if (min == 0)break;
	}
	cout << min << endl;
}



int32_t main() {
	FIO
	sub();
	int t = 1;
	// cin >> t;
	while (t--)
		solve();

	return 0;
}




Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


const int N = 2e5+10;
int n,k,c;

int seg[2*N];
int seg2[2*N];
int seg3[2*N];

void updp(int id,int val)
{
    for(seg[id+=n]=val;id>1;id>>=1) seg[id>>1] = max(seg[id],seg[id^1]);
}
        
int queryp(int l,int r)
{
    int res = 0;
    
    for(l+=n,r+=n+1;l<r;l>>=1,r>>=1)
    {
        if(l&1) res=max(res,seg[l++]);
        if(r&1) res=max(res,seg[--r]);
    }
    
    return res;
}

void upds(int id,int val)
{
    for(seg2[id+=n]=val;id>1;id>>=1) seg2[id>>1] = max(seg2[id],seg2[id^1]);
}
        
int querys(int l,int r)
{
    int res = 0;
    
    for(l+=n,r+=n+1;l<r;l>>=1,r>>=1)
    {
        if(l&1) res=max(res,seg2[l++]);
        if(r&1) res=max(res,seg2[--r]);
    }
    
    return res;
}
        
void upd(int id,int val)
{
    for(seg3[id+=n]=val;id>1;id>>=1) seg3[id>>1] = max(seg3[id],seg3[id^1]);
}
        
int query(int l,int r)
{
    int res = 0;
    
    for(l+=n,r+=n+1;l<r;l>>=1,r>>=1)
    {
        if(l&1) res=max(res,seg3[l++]);
        if(r&1) res=max(res,seg3[--r]);
    }
    
    return res;
}


void solve()
{
    cin >> n >> k >> c;
    
    string s;
    cin >> s;
    
    f(i,n)
    {
        if(s[i] == 'x') continue;
        
        if(i>=c+1) updp(i,1+queryp(0,i-c-1));
        else updp(i,1);
    }
    
    f(i,n)
    {
        if(s[n-i-1] == 'x') continue;
 
        if(n-i-1+c+1 <=n-1) upds(n-i-1,1+querys(n-i-1+c+1,n-1));
        else upds(n-i-1,1);
    }
    
    if(queryp(0,n-1) > k) return;
    
    assert(querys(0,n-1) == k);
    assert(queryp(0,n-1) == k);
    
   f(i,n) upd(i,querys(i,i) + queryp(i,i)-1); 
    
   f(i,n)
   {
       if(s[i] == 'x') continue;
       
       //if i must be taken,means none of i+c and i-c is able to do
       int left = query(max(0,i-c),i-1);
       int right = query(i+1,min(n-1,i+c));
                         
       if(max(left,right) < k) cout << i+1 << '\n';
      
   }
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

Measured memory_bytes: 6548
N = int(input())
mod = 998244353
# DP ナップサックぽいやつ
# DP[i][j] := a_0からa_iまでの部分集合で和がjになるものの個数
# 配るDPの方が場合分けがなくて簡潔に書ける 計算量増えるかも
# DP[i-1][j]→DP[i][j]とDP[i][j + a_i ]に配る
 
aaa = [int(input()) for _ in range(N)]
 
sum_now = 0
DP = [[0] * (sum(aaa)+1) for i in range(N)]
DP2 = [[0] * (sum(aaa)+1) for i in range(N)]
 
a = aaa[0]
DP[0][0] = 2
DP[0][a] = 1
 
DP2[0][0] = 1
DP2[0][a] = 1
 
sum_now += a
 
for i in range(1, N):
	a = aaa[i]
	for j in range(sum_now + 1):
		DP[i][j] += DP[i-1][j] * 2
		DP[i][j] %= mod
		DP[i][j + a] += DP[i-1][j]
 
		DP2[i][j] += DP2[i-1][j]
		DP2[i][j] %= mod
		DP2[i][j + a] += DP2[i-1][j]
 
	sum_now += a
 
# print(DP2)
minimum_invalid_length = int((sum_now+1)//2)
num_too_long = sum (DP[N-1][minimum_invalid_length:])
if (sum(aaa) %2 == 0):
	num_too_long -= DP2[N-1][int(sum(aaa) /2)]
# print(num_too_long)
# print(sum(aaa))
print((3** N - num_too_long * 3) % mod )

Measured memory_bytes: 457112
# -*- coding:utf-8 -*-

a = []
b = []
time = 0
for i in range(5):
    a.append(int(input()))
for i in range(5):
    b.append(a[i]%10)
    if a[i]%10 != 0:
        a[i] = (a[i]//10 + 1) * 10
    else:
        b[i] = 10
    time += a[i]
b.sort(reverse=True)
time = time - (10-b[4])
print(time)


Measured memory_bytes: 3060
#include <bits/stdc++.h>

using namespace std;

int main() {
    std::ios::sync_with_stdio(false); 
    cin.tie(nullptr);

    int A, B, C;
    cin >> A >> B >> C;
    int transfer = min(C, A - B);
    cout << C - transfer << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>

using namespace std;

int main(){
  string S;
  cin >> S;
  
  string ret = "No";
  for(int i=0; i<3; i++){
    if(S[i] == '7') ret = "Yes";
  }
  
  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
static const int INFTY = (1 << 30);
int N, M;
void func()
{
    cin >> N;
    if (N % 1000 == 0)
        cout << 0 << endl;
    else
        cout << 1000 - N % 1000 << endl;
}
int main()
{
    func();
}

Measured memory_bytes: 3628
import java.lang.Math;
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    double r = sc.nextDouble();

    double area = r*r*Math.PI;
    double length = 2*Math.PI*r;

    System.out.printf("%.6f %.6f",area,length);
    sc.close();
  }
}



Measured memory_bytes: 28356
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include<cassert>
    #include<cmath>
    #include<cstdint>
    #include<numeric>
    #include<array>
     
    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
    #define ALL(a)  (a).begin(),(a).end()
    #define chmin(a, b) a = min(a, b)
    #define chmax(a, b) a = max(a, b)
    #define Vl vector<ll>
     
    using namespace std;
    using ll = long long;
    using Graph = vector<vector<ll>>;
    using P = pair<ll, ll>;
     
const ll MOD = 1e9 + 7;
const ll ZER = 0;

int main(){
    int n;
    cin >> n;
    map<ll, ll> mp;
    ll sum = 0;
    rep(i, n){
        ll a;
        cin >> a;
        mp[a]++;
        sum += a;
    }
    ll Q;
    cin >> Q;
    while(Q--){
        ll b, c;
        cin >> b >> c;
        ll tmp = sum;
        tmp -= (b * mp[b]);
        tmp += (c * mp[b]);
        mp[c] += mp[b];
        mp[b] = 0;
        cout << tmp << endl;
      sum = tmp;
    }
}

Measured memory_bytes: 9488
#include <cstdint>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>

using Value = std::int64_t;
constexpr Value mod = 998244353;

template<typename T>
T modpow(T base, T exp, T modulus)
{
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

long solve(const std::vector<int>& v)
{
  const auto sum = std::accumulate(v.begin(), v.end(), 0);
  std::vector<Value> counts_of_r_size(sum + 1);
  counts_of_r_size[0] = 1;
  auto counts_of_r_size2 = counts_of_r_size;

  for (auto a : v) {
    for (int i = sum; i >= 0; --i) {
      counts_of_r_size[i] *= 2;
      if (a <= i) counts_of_r_size[i] += counts_of_r_size[i - a];
      counts_of_r_size[i] %= mod;
    }
  }
  const auto count1 = std::accumulate(
      std::next(std::begin(counts_of_r_size), (sum + 1) / 2),
      std::end(counts_of_r_size),
      Value{0},
      [](Value r, Value i) { return (r + i) % mod; })
      * 3 % mod;

  if (sum % 2 == 0) {
    for (auto a : v) {
      for (int i = sum; i >= 0; --i) {
        if (a <= i) {
          counts_of_r_size2[i] += counts_of_r_size2[i - a];
          counts_of_r_size2[i] %= mod;
        }
      }
    }
  }
  const auto count2 = counts_of_r_size2[sum / 2] * 3 % mod;

  return (modpow<Value>(3, v.size(), mod) - count1 + count2 + mod) % mod;
}

int main()
{
  int n;
  std::cin >> n;

  std::vector<int> v(n);
  for (auto& i : v) {
    std::cin >> i;
  }

  std::cout << solve(v) << std::endl;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, h[100008];
string str;

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> h[i];
	}
	
	ll buf = 0;
	ll ans = 0;
	for(ll i = 1; i < n; i++){
		if(h[i] >= h[i+1]){
			buf++;
		}
		else{
			ans = max(buf, ans);
			buf = 0;
		}
	}
	ans = max(buf, ans);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;
const int INF = 1e9;
#define ll long long

class TaskA {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int a, b;
		cin >> a >> b;
		cout << a * b << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};

int main(){
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
#define int long long
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;

signed main(){
	int A,B,K;
	vector<int> v;
	int cnt=0;
	cin>>A>>B>>K;
	for(int i=1;i<=100;i++){
		if(A%i==0&&B%i==0){
			cnt++;
			v.push_back(i);
		}
	}
	sort(v.begin(),v.end(),greater<>());
	cout<<v[K-1]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {

  int n;

  int not_prime[51000];
  int ans;

  int idx;

  
  not_prime[0]=not_prime[1]=1;

  for(int i=2;i<=50000;i++) not_prime[i]=0;

  for(int i=2;i<=sqrt(50000);i++) {

    if(not_prime[i]==0) {

      for(int j=2*i;j<=50000;j+=i) {

	not_prime[j]=1;

      }

    }

  }

  //for(int i=0;i<=50000;i++) cout << not_prime[i] << " ";

  while(1) {

    cin >> n;

    if(n==0) break;

    ans=0;

    for(int i=2;i<=n/2;i++) {

      if(not_prime[i]==0 && not_prime[n-i]==0) ans++;

    }
  
    cout << ans << endl;

  }

  return 0;

}

  

Measured memory_bytes: 1064
def main():
    A, B, K = map(int, input().split())
    cnt = 0
    if A == B:
        cnt += 1
        if K == 1:
            print(A)
            exit()
    if A > B:
        A, B = B, A
    for i in range(B // 2, 0, -1):
        if A % i == 0 and B % i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                break


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>

using namespace std;

typedef long long          ll;
typedef unsigned long long ull;
typedef vector<int>	       vi;
typedef vector<bool>       vb;
typedef map<int, int>      mii;
typedef pair<int, int>     ii;

#define INF                0x3f3f3f3f
#define INFLL              0x3f3f3f3f3f3f3f3f
#define each(x, s)         for(auto& x : s)
#define loop(x)	           for(int i = 0;i < x;i++)
#define vloop(v, x)        for(int v = 0;v < x;v++)
#define avg(l, r)          l + (r - l) / 2
#define iter(a)            a.begin(), a.end()
#define riter(a)           a.rbegin(), a.rend()
#define endl               "\n"

const ll mod = 1000000007;

int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

  int n, x, t;
  cin >> n >> x >> t;
  cout << (n + x - 1) / x * t << endl;
	return 0;
}



Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include <vector>
#include <algorithm>
#define max(a,b) ((a < b) ? b : a)
#define min(a,b) ((a > b) ? b : a)
using namespace std;
int main() {
  // 入力
  int p, q, r;
  cin >> p >> q >> r;
  
  // 出力
  int ans = p + q + r - max(p, max(q, r));
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define repi(n) for (int i = 0; i < n; i++)
#define repj(n) for (int j = 0; j < n; j++)
#define repk(n) for (int k = 0; j < n; k++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (auto i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}

int main() {
  double t, x;
  cin >> t >> x;
  cout << t / x << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define sc(a) scanf("%d", &a)
#define sc2(a,b) scanf("%d%d", &a, &b)
#define sc3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define pri(x) printf("%d\n", x)
#define mp make_pair
#define pb push_back
#define BUFF ios::sync_with_stdio(false);
#define imprime(v) for(int X=0;X<v.size();X++) printf("%d ", v[X]); printf("\n");
#define endl "\n"
const int INF= 0x3f3f3f3f;
const long double pi= acos(-1);
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector< vector< int > > vvi;
const int MOD=1e9+7;
const ll LINF=0x3f3f3f3f3f3f3f3f;
int a[100005];
bool ok;

void check_group(int n, int k)
{
  assert(n!=0);
  if(k<=0 or k>=n or n<k*2)
  {
    ok=false;
  }
}

int n;
int main()
{
  ok=true;
  int maxval=0;
  sc(n);
  int minval=n+10;
  for(int i=0;i<n;i++)
  {
    sc(a[i]);
    maxval=max(maxval,a[i]);
    minval=min(minval,a[i]);
  }
  if(maxval-minval>1)
  {
    puts("No");
    return 0;
  }
  if(maxval==minval)
  {
    check_group(n,maxval);
    if(maxval!=0 and maxval==n-1) ok=true;
  }
  else
  {
    int cont=0;
    for(int i=0;i<n;i++)
    {
      if(a[i]==minval)
      {
        cont++;
      }
    }
    check_group(n-cont,maxval-cont);
  }
  if(ok) puts("Yes");
  else puts("No");

  return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
#define all(V) V.begin(),V.end()
#define stackReplaceBegin(size)\
	void* p=malloc(size);\
	esp_new=(lint)p+size-1;\
	void * stack_extend_memory_ = malloc(size);\
	void * stack_extend_origin_memory_;\
	char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);\
	*stack_extend_dummy_memory_ = 0;\
	asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI = 3.141592653589793238462643383279;
lint esp_new;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, unsigned int b) {
	T res(1),now(a);
	while(b){
		if(b&1)res*=now;
		b>>=1;
		now*=now;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, (int)vec.size() - 1)std::cout << vec[i] << " ";
	if(!vec.empty())std::cout << vec.back() << std::endl;
}
template<typename T>
void printArray(T l, T r) {
	T rprev = r;
	rprev--;
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
int n,a[200010];
int main() {
	std::cin>>n;
	for(int i=0;i<n;i++)std::cin>>a[i];
	int s=0;
	for(int i=0;i<n;i++)s^=a[i];
	for(int i=0;i<n;i++){
		std::cout<<(s^a[i]);
		if(i!=n-1)std::cout<<" ";
		else std::cout<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 4340
#include <cstdio>
#include <set>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  set<int> s;
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    s.insert(x);
  }
  puts((int)s.size() == n ? "YES" : "NO");
}


Measured memory_bytes: 9600
/*input
5 3
-30 -10 10 20 50
*/

#include <bits/stdc++.h>

// max, min, log, input is defined

using namespace std; 

int n, k, num, zero = 0, plcou=0, micou=0;
int p[100010], m[100010];
int mini = 2e9;

int main(){
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		cin >> num;
		if (num>0) { p[plcou] = num; plcou++; }
		else if (num == 0) zero++;
		else { m[micou] = 0-num; micou++; }
	}
	k-=zero;

	int pstat=1, mstat=1;

	if (!plcou) { plcou++; pstat=0; }
	if (!micou) { micou++; mstat=0; }

	// cout << plcou << ' ' << micou << endl;

	for (int i=0; i<plcou; ++i)
	{
		for (int jj=micou-1, j=0; jj>=0; jj--, j++)
		{
			if (i+j+pstat+mstat==k){
				int save = p[i]>m[jj]?(p[i]+2*m[jj]):(2*p[i]+m[jj]);
				// cout << p[i] << ' ' << m[jj] << ' ' << save << endl;
				mini = save<mini?save:mini;
			}
		}
	}

	cout << mini;

	return 0;
}

Measured memory_bytes: 640
n, x=map(int, input().split())
m = []
m_min = 0

for i in range(n):
  m.append(int(input()))
# print(m)

for i in range(len(m)):
  x = x - m[i]
# print(x)

for i in range(len(m)):
  if m[m_min] > m[i]:
    m_min = i
# print(m[m_min])

print(x // m[m_min] + n)

Measured memory_bytes: 3064
import collections


def bfs(dq, g, current, before, seen: {}):
    # reached = False
    while len(dq) > 0:
        base = dq.popleft()
        _crt = base[0]
        _cnt = base[1]
        _cnt2 = _cnt + 1
        _nxt = g[_crt]
        for x in _nxt:
            # さっき来たところなら行かない
            if x == before:
                continue
            # seen登録済ならスルー
            seen.setdefault(x, (-1, -1))
            if seen[x][0] != -1:
                continue
            # 次の探索候補に追加
            seen[x] = (_crt, _cnt2)
            dq.append((x, _cnt2))


def main():
    n, m = map(int, input().split())

    g = {}
    for i in range(m):
        a, b = map(int, input().split())
        g.setdefault(a, [])
        g[a].append(b)
        g.setdefault(b, [])
        g[b].append(a)

    dq = collections.deque()
    # (current, count)
    dq.append((1, 1))

    seen = {1: (-1, 0)}

    bfs(dq, g, 1, -1, seen)

    if len(seen.keys()) != n:
        print("No")
    else:
        print("Yes")
        for i in range(2, n + 1):
            print(seen[i][0])


main()


Measured memory_bytes: 57200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include<queue>
#include<functional>
#define loop(n) for(int i = 0; i < n; i++)
#define FOR(x,y,z) for(int x = y; x < z; x++)
#define REP(i,n) FOR(i,0,n)
#define INF 999999999
#define VEC vector<int>
#define in push_back
#define ans(x) cout<<x<<endl
typedef long long ll;
using namespace std;
priority_queue<int, vector<int>, greater<int>> small;//chiisai
priority_queue<ll>large;//ookii
int main()
{
	ll n, k,a[1000];
	cin >> n >> k;
	REP(i, n) {
		cin >> a[i];
	}
	ll goukei = 0;
	sort(a, a + n);
	for (int i = n-1; i >=n-k; i--)
	{
		goukei += a[i];
	}
	cout << goukei << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();		
        int m = sc.nextInt();
		int a = 1;
        int b = m;
        if(m%2==0){b++;}
        int c = b;
        for(int i=0;i<m;i++){if(a==b){a=c+1;b=2*m+1;}
                             System.out.println(a + " " + b);
                             a++;b--;                            
                            }                         		
	}
}                     

Measured memory_bytes: 52740
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 1005;
int n;
char m4[7][7] = {{'a','a','c','d'},
				 {'b','b','c','d'},
				 {'e','f','g','g'},
				 {'e','f','h','h'}};
char m5[7][7] = {{'a','a','b','.','c'},
				 {'.','d','b','.','c'},
				 {'e','d','.','f','f'},
				 {'e','.','g','g','h'},
				 {'i','i','j','j','h'}};
char m6[7][7] = {{'a','.','b','.','c','.'},
				 {'a','.','b','.','c','.'},
				 {'d','d','e','e','f','f'},
				 {'g','g','h','h','i','i'},
				 {'.','j','.','k','.','l'},
				 {'.','j','.','k','.','l'}};
char m7[7][7] = {{'a','a','b','b','.','.','c'},
				 {'d','.','.','e','e','.','c'},
				 {'d','f','.','.','.','.','g'},
				 {'.','f','.','.','h','h','g'},
				 {'.','.','i','.','.','j','k'},
				 {'.','.','i','.','.','j','k'},
				 {'l','l','m','m','n','n','.'}};
char ans[MAXN][MAXN];
inline void copy(char a[7][7], int x1, int y1, int x2, int y2)
{
	//cout << "copy " << x1 << " " << x2 << " " << y1 << " " << y2 << endl;
	for(int i = x1; i<=x2; i++)
	    for(int j = y1; j<=y2; j++)
	    	ans[i][j] = a[i-x1][j-y1];
}

int main()
{
	cin >> n;
	if(n==2)
	{
        cout << -1 << endl;
        return 0;
	}
	if(n==3)
	{
	    cout << "a.." << endl;
	    cout << "a.." << endl;
	    cout << ".bb" << endl;
	    return 0;
	}
	for(int i = 1; i<=n; i++)
	    for(int j = 1; j<=n; j++)
	        ans[i][j] = '.';
	int now = 1;
	if(n%4==3)
	{
		for(; now+3<=n-4; now += 4)
        	copy(m4,now,now,now+3,now+3);
        copy(m7,now,now,n,n);
	}
	if(n%4==1)
	{
        for(; now+3<=n-4; now += 4)
        	copy(m4,now,now,now+3,now+3);
        copy(m5,now,now,n,n);
	}
	if(n%4==2)
	{
        for(; now+3<=n-4; now += 4)
            copy(m4,now,now,now+3,now+3);
        copy(m6,now,now,n,n);
	}
	if(n%4==0)
        for(; now+3<=n; now += 4)
            copy(m4,now,now,now+3,now+3);
	for(int i = 1; i<=n; i++)
	    cout << ans[i]+1 << endl;
	return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;

typedef long long int ll;

int main () {
  int N;
  vector<ll> avec;
  cin >> N;
  ll total = 0;
  for (int i = 0; i < N; i++) {
    ll temp;
    cin >> temp;
    total += temp;
    avec.push_back(temp);
  }
  //cout << total << endl;
  ll x, y, min;
  x = 0;
  y = total;
  for (int i = 0; i < N - 1; i++) {
    x += avec.at(i);
    y -= avec.at(i);
    //cout << x << " " << y << endl;
    ll temp = x - y;
    if (temp < 0) temp = -temp;
    if (i == 0 || temp < min) min = temp;
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 2420
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    
    static Scanner cin = new Scanner();
    static void Main() {
        //string X = Console.ReadLine();
        //string tmp = "";
        //long cnt = 0; //減らす文字数
        //for (int i = 0; i < X.Length; i++) {
        //    if(X[i] == 'S') {
        //        if (tmp == "") tmp += "S";
        //        else if (tmp[tmp.Length - 1] == 'S') tmp += "S";
        //        else {
        //            cnt += 2 * Math.Min(tmp.ToCharArray().Count(x => x == 'S'), tmp.ToCharArray().Count(x => x == 'T'));
        //            tmp = "S";
        //        }
        //    }
        //    else {
        //        if (tmp != "") tmp += "T";
        //    }
        //}

        //cnt += Math.Min(tmp.ToCharArray().Count(x => x == 'S'), tmp.ToCharArray().Count(x => x == 'T'));
        //Console.WriteLine(X.Length - cnt);

        string X = Console.ReadLine();
        int N = 0, W = 0, S = 0, E = 0;
        foreach (var x in X) {
            if (x == 'N') N++;
            else if (x == 'W') W++;
            else if (x == 'S') S++;
            else E++;
        }

        bool NS = (N > 0 && S > 0) || (N == 0 && S == 0);
        bool WE = (W > 0 && E > 0) || (W == 0 && E == 0);
        Console.WriteLine(NS && WE ? "Yes" : "No");
        Console.ReadLine();
    }
}

Measured memory_bytes: 11092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    static int count;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        while (sc.hasNext()) {
            count = 0;
            int n = sc.nextInt();
            int s = sc.nextInt();
            if (n == 0 && s == 0) { break; }

            solve(0, n, s);
            System.out.println(count);
        }
    }

    // p: 加算する数字
    // n: 加算する数字の数
    // s: 目標の合計値
    static void solve(int p, int n, int s) {
        if (p > 9 || n == 0 || p > s) {
            return;
        }
        if (n == 1 && p == s) {
            count++;
        }
        solve(p + 1, n - 1, s - p);
        solve(p + 1, n, s);
    }
}

Measured memory_bytes: 18028
#include<iostream>
using namespace std;
int h,w;
char farm[100][100];
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
void dfs(int x,int y,char c){
  farm[x][y]='.';
  for(int i=0;i<4;i++){
    int nx=x+dx[i],ny=y+dy[i];
    if(0<=nx&&nx<h&&0<=ny&&ny<w&&farm[nx][ny]==c) dfs(nx,ny,c);
  }
  return ;
}
int main(){
  while(1){
    cin >> h >> w;
    if(h==0&&w==0) break;
    for(int i=0;i<h;i++)
      for(int j=0;j<w;j++) cin >> farm[i][j];
    int ans=0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(farm[i][j]=='#'){
	  dfs(i,j,'#');
	  ans++;
      }
	if(farm[i][j]=='@'){
	  dfs(i,j,'@');
	  ans++;
	}
	if(farm[i][j]=='*'){
	  dfs(i,j,'*');
	  ans++;
	}
      }
    }
    cout << ans  << "\n";
  }
  return 0;
}



Measured memory_bytes: 3576
// https://atcoder.jp/contests/abc126/tasks/abc126_b

#include <bits/stdc++.h>
using namespace std;
bool val(int n) {
    return (1 <= n && n <= 12);
}
int main() {
    string a, b;
    for(int i = 0; i < 2; i++) {
        char c;
        cin >> c;
        a += c;
    }

    for(int i = 0; i < 2; i++) {
        char c;
        cin >> c;
        b += c;
    }

    if(val(stoi(a)) && val(stoi(b)))
        cout << "AMBIGUOUS" << endl;
    else if(val(stoi(a)))
        cout << "MMYY" << endl;
    else if(val(stoi(b)))
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

// 解説AC
// 5度目の正直!w←:thinking:

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    ll n,x;
    cin>>n>>x;
    vi a(n);
    cin>>a;
    vi b(a);
    ll mi=LINF;
    REP(k,n){
        ll co=0;
        dprint(b);
        REP(i,n){
            co+=b[i];
            chmin(b[i], a[(i-k-1+n*2)%n]);
        }
        chmin(mi, co+k*x);
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <iostream>
using namespace std;

char map[200][200];
int H, W;

void orchard(int y, int x, char c);

int main()
{
  while (scanf("%d%d", &H, &W), H){
    int cnt = 0;
    for (int i = 0; i < H; i++){
      scanf("%s", map[i]);
    }

    for (int i = 0; i < H; i++){
      for (int j = 0; j < W; j++){
        if (map[i][j] != '0'){
          cnt++;
          orchard(i, j, map[i][j]);
        }
      }
    }
    printf("%d\n", cnt);
  }

  return (0);
}

void orchard(int y, int x, char c)
{
  map[y][x] = '0';

  if (x + 1 < W && c == map[y][x + 1]){
    orchard(y, x + 1, map[y][x + 1]);
  }
  if (x - 1 >= 0 && c == map[y][x - 1]){
    orchard(y, x - 1, map[y][x - 1]);
  }
  if (y + 1 < H && c == map[y + 1][x]){
    orchard(y + 1, x, map[y + 1][x]);
  }
  if (y - 1 >= 0 && c == map[y - 1][x]){
    orchard(y - 1, x, map[y - 1][x]);
  }
}

Measured memory_bytes: 1676