akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        long N = scan.nextLong();
        BigInteger answer = BigInteger.ZERO;
        long temp = (long) Math.sqrt(N);
        temp += 10;
        BigInteger x = new BigInteger(Long.toString(temp));
        BigInteger y = BigInteger.ZERO;
        do {
            x = x.subtract(BigInteger.ONE);
            y = (x.add(BigInteger.ONE)).multiply(x);
        }
        while ((new BigInteger(Long.toString(N)).compareTo(y)) < 1);
        for (int i = 1; i < x.longValue()+1; i++) {
            if (N % i != 0) {
                continue;
            }
            answer = answer.add(new BigInteger(Long.toString(N / i - 1)));
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 22996
def solve
  n = gets.to_i
  x = gets.split.map!(&:to_i)
  sorted_x = x.sort
  min_x = sorted_x[0]
  max_x = sorted_x[n - 1]
  min_ans = 1000000000
  (min_x..max_x).each do |i|
    sum_x = 0
    x.each do |j|
      sum_x += (j - i)**2
    end
    min_ans = sum_x if min_ans > sum_x
  end

  print min_ans
end
solve


Measured memory_bytes: 1788
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String S = scanner.nextLine();
        String T = scanner.nextLine();
        if (T.length() - S.length() != 1) {
            System.out.println("No");
        } else {
            boolean flag = false;
            for (int i = 0; i < S.length(); i++) {
                if (S.charAt(i) != T.charAt(i)) {
                    flag = true;
                    System.out.println("No");
                    break;
                }
            }
            if (!flag) {
                System.out.println("Yes");
            }
        }
    }
}

Measured memory_bytes: 26976
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <utility>
#include <climits>
#include <iomanip>
using namespace std;
#define MAXSIZE 100005
#define MAXL 100
typedef long long int lli;

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

    int array[3 * n];
    for (int i = 0; i < 3 * n; i++){
        cin >> array[i];
    }
    sort(array, array + 3 * n, greater<int>());

    lli ans = 0, cnt = 0;
    for(int i = 1; cnt < n; i += 2){
        ans += array[i];
        cnt++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 0x3f3f3f3f;
ll a,b,c;
int main() 
{
    cin>>a>>b>>c;
    if(a%2==0||b%2==0||c%2==0) {
        cout<<0;
        return 0;
    }
    cout<<min(min(a*b,a*c),b*c);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i=0, i##_len=(n); i<i##_len; ++i)
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
using ll = long long;
using namespace std;

int main()
{
    int N, H, W;
    cin >> N >> H >> W;

    int ret = (N+1-H)*(N+1-W);
    cout << ret << endl;
    return 0;
}


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

using namespace std;

int main(){
    int n;
    cin >> n;
    vector<string> s;
    vector<int> p, order; 
    for(int i = 0; i < n; i++){
        string ss;
        int pp;
        cin >> ss >> pp;
        s.push_back(ss);
        p.push_back(pp);
    }
    vector<bool> done(n, false);
    for(int i = 1; i <= n; i++){
        int mn = -1;
        for(int j = 0; j < n; j++){
            if(done[j]) continue;
            if(mn == -1) mn = j;
            else if(s[j] < s[mn]) mn = j;
            else if(s[j] == s[mn] && p[j] > p[mn]) mn = j;
        }
        order.push_back(mn + 1);
        done[mn] = true;
    }
    for(int& i: order) cout << i << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        double[] dice = new double[n];
        for(int i = 0; i < n; i++){
            dice[i] = ExpectOfEachDice(sc.nextInt());
        }
        //System.out.println(Arrays.toString(dice));

        double maxExpect = 0;
        double tempExpect = 0;


        for(int i = 0; i < n; i++ ){
            if (i < k){
                maxExpect+=dice[i];
                tempExpect +=dice[i];
                continue;
            }
            tempExpect+=dice[i];
            tempExpect-=dice[i-k];
            maxExpect = Math.max(tempExpect, maxExpect);
            
        }

        System.out.println(maxExpect);
    }

    public static double ExpectOfEachDice(int n){
        if (n%2==1){
            return ((n/2)+1.0);
        }else {
            return ((n/2.0)+0.5);
        }
    }
}

Measured memory_bytes: 81492
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int x,y; cin >> x >> y;
    if(x*2 <= y and x*4 >= y and y%2 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    double gl=0;
    scanf("%d%d",&n,&k);
    double cl=0.5;
    int a[100005];
    memset(a,0,sizeof a);
    int t=1;
    for(int i=1;i<=n;i++)
    {
        while(t<k)
        {
            a[i]++;
            t*=2;
        }
        t=i+1;
        if(i>=k-1)break;
    }
    for(int i=1;i<=n;i++)
    {
        gl+=pow(cl,a[i]);
    }
    printf("%.12lf",gl/n);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    long long t , n,count= 0;
    string s;
    cin>>n;
    vector <int> p(n),q(n);
    for(int i = 0;i<n;i++)
    {
        cin>>p[i];
    }
    for(int i = 0;i<n;i++)
    {
        cin>>q[i];
    }
    vector <int> ans;
    int c = 0;
    vector <int> arr(n);
    for(int i = 0;i<n;i++)
    {
        arr[i] = i+1;
    }
    int x = 0;
    if(p==q)
    {
       ans.push_back(1);
       ans.push_back(1);
    } else{
    while(c<2)
    {
       x++;
       if(arr==p||arr==q)
       {
           ans.push_back(x);
           c++;
       }
       next_permutation(arr.begin(),arr.end());
    } }
    cout<<abs(ans[0] - ans[1]);
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
const int INF = (int)2e9 + 1;
const long long LINF = (long long)9e18 + 1;

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

	int N, max = 0, cnt = 0;
	cin >> N;
	vector<int> sq(N);
	for (auto &v : sq)
	{
		cin >> v;
	}

	for (int i = 1; i < N; i++)
	{
		if (sq[i] <= sq[i - 1])
		{
			cnt++;
			if (cnt > max)
			{
				max = cnt;
			}
		}
		else
		{
			cnt = 0;
		}
	}

	cout << max << endl;

	return 0;
}


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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  *  */

signed main() {
  int a, b, c;
  cin >> a >> b >> c;

  cout << c << " " << a << " " << b << endl;

  return 0;
}





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

long long f1( long long h, long long w, long long y )
{
	long long size[3];

	long long temp = h - y;
	long long a = temp / 2;
	long long b = temp - a;

	if( temp == 0 || a == 0 || b == 0 ) return numeric_limits<long long>::max();

	size[0] = w * y;
	size[1] = w * a;
	size[2] = w * b;

	return max( abs( size[0] - size[1] ), max( abs( size[1] - size[2] ), abs( size[2] - size[0] ) ) );
}

long long f2( long long h, long long w, long long y )
{
	long long size[3];

	long long temp = h - y;
	long long a = w / 2;
	long long b = w - a;

	if( temp == 0 || a == 0 || b == 0 ) return numeric_limits<long long>::max();

	size[0] = w * y;
	size[1] = temp * a;
	size[2] = temp * b;

	return max( abs( size[0] - size[1] ), max( abs( size[1] - size[2] ), abs( size[2] - size[0] ) ) );
}

long long f( long long h, long long w )
{
	long long min_size = numeric_limits<long long>::max();

	for( long long y = 1; y < h; ++y )
	{
	
		min_size = min( min_size, f1( h, w, y ) );
		min_size = min( min_size, f2( h, w, y ) );			
	}
	return min_size;
}

int main()
{

	long long h,w;
	cin >> h >> w;
	cout << min( f(h,w), f(w,h) ) << endl;
	return 0;

}


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

typedef long long int ll;

int main()
{
    ll h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;

    ll ans = 0;
    if(h1 != h2){
        ans = (h2 - h1 - 1) * 60;
        ans += 60 - m1;
        ans += m2;
    }
    else{
        ans = m2 - m1;
    }

    ans -= k;

    cout << ans;


    return 0;
    
}


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

int main() {
    
    
  int N , A , B , C = 0,D;
  cin >> A >> B;
  int a , b , c , d, e;
  N = B-A+1;
  D = A;
    for (int i = 0; i < N; i++) { 
	
      A = D;
        
      a =A%10;
      A = A/10;
      b =A%10;
      A = A/10;
      c =A%10;
      A = A/10;
      d =A%10;
      A = A/10;
      e = A%10;
      
    
	if (a == e && b == d) {
      C ++ ;
    }
      D++ ;
    }

  cout << C << endl;

}
	


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

using namespace std;
using ll = long long;

int init();
int solve();

#define rep(i, a) for (int i = 0; i < (int) (a); i++)
#define reps(i, a, b) for (int i = (int) (a); i < (int) (b); i++)
#define rrep(i, a) for (int i = (int) a-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int) (a)-1; i >= (int) (b); i--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x

#ifdef LOCAL
#define lcout(a) cout << a
#define lcoutln(a) cout << a << endl
#define lcerr(a) cerr << a
#define lcerrln(a) cerr << a << endl
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif
#define MOD 1000000007
#define PI 3.141592653589793238462643383

signed main()
{
	init();
	solve();
}

int N, K;
vector<int> v;

int init()
{
	cin >> N >> K;
	v.resize(N);
	rep(i, N) cin >> v[i];
	sort(all(v));
	return 0;
}

int gcd(int x, int y)
{
	if (x < y) return gcd(y, x);
	if (x % y == 0) return y;
	return gcd(y, x % y);
}

void print(int x)
{
	if (x == 0) cout << "IM";
	cout << "POSSIBLE" << endl;
}

int solve()
{
	rep(i, N) {
		if (v[0] == K) {
			print(1);
			return 0;
		}
	}
	if (N == 1) {
		print(0);
		return 0;
	}
	int g = v[0];
	reps(i, 1, N) {
		g = gcd(g, v[i]);
	}
	print(K % g == 0 && v.back() >= K);
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		
		int n=sc.nextInt();
		int m=sc.nextInt();
		boolean flag=true;
		for(int i=1,j=1,k=0;k<m;i++,j++,k++){
			if(n%2==0 && (n-j)-i<=n/2 && flag==true){
				i++;
				flag=false;
			}
			System.out.println(i+" "+(n-j));
			
		}
		
		

		
	}
	
}


Measured memory_bytes: 54360
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

static immutable PS = [
2,
4,
8,
16,
32,
64,
128,
256,
512,
1024,
2048,
4096,
8192,
16384,
32768,
65536,
131072,
262144,
524288,
1048576,
2097152,
4194304,
8388608,
16777216,
33554432,
67108864,
134217728,
268435456,
536870912,
1073741824,
2147483648
];

int[long] MEMO;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);
    sort(AS);
    foreach (a; AS) {
        if (a in MEMO) {
            ++MEMO[a];
        } else {
            MEMO[a] = 1;
        }
    }

    int cnt;
    foreach_reverse (a; AS) {
        if (!MEMO[a]) continue;
        --MEMO[a];
        foreach (p; PS) {
            auto b = p - a;
            if (b < 0 || b > a) continue;
            if (b in MEMO && MEMO[b]) {
                --MEMO[b];
                ++cnt;
            }
        }
    }

    writeln(cnt);
}

Measured memory_bytes: 25072
from collections import defaultdict

def main():
    N = int(input())
    s = defaultdict(int)
    ans = 0
    for i in range(N):
        a = "".join(sorted(input()))
        s[a] += 1
        if s[a] != 1:
            ans += (s[a]-1)
    print(ans)

if __name__ == '__main__':
    main()

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

const int maxe = 2e5+5;

ll t=1, n, x, k;
ll arr[maxe];
ll dp[maxe];
void solve(){
	cin >> n;
	for(int i = 1; i<=n; i++){
		cin >> arr[i];
	}
	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	
	for(int i = 3; i<=n; i++){
		dp[i] = min(dp[i-1]+abs(arr[i]-arr[i-1]), dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	
	cout << dp[n];
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	while(t--){
		solve();
	}
    return 0;
}


Measured memory_bytes: 5220
#pragma warning(disable:4996)
#include <stdio.h>

int main() {
	int n, x;
	int L[150];

	scanf("%d %d", &n, &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &L[i]);
	}

	int answer = 0;
	int a = 0;
	for (int i = 0; i < n+1; i++) {
		if (a <= x) {
			answer++;
			a += L[i];
		}
		else {
			break;
		}
	}
	printf("%d\n", answer);
}

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

int main(){
	int n; // n <= 100
	cin >> n;
	for(int z = 0; z < n; z++){//zセット入る
		int day = 1;
		int y,m,d;//year,month,day
		cin >> y >> m >> d;//input

		if(m%2 == 1 || y%3 == 0){
			day += 20 - d;
		}else{
			day += 19 - d;
		}//dayのずれを埋めた
		for(int i = m+1; i <= 10; i++){
			if(i % 2 == 1 || y%3 == 0){
				day += 20;
			}else{
				day += 19;
			}
		}//monthのずれを埋めた
		for(int i = y+1; i < 1000; i++){
			if(i%3 == 0){
				day += 200;
			}else{
				day += 195;
			}
		}	//生まれ年以外の年の日
		//できたー
		cout << day << endl;
	}
	return 0;
}

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

#define REP(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define REPS(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define RREP(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define RREPS(i, n) for (int i = ((int)(n)); i > 0; i--)
#define IREP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define IREPS(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RVISORT(v) sort(v.begin(), v.end(), greater<int>());
#define ALL(v) v.begin(), v.end()
#define MP(n, m) make_pair(n, m);

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using ll = long long;
using ul = unsigned long;

typedef long long ll;

template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

const int mod=1e9+7;

void printv(VI& v){
  REP(i,v.size()) cout << v[i] << " ";
  cout << endl;
}

int vtotal(VI& v){
  int total=0;
  REP(i,v.size()) total+=v[i];
  return total;
}

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

  // string n;
	// getline(cin,n);

  int a,b;
  cin>>a>>b;

  if((a+b)%2!=0){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
  }
  int ans=(a+b)/2;

  cout<<ans<<endl;

  // cout<<std::setprecision(10)<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIII pair< int, pair<int,int> >
const int MaxN = 1e5+5;
vector<int> g[MaxN];
int dp[MaxN];
int N;

int dfs(int node){

    auto &ret = dp[node];
    if(ret!=-1) return ret;
    ret = 0;
    for(auto i: g[node])
        ret = max( ret, dfs(i)+1 );
    return ret;
}

void read(){

    int i,edge;
    memset(dp,-1,sizeof dp);
    cin>>N>>edge;
    for(i=0; i<edge; i++){
        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
    }
}

void solve(){

    read();
    int res = 0;
    for(int i=1; i<=N; i++){
        res = max( res, dfs(i) );
    }

    cout<< res << "\n";
}

int main(){

    //freopen("input.txt","r",stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}


Measured memory_bytes: 11480
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include<iostream>

using namespace std;

int main(){

   string a,b,c;
   cin >> a >> b >> c;

   if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]){
      cout << "YES" << endl;
   }else{
      cout << "NO" << endl;
   }

}

Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int Max(int(a), int(b), int(c)) {
	return max(max(a, b), c);
}
int Min(int(a), int(b), int(c)) {
	return min(min(a, b), c);
}

int gcd(ll(a), ll(b)) {
	ll c = a;
	while (a % b != 0) {
		c = a % b;
		a = b;
		b = c;
	}
	return b;
}



int main() {
	ll N,an=0,m=99;
	
	vector<ll> vec(5);
	for (int i = 0; i < 5; i++) {
		cin >> vec.at(i);
		an += ((vec.at(i)-1)/10)*10+10;
		m = min((vec.at(i) - 1) % 10, m);
	}
	


	cout << an-(9-m) << endl;

	
}

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

int main()
{
    int n; cin >> n;
    set<ll> a;
    ll tmp;
    rep(i,n) {
        cin >> tmp;
        a.insert(tmp);
    } 

    if(a.size() == n) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 12976
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)

    val n = sc.nextInt()
    val a = Array(n) { 0L }
    val b = Array(n) { 0L }
    var ans = 0L

    for (i in 0 until n) {
        a[i] = sc.nextLong()
        b[i] = sc.nextLong()
    }

    for (i in n - 1 downTo 0) {
        a[i] += ans
        if (a[i] % b[i] != 0L) {
            ans += Math.abs(a[i] % b[i] - b[i])
        }
    }
    println(ans)
}


Measured memory_bytes: 80456
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int w = sc.nextInt();
    int n = sc.nextInt();
    int[] values = new int[w];
    for(int i=0;i<values.length;i++){
      values[i]=i+1;
    }
    for(int i=0;i<n;i++){
      String str = sc.next();
      String[] ab = str.split(",");
      int a = Integer.parseInt(ab[0]) - 1;
      int b = Integer.parseInt(ab[1]) - 1;
      int work;
      work = values[a];
      values[a] = values[b];
      values[b] = work;
    }
    for(int i=0;i<values.length;i++){
      System.out.println(values[i]);
    }
  }
}

Measured memory_bytes: 26140
/*
    handle - pruvi007
    questionName - 
    Contest - 
    Topic - 
    Platform - 
*/
#include<bits/stdc++.h>
using namespace std;
#define ll          long long int
#define fast         ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define INF          1e18
#define MOD          1000000007
#define Vi           vector<ll> 
#define Vs           vector<string>
#define VI           vector<vector<ll> >
#define PII          pair<ll,ll> 
#define PSI          pair<string,ll>
#define PB           push_back


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

int main()
{
    fast;
    int k;
    cin >> k;
    string s = "ACL";
    for(int i=1;i<k;i++)
    	s = s + "ACL";
    cout << s << '\n';
}

Measured memory_bytes: 3640
#include<stdio.h>

#define SIZE 200000

int main(void)
{
  long long int N,D;
  long long int x,y;
  long long int dd,cd;
  int ans = 0,i;

  scanf("%lld %lld",&N,&D);

  cd = D * D;
  for (i = 0; i < N; i++)
  {
    scanf("%lld %lld",&x,&y);
    dd = (x * x) +(y * y);
    if(dd <= cd) ans++;
  }

  printf("%d\n",ans);

  return 0;
}

Measured memory_bytes: 1732
n = input()
if n[-1] == "2" or n[-1] == "4" or n[-1] == "5" or n[-1] == "7" or n[-1] == "9" :
    print("hon")
elif n[-1] == "0" or n[-1] == "1" or n[-1] == "6" or n[-1] == "8" :
    print("pon")
else:
    print("bon")


Measured memory_bytes: 9108
#include <iostream>
#include <cmath>

using namespace std;


int main(){
    int n;
    cin >> n;
    int a[200000];
    int minid[200000];
    int total=-1000000000;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(i==0)continue;
        if (a[minid[i-1]]>a[i]){
            minid[i]=i;
        }else{
            minid[i]=minid[i-1];
        }
        total=max(total,a[i]-a[minid[i-1]]);
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 4664
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))
#define DEBUGM(d,n,m,i,j) printf("DEBUGM :\n"); rep(i,n){ rep(j,m) if(inf==d[i][j]) printf("inf "); else printf("%d ", d[i][j]); printf("\n");} printf("DEBUGM END LINE\n")

typedef vector<vector<pair<int,int> > > graph;
typedef long long ll;

const ll INF =1LL << 62;
const int inf =1 << 29;

double dp[40005];
double v[105],t[105];

bool check(double tm,int tmz,double val, int n){
    // tm にはその時間帯で左から秒目かが入っている。    
    double gap = (double)t[tmz] - tm;
    if(val > v[tmz]) return false;
    double sum=0;
    while(tmz <= n){
        if(val - (gap+sum) > v[tmz+1]) return false;
        if(val - (gap+sum) < 0) break;
        sum += t[tmz+1];
        tmz++;
    }
    return true;
}

int main(){
    int n;
    cin >> n;
    int sum = 0;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n){
        if(p[i]==i+1){sum++; i++;}
    }
    cout << sum << endl;
    return 0;
}

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

#define M 2000

bool ab[100000], ac[100000], bc[100000];

bool match(char c1, char c2) {
    return (c1 == '?' || c2 == '?' || c1 == c2);
}

int main() {
    int i, j;
    string a, b, c;
    cin >> a >> b >> c;

    int A = a.length();
    int B = b.length();
    int C = c.length();

    for (int i = 0; i < A; i++) {
        for (int j = 0; j < B; j++) {
            if (!match(a[i], b[j])) {
                ab[i-j+50000] = true;
            }
        }
    }

    for (int i = 0; i < A; i++) {
        for (int j = 0; j < C; j++) {
            if (!match(a[i], c[j])) {
                ac[i-j+50000] = true;
            }
        }
    }

    for (int i = 0; i < B; i++) {
        for (int j = 0; j < C; j++) {
            if (!match(b[i], c[j])) {
                bc[i-j+50000] = true;
            }
        }
    }

    int ans = 3 * M;
    for (int i = -2*M; i <= 2*M; i++) {
        for (int j = -2*M; j <= 2*M; j++) {
            if (!ab[i+50000] && !ac[j+50000] && !bc[j-i+50000]) {
                int L = min(0, min(i, j));
                int R = max(A, max(B+i, C+j));
                ans = min(ans, R-L);
            }
        }
    }

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

Measured memory_bytes: 256
N = int(input())

A = list(map(int,input().split()))

dic = {}
ans = 0

for j in range(N):

    now = A[j] - (j+1)

    if now in dic:
        ans += dic[now]

    pl = -1 * A[j] - (j+1)

    if pl not in dic:
        dic[pl] = 1
    else:
        dic[pl] += 1

print (ans)


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)

bool flg[10];
int N,K;

bool check(int x){
    while(x){
        if (flg[x%10]){
            return false;
        }
        x/=10;
    }
    return true;
}

int main(){
    cin>>N>>K;
    REP(i,K){
        int D;
        cin>>D;
        flg[D]=true;
    }
    while(1){
        if (check(N)){
            printf("%d\n",N);
            break;
        }
        N++;
    }
    return 0;
}

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

int a[4][4];
int main() 
{
	for (int i = 1; i <= 3; i++) 
	{
		for (int j = 1; j <= 3; j++) 
		{
			cin >> a[i][j];
		}
	}
	int flag = 1;
	for (int k = -1000; k <= 1000; k++) 
	{
		int a2, a3, b1, b2, b3;
		int a1 = k;
		b1 = a[1][1] - k;
		b2 = a[1][2] - k;
		b3 = a[1][3] - k;
		a2 = a[2][1] - b1;
		a3 = a[3][1] - b1;
		if (a[2][2] != a2 + b2) flag = 0;
		if (a[2][3] != a2 + b3) flag = 0;
		if (a[3][2] != a3 + b2) flag = 0;
		if (a[3][3] != a3 + b3) flag = 0;
		if (flag) 
		{ 
			break;
		}
	}
	if(flag)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	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;
using ll = long long int;
using vec = vector<int>;
using P = pair<int,int>;
const int INF = 1e9+7;

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

  cout << s[0] << s[1] << s[2] << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


bool solve(){
	
	string s;
	while(getline(cin,s)){
		string str[26];
		int num;
		for(int i=0;i<26;i++){
			str[i] = s;
			for(int j=0;j<str[i].size();j++){
				for(int k=0;k<i;k++){
					if(str[i][j]=='.' || str[i][j]==' '){
						continue;
					}
					if(str[i][j] == 'a'){
						str[i][j] = 'z';
						continue;
					}
					str[i][j]--; 
				}
			}
			
			for(int j=0;j<str[i].size();j++){
				string str_temp, str_temp2;	
				if(j+3 <= str[i].size()){
					str_temp  = str[i].substr(j,3);
				}
				if(j+4 <= str[i].size()){
					str_temp2 = str[i].substr(j,4);
				}
				if(str_temp=="the" || str_temp2=="this" || str_temp2=="that"){
					num = i;
				}
			}
		}
		
		
		cout<< str[num]<< endl;
	}		
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

 

Measured memory_bytes: 1192
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

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

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))


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

    int n;
    cin >> n;

    set<int> s;
    rep (i, n)
    {
        int d;
        cin >> d;
        s.insert(d);
    }

    cout << s.size() << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define debug
#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 510;

int h, w;
char mat[MAXN][MAXN];

int a[MAXN][MAXN];
int b[MAXN][MAXN];

int main(void) {
  scanf("%d %d",&h,&w);
  REP(i, h) scanf("%s",mat[i]);

  REP(r, h) a[r][0] = 1;
  REP(c, w - 1) a[h-1][c] = 1;
  FOR(r, 1, h) a[r][w-2] = 1;

  for (int r = 1; r < h; r += 2)
    for (int c = 2; c < w - 1; ++c)
      a[r][c] = 1;

  REP(r, h) REP(c, w) b[r][c] = a[r][c] ^ 1;
  REP(r, h) REP(c, w)
    if (mat[r][c] == '#')
      a[r][c] = b[r][c] = 1;
  
  REP(r, h) {
    REP(c, w)
      printf(a[r][c] ? "#" : ".");
    printf("\n");
  }
  printf("\n");
  REP(r, h) {
    REP(c, w)
      printf(b[r][c] ? "#" : ".");
    printf("\n");
  }

  REP(r, h) {
    REP(c, w) debug("%d",a[r][c] & b[r][c]);
    debug("\n");
  }
  
  return 0;
}


Measured memory_bytes: 2944
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(){
	bool prime[1 << 14 + 1] = { 0 };
	FOR(i, 0, 1 << 14 + 1) {
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	for(int i=0;i*i<1 << 14 + 1;i++) {
		if (prime[i]) {
			for(int j = i+i; j < 1<<14 + 1; j+=i) {
				prime[j] = false;
			}
		}
	}

	int n;
	while(cin >> n, n) {
		int cnt = 0;
		FOR(i, 2, n/2+1) {
			if(prime[i] && prime[n - i]) {
				++cnt;
			}
		}
		cout << cnt << endl;
	}
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;
const ll mod = 1000000007;

int main() {
 string S;
  in(S);
  ll K;
  in(K);
  ll N =  sz(S);
  ll a=-100;
  rep(i,N){
   if(S[i]!='1'){
     a=i;
     break; 
   }
   }
  if(a<0) out(1);
 else if(K<=a) out(1);
  else out(S[a]);
}	

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

int main(){
  int H, W;
    while(1){
      cin >> H >> W;       
      if ( H == 0 && W == 0 ) break;
        
        for ( int i = 0; i < H; i++ ){
            for ( int j = 0; j < W; j++ ){
              cout << "#";
            }
            cout << "\n";
        }
        cout << endl;
    }
    
     return 0;
}

Measured memory_bytes: 1152
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    X = [int(x) for x in input().split()]
    Xsub = sorted(X)
    midl, midr = Xsub[(N - 1) // 2], Xsub[N // 2]
    ans = [0] * N
    for i, x in enumerate(X):
        if x <= midl: ans[i] = midr
        else: ans[i] = midl
    print(*ans, sep="\n")

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 25572
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
typedef pair <int, int> pii;
typedef long long cc;
const int N = 200005, oo = 1000 * 1000 * 1000;
int a[N], n;
int gt[N], revgt[N];
const int md = oo + 7;

int Pow(int a, int b) {
    if (b == 0) return 1;
    if (b == 1) return a;
    int tmp = Pow(a, b >> 1);
    if (b % 2) {
        tmp = (1ll * tmp * tmp) % md;
        return (1ll * tmp * a) % md;
    }
    return (1ll * tmp * tmp) % md;
}
bool app[N];
int nCk(int nn, int k) {
    int ans = 1;
    ans = (1ll * gt[nn] * revgt[k]) % md;
    ans = (1ll * ans * revgt[nn - k]) % md;
    return ans;
}
int main() {
    //freopen("input.inp", "r", stdin);
    ios_base :: sync_with_stdio(false); cin.tie(0);
    cin >> n;
    for (int i = 1; i <= n + 1; i++) cin >> a[i];
    gt[0] = 1;
    gt[1] = 1;
    for (int i = 2; i <= n + 1; i++) gt[i] = (1ll * gt[i - 1] * i) % md;
    for (int i = 0; i <= n + 1; i++) revgt[i] = Pow(gt[i], md - 2);
    int sl = 0;
    int trung = -1;
    for (int i = 1; i <= n + 1; i++) {
        if (app[a[i]]) {
            sl = n + 1 - i + 1;
            trung = a[i];
            break;
        }
        app[a[i]] = true;
    }
    for (int i = 1; i <= n; i++) if (a[i] != trung) sl++; else break;
    cout << n << "\n";
    for (int k = 2; k <n + 1; k++) {
        int res = nCk(n + 1, k);
        int res2 = 0;
        if (k <= sl) {
            int res2 = nCk(sl - 1, k- 1);
            res -= res2;
            if (res < 0) res += md;
        }
        cout << res << "\n";
    }
    cout << 1;
    return 0;
}


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


int main() {
  int a=1;
  int N,K;
  cin>>N>>K;
  for(int i=0;i<N;i++){
    if(a<=K){
      a*=2;
    }else if(a>K){
      a+=K;
    }
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int T[3][6];
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 6; j++) {
      cin >> T[i][j];
    }
  }

  int t[3][3];
  for (int i = 0; i < 3; i++) {
    T[i][1] += T[i][0] * 60, T[i][4] += T[i][3] * 60;
    T[i][2] += T[i][1] * 60, T[i][5] += T[i][4] * 60;
    t[i][2] = T[i][5] - T[i][2];
    t[i][1] = t[i][2] / 60;
    t[i][2] %= 60;
    t[i][0] = t[i][1] / 60;
    t[i][1] %= 60;
  }

  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      if (j == 2) {
        cout << t[i][j] << endl;
      } else {
        cout << t[i][j] << " ";
      }
    }
  }

  return 0;
}


Measured memory_bytes: 3096
#include<iostream>
using namespace std;
int main(int argc, char *argv[])
{
  int l, a, b, c, d;
  cin >> l >> a >> b >> c >> d;
  int x = (a + c - 1) / c;
  int y = (b + d - 1) / d;
  int z = max(x, y);
  cout << max(l - z, 0) << endl;
  return 0;
}

Measured memory_bytes: 3044
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long int n,m,daikin=0;
  cin >> n >> m;
  long long int b[n],c[n];
  vector<pair<long long int,long long int>> a(n);
  for(int i=0;i<n;i++){
    cin >>b[i]>>c[i];
    a[i]=make_pair(b[i],c[i]);
  }
  sort(a.begin(),a.end());
  for(int i=0;i<n;i++){
    if(m-a[i].second>=0){
      m-=a[i].second;
      daikin+=a[i].first*a[i].second;
    }
    else{
      daikin+=a[i].first*m;
      m=0;
      break;
    }
  }
  
  cout << daikin <<endl;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

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

    vector<ll> c(k);
    for(int i=1; i<=n; ++i) ++c[i%k];

    ll ans = 0;
    rep(i,k){
        int r = (k-i)%k;
        if(i==r){
            ans += c[i];
            ans += (c[i]*(c[i]-1))*3;
            ans += (c[i]*(c[i]-1)*(c[i]-2))/6*6;
        }
        else{
            if((2*r)%k == 0) ans += c[i]*3*(c[r] + (c[r]*(c[r]-1))/2*2);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
from sys import stdin

s_in = lambda: stdin.readline()[:-1]  # s = s_in()


ALPHABET = [i for i in range(ord('a'), ord('z') + 1)]
S = s_in()

if len(S) < len(ALPHABET):
    list_s = list(S)
    for a in ALPHABET:
        if chr(a) not in list_s:
            S += chr(a)
            break
    print(S)
else:
    reversed_s = list(S)[::-1]
    last_s = reversed_s[0]
    cand = [ord(last_s)]
    ans = ''
    for i in range(len(reversed_s[1:])):
        s = reversed_s[i + 1]
        if ord(s) > ord(last_s):
            last_s = s
            cand.append(ord(last_s))
        else:
            min_s = float('inf')
            for c in cand:
                if c > ord(s):
                    min_s = min(min_s, c)
            if (i + 2) == len(reversed_s):
                ans = chr(min_s)
            else:
                ans += ''.join(reversed_s[i + 2:][::-1]) + chr(min_s)
            break
    if ans == '':
        print(-1)
    else:
        print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF=1e18,MOD=1e9+7;
int main(){
	int n;
	ll mini=INF,p=INF;
	cin>>n;
	vector<ll>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
		if(p>a[i]){
			mini=p;
			p=a[i];
		}
		else if(mini>a[i]){
			mini=a[i];
		}
	}
	for(;mini>0;mini--){
		int cnt=0;
		for(int i=0;i<n;i++){
			if(a[i]%mini!=0)cnt++;
			if(cnt>1)break;
		}
		if(cnt<=1){
			cout<<mini<<endl;
			break;
		}
	}
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//
ll ans[105][105];
int main() {
    init();
    ll H, W, N;
    cin >> H >> W >> N;
    vl A(N);
    rep(i, N) cin >> A[i];

    ll ai = 0;
    queue<pair<ll, ll>> q;
    rep(i,H){
        if (i % 2 == 0) 
            rep(j, W) q.emplace(i, j);
        else
            repr(j, W) q.emplace(i, j);
    }

    while(!q.empty()){
        ll h, w;
        tie(h, w) = q.front(), q.pop();
        ans[h][w] = ai + 1;
        A[ai]--;

        if (A[ai] == 0) ai++;
    }

    rep(i,H){
        rep(j, W) cout << ans[i][j] << " ";
        cout << endl;
    }
}

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

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    ll g = gcd(a, b);
    return a / g * b;
}

void solve(std::string s)
{
    cout << s.at(0) << s.size() - 2 << s.at(s.size() - 1) << endl;
}

int main()
{
    std::string s;
    std::cin >> s;
    solve(s);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

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

    int amari=N%10;
    string ans="hon";
    if(amari==0 || amari==1 || amari==6 || amari==8) ans="pon";
    else if(amari==3) ans="bon";

    cout<<ans<<endl;
}

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

ll N;

void SFT(ll num,int B,ll &count){
    if(num>N){
        return;
    }
    if(B==0b111){
        count++;
    }
    SFT(num*10+3,B|0b001,count);
    SFT(num*10+5,B|0b010,count);
    SFT(num*10+7,B|0b100,count);
}

int main(){
    cin>>N;
    ll c=0;
    SFT(0,0b000,c);
    cout<<c<<endl;  
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;

fn func(s: &Vec<char>) -> bool {
    let n:usize = s.len() as usize;
    for i in 0..n/2 {
        if s[i] != s[n-i-1] { return false; }
    }
    return true;
}

fn main() {
    let a:i64 = read();
    let b:i64 = read();

    let mut ans:i64 = 0;
    for i in a..b+1 {
        let s = i.to_string();
        //debug!(s);
        if func(&s.chars().collect::<Vec<char>>()) { ans += 1; }
    }
    println!("{}", ans);
}


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

#define ll long long int
#define mem(n) memset(n,0,sizeof(n))
#define LCM(a,b) (a / __gcd(a,b) ) * b
#define gcd(a,b) __gcd(a,b)
#define for0(l,n) for(int l=0;l<n;l++)
#define for1(l,n) for(int l=1;l<=n;l++)
#define bug(n) cout<<">> "<<n<<" <<";
#define pb push_back
#define P1(a) cout<<a<<endl;
#define P2(a,b) cout<<a<<" "<<b<<endl;
#define P3(a,b,c) cout<<a<<" "<<b<<" "<<c<<endl
#define S1(a) cin>>a
#define S2(a,b)cin>>a>>b
#define S3(a,b,c) S2(a,b),S2(c)
#define squerit(n) (ll)n*n
#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)

bool vowel(char a)
{
    a= toupper(a);
    if((a=='A')||(a=='E')||(a=='I')||(a=='O')||(a=='U'))return 1;
    return 0;
}

ll n,m,q,a,b,c,sum=0,cnt=0;
ll arr[1000055];
map<ll,bool>mp;
string str;
int main()
{
    FastRead;

    cin>>a>>b;

    cout<< (((a*b)%2)? "Odd":"Even")<<endl;


}















Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;



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

  int n;

  cin >> n;
  cout << n/3 << endl;

  return 0;
}



Measured memory_bytes: 256
// 世界は変わらない
#include <bits/stdc++.h>
#define int long long int
#define eb emplace_back
#define vi vector <int>
#define pii pair <int, int>
#define ff first
#define ss second

using namespace std;

void solve()
{
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) 
    {
        cin >> a[i];
    }
    sort(a, a + n, greater<>());
    int res = a[0], j = 1;
    n-=2;
    bool f = false;
    while(n > 0) {
        res += a[j] * min((int)2, n);
        j++;
        n -= 2;
    }
    cout << res;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 5216
#include<cstdio>
//#include<algorithm>
using namespace std;

int a,b,c,tyo,hi;

int main(){
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		if(c*c==a*a+b*b) tyo++;
		if(a==b) hi++;
	}
	printf("%d\n%d\n",tyo,hi);

	return 0;
}

Measured memory_bytes: 2696
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt(), w = sc.nextInt();
        ArrayList<String> li = new ArrayList<String>();
        for(int i=0;i<h;i++)li.add(sc.next());
        for(int i=0;i<h;i++){System.out.println(li.get(i)); System.out.println(li.get(i));}
    }
}

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

int main(){
  int n,sort[1111111],cou,tmp;
  while(1){
    cou=0;
    cin >> n;
    if(n == 0) break;
    for(int i=0;i<n;i++){
      cin >> sort[i];
    }
    for(int i=0;i<n;i++){
      for(int j=0;j<n-i-1;j++){
	if(sort[j] > sort[j+1]){
	  swap(sort[j],sort[j+1]);
	  cou++;
	}
      }
    }
    cout << cou << endl;
  }
}

Measured memory_bytes: 1164