akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

typedef long long ll;

int main() {
    ll K, A, B;
    ll cookie = 1;
    ll yen = 0;
    bool change = false;
    double BperA;
    cin >> K >> A >> B;

    //BperA = (double)B / (double)A;
    for (int i = 0; i < K; i++) {
        if (change) {
            yen-=1;
            cookie += B;
            change = false;
            continue;
        }
        if (cookie < A) {
            cookie++;
        } else if (K-i >= 2 && cookie>=A && B-A > 2) {
            cookie -= A;
            yen+=1;
            change = true;
        } else {
            cookie++;
        }
    }
    cout << cookie << endl;
}


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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  string s;
  cin >> s;

  int Q;
  cin >> Q;

  deque<char> deq;

  rep(i, s.length()){
    deq.push_back(s[i]);
  }

  bool state = true;

  while(Q--){
    
    int T;
    cin >> T;

    if(T == 1){

      state = !state;

    }else{

      int F;
      cin >> F;
      char c;
      cin >> c;

      if(F == 1){

        if(state){
          // 先頭から
          deq.push_front(c);
        }else{
          // 末尾に
          deq.push_back(c);
        }

      }else{

        if(state){
          deq.push_back(c);

        }else{

          deq.push_front(c);

        }
      }
    }

  }

  string ans;

  if(state){
    // deqの先頭から

    while(deq.size() > 0){
      
      ans += deq.front();
      deq.pop_front();

    }

  }else{

    while(deq.size() > 0){

      ans += deq.back();
      deq.pop_back();
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1368
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 200050
#define INF 2139062143
char s[N];
int a[30],f[N],nxt[N][30],n,i,j;
int main()
{
	scanf("%s",s);n=strlen(s);memset(f,0x7f,sizeof(f));f[0]=0;
	for (i=n;i>=1;i--){
		for (j=0;j<26;j++) nxt[i][j]=a[j],f[i]=min(f[i],f[a[j]]+1);
		a[s[i-1]-'a']=i;
	}int ans=INF,now;
	for (j=0;j<26;j++) ans=min(ans,f[a[j]]+1);
	for (j=0;j<26;j++) if (f[a[j]]==ans-1){
		putchar(j+'a');now=a[j];break;
	}
	while (now){
		for (j=0;j<26;j++) if (f[now]==f[nxt[now][j]]+1){
			putchar(j+'a');now=nxt[now][j];break;
		}
	}
	return 0;
}

Measured memory_bytes: 24576
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()

const int INF=1e9+5;
const vector<int> dx={-1,0,1,0};
const vector<int> dy={0,1,0,-1};

int main(){
    int h,w=0;
    cin>>h>>w;
    char p[25][25];
    rep(i,25) rep(j,25) p[i][j]='#';
    rep(i,h){
        string s;
        cin>>s;
        rep(j,w){
            p[i+1][j+1]=s[j];
        }
    }
    deque<P> d;
 
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(p[i+1][j+1]=='#') continue;
            vector<vector<int>> ansmat(h+1,vector<int>(w+1,INF));
            ansmat[i+1][j+1]=0;
            d.push_back({i+1,j+1});
            while(!d.empty()){
                rep(k,4){
                    int s=d.front().first+dx[k];
                    int t=d.front().second+dy[k];
                    if(p[s][t]!='#' && ansmat[s][t]==INF){
                        ansmat[s][t]=ansmat[d.front().first][d.front().second]+1;
                        d.push_back({s,t});
                    }
                }
                d.pop_front();
            }
            int now=0;
            rep(i,h+1){
                rep(j,w+1){
                    if(ansmat[i][j]!=INF){
                        now=max(now,ansmat[i][j]);
                    }
                }
            }
            ans=max(ans,now);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

use std::cmp::{max, min};
use std::collections::HashMap;

fn main() {
  let x = read::<i64>();
  let a = read::<i64>();

  println!(
    "{}",
    if x -a > 0 {
      x- a
    } else {
      0
    }
  );
}



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

vector<bool> v(100000, true);
vector<int> prime;

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

    if (n >= 3) cout << 0 << endl;
    else if (n == 2) cout << 1 << endl;
    else if (n == 1) cout << 2 << endl;
    else cout << 1 << endl;

    return 0;
}

Measured memory_bytes: 3128
n = int(input())
aa = list(map(int, input().split()))

if n==1:
    print(1)
else:
    mode = None
    ans = 1
    for i in range(n-1):
        if aa[i] != aa[i+1]:
            if mode == None:
                mode = aa[i]<aa[i+1]
            elif (aa[i] < aa[i+1]) != mode:
                ans+=1
                mode = None
        # print(aa[i], aa[i+1], aa[i]<aa[i+1],  mode, ans)
    print(ans)


Measured memory_bytes: 14224
N,K = map(int,input().split())
A = list(map(int,input().split()))

def f(x):
    if x!= 0:
        now = 0
        for i in range(N):
            now += (A[i]-1)//x
        return now <= K
    else:
        return False
l = 0; r = 10**10
while r-l > 1:
    x = (l+r)//2
    if f(x):
        r = x
    else:
        l = x
print(r)

Measured memory_bytes: 30716
#include <set>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
#define int long long
#define float double
//const int INF = 100000000000000000;

signed main(void){
  int label[] = {1,2,1,3,1,3,1,1,3,1,3,1};
  int x,y;
  cin >> x >> y;
  if(label[x-1] == label[y-1])cout << "Yes\r\n";
  else cout << "No\r\n";

}


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

int main(){
	bool is_prime[1000000];

	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<1000000; i++){
		is_prime[i]=true;
	}

	for(int i=2; i*i<1000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<1000000; j+=i){
				is_prime[j]=false;
			}
		}
	}

	while(true){
		int a;
		cin>>a;
		if(a==0)
			break;

		int cnt=0;
		for(int i=2; i<=a/2; i++){
			if(is_prime[i]){
				if(is_prime[a-i]){
					cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  int tmp=0;
  bool ans=0;
  rep(i,n){
    int di,dj;
    cin>>di>>dj;
    if(di==dj) tmp++;
    else tmp=0;
    if(tmp==3) ans=1;
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main() {
    int N, M;
    int dx[] = {1, 0, -1, 0};
    int dy[] = {0, 1, 0, -1};
    while (cin >> M >> N, N || M) {
        vector<string> v(N);
        for (auto& i: v) cin >> i;

        int sx, sy;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < M; j++) {
                if (v[i][j] == '@') sx = i, sy = j;
            }
        }

        queue<pair<int,int>> que;
        que.push(make_pair(sx, sy));

        vector<vector<int>> flag(N, vector<int>(M));
        int count = 0;
        while (que.size()) {
            auto p = que.front();
            que.pop();

            int x = p.first;
            int y = p.second;

            if (flag[x][y]) continue;

            count++;
            flag[x][y] = 1;

            for (int i = 0; i < 4; i++) {
                int nx = x + dx[i];
                int ny = y + dy[i];

                if (0 <= nx && nx < N && 0 <= ny && ny < M && v[nx][ny] == '.' && !flag[nx][ny]) {
                    que.push(make_pair(nx, ny));
                }
            }
        }

        cout << count << endl;
    }

    return 0;
}



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;

int main(){
  int n,k,c;
  string s;
  cin >>n>>k>>c;
  cin >>s;

  vector<int> l(k,0),r(k,n); //i番目の仕事日はl(i)日以降,r(i)日以前．
  
  int il=0,ir=k-1;
  int yl=-1, yr=-1;
  rep(i,n){ 

    
    if(s[i]=='o' && il<=k-1 && yl<0){
      
      l[il]=i;
      il++;
      yl=c;
    }
    
    
    if(s[n-1-i]=='o' && ir>=0 && yr<0){
      r[ir]=n-1-i;
      ir--;
      yr=c;
    }
    
    yl--;
    yr--;
  }
  
  rep(i,k){
   // cout<<r[i]<<" "<<l[i]<<" "<<endl;;
    if(r[i]==l[i]){
      cout<<r[i]+1<<endl;
    }
  }
  return 0;
  
}


Measured memory_bytes: 5036
// luogu-judger-enable-o2
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
char a[200007];
LL sum,cnt[60],l;
void rds()
{
	l=0;
	char c=getchar();
	while((c<'A'||c>'Z')&&(c<'a'||c>'z'))c=getchar();
	while((c>='A'&&c<='Z')||(c>='a'&&c<='z'))
	{
		if(c>='A'&&c<='Z')cnt[c-'A'+1]++;
		else cnt[c-'a'+31]++;
		a[++l]=c;c=getchar();
	}
	return;
}
int main()
{
	rds();
	sum=l*(l-1)/2+1;
	for(int i=1;i<=56;i++)if(cnt[i])sum-=(cnt[i]*(cnt[i]-1)/2);
	printf("%lld",sum);
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int n,a[100000],i,x[100000];
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&a[i]); x[a[i]]=i;
	}
	for(i=1;i<=n;i++) printf("%d ",x[i]);
	return 0;
}


Measured memory_bytes: 2460
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

sys.setrecursionlimit(20000000)

def yn(b):
    print("Yes" if b==1 else "No")
    return

def count_ones_by_bin(num):
    bin_num = bin(num)[2:]
    count = 0
    for i in bin_num:
            count += int(i)
    return count

def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    x=readline().rstrip()

    #pc=[0]*(10**5+1)
    #for i in range(1,10**5):
    #    pc[i]=count_ones_by_bin(i)
    amr1=[0]*((10**5)*2 + 5)
    amr2=[0]*((10**5)*2 + 5)
    bits=[False]*((10**5)*2 + 5)
    pc=[-1]*((10**5)*2 + 5)
    bcnt=0
    j=0
    for i in x:
        if int(i)==1:
            bcnt += 1
            bits[j]=True
        j+=1

    base1=0
    base2=0
    ni1=1
    ni2=1
    for j in range(n):
        i=n-1-j
        jo=n-i-1
        if j > 0:
            ni1*=2
            ni2*=2
        #amr1[i]=pow(2,jo,bcnt+1)
        ni1=ni1%(bcnt+1)
        amr1[i]=ni1
        if (bcnt-1)==0:
            amr2[i]=0 #pow(2,jo)
        else:
            #amr2[i]=pow(2,jo,bcnt-1)
            ni2=ni2%(bcnt-1)
            amr2[i]=ni2
        if bits[i]==True:
            base1+=amr1[i]
            base2+=amr2[i]
    for i in range(n):
        ans=0
        if bits[i]==True: #1->0
            if (bcnt-1)==0:
                base=0
            else:
                base=(base2-amr2[i])%(bcnt-1)
                ans+=1
        else:
            base=(base1+amr1[i])%(bcnt+1)
            ans+=1
        
        while base > 0:
            if pc[base]==-1:
                pc[base]=count_ones_by_bin(base)
            base=base%pc[base]
            ans+=1
        print(ans)
    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 35396
#include <stdio.h>
#include <math.h>
int main(){
	int n;
	scanf("%d",&n);
	int a;
	int i;
	long int sum=0;
	int min=1000000;
	int max=-1000000;
	for(i=0;i<n;i++){
		scanf("%d",&a);
		sum+=a;
		if(a>max){
			max=a;
		}
		if(a<min){
			min=a;
		}
	}
	printf("%d %d %ld\n",min,max,sum);
	return 0;
}

Measured memory_bytes: 600
n,x = map(int,input().split())
l = list(map(int,input().split()))
d = [0]*(n+1)
cnt =  0
for i in range(len(d)):
    if(i==0):
        d[i] = 0
    else :
        d[i] = d[i-1] + l[i-1]
    if(d[i]>x):
        break
    cnt += 1
print(cnt)


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

const int maxn=100005;
typedef long long ll;

int read()
{
	int f=0; char c=getchar();
	while(c>'9' || c<'0') c=getchar();
	while(c<='9' && c>='0') {f=f*10+c-'0'; c=getchar();}
	return f;
}

ll k;

ll d[maxn][15];
ll g[maxn][15];
ll s;

int main()
{
	cin>>k;
	int w;
	for(int i=0;i<=9;i++)
	{
		g[1][i]=i;
		d[1][i]=1;
	}
	if(k<=9)
	{
		cout<<k<<endl;
		return 0;
	}
	s+=9;
	for(int i=2;;i++)
	{
		for(int j=0;j<=9;j++)
		{
			for(int k=max(0,j-1);k<=min(9,j+1);k++)
			{
				d[i][j]+=d[i-1][k];
			}
			if(j!=0)
				g[i][j]=g[i][j-1]+d[i][j];
		//	cout<<"d "<<i<<' '<<j<<' '<<g[i][j]<<endl;
		}
		s+=g[i][9];
		if(s>=k)
		{
			w=i;
			break;
		}
	}
	for(int i=1;i<=w-1;i++)
		k-=g[i][9];
//	cout<<g[2][9]<<endl;
	int lst=-1;
	ll s;
	for(int i=w;i>=1;i--)
	{
		//	cout<<"here "<<i<<' '<<k<<endl; 
		if(i==w)
		{
			for(int j=9;j>=0;j--)
			{
			//	cout<<"here "<<j<<' '<<k<<' '<<g[i][j]<<endl;
				if(g[i][j]<k)
				{
					cout<<j+1; lst=j+1;
					k-=g[i][j];
					break;
				}
			}
		}
		else
		{
			s=0;
			for(int j=max(0,lst-1);j<=min(9,lst+1);j++)
			{
				s+=d[i][j];
				if(s>=k)
				{
					cout<<j; lst=j;
					k-=(s-d[i][j]);
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2304
/*
CODED BY               
**************
DARSHAN JAIN
darshanjain31
**************
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define M 1000000007
#define mint INT_MAX;
#define sd(x) scanf("%d",&x)
#define pds(x) printf("%d ",x)
#define pdn(x) printf("%d\n",x)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define funcvalue(qq,ww) cout<<"value1="<<qq<<"     "<<"value2="<<ww<<endl;
#define output(out) cout<<out<<endl;
#define linechange cout<<endl;
using namespace std;
#define MAX 100005
bool palindrome(string s)
{
    ll n= s.size();
    for(int i=0;i<s.size()/2;i++)
    {
        if(s[i]!=s[n-i-1])
         return false;
    }
    return true;
}
int main()
{
    string s;
    cin>>s;
    ll n=s.size();
    string s1,s2;
    for(int i=1;i<=(n-1)/2;i++) 
    {
      s1.push_back(s[i-1]);
    }
    for(int i=(n+3)/2;i<=n;i++) 
    {
      s2.push_back(s[i-1]);
    }
    if(palindrome(s)&& palindrome(s1)&& palindrome(s2))
    { 
      cout<<"Yes"<<endl;
    }
    else 
      {
        cout<<"No"<<endl;
      }
   
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#define REP(i, N) for(ll i = 0; i < N; ++i)
#define FOR(i, a, b) for(ll i = a; i < b; ++i)
#define ALL(a) (a).begin(),(a).end()
#define pb push_back
#define INF (long long)1000000000
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	while(true) {
		int n, m;
		cin>>n;
		if(n == 0) break;
		vector<P> bil(n);
		vector<vector<double> > p(n, vector<double>(n));
		REP(i, n) {
			ll b, x, y;
			cin>>b>>x>>y;
			--b;
			bil[b] = P(x, y);
		}
		REP(i, n) {
			REP(j, n) {
				if(i == j) continue;
				p[j][i] = p[i][j] = (bil[i].first - bil[j].first) * (bil[i].first - bil[j].first) + (bil[i].second - bil[j].second) * (bil[i].second - bil[j].second);
			}
		}
		cin>>m;
		REP(i, m) {
			int s, g;
			cin>>s>>g;
			--s;
			--g;
			priority_queue<P> que;
			vector<ll> d(n, INF * INF);
			vector<ll> bef(n, INF * INF);
			que.push(P(0, s));
			d[s] = 0;
			while(!que.empty()) {
				P np = que.top();
				que.pop();
				if(d[np.second] != np.first) continue;
				REP(j, n) {
					if(j == np.second) continue;
					if(p[np.second][j] <= 2500) {
						if(d[j] > d[np.second] + sqrt(p[np.second][j])) {
							d[j] = d[np.second] + sqrt(p[np.second][j]);
							que.push(P(d[j], j));
							bef[j] = np.second;
						}
					}
				}
			}
			if(d[g] == INF * INF) cout<<"NA"<<endl;
			else {
				vector<ll> pass;
				pass.pb(g);
				ll np = g;
				while(true) {
					pass.pb(bef[np]);
					if(bef[np] == s) break;
					np = bef[np];
				}
				REP(j, pass.size()) {
					cout<<pass[pass.size() - 1 - j] + 1;
					if(j != pass.size() - 1) cout<<" ";
					else cout<<endl;
				}
			}
		}
	}
}

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

#define N 105

int c[N];

vector <pair <int, int> > vec;

int main() {
    int n, tot = 0;
    scanf("%d", &n);
    int up = n;
    if (n&1) c[n] = ++ tot, up --;
    for (int i = 1; i <= up/2; i ++) {
        c[i] = c[up+1-i] = ++ tot;
    }
    for (int i = 1; i <= n; i ++) {
        for (int j = i+1; j <= n; j ++) {
            if (c[i] != c[j]) vec.push_back(make_pair(i, j));
        }
    }
    printf("%d\n",vec.size());
    for (auto x : vec) printf("%d %d\n", x.first, x.second);
	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll                          long long int
#define rep(i,a,n)                  for(int i=a;i<n;++i)
#define per                         for(int i=n-1;i>=0;--i)
#define pb                          push_back
#define mp                          make_pair                        
#define all(x)                      (x).begin(),(x).end() 
#define in                          insert
#define transup(str)                transform(str.begin(),str.end(),str.begin(),::toupper)
#define translow(str)               transform(str.begin(),str.end(),str.begin(),::tolower)
#define intmax                      INT_MAX
#define intmin                      INT_MIN
#define mod                         1000000007
using namespace std;
int gcd(int a,int b){

    if (b==0){
        return a;
    }
    else{
        return gcd(b,a%b);
    }
}
std::vector<int> primefactors;   
void primefactorisation(int n)  
{  
    
    while (n % 2 == 0)  
    {  
        primefactors.pb(2);
        n = n/2;  
    }  
  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        
        while (n % i == 0)  
        {  
            primefactors.pb(i);
            n = n/i;  
        }  
    }
    if (n>2)
    {
        primefactors.pb(n);
    }
    return ;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
ll check(int*arr,int s,int e,int key){

    ll ans=-1;
    while(s<=e){
       
        ll mid=(s+e)/2;
        if (arr[mid]==key)
        {
            ans=1;
            break;
        }
        else if (arr[mid]>key)
        {
            e=mid-1;
        }
        else if (arr[mid]<key)
        {
            s=mid+1;
        }
    }

    return ans;
}
void sieve(){

    ll prime[1000001]={0};
    for (ll i = 4; i <=1000000; i+=2)
    {
        prime[i]=1;
    }
    prime[2]=0;
    for(ll i=3;i<=1000000;i+=2){
        for(ll j=i*i;j<1000000;j+=i){
            prime[j]=1;
        }
    }
    prime[0]=1;
    prime[1]=1;
    std::vector<ll> vprime;
    for(ll i=0;i<10000;++i){
        if (prime[i]==0)
        {
            vprime.pb(i);
        }
    }

}
bool compare(int a,int b){
    return a>b;
}
int main(int argc, char const *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    int x,y,z;
    cin>>x>>y>>z;
    swap(x,y);
    swap(x,z);
    cout<<x<<" "<<y<<" "<<z<<'\n';
    

    return 0;
}



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

using namespace std;

int main() {
	int n, t, a;
	cin >> n >> t >> a;
	vector<int> h(n+1);
	for (int i = 1; i <= n; i++) {
		cin >> h[i];
	}
	double m = 1000000;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		double d = abs(a*1000 - (t*1000 - h[i] * 6));
		m = min(m, d);
		if (m == d)ans = i;
	}

	cout << ans << endl;

	return 0;
}

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

int main() {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;

	if (a1 + a2 + a3 >= 22) cout << "bust" << endl;
	else cout << "win" << endl;
	
	
	return 0;
}









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

num=[0]*10**5 
a=sum(A)

for i in A: #各数字が何個あるか
  num[i-1]+=1

for _ in range(Q):
  b,c=map(int, input().split())
  
  a=a+(-num[b-1]*b+c*num[b-1])
  num[c-1]+=num[b-1]
  num[b-1]-=num[b-1]
  print(a)


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

namespace AtCoder
{
    class Program
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();
            bool flag = false;
            long res = 0;
            List<int> lwhite = new List<int>();
            List<int> lblack = new List<int>();
            if (S[0] == '.') lblack.Add(0);
            char bef = S[0];
            int temp = 0;
            for (int i = 0; i < N; i++)
            {
                if (S[i] == bef)
                {
                    temp++;
                }
                else
                {
                    if (bef == '.')
                    {
                        lwhite.Add(temp);
                    }
                    else
                    {
                        lblack.Add(temp);
                    }
                    temp = 1;
                    bef = S[i];
                }
            }
            if (bef == '.')
            {
                lwhite.Add(temp);
            }
            else
            {
                lblack.Add(temp);
                lwhite.Add(0);
            }
            long bnum = 0, wnum = 0;
            bnum += lblack[0];
            for (int i = 1; i < lwhite.Count; i++)
            {
                wnum += lwhite[i];
            }
            long restemp = bnum + wnum;
            long minres = restemp;
            for (int i = 1; i < lwhite.Count; i++)
            {
                restemp = restemp - lwhite[i] + lblack[i];
                minres = (minres > restemp)? restemp: minres;
            }
            for (int i = 0; i < N; i++)
            {
                if (S[i] == '#') flag = true;
                if (flag && S[i] == '.') res++;
            }
            flag = false;
            long res2 = 0;
            for (int i = N - 1; i >= 0; i--)
            {
                if (S[i] == '.') flag = true;
                if (flag && S[i] == '#') res2++;
            }
            long ress = (res < res2)? res: res2;
            Console.WriteLine((minres < ress)? minres: ress);
        }
    }
}

Measured memory_bytes: 13792
#2020-03-18
while True:
	a, b, c = input().split()
	a = int(a)
	c = int(c)
	if b == "?":
		break
	if b == "+":
		print(a + c)
	if b == "-":
		print(a - c)
	if b == "*":
		print(a * c)
	if b == "/":
		print(a // c)


Measured memory_bytes: 5596
import java.util.Scanner;

public class Main {
	private static Scanner sc=new Scanner(System.in);
	private static int point=sc.nextInt();
	private static int line=sc.nextInt();
	private static int[][] a=new int[point+1][point+1];
	private static int counter=0;
	private static int[] visited=new int[point+1];
	public static void main(String[] args){
		for(int i=0;i<line;i++){
			int pa=sc.nextInt();
			int pb=sc.nextInt();
			a[pa][pb]=1;
			a[pb][pa]=1;
		}
		visited[1]=1;
		visit(1);
		System.out.println(counter);
	}
	private static void visit(int i){
		int sum=0;
		for(int k=1;k<=point;k++){
			sum+=visited[k];
		}
		if(sum==point){ 
			counter++;
			return;
		}
		for(int j=1;j<=point;j++){
			if(a[i][j]==1&&visited[j]==0){
				visited[j]=1;
				visit(j);
				visited[j]=0;
			}
		}
	}
}

Measured memory_bytes: 21844
#!/usr/bin/env python
# -*- coding: utf-8 -*-

PQR = input()
P = int(PQR.split(' ')[0])
Q = int(PQR.split(' ')[1])
R = int(PQR.split(' ')[2])

#print(P, Q, R)

result = []
result.append(P+Q)
result.append(P+R)
result.append(R+Q)

print(min(result))


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n =sc.nextLong();
        long k =sc.nextLong();
        n = n % k;
        while (true) {
            long tmp = Math.abs(k - n);
            if (tmp >= n) {
                break;
            }
            n = tmp;
        }
        System.out.println(n);
    }
}


Measured memory_bytes: 21844
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class EFriendships {
public:
    static constexpr int kStressIterations = 0;

    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;

        if (N == 2) {
            if (K != 0) {
                cout << -1 << endl;
            } else {
                cout << 1 << endl;
                cout << 1 << " " << 2 << endl;
            }
            return;
        }

        int c = N - 2;
        int max = c + c * (c - 1) / 2;
        if (K > max) {
            cout << -1 << endl;
            return;
        }

        vector<P> v;
        v.emplace_back(1, 2);
        REP(i, c) {
            v.emplace_back(2, i + 3);
        }

        int diff = max - K;
        FOR(i, 3, N) {
            FOR(j, i + 1, N) {
                if (diff == 0) break;
                v.emplace_back(i, j);
                diff--;
            }
        }
        if (diff > 0) {
            FOR(i, 3, N) {
                if (diff == 0) break;
                v.emplace_back(1, i);
                diff--;
            }
        }
        cout << v.size() << endl;
        REP(i, v.size()) {
            cout << v[i].first << " " << v[i].second << endl;
        }

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    EFriendships solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

ll d[(1<<9)+1][100001];


ll pow(ll a, ll b) {
  if (b == 0) {
    return 1;
  } else if (b % 2 == 0) {
    ll d = pow(a, b / 2);
    return (d * d) % MOD;
  } else {
    ll d = pow(a, b - 1);
    return (a * d) % MOD;
  }
}

int main(){
    ll n,q;
    cin >> n;
    vector<ll> v(n+1),w(n+1);
    for(int i = 1; i <= n; i++){
        cin >> v[i] >> w[i];
    }

    for(int i = 0; i < (1<<9); i++){
        for(int j = 0; j < 100001; j++){
            d[i][j] = 0;
        }
    }

    ll half = min(((ll)1<<9L), n+1);
    for(int i = 1; i < half; i++){
        for(int j = 0; j < 100001; j++){
            d[i][j] = max(d[i][j],d[i/2][j]);
            if(j-w[i] >= 0) {
                d[i][j] = max(d[i][j],d[i/2][j-w[i]]+v[i]);
            }
        }
    }

    cin >> q;
    for(int i = 0; i < q; i++){
        ll p,l;
        cin >> p >> l;
        if(p < half){
            cout << d[p][l] << endl;
        } else {
            vector<ll> items;
            ll tmp = p;
            while(tmp >= half){
                items.push_back(tmp);
                tmp /= 2;
            }
            ll ans = d[tmp][l];
            ll cnt = items.size();
            for(int j = 0; j < (1<<cnt); j++){
                ll tmp_v = 0, tmp_w = 0;
                for(int k = 0; k < cnt; k++){
                    if(((j>>k)&1) == 1){
                        tmp_v += v[items[k]];
                        tmp_w += w[items[k]];
                    }
                }
                if(l-tmp_w >= 0){
                    ans = max(ans, d[tmp][l-tmp_w]+tmp_v);
                }
            }

            cout << ans << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 407360
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

ll v[32] {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    ll k;
    cin >> k;
    out(v[k-1]);
    re0;
}

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

using namespace std;

int main() {
  vector<int> A(3);
  for (int i = 0; i < 3; i++) cin >> A[i];
  cout << accumulate(A.begin(), A.end(), 0) - *max_element(A.begin(), A.end()) << endl;;
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"os"
)

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	var n int
	var s string
	fmt.Fscan(fp, &n, &s)

	diff := 0

	for i := 0; i < n; i++ {
		if s[i] == 'R' {
			diff++
		} else {
			diff--
		}
	}
	if diff > 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")

	}

}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
using namespace std;
typedef long long ll;
typedef pair<ll,int> p;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    if(p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      ++ans;
    }
  }
  if(p[n - 1] == n) ++ans;
  cout << ans << endl;
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int twopower[35] = {};

int main() {
    twopower[0] = 1;
    int n,sum = 0;
    scanf("%d", &n);
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a.at(i));
    }
//    cout << a.at(1) << endl;
    for (int i = 1; i <= 30; i++)
    {
        twopower[i] = twopower[i - 1] * 2;
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j <= 30; j++)
        {
            if ( (a.at(i)%twopower[j]) != 0 )
            {
                sum += (j - 1);
                break;
            }
        }
    }

    cout << sum << endl;
}

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

long long n,a,b;

int main()
{
	scanf("%lld %lld %lld",&n,&a,&b);
	if(abs(a-b)%2==0) printf("%lld",abs(a-b)/2);
	else {
		printf("%lld",min(min(a,b)-1,n-max(a,b))+1+(abs(a-b)-1)/2);
	}
}

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

using namespace std;

class DisjointSet
{
public:
    DisjointSet(int size) : fathers_(size, -1) {}

    int GetRoot(int node)
    {
        if (fathers_[node] == -1) {
            return node;
        }
        return fathers_[node] = GetRoot(fathers_[node]);
    }

    void Unite(int a, int b)
    {
        int root_a = GetRoot(a);
        int root_b = GetRoot(b);

        if (root_a != root_b) {
            fathers_[root_b] = root_a;
        }
    }

private:
    vector<int> fathers_;
};

int main()
{
    int n, m;
    cin >> n >> m;

    vector<int> perm(n);
    for (auto &num : perm) {
        cin >> num;
        num -= 1;
    }

    DisjointSet groups(n);
    for (int i = 0; i < m; i += 1) {
        int a, b;
        cin >> a >> b;
        groups.Unite(a - 1, b - 1);
    }

    int res = 0;
    for (int i = 0; i < n; i += 1) {
        res += (groups.GetRoot(i) == groups.GetRoot(perm[i]) ? 1 : 0);
    }

    cout << res << "\n";
    return 0;
}


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

int main()
{
    int count=0;
    int n;
    cin>>n;
    vector <int> v(n);
    
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }

    sort(v.begin(),v.end());

    int q,x;
    cin>>q;
    for(int i=0;i<q;i++)
    {
        cin>>x;
        if(binary_search(v.begin(),v.end(),x))
        {
            count++;
        }
    }

    cout<<count<<endl;
    return 0;
}


Measured memory_bytes: 3140
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define mkp make_pair
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
typedef long double ld;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<62);
const int inf=(1<<30);
const int nmax=1e5+50;
const int mod=1e9+7;
using namespace std;
int n,i;
ld cur,tot,f,x[10],y[10];
vector<int>pr;
ld dist(int i,int j)
{
	ld v=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
	return sqrt(v);
}
int main()
{
	//freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	f=1.0;
	for(i=1;i<=n;i++)cin>>x[i]>>y[i],pr.pb(i),f*=i;
	do
	{
		cur=0;
		for(i=1;i<n;i++)
		{
			cur+=dist(pr[i-1],pr[i]);
		}
		tot+=cur;
	}while(next_permutation(pr.begin(),pr.end()));
	tot/=f;
	cout<<fixed<<setprecision(10)<<tot<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,d,ans = 0;
	cin>>a>>b>>c>>d;
	ans += min(d,a);
	d -= min(d,a);
	if(d)d-=min(b,d);
	if(d)ans-=min(d,c);
	cout<<ans;
}

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

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(i,b) for(int i=0;i<b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);
int cnt[105];
const LL MOD = 1e9 + 7;
int main()
{
    int n;
    cin >> n;
    string str;
    cin >> str;
    REP(i,n)
    {
        int d = str[i] - 'a';
        cnt[d]++;
    }
    LL ans = 1;
    for(int i = 0;i < 26;i++)ans = (ans * (cnt[i] + 1)) % MOD;
    ans = (ans - 1 + MOD) %MOD;
    cout << ans << "\n";
}


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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
}

void solve() {
	string s; cin >> s;
	set<char> q; for (char c: s) q.insert(c);
	cout << (q.size() > 1?"Yes":"No");
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x[] = new int[3];
        for(int i=0; i<3; i++){
            x[i] = sc.nextInt();
        }
        System.out.println((x[0] * x[1])/2);
        
    }
}


Measured memory_bytes: 22740
#include <stdio.h>
int main(void){
    long long a,i,b;
    long long sum=0;
    long long min=100000000;
    long long max=-100000000;
    scanf("%lld",&a);
    for(i=1;i<=a;i++){
        scanf("%lld",&b);
        if(b>max){
        max=b;
        }
        if(b<min){
            min=b;
        }
        sum=sum+b;
    }        
        printf("%lld %lld %lld\n",min,max,sum);
        return 0;
}


Measured memory_bytes: 2104
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int v;
	map<int, int>a, b;
	rep(i, n) {
		cin >> v;
		if (i % 2)a[v]++;
		else b[v]++;
	}
	int ma = 0;
	int ans = 0;
	int ans2 = 0;
	int f;
	for (auto i = a.begin(); i != a.end(); i++) {
		int z = ma;
		ma = max((*i).second, ma);
		if (z != ma)f = (*i).first;
	}
	ans += (n + 1) / 2 - ma;
	ma = 0;
	for (auto i = b.begin(); i != b.end(); i++) {
		if (f != (*i).first)ma = max((*i).second, ma);
	}
	ans += n / 2 - ma;
	ma = 0;
	for (auto i = b.begin(); i != b.end(); i++) {
		int z = ma;
		ma = max((*i).second, ma);
		if (z != ma)f = (*i).first;
	}
	ans2 += n / 2 - ma;
	ma = 0;
	for (auto i = a.begin(); i != a.end(); i++) {
		if (f != (*i).first)ma = max((*i).second, ma);
	}
	ans2 += (n + 1) / 2 - ma;
	cout << min(ans, ans2) << endl;
	return 0;
}

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

using namespace std;




int main(){
    
    
    int N;
    cin >> N;
    int A[N+1];
    int B[N+1];
    int C[N];
    
    A[0] = 0;
    B[0] = 0;
    C[0] = 0;
    
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
        
    }
    for (int i = 1; i <= N; i++) {
        cin >> B[i];
        
    }
    for (int i = 1; i <= N-1; i++) {
        cin >> C[i];
        
    }
    
    int ans = 0;
    
    for (int i = 1; i <= N; i++) {
        ans += B[A[i]];
        if (i!=1) {
            if (A[i-1] + 1 == A[i]) {
                ans += C[A[i-1]];
            }
        }
        
        
    }
    
    cout << ans << endl;
    
    
}



Measured memory_bytes: 256
l = []
while True:
    n,k = map(int,input().split())
    if n == 0 and k == 0:
        break
    for i in range(n):
        l.append(int(input()))
    n_sum1 = 0
    n_sum2 = 0
    n_max = 0
    for i in range(k):
        n_sum1 += l[i]
    for i in range(n-k):
        n_sum2 =n_sum1 - l[i] +l[i+k]
        if n_sum2 > n_max:
            n_max = n_sum2
        n_sum1 = n_sum2
    print(n_max)


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

int main() {
    string S; cin >> S;
    int ans = 1000;
    for (int i = 0; i < S.size() - 2; i++) {
        int picked_number = stoi(S.substr(i, 3));
        int diff = max(picked_number - 753, 753 - picked_number);
        ans = min(ans, diff);
    }
    cout << ans << endl;
}


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

int main(){
    int N;
    double ans = 0;
    cin >> N;
    vector<int>vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    ans =(vec.at(0) + vec.at(1)) / 2.0;
    if(N > 2){
        for(int i = 2; i < N; i++){
            ans = (ans + vec.at(i)) / 2.0;
        }  
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
s=input()
n=len(s)
list=['A','C','G','T']
ans=[]
for i in range(n):
  k=0
  while i+k<=n-1:
    if all(a in list for a in s[i:i+k+1]):
      ans.append(k+1)
    k+=1
if len(ans)==0:
  print(0)
else:
  print(max(ans))

Measured memory_bytes: 3060
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int MAX = 1299709;

int main() {
	vi prime(MAX+1, 1);
	FOR(i, 2, MAX) {
		if(prime[i]) {
			for(int j = 2*i; j <= MAX; j+=i) {
				prime[j] = 0;
			}
		}
	}

	int n;
	while(cin >> n, n) {
		int ans = 0;
		int left, right;
		left = right = n;
		while(!prime[left]) {
			ans++;
			left--;
		}

		while(!prime[right]) {
			ans++;
			right++;
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 6220
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

int main()
{
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for(int i=0; i<N; i++) cin >> h[i];

    int ans = 0;
    for(int i=0; i<N; i++){
        if(h[i] >= K) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
n, k = (int(i) for i in input().split())
c = 0
for x in range(k, n+2):
    h = x * (x - 1) / 2
    t = x * (n + n - x + 1) / 2
    c = c + (t - h) + 1
print(int(c%(10**9+7)))


Measured memory_bytes: 9184
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
	int i;
	int len1,len2;
	char a[105];
	char b[105];
	scanf("%s",a);
	scanf("%s",b);
	len1 = strlen(a);
	len2 = strlen(b);
	if(len1 < len2)
	{
		printf("LESS\n");
	}
	if(len1 > len2)
	{
		printf("GREATER\n");
	}
	int vis = 1;
	if(len1 == len2)
	{
		for(i = 0 ; i < len1 ; i++)
		{
			if(a[i] < b[i])
			{
				vis = 0;
				printf("LESS\n");
				break;
			}
			if(a[i] > b[i])
			{
				vis = 0;
				printf("GREATER\n");
				break;
			}
		}
		if(vis == 1)
		{
			printf("EQUAL\n");
		}
	}
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n;
    string s;
    cin>>n>>s;
    for(int i=0;i<s.size();i++)
    {
        char c=s[i];
        int cnt=(s[i]-'A'+n)%26;
        s[i]='A'+cnt;
    }
    cout<<s<<endl;
    
    return 0;
}

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

int main(){

  int t,len,s,i,j;
  char str[200];
  int count=1;
  scanf("%s",str);

  len=strlen(str);
  //    printf("%d\n",len);
  for(i=1;i<len;i++){
    t=1;
    //    count++;
    //printf("%d\n",i);

    if((len-i)%2!=0){
      continue;
    }else{
      // printf("%d\n",len-i);
      // s=len-i;
      //      printf("%d\n",len);
      for(j=0;j<(len-i)/2;j++){

        // printf("%d\n",t);
        if(str[j] != str[(len-i)/2+j]){
          t = 0;
          // printf("%d",t);
        }
      }

      if(t == 1){
        printf("%d\n",len-i);
        break;
      }
    }
  }
  return 0;
}

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

D = []
for _ in range(N):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        D.append(True)
    else:
        D.append(False)

for i in range(N-2):
    if D[i] and D[i+1] and D[i+2]:
        print('Yes')
        exit(0)
print('No')


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

int main( ) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,n;
    t = 1;
    while(t--) {
	 cin >> n;
	  cout << n * n * n << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    string s;
    cin >> n >> s;

    ll x = 0;
    ll ans = 0;
    rep(i, n) {
        if(s[i] == 'I') {
            x++;
        }
        else {
            x--;
        }
        chmax(ans, x);
    }
    
    out(ans);
    re0;
}

Measured memory_bytes: 256