akhauriyash/Code-Regression huggingface dataset:
from collections import deque

class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time

n, q = map(int, input().split())
processes = deque()

for _ in range(n):
    name, time = input().split()
    processes.append(Process(name, int(time)))

completion_time = 0
while len(processes) != 0:
    process = processes.popleft()
    tmp_time = process.time - q
    if tmp_time <= 0:
        completion_time += tmp_time + q
        print(process.name, completion_time)
    else:
        completion_time += q
        process.time = tmp_time
        processes.append(process)



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

int main() {
  int N;
  cin >> N;
  
  vector<int> vec(N);
  for(int i = 0; i < N; i++){
    cin >> vec.at(i);
  }
  
  int count = 1;
  int num = 0;
  
  while(vec.at(num) != 2){
    count++;
    num = vec.at(num) - 1;
    if(count >= N){
      count = -1;
      break;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 640
import copy as cp
#INPUT
D = int(input())
c = [int(i) for i in input().split()]
s = []
for i in range(D):
    new = [int(i) for i in input().split()]
    s.append(new)

#Utilitiy
def score(ans):
    if len(ans) != D:
        print("wrong length")
        return 0
    else:
        p = 0
        last = [-1]*26
        for i in range(D):
            contest = ans[i]-1
            p += s[i][contest]
            last[contest] = i
            for j in range(26):
                p -= c[j]*(i-last[j])
        return p

def greedy(ahead=0):
    ans = []
    p = 0
    last = [-1]*26
    for i in range(D):
        decay = 0
        for j in range(26):
            decay -= c[j]*(i-last[j])
            
        max_j = -1
        max_plus = decay
        for j in range(26):
            plus = s[i][j] + c[j]*(i-last[j]) + c[j]*(ahead*(i-last[j])+ahead*(ahead+1)//2)
            if plus > max_plus:
                max_plus = plus
                max_j = j
        ans.append(max_j+1)
        last[max_j]=i
        p += max_plus + decay - c[max_j]*ahead
    return ans, p
        
#MAIN
max_points = -10000000
for k in range(20):
    ans_temp, points = greedy(ahead = k)
    if points > max_points:
        max_points = points
        ans = cp.copy(ans_temp)

for i in range(D):
    print(ans[i])

Measured memory_bytes: 9652
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,b;
   cin>>a>>b;
   string name;
   name+=to_string(a);
   name+=to_string(b);
   int number =stoi(name);
   int n=sqrt(number);
   if(n*n==number)cout<<"Yes"<<endl;
   else
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<string>
#define N 102
#define int long long
using namespace std;
int f[N][N][N * 3],n,w[N],v[N],ans,W;
main()
{
	memset(f,0,sizeof(f));
	scanf("%lld %lld",&n,&W);
	for (int i = 1;i <= n; ++i)
		scanf("%lld %lld",&w[i],&v[i]);
	for (int i = 1;i <= n; ++i)
		for (int k = 0;k <= i; ++k)
			for (int o = 0;o <= i * 3; ++o)
				{
					f[i][k][o] = f[i - 1][k][o];
					if (k > 0&&o >= w[i] - w[1])
						f[i][k][o] = max(f[i][k][o],f[i - 1][k - 1][o - (w[i] - w[1])] + v[i]);
				}
	ans = 0;
	for (int i = 0;i <= n; ++i)
		for (int j = 0;j <= 3 * n; ++j)
			if (i * w[1] + j <= W) 
			ans = max(ans,f[n][i][j]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 25216
/*
 * Created by Dipta Das on 08-05-2019
 * Title: 
 * Problem Link: 
 * Editorial: 
 * Source Code: 
 * Comments: 
*/

#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

const int INF = 1e9 + 5;
struct task {
    ll a,b, c;
};

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

    ll n;
    cin >> n;
    vector<vector<ll>> ar(n, vector<ll>(3));

    for (auto &i : ar) {
        cin >> i[0] >> i[1] >> i[2];
    }

    vector<vector<ll>> dp(n, vector<ll> (3, 0));
    for (int i = 0; i < 3; ++i) dp[0][i] = ar[0][i];

    for (int i = 1; i < n; ++i) {
        dp[i][0] = ar[i][0] + max (dp[i-1][1], dp[i-1][2]);
        dp[i][1] = ar[i][1] + max (dp[i-1][0], dp[i-1][2]);
        dp[i][2] = ar[i][2] + max (dp[i-1][1], dp[i-1][0]);
    }

    /* for (auto i : dp) { */
    /*     for (auto j : i) { */
    /*         cout << j << "\t"; */
    /*     } */
    /*     cout << endl; */
    /* } */

    cout << max ({dp[n-1][0], dp[n-1][1], dp[n-1][2]}) << endl;
    




    return 0;
}



Measured memory_bytes: 11264
S = input()
min_x = abs(int(S[0] + S[1] + S[2]) - 753)
for i in range(len(S)-2):
    x = abs(int(S[i] + S[i+1] + S[i+2]) - 753)
    if x < min_x:
        min_x = x
print(min_x)

Measured memory_bytes: 3060
s1 = list(map(int, input().split()))

n = s1[0]
m = s1[1]

a = list(map(int, input().split()))

lt = 0

for i in range(m):
    lt = lt +a[i] 

ld = n - lt

if ld < 0:
    print("-1")
else:
    print(ld)


Measured memory_bytes: 10016
n, k = (int(i) for i in input().split())
a = [int(i) for i in input().split()]
count = 0
mod = 10 ** 9 + 7

back = 0
forward = 0
for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            back += 1
    for j in range(i):
        if a[i] > a[j]:
            forward += 1

count += back * (1+k) * k // 2 + forward * k * (k-1) // 2
ans = count % mod
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>	
#define pb push_back
typedef long long ll;
const int inf = 2e9;
using namespace std;


int main(){
	
	int n[4],ans=0;

	scanf("%d%d%d",&n[0],&n[1],&n[2]);

	sort(n,n+3);

	ans+=(n[1]-n[0])/2 + (n[1]-n[0])%2;
	if((n[1]-n[0])%2)n[2]++;
	ans+=n[2]-n[1];	

	cout<<ans<<endl;

	return 0;
}	

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

#define NMAX 30

int n;
int dp[NMAX+1];

int main()
{
  while(cin >> n && n > 0){
    for(int i = 1; i <= n; i++){
      dp[i] = 0;
    }
    dp[0] = 1;
    for(int i = 1; i <= n; i++){
      for(int j = 1; j <= 3 && j <= i; j++){
        dp[i] += dp[i - j];
      }
    }
    cout << dp[n] / 3650 + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	private static final Scanner S=new Scanner(System.in).useDelimiter("\\s*,\\s*|\\s+");
	private static final PrintStream O=System.out;
	
	private static class Seal {
		private final double x;
		private final double y;
		private final Ols ols[];
		private int nol=0;
		private int col=0;
		private int mol=0;
		
		private static class Ols {
			private final double arg[]=new double[2];
			private final Ols ols[];
			private int nol=0;
			private int mol=0;
			
			private Ols(final int mol) {
				ols=new Ols[mol];
			}
			
			private static double subArg(double a, final double b) {
				a-=b;
				a%=(2*Math.PI);
				if(a<0) a+=(2*Math.PI);
				return a;
			}
			
			private void jolol(final Ols a) {
				double rarg=subArg(arg[1],arg[0]);
				double d0=subArg(a.arg[0],arg[0]);
				double d1=subArg(a.arg[1],arg[0]);
				if(d0<=rarg) {
					ols[nol]=new Ols(nol);
					ols[nol].arg[0]=a.arg[0];
					if(d1<=rarg) ols[nol].arg[1]=a.arg[1];
					else ols[nol].arg[1]=arg[1];
					smol();
				} else if(d0>d1) {
					ols[nol]=new Ols(nol);
					ols[nol].arg[0]=arg[0];
					if(d1<=rarg) ols[nol].arg[1]=a.arg[1];
					else ols[nol].arg[1]=arg[1];
					smol();
				}
			}
			
			private void smol() {
				for(int i=0;i<nol;i++) ols[nol].jolol(ols[i]);
				int tol;
				if((tol=ols[nol].mol+1)>mol) mol=tol;
				nol++;
			}
		}
		
		private Seal(final double x, final double y, final int mol) {
			this.x=x;
			this.y=y;
			ols=new Ols[mol];
		}
		
		private void jol(final Seal a) {
			final double dx=a.x-x;
			final double dy=a.y-y;
			final double sqds=Math.pow(dx,2)+Math.pow(dy,2);
			if(sqds>4) return;
			if(sqds==0) {
				col++;
				return;
			}
			final double marg=Math.atan2(dy, dx);
			final double rarg=Math.acos(Math.sqrt(sqds/4));
			ols[nol]=new Ols(nol);
			ols[nol].arg[0]=marg-rarg;
			ols[nol].arg[1]=marg+rarg;
			for(int i=0;i<nol;i++) ols[nol].jolol(ols[i]);
			int tol;
			if((tol=ols[nol].mol+1)>mol) mol=tol;
			nol++;
		}
	}
	
	public static void main(String[] args) {
		final Seal seal[]=new Seal[100];
		int n,mol;
		
		while((n=S.nextInt())!=0) {
			mol=1;
			for(int i=0;i<n;i++) seal[i]=new Seal(S.nextDouble(), S.nextDouble(), n);
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) seal[i].jol(seal[j]);
				int tol;
				if((tol=seal[i].mol+seal[i].col)>mol) mol=tol;
			}
			O.println(mol);
		}
	}
}

Measured memory_bytes: 13000
#include <iostream>

using namespace std;

int main()
{
  int N;
  
  cin >> N;
  
  for(int i = 0;i < N; i++)
  {
	for(int j = 0;j < N;j++)
    {
		if(4 * i + 7 * j > N)
        {
			break;
        }
      
      	if(4 * i + 7 * j == N)
        {
			cout << "Yes" << endl;
          	return 0;
        }
    }
  }
  
  cout << "No" << endl;
  
  return 0;
}

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

using namespace std;

int main(void) {
  int e[4];
  for (int i = 0; i < 4; i++) {
    cin >> e[i];
  }
  sort(e, e + 4);

  cout << (e[0] == e[1] && e[2] == e[3] ? "yes" : "no") << endl;

  return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<set>
#include<numeric>

using namespace std;

int par[123456];

int find(int x){
  return (x==par[x])?x:find(par[x]);
}

void unite(int a,int b){
  par[find(a)]=find(b);
}

int main(){
  for(int N,M;cin>>N>>M,N|M;){
    iota(begin(par),end(par),0);
    for(int i=0;i<M;i++){
      int a,b;
      cin>>a>>b;
      a--;
      b--;
      unite(a,b);
    }
    set<int> s;
    for(int i=0;i<N;i++){
      s.insert(find(i));
    }
    int ans=1;
    for(int i=0;i<s.size();i++){
      ans=(ans*2)%1000000007;
    }
    cout<<(ans+!!M)%1000000007<<endl;
  }
}

    

Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, n) for (int i = (n); i >= 0; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1 << 25;
const int MOD = 1e9+7;
 
int main() {
 	string s, t;
	cin >> s >> t;
	map<char, char> d, dd;
	rep(i,26) {
		d['a'+i] = 'X';
		dd['a'+i] = 'X';
	}
	bool can = true;
	rep(i,s.size()) {
		if (d[s[i]] != 'X' && d[s[i]] != t[i]) can = false;
		d[s[i]] = t[i];  
		dd[t[i]] = s[i];
	}

	rep(i,s.size()) {
		if (d[s[i]] != t[i]) can = false;
		if (dd[t[i]] != s[i]) can = false;
	}
	if (can) cout << "Yes" << endl;
	else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3924
PROGRAM-ID.                      ABC_049_C.
ENVIRONMENT                      DIVISION.
INPUT-OUTPUT                     SECTION.
FILE-CONTROL.
    SELECT SYSIN ASSIGN TO KEYBOARD ORGANIZATION LINE SEQUENTIAL.

DATA                             DIVISION.
FILE                             SECTION.
    FD  SYSIN.
        01 INDATA PIC X(100000).

WORKING-STORAGE                  SECTION.
    01 S       PIC X(100000).
    01 dr      PIC X(7) VALUE "dreamer".
    01 er      PIC X(6) VALUE "eraser".
    01 d       PIC X(5) VALUE "dream".
    01 e       PIC X(5) VALUE "erase".

    01 word    PIC X(7).
    01 wordlen PIC 9(1).

    01 len     PIC 9(6).
    01 bklen   PIC 9(6).

    01 drlen   PIC 9(1).
    01 erlen   PIC 9(1).
    01 dlen    PIC 9(1).
    01 elen    PIC 9(1).

    01 flg     PIC 9(1) VALUE ZERO.

PROCEDURE                        DIVISION.
    OPEN INPUT SYSIN.

    READ SYSIN INTO S.

    CLOSE SYSIN.

    COMPUTE drlen = FUNCTION STORED-CHAR-LENGTH(dr).
    COMPUTE erlen = FUNCTION STORED-CHAR-LENGTH(er).
    COMPUTE dlen = FUNCTION STORED-CHAR-LENGTH(d).
    COMPUTE elen = FUNCTION STORED-CHAR-LENGTH(e).

    COMPUTE len = FUNCTION STORED-CHAR-LENGTH(S).
    MOVE ZERO TO bklen.
    PERFORM UNTIL flg NOT = ZERO

        IF len = ZERO THEN
            MOVE 1 TO flg
        END-IF

        IF len = bklen THEN
            EXIT PERFORM
        END-IF

        MOVE len TO bklen

        MOVE dr TO word
        MOVE drlen TO wordlen
        PERFORM ERASEWORD

        MOVE er TO word
        MOVE erlen TO wordlen
        PERFORM ERASEWORD

        MOVE d TO word
        MOVE dlen TO wordlen
        PERFORM ERASEWORD

        MOVE e TO word
        MOVE elen TO wordlen
        PERFORM ERASEWORD

    END-PERFORM.

    IF flg = 1 THEN
        DISPLAY "YES"
    ELSE
        DISPLAY "NO"
    END-IF.

    STOP RUN.

ERASEWORD                        SECTION.
    IF ZERO <= len - wordlen THEN
        IF S(len - wordlen + 1:wordlen) = word THEN
            MOVE ALL SPACE TO S(len - wordlen + 1:wordlen)
        END-IF
    END-IF.

    COMPUTE len = FUNCTION STORED-CHAR-LENGTH(S).


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))
#define miin(a, b, c) min((a), min((b), (c)))
#define maax(a, b, c) max((a), max((b), (c)))
#define mod 1000000007

double a, b, c, d;

main(){
    scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
    printf("%.12f\n", sqrt(a*a + b*b - 2*a*b* cos(((c+d/60.)*30.-d*6.)/180.*3.141592653589793)));
    return 0;
}

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

int main(){
  string s;
  int answer=700;
  cin >> s;
  
  for(int i=0; i<3; i++){
    if(s.at(i) == 'o'){
      answer += 100;
    }
  }
  
  cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int N,L,T,S=0,x;
  cin>>N>>L>>T;
  vector<long long int>X(N),H(N),W(N);
  for(long long int i=0;i<N;i++){
    cin>>X.at(i)>>W.at(i);
    H.at(i)=X.at(i);
  }
  for(long long int i=0;i<N;i++){
    if(W.at(i)==1)X.at(i)=(X.at(i)+T)%L;
    else X.at(i)=(X.at(i)-T+L)%L;
    if(X.at(i)<0)X.at(i)+=L;
  }
  x=X.at(0);
  sort(X.begin(),X.end());
  for(long long int i=1;i<N;i++)if(W.at(i)!=W.at(0)){
    if(W.at(0)==1)S+=(2*T-H.at(i)+H.at(0))/L+1;
    else S-=(2*T+H.at(i)-H.at(0))/L;
  }
  long long int p=0,q=1;
  while(X.at(p)!=x)p++;
  while(q<N&&W.at(0)!=W.at(q))q++;
  if(N>90000&&q<N&&H.at(q)-H.at(0)!=X.at((p+q)%N)-X.at(p)&&X.at((p+1)%N)==x)p++;
  p=(p-S)%N;if(p<0)p+=N;
  for(long long int i=0;i<N;i++)cout<<X.at((p+i)%N)<<endl;
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s; cin >> s;
	for (int i = 0; i < int(s.size()); i++) {
		if (i+1 < int(s.size()) && s[i] == s[i+1]) {
			cout << i+1 << ' ' << i+2 << '\n';
			exit(0);
		}
		if (i+2 < int(s.size()) && s[i] == s[i+2]) {
			cout << i+1 << ' ' << i+3 << '\n';
			exit(0);
		}
	}
	cout << -1 << ' ' << -1 << '\n';

	return 0;
}


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

using namespace std;

int main() {

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

    string s, t;
    cin>>s>>t;
    bool flag = true;
    for(int i=0;i<s.length();i++){
        if(s[i]!=t[i])
            flag = false;
    }
    if(flag){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 3652
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <random>
using namespace std;
#define rep(i, a, n) for (int i = a; i < n; i++)
#define per(i, a, n) for (int i = n - 1; i >= a; i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef double db;
mt19937 mrand(random_device{}());
const ll mod = 2019;
int rnd(int x) { return mrand() % x; }
ll powmod(ll a, ll b)
{
	ll res = 1;
	a %= mod;
	assert(b >= 0);
	for (; b; b >>= 1)
	{
		if (b & 1)
			res = res * a % mod;
		a = a * a % mod;
	}
	return res;
}
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

static uint MD = mod;
struct ModInt
{
	using M = ModInt;
	uint v;
	ModInt(ll _v = 0) { set_v(uint(_v % MD + MD)); }
	M &set_v(uint _v)
	{
		v = (_v < MD) ? _v : _v - MD;
		return *this;
	}
	explicit operator bool() const { return v != 0; }
	M operator-() const { return M() - *this; }
	M operator+(const M &r) const { return M().set_v(v + r.v); }
	M operator-(const M &r) const { return M().set_v(v + MD - r.v); }
	M operator*(const M &r) const { return M().set_v(uint(ull(v) * r.v % MD)); }
	M operator/(const M &r) const { return *this * r.inv(); }
	M &operator+=(const M &r) { return *this = *this + r; }
	M &operator-=(const M &r) { return *this = *this - r; }
	M &operator*=(const M &r) { return *this = *this * r; }
	M &operator/=(const M &r) { return *this = *this / r; }
	bool operator==(const M &r) const { return v == r.v; }
	M pow(ll n) const
	{
		M x = *this, r = 1;
		while (n)
		{
			if (n & 1)
				r *= x;
			x *= x;
			n >>= 1;
		}
		return r;
	}
	M inv() const { return pow(MD - 2); }
	friend ostream &operator<<(ostream &os, const M &r) { return os << r.v; }
};
using Mint = ModInt;
//head
// cin >> t;
// for (int cas = 1; cas <= t; ++cas)
// {
// 	cout << "Case #" << cas << ": ";
// }
int main()
{
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;

	vector<Mint> a(sz(s));

	int len = sz(s);
	Mint t = s[len - 1] - '0';
	a[len - 1] = t;
	per(i, 0, len - 1)
	{
		t += Mint(10).pow(len - i - 1) * (s[i] - '0');
		a[i] = t;
	}

	vi cnt(2020, 0);
	ll ans = 0;
	per(i,0,len) {
		if(a[i].v==0) ans++;
		ans += cnt[a[i].v];
		cnt[a[i].v]++;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi std::vector<int>
#define vvi std::vector<std::vector<int> >
#define vpi std::vector<pi >
#define pi std::pair<int,int>
#define fi first
#define se second
#define all(n) n.begin(), n.end()

#define FROMTO(var, from, to) for (int var = (from), var##down = ((int)(to)) < ((int)(from));var##down ? (var >= (int)(to)) : (var <= (int)(to));var##down ? var-- : var++)
#define UPTO(var, from, to)   for (int var = (from); var <= ((int)(to)); var++)
#define DOWNTO(var, from, to) for (int var = (from); var >= ((int)(to)); var--)
#define FOR(var, to)		  UPTO(var, 0, (to)-1)
#define DOWN(var, from)	   DOWNTO(var, (from)-1, 0)

#define INIT(var, val) FOR(i,countof(var)) var[i] = val
#define INPUT(var) FOR(i,countof(var)) std::cin >> var[i]
#define INPUT1(var) FOR(i,countof(var)) std::cin >> var[i], var[i]--

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)
#define QSORT(v,b) qsort(v,countof(v),sizeof(*v),b)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static const int MOD = 1000000007;
static const int INF = ((1<<30)-1);
static const s64 LINF = ((1LL << 62)-1);

struct Comb {
	std::vector<std::vector<s64> > a;
	Comb(int n) { // O(n^2)
		a.resize(n+1);
		FOR(i,n+1) {
			a[i].resize(i+1, 1);
			UPTO(j,1,i-1) a[i][j] = a[i-1][j] + a[i-1][j];
		}
	}
	s64 ncr(int n, int r) {
		assert(n >= 0);
		assert(n <= (int)a.size());
		assert(r >= 0);
		assert(r <= n);
		return a[n][r];
	}
};

#define gc(c) (c)=getchar()
int ri() {
	int c,s=0,r=0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}
s64 rs64() {
	s64 r = 0;
	int c,s = 0;
	for(;;){gc(c);if(c=='-'){s=1;break;}if(c>='0'&&c<='9'){r=c-'0';break;}}
	for(;;){gc(c);if(c<'0'||c>'9')break;r*=10;r+=c-'0';}
	if(s)r=-r;
	return r;
}

int int_less(const void *a, const void *b) {
	return (*(const int*)a - *(const int*)b);
}
int int_greater(const void *a, const void *b) {
	return (*(const int*)b - *(const int*)a);
}
std::string operator*(const std::string &s, int n){ std::string res; FOR(i,n) res += s; return res; }

template<class T> std::ostream& operator<<(std::ostream& os, std::vector<T> a) { for (auto i : a) os << i << " "; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, std::set<T> a) { for (auto i : a) os << i << " "; return os; }
template<class A, class B> std::ostream& operator<<(std::ostream&os, std::pair<A,B> a) { os << a.fi << "," << a.se; return os; }


int main() {
	int a = ri();
	int b = ri();
	if (a < b) std::swap(a,b);
	std::cout << std::max(a*2 - 1, a + b) << std::endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		int i, j;
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int q = sc.nextInt();
			ArrayList<Deque<Integer>> array = new ArrayList<>();
			for(i = 0; i < n; i++) {
				array.add(new ArrayDeque<Integer>());
			}
			for(i = 0; i < q; i++) {
				int order_number = sc.nextInt();
				int t = sc.nextInt();
				//命令1と2は配列が空なら処理しない
				if(array.get(t).isEmpty() && order_number != 0) {
					continue;
				}
				switch(order_number) {
				case 0 :
					array.get(t).add(sc.nextInt());
					break;
				case 1 :
					System.out.println(array.get(t).peek());
					break;
				case 2 :
					array.get(t).remove();
					break;
				}
			}
		}
	}
}



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

int main(){
	int w,ww;
	string www;
	cin>>w;
	while(w){
		ww=w%3;
		switch(ww){
		case 0:
			www="0"+www;
			break;
		case 1:
			www="+"+www;
			break;
		case 2:
			www="-"+www;
			w++;
			break;
		}
		w/=3;
	}
	cout<<www<<endl;
	return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main(){
  ll N = 0, M = 0, ans1 = 0, ans2 = 0;
  cin >> N >> M;
  vector<ll>A(N);
  rep(i,N){
    cin >> A[i];
  }
  sort(A.begin(), A.end()); //小さい順
  vector<ll>s(N);
  rep(i,N-1){
    s[i] = A[i+1] - A[i];
  }
  ans2 = 1000000000;
  rep(i,N-M+1){
    ans1 = 0;
    rep(j,M-1){
      ans1 += s[i+j];
    }
    ans2 = min(ans2,ans1);
  }
  cout << ans2;
}

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static int N;
    private static List<Integer> h = new ArrayList<>();

    static {
        Scanner sc = new Scanner(System.in);
        N = Integer.parseInt(sc.next());
        for (int i = 0; i < N; i++) {
            h.add(Integer.parseInt(sc.next()));
        }
    }

    public static void main(String[] args) {
        System.out.println(rec(h));
    }

    private static int rec(List<Integer> l) {
        if (l == null || l.size() == 0) {
            return 0;
        }
        if (l.size() == 1) {
            return l.get(0);
        }
        int min = 101;

        for (int i : l) {
            min = Math.min(min, i);
        }

        int res = min;
        List<Integer> newL = new ArrayList<>();
        for (int i : l) {
            int v = i - min;
            if (v != 0) {
                newL.add(v);
            } else {
                res += rec(newL);
                newL = new ArrayList<>();
            }
        }

        if (!newL.isEmpty()) {
            res += rec(newL);
        }

        return res;
    }
}


Measured memory_bytes: 23632
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007LL
#define llMAX 9223372036854775807LL
#define llMIN -9223372036854775808LL
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n;
ll M=(1e5)+1;

//bit全探索
vi bt;
void setbit(ll i){
  bt.clear();
  for(ll tmp=0;i>0;i/=2){
    if (i%2==1) bt.push_back(tmp);
    tmp++;
  }
}




int main(){
  ll ans=0,q;
  cin >>n;
  n++;
  ll nlg=ceil(log2(n));
  vi V(n),W(n);
  REP(i,n-1) cin>>V[i+1]>>W[i+1];

  cin >>q;
  vi u(q),L(q);
  REP(i,q) cin>>u[i]>>L[i];

  //上半分
  ll nhi=nlg-(nlg/2);
  vvi data(1LL<<nhi, vi(M));  // N * M の2次元配列

  for(ll i=1;i<(1LL<<nhi);i++){
    for(ll j=0;j<M;j++){
      if ((j-W[i])>=0)
      {
        data[i][j]=max(data[i/2][j-W[i]]+V[i],data[i/2][j]);
      }
      else
      {
        data[i][j]=data[i/2][j];
      }
    }
  }


int uiv[10];
int wuiv=0;


//下半分
for(ll loop=0;loop<q;loop++){
  ll uidx=u[loop];
  if (uidx<(1LL<<nhi)){
    cout<<data[uidx][L[loop]]<<endl;
  }else{//上＋下
    ll maxval=0;
    //vi uiv;
    int nn=0;
    wuiv=0;
    for(;;uidx/=2){
      if (uidx<(1LL<<nhi))break;
      uiv[wuiv]=uidx;
      wuiv++;
      nn++;
    }

    int bn=1<<nn;
    for(int i=0;i<bn;i++){
      //setbit(i);
      ll tmpw=0;
      ll tmpv=0;
      for(int j=0;j<nn;j++){
        if (i&(1<<j)){
          tmpv+=V[uiv[j]];
          tmpw+=W[uiv[j]];
        }
      }
      //for (auto j : bt) {
        //tmpv+=V[uiv[j]];
        //tmpw+=W[uiv[j]];
      //}
      if (tmpw<=L[loop]){
        maxval=max(data[uidx][L[loop]-tmpw]+tmpv,maxval);
      }
    }

    cout<<maxval<<endl;
  }












}


  return 0;
}

Measured memory_bytes: 207504
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sz(a)((int)(a).size())
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);iostream::sync_with_stdio(0);cout<<fixed<<setprecision(10);cerr<<fixed<<setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());const int D=4,dx[]={+1,0,-1,0},dy[]={0,+1,0,-1};
int bigk(int n,int k){
    while(n>=k&&n%k){
        int m=n/k;
        int c=(n-k*m+m)/(m+1);
        n-=c*(m+1);
    }
    return n/k;
}
int smak(int n,int k){
    while(n>=k&&n%k)n=n-n/k-1;
    return n/k;
}
int32_t main(){
    int n;
    cin>>n;
    int x=0;
    forn(i,n){
        int a,k;
        cin>>a>>k;
        if(k<=10000)x^=smak(a,k);
        else x^=bigk(a,k);
    }
    if(x)cout<<"Takahashi\n";
    else cout<<"Aoki\n";
    return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
int n;
string s;
int main(){
	cin >> s;
	int cnt = 0;
	for (int i = 0;i < s.length();i++){
		if (((s[i] - '0')&1) && (i&1)){
			cnt++;
		}
		if (!((s[i] - '0')&1) && !(i&1)){
			cnt++;
		}
	}
	printf("%d\n",min(cnt,(int)(s.length()-cnt)));
}


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

int teck(char unch[22],char ch[11],int ach,int aunch){
	int ans=0;
	for(int w=0;w<aunch;w++){
		for(int k=0;k<ach;k++){
			if(unch[w+k]==ch[k]){
				ans++;
			}if(ans>=ach){
				return 1;
			}
		}
		ans=0;
	}
	return 0;
}
		



int main(){
	char ch[11],unch[22];
	int n,ans=0;
	cin>>ch;
	int ach=strlen(ch);
	int aunch;
	cin>>n;
	for(int p=0;p<n;p++){
		cin>>unch;
		aunch=strlen(unch);
		for(int w=0;w<aunch;w++){
			unch[aunch+w]=unch[w];
		}
		aunch=strlen(unch);
		ans=ans+teck(unch,ch,ach,aunch);
	}
	printf("%d\n",ans);
}			


Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
const int mxn(1e5 + 10), mxm(4e5 + 10);
const long long modl(998244353);
long long nm, n, m, p, t, k, ans, l, r;
long long a[mxn], b[mxn], h[mxn];
int main() {
  ios_base::sync_with_stdio(false);
//  freopen("in.txt", "r", stdin);///////////////////////////
//  cin >> nm;
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
//    memset(a, 0, sizeof(a));
//    cin >> a[0] >> a[1] >> a[2] >> a[3];
    ans = LLONG_MIN;
    ans = max(ans, a[0]*a[2]),
    ans = max(ans, a[0]*a[3]),
    ans = max(ans, a[1]*a[2]),
    ans = max(ans, a[1]*a[3]);
    cout << ans;
    cout << endl;////////////////////////
  }
  return 0;
}
////////////////////////////////////////////////////////////////////////////////


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int X;

int dp[2000000];

int main(void) {

	cin >> X;

	dp[0] = 1;

	for (int i = 0; i <= 5; i++) {

		int num = 100 + i;

		for (int j = 0; j <= 1000000; j++) {
			if (dp[j] != 0) { dp[j + num] = 1; }
		}

	}

	if (dp[X] != 0) { cout << 1 << endl; }
	else { cout << 0 << endl; }


	return 0;
}

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

int main() {
 
	int n;
	
	cin >> n;
	
    int ok = 0;
    for ( int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            int mul = i * j;
            if (i * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
	cout << "No" << endl;
      return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
vector<P> node[100005];
bool used[100005];
int ans[100005]={0};
void dfs(int pos,int col){
  ans[pos]=col;
  for(int i=0;i<node[pos].size();i++){
    int to=node[pos][i].first;
    ll dis=node[pos][i].second;
    if(!used[to]){
      used[to]=true;
      dfs(to,(int)((col+dis)%2));
    }
  }
  
}
int main(){
  ll n;
  cin>>n;
  for(int i=1;i<=n;i++) used[i]=false;
  for(int i=1;i<n;i++){
    ll u,v,w;
    cin>>u>>v>>w;
    node[u].push_back(P(v,w));
    node[v].push_back(P(u,w));
  }
  used[1]=true;
  dfs(1,0);
  for(int i=1;i<=n;i++) cout<<ans[i]<<endl;
}


Measured memory_bytes: 9984
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#define llong long long
#define pb(a) push_back(a)
#define strVecSORT(strVec) sort(strVec.begin(), strVec.end());
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;

int main(){
  int r,g,b;
  cin>>r>>g>>b;
  int RGB=r*100+g*10+b;
  int ans =RGB%4;
  if(ans==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  double sum = 0;
  for (int i = 0; i < n; ++i) {
    double d;
    string s;
    cin >> d >> s;
    if (s == "JPY") {
      sum += d;
    } else {
      sum += 380000.0 * d;
    }
  }
  cout << fixed << setprecision(16) << sum << endl;
}

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

int main() {
  int64_t n, s = 0, tmp = 0;
  cin >> n;
  vector<int64_t> a(n);
  rep(i, n){
    if(i == 0) cin >> a[i];
    else{
      int b;
      cin >> b;
      a[i] = a[i-1] + b;
    }
    if(a[i] == 0) ++s;
  }
  sort(a.begin(), a.end());
  rep(i, n-1){
    if(a[i] == a[i+1]){
      ++tmp;
      s += tmp;
    }
    else tmp = 0;
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 1792
//include
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#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;

// conversion
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();
}

//math
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

int main()
{
    int X, A;
    cin >> X >> A;
    puts(X < A ? "0" : "10");
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

i4 = numba.int32

def get_input():
    D = int(readline())
    C = np.array(readline().split(), np.int32)
    S = np.array([readline().split() for _ in range(D)], np.int32)
    return D, C, S

@njit((i4, i4[:], i4[:, :], i4[:]), cache=True)
def first_computation(D, C, S, T):
    x = 0
    last = np.zeros((26, D), np.int32)
    for d in range(D):
        if d:
            last[:, d] = last[:, d - 1]
        i = T[d]
        x += S[d, i]
        last[i, d] = d + 1
        for i in range(26):
            x -= C[i] * (d + 1 - last[i, d])
    return last, x

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :], i4, i4), cache=True)
def difference_update(D, C, S, T, last_day, d, q):
    p = T[d]
    T[d] = q
    x = S[d, q] - S[d, p]

    i = np.searchsorted(last_day[p], d + 1)
    d_p = last_day[p, i - 1] if i >= 1 else 0
    coef = 0
    for k in range(d, D):
        if last_day[p, k] == d + 1:
            # k 日目に入るスコアの変更
            coef += d_p - d - 1
            last_day[p, k] = d_p
        else:
            break
    x += coef * C[p]

    coef = 0
    for k in range(d, D):
        if last_day[q, k] < d + 1:
            coef += (d + 1 - last_day[q, k])
            last_day[q, k] = d + 1
        else:
            break
    x += coef * C[q]
    return x

def output(T):
    T += 1
    print(*T, sep='\n')

@njit((i4, i4[:], i4[:, :], i4[:], i4[:, :]), cache=True)
def random_update(D, C, S, T, last_days):
    d = np.random.randint(0, D, 1)[0]
    p = T[d]
    xcum = 0
    for q in range(26):
        if p == q:
            continue
        xcum += difference_update(D, C, S, T, last_days, d, q)
        if xcum > 0:
            return q, xcum
    difference_update(D, C, S, T, last_days, d, p)
    return p, 0

@njit((i4, i4[:], i4[:, :], i4[:], i4[:,:]), cache=True)
def main(D, C, S, T, last_days):
    x = 0
    for _ in range(3*10**5):
        x += random_update(D, C, S, T, last_days)[1]
    return T, x

def first_strategy(D, C, S):
    T = np.empty(D, np.int32)
    for d in range(D):
        T[d] = d % 26
    return T

D, C, S = get_input()

T = first_strategy(D, C, S)
last_days, score = first_computation(D, C, S, T)

T, x = main(D, C, S, T, last_days)

output(T)


Measured memory_bytes: 108068
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7,N=1e5+5;
int mul(int a,int b){return (long long)a*b;}
typedef long long ll;
int n,x[N],y[N],d[N];
const double inf=1e20;
double getans(double mid)
{
    double mnx=inf,mxx=-inf,mny=inf,mxy=-inf;
    for(int i=1;i<=n;i++)
    {
        double xx=x[i],yy=y[i];
        if(d[i]==1) xx-=mid;
        if(d[i]==2) xx+=mid;
        if(d[i]==3) yy+=mid;
        if(d[i]==4) yy-=mid;
        mnx=min(mnx,xx);
        mxx=max(mxx,xx);
        mny=min(mny,yy);
        mxy=max(mxy,yy);
    }
    return (mxx-mnx)*(mxy-mny);
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        char s[5];
        scanf("%d%d%s",&x[i],&y[i],s);
        if(s[0]=='L') d[i]=1;
        else if(s[0]=='R') d[i]=2;
        else if(s[0]=='U') d[i]=3;
        else d[i]=4;
    }
    double l=0,r=1e8;
    while(r-l>1e-8)
    {
        double len=(r-l)/3,mid=l+len,midmid=l+2*len;
        if(getans(midmid)>=getans(mid)) r=midmid;
        else l=mid;
    }
    printf("%f\n",getans((r+l)/2));
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i =a, i>=b;i--)
#define sz(x)       (int)x.size()
#define F			first
#define S			second
#define debug(x)	for(int i=0;i<x;i++) cout<<"##########"<<endl
#define M			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
#define pii 		pair<int ,int >
#define	all(a)		a.begin(), a.end()
#define vi 			vector<int> 
#define vii 		vector<pii>

// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == > != precedence gretaer then & , << precedence greater than <= == => , 
//int chk, cnt, fl, pos, in, src, tar, val, res. dummy;  fill (myvector.begin(),myvector.begin()+4,5), freq;

void solve()
{
	int n;
	cin>>n;
	int arr[n];
	rep(i,0,n)
	{
		cin>>arr[i];
	}
	
	int dp[n];
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	
	rep(i,2,n)
	{
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	}
	cout<<dp[n-1]<<endl;
}

signed main()
{
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		int t=1;
		while(t--)
		{
			solve();
		}
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a, b = map(int, input().split())
product = a * b
amari = product % 2
if amari == 0: hantei = "Even"
elif amari == 1: hantei = "Odd"
# 出力
print(hantei)

Measured memory_bytes: 2940
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    n = int(readline())
    a = list(map(int, readline().split()))
    b = list(map(abs, a))
    idx = b.index(max(b))

    res = []
    for i, x in enumerate(a):
        a[i] += a[idx]
        res.append((idx + 1, i + 1))

    if a[idx] > 0:
        for i in range(1, n):
            if a[i - 1] > a[i]:
                a[i] += a[i - 1]
                res.append((i, i + 1))
    elif a[idx] < 0:
        for i in range(n - 2, -1, -1):
            if a[i] > a[i + 1]:
                a[i] += a[i + 1]
                res.append((i + 2, i + 1))

    print(len(res))
    for x, y in res:
        print(x, y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <cstdio>
#include <iostream>

using namespace std;

struct dice{
	int q1,q2,q3,q4,q5,q6;
};

void mN(dice &d){
	int tmp=d.q1;
	d.q1=d.q2;
	d.q2=d.q6;
	d.q6=d.q5;
	d.q5=tmp;
}

void mE(dice &d){
	int tmp=d.q1;
	d.q1=d.q4;
	d.q4=d.q6;
	d.q6=d.q3;
	d.q3=tmp;
}
void mW(dice &d){
	int tmp=d.q1;
	d.q1=d.q3;
	d.q3=d.q6;
	d.q6=d.q4;
	d.q4=tmp;
}
void mS(dice &d){
	int tmp=d.q1;
	d.q1=d.q5;
	d.q5=d.q6;
	d.q6=d.q2;
	d.q2=tmp;
}

void spin(dice &d){
	int tmp=d.q2;
	d.q2=d.q3;
	d.q3=d.q5;
	d.q5=d.q4;
	d.q4=tmp;
}

int main(){
	dice y, z;
	bool flag = false;
	
	scanf(" %d %d %d %d %d %d", &y.q1, &y.q2, &y.q3, &y.q4, &y.q5, &y.q6);
	scanf(" %d %d %d %d %d %d", &z.q1, &z.q2, &z.q3, &z.q4, &z.q5, &z.q6);
	
	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){
			//printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
		
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}
	
	mE(y);
	
	//printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
	
	for(int i=0; i<4; ++i){
		for(int j=0; j<4; ++j){
			//printf("now: %d %d %d %d %d %d\n", y.q1, y.q2, y.q3, y.q4, y.q5, y.q6);
		
			if(y.q1==z.q1 && y.q2==z.q2 && y.q3==z.q3 && y.q4==z.q4 && y.q5==z.q5 && y.q6==z.q6) {
				flag = true;
				break;
			}
			spin(y);	
		}
		if(flag) break;
		mN(y);
	}	
			
	if(flag)printf("Yes\n");
	else printf("No\n");
		
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int main() {
    int n, minj;
    cin >> n;
    string A[n], B[n], state="Stable";
    for (int i=0; i<n; i++){
        cin >> A[i];
        B[i] = A[i];
    }
    for (int i=0; i<n; i++){
        for (int j=n-1; j>i; j--){
            if (A[j][1] < A[j-1][1]){
                swap(A[j],A[j-1]);
            }
        }
    }
    for (int i=0; i<n; i++){
        if (i == n-1){
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    cout << "Stable" << endl;
    for (int i=0; i<n; i++){
        minj = i;
        for (int j=i; j<n; j++){
            if (B[j][1] < B[minj][1]){
                minj = j;
            }
        }
        swap(B[i], B[minj]);
    }
    for (int i=0; i<n; i++){
        if (i == n-1){
            cout << B[i] << endl;
        } else {
            cout << B[i] << " ";
        }
        if (A[i] != B[i]) state="Not stable";
    }
    cout << state << endl;
    return 0;
}


Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long

using namespace std;

string a,b;

int main(){
		cin>>a>>b;
		int n=a.length();
		int m=b.length();
		if(n>m){
				cout<<"GREATER"<<endl;
				return 0;
		}else if(n<m){
				cout<<"LESS"<<endl;
				return 0;
		}else{
				for(int i=0;i<n;i++){
						if(a[i]<b[i]){
								cout<<"LESS"<<endl;
								return 0;
						}else if(a[i]>b[i]){
								cout<<"GREATER"<<endl;
								return 0;
						}
				}
				cout<<"EQUAL"<<endl;
				return 0;
		}
}


Measured memory_bytes: 256
n = input()
tmp_n = n.split(" ")

list1=[1,3,5,7,8,10,12]
list2=[4,6,9,11]
list3=[2]

if int(tmp_n[0]) in list1 and int(tmp_n[1]) in list1:
    print("Yes")
elif int(tmp_n[0]) in list2 and int(tmp_n[1]) in list2:
    print("Yes")
elif int(tmp_n[0]) in list3 and int(tmp_n[1]) in list3:
    print("Yes")
else:
    print("No")


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

void xor(int map[][10], int y, int x)
{
    int i, j;
    
    for (i = -1; i <= 1; i++){
        for (j = -1; j <= 1; j++){
            if ((i == 0 || j == 0) && 0 <= y + i && y + i < 10
                    && 0 <= x + j && x + j < 10){
                map[y + i][x + j] ^= 1;
            }
        }
    }
}

int main(void)
{
    int map[10][10], ans[10][10], rec[10][10];
    int i, j, k;
    int n;
    int flag;
    
    scanf("%d", &n);
    
    while (n-- != 0){
        memset(map, 0, sizeof(map));
        for (i = 0; i < 10; i++){
            for (j = 0; j < 10; j++){
                scanf("%d", &map[i][j]);
            }
        }
        
        memcpy(rec, map, sizeof(map));
        
        for (i = 0; i < 1024; i++){
            memset(ans, 0, sizeof(ans));
            memcpy(map, rec, sizeof(rec));
            for (j = 0; j < 10; j++){
                if ((i >> j) & 1){
                    ans[0][j] = 1;
                    xor(map, 0, j);
                }
            }
            
            for (j = 1; j < 10; j++){
                for (k = 0; k < 10; k++){
                    if (map[j - 1][k] == 1){
                        ans[j][k] = 1;
                        xor(map, j, k);
                    }
                }
            }
            
            flag = 1;
            for (j = 0; j < 10; j++){
                for (k = 0; k < 10; k++){
                    if (map[j][k] != 0){
                        flag = 0;
                    }
                }
            }
            
            if (flag == 1){
                for (j = 0; j < 10; j++){
                    for (k = 0; k < 10; k++){
                        printf("%d%c", ans[j][k], k == 9 ? '\n' : ' ');
                    }
                }
                break;
            }
        }
    }
    
    return (0);
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void)

{

 int i, n, a[10000];

 scanf("%d",&n);



 for(i = 0 ; i < n ; i++){

   scanf("%d",&a[i]);

}

int min = a[0], max = a[0];

 long long int sum = 0;

for( i = 0 ; i < n ; i++){

if( a[i] < min){

   min = a[i];

}else if( a[i] > max){

max = a[i];

}

sum += a[i];

}



printf("%d %d %lld\n",min,max,sum);

return 0;

}

Measured memory_bytes: 636
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
#define rep(i,n)	for(int i=0;i<n;i++)
int main(){
	string s;
	cin>>s;
	bool north=false;
	bool south=false;
	bool east=false;
	bool west=false;
	for(int i=0;i<s.size();i++){
		if(s[i]=='S')south=true;
		if(s[i]=='N')north=true;
		if(s[i]=='E')east=true;
		if(s[i]=='W')west=true;
	}
	bool sn=true;
	bool ew=true;
	if(south!=north)sn=false;
	if(east!=west)ew=false;
	if(sn==true&&ew==true){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
		
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;
int F(int x){
    int res = 0;
    while(x % 2 == 0){
        x /= 2;
        res++;
    }
    return res;
}
int main(){
    int N;
    cin >> N;
    int A[N];
    REP(i,N) cin >> A[i];
    int ans = 1000;
    REP(i,N){
        ans = min(ans, F(A[i]));
    }
    cout << ans << endl;
}

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

using namespace std;
using ll = long long;
using pii = pair<int,int>;

int main() {
	// freopen("in.txt","r",stdin);
	int cnt[26] = {0};
	int h, w;
	cin >> h >> w;
	string s;
	for (int i = 0; i < h; ++i) {
		cin >> s;
		for (char c : s)
			++cnt[c-'a'];
	}
	int a, b, c;
	if (h%2 && w%2) {
		b = h/2 + w/2;
		c = 1;
	}
	else if (h%2 && !(w%2)) {
		b = w/2;
		c = 0;
	}
	else if (w%2 && !(h%2)) {
		b = h/2;
		c = 0;
	}
	else {
		b = 0;
		c = 0;
	}
	int mm = 0, nn = 0;
	for (int i = 0; i < 26; ++i) {
		int x = cnt[i]%4;
		if (x == 1 || x == 3) ++mm;
		if (x == 2 || x == 3) ++nn;
	}
	if (mm > c || (c-mm)%2) {
		cout << "No" << endl;
		return 0;
	}
	nn -= (c-mm)/2;
	if (nn > b) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
}

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

using ll=long long;
#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define ALL(x) x.begin(),x.end()
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using pi=pair<int,int>;
using vi=vector<int>;
using ld=long double;

template<class T,class U>
ostream& operator<<(ostream& os,const pair<T,U>& p){
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator <<(ostream& os,const vector<T>& v){
	os<<"[";
	REP(i,(int)v.size()){
		if(i)os<<",";
		os<<v[i];
	}
	os<<"]";
	return os;
}

int read(){
	int i;
	scanf("%lld",&i);
	return i;
}

void printSpace(){
	printf(" ");
}

void printEoln(){
	printf("\n");
}

void print(int x,int suc=1){
	printf("%lld",x);
	if(suc==1)
		printEoln();
	if(suc==2)
		printSpace();
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

template<class T>
T Sq(const T& t){
	return t*t;
}

const int inf=LLONG_MAX/3;

signed main(){
	vi cnt(26,inf);
	int n=read();
	REP(i,n){
		vi w(26,0);
		string s=readString();
		for(auto c:s)w[c-'a']++;
		REP(j,26)chmin(cnt[j],w[j]);
	}
	REP(i,26)REP(j,cnt[i])putchar('a'+i);
	puts("");
}


Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std;
typedef long long ll;
typedef struct pair<int,int> P;
typedef struct pair<int,P> P2;

int n;

int dp[31][1000001]={};
int d[31][1000001]={};

const ll INF=100000000001;
int main() {
	int h,w;
	cin>>h>>w;
	ll c[10][10]={};
	for(int i=0;i<10;++i){
		for(int j=0;j<10;++j){
			cin>>c[i][j];
		}
	}
	bool flg=true;
	while(flg){
		flg=false;
		for(int i=0;i<10;++i){
			for(int j=0;j<10;++j){
				for(int k=0;k<10;++k){
					if(c[i][j]>c[i][k]+c[k][j]){
						c[i][j]=c[i][k]+c[k][j];
						flg=true;
					}
				}
			}
		}
	}
	ll total=0;
	int a1;
	for(int i=0;i<h;++i){
		for(int j=0;j<w;++j){
			cin>>a1;
			if(a1>=0)total+=c[a1][1];
		}
	}
	cout<<total<<endl;
	return 0;
}


Measured memory_bytes: 384