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



void solve(long long N, map<string,int> S){
  multimap<int, string> reversed;
  int mymax = 0;

  for (auto i = S.begin(); i != S.end(); ++i) {
    reversed.emplace(i->second, i->first);
    mymax = max(mymax, i->second);
  }

  auto p = reversed.equal_range(mymax);

  for (auto it = p.first; it != p.second; ++it) {
    std::cout << it->second << std::endl;
  }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    string in;
  scanf("%lld",&N);
  map<string,int> S;
  for(int i = 0 ; i < N ; i++){
    cin >> in;
    S[in]++;
  }
    solve(N, std::move(S));
    return 0;
}


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

int gcd(int a, int b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
    int N, K; cin >> N >> K;
    int ma = 0, g = 0;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        ma = max(ma, x);
        g = gcd(g, x);
    }
    if (K % g || K > ma) {
        cout << "IMPOSSIBLE" << endl;
    } else {
        cout << "POSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int64_t k,n,ans=0,a,b;
  cin >> k>>n;
  
  int64_t a1;
  cin >> a1;
  b=a1;
  for(int i;i<n-1;i++){
    cin >>a;
    if(a-b>ans){
      ans=a-b;
    }
    b=a;
  }
  cout << k-max(ans,a1+k-a) <<endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<pii>>;
using mat = vector<vector<int>>;
const int MOD = 1e9 + 7;

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

    ll H;
    cin >> H;
    ll ans = 1;
    while (ans <= H)
        ans <<= 1;
    cout << ans - 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string s;
  cin >> s;
  ll y = stoll(s.substr(0, 4));
  ll m = stoll(s.substr(5, 2));
  if ((y == 2019 && m <= 4) || (y < 2019)) {
    cout << "Heisei" << endl;
  } else {
    cout << "TBD" << endl;
  }
  return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { 1,0,-1,0 };
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int R, C, sx, sy, tx, ty;
	cin >> R >> C >> sx >> sy >> tx >> ty;
	vector <vector<int> > dist(R, vector<int>(C, (int)1 << 60));
	vector <vector<int> > dp(R, vector<int>(C, 0));
	vector <vector<int> > V(R, vector<int>(C, 0));
	queue<pair<int, int> > qu;
	qu.emplace(sx, sy);
	dist[sx][sy] = 0;
	dp[sx][sy] = 1;
	while ((int)qu.size() > 0) {
		int X = qu.front().first;
		int Y = qu.front().second;
		qu.pop();
		for (int k = 0; k < 8; k++) {
			int xx, yy;
			if (k < 4) {
				xx = X + dx[k];
				yy = Y + dy[k];
			}
			else if (k == 4) {
				xx = 0;
				yy = Y;
			}
			else if (k == 5) {
				xx = R - 1;
				yy = Y;
			}
			else if (k == 6) {
				xx = X;
				yy = 0;
			}
			else if (k == 7) {
				xx = X;
				yy = C - 1;
			}
			if (xx >= 0 && xx < R && yy >= 0 && yy < C) {
				if (dist[xx][yy] > dist[X][Y] + 1) {
					dist[xx][yy] = dist[X][Y] + 1;
					if (V[xx][yy] == 0) {
						V[xx][yy] = 1;
						qu.emplace(xx, yy);
					}
				}
			}
		}
	}
	qu.emplace(sx, sy);
	while ((int)qu.size() > 0) {
		int X = qu.front().first;
		int Y = qu.front().second;
		qu.pop();
		for (int k = 0; k < 8; k++) {
			int xx, yy;
			if (k < 4) {
				xx = X + dx[k];
				yy = Y + dy[k];
			}
			else if (k == 4) {
				xx = 0;
				yy = Y;
			}
			else if (k == 5) {
				xx = R - 1;
				yy = Y;
			}
			else if (k == 6) {
				xx = X;
				yy = 0;
			}
			else if (k == 7) {
				xx = X;
				yy = C - 1;
			}
			if (xx >= 0 && xx < R && yy >= 0 && yy < C) {
				if (dist[xx][yy] == dist[X][Y] + 1) {
					//cerr << xx << " " << yy << " " << X << " " << Y << endl;
					dp[xx][yy] = (dp[xx][yy] + dp[X][Y]) % MOD;
					if (V[xx][yy] != 2) {
						V[xx][yy] = 2;
						qu.emplace(xx, yy);
					}
				}
			}
		}
	}
	cout << dist[tx][ty] << " " << dp[tx][ty] << endl;
}


Measured memory_bytes: 7140
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N (1000000000+7)


int main(void) {
	int n, l;
	cin >> n >> l;
	vector<string>s(n);
	for (int i = 0;i < n;i++)cin >> s[i];
	sort(s.begin(), s.end());
	for (int i = 0;i < n;i++)cout << s[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
count = 0
INF = float('inf')
def merge(A, left, mid, right):
    global count
    L = A[left:mid] + [INF]
    R = A[mid:right] + [INF]
    i,  j = 0, 0
    for k in range(left, right):
        count +=1
        if L[i] <= R[j]:
            A[k] = L[i]
            i = i+1
        else:
            A[k] = R[j]
            j = j+1


def mergeSort(A, left, right):
    if left+1 < right:
        mid =  int((left+right)/2)
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)



#right は部分配列の末尾+1 の要素を指す。

n = int(input())
A = list(map(int, input().split()))
mergeSort(A, 0, n)
for i in range(n):
    if i>0:
        print(" ", end="")
    print(A[i], end="")
print()
print(count)
     


Measured memory_bytes: 61656
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<ll, int> P;
int main() {
	int N, M;
	cin >> N >> M;
	vector<P> vec;
	for (int i = 0; i < N; i++) {
		int A, B;
		cin >> A >> B;
		vec.emplace_back(A, B);
	}
	sort(vec.begin(), vec.end());
	ll sum = 0;
	for (int i = 0; i < N; i++) {
		int t = min(M, vec[i].second);
		sum += vec[i].first*t;
		M -= t;
	}
	cout << sum << endl;
 }

Measured memory_bytes: 3444
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static char[] word = "MARCH".ToCharArray();
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var dict = new Dictionary<char, int>();
            for (var i = 0; i < N; i++)
            {
                var tmp = Console.ReadLine();
                if (word.Contains(tmp[0]))
                {
                    if (dict.ContainsKey(tmp[0])) dict[tmp[0]]++;
                    else dict[tmp[0]] = 1;
                }
            }

            var list = dict.Select(z => z.Value).ToList();
            var sol = new Solve(N, list, list.Count);

            Console.WriteLine(sol.Dfs(0, 0, 1));
        }
    }

    class Solve
    {
        public int N { get; set; }
        public List<int> List { get; set; }
        public int Len { get; set; }
        public int SelectCount { get; set; } = 3;
        public Solve(int n, List<int> list, int len)
        {
            N = n;
            List = list;
            Len = len;
        }

        public long Dfs(int n, int use, long total)
        {
            if (use == SelectCount) return total;
            if (n == Len && use != SelectCount) return 0;

            var sum1 = Dfs(n + 1, use + 1, total * List[n]);
            var sum2 = Dfs(n + 1, use, total);

            return sum1 + sum2;
        }
    }
}


Measured memory_bytes: 15452
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, c, k;
  scanf("%d %d %d", &n, &c, &k);
  vi t(n);
  rep (i, n) {
    scanf("%d", &t[i]);
  }
  sort(all(t));
  int earliest = t[0];
  int waiting = 0;
  int ans = 0;
  rep (i, n-1) {
    waiting += 1;
    if (waiting == c || earliest + k < t[i+1]) {
      ans += 1;
      waiting = 0;
      earliest = t[i+1];
    }
  }

  ans += 1;
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define N 110
using namespace std;
int h,w;
char mp[N][N];
int col[N][N];
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};

void paint(int y,int x,int c){
  col[y][x] = c;
  int ch = mp[y][x];

  for(int i=-1;i<=1;i++)
    for(int j=-1;j<=1;j++){
      int ny = y + i;
      int nx = x + j;
      if(nx<0||ny<0||nx>=w||ny>=h||mp[ny][nx]!=ch||col[ny][nx]!=-1) continue;
      if(ch == '.' && i!=0 && j!=0) continue; 
      paint(ny,nx,c);
    }
}

vector<vector<int> >mkG(){

  cin>>h>>w;
  memset(mp,'.',sizeof(mp));
  if(!h&&!w) exit(0);
  for(int i=1;i<=h;i++)
    for(int j=1;j<=w;j++) cin>>mp[i][j];
  h+=2,w+=2;
  
  vector< vector<int>> res;
  memset(col,-1,sizeof(col));

  paint(0,0,0);
  int cnt = 1;
  for(int i=0;i<h;i++)
    for(int j=0;j<w;j++){
      if(col[i][j] != -1)continue;
      res.push_back(vector<int>());
      for(int k=0;k<4;k++) {
	int ny = i+dy[k];
	int nx = j+dx[k];
	if(nx<0||ny<0||nx>=w||ny>=h||col[ny][nx]==-1)continue;
	
	res[col[ny][nx]].push_back(cnt);
	break;
      }
      paint(i,j,cnt++);
    }
  return res;
}




string GtoS(int pos,vector<vector<int>> &G){
  string res;

  priority_queue<string> Q;
  if(pos<(int)G.size())
    for(int nx:G[pos])Q.push(GtoS(nx,G));
  
  while(!Q.empty()){ res+=Q.top();Q.pop();}
  return '0'+res+'1';
}



int main(){
  while(1){
    vector<vector<int>> G1=mkG();
    vector<vector<int>> G2=mkG();
    string s1 = GtoS(0,G1);
    string s2 = GtoS(0,G2);
    cout<<(s1==s2? "yes":"no")<<endl;
  }
  return 0;
}

Measured memory_bytes: 3348
#include<stdio.h>
#define MAX 10001
#define NIL -1
void Preorder(int);
void Inorder(int);
void Postorder(int);

typedef struct {
  int p,l,r;
}Node;

Node T[MAX];
int n;

int main(){
  int i,u,l,r,id;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    T[i].p = NIL;
  }
  for(i = 0; i < n; i++){
    scanf("%d %d %d",&id,&l,&r);
    T[id].l = l;
    T[id].r = r;
    if(l != NIL) T[l].p = id;
    if(r != NIL) T[r].p = id;
  }
  for(i = 0; i < n; i++) if(T[i].p == NIL) u = i;
  printf("Preorder\n");
  Preorder(u);
  printf("\nInorder\n");
  Inorder(u);
  printf("\nPostorder\n");
  Postorder(u);
  printf("\n");
  return 0;
}


void Preorder(int u){
  if(u == NIL) return;
  printf(" %d",u);
  Preorder(T[u].l);
  Preorder(T[u].r);
}

void Inorder(int u){
  if(u == NIL) return;
  Inorder(T[u].l);
  printf(" %d",u);
  Inorder(T[u].r);
}

void Postorder(int u){
  if(u == NIL) return;
  Postorder(T[u].l);
  Postorder(T[u].r);
  printf(" %d",u);
}



Measured memory_bytes: 2036
def ispalindrome(s):
        return 1 if s == s[::-1] else 0
s = input()
n = len(s)
if ispalindrome(s) and ispalindrome(s[:(n - 1) // 2]) and ispalindrome(s[(n + 3)//2 -1:n]) :
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
s = input()

l = 0
r = len(s)-1
ans = 0

while r-l >= 1:
    if s[l] == s[r]:
        l += 1
        r -= 1
    elif s[l] == "x":
        l += 1
        ans += 1
    elif s[r] == "x":
        r -= 1
        ans += 1
    else:
        ans = -1
        break

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <queue>
using namespace std;
typedef pair<int,int> P;
int W,H;
int visited[51][51] = {};
char A[51][51];

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

bool in(int x,int y){
    return 1<=x && x<=H && 1<=y && y<=W;
}

void init(){
    for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) visited[i][j] = 0;
}

int main(){
    while(cin >> W >> H && W>0){
        for(int i=1;i<=H;i++) for(int j=1;j<=W;j++) cin >> A[i][j];
        int black = 0,white = 0;
        for(int i=1;i<=H;i++){
            for(int j=1;j<=W;j++){
                if(A[i][j]!='.') continue;
                init();
                visited[i][j] = 1;
                queue<P> Q;
                Q.push({i,j});
                bool b = false,w = false;
                while(!Q.empty()){
                    int x = Q.front().first,y = Q.front().second;
                    Q.pop();
                    for(int i=0;i<4;i++){
                        int nx = x+dx[i],ny = y+dy[i];
                        if(!in(nx,ny)) continue;
                        if(visited[nx][ny]==1) continue;
                        if(A[nx][ny]=='W') w = true;
                        if(A[nx][ny]=='B') b = true;
                        if(A[nx][ny]=='.'){
                            visited[nx][ny] = 1;
                            Q.push({nx,ny});
                        }
                    }
                }
                if(b&&!w) black++;
                if(!b&&w) white++;
            }
        }
        cout << black << " " << white << endl;
    }
}


Measured memory_bytes: 3164
N, W = map(int, input().split())
WV = [list(map(int, input().split())) for _ in range(N)]

INF = 10 ** 12
V = 10 ** 3 * 100 + 10

dp = [0] + [INF] * V
for w, v in WV:
	for i in range(V, v - 1, -1):
		dp[i] = min(dp[i], dp[i - v] + w)

r = 0
for i in range(V):
	if dp[i] <= W:
		r = i
print(r)

"""
for cell in dp:
	if cell == INF:
		print("  INF", end="")
	else:
		print("{:5d}".format(cell), end="")
print()
"""


Measured memory_bytes: 41692
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
using namespace std;

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

	string consonants = "w_kstnhmyr";
	map<char, char> vowels;
	vowels.insert(make_pair('T', 'a'));
	vowels.insert(make_pair('L', 'i'));
	vowels.insert(make_pair('U', 'u'));
	vowels.insert(make_pair('R', 'e'));
	vowels.insert(make_pair('D', 'o'));

	string s;
	cin >> s;

	string ans;

	for(int i = 0; i < s.size(); i += 2) {
		if(s[i] == '0' && s[i + 1] == 'U')
			ans += "nn";

		else {
			if(isalpha(consonants[s[i] - '0']))
				ans += consonants[s[i] - '0'];

			ans += vowels[s[i + 1]];
		}
	}

	cout << ans << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1196
def result(m, b):
    sum1 = m
    resmin = m
    for i in range(len(b)):
        resmin += b[i][0]
        if resmin < 0:
            return -1
        else:
            resmin += b[i][1] - b[i][0]
    for i in range(len(b)):
        sum1 += b[i][1]
    if sum1 != 0:
        return -1
    return 0
n = int(input().strip('\n'))
resmin = 10 ** 7
set_pos = []
set_neg = []
for i in range(n):
    a = input().strip('\n')
    loc_min = 10 ** 7
    total = 0
    flag = True
    tmp = 0
    for j in range(len(a)):
        if a[j] == '(':
            tmp += 1
        else:
            tmp -= 1
        if tmp < loc_min:
            loc_min = tmp
    total = tmp
    if total >= 0:
        set_pos.append((loc_min, total))
    else:
        set_neg.append((loc_min, total))
total_pos = 0
set_pos = sorted(set_pos, key = lambda l: l[0], reverse = True)
for elem in set_pos:
    if total_pos + elem[0] < 0:
        flag = False
    total_pos += elem[1]   
b = sorted(set_neg, key = lambda l: l[1] - l[0], reverse = True)
#print(b)
#print(set_pos, b)
res = result(total_pos, b)
print('No' if (res == -1 or not flag) else 'Yes')
        
    
    

Measured memory_bytes: 177284
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<map>

using namespace std;
#define endl '\n'
#define pb push_back
#define fst first
#define scd second
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define REP(i,n) for(int i = 0;i < (n);i++)
#define FOR(i,a,b) for(int i = (a);i <= (b);i++)
#define YES(n) cout << ((n) ? "YES" : "NO" ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No" ) << endl

constexpr int MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> vii;

template <class T = int> T in() { T x; cin >> x; return (x); }
template <class T = int> void out(T x) { cout << (x) << endl; }

int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

void solve() {

	int n;
	cin >> n;

	vi v1(n / 2), v2(n / 2);

	int a[100001] = {}, b[100001] = {};
	REP(i, n / 2) {
		cin >> v1[i] >> v2[i];
		a[v1[i]]++;
		b[v2[i]]++;
	}
	int maxa = 0, maxa2 = 0, maxb = 0, maxb2 = 0;
	FOR(i, 1, 100000) {
		if (a[maxa] <= a[i]) {
			maxa = i;
		}
		if (b[maxb] <= b[i]) {
			maxb = i;
		}
	}
	FOR(i, 1, 100000) {
		if (a[maxa2] <= a[i] && i != maxa) {
			maxa2 = i;
		}
		if (b[maxb2] <= b[i] && i != maxb) {
			maxb2 = i;
		}
	}

	int cnt = 0;
	int cnta = 0, cnta2 = 0;
	int cntb = 0, cntb2 = 0;
	REP(i, n / 2) {
		if (v1[i] != maxa) cnta++;
		if (v2[i] != maxb) cntb++;
		if (v1[i] != maxa2) cnta2++;
		if (v2[i] != maxb2) cntb2++;
	}
	if (maxa == maxb) {
		cnt = cnta + cntb2 < cnta2 + cntb ? cnta + cntb2 : cnta2 + cntb;

	}
	else {
		cnt = cnta + cntb;
	}


	out(cnt);

	return;

}

int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	solve();

	return 0;

}

Measured memory_bytes: 1408
/*Bismillahir Rahmanir Rahim
->>Code by Ashraful Islam Paran
->>CUET,CSE
*/
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define f(a,b,x) for(int a=b;a<x;a++)
#define pb push_back
#define endl "\n"
#define MX 200000
#define yes cout<<"YES"<<endl
#define no cout<<"NO"<<endl
#define vi vector<int>

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

    string s;
    cin>>s;
    f(i,0,3)
    {
        cout<<s[i];
    }
    cout<<endl;

    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

map<int,string> names;
int times[40][40];
int point[40][40];
int main(void){
  int n;
  while(cin>>n,n){
    names.clear();
    memset(times,0,sizeof(times));
    memset(point,0,sizeof(point));
    rep(i,n){
      string nm;
      cin>>nm;
      names[i] = nm;
      int m;
      cin>>m;
      rep(j,m){
	int x;
	cin>>x;
	times[i][x] = 1;
      }
    }
    rep(i,n){
      rep(j,30){
	if(times[i][j]==0)continue;
	int cnt = 0;
	rep(k,n){
	  cnt += times[k][j];
	}
	point[i][j]= n + 1 - cnt;
      }
    }
    int mn = MAX, res = 0;
    rep(i,n){
      int cnt = 0;
      rep(j,30){
	cnt += point[i][j];
      }
      if(mn>cnt){
	res = i;
	mn = cnt;
      }else if(mn==cnt){
	if(names[res]>names[i]){
	  res = i;
	}
      }
    }
    cout<<mn<<" "<<names[res]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define ios ios_base::sync_with_stdio(0) ; cin.tie(0) ; cout.tie(0)
#define so sizeof
#define pb push_back
#define vl vector<ll>
#define forn(i,a,b) for(ll i=1;i<=b;++i)
#define forr(i,a,b) for(ll i=0;i<b;++i)
#define vll vector<pair<ll,ll> >
#define r0 return 0
#define be begin()
#define en end()
#define pll pair<ll,ll>
#define plll pair<ll,pair<ll,ll>>
#define plvl pair<pair<ll,ll> ,ll>
#define mp make_pair
#define cf cout.flush()
int main()
{
   ios;
   ll a , b , c ;
   cin >> a >> b >> c;
   vl v ; v.pb(a) ; v.pb(b) ; v.pb(c);
   sort(v.be, v.en);

   cout << (v[0] * v[1])/2;
}


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

using namespace std;

int main() {
  string s[3];
  for (int i = 0; i < 3; i++) {
    cin >> s[i];
    reverse(s[i].begin(), s[i].end());
  }
  int who = 0;
  while (true) {
    if (s[who].empty()) {
      cout << (char) ('A' + who) << '\n';
      return 0;
    }
    char c = s[who].back();
    s[who].pop_back();
    who = c - 'a';
  }
  assert(false);
  return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;
use std::collections::BTreeSet;

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")
}

fn main() {
    let n: u32 = read();
    let mut a: BTreeSet<u32> = (0..n).map(|_| read()).collect();
    println!("{}", a.len());
}

Measured memory_bytes: 4352
//Deforestation
#include <iostream>
#include <climits>
#include <queue>

using namespace std;

static const int MAX = 30;
static const int dx[4] = {0, -1, 0, 1};
static const int dy[4] = {1, 0, -1, 0};

struct State {
    int x, y, step, cost;
    State(int x, int y, int step, int cost): x(x), y(y), step(step), cost(cost) {}
    bool operator < (const State &arg) const {
        return cost > arg.cost;
    }
};

int A[MAX][MAX], d[MAX][MAX][MAX * MAX + 1];
int H, W;

bool isInRange(int x, int y) {
    return (x >= 0 && y >= 0 && x < W && y < H);
}

int solve() {
    priority_queue<State> PQ;
    PQ.push(State(0, 0, 0, 0));
    int ans = INT_MAX;
    while(!PQ.empty()) {
        State s = PQ.top();
        PQ.pop();
        if(s.x == W - 1 && s.y == H - 1) {
            ans = min(ans, s.cost - s.step);
            continue;
        }
        if(s.step > H * W) continue;
        if(s.cost > d[s.x][s.y][s.step]) continue;
        for(int r = 0; r < 4; r++) {
            int x = s.x + dx[r];
            int y = s.y + dy[r];
            if(!isInRange(x, y )) continue;
            int step = s.step + 1;
            int cost = s.cost + 1 + A[y][x] * (2 * s.step + 1);
            if(d[x][y][step] > cost) {
                d[x][y][step] = cost;
                PQ.push(State(x, y, step, cost));
            }
        }
    }
    return ans;
}

int main() {
    cin >> H >> W;
    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            cin >> A[i][j];
        }
    }
    for(int i = 0; i < MAX; i++) {
        for(int j = 0; j < MAX; j++) {
            for(int k = 0; k <= MAX * MAX; k++) {
                d[i][j][k] = INT_MAX;
            }
        }
    }

    cout << solve() << endl;
}


Measured memory_bytes: 10080
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
int max(int a, int b) { return a > b ? a : b; }
int main(void){
    int n,m,i,j,k,ans=0;
    int a,b,c[100001],h[100001],flag[100001],group[100001][100001];
    scanf("%d %d\n",&n,&m);
    for(i=0; i<n; i++){
        scanf("%d ",&h[i]);
        flag[i]=0;
    }for(i=0; i<m; i++){
        scanf("%d %d\n",&a,&b);
        flag[a-1]=max(flag[a-1],h[b-1]);
        flag[b-1]=max(flag[b-1],h[a-1]);
    }
    for(i=0; i<n; i++){
        if(h[i]>flag[i])ans++;
    }
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 2508
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	long long a, b, c, d, x,ans=0;
	cin >> a >> b >> c >> d >> x;
	x *= 4;
	if (x >= 8) {
		ans += x / 8 * min(a * 8, min(b * 4, min(c * 2, d)));
		x %= 8;
	}
	if (x >= 4) {
		ans += x / 4 * min(a * 4, min(b * 2, c));
		x %= 4;
	}
	if (x >= 2) {
		ans += x / 2 * min(a * 2, b);
		x %= 2;
	}
	if (x >= 1) {
		ans += x * a;
	}
	cout << ans << endl;
	return 0;
}

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for k in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for k in range(c)] for k in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class BIT:
    """ Binary Indexed Tree """

    def __init__(self, n):
        # 0-indexed
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def get(self, l, r=None):
        """ 区間和の取得 [l, r) """
        # 引数が1つなら一点の値を取得
        if r is None: r = l + 1
        res = 0
        if r: res += self.sum(r-1)
        if l: res -= self.sum(l-1)
        return res

def compress(A):
    """ 座標圧縮 """

    zipped, unzipped = {}, {}
    for i, a in enumerate(sorted(set(A))):
        zipped[a] = i
        unzipped[i] = a
    return zipped, unzipped

N = INT()
A = LIST()

zipped, _ = compress(A)
bit = BIT(N)
ans = 0
for i in range(N-1, -1, -1):
    a = zipped[A[i]]
    ans += bit.sum(a)
    bit.add(a, 1)
print(ans)



Measured memory_bytes: 55436
players = {}
players["A"] = input()
players["B"] = input()
players["C"] = input()

now_play = "A"

while True:
    if len(players[now_play]) == 0:
        print(now_play)
        break

    trushed_card = players[now_play][0].upper()
    players[now_play] = players[now_play][1:]
    now_play = trushed_card

Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main() {
	int N, K;
	std::cin >> N >> K;

	std::string S;
	std::cin >> S;

	// 両端は1から始まるとする。
	// S = 0010 のとき list = {0,2,1,2,0}
	std::vector<int> list;
	int left = 0;
	// 番兵
	S.append("x");
	if(S[0] == '0') {
		list.emplace_back(0);
	}
	for(int i = 1; i < S.size(); i++) {
		if(S[i - 1] != S[i]) {
			list.emplace_back(i - left);
			left = i;
		}
	}
	if(S[N - 1] == '0') {
		list.emplace_back(0);
	}

	int numSelect = K * 2 + 1;
	if(numSelect > list.size()) {
		numSelect = list.size();
	}
	int begin = 0;
	int end = numSelect;
	int sum = 0;
	for(int i = begin; i < end; i++) {
		sum += list[i];
	}

	int result = sum;
	while(end <= list.size() - 1) {
		sum -= list[begin];
		sum += list[end];
		begin++;
		end++;
		if(begin % 2 != 0) {
			continue;
		}
		result = std::max(result, sum);
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

const int N=3e5+5;
ll a[N],s=0;

int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
rep(i,0,n-1)cin>>a[i],s^=a[i];

rep(i,0,n-1)
{
	ol((s^a[i]));os;
}
return 0;
}



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

int main() {
    int a=0,b=0,H[100],W[100];
    while (1) {
        cin >> H[a] >> W[a];
        if (H[a] == 0 && W[a] == 0) break;
        a++;
        
    }
    
    while (b<a) {

        for (int i = 0; i < H[b]; i++) {
            for (int j = 0; j < W[b]; j++) {
                if((i+j)%2==0) printf("#");
                else printf(".");
            }
        printf("\n");
        }
        b++;
        printf("\n");
    }

    return 0;
}



Measured memory_bytes: 2992
n,k,q = map(int, input().split())
Q=[]
S=[]
if k>q:
    for i in range(n):
        print("Yes")
else:
    for j in range(q):
        Q.append(int(input()))
    for m in range(n):
        S.append(k)
    for l in range(q):
        S[Q[l]-1]+=1
    for x in range(n):
        S[x]-=q
    for z in range(n):
        if S[z]<=0:
            print("No")
        else:
            print("Yes")

Measured memory_bytes: 11792
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

int w,n;

int main(){
    cin >> w >> n;
    vector<int> a(n),b(n);
    rep(i,n) scanf("%d,%d",&a[i],&b[i]),a[i]--,b[i]--;

    vector<int> number(w);
    iota(number.begin(),number.end(),1);
    rep(i,n) swap(number[a[i]],number[b[i]]);

    rep(i,w) cout << number[i] << endl;
}

Measured memory_bytes: 3064
#include <stdio.h>

int main(void){
  int w,h,x,y,r;
  
  scanf("%d%d%d%d%d",&w,&h,&x,&y,&r);
  if(0<=x-r && x+r<=w && 0<=y-r && y+r<=h)  printf("Yes\n");
  else  printf("No\n");

  return 0;
}

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

const int mn=3e5+6;
int n,m,cnt,cntn[mn],cntm[mn],idn[mn],idm[mn];
map<pair<int,int>,bool> vis;

bool cmpn(int a,int b) {return cntn[a]>cntn[b];}
bool cmpm(int a,int b) {return cntm[a]>cntm[b];}

int main()
{
    scanf("%d%d%d",&n,&m,&cnt);
    int a,b;
    for(int i=1;i<=cnt;++i) {
        scanf("%d%d",&a,&b);
        cntn[a]++,cntm[b]++;
        vis[make_pair(a,b)]=1;
    }
    for(int i=1;i<=n;++i) idn[i]=i;
    for(int i=1;i<=m;++i) idm[i]=i;
    sort(idn+1,idn+n+1,cmpn);
    sort(idm+1,idm+m+1,cmpm);
    int lasn=1,lasm=1;
    for(int i=2;i<=n;++i) {if(cntn[idn[i]]==cntn[idn[lasn]]) lasn++;else break;}
    for(int i=2;i<=m;++i) {if(cntm[idm[i]]==cntm[idm[lasm]]) lasm++;else break;}
    if(lasn*lasm>cnt) {printf("%d",cntn[idn[lasn]]+cntm[idm[lasm]]);return 0;}
    for(int i=1;i<=lasn;++i) for(int j=1;j<=lasm;++j) {
        if(!vis[make_pair(idn[i],idm[j])]) {printf("%d",cntn[idn[lasn]]+cntm[idm[lasm]]);return 0;}
    }
    printf("%d",cntn[idn[lasn]]+cntm[idm[lasm]]-1);return 0;
}

Measured memory_bytes: 27212
#include<bits/stdc++.h>
using namespace std;
int sum = 0;

void dfs(int i, int pre, vector<vector<int>> &rel,vector<bool> &checked){
    bool all_checked = true;
    for (int j : rel[i])
    {
        if(!checked[j]) all_checked = false;
    }
    if(all_checked) return;
    for (int j : rel[i])
    {
        if(j == pre) continue;
        if(!checked[j]){
            checked[j] = true;
            dfs(j,i,rel,checked);
        }
    }    
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> rel(n);
    for (int i = 0; i < m; i++)
    {
        int a, b, c;
        cin>> a >> b >> c;
        rel[a-1].push_back(b-1);
        rel[b-1].push_back(a-1);
    }
    int sum = 0;
    vector<bool> checked(n,false);
    for (int i = 0; i < n; i++)
    {
        if(!checked[i]){
            checked[i] = true;
            dfs(i,-1,rel,checked);
            sum ++ ;
        }
    }
    cout << sum << endl; 
}

Measured memory_bytes: 14640
m = 1000000007

N = int(input())
S1 = input()
S2 = input()

state = ""
ans = 1
for n in range(N):
    s1, s2 = S1[n], S2[n]

    if s1 == s2:
        if state == "":
            ans = (ans*3) % m
        elif state == "tate":
            ans = (ans*2) % m
        state = "tate"
    else:
        if state == "yoko_continue":
            state = "yoko"
            continue
        elif state == "":
            ans = (ans*3*2) % m
        elif state == "tate":
            ans = (ans*2) % m
        elif state == "yoko":
            ans = (ans*3) % m
        state = "yoko_continue"

print(ans)


Measured memory_bytes: 3064
l[4],r[4],i;main(){float a,b;for(;~scanf("%f%f",&a,&b);){l[a<0.2?3:a<0.6?2:a<1.1?1:0]++;r[b<0.2?3:b<0.6?2:b<1.1?1:0]++;}for(i=0;i<4;i++){printf("%d %d\n",l[i],r[i]);}exit(0);}

Measured memory_bytes: 624
#include<cstdio>
//#include<iostream>
#include<vector>
#include<string>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
const int maxv = 200005;
const int inf = 1e9 + 7;
int ar[maxv];
int main(){
	int n;
	ll sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&ar[i]);
		sum+=ar[i];
		sum%=inf;
	} 
	ll ans=0;
	for(int i=1;i<=n;i++){
		sum-=ar[i];
		if(sum<0) sum+=inf;
		ans+=ar[i]*sum;
		ans%=inf;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 2484
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const ll MOD2=998244353;
const double PI=acos(-1);
const ll INF=1e18;
const int inf=1e8+1;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

ll mypow(ll t,ll x){
  if(x==0){
    return 1;
  }
  if(x>=30){
    return inf;
  }
  if(x%2==0){
    ll X=mypow(t,x/2);
    return X*X;
  }
  else{
    return mypow(t,x-1)*t;
  }
}

int main() {
  ll n;
  cin >> n;
  vl a(n+1);
  bool b=true;
  rep(i,n+1){
    cin >> a[i];
  }
  if(n==0&&a[0]!=1){
    b=false;
  }
  if(n!=0&&a[0]!=0){
    b=false;
  }
  ll ans=1;
  vl dp(n+1);
  dp[0]=1;
  ll x=1;
  FOR(i,1,n+1){
    x*=2;
    dp[i]=x;
    x-=a[i];
    if(dp[i]<=a[i]&&i!=n){
      b=false;
    }
    if(n==i&&dp[i]+1<=a[i]){
      b=false;
    }
    if(x>INF){
      x=INF;
    }
  }
  /*rep(i,n+1){
    cout << dp[i] << endl;
  }*/
  ll sum=0;
  for(ll i=n-1;i>=1;i--){
    sum+=a[i];
    ans+=min(dp[i],a[n]+sum);
  }
  ans+=a[n];
  if(b&&n==0){
    cout << 1 << endl;
  }
  else if(b){
    cout << ans << endl;
  }
  else{
    cout << -1 << endl;
  }
}

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

typedef pair<int, pair<int, int> > p;

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

    int H, W;
    cin >> H >> W;

    int count = 0;

    vector<vector<char> > s(H + 2, vector<char>(W + 2, '#'));
    vector<vector<bool> > c(H + 2, vector<bool>(W + 2));

    int d[4][2] = {
        {-1,  0},
        { 1,  0},
        { 0, -1},
        { 0,  1},
    };

    for(int i = 1; i <= H; i++) {
        for(int j = 1; j <= W; j++) {
            cin >> s[i][j];
            if(s[i][j] == '.') count++;
        }
    }

    queue<p> q;

    q.push(make_pair(1, make_pair(1, 1)));

    while(!q.empty()) {
        p f = q.front();
        int n = f.first;
        int x = f.second.first;
        int y = f.second.second;

        q.pop();

        if(x == W && y == H) {
            cout << count - n << endl;
            return 0;
        }

        for(int i = 0; i < 4; i++) {
            int kx = x + d[i][0];
            int ky = y + d[i][1];

            if(s[ky][kx] == '#' || c[ky][kx]) continue;

            q.push(make_pair(n + 1, make_pair(kx, ky)));
            c[ky][kx] = true;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())

using namespace std;

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}

typedef pair<ll,ll> Pair;
const ll inf =1000000007;

void solve(){
    ll n;
    cin >> n;
    map<string,ll> mp;
    rep(i,n){
        string s;
        cin >>s;
        if(mp.find(s)==mp.end()) {
            mp[s] = 1;
        }
    }
    ll ans=0;
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        ans++;
    }
    kaku(ans);
}

int main(){
    solve();
}

Measured memory_bytes: 19156
#include <iostream>
#include <stdio.h>
#include<algorithm>
#include <math.h>
#include <string.h>
#include <map>
#define eps 1e-9
typedef long long int ll;
#define p1 3.1415926535898
using namespace std;
int main()
{
    int sum=0;
    long long int n,m;
    cin>>n>>m;
    while(n/m!=0)
    {
        sum++;
        n=n/m;

    }
    if(n!=0)
    {
        sum++;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll n,i,a[101010],h1,h2;
int main()
{
//	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	reverse(a+1,a+1+n);
	for(i=1;i<=n;i+=2)
		h1+=a[i];
	for(i=2;i<=n;i+=2)
		h2+=a[i];
	cout<<h1-h2<<"\n";
	
}

Measured memory_bytes: 256
N=parse(Int,readline())
A=map(x->parse(Int,x),split(readline()))
L=A[1]
R=sum(A)-L
ans=abs(L-R)
for i=2:N-1
  L+=A[i]
  R-=A[i]
  ans=min(ans,abs(L-R))
end
println(ans)

Measured memory_bytes: 153224
import java.util.*;
import java.util.Map.Entry;

//文字操作
class Main {
	Scanner sc = new Scanner(System.in);

	public void run() {
		Hashtable<Integer,Integer> data1=new Hashtable<Integer, Integer>();
		Hashtable<Integer,Integer> data2=new Hashtable<Integer, Integer>();

		while(sc.hasNext()){
			String[] str=sc.nextLine().split(",");
			if("".equals(str[0]))break;
			int[] vals=new int[]{Integer.parseInt(str[0]),Integer.parseInt(str[1])};
			if(data1.containsKey(vals[0])){
				data1.put(vals[0],data1.get(vals[0])+1);
			}else{
				data1.put(vals[0],1);
			}
		}
		while(sc.hasNext()){
			String[] str=sc.nextLine().split(",");
			if("".equals(str[0]))break;
			int[] vals=new int[]{Integer.parseInt(str[0]),Integer.parseInt(str[1])};
			if(data2.containsKey(vals[0])){
				data2.put(vals[0],data2.get(vals[0])+1);
			}else{
				data2.put(vals[0],1);
			}
		}
		ArrayList<Entry<Integer,Integer>> data1list=new ArrayList<Entry<Integer,Integer>>(data1.entrySet());
		Collections.sort(data1list,new Comparator<Entry<Integer,Integer>>() {
			@Override
			public int compare(Entry<Integer, Integer> o1,
					Entry<Integer, Integer> o2) {
				return o1.getKey()-o2.getKey();
			}
		});
		for(Entry<Integer,Integer> entry:data1list){
			if(data2.containsKey(entry.getKey())){
				ln(entry.getKey()+" "+ (entry.getValue()+data2.get(entry.getKey())));
			}
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public static void pr(Object o) {
		System.out.print(o);
	}

	public static void ln(Object o) {
		System.out.println(o);
	}

	public static void ln() {
		System.out.println();
	}
}

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

#define rep(i,n) for(int (i)=0;(i)<(n); ++(i))
using namespace std;

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

    while(1) {
        c -= b;
        if(c <= 0) {
            cout << "Yes" << endl;
            break;
        }

        a -= d;
        if(a <= 0) {
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3044
///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 2005
using namespace std;
int n,m;
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
    scanf("%d %d",&n,&m);
    vector<pair<int,int> > v;
    for(int i=0;i<m;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        v.push_back(make_pair(a,b));
    }
    sort(v.begin(),v.end());
    int ans=0;
    int l=v[0].first;
    int r=v[0].second;
    for(int i=1;i<m;i++){
        l=v[i].first;
        r=min(r,v[i].second);
        if(l>=r){
            ans++;
            r=v[i].second;
        }
    }
    cout<<ans+1<<endl;
	return 0;
}



Measured memory_bytes: 1400
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>


#define rep(i,p,q) for(int i = p;i < q;++i)
#define ll long long

using namespace std;


//133 A
int main(void) {
	int a, b, n;
	cin >> n >> a >> b;
	cout << min(a * n, b) << endl;
}


Measured memory_bytes: 256
# https://atcoder.jp/contests/abc084/tasks/abc084_b
a, b = map(int, input().split())

s = input()

if s.count('-') != 1:
    print('No')
else:
    l, r = s.split('-')
    if len(l) == a and len(r) == b:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 38384
N,X = map(int,input().split())

n_sum= X
answer = [0]
def saiki(layer,n_sum,sum_p):
    # print(layer,n_sum,sum_p)
    # if layer == 0:
    #     answer[0] = sum_p
    #     return
    if n_sum == 0:
        answer[0] = sum_p
        return 
    if layer == 1:
        if n_sum == 1:
            answer[0] = sum_p
        elif n_sum == 2:
            answer[0] = sum_p+1
        elif n_sum ==3:
            answer[0] = sum_p+2
        else:
            answer[0] = sum_p+3
        return

    ##現layerの合計を計算
    layer_sum = 2**(layer+2)-3
    ##前のlayerの合計を計算
    pre_layer_sum = 2**(layer+1)-3
    pre_p_sum = 2**(layer)-1
    #もし左側
    if n_sum  < layer_sum //2 +1 :
        # print("left")
        n_sum -= 1
        saiki(layer-1,n_sum,sum_p)
    
    else:
        # print("right")
        n_sum -= (pre_layer_sum+2)
        sum_p += (1+pre_p_sum)
        saiki(layer-1,n_sum,sum_p)

saiki(N,X,0)

print(answer[0])








Measured memory_bytes: 3064
import bisect
# from collections import defaultdict
N, M = map(int, input().split())

# d = defaultdict(int)

# for i in range(2, M+1):
#     while M % i == 0:
#         d[i] += 1
#         M //= i
#     if M == 1:
#         break


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors


divs = make_divisors(M)


i = bisect.bisect_right(divs, int(M/N))

print(divs[i-1])


Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	ll n;
	cin >> n;
	ll ans = 0;
	ll tmp = n % 11;

	if (tmp == 0) {
		ans = (n/11)*2;
	} else if (tmp <= 6) {
		ans = (n/11)*2 + 1;
	} else {
		ans = (n/11)*2 + 2;
	}
	cout << ans << endl;

}


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

int main() {
  int H,N;
  cin>>H>>N;
  int sum=0;
  int a;
  for(int i=0; i<N; i++){
    cin>>a;
    sum+=a;
  }
  if(sum>=H) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3632
# abc111_c_new

from collections import Counter


def solve(n, seq):
    odd = seq[::2]  # odd numbers of the seq
    even = seq[1::2]  # even numbers of the seq

    # print(odd)
    # print(even)

    # odd = Counter(odd).most_common()  # example -> returns [(1, 5), (2, 5)]
    # even = Counter(even).most_common()
    odd = sorted([(k, v) for k, v in Counter(odd).items()], key=lambda x: x[1], reverse=True)
    even = sorted([(k, v) for k, v in Counter(even).items()], key=lambda x: x[1], reverse=True)

    # print(odd)
    # print(even)

    sol = 0
    if odd[0][0] == even[0][0]:
        if len(odd) == 1 and len(even) == 1:  # seq [1, 1, 1, 1]  (special case)
            sol = int(n // 2)  # [1, 1, 1, 1] sol = N / 2
        else:
            if len(odd) >= 2 and len(even) >= 2:
                sol = min(n - odd[0][1] - even[1][1], n - odd[1][1] - even[0][1])
            else:
                if odd[0][1] > even[1][1]:
                    # sol = n - odd[0][1] - even[1][1] ==
                    sol = (n // 2 - odd[0][1]) + (n // 2 - even[1][1])
                else:
                    # sol = n - odd[1][1] - even[0][1] ==
                    sol = (n // 2 - odd[1][1]) + (n // 2 - even[0][1])
    else:
        # sol = n - odd[0][1] - even[0][1] ==
        sol = (n // 2 - odd[0][1]) + (n // 2 - even[0][1])

    return sol


if __name__ == "__main__":
    n = int(input())
    seq = list(map(int, input("").split(" ")))
    print(solve(n, seq))


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

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

bool isPrime(ll num) {
    if (num < 2) return false;

    for (ll i = 2; i * i <= num; i++) {
        if (num % i == 0) {
            return false;
        }
    }
    return true;
}

vector<pair<ll, ll >> prime_factorize(ll n) {
    vector<pair<ll, ll>> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) continue;
        int num = 0;
        while (n % i == 0) {
            num++;
            n /= i;
        }
        res.push_back(make_pair(i, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));

    return res;
}

int main() {
    ll n;
    cin >> n;
    auto x = prime_factorize(n);
    ll ans = 0;

    // for (int i = 0; i <= 14; i++) {
    //     cout << x[i].first << " " << x[i].second << endl;
    // }

    for (auto i:x) {
        ll current = i.first;
        while (n % current == 0) {
            ans++;
            n /= current;
            current *= i.first;
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580