akhauriyash/Code-Regression huggingface dataset:
use proconio::{fastout, input};

use std::cmp::max;

#[fastout]
fn main() {
    input! {
        n: usize,
        aa: [i64; n]
    }
    let mut u = vec![0; n + 1];
    let mut v = vec![0; n + 1];
    let mut w = vec![0; n + 1];
    let mut x = vec![0; n + 1];
    let mut y = vec![0; n + 1];
    let mut z = vec![0; n + 1];
    for i in 0..n {
        u[i + 1] = x[i] + aa[i];
        v[i + 1] = y[i] + aa[i];
        w[i + 1] = z[i] + aa[i];
        x[i + 1] = u[i];
        y[i + 1] = max(x[i], v[i]);
        z[i + 1] = max(y[i], w[i]);
    }
    // println!("{} {} {} {} {} {}", u[n], v[n], w[n], x[n], y[n], z[n]);
    if n % 2 == 1 {
        println!("{}", max(w[n], y[n]));
    } else {
        println!("{}", max(v[n], x[n]));
    }
}


Measured memory_bytes: 15132
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int R ,G; cin >> R >> G;
	cout << G * 2 - R << endl;
	return 0;
}

Measured memory_bytes: 256
#
#    ------------------------------------------------
#           ____          _     Generatered using
#          / ___|        | |
#         | |    __ _  __| | ___ _ __  ______ _
#         | |   / _` |/ _` |/ _ \ '_ \|_  / _` |
#         | |__| (_| | (_| |  __/ | | |/ / (_| |
#          \____\____|\____|\___|_| |_/___\____|
#
#      GNU Affero General Public License v3.0
#    ------------------------------------------------
#    Author   : prophet
#    Created  : 2020-07-05 22:32:00.862335
#    UUID     : 7dkLQccO4q5xeCWr
#    ------------------------------------------------
#
production = True

import sys, math, collections

def input(input_format = 0, multi = 0):

    if multi > 0: return [input(input_format) for i in range(multi)]
    else:
        next_line = sys.stdin.readline()[:-1]

        if input_format >= 10:
            use_list = False
            input_format = int(str(input_format)[-1])
        else: use_list = True

        if input_format == 0: formatted_input = [next_line]
        elif input_format == 1: formatted_input = list(map(int, next_line.split()))
        elif input_format == 2: formatted_input = list(map(float, next_line.split()))
        elif input_format == 3: formatted_input = list(next_line)
        elif input_format == 4: formatted_input = list(map(int, list(next_line)))
        elif input_format == 5: formatted_input = next_line.split()
        else: formatted_input = [next_line]

        return formatted_input if use_list else formatted_input[0]

def out(output_line, output_format = 0, newline = True):

    formatted_output = ""

    if output_format == 0: formatted_output = str(output_line)
    elif output_format == 1: formatted_output = " ".join(map(str, output_line))
    elif output_format == 2: formatted_output = "\n".join(map(str, output_line))

    print(formatted_output, end = "\n" if newline else "")

def log(*args):
    if not production:
        print("$$$", end = "")
        print(*args)

enu = enumerate

ter = lambda a, b, c: b if a else c

def mapl(iterable, format = 0):
    
    if format == 0: return list(map(int, iterable))
    elif format == 1: return list(map(str, iterable))
    elif format == 2: return list(map(list, iterable))
#
#   >>>>>>>>>>>>>>> START OF SOLUTION <<<<<<<<<<<<<<
#


def solve():

    n = input(11)
    g = input(0, n)

    a = t = w = r = 0

    for i in g:
        i = i[0]
        if i == "AC":
            a += 1
        elif i == "TLE":
            t += 1
        elif i == "WA":
            w += 1
        elif i == "RE":
            r += 1

    out(f"AC x {a}")
    out(f"WA x {w}")
    out(f"TLE x {t}")
    out(f"RE x {r}")

    return


#for i in range(input(11)): solve()
solve()

#
#   >>>>>>>>>>>>>>>> END OF SOLUTION <<<<<<<<<<<<<<<
#


Measured memory_bytes: 88224
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
int main(){
	int n;
	cin>>n;
	ll a[n];
	int j=0;
	map<ll,ll> m;
	ll num;
	for(int i=0;i<n;i++){
		cin>>num;
		m[num]++;
	}
	ll flag=0;
    for(map<ll,ll>::reverse_iterator rit=m.rbegin();rit!=m.rend();rit++){
        if(rit->second>=2){
        	a[j++]=rit->first;
        	if(j>=2){
                break;
        	}
		}
        if((*rit).second>=4){
            flag=(*rit).first;
        }
        //cout<<(*rit).first<<","<<(*rit).second<<endl;
    }
	/*map<ll, ll>::iterator  iter;
	for(iter = m.end(); iter != m.begin(); iter--){

		cout<<iter->first<<" "<<iter->second<<endl;
    }
    for(iter = m.begin(); iter != m.end(); iter++){
        if(iter->second>=2){
        	a[j++]=iter->first;
		}
		cout<<iter->first<<" "<<iter->second<<endl;
    }
*/
    /*for(int i=0;i<j;i++){
    	cout<<a[i]<<" ";
	}*/

	if(flag){
        cout<<flag*flag<<endl;
    }else{
        if(j<2){
            if(flag){
                cout<<flag*flag<<endl;
            }else{
                cout<<0<<endl;
            }

        }else{
            cout<<a[j-1]*a[j-2]<<endl;
        }
    }
	return 0;
}


Measured memory_bytes: 6528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define min(a,b) a<b?a:b
int main()
{
    char s[102],ans;
    int i,len;
    long long k;
    scanf("%s",s);
    scanf("%d",&k);
    len=strlen(s);
    for(i=0;i<len-1;i++){
        if(s[i]!='1')break;
    }
    if(i>=k){
        printf("1");
    }else{
    printf("%c",s[i]);
    }
    return 0;
}


Measured memory_bytes: 128
import itertools

N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))


prm = list(itertools.permutations(range(1,N+1)))

i = 0
for t in prm:
    i += 1
    if t == P:
        a = i
    if t == Q:
        b = i
print(abs(a-b))


Measured memory_bytes: 79992
/*
 * Author - Abhas Jain
 * Code is inside the solve function
 */
 
#include <bits/stdc++.h>
 
#define F first
#define S second
#define all(c) c.begin(), c.end()
#define endl '\n'
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
 
const ld PI = 3.141592653589793;
const ll INF = 9223372036854775807ll;
const ll mod = 1e9 + 7;
 
void solve() 
{
	for (int i = 1; ; ++i) {
		int cur;
		cin >> cur;
		if (!cur) {
			cout << i << endl;
			exit(0);
		}
	}
}
 
int main( )
{   
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    solve();
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cctype>
using namespace std;

int n,idx,leaf[10];
string s;

map<int,int> solve(void){
	map<int,int> res;
	if(isdigit(s[idx])){
		res[ leaf[s[idx++]-'1'] ]++;
		return res;
	}

	idx++;
	map<int,int> left = solve();
	idx++;
	map<int,int> right = solve();
	idx++;

	for(map<int,int>::iterator i=left.begin();i!=left.end();i++){
		for(map<int,int>::iterator j=right.begin();j!=right.end();j++){
			int lbit = i->first;
			int rbit = j->first;
			res[lbit & rbit] += i->second * j->second;
			res[lbit | rbit] += i->second * j->second;
			res[lbit ^ rbit] += i->second * j->second;
		}
	}

	return res;
}

int main(void){
	while(getline(cin,s),s!="END"){
		cin>>n;
		for(int i=0;i<n;i++){
			leaf[i] = 0;
			for(int j=0;j<4;j++){
				int x;
				cin>>x;
				if(x) leaf[i] |= 1<<j;
			}
		}

		idx = 0;
		map<int,int> rst = solve();
		cout<<rst[15]<<endl;

		getchar();
	}

	return 0;
}

Measured memory_bytes: 0
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
    ans = 0
    N, M, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    A = [0]+list(accumulate(A))
    B = [0]+list(accumulate(B))
    b = M
    for a in range(N+1):
        if A[a]>K:
            break
        while A[a]+B[b]>K:
            b -= 1
        ans = max(a+b,ans)
    return ans
print(solve())


Measured memory_bytes: 135436
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long n,k;
    scanf("%ld %ld", &n, &k);
    vector<vector<int>> vvilessThanK(31,vector<int>(30));
    for(long i = 0;  i < 30; i++){
        long l = k % (1<<i) + 1;
        if(l <= k){
            l = k - l;
        }
        else{
            l = 0;
        }
//        printf("%ld\n", l);
        for(int j = 0; j < 30; j++){
            vvilessThanK[i][j] = (l>>j)&1;
        }
    }
    for(int j = 0; j < 30; j++){
        vvilessThanK[30][j] = (k>>j)&1;
    }
    vector<vector<int>> vviNum(n,vector<int>(30));
    vector<long> viValue(n);
    for(long i = 0; i < n; i++){
        long a;
        scanf("%ld %ld", &a, &viValue[i]);
        for(int j = 0; j < 30; j++){
            vviNum[i][j] = (a>>j)&1;
        }
    }
    
    long nAns = 0;
    for(long i = 0; i < 31; i++){
        long iSum = 0;
        for(long j = 0; j < n; j++){
            bool iPlus = true;
            for(long k = 0; k < 30; k++){
                if(vvilessThanK[i][k] == 0 && vviNum[j][k] == 1){
                    iPlus = false;
                    break;
                }
            }
            if(iPlus){
            iSum += viValue[j];
            }
        }
        nAns = (std::max)(iSum, nAns);        
    }
  
    printf("%ld", nAns);
    
    return 0;
}


Measured memory_bytes: 18468
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
//cout << fixed << setprecision(10);

int main () {
  ll a, b, k;
  cin >> a >> b >> k;

  if (k <= a) {
    cout << a-k SP b << endl;
  }
  else if (k <= a + b) {
    cout << 0 SP b - (k-a) << endl;
  }
  else {
    cout << 0 SP 0 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
    else if(str[i]>='A'&&str[i]<='Z') str[i]+='a'-'A';
  }
    cout << str << endl;
  return 0;
}



Measured memory_bytes: 3172
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define int long long
using namespace std;
const int inf=0x3f3f3f;
struct node{
	int nxt,to,weigh,flow;
}edge[200100];
int pre[10010],maxflow,mincost;
int m,n,S,T,R,cnt=1,head[10010];
int dis[10010],flow[10010],Find[10010],last[10010];
std::queue<int>qu;
void addedge(int x,int y,int z,int w){
	edge[++cnt].nxt=head[x];
	edge[cnt].to=y;
	edge[cnt].flow=z;
	edge[cnt].weigh=w;
	head[x]=cnt;
	edge[++cnt].nxt=head[y];
	edge[cnt].to=x;
	edge[cnt].flow=0;
	edge[cnt].weigh=-w;
	head[y]=cnt;
}
bool SPFA(){
	memset(dis,0x3f,sizeof(dis));
	memset(flow,0x3f,sizeof(flow));
	memset(Find,false,sizeof(Find));
	dis[S]=0;
	Find[S]=true;
	pre[T]=-1;
	qu.push(S);
	while(!qu.empty()){
		int u=qu.front();
		qu.pop();
		Find[u]=0;
		for(int i=head[u];i;i=edge[i].nxt){
			int upup=edge[i].to;
			if(edge[i].flow>0 && dis[u]+edge[i].weigh<dis[upup]){
				dis[upup]=dis[u]+edge[i].weigh;
				pre[upup]=u;
				last[upup]=i;
				flow[upup]=min(flow[u],edge[i].flow);
				if(!Find[upup]){
					Find[upup]=1;
					qu.push(upup);
				}
			}
		Find[u]=false;
		}
	}
	return pre[T]!=-1;
}
void MCMF(){
	maxflow=0;
	while(SPFA()){
		maxflow+=flow[T];
		mincost+=flow[T]*dis[T];
		int now=T;
		while(now!=S){
			edge[last[now]].flow-=flow[T];
			edge[last[now]^1].flow+=flow[T];
			now=pre[now];
		}
	}
}
signed main(){
    scanf("%lld",&n);
    int x,y,z;
    S=0,T=2*n+5;
    for(int i=1;i<=n;i++){
    	scanf("%lld%lld%lld",&x,&y,&z);
    	addedge(S,i,z,0);
    	addedge(i,2*n+1,z,x+y);
    	addedge(i,2*n+2,z,x-y);
    	addedge(i,2*n+3,z,-x+y);
    	addedge(i,2*n+4,z,-x-y);
    }
    for(int i=n+1;i<=2*n;i++){
    	scanf("%lld%lld%lld",&x,&y,&z);
    	addedge(2*n+4,i,z,x+y);
    	addedge(2*n+3,i,z,x-y);
    	addedge(2*n+2,i,z,-x+y);
    	addedge(2*n+1,i,z,-x-y);
    	addedge(i,T,z,0);
    }  
    MCMF();
    printf("%lld\n",-mincost);
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    long long i,j,k,l,m,n,p,q;
   while(cin>>m>>n){
    long long x[m];
    for(i=0;i<m;i++)cin>>x[i];
   for(i=n;i<m;i++)if(x[i]>x[i-n])cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
   }
    return 0;
}


Measured memory_bytes: 5204
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    string c;
    cin >> c;
    int l=-1, r=n, cnt=0;
    while(r-l>1){
        int i;
        for(i=l+1;i<r;i++){
            if(c[i]=='W'){
                l = i;
                break;
            }
        }
        if(i==r){
            break;
        }
        for(i=r-1;i>l;i--){
            if(c[i]=='R'){
                r = i;
                break;
            }
        }
        if(i==l){
            break;
        }
        cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	double R; cin>>R; cout<<setprecision(10)<<fixed<<2*2*acos(0)*R<<endl;
	return 0;
}

Measured memory_bytes: 3808
#include <stdio.h>
#include <string.h>

int main(){
  char N[200001];
  scanf("%s", N); // scanf("%d", &N);
  int S = 0;
  
  int k = 0;
  
  int L = strlen(N); //N の中に入っている文字の個数
  
  while( k < L ){
    S = S + N[k] - '0';
    k++; //k = k + 1; と同じ
  }
  
  if(S % 9 == 0) printf("Yes\n");
  else printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1832
#include <bits/stdc++.h> 
using namespace std;
int main() {
  int A,B;
  cin >> A >> B;
  if (B*2 - A >= 0) {
    cout << "0" << endl;
  }
  else {
    cout << A - 2 * B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,p,a,b;
  int i,j,k,l;
  int x,y,z;
  while(cin>>n>>m>>p>>a>>b,n||m||p||a||b){
    a--;b--;
    int t[n];
    for(i=0;i<n;i++) cin>>t[i];
    int e[m][m];
    memset(e,-1,sizeof(e));
    for(i=0;i<p;i++){
      cin>>x>>y>>z;
      x--;y--;
      e[x][y]=e[y][x]=z;
    }
    double dp[1<<n][m];
    double inf = 1<<28;
    for(i=0;i<1<<n;i++)
      for(j=0;j<m;j++)
	dp[i][j]=inf;
    dp[0][a]=0;
    for(i=0;i<1<<n;i++){
      for(j=0;j<m;j++){
	for(k=0;k<m;k++){
	  if(!~e[j][k]) continue;
	  for(l=0;l<n;l++){
	    if(i>>l&1) continue;
	    dp[i|1<<l][k]=min(dp[i|1<<l][k],dp[i][j]+(double)e[j][k]/t[l]);
	  }
	}
      }
    }
    double ans = inf;
    for(i=0;i<1<<n;i++) ans=min(ans,dp[i][b]);
    if(ans!=inf) printf("%.8f\n",ans);
    else printf("Impossible\n");
  }
  return 0;
}

Measured memory_bytes: 1264
// https://atcoder.jp/contests/abc045/tasks/arc061_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

  ll r = 0;
  int l = s.length() - 1;
  int m = powf(2, l);
  REP(i, m)
  {
    ll sum = 0,
       num = s[0] - '0';
    REP(j, l)
    {
      if (i >> j & 1)
      {
        sum += num;
        num = 0;
      }
      num = num * 10 + (s[j + 1] - '0');
    }
    r += (sum + num);
  }

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    bool tb[n] = {false};

    //dreameraser , erasedreamer,11 ,12
    repi(i, n - 10, 0)
    {
        if (s.substr(i, 11) == "dreameraser")
        {
            repi(j, i + 11, i)
            {
                tb[j] = true;
            }
        }
    }
    repi(i, n - 11, 0)
    {
        if (s.substr(i, 12) == "erasedreamer")
        {
            repi(j, i + 12, i)
            {
                tb[j] = true;
            }
        }
    }

    //dreamer, eraser, 7,6
    repi(i, n - 6, 0)
    {
        if (s.substr(i, 7) == "dreamer")
        {
            repi(j, i + 7, i)
            {
                tb[j] = true;
            }
        }
    }
    repi(i, n - 5, 0)
    {
        if (s.substr(i, 6) == "eraser")
        {
            repi(j, i + 6, i)
            {
                tb[j] = true;
            }
        }
    }

    //dream, erase, 5,5
    repi(i, n - 4, 0)
    {
        if (s.substr(i, 5) == "dream" || s.substr(i, 5) == "erase")
        {
            repi(j, i + 5, i)
            {
                tb[j] = true;
            }
        }
    }

    //check
    repi(i, n, 0)
    {
        if (!tb[i])
        {
            cout << "NO" <<endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 512
#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;

int main()
{ios_base::sync_with_stdio(false);
ll n,k,a[100005];
cin>>n>>k;

ll gg;

rep(i,0,n-1)cin>>a[i];
gg=a[0];
rep(i,1,n-1)gg=__gcd(gg,a[i]);


rep(i,0,n-1)
{
	if(a[i]%gg==k%gg&&k<=a[i])
	{
		ol("POSSIBLE");
		return 0;
	}
}

ol("IMPOSSIBLE");

return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i, n) ;for (int i = 0;i < (int)(n);i++)
#define rep2(i, s, n) ;for (int i = s; i < (int)(n);i++)
#define ALL(vec)  (vec).begin(),(vec).end()
#define pi 3.1415926535897932384626433832795
#define MAX_INF 9223372036854775807
#define MIN_INF (922337203685477587+1)
#define sosuu 1000000007

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> X(M);
  rep(i, M){
  cin  >> X[i];
  }
  sort(ALL(X));
  
  vector<int> distance(M-1);
  rep(i, M-1)
    distance[i]=X[i+1]-X[i];
  sort(ALL(distance));
  int ans=0;
  if(N<M){
  rep(i, M-N){
  ans+=distance[i];
  }}
  cout << ans << endl;
}

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

int main(int argc, char const *argv[]) {
  ll k, n;std::cin >> n;
  multiset<ll> s;
  re(i, n){
    std::cin >> k;
    s.insert(k);
  }
  ll ans = 0;
  while(s.size()!=0){
    ll i = *s.begin();
    if(s.count(i)>=i) ans += s.count(i)-i;
    else ans += s.count(i);
    s.erase(i);
  }
  std::cout << ans << '\n';
}


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

using namespace std;

typedef long long ll;

// Defines and one-liners
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
template <typename T> inline T& back(vector<T> &vec) { return *(vec.end() - 1); }
template <typename T> inline void pop(vector<T> &vec) { return vec.erase(vec.end() - 1); }

// Scan, Debug, and other nonsense
template <typename T> ostream& operator<<(ostream& out,vector<T> iter){out<<"[";for(auto t:iter){out<<t<<", ";}out<<"]";return out;}
template <typename T> void printArray(ostream& out,T* arr,int sz){out<<"[";for(int i=0;i<sz;i++){out<<arr[i]<<", "; } out<<"]";}
#define OUT_OPERATOR(type, propa, propb) ostream& operator<<(ostream& out,type obj){out<<"("<<#propa<<"="<<obj. propa<<", "<<#propb<<"="<<obj. propb<<")";return out;}

void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F f,R... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

const int MN = 51;
int n,
    seq[MN];

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

    scan(n);

    for (int i = 0; i < n; i++) {
        scan(seq[i]);
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            swap(seq[i], seq[j]);

            bool flag = true;
            for (int k = 1; k < n; k++)
                flag &= seq[k] > seq[k - 1];
            
            if (flag) {
                cout << "YES\n";
                return 0;
            }

            swap(seq[i], seq[j]);
        }
    }

    cout << "NO\n";

    return 0;
}

Measured memory_bytes: 256
N=gets.to_f

(1..3500).each do |h|
  (1..3500).each do |n|
    w=(N*h*n)/(4*h*n-N*(n+h))
    if w>0 && w%1==0
      puts "#{h} #{n} #{w.to_i}"
      exit 0
    end
  end
end

Measured memory_bytes: 1788
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int a[3];
	scanf("%d%d%d",&a[0],&a[1],&a[2]);
	sort(a,a+3);
	printf("%d %d %d\n",a[0],a[1],a[2]);
}


Measured memory_bytes: 3200
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

# sys.setrecursionlimit(100000)
input = sys.stdin.buffer.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(K, A, B):
    ans = 0
    for i in range(100000):
        if A <= i*K <= B:
            return 'OK'
        if i * K > B:
            break
    return 'NG'


def main():
    K = read_int()
    A, B = read_int_n()
    print(slv(K, A, B))


if __name__ == '__main__':
    main()


Measured memory_bytes: 76908
package main

import (
  "bufio"
  "fmt"
  "os"
)

var sc = bufio.NewScanner(os.Stdin)


func next() string {
  sc.Scan()
  return sc.Text()
}

func main() {
  sc.Split(bufio.ScanWords)
  s := next()

  ansStr := ""
  for i := 0; i < len(s); i++ {
    ansStr += "x"
  }
  fmt.Println(ansStr)
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>
#include <set>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	int a, b, c;
	cin >> a >> b >> c;
	int d = max(a, max(b, c));
	int t1 = (d - a)/2;
	int t2 = (d - b)/2;
	int t3 = (d - c)/2;
	if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		cout << (t1 + t2 + t3)<< endl;
		return 0;
	}
	else if (a % 2 == 1 && b % 2 == 1 && c % 2 == 1) {

		cout << (t1 + t2 + t3)<< endl;
		return 0;
	}
	else {
		int t = t1 * 2 + t2 * 2 + t3 * 2 + a + b + c;
		if (t % 3 == 1) {
			cout << (t1 + t2 + t3)+1 << endl;
		}
		else {
			cout << (t1 + t2 + t3)+2 << endl;
		}
	}






	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll n;
  cin>>n;
  ll arr[n];
  for(ll i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  ll t=0,c=0;
  for(ll i=0;i<n;i++)
  {
    if(arr[i]%2==0)
    {	t++;
      if(arr[i]%3==0 || arr[i]%5==0)
      {
        c++;
      }
    }
  }
    if(t==c)
    {
      cout<<"APPROVED"<<endl;
      return 0;
    }
  cout<<"DENIED"<<endl;
  }

Measured memory_bytes: 256
a,b,c,x,y=map(int,input().split())

a,b,x,y=(a,b,x,y) if x<=y else(b,a,y,x)
if 2*c<=a+b:
    print(2*x*c+(y-x)*min(2*c,b))
else:
    a,b,x,y=(a,b,x,y) if a<=b else(b,a,y,x)
    if a>=2*c:
        print(2*c*max(x,y))
    elif b>=2*c:
        print(2*c*y+a*max(0,x-y))
    else:
        print(a*x+b*y)

Measured memory_bytes: 3064
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;

   cin >> n;
   int a[n];
   for(int i=0;i<n;i++){
     cin >> a[i];
   }
  
   int ans = 0;
   for(int i=0;i<n;i++){
     
     if(a[i]%2==0){
       
       if(a[i]%3==0||a[i]%5==0){
         
         ans++;
       }
       
     }else{
       ans++;
     }
     
   }
   
  if(ans == n){
    cout << "APPROVED" << endl;
  }else{
    cout << "DENIED" << endl;

  }
   
  
   
  return 0;
}

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

unsigned int errorSum[2][256];
bool concerning[2][256];

short samples[20001];
int codeBook[16];

const unsigned int MAX = (1 << 32) - 1;

int main() {
	int n, m;
	while(true) {

		cin >> n >> m;

		if (n == 0 && m == 0) {
			break;
		}

		for (int i = 0; i < m; i++) {
			cin >> codeBook[i];
		}
		for (int i = 1; i <= n; i++) {
			cin >> samples[i];
		}

		for (int i = 0; i < 256; i++) {
			errorSum[0][i] = errorSum[1][i] = MAX;
			concerning[0][i] = concerning[1][i] = false;
		}
		concerning[0][128] = true;

		for (int i = 0; i < n; i++) {
			for (int j = 0; j < 256; j++) {
				if(concerning[i % 2][j]) {
					concerning[i % 2][j] = false;
					for (int k = 0; k < m; k++) {
						int next = min(max(0, j + codeBook[k]), 255);
						unsigned int error = (errorSum[i % 2][j] == MAX ?
								0 : errorSum[i % 2][j])
								+ (next - samples[i+1]) * (next - samples[i+1]);

						if(error <= errorSum[(i+1) % 2][next]) {
							concerning[(i+1) % 2][next] = true;
							errorSum[(i+1) % 2][next] = error;
						}
					}
				}
				errorSum[i % 2][j] = MAX;
			}
		}

		unsigned int minError = MAX;
		int lastIndex = n % 2;
		for (int i = 0; i < 256; i++) {
			if(concerning[lastIndex][i]
			        && errorSum[lastIndex][i] < minError) {
				minError = errorSum[lastIndex][i];
			}
		}
		cout << minError << endl;
	}
	return 0;
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
template <typename T> inline T LB(vector<T>& v, T a) { return *lower_bound(ALL(v),a); }
template <typename T> inline int LBP(vector<T>& v, T a) { return lower_bound(ALL(v),a) - v.begin(); }
template <typename T> inline T UB(vector<T>& v, T a) { return *upper_bound(ALL(v),a); }
template <typename T> inline int UBP(vector<T>& v, T a) { return upper_bound(ALL(v),a) - v.begin(); }
template <typename T1, typename T2> ostream& operator<< (ostream& os, const pair<T1,T2>& p) { os << p.first << " " << p.second; return os; }
template <typename T1, typename T2> istream& operator>> (istream& is, pair<T1,T2>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator<< (ostream& os, const vector<T>& v) { REP(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator>> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e,v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;

int X, Y;

void _main() {
    cin >> X >> Y;
    cout << X + Y / 2 << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i'))
            freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o'))
            freopen("output.txt", "w", stdout);
    }
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int A = scanner.nextInt();
        int B = scanner.nextInt();
        int C = scanner.nextInt();

        if ((A == B && A != C) || (A == C && A != B) || (B == C &&  A != B)) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 35824
N = int(input())
aList = list(map(int, input().split()))
aList.sort(reverse = True)
aPoint = 0
bPoint = 0
if N % 2 == 0:
    for i in range(N//2):
        aPoint += aList[2*i]
        bPoint += aList[2*i + 1]
else:
    for i in range(N//2):
        aPoint += aList[2*i]
        bPoint += aList[2*i + 1]
    aPoint += aList[N-1]
print(aPoint - bPoint)

Measured memory_bytes: 3064
#include<iostream>
#include<cmath>
#include<string>
using namespace std;

class Dice{
public:
	int face[6];
	Dice(int a, int b, int c, int d, int e, int f){
		face[0] = a;
		face[1] = b;
		face[2] = c;
		face[3] = d;
		face[4] = e;
		face[5] = f;
	}

	void move(char dire){
		int t;
		if (dire == 'E'){
			t = face[0];
			face[0] = face[3];
			face[3] = face[5];
			face[5] = face[2];
			face[2] = t;
		}
		if (dire == 'W'){
			t = face[0];
			face[0] = face[2];
			face[2] = face[5];
			face[5] = face[3];
			face[3] = t;
		}
		if (dire == 'N'){
			t = face[0];
			face[0] = face[1];
			face[1] = face[5];
			face[5] = face[4];
			face[4] = t;
		}
		if (dire == 'S'){
			t = face[0];
			face[0] = face[4];
			face[4] = face[5];
			face[5] = face[1];
			face[1] = t;
		}
		if (dire == 'T'){
			t = face[1];
			face[1] = face[2];
			face[2] = face[4];
			face[4] = face[3];
			face[3] = t;
		}
	}

};

int main(){
	int a0, b0, c0, d0, e0, f0, a1, b1, c1, d1, e1, f1;
	cin >> a0 >> b0 >> c0 >> d0 >> e0 >> f0 >> a1 >> b1 >> c1 >> d1 >> e1 >> f1;
	
	string st = "TTTTSTTTTSTTTTSTTTTSETTTTWWTTTT";

	Dice dice1(a0, b0, c0, d0, e0, f0);
	Dice dice2(a1, b1, c1, d1, e1, f1);
	int count = 0;
	for (int i = 0; i < st.size(); i++){
		char di = st[i];
		dice1.move(di);
		if (dice1.face[0] == dice2.face[0] && 
		    dice1.face[1] == dice2.face[1] && 
		    dice1.face[2] == dice2.face[2] && 
		    dice1.face[3] == dice2.face[3] && 
		    dice1.face[4] == dice2.face[4] && 
		    dice1.face[5] == dice2.face[5]){
			cout << "Yes" << endl;
			count = 1;
			break;
		}
	}
	if (count == 0) cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
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 int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

ll n,m;

void input(){
    cin >> n >> m;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    ll ans;
    if(m - 2*n >= 0) ans = n + (m - 2*n) / 4;
    else ans = m / 2;
    cout << ans << endl;
    return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#define S second
#define F first
#define S second
#define N 100005
using namespace std;

typedef long long ll;
#define PI pair<ll, ll>
ll n, x, y, sz, s, bu[N];
PI a[N], b[N];
struct st {
	ll c1, c2, c3;
}c[200005];

bool comp(st p, st q) {
	return p.c1 < q.c1;
}

ll f(ll p) {
	if (bu[p] == p) return p;
	return bu[p] = f(bu[p]);
}
int main()
{
	ll i,t1, t2;
	cin >> n;
	for (i = 0; i <n; i++) {
		scanf ("%lld %lld", &x, &y);
		a[i].F = x;
		a[i].S = i;
		b[i].F = y;
		b[i].S = i;
	}
	sort(a, a + n);
	sort(b, b + n);
	for (i = 0; i < n - 1; i++) {
		c[sz++] = {a[i + 1].F - a[i].F, a[i].S, a[i + 1].S};
	}
	for (i = 0; i < n - 1; i++) {
		c[sz++] = {b[i + 1].F - b[i].F, b[i].S, b[i + 1].S};
	}
	sort(c, c + sz, comp);
	for (i = 1; i <= n; i++) bu[i] = i;
	for (i = 0; i < n * 2 - 1; i++){
		t1 = f(c[i].c2);
		t2 = f(c[i].c3);
		if (t1 != t2) {
			bu[t1] =t2;
			s += c[i].c1;
		}
	}
	cout << s;
    return 0;
}


Measured memory_bytes: 8832
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstring>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll = long long;
using namespace std;

int main() {
    int n, r;
    cin >> n >> r;
    if (n < 10) {

        int ans = r + 100 * (10 - n);
        cout << ans << endl;
    } else {
        cout << r << endl;
    }
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  if (n == 0){
    cout << 0 << endl;
    return 0;
  }
  while(n){
    int p = abs(n % (-2));
    if (n < 0 && n % 2 != 0) n = n / (-2) + 1;
    else n /= (-2);
    s += '0' + p;
  }
  rep(i, s.size()) cout << s[s.size() - 1 - i];
  cout << endl;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

int main()
{
  int N;
  cin>>N;
  vector<int> cost(100001);
  vector<int> H(100001);
  REP(i,N)
  {
    cin>>H.at(i);
  }
  cost.at(1)=abs(H.at(1)-H.at(0));
  FOR(i,2,N)
  {
    cost.at(i)=min(abs(H.at(i-1)-H.at(i))+cost.at(i-1),abs(H.at(i-2)-H.at(i))+cost.at(i-2));
  }
cout<<cost.at(N-1)<<endl;
}

Measured memory_bytes: 1024
n=int(input())
li=list(input().split(" "))
for g in range(n):
    li[g]=int(li[g])
ali=0
bob=0
li.sort()
li.reverse()
for i in range(n):
    if i%2==0:
        ali+=li[i]
    else:
        bob+=li[i]
print(abs(ali-bob))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
typedef double dd;
#define pb push_back
#define mp make_pair
#define endl "\n"
ll const M = 998244353;
dd const pi = acos(-1);
ll const inf = 2e18;
ll const N = 200001;
ll power(ll a,ll b)
{
    ll res = 1;
    while(b > 0)
    {
        if(b & 1)
            res = (res*a)%M;
        a = (a*a)%M;
        b = b >> 1;
    }
    return res;
}
ll modinv(ll a)
{
   return power(a,M - 2); 
}  
int main()
{
    fast;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    ll i,j,n,m,k;
    cin >> n >> m >> k;
    ll ans = 0;
    vector<ll> fact(n + 1);
    fact[0] = fact[1] = 1;
    for(i = 2; i <= n; i++)
      fact[i] = (fact[i - 1]*i)%M;
    for(i = 0; i <= k; i++)
    {
      ll temp = (fact[n - 1]*modinv(fact[i]))%M;
      temp = (temp*modinv(fact[n - 1 - i]))%M;
      temp = (temp*power(m - 1,n - i - 1))%M;
      ans = (ans + (m*temp)%M)%M;
    }
    cout<<ans<<endl;
    return 0;
}    

Measured memory_bytes: 4744
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
using namespace std;

ll dp[(1<<12)+5];
void solve(){
	int n,m;
    cin>>n>>m;
    rep(i,(1<<n)+5)dp[i]=INF;//最小値なのでINFで初期化
    dp[0]=0;
    vector<ll>a(m),b(m),c(m,0);
    rep(i,m){
        cin>>a[i]>>b[i];
        int cur=0;
        rep(j,b[i]){
            cin>>c[j];
            c[j]--;
            cur|=(1<<c[j]);
        }
        rep(bit,(1<<n))chmin(dp[bit|cur],dp[bit]+a[i]);
    }
    cout<<(dp[(1<<n)-1]!=INF?dp[(1<<n)-1]:-1)<<"\n";
}

signed main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 1000000007
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ub upper_bound
#define lb lower_bound
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int main() {

    zoom;
    ll N, i;
    cin >> N;
    vector<ll> A(N);
    ll past = -1, future = 0, tot = 0;
    for(i = 0; i < N; i += 1) {
    	cin >> A[i];
    	tot += A[i];
    }
    ll curr = 0;
    for(i = 0; i < N; i += 1) {
    	curr += A[i];
    	if(curr < tot / 2)
    		past = curr;
    	else {
    		future = curr;
    		break;
    	}
    }
    if(past == -1) 
    	cout << 2 * future - tot;
    else
    	cout << (ll)min(2 * future - tot, tot - 2 * past);
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <map>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i <= n; i++)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
using namespace std;
ll mod = 1e9 + 7;
ll comb2(ll);

int main()
{
	int N;
	cin >> N;
	vector<string> s(N);
	for (int i = 0; i < N; i++)
	{
		cin >> s[i];
	}
	for (int i = 0; i < N; i++)
	{
		sort(s[i].begin(), s[i].end());
	}
	sort(s.begin(), s.end());
	int i = 0;
	vector<int> sizes;
	while (i < N)
	{
		int size = 1;
		while (i < N - 1 && s[i + 1] == s[i])
		{
			size++;
			i++;
		}
		if (size > 1)
		{
			sizes.push_back(size);
		}
		i++;
	}
	ll ans = 0;
	if (sizes.size() == 0)
	{
		cout << ans;
		return 0;
	}
	for (int i = 0; i < sizes.size(); i++)
	{
		ans += comb2(sizes[i]);
	}
	cout << ans << endl;
	return 0;
}

ll comb2(ll a)
{
	ll r = (ll)a * ((ll)a - 1) / 2;
	return r;
}

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

vector<int>getPrime(int n){
  vector<bool>used(n+1,0);

  for(int i=2;i*i<=n;i++)
    if(!used[i])
      for(int j=2;j<=n/i;j++)used[i*j]=1;

  vector<int> res;
  for(int i=2;i<=n;i++)if(!used[i])res.push_back(i);

  return res;
}

bool isPrime(ll n){
  for(ll i=2;i*i<=n;i++)
    if(n%i==0) return 0;
  return 1;
}

int main(){
  int n;
  cin>>n;
  int ans=0,a;
  while(n--)cin>>a,ans+=isPrime(a);
  cout<<ans<<endl;
  

  return 0;
}

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

bool contains(int *arr, int length, int key);

int main() {
	int n;
	cin >> n;
	int S[n];
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
	}
	int q;
	cin >> q;
	int ans = 0;
	for (int i = 0; i < q; ++i) {
		int T;
		cin >> T;
		if (contains(S, n, T)) {
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

bool contains(int *arr, int length, int key) {
	int left = 0;
	int right = length;
	while (left < right) {
		int mid = (left + right) / 2;
		if (arr[mid] == key) {
			return true;
		} else if (key < arr[mid]) {
			right = mid;
		} else {
			left = mid + 1;
		}
	}
	return false;
}

Measured memory_bytes: 1548
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    string s;cin >> s;
    ll k;cin >> k;
    for(ll i=0;i<min((ll)s.size(),k);i++){
        if(s[i]>='2'){
            cout << s[i] << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int sum(int x) {
	int ret = 0;
	while(x > 0) {
		ret += x % 10;
		x /= 10;
	}
	return ret;
}
int main() {
	int n;
	cin >> n;
	int mini = 1e9;
	for(int i = 1; i < n; i++) {
		int a = i, b = n - i;
		mini = min(mini, sum(a) + sum(b));
	}
	cout << mini << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int arr[100],N,a,i,x=0;
    scanf("%d",&N);
    for(i=0;i<N;i++){
        scanf("%d",&a);
        arr[i]=a;
       if(i%2==0 && (a*a)%2!=0){x++;}
    }
    printf("%d\n",x);

    return 0;
}


Measured memory_bytes: 1724