akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> inline int Log2(T& x) {int k; for(k=0; (T(1)<<k)<=x; ++k); return k;} // number of binary digits


int main() {
  ll X, Y, A, B, C; cin >> X >> Y >> A >> B >> C;
  priority_queue<Pll> pq;
  rep(i, A) {int p; cin >> p; pq.push(Pll(p, 0));};
  rep(i, B) {int p; cin >> p; pq.push(Pll(p, 1));};
  rep(i, C) {int p; cin >> p; pq.push(Pll(p, 2));};

  int cnta = 0;
  int cntb = 0;
  int cntc = 0;
  ll ans = 0;

  while (cnta + cntb + cntc < X + Y) {
    ll x, y;
    tie(x, y) = pq.top(); pq.pop();

    if (y == 0) {
      if (cnta < X) {
        ans += x;
        cnta++;
      }
    }
    else if (y == 1) {
      if (cntb < Y) {
        ans += x;
        cntb++;
      }
    }
    else {
      ans += x;
      cntc++;
    }
  }

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


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

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
if N == 1: print(0)
else:
    lst = factorization(N)
    ans = 0
    for f, i in lst:
        cnt = i
        for j in range(1, i+1):
            if cnt - j > j:
                ans += 1
                cnt -= j
            else:
                ans += 1
                break
    print(ans)

Measured memory_bytes: 9496
import collections
N=int(input())
A=list(map(int,input().split(' ')))
counter=collections.Counter(A)
Y=sorted(list(counter.keys()))
ans=-1
if max(Y)-min(Y)<=2:
  ans=N
else:
  Y_all = [ counter[i] for i in range(min(Y),max(Y)+1) ]
  for i in range(len(Y_all)-2):
    ans = max(sum(Y_all[i:i+3]), ans)
print(ans)

Measured memory_bytes: 14564
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define pii pair<int, int>
#define tii tuple<int, int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{

    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

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

	char c; cin>>c;
	if(c>='A' && c<='Z') cout<<"A"<<endl;
	else cout<<'a'<<endl;    

}

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

int main(){
    
    cin.tie(0);
    ios::sync_with_stdio(false);
   
    int n;
    cin >> n;
    
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    
    ll ans = 0;
    
    int cnt = 0;
    
    for(int i = 0; i <= n; i++){
        if(a[i+1] == a[i]){
            if(cnt == 0) ans = a[i];
            else if(cnt == 1) ans *= a[i];
            i++;
            cnt++;
        }
        if(cnt == 2) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(void){
	int i,j,sum=0,ans=1;
	
	int n,x;
	
	scanf("%d%d",&n,&x);
	
	int l[n+1];
	for(i=1;i<=n;i++){
		scanf("%d",&l[i]);
	}
	
	for(i=1;;i++){
		sum+=l[i];
		if(sum<=x){
			ans++;
		}else{
			break;
		}
	}
	
	printf("%d\n",ans);	
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <functional>
using namespace std;
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#define	ll long long
#define	ull unsigned long long
#define	vi vector<int>
#define	vll vector<long long>
#define	pii pair<int,int>
#define	pll pair<long long,long long>
#define	PB push_back
#define	MP make_pair
#define	ff first
#define	ss second
#define	IT iterator
#define	IOS ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define	LB cout<<"\n"
#define	CS <<" "<<
#define	DB cout<<"> "
#define	endl "\n"
#define	loop(x,y) for(int x=0;x<y;++x)
#define	loop1(x,y) for(int x=1;x<=y;++x)
#define	MS(x,y) memset(x,y,sizeof(x))

int n;
int a[101];
int s[2];


int main(){
	cin >> n;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a,a+n,greater<int>());
	for(int i=0; i<n; i++) s[i%2] += a[i];
	cout << s[0]-s[1] << endl;
}

Measured memory_bytes: 256
N = int(input())
X_list = list(map(int,input().split()))

P = 0
min_sum = 100 ** 2 * 100
while(True):
  sum = 0
  for x in range(N):
    sum += (X_list[x]- P) ** 2
  if(sum <= min_sum):
    min_sum = sum
    P += 1
    continue
  else:
    break

print(min_sum)

Measured memory_bytes: 3060
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] str=br.readLine().split(" ");
			int H=Integer.parseInt(str[0]);
			int W=Integer.parseInt(str[1]);
			
			if(H==0&&W==0) break;
			
			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++){
					System.out.print("#");
				}
				System.out.println();
			}
		System.out.println();
		}
	}
}

Measured memory_bytes: 32760
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll read()
{
    char ch=getchar();
    ll x=0,f=1;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
priority_queue<ll,vector<ll>,greater<ll> > qa,qb;
priority_queue<ll> qo,t;
int main()
{
    ll xx,y,a,b,c;
    ll x,ans=0;
    cin>>xx>>y>>a>>b>>c;

    while(!t.empty())
        t.pop();
    for(int i=0;i<a;i++)
    {
        x=read();
        t.push(x);
    }
    for(int i=0;i<xx;i++)
    {
        x=t.top();
        t.pop();
        qa.push(x);
    }

    while(!t.empty())
        t.pop();
    for(int i=0;i<b;i++)
    {
        x=read();
        t.push(x);
    }
    for(int i=0;i<y;i++)
    {
        x=t.top();
        t.pop();
        qb.push(x);
    }
	for(int i=0;i<c;i++)
    {
        x=read();
        qo.push(x);
    }
    
    ll to,ta,tb;
    while(1)
    {
        to=qo.top();
        ta=qa.top();
        tb=qb.top();
        /*
        if(to<=ta&&to<=tb)
            break;
        */
        if(ta>tb)
        {
            if(tb<=to)
            {
                qb.pop();
                qb.push(to);
                qo.pop();
                if(qo.empty())
                	break;
                	
            }
            else
                break;
        }
        else
        {
            if(ta<=to)
            {
                qa.pop();
                qa.push(to);
                qo.pop();
                if(qo.empty())
                	break;
                	
            }
            else
                break;
        }
    }
    while(!qa.empty())
    {
        ans+=qa.top();
        qa.pop();
    }
    while(!qb.empty())
    {
        ans+=qb.top();
        qb.pop();
    }
    cout<<ans<<endl;
	return 0;
}
/*
20 5
0 5 10 17 19
*/

Measured memory_bytes: 3956
n,l = map(int,input().split())

t = [(l + i - 1) for i in range(1,n + 1)]

if t[0] >= 0:
    p = sum(t) - l
elif t[-1] > 0:
    p = sum(t)
else:
    p = sum(t) - t[-1]

print(p)

Measured memory_bytes: 3060
# 169A
# A×Bを整数として出力せよ。

# 1.入力をプログラムで扱えるように受け取る事
a, b = map(int, input().split())
# print(a, b)

# 2.受け取った入力値を使って、適切に処理（計算）すること
answer = a * b

# 3.計算した結果を出力すること
print(answer)

Measured memory_bytes: 9016
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;
const int di[4] = { -1, 0, 1, 0 };
const int dj[4] = { 0, -1, 0, 1 };
int main() {
    int n;
    cin >> n;
    vector<int> a(n * n);
    vector<vector<int>> dist(n, vector<int>(n));
    vector<vector<int>> exist(n, vector<int>(n, 1));
    for (int i = 0, x = 0, y = 0; i < n * n; i++, y = (y + 1) % n) {
        cin >> a[i];
        a[i]--;
        dist[x][y] = min({ x, y, n - x - 1, n - y - 1 });
        if ((i + 1) % n == 0) {
            x++;
        }
    }
    queue<pair<int, int>> q;
    vector<vector<bool>> inq(n, vector<bool>(n));
    int ans = 0;
    for (int id : a) {
        int i = id / n, j = id % n;
        ans += dist[i][j];
        exist[i][j] = 0;
        q.emplace(i, j);
        while (!q.empty()) {
            int mi, mj;
            tie(mi, mj) = q.front();
            q.pop();
            inq[mi][mj] = false;
            int val = dist[mi][mj] + exist[mi][mj];
            for (int d = 0; d < 4; d++) {
                int ni = mi + di[d], nj = mj + dj[d];
                if (ni >= 0 && nj >= 0 && ni < n && nj < n &&
                    val < dist[ni][nj]) {
                    dist[ni][nj] = val;
                    if (!inq[ni][nj]) {
                        q.emplace(ni, nj);
                        inq[ni][nj] = true;
                    }
                }
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 6344
import java.util.*;

public class Main {
    static int N;
    static ArrayList<Node> list;
    static long[][] dp;
    static int mod = 1_000_000_007;

    public static class Node {
        public ArrayList<Integer> neighbor;
        public int parent;
        public ArrayList<Integer> children;

        public Node() {
            this.neighbor = new ArrayList<Integer>();
            this.parent = -2;
            this.children = new ArrayList<Integer>();
        }
    }

    static void dfs(int from) {
        for (Integer to : list.get(from).neighbor) {
            if (list.get(to).parent!=-2) continue;
            list.get(from).children.add(to);
            list.get(to).parent = from;
            dfs(to);
        }
    }

    static long[] dfs_dp(int from) {
        long[] tmp = new long[2]; // tmp[0]->white tmp[1]->black
        tmp[0] = 1;
        tmp[1] = 1;
        if (dp[from][0]!=-1 && dp[from][1]!=-1) {
            tmp[0] = dp[from][0];
            tmp[1] = dp[from][1];
            return tmp;
        } else {
            for (Integer child : list.get(from).children) {
                long[] add = dfs_dp(child);
                tmp[0] = (tmp[0]*(add[0]+add[1])%mod)%mod;
                tmp[1] = (tmp[1]*add[0])%mod;
            }
            dp[from][0] = tmp[0];
            dp[from][1] = tmp[1];
            return tmp;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        list = new ArrayList<Node>();
        for (int i=0;i<N;i++) {
            Node add = new Node();
            list.add(add);
        }
        for (int i=0;i<N-1;i++) {
            int x = Integer.parseInt(sc.next())-1;
            int y = Integer.parseInt(sc.next())-1;
            list.get(x).neighbor.add(y);
            list.get(y).neighbor.add(x);
        }

        list.get(0).parent = -1;
        dfs(0);

        dp = new long[N][2];
        for (int i=0;i<N;i++) {
            for (int j=0;j<2;j++) {
                dp[i][j] = -1;
            }
        }
        dfs_dp(0);
        System.out.println((dp[0][0]+dp[0][1])%mod);
    }
}

Measured memory_bytes: 110008
#include <iostream>
using namespace std;
int main (int argc, const char * argv[])
{
    int h,m,s,S;
    cin >>S;
    h=S/3600;
    m=S%3600/60;
    s=S%3600%60;
    // insert code here...
    cout <<h<<":"<<m<<":"<<s<<endl;
    return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mod 1000000007
#define fi first
#define se second
#define pb push_back
#define IOS ios_base::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);

using namespace std;

int main()
{
    IOS;
    int n,k;
    string s;
    cin>>n>>k;
    cin>>s;
    for(int i=0;i<n;i++)
    {
        if(i==k-1) cout<<char(tolower(s[i]));
        else cout<<s[i];
    }
    return 0;
}

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

#define rep1(i, a, n) for (int i = a; i < n; i++)
#define rep2(i, a, n) for (int i = n; i >= a; i--)
#define asc(v) sort(v.begin(), v.end())
#define desc(v) sort(v.begin(), v.end(), greater<int>())

using namespace std;

int main() {
  int N, ptr = 0, ans = 0;
  cin >> N;
  vector<int> A(N, 0);
  rep1(i, 0, N) cin >> A[i];
  asc(A);
  while (ptr < N) {
    int cur = A[ptr], cnt = 0;
    while (ptr < N && cur == A[ptr]) {
      cnt++;
      ptr++;
    }
    ans += cnt % 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
 
using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);
 
 
int main(){
  FAST_IO  
  
  int N; cin >> N;
  int count[5] = {0};

  for(int rep = 0; rep < N; ++rep){
    string s; cin >> s;
    if(s[0] == 'M') count[0]++;
    else if(s[0] == 'A') count[1]++;
    else if(s[0] == 'R') count[2]++;
    else if(s[0] == 'C') count[3]++;
    else if(s[0] == 'H') count[4]++;
  }

  LL ways = 0;

  for(int start = 0; start < 5; ++start){
    for(int mid = start + 1; mid < 5; ++mid){
      for(int end = mid + 1; end < 5; ++end){
        ways += (LL)count[start] * count[mid] * count[end];
      }
    }
  }

  cout << ways << "\n";

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;


int main() {
    int N;
    cin >> N;
    int a;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        cin >> a;
        ans += a - 1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
a = input()
b = int(a[:2])
c = int(a[2:])
if 0 < b <= 12 and 0 < c <= 12:
    print("AMBIGUOUS")
elif 0 < b <= 12:
    print("MMYY")
elif 0 < c <= 12:
    print("YYMM")
else:
    print("NA")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double W, H, x, y, S;
  cin >> W >> H >> x >> y;
  S = W * H / 2;
    W = W / 2;
    H = H / 2;
  if (W == x && H == y){
    cout << S << " " << 1 << endl;
  }
  else{
    cout << S << " "<< 0 << endl;
  }
}

Measured memory_bytes: 384
X,Y,Z,K=map(int,input().split())
A= list(map(int,input().split()))
B= list(map(int,input().split()))
C= list(map(int,input().split()))
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
ans=[]
for i in range(min(X,K)):
 D=int(K/(i+1))+1
 for j in range(min(D,Y,K)):
  E=int(D/(j+1))+1
  for k in range(min(E,Z,K)):
   ans.append(A[i]+B[j]+C[k])
ans.sort(reverse=True)
for i in range(K):
 print(ans[i])


Measured memory_bytes: 9940
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int constant(int day)//1~26 順番
{
  return day%type+1;
}
int get_random()//1~26 ランダム
{
  return rand()%type+1;
}
int max(int s[][type+1],int day)//その日の最大の満足度選ぶ
{
  int m,max_score=0,i;
  for(i=1;i<=type;i++)
  {
    if(s[day][i]>max_score){
      max_score=s[day][i];
      m=i;
    }
  }
  return m;
}
void cal(int select,int c[type+1],int last[type+1],int s[][type+1],int day,int sum[])
{
  int i;
  sum[day]=sum[day-1]+s[day][select];
  for(i=1;i<=type;i++){
    sum[day]-=c[i]*(day-last[i]);
  }
}
int change(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D,int d)
//ランダムに変更
{
  int t,old,total=0,i,j;
  d+=(rand()%20+1);
  d=d%D;
  t=rand()%type+1;
  old=schedul[d];
  schedul[d]=t;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
  //  printf("change\n");
    sum[D]=total;
  }
  else{
    schedul[d]=old;
  }
  return d;
}
int main(void)
{
  int D,c[type+1],i,j;
  clock_t start,stop;
  srand((unsigned int)time(NULL));
  scanf("%d",&D);//D=365
  int s[D+1][type+1],last[type+1],sum[D+1],schedul[D+1];
  for(i=0;i<=D;i++) sum[i]=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=type;i++) scanf("%d",&c[i]);
  for(i=1;i<D+1;i++){
    for(j=1;j<=type;j++) scanf("%d",&s[i][j]);
  }
  start=clock();
  for(i=1;i<D+1;i++){
    int select;
    select=constant(i);
    last[select]=i;
    schedul[i]=select;
    cal(select,c,last,s,i,sum);
    //printf("%d\n",sum[i]);
  }
  int count=0,aa=0;
  stop=start;
  while((double)(stop - start) / CLOCKS_PER_SEC<1.98){
    aa=change(c,last,s,sum,schedul,D,aa);
    count++;
    stop=clock();
  }
  /*
  printf("count:%d\n",count);
  printf("time:%f\n",(double)(stop - start) / CLOCKS_PER_SEC);
  printf("%d\n",sum[D]);
  printf("確認\n");
  int total=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  printf("%d\n",total);
  */
  for(i=1;i<=D;i++) printf("%d\n",schedul[i]);
  return 0;
}


Measured memory_bytes: 1816
#include<iostream>
#include<cmath>
using namespace std;
int count;
void doit(int p,int q,double a,int n,int bx){
    if(n>0){
        int x=bx;
        double A =a;
        if(bx==0){
            x++;
        }else{
            A=a/bx;
        }   
        while(x<=A){
            if(p*x>q){
                doit(x*p-q,x*q,A,n-1,x);   
            }else if(p*x==q){
                count++;
            }
            x++;
        }
    }
    return;
}
int main(){
    int p,q,a,n;
    while(true){
        cin>>p>>q>>a>>n;
        if(p==0){
            break;
        }else{
            count =0;
            doit(p,q,a,n,0);
            cout<<count<<endl;
            count=0;
        }
    }
    return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n,k;
    cin>>n>>k;
    ll ans=0;
    for(int i=k+1;i<=n;i++)
    {
        for(int j=0;j<=n;j+=i)
        {
            ans+=max(0,min(n-j+1,i)-k);
            if(j==0&&k==0) ans--;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let n = get!(i32);
    let mut i = 2;
    while i <= n {
        i *= 2;
    }
    println!("{}", i / 2);
}

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

//Function Macros:
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define setpre(n) cout << fixed << setprecision(n)

//Type Definitions:
typedef long long ll;
typedef unsigned long long ull;

//Constants:
const int INF = 2e9;
const int MOD = 1e9 + 7;

//Global Variables:

//Prototype Declarations:
int gcd(int, int);

//================ Main Loop ================
int main()
{
    ll n, a, b, c, d, e;
    cin >> n >> a >> b >> c >> d >> e;
    cout << (ll)ceil((double)n / min(a, min(b, min(c, min(d, e))))) + 4 << endl;
    return 0;
}
//===========================================

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

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

using namespace std;

typedef pair<int, int> P;

// .#迷路において、(i, j) がフィールド内であれば行き先をvectorで返す。
vector<P> possible_distination(P cur, int H, int W){
    vector<P> dist;
    int i = cur.first;
    int j = cur.second;
    if(0 <= i-1) dist.push_back({i-1, j});
    if(0 <= j-1) dist.push_back({i, j-1}); 
    if(i+1 <= H) dist.push_back({i+1, j});
    if(j+1 <= W) dist.push_back({i, j+1});
    return dist;
}

// .#の迷路の最短距離を返す。スタートが(a,b)でゴールが(c, d)
int maze_solver(string * G, int H, P s, P g){
    int W = G[0].length();
    bool vis[H][W]; for(int i=0; i<H; i++) fill(vis[i], vis[i] + W, false);
    vis[s.first][s.second] = true;
    queue< pair <int, P > > q;
    q.push({0, s});
    int ans = -1; // 辿り着けなかったら-1を返す。
    while(!q.empty()){
        auto cur = q.front(); q.pop();
        auto cur_pos = cur.second;
        auto cur_d = cur.first;
        if(cur_pos == g){
            ans = cur_d;
            break;
        }
        auto pd = possible_distination(cur_pos, H, W);
        for(auto dist : pd){
            if(G[dist.first][dist.second] == '.' && !vis[dist.first][dist.second]){
                q.push({cur_d + 1, dist});
                vis[dist.first][dist.second] = true;
            }
        }
    }
    return ans;
}

int main(){
    int H, W;
    cin >> H >> W;
    string G[H];
    for(int i=0; i<H; i++) cin >> G[i];    
    int ini_white = 0;
    for(int i=0; i<H; i++){
        for(int j=0; j<W; j++){
            if(G[i][j] == '.') ini_white++;
        }
    }
    int dist = maze_solver(G, H, {0, 0}, {H-1, W-1});
    if(dist == -1) cout << -1 << endl;
    else{
        cout << ini_white - dist - 1 << endl;
        //cout << "dist = " << dist << endl;
        //cout << "white = " << ini_white << endl;
    }
    return 0;
}
/*
2 2
..
..
*/

Measured memory_bytes: 256
n=int(input())
b=200
s=0
for i in range(n):
  a=int(input())
  s+=a
  if a%10!=0:
    b=min(b,a)
if s%10!=0:
  print(s)
elif b<200:
  print(s-b)
else:
  print(0)

Measured memory_bytes: 3060
#include"stdio.h"

int num;
int time;
int start;
int end;
int ans = 0;

int main() {
	scanf("%d %d %d", &num, &start, &end);
	for (int i = 0; i < num; i++) {
		scanf("%d", &time);
		if (time < start || time >= end)ans++;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    string s,t;cin>>s>>t;
    int res=2*n;
    rep(i,n){
        bool ok=true;
        rep(j,n-i){
            if(s[i+j]!=t[j]){
                ok=false;
                break;
            }
        }
        if(ok)chmin(res,i+n);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3596
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;



int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    char c;
    cin >> c;
    cout << ((c=='a'||c=='i'||c=='u'||c=='e'||c=='o')? "vowel":"consonant")<<endl;
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"bufio"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}

func parseStringSlice(a []int, n int) []string {
	s := make([]string, len(a))
	for i := 0; i < len(a); i++ {
		if i == n {
			s[i] = "[" + strconv.Itoa(a[i]) + "]"
		} else {
			s[i] = strconv.Itoa(a[i])
		}
	}
	return s
}

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

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	A := make([]int, n)

	for i := 0; i < n; i++ {
		A[i] = nextInt()
	}

	idx := partition(A, 0, n)
	ans := parseStringSlice(A, idx)
	fmt.Println(strings.Join(ans, " "))
}


Measured memory_bytes: 5520
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	if (s[0] != s[1] || s[1] != s[2])cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef DEMETRIO
#define deb(...) fprintf(stderr,__VA_ARGS__)
#define deb1(x) cerr << #x << " = " << x << endl
#else
#define deb(...) 0
#define deb1(x) 0
#endif
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define SZ(x) ((int)x.size())
using namespace std;
typedef long long ll;

int main(){
	int n,a,b;
	scanf("%d%d%d",&n,&a,&b);
	puts((b-a)%2?"Borys":"Alice");
	return 0;
}

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

using namespace std;

#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repp(i,a,b) for(int i=a;i>=b;i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define ll long long


typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<ll> vll;

const long long mod=1000000007;

int n,m,x,y,z,sz;
vector<vi> g;
bool visited[100001];

void dfs(int u) {
	visited[u]=true;
	rep(i,0,(int)g[u].size()-1) {
		int v=g[u][i];
		if(!visited[v]) dfs(v);
	}
}

signed main() {
	   fastio;
	   // freopen(".inp","r",stdin); freopen(".out","w",stdout);
	   cin >> n >> m;
	   g.assign(n+1,vi());
	   memset(visited,false,sizeof(visited));
	   rep(i,1,m) {
	   	cin >> x >> y >> z;
	   		g[x].pb(y);
	   		g[y].pb(x);
	   }
	   sz=0;
		rep(i,1,n) {
			if(!visited[i]) {
				dfs(i);
				sz++;	
			}
		}
	   cout << sz;
}



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

int main() {
	int a, b;
	while (cin >> a >> b) {
		int sum = a + b;
		int i = 1;
		int count = 0;
		while (sum / i != 0) {
			count++;
			i *= 10;
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3068
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

def search3(w,v,n):
    res = 0
    for n1 in range(n//w[0]+1):
        for n2 in range((n-w[0]*n1)//w[1]+1):
            n3 = (n-w[0]*n1-w[1]*n2)//w[2]
            res = max(res,n+(v[0]-w[0])*n1+(v[1]-w[1])*n2+(v[2]-w[2])*n3)
    return res

def search2(w,v,n):
    res = 0
    for n1 in range(n//w[0]+1):
        n2 = (n-w[0]*n1)//w[1]
        res = max(res,n+(v[0]-w[0])*n1+(v[1]-w[1])*n2)
    return res

AB = [[A[0]-B[0],A[0],B[0]],[A[1]-B[1],A[1],B[1]],[A[2]-B[2],A[2],B[2]]]
AB.sort()
A = [AB[i][1] for i in range(3)]
B = [AB[i][2] for i in range(3)]

if AB[0][0]>0:
    ans = search3(B,A,N)
elif AB[1][0]>0:
    n = N+(B[0]-A[0])*(N//A[0])
    ans = search2(B[1:],A[1:],n)
elif AB[2][0]>0:
    n = search2(A[:2],B[:2],N)
    ans = n+(A[2]-B[2])*(n//B[2])
else:
    ans = search3(A,B,N)

print(ans)

Measured memory_bytes: 39408
#!/bin/bash
 
read a b c
 
if [ ${a} == ${b} ] && [ ${b} == ${c} ]; then
cnt=1
else
  if [ $a != $b ] && [ $b != $c ] && [ $a != $c ]; then
    cnt=3
  else
    cnt=2
  fi
fi  
echo $cnt

Measured memory_bytes: 376
program main
	implicit none
    integer i,j,n,k
    integer,allocatable :: p(:),q(:)
    
    read(*,*) n,k
    allocate(p(n))
    read(*,*) (p(i),i=1,n)
    allocate(q(n-k+1))
    q(:)=0
    do i=1,k
       q(1)=q(1)+p(i)
    end do    
    do i=2,n-k+1
       q(i)=q(i-1)-p(i-1)+p(i+k-1)
    end do

    write(*,'(f0.12)') real(maxval(q)+k)/2.0e0
end program main

Measured memory_bytes: 2304
n,A,B,C=map(int,input().split())
r=[A,B,C]
g=list()
for i in range(n):
    g.append(str(input()))
    
def re(string):
    if string=="AB":
        return(0,1)
    elif string=="AC":
        return(0,2)
    else:
        return(1,2)
    
def al(num):
    if num==0:
        return "A"
    elif num==1:
        return "B"
    else:
        return "C"
    
flag=0
result=list()
for i in range(n):
    a,b=re(g[i])
    if r[a]==0 and r[b]==0:
        print("No")
        flag=1
        break
    elif r[a]>r[b]:
        r[a]-=1
        r[b]+=1
        result.append(al(b))
    elif r[a]<r[b]:
        r[a]+=1
        r[b]-=1
        result.append(al(a))
    else:
        if i+1==n:
            r[a]+=1
            r[b]-=1
            result.append(al(a))
            break
        x,y=re(g[i+1])
        if (x,y)==(a,b):
            r[a]+=1
            r[b]-=1
            result.append(al(a))
        else:
            if x in (a,b):
                r[x]+=2
                r[a]-=1;r[b]-=1
                result.append(al(x))
            else:
                r[y]+=2
                r[a]-=1;r[b]-=1
                result.append(al(y))
        
if flag==0:
    print("Yes")
    for item in result:
        print(item)

Measured memory_bytes: 17096
#include<bits/stdc++.h>
using namespace std;
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define F first
#define S second
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define vpp vector<pair<long long,long long>>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define d0(x) cout<<(x)<<" "
#define c1(x) cin>>(x)
#define c2(x,y) cin>>(x)>>(y)
#define c3(x,y,z) cin>>(x)>>(y)>>(z)
#define c4(w,x,y,z) cin>>(w)>>(x)>>(y)>>(z)
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define d5(a,b,c,d,e) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<" "<<(e)<<endl
#define fo(i,a,b) for(int i=a;i<b;i++)
#define alld(c) (c).rbegin(),(c).rend()
#define alli(c) (c).begin(),(c).end()
#define ll long long
const int M=1e9+7;

int main()
{
	int t=1;
	while(t--)
	{
		int n; cin>>n;
		map<string,int> mp;
		for(int i=0;i<n;i++)
		{
			string st; cin>>st;
			mp[st]++;
		}

		cout<<"AC"<<" "<<"x"<<" "<<mp["AC"]<<endl;
		cout<<"WA"<<" "<<"x"<<" "<<mp["WA"]<<endl;
		cout<<"TLE"<<" "<<"x"<<" "<<mp["TLE"]<<endl;
		cout<<"RE"<<" "<<"x"<<" "<<mp["RE"]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3568
#include<cstdio>
int main ()
{
    int n,k,m,p,q,ans,cnt;
    while(1){
        scanf("%d%d",&n,&k);
        if(n==0&&k==0)break;
        p=1,ans=0,cnt=0;
        int N[100002]={0};
        for(int i=0;i<k;i++){
            scanf("%d",&m);
            if(m==0) p=0;
            else N[m]=1;
        }
        if(p==0){
            for(int i=1;i<=n+1;i++){
                if(N[i]==1)cnt++;
                else if(N[i]==0&&p==0){
                    p=1;
                    cnt++;
                    q=i;
                }
                else if(N[i]==0&&p==1){
                    if(ans<cnt)ans=cnt;
                    cnt=0;
                    i=q;
                    q=0;
                    p=0;
                }
            }
        }
        else {
            for(int i=1;i<=n+1;i++){
                if(N[i]==1)cnt++;
                else {
                    if(ans<cnt){
                        ans=cnt;
                        cnt=0;
                    }
                    cnt=0;
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

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

    if(N % 10 == 2 || N % 10 == 4 || N % 10 == 5 || N % 10 == 7 || N % 10 == 9) cout << "hon" << endl;
    else if(N % 10 == 0 || N % 10 == 1 || N % 10 == 6 || N % 10 == 8) cout << "pon" << endl;
    else if(N % 10 == 3) cout << "bon" << endl;

    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
    #include <cstdio>
    #include <algorithm>
    #include <vector>
    #include <string>
    #include <string.h>
     
    typedef long long ll;
    using namespace std;
    const ll INF = 1000000000000000000ll;
    const ll MOD = 1000000007ll;
     
    const double EPS = 1e-8;
     
    int main()
    {
   		long A,B,C,D;

		cin >> A >> B >> C >> D;

		cout << max(A*B,C*D);

		return 0;
    }

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    int b=sc.nextInt();
    int x=sc.nextInt();
    if (a>x) {
      System.out.println("NO");
    }else{
      if ((x-a)<=b) {
        System.out.println("YES");
      }else{
        System.out.println("NO");
      }
    }
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fi first
#define se second
const int N=2e6+1;
int n,k;
char c[N];
int main(){
	ios::sync_with_stdio(false);
	ll d;
	cin >> d;
	if(d>=30) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstring>
#include <queue>
#include <iostream>
#include<bits/stdc++.h>
typedef long long int ll;
const int maxn=1e6+7;
using namespace std;
//四步走，
//确定状态 1、最后一步2、化成子问题
//转移方程
//初始条件和边界情况
//计算顺序，确保要用到的都算过
int main()
{
    int n,x,t;
    cin>>n>>x>>t;
    int ans;
    int l=n/x;
    if(n%x==0)ans=l*t;
    else{
        ans=(l+1)*t;
    }
    printf("%d\n",ans);
    return 0;
}

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

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

int N;
int A[101010],ok[101010];
int B[101010];
pair<int,int> P[101010];
set<int> add[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>A[i];
	FOR(i,N) cin>>B[i];
	FOR(i,N) {
		P[i]={B[i],A[i]};
	}
	sort(A,A+N);
	sort(B,B+N);
	FOR(i,N) {
		if(B[i]<A[i]) return _P("No\n");
	}
	sort(P,P+N);
	FOR(i,N) {
		A[i]=P[i].second;
		B[i]=P[i].first;
	}
	FOR(i,N) {
		ok[i]=lower_bound(B,B+N,A[i])-B;
		//cout<<i<<" "<<A[i]<<" "<<B[i]<<" "<<ok[i]<<endl;
		add[ok[i]].insert(i);
	}
	
	set<int> S;
	FOR(i,N-1) {
		FORR(e,add[i]) S.insert(e);
		//cout<<i<<" "<<S.size()<<endl;
		assert(S.size());
		if(S.count(i)) return _P("Yes\n");
		
		x=*S.rbegin();
		S.erase(x);
		swap(A[i],A[x]);
		swap(ok[i],ok[x]);
		add[ok[x]].erase(i);
		add[ok[x]].insert(x);
	}
	cout<<"No"<<endl;
	
}


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


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
 
using ll = int64_t;
constexpr ll mod = ll(1e9 + 7);
 
int main () {
  ios::sync_with_stdio(0); cin.tie(0);
 
  int TT = 1;
//  cin >> TT;
  while (TT--) {
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (auto& x : A) cin >> x;
    ll all_xor = 0;
    for (int i = 0; i < N; ++i) {
      all_xor ^= A[i];
    }
    for (int i = 0; i < N; ++i) {
      cout << (all_xor ^ A[i]) << " ";
    }
    cout << endl;


//    for (auto& x : ans) cout << x << endl;
  }
}


Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"

#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

#define vi vector<int>
#define vl vector<ll>
#define vvi vector<vector<int>>
#define vvl vector< vector<long long>>
#define mi map<int,int>
#define pi pair<int,int>

#define Fori(i,a,b) for(int i=a; i<b; i++)
#define Ford(i, a, b) for(int i=a; i>=b; i--)

#define pb push_back
#define mp make_pair

#define read(a, n) for(int i=0; i<n; i++) cin >> a[i];
#define print(x) cout << "X: == " << x << endl;
#define printMap(a) for(auto it=a.begin() ; it!= a.end() ; it++) {cout << it->first << "  " << it->second << endl; }
#define printVector(a) for(auto it = a.begin() ; it!= a.end() ;it++) {cout << *it << endl;}

#define MOD 1000000007
using namespace std;
int main() {
    IOS
    ll n;
    cin >> n; 
    vl a(n);
    read(a, n);
    sort(a.begin(), a.end());
    ll tri = 0;
    Fori(i, 0, n) {
        Fori(j, i+1, n) {
            if(a[i] == a[j])continue;
            ll sum = a[i] + a[j];
            Fori(k, j+1, n) {
                if(a[j] == a[k] || a[i] == a[k]) continue;
                if(a[k] < sum)tri++;
            }
        }
    }
    cout << tri << endl;
    return 0;
}

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

using namespace std;

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

    /*
     * ans.at[i].at(0) : i番目を-1倍したときの最大値
     * ans.at[i].at(1) : i番目を-1倍しなかったときの最大値 */
    vector<vector<long long>> ans(N+1, {0, 0});
    ans.at(1).at(0) = -1 * A.at(1);
    ans.at(1).at(1) = A.at(1);
    for ( int i=2; i<N; i++ ) {
        ans.at(i).at(0) = max(ans.at(i-1).at(0) + A.at(i),  /* i-1番目とi番目を-1倍した場合 */
                              ans.at(i-1).at(1) - A.at(i)); /* i番目だけ-1倍した場合 */
        ans.at(i).at(1) = max(ans.at(i-1).at(0) - A.at(i),
                              ans.at(i-1).at(1) + A.at(i));
    }

    long long final_ans = max(ans.at(N-1).at(0) - A.at(N), ans.at(N-1).at(1) + A.at(N));
    cout << final_ans << endl;
    return 0;
}


Measured memory_bytes: 6528
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;

namespace Atcoder_Answer
{
    class Program
    {
        const int mod = 1000000007;

        static void Main(string[] args)
        {
            int N = int.Parse(ReadLine());
            string[] Reader = ReadLine().Split(' ');
            int[] As = Reader.Select(int.Parse).ToArray();
            List<int> ABody = new List<int>();
            ABody.AddRange(As);

            ABody.Sort((a, b) => a - b);

            bool Ret = true;
            for (int loop = 0; loop < N - 1; loop++) 
            {
                if (ABody[loop] == ABody[loop + 1]) 
                {
                    Ret = false;
                    break;
                }
            }

            if (Ret) WriteLine("YES");
            else WriteLine("NO");
        }

    }

    public static class Extension
    {
        #region 拡張:bool
        #region キャスト関連
        public static int ToInt(this bool Bool)
        {
            if (Bool) return 1;
            else return 0;
        }

        public static string ToString(this bool Bool, string TrueStr, string FalseStr)
        {
            if (Bool) return TrueStr;
            else return FalseStr;
        }
        #endregion
        #endregion

        #region 拡張:int
        #region キャスト関連
        public static char ToAlphaBets(this int Base) => (char)Base;
        #endregion
        #endregion

        #region 拡張:char
        #region 変換関連
        public static char NextAlpha(this char Char) => (char)((Char) + 1); //次の文字を取得
        #endregion
        #endregion

        #region 拡張:int[]
        public static long Sum(this int[] Array)
        {
            int Ret = 0;
            for (int loop = 0; loop < Array.Length; loop++) Ret += Array[loop];
            return Ret;
        }
        #endregion

        #region 拡張: string
        public static string Multi(this string THIS, int Value) 
        {
            string RetValue = "";

            for (int loop = 0; loop < Value; loop++) RetValue += THIS;

            return RetValue;
        }
        #endregion
    }
}


Measured memory_bytes: 33504
#include <cstdio>
#include <cstdio>
#include <map>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using P = std::pair<int, int>;

int N;
std::map<P, int> mp;

P digit( int x )
{
  int a = x%10, b;

  while( x > 0 )
  {
    if( x < 10 )
      b = x;

    x /= 10;
  }

  return P(a,b);
}

int main()
{
  scanf( "%d", &N );

  rep( i, N+1 )
  {
    P p = digit(i);

    ++mp[p];
  }

  int ans = 0;

  rep( i, N+1 )
  {
    P p = digit(i);
    P q( p.second, p.first );

    ans += mp[q];
  }

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

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int n;
cin >> n;
vector<int>h(n);
for(int i=0;i<n;i++){
  cin >> h.at(i);
}
vector<int>dp(n,10e6);
dp.at(0)=0;
for(int i=1;i<n;i++){
  if(i==1){
    dp.at(1)=abs(h.at(i-1)-h.at(i))+dp.at(0);
  }
  else{
    dp.at(i)=min(abs(h.at(i-1)-h.at(i))+dp.at(i-1),abs(h.at(i-2)-h.at(i))+dp.at(i-2));
  }
}
cout << dp.at(n-1)<<endl;
}
 


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long int
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
int main() {
	ll n,m;
	cin>>n>>m;
	ll ans=0;
	if(n>=2)
	ans+=(n*(n-1))/2;
	if(m>=2)
	ans+=(m*(m-1))/2;
	cout<<ans;





	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

n = len(a)
a.sort()
a.append(0)
ans = 0
i = 0

while i < n:
    cnt = 1
    while a[i] == a[i+1]:
        cnt += 1
        i += 1
    if cnt >= a[i]:
        ans += cnt - a[i]
    else:
        ans += cnt
    i += 1
print(ans)

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

int main(){
  string mes;
  char code[6][5] = { {'a','b','c','d','e'},
		      {'f','g','h','i','j'},
		      {'k','l','m','n','o'},
		      {'p','q','r','s','t'},
		      {'u','v','w','x','y'},
		      {'z','.','?','!',' '} };

  while(cin>>mes){
    string ans;
    bool f = true;
    if(mes.size()&1)f = false;
    else{
      for(int i=0;i<(int)mes.size();i+=2){
	int c = mes[i]-'0'-1, r = mes[i+1]-'0'-1;
	if(c<0 || r<0 || c>=6 || r>=5){
	  f = false;
	  break;
	}
	ans += code[c][r];
      }
    }
    if(f)cout << ans << endl;
    else cout << "NA" << endl;
  }
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> ans(n,1);
  int mn,mx;
  rep(i,m){
    int l,r;
    cin >> l >> r;
    if( i==0 ){
      mn = l;
      mx = r;
    }else{
      mn = max(mn,l);
      mx = min(mx,r);
    }
  }
  
  if( mx - mn < 0 ){
    cout << 0 << endl;
  }else{
    cout << mx-mn+1 << endl;
  }
    
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
long S[1000000];
int N;
int K;
long A[1000];
long bita[40];
bool check(long X){
	int c = 0;
	for(int i=0;i<N;i++){
		if((X & S[i]) == X){
			c++;
		}
	}
	return c >= K;
}
void Calc(){
	int n = rei();
	K = rei();
	int c = 0;
	for(int i=0;i<n;i++){
		A[i] = rei();
	}
	for(int i=0;i<n;i++){
		long sum = 0;
		for(int j=i;j<n;j++){
			sum += A[j];
			S[c++] = sum;
		}
	}
	N = c;
	bita[0] = 1;
	for(int i=0;i<39;i++){
		bita[i+1] = bita[i] * 2;
	}
	long ans = 0;
	for(int i=39;i>=0;i--){
		if(check(ans + bita[i])){
			ans += bita[i];
		}
	}
	cout << ans << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 4352
#include<stdio.h>
#define N 100
int main()
{
	int n,b;
	scanf("%d",&n);
	int a[N];
	for(int i=0;i<n;i++)
	{
		scanf("%d",a+i);	
	}
	for(int j=1;j<n;j++)
	{
		for(int c=0;c<n;c++)
		{
			printf("%d",a[c]);
			if(c!=n-1)
			{
				printf(" ");
			}	
		}
		printf("\n");
		int numble;
		b=a[j];
		numble=j;
		while(numble>0&&b<a[numble-1])
		{
			a[numble]=a[numble-1];
			numble--;
		}
		a[numble]=b;
	}
	for(int c=0;c<n;c++)
		{
			printf("%d",a[c]);
			if(c!=n-1)
			{
				printf(" ");
			}	
		}
		printf("\n");
		return 0;
}


Measured memory_bytes: 2688