akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define COL 5

//ステップ1,2,3を一回実行する関数
int solve_1_time(int ** ban, int H) {
    int i, j, k;
    int score = 0;
    //消滅の過程
    for (i = H - 1; i >= 0; i--) {
        int same_num = 1;
        int max_id = -1;
        int max = 0;
        for (j = 1; j < COL; j++) {
            if (ban[i][j] == ban[i][j-1] && ban[i][j] != 0) {
                same_num++;
                if (same_num > max) {
                    max = same_num;
                    max_id = j;
                }
            } else {
                same_num = 1;
            }
        }
        if (max > 2) score += max * ban[i][max_id];
        if (max > 2) {
            for (k = max_id+1-max; k <= max_id; k++) {
                ban[i][k] = 0;
            }
        }
    }
    //落下の過程
    for (i = H - 2; i >=0; i--) {
        for (j = 0; j < COL; j++) {
            for (k = 1; i + k < H; k++) {
                if (ban[i+k][j] != 0) break;
            }
            if (k > 1) {
                ban[i+k-1][j] = ban[i][j];
                ban[i][j] = 0;
            }
        }
    }
    return score;
}

int main(void) {
    int H;
    int i, j;
    int **ban;
    while (1) {
        scanf("%d", &H);
        if (H == 0) break;
        //盤の読み込み
        ban = (int **)malloc(sizeof(int*) * H);
        for (i = 0; i < H; i++) {
            ban[i] = (int *)malloc(sizeof(int) * COL);
        }
        for (i = 0; i < H; i++) {
            for (j = 0; j < COL; j++) {
                scanf("%d", &ban[i][j]);
            }
        }
        
        int score;
        int tot = 0;
        do {
            score = solve_1_time(ban, H);
            tot += score;
        } while (score != 0);
        
        printf("%d\n", tot);
        
        //free
        for (i = 0; i < H; i++) {
            free(ban[i]);
        }
        free(ban);
    }
    return 0;
}



Measured memory_bytes: 2140
MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  res = 1
  i = k
  j = 1
  while i > 0
    res = res * (n - i + 1)
    res %= MOD
    j *= i
    j %= MOD
    i -= 1
  end
  res *= inv(j)
  res %= MOD
  res
end

def repeated_nCk(n, k)
  # 仕切りのイメージで
  nCk(n + k - 1, n - 1) % MOD
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

s = gets.chomp.split("")
mods = [0]
current = 0
multiples = [1]
224.times { |i| multiples[i + 1] = multiples[i] * 10 }
s.reverse.each_with_index do |n, i|
  current += n.to_i * multiples[i % 224]
  mods << current % 2019
end
puts mods.tally.values.select { |v| v > 1 }.inject(0) { |res, num| res + nCk(num, 2) }


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

int main(){
	string S;
	cin >> S;
	
	bool ok = true;
	
	if(S[0] != 'A'){
		ok = false;
	}
	
	int count = 0;
	
	for (int i = 2; i < S.size() - 1. ; ++i) {
		if (S[i] == 'C'){
			count++;
		}
	}
	
	if(count != 1){
		ok = false;
	}
	
	int count2 = 0;
	
	rep(i,S.size()){
		if ('A' <= S[i] &&  S[i] <= 'Z') count2++;
	}
	
	if (count2 != 2){
		ok = false;
	}
	
	if (ok){
		cout << "AC" << endl;
	}else{
		cout << "WA" << endl;
	}
}




Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int ab = sc.nextInt();
		int bc = sc.nextInt();
		int ca = sc.nextInt();
        
        int result1 = ab + bc;
        int result2 = bc + ca;
        int result3 = ca + ab;

        int min = result1;
        if (min > result2) {
            min = result2;
        }
        if (min > result3) {
            min = result3;
        }
		// 出力
		System.out.println(min);
	}
}

Measured memory_bytes: 22484
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
using I=long long;
#define rep(i,n) for(I i=0;i<n;++i)
int main(){
  I n;
  cin>>n;
  string s;
  cin>>s;
  I ans=0;
  rep(d,n){
    I cnt=0;
    rep(i,n-d){
      if(s[i]==s[i+d]){
        cnt++;
      }else{
        cnt=0;
      }
      ans=max(ans,min(d,cnt));
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 384
import numpy as np

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

ans = 0

def func1(n):
  return n/2

def func2(n):
  return n%2

i = 0
while i == 0:
  
  x = list(map(func2,A))
  
  if sum(x) == 0:
    ans += 1
    A = list(map(func1,A))
  else:
    break

print(ans)




Measured memory_bytes: 27000
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<int,int>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}

int n,k,p[200005],ans=1;
string str;
priority_queue<long long ,vector<long long> > que;
set<int> st;
bool a=0;
int main() {
	cin>>n>>k;
	rep(i,0,n)cin>>p[i];
	rep(i,0,k){
		st.insert(p[i]);
	}
	int c=1;
	bool f=0;
	rep(i,1,n){
		if(p[i-1]>p[i]){
			if(c>=k){
				--ans;
				f=true;
			}
			c=0;
		}
		c++;
	}
	if(c>=k){
		--ans;
		f=true;
	}
	if(f)ans++;

	for(int i=1;i<n-k+1;++i){
		auto itr1=st.begin();
		int it=*itr1;
		st.erase(p[i-1]);
		st.insert(p[i+k-1]);
		auto itr2=st.end();
		itr2--;
		if(it==p[i-1]&&*itr2==p[i+k-1])--ans;
		++ans;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 11776
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[2009][2009],ans[2009];
int f(int x)
{
    return x>0?x:-x;
}
int main()
{
    int n,x,y;
    memset(a,0,sizeof(a));
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1; i<=n; i++)
        for(int j=1; j<i; j++)
        {
            if(j<=x&&i>=y)
                a[i][j]=i-y+x-j+1;
            else if(i<=x||j>=y)
                a[i][j]=i-j;
            else
                a[i][j]=min(i-j,f(y-i)+1+f(j-x));
        }
    for(int i=1; i<=n; i++)
        for(int j=1; j<i; j++)
            ans[a[i][j]]++;
    for(int i=1; i<=n-1; i++)
        printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 16000
#include <algorithm>
#include <iostream>
#include <list>
#include <map> //連想配列
#include <queue>
#include <set> //
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector> //動的配列

using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (b - a == c - b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define itr(a) begin(a), end(a)
#define pb push_back
#define x first
#define y second
#define endl '\n'

#define FAST cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

#ifndef __LOCAL
#define FILES(namein, nameout) freopen(namein, "r", stdin); freopen(nameout, "w", stdout); FAST;
#else
#define FILES(namein, nameout) FAST;
#endif //__LOCAL

using namespace std;
using namespace __gnu_pbds;
using python = void;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef unsigned short uss;
typedef pair<ll, ll> pll;
typedef tree<ll, null_type> ordered_set;

const ll M = 1e9+7;
const ll N = 1e3+11;
const ll N2 = 3e4+228;
constexpr ll inf = 0x3f3f3f3f3f3f3f3f;
ll a[N], b[N], dp[N2];
python solve(){
	FAST;
	ll h, n;
	memset(dp, 0x3f, sizeof(dp));
	cin >> h >> n;
	for(ll i =0;i<n;i++) cin >> a[i] >> b[i];
	dp[0] = 0;
	for(ll i = 0;i<n;i++){
		for(ll j = a[i];j<N2;++j){
			dp[j] = min(dp[j], dp[j-a[i]]+b[i]);
		}
	}
	ll mr = dp[h];
	for(ll i = h+1;i<N2;i++) mr = min(mr, dp[i]);
	cout << mr << '\x0a';
}

signed main(){
	FAST;
	ll q = 1;
	//cin >> q;
	while(q--){
		solve();
	}
}

Measured memory_bytes: 512
#include<stdio.h>
#include<string.h>
int prime(int);
int p[1000001]={};
int main(){
	int n,x,v[30],i,j,o,a;
	while(1){
		memset(p,0,sizeof(p));
		memset(v,0,sizeof(v));
		scanf("%d %d",&n,&x);
		if(n==0&&x==0){
			break;
		}
		for(i=0;i<n;i++){
			scanf("%d",&v[i]);
			p[v[i]]=1;
		}
		for(i=0;i<=x;i++){
			if(p[i]){
				for(j=0;j<n;j++){
					if(i+v[j]<=x){
						p[i+v[j]]=1;
					}
				}
			}
		}
		o=0;
		for(i=x;i>=0;i--){
			if(p[i]){
				if(prime(i)){
					o=1;
					break;
				}
				
			}
		}
		if(o){
			printf("%d\n",i);
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}
int prime(int x){
	int i;
	if(x<2) return 0;
	else if(x==2) return 1;
	if(x%2==0) return 0;
	for(i=3;i*i<=x;i+=2){
		if(x%i==0) return 0;
	}
	return 1;
}

Measured memory_bytes: 6532
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
// #include<C:\Users\J\Desktop\AC\athead.h>
#define showa(v) for(int iii = 0; iii < v.size(); iii++){ cout << v[iii] << " ";} cout << endl;
#define show(iiii) cout << iiii << endl; 
#define shows(iiiii) cout << iiiii << " ";
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <set>
#include <deque>
#include <numeric>
#include<tuple>
#include <utility>
#include <map>
#include <unordered_map>   
#define waru 1000000000+7

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> h(n);
  int prev = 0;
  int res = 0;
  int now = 0;
  rep(i,n){
   //   shows(res)
   //   show(now)
     cin >> h[i];
   //   now = h[i];
   //   prev = h[i-1]
     if(!(prev < h[i])){
        now++;
     }
     else{
        now = 0;
     }
     if(now > res) res = now;
     prev = h[i];
  }
  cout << res;


}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reprev(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;

int main()
{
    int h, w;
    cin >> h >> w;

    vector<vector<char>> arr(h, vector<char>(w, '-'));
    vector<bool> ho(w, true);
    vector<bool> va(h, true);

    rep(i, h)
    {
        string str;
        cin >> str;
        rep(j, w)
        {
            arr.at(i).at(j) = str[j];
        }
    }

    rep(i, h)
    {
        rep(j, w)
        {
            if (arr.at(i).at(j) == '.')
            {
                if (j == (w - 1))
                    va.at(i) = false;
            }
            else
                break;
        }
    }

    rep(j, w)
    {
        rep(i, h)
        {
            if (arr.at(i).at(j) == '.')
            {
                if (i == (h - 1))
                    ho.at(j) = false;
            }
            else
                break;
        }
    }

    rep(i, h)
    {

        if (!va.at(i))
            continue;
        rep(j, w)
        {
            if (ho.at(j))
            {
                cout << arr.at(i).at(j);
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,q,count=0;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> vec(n-1);
    for(int i=0;i<n-1;i++){
        if(s.at(i)=='A'&&s.at(i+1)=='C'){
            count++;
        }
         vec.at(i) = count;
    }
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;
        if(l==1){
            cout << vec.at(r-2) << endl;
        }
        else{
        cout << vec.at(r-2)-vec.at(l-2) << endl;
        }
    }

}

Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
public class Main {
    public static double dp[][] = new double[3005][3005];
    public static double arr[];
    public static double solve(int i , int x){
        if(x == 0) return 1;
        if(i == 0) return 0;

        // System.out.println( i + " " + x);

        if(dp[i][x] > -0.9) return dp[i][x];

        return dp[i][x] = (arr[i-1] * solve(i - 1 , x - 1)) + ((1 - arr[i-1]) * solve(i-1 , x));
    }
    public static void main(String args[]) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();

        arr = new double[n];

        for(int i = 0 ; i < n ; i++){
            arr[i] = s.nextDouble();
        }
        for(int i = 0 ; i < dp.length ; i++){
            for(int j = 0 ; j < dp[0].length ; j++){
                dp[i][j] = -1;
            }
        }

        System.out.println(solve(n , (n+1)/2));
    }
}

Measured memory_bytes: 146844
#include <iostream>
#include <string>
#include <vector>
#include<math.h>
using namespace std;

int gcd(int a, int b)
{
  if (a == 1 || b == 1) {
    return (1);
  }
  if (a%b == 0) {
    return (b);
  } else {
    return(gcd(b, a%b));
  }
}


int main()
{
  int a, b, c;
  int k;
  int ans = 0;
  cin >> k;

  for (a = 1; a <= k; a++) {
    for (b = 1; b <= k; b++) {
      for (c = 1; c <= k; c++) {
        ans += gcd(a, gcd(b, c));
      }
    }
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int max(int a,int b);

int main(void){

	double ulim,sum;
	int i,j,k;
	int count=0;
	double tulim[2];
	
	while(1){
		count=0;
		
		scanf("%lf",&ulim);
		scanf("%lf",&sum);
		
		if(ulim==0&&sum==0){
			break;
		}
		
		tulim[0]=max(ulim,sum/3);
		
		for(i=1;i<tulim[0];i++){
		
			tulim[1]=max((sum-i)/2,ulim);
		
			for(j=i+1;j<tulim[1];j++){
				k=sum-i-j;
				if(k>j && k<=ulim){
					count++;
					/* printf("%d %d %d\n",i,j,k); */
				}
			}
		}
		
		printf("%d\n",count);
		
	}
	
	
	return 0;
}

int max(int a,int b){
	if(a>=b){
		return a;
	}else{
		return b;
	}
}

Measured memory_bytes: 2728
#define _USE_MATH_DEFINES
#include <cmath>
#include <string>
#include <vector>
#include <utility>
#include <iostream>
#include <algorithm>
#include <unordered_map>
#include <numeric>
#include <array>
#include <float.h>
#include <memory>
#include <functional>
#include <iomanip>
#include <queue>
#include <random>
#include <map>
#include <set>
#include <boost/multiprecision/cpp_int.hpp>

#pragma warning(disable:4996)

using namespace std;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> town(n, 0);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    ++town[a - 1], ++town[b - 1];
  }
  for (auto&& v : town) {
    cout << v << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
    int main()
    {
       int a[3],count1=0,count=0;
       for(int i=0;i<3;i++){
        scanf("%d",&a[i]);
        if(a[i]==5){
            count1++;
        }else if(a[i]==7){
        count++;
        }
       }
       if(count1==2&&count==1){
        printf("YES");
       }else {
       printf("NO");
       }

        return 0;
    }


Measured memory_bytes: 1700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

typedef tuple<ll,ll,ll> T;


ll i,j,k;


int main(){
    ll A,B;
    cin>>A>>B;
    ll cnt=0;
    ll tap=1;
    while(tap<B){
        cnt++;
        tap+=A-1;
    }
    cout<<cnt<<endl;
    
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




int main() {
    ll n, m, p, a, b;
    cin >> n >> m >> p >> a >> b;
    
    while(n | m | p | a | b){
        a--;b--;
        vector<double> t(n);
        REP(i, n){
            cin >> t[i];
        }
        
        vector<vector<double>> e;
        e.resize(m);
        REP(i, m){
            e[i].assign(m, 1e6);
            REP(j, m){
                if(i == j){
                    e[i][j] = 0;
                }
            }
        }
        REP(i, p){
            ll x, y;
            double z;
            cin >> x >> y >> z;
            x--;y--;
            e[x][y] = z;
            e[y][x] = z;
        }
        
        vector<vector<double>> dp(m, vector<double>((1 << n), 1e6));
        dp[a][0] = 0;
        /*
        REP(i, m){
            REP(j, 1 << n){
                cout << dp[i][j] << ' ';
            }
            cout << endl;
        }
        */
        for(ll i = 1; i < (1 << n); i++){
            REP(j, m){
                REP(k, m){
                    if(j == k || e[j][k] == 1e6)continue;
                    REP(l, n){
                        if((i >> l) & 1){
                            // cout << dp[j][(i^(1<<l))] << ' ';
                            // cout << e[j][k] << ' ';
                            /*
                            if(e[j][k] == 0){
                                cout << j << ' ' << k << ' ';
                            }
                            */
                            // cout << e[j][k] / t[n - 1 - l] << ' ';
                            dp[k][i] = min(dp[k][i], dp[j][i ^ (1 << l)] + e[j][k] / t[n - 1 - l]);
                        }
                    }
                }
            }
        }
        /*
        REP(i, m){
            REP(j, 1 << n){
                cout << dp[i][j] << ' ';
            }
            cout << endl;
        }
        */
        
        double ans = 1e6;
        REP(i, 1 << n){
            ans = min(ans, dp[b][i]);
        }
        if(ans < 1e6){
            printf("%.3lf\n", ans);
        }
        else{
            cout << "Impossible" << endl;
        }
        
        cin >> n >> m >> p >> a >> b;
    }
}



Measured memory_bytes: 3408
# coding: utf-8

def printA(a, n):
    for i in range(n):
        print(a[i],end="")
        if i < n - 1:
            print(" ", end="")
        else:
            print()

def insertionSort(a, n):
    printA(ai, n)
    for i in range(1,n):
        v = a[i]
        j = i - 1
        while j >= 0 and a[j] > v:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v
        printA(ai, n)

num = int(input().rstrip())
ai = list(map(int,input().rstrip().split()))
insertionSort(ai, num)


Measured memory_bytes: 6324
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define INF 1<<50LL
#define FOR(i,a,b) for(auto i=(a);i<(b);i++)
#define RFOR(i,a,b) for(auto i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;

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

  string t;
  cin >> t;
  
  bool w = false,n = false, e = false, s = false;
  REP(i,t.size()){
    if(t[i] == 'W') w = true;
    if(t[i] == 'E') e = true;
    if(t[i] == 'S') s = true;
    if(t[i] == 'N') n = true;
  }
  
  if(w == e && s == n) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    int a[N];
    int x = 0;
    int cnt[30]; //iビット以下を変更できるaの存在
    fill(cnt, cnt + 30, 0);

    for(int i = 0; i < N; i++){
        cin >> a[i];
        x ^= a[i];

        int ind = 0;
        while(true){
            if(a[i] & (1 << ind)){
                cnt[ind]++;
                break;
            }
            ind++;
        }
    }

    int ans = 0;
    for(int i = 29; i >= 0; i--){
        if(x & (1 << i)){
            if(cnt[i] > 0){
                ans++;
                x = ~x;
            } else {
                ans = -1;
                break;
            }
        }
        else {

        }
    }

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back 
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()
#define Uniq(v) v.erase(unique(All(v)),v.end())
typedef pair<int, int> Pii; 
typedef pair<int, Pii> Pip;
typedef pair<string, int> Psi;
typedef vector<int> Vi;
const int INF = (1<<30);
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

int main()
{
  int n;
  vector<int> v;
  cin >> n;
  Rep(i, n*2) {
    int a; cin >> a;
    v.pb( a );
  }

  sort( All( v ) );
  int ans = 0;
  for(int i=0; i<n*2; i+=2) {
    ans += min(v[i], v[i+1]);
  }

  cout << ans << endl;

}
  

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  string s;
  ll k;
  cin >> s >> k;

  ll n = s.size();
  ll lp = n, rp = n;
  rep(i, n) {
    if (s[0] != s[i]) {
      lp = i;
      break;
    }
  }
  if (lp == n) {
    cout << n*k/2 << endl;
    return 0;
  }

  rep(i, n) {
    if (s[0] != s[n - 1 - i]) {
      rp = i;
      break;
    }
  }
  ll block = 0;
  ll cnt = 0;
  char tmp = '0';
  repLRE(i, lp, n - 1 - rp) {
    if(tmp != s[i]){
      block += cnt / 2;      
      cnt = 1;
      tmp = s[i];
    } else
      cnt++;
  }
  block += cnt / 2;

  ll t1 = lp / 2;
  ll t2 = rp / 2;
  ll t3 = block * k;
  ll t4 = ((lp + rp) / 2) * (k - 1);
  ll ans = t1 + t2 + t3 + t4;

  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 REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
ll cnt = 0;
ll N;

void dfs(ll cur, ll use) {
  if (cur > N) return;
  if (use == 0b111) cnt++;

  dfs(cur * 10 + 7, use | 0b100);
  dfs(cur * 10 + 5, use | 0b010);
  dfs(cur * 10 + 3, use | 0b001);
}

int main() {
  cin >> N;
  dfs(0, 0b000);
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
#D
n = int(input())
#約数の数を求める＞＞倍数であり、n以下であるものの総和を求める

ans = 0
for i in range(1, n + 1):
    #iの倍数の数を求める
    m = n // i
    #初項i:公差i:m項までの等比数列の和
    ans += m * (2 * i + i * (m - 1)) *0.5
print(int(ans))

Measured memory_bytes: 9084
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/













int N, K;
//---------------------------------------------------------------------------------------------------
vector<vector<int>> solve() {
	int ma = K + 3 * N - 1;

	int a = K;
	int b = K + 2 * N - 1;
	int c = b + K;
	if (ma < c) return {};

	set<int> sa, sb, sc;
	vector<vector<int>> ans;
	while (K + N <= b and K + 2 * N <= c) {
		sa.insert(a);
		sb.insert(b);
		sc.insert(c);
		ans.push_back({ a, b, c });
		a++;
		b -= 2;
		c--;
	}

	b = K + 2 * N - 1;
	c = K + 3 * N - 1;
	while (sb.count(b)) b--;
	while (sc.count(c)) c--;
	while (a < K + N and K + N <= b and K + 2 * N <= c) {
		sa.insert(a);
		sb.insert(b);
		sc.insert(c);
		ans.push_back({ a, b, c });
		a++; b--; c--;
		while (sb.count(b)) b--;
		while (sa.count(c)) c--;
	}

	fore(v, ans) if (v[0] + v[1] > v[2]) return {};
	map<int, int> cnt;
	fore(v, ans) {
		rep(i, 0, 3) cnt[v[i]]++;
	}
	rep(i, K, K + 3 * N) if (cnt[i] != 1) return {};

	if (ans.size() == N) return ans;
	return {};
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> K;
	auto ans = solve();
	if (ans.size() == 0) {
		cout << -1 << endl;
		return;
	}
	fore(v, ans) printf("%d %d %d\n", v[0], v[1], v[2]);
}



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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const LL INF = 1e18;

bool dfs(vector<vector<PLL>>& G, int u, VL& dist){
  for(auto& e: G[u]){
	if(dist[e.FF] == INF){
	  dist[e.FF] = dist[u] + e.SS;
	  if(!dfs(G, e.FF, dist))
		return false;
	}
	else if(dist[e.FF] != dist[u] + e.SS)
	  return false;
  }
  return true;
}

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

  int N, M;
  cin >> N >> M;
  vector<vector<PLL>> G(N);
  REP(i,M){
	int l, r, d;
	cin >> l >> r >> d;
	--l;
	--r;
	G[l].EB(r,d);
	G[r].EB(l,-d);
  }

  VL dist(N, INF);
  bool ok = true;
  REP(i,N){
	if(dist[i] != INF) continue;
	dist[i] = 0;
	ok = ok && dfs(G, i, dist);
  }

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

  return 0;
}


Measured memory_bytes: 17408
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <iomanip>
#include <queue>
#include <list>

using namespace std;

typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
const int inf = 1ULL << 31 - 1;
const ll linf = 1ULL << 63 - 1;
const string nilstr("");

char encode(char c) {
    return c >= 'A' && c <= 'Z' ? c - 'A' : c - 'a' + (char) 26;
}

char decode(char i) {
    return i < 26 ? i + 'A' : i - (char) 26 + 'a';
}

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    string s1, s2;
    cin >> s1 >> s2;
    int n = s1.size();
    for (int i = 0; i < n; i++) {
        char x = s2.back();
        for (int j = n - 1; j > 0; j--) {
            s2[j] = s2[j - 1];
        }
        s2[0] = x;
        if (s1 == s2) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys

#S = input()
#N = int(input())
#n = [list(map(int,input().split())) for i in range(N)]
#n, y = map(int, input().split())

n = list(map(int,input().split())) 
#print(n)

for i in range(5):
    if (n[i] == 0):
        print(i+1)







Measured memory_bytes: 9152
#include<stdio.h>
int main(){
    int a, b, i;
    long long int c, l, c7;
    scanf("%d %d %lld", &a, &b, &c);
    c7 = 7*a + b;
    if(c > c7){
        l = (c / c7) * 7;
        c = (c % c7);
        for(i=0;i<7 && c>0;i++){
            c-=a;
            if(i == 6) c-=b;
            l++;
        }
        printf("%lld\n", l);
    }else if(c < c7){
        l = 0;
        for(i=0;i<7 && c>0;i++){
            c-=a;
            if(i == 6) c-=b;
            l++;
        }
        printf("%lld\n", l);
    }else{
        printf("%lld\n", 7);
    }

return 0;
}



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

public class Main{
	public static void main(String[] args){
		Scanner stdIn = null;
		
		try{
			stdIn = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
			while( stdIn.hasNext() ){
				String str = stdIn.next();
				String[] s = str.split(",");
				double[] p = new double[6];
				for(int i = 0; i < 6; i++){
					p[i] = Double.parseDouble(s[i]);
				}
				double px = p[2]-p[0];
				double py = p[3]-p[1];
				double ax = p[4]-p[0];
				double ay = p[5]-p[1];
				double t = (px*ax+py*ay)/(px*px+py*py);
				double ansx = 2*t*px-ax+p[0];
				double ansy = 2*t*py-ay+p[1];
				System.out.printf("%.6f %.6f%n", ansx, ansy);			
			}		
		} finally {
			if( stdIn != null){
				stdIn.close();
			}
		}
	}
}

Measured memory_bytes: 12000
L, R = map(int, input().split())
if L // 2019 != R // 2019:
  print(0)
else:
  L, R = L % 2019, R % 2019
  if L // 673 != R // 673:
    if L // 3 != R // 3:
      print(0)
    else:
      p = 2019
      for i in range(3):
        for j in range(i+1, 3):
          if p > ((L + i) * (L + j)) % 2019:
            p = ((L + i) * (L + j)) % 2019
      print(p)
  elif L // 673 == R // 673:
    p = 2019
    for i in range(L, R + 1):
      for j in range(i+1, R + 1):
        if p > ((i % 2019) * (j % 2019)) % 2019:
          p = ((i % 2019) * (j % 2019)) % 2019
    print(p)

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

typedef long long ll;
typedef vector<int>::iterator viit;
#define pb push_back
const int MAXN = 100010;
const ll MOD = 1000000007;

inline int read() {
	int x = 0, f = 1;
	char ch = getchar();
	for(; !isdigit(ch); ch = getchar()) if(ch=='-') f=-1;
	for(; isdigit(ch); ch = getchar()) x = (x*10)+(ch^48);
	return x * f;
}

int n, indeg[MAXN], dfs_clock;
int dfn[MAXN], low[MAXN], sccno[MAXN];
int cnt, to[MAXN], S[MAXN], top;
int l[MAXN], c[MAXN];
vector<int> P[MAXN];
bool notc[MAXN];
ll ans, p2[MAXN], ifac[MAXN];
ll ip2[MAXN], fac[MAXN];

inline ll qpow(ll a, ll b) {
	ll res = 1;
	while(b) {
		if(b & 1LL) res = res * a % MOD;
		b >>= 1, a = a * a % MOD;
	}
	return res;
}

void dfs(int u) {
	dfn[u] = low[u] = ++dfs_clock;
	S[++top] = u;
	int v = to[u];
	if(!dfn[v]) {
		dfs(v);
		low[u] = min(low[u], low[v]);
	}
	else if(!sccno[v])
		low[u] = min(low[u], dfn[v]);
	if(low[u] == dfn[u]) {
		++cnt;
		while(S[top] != u) {
			P[cnt].pb(S[top]);
			sccno[S[top--]] = cnt;
		}
		P[cnt].pb(S[top]);
		sccno[S[top--]] = cnt;
	}
}

int main() {
	int i, j;

	n = read();
	p2[0] = 1;
	for(i = 1; i <= n; i++) p2[i] = (p2[i-1]<<1)%MOD;
	ip2[n] = qpow(p2[n], MOD-2);
	for(i = n; i >= 1; i--) ip2[i-1] = (ip2[i]<<1)%MOD;
	fac[0] = 1;
	for(i = 1; i <= n; i++) fac[i] = fac[i-1]*i%MOD;
	ifac[n] = qpow(fac[n], MOD-2);
	for(i = n; i >= 1; i--) ifac[i-1] = ifac[i]*i%MOD;
	for(i = 1; i <= n; i++) 
		to[i] = read(), indeg[to[i]]++;

	for(i = 1; i <= n; i++)
		if(indeg[i] > 2) {
			printf("0\n");
			return 0;
		}
	for(i = 1; i <= n; i++) 
		if(!dfn[i]) dfs(i);

	ans = 1;
	for(i = 1; i <= cnt; i++) 
		if(P[i].size() == 1 && to[P[i].back()] != P[i].back()) {
			if(indeg[P[i].back()] > 1) {
				printf("0\n");
				return 0;
			}
			if(indeg[P[i].back()] == 0) {
				int u = P[i].back(), res = 0;
				while(P[sccno[u]].size() == 1 && to[u] != u) {
					res++;
					u = to[u];
				}
				l[u] = res;
				notc[sccno[u]] = true;
			}
		}
	for(i = 1; i <= cnt; i++) 
		if(P[i].size() > 1 || (to[P[i].back()] == P[i].back())) {
			if(notc[i]) {
				ll res = 1;
				viit v;
				/*for(v = P[i].begin(); v != P[i].end(); v++)
					printf("%d:%d ", *v, l[*v]);
				printf("\n");*/
				for(v = P[i].begin(); v != P[i].end(); v++) if(l[*v]) break;
				for(viit u = v; ; u = v) {
					v = u+1;
					int len = 1;
					bool f = false;
					for(; ; v++, len++) {
						if(v == P[i].end()) v = P[i].begin(), f = true;
						if(l[*v]) break;
					}
					if(l[*u] == len) ;
					else if(l[*u] < len) res = (res<<1)%MOD;
					else res = 0;
					if(f) break;
				}
				ans = ans*res%MOD;
				//printf("%lld\n", res);
			}
			else c[P[i].size()]++;
		}
	for(i = 1; i <= n; i++) {
		ll res = 0, p = 1;
		for(j = 0; (j<<1) <= c[i]; j++) {
			if((i & 1) & (i != 1)) 
				res = (res+fac[c[i]]*ip2[j]%MOD*ifac[c[i]-(j<<1)]%MOD*ifac[j]%MOD*p%MOD*p2[c[i]-(j<<1)]%MOD)%MOD;
			else
				res = (res+fac[c[i]]*ip2[j]%MOD*ifac[c[i]-(j<<1)]%MOD*ifac[j]%MOD*p%MOD)%MOD;
			//printf("%d::%lld\n", i, res);
			p = p * i % MOD;
		}
		ans = ans * res%MOD;
	}
	printf("%lld\n", ans);
	return 0;
}



Measured memory_bytes: 13436
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
    int r,d,xi;
    cin >> r >> d >> xi;
    for(int i=0; i < 10; i++){
        xi = r * xi - d;
        cout << xi << endl;
    }
    
}

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

int f[102][102];

bool dfs(int ys,int xs,int yg,int xg,int c){
  if(f[ys][xs]!=c)return 0;

  if(ys==yg && xs==xg)return 1;;

  f[ys][xs]=0;

  bool flag=0;
  flag += dfs(ys+1,xs,yg,xg,c);
  flag += dfs(ys-1,xs,yg,xg,c);
  flag += dfs(ys,xs+1,yg,xg,c);
  flag += dfs(ys,xs-1,yg,xg,c);
  return flag;
}

void set(int c,bool d,int x,int y){
  if(d==0){
    for(int i=0; i<4; i++){
      f[y][x+i]=c;
      f[y+1][x+i]=c;
    }
  }else if(d==1){
    for(int i=0; i<4; i++){
      f[y+i][x]=c;
      f[y+i][x+1]=c;
    }
  }
}
;
int main(){
  while(1){

  int w,h;
  cin >> w >> h;
  if(w==0 && h==0)break;

  int xs,ys;
  cin >> xs >> ys;
  int xg,yg;
  cin >> xg >> yg;
  int n;
  cin >> n;

  for(int i=0; i<n; i++){
    bool d;
    int c,x,y;
    cin >> c >> d >> x >> y;
    set(c,d,x,y);
  }

  if(dfs(ys,xs,yg,xg,f[ys][xs])){
    cout << "OK\n";
  }else{
    cout << "NG\n";
  }
  }

  return 0;
}


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

lint mod = 1e+9 + 7;
int n;
vector<lint> a;

//素因数分解unordered_map版　O(√n)
template <typename T>
unordered_map<T, T> pf_um(T n) {
    unordered_map<T, T> res;
    for (long long int i = 2; i * i <= n; i++)
        while (n % i == 0) {
            res[i]++;
            n /= i;
        }
    if (n != 1) res[n]++;
    return res;
}

// a^n mod pを計算　O(log n)
long long int pow_mod(long long int a, long long int n, long long int p) {
    if (n == 0) return 1;
    long long int temp = pow_mod(a, n / 2, p);
    return n & 1 ? (((temp * temp) % p) * a) % p : (temp * temp) % p;
}

// Z_pでのaの逆元を計算 O(log p)
// depend:pow_mod
long long int inv_mod(long long int a, long long int p) {
    return pow_mod(a, p - 2, p);
}

int main() {
    cin >> n;
    a.resize(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    unordered_map<lint, lint> lcm;
    for (int i = 0; i < n; i++) {
        unordered_map<lint, lint> pf = pf_um(a[i]);
        for (auto e : pf) {
            int fac = e.first;
            if (lcm[fac] < e.second) {
                lcm[fac] = e.second;
            }
        }
    }
    lint l = 1;
    for (auto e : lcm) {
        l = (l * pow_mod(e.first, e.second, mod)) % mod;
    }
    lint ans = 0;
    for (int i = 0; i < n; i++) {
        lint temp = l * inv_mod(a[i], mod);
        ans = (ans + temp) % mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 768
import math
t = []
output = 0
amari = 10
for i in range(0, 5):
    t.append(int(input()))
    output = output+math.ceil(t[i]/10)*10
    if 0<t[i]%10<amari:
        amari = t[i]%10
output = output-10+amari
print("{}".format(output))


Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    int n, k; cin >> n >> k;
    V<ll> p(n), c(n);
    rep(i, n) cin >> p[i];
    rep(i, n) p[i]--;
    rep(i, n) cin >> c[i];
    ll ans = -1e18;
    rep(si, n) {
        V<ll> loop;//siの入っているloopの各スコア
        int np = si;
        ll loop_score = 0;
        while (true) {
            np = p[np];
            loop.push_back(c[np]);
            loop_score += c[np];
            if (np == si) break;
        }

        ll t = 0;
        rep(i, loop.size()) {//最後がloop[i] 最後の周はsiからi+1回移動
            if (i+1 > k) break;
            t += loop[i];
            ll now = t;
            if (loop_score > 0) {
                ll cnt = (k-(i+1)) / loop.size();//cnt回周回
                now += cnt * loop_score;
            }
            chmax(ans, now);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3696
#include <stdio.h>

int main(void){
  int a, b;
  scanf("%d %d" , &a, &b);
  int flag = 0;
  if(a % 3 == 0) flag = 1;
  if(b % 3 == 0) flag = 1;
  if( (a + b) % 3 == 0) flag = 1;
  if(flag) printf("Possible\n");
  else printf("Impossible\n");
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w)
{
	cout<<w.size()<<endl;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<endl;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=10;
		k+=a[i]-'0';
	}
	return k;
}

string its(ll k)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%10)+'0');
		k/=10;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

inline int mult(ll a,ll b)
{
	return (a*b)%MOD;
}

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

ll has(string x)
{
	ll h1=0,h2=0;
	x=to_lower(x);
	for (char a: x)
	{
		h1*=bases[0];
		h1+=a-'a';
		h1%=bases[3];
		h2*=bases[1];
		h2+=a-'a';
		h2%=bases[4];
	}
	return h1*(MOD+13893829)+h2;
}

const int N=300010;
int n,h[N];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829)+13893829);
	cin>>n;
	for (int i=0;i<n;++i) cin>>h[i];
	sort(h,h+n);
	cout<<h[n/2]-h[n/2-1];
}




Measured memory_bytes: 640
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main(){
  int n;cin>>n;
  string s;cin>>s;
  int sum=0;
  for(int i=0;i<n-1;i++)
  {
    if(s.at(i)==s.at(i+1))
      sum++;
  }
  cout<<n-sum;
}
    

Measured memory_bytes: 512
#define _USE_MATH_DEFINES

#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{


	double n, s[1001], a, sum, m,SUM;


	while (1){
		cin >> n;

		sum = 0;

		SUM = 0;

		if (n == 0)break;

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

			sum += s[i];
		}

		m = sum / n;

		for (int i = 0; i < n; i++)
		{
			SUM += pow(s[i] - m, 2);
		}

		SUM = SUM / n;

		printf("%lf\n",sqrt(SUM));
	}

	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int k;
    cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    if (k>=n) cout<<s;
    else{
        for (int i=0; i<k; i++){
            cout<<s[i];
        }
        cout<<"...";
    }
    return 0;
}

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

using namespace std;

int main()
{
   // freopen("in","r",stdin);

    int Nparticipants,Days,Xleft_chocolate,Ai , ans = 0;

    cin >> Nparticipants >> Days >> Xleft_chocolate;

    ans += Xleft_chocolate;

    for(int i = 0; i < Nparticipants; ++i)
    {
        cin >> Ai;
        for(int j = 0; j <= Days; ++j)
        {
            int day = (j*Ai + 1);
            if(day <= Days) ans++;
            else break;
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  vector<char> a(200, 0);
  for(int i = 1; i < n - 1; i++) {
    a[s[i]]++;
  }
  int maxi = *max_element(a.begin(), a.end());
  // cout << maxi << endl;
  if(maxi == 1) {
    bool ok = true;
    char tmp = s[0];
    for(int j = 0; j < n; j++) {
      if(s[j] != tmp) {
        ok = false;
        break;
      }
    }
    if(ok) {
      cout << 0 << endl;
    } else {
      cout << n / 2 << endl;
    }
    return 0;
  }
  string t;
  int ans = 1001001001;
  string re = s;

  for(int i = 'a'; i <= 'z'; i++) {
    int cnt = 0;
    s = re;
    while(1) {
      bool ok = true;
      char tmp = s[0];
      n = s.length();
      for(int j = 0; j < n; j++) {
        if(s[j] != tmp) {
          ok = false;
          break;
        }
      }
      if(ok) {
        // cout << cnt << endl;
        // cout << s << endl;
        ans = min(ans, cnt);
        break;
      }
      for(int j = 0; j < n - 1; j++) {
        if(s[j] == i) {
          t += s[j];
        } else if(s[j + 1] == i) {
          t += s[j + 1];
        } else {
          t += s[j];
        }
      }
      s = t;
      t.clear();
      cnt++;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

int cnt, A[500010];

void merge(int left, int mid, int right) {
  int n1 = mid - left, n2 = right - mid;
  vector<int> L(n1+1), R(n2+1);
  REP(i, n1) L[i] = A[left + i];
  REP(i, n2) R[i] = A[mid + i];
  L[n1] = R[n2] = (int)1e9 + 1;
  int i = 0, j = 0;
  FOR(k, left, right) {
    cnt++;
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
  }
}

void mergeSort(int left, int right) {
  if (left + 1 < right) {
    int mid = (left + right) / 2;
    mergeSort(left, mid);
    mergeSort(mid, right);
    merge(left, mid, right);
  }
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;
  REP(i, N) cin >> A[i];
  mergeSort(0, N);
  REP(i, N) {
    cout << A[i] << (i == N-1 ? '\n' : ' ');
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 5060
import java.util.Scanner;
class Main{
    public static void main(String[]$){
        Scanner s=new Scanner(System.in);
        int a=s.nextInt(),b=s.nextInt();
        System.out.println((((a%3)*(b%3)*((a+b)%3)==0)?"P":"Imp")+"ossible");
    }
}


Measured memory_bytes: 23124
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i,j,H,*z;

  scanf("%d",&H);
  z = malloc(H*sizeof(int)+1);
  for(i=1;i <= H;i++){
    scanf("%d",&z[i]);
  }
  for(i=1;i <= H;i++){
    printf("node %d: key = %d, ",i,z[i]);
    if(i/2 != 0){
      printf("parent key = %d, ",z[i/2]);
    }
    if(2*i <= H){
      printf("left key = %d, ",z[2*i]);
    }
    if(2*i+1 <= H){
      printf("right key = %d, ",z[2*i+1]);
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2104
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;
#define REP(i,n) for (ll i = 0; i < (n); ++i)

int main(){
    ll n;
    cin >> n;
    vector<ll> t(n), a(n);
    REP(i, n){
        cin >> t.at(i);
    }
    REP(i, n){
        cin >> a.at(i);
    }

    vector<pair<ll, ll>> h(n, make_pair(1, 1000000000));
    ll prev_t = 0;
    REP(i, n){
        if(t.at(i) > prev_t){
            h.at(i).first = max(h.at(i).first, t.at(i));
        }
        h.at(i).second = min(h.at(i).second, t.at(i));
        prev_t = t.at(i);
    }

    ll prev_a = 0;
    for(ll i = n - 1; i >= 0; --i){
        if(a.at(i) > prev_a){
            h.at(i).first = max(h.at(i).first, a.at(i));
        }
        h.at(i).second = min(h.at(i).second, a.at(i));
        prev_a = a.at(i);
    }

    ll ans = 1;
    for(auto p : h){
        ans *= max(0LL, (p.second - p.first + 1));
        ans %= 1000000007;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328