akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <map>
#include <tuple>

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

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> b;
    rep(i, n){
        if(i%2 == 0){
            b.insert(b.end(), a[i]);
        }
        else{
            b.insert(b.begin(), a[i]);
        }
    }
    
    if(n%2 != 0) reverse(b.begin(), b.end());
    rep(i,n) {
        cout << b[i] << endl;
        
    }
}


Measured memory_bytes: 3828
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
   if len(set(list(S))) != 1:
   	print(YES)
   else:
   	print(NO)


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()

ll H, W;
ll WALL = -1;

ll BFS(vector<vector<ll>> cost, ll x, ll y) {
    vector<ll> dist_x = {1, -1, 0, 0};
    vector<ll> dist_y = {0,  0, 1, -1};
    queue<pair<ll, ll>> que;
    que.push({x, y});
    cost[x][y] = 0;
    ll ans = 0;
    while(!que.empty()) {
        pair<ll, ll> q = que.front();
        que.pop();
        rep(i, 0, dist_x.size()) {
            ll next_x = q.first + dist_x[i];
            ll next_y = q.second + dist_y[i];
            if (next_x >= 0 && next_x < H && next_y >= 0 && next_y < W) {
                if (cost[next_x][next_y] == LONG_MAX) {
                    cost[next_x][next_y] = cost[q.first][q.second] + 1;
                    ans = max(ans, cost[next_x][next_y]);
                    que.push({next_x, next_y});
                }
            }
        }
    }
    return ans;
}

int main(void) {
    cin >> H >> W;
    char s;
    vector<vector<ll>> cost(H, vector<ll>(W, LONG_MAX));
    rep(i, 0, H) {
        rep(j, 0, W) {
            cin >> s;
            if (s == '#') cost[i][j] = WALL;
        }
    }

    ll ans = 0;
    rep(i, 0, H) {
        rep(j, 0, W) {
            if (cost[i][j] != WALL) ans = max(ans, BFS(cost, i, j));
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
f=lambda:map(int,input().split())
n,st,sa=f()
g=[set() for _ in range(n)]
for _ in range(n-1):
  a,b=f()
  g[a-1].add(b-1)
  g[b-1].add(a-1)
def bfs(s):
  l=[-1]*n; l[s]=0; q=[s]
  while q:
    v=q.pop(); d=l[v]+1
    for c in g[v]:
      if l[c]<0: l[c]=d; q+=[c]
  return l
lt=bfs(st-1)
la=bfs(sa-1)
print(max(la[i] for i in range(n) if lt[i]<la[i])-1)

Measured memory_bytes: 39744
#include<iostream>
#include<algorithm>
#include <cassert>
#include<string>
#include<vector>
#include <utility>
#include <math.h>
#include<cmath>
#include<map>
#include <limits>
# include <iomanip>
#define INF 1000000009;
using namespace std;
int gcd(int a, int b) {
	while (a % b != 0) {
		int c = 0;
		c = a % b;
		a = b;
		b = c;
	}
	return  b;
}

int main() {
	int N = 0,a[10009];
	long ans = 0;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		while (a[i] % 2==0) {
			ans++;
			a[i] /= 2;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
s=input()
x,y=map(int,input().split())

l=[0]
for i in s:
    if i=="F":
        l[-1]+=1
    else:
        l.append(0)
lx=[0]
ly=[0]
for i in range(len(l)):
    if i==0:
        continue
    if i%2==0:
        lx.append(l[i])
    else:
        ly.append(l[i])

q=[l[0]]
for i in lx:
    ll=set()
    for j in q:
        ll.add(j+i)
        ll.add(j-i)
    q=list(ll)
if x not in set(q):
    print("No")
    exit()

q=[0]
for i in ly:
    ll=set()
    for j in q:
        ll.add(j+i)
        ll.add(j-i)
    q=list(ll)
if y in set(q):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 46812
#include <iostream>

using namespace std;

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

int main(){
  char s[3];
  cin >> s;
  int cnt = 0;
  rep(i, 3) {
    if (s[i] == '1') ++cnt;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

fin = sys.stdin.readline
N, A, B, C, D = [int(elem) for elem in fin().split()]
cell_list = fin().split()[0]

init_max = max(A, B)
init_min = min(A, B)
end_max = max(C, D)
end_min = min(C, D)

after_min_cells = cell_list[init_min:end_max-1]
after_max_cells = cell_list[max(0, init_max-2):end_min+1]
# 途中に#が2つ連続しないか
if '##' in after_min_cells:
    result = 'No'
# 入れ替えが必要かどうか
elif (A-B) * (C-D) < 0:
    # 途中に.が3つ連続するかどうか（＝入れ替えが可能かどうか）
    if '...' in after_max_cells:
        result = 'Yes'
    else:
        result = 'No'
else:
    result = 'Yes'

print(result)


Measured memory_bytes: 40924
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int n, l[1000], i, j, sum=0;
    scanf("%d", &n);
    for(i=1;i<=2*n;i++)
        scanf("%d", &l[i]);
    sort(l+1, l+2*n+1);
    for(i=1;i<=n;i++)
        sum+=l[2*i-1];
    printf("%d", sum);
    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fail puts("NO"),exit(0);
#define eps 1e-10
#define maxn 500
#define maxm 100010
#define inf 1000000007
//#define mod 998244353
#define pi acos(-1)
#define mp(x,y) make_pair(x,y)
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef bitset<maxn> bit;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch-'0'<0||ch-'0'>9){if(ch=='-') f=-1;ch=getchar();}
    while(ch-'0'>=0&&ch-'0'<=9){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int n,mod;
struct P{
    int id,l,r;
}a[maxn*2];
bool cmp(P a,P b)
{
    int x1=a.l,x2=a.r,y1=b.l,y2=b.r;
    if(a.id>=n)  swap(x1,x2);
    if(b.id>=n)  swap(y1,y2);
    if(x1!=y1)  return x1<y1;
    return x2<y2;
}
int f[2][maxn],ans;
void add(int &x,int y)
{
    x=(x+y>=mod)?(x+y-mod):x+y;
}
int main()
{
    n=read();mod=read();
    for(int i=0;i<=2*n-1;i++)
    {
        a[i+1].id=i;
        if(i>=n)  a[i+1].l=0;
        else      a[i+1].l=ceil(sqrt((double)(1ll*n*n-1ll*i*i)));
        a[i+1].r=min(2*n,(int)floor(sqrt((double)(4ll*n*n-1ll*i*i)))+1);
    }
    sort(a+1,a+2*n+1,cmp);
    for(int k=0;k<=n;k++)
    {
        memset(f,0,sizeof(f));
        int now=0,c1=0,c2=0;
        f[0][0]=1;
        for(int i=1;i<=2*n;i++)
        {
            for(int j=0;j<=k;j++)
            {
                if(!f[now][j])  continue;
                if(a[i].id>=n)
                {
                    add(f[now^1][j],1ll*f[now][j]*max(0,a[i].r-c1-j)%mod);
                }
                else{
                    add(f[now^1][j],1ll*f[now][j]*max(0,a[i].r-n-k-(c2-j))%mod);
					if(j<k)  add(f[now^1][j+1],1ll*f[now][j]*max(0,a[i].l-c1-j)%mod);
                }
				f[now][j]=0;
            }
			if(a[i].id>=n)  c1++;
			else            c2++;
            now^=1;
        }
        if(k&1)  add(ans,mod-f[now][k]);
        else     add(ans,f[now][k]);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int R;
int main() {
  cin >> R;
  if (R < 1200) {
    cout << "ABC" << endl;
  } else if (R < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)998244353;
const int MAXN = (int)2003;
const int infint = (int)1e9 + 3;
const ll inf = (ll)1e18;
ll f[MAXN][MAXN], a[MAXN], n, x;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin >> n >> x;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	
	for (int i = 0; i < n; i++)
	{
		f[i][0] = a[i];
		for (int j = 1; j < n; j++)
			f[i][j] = min(f[i][j - 1], a[(i + j) % n]);
	}
	
	ll ans = inf;
	for (int i = 0; i < n; i++)
	{
		ll cur = x * i;
		for (int j = 0; j < n; j++)
			cur += f[j][i];
		ans = min(ans, cur);
	}
	cout << ans;
}


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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  bool ans=true;
  while(n>0){
    if(n>4&&s.at(n-5)=='d'&&s.at(n-4)=='r'&&s.at(n-3)=='e'&&s.at(n-2)=='a'
       &&s.at(n-1)=='m'){
     n-=5;
      continue;
    }
     if(n>4&&s.at(n-5)=='e'&&s.at(n-4)=='r'&&s.at(n-3)=='a'&&s.at(n-2)=='s'
       &&s.at(n-1)=='e'){
     n-=5;
      continue;
    }
     if(n>6&&s.at(n-7)=='d'&&s.at(n-6)=='r'&&s.at(n-5)=='e'&&s.at(n-4)=='a'
       &&s.at(n-3)=='m'&&s.at(n-2)=='e'&&s.at(n-1)=='r'){
     n-=7;
      continue;
    }
     if(n>5&&s.at(n-6)=='e'&&s.at(n-5)=='r'&&s.at(n-4)=='a'&&s.at(n-3)=='s'
       &&s.at(n-2)=='e'&&s.at(n-1)=='r'){
     n-=6;
      continue;
    }
    ans=false;
    break;
  }
  if(ans) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

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

using namespace std;

int main() {
	string N;
	
	cin >> N;
	
	if(N == "SUN") {
		cout << 7;
	} else {
		if(N == "MON") {
			cout << 6;
		} else {
			if(N == "TUE") {
				cout << 5;
			} else {
				if(N == "WED") {
					cout << 4;
				} else {
					if(N == "THU") {
						cout << 3;
					} else {
						if(N == "FRI") {
							cout << 2;
						} else {
							if(N == "SAT") {
								cout << 1;
							}
						}
					}
				}
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
AB = []
for _ in range(N):
    li = list(map(int, input().split()))
    AB.append(li)

AB.sort()

ans = 0
count = 0
for li in AB:
    if M - count >= li[1]:
        count += li[1]
        ans += li[0]*li[1]
    else:
        ans += li[0]*(M-count)
        break

print(ans)


Measured memory_bytes: 27760
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MAX_N = 4020;
const int INF = 1145141919;

struct BIT{
    // [1, n]
    vector<int>bit;
    int N;
    void init(int n){
        N = n;
        bit.resize(n, 0);
    }
    BIT(int n=0){
        init(n);
    }
    int sum(int i){
        int s = 0;
        while(i>0){
            s += bit[i];
            i -= i & -i;
        }
        return s;
    }
    void add(int i, int x){
        while(i <= N){
            bit[i] += x;
            i += i & -i;
        }
    }
};

int dp[MAX_N][MAX_N];

int main(){
    
    rep(i,MAX_N)rep(j,MAX_N)dp[i][j] = INF;
    dp[0][0]=0;

    int N;
    cin >> N;
    BIT bit(MAX_N);
    vector<int>bpos(N+1), wpos(N+1);
    for(int i = 1; i <= 2*N; i++){
        char c;
        int a;
        cin >> c >> a;
        if(c=='B')bpos[a] = i;
        else wpos[a] = i;
        bit.add(i, 1);
    }

    for(int b=0; b<=N; b++){
        for(int w=0; w<=N; w++){
            if(b < N){
                chmin(dp[b+1][w], dp[b][w] + bit.sum(bpos[b+1]-1));
            }
            if(w < N){
                chmin(dp[b][w+1], dp[b][w] + bit.sum(wpos[w+1]-1));
                bit.add(wpos[w+1], -1);
            }
        }
        for(int w=1;w<=N;w++)bit.add(wpos[w], 1);
        if(b<N)bit.add(bpos[b+1], -1);
    }
    cout << dp[N][N] << endl;

    return 0;
}

Measured memory_bytes: 63360
#include <bits/stdc++.h>
 
using namespace std;
#define int long long


 const int MAX = 1001;
const int MOD = 1000000007;



signed main(){
 
   int n,m;
   cin>>n>>m;
   int s,t;
   cin>>s>>t;
   s--;t--;
   int ds[n],cs[n]={},dt[n],ct[n]={};
   vector<pair<int,int>> hen[n];
   int u,v,d;
   for(int i=0;i<m;i++){
       cin>>u>>v>>d;
       hen[u-1].push_back(make_pair(v-1,d));
       hen[v-1].push_back(make_pair(u-1,d));

   }
   for(int i=0;i<n;i++){
       ds[i]=LLONG_MAX;
       dt[i]=LLONG_MAX;
   }

    ds[s]=0;cs[s]=1;
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>> > que;
    que.push(make_pair(0,s));
    
    int p,q;
    while(!que.empty()){
        p=que.top().second;q=que.top().first;
        que.pop();
        if(ds[p]<q)continue;
        for(int i=0;i<hen[p].size();i++){
            if(ds[hen[p][i].first]==ds[p]+hen[p][i].second){
            //   cerr<<p<<' '<<hen[p][i].first<<endl;
                cs[hen[p][i].first]=(cs[hen[p][i].first]+cs[p])%MOD;
            }
            if(ds[hen[p][i].first]>ds[p]+hen[p][i].second){
                ds[hen[p][i].first]=ds[p]+hen[p][i].second;
                cs[hen[p][i].first]=cs[p];
                que.push(make_pair(ds[hen[p][i].first],hen[p][i].first));
            }
            
        }
    }
  
    dt[t]=0;que.push(make_pair(0,t));ct[t]=1;
    while(!que.empty()){
        p=que.top().second;q=que.top().first;
        que.pop();
        if(dt[p]<q)continue;
        for(int i=0;i<hen[p].size();i++){
            if(dt[hen[p][i].first]==dt[p]+hen[p][i].second){
               
                ct[hen[p][i].first]=(ct[hen[p][i].first]+ct[p])%MOD;
            }
            if(dt[hen[p][i].first]>dt[p]+hen[p][i].second){
                dt[hen[p][i].first]=dt[p]+hen[p][i].second;
                ct[hen[p][i].first]=ct[p];
                que.push(make_pair(dt[hen[p][i].first],hen[p][i].first));
            }
            
        }
    }
    
    int mind=ds[t],ans=0,w;
    for(int i=0;i<n;i++){
       if(ds[i]+dt[i]!=mind)continue;
       if(2*ds[i]==mind){
         //  cerr<<cs[i]<<' '<<ct[i]<<endl;
         w=(cs[i]*cs[i])%MOD;w=(w*ct[i])%MOD;w=(w*ct[i])%MOD;
           ans=(ans+w)%MOD;
       }
       if(2*ds[i]<mind){
           for(int j=0;j<hen[i].size();j++){
               if(ds[i]+hen[i][j].second==ds[hen[i][j].first]&&ds[hen[i][j].first]+dt[hen[i][j].first]==mind&&2*ds[hen[i][j].first]>mind){
                   w=(cs[i]*cs[i])%MOD;w=(w*ct[hen[i][j].first])%MOD;w=(w*ct[hen[i][j].first])%MOD;
                   ans=(ans+w)%MOD;
               }
           }
       }
    }
   // for(int i=0;i<n;i++)cerr<<ds[i]<<' ';
  //  cerr<<ans<<' '<<mind<<endl;
    cout<<(MOD+cs[t]*cs[t]-ans)%MOD;



   return 0;
}

Measured memory_bytes: 18160
#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

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

    int n,k;
    int l[50];
    int ans[50];
    for(int i = 0; i < 50; i++) ans[i] = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++)cin >> l[i];
    for(int i = 0; i < k; i++){
        ans[i] = l[i];   
    }
    for(int i = 0; i < k-1; i++){
        for(int j = i; j < k; j++){
            if(ans[i] < ans[j]) swap(ans[i], ans[j]);
        }
    }
    for(int i = k; i < n; i++){
        if(ans[k-1] < l[i]){
            ans[k-1] = l[i];
            for(int j = k-1; j >=0; j--){
                if(ans[j] < ans[k-1]) swap(ans[k-1], ans[j]);
            }
        }
    }
    int aaa = 0;
    for(int i = 0; i < k; i++){
        aaa += ans[i];
    }
    cout << aaa << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int x;
  cin >> x;
  int cnt = 0;
  while(x-100>=0){
    x -= 100;
    cnt++;
  }
  if(cnt*5>=x) cout << 1 << "\n";
  else cout << 0 << "\n";
  return 0;
}


Measured memory_bytes: 256
N,D = map(int,input().rstrip().split())

maplist = []
for i in range(N):
    maplist.append(list(map(int,input().split())))
count = 0
for i in range(N-1):

    for j in range(i+1,N):
        dis = 0
        for k in range(D):
            dis += (maplist[i][k] - maplist[j][k]) ** 2
        dis = dis ** 0.5
        if float(int(dis)) == dis:
            count += 1
print(count)


Measured memory_bytes: 3064
N, K = map(int, input().split())
Ans0 = [0] * N
Ans1 = [0] * N
Ans2 = list(range(K+2*N, K+3*N))
n = K
for i in range(0, N, 2):
    Ans0[i] = n
    n += 1
for i in range(1, N, 2):
    Ans0[i] = n
    n += 1
for i in range(1, N, 2):
    Ans1[i] = n
    n += 1
for i in range(0, N, 2):
    Ans1[i] = n
    n += 1
Ans = []
for a, b, c in zip(Ans0, Ans1, Ans2):
    if a+b > c:
        print(-1)
        exit()
    Ans.append("{} {} {}".format(a, b, c))
print("\n".join(Ans))


Measured memory_bytes: 75484
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000007
#define MAX 100001
#define INF LLONG_MAX
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string s;
    cin>>s;
    char a = s[0];
    char b = s[1];
    char c = s[2];
    if(a=='R' && b=='R' && c=='R')
        cout<<3<<endl;
    else if((a=='R' && b=='R') || (b=='R' && c=='R'))
        cout<<2<<endl;
    else if(a=='R' || b=='R' || c=='R')
        cout<<1<<endl;
    else
        cout<<0<<endl;
    return 0;
}


Measured memory_bytes: 3608
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int[] num = new int[N];
		int a = 0;      
		for( int i=0; i<N; i++ ){
			num[i] = sc.nextInt();
			a+=num[i];
		}
		int a1 = a/N;
		int a2 = a/N+1;      
		int ans1 = 0;
		int ans2 = 0;      
		for( int i=0; i<N; i++ ){
			ans1 = ans1 + (num[i]-a1)*(num[i]-a1);
		}
		for( int i=0; i<N; i++ ){
			ans2 = ans2 + (num[i]-a2)*(num[i]-a2);          
        }          
		System.out.println(Math.min(ans1,ans2));
	}
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved
int gcd(int a,int b){
     while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;

}
int main(){
    int k;
    cin>>k;
    long long ans=0;
    rep2(i,k){
        rep2(l,k){
            rep2(t,k){
            int now=gcd(i,l);
            ans+=gcd(now,t);
            }
        }
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 3636
N = int(input())
A = input().split(" ")
A = [int(i) for i in A]
list = [min(A)]
A = sorted(A)
iii = 0
while True:
    iii += 1
    if A[N-1] % A[N-2] != 0:
        A[N-1] = A[N-1] % A[N-2]
    elif N >= 3 and A[N-1] % A[N-3] != 0:
        A[N-1] = A[N-1] % A[N-3]
    elif N >= 4 and A[N-1] % A[N-4] != 0:
        A[N-1] = A[N-1] % A[N-4]
    elif N >= 5 and A[N-1] % A[N-5] != 0:
        A[N-1] = A[N-1] % A[N-5]
    elif N >= 6 and A[N-1] % A[N-6] != 0:
        A[N-1] = A[N-1] % A[N-6]
    elif N >= 7 and A[N-1] % A[N-7] != 0:
        A[N-1] = A[N-1] % A[N-7]
    elif N >= 8 and A[N-1] % A[N-8] != 0:
        A[N-1] = A[N-1] % A[N-8]
    elif N >= 9 and A[N-1] % A[N-9] != 0:
        A[N-1] = A[N-1] % A[N-9]
    elif N >= 10 and A[N-1] % A[N-10] != 0:
        A[N-1] = A[N-1] % A[N-10]
    elif N >= 11 and A[N-1] % A[N-11] != 0:
        A[N-1] = A[N-1] % A[N-11]
    elif N >= 12 and A[N-1] % A[N-12] != 0:
        A[N-1] = A[N-1] % A[N-12]
    elif N >= 13 and A[N-1] % A[N-13] != 0:
        A[N-1] = A[N-1] % A[N-13]
    elif N >= 14 and A[N-1] % A[N-14] != 0:
        A[N-1] = A[N-1] % A[N-14]
    elif N >= 15 and A[N-1] % A[N-15] != 0:
        A[N-1] = A[N-1] % A[N-15]
    elif N >= 16 and A[N-1] % A[N-16] != 0:
        A[N-1] = A[N-1] % A[N-16]
    elif N >= 17 and A[N-1] % A[N-17] != 0:
        A[N-1] = A[N-1] % A[N-17]
    elif N >= 18 and A[N-1] % A[N-18] != 0:
        A[N-1] = A[N-1] % A[N-18]
    elif N >= 19 and A[N-1] % A[N-19] != 0:
        A[N-1] = A[N-1] % A[N-19]

    A = sorted(A)
    list.append(min(A))
    if iii > 128:
        break       
#print(list)
for i in range(N-1):
    if A[i+1]-A[i] > 0:
        list.append(A[i+1]-A[i])
#print(list)
print(min(list))

Measured memory_bytes: 14276
#include<iostream>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<cmath>
#include<string>
#include<iomanip>
#include<algorithm>
using namespace std;

int main()
{
	string s1,s2;
	int len;
	cin >> s1 >> s2;
	int len1 = s1.size() ;
	int len2 = s2.size() ;
	if(len1 >= len2)
	{
		for(int i = 0;i < len2;i++)
		{
			cout << s1[i] << s2[i];
		}
		for(int i = len2;i < len1;i++)
		{
			cout << s1[i];
		}
		cout << endl;
	}
	else
	{
		for(int i = 0;i < len1;i++)
		{
			cout << s1[i] << s2[i];
		}
		for(int i = len1;i < len2;i++)
		{
			cout << s1[i];
		}
		cout << endl;
	}
	
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
const int INF = 1000000000; // 10^9
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    ll ans = 0;
    for(int i = 1; i <= N; i++) {
        if(i % 3 == 0 && i % 5 == 0){

        } else if(i % 3 == 0){

        } else if(i % 5 == 0){

        } else{
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007;
#define INF (1<<28)
#define int long long
#define double long double
#define floot10 cout<<fixed<<setprecision(10)



signed main(){
  int n;
  cin>>n;
  int l=0,r=10000;
  int m;
  int a[100];
  lp(i,n){
    cin>>a[i];
  }
  lp(z,30){
    m=(l+r)/2;
    int cnt=0;
    bool check=true;
    lp(i,n){
      cnt+=a[i];
      cnt-=m;
      if(cnt<0){
	check=false;
      }
    }
    if(check==true){
      l=m;
    }
    else{
      r=m;
    }
  }
  m++;
  while(1){
    int cnt=0;
    bool check=true;
    lp(i,n){
      cnt+=a[i];
      cnt-=m;
      if(cnt<0){
	check=false;
      }
    }
    if(check==true){
      cout<<m<<endl;
      return 0;
    }
    else{
      m--;
    }
  }
  return 0;
}




Measured memory_bytes: 3092
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stdlib.h>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=500000004;
int d[110000];
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++)scanf("%d",d+i);
	std::sort(d,d+a);
	int ret=1;
	int at=0;
	for(int i=0;i<a;i++){
		if(d[at]+c<d[i]||at+b<=i){
			at=i;
			ret++;
		}
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    val (n, a, b) = readLine()!!.split(' ').map(String::toLong)
    val hList = (1..n).map { readLine()!!.toLong() }

    fun checkCanKill(totalAttackNum: Long): Boolean {
        val damaged = hList.map { it - b * totalAttackNum }
        val left = damaged.filter { it > 0 }
        val killCount = left.map { it / (a - b) + if (it % (a - b) == 0L) 0 else 1 }
        val needAttackCount = killCount.sum()
        return needAttackCount <= totalAttackNum
    }

    var goalCount = 1L shl 30
    for (i in 29 downTo 0) {
        val diff = 1L shl i
        val currentIndex = goalCount - diff
        if (checkCanKill(currentIndex)) {
            goalCount -= diff
        }
    }
    println(goalCount)
}

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

int main() {
  string S;
  cin >> S;
  int len = static_cast<int>(S.length());

  long total{};
  for (int i{}; i < (1 << (len - 1)); ++i) {
    long sum{S[0] & 0xF};
    for (int j{}; j < len - 1; ++j) {
      if (i & (1 << j)) {
        total += sum;
        sum = 0;
      }
      sum *= 10;
      sum += S[j + 1] & 0xF;
    }
    total += sum;
  }

  cout << total << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <string>
#include <string.h>
using namespace std;
using ll = long long;

#define right true
#define left false

int main()
{
  int n;
  cin >> n;
  vector<string> u(n);
  for (auto &e : u)
    cin >> e;
  int m;
  cin >> m;
  vector<string> t(m);
  for (auto &e : t)
    cin >> e;

  bool state = 0;
  for (int i = 0; i < m; ++i)
  {
    bool exist = false;
    for (int j = 0; j < n; ++j)
    {
      if (t[i] == u[j])
        exist = true;
    }
    if (exist)
    {
      if (state)
      {
        cout << "Closed by " << t[i] << endl;
        state = false;
      }
      else
      {
        cout << "Opened by " << t[i] << endl;
        state = true;
      }
    }
    else
    {
      cout << "Unknown " << t[i] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3220
import java.util.*;
 
class Main{
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int k = stdIn.nextInt();
        int x = stdIn.nextInt();
        String c = ""; 
        for(int i = x - k + 1; i <= x + k - 1 ; i++){
            System.out.print(c + i);
            c = " ";
        }
        System.out.println();
   }
}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
const int N=1e5+5;
int n,m;
typedef long long ll;
typedef std::pair<ll,int> P;
std::priority_queue<P,std::vector<P>,std::greater<P> > q;
std::vector<P> g[N];
ll dp[N];
const ll INF=1e18;
int main() {
    scanf("%d%d",&n,&m);
    for(int l,r,c;m--;) {
        scanf("%d%d%d",&l,&r,&c);
        g[l].push_back(P(c,r));
    }
    dp[1]=0;
    for(P c:g[1]) q.push(c);
    for(int i=2;i<=n;i++) {
        while(!q.empty()&&q.top().second<i) q.pop();
        if(q.empty()) {
            dp[i]=INF;
        }
        else {
            dp[i]=q.top().first;
            for(P c:g[i]) q.push(P(dp[i]+c.first,c.second));
        }
    }
    printf("%lld",dp[n]<INF?dp[n]:-1LL);
    return 0;
}


Measured memory_bytes: 7544
#include <bits/stdc++.h>
#define repi(i, a, b) for (int i = (int)(a) ; i < (int)(b) ; i++)
#define rep(i, n) repi(i, 0, n)
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
// using P = pair<int, int>;
struct Vec{
        double x, y;
};
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;
int main()
{
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        // cout << fixed << setprecision(15);
        int n;
        cin >> n;
        int ans = 0;
        n -= 1;
        repi(i,1, n + 1){
            ans += (n  / i);
        }
        cout << ans << endl;
        return 0;
}

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

int main(){

    int A, B, C, K;
    cin >> A >> B >> C >> K;


    while (B <= A){
        B *= 2;
        K--;
    }

    while (C <= B){
        C *= 2;
        K--;
    }

    if (K < 0){
        cout << "No";
    }
    else {
        cout << "Yes";
    }


}


Measured memory_bytes: 3600
import sys
from sys import stdin

#input = stdin.readline()

A, B, C = input().split()
A = int(A)
B = int(B)
C = int(C)

def Process(A, B, C):    #その一週間のログイン計画を演算する
    got, login = 0, 0
    if C > (7*A+B):    #一週間フルでログインしてもまだ目標に到達しない場合.
        week, remain = divmod(C, (7*A+B))
        login += (7*week)
        got += ((7*A+B)*week)

    local_date = 1
    while C > got:
        got += A
        login += 1
        local_date += 1
        if local_date == 8:
            got += B
    return login

print(Process(A, B, C))



Measured memory_bytes: 5604
N = int(input())
A = [int(i) for i in input().split(" ")]

cnt = 0
zero = False
for i in range(N):
    if A[i] < 0:
        cnt += 1
        A[i] *= -1
    elif A[i] == 0:
        zero = True
if cnt % 2 == 0 or zero:
        print(sum(A))
else:
    print(sum(A) - 2*min(A))

Measured memory_bytes: 14284
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define all(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;
const ll inf = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };

int main()
{
	ll n;
	cin >> n;
	if (n % 2 == 0) {
		cout << n << endl;
	}
	else {
		cout << n * 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	int graph[101][101] = {};
	cin >> n;
	int ans[101] = {};
	for(int i = 0; i < n; i++){
		ans[i] = -1;
		int u, k;
		cin >> u >> k;
		for(int j = 0; j < k; j++){
			int v, c;
			cin >> v >> c;
			graph[u][v] = c;
		}
	}
	priority_queue<pair<int, int> > qu;
	qu.push(make_pair(0, 0));
	ans[0] = 0;
	while(!qu.empty()){
		int nowd = -(qu.top()).first;
		int nownode = (qu.top()).second;
		qu.pop();
		for(int i = 0; i < n; i++){
			if(graph[nownode][i] == 0) continue;
			int next = nowd + graph[nownode][i];
			if(ans[i] == -1 || ans[i] > next){
				ans[i] = next;
				qu.push(make_pair(-next, i));
			}
		}
	}
	for(int i = 0; i < n; i++){
		cout << i << " " << ans[i] << endl;
	}
}

Measured memory_bytes: 3120
#include <iostream>

using namespace std;

typedef long long LL;

LL fact(int);

int main() {
    int n;
    cin >> n;
    cout << fact(n) << "\n";
    return 0;
}

LL fact(int n) {
    if (n == 1) 
        return 1;
    return fact(n-1) * n;
}

Measured memory_bytes: 2980
def readinput():
    n=int(input())
    dama=[]
    for _ in range(n):
        a,b=input().split()
        dama.append((a,b))
    return n,dama

def main(n,dama):
    sum=0.0
    for x,u in dama:
        if u=='JPY':
            sum+=int(x)
        else:
            sum+=float(x)*380000.0
    return sum

if __name__=='__main__':
    n,dama=readinput()
    ans=main(n,dama)
    print(ans)


Measured memory_bytes: 9136
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
int main(){
    int n,q;
    string s;
    cin>>n>>q>>s;
    int cnt=0;
    int count[n];
    count[0]=0;
    rep(i,1,n){
        if(s[i-1]=='A'&&s[i]=='C'){
            cnt++;
        }
        count[i]=cnt;
    }
    while(q--){
        int x,y;
        cin>>x>>y;
        cout<<count[y-1]-count[x-1]<<endl;
    }
}


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

vector<int> G[100000];
ll c[100000];
int vis[100000];
int id[100000];
priority_queue<int, vector<int>, greater<int>> q[100000];

void dfs(int v, int p, int i){
	id[v] = i;
	q[i].push(c[v]);
	vis[v] = 1;
	for(auto c : G[v]){
		if(c == p) continue;
		dfs(c, v, i);
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N, M;
	cin >> N >> M;

	if(M == N - 1){
		cout << 0 << endl;
		return 0;
	}

	for(int i = 0; i < N; i++){
		cin >> c[i];
	}
	for(int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	int T = 0;
	for(int i = 0; i < N; i++){
		if(!vis[i]){
			dfs(i, -1, T);
			T++;
		}
	}

	ll ans = 0;
	priority_queue<int, vector<int>, greater<int>> Q;
	for(int i = 0; i < T; i++){
		ans += q[i].top();
		q[i].pop();
		while(q[i].size()){
			Q.push(q[i].top());
			q[i].pop();
		}
	}

	if(Q.size() < T - 2){
		cout << "Impossible" << endl;
		return 0;
	}

	for(int i = 0; i < T - 2; i++){
		ans += Q.top();
		Q.pop();
	}
	cout << ans << endl;
}


Measured memory_bytes: 11644
import java.io.BufferedReader;
import java.io.InputStreamReader;

class Main {

        static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        public static void main(String[] args) throws Exception{

            int[] cnts = new int[51];

            for (int i=0; i<10; i++) {
                for (int j=0; j<10; j++) {
                    for (int k=0; k<10; k++) {
                        for (int l=0; l<10; l++) {
                            int sum = i + j + k + l;
                            cnts[sum]++;
                        }
                    }
                }
            }

            String s = "";
            while ((s = reader.readLine()) != null) {
                System.out.println(cnts[Integer.parseInt(s)]);
            }

        }

}

Measured memory_bytes: 16876
n,m = map(int, input().split())
p = [0] * m
s = [0] * m
for i in range(m):
    p[i],s[i] = map(str,input().split())
    p[i] = int(p[i])

ac = [0] * (n+1)
wa = [0] * (n+1)
for i in range(m):
    if s[i] == 'WA':
        if ac[p[i]] == 0:
            wa[p[i]] += 1
        else:
            pass
    if s[i] == 'AC':
        ac[p[i]] = 1

ac_num = 0
for i in range(len(ac)):
    if ac[i] != 0:
        ac_num += 1
ng = 0
for i in range(len(wa)):
    if ac[i] != 0:
        ng += wa[i]
            
print(ac_num,ng)


Measured memory_bytes: 14808
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i,n,mi,misum = 0,y,m,d;
    
    mi = 196470;
    
    
    
    scanf("%d",&n);
    for (i = 0; i < n; i++) {
        
        scanf("%d %d %d",&y,&m,&d);
        
        misum += (y-1) * 195;
        misum += (((y-1)/3)) * 5;
        
    
        misum += (m-1) * 20;
        
        if (y%3 != 0) {
        
            misum -= (m-1)/2*1;
        
        }
        
        
        misum += d-1;

        printf("%d\n",mi-misum);
        misum = 0;
        
    }
    return 0;
}

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

int main() {
    int D;
    cin >> D;
    if(D ==25){
        cout << "Christmas" << endl;
    }
    else if(D ==24){
        cout << "Christmas Eve" << endl;
    }
    else if(D ==23){
        cout << "Christmas Eve Eve" << endl;
    }
    else if(D ==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<limits>
#include<string.h>
#include<vector>
#include<stack>
#include<queue>
using namespace std;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if (a<c and c<b)
    {
        cout<<"Yes"<<endl;

    }else if (a>c and c>b)
    {
        cout<<"Yes"<<endl;  
    }else
    {
        cout<<"No"<<endl;
    }
    
    
    

    return 0;
}

Measured memory_bytes: 3092
package main

import (
	"fmt"
	"regexp"
)

func main() {
	var s string
	fmt.Scan(&s)
	// 正規表現使うとあっという間
	// ただ、正規表現の書き方が合ってるかを検証するのがめんどくさそう…。
	// 前方一致、後方一致を指定しないと失敗する
	var re = regexp.MustCompile(`^(dream(er)?|eraser?)+$`)
	// var re = regexp.MustCompile(`^(dream|dreamer|erase|eraser)+$`)
	if re.MatchString(s) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

int main() {
    int A, B, H, M;
    double l, m, diff, c;

    cin >> A >> B >> H >> M;

    l = (double)M * 6;
    double tmp = l / 12;
    m = (double)H * 30 + tmp;

    if(l == 0) {
        l = 360;
    }
    if(m == 0) {
        m = 360;
    }
    if(l > m) {
        diff = l - m;
    } else {
        diff = m - l;
    }

    double a = cos(diff * M_PI / 180);
    tmp = pow(A, 2) + pow(B, 2) - 2 * A * B * a;
    c = sqrt(tmp);
    printf("%.10f\n", c);

    return 0;
}

Measured memory_bytes: 4156
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
#define gr vector<vpii>
#define str string
#define mask vector<bool>
#define vs vector<str>
#define pq priority_queue
#define si set<int>
#define ordered_set_of(T) tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
#define fi first
#define se second
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define nub(x) x.resize(unique(all(x)) - x.begin())
#define TWO class T1, class T2
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define GAME_OVER return 0
using namespace std;
using namespace __gnu_pbds;
char _$ = ' ';
struct sep {sep(char c) {_$ = c;}};
ostream& operator<<(ostream& o, sep s) {return o;}
template<TWO> ostream& operator<<(ostream& o, pair<T1, T2> x) {return o << x.fi << ' ' << x.se;}
template<TWO> istream& operator>>(istream& i, pair<T1, T2>& x) {return i >> x.fi >> x.se;}
template<class T> ostream& operator<<(ostream& o, vector<T> x) {for (auto it : x) o << it << _$; return o;}
template<class T> istream& operator>>(istream& i, vector<T>& x) {for (auto& it : x) i >> it; return i;}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    int res = 0;
    for (int i = 1; i <= n; i++)
    {
        int k = n / i;
        res += (i + k * i) * k / 2;
    }
    cout << res << endl;
    GAME_OVER;
}

Measured memory_bytes: 3608
N,K = gets.split.map(&:to_i)
S = gets.chomp
nums = []
num = "1"
count = 0

for i in 0..N-1 do
# 連続数カウント
  if S[i] == num then
    count+=1
  else
# 連続数メモ&カウントのリセット&カウント数字の切り替え
    nums.push(count)
    count = 1
    num = num == "1"  ? "0" : "1"
  end
end
# 最後まで行くと、それ以上連続しないのでカウントをメモ
nums.push(count)
# 1..0みたいに0で終わってたら1の連続数0を加える
if nums.length % 2 == 0
  nums.push(0)
end

add = 2 * K + 1
left = 0
right = 0
tmp = 0
ans = 0

# 1の連続数は偶数ばんめのインデックス
0.step(nums.length-1, 2) do |i|
# 連続の一番左インデックス
# 連続の一番右インデックスの一個右
  nextleft = i
  nextright = [i + add, nums.length].min

# インデックス0から連続の左端手前まで引く
  while nextleft > left
    tmp -= nums[left]
    left += 1
  end
  # インデックス0から連続の右端までたす
  while nextright > right
    tmp += nums[right]
    right += 1
  end
  ans = tmp if tmp > ans  

end

puts ans

Measured memory_bytes: 2812
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    int c[n];
    int i, j;
    int alice = 0;
    int bob = 0;
    int count = 0;
    for(i=0; i<n; i++){
        cin>>c[i];
    }
    sort(c, c+n);
    for(i=n-1; i>=0; i--){
        if(count==0){
            alice+=c[i];
            count++;
        }
        else{
            bob+=c[i];
            count = 0;
        }
    }
    cout<<alice-bob<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int gcd(int,int);
int min(int,int);

int main() {

  int x,y;

  scanf("%d %d",&x,&y);

  printf("%d\n",gcd(x,y));

  return 0;

}

int gcd(int a,int b) {

  int i;
  /*
  for(i=min(a,b);i>0;i--) {
    if(a%i==0 && b%i==0) return i;
  }
  */
  i = min(a,b);
  if (i==a) { a=b; b=i; }//swap a>b
  while (b>0){
    i = a % b;
    a = b;
    b = i;
  }
  return a;
}

int min(int a,int b) {

  if(a>=b) return a;
  else return b;

}



Measured memory_bytes: 2736
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S;
const ll MOD = 998244353;
//const ll MOD = (1e+9) + 7;
const ll INF = 1LL<<58;
typedef pair<ll, ll> P;

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

int main() {
    cin>>N;
    vec a(N);
    rep(i,N) cin>>a[i];
    int skip = (N&1 ? 3 : 2);
    vector<mat> dp(N + 1, mat(2, vec(skip, 0)));
    rep(j,2) rep(k,skip) dp[0][j][k] = -INF;
    dp[0][0][0] = 0;
    rep(i,N){
        rep(k,skip){
            dp[i+1][0][k] = dp[i][1][k];
            if(k != 0) chmax(dp[i+1][0][k], dp[i][0][k-1]);
            dp[i+1][1][k] = dp[i][0][k] + a[i];
        }
    }
    ll ans = max(dp[N][0][skip - 1], dp[N][1][skip - 1]);
    chmax(ans, dp[N][0][skip - 2]);
    cout<<ans<<endl;
}

Measured memory_bytes: 34412
// [AT2285 Increment Decrement] https://www.luogu.org/problemnew/show/AT2285
#include <iostream>
#include <algorithm>

using namespace std;

int N;
int high, now;
char c;

int main()
{
    cin >> N;

    for (int i = 0; i < N; i++)
    {
        cin >> c;

        if (c == 'I')
        {
            now++;
        } else {
            now--;
        }

        if (now > high)
        {
            high = now;
        }
    }

    cout << high << endl;
    return 0;
}

Measured memory_bytes: 256
n = list(input())

if n[0] == n[1] and n[1] == n[2]:
    print('Yes')
elif n[1] == n[2] and n[2] == n[3]:
    print('Yes')
elif n[0] == n[1] == n[2] == n[3]:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,w,k;
    cin>>h>>w>>k;
    vs s(h);
    // w++;
    rep(i,h)cin>>s[i];//,s[i]+='0';
    vvi cnt(h+1,vi(w+1));
    rep(i,h){
        rep(j,w)cnt[i+1][j+1]=s[i][j]-'0';
        rep(j,w)cnt[i+1][j+1]+=cnt[i+1][j];
    }
    rep(i,h)REP(j,1,w)cnt[i+1][j]+=cnt[i][j];
    int ans=inf;
    rep(bit,1<<(h-1)){
        int t=__builtin_popcount(bit);
        vi c;
        c.eb(0);
        rep(i,h-1)if((bit>>i)&1)c.eb(i+1);
        c.eb(h);
        int d=0;
        REP(j,1,w){
            rep(i,c.size()-1){
                if(cnt[c[i+1]][j]-cnt[c[i+1]][d]-cnt[c[i]][j]+cnt[c[i]][d]>k){
                    if(j==d+1)goto l;
                    t++;
                    d=--j;
                }
            }
        }
        // cout<<t<<endl;
        ans=min(ans,t);
        l:;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3776
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
	int x, y, a = 0, b = 0;
	double c = 0;
	cin>>x>>y;
	a = x / y;
	b = x % y;
	c = double(x) / double(y);
	cout<<a<<" "<<b<<" "<<setprecision(5)<<fixed<<c<<endl;
return 0;
}

Measured memory_bytes: 3272
n, m = map(int, input().split())
l = [list(map(int, input().split())) for _ in range(m)]
l.sort(key=lambda x: x[1])
ans = 0
cur = 0
for i in range(m):
    if l[i][0] >= cur:
        cur = l[i][1]
        ans += 1
print(ans)

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

const int N=1000000,mod=998244353;
int n,k,jc[1000010],inv[1000010],ans;

int quickmi(int a,int b)
{
	int t=1;
	for (; b; b>>=1,a=1ll*a*a%mod)
		if (b&1) t=1ll*t*a%mod;
	return t;
}

int calc(int x,int y,int T)
{
	if (y-x>=T||x<0||y<0||T<=0) return 0;
	if (T>y) return 1ll*jc[x+y]*inv[x]%mod*inv[y]%mod;
	return (1ll*jc[x+y]*inv[x]%mod*inv[y]+1ll*(mod-jc[x+y])*inv[x+T]%mod*inv[y-T])%mod;
}

int main()
{
	jc[0]=1;
	for (int i=1; i<=N; i++) jc[i]=1ll*jc[i-1]*i%mod;
	inv[N]=quickmi(jc[N],mod-2);
	for (int i=N; i; i--) inv[i-1]=1ll*inv[i]*i%mod;
	scanf("%d%d",&n,&k),ans=0;
	for (int R=max(n,(k+1>>1)); R<=k; R++)
		ans=(ans+calc(R,k-R,R-n+1)-(R==k-R?calc(k-R-1,k-R,R-n+1):0))%mod;
	return printf("%d\n",ans),0;
}

Measured memory_bytes: 8064
N, M, *I = map(int, open(0).read().split())
H, AB = [0] + I[:N], I[N:]

memo = [0] * (N + 1)
for a, b in zip(*[iter(AB)] * 2):
    memo[a] = max(memo[a], H[b])
    memo[b] = max(memo[b], H[a])

print(sum(h > ma for h, ma in zip(H[1:], memo[1:])))

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

std::string s1, s2;

int main() {
    std::cin >> s1 >> s2;
    bool ok = true;
    for (int i = 0; i < 3; i++) {
        if (s1[i] != s2[2-i]) {
            ok = false;
            break;
        }
    }
    if (ok) {
        std::cout << "YES" << std::endl;
    }
    else {
        std::cout << "NO" << std::endl;
    }
}


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

from math import ceil
times = []
times.append(int(input()))
times.append(int(input()))
times.append(int(input()))
times.append(int(input()))
times.append(int(input()))


just_times = [time for time in times if time%10==0]
other_times = [time for time in times if time%10!=0]
other_times = sorted(other_times, key=lambda time: time%10)

answers = []
if len(other_times) >= 1:
    answers += [other_times[0]]
if len(other_times) > 1:
    answers += [(ceil(time/10))*10 for time in other_times[1:]]
answers += just_times
print(sum(answers))

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

int main(void){

    int n; cin >> n;
    vector<long long> a(3*n);
    for(int i = 0; i < 3*n; i++){
        cin >> a[i];
    }

    long long sum_red = 0, sum_blue = 0;
    priority_queue<long long, vector<long>, greater<long> > pb_red;
    priority_queue<long long> pb_blue;

    //redの表
    for(int i = 0; i < n; i++){
        pb_red.push(a[i]);
        sum_red += a[i];
    }

    long long ans[2][100010];
    ans[0][0] = sum_red;

    for(int i = 1; i <= n; i++){
        sum_red += a[i + n - 1];
        pb_red.push(a[i + n - 1]);
        sum_red -= pb_red.top();
        pb_red.pop();
        ans[0][i] = sum_red;
    }

    //blueの表
    for(int i = 0; i < n; i++){
        pb_blue.push(a[3*n - 1 - i]);
        sum_blue += a[3*n - 1 - i];
    }
    ans[1][n] = sum_blue;

    for(int i = n - 1; i >= 0; i--){
        sum_blue += a[i + n];
        pb_blue.push(a[i + n]);
        sum_blue -= pb_blue.top();
        pb_blue.pop();
        ans[1][i] = sum_blue;
    }

    long long ans_max = ans[0][0] - ans[1][0];
    for(int i = 1; i <= n; i++){
        ans_max = max(ans_max, ans[0][i] - ans[1][i]);
    }

    cout << ans_max << endl;
    return 0;
}


Measured memory_bytes: 5876
from collections import defaultdict
N, M = map(int, input().split())
d = defaultdict(list)
for i in range(M):
    a,b = map(int, input().split())
    d[a].append(b)

for i,j in list(d.items()):
    if i!=1:
        continue
    for k in j:
        if N in d[k]:
            print('POSSIBLE')
            exit()
print('IMPOSSIBLE')

Measured memory_bytes: 55208