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


// fn rec_convert_digit_10_26(res_char_vec: &mut VecDeque<char>, n: f64) {
//     let current_digit = n.log(26.).floor();
//     if current_digit == 0. {
//         res_char_vec.push_front(((n + 96.) as u8) as char);
//     } else {
//         let current_digit_num = (n / (26. as f64).powi(current_digit as i32)).floor();
//         // println!("{} / {} = {}", n, (26. as f64).powi(current_digit as i32), current_digit_num);
//         // println!("{} -> {}", n, n - current_digit_num);
//         rec_convert_digit_10_26(res_char_vec, n - current_digit_num * (26. as f64).powi(current_digit as i32));
//         res_char_vec.push_front(((current_digit_num + 96.) as u8) as char);
//     }
//     
// }
// 
// // #[fastout]
// fn main() {
//     input! {
//         n: f64,
//     }
// 
//     let mut res_char_vec = VecDeque::new();
// 
//     rec_convert_digit_10_26(&mut res_char_vec, n);
// 
//     let res_string: String = res_char_vec.into_iter().collect();
// 
//     println!("{}", res_string);
// }

#[fastout]
fn main() {
    input! {
        mut n: usize,
    }
    let mut res = String::from("");
    let digit_char;
    if n % 26 == 0 {
        digit_char = 'z';
        n -= 26;
        n /= 26;
    } else {
        digit_char = ((n % 26) as u8 + 96) as char;
        n -= n % 26;
        n /= 26;
    }
    res.push(digit_char);
    while n > 0 {
        let digit_char;
        if n % 26 == 0 {
            digit_char = 'z';
            n -= 26;
            n /= 26;
        } else {
            digit_char = ((n % 26) as u8 + 96) as char;
            n -= n % 26;
            n /= 26;
        }
        res.push(digit_char);
    };

    println!("{}", res.chars().rev().collect::<String>());
}


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

using namespace std;

int main()
{
    char a;

    cin >> a;

    if('a' <= a && a <= 'z')
    {
        cout << "a" << endl;
    }
    else if('A' <= a && a <= 'Z')
    {
        cout << "A" << endl;
    }

    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(){
  long long int A, B, C, m;
  cin >> A >> B >> C;
  if(A%2+B%2+C%2){
    cout << 0 << endl;
    return 0;
  }
  m = min(min(A,B),C);
  A -= m;B -= m; C -= m;
  if (!(A+B+C)) cout << -1;
  else{
    int c = 0;
    while((A%2)+(B%2)+(C%2) == 0){
      A /= 2;
      B /= 2;
      C /= 2;
      ++c;
    }
    cout << c << endl;
  }
  return 0;
}


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

int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c;
    e=0;
    for(int i=a; i<=b; i++){
        d=c%i;
        if(d==0)
            ++e;
    }
    cout<<e<<'\n';
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <complex>
#include <cmath>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define EPS 1e-12
 
using namespace std;
typedef complex<double> C;
const double PI = 4 * atan(1.0);
 
struct L : public vector<C>
{
    L(){}
    L(const C a,const C b){
        push_back(a); push_back(b);
    }
};
 
double cross(const C a,const C b)
{
    return imag(conj(a)*b);
}
 
double dot (const C a,const C b)
{
    return real(conj(a)*b);
}
 
C projection(const L& l,const C p)
{
    double t = dot(p-l[0],l[0]-l[1]) / norm(l[0]-l[1]);
    return l[0] + t*(l[0]-l[1]);
}
 
int ccw(C a,C b,C c)
{
    b -=a,c -= a;
    if(cross(b,c) > 0) return +1;
    if(cross(b,c) < 0) return -1;
    if(dot(b,c) < 0) return +2;
    if(norm(b) < norm(c)) return -2;
    return 0;
}
 
double intersectSP(const L& s,const C p)
{
    return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0]) < EPS;
}
 
double intersectSS(const L& s,const L& t)
{
    return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 && ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}
 
double distanceSP(const L& s,const C p)
{
    const C r = projection(s,p);
    if(intersectSP(s,r)) return abs(r-p);
    return min(abs(s[0]-p),abs(s[1]-p));
}
 
bool dp[(1 << 16)];
 
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> r(n);
    vector<C> s(n),t(n);
    rep(i,n){
        int a,b,c,d,e;
        cin >> a >> b >> c >> d >> e;
        r[i] = a,s[i] = C(b,c),t[i] = C(d,e);
    }
    int mx = 0;
    rep(i,(1<<n)){
        dp[i] = false;
    }
    dp[0] = true;
    for(int i=1;i<(1<<n);i++){
        bool flag = false;
        rep(j,n){
            if(i & (1 << j)){
                if(dp[i^(1<<j)]){
                    bool dame = false;
                    int cri = (i^(1<<j));
                    vector<int> vec(n,0);
                    rep(k,n){
                        if(cri & (1 << k)){
                            vec[k] = 1;
                        }
                    }
                    rep(k,n){
                        if(k == j){
                            continue;
                        }
                        if(vec[k] == 1){
                            if(distanceSP(L(s[j],t[j]),t[k]) <= r[j]+r[k]){
                                dame = true;
                                break;
                            }
                        }else{
                            if(distanceSP(L(s[j],t[j]),s[k]) <= r[j]+r[k]){
                                dame = true;
                                break;
                            }
                        }
                    }
                    if(!dame){
                        flag = true;
                        break;
                    }
                    if(flag){
                        break;
                    }
                }
            }
        }
        dp[i] = flag;
    }
    rep(i,(1<<n)){
        if(dp[i]){
            mx = max(mx, __builtin_popcount(i));
        }
    }
    cout << mx << "\n";
}



Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int64_t N, ans = 0;
    cin >> N;
    for (int i = 0; i < N; i++) {
        int64_t A;
        cin >> A;
        ans += A - (i + 1);
    }
    cout << ans << endl;
}



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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,y;
    cin >> x >> y;
    int count=0;
    while(x<=y) {
        x*=2;
        count++;
    }
    cout << count << "\n";

    return 0;
}

Measured memory_bytes: 256
import java.io.*;

import java.math.BigInteger;
import java.util.*;

import java.util.ArrayList;

import java.util.Scanner;


 class Main {

    /*static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    static final int mod = 1000000007;

    public static int gcd(int a, int b)
    {
        if (a == 0)
            return b;
        return gcd(b % a, a);
    }
    public static boolean isPalindrome(String str)
    {

        // Pointers pointing to the beginning
        // and the end of the string
        int i = 0, j = str.length() - 1;

        // While there are characters toc compare
        while (i < j) {

            // If there is a mismatch
            if (str.charAt(i) != str.charAt(j))
                return false;

            // Increment first pointer and
            // decrement the other
            i++;
            j--;
        }

        // Given string is a palindrome
        return true;
    }*/

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

            int h=sc.nextInt();
            int d=sc.nextInt();
            System.out.println((int)Math.ceil((double)h/d));
        }
    }




Measured memory_bytes: 23764
n = int(input())
chars = "Xabcdefghijklmnopqrstuvwxyz"  # x番目がほしいときにchars[x-1]としたくないので、chars[0]は使わないことにします
res = ""

n_rem = n

while True:
    x = n_rem % 26
    # 余りが0、zの場合は、26にします
    if x == 0:
        x = 26
    res += chars[x]

    # xを引いて、26で割ります
    n_rem -= x
    n_rem //= 26

    # 0なら終了します
    if n_rem == 0:
        break

# 0桁目が先頭で、最後の桁が末尾になっているので、反転させます
print(res[::-1])

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

int v[55];

int main() {
   int n, p;
   while (1) {
      cin >> n >> p;
      if (n == 0 && p == 0) return 0;

      int wan = p;
      fill(v, v+55, 0);
      [&]() {
         while (1) {
            rep (i, n) {
               if (wan) {
                  v[i]++, wan--;
               } else {
                  wan += v[i], v[i] = 0;
               }
               if ( [&]() { rep (i, n) { if (v[i]==p) return true; } return false; }() ) {
                  cout << i << endl;
                  return;
               }
               // debug(wan)
            }
         }
      }();

   }

   return 0;
}


Measured memory_bytes: 2968
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

vector<int>to[100009];

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>h(n);
  rep(i,n)cin>>h[i];
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  int ans=0;
  rep(i,n){
    bool ok=true;
    for(auto u:to[i]){
      if(h[i]<=h[u])ok=false;
    }
    if(ok)ans++;
  }
  cout<<ans<<endl;
  return(0);
}


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

#define IOS cin.tie(0);ios::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>

const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>; //Caution!! Segmentation Fault!! Don't forget to add +1!

#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template <class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?' ':'\n'); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);}//最小公倍数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

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

const int NMAX = 200;
bool flag;

bool comp(int x,int y){
    return abs(0-x)<abs(0-y);
}

signed main(){
    IOS;
    CIN(N);
    flag=true;
    vector<string> vs(N);
    map<string,int> mp;
    rep(i,N){
        cin>>vs[i];
        mp[vs[i]]++;
        if(i>0){
            if(vs[i].front()!=vs[i-1].back())flag=false;
        }
        if(mp[vs[i]]>1)flag=false;
    }
    Yes(flag);

    return 0;
}

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

long long int dp[2000];

void insert()
{
    for(long long int i=0;i<2000;i++)
    {
        dp[i]=1LL*i*i*i*i*i;
    }
}

int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    
  insert();

   long long int num;
    cin>>num;
    int flag=0;
    for(int i=0;i<2000;i++)
    {
        for(int j=i+1;j<2000;j++)
        {
            if(dp[i]+dp[j]==num)
            {
                cout<<i<<" -"<<j<<endl;
                flag=1;
                break;
            }
            if(dp[j]-dp[i]==num)
            {
                cout<<j<<" "<<i<<endl;
                
                flag=1;
                break;
            }
        }
        if(flag)
            break;
    }
  
  return 0;

}

Measured memory_bytes: 3588
input = gets.to_s.split(' ')
x_1 = input[0].to_i
y_1 = input[1].to_i
x_2 = input[2].to_i
y_2 = input[3].to_i

l = ((x_1 - x_2)**2 + (y_1 - y_2)**2)**(1/2)

sin_theta = (y_2 - y_1) / l
cos_theta = (x_2 - x_1) / l

x_3 = x_2 - l * sin_theta
y_3 = y_2 + l * cos_theta

x_4 = x_1 - l * sin_theta
y_4 = y_1 + l * cos_theta

puts "#{x_3} #{y_3} #{x_4} #{y_4}"


Measured memory_bytes: 1788
while(True):
    h, w = (int(x) for x in input().split())
    if (h == 0) and (w == 0):
        break;
    for j in range(w):
        print('#', end = '')
    print('')
    for i in range(h - 2):
        print('#', end = '')
        for j in range(w - 2):
            print('.', end = '')
        print('#')
    for j in range(w):
        print('#', end = '')
    print('')
    print('')


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

string a[110];
bool row[110], column[110];

int main() {
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < H; i++) cin >> a[i];
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            if (a[i][j] == '#') row[i] = column[j] = true;
        }
    }

    for (int i = 0; i < H; i++) {
        if (!row[i]) continue;
        for (int j = 0; j < W; j++) {
            if (!column[j]) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#define PI 3.14159265359
using namespace std;

int main(){

	int n;
	double x1, y1, x2, y2, x3, y3;
	double la, lb, lc;
	double a, b, c;
	
	double r;
	double px, py;

	cin >> n;

	for(int i=0;i<n;i++){
		cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

		//lc = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
		la = (x2 - x3) * (x2 - x3) + (y2 - y3) * (y2 - y3);
		//lb = (x3 - x1) * (x3 - x1) + (y3 - y1) * (y3 - y1);

		a = fabs((atan2( y2 - y1, x2 - x1 ) - atan2( y3 - y1, x3 - x1 )));
		b = fabs((atan2( y1 - y2, x1 - x2 ) - atan2( y3 - y2, x3 - x2 )));
		c = fabs((atan2( y1 - y3, x1 - x3 ) - atan2( y2 - y3, x2 - x3 )));


		if( a >= PI ) a=2*PI-a;
		if( b >= PI ) b=2*PI-b;
		if( c >= PI ) c=2*PI-c;


		r = sqrt(la) / (sin(a)*2);
		px = ( sin(2*a) * x1 + sin(2*b) * x2 + sin(2*c) * x3 ) / (sin(2*a)+sin(2*b)+sin(2*c));
		py = ( sin(2*a) * y1 + sin(2*b) * y2 + sin(2*c) * y3 ) / (sin(2*a)+sin(2*b)+sin(2*c));

		r = floor(r*1000+0.5)/1000;
		px = floor(px*1000+0.5)/1000;
		py = floor(py*1000+0.5)/1000;

		cout << setprecision(3) << fixed  << px << " " << py << " " << r << endl;

	}
	return 0;
}

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

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

  int ans = 0;

  if (a <= 2 * b) {
    cout << 0 << endl;
  }
  else {
    cout << a- 2 * b << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a=0,b=0,i;
    char ch;
    for(i=0;i<3;i++)
    {
        cin>>ch;
        if(ch=='A')
        a++;
        else 
        b++;
    }
    if(a!=0&&b!=0)
    cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
n=input()
l=len(n)
ans=0
for i in range(2**(l-1)):
  op=["-","-","-"]
  ans=n[0]
  for j in range(l-1):
    if ((i>>j)&1):
      op[j]="+"
    ans+=op[j]+n[j+1]
  if eval(ans)==7:
    print(ans+"=7")
    break

Measured memory_bytes: 3064
from collections import defaultdict

root = 10000
MOD = 2 ** 61 - 1


#"""
N = int(input())
S_list = [input() for _ in range(N)]
"""
def to_alpha(n):
    ret = ''
    while n > 0:
        n -= 1
        ret += chr(n % 26 + ord('a'))
        n //= 26
    return ret

N = 2 * 10 ** 5
S_list = [to_alpha(i) for i in range(2, 2 * N + 2, 2)]
#"""


S_list.sort(key=len)

ans = 0
wanted = defaultdict(set)
for S in S_list:
    suffix_hashes = [0]
    for c in S[-1:0:-1]:
        suffix_hashes.append((suffix_hashes[-1] * root + ord(c)) % MOD)
    suffix_hashes.reverse()
    l = len(S)
    alpha_set = set()
    for i, c in enumerate(S):
        alpha_set.add(c)
        # print(alpha_set, suffix_hashes[i])
        if suffix_hashes[i] in wanted:
            for alpha in wanted[suffix_hashes[i]]:
                if alpha in alpha_set:
                    ans += 1
    wanted[suffix_hashes[0]].add(S[0])
        
# print(wanted)
print(ans)


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

using namespace std;

int main(){
    string s,t;
    cin>>s>>t;
    ll n=s.length();
    ll m=t.length();
    ll ans=LONG_MAX;

    for(ll i=0;i<=n-m;i++){
            ll cnt=0;
        for(ll k=i;k<i+m;k++){
            if(s[k]!=t[k-i])
                cnt++;
        }
        ans=min(ans,cnt);
        //cout<<ans<<endl;
    }
   cout<<ans;

    return 0;
}


Measured memory_bytes: 3596
t = int(input())
par = [0, 0]
for i in range(t):
	p, t = map(int, input().split())
	if p >= par[0] and t >= par[1]:
		par = [p, t]
	else:
		n = max((par[0]-1)//p + 1, (par[1]-1)//t +1)
		par = [p*n, t*n]
print(sum(par))


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

using namespace std;

int main(){

    int n;

    scanf("%d", &n);

    int mini = 1000000008;
    int maxi = -2;
    int aux;

    for(int i=0; i<n; i++){
        scanf("%d", &aux);
        if(aux>maxi) maxi = aux;
        if(aux<mini) mini = aux;
    }

    printf("%d\n", maxi-mini);

    return 0;
}




Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int a,b,c,d=0;
	scanf("%d",&a);
	for(int i=1;i<=a;i++){
		scanf("%d",&b);
		if(i==1)
		c=b;
		if(c>b)
		c=b;
		if(d<b)
		d=b;
	}
	printf("%d",d-c);
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <map>
#define N 100005
using namespace std;
typedef long long ll;
const ll mod = 1000000007LL;
string a,b;
int main() {
  cin>>a>>b;
  if (a == b) cout<<"EQUAL"<<endl;
  else {
  	if (a.size() > b.size() || (a.size()==b.size() && a>b)) cout<<"GREATER"<<endl;
    else cout<<"LESS"<<endl;
  }
	return 0;
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

LL scoring(int D, vector<vector<LL>> s, vector<int> schedule, vector<LL> c) {
    vector<int> last(26, 0);
    LL score = 0;
    FOR(i, 1, D + 1) {
        LL satisfaction = s[i][schedule[i]];
        last[schedule[i]] = i;
        REP(k, 26) {
            satisfaction -= (i - last[k])*c[k];
        }
        score += satisfaction;
    }
    return score;
}

LL delta(int D, vector<vector<LL>> s, vector<int> schedule, vector<LL> c, int d, int q) {
    int p = schedule[d];
    if(p == q) {
        return 0;
    }

    int lp = 0, rp = D + 1, lq = 0, rq = D + 1;
    for(int i = d - 1;0 <= i;i--) {
        if(schedule[i] == p) {
            lp = i;
            break;
        }
    }
    for(int i = d - 1;0 <= i;i--) {
        if(schedule[i] == q) {
            lq = i;
            break;
        }
    }
    for(int i = d + 1;i <= D;i++) {
        if(schedule[i] == p) {
            rp = i;
            break;
        }
    }
    for(int i = d + 1;i <= D;i++) {
        if(schedule[i] == q) {
            lq = i;
            break;
        }
    }
    return -s[d][p] + s[d][q] - c[p]*(d - lp)*(rp - d) + c[q]*(d - lq)*(rq - d);
}


int main() {
    int D;
    cin >> D;
    vector<LL> c(26);
    vector<vector<LL>> s(D + 1, vector<LL>(26, 0));
    REP(i, 26) {
        cin >> c[i];
    }
    REP(i, D) {
        REP(j, 26) {
            cin >> s[i + 1][j];
        }
    }
    vector<int> last(26, 0);
    vector<int> schedule(D + 1, 0);

    LL score = 0;
    FOR(i, 1, D + 1) {
        int contest = -1;
        int satisfaction = -IINF;
        REP(j, 26) {
            LL x = s[i][j];
            REP(k, 26) {
                x -= (i - last[k])*c[k];
            }
            x += (i - last[j])*c[j];
            if(satisfaction < x) {
                satisfaction = x;
                contest = j;
            }
        }
        last[contest] = i;
        schedule[i] = contest + 1;
        score += satisfaction;
    }

    FOR(i, 1, D + 1) {
        LL mdel = -IINF;
        LL q = -1;
        REP(j, 26) {
            LL del = delta(D, s, schedule, c, i, j);
            if(mdel < del) {
                q = j;
            }
        }
        schedule[i] = q;
    }
    FOR(i, 1, D + 1) {
        cout << schedule[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 3816
x,n = map(int, input().split())
p = list(map(int, input().split()))

cnt1 = 0
cnt2 = 0
ans1 = 0
ans2 = 0

for i in range(x,102):
    cnt1 += 1
    if not i in p:
        ans1 = i
        break

for i in range(x,-1,-1):
    cnt2 += 1
    if not i in p:
        ans2 = i
        break

if cnt1 < cnt2:
    print(ans1)
elif cnt1> cnt2:
    print(ans2)
else:
    print(ans2)


Measured memory_bytes: 9204
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	vector<int> num(3);
	cin >> num[0] >> num[1] >> num[2];
	sort(num.rbegin(), num.rend());
	printf("%d", num[0] * 10 + num[1] + num[2]);
}

Measured memory_bytes: 764
import sys
input  = sys.stdin.readline


def solve():
    N = int(input())
    S,T = map(str,input().strip().split())
    rtn = ""
    for i in range(N):
    	rtn += "{}{}".format(S[i],T[i])
    print(rtn)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 2940
#include<stdio.h>
int main(void)
{
	int n,w,i,ans=10000,l,m,p[1000]={0};
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&w);
		p[i]+=p[i-1]+w;
	}
	for(i=1;i<=n;i++){
		m=p[n]-p[i];
		l=m-p[i];
		if(l<0){
			l*=-1;
		}
		if(ans>l){
			ans=l;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
import java.util.*;
class Main
{
public static void main(String args[])
{
    int a=0,w=0,r=0,t=0;
Scanner sc=new Scanner(System.in);
int n= sc.nextInt();
String s[]=new String[n];
sc.nextLine();

for(int i=0;i<n;i++)
{
s[i]=sc.nextLine();
}
for(int i=0;i<n;i++)
{
if(s[i].equals("AC"))
  a++;
if(s[i].equals("WA"))
  w++;
if(s[i].equals("TLE"))
 t++;
if(s[i].equals("RE"))
r++;
}
System.out.println("AC   x    "+ a);
System.out.println("WA  x   "+w);
System.out.println("TLE  x   "+t);
System.out.println("RE x   "+r);

}
}

Measured memory_bytes: 65176
import math
MOD = 10 ** 9 + 7
N, M = map(int, input().split())
if abs(N - M) > 1:
    print(0)
    exit()
n = math.factorial(N) % MOD
m = math.factorial(M) % MOD
if N == M:
    print(2 * n * m % MOD)
    exit()
print(n * m % MOD)


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

int main(){
  string S;cin >>S;
  const char* s;
  int count = 0;
  s=S.c_str();
  for(int i=0;i<S.length();i++){
    if(s[i] == 'o'){
      count++;
    }
  }
  if (count+(15-S.length()) >= 8){
    cout << "YES" <<endl;
  }else{
    cout << "NO" <<endl;
  }

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;
int main() {
	int A, B, N;
	int fore = 0;
	int dom = 0;
	string s;
	cin >> N >> A >> B;
	cin >> s;
	for (int i = 0; i < N; i++) {
		if (s[i] == 'a') {
			if (dom + fore < A + B) {
				cout << "Yes" << endl;
				dom++;
			}
			else cout << "No" << endl;
			

		}
		else if (s[i] == 'b') {
			if (dom + fore < A + B && fore < B) { cout << "Yes" << endl; fore++;
			}
			else cout << "No" << endl;
			
		}

		else cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>

using namespace std;

int main()
{
    int k[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    /*
    int a[n];
    for(int i=0; i<n; i++){
        int tmp;
        cin >> tmp;
        a[i] = tmp;
    }
    */
    int ans = k[n-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#define INF 1e9
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}

template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
  s << vv[i] << endl;
  }
  return s;
}

int R,G,B,N;
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> R >> G >> B >> N;
  int ret = 0;
  for(int a = 0 ; a < (N/R)+1 ; a++){
    for(int b = 0 ; b < (N/G)+1; b++){
      if((N - (a * R + b * G)) % B == 0 && ((N-(a * R + b * G)) >= 0)){
        ret++;
      }
    }
  }
  cout << ret << endl;
  return 0;
}


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

using namespace std;
#define vec vector
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long

int main()
{
    int n,k,index=1;
    cin >> n>>k;
    
    rep(i,n)
    {
        if(index+k-1 > n)
            break;
        
        index++;
    }
    cout << index-1;
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
const double PI=acos(-1.0);
int main(){
	double r;
	cin>>r;
	printf("%.6lf\n",2*PI*r);
	
	return 0;
}


Measured memory_bytes: 3784
N,Y = map(int, input().split())

x,y,z = -1, -1, -1
for i in range(N+1):
    for j in range(N+1-i):
        k = (N-i-j)
        if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
            x,y,z = i,j,k
            break
    else:
        continue
    break

print(x,y,z,sep=' ')


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<string>
#include<bitset>
#include<cfloat>
#include<iomanip>
#include<numeric>

//#define int long long
#define repi(i,start,end) for(int (i)=(start),TemPNuM=(int)(end);(i)<TemPNuM;++(i))
#define rep(i,end) repi((i),0,(end))
#define rfor(x,v) for(auto& (x) : (v))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fsort(v,lambda) sort(all((v)),(lambda))
#define vin(v) rep(i,(v).size())cin >> (v)[i];
#define vpin(v) rep(i,(v).size())cin>>v[i].first>>v[i].second

using namespace std;
using ll =  long long;
using pint =  pair<int,int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vpint = vector<pint>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>void put_double(T a){if(cout.precision()!=12)cout<<setprecision(12);cout<<a<<endl;}
template<class T>void print(T a){cout << a << endl;}
//lambda: [](int x, int y){return x<y;}

signed main(void) {
    int n, m; cin >> n >> m;
    n--; m--;
    print(n * m);

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main(void) {
    int ary[3],temp;
    scanf("%d %d %d", &ary[0],&ary[1],&ary[2]);
    for (int i = 0; i <= 2; i++) {
        for (int j = 0; j <= 1; j++) {
            if (ary[j] > ary[j + 1]) {
                temp = ary[j + 1];
                ary[j+1] = ary[j];
                ary[j] = temp;
            }
        }    
    }
    printf("%d %d %d\n", ary[0], ary[1], ary[2]);
    return 0;
}


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

#define MAX_NUM (1000000000 + 7)

typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;

using namespace std;

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}

u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

int main() {
  cout << setprecision(15);
  u32 A[3][3];
  bool res[3][3];
  for (u32 i = 0; i < 3; ++i) {
    for (u32 j = 0; j < 3; ++j) cin >> A[i][j], res[i][j] = false;
  }
  u32 N;
  cin >> N;
  vector<u32> b(N);
  ArrayInput(b);
  for (u32 k = 0; k < N; ++k) {
    for (u32 i = 0; i < 3; ++i) {
      for (u32 j = 0; j < 3; ++j) {
        if (b[k] == A[i][j]) res[i][j] = true;
      }
    }
  }
  vector<bool> bingo;
  for (u32 i = 0; i < 3; ++i) {
    bool flag = true;
    for (u32 j = 0; j < 3; ++j) {
      if (!res[i][j]) flag = false;
    }
    bingo.push_back(flag);
  }
  for (u32 i = 0; i < 3; ++i) {
    bool flag = true;
    for (u32 j = 0; j < 3; ++j) {
      if (!res[j][i]) flag = false;
    }
    bingo.push_back(flag);
  }
  if (res[1][1] && res[2][2] && res[0][0]) bingo.push_back(true);
  if (res[0][2] && res[1][1] && res[2][0]) bingo.push_back(true);
  if (find(bingo.begin(), bingo.end(), true) != bingo.end()) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){

	long long N,res;
	const long long M = 1000000007;

	cin >>N;
	res=1;

	for(int i=1; i<=N; i++){

		res =(res*i)%M; 

	//	cout <<i <<" " <<res <<endl;

	}
	cout <<res <<endl;

}

Measured memory_bytes: 256
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y

N=II()
xs=LI()

cur = 1
idx = 0
res = 0
for x in xs:
    if x == cur:
        cur += 1
    else:
        res += 1
if cur != 1:
    print(res)
else:
    print(-1)


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

using namespace std;
#define REPP(i,a,b,c) for(int i=a; i<=b; i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,c) for(int i=a; i>=b; i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FOR(i,a) REP(i,0,(int)a-1)
#define FORD(i,a) REV(i,(int)a-1,0)
#define PB push_back
#define POB pop_back
#define FI first
#define SE second
#define MP make_pair
typedef long long ll;
typedef unsigned long long ull;
typedef pair < int , int > pii;
typedef vector < int > vi;
typedef vector < pii > vii;
typedef vector < ll > vl;
typedef pair < ll , ll > pll;

const double PI = acos(-1);
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const int INF = 1e9;


ll addMod(ll a, ll b){
	if(a + b >= MOD) return a + b - MOD;
	return a + b;
}

ll mulMod(ll a, ll b){
	return (a*b)%MOD;
}

ll fast(ll a, ll b){
	if(b == 0) return 1;
	ll tmp = fast(a,b/2);
	tmp = mulMod(tmp,tmp);
	if(b & 1) tmp = mulMod(tmp,a);
	return tmp;
}

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

//////////////////////////////////////////////


int main(){
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n,x, cnt=0;
	cin >> n;
	FOR(i,n){
		cin >> x;
		if(x % 2 == 1) cnt++;
	}
	if(cnt % 2 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    s += '0';
    int n = s.size();
    vector<array<int, 2>> dp(n+1);
    dp[0][0] = 0, dp[0][1] = 1e9;
    for (int i = 0; i < n; ++i) {
        int u = s[i]-'0';
        dp[i+1][0] = min(dp[i][0]+u, (u == 9 ? (int)1e9 : dp[i][1]+u+1));
        dp[i+1][1] = min(dp[i][0]+10-u, dp[i][1]+9-u);
    }
    cout << dp[n][0] << '\n';
    return 0;
}


Measured memory_bytes: 12144
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
bool cmp(pll a,pll b)
{
    if(a.se == b.se)
    {
        return (a.fi <= b.fi);
    }
    return (a.se<b.se);
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<pll> v(n);
    for(auto &x:v)
    {
        cin>>x.fi>>x.se;
    }
    sort(v.begin(),v.end(),cmp);
    ll cs = 0;
    for(ll i=0;i<n;i++)
    {
        cs += v[i].fi;
        if(cs > v[i].se)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
"""
Created on Fri May  8 14:22:50 2020

@author: shinba
"""
from collections import Counter

n = int(input())
X = list(map(int,input().split()))

ans = Counter(X)

if len(ans) == n:
    print("YES")
else:
    print("NO")

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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) {
    if (ch=='A') return 1;
    else if(ch=='C') return 2;
    else if(ch=='G') return 3;
    else if(ch=='T') return 4;
    else return 0;
}

// 文字列から数値へ変換してkeyを生成する
long long getKey(char str[]) {
    long long sum=0, p=1, i;
    for (i=0; i<strlen(str); i++) {
        sum += p*getChar(str[i]);
        p *= 5;
    }
    return sum;
}

int h1(int key) { return key % M; }
int h2(int key) { return (key%(M-1)); }

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i=0; ; i++) {
        h = (h1(key) + i+h2(key)) % M;
        if( strcmp(H[h], str) == 0) return 1;
        else if( strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i=0; ; i++) {
        h = (h1(key) + i+h2(key)) % M;
        if( strcmp(H[h], str) == 0) return 1;
        else if( strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main() {
    int i, n, h;
    char str[L], com[9];
    for (i=0; i<M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for(i=0; i<n; i++) {
        scanf("%s %s", com, str);
        
        if(com[0] == 'i') {
            insert(str);
        } else {
            if(find(str)) {
                printf("yes\n");
            }else{
                printf("no\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 17060
#include<bits/stdc++.h>
using namespace std;
 
//#define USING_LONG_LONG
#ifdef USING_LONG_LONG
    #define int long long
    const int INF=1001001001001001001ll;
#else
    const int INF=1001001001;
#endif
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREP(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define clr(a) memset((a),0,sizeof(a))
#define CLR(a) memset((a),-1,sizeof(a))
#define each(i,v) for(__typeof((v).begin()) i=(v).begin();i!=(v).end();i++)
#define minv(a,b) (a)=min((a),(b))
#define maxv(a,b) (a)=max((a),(b))
typedef vector<int>vi;
typedef vector<vi>vvi;
typedef vector<string>vs;
typedef pair<int,int>pii;
#define fi first
#define se second
 
int M;
int a[6],s,g;
int d[300];
int dist[300];
 
signed main(){
    scanf("%d",&M);rep(i,6)scanf("%d",&a[i]);scanf("%d%d",&s,&g);s--;g--;
    rep(i,M)scanf("%d",&d[i]);
 
    CLR(dist);
    dist[g]=0;
 
    queue<int>que;que.push(g);
 
    while(que.size()){
        int v=que.front();que.pop();
        rep(i,M){
            if(i+d[i]!=v)continue;
            rep(j,6){
                int va=i+a[j];
                int vb=i-a[j];
                if(0<=va&&va<M&&dist[va]==-1){
                    dist[va]=dist[v]+1;
                    que.push(va);
                }
                if(0<=vb&&vb<M&&dist[vb]==-1){
                    dist[vb]=dist[v]+1;
                    que.push(vb);
                }
            }
        }
    }
    int cnt=0;
    while(s!=g&&cnt<3000){
        int dice;scanf("%d",&dice);
        dice--;
        int va=s+a[dice];
        int vb=s-a[dice];
        if(va>=0&&va<M&&va+d[va]>=0&&va+d[va]<M&&dist[va+d[va]]!=-1&&dist[va+d[va]]<dist[s]){
            va+=d[va];
            printf("1\n");fflush(stdout);
            s=va;
        }
        else if(vb>=0&&vb<M&&vb+d[vb]>=0&&vb+d[vb]<M&&dist[vb+d[vb]]!=-1&&dist[vb+d[vb]]<dist[s]){
            vb+=d[vb];
            printf("-1\n");fflush(stdout);
            s=vb;
        }
        else{
            printf("0\n");fflush(stdout);
        }
        cnt++;
    }
 
    return 0;
}

Measured memory_bytes: 3244
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define max 10000000
// cout << "YES\n";
// cout << "NO\n";
int main()
{
  	int x;
  	cin>>x;
  	if(x==1)
      cout<<0<<endl;
  	if(x==0)
      cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static void main(String[] args) {
		FastReader sc = new FastReader();
		int n=sc.nextInt(),i=sc.nextInt();
             System.out.println(n-i+1);
}
}

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

#define MOD 1000000007

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

  int ans = 1;
  while(n > 0){
    if(n & 1 == 1) ans = (long long)ans * m % MOD;
    m = (long long)m*m % MOD;
    n >>= 1;
  }

  cout << ans  << endl;

  return 0;
}





Measured memory_bytes: 3136
#include "bits/stdc++.h" 
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rerep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    cout<<" "<<c<<" "<<a<<" "<<b<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main() {
	
    string array[]={"0","MON","TUE","WED","THU","FRI","SAT","SUN"};
	string ptr;
	cin>>ptr; 
	int num=0;
	for(int i=1;i<=7;i++){
		if(array[i]==ptr){
			num=i;
			break;
		}
	}
	if(abs(num-7)==0){
		cout<<7<<endl;
	}else cout<<abs(num-7)%7<<endl;

    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>
#include <cstdio>

using namespace std;


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;
	int num = 0;
	int ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'A' || s[i] == 'T' || s[i] == 'C' || s[i] == 'G') {
			num++;
		}
		else {
			ans = max(ans, num);
			num = 0;
		}
	}
	ans = max(ans, num);
	num = 0;

	cout << ans << endl;

	return 0;
}

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

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

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;

void solve()
{
	int A, B, C;
	cin >> A >> B >> C;
	set<int> remain;
	unsigned long long int sum = A;
	int pre_size = -1;
	while (pre_size != remain.size())
	{
		pre_size = remain.size();
		if (sum % B == C)
		{
			cout << "YES" << endl;
			return;
		}
		remain.insert(sum % B);
		sum += A;
	}
	cout << "NO" << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{

  int N,K;
  cin>>N>>K;
  map<int,int> mp;
  for (int i = 0; i < N; i++)
  {
    int A,B;
    cin>>A>>B;
    auto itr = mp.find(A);
    if(itr == mp.end())
    {
      mp[A] = B;
    }
    else
    {
      itr->second += B;
    }
    
  }
  auto itr = mp.begin();
  int SUM = 0;
  for (int i = 0; i < mp.size(); i++)
  {
    if(SUM <= K &&  K <= SUM + itr->second)
    {
      break;
    }
    else
    {
      SUM += itr->second;
      itr++;
    }
    
  }
  cout<<itr->first<<endl;
  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,M;
  cin >> N >> M;
  if(N==M) {
    cout << "Yes" << endl; 
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256