akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;

int ctoi(char c) {
    if(c >= '0' && c <= '9') {
        return c - '0';
    }
    return 0;
}

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    string N;
    cin >> N;
    if(N[0] == N[1] && N[0] == N[2]) {
        cout << N << endl;
    } else if(N[0] == N[1] && N[0] < N[2]){
        cout << (ctoi(N[0]) + 1) << (ctoi(N[0]) + 1) << (ctoi(N[0]) + 1) << endl;
    } else if(N[0] == N[1] && N[0] > N[2]){
        cout << N[0] << N[0] << N[0] << endl;
    } else if(N[0] < N[1]){
        cout << (ctoi(N[0]) + 1) << (ctoi(N[0]) + 1) << (ctoi(N[0]) + 1) << endl;
    } else if(N[0] > N[1]){
        cout << N[0] << N[0] << N[0] << endl;
    }
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	n, k := nextInt(), nextInt()
	num := make([]int, k)
	for i := 1; i <= n; i++ {
		num[i%k]++
	}

	res := 0
	for a := 0; a < k; a++ {
		b := (k - a) % k
		c := (k - a) % k
		if (b+c)%k != 0 {
			continue
		}
		res += num[a] * num[b] * num[c]
	}

	fmt.Println(res)

}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
using namespace std;


signed main()
{
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	
	int a,b,n; cin>>a>>b>>n;
	
	if( n < b ) {
		int ans= (a*n)/b;
		cout<<ans<<endl;
	}
	else{
		int ans= (a*(b-1))/b;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 3648
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#include <math.h>
#define ll long long 
#define PI 3.14159265358979323846
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(x,n) for(ll x=1;x<(ll)n+1;x++)
using namespace std;



int main() {
    ll X, Y;
    ll asi, hiki;
    cin >> X >> Y;
    rep(i, 51) {
        rep(j, 51) {
            hiki = i + j;
            asi = 2 * i + 4 * j;
            if (hiki == X && asi == Y) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
 }


Measured memory_bytes: 3592
antennas = [0] * 5
for i in range(5):
    antennas[i] = int(input())

k = int(input())

for i in range(len(antennas)):
    for j in range(i + 1,len(antennas)):
        if antennas[j] - antennas[i] > k:
            print(":(")
            exit(0)

print('Yay!')


Measured memory_bytes: 2940
#include<cstdio>
#include<iostream>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<deque>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<limits>
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
using namespace std;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}
template<class T>inline void outs(vector<T> V){int n=V.size();rep(i,n)cout<<V[i]<<" \n"[i==n-1];}
inline void solve(void){
  ll K,N;in(K,N);
  vector<ll>A(N);ins(A);
  ll L=K-A[N-1]+A[0];
  up(i,0,N-2)if(A[i+1]-A[i]>L)L=A[i+1]-A[i];
  out(K-L);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
    long long int n, k, ans;
    cin >> n >> k;
    ans = n;

    if (n % k < abs(n % k - k))
    {
        ans = n % k;
    }
    else
    {
        ans = abs(n % k - k);
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3604
#include<cstdio>
#include<iostream>
using namespace std;
const int N=5e3+10;
const int mod=1e9+7;
int n,A,B,head[N],cnt,dp[N][N][2],f[N][2],son[N],ans,facc[N];
struct edge{int nxt,to;}ed[N<<1];
inline void addedge(int x,int y){
	ed[++cnt].to=y;ed[cnt].nxt=head[x];head[x]=cnt;
	ed[++cnt].to=x;ed[cnt].nxt=head[y];head[y]=cnt;}
inline void Add(int &x,int y){x+=y;x-=x>=mod? mod:0;}
inline int MOD(int x){x-=x>=mod? mod:0;return x;}
inline int Minus(int x){x+=x<0? mod:0;return x;}
inline void DFS(int u,int fa){
	dp[u][1][0]=1;son[u]=1;
	for(register int i=head[u];i;i=ed[i].nxt){
		int v=ed[i].to;if(v==fa)continue;DFS(v,u);
		for(register int j=1;j<=son[u];j++)
			f[j][0]=dp[u][j][0],dp[u][j][0]=0,f[j][1]=dp[u][j][1],dp[u][j][1]=0;
		for(register int j=1;j<=son[u];j++)
			for(register int k=1;k<=son[v];k++){
				Add(dp[u][j+k][0],MOD(1ll*f[j][0]*dp[v][k][0]%mod+1ll*f[j][1]*dp[v][k][1]%mod));
				Add(dp[u][j+k][1],MOD(1ll*f[j][0]*dp[v][k][1]%mod+1ll*f[j][1]*dp[v][k][0]%mod));
				Add(dp[u][j][0],MOD(1ll*f[j][0]*facc[k-1]%mod*dp[v][k][1]%mod+1ll*f[j][1]*facc[k-1]%mod*dp[v][k][0]%mod));
				Add(dp[u][j][1],MOD(1ll*f[j][1]*facc[k-1]%mod*dp[v][k][1]%mod+1ll*f[j][0]*facc[k-1]%mod*dp[v][k][0]%mod));
			}
		son[u]+=son[v];
	}
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<n;i++)
		scanf("%d%d",&A,&B),addedge(A,B);
	facc[1]=1;for(register int i=3;i<=n;i+=2)facc[i]=1ll*facc[i-2]*i%mod;
	DFS(1,0);//直接容斥即可，全集会在i==n时加上 
	for(register int i=2;i<=n;i+=2){
		Add(ans,1ll*dp[1][i][0]*facc[i-1]%mod);
		ans=Minus(ans-1ll*dp[1][i][1]*facc[i-1]%mod);
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    int x = 0;
    int y = 0;
    int tmpa = a;
    int tmpb = b;

    for(int i = 0; i < tmpb; i++){
        x += a;
        a = a*10;
    }
    for(int i = 0; i < tmpa; i++){
        y += b;
        b = b * 10;
    }

    if(x > y){
        cout << x << endl;
    }else{
        cout << y << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
short p[4][6] = { {5,4,2,3,0,1},{4,5,2,3,1,0},{0,1,5,4,2,3},{0,1,4,5,3,2} };
short n, C[20][6], cx[20], cy[20]; string px[20];
map<pair<short, short>, short>D[20], E[1 << 16];
vector<tuple<short, short, short>>_D[20];
vector<pair<short, short>>_E[1 << 15];
short dx[4] = { -1,1,0,0 }, dy[4] = { 0,0,-1,1 }, dp[1 << 15];
void Init1(int I) {
	vector<tuple<short, short, short, short>>__D;
	__D.push_back(make_tuple(cx[I], cy[I], -1, C[I][4]));
	D[I][make_pair(cx[I], cy[I])] = C[I][4];
	for (int j = 0; j < px[I].size(); j++) {
		int A = 3, F[6] = { 0,0,0,0,0,0 };
		if (px[I][j] == 'L')A = 0; if (px[I][j] == 'R')A = 1;
		if (px[I][j] == 'F')A = 2; if (px[I][j] == 'B')A = 3;
		for (int k = 0; k < 6; k++)F[k] = C[I][p[A][k]];
		for (int k = 0; k < 6; k++)C[I][k] = F[k];
		cx[I] += dx[A]; cy[I] += dy[A];
		__D.push_back(make_tuple(cx[I], cy[I], j, C[I][4]));
		D[I][make_pair(cx[I], cy[I])] = C[I][4];
	}
	sort(__D.begin(), __D.end());
	for (int i = 0; i < __D.size(); i++) {
		if (i == __D.size() - 1)_D[I].push_back(make_tuple(get<0>(__D[i]), get<1>(__D[i]), get<3>(__D[i])));
		else if (get<0>(__D[i]) != get<0>(__D[i + 1]) || get<1>(__D[i]) != get<1>(__D[i + 1])) {
			_D[I].push_back(make_tuple(get<0>(__D[i]), get<1>(__D[i]), get<3>(__D[i])));
		}
	}
	return;
}
void Init2(int p) {
	for (int j = 0; j < n; j++) {
		if ((p / (1 << j)) % 2 == 0)continue;
		for (int k = 0; k < _D[j].size(); k++) {
			pair<short, short>pa = make_pair(get<0>(_D[j][k]), get<1>(_D[j][k]));
			if (E[p][pa] == 0) { _E[p].push_back(pa); } E[p][pa] = 1;
		}
	}
	E[p].clear();
	sort(_E[p].begin(), _E[p].end());
}
int main() {
	while (true) {
		for (int i = 0; i < 15; i++) { D[i].clear(); _D[i].clear(); }
		for (int i = 0; i < 32768; i++) { E[i].clear(); _E[i].clear(); }
		for (int i = 0; i < 32768; i++)dp[i] = -1;
		cin >> n; if (n == 0)break;
		for (int i = 0; i < n; i++) {
			cin >> cx[i] >> cy[i]; for (int j = 0; j < 6; j++) cin >> C[i][j]; cin >> px[i];
			Init1(i);
		}
		for (int i = 0; i < (1 << n); i++) Init2(i); dp[0] = 0;
		for (int i = 0; i < (1 << n); i++) {
			for (int j = 0; j < n; j++) {
				if ((i / (1 << j)) % 2 == 1)continue;
				short cnt = 0;
				for (int k = 0; k < _D[j].size(); k++) {
					pair<short, short>pa = make_pair(get<0>(_D[j][k]), get<1>(_D[j][k]));
					int pos1 = lower_bound(_E[i].begin(), _E[i].end(), pa) - _E[i].begin();
					if (_E[i].size() == pos1 || _E[i][pos1] != pa)cnt += get<2>(_D[j][k]);
				}
				dp[i + (1 << j)] = max(dp[i + (1 << j)], (short)(dp[i] + cnt));
			}
		}
		cout << dp[(1 << n) - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 36648
N = int(input())
S = input()
r = S.count('R')
g = S.count('G')
b = S.count('B')
count = r * g * b
for i in range(N):
    for j in range(i+1,N-1):
        if 2*j - i <= N-1:
            l = set([S[i],S[j],S[2*j-i]])
            if len(l) == 3:
                count -= 1
print(count)

Measured memory_bytes: 68232
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define ll long long
#define se second
using namespace std;

int main(){
		ll n;cin>>n;ll s[n+1],c[n+1],f[n+1];
		for(int i=1;i<=n-1;i++)
		cin>>c[i]>>s[i]>>f[i];
		
	
		for(int i=1;i<=n-1;i++)
		{
			ll total=c[i]+s[i];
			for(int j=i+1;j<=n-1;j++)
			{
				if(total<=s[j])
				total=s[j];
				else if(total%f[j]==0);
				else
				total+=f[j]-(total%f[j]);
				
				total+=c[j];
			}
			cout<<total<<endl;
		}
		cout<<0<<endl;
		
		
		
		
}

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

int main() {
	int n;
	cin >> n;
	int au[1000] = {}, ad[1000] = {};
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		au[i + 1] = au[i] + a;
	}
	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;
		ad[i + 1] = ad[i] + a;
	}
	int ans = 0;
	for (int i = 1;i <= n;i++) {
		ans = max(au[i] + (ad[n] - ad[i - 1]), ans);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <stack>
#include <map>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	int n,m;
	while(cin>>n>>m)
	{
		int fib[1002]={0};
		fib[0]=1;
		fib[1]=1;
		for(int i=2;i<n+2;i++){
			fib[i]=(fib[i-2]+fib[i-1])%1001;
		}
		sort(fib+2,fib+n+2);
		int ans=1;
		for(int i=3;i<n+2;i++){
			if(fib[i]-fib[i-1]>=m)ans++;
		}
		//REP(i,n+1)cout<<fib[i]<<" ";cout<<endl;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
using namespace std;
int main(){
  char ser[3];
  cin >> ser;
  int i;
  int A=0;
  int B=0;
  for (i=0;i<=2;i++){
    if (ser[i]=='B'){
      B+=1;}
    if (ser[i]=='A'){
    	A+=1;
	}}
  if (A!=0 && B !=0){
    cout << "Yes";}
  else cout << "No";}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int num[200]={0};
int main(){
	string str;
	cin>>str;
	for(int i=0;i<str.length();i++){
		num[str[i]]++;
	}
	int sign=1;
	for(int i=97;i<=122;i++){
		if(num[i]%2!=0){
			sign=0;
			cout<<"No"<<endl;
			break;
		}
	}
	if(sign)
		cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using iii = pair<ii, int>;
#define vt vector
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define __lcm(a, b) a * b / __gcd(a, b)
const int MOD = 1e9 + 7;
const int INF = 2e9;
const int N = 1e3 + 5;

int dr4[] = {1, -1, 0, 0};
int dc4[] = {0, 0, 1, -1};
int dr8[] = {1, -1, 0, 0, -1, -1, 1, 1};
int dc8[] = {0, 0, 1, -1, -1, 1, -1, 1};
int dr20[] = {-2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};
int dc20[] = {-2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2};

int R, C, sr, sc, er, ec;
int dist[N][N];
char a[N][N];
deque<ii> q;

bool inside(int row, int col) {
    return row >= 1 && row <= R && col >= 1 && col <= C;
}

bool invalid(int row, int col) {
    return !inside(row, col) || a[row][col] == '#';
}

void BFS() {
    q.push_front(mp(sr, sc));
    dist[sr][sc] = 0;
    while(q.size()) {
        ii x = q.front(); q.pop_front();
        int r = x.fi, c = x.se;
        for(int i = 0; i < 4; i++) {
            int nr = r + dr4[i], nc = c + dc4[i];
            if(invalid(nr, nc)) continue;
            if(dist[nr][nc] > dist[r][c]) {
                dist[nr][nc] = dist[r][c];
                q.pf(mp(nr, nc));
            }
        }
        for(int i = 0; i < 20; i++) {
            int nr = r + dr20[i], nc = c + dc20[i];
            if(invalid(nr, nc)) continue;
            if(dist[nr][nc] > dist[r][c] + 1) {
                dist[nr][nc] = dist[r][c] + 1;
                q.pb(mp(nr, nc));
            }
        }
    }
}

void solve() {
    cin >> R >> C >> sr >> sc >> er >> ec;
    for(int i = 1; i <= R; i++) {
        for(int j = 1; j <= C; j++) {
            cin >> a[i][j];
            dist[i][j] = INF;
        }
    }
    BFS();
    cout << (dist[er][ec] == INF ? -1 : dist[er][ec]) << "\n";
}

int main() {
 
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
 
    solve();
    
}

Measured memory_bytes: 8568
N = int(input())
blues=[]
for i in range(N):
  blues.append(input())
M = int(input())
reds=[]
for i in range(M):
  reds.append(input())

ma = 0

blueset = set(blues)

for S in blueset:
  ma = max(ma,blues.count(S)-reds.count(S))
print(ma)

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

#define ll long long

using namespace std;

const int MAXN = 100010;
const int MAXM = 100010;
const int INF = 0x3f3f3f3f;
const int mod = 1e9 + 7;

int n, m, k;
int ans, tot, cnt;

int a[MAXN];

string s;

int main(){
	int t;
	cin >> k >> n >> m;
	for (int i = n; i <= m; i++) {
		if (i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}



Measured memory_bytes: 3624
#include <iostream>
#include <fstream>

using namespace std;


int main()
{
    int N,M,C;
    int cnt = 0;
    int iMax = 0;

    int res;

//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());
    cin >> N >> M >> C;

    int B[M];
    int A[N][M];

    for(int j = 0; j < M; j++)
    {
        cin >> B[j];
    }

    for(int i = 0; i < N; i++)
    {
        res = C;

        for(int j = 0; j < M; j++)
        {
            cin >> A[i][j];

            res += A[i][j]*B[j];

        }
        if(res > 0)cnt++;
    }



    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1005;
vector<int> inf;
int n,k,a[N],b[N],ans[N],vis[N],now;
bool check(){
	int x=*max_element(a+1,a+k+1);
	int y=*min_element(a+1,a+k+1);
	return x<=2*y;
}
void merge(vector<int> &a,vector<int> &b,vector<int> &c){
	int posa=0,posb=0;
	while(posa<a.size() && posb<b.size()){
		if(a[posa]<b[posb]) c.push_back(a[posa++]);
		else c.push_back(b[posb++]);
	}
	while(posa<a.size()) c.push_back(a[posa++]);
	while(posb<b.size()) c.push_back(b[posb++]);
}
vector<int> calc(int len){
	//cout<<len<<endl;
	for(int i=1;i<=k;++i)
		b[i]=a[i],vis[i]=0;
	for(int i=now+len-k+1;i<=now;++i)
		vis[ans[i]]=1;
	for(int i=1;i<=k;++i)
		if(vis[i]==0){
			--b[i];
			if(b[i]<0) return inf;
		}
	int x=*max_element(b+1,b+k+1),
		y=*min_element(b+1,b+k+1);
	//cout<<x<<" "<<y<<endl;
	vector<int> res;
	if(x>2*y+1) return inf;
	if(x<=2*y){
		for(int i=1;i<=k;++i)
			if(!vis[i]) res.push_back(i);
		return res;
	}
	vector<int> A,B,all;
	for(int i=1;i<=k;++i)
		if(!vis[i] && b[i]==x) A.push_back(i);
	for(int i=1;i<=k;++i)
		if(!vis[i] && b[i]==y) A.push_back(i);
	for(int i=1;i<=k;++i)
		if(!vis[i] && b[i]!=x && b[i]!=y) B.push_back(i);
	merge(A,B,res);
	for(int i=now+len-k+1;i<=now;++i)
		all.push_back(ans[i]);
	all.insert(all.end(),res.begin(),res.end());
	int pos_mx=-1,pos_mn=n+1;
	for(int i=0;i<all.size();++i)
		if(b[all[i]]==x) pos_mx=max(pos_mx,i);
		else if(b[all[i]]==y) pos_mn=min(pos_mn,i);
//	for(int i=0;i<all.size();++i)
//		cout<<all[i]<<" ";cout<<endl;
	if(pos_mx>pos_mn) return inf;
	else return res;
}
int main(){
	cin>>k;
	for(int i=1;i<=k;++i)
		cin>>a[i],n+=a[i];
	if(!check()) return puts("-1"),0;
	inf.push_back(23333);
	while(now<n){
		vector<int> S=inf;
		for(int len=1;now+len<=n && len<=k;++len)
			if(now+len>=k) S=min(S,calc(len));
		//cout<<S.size()<<endl;
		for(int i=0;i<S.size();++i)
			ans[++now]=S[i],--a[S[i]];
	}
	for(int i=1;i<=now;++i)cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define db double 
#define maxn 200005 
#define mod 998244353
#define vi vector<double>
#define pb push_back
#define ll long long
using namespace std;
ll ksm(ll a, ll b) {
	if (!b) return 1;
	ll ns = ksm(a, b >> 1);
	ns = ns * ns % mod;
	if (b & 1) ns = ns * a % mod;
	return ns;
}
inline int add(int a, int b) {
	a += b;
	return (a < mod) ? a : (a - mod);
}
inline int sub(int a, int b) {
	a -= b;
	return (a < 0) ? a + mod : a;
}
inline int mul(int a, int b) {
	return (ll)a * b % mod;
}
// head
char inp[maxn]; 

int main() {
	scanf("%s", inp);
	int n = strlen(inp);
	int k = 0, ls = 0;
	for (int i = 0; i < n; ) {
		if (ls == 1 && inp[i] == inp[i - 1]) {
			if (i != n - 1) {
				i += 2, k++;
				ls = 0;
			}
			else i++;
		}
		else {
			i++, ls = 1;
			k++;
		}
	}
	cout << k << endl;
	return 0;
}


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

int main(){
  int N;
  vector<int> A(9); //ビンゴの宣言
  vector<int> B(N); // 呼ばれた文字
  vector<int> C(9); //呼ばれたかの判定
  
  for(int i=0;i<9;i++){
    cin >> A.at(i);
  }
  
  cin >> N;
  for (int i=0;i<N;i++){
    cin >> B.at(i);
  }
  for (int i=0;i<9;i++){
    for(int j=0;j<N;j++){
      if(A.at(i) == B.at(j)){
        C[i] = 1;
        break;
      }
    }
  }
  
  /*
  for (int i =0;i<9;i++){
    cout << C.at(i) <<endl;
  }
  */

  if(C.at(0)==1 && C.at(1)==1 && C.at(2)==1) cout << "Yes" << endl;
  else if(C.at(3)==1 && C.at(4)==1 && C.at(5)==1) cout << "Yes" << endl;
  else if(C.at(6)==1 && C.at(7)==1 && C.at(8)==1) cout << "Yes" << endl;
  else if(C.at(0)==1 && C.at(3)==1 && C.at(6)==1) cout << "Yes" << endl;
  else if(C.at(1)==1 && C.at(4)==1 && C.at(7)==1) cout << "Yes" << endl;
  else if(C.at(2)==1 && C.at(5)==1 && C.at(8)==1) cout << "Yes" << endl;
  else if(C.at(0)==1 && C.at(4)==1 && C.at(8)==1) cout << "Yes" << endl;
  else if(C.at(2)==1 && C.at(4)==1 && C.at(6)==1) cout << "Yes" << endl;
  else cout << "No" <<endl;


}

Measured memory_bytes: 384
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { y.modpow(mod - 2); x.modm(y); }

void main()
{
	auto N = RD;
	auto c = RD!string;
	
	auto cnt = new long[](N+1);
	foreach (i; 0..N)
	{
		cnt[i+1] = cnt[i];
		if (c[i] == 'R')
			++cnt[i+1];
	}

	long ans = long.max;
	foreach (i; 0..N+1)
	{
		auto l = i - cnt[i];
		auto r = max(0, cnt[$-1] - cnt[i] - l);
		ans.chmin(l+r);
		debug writeln("i:", i, " ans:", l+r);
	}

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 4660
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main()
{
    int n;
    int i;
    int cnt = 0;
    int *str;
    cin >> n;
    str = new int[n];
    for (i = 0; i < n; i++)
    {
        if (scanf("%d", &str[i]) != 1) {
            return 0;
        }
    }
    for (i = 1; i <= n; i += 2)
    {
        if (str[i-1] % 2 == 1)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;


signed main(){
    int T;
    cin >> T;
    rep(ti,0,T) {
        int N;
        cin >> N;
        vector<ll> A(N);
        rep(i,0,N) cin >> A[i];
        string S;
        cin >> S;

        // if base[i] != 0, base[i]'s ith bit is 1 and the other base's ith bit is 0.
        vector<ll> base(60);
        bool zero = true;
        rrep(i,0,N) {
            if (S[i] == '0') {
                // remove 1 from A[i]'s bits where base exists.
                rrep(bi,0,base.size()) {
                    if (base[bi] != 0 && (A[i] & (1LL << bi))) {
                        A[i] ^= base[bi];
                    }
                }
                // insert A[i] into base
                rrep(bi, 0, base.size()) {
                    // found
                    if (A[i] & (1LL << bi)) {
                        base[bi] = A[i];
                        // remove 1 in bi'th bit from other base
                        rep(j,0,base.size()) {
                            if (j != bi && (base[j] & (1LL << bi))) {
                                base[j] ^= base[bi];
                            }
                        }
                        break;
                    }
                }
            } else {
                rrep(bi, 0, base.size()) {
                    if (base[bi] != 0 && (A[i] & (1LL << bi))) {
                        A[i] ^= base[bi];
                    }
                }
                // A[i] is not included in base
                if (A[i] != 0) {
                    zero = false;
                    break;
                }
            }
        }
        cout << (zero ? 0 : 1) << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=998244353;
const int size=3e5+1;
const int inf=1e9;
int main(){
	long A,B,C,K; cin>>A>>B>>C>>K;
	if(K % 2 == 0) cout<<A - B<<endl;
	else cout<<B - A<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,srt,end) for(ll i=(ll)(srt); i<(ll)(end); i++)

int main(){
    ll K,S;
    cin>>K>>S;
    ll z;
    ll ans=0;
    rep(x,0,K+1){
        rep(y,0,K+1){
            z = S-x-y;
            if(0<=z&&z<=K)ans++;
        }
    }
    cout<<ans<<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[] p = new int[n];
    int[] q = new int[n];
    for (int i = 0; i < n; i ++) {
        p[i] = sc.nextInt();
    }
    for (int i = 0; i < n; i ++) {
        q[i] = sc.nextInt();
    }

    System.out.println(Math.abs(lexographicalIndex(p, n) - lexographicalIndex(q, n)));
  }

  private static int lexographicalIndex(int[] values, int length) {
      List<Integer> options = new LinkedList<Integer>();
      for (int i = 0; i < length; i++) {
          options.add(i + 1);
      }
      int index = 1;
      for (int i = 0; i < length - 1; i++) {
          int val = options.indexOf(values[i]);
          options.remove(val);
          index += val * factorial(length - i - 1);
      }
      return index;

  }

  private static int factorial(int a) {
      int output = 1;
      for (int i = 1; i <= a; i++) {
          output = output * i;
      }
      return output;
  }
}


Measured memory_bytes: 21332
import sys
    
BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001
    
    
S = str(input())
P = str(input())
    
is_ok = False
    
for i in range(len(S)):
    FLG = True
    for k in range(len(P)):
        if S[(i+k)%(len(S))] != P[k]:
            FLG = False
            break
    
    if FLG == True:
        is_ok = True
        break
    
if is_ok == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5580
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
//const ll M=1000000007;
int n;
int t[300000];

int main(){
	cin>>n;
	rep(i,n)cin>>t[i];
	sort(t,t+n,greater<int>());
	int a=t[0],b=t[1];

	rep(i,n){
		if(a>t[i]){
			if(min(t[i],a-t[i])>min(b,a-b))b=t[i];
		}
	}
	cout<<a<<" "<<b<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <cstdlib>

typedef long long ll;
using namespace std;

map<int,vector<int>> Data ;
vector<int> DP ;
int N, M;

int calcPath( int n )
{
	if(DP[n-1] != -1){
		return DP[n-1];
	}
	if( Data.count(n) == 0 ){
		DP[n-1] = 0;
		return DP[n-1];
	}
	int maxpath = 0;
	vector<int> v = Data[n];
	for( auto itr = v.begin(); itr != v.end(); itr++ ){
		maxpath = max(maxpath, calcPath(*itr)+1);
	}
	DP[n-1] = maxpath;
	return DP[n-1];
}

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

	DP = vector<int>(N);
	for( int i = 0; i < N; i++ ){
		DP.at(i) = -1;
	}

	int x, y;
	for(int i = 0; i < M; i++){
		cin >> x >> y ;
		if( Data.count(x) == 0){
			vector<int> v ;
			Data[x] = v ;
		}
		Data[x].push_back(y) ;
	}

	for( int i = 0; i < N; i++ ){
		if( DP.at(i) == -1){
			calcPath(i+1);
		}
	}
	int maxpath = 0;
	for( int i = 0; i < N; i++ ){
		maxpath = max(maxpath,DP[i]);
	}
	cout << maxpath << endl;
}


Measured memory_bytes: 17024
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;
typedef pair<int, int> pii;

int main() {
  int n, t;
  cin >> n >> t;
  vector<pii> foods(n + 1, pii(0, 0));
  for (int i = 1; i <= n; i++) {
    cin >> foods[i].first >> foods[i].second;
  }
  sort(foods.begin() + 1, foods.end());
  vector<vector<int>> dp(n + 1, vector<int>(6010, 0));
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 6005; j++) {
      dp[i][j] = dp[i - 1][j];
    }
    for (int j = 1; j <= t; j++) {
      dp[i][j + foods[i].first] =
          max(dp[i][j + foods[i].first], dp[i - 1][j] + foods[i].second);
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 6005; j++) {
      ans = max(ans, dp[i][j]);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
#define FAST_IO {ios::sync_with_stdio(0);cin.tie(0);}
using namespace std;
signed main() {
  int a, b, ans;
  char op;
  while (cin >> a >> op >> b, op != '?') {
    switch (op) {
      case '+':
        ans = a+b;
        break;
      case '-':
        ans = a-b;
        break;
      case '*':
        ans = a*b;
        break;
      case '/':
        ans = a/b;
        break;
    }
    cout << ans << endl;
  }
}




Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = 1; i <= n; i++)
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); }
using P = pair <int, int>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

ll MOD = 1000000007;
ll INF =1<<30;
ll dp[110][100100];


int main(){
    int L,R,d;
    cin >> L >> R >>d;
    cout  << R/d-(L-1)/d <<endl;
}

Measured memory_bytes: 3592
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    if(n>=400&&n<600)
        cout<<"8"<<endl;
    else if(n<800)
        cout<<"7"<<endl;
    else if(n<1000)
        cout<<"6"<<endl;
    else if(n<1200)
        cout<<"5"<<endl;
    else if(n<1400)
        cout<<"4"<<endl;
    else if(n<1600)
        cout<<"3"<<endl;
    else if(n<1800)
        cout<<"2"<<endl;
    else
        cout<<"1"<<endl;
}


Measured memory_bytes: 3632
from collections import deque

h, w = map(int, input().split())
s = [[i for i in input()] for j in range(h)]

def bfs(s, start_x, start_y, h, w):
    que = deque()
    que.append((start_x, start_y))
    
    d = [[-1]*w for i in range(h)]
    d[start_y][start_x] = 0
    
    while que:
        (x, y) = que.popleft()
        for (nx, ny) in [(x+1, y), (x-1, y), (x, y+1), (x, y-1)]:
            if 0 <= nx and nx<w and 0<=ny and ny<h and s[ny][nx]!='#' and d[ny][nx]==-1:
                que.append((nx, ny))
                d[ny][nx] = d[y][x] + 1
                
    answer = 0    
    for i in range(h):
        for j in range(w):
            answer = max(answer, d[i][j])
                        
    return answer

answer = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '.':
            new_answer = bfs(s, j, i, h, w)
            answer = max(new_answer, answer) 
            
print(answer)

Measured memory_bytes: 3316
# = int(input())
X, Y = map(int, input().split())
# = list(map(int, input().split()))
# = [int(input()) for i in range(N)]
# = [list(map(int, input().split())) for i in range(N)]

if 4*X - Y < 0 or Y - 2*X < 0:
    print("No")
    exit()

else:
    if (4*X - Y)%2 == 0 and (Y - 2*X)%2 == 0:
        print("Yes")

    else:
        print("No")


Measured memory_bytes: 9172
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int fh = a / 500;
    a = a - (fh * 500); 
    int f = a / 5;
    int ans = (fh * 1000) + (f * 5);
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
import itertools
import fractions
import functools

N = input()
N = int(N)

l = list(itertools.combinations_with_replacement(list(range(1,N+1)), 3))
s_all = 0

def euclid(a, b):
    if b == 0:
        return a
    else:
        return euclid(b, a%b)
def gcd(nums):
    return functools.reduce(euclid, nums)

for nums in l:
    count = 0
    # ans = nums[0]
    # for i in range(1, 3):
    #     ans = fractions.gcd(ans, nums[i])
    # ans = list(map(int, input().split()))
    ans = gcd(nums)
    a,b,c = nums[0], nums[1], nums[2]
    if a==b:
        count+=1
    if a==c:
        count+=1
    if b==c:
        count+=1

    if count==0:
        num = 6
    elif count==1:
        num=3
    elif count==3:
        num=1
    s_all += ans*num
print(s_all)


Measured memory_bytes: 106752
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    vector<int> B(N);
    vector<int> C(N-1);
    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];
    rep(i, N - 1) cin >> C[i];
   int ans = 0;
    rep(i, N) {
        ans += B[A[i] - 1];
        if (A[i] + 1 == A[i + 1]) {
            ans += C[A[i] - 1];
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int x;
    cin >> x;
    cout << 8 - (x - 400) / 200 << newl;

    return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
const ll INF=0x3f3f3f3f;
ll a[105];
void solve(int T){
	ll x,k,d,ans1,ans2;
	scanf("%lld %lld %lld",&x,&k,&d);
	x=abs(x);
	ll times=x/d;
	if(times>=k){
		printf("%lld",x-d*k);
		return;
	}
	ans1=x%d;
	ans2=-1*(ans1-d);
	k-=times;
	if(k&1)printf("%lld",ans2);
	else printf("%lld",ans1);
}
signed main(){
	int t=1;
	//scanf("%d",&t);
	for(int i=1;i<=t;i++){
		solve(i);
	}
}

Measured memory_bytes: 3824
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 200010
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    //cout<<"paken"<<endl;
    //cout<<"Paken"<<endl;
    //cout<<"PAKEN"<<endl;
    cout<<"square1001"<<endl;
}





Measured memory_bytes: 3212
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;

namespace AOJ
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Trim().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        //18.3 べき乗(a^n % mod)
        static long modpow(long a, long n, long mod)
        {
            var res = 1L;
            if (0 < n)
            {
                res = modpow(a, n / 2, mod);
                res = res * res % mod;
                if (0 != n % 2) res = res * a % mod;
            }
            return res;
        }
        static void Main(string[] args)
        {
            var mn = Sarray();
            WriteLine(modpow(mn[0], mn[1], 1000000007));
        }
    }
}


Measured memory_bytes: 18388
#include <vector>
#include <iostream>
#include <string>
using namespace std;

int main()
{
	int N, A, B;
	string S;
	cin >> N >> A >> B >> S;
	vector<bool> pass(N, false);
	int numPass = 0, osRank = 0;
	for (int i = 0; i < S.size();++i){
		if (S[i] == 'a'){
			if (numPass < (A + B))	{
				numPass++;
				pass[i] = true;
			}
		}
		if (S[i] == 'b'){
			if ((numPass < (A + B)) && (++osRank <= B)){
				numPass++;
				pass[i] = true;
			}
		}
		if (S[i] == 'c'){
			pass[i] = false;
		}
	}
	for (auto el : pass){
		if (el)	cout << "Yes" << endl;
		else	cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 896
#include <stdio.h>
#include <string.h>

int main(void)
{
	char c[10];
	
	while(scanf("%s", c) != EOF) {
		int count = 0;
		int i;
		
		if(c[0] == 'o' || c[0] == 'x') {
			if(c[0] == c[4] && c[0] == c[8]) {
				count++;
				printf("%c\n", c[0]);
			}
		}
		if(c[2] == 'o' || c[2] == 'x') {
			if(c[2] == c[4] && c[2] == c[6]) {
				count++;
				printf("%c\n", c[2]);
			}
		}
		for(i = 0; i < 3; i++) {
			if(c[i] == 'o' || c[i] == 'x') {
				if(c[i] == c[i + 3] && c[i] == c[i + 6]) {
					count++;
					printf("%c\n", c[i]);
					break;
				}
			}
			if(c[i * 3] == 'o' || c[i * 3] == 'x') {
				if(c[i * 3] == c[i * 3 + 1] && c[i * 3] == c[i * 3 + 2]) {
					count++;
					printf("%c\n", c[i * 3]);
					break;
				}
			}
		}
		if(count == 0) puts("d");
	}
	
	return 0;
}


Measured memory_bytes: 552
#include<stdio.h>
#include<math.h>
int main()
{
    int n,i;
    int a[1000],b[1000],c[1000];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d%d%d",&a[i],&b[i],&c[i]);
    }
    for(i=0;i<n;i++){
        if((c[i]*c[i])==(a[i]*a[i]+b[i]*b[i])||(a[i]*a[i])==(b[i]*b[i]+c[i]*c[i])||(b[i]*b[i])==(a[i]*a[i]+c[i]*c[i])){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    return 0;
}
 

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    string s; cin >> s;
    if(s[0] == s[1] && s[1] == s[2]) {
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
}


Measured memory_bytes: 256
# import numpy as np
# import scipy as sp
# import sys
# input = sys.stdin.readline
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=list(map(int, input().split()))  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# a=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# a=[int(input()) for _ in range (n)]  #リスト入力  改行でa1 ... anのとき
# s=[list(map(str,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# a = b[:], a = [x[:] for x in b] # deepcopy
# chr(ord('a') + 1) # chrのインクリメント
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#　

h, w = list(map(int, input().split()))
s = [list(map(str, list(input()))) for i in range(h)]

INF = float("inf")
dp = [[INF]*w for _ in range(h)]

if s[0][0] == '#':
    dp[0][0] = 1
else:
    dp[0][0] = 0

for i in range(h):
    for j in range(w):
        if i+1 <= h-1:
            if s[i+1][j] == '.':
                dp[i+1][j] = min(dp[i+1][j], dp[i][j])
            else:
                if s[i][j] == '.':
                    dp[i+1][j] = min(dp[i+1][j], dp[i][j]+1)
                else:
                    dp[i+1][j] = min(dp[i+1][j], dp[i][j])

        if j+1 <= w-1:
            if s[i][j+1] == '.':
                dp[i][j+1] = min(dp[i][j+1], dp[i][j])
            else:
                if s[i][j] == '.':
                    dp[i][j+1] = min(dp[i][j+1], dp[i][j]+1)
                else:
                    dp[i][j+1] = min(dp[i][j+1], dp[i][j])

print(dp[-1][-1])


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


const int INF = 1e9+5;
using ll = long long;
int main(){
    int n,W;
    cin>>n>>W;
    vector<ll> dp(W+1,0);

    for(int i=0; i<n; i++){
        int w,v;
        cin>>w>>v;

        for(int wa=W-w; wa>=0; --wa){
            dp[wa+w]=max(dp[wa+w],dp[wa]+v);
        }
    }

    cout<<*max_element(dp.begin(),dp.end());

}

Measured memory_bytes: 3932
#include "bits/stdc++.h"

#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define eb emplace_back
#define rep(i, a, b) for (long i = (a); i <= (b); ++i)
#define per(i, a, b) for (long i = (a); i >= (b); --i)
#define mmst(v) memset(v, 0, sizeof(v))

template<typename T1,typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 & a, T2 b) { if (a < b) a = b; }

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;
const long long kMod = 1000000007;

const long kMAX = 1000000000;

using namespace std;
using ll = long long;

inline int readInt() {
  char c = getchar();
  while(!isdigit(c) && c != '-') c = getchar();
  int sigma = 1;
  if (c == '-') {
    sigma = -1;
    c = getchar();
  }
  int x = 0;
  while (isdigit(c)) {
    x = x * 10 + c - '0';
    c = getchar();
  }
  return x * sigma;
}

template <typename T>
struct RMQ {
  using F = function<T(T, T)>;
  T dat[kMax5][20];
  F f;

  RMQ() {}
  RMQ(F f): f(f) {}

  void init(const vector<T> & a) {
    auto n = a.size();
    rep(i, 0, n - 1) { dat[i][0] = a[i]; }
    for (auto j = 1; (1 << j) <= n; ++j) {
      for (auto i = 0; i + (1 << j) - 1 < n; ++i) {
        dat[i][j] = f(dat[i][j - 1], dat[i + (1 << (j - 1))][j - 1]);
      }
    }
  }

  T query(ll l, ll r) {
    if (l > r) {
      return 0;
    }

    auto k = 0;
    while (l + (1 << (k + 1)) - 1 <= r) { ++k; }
    return f(dat[l][k], dat[r - (1 << k) + 1][k]);
  }
};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);

  ll ans = 0;

  int n, m;
  vector<ll> a, b;
  string s, t;

  cin >> n;
  rep(i, 1, n) {
    int a0;
    cin >> a0;
    a.pb(a0);
  }
  rep(i, 1, n) {
    int b0;
    cin >> b0;
    ans += b0;
  }
  rep(i, 1, n - 1) {
  int c0;
  cin >> c0;
  b.pb(c0);
  }
  rep(i, 1, n - 1) {
    if (a[i] - a[i - 1] == 1) {
      ans += b[a[i - 1] - 1];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,A[200100];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	deque<int>q;
	for(int i=1;i<=n;i++){
		if(i&1)q.push_back(A[i]);
		else q.push_front(A[i]);
	}
	if(n&1)
		for(int i=q.size()-1;i>=0;i--)printf("%d ",q[i]);
	else 
		for(int i=0;i<q.size();i++)printf("%d ",q[i]);
}	



Measured memory_bytes: 3840
#include<iostream>
#include<string>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<vector>
#include<math.h>

using namespace std;

#define INF 1000000007
#define LINF (1LL << 62)

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


int n, m, a[101010], b[101010];
vector<int> v[101010], vv[101010];

int main(){
	cin >> n >> m;
	for(int i = 0; i < n-1 + m; i++){
		cin >> a[i] >> b[i];
		v[a[i]].push_back(b[i]);
		vv[b[i]].push_back(a[i]);
	}
	
	int t = 0;
	for(int i = 1; i <= n; i++){
		if(vv[i].size() == 0) t = i;
	}
	
	queue<P> q;
	q.push(P(0,t));
	int ans[101010] = {0}, cnt[101010] = {0};
	while(!q.empty()){
		P p = q.front();
		q.pop();
		int prev = p.first, now = p.second;
		ans[now] = prev;
		for(int i = 0; i < v[now].size(); i++){
			cnt[v[now][i]]++;
			if(vv[v[now][i]].size() > cnt[v[now][i]]){
				continue;
			}
			q.push(P(now, v[now][i]));
		}
	}
	
	for(int i = 1; i <= n; i++){
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 13440
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#define _USE_MATH_DEFINES
using namespace std;
vector<double> x;
vector<double> y;

void solve(int N){
  if(N > 0){
    vector<double> xx;
    vector<double> yy;
    xx.push_back(x[0]);
    yy.push_back(y[0]);
    double px = x[0];
    double py = y[0];
    int size = x.size();
    double tmpx[4];
    double tmpy[4];
    for(int i = 1; i < size; i++){
      double qx = x[i];
      double qy = y[i];
      double sx = (2.0 * px + qx) / 3.0;
      double sy = (2 * py + qy) / 3.0;
      double tx = (px + 2.0 * qx) / 3.0;
      double ty = (py + 2.0 * qy) / 3.0;
      double angle = atan2(ty - sy, tx - sx);
      double radius = sqrt((ty - sy) * (ty - sy) + (tx - sx) * (tx - sx));
      double mx = sx + radius * cos(angle + M_PI / 3.0);
      double my = sy + radius * sin(angle + M_PI / 3.0);
      tmpx[0] = sx;
      tmpx[1] = mx;
      tmpx[2] = tx;
      tmpx[3] = qx;
      tmpy[0] = sy;
      tmpy[1] = my;
      tmpy[2] = ty;
      tmpy[3] = qy;
      for(int j = 0; j < 4; j++){
	xx.push_back(tmpx[j]);
	yy.push_back(tmpy[j]);
      }
      px = qx;
      py = qy;
    }
    x = xx;
    y = yy;
    solve(N - 1);
  }
}

int main() {
  int N;
  cin >> N;
  x.push_back(0);
  y.push_back(0);
  x.push_back(100);
  y.push_back(0);
  solve(N);
  for(int i = 0; i < x.size(); i++){
    cout << x[i];
    cout << " ";
    cout << y[i] << endl;
  }
}

//鶴崎 修功 45-186020
//平安京ウォーキング https://onlinejudge.u-aizu.ac.jp/#/problems/2186
//教卓から見て中央・中央あたりに座っていました。


Measured memory_bytes: 3748
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	
	 static Scanner in = new Scanner(System.in);
	 
   
	public static void main(String args[])throws IOException  {
   
    	
         int n=in.nextInt();
         long[] a=new long[n+1];
         long[] b=new long[n+1];
         ArrayList<Long> list=new    ArrayList<Long>();
         long sum=0;
         for(int i=0;i<n;i++)
        	 a[i]=in.nextLong();
         int ans=0;
         for(int i=0;i<n;i++)
         {
        	 b[i]=in.nextLong();
        	 if(a[i]<b[i])
        	 {
        		 sum+=b[i]-a[i];
        		 ans++;
        	 }
        	 if(a[i]>b[i])
        		 list.add((a[i]-b[i]));
         }
         Collections.sort(list);
         int pos=list.size();
       
         for(int i=pos-1;i>=0;i--)
         {if(sum<=0) break;
        	 ans++;
        	 sum-=list.get(i).longValue();
        	 
         }
         if(sum<=0)
        	 
    		System.out.println(ans);
         else
        	 System.out.println(-1);
     	
    }

	
	
 
	
}

Measured memory_bytes: 94076
s = str(input())
sum_ = 0

for i in range(2**(len(s)-1)):
    l = []
    for b in range(len(s)):
        bit = 2**b
        if i & bit > 0:
            l.append(b)
    if len(l) == 0:
        cal_l = [int(s)]
    else:
        pre = 0
        cal_l = []
        for index in l:
            cal_l.append(int(s[pre:index+1]))
            pre = index+1
        cal_l.append(int(s[pre:]))
    sum_ += sum(cal_l)
print(sum_)


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

using namespace std;

int main() {
	int n, k;
	while (cin >> n >> k) {
		if (n == 0 && k == 0) {
			break;
		}
		vector<int> data(n);
		long long int sum = 0;
		long long int MAX;
		for (int i = 0; i < n; i++) {
			cin >> data[i];
			sum += data[i];
			if (i == k-1) {
				MAX = sum;
			} else if (i > k-1) {
				sum -= data[i-k];
				MAX = max(MAX, sum);
			}
		}
		cout << MAX << endl;
	}
	return 0;
}

Measured memory_bytes: 1532