akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;i <= 0; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x); i++)
#define rreps(i,x) for(ll i = (ll)(x)-1; i <= 1; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

int main(){
    ll n,q; cin >> n >> q;
    string s;cin >> s;
    string que, lr;
    rep(i,q){
        string a;cin >> a;
        string l;cin >> l;
        que += a; lr += l;
    }
    auto right = [&](int id){
            if(id >= n)return true;
            if(id < 0)return false;
        rep(i,q){
            if(s[id] == que[i]){
                if(lr[i] == 'R')id++;
                else id--;
            }
            if(id >= n)return true;
            if(id < 0)return false;
        }
        return false;
    };
    auto left = [&](int id){
            if(id >= n)return false;
            if(id < 0)return true;
        rep(i,q){
            if(s[id] == que[i]){
                if(lr[i] == 'R')id++;
                else id--;
            }
            if(id >= n)return false;
            if(id < 0)return true;
        }
        return false;
    };

    ll l = n, r = -1;
    ll ok = -1;
    while(abs(l - ok) > 1){
        ll id = (l + ok) / 2;
        if(left(id))ok = id;
        else l = id;
    }
    ok = n;
    while(abs(ok - r) > 1){
        ll id = (r + ok)/2;
        if(right(id))ok = id;
        else r = id;
    }

    debug(l);debug(r);
    cout << r - l + 1 << endl;

}

Measured memory_bytes: 1024
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn=2e5+5;
const int mod=1e9+7;
ll a,b,c,s;

int main()
{
    cin>>a>>b>>c;
    s=c-a-b;
    if(a>c || b>c) cout<<"No"<<endl;
    else if(4*a*b<s*s) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int a;
	int 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: 1008
N, K = map(int, input().split())
S = list(input())

           
if(S[K-1] == "A"):
  S[K-1] = "a"
elif(S[K-1] == "B"):
  S[K-1] = "b"
elif(S[K-1] == "C"):
  S[K-1] = "c"
           
"".join(S)

S_1 = S[0]
for i in range(1,N):
  S_1 = S_1 + S[i]
print(S_1)


Measured memory_bytes: 9128
import java.util.*;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int N = Integer.parseInt(in.readLine());
		int result = N * N * N;
		System.out.println(result);
	}

}


Measured memory_bytes: 22612
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

const LL INF = 1e9+1;

const int MAX_VAL = 100000;
LL dp[100][MAX_VAL+1]; //! [item][value] => min weight to achieve the value

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, W;
    cin >> N >> W;
    vector<int> w(N), v(N);
    rep(i, N) cin >> w[i] >> v[i];

    rep(j, MAX_VAL+1) {
        if (j <= v[0]) {
            dp[0][j] = w[0];
        } else {
            dp[0][j] = INF;
        }
    }
    for (int i = 1; i < N; ++i) rep(j, MAX_VAL+1) {
        if (j <= v[i]) {
            dp[i][j] = min(dp[i-1][j], (LL)w[i]);
        } else {
            dp[i][j] = min(dp[i-1][j], w[i]+dp[i-1][j-v[i]]);
        }
    }

    LL ans = 0;
    for (int j = MAX_VAL; !ans && 0 <=j; --j) {
        if (dp[N-1][j] <= W) {
            ans = j;
        }
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 78464
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        x1: i32,
        y1: i32,
        x2: i32,
        y2: i32,
    }
    let a = x2 - x1;
    let b = y2 - y1;
    println!("{} {} {} {}",
        x2-b, y2+a, x1-b, y1+a);
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
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; }
const ll MOD = 1e9+7;

class SegmentTree{
    int n;
    vector<int> vec;

    public:
    SegmentTree(vector<int> v){
        int size = v.size();
        n = 1; 
        while(n < size) n *= 2;
        vec.resize(2*n - 1, 0);

        REP(i, size) vec[n-1 + i] = v[i];
        for(int i = n-2; i >= 0; i--)
            vec[i] = vec[2*i+1] + vec[2*i+2];
    }

    void update(int i, int t){
        i += n-1;
        vec[i] = t;
        while(i > 0){
            i = (i-1)/2;
            vec[i] = vec[2*i+1] + vec[2*i+2];
        }
    }

    int sum(int a, int b, int l=0, int r=-1, int k=0){
        if(r < 0) r = n;

        if(b <= l || r <= a)
            return 0;
        if(a <= l && r <= b)
            return vec[k];

        int left = sum(a, b, l, (l+r)/2, k*2+1);
        int right = sum(a, b, (l+r)/2, r, k*2+2);
        return left + right;
    }

};

vector<int> X[30];
SegmentTree* Seg[30];

int main(){
    ll N;
    cin >> N;
    string S;
    cin >> S;

    REP(i,30)
        X[i].resize(N);
    REP(i,N){
        int x = S[i] - 'a';
        X[x][i] = 1;
    }
    REP(i,30)
        Seg[i] = new SegmentTree(X[i]);


    ll Q;
    cin >> Q;
    REP(q,Q){
        int type;
        cin >> type;
        if(type == 1){
            int i;
            char c;
            cin >> i >> c;
            i--;
            int x = c - 'a';
            int y = S[i] - 'a';
            Seg[y]->update(i, 0);
            Seg[x]->update(i, 1);
            S[i] = c;
        }
        else{
            int l, r;
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            REP(i,30){
                int s = Seg[i]->sum(l, r+1);
                if(s > 0) ans++;
            }
            cout << ans << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 184416
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
 
public class Main implements Runnable {
	
    public static void main(String[] args) {
    	new Thread(null, new Main(), "", 16 * 1024 * 1024).start();
    }
    
    public void run() {
        FastScanner sc = new FastScanner();
        
        int n = sc.nextInt();
        int[] w = sc.nextIntArray(n);
        
        int ans = Integer.MAX_VALUE;
        
        int rsum = 0;
        
        for(int i=0;i<n;i++){
        	rsum += w[i];
        }
        
        int lsum = 0;
        for(int i=0;i<n;i++){
        	lsum += w[i];
        	rsum -= w[i];
        	ans = Math.min(ans, Math.abs(lsum-rsum));
        }

        System.out.println(ans);
    }

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}
	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}
	public int[] nextIntArray(int n){
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public Integer[] nextIntegerArray(int n){
		Integer[] a = new Integer[n];
		for(int i=0;i<n;i++){
			a[i] = nextInt();
		}
		return a;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 23252
S = list(input())

D = list("abcdefghijklmnopqrstuvwxyz")

if len(S) == 26:
  cnt = 0
  L = []
  for i in range(25, -1, -1):
    Flag = True
    for j in range(cnt, 26):
      if S[i] == D[j]:
        L.append(S[i])
        cnt = j
        Flag = False
        break
    if Flag:
      L.sort()
      for k in L:
        if k > S[i]:
          S[i] = k
          break
      print("".join(S[:i + 1]))
      exit()
  print("-1")      
else:
  for i in S:
    D.remove(i)
  print("".join(S) + D[0])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long n,W;
  cin>>n>>W;
  long long w[n],v[n];
  for(long long i=0;i<n;i++){
    cin>>w[i]>>v[i];
  }
  long long k[n+1][W+1];
  for(long long i=0;i<=n;i++){
    for(long long j=0;j<=W;j++){
		if(i==0||j==0)
          k[i][j]=0;
      	else if(w[i-1]<=j)
          k[i][j]=max(k[i-1][j],k[i-1][j-w[i-1]]+v[i-1]);
        else
          k[i][j]=k[i-1][j];
    }
  }
  cout<<k[n][W]<<'\n';
}

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

ll a[200000],b[200000];
int main(){
	int n;scanf("%d",&n);
	rep(i,n)scanf("%lld",&a[i]);
	rep(i,n)scanf("%lld",&b[i]);
	deque<P>v;//みたしている
	rep(i,n){
		if(a[i]>b[i]){
			v.push_back(P(a[i]-b[i],i));
		}
	}
	sort(v.begin(),v.end(),greater<>());
	set<int>se;
	rep(i,n){
		if(a[i]<b[i]){
			se.insert(i);
			ll d=b[i]-a[i];
			while(!v.empty()&&d>0){
				if(d>=v[0].first){
					se.insert(v[0].second);
					d-=v[0].first;
					v.pop_front();
				}
				else{
					se.insert(v[0].second);
					v[0].first-=d;
					d=0;
				}
			}
			if(v.empty()){
				puts("-1");return 0;
			}
		}
	}
	cout<<se.size()<<endl;
}

Measured memory_bytes: 6144
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <time.h>
#include <random>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define LONG_INF 10000000000000000
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	long long m, n;
	cin >> m >> n;
	long long ans = 1;
	while (n != 0) {
		if (n % 2 == 1) {
			ans *= m;
			ans %= MAX_MOD;
		}
		n /= 2;
		m *= m;
		m %= MAX_MOD;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll = long long;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

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

  int ans = 1001001001;
  rep(i, 2) {
    int now = 0;
    rep(j, s.size()) {
      if ((j % 2 == 0) && ((s[j] - '0') != i)) ++now;
      if ((j % 2 == 1) && ((s[j] - '0') == i)) ++now;
    }
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3752
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
#define int long long
const int mod=1000000007;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int32_t main()
{
    speed
    string a,b;
    cin>>a>>b;
    int suma=0;
    for(int i=0;i<a.size();i++)
        if(a[i]!=b[i])
            suma++;
    cout<<suma;
    return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
    cin>>a>>b>>c;
    for(register int i=1;i<=b;i++)
    {
        if((a*i)%b==c)
			return cout<<"YES\n",0;
    }
    return cout<<"NO\n",0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var N, Y int
	fmt.Scan(&N, &Y)
	for x := 0; x <= 2000; x++ {
		for y := 0; y <= 2000; y++ {
			z := N - x - y
			// fmt.Println("x,y,z -> ", x, y, z)
			if 0 <= z && 10000*x+5000*y+1000*z == Y {
				fmt.Println(x, y, z)
				return
			}
		}
	}
	fmt.Println("-1 -1 -1")
}


Measured memory_bytes: 512
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string s[101];
int main()
{
    int n,l;
    cin>>n>>l;
    for(int i=1;i<=n;i++)
        cin>>s[i];
    sort(s,s+n+1);
    for(int i=1;i<=n;i++)
    	cout<<s[i];
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 128;
int D[N][N][N];
int main(void)
{
    int a,b,c;
    cin>>a>>b>>c;
    queue < vi > q;
    for (int i = 0;i < N;++i)
    	D[i][i][i] = 1,q.push(vi{i,i,i});
    while (!q.empty()) {
    	int x = q.front()[0];
    	int y = q.front()[1];
    	int z = q.front()[2];
    	q.pop();
  		for (int o1 = 0;o1 <= 2;++o1)
  			for (int o2 = 0;o2 <= 2;++o2)
  				for (int o3 = 0;o3 <= 2;++o3)
  					if (o1 + o2 + o3 == 2 && x >= o1 && y >= o2 && z >= o3) {
  						int nx = x - o1;
  						int ny = y - o2;
  						int nz = z - o3;
  						if (!D[nx][ny][nz])
  							D[nx][ny][nz] = D[x][y][z] + 1,q.push({nx,ny,nz});
  					}  	
    }
    cout << D[a][b][c] - 1 << '\n';
    return 0;
}

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

#define ll long long
#define sd(x) scanf("%d", &(x))
#define pii pair<int, int>
#define F first
#define S second
#define all(c) ((c).begin()), ((c).end())
#define sz(x) ((int)(x).size())
#define ld long double

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

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

#ifdef LOCAL
#define cerr cout
#else
#endif

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

int main(){
	ll n, a, b; scanf("%lld %lld %lld", &n, &a, &b);
	if( (b - a) % 2 == 0){
		printf("%lld\n", (b - a) / 2);
		return 0;
	}
	ll delta = b - a;
	ll num = min(n - b, a - 1);
	printf("%lld\n", num + 1 + delta / 2);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

int main()
{
    string S, before, after;
    cin >> S;
    before = S.substr(0, 2);
    after = S.substr(2, 2);
    int before_num, after_num;
    before_num = atoi(before.c_str());
    after_num = atoi(after.c_str());

    bool isBefore = false, isAfter = false;

    if (1 <= before_num && before_num <= 12)
    {
        isBefore = true;
    }

    if (1 <= after_num && after_num <= 12)
    {
        isAfter = true;
    }

    if (isBefore && isAfter)
    {
        cout << "AMBIGUOUS" << endl;
    }
    else if (!isBefore && isAfter)
    {
        cout << "YYMM" << endl;
    }
    else if (isBefore && !isAfter)
    {
        cout << "MMYY" << endl;
    }
    else
    {
        cout << "NA" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int maxn=1e5+10;
int a[maxn];
int cmp(const int a,const int b){
    return a>b;
}
int n,m,v,p;
int b[maxn];
bool judge(int mid){
    //printf("hello %lld\n",mid);
    if(mid<=p)return true;
    if(a[mid]+m<a[p])return false;
    if(v<=p-1&&a[mid]+m>=a[p])return true;
    for(int i=1;i<=n;i++)b[i]=a[i];
    int temp=0;
    int inx=n,cnt=v-p+1;
    //给后面的元素加值
    while(inx>mid&&cnt>1){
        temp+=m;
        inx--;
        cnt--;
        b[inx]+=m;
    }
    temp+=m*p;
    int now=a[mid]+m;
    int res=m*v-temp;
    for(int i=p;i<mid;i++){
        int add=min(m,max(now-a[i],0ll));
        if(add>res)add=res;
        res-=add;
        b[i]+=add;
    }
    return now>=b[p]&&res<=0;
}
signed main(){
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    sort(a+1,a+n+1,cmp);
    int low=1,high=n;
    int ans=0;
    while(low<=high){
        int mid=(low+high)>>1;
        if(judge(mid)){
            low=mid+1;
            ans=mid;
        }
        else{
            high=mid-1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=(max({a,b,c})*3-a-b-c)%2?(max({a,b,c})*3+3-a-b-c)/2:(max({a,b,c})*3-a-b-c)/2;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
*a, = map(int, input().split())
*b, = map(int, input().split())
*c, = map(int, input().split())
ans = 0
ans += b[a[0]-1]
for i in range(1, n):
    ans += b[a[i]-1]
    if a[i] == a[i-1] + 1:
        ans += c[a[i-1]-1]
print(ans)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
double fx[37];
double fy[37];
double diff[39][39];
int arra[59];
int main()
{
    int n,m,p,q,r,s,t,u=0,v,w,x=0,i,j;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>arra[i];
    for(i=1;i<=n;i++)
    {
        if(arra[i]!=i)
        {
            if(arra[arra[i]]==i)
            {
                u=1;
            }
            x++;
        }
    }
    if(x==0)
        cout<<"YES";
    else if(x==2)
    {
        if(u==1)
            cout<<"YES";
    }
    else
    {
        cout<<"NO";
    }




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
    
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
    
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
    
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
    
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

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

    LL tmp = A;
    REP(i, 10000) {
        if(tmp % B == C) {
            cout << "YES" << endl;
            return 0;
        }

        tmp += A;
    }

    cout << "NO" << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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 T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1e16;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int d,n;
    cin >> d >> n;
    if (d == 0){
        if (n == 100) PRINT(101);
        else PRINT(n);
    }
    else if (d == 1){
        if (n == 100) PRINT(10100);
        else PRINT(n*100);
    }
    else{
        if (n == 100) PRINT(1010000);
        else PRINT(n*10000);
    }
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-10;

int main() {
	ll x, y;
	cin >> x >> y;
	if (x <= 1 && y <= 1) puts("Brown");
	else puts(abs(x - y) <= 1 ? "Brown" : "Alice");

	return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B = MAP()

if B % A == 0:
    print(A+B)
else:
    print(B-A)


Measured memory_bytes: 6168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int[][] memo;

	public static int hoge(int current, int n, String last) {
		return 0;
	}

	public static void main(String[] args) throws IOException {
		BufferedReader bf = null;
		bf = new BufferedReader(new InputStreamReader(System.in));
		int ans = 0,k = 0,temp = 10;
		int[] a = new int[5],b = new int[5];
		String str;
		str = bf.readLine();
		a[0] = Integer.parseInt(str);
		str = bf.readLine();
		a[1] = Integer.parseInt(str);
		str = bf.readLine();
		a[2] = Integer.parseInt(str);
		str = bf.readLine();
		a[3] = Integer.parseInt(str);
		str = bf.readLine();
		a[4] = Integer.parseInt(str);
		for(int i = 0;i < 5;++i) {
			b[i] = a[i]%10;
			if(b[i] < temp && b[i] != 0) {
				temp = b[i];
				k = i;
			}
			a[i] /= 10;
		}
		for(int i = 0;i < 5;++i) {
			if(k == i) {
				continue;
			}
			if(b[i] == 0) {
				ans += a[i]*10;
			} else {
				ans += (a[i]+1)*10;
			}
		}
		ans += a[k]*10 + b[k];
		System.out.println(ans);
	}
}

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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int r,c;
    scanf("%d %d",&r,&c);
    int sheet[r+1][c+1];
    for(int i=0;i<r;i++){
        for(int j=0;j<c;j++){
            scanf("%d",&sheet[i][j]);
        }
    }
    for(int i=0;i<r;i++){
        sheet[i][c]=0;
        for(int j=0;j<c;j++){
            sheet[i][c]+=sheet[i][j];
        }
    }
    for(int i=0;i<c+1;i++){
        sheet[r][i]=0;
        for(int j=0;j<r;j++){
            sheet[r][i]+=sheet[j][i];
        }
    }
    for(int i=0;i<r+1;i++){
        for(int j=0;j<c+1;j++){
            if(j<c){
                printf("%d ",sheet[i][j]);
            }else{
                printf("%d\n",sheet[i][j]);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1212
# coding: utf-8

import statistics

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

for i,num in enumerate(a):
    a[i] = a[i] - (i + 1)

b = int(statistics.median(a))

res = 0
for i in a:
    res += abs(i - b)

print(res)


Measured memory_bytes: 27236
x = []
s = ['','']
while True:
    h, w = map(int, raw_input().split())
    if h == 0 and w== 0: break
    tmp = (w+1)/2
    s[0] = ('#.' * tmp)[:w]
    s[1] = ('.#' * tmp)[:w]
    for j in range(h):
        print s[j % 2]
    print
    

Measured memory_bytes: 4224
#include <bits/stdc++.h>
#include <time.h>
#define int long long int
#define pb push_back
#define all(a) a.begin(), a.end()
#define scnarr(a, n) for (int i = 0; i < n; ++i) cin >> a[i]
#define vi vector<int>
#define si set<int>
#define pii pair <int, int>
#define sii set<pii>
#define vii vector<pii>
#define mii map <int, int>
#define faster ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace chrono;
/* -------------------------------Solution Sarted--------------------------------------*/
//Constants
const int MOD = 1000000007; // 1e9 + 7
const int MAXN = 1000005; // 1e6 +5

void solve(){
	int n, k;
	cin >> n >> k;
	vi a(n), pos, neg;
	scnarr(a, n);
	
	for(int i = 0; i < n; ++i){
		a[i] < 0 ? neg.push_back(a[i]) : pos.push_back(a[i]);
	}
	
	if(k == n){
		int ans = 1;
		
		for(int i = 0; i < k; ++i)
			ans = ((ans * a[i] % MOD) + MOD) % MOD;

		cout << ans << endl;
		return;
	}

	if(k&1 and pos.size() == 0){
		int ans = 1;
		sort(all(neg), greater<int>());
		for(int i = 0; i < k; ++i)
			ans = ((ans * neg[i] % MOD) + MOD) % MOD;

		cout << ans << endl;
		return;
	}

	if(pos.size() == 0){
		int ans = 1;
		sort(all(neg));
		for(int i = 0; i < k; ++i)
			ans = ans * neg[i] % MOD;

		cout << ans << endl;
		return;
	}

	if(neg.size() == 0){
		int ans = 1;
		sort(all(pos), greater<int>());
		for(int i = 0; i < k; ++i)
			ans = ans * pos[i] % MOD;

		cout << ans << endl;
		return;
	}

	sort(all(neg));
	sort(all(pos), greater<int>());

	int i = 0, j = 0, cnt = 0, ans = 1;

	if(k&1){
		ans = ans * pos[i++] % MOD;
		cnt++;
	}

	while(cnt < k){
		if(k - cnt == 1){
			ans = ans * pos[i] % MOD;
			break;
		}

		if(i != pos.size() -1 and j != neg.size() -1){
			if(pos[i]*pos[i +1] > neg[j]*neg[j +1]){
				ans = ans * pos[i] % MOD;
				ans = ans * pos[i +1] % MOD;
				i += 2;
			}else{
				ans = ans * (neg[j] * neg[j +1] % MOD) % MOD;
				j += 2;
			}
			cnt += 2;
		}else if(j == neg.size() -1){
			ans = ans * pos[i] % MOD;
			ans = ans * pos[i +1] % MOD;
			i += 2;
			cnt += 2;
		}else{
			ans = ans * (neg[j] * neg[j +1] % MOD) % MOD;
			j += 2;
			cnt += 2;
		}

	}

	cout << ans << endl;


}

signed main()
{
	faster;
#ifndef ONLINE_JUDGE
	freopen("ip.txt", "r", stdin);
	freopen("op.txt", "w", stdout);
#endif
	// int t; cin >> t; while(t--)
		solve();
	return 0;
}


//Author : Ankit Raj
//Problem Link :

/*Snippets*/
/*
sieve - prime factorization using sieve and primes in range
zpower - pow with mod
plate - Initial template
bfs 
dfs
fenwik - BIT
binary_search
segment_tree
*/
	

Measured memory_bytes: 6944
#include <bits/stdc++.h>
#define int long long
#define mod (int)1e9+7
#define inf (int)(3e18)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define PP pair<P,P>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;
template<class T> inline void chmax(T& a, T b) { a = max(a, b); }
template<class T> inline void chmin(T& a, T b) { a = min(a, b); }

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
int get_rand(int MIN, int MAX) {
	random_device rnd;
	mt19937_64 mt64(rnd());
	uniform_int_distribution<int>engine(MIN, MAX);
	return engine(mt64);
}
/*--------Library Zone!--------*/


signed main() {
	int n; cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; i++) {
		int j = i, cnt = 0;
		while (j) {
			j /= 10;
			cnt++;
		}
		if (cnt % 2)ans++;
	}
	cout << ans << endl;
}


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


using namespace std;

#define fastio() ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()
#define print_vec(vec) for(int i=0;i<sz(vec);i++) cout << vec[i] << " ";
#define FORin(vec) for(int& x : vec) cin>>x;

void go(){
	int n;cin>>n;
	int INF=1e9;
	vector<int> h(n); FORin(h);
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++) {
		for(int j : {i+1,i+2}) {
			if(j<n) {
				dp[j]=min(dp[j],dp[i] + abs(h[i]-h[j]));
			}
		}
	}
	cout << dp[n-1];
			
}
int main(){
   
   fastio();
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}




Measured memory_bytes: 3956
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()

int main() {
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  REP(i, n) cin >> a[i] >> b[i];
  vector<ll> dp(2 * 1e4 + 1, 1e9 + 1);
  dp[0] = 0;
  REP(i, n) {
    REP(j, dp.size()) {
      if (j + a[i] < dp.size()) {
        dp[j + a[i]] = min(dp[j + a[i]], dp[j] + b[i]);
      }
    }
  }
  ll ans = 1e9 + 1;
  for (int i = h; i < dp.size(); ++i) ans = min(ans, dp[i]);
  cout << ans << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    int n,m; cin >> n >> m;
    vector<int> a(n),b(n);
    vector<int> c(m),d(m);
    rep(i,n) cin >> a[i] >> b[i];
    rep(i,m) cin >> c[i] >> d[i];

    rep(i,n){
        ll min = 1000000000;
        ll dis;
        ll ans;
        rep(j,m){
            dis = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if(min > dis){
                min = dis;
                ans = j;
            }
        }
        cout << ans+1 << endl;
    }
}

Measured memory_bytes: 256
/*
	EDPC[A] カエル問題
	https://qiita.com/drken/items/dc53c683d6de8aeacf5a
	https://atcoder.jp/contests/dp/tasks/dp_a
*/

#include <bits/stdc++.h>
using namespace std;

#define N_MAX 100010

int main() {
	
	int N;
	int h[N_MAX];
	
	cin >> N;
	for(int i=0; i<N; i++) cin >> h[i];
	
	int dp[N_MAX];
	dp[0] = 0;
	for(int i=0; i<N-1; i++){
		if(i == 0) dp[i+1] = dp[i] + abs(h[i+1] - h[i]);
		else dp[i+1] = min(dp[i] + abs(h[i+1] - h[i]), dp[i-1] + abs(h[i+1] - h[i-1]));
		//printf("dp[%d] = %d\n", i+1, dp[i+1]);
	}
	
	cout << dp[N-1] << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

typedef struct {
	vector <int> to;
	int cost;
	bool is_visited;
} edge;
int main( void ){
	ll H,W; cin >> H >>W;
	if (min(H, W) == 1)
		cout << 1<< endl;
	else
		cout << (H*W+1)/2 << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <assert.h>
#include <math.h>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long;
constexpr int inf = 1e9 + 7;
constexpr ll longinf = 1LL << 60;
constexpr ll mod = 1e9 + 7;

string res;

int counter;

int query(string& s) {
  ++counter;
  cout << "? " << s << endl;
  int ret;
  cin >> ret;
  return ret;
}

const int m = 62;
int cnt[62][200], n;
string ans, cha;

void solve(int l, int r) {
  if (l + 1 == r) {
    rep(i, m) if (cnt[i][r] != cnt[i][l]) {
      ans[l] = cha[i];
      return;
    }
  }
  int mid = (l + r) / 2;
  int sum = 0, num = 0;
  vector<int> c(m);
  int j = -1;
  vector<int> rem;
  REP(i, 0, m) {
    if (cnt[i][l] == cnt[i][r]) {
      cnt[i][mid] = cnt[i][l];
      sum -= cnt[i][l];
      j = i;
    } else
      rem.push_back(i);
  }
  if (j == -1) {
    for (auto i : rem) {
      if (i == 25) continue;
      string s(n, 'z');
      REP(k, 0, mid) s[k] = cha[i];
      c[i] = query(s) - n + cnt[25][n];
      sum += c[i];
      num++;
    }
    assert((mid + sum) % (num + 1) == 0);
    int ret = (mid + sum) / (num + 1);
    cnt[25][mid] = cnt[25][0] + ret;
    REP(i, 0, m) {
      if (i == 25 || cnt[i][l] == cnt[i][r]) {
        continue;
      }
      cnt[i][mid] = cnt[i][0] - c[i] + ret;
    }
  } else {
    sum += cnt[j][l];
    for (auto i : rem) {
      if (i == rem.back()) {
        c[i] = (rem.size() + 1) * cnt[j][mid] - sum - mid;
        continue;
      }
      string s(n, cha[j]);
      REP(k, 0, mid) s[k] = cha[i];
      c[i] = query(s) - n + cnt[j][n];
      sum += c[i];
    }
    for (auto i : rem) {
      cnt[i][mid] = cnt[i][0] - c[i] + cnt[j][mid];
    }
  }
  solve(l, mid);
  solve(mid, r);
}

// Judge's code but changing 'a' to 'z'.
// I suspect the judge's solution is wrong.
int main() {
  rep(i, 26) cha += 'a' + i;
  rep(i, 26) cha += 'A' + i;
  rep(i, 10) cha += '0' + i;
  vector<int> c(m);
  rep(i, m) {
    string s(128, cha[i]);
    c[i] = query(s);
    n += 128 - c[i];
  }
  rep(i, m) cnt[i][n] = 128 - c[i];
  ans.resize(n, '-');
  solve(0, n);
  if (counter > 761) {
    cout << 3 << endl;
  }
  cout << "! " << ans << endl;
}

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

inline bool is_prime(int x){
  for(int j=2;j*j<=x;j++){
    if(x%j==0){
      return false;
    }
  }
  return x != 1;

}

int main(){
	int num;
  cin >> num;
  int input=0;
  int solve=0;
	for(int i=0;i<num;i++){
    cin >> input;
    if(is_prime(input))
      solve++;
  }
	cout << solve << endl;
	return 0;
}

Measured memory_bytes: 3104
#include<iostream>
#include<string>
#include<string.h>
#include<map>
#include<set> 
#include<vector>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue> 
using namespace std;
int main() 
{int n,x,ans=0;
 cin>>n>>x;
 int m[n]; 
 for (int i=0;i<n;i++){
 cin>>m[i];
 x-=m[i];}
 sort (m,m+n);
 cout<<n+x/m[0];
 system("pause");
 return 0;
}        


Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn=1e6+10;
#define p 1000000007
int main(){
	fast;
	ll n,s=0,ans=0; cin>>n;
	vector<ll> arr(n);
	for(auto &it:arr){
		cin>>it;
		s+=it;  
	}
	for(auto i=n-1;i>=0;--i){
		s-=arr[i];
		ans+=(s%p*arr[i])%p;
		ans%=p;
	}
	cout<<ans<<'\n';
	return 0;
}
//prime func
//subset production
//factorization
//modpow
//modinv ( a^(p-2)=a^(-1) (mod p) )
//sieve
//ncr
//euler totien func (co prime divisiors upto n)
//matrix exponentation
//dsu
//Trees
//Graphs(dfs,bfs,shortes path etc.)
//DP-Recursion

Measured memory_bytes: 4756
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args) 
	{
		@SuppressWarnings("resource")
		Scanner sc = new Scanner(System.in);
		
		int no		=	sc.nextInt();
		
		for(int i= 1; i < 10; i++)
		{
			if(no%i == 0 && no/i < 10)
			{
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
	}
}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define rep(i,N) for(int i=1;i<N;i+=1)
using namespace std;
int main() {
  int A;
  cin>>A;
  bool ans=true;
  rep(i,10) rep(j,10) if(A==i*j) {
  ans=false;
  }
  if(ans==false)
  cout<<"Yes"<<endl;
  if(ans)
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define VI vector<int>
#define VL vector<lint>
#define VC vector<char>
#define VVI vector<vector<int>>
#define rep(i, n) for(int i = 0 ; i < n ; i++)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c.begin(), c.end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

int n;
VI a;

bool solve(int i, int m){
    if(m == 0){
        return true;
    }
    if(i >= n){
        return false;
    }
    return solve(i + 1, m) || solve(i + 1, m - a[i]);
}

int main(){
    cin >> n;
    a.resize(n);
    rep(i, n){
        cin >> a[i];
    }
    int q;
    cin >> q;
    rep(i, q){
        int m;
        cin >> m;
        if(solve(0, m)){
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
import java.util.Scanner;

public class Main {
	static int island[][] = new int[12][12];

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		boolean start = true;
		while (start) {
			// 島を配列islandで定義
			// 1か0を入力し島を形成
			for (int length = 0; length < 12; length++) {
				String line = scanner.nextLine();
				for (int side = 0; side < 12; side++) {
					char area = line.charAt(side);
					island[length][side] = Character.getNumericValue(area);
				}
			}

			// 島の数islandの宣言、初期化
			int islandcount = 0;
			// 島を見つける
			for (int length = 0; length < 12; length++) {
				for (int side = 0; side < 12; side++) {
					if (island[length][side] == 1) {
						islandcount++;
						islandnumber(length, side);
						island[length][side] = -1;
					}
				}
			}
			System.out.println(islandcount);
			if (scanner.hasNext()) {
				String space = scanner.nextLine();
			} else {
				start = false;
			}
		}
	}

	static void islandnumber(int a, int b) {
		island[a][b] = -5;
		if (a != island.length - 1 && island[a + 1][b] == 1) {
			islandnumber(a + 1, b);
		}
		if (a != 0 && island[a - 1][b] == 1) {
			islandnumber(a - 1, b);
		}
		if (b != island.length - 1 && island[a][b + 1] == 1) {
			islandnumber(a, b + 1);
		}
		if (b != 0 && island[a][b - 1] == 1) {
			islandnumber(a, b - 1);
		}
	}
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	map<string,int> m;
	for(int i=0;i<n;i++)
	{
	    string s;
	    cin>>s;
	    m[s]+=1;
	}
	map<string,int>::iterator p=m.begin();
	int max=0;
	while(p!=m.end())
	{
	    if(p->second > max)
	    max=p->second;
	    p++;
	}
	p=m.begin();
	while(p!=m.end())
	{
	    if(p->second == max)
	    cout<<p->first<<endl;
	    p++;
	}
	return 0;
}


Measured memory_bytes: 25216
#from collections import deque,defaultdict
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7
#R = 998244353

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
sm = 0
for i in range(n):
    if i%2==0 and a[i]%2>0:
        sm += 1
print(sm)


Measured memory_bytes: 61764
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  ll N,A,B;
  cin >> N >> A >> B;
  if (A > N || B > N) {
    cout << -1 << endl;
    return 0;
  }
  if ((B - 1) * A >= (N - A) && (B - 1) <= (N - A)) {
    int sum = N;
    for (int i = 0; i < A; i++) {
      cout << N - ((A - 1) - i) << " ";
    }
    sum -= A;
    for (int i = 0; i < B-1; i++) {
      int s = (N - A) / (B - 1);
      if (i < (N-A) % (B-1)) s++;
      for (int j = 0; j < s; j++) {
        cout << sum - (s - j) + 1 << " ";
      }
      sum -= s;
    }
    cout << endl;
  } else if ((A - 1) * B >= (N - B) && (A - 1) <= (N - B)) {
    int sum = 0;
    for (int i = 0; i < B; i++) {
      cout << B - i << " ";
    }
    sum += B;
    for (int i = 0; i < A-1; i++) {
      int s = (N - B) / (A - 1);
      if (i < (N-B) % (A-1)) s++;
      for (int j = 0; j < s; j++) {
        cout << sum + (s - j) << " ";
      }
      sum += s;
    }
    cout << endl;
  } else {
    cout << -1 << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) (v).begin(), (v).end()



int main() {
	ll D, G, p[11], c[11];
	cin >> D >> G;
	rep(i, D) cin >> p[i] >> c[i];

	ll ans = INF;
	rep(mask, 1 << D) {
		ll s = 0, num = 0, rest_max = -1;
		rep(i, D) {
			if (mask >> i & 1) {
				s += 100 * (i + 1) * p[i] + c[i];
				num += p[i];
			}
			else rest_max = i;
		}
		if (s < G) {
			ll s1 = 100 * (rest_max + 1);
			ll need = (G - s + s1 - 1) / s1;
			if (need >= p[rest_max]) continue;
			num += need;
		}
		ans = min(ans, num);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256