akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>

using namespace std;

int main(){
	int n;
	cin >> n;
	long long int a[n],y = 0, x[n], c[n-1];
	for(int i = 0; i < n; i++){
		cin >> a[i];
		x[i] = a[i];
		y += a[i];
		if(i > 0)
			x[i] += x[i - 1];
	}
	
	for(int i = 0; i < n - 1; i++){
		c[i] = abs(x[i] - (y - x[i]));
	}
	
	sort(c, c + n -1);
	
	cout << c[0] << endl;
	
 	return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S, T;
    cin >> S >> T;
    int size = S.size();
    rep(0, i, size)
    {
        if (S == T)
        {
            cout << "Yes" << endl;
            return 0;
        }
        else
        {
            string a = "0";
            a[0] = S[size - 1];
            S = a + S;
            S.pop_back();
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int lli;

bool dfs_coloring(int v, int c, vector<int> &num_c, vector<int> &color, vector<vector<int>> &g){
    if(color[v] != -1) return color[v]==c;
    color[v] = c;
    num_c[c]++;
    for(int next: g[v]){
        bool ret = dfs_coloring(next, 1-c, num_c, color, g);
        if(!ret) return false;
    }
    return true;
}
vector<vector<int>> bipertite_color_count(vector<vector<int>> &g){
    int n = g.size();
    vector<int> color(n, -1);
    vector<vector<int>> res;
    for(int i=0; i<n; i++){
        if(color[i] != -1) continue;
        vector<int> num_color{0, 0};
        bool ret = dfs_coloring(i, 0, num_color, color, g);
        if(!ret) return {};
        res.push_back(num_color);
    }
    return res;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> adj(n);
    for(int i=0; i<m; i++){
        int a,b;
        cin >> a >> b;
        a--; b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    auto ret = bipertite_color_count(adj);
    if(ret.empty()){
        cout << -1 << endl;
        return 0;
    }

    map<int, int> w_pre;
    int base = 0;
    for(auto v: ret){
        if(v[0] != v[1]){
            w_pre[abs(v[0]-v[1])]++;
        }
        base += min(v[0], v[1]);
    }
    int ulim = n-2*base;
    vector<int> w;
    for(auto p: w_pre){
        int num = 1;
        while(p.second >= num){
            w.push_back(p.first * num);
            p.second -= num;
            num *= 2;
        }
        if(p.second > 0){
            w.push_back(p.first * p.second);
        }
    } 
    vector<bool> dp(ulim+1, false);
    dp[0] = true;
    for(int t: w){
        for(int i=ulim; i>=0; i--){
            if(dp[i] and i+t <= ulim){
                dp[i+t] = true;
            }
        }
    }
    lli ans = 0;
    for(int i=0; i<=ulim; i++){
        if(!dp[i]) continue;
        ans = max(ans, 1LL*(base+i)*(base+ulim-i)-m);
    }
    cout << ans << endl;
    return 0;
}


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

char field[500];

#define AT(f,x,y) f[(x)+(y)*w]
inline int isIn(int w, int h, int x, int y){
  if (x<0 || x>=w) return 0;
  if (y<0 || y>=h) return 0;
  return 1;
}

// return {pos, dist}
pair<int,int> bfs(int w, int h, int x, int y){
  int dist[500];
  deque<int> dq;
  int dx[]={1,0,-1,0}, dy[]={0,1,0,-1};
  int mxDist=-1, mxPos;
  
  for (int i=0; i<500; i++) dist[i]=-1;
  dq.push_back(x+y*w);
  dist[x+y*w]=0;
  while(dq.size()){
    x = dq[0]%w; y = dq[0]/w; dq.pop_front();
    for(int i=0; i<4; i++){
      int xx,yy;
      xx=x+dx[i]; yy=y+dy[i];
      if (isIn(w,h,xx,yy)==0) continue;
      if (AT(field,xx,yy)=='#' || AT(dist,xx,yy)>=0) continue;
      AT(dist,xx,yy) = AT(dist,x,y)+1;
      if (AT(dist,xx,yy)>mxDist){
        mxDist = AT(dist,xx,yy);
        mxPos = xx+yy*w;
      }
//      cout << xx << " " << yy << " " << (AT(dist,xx,yy)) << endl;
      dq.push_back(xx+yy*w);
    }
  }
/*  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      char buf[]="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz!?";
      if (AT(field,j,i)=='#') cout << '#';
      else cout << buf[AT(dist,j,i)%64];
    }
    cout << endl;
  }*/ 
  return make_pair(mxPos,mxDist);
}

int main(void){
  int h,w,farest=-1,st,d;
  
  cin >> h >> w;
  for (int i=0; i<h; i++){
    char buf[30];
    cin >> buf;
    for (int j=0; j<w; j++){
      AT(field,j,i) = buf[j];
      if (buf[j]!='#') st=j+i*w;
    }
  }
  for (int i=0; i<w*h; i++){
    if (field[i]=='.'){ 
      d = bfs(w,h,i%w,i/w).second;
      farest = farest<d?d:farest;
    }
  }
  cout << farest << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int a1[] = fs.nextIntArray(n);
		int a2[] = fs.nextIntArray(n);
		
		int ans = 0;
		for(int i=0;i<n;i++) {
			int sum = 0;
			for(int j=0;j<=i;j++) {
				sum += a1[j];
			}
			for(int j=i;j<n;j++) {
				sum += a2[j];
			}
			ans = Math.max(ans, sum);
		}
		System.out.println(ans);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 22484
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;
vvint adj;
vector <bool> vis;

void dfs(int s){
	vis[s] = 1;
	for(int u : adj[s]){
		if(!vis[u]) dfs(u);
	}
	return;
}

void solve(){
	int n,m;
	cin >> n >> m;
	adj = vvint(n);
	vis = vector <bool>(n,0);
	for(int i = 0;i < m;++i){
		int u,v;
		cin >> u >> v;
		--u,--v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	int ans = 0;
	for(int i = 0;i < n;++i){
		if(!vis[i]) dfs(i),++ans;
	}
	cout << ans - 1 << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


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

#define rep(i,N) for(int i = 0; i < (int)N; ++i)

int main(){
  int N;
  cin >> N;
  int c[10][10] = {};
  for(int i = 1; i <= N; ++i){
    string s = to_string(i);
    c[s.at(0) - '0'][s.at(s.size()-1) - '0']++;
  }
  int count = 0;
  rep(i,10){
    rep(j,10){
      count += c[i][j] * c[j][i];
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
#ABC 088 B
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Alice=0
Bob=0

if len(A)%2==1:
    A.append(0)

while len(A)>=1:
    Alice+=A.pop(0)
    Bob+=A.pop(0)
print(Alice-Bob)

Measured memory_bytes: 3060
# coding: utf-8
# Your code here!
import fractions as math
#import math
a,b,c,d = map(int,input().split())
cd=c*d//math.gcd(c,d)
tc=((a-1)//c+1)*c
td=((a-1)//d+1)*d
tcd=((a-1)//(cd)+1)*(cd)

ans= (b-a)+1
if c<=b:
    ans-=((b-tc)//c+1)
if d<=b:
    ans-=((b-td)//d+1)
if cd<=b:
    ans+=((b-tcd)//(cd)+1)

print(ans)

Measured memory_bytes: 5052
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
#define MAX 100000

int A[MAX], n;

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

int main(){
    int i,q;
    scanf("%d", &n);
    rep(i,n) scanf("%d", &A[i]);
    q = partition(0, n-1);

    rep(i,n){
        if (i) printf(" ");
        if (i == q) printf("[");
        printf("%d", A[i]);
        if (i == q) printf("]");
    }
    printf("\n");
}


Measured memory_bytes: 3588
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string.h>
#include <stack>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    int ans = 0;
    rep(i, 0, n) cin >> l[i];
    rep(i, 0, n){
        rep(j, 0, n){
            rep(k, 0, n){
                if(i < j && j < k){
                    if(l[i] == l[j]) continue;
                    if(l[i] == l[k]) continue;
                    if(l[k] == l[j]) continue;
                    if((ll)l[i]+l[j]+l[k] <= max({l[i],l[j],l[k]})*2)continue;
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
  char a, b; cin >> a >> b;
  if (a == 'H') cout << b << endl;
  else {
    if (b == 'H') cout << 'D' << endl;
    else cout << 'H' << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    long int n, i, cnt[5]={0}, march=0, ans=0, j, k;
    scanf("%ld", &n);
    char s[n][11];  
    for(i=0;i<n;i++){
        scanf("%s",s[i]);
    }

    for(i=0;i<n;i++){
        if(s[i][0]=='M' && cnt[0]==0){
            cnt[0]++;
            march++;
        }
        else if(s[i][0]=='M') cnt[0]++;
        if(s[i][0]=='A' && cnt[1]==0){
            cnt[1]++;
            march++;
        }
        else if(s[i][0]=='A') cnt[1]++;
        if(s[i][0]=='R' && cnt[2]==0){
            cnt[2]++;
            march++;
        }
        else if(s[i][0]=='R') cnt[2]++;
        if(s[i][0]=='C' && cnt[3]==0){
            cnt[3]++;
            march++;
        }
        else if(s[i][0]=='C') cnt[3]++;
        if(s[i][0]=='H' && cnt[4]==0){
            cnt[4]++;
            march++;
        }
        else if(s[i][0]=='H') cnt[4]++;
    }

    for(i=0;i<5;i++){
        for(j=i+1;j<5;j++){
            for(k=j+1;k<5;k++){
                ans=ans+cnt[i]*cnt[j]*cnt[k];
            }
        }
    }

    printf("%ld\n", ans);
    return 0;
}


Measured memory_bytes: 1280
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N]; 
		for(int i=0;i<N;i++)A[i]=sc.nextInt();
		sc.close();
		
		long ans = 0;
		int cnt[] = new int[20];
		
		int r = 0;
		for(int l=0;l<N;l++) {
			if(l>r) {
				r++;
				int a = A[r];
				for(int i=0;i<20;i++) {
					if((a>>i&1)==1)cnt[i]++;
				}
			}

			
			while(r<N&&check(add(cnt,A[r]))) {
				cnt = add(cnt,A[r]);
				r++;
			}
			ans +=(r-l);
			
 			for(int i=0;i<20;i++) {
				cnt[i]-=(A[l]>>i&1);
			}
		}
		System.out.println(ans);
		
	}
	
	static boolean check(int cnt[]) {
		for(int t:cnt) {
			if(t>=2)return false;
		}
		return true;
	}
	
	static int[] add(int cnt[], int a) {
		int tmp[] = cnt.clone();
		for(int i=0;i<20;i++) {
			if((a>>i&1)==1)tmp[i]++;
		}
		return tmp;
	}
}


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

inline int64_t ceiling_div(int64_t a, int64_t b){ // ceiling(a/b)= floor((a+b-1)/b)
  return (a+b-1)/b;
}

int main(){
  const int Ndata= 5;
  vector<int> data(Ndata);

  for(int i=0; i<Ndata; i++){
    cin >> data.at(i);
  }

  int ans= INT_MAX;
  for(int last=0; last<Ndata; last++){
    int time= data.at(last);
    for(int i=0; i<Ndata; i++){
      if(i!=last){ time+= 10*ceiling_div(data.at(i), 10); }
    }

    ans= min(ans, time);
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    int w,h,n;
    cin>>w>>h>>n;
    int x[n];
    int y[n];
    int a[n];
    int b1=0,b2=w,b3=0,b4=h;
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i]>>a[i];
        if(a[i]==1){
            b1=max(b1,x[i]);
        }
        else if(a[i]==2){
            b2=min(b2,x[i]);
        }
        else if(a[i]==3){
            b3=max(b3,y[i]);
        }
        else{
            b4=min(b4,y[i]);
        }
    }
    if(b2-b1<0||b4-b3<0){
        cout<<0<<endl;
    }
    else{
        cout<<(b2-b1)*(b4-b3)<<endl;
    }
}


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

const int INF = 1001001001;

int di[] = { 0, 0, 1,-1};
int dj[] = { 1,-1, 0, 0};

int main(){
  
  int h,w;
  cin >> h >> w;
  
  vector<string> map(h);
  rep(i,h) cin >> map[i];
  
  queue<P> q;
  q.emplace(0,0);
  
  int dist[h][w];
  rep(i,h) rep(j,w) dist[i][j] = INF;
  dist[0][0] = 1;
  
  while(!q.empty()){
    int i = q.front().first;
    int j = q.front().second; q.pop();
    rep(dir,4){
      int ni = i + di[dir];
      int nj = j + dj[dir];
      if(ni<0||nj<0||ni>=h||nj>=w) continue;
      if(map[ni][nj] == '#') continue;
      if(dist[ni][nj] != INF) continue;
      dist[ni][nj] = dist[i][j] + 1;
      q.emplace(ni,nj);
    }
  }
  
  if(dist[h-1][w-1] == INF){ cout << -1 << endl; return 0;}
  
  int num = 0;
  rep(i,h) rep(j,w) if(map[i][j] == '#') num++;
      
  int ans = h*w - num - dist[h-1][w-1];
  cout << ans << endl;
  return 0;
}
    
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll ans = 0;
    ll t = n-1;
    int i = 0;
    while(t > 0){
        if(i == 0){
            ans += a[i];
            t--;
            i++;
            continue;
        }
        rep(j,2){
            ans += a[i];
            t--;
            if(t <= 0) break;
        }
        i++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4800
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;


ll P = 998244353;
ll mpow(ll a, ll b, ll p = -1){
  ll ret = 1, num = a;
  if(p==-1){
    while(b>0){
      if(b%2) ret *= num;
      num = num * num;
      b /= 2;
    }
  }else{
    while(b>0){
      if(b%2) ret = (ret*num)%p;
      num = (num*num)%p;
      b /= 2;
    }
  }
  return ret;
}

int main(int argc, char const *argv[]) {
  // 2^n+m-1(全体の半分)
  // 自由度xに対し
  // ans = 2^(n-1+m) - 2^(n-1 + x)
  ll n, m;std::cin >> n >> m;
  ll x = 0;
  vvl dat = VV(n, m, 0, ll);

  for(int i=0;i<n;i++) for(int j=0;j<m;j++) scanf("%lld", &dat[i][j]);

  ll st = 0;
  for(int i=0;i<min(n, m);i++){
    //i列目が1の行を探す
    ll idx = -1;
    for(int j=st;j<n;j++){
      if(dat[j][i]){
        idx = j;
        break;
      }
    }
    if(idx==-1) continue;
    swap(dat[st], dat[idx]);

    //stが今、st+1行目以降掃き出し
    for(int j=st+1;j<n;j++){
      if(!dat[j][i]) continue;
      for(int k=i;k<m;k++) dat[j][k] ^= dat[st][k];
    }
    st++;
  }
  for(int i=0;i<n;i++){
    bool f = true;
    for(int j=0;j<m;j++){
      if(dat[i][j]) {
        f = false;
        break;
      }
    }
    if(!f) x++;
  }
  ll ans = (mpow(2, n-1+m, P) - mpow(2, n-1+m-x, P) +P)%P;
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
fn main() {
    let (a, b) = input();
    println!("{}", solve(a, b));
}

fn input() -> (usize, usize) {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.pop();
    let mut iter = buf.split_whitespace();
    let a: usize = iter.next().unwrap().parse().unwrap();
    let b: usize = iter.next().unwrap().parse().unwrap();
    (a, b)
}

fn solve(a: usize, b: usize) -> i32 {
    for x in 1..1001 {
        let aa = (x * 8) / 100;
        let bb = x / 10;
        if aa == a && bb == b { return x as i32; }
    }
    -1
}

Measured memory_bytes: 4352
S=input()
if S[0]!="h":
    print("No")
    exit()
if len(S)<2:
    print("No")
    exit()
han="i"
for i in range(1,len(S)):
    if S[i]!=han:
        print("No")
        exit()
    if S[i-1]=="h":
        han="h"
    elif S[i-1]=="i":
        han="i"
if S[-1]=="h":
    print("No")
    exit()
print("Yes")

Measured memory_bytes: 3064
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
//int tot=0;
vector<int> res;
int flag[200000+10];
int main(){
	int n;
	int a[200000+10];
	scanf("%d",&n);
	rb(i,1,n) scanf("%d",&a[i]);
	rl(i,n,1){
		int now=i*2;
		int tot=0;
		while(now<=n){
			tot+=flag[now];
			now+=i;
		}
		if(tot&1){
			if(a[i]==0){
				res.PB(i);
				flag[i]=1;
			}
		}
		else{
			if(a[i]==1){
				res.PB(i);
				flag[i]=1;
			}
		}
	}
	cout<<res.size()<<endl;
	rb(i,1,res.size()){
		cout<<res[i-1]<<" ";
	}
	return 0;
}

Measured memory_bytes: 2936
from math import floor


def solve(n, m):
    factor = [1]
    if m % n == 0:
        ans = m // n
    else:
        for f in range(floor(m//n), 1,-1):
            if m % f == 0:
                factor.append(f)
                break
        ans = factor[-1]

    return ans


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve(n, m))


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

char s[400][400];
int ans[400][400];

int main(){
	int h,w,K;cin>>h>>w>>K;
	vector<int>ys;
	map<int,vector<int>>mp;
	rep(i,h){
		scanf("%s",s[i]);
		rep(j,w){
			if(s[i][j]=='#'){
				ys.push_back(i);
				mp[i].push_back(j);
			}
		}
	}
	int cnt=1;
	sort(ys.begin(),ys.end());
	ys.erase(unique(ys.begin(),ys.end()),ys.end());
	rep(i,ys.size()){
		auto v=mp[ys[i]];
		vector<P>vs;
		rep(i,v.size()){
			vs.push_back(P((i==0?0:v[i-1]+1),(i==v.size()-1?w-1:v[i])));
		}
		int y1=(i==0?0:ys[i-1]+1),y2=(i==ys.size()-1?h-1:ys[i]);
		vector<int>ids;
		rep(i,vs.size())ids.push_back(cnt++);
		for(int j=y1;j<=y2;j++){
			int t=0;
			for(auto p:vs){
				for(int k=p.first;k<=p.second;k++)ans[j][k]=ids[t];
				t++;
			}
		}
	}
	rep(i,h){
		rep(j,w)cout<<ans[i][j]<<' ';
		cout<<endl;
	}
}

Measured memory_bytes: 2296
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
  string str,str2;
  cin>>str>>str2;
  int k=0;
  int j=0;
  vector<char> v;
   for(int i=0;i<str.length()+str2.length();i++)
   {      if(i%2==0)
        {
          v.push_back(str[k]);
          k++;
        } 
        else
        {
            v.push_back(str2[j]);
            j++;
        }

   }

   for(auto x:v)
    cout<<x;
    return 0;
}








Measured memory_bytes: 3660
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << '\n'
#define debug_arr(a , n) for(ll i = 0 ; i < n ; i++)cout << a[i] << " "
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vi vector<ll>
#define vll vector<ll> 
#define inf 100000000000
#define mod 1000000007

const ll max_n = 2e5 + 9;

typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a , ll b)
{
    ll prod = 1;
    while(b)
    {
        if(b&1)
        prod = (prod*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return prod;
}
int main()
{
	int n;
  cin >> n;
  map<int , int> m;
  int a[n];
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
    m[a[i]]++;
  }
  
  ll sum = 0;
  for(auto it : m){
    sum += (1ll * it.ss * (it.ss - 1)) / 2;
  }
  
  for(int i = 0 ; i < n ; i++){
    int num = m[a[i]];
    // debug(num);
    ll sum1 = sum;
    if(num > 1){
      sum -= (1ll * num * (num - 1)) / 2;
      sum += (1ll * (num - 2) * (num - 1)) / 2;
    }
    cout << sum << endl;
    sum = sum1;
  }
}


Measured memory_bytes: 8320
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

mod util {
    #[allow(dead_code)]
    pub fn chmin<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x > y && {
            *x = y;
            true
        }
    }

    #[allow(dead_code)]
    pub fn chmax<T>(x: &mut T, y: T) -> bool
    where
        T: PartialOrd + Copy,
    {
        *x < y && {
            *x = y;
            true
        }
    }

    /// 整数除算切り上げ
    #[allow(dead_code)]
    pub fn roundup(a: i64, b: i64) -> i64 {
        (a + b - 1) / b
    }

    #[allow(dead_code)]
    pub fn ctoi(c: char) -> i64 {
        c as i64 - 48
    }
}

#[allow(unused_imports)]
use util::*;

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};

fn main() {
    input! {
        s:String,t:String
    }

    println!("{}{}", t, s);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) ::std::begin(x), ::std::end(x)
using namespace std;

const string YES = "Yes";
const string NO = "No";
bool solve(int64_t D, int64_t T, int64_t S) {
    return T * S >= D ? true : false;
}

// generated by online-judge-template-generator v4.6.0 (https://github.com/kmyk/online-judge-template-generator)
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    constexpr char endl = '\n';
    int64_t D, T, S;
    cin >> D >> T >> S;
    auto ans = solve(D, T, S);
    cout << (ans ? YES : NO) << endl;
    return 0;
}


Measured memory_bytes: 3644
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int h = 0, w = 0, a = 0, b = 0;
    cin >> h >> w >> a >> b;
    if (a == 0) {
        for (int i=0; i<h; i++) {
            if (i < b) {
                for (int j=0; j<w; j++) {
                    cout << 1;
                }
            }
            else {
                for (int j=0; j<w; j++) {
                    cout << 0;
                }
            }
            cout << endl;
        }
    }
    else if (b == 0) {
        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                if (j < a) {
                    cout << 1;
                }
                else {
                    cout << 0;
                }
            }   
            cout << endl;
        }
    }
    else {
        for (int i=0; i<h; i++) {
            if (i < b) {
                for (int j=0; j<w; j++) {
                    if (j < a) {
                        cout << 0;
                    }
                    else {
                        cout << 1;
                    }
                }
            }
            else {
                for (int j=0; j<w; j++) {
                    if (j < a) {
                        cout << 1;
                    }
                    else {
                        cout << 0;
                    }
                }
            }
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main()
{
    int n;
    cin>>n;
    int a[n],dp[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i] = 0;
    }
    dp[1] = abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#
# abc077 c
#
import sys
from io import StringIO
import unittest
import bisect


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
1 5
2 4
3 6"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
1 1 1
2 2 2
3 3 3"""
        output = """27"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """6
3 14 159 2 6 53
58 9 79 323 84 6
2643 383 2 79 50 288"""
        output = """87"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))

    A.sort()
    B.sort()
    C.sort()

    ans = 0
    for b in B:
        an = bisect.bisect_left(A, b)
        cn = N - bisect.bisect_right(C, b)
        ans += an*cn

    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 37116
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner scanner = new Scanner(System.in)) {
            int n = scanner.nextInt();
            int x = scanner.nextInt();
            int t = scanner.nextInt();

            Takoyaki takoyaki = new Takoyaki();
            System.out.println(takoyaki.getTimeOfBake(n, x, t));
        }
    }
}


class Takoyaki {

	int getCountOfBake(int numOfCanBeBakedAtOneTime, int numOfWant) {
		if (numOfWant % numOfCanBeBakedAtOneTime > 0) {
			return (numOfWant / numOfCanBeBakedAtOneTime) + 1;
		}
		return numOfWant / numOfCanBeBakedAtOneTime;
	}

	public int getTimeOfBake(int n, int x, int bakeTimeUnit) {
		int bakeCount = this.getCountOfBake(x, n);
		return bakeTimeUnit * bakeCount;
	}
}

Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using P = pair<int,int>;
void Yes() {
    cout << "Yes" << endl;
}
void No() {
    cout << "No" << endl;
}
int main(void) {
    string s; cin >> s;
    sort(s.begin(), s.end());
    bool ok = false;
    do {
        if(s == "abc") ok = true;
    } while (next_permutation(s.begin(), s.end()));
    if(ok) Yes();
    else No();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n, k;
    cin >> n >> k;
    vector<ll> p(n);
    REP(i, n){ cin >> p.at(i); }
    sort(ALL(p));
    ll ans = 0;
    REP(i, k){ ans += p.at(i); }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# File              : B.py
# Author            : JCHRYS <jchrys@me.com>
# Date              : 19.01.2020
# Last Modified Date: 19.01.2020
# Last Modified By  : JCHRYS <jchrys@me.com>

a, b = map(int, input().split())

arr = []
arr.append(str(a)*b)
arr.append(str(b)*a)
arr.sort()
print(arr[0])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=1000000007;


int main() {
  int n;
  cin >> n;
  if(n%1000==0)
  cout << 0 << endl;
  else
  cout << 1000-(n%1000) << endl;
}


Measured memory_bytes: 3604
#include <iostream>
using namespace std;
int main(){
  int n,a,b;cin>>n>>a>>b;
  int ans = 0;
  for(int i = 0; n > i; i++){
    int c;cin>>c;
    if(!(a <= c && c < b))ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  ll n,k;
  cin >> n >> k;
  vector<ll> a(n),f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];

  sort(a.rbegin(),a.rend());
  sort(f.begin(),f.end());
  ll l = -1LL, r = 1e12;
  while(l+1<r){
    ll x = (l+r)/2;
    bool ok = [&](){
      ll nk = k;
      rep(i,n){
        ll t = a[i]*f[i]-x;
        if(t<=0) continue;

        nk -= (t+f[i]-1)/f[i];
        if(nk<0){
          return false;
        }
      }
      return true;
    }();
    if(ok){
      r = x;
    }else{
      l = x;
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 3328
import java.util.*;
import java.math.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long MOD = 1000000007;

    int[] color = new int[3];
    long out = 1;
    while (N-- > 0){
      int n = sc.nextInt();
      int p = 0;
      for (int i = 0; i < 3; i++) {
        if (color[i] == n) {
          p++;
          if (p == 1) color[i]++;
        }
      }
      out *= p;
      out %= MOD;
    }
    System.out.println(out);
  }
}


Measured memory_bytes: 48944
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%lld\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	string s;
	cin >> s;

	if (s == "Sunny") {
		cout << "Cloudy\n";
	}
	else if (s == "Cloudy") {
		cout << "Rainy\n";
	}
	else {
		cout << "Sunny\n";
	}


	return 0;
}

Measured memory_bytes: 3488
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef pair<int, int> P;
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;
}

const int INF = 1001001001;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = {0, -1, 0, 1};

vector<int> vec;
vector<int> ans_vec;

int main() {
  while (1) {
    int n;
    cin >> n;
    if (n == 0) break;
    vec.push_back(n);
  }

  for (auto&& n : vec) {
    vector<int> dp(n + 1, 0);
    dp[0] = 1;
    dp[1] = 1;

    for (int i = 2; i <= n; i++) {
      dp[i] += dp[i - 1] + dp[i - 2];
      if (i > 2) {
        dp[i] += dp[i - 3];
      }
    }

    int ans = ceil(ceil((double)dp[n] / 10.0) / 365.0);
    ans_vec.push_back(ans);
  }

  for (auto&& i : ans_vec) {
    printf("%d\n", i);
  }
}



Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
string a, b, c;
int main() {

    getline( cin,a );
    b = a;
    reverse( a.begin(),a.end() );
    for( int i = 0; i < a.size(); i ++ ) {

           if( a[i] == 'p' ) {
               a[i] = 'q';
           }
           else if( a[i] == 'q' ) {
               a[i] = 'p';
           }
           else if( a[i] == 'b' ) {
               a[i] = 'd';
           }
           else if( a[i] == 'd' ) {
               a[i] = 'b';
           }
    }
    if( a == b ) {
        cout << "Yes" << endl;
        return 0;
    }
    else {
        cout << "No" << endl;
        return 0; 
    }
    return 0;
}

Measured memory_bytes: 512
/*
 2020/01/26 difficulty 944
 https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;
    int WTcnt=0;
    for(int i=0;i<N;i++){
        if(S[i]=='.'){
            WTcnt++;
        }
    }
    int ans = WTcnt;
    int BK=0;
    int WT=0;
    for(int i=0;i<N;i++){
        if(S[i]=='.'){
            WT++;
        }else{
            BK++;
        }
        ans = min(ans,WTcnt-WT+BK);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.logging.LoggingMXBean;

/**
 * @author wuyue
 *
 */
public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		
//		int nn = (int) Math.sqrt(n);
//		int mm = (int) Math.sqrt(m);
//		int kk = (int) Math.sqrt(k);
//		if (nn + mm < kk) {
//			System.out.println("Yes");
//		} else {
//			System.out.println("No");
//		}
		 
		if (k - m- n>0 && (k-m-n) *(k-m-n) > 4*n*m) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		
		
		
	}

}


Measured memory_bytes: 23252
n, k = list(map(int, input().split()))
mod = 10**9 + 7


# pow(求めたいもの,-1,mod)でpython3.8.2ならできる
a = [1]  # i+1番目までの階乗
b = [1]  # a[i]の逆元

for i in range(1, n+1):
    a.append(i * a[i-1] % mod)
    b.append(pow(a[i], -1, mod))
for i in range(1, k+1):  # ../data_picture
    if n-k < i-1:
        print(0)
    else:
        blue_ball = k-i
        blue_partition = i
        blue_ans = a[blue_ball + blue_partition - 1] * \
            b[blue_ball] % mod * b[blue_partition-1] % mod
        red_ball = n-k-i+1
        red_partition = i+1
        red_ans = a[red_ball + red_partition - 1] * \
            b[red_ball] % mod * b[red_partition-1] % mod
        print((blue_ans * red_ans) % mod)


Measured memory_bytes: 9264
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int w = sc.nextInt();
        int m = sc.nextInt();
        int[][]hc = new int[h][2];
        int[][] wc = new int[w][2];
        for (int i = 0; i < h; i++) {
            hc[i][1] = i;
        }
        for (int i = 0; i < w; i++) {
            wc[i][1] = i;
        }
        Set<Long> set = new HashSet<>();
        for (int i = 0; i < m; i++) {
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            hc[x][0]++; wc[y][0]++;
            set.add(x*1000000L + y);
        }
        Arrays.sort(hc, (x,y) -> y[0] - x[0]);
        Arrays.sort(wc, (x,y) -> y[0] - x[0]);
        int hmax = hc[0][0], wmax = wc[0][0];
        boolean alldup = true;
        for (int i = 0; i < h; i++) {
            if(hc[i][0] < hmax) break;
            for (int j = 0; j < w; j++) {
                if(wc[j][0] < wmax) break;
                long n = hc[i][1] * 1000000L + wc[j][1];
                if(!set.contains(n)){
                    alldup = false;
                    break;
                }
                if(!alldup) break;
            }
        }
        int ans = hmax + wmax - 1;
        if(!alldup) ans++;
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 101584
package main

import (
	"fmt"
	"math"
)

func gcd(a, b int) int {
	for a%b != 0 {
		a, b = b, a%b
	}
	return b
}

func main() {
	var n, x, t, r int
	fmt.Scan(&n, &x)

	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		r = gcd(r, int(math.Abs(float64(t - x))))
	}

	fmt.Println(r)
}

Measured memory_bytes: 5504
H, W = map(int,input().split())
A = [list(map(int,input().split())) for k in range(H)]
t = 0
B = []
for y in range(W):
    for x in range(H):
        if A[x][y] % 2 == 1:
            if x+1<H:
                A[x+1][y] += 1
                A[x][y] -= 1
                B.append([x+1,y+1,x+2,y+1])
            elif y+1<W:
                A[x][y+1] += 1
                A[x][y] -= 1
                B.append([x+1,y+1,x+1,y+2])
            elif x+1<H and y+1<W:
                A[x+1][y+1] += 1
                A[x][y] -= 1
                B.append([x+1,y+1,x+2,y+2])
print(len(B))
for b in B:
    print(" ".join(map(str,b)))

Measured memory_bytes: 30060
#include <bits/stdc++.h>
#include <cstring>
#include <limits>
using namespace std;
#define ll long long int
#define X first
#define Y second
#define fw(i, start, end) for (ll i = start; i < end; ++i)
#define fe(i, start, end) for (ll i = start; i <= end; ++i)
#define L(T)  \
    ll T;     \
    cin >> T; \
    while (T--)
#define FASTIO                   \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);            \
    cout.tie(nullptr);
#define endl "\n"
#define mem(a, i) memset(a, i, sizeof(a))
int main()
{
    FASTIO
   long double n, m;
    cin >> n >> m;
    cout << (ll)((n * m)+.001) << endl;

    return 0;
}


Measured memory_bytes: 3736
n = int(input())
a = list(map(int, input().split()))
indices = [i + 1 for i in range(n)]
result = sorted(zip(a, indices))
ans = "{}".format(result[0][1])
for i in range(n)[1::]:
    ans += " {}".format(result[i][1])
print(ans)


Measured memory_bytes: 19708
n = gets.to_i
as = Array.new(n, 0)
bs = Array.new(n, false)

n.times do |i|
  as[i] = gets.to_i - 1
end

x = 0
c = 1
loop do
  x = as[x]
  break if x == 1
  break if bs[x]
  bs[x] = true
  c += 1
end

p x == 1 ? c : -1


Measured memory_bytes: 3580
using System; using System.Linq;

class A {
	static void Main() {
		var n = Console.ReadLine().Split().Select(int.Parse).ToArray()[0];
		var a = new string[n];
		for(int i = 0;i < n;i++) {
			a[i] = Console.ReadLine();
		}
		Array.Sort(a);
		Console.WriteLine(string.Join("",a));
	}
}

Measured memory_bytes: 3288
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int index = 1;
    int i = 0;
    int ans = 0;
    while (i < n) {
        if (a[i] != index) {
            i++;
            ans++;
        } else {
            i++;
            index++;
        }
    }

    if (ans == n) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }
}


Measured memory_bytes: 1024
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;


int main() {
  int n;
  cin>>n;
  int t[n];
  int a=0,b=0,c=0;
  int x[n];
  int y[n];

for(int i=0;i<n;i++)
{   cin>>t[i]>>x[i]>>y[i];
if((t[i]-a-x[i]-y[i]+b+c)>=0&&(t[i]-a-x[i]-y[i]+b+c)%2==0)
{      a=t[i];
	 b=x[i];
	 c=y[i];
	continue;
}
else
goto label;
}
cout<<"Yes";
goto a;
label: cout<<"No";
a:;
 return 0;
}


Measured memory_bytes: 1408
/*
 * short          2^15-1 ~ 3e4
 * int, long x86  2^31-1 ~ 2e9
 * long long      2^63-1 ~ 9e18
 */
#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a, b) for (int a = 0; a < b; ++a)
using namespace std; typedef long long ll; const int inf = numeric_limits<int>::max(); void print() {cerr << endl;}
template<typename T, typename... Ts> void print(T&&a, Ts&&...etc) {cerr << a << ' '; print(etc...);}
template<typename T, typename U> ostream& operator<<(ostream& s, const pair<T,U>&p) {s << "<" << p.x << ", " << p.y << ">"; return s;} // ver. 2020-02-17
template<typename T> ostream& operator<<(ostream& s, const vector<T>&v) {s << "["; for (auto &x : v) s << x << ", "; if (!v.empty()) s << "\b\b"; s << "]"; return s;}
struct io{io(){ios_base::Init i; ios_base::sync_with_stdio(0); cin.tie(0);}}io;

int main() {
    string s;
    cin >> s;
    if (s.length() % 2 ){
        cout << "No" << endl;
        return 0;
    } else {
        for (int i = 0; i < s.length()/2; ++i) {
            if (s[2*i] != 'h' || s[2*i+1] != 'i') {
        cout << "No" << endl;
            return 0;
            }
        }
    }
        cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
a = [int(input()) for i in range(5)]
time_t = []

def dfs(time,depth,list):
	if(depth == 5):
		time_t.append(time)
	time += (10 - time%10)%10
	for ind,l in enumerate(list):
		new_list = list[0:ind]+list[ind+1:len(list)]
		dfs(time+a[l],depth+1,new_list)

dfs(0,0,[0,1,2,3,4])
print(min(time_t))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int d[n];
  for(int i=0;i<n;i++)cin >> d[i];
  sort(d,d+n);
  cout << d[n/2]-d[(n/2)-1] << endl;
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<long long int,long long int>,null_type,less<pair<long long int,long long int> >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

void go()
{
    ll int x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    ll int moves=abs(x)/d;
    ll int poss=min(k,moves);
    ll int curr_pos=x-poss*d;
    ll int rem=k-poss;
    if(rem > 0 && rem&1)
        cout<<abs(curr_pos-d);
    else
        cout<<abs(curr_pos);
}
int main()
{
    FIO;
//    int t;
//    cin>>t;
//    while(t--)
        go();
    return 0;
}


Measured memory_bytes: 3648
def main():
    n = int(input())
    ans = 0
    for i in range(-200,201):
        if ans:
            break
        else:
            for j in range(-201,200):
                if i**5 - j**5 == n:
                    print(i,j)
                    ans = 1
                    break

if __name__ == '__main__':
    main()

Measured memory_bytes: 64448
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A[100010], B[100010];
    cin >> N;
    rep(i,0,N) cin >> A[i] >> B[i];
    vector<lpair> lp;
    rep(i,0,N) lp.push_back(make_pair(A[i], B[i]));
    sort(lp.begin(), lp.end());
    print(lp[N-1].first + lp[N-1].second);
}

Measured memory_bytes: 3956