akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int64_t N;
	cin >>N;
	int64_t pn_2=2LL;
	int64_t pn_1=1LL;
	for(int64_t i=0;i<N-1;i++){
		pn_1 = pn_1+pn_2;
		pn_2 = pn_1-pn_2;
	}
	cout << pn_1<<endl;
	}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <algorithm>

using namespace std;
using LL = long long;
const int N = 200005;
int n, a[N];
int mp[N];
int main()
{
	LL k;
	cin >> n >> k;

	for (int i = 1; i <= n; ++i)
	{
		cin >> a[i];
		mp[i] = a[i];
	}

	int now = 1;
	map<int, int> v;

	int count = 1;
	if (a[1] == 1)
	{
		cout << 1 << endl;
		return 0;
	}

	int len, k1;

	while (1)
	{
		if (v[now] > 0)
		{
			len = count - v[now];//环的长度
			k1 = v[now] - 1;//多余路径长度
			break;
		}
		v[now] = count;
		now = mp[now];//跳到新节点
		++count;//路径增加
	}

	int res = 0;

	if (k > k1)
	{
		res = k1 + (k - k1) % len;
	}
	else
		res = k;

	now = 1;
	for (int i = 1; i <= res; ++i)
	{
		now = mp[now];
	}
	
	cout << now << endl;

	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    long int n;cin>>n;
    vector<char> name;
    while(n!=0){
        n--;
        char c=n%26+'a';
        name.push_back(c);
        n/=26;
    }
    for(int i=name.size()-1;i>=0;i--){
        cout<<name[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3636
import numpy as np

N = int(input())
a = list(map(int,input().split()))
dp = [0] * (N+1)
dp[0] = abs(a[0])
for i in range(1, N):
    dp[i] = abs(a[i]-a[i-1])
dp[N] = abs(a[-1])
result = sum(dp)
for i in range(N):
    ans = result
    ans -= dp[i]+dp[i+1]
    if i == 0:
        ans += abs(a[i+1])
    elif i == N-1:
        ans += abs(a[i-1])
    else:
        ans += abs(a[i+1] - a[i-1])
    print(ans)


Measured memory_bytes: 22856
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define pb push_back
int n;

struct chip {
  int x, y;
  chip(int ax, int ay):x(ax), y(ay){}
};

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

void solve() {
  int max_x = 0, min_x = 0, max_y = 0, min_y = 0;
  
  vector<chip> cl;
  cl.pb(chip(0, 0));
  for (int i = 0; i < n-1; i += 1) {
    int id, dir, tx, ty;
    cin>>id>>dir;
    tx = cl[id].x + dx[dir];
    ty = cl[id].y + dy[dir];
    cl.pb(chip(tx, ty));
    max_x = max(max_x, tx);
    max_y = max(max_y, ty);
    min_x = min(min_x, tx);
    min_y = min(min_y, ty);
  }
  
  cout<<max_x-min_x + 1<<" "<<max_y-min_y + 1<<endl;  
}

int main (int argc, char const* argv[]) {
  while (cin>>n, n) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 0
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	a, p := make([]int, n), make([]int, n)
	for i := range a {
		fmt.Scan(&a[i])
		p[i] = a[i] - i - 1
	}
	sort.Ints(p)

	b := p[n/2]
	ans := 0
	for i := range p {
		ans += abs(p[i] - b)
	}
	fmt.Println(ans)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

Measured memory_bytes: 7808
module Main where


main :: IO()
main = do
  [n,m,k] <- map read . words <$> getLine
  putStrLn $ solve n m k

solve :: Int -> Int -> Int -> String
solve n m k = if subSolve n m k then "Yes" else "No"

subSolve :: Int -> Int -> Int -> Bool
subSolve n m k = anyForList . map (\(hp, wp) ->
  case cellsNum n m hp wp of
    Just x  -> x == k
    Nothing -> False) $ allPattern [0..n] [0..m]

allPattern :: [a] -> [a] -> [(a,a)]
allPattern [] _ = []
allPattern (x:xs) xss' = map (\x' -> (x, x')) xss' ++ allPattern xs xss'

cellsNum :: Int -> Int -> Int -> Int -> Maybe Int
cellsNum h w hp wp
  | h < hp || w < wp  = Nothing
  | otherwise         = Just $ (w - wp) * hp + (h - hp) * wp

anyForList :: [Bool] -> Bool
anyForList [] = False
anyForList (b:bs)
  | b         = True
  | otherwise = anyForList bs


Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
#define EPS 0.001
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    ll a; cin >> a;
    string b; cin >> b;
    ll b100 = (b[0] - '0') * 100 + (b[2] - '0') * 10 + (b[3] - '0');
    cout << a * b100 / 100 << endl;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

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

int main() {
  int h,w,d;
  cin>>h>>w>>d;
  P memo[h*w+1];
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int a;
      cin>>a;
      memo[a]=make_pair(i,j);
    }
  }
  int sum[h*w+1];
  for(int i=1;i<=d;i++){
    for(int j=i;j<=h*w;j+=d){
      if(j==i) sum[j]==0;
      else{
        sum[j]=sum[j-d]+abs(memo[j].first-memo[j-d].first)+abs(memo[j].second-memo[j-d].second);
      }
    }
  }
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<sum[r]-sum[l]<<endl;
  }
  return 0;
}


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

const int N = 1e6+1;
int p[N], cnt[N], a[N];
int g, n;

void solve(int &test) {
	for(int i = 2; i < N; i++) {
		if(!p[i]) {
			for(int j = i; j < N; j += i) {
				if(!p[j])p[j] = i;
			}
		}
	}

	cin >> n;

	for(int i = 0; i < n; i++) {
		cin >> a[i];

		int x = a[i];
		while(x != 1) {
			int y = p[x];
			while(x % y == 0) {
				x /= y;
				cnt[y]++;
			}
		}

		g = __gcd(g, a[i]);
	}

	bool ans = 1;

	for(int i = 0; i < n; i++) {
		bool f = 1;

		while(a[i] != 1) {
			int y = p[a[i]];
			while(a[i]%y == 0) {
				a[i] /= y;
				cnt[y]--;
			}

			if(cnt[y] > 0)f = 0;
		}

		ans &= f;
	}

	if(ans) {
		cout << "pairwise coprime" << endl;
	}
	else if(g == 1) {
		cout << "setwise coprime" << endl;
	}
	else {
		cout << "not coprime" << endl;
	}
}

signed main(){

    ios_base::sync_with_stdio(0); 
    cin.tie(0); cout.tie(0);   
    start = clock();
    
  
    int test = 1;
    // cin >> test;

    cout << fixed << setprecision(2);
     
    for(int i = 1; i <= test; ++i){
        solve(i); 
    }

    cerr << time(start);
    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);

    int n;
    int k;

    cin >> n >> k;
    vector<int> v(10);

    for (int i = 0; i < k; ++i) {
        int a;
        cin >> a;
        v[a]++;
    }

    int t = 0;
    while (!t) {
        int temp = n;
        int f = 1;
        while (temp) {
            if (v[temp%10] == 1) {
                f = 0;
                break;
            }
            temp /= 10;
        }
        if (f) {
            cout << n;
            break;
        }
        n++;
    }

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w,d;
  cin>>h>>w>>d;
  vector<vector<int>> a(h*w,vector<int>(2));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int x;
      cin>>x;
      a.at(x-1)={i,j};
    }
  }
  vector<int64_t> s(h*w,0);
  for(int i=d;i<h*w;i++)
    s.at(i)=s.at(i-d)+abs(a.at(i).at(0)-a.at(i-d).at(0))+abs(a.at(i).at(1)-a.at(i-d).at(1));
  int q;
  cin>>q;
  for(int i=0;i<q;i++){
    int l,r;
    cin>>l>>r;
    cout<<s.at(r-1)-s.at(l-1)<<endl;
  }
}

Measured memory_bytes: 6784
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int n;
    cin >> n;
    while(--n >= 0){
        vector<vector<int> > a(9, vector<int>(9));
        for(int i=0; i<9; ++i){
            for(int j=0; j<9; ++j){
                cin >> a[i][j];
            }
        }

        vector<vector<bool> > wrong(9, vector<bool>(9, false));
        for(int i=0; i<9; ++i){
            for(int j=0; j<9; ++j){
                for(int k=j+1; k<9; ++k){
                    if(a[i][j] == a[i][k])
                        wrong[i][j] = wrong[i][k] = true;
                    if(a[j][i] == a[k][i])
                        wrong[j][i] = wrong[k][i] = true;
                    int y1 = (i/3)*3 + (j/3);
                    int x1 = (i%3)*3 + (j%3);
                    int y2 = (i/3)*3 + (k/3);
                    int x2 = (i%3)*3 + (k%3);
                    if(a[y1][x1] == a[y2][x2])
                        wrong[y1][x1] = wrong[y2][x2] = true;
                }
            }
        }

        for(int i=0; i<9; ++i){
            for(int j=0; j<9; ++j){
                if(wrong[i][j])
                    cout << '*';
                else
                    cout << ' ';
                cout << a[i][j];
            }
            cout << endl;
        }

        if(n > 0)
            cout << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

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

#define int long long

#define MOD 1000000007

vector<int> graph[100010];
vector<int> tree[100010];

int used[100010] = {};
void make_tree(int idx){
    used[idx] = 1;
    for(int i = 0;i < graph[idx].size();i++){
        if(used[graph[idx][i]] == 0){
            tree[idx].push_back(graph[idx][i]);
            make_tree(graph[idx][i]);
        }
    }
    return;
}

int memo[100010][2];

int dp(int idx){
    for(int i = 0;i < tree[idx].size();i++){
        dp(tree[idx][i]);
    }

    int white = 1;
    int black = 1;

    for(int i = 0;i < tree[idx].size();i++){
        int child = tree[idx][i];
        white *= (memo[child][0] + memo[child][1]);
        black *= memo[child][0];
        white %= MOD;
        black %= MOD;
    }

    memo[idx][0] = white;
    memo[idx][1] = black;

    return 0;
}

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

    for(int i = 0;i < n-1;i++){
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }

    make_tree(0);

    memset(memo, -1, sizeof(memo));

    dp(0);

    cout << (memo[0][0] + memo[0][1]) % MOD << endl;

    return 0;
}



Measured memory_bytes: 17664
#include<iostream>
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 cout << "Christmas Eve Eve Eve" << endl;

  return 0;
}

Measured memory_bytes: 256
const main = async () => {
  'use strict'
  const input = require('fs').readFileSync('/dev/stdin', 'UTF-8').trim()
  
  let setting = input.split('\n')
  
  const str = setting[0].split('')
  const sample = setting[1].split('')

  let count = 0

  for (let i = 0; i < str.length; i++) {
    if (str[i] !== sample[i]) {
      count++
    }
  }

  console.log(count)
}

main()

Measured memory_bytes: 38988
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define NIN -100000000
#define EPS 0.0000000001
int main()
{
    long long a,b,c;
    scanf("%lld %lld.%lld",&a,&b,&c);
    b=b*100+c;
    long long ans=a*b;
    ans=ans/100;
    printf("%lld",ans);
    return 0;
}


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

void prime_div(int num);

int N;
vector<int> used(250);

int main(){

    cin >> N;

    int i, j, sum, cnt = 0;
    for (i=1; i<=N; i += 2){
        sum = 1;
        for (int &x: used){
            x = 0;
        }

        prime_div(i);
//        cout << "i = " << i << endl;
/*
        for (int x: used){
            cout << x << " ";
        }
        cout << endl;
*/
        for (j=0; j<201; j++){
            if (used.at(j) != 0){
//                cout << "used.at(" << j << ") = " << used.at(j) << endl;
                sum *= (used.at(j) + 1);
            }
        }
//        cout << "sum = " << sum << endl; 
        if (sum == 8){
            cnt++;
        }
    }

    cout << cnt << endl;
    return 0;
}

void prime_div(int num){

    int div;
    for (div=2; div<=num; div++){
        while ((num%div==0) && (num != 0)){
            num /= div;
            used.at(div)++;
//            cout << "num = " << num << " div = " << div << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n,a[200005];
    cin >> n;
    for(int i=1;i<=n;i++) cin >> a[i];
    sort(a+1,a+n+1);
    for(int i=1;i<=n-1;i++) 
    {
    	if(a[i]==a[i+1])
    	{
    		cout << "NO";
    		return 0;
		}
	}
	cout << "YES";
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>

typedef long long LL;

const int N=200005;

int n,a[N],b[N],pts[N],ls[N],nx[N];
bool vis[N];
LL m;

int main()
{
	scanf("%d%lld",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	for (int i=n;i>=1;i--)
	{
		nx[i]=ls[a[i]];ls[a[i]]=i;
		if (!nx[i]) pts[i]=i;
		else pts[i]=pts[nx[i]+1];
	}
	if (pts[1]==0) return 0;
	int x=1,tot=0;
	while (1)
	{
		if (vis[x]) break;
		b[++tot]=x;
		vis[x]=1;
		if (x) x=ls[a[pts[x]]]+1;
		else x=1;
		if (x>n) x=0;
	}
	if (m>tot)
	{
		int l=1;
		while (b[l]!=x) l++,m--;
		m=(m-1)%(tot-l+1)+1;
		m+=l-1;
	}
	for (int i=pts[b[m]];i;i=pts[i+1]) printf("%d ",a[i]);
	return 0;
}

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

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define ms(arr, val) memset(arr, val, sizeof(arr))
#define incl(i, a, b) for(int i = a; i <= b; i++)
#define decl(i, a, b) for(int i = a; i >= b; i--)

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

    int r; cin >> r;
    cout << 3 * r * r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vec = vector<ll>;
using vecp = vector<P>;
using mat = vector<vec>;
using matp = vector<vecp>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define all(v) v.begin(), v.end()

ll modPow(ll a, ll n) {
  if (n == 0) return 1; // 0乗にも対応する場合
  if (n == 1) return a % MOD;
  if (n % 2 == 1) return (a * modPow(a, n - 1)) % MOD;
  ll t = modPow(a, n / 2);
  return (t * t) % MOD;
}

int main(){
  ll N,x;
  cin >> N;
  vec A(N+1),U(N+1,-1);
  rep(i,N+1){
    cin >> A.at(i);
    if(U.at(A.at(i))==-1){
      U.at(A.at(i))=i;
    }else{
      x=i-U.at(A.at(i))+1;
    }
  }
  vec C(N+2),c(N+2-x);
  rep(i,N+2){
    if(i==0){
      C.at(i)=1;
    }else{
      C.at(i)=C.at(i-1)*(N+2-i);
      C.at(i)%=MOD;
      C.at(i)*=modPow(i,MOD-2);
      C.at(i)%=MOD;
    }
  }
  rep(i,N+2-x){
    if(i==0){
      c.at(i)=1;
    }else{
      c.at(i)=c.at(i-1)*(N+2-i-x);
      c.at(i)%=MOD;
      c.at(i)*=modPow(i,MOD-2);
      c.at(i)%=MOD;
    }
  }
  
  rep(i,N+1){
    if(N+1-x>=i){
      cout << (MOD+C.at(i+1)-c.at(i))%MOD << endl;
    }else{
      cout << C.at(i+1) << endl;
    }
  }
  
}

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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;

inline bool LT(double a,double b) { return !equals(a,b) && a < b; }
inline bool LTE(double a,double b) { return equals(a,b) || a < b; }

int N,M,Q;
struct Data {
  int l,r,idx;
};

vector<Data> es, qs;

bool cmp(Data a,Data b) {
  if( a.r != b.r ) return a.r < b.r;
  return a.r < b.r;
}

int cnt[510],ans[200100];

void compute() {
  sort(ALL(es),cmp);
  sort(ALL(qs),cmp);
  int cur = 0;
  rep(i,Q) {
    int l = qs[i].l, r = qs[i].r;
    while( cur < M && es[cur].r <= qs[i].r ) {
      ++cnt[es[cur].l];
      ++cur;
    }
    int tmp = 0;
    REP(j,l,r+1) {
      tmp += cnt[j];
    }
    ans[qs[i].idx] = tmp;
  }
  rep(i,Q) {
    cout << ans[i] << endl;
  }
}

int main() {
  cin >> N >> M >> Q;
  es.resize(M);
  qs.resize(Q);
  rep(i,M) cin >> es[i].l >> es[i].r;
  rep(i,Q) {
    cin >> qs[i].l >> qs[i].r;
    qs[i].idx = i;
  }
  compute();
  return 0;
}


Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define vll vector<ll>
#define vi vector<int>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n;
  cin >> n;
  vi x(n);
  rep(i,n) cin >> x[i];
  int ans = 100000000;
  rep(p,101){
    int tmp = 0;
    rep(i,n) tmp += (x[i]-p)*(x[i]-p);
    ans = min(ans,tmp);
  }
  cout << ans << endl;

  return 0;
}


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

int main() {
  int A, B, C ,D;
  cin >> A >> B >> C >> D;

  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
#define mod 1000000007
typedef long long ll;
int main(void)
{
	string S, T;
	cin >> S >> T;
	bool judge = true;
	rep(i,S.size()) if(S[i]!=T[i]) judge = false;
	if(judge) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

typedef pair<int, int> p;

int main(){
  int n;
  vector<int> x, y;
  cin >> n;
  for(int i = 0 ; i < n ; i++){
    int a;
    cin >> a;
    x.push_back(a);
    y.push_back(a);
  }
  sort(x.begin(), x.end());
  int m = n/2-1;
  for(int i = 0; i < n; i++){
    if(y[i] < x[n/2]) cout << x[m+1] << endl;
    else cout << x[m] << endl;
  }
}


Measured memory_bytes: 3948
using System;
using System.Text;

public class A
{
	public static void Main()
	{
		string s = Console.ReadLine();
		s = s.Replace("eraser", "");
		s = s.Replace("erase", "");
		s = s.Replace("dreamer", "");
		s = s.Replace("dream", "");
		if(s != "")
		{
			Console.WriteLine("NO");
		}
		else
		{
			Console.WriteLine("YES");
		}
	}
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
     
#define ll long long
#define loop(i,a,n) for(ll i=a;i<n;++i)
#define revloop(i,a,b) for(ll i=a;i>=b;--i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define INF 99999999999999999
#define MOD 1000000007

void func()
{
    string s,t;
    cin>>s>>t;
    ll n=s.length(),ans=0;
    loop(i,0,n){
        if(s[i]!=t[i]){
            ++ans;
        }
    }
    cout<<ans<<"\n";
}
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w" , stdout);
    #endif
 
    ll t=1;
    //cin>>t;
    while(t--)
    {
        func();
    }
}

Measured memory_bytes: 3796
import math
import sys
# input = sys.stdin.readline

N=int(input())
s=list(input())

d=1
p1=0
p2=1
p3=2

cR=s.count("R")
cG=s.count("G")
cB=s.count("B")
# print(cR,cG,cB)
count=0
while d<N:
	# print(p1,p2,p3,count)
	if p1<N and p2<N and p3<N:
		if s[p1]!=s[p2] and s[p2]!=s[p3] and s[p3]!=s[p1]:
			count+=1
		p1+=1
		p2+=1
		p3+=1
	else:
		d+=1
		p1=0
		p2=p1+d
		p3=p2+d

ans=cR*cG*cB-count
print(ans)


Measured memory_bytes: 68052
import java.io.*;
import java.util.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line1 = br.readLine().split(" ");
    int n = Integer.parseInt(line1[0]);
    int m = Integer.parseInt(line1[1]);
    int k = Integer.parseInt(line1[2]);
  
    int[] numFriends = new int[n];
    int[] numBlock = new int[n];
    UnionFind unionFind = new UnionFind(n);
    String[] data;
    int a;
    int b;
    
    for (int i=0; i<m; i++){
      data = br.readLine().split(" ");
      a = Integer.parseInt(data[0]) -1;
      b = Integer.parseInt(data[1]) -1;
      
      unionFind.union(a, b);
      numFriends[a]++;
      numFriends[b]++;
    }
    for (int i=0; i<k; i++){
      data = br.readLine().split(" ");
      a = Integer.parseInt(data[0]) -1;
      b = Integer.parseInt(data[1]) -1;
      
      if (unionFind.isSameRoot(a, b)){
        numBlock[a]++;
        numBlock[b]++;
      }
    }
    StringJoiner stringJoiner = new StringJoiner(" ");
    for (int i=0; i<n; i++){
      stringJoiner.add(String.valueOf(unionFind.getSize(i) - numFriends[i] - numBlock[i] - 1));
    }
    
    System.out.println(stringJoiner);
  }
  
}
class UnionFind {
  private int[] tree;
  private int[] size;
  
  UnionFind(int size){
    this.tree = new int[size];
    this.size = new int[size];
    for (int i=0; i<size; i++){
      this.tree[i] = i;
      this.size[i] = 1;
    }
  }
  
  int find(int idx) {
    if(tree[idx]==idx) return idx;
    else return tree[idx] = find(tree[idx]);
  }
  
  void union(int idx1,int idx2) {
    int root1 = find(idx1);
    int root2 = find(idx2);
    
    if (root1 == root2){
      return;
    }
    tree[root2] = root1;
    size[root1] += size[root2];
  }
  
  public boolean isSameRoot(int idx1, int idx2){
    return find(idx1) == find(idx2);
  }
  
  public int getSize(int idx){
    return size[find(idx)];
  }
}


Measured memory_bytes: 61412
n = int(input())
p = []
q = []
r = []
for i in range(2,(int(n**0.5)+1)):
    N = n
    if N%i == 0:
        p.append(i)
for i in range(2,(int(n**0.5)+1)):
    N = n - 1
    if N%i == 0:
        r.append(i)
        if i != N//i:
            r.append(N//i)
for i in range(len(p)):
    N = n
    while N % p[i] == 0:
        N = N / p[i]
    if N % p[i] == 1:
        q.append(p[i])
for i in range(len(r)):
    if n % r[i] == 1:
        q.append(r[i])
if n == 2:
    print(1)
else:
    print(len(q)+2)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n * 2);
  for (int i = 0; i < n * 2; i++) {
    scanf("%d", &a[i]);
  }
  sort(a.begin(), a.end());
  int l = 0, r = n;
  while (l < r) {
    int mid = (l + r) >> 1;
    bool ok = true;
    for (int i = 0; i < n * 2 - mid * 2; i++) {
      if (a[mid * 2 + i] + a[n * 2 - 1 - i] < m) {
        ok = false;
        break;
      }
    }
    if (ok) {
      r = mid;
    } else {
      l = mid + 1;
    }
  }
  int ans = 0;
  for (int i = 0; i < l * 2; i++) {
    ans = max(ans, (a[i] + a[l * 2 - 1 - i]) % m);
  }
  for (int i = 0; i < n * 2 - l * 2; i++) {
    ans = max(ans, (a[l * 2 + i] + a[n * 2 - 1 - i]) % m);
  }
  printf("%d\n", ans);
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> Pii;
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1000000000
#define rep(i,a,b) for(int i =(a);i<(b);i++)
#define fs first
#define ss second
inline int Scan() {
    int x=0;int f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}

template<typename T, typename U>
static inline void amin(T &x, U y)
{
    if (y < x)
        x = y;
}

// call by reference is used in x
template<typename T, typename U>
static inline void amax(T &x, U y)
{
    if (x < y)
        x = y;
}
//////////////////////////////////////end of template//////////////////////////////////////

int main(){

   int n;
   cin >> n;
   string s;
   cin >> s;
   
   int ans = 0;
   
   for(int i=0;i<n-1;i++){
	   if(s[i] !=s[i+1]) ans++;
   }
   
   cout << ans+1 <<endl;

}




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

int main() {
  uint32_t N = 0, S = 0;
  std::cin >> N >> S;
  std::vector<uint32_t> A(N);
  for (auto &&a : A) std::cin >> a;

  size_t min_len = -1;
  for (size_t start = 0, end = 0, sum = 0; start < N; sum -= A[start++]) {
    while (end < N && sum < S) sum += A[end++];
    if (sum < S) break;
    min_len = std::min(end - start, min_len);
  }

  std::cout << (min_len > N ? 0 : min_len) << std::endl;

  return 0;
}


Measured memory_bytes: 3124
N = int(input())
p = map(int, input().split())

a = [0] * (10 ** 5 + 1)
for i, p_i in enumerate(p, 1):
    if i == p_i:
        a[i - 1] = 1

count = 0
for i in range(10 ** 5):
    if a[i] == 1:
        a[i] = 0
        a[i + 1] = 0
        count += 1

print(count)

Measured memory_bytes: 10612
from collections import Counter
import sys
n = int(sys.stdin.readline())
sn = sys.stdin.read().split()
c = Counter(sn)
c = sorted(c.items(), key=lambda x: (-x[1], x[0]))
num = c[0][1]
for i, j in c:
  if j == num:
    print(i)
  else:
    quit()

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

int main(){
    long long a, b, n;
    cin >> a >> b >> n;
    if (a % n == 0){
        cout << (b/n) - (a/n) + 1 <<endl;
    } else {
        cout << (b/n) - (a/n) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M,Q = list(map(int,input().split()))
ABCD = []
for i in range(Q):
    ABCD.append(list(map(int,input().split())))

ABCD.sort(key=lambda x:x[3],reverse=True)

from itertools import combinations_with_replacement,product
a = []
for i in range(M):
    a.append(i+1)
L = list(combinations_with_replacement(a,N))

out = 0
for X in L:
    cand = 0
    for i in range(Q):
        A = ABCD[i][0]
        B = ABCD[i][1]
        C = ABCD[i][2]
        D = ABCD[i][3]
        if X[B-1]-X[A-1]==C:
            cand += D
    if cand>out:
        out = cand
print(out)

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

int main() {
    int n;
    cin >> n;
    bitset<10> f[n];
    int p[n][10];

    rep(i, n) {
        string s;
        char c;
        rep(j, 10) cin >> c, s += c;
        f[i] = bitset<10>(s);
    }
    rep(i, n) rep(j, 11) cin >> p[i][j];

    ll ans = -1e9;
    for (int bit = 1; bit < (1 << 10); bit++) {
        bitset<10> b(bit);
        ll now = 0;
        rep(i, n) {
            now += p[i][(b & f[i]).count()];
        }
        ans = max(ans, now);
    }

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


Measured memory_bytes: 256
#include<stdio.h>
/* 素数判定 */
int isPrime(int x) {
  int i;
  if ( x < 2 ) return 0;
  else if ( x == 2 ) return 1;   // 2 は素数
  if ( x % 2 == 0 ) return 0;    // 2以外の偶数は素数ではない
  for ( i = 3; i*i <= x; i+=2 )  // i が x の平方根以下の間
    if ( x % i == 0) return 0;
  return 1;
}

int main() {
  int n, x, i;
  int cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++ ) {
    scanf("%d", &x);
    if ( isPrime(x) ) cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 2704
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <bitset>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
const double PI=3.141592653589793238462643383279;
//
int main(){
  int A,B;
  cin>>A>>B;
  int N;
  if(B==100){
    N=A*1000+B;
  }else if(B>=10){
    N=A*100+B;
  }else{
    N=A*10+B;
  }
  int i=1;
  while(i*i<N){
    i++;
  }
  if(i*i==N){
    Yes(1);
  }else{
    Yes(0);
  }
  return 0;
}


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

char T[550005];
int salsa2[550005];
int salsaNext[550005];
int p[550005];

// Based on editorial solution
int D[13][550005]; // one digit at a time, with digit 0 representing the ones place
int W[13][550005];
int lastUpdated[13][550005];

int N;

void update(int n, int indx, int cntS){
    if((cntS&1) != (lastUpdated[n][indx]&1)){
        // conduct salsa
        if(D[n][indx] == 1){
            D[n][indx] = 2;
        }else if(D[n][indx] == 2){
            D[n][indx] = 1;
        }
    }
    // updated the lastUpdated index
    lastUpdated[n][indx] = cntS;
}

int pow3[16];

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

    scanf(" %s", T);

    int M = strlen(T);

    pow3[0] = 1;
    for(int i = 1; i <= N; i ++){
        pow3[i] = pow3[i-1]*3;
    }

    int pow3N = pow3[N];

    //printf("ok");
    memset(W, 0, sizeof(W));
    for(int n = 1; n <= N; n ++){
        //printf("ok");
        for(int j = 0; j < pow3[N]; j ++){
            D[n][j] = (j%pow3[n])/pow3[n-1];
            //printf("D[%d][%d]=%d\n", n, j, D[n][j]);
        }
        W[n][0] = pow3[n]-1;
    }


    memset(lastUpdated, 0, sizeof(lastUpdated));
    int cntS2 = 0;
    for(int n = 1; n <= N; n ++){
        int cntS = 0;
        for(int i = 0; i < M; i ++){
            int indx0 = W[n-1][i];
            int indx1 = W[n-1][i]+pow3[n-1];
            if(indx1 >= pow3[n]){
                indx1 -= pow3[n];
            }
            int indx2 = W[n-1][i]+(pow3[n-1]<<1);
            if(indx2 >= pow3[n]){
                indx2 -= pow3[n];
            }

            update(n, indx0, cntS+(T[i]=='S'));
            update(n, indx1, cntS+(T[i]=='S'));
            update(n, indx2, cntS+(T[i]=='S'));
            if(D[n][indx0] == 2){
                W[n][i] = indx0;
            }else if(D[n][indx1] == 2){
                W[n][i] = indx1;
            }else{
                W[n][i] = indx2;
            }

            if(T[i] == 'R'){
                D[n][indx0] = (D[n][indx0]+1);
                D[n][indx1] = (D[n][indx1]+1);
                D[n][indx2] = (D[n][indx2]+1);
                if(D[n][indx0] == 3){D[n][indx0] = 0;}
                if(D[n][indx1] == 3){D[n][indx1] = 0;}
                if(D[n][indx2] == 3){D[n][indx2] = 0;}
                lastUpdated[n][indx0] = cntS;
                lastUpdated[n][indx1] = cntS;
                lastUpdated[n][indx2] = cntS;
            }else if(T[i] == 'S'){
                cntS ++;
            }

            //printf("W[%d][%d]=%d\n", n, i+1, W[n][i+1]);
        }

        cntS2 = cntS;
    }

    for(int n = 1; n <= N; n ++){
        for(int i = 0; i < pow3[n]; i ++){
            update(n, i, cntS2);
        }
    }

    for(int i = 0; i < pow3[N]; i ++){
        int temp = 0;
        for(int n = 1; n <= N; n ++){
            temp += D[n][i%pow3[n]]*pow3[n-1];
        }
        printf("%d ", temp);
    }

    /*printf("\n");
    for(int i = 0; i < pow3[N]; i ++){
        int temp = 0;
        for(int n = 0; n < N; n ++){
            temp += D[n][i%pow3[n+1]]*pow3[n];
        }
        printBase3(temp, N);
        printf("\n");
    }*/

    return 0;
}


Measured memory_bytes: 85168
#![allow(non_snake_case, unused)]
use std::collections::*;

////////// missing functions in 1.15.1 //////////
macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}
/////////////////////////////////////////////////
pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

fn run() {
	let s = read!([u8]);
	let t = read!([u8]);
	let mut dp = mat![0; s.len() + 1; t.len() + 1];
	for i in 0..s.len() {
		for j in 0..t.len() {
			if s[i] == t[j] {
				dp[i + 1][j + 1] = dp[i][j] + 1;
			} else {
				dp[i + 1][j + 1] = std::cmp::max(dp[i + 1][j], dp[i][j + 1]);
			}
		}
	}
	let mut ans = vec![];
	let mut i = s.len();
	let mut j = t.len();
	while i > 0 && j > 0 {
		if s[i - 1] == t[j - 1] {
			ans.push(s[i - 1]);
			i -= 1;
			j -= 1;
		} else if dp[i][j] == dp[i - 1][j] {
			i -= 1;
		} else {
			j -= 1;
		}
	}
	println!("{}", String::from_utf8(ans.into_iter().rev().collect::<Vec<u8>>()).unwrap());
}


Measured memory_bytes: 45436
# coding: utf-8

n = int(input().rstrip())

scorelist = list(map(int, input().rstrip().split(" ")))

color1 = len(set([int(i/400) for i in scorelist if i < 3200]))

color2 = len([i for i in scorelist if i >= 3200])

ans_min = max(1, color1)
ans_max = color1 + color2

print("{} {}".format(ans_min, ans_max))


Measured memory_bytes: 3060
n = int(input())
#j = L0
j = 2
#k = L1
k = 1

if n == 0:
    print(2)
    exit(0)
if n == 1:
    print(1)
    exit(0)

for i in range(1,n):
    l = j + k
    j = k
    k = l

print(l)

Measured memory_bytes: 9140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
constexpr int di[] = { 0, 1, 0, -1 }, dj[] = { 1, 0, -1, 0 };
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(), (v).end()
#define MAX 100
#define vmax 10000
#define sentinel 2000000000
#define INF (1<<30)
constexpr long long int inf = 100000000000000000;
constexpr long long int rinf = -(INT64_MAX);
static const int NIL=-1;

//cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);

struct edge{
    int f,t,c;
};

int d[MAX];
vector<edge> g;

int main(){
    int v,e,s,t;
    cin>>v>>e;
    for(int i=0;i<e;i++){
        cin>>s>>t;
        g.push_back({s,t,-1});
    }
    for(int i=0;i<v;i++){
        d[i]=0;
    }
    for(int i=0;i<v;i++){
        for(auto e:g){
            if(d[e.t]>d[e.f]+e.c){
                if(i==v-1){
                    cout<<1<<endl;
                    return 0;
                }
                d[e.t]=d[e.f]+e.c;
            }
        }
    }
    cout<<0<<endl;
    return 0;
}






Measured memory_bytes: 3160
#include <cmath>
#include<iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
using namespace std;
 
int main(){    
  long long N;
  cin >> N;
  int A[N],j=1;
  
  for(int i=0;i<N;i++){
    cin >> A[i];
    if(A[i] == j){
      j++;
    }
  }
  j=j-1;
  if(j == 0){
    cout << "-1"<< endl;
  }
  else{
   cout << N-j << endl;
  }
}

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

int main(){
  long long int r,g,b,n,count=0;
cin >>r >>g>>b>>n;
for(long long int i=0;i<=n/r;i++){
for(long long int j=0;j<=(n-i*r)/g;j++){
if((n-r*i-g*j)%b==0 && (n-r*i-g*j)>=0){
count++;
}
}
}
cout <<count<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
const int maxn=1e5;
int n,t,m,ans,sum,a,b,c;
int main(){
	cin>>a>>b>>c;
	cin>>t;
	ans=a+b+c;
	m=max(a,b);
	m=max(m,c);
	ans-=m;
	while(t--){
		m*=2;
		}
	ans+=m;
	printf("%d\n",ans);
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

 int q[3000][3000][4];
     signed main(){
       int r,c,k;
       cin>>r>>c>>k;
       int p[r][c];
       for(int i=0;i<r;i++)fill(p[i],p[i]+c,0ll);
       int x,y,v;
       for(int i=0;i<k;i++){
           cin>>x>>y>>v;x--;y--;
           p[x][y]=v;
       }
      
       

       for(int i=0;i<r;i++)for(int j=0;j<c;j++){
           q[i][j][0]=0;
       q[i][j][1]=0;
       q[i][j][2]=0;
         q[i][j][3]=0;
            if(j!=0){
                q[i][j][0]=max(q[i][j][0],q[i][j-1][0]);
                for(int ii=1;ii<4;ii++){
                    q[i][j][ii]=max(q[i][j][ii],max(q[i][j-1][ii],q[i][j-1][ii-1]+p[i][j-1]));
                }
            }
             if(i!=0){
                q[i][j][0]=max(q[i][j][0],q[i-1][j][3]);
                for(int ii=0;ii<3;ii++){
                    q[i][j][0]=max(q[i][j][0],q[i-1][j][ii]+p[i-1][j]);
                }
            }
       }
       int ans=0;
       for(int ii=0;ii<3;ii++)ans=max(ans,q[r-1][c-1][ii]+p[r-1][c-1]);
       ans=max(ans,q[r-1][c-1][3]);
       cout<<ans<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 354792
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var k = int.Parse(input.ReadLine());
        var s = "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";

        var ss = s.Split(',');

        return ss[k-1].Trim();
    }
}

Measured memory_bytes: 11092
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>

using namespace std;

typedef long long int lli;

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

int lcm(int a, int b) {
	return a * b / gcd(a, b);
}

#define N_MAX 8
#define MOD 1000000007

bool comp(int N, int *src, int *dst)
{
	for (int i = 0; i < N; i++) {
		if (src[i] != dst[i]) {
			return false;
		}
	}
	return true;
}

void solv()
{
	int N; scanf("%d", &N);
	int P[N_MAX], Q[N_MAX];
	for (int i = 0; i < N; i++) {
		scanf("%d", P + i);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", Q + i);
	}

	int perm[N_MAX];
	for (int i = 0; i < N; i++) {
		perm[i] = i + 1;
	}

	int p, q;
	for (int i = 0;; i++) {
		if (comp(N, P, perm)) {
			p = i;
		}
		if (comp(N, Q, perm)) {
			q = i;
		}
		if (!next_permutation(perm, perm + N)) {
			break;
		}
	}

	printf("%d", abs(p - q));

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define MOD 1000000007
ll fact[200005];
#define eps 1e-9
#define INF 1e17
#define N 200005
inline ll mul(ll a,ll b){
  a=(a+MOD)%MOD;
  b=(b+MOD)%MOD;
  ll c=a*b;
  c=(c+MOD)%MOD;
  return c;
}
ll power(ll a,ll b,ll c){
  ll ans=1;
  while(b){
    if(b&1){
      ans=mul(ans,a);
    }
    a=mul(a,a);
    b=b/2;
  }
  return ans;
 }
ll min(ll a,ll b){return a<b?a:b;}
ll max(ll a,ll b){return a>b?a:b;}
int main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        int n,m; cin>>n>>m;
        int h[n+1];
        for(int i=1;i<=n;++i)cin>>h[i];
        vector<int> v[n+1];
        for(int i=0;i<m;++i){
            int x,y; cin>>x>>y;
            v[x].push_back(y);
            v[y].push_back(x);
        }
        int cnt=0;
        for(int i=1;i<=n;++i){
            int flag=1;
            for(auto x: v[i]){
                if(h[x]>=h[i])flag=0;
            }
            cnt+=flag;
        }
        cout<<cnt;
        return 0;
}


Measured memory_bytes: 9176
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
//typedef tree<int,null_type,less<int >,rb_tree_tag,tree_order_statistics_node_update>indexed_set;
template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p);
template <class T>
ostream &operator <<(ostream &os, vector<T>&v);
template <class T>
ostream &operator <<(ostream &os, set<T>&v);
#define debug(a) cout<<#a<<" --> "<<(a)<<endl;
#define fastInput ios_base::sync_with_stdio(false);cin.tie(0)
#define INPUT freopen("input.txt","r",stdin)
#define OUTPUT freopen("output.txt","w",stdout)
#define Error  1e-9
#define pi (2*acos(0))
const ll mod =1e9 +7;
const int N = 1e5 +5;

void Solve(int cas)
{
    int n,r;
    scanf("%d %d",&n,&r);
    if(n>=10)
    {
        printf("%d\n",r);
    }
    else{
        printf("%d\n",r+100*(10-n));
    }



}



int main()
{
    //fastInput;
    //cout.tie(0);
    //INPUT;
    //OUTPUT;
    int t=1,cas=0;
    //scanf("%d",&t);
    while(t--)
    {
        Solve(++cas);
    }
    return 0;
}
/*

*/


//os.order_of_key(v): returns how many elements strictly less than v
//os.find_by_order()

template<class T1, class T2>
ostream &operator <<(ostream &os, pair<T1,T2>&p)
{
    os<<"{"<<p.first<<", "<<p.second<<"} ";
    return os;
}
template <class T>
ostream &operator <<(ostream &os, vector<T>&v)
{
    os<<"[ ";
    for(int i=0; i<v.size(); i++)
    {
        os<<v[i]<<" " ;
    }
    os<<" ]";
    return os;
}

template <class T>
ostream &operator <<(ostream &os, set<T>&v)
{
    os<<"[ ";
    for(T i:v)
    {
        os<<i<<" ";
    }
    os<<" ]";
    return os;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
 
 
int pow1(int n, int p)
{
	if(p==0)	return 1;
	int x=pow1(n, p/2);
	x=(x*x)%mod;
	if(p%2==0)
		return x;
	else
		return (x*n)%mod;
}
 
int32_t main()
{
	fast;

	char c;
	cin>>c;
	c++;
	cout<<c<<endl;

	return 0;
}

Measured memory_bytes: 256
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$st = strpos($key->A[0],"A");
$ed = strrpos($key->A[0],"Z");
printf("%d\n",$ed-$st+1);


Measured memory_bytes: 4088
def main():
    n = int(input())
    a = list(map(int, input().split()))
    
    money = 1000
    have = 0
    for i in range(len(a)-1):
        if a[i] < a[i+1]:
            have += money // a[i]
            money -= a[i] * (money // a[i])
        elif a[i] > a[i+1]:
            money += a[i] * have
            have = 0
    money += have * a[-1]
    print(money)
   
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9072
#include <iostream>
#include <algorithm>
#include <utility>
using namespace std;
int a[200010],b[200010];
pair<int,int> p[200010];
int main(){
    int i,n; cin >> n;
    for(i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    sort(a,a + n); sort(b,b + n);
    if(n&1){
        int l = a[(n - 1)/2],r = b[(n - 1)/2];
        cout << r - l + 1 << endl;
    }else{
        int l1 = a[n/2 - 1],l2 = a[n/2],r1 = b[n/2 - 1],r2 = b[n/2];
        cout << r2 + r1 - l1 - l2 + 1 << endl;
    }
}

Measured memory_bytes: 5196
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <deque>
#include <string.h>
using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

const int MAX_N = 100000;
int n;
ll a[MAX_N];


int main(){
  cin >> n;
  REP(i, n) cin >> a[i];
  REP(i, n) {
    if(a[i] % 2 == 1) {
      cout << "first" << endl;
      return 0;
    }
  }

  cout << "second" << endl;
  return 0;
}


Measured memory_bytes: 1024