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

string getId(int n) {
    ostringstream id;
    id << setw(6) << setfill('0') << right << n;
    return id.str();
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<P>> a(n);

    rep(i, m) {
        int p, y;
        cin >> p >> y;
        p--;
        a[p].push_back(make_pair(y, i));
    }

    string ans[m];
    rep(i, a.size()) {
        sort(a[i].begin(), a[i].end());
        for (int j = 0; j < a[i].size(); j++) {
            ans[a[i][j].second] = getId(i + 1) + getId(j + 1);
        }
    }

    rep(i, m) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

string S,T;
int A[10060];
int B[10060];
int L[10060],R[10060];
int N;
int n1,n0;
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>S>>T;
	N=S.size();
	
	n1=count(ALL(S),'1');
	n0=count(ALL(T),'0');
	if(n1 && n0==N) return _P("-1\n");
	if(S==T) return _P("0\n");
	
	int mi=1<<30;
	for(int loop=0;loop<2;loop++) {
		int pre=-1;
		FOR(i,5*N) {
			A[i]=S[i%N]=='1';
			B[i]=T[i%N]=='1';
			if(B[i]) pre=i;
			L[i]=pre;
		}
		pre=5*N;
		for(i=5*N-1;i>=0;i--) {
			if(B[i]) pre=i;
			R[i]=pre;
		}
		
		//left
		FOR(i,N) {
			int tar=0,shiftmi=101010;
			vector<pair<int,int>> V;
			FOR(j,N) {
				x=2*N+j;
				y=2*N+j-i;
				if(A[x]!=B[y]) {
					tar++;
					if(L[x]<y) V.push_back({y-L[x],R[x]-x});
				}
			}
			if(V.empty()) {
				shiftmi=0;
			}
			else {
				int RR[2020]={};
				int lma=0,rma=0;
				sort(ALL(V));
				FORR(v,V) lma=max(lma,v.first),rma=max(rma,v.second);
				shiftmi=min(lma,rma);
				for(r=V.size()-1;r>=0;r--) {
					RR[r]=max(RR[r+1],V[r].second);
					shiftmi=min(shiftmi,V[r].first+RR[r+1]);
				}
			}
			mi=min(mi,tar+i+2*shiftmi);
		}
		reverse(ALL(S));
		reverse(ALL(T));
	}
	
	
	cout<<mi<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6+5;
int fir[N],snd[N],d[N];
int hed[N],to[N<<1],nxt[N<<1],cnt;
int L = 0;
inline void dfs(int x,int pre){
	d[x] = d[pre]+1;
	fir[x] = snd[x] = d[x];
	for(int i=hed[x];i;i=nxt[i]){
		int v=to[i];if(v==pre)continue;
		dfs(v,x);
		if(fir[v] >= fir[x])snd[x] = fir[x], fir[x] = fir[v];
		else if(fir[v] >= snd[x])snd[x] = fir[v];
	}
	L = max(L, fir[x]+snd[x]-2*d[x]);
}
int n;
int main()
{
	cin >> n ;
	for(int i=1;i<n;i++){
		int u,v;scanf("%d%d",&u,&v);
		++cnt;to[cnt]=v,nxt[cnt]=hed[u];hed[u]=cnt;
		++cnt;to[cnt]=u,nxt[cnt]=hed[v];hed[v]=cnt;
	}
	dfs(1,0);
	cout << (L%3==1?"Second":"First") << endl;
}

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

int main() {

	int H, W;
	string s[55];
	string ans[55] = {};

	const int dx[8] = { -1, 0, 1,-1, 1,-1,0,1 };
	const int dy[8] = { -1,-1,-1, 0, 0, 1,1,1 };

	cin >> H >> W;
	for (int i = 0; i < H; ++i) cin >> s[i];

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {

			if (s[i][j] == '#') continue;
			int num = 0;
			for (int k = 0; k < 8; ++k) {
				int nx = j + dx[k];
				int ny = i + dy[k];
				if (nx >= 0 && nx < W && ny >= 0 && ny < H) {
					if (s[ny][nx] == '#') {
						num++;
					}
				}

			}
			s[i][j] = char(num + '0');
		}
	}
	
	for (int i = 0; i < H; ++i) cout << s[i] << '\n';

	return 0;
}

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

const int mnx = 2e6 + 9;
const int mod = 1e9 + 7;

ll q, h, s, d;
ll n;

int main(){

cin>>q>>h>>s>>d;
cin>>n;

cout<<(n / 2) * min(8 * q, min(4 * h, min(2 * s, d))) + (n % 2) * min(4 * q, min(2 * h, s))<<'\n';

return 0;

}















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
 
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;
 
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;
 
#define _  %  MOD
#define __ %= MOD
 
#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))
 
#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
#define fbo find_by_order
#define ook order_of_key
 
ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent
 
int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
	ll n;
	cin>>n;
	set<ll> st1,st2;
	rep(i,n)
	{
		ll x,y;
		cin>>x>>y;
		st1.insert(x-y);
		st2.insert(x+y);
	}
   ll ans=max(abs(*st1.rbegin()-*st1.begin()),abs(*st2.rbegin()-*st2.begin()));cout<<ans<<'\n';return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!



Measured memory_bytes: 22392
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int main() {
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;

    vector<int64_t> a(A);
    vector<int64_t> b(B);
    vector<int64_t> c(C);

    for (int i = 0; i < A; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
    }
    for (int i = 0; i < C; ++i) {
        cin >> c[i];
    }

    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());
    sort(c.begin(), c.end(), greater<int>());

    vector<int64_t> p;
    p.reserve(X + Y + C);

    for (int i = 0; i < X; ++i) {
        p.push_back(a[i]);
    }
    for (int i = 0; i < Y; ++i) {
        p.push_back(b[i]);
    }
    for (int i = 0; i < C; ++i) {
        p.push_back(c[i]);
    }

    sort(p.begin(), p.end(), greater<int>());

    int64_t ans = 0;
    for (int i = 0; i < X + Y; ++i) {
        ans += p[i];
    }

    cout << ans << endl;
}

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

int main(){
	int n;
	cin >> n;
	vector<int> l(n);
	rep(i, n) cin >> l.at(i);
	sort(l.begin(), l.end());
	
	int ans = 0;
	rep(b, n) rep(a, b) {
		int sum = l.at(a) + l.at(b);
		int max = lower_bound(l.begin(), l.end(), sum) - l.begin();
		ans += max - b - 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


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

    ll N;  cin >> N;

    ll h, n, w;
    bool found = false;
    for (ll i = 1; i < 3501; i++) {
        for (ll j = 1; j < 3501; j++) {
            int l = 1, r = 3501;
            while(l<r){
                ll m = (l + r) / 2;

                if (4*i*j*m == (i*j + j*m + m*i)*N){
                    h = i; n = j; w = m;
                    found = true;
                    break;
                } else if ((4*i*j - N*j - N*i)*m > i*j*N) {
                    r = m;
                } else {
                    l = m + 1;
                }
            }
            if (found) break;
        }
        if (found) break;
    }

    cout << h << " " << n << " " << w << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main{
	public static void main(String[] args) throws IOException{
		Scanner stdIn=new Scanner(System.in);
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		int n=stdIn.nextInt();
		int m=stdIn.nextInt();
		int a[][]=new int[n][m];
		int b[]=new int[m];
		int c[]=new int[n];
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				a[i][j]=stdIn.nextInt();
		}
		for(int i=0;i<m;i++)
			b[i]=stdIn.nextInt();
		for(int i=0;i<n;i++){
			for(int j=0;j<m;j++)
				c[i]+=a[i][j]*b[j];
		}
		for(int i=0;i<n;i++)
			System.out.println(c[i]);
	}
}

Measured memory_bytes: 40832
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>

int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};

typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=1e3+100;;
int n,c;
int dp[5000][sz];
int ara[sz][15];
int bara[sz],tk[sz];
int cholo(int mask,int id)
{
   if(__builtin_popcount(mask)==n){
     return 0;
   }
   if(id>=c) return Max;
   int &ret=dp[mask][id];
   if(~ret)  return ret;
   int mn=cholo(mask,id+1);
   int temp=mask;
   for(int i=0;i<bara[id];i++){
      temp=Set(temp,ara[id][i]);
   }
   mn=min(mn,tk[id]+cholo(temp,id+1));
   return (ret=mn);

}
int main()
{
    Khela
    int a,b,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n>>c)
    {
        for(i=0;i<c;i++){
            cin>>tk[i]>>bara[i];
            for(j=0;j<bara[i];j++) {
                    cin>>ara[i][j];
            --ara[i][j];
            }
        }
        memset(dp,-1,sizeof dp);
        p=cholo(0,0);
        if(p==Max) cout<<"-1"<<endl;
        else cout<<p<<endl;

    }

}


Measured memory_bytes: 21888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		int H, W, i, j, flag;
		
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			
			H = scan.nextInt();
			W = scan.nextInt();
			
			if(H == 0 && W == 0) break;
			
			for(i = 0; i < H; i++) {
				
				//奇数行目の時flag=-1とする
				if(i % 2 == 1) flag = -1;
				else flag = 1;
				
				for(j = 0; j < W; j++) {
					if(flag == 1) System.out.printf("#");
					else System.out.printf(".");
					flag *= -1;
				}
				
				System.out.println();
				
			}
			
			System.out.println();
			
		}
		
	}

}


Measured memory_bytes: 58152
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;
ll A[200000];
ll dp[200001][3];
const ll INF = 1e+17;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int N;
    cin >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    if(N%2 == 0){
        dp[0][0] = A[0];
        dp[0][1] = 0;
        for(int i = 1; i < N; i++){
            if(i%2 == 0){
                dp[i][0] = dp[i-1][0]+A[i];
                dp[i][1] = max(dp[i-1][0], dp[i-1][1]);
            }else{
                dp[i][0] = dp[i-1][0];
                dp[i][1] = max(dp[i-1][0], dp[i-1][1]+A[i]);
            }
        }
        cout << max(dp[N-1][0], dp[N-1][1]) << endl;
    }else{
        dp[0][0] = A[0];
        dp[0][1] = 0;
        dp[0][2] = -INF;
        for(int i = 1; i < N; i++){
            if(i%2 == 0){
                dp[i][0] = dp[i-1][0]+A[i];
                dp[i][1] = max(dp[i-1][0], dp[i-1][1]);
                dp[i][2] = max(dp[i-1][2]+A[i], dp[i-1][1]);
            }else{
                dp[i][0] = dp[i-1][0];
                dp[i][1] = max(dp[i-1][0], dp[i-1][1]+A[i]);
                dp[i][2] = max(dp[i-1][2], dp[i-1][1]);
            }
        }
        cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << endl;
    }
}

Measured memory_bytes: 9864
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  sort(c.begin(), c.end());
  ll ans = 0;
  rep(i, n) {
    int middle = b[i];
    ll up = lower_bound(a.begin(), a.end(), middle) - a.begin();
    ll low = n - (upper_bound(c.begin(), c.end(), middle) - c.begin());
    ans += up * low;
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
N=int(input())
p=[[]for _ in range(N+1)]
for _ in range(N-1):
  u,v,w=map(int,input().split())
  p[u].append((v,w))
  p[v].append((u,w))
s=[(1,0)]
l=[-1]*N
while s:
  a,w=s.pop()
  l[a-1]=w%2
  for b,c in p[a]:
    if l[b-1]==-1:
      s.append((b,w+c))
for i in l:
	print(i)


Measured memory_bytes: 70692
#include <iostream>  
using namespace std;  
int main()  
{  
int a[100],i,k,c=0 ;
long n;    
cin>>n>>k;    
for(i=0; n>0; i++)    
{    
a[i]=n%k;    
n= n/k;  
}    
   
for(i=i-1 ;i>=0 ;i--)    
{    
  c++;    
} 
cout<<c;   
}  


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int count=0;
    char S[101];
    
  cin>>S;
         int n=strlen(S);
  
         for(int i=0;i<=(n-2)/2;i++){
             if(S[n-1-i]!=S[i]){
                 S[n-1-i]=S[i];
                 count++;}}
    
      
     cout<< count;
    
     return 0;
  
    }

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

int main(){
  int n;
  cin >> n;
  vector<int>kazu(n);
  for(int i=0;i<n;i++)
    cin >> kazu.at(i);
  bool ok=true;
  int ans=0;
  while(ok){
    for(int i=0;i<n;i++){
      if(kazu.at(i)%2==0)
        kazu.at(i)/=2;
      else
        ok=false;
    }
    if(!ok)
      break;
    ans++;
  }
  cout << ans << endl;
}

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

using namespace std;

// #define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define rep(i,a,b) for (int i = a; i <= (int)b; ++i)
#define f first
#define s second

#define single_test

const int maxn = 3004;
int dp[maxn][maxn];
string a, b;

int go(int i, int j) {
    if (i == a.size() or j == b.size()) {
        return 0;
    }
    int &ref = dp[i][j];
    if (ref != -1) {
        return ref;
    }
    int ans = 0;
    if (a[i] == b[j]) {
        ans = 1 + go(i + 1, j + 1);
    }
    else {
        int l = go(i + 1, j);
        int r = go(i, j + 1);
        if (l < r) {
            ans = r;
        }
        else {
            ans = l;
        }
    }
    return ref = ans;
}

void print(int i, int j) {
    if (i == a.size() or j == b.size()) {
        return;
    }
    int ans = 0;
    if (a[i] == b[j]) { 
        cout << a[i];
        print(i + 1, j + 1);
    }
    else {
        int l = go(i + 1, j);
        int r = go(i, j + 1);
        if (l > r) {
            print(i + 1, j);
        }
        else {
            print(i, j + 1);
        }
    }
    return;
}

void solve() {
    memset(dp, -1, sizeof dp);
    cin >> a >> b;
    int len = go(0, 0);
    // cout << len << '\n';
    print(0, 0);
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}

Measured memory_bytes: 39292
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()


int main() {
    int N, A, abs_max = 0, index = 0;
    bool negative = false;
    cin >> N;
    REP(i, N) {
        cin >> A;
        if (abs(A) > abs_max) {
            abs_max = abs(A);
            index = i;
            negative = A < 0;
        }
    }
    cout << 2 * (N - 1) << endl;
    REP(i, N) if (i != index) cout << index + 1 << " " << i + 1 << endl;
    if (negative)
        RREP(i, N - 1) cout << i + 2 << " " << i + 1 << endl;
    else
        REP(i, N - 1) cout << i + 1 << " " << i + 2 << endl;

    return 0;
}

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

int main(){
  int N,A,B,C,D;
  string S;
  cin>>N>>A>>B>>C>>D;
  cin>>S;
  bool flag=0;
  for (int i=A;i<(max(C,D));i++){
    //cout<<S.at(i)<<" "<<flag<<endl;
    if(S.at(i)=='#'){
      if(flag){
        cout<<"No"<<endl;
        return 0;
      }
      flag=1;
    }
    else{
      //cout<<"##"<<endl;
      flag=0;
    }
  }
  int cnt=0;
  if(C>D){
    for (int i=B-2;i<=D-2;i++){
      if((S.at(i)=='.')&&(S.at(i+1)=='.')&&(S.at(i+2)=='.')){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  return 0;
}

    
    
  
  
  
    

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

using namespace std;

string set_to_string(const set<int64_t> &s)
{
  stringstream ss;
  auto itr = s.begin();
  while (itr != s.end()) {
    ss << *itr;
    ++itr;
    if (itr != s.end()) {
      ss << ' ';
    }
  }
  return ss.str();
}

int main()
{
  int64_t N;
  cin >> N;
  
  vector<int16_t> a(N + 1, 0);
  for (int64_t n = 1; n <= N; ++n) {
    cin >> a[n];
  }
  
  set<int64_t> s;
  vector<int16_t> c(N + 1, 0);
  
  for (int64_t n = N; n >= 1; --n) {
    if (a[n] != c[n]) {
      s.insert(n);
      
      for (uint64_t y = 1; y <= (uint64_t)floor(sqrt(n)); ++y) {
        if (n % y == 0) {
          c[y] = (c[y] == 1) ? 0 : 1;
          if (y != (n / y)) {
            c[n / y] = (c[n / y] == 1) ? 0 : 1;
          }
        }
      }
    }
  }
  
  cout << s.size() << endl;
  cout << set_to_string(s) << endl;
  
  return 0;
}

Measured memory_bytes: 8776
#include <bits/stdc++.h>
#include <iostream>
#define ll long long
#define mem(f, x) memset(f, x, sizeof(f))
#define INF 0x3f3f3f3f
using namespace std;
const int M = 15;
const int N = 10005;
int a, b;
int main( ){
    while( scanf( "%d %d", &a, &b ) != EOF ){
        int flag = 0;
        for( int i = 1; i <= 1300; i++ ){
            if( int(i*0.08) == a && int( i*0.1 ) == b ){
                printf( "%d\n", i );
                flag = 1;
                break;
            }
        }
        if( !flag )
            printf( "-1\n" );
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

const int g1[] = { 1, 3, 5, 7, 8, 10, 12 };
const int g2[] = { 4, 6, 9, 11 };
const int g3[] = { 2 };

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

	map<int,int> group; group.clear();
	rep (i, sizeof(g1)/sizeof(g1[0])) group[g1[i]] = 1;
	rep (i, sizeof(g2)/sizeof(g2[0])) group[g2[i]] = 2;
	rep (i, sizeof(g3)/sizeof(g3[0])) group[g3[i]] = 3;

	int x, y; cin >> x >> y;

	bool ok = (group[x] == group[y]);

	cout << (ok ? "Yes" : "No") << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N,T;
    cin >> N >> T;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    int A = Inf;
    int cnt = 0;
    for(int i = 0;i < N - 1;i++) {
        A = min(A,vec.at(i));
        cnt = max(cnt,vec.at(i + 1) - A);
    }
    if(cnt == 0) {
        cout << 0 << endl;
    }
    else {
        int ret = 0;
        A = Inf;
        for(int i = 0;i < N - 1;i++) {
            A = min(A,vec.at(i));
            if(vec.at(i + 1) - A == cnt) {
                ret++;
            }
        }
        cout << ret << endl;
    }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);

    string in; cin >> in;
    int res = 0;
    for(auto& c : in){
        if(c == '+') res++;
        else res--;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;
    if(a>b)
    cout << "a > b" << endl;
    else if (a==b)
    cout << "a == b" << endl;
    else 
    cout << "a < b"<< endl;


   
   return 0;
}


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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
const ll integer=1000000000;


int main(){
    int mod[6]={0,1,2,3,4,5};
    int val[6]={100,101,102,103,104,105};
    int x;
    cin >> x;
    int y=x%100;
    if (y==0) {
        cout << 1 << endl;
        return 0;
    }
    int ans=0;
    for(int i=5; 0 < i; i--){
        while(y >= mod[i]) {
            y-=mod[i];
            ans+=val[i];
        }
    }
    if (ans > x){
        cout << 0 << endl;
        return 0;
    }
    else cout << 1 << endl;
    
    return 0;
}


Measured memory_bytes: 256
# coding: utf-8


N,K  = map(int,input().split())
moto = input().split()
for i in range(N):
    moto[i] = int(moto[i])

def real(n):
    if n >= 0:
        return n 
    else:
        return -1*n 

l = []
for i in range(N-K+1):
    l.append(real(moto[i]) + real(moto[i+K-1]-moto[i]))
    l.append(real(moto[i+K-1])+real(moto[i+K-1]-moto[i]))
print(min(l))

Measured memory_bytes: 11100
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
        int n;
        cin >> n;
        int t=0,x=0,y=0,i;
        for(i=0;i<n;i++){
                int ti,xi,yi;
                cin >> ti >> xi >> yi;
                int time=ti-t,mx=abs(x-xi),my=abs(y-yi);
                if((mx+my-time)>0 || (mx+my-time)%2){
                        cout << "No" << endl; break;
                }
                t=ti; x=xi; y=yi;
        }
        if(i==n) cout << "Yes" << endl;
        return 0;
}


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


int main(){
  int N ; 
  cin >> N ; 
  vector<int> P(N) ; 
  for(int i = 0 ; i < N ;i++){
    cin >> P.at(i) ; 
  }
  
  sort(P.begin(),P.end());
  reverse(P.begin(),P.end());
  
  int ans = 0 ; 
  
  for(int i = 0 ; i < N ; i++){
    if(i == 0 ) P.at(i) /= 2 ; 
    ans += P.at(i) ; 
  }
  
  cout << ans << endl ; 
  
}

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

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

  vector<long> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);

    if (A.at(i) == 0)
    {
      cout << 0 << endl;
      return 0;
    }
  }

  long long MAX = pow(10, 18);
  long long ans = 1;

  for (int i = 0; i < N; i++)
  {
    if (MAX / ans >= A.at(i))
    {
      ans *= A.at(i);
    }
    else
    {
      cout << -1 << endl;
      return 0;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 4020
#include <iostream>
#include <string>
#include <algorithm>
#define int long long
using namespace std;
pair<int, int>c[100];
int n, t;
signed main() {
	cin >> n >> t;
	for (int i = 0; i < n; i++) {
		cin >> c[i].first>> c[i].second;
	}
	sort(c, c + n);
	for (int i = 0; i < n; i++) {
		if (c[i].second<=t) {
			cout << c[i].first << endl;
			return 0;
		}
	}
	cout << "TLE" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<climits>
#include<algorithm>
#include<sstream>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<list>
#include<map>
#include<vector>

using namespace std;


#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define ll long long

#define IMIN INT_MIN;
#define IMAX INT_MAX;

int maxelem(vector<int> src) {
	int dst = IMIN;
	rep(i, src.size()) {
		dst = (dst > src[i]) ? dst : src[i];
	}
	return dst;
}

int secondelem(vector<int> src) {
	int dst = IMIN;
	int dst2 = IMIN;
	rep(i, src.size()) {
		if (dst < src[i]) {
			dst2 = dst;
			dst = src[i];
		}
		else if (dst2 < src[i]) {
			dst2 = src[i];
		}
	}
	return dst2;
}

vector<int> count(vector<int> a) {
	int ma = maxelem(a);
	vector<int> count(ma+1, 0);
	rep(i, a.size()) {
		count[a[i]]++;
	}
	return count;
}

int find(vector<int> a, int b) {
	rep(i, a.size()) {
		if (a[i] == b) return i;
	}
	return -1;
}

ll fibo(int n) {
	ll fibos[n];
	fibos[0] = 2;
	fibos[1] = 1;
	rept(i, 2, n+1) {
		fibos[i] = fibos[i-2] + fibos[i-1];
	}
	return fibos[n];
}

int main(){
	ll lucas;
	int n;
	cin >> n;
	lucas = fibo(n);
	cout << lucas;


	return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

struct mypair{
    int num;
    bool red;
    mypair(int i,bool j):num(i),red(j){

    }
};

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

    int n,m;
    cin >> n >> m;

    vector<mypair> vec(n+1,mypair(1,false));
    vec[1].red = true;

    vector<int> x(m),y(m);

    for(int i = 0; i < m; i++){
        cin >> x[i] >> y[i];
    }

    for(int i = 0; i < m; i++){
        vec[x[i]].num--;
        vec[y[i]].num++;
        if(vec[x[i]].red){
            vec[y[i]].red = true;
        }
        if(vec[x[i]].num == 0){
            vec[x[i]].red = false;
        }
    }

    int count = 0;

    for(int i = 1; i < n+1; i++){
        if(vec[i].red){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
 
struct Node
{
    int key;
    Node *right, *left, *parent;
};
 
Node *root, *NIL;
 
void insert(int k)
{
    Node *y=NIL;
    Node *x=root;
    Node *z;
     
    z=(Node *)malloc(sizeof(Node));
    z->key=k;
    z->left=NIL;
    z->right=NIL;
     
    while(x!=NIL)
    {
        y=x;
        if(z->key < x->key) x=x->left;
        else x=x->right;
    }
    z->parent=y;
    if(y==NIL) root=z;
    else
    {
        if(z->key < y->key) y->left=z;
        else y->right=z;
    }
}
 
void inorder(Node *u)
{
    if(u==NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
 
void preorder(Node *u)
{
    if(u==NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}
 
int main()
{
    int i,n,x;
    string com;
     
    scanf("%d",&n);
     
    for(i=0;i<=n-1;i++)
    {
        cin >> com;
        if(com=="insert")
        {
            scanf("%d",&x);
            insert(x);
        }
        else if(com=="print")
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}




Measured memory_bytes: 26644
//https://atcoder.jp/contests/abc086/tasks/abc086_a

#include <iostream>
#include <vector>
using namespace std;

int main() {
    // 入力
    int a, b;
    cin >> a >> b;

    if(a*b % 2 == 0)
    {
      cout << "Even" << endl;
    }
    else
    {
      cout << "Odd" << endl;
    }


}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a,b; cin >> a;
  cin >> b;
  if(a>b)swap(a,b);
  if(a == 1 && b == 2) cout << 3;
  if(a == 1 && b == 3) cout << 2;
  if(a == 2 && b == 3) cout << 1;
  return 0;
}

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

#define ll long long int
#define endl '\n'
#define inf 1e18

// Link of the code
//https://www.geeksforgeeks.org/find-the-number-of-pairs-such-that-their-gcd-is-equals-to-1/
ll lpf[1000005], mobius[1000005]; 
ll a[1000006];
  
// Function to calculate least 
// prime factor of each number 
void least_prime_factor() 
{ 
    for (int i = 2; i < 1000005; i++) 
  
        // If it is a prime number 
        if (!lpf[i]) 
  
            for (int j = i; j < 1000005; j += i) 
  
                // For all multiples which are not 
                // visited yet. 
                if (!lpf[j]) 
                    lpf[j] = i; 
} 
  
// Function to find the value of Mobius function 
// for all the numbers from 1 to n 
void Mobius() 
{ 
    for (int i = 1; i < 1000001; i++) { 
  
        // If number is one 
        if (i == 1) 
            mobius[i] = 1; 
        else { 
  
            // If number has a squared prime factor 
            if (lpf[i / lpf[i]] == lpf[i]) 
                mobius[i] = 0; 
  
            // Multiply -1 with the previous number 
            else
                mobius[i] = -1 * mobius[i / lpf[i]]; 
        } 
    } 
} 
  
// Function to find the number of pairs 
// such that gcd equals to 1 
ll gcd_pairs(ll n) 
{ 
    // To store maximum number 
    ll maxi = 0; 
  
    // To store frequency of each number 
    ll fre[1000005] = { 0 }; 
  
    // Find frequency and maximum number 
    for (int i = 1; i <=n; i++) { 
        fre[a[i]]++; 
        maxi = max(a[i], maxi); 
    } 
  
    least_prime_factor(); 
    Mobius(); 
  
    // To store number of pairs with gcd equals to 1 
    ll ans = 0; 
  
    // Traverse through the all possible elements 
    for (int i = 1; i <= maxi; i++) { 
        if (!mobius[i]) 
            continue; 
  
        ll temp = 0; 
        for (int j = i; j <= maxi; j += i) 
            temp += fre[j]; 
  
        ans += temp * (temp - 1) / 2 * mobius[i]; 
    } 
  
    // Return the number of pairs 
    return ans; 
}
void testCase()
{
    //ll t; cin>>t; while(t--)
    {
       ll n;
       cin>>n;
     
       ll full=0;
       for(int i=1;i<=n;i++)
       {
           cin>>a[i];
           full=__gcd(a[i],full);
       }

       ll temp=gcd_pairs(n);
       if(temp==(n*(n-1))/2)
       {
           cout<<"pairwise coprime"<<endl;
       }
       else
       if(full==1)
       {
           cout<<"setwise coprime"<<endl;
       }
       else{
           cout<<"not coprime"<<endl;
       }


    } 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    testCase();
    return 0;
}

Measured memory_bytes: 34740
var
	r1,r2,ans,id,idd,N,M,i,j,k,s:Longint;
	A:array[1..10,1..10]of Boolean;
	B:array[1..10,1..11]of Boolean;
	tmp:Boolean;
begin
	read(N,M);
	for i:=1 to M do begin
		read(k);
		for j:=1 to k do begin
			read(s);
			A[i,s]:=True;
			B[i,s]:=True;
		end;
	end;
	for i:=1 to M do begin
		read(s);
		if s=1 then B[i,N+1]:=True;
	end;
	for i:=1 to N do begin
		inc(id);
		idd:=id;
		while(idd<=M)and(not A[idd,i])do inc(idd);
		if idd>M then begin
			dec(id);
			continue;
		end;
		for j:=i to N do begin
			tmp:=A[id,j];
			A[id,j]:=A[idd,j];
			A[idd,j]:=tmp;
		end;
		inc(r1);
		for j:=id+1 to M do begin
			if A[j,i]then begin
				for k:=i to N do begin
					A[j,k]:=A[j,k]xor A[id,k];
				end;
			end;
		end;
	end;
	id:=0;
	for i:=1 to N+1 do begin
		inc(id);
		idd:=id;
		while(idd<=M)and(not B[idd,i])do inc(idd);
		if idd>M then begin
			dec(id);
			continue;
		end;
		for j:=i to N+1 do begin
			tmp:=B[id,j];
			B[id,j]:=B[idd,j];
			B[idd,j]:=tmp;
		end;
		inc(r2);
		for j:=id+1 to M do begin
			if B[j,i]then begin
				for k:=i to N+1 do begin
					B[j,k]:=B[j,k]xor B[id,k];
				end;
			end;
		end;
	end;
	ans:=1;
	if r1<>r2 then ans:=0;
	for i:=1 to N-r1 do ans:=ans*2;
	writeln(ans);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};

int dp[101010];
int check[101010];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, M;
    cin >> N >> M;
    REP(i,N+1) check[i] = 1;
    REP(i,M){
        int a; cin >> a;
        check[a] = 0;
    }
    dp[0] = 1;
    for(int i=0;i<=N;i++){
        for(int next=i+1;next<=min(N,i+2);next++){
            if(check[next]){
                dp[next] += dp[i];
                dp[next] %= MOD;
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    double x;
    double sum=0;
    string s;
    for(int i=0;i<n;i++){
        cin>>x>>s;
        if(s=="JPY"){
            sum+=x;
        }
        else{
            sum+=380000.0*x;
        }
    }
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
typedef tuple<ll, ll, ll> T;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    int x,y;
    cin>>s>>x>>y;
    int d=0;
    vector<vector<int>> a(2);
    REP(i,s.size()){
        int t=0;
        while(s[i]=='F'&&i<s.size()) t++,i++;
        a[d].push_back(t);
        d = 1-d;
    }
    int g=8000;
    int dx[2][2*8000]={},dy[2][2*8000]={};
    dx[0][g]=dy[0][g]=1;
    REP(i,a[0].size()){
        REP(j,2*g){
            if(dx[i%2][j]){
                dx[(i+1)%2][j+a[0][i]]=1;
                if(i>0) dx[(i+1)%2][j-a[0][i]]=1;
                dx[i%2][j]=0;
            }
        }
    }
    REP(i,a[1].size()){
        REP(j,2*g){
            if(dy[i%2][j]){
                dy[(i+1)%2][j+a[1][i]]=1;
                dy[(i+1)%2][j-a[1][i]]=1;
                dy[i%2][j]=0;
            }
        }
    }
    if(dx[(int)(a[0].size())%2][x+g] && dy[(int)(a[1].size())%2][y+g])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, a;
    cin >> n >> a;

    cout << n*n-a;
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 768
#include <cstdio>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using ll = long long;
using namespace std;

ll binsearch(ll l, ll r, function<bool (ll)> p) { // [l, r), p is monotone
    assert (l < r);
    -- l; -- r; // (l, r]
    while (l + 1 < r) {
        ll m = (l + r) / 2;
        (p(m) ? r : l) = m;
    }
    return r; // = min { x | p(x) }
}
int main() {
    int n, a, b; scanf("%d%d%d", &n, &a, &b);
    vector<int> h(n); repeat (i, n) scanf("%d", &h[i]);
    ll result = binsearch(0, *whole(max_element, h) + 1, [&](ll m) {
        ll cnt = 0;
        repeat (i, n) {
            ll x = h[i] - m * b;
            if (x >= 0) {
                cnt += (x + a-b-1) / (a-b);
            }
        }
        return cnt <= m;
    });
    printf("%lld\n", result);
    return 0;
}


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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
#define dbg(x) cerr << #x"= " << x << endl

std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

const int N=1e5+1;
ll f[N];

ui ncr(int a,int b){
    if (a==b || b==0) return 1;
    if (b+1==a) return a;
    return f[a] * powmod(f[b]*f[a-b],MOD-2,MOD) % MOD;
}
int main() {
    READ(0);
    f[0]=f[1]=1;
    for(int i=2;i<N;++i) f[i]=f[i-1]*i%MOD;
    int n,k;cin>>n>>k;
    vector<ll> vals(n);
    FOR(i,n) cin>>vals[i];
    sort(vals.begin(),vals.end());
    ll mx=0;
    for(int i=k-1;i<n;++i){
        mx += vals[i]*ncr(i,k-1)%MOD;
        if (mx>=MOD) mx -= MOD;
        else if (mx<0) mx += MOD;
    }
    ll mn=0;
    for(int i=n-k;i>=0;--i){
        mn += vals[i]*ncr(n-i-1,k-1)%MOD;
        if (mn>=MOD) mn -= MOD;
        else if (mn<0) mn += MOD;
    }
    ui ret=mx+MOD-mn;
    if (ret>=MOD) ret-= MOD;
    cout << ret;
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define REP(i, m, n) for (int i = (m); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define mp make_pair
#define pb push_back
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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; }

template <class T> inline auto __lcm(T &a, T &b)
{ return a * b / __gcd(a, b); }


int main() {
    ll  A, B;
    cin >> A >> B;

    print(__lcm(A, B));

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int Partition(int A[],int p,int r){
	int x=A[r];
	int i=p-1;
	for(int j=p;j<=r-1;j++){
		if(A[j]<=x){
			i++;
			swap(A[i],A[j]);
		}
	}
	swap(A[i+1],A[r]);
	return i+1;
}

int main(void){
	std::ios_base::sync_with_stdio(false);

	int n,A[100000+5];

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

	int kizyun=Partition(A,0,n-1);

	for(int i=0;i<n;i++){
		if(i!=kizyun) cout<<A[i];
		else cout<<"["<<A[i]<<"]";
		if(i==n-1) cout<<endl;
		else cout<<" ";
	}

	return 0;
}

Measured memory_bytes: 1592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    int n; cin >> n;
    string s, t; cin >> s >> t;
    string ans = "";
    for (int i = 0; i < n; i++) {
        ans += s[i];
        ans += t[i];
    }

    cout << ans << endl;
    return 0;
}

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

int main(){
    int n,x,d=0,l,ans=1;
    cin>>n>>x;
    for(int i=0;i<n;i++){
        cin>>l;
        d+=l;
        if(d>x) break;
        ans++;
    }
    cout<<ans;
    return 0;
}

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

int main() {
    int N, M;
    cin >> N >> M;
    priority_queue<int> que;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        que.push(a);
    }

    while (M > 0 && !que.empty()) {
        int t = que.top(); que.pop();
        M--;
        t /= 2;
        if (t > 0) que.push(t);
    }

    long long res = 0;
    while (!que.empty()) {
        int t = que.top(); que.pop();
        res += t;
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 入力受付
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
            System.out.println(a * b);
        } else {
            System.out.println(-1);
        }

    }

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a:A) cin >> a;}


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

i64 A, B, C, K; cin >> A >> B >> C >> K;

if (K <= A + B) cout << min(A, K) << "\n";
else cout << A - (K - A - B) << "\n";



return 0;
}
// コンテスト前はtemplate振り返り。
// 書いて考える．場合分け．情報整理．
// 問題文から考える。自分ができることから考える。
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索。逆から考える。
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。数表出力プログラム作る
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 3652
#include<stdio.h>

void kansu(int,int);

	int data[91][91];
	int n,m;
	int max,cnt;

int main(void)
{
	int i,j;
	int x,y;
	scanf("%d",&m);
	scanf("%d",&n);
	while(m!=0 && n!=0){
		max=0;
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				scanf("%d",&data[i][j]);
			}
		}
		for(i=0;i<m;i++){
			for(j=0;j<n;j++){
				if(data[i][j]==1){
					cnt=1;
					data[i][j]=0;
					kansu(i,j);
					data[i][j]=1;
				}
			}
		}
		printf("%d\n",max);
		scanf("%d",&m);
		scanf("%d",&n);
	}
	return 0;
}
void kansu(int x,int y)
{
	
	if(x-1>=0){
		if(data[x-1][y]==1){
			cnt++;
			if(cnt>max){
				max=cnt;
			}
			data[x-1][y]=0;
			kansu(x-1,y);
			data[x-1][y]=1;
			cnt--;
		}
	}
	if(x+1<=m){
		if(data[x+1][y]==1){
			cnt++;
			if(cnt>max){
				max=cnt;
			}
			data[x+1][y]=0;
			kansu(x+1,y);
			data[x+1][y]=1;
			cnt--;
		}
	}
	if(y-1>=0){
		if(data[x][y-1]==1){
			cnt++;
			if(cnt>max){
				max=cnt;
			}
			data[x][y-1]=0;
			kansu(x,y-1);
			data[x][y-1]=1;
			cnt--;
		}
	}
	if(y+1<=n){
		if(data[x][y+1]==1){
			cnt++;
			if(cnt>max){
				max=cnt;
			}
			data[x][y+1]=0;
			kansu(x,y+1);
			data[x][y+1]=1;
			cnt--;
		}
	}
}

Measured memory_bytes: 632
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=100010;
int n,m,kq;
int a[N],b[N],x[N],y[N],p[N],id[N],ans[N];
int root(int x){return id[x]<0?x:id[x]=root(id[x]);}
main()
{
    ios_base::sync_with_stdio(false),cin.tie(nullptr);
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>x[i],id[i]=-1;
    for(int i=1;i<=m;++i) cin>>a[i]>>b[i]>>y[i],p[i]=i;
    sort(p+1,p+m+1,[](int i,int j){return y[i]<y[j];});
    for(int i=1;i<=m;++i)
    {
        int u=root(a[p[i]]),v=root(b[p[i]]),c=y[p[i]];
        if(u==v) ans[u]+=c>x[u];
        else
        {
            x[u]+=x[v],id[v]=u;
            ans[u]+=ans[v];
            ans[u]=(c>x[u] ? ans[u]+1 : 0);
        }
    }
    for(int i=1;i<=n;++i) if(id[i]<0) kq+=ans[i];
    cout<<kq;
}


Measured memory_bytes: 5760