akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

void dfs(vvll &g,int n,int a,int b,vb &ok){
	if(ok.at(n)) return ;
	ok.at(n) = true ;
	for(int i=0;i<g.at(n).size();i++){
		if((a==n&&b==g.at(n).at(i))||(a==g.at(n).at(i)&&b==n)) continue ;
		dfs(g,g.at(n).at(i),a,b,ok) ;
	}
}
bool check(vb &ok){
	for(int i=0;i<ok.size();i++) if(!ok.at(i)) return false ;
	return true ;
}

int main(){
	ll n,m ;
	cin >> n >> m ;
	vvll g(n,vll(0)) ;
	vector<pll> e(m) ;
	for(int i=0;i<m;i++){
		ll a,b ;
		cin >> a >> b ;
		a-- ; b-- ;
		g.at(a).push_back(b) ;
		g.at(b).push_back(a) ;
		if(a>b) swap(a,b) ;
		e.at(i) = make_pair(a,b) ;
	}
	ll ans = 0 ;
	for(int i=0;i<m;i++){
		vb ok(n,false) ;
		dfs(g,0,e.at(i).first,e.at(i).second,ok) ;
		if(!check(ok)) ans++ ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var sResult = ""
    val sDash = readLine().orEmpty().reversed()
    val sLength = sDash.length
    val tStr = readLine().orEmpty().reversed()
    val tLength = tStr.length
    var foundId = 0
    var judge = "UNRESTORABLE"

    run loop@{
        for(i in 0 .. sLength - tLength){
            val sSub = sDash.substring(i ,i + tLength)
            var sJudge = ""
            sSub.forEach {
                if(it == '?'){
                    sJudge += "[a-z]"
                }else{
                    sJudge += it
                }
            }
            val sReg = Regex(sJudge)
            val tmp = sReg.matchEntire(tStr)

            if(tmp != null){
                foundId = i
                judge = ""
                return@loop
            }

        }
    }

    if(judge == "UNRESTORABLE"){
        println(judge)
    }else{
        val sRepl = sDash.substring(foundId, foundId + tLength)
        sResult = sDash.replaceFirst(sRepl, tStr)
        sResult = sResult.replace("?","a").reversed()
        println(sResult)
    }
}

Measured memory_bytes: 36328
// Didn't see editorial
#include <iostream>
#include <queue>
#include <iomanip>
#include <map>
#include <algorithm>

using namespace std;

using ll = long long;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

int main() {
    while(true) {
        int N, K;
        cin >> N >> K;
        if (N == 0) return 0;

        vector<int> R(N);
        int ans = 0;
        map<int, bool> appeared;
        for (int i = 0; i < N; i++) cin >> R[i];

        for (int i = 0; i < (1<<N); i++) {
            vector<int> cards;
            for (int k = 0; k < N; k++) {
                if ((i>>k) & 1) cards.push_back(R[k]);
            }
            if (cards.size() != K) continue;
            sort(cards.begin(), cards.end());

            do {
                string joined = "";
                for (auto val : cards) {
                    joined += to_string(val);
                }
                if (!appeared[stoi(joined)]) {
                    appeared[stoi(joined)] = true;
                    ans++;
                }
            } while (next_permutation(cards.begin(), cards.end()));
        }
        cout << ans << endl;
    }
}

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


int main(){
	ll n,m,c;
	cin >> n >> m >> c;
	vector <ll> arr(m);
	for (int z=0;z<m;z++){
		cin >> arr[z];
	}
	ll count = 0;
	for (int z=0;z<n;z++){
		ll a = 0;
		for (int x=0;x<m;x++){
			ll temp;
			cin >> temp;
			a += temp*arr[x];
		}
		if (a+c >0){
			count ++;
		}
	}
	cout << count << endl;
	cin >> m;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
//#include<bits/stdc++.h>
using ll = long long;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
ll test[12345678];
signed main() {
	ll n = 0, m, q, k, a = 0, b = 0, c = 0, d = 0, cnt = 0; string s, t;
	vector<ll> v(n);
	cin >> a >> b;
	cnt = a * 2;
	while (true) {
		if (cnt > a * 4) { break; }
		if (cnt == b) { cout << "Yes" << endl; return 0; }
		cnt += 2;
	}
	cout << "No" << endl;
	return 0;
}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};

typedef struct node * Node;

Node root;

void insert(int key);
void inorder(Node );
void preorder(Node );

int main()
{
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

void insert(int key)
{
  Node x,y,z;
  y = NULL;
  x = root;

  z = malloc(sizeof(struct node));
  z->key = key;
  z->right = NULL;
  z->left = NULL;

  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  if(y == NULL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u)
{

  if(u != NULL){
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
  }
}

void preorder(Node u)
{
  if(u != NULL){
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
  }
}



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

int main() {
  int n;cin>>n;
  vector<int> x(n),y(n),vec(n);
  rep(i,n){
    cin>>x[i]>>y[i];
    vec[i]=i;
  }
  double ans=0;
  int cnt=0;
  do{
    rep(i,n-1){
      double dx=x[vec[i]]-x[vec[i+1]],dy=y[vec[i]]-y[vec[i+1]];
      ans+=sqrt(dx*dx+dy*dy);
    }
    cnt++;
  }while(next_permutation(all(vec)));
  ans/=cnt;
  cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3816
#include<cstdio>
#include<vector>
#include<algorithm>

#define	pb	push_back

using namespace std;

typedef	vector<int>	vi;

int main(){
	static bool era[110000];
	for(int i=2;i<340;i++){
		if(!era[i])	for(int j=i*i;j<110000;j+=i)	era[j]=true;
	}

	vi pr;
	for(int i=2;i<110000;i++)	if(!era[i])	pr.pb(i);

	for(int n,p;scanf("%d%d",&n,&p),~n;){
		vi::iterator it=upper_bound(pr.begin(),pr.end(),n);
		vi candi;
		for(int i=0;i<p;i++)for(int j=i;j<p;j++)	candi.pb(*(it+i)+*(it+j));
		sort(candi.begin(),candi.end());
		printf("%d\n",candi[p-1]);
	}

	return 0;
}

Measured memory_bytes: 1024
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.format;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int n, k;

void main()
{
  int n = readln.chomp.to!int;
  int k = readln.chomp.to!int;
  int ans = int.max;
  foreach (i; 0 .. 1 << n)
  {
    int v = 1;
    foreach (j; 0 .. n)
    {
      if ((i >> j) & 1)
      {
        v *= 2;
      }
      else
      {
        v += k;
      }
    }
    ans = min(ans, v);
  }
  ans.writeln;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;


public class Main {
    int D;
    private void solve() {
        D = nextInt();

        int cnt = 25 - D;
        String ans = "Christmas";
        for(int i = 0;i < cnt;i++) {
            ans += " Eve";
        }

        out.println(ans);
    }

    public static void main(String[] args) {
        out.flush();
        new Main().solve();
        out.close();
    }

    /* Input */
    private static final InputStream in = System.in;
    private static final PrintWriter out = new PrintWriter(System.out);
    private final byte[] buffer = new byte[4096];
    private int p = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (p < buflen)
            return true;
        p = 0;
        try {
            buflen = in.read(buffer);
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (buflen <= 0)
            return false;
        return true;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrint(buffer[p])) {
            p++;
        }
        return hasNextByte();
    }

    private boolean isPrint(int ch) {
        if (ch >= '!' && ch <= '~')
            return true;
        return false;
    }

    private int nextByte() {
        if (!hasNextByte())
            return -1;
        return buffer[p++];
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = -1;
        while (isPrint((b = nextByte()))) {
            sb.appendCodePoint(b);
        }
        return sb.toString();
    }

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

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

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


Measured memory_bytes: 22100
// Daniel Grzegorzewski
// while (clock()<=69*CLOCKS_PER_SEC)
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")

#define MP make_pair
#define PB push_back
#define ST first
#define ND second
#define int long long

using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

//X.find_by_order(k); - zwraca iterator na k-ty element (numeracja od zerowego)
//X.order_of_key(k); - zwraca liczbę elementów ostro mniejszych niż k

typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VII;
typedef long long LL;

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

const int N = 203;
const int K = 61;

int t, n, a[N], rep[K];
string s;

signed main() {
  init_ios();
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; ++i)
      cin >> a[i];
    cin >> s;
    for (int i = 0; i < K; ++i)
      rep[i] = 0;
    bool ok = true;
    for (int i = n-1; i >= 0; --i) {
      int bit = -1;
      for (int j = K-1; j >= 0; --j) {
        if (a[i]&(1LL<<j)) {
          if (rep[j] == 0) {
            // rep[j] = a[i];
            bit = j;
            break;
          }
          a[i] ^= rep[j];
        }
      }
      if (s[i] == '0' && bit != -1)
        rep[bit] = a[i];
      else if (s[i] == '1' && a[i])
        ok = false;
    }
    if (ok)
      cout<<"0\n";
    else
      cout<<"1\n";
  }
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define ull unsigned ll
#define pb push_back
#define popb pop_back
#define mt make_tuple
#define eb emplace_back
#define mp make_pair
#define ff first
#define ss second
#define pii pair <int,int>
#define piii pair <pii,int>
#define piiii pair <pii,pii>
#define pll pair <ll,ll>
#define plll pair <pair <ll, ll>, ll>
#define rep0(i,n) for(ll i=0;i<(ll)n;i++)
#define rep1(i,n) for(ll i=1;i<=(ll)n;i++)
#define rep(i,x,y) for(ll i=(ll)x;i<=(ll)y;i++)
#define reprev(i,n) for(ll i=(ll)n;i>=0;i--)
#define all(c) c.begin(),c.end()
#define print(a) rep0(i,a.size()) cout << a[i] << " "
#define hi() cout << "\nHello, I am error. Can you find me? :):):)\n"
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_eppoch().count())
 
using namespace __gnu_pbds;
using namespace std;
using ordered_set =  tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>;

// FOR DEBUGGING
vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", ";
	else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifndef XOX
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

const int mod = 1e9+7;
const long double pi = acos(-1);
const ll INF = 1e15;

ll power(ll x, ll y){
	x %= mod;
	ll ans = 1;
	while(y){
		if(y&1) ans = (ans*x)%mod;
		y /= 2;
		x = (x*x)%mod;
	}
	return ans;
}

void solve(){

	int n;
	cin >> n;
	vector <int> ans(n+1,0);
	rep1(i,200){
		rep1(j,200){
			rep1(k,200){
				int tmp = i*i + j*j + k*k + i*j + i*k + j*k;
				if(tmp<=n) ans[tmp]++;
			}
		}
	}
	rep1(i,n) cout << ans[i] << "\n";

	return;
}

int main(){

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

	int TC = 1,t = 0;
	// cin >> TC;
	while(t++ < TC){
		// cout << "Case #" << t << ": ";
		solve();
		// cout << "\n";
	}

	cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";

	return 0; 
}

Measured memory_bytes: 3808
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N,x=get_i
m=array(N)
N.times do|i|
    m[i]=gets.to_i
end
m.sort!
ans=N
sum=m.inject(:+)
x-=sum
while x-m[0]>=0
  x-=m[0]
  ans+=1
end
puts ans

Measured memory_bytes: 3836
def maxPoints(a,b,c,N):
    dp = [[0]*3 for _ in range(N)]
    dp[0][0] = a[0]
    dp[0][1] = b[0]
    dp[0][2] = c[0]

    for i in range(1,N):
        dp[i][0] = a[i] + max(dp[i-1][1],dp[i-1][2])
        dp[i][1] = b[i] + max(dp[i-1][0],dp[i-1][2])
        dp[i][2] = c[i] + max(dp[i-1][1],dp[i-1][0])
    
    return max(dp[N-1])

n = int(input())
a = [0] * n
b = a.copy()
c = a.copy()
for i in range(n):
    a[i],b[i],c[i] = map(int,input().split())
print(maxPoints(a,b,c,n))

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

int main(void) 
{
   vector<ll> x(5);
   rep(i,5) cin >> x[i];
   rep(i,5)
   {
      if(x[i] == 0)
      {
         cout << i+1 << endl;
         return 0;
      }
   }
}

Measured memory_bytes: 3592
#include<stdio.h>

int main(){
	int c,y,t,o,p;
	char a[9];
	scanf("%d",&c);
	for(y=0;y<c;y++){
		t=o=p=0;
		while(1){
			scanf("%s",&a);
			if(a[0]=='H')t++;
			if(a[0]=='O')o++;
			if(a[1]=='O'){p+=t;t=0;}
			if(t>3){p++;t--;}
			if(o>2)break;
		}
		printf("%d\n",p);
	}
}

Measured memory_bytes: 0
/*||>>>> Praveen Ojha <<<<>>>> 27 May 2019 <<<<>>>> 01:25:39 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf 1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
  int n,k;
  cin>>n>>k;
  deque <int> a(n);
  for(int i=0;i<n;i++)
    cin>>a[i];
  int maxi=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=i;j++){
      vi vv;
      deque <int> tt=a;
      int fr=j,ba=i-j;
      while(fr>0 && !tt.empty()){
        vv.push_back(tt.front());
        tt.pop_front();
        fr--;
      }
      while(ba>0 && !tt.empty()){
        vv.push_back(tt.back());
        tt.pop_back();
        ba--;
      }
      // if(i==3)
      //   debug()<< imie(j) imie(i-j) imie(vv);
      sort(rall(vv));

      int le=k-i;
      while(!vv.empty() && le>0 && vv.back()<0){
        le--;
        vv.pop_back();
      }

      int sumi=0;
      for(int kk=0;kk<sz(vv);kk++)
        sumi+=vv[kk];
      maxi=max(maxi,sumi);
    }
  }
  cout<<maxi<<"\n";
return 0;
}

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

int main()
{
    int h, w, n, x, y;
    cin >> h >> w >> n;
    int a[h][w];
    x = y = 0;
    for(int i=1; i<=n; i++){
        int tmp;
        cin >> tmp;
        for(int j = 1; j<=tmp; j++){
            a[x][y] = i;
            if(x==h-1 && y%2==0 || x==0 && y%2==1){
                y++;
            }else if(y%2==0){
                x++;
            }else{
                x--;
            }
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cout << a[i][j]<<" ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
void solve() {
  ll N, M, P;
  cin >> N >> M >> P;
  vector<ll> A(M), B(M), C(M);
  REP(i, M) {
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<ll> d(N, INF);
  d[0] = 0;
  REP(i, 2 * N) {
    REP(j, M) {
      ll from = A[j] - 1, to = B[j] - 1, cost = P - C[j];
      if(d[from] < INF && d[to] > d[from] + cost) {
        if(i < N - 1) {
          d[to] = d[from] + cost;
        } else {
          d[to] = -INF;
        }
      }
    }
  }
  cout << (d[N-1] <= -INF ? -1 : max(0ll, -d[N-1])) << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var X, N int

func main() {
	sc.Split(bufio.ScanWords)

	X, N = nextInt(), nextInt()

	P := make([]int, 102)
	for i := 0; i < N; i++ {
		p := nextInt()
		P[p] = 1
	}

	//fmt.Println(P)

	if P[X] != 1 {
		fmt.Println(X)
		return
	}

	ansl, ansr := -1, -1
	l, r := X-1, X+1
	for i := 0; i <= 200; i++ {
		if P[l] == 0 {
			ansl = l
			break
		}
		l--
	}

	for i := 0; i <= 200; i++ {
		if P[r] == 0 {
			ansr = r
			break
		}
		r++
	}

	if absInt(X-ansl) > absInt(X-ansr) {
		fmt.Println(ansr)
	} else if absInt(X-ansl) <= absInt(X-ansr) {
		fmt.Println(ansl)
	}
}


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

long long so(long long a){
    long long ans = a-1;
    long long b, i;
    for(i = 2; i <= sqrt(a); i++){
        if(a % i == 0){
            b = i + (a/i) - 2;
            ans = min(ans, b);
        }
    }
    return ans;
}

int main(){
    long long n;
    cin >> n;
    cout << so(n) << endl;
}

Measured memory_bytes: 384
#include <iostream>

#define MAX 10

using namespace std;

int iMap[MAX][MAX];

int min(int a, int b) {

	return (a < b) ? a : b;

}

void floydwarshall(void) {

	int iI, iJ, iK;

	for (iK = 0; iK < MAX; iK++)
		for (iI = 0; iI < MAX; iI++)
			for (iJ = 0; iJ < MAX; iJ++)
				iMap[iI][iJ] = min(iMap[iI][iJ], iMap[iI][iK] + iMap[iK][iJ]);

}

int main(void) {

	int iH, iW;
	int iI, iJ;
	int iV, iAnswer = 0;

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

	cin >> iH >> iW;

	for (iI = 0; iI < MAX; iI++)
		for (iJ = 0; iJ < MAX; iJ++)
			cin >> iMap[iI][iJ];
			
	floydwarshall();

	for (iI = 0; iI < iH; iI++) {
		for (iJ = 0; iJ < iW; iJ++) {
			cin >> iV;
			if (iV >= 0)
				iAnswer += iMap[iV][1];
		}
	}

	cout << iAnswer << endl;

	return 0;


}

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

int main() {
  int N ,a, b, c, d;
  cin >> N;
  a = N/1000%10;
  b = N/100%10;
  c = N/10%10;
  d = N%10;
  if((a == b && b ==c) || (b == c && c ==d))
    cout << "Yes" << endl;
  else
  	cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	bool flag = false;
	int counter = 0;
	while (true) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 != 0) {
				flag = true;
				break;
			}
			else {
				a[i] /= 2;
			}
		}
		if (flag) {
			break;
		}
		else {
			counter++;
		}
	}
	cout << counter << endl;
	return 0;
}

Measured memory_bytes: 256
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<bitset>
#include<random>
#include<cstdint>
#include<math.h>
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
#define shosu setprecision(17)
#define hayai cin.tie(0);ios::sync_with_stdio(false);
 
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<char,P> Q;
ll longinf=(1ll<<60);
ll inf=1ll<<29;
ll mod=998244353;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b;
    string s;
    cin>>n>>a>>b;
    cin>>s;
    int tsuukasha=0;
    int kaigai=0;
    rep0(i,n){
      if(s[i]=='c'){
        cout<<"No"<<endl;
      }
      if(s[i]=='a'){
        if(tsuukasha<a+b){
          cout<<"Yes"<<endl;
          tsuukasha++;
        }
        else{
          cout<<"No"<<endl;
        }
      }
      if(s[i]=='b'){
        if(tsuukasha<a+b&&kaigai<b){
          cout<<"Yes"<<endl;
          tsuukasha++;
          kaigai++;
        }
        else{
          cout<<"No"<<endl;
        }
      }

    }
      return 0;
}

Measured memory_bytes: 848
#include<cstdio>
int n,w;
long long wei[200005], v[200005], dp[200005];
long long best=0;

inline long long maks(long long a, long long b){
	return a>b?a:b;
}

int main(){

	scanf("%d %d", &n, &w);
	for(int i=0;i<n;i++){
		scanf("%lld %lld", &wei[i], &v[i]);
	}
	for(int j=0;j<n;j++){
		for(int i=w;i>=0;i--){
				dp[i+wei[j]]=maks(dp[i+wei[j]], dp[i]+v[j]);
				if(i+wei[j]<=w)best=maks(best, dp[i+wei[j]]);
		}
	}
	printf("%lld\n", best);
}


Measured memory_bytes: 3712
S, T = [input() for _ in range(2)]
answer = 1001

for i in range(len(S) - len(T) + 1):
	k = 0
	U = S[i:i + len(T)]
	for j in range(len(T)):
		if T[j] != U[j]:
			k += 1
	answer = min(answer, k)
print(answer)

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n),b(n);
  for(int i=0;i<n;i++){
    cin >> a.at(i);
    b.at(i) = a.at(i);
  }
  sort(b.begin(),b.end());
  for(int i=0;i<n;i++){
    if(a.at(i) != b.at(n-1)){
      cout << b.at(n-1) << endl;
    }
    else{
      cout << b.at(n-2) << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v){stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modpow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isprime(ll n){if(n<2)return 0;if(!(n%2))return !(n-2);lll d=n-1,t,y;while(!(d%2))d>>=1;vl al={2,325,9375,28178,450775,9780504,1795265022};for(ll a:al){if(n<=a)break;t=d,y=modpow(a,t,n);while(t!=n-1&&y!=1&&y!=n-1)y=y*y%n,t<<=1;if(y!=n-1&&!(t%2))return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
void YN(bool z){cout<<(z?"YES\n":"NO\n");}
void Yn(bool z){cout<<(z?"Yes\n":"No\n");}
void yn(bool z){cout<<(z?"yes\n":"no\n");}
const int iinf = 1e9+6;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;

const int N = 1<<17;
ll dp[N], dpn[N];
int n, x[3], y, z;

main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, 3) cin >> x[i];
  x[1] += x[2];
  x[0] += x[1];
  y = (1<<x[0])-1;
  z = (1<<(x[0]-1)) + (1<<(x[1]-1)) + (1<<(x[2]-1));
  ll ans = 0;
  dp[0] = 1;
  FOR(i, 0, n){
    ans *= 10;
    Fill(dpn, 0);
    FOR(k, 0, 1<<x[0]){
      FOR(j, 0, 7) dpn[((k*2+1)<<j)&y] += dp[k];
      dpn[0] += dp[k] * 3;
    }
    FOR(k, 0, 1<<x[0]){
      dpn[k] %= mod;
      if((k&z)==z){
        ans += dpn[k];
        dpn[k] = 0;
      }
    }
    ans %= mod;
    swap(dp, dpn);
  }
  cout << ans << endl;
  return 0;
}

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

const int MAX_N = 10100;
const int inf = 1e8;

int idx[MAX_N];


int main(){
 int N,M; cin >> N >> M;
 string S; cin >> S;
 
 vector<int> ans;
 
 int pos = N;
 
 while( pos > 0 ) {
  ans.push_back(pos);
  bool flag = true;
  for(int i = min(M,pos); i >= 1; i--){
   if( S[pos-i] == '0'){ pos -= i; flag = false; break;}
   }
   if(flag){ cout << -1 << endl; return 0;}
 }
 
 ans.push_back(0);
 
 reverse(ans.begin(),ans.end());
 
 for(int i = 0; i < (int)ans.size()-1; i++){
  cout << ans[i+1]-ans[i] << " ";
  }
  
  cout << endl;
  
  return 0;
 }

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define end "\n"
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;


void solve(){
	int a,b;
	cin>>a>>b;
	if(a>12)cout<<b;
	else if(a<=12 && a>=6)cout<<b/2;
	else cout<<0;


}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する

int main() {
    int n;
    cin >> n;
    vector<int> v1(100000, 0);
    vector<int> v2;

    if(n == 2){
        int a,b;
        cin >> a >> b;
        if(abs(a-b) <= 1){
            cout << 2 << endl;
        }else{
            cout << 1 << endl;
        }
        return 0;
    }

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


    if (n == 1) {
        cout << 1 << endl;
        return 0;
    }


    for (int i = 0; i < n - 2; i++) {
        v2.push_back(v1[i] + v1[i + 1] + v1[i + 2]);
    }
    sort(v2.begin(), v2.end(), greater<int>());
    cout << v2[0] << endl;

    return 0;
}


Measured memory_bytes: 1276
#include <stdio.h>
#include <stdlib.h>

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

    int *A = malloc(sizeof(int) * n);
    int i;
    for (i = 0; i < n; i++) scanf("%d", A + i);

    int m;
    scanf("%d", &m);

    int *B = malloc(sizeof(int) * m);
    for (i = 0; i < m; i++) scanf("%d", B + i);

    int ans;
    if (n < m) {
        ans = 1;
    }
    else {
        ans = 0;
        n = m;
    }
    for (i = 0; i < n; i++) {
        if (A[i] < B[i]) {
            ans = 1;
            break;
        }
        else if (A[i] > B[i]) {
            ans = 0;
            break;
        }
    }

    printf("%d\n", ans);

    free(A);
    free(B);

    return 0;
}


Measured memory_bytes: 2088
#include<iostream>
using namespace std;
string S, T;
int i,j,k;
char x;
int main(){
    cin>>S>>T;
    j=S.size()-1;
    for(k=j; k>=0; k--){
        x=S[j];
        S.insert(i,1,x);
        S.erase(j+1);
        if (S==T){
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
/*
AizuOnline A0121
A Milk Shop
*/
#include <stdio.h>
#include <stdlib.h>

int int_lessp(int *a,int *b)
{
  return(*a - *b);
}

main()
{
  int i,c,n[10001];
  long long int sum;

  while(EOF!=scanf("%d",&c) && c > 0)
    { sum = 0;
      for(i=0;i<c;i++)
         scanf("%d",n+i);
         
      qsort(n,c,sizeof(int),int_lessp);
      
      for(i=0;i<c;i++)
        sum += (c-i-1)*n[i];

      printf("%lld\n",sum);

    }
return(0);
}

Measured memory_bytes: 0
n = int(input())
s = list(map(int,input().split()))
c = 0
l = []
ind = 1
#print(s)
for i in s:
  #print(i)
  if i == ind:
    ind += 1
    #print("t")
  else:
    c += 1
#print(ind)
if ind == 1:
  print(-1)
else:
  print(c)


Measured memory_bytes: 24744
#! -*- coding: utf-8 -*-

n,k = map(int,raw_input().split())

a = map(int,raw_input().split())

#for i in range(n):
#    if a[i] == 1:
#        break

#x = i/(k-1)
#if i%(k-1) > 0:
#    x += 1
#y = (n-i-1)/(k-1)
#if (n-i-1)%(k-1) > 0:
#    y += 1
#

ans = (n-1)/(k-1)
if (n-1)%(k-1)>0:
    ans += 1

print ans


Measured memory_bytes: 11304
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b;
    scanf("%d %d", &a, &b);
    if(a > b){
        printf("a > b\n");
    }else if(a < b){
        printf("a < b\n");
    }else{
        printf("a == b\n");
    }
    return 0;
}

Measured memory_bytes: 580
// 基本のinclude
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;

string sp = "ABC";

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

    int ans = 0;
    rep(i, s.size()-2) {
        if (s[i] == sp[0] && s[i+1] == sp[1] && s[i+2] == sp[2]) {
            ans++;
        }
    }

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

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
const int maxn = 1e5 + 7;

vector<int> G[maxn];
int pi[maxn];
int dep[maxn];
bool vis[maxn];
int lf;


void dfs(int x,int h) {
	int ch = 0; dep[x] = h;
	
	for (int j = 0; j < G[x].size(); j++) {
		int z = G[x][j];
		if (pi[z] > -2) continue;
		pi[z] = x; ch++;
		dfs(z,h+1);
	}

	if (ch == 0) lf = x;
}



vector<int> p;

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

	int n,m; cin>>n>>m;

	for (int i = 1; i <= n; i++) {
		pi[i] = -2; dep[i] = 0; vis[i] = false;
	}

	for (int i = 1; i <= m; i++) {
		int x,y; cin>>x>>y;
		G[x].pb(y); G[y].pb(x);
	}
	
	pi[1] = -1;
	dfs(1,0);	

	int cur = lf; int maxh = 0;
	
	p.clear();

	while (true) {
		while (dep[cur] >= maxh) {
			//cout<<cur<<" : "<<pi[cur]<<endl;
			vis[cur] = true; p.pb(cur);
			if (pi[cur] < 0 || vis[pi[cur]]) break;
			cur = pi[cur];
		}
		maxh = dep[cur] + 1; bool ok = false;
		for (int j = 0; j < G[cur].size(); j++) {
			if (!vis[ G[cur][j] ]) { cur = G[cur][j]; ok = true; break; }
		}

		if (!ok) break;
	}

	cout<<p.size()<<endl;
	for (int i = 0; i < p.size(); i++) {
		cout<<p[i]<<" ";
	}
	cout<<endl;

}


Measured memory_bytes: 13432
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int counter = scanner.nextInt();

        int left = 0;
        for (int i = 0; i < counter; i++) {
            final int stair = scanner.nextInt() - 1;
            if (stair >= left) {
                left = stair;
            } else {
                if (left > stair + 1) {
                    System.out.println("No");
                    return;
                }
            }
        }

        System.out.println("Yes");
    }
}


Measured memory_bytes: 49424
from fractions import Fraction
n,m=map(int,input().split())
a=list(map(int,input().split()))

cnt=0

for i in a:
	if (sum(a))*(Fraction(1,4*m))<=i:
		cnt+=1
		if cnt==m:
			print("Yes")
            
if cnt<m:
	print("No")

Measured memory_bytes: 10348
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[200005];

int main(){
    int k,n;
    scanf("%d%d",&n,&k);
    /*while(t--){}*/
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    
    for(int i=k;i<=n-1;i++){
    	if(a[i+1]>a[i-k+1]) printf("Yes\n");
    	else printf("No\n");
    }
    
    
    //printf("%d",t);

    return 0;
}


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

int main(void) {
	int n, ans = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	while (1) {
		for (int i = 0; i < n; i++) {
			if (a[i] % 2 == 0) a[i] = a[i] / 2;
			//else if (a[i] == 0) {
			//	cout << ans << endl;
			//	return 0;
			//}
			else {
				cout << ans << endl;
				return 0;
			}
		}
		ans++;
	}
	return 0;
}

Measured memory_bytes: 256
//
// Created by yamunaku on 2019/12/01.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CYESA cout<<"Yay!"<<endl
#define CNOA cout<<":("<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

int main(){
    // CFS;
    int x;
    cin >> x;
    int p = x / 100, q = x % 100;
    q = (q + 4) / 5;
    cout << (p >= q ? 1 : 0) << endl;
    return 0;
}

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

using namespace std;

int main() {
	typedef long long int lli;
	
	lli a, b, c, k;
	lli sum {0}, count {0};
	
	cin >> a >> b >> c >> k;
	
	if (a <= k)
	{
		sum += a;
		count += a;
		
		if (count < k)
		{
			if (b <= (k - a)) count += b;
			else if (b > (k - a))
			{
				count += (b - (k - a));
				}
			}
		if (count < k)
		{
			if (c <= (k - a - b)) sum -= c;
			else if (c > (k - a - b)) sum -= (k - a -b);
			}
			//}
		}
	else if (a > k)
	{
		sum += k;
		}
	
	cout << sum << "\n";
	
	return 0;
	}


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

int q;
int a[100005],b[100005],c[100005];
int ans[100005];
int x,y;

int main()
{
	cin>>q;
	for(int i=2;i<=100000;i++) a[i]=1;
	for(int i=2;i<=100000;i++){
		if(a[i]){
			for(int j=i+i;j<=100000;j+=i) a[j]=0;
		}
	}
	
	c[0]=c[1]=0;
	
	for(int i=2;i<=100000;i++) if(a[i] && a[(i+1)/2]) b[i]=1;
	for(int i=1;i<=100000;i++) c[i]=c[i-1]+b[i];
	
	for(int i=1;i<=q;i++){
	   cin>>x>>y;
	   ans[i]=c[y]-c[x-1];
	}
	
	for(int i=1;i<=q;i++) cout<<ans[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int n,m,q,a[50],b[50],c[50],d[50],o,p[10];
void u(int l,int f){if(l==n){int s=0;for(int i=0;i<q;i++)if(p[b[i]-1]-p[a[i]-1]==c[i])s+=d[i];o=max(o,s);return;}for(int i=f;i<=m;i++){p[l]=i;u(l+1,i);}}
int main(){cin>>n>>m>>q;for(int i=0;i<q;i++)cin>>a[i]>>b[i]>>c[i]>>d[i];u(0,1);cout<<o;}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    if (n % 1000 != 0) {
        cout << 1000 - (n % 1000) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

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

int k,ans;
vector<int> dif;
const int M = 10;

void rec(int d, int p){
  if(p==k){
    ans = min(ans,d);
    return;
  }
  if(d>=ans)return;

  for(int i=k;i>=1;i--){
    if(p+i-1>=k)continue;
    vector<int> tmp = dif;
    for(int j=p+i-1;j>=p;j--){
      dif[j] -= dif[p];
      dif[j] = (dif[j]%M +M)%M;
    }
    int np = p;
    while(np<k && !dif[np])np++;
    rec(d+1,np);
    dif = tmp;
  }
}

int main(){
  while(cin >> k,k){
    dif.resize(k);

    string s,t;
    cin >> s >> t;
    for(int i=0;i<k;i++){
      dif[i] = (( (int)(t[i]-s[i]) ) % M + M ) % M;
    }

    ans = k;
    int p = 0;
    while(p<k && !dif[p])p++;
    rec(0,p);
    cout << ans << endl;
  }
}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
#define maxn 305

using namespace std;
int dp[maxn][maxn][maxn],n,k,l,r;
char s[maxn];

int main()
{
    scanf("%s",s); scanf("%d",&k); n=strlen(s);
    for (int i=0;i<n;i++) for (int j=0;j<=k;j++) dp[i][i][j]=1;
    for (int i=1;i<n;i++) dp[i][i-1][0]=0;
    for (int i=1;i<n;i++)
        for (int j=0;j+i<n;j++)
        {
            l=j; r=j+i;
            for (int m=0;m<=k;m++)
            {
                dp[l][r][m]=max(dp[l+1][r][m],dp[l][r-1][m]);
                if (m>0) dp[l][r][m]=max(dp[l][r][m-1],dp[l][r][m]);
                if (m-(s[l]!=s[r])>=0) dp[l][r][m]=max(dp[l][r][m],dp[l+1][r-1][m-(s[l]!=s[r])]+2);
            }
        }
    cout << dp[0][n-1][k] << endl;
    return 0;
}


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

const int cut = 1000000007;

int main() {
    int n, k;
    cin >> n >> k;
    int start = 0, end = 0;
    int ans = 0;
    for (int i = 1; i <= n+1; ++i) {
        start += i-1; start %= cut;
        end += n+1-i; end %= cut;

        if (i >= k) {
            ans += end - start + 1;
            if (end < start) ans += cut;
            ans %= cut;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <unordered_set>

using namespace std;

int main() {
    int N;
    long long int A;
    cin >> N;
    unordered_set<long long int> set;
    for(int i = 0; i < N; ++i) {
        cin >> A;
        auto search = set.find(A);
        if(search != set.end())
            set.erase(search);
        else
            set.insert(A);
    }
    cout << set.size() << endl;
    return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

i64 f(i64 n){
    if(n%2==0) return n/2;
    return 3*n+1;
}

void solve() {
    //const i64 mod = 1'000'000'007;


    i64 s;
    cin >> s;

    i64 a=s,m=1;
    set<i64> st;
    st.insert(a);
    while(true){
        a=f(a);
        ++m;
        if(st.find(a)!=st.end()){
            cout << m << endl;
            return;
        }
        st.insert(a);
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

struct UnionFind {
  vector<int> data;
  void init(int n) { data.assign(n, -1); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  bool same(int x, int y) { return root(x) == root(y); }
  bool unite(int x, int y) {
    x = root(x), y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y];
      data[y] = x;
    }
    return x != y;
  }
  int size(int x) { return -data[root(x)]; }
};

int main() {
  int n, m;
  cin >> n >> m;
  UnionFind uf;
  uf.init(n);
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    if (!uf.same(a, b)) {
      uf.unite(a, b);
    }
  }
  int ans = -1;
  for (int i = 0; i < n; ++i) {
    ans = max(ans, uf.size(i));
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  if(n==1){
      cout << "Hello World" << endl;
  }
  else{
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
}

Measured memory_bytes: 3560