akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define fr(i, n) for (int i = 0; i < n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define pb push_back

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e15 + 10;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-9;

const int N = 2e5 + 10;
const int M = 1e3 + 10;

ll a[N];

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    ll x, y;
    cin >> x >> y;
    if (abs(x - y) <= 1)
        cout << "Brown";
    else
        cout << "Alice";
}


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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


signed main(){

	int Q,H,S,D;
	cin >> Q >> H >> S >> D;
	int N;
	cin >> N;

	vector<vector<int>> v;
	v.push_back(vector < int > {1, Q, Q * 8});
	v.push_back(vector < int > {2, H, H * 4});
	v.push_back(vector < int > {4, S, S * 2});
	v.push_back(vector < int > {8, D, D});

	sort(v.begin(), v.end(), 
		[](const vector<int>& a, const vector<int>& b){return (a[2] < b[2]); });

	N *= 4;
	int ans = 0;
	ans += (N / v[0][0]) * v[0][1];
	N %= v[0][0];
	ans += (N / v[1][0]) * v[1][1];

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lowbit(a) ((a) & -(a))
#define clean(a, b) memset(a, b, sizeof(a))
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int maxn = 2e5 + 9;

int _;

//========================================================================
int a[maxn],vis[maxn],b[maxn];
//========================================================================
int main()
{
    int n;
    ll k;
    scanf("%d%lld",&n,&k);
    k++;
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&a[i]);
    }
    int pos=1,flag=0,x,y,ans_;
    vis[1]=1;
    b[1]=1;
    for(int i=2;i<=n+1;i++)
    {
        pos=a[pos];
        b[i]=pos;
        // printf("%d %d\n",b[i],vis[pos]);
        if(vis[pos])
        {
            flag=1;
            x=vis[pos]-1;
            y=i-vis[pos];
            // printf("x=%d y=%d\n",x,y);
            break;
        }
        vis[pos]=i;
    }
    if(k>=(x+y))
    {
        int ans=(k-x)%y;
        if(ans==0) ans=b[y+x];
        else ans=b[ans+x];
        printf("%d\n",ans);
    }
    else 
    {
        printf("%d\n",b[k]);
    }
    return 0;
}
/*
6 5
3 6 5 4 2 1
*/


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


int main() {
  char a, b, c, d, e, f, g, h ,i;
  cin >> a >> b >> c >> d >> e >> f >> g >> h >> i;
  cout << a << e << i;
  return 0;
}




Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int group1[7] = { 1, 3, 5, 7, 8, 10 ,12 };
int group2[4] = { 4, 6, 9, 11 };
int group3 = 2;

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

	int x, y; cin >> x >> y;
	int X, Y;
	rep(i, 7) if (group1[i] == x) X = 1;
	rep(i, 7) if (group1[i] == y) Y = 1;
	rep(i, 4) if (group2[i] == x) X = 2;
	rep(i, 4) if (group2[i] == y) Y = 2;
	if (group3 == x) X = 3;
	if (group3 == y) Y = 3;
	if (X == Y) cout << "Yes" << endl;
	else cout << "No" << endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <deque>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <iomanip>
#include <map>
#include <stack>
#include <queue>
#include <functional>
#include <climits>
#include <numeric>
#include <bitset>
#include <random>
#include <tuple>
#include <initializer_list>
#include <fstream>
#include <cctype>
#include <string>

int main() {
	int a, p; std::cin >> a >> p;
	std::cout << ((a * 3 + p) >> 1) << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 1000000007
#define tp tuple<ll,ll,ll>

int main() {
	ll N, M, V, P;
	cin >> N >> M >> V >> P;
	vector<ll> A(N);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	sort(all(A));
	reverse(all(A));
	
	ll ok = P - 1, ng = N, mid, v, p;

	ll ans;
	while (ok + 1 != ng) {
		ans = 0;
		mid = (ng + ok) / 2;
		v = N - mid;//自分より後ろ
		p = V - v - (P - 1);
		if (p <= 0) {
			if (A[P - 1] <= A[mid] + M) {
				ok = mid;
			}
			else {
				ng = mid;
			}
			continue;
		}
		for (int i = P - 1;i < mid;i++) {
			ans += A[i] - A[mid];
		}
		//cout << ans << " " << p << endl;

		
		if (max((ans - 1) / (N - V) + 1, A[P - 1] - A[mid]) > M) {
			ng = mid;
		}
		else {
			ok = mid;
		}
	}
	ans = N;
	for (int i = 0;i < N;i++) {
		if (A[i] < A[ok]) {
			ans = i;break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int Q = sc.nextInt();
		String S = sc.next();
		int[] l = new int[Q + 1];
		int[] r = new int[Q + 1];
		for (int i = 1; i <= Q; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		int[] a = new int[N];

		for (int i = 0; i < N - 1; i++) {
			a[i + 1] = a[i];
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				a[i + 1]++;
			}
		}
		for (int i = 1; i <= Q; i++)
			System.out.println(a[r[i] - 1] - a[l[i] - 1]);

	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
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 double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 43212
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;
LL n,s;

inline bool f(LL b,LL n) {
    LL res=0;
    while (n>=b) {
        res+=n%b;
        n/=b;
    }
    if (b>n) res+=n;
    return res==s;
}
int main() {
    while (~scanf("%lld%lld",&n,&s)) {
        if (s==n) {
            printf("%lld\n", n+1);
            continue;
        }
        if (s>n) {
            puts("-1");
            continue;
        }
        LL t=sqrt(n)+1;
        bool flag=false;
        // b<=sqrt(n)
        for (LL i=2;i<=t;i++)
            if (f(i,n)) {
                printf("%lld\n", i);
                flag=true;
                break;
            }
        if (flag) continue;

        // b>sqrt(n) b进制下只有两位
        // n=pb+q  s=p+q
        // n-s=p(b-1) => b=(n-s)/p+1
        LL ans=1e12;
        for (LL p=1;p*p<=n-s;p++) {
            if ((n-s)%p==0) {
                LL b=(n-s)/p+1;
                if (f(b,n)) {
                    flag=true;
                    ans=min(ans,b);
                }
            }
        }
        if (!flag) puts("-1");
        else printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 128
A, B = list(map(int, input().split(' '))) 
 
res = -1
# 最大で1009円まで
for i in range(1, 1010):
  q_A = int(i * 0.08)
  q_B = int(i * 0.1)
  if q_A == A and q_B == B:
    res = i
    break
  else:
    continue
 
print(res)

Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<queue>
#include <string.h>
#include <algorithm>

using namespace std;

int main(){
  int N;cin>>N;
  string X[N], Y[N];
  for (int i=0;i < N; i++) {
    cin>>X[i];cin>>Y[i];
  }
  for (int i=0;i < N; i++) {
    string x_t=X[i];int x_len=x_t.length();
    string y_t=Y[i];int y_len=y_t.length();
    int dp[x_len+1][y_len+1];
    memset(dp,0,sizeof(dp));
    for (int x = 0; x <= x_len; x++)dp[x][0]=0;
    for (int y = 0; y <= y_len ; y++)dp[0][y]=0;
    for (int x=1;x<=x_len;x++){
      for (int y=1;y<=y_len;y++){
        if(x_t[x-1]==y_t[y-1]){
          dp[x][y]=dp[x-1][y-1]+1;
        }else{
          dp[x][y]=max(dp[x][y-1],dp[x-1][y]);
        }
      }
    }
    cout<< dp[x_len][y_len] << "\n";
  }

}


Measured memory_bytes: 7132
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

template<class Monoid, class Action> struct StarrySky {
    const Monoid INF;
    const Action ZERO;
    int SIZE;
    vector<pair<Monoid, int> > dat;
    vector<Action> lazy;
    
    StarrySky(int n, const Monoid &inf, const Action &zero) : INF(inf), ZERO(zero) {
        init(n);
    }
    void init(int n) {
        SIZE = 1;
        while (SIZE < n) SIZE <<= 1;
        dat.assign(SIZE * 2, {INF, -1});
        lazy.assign(SIZE * 2, ZERO);
    }
    
    /* set, a is 0-indexed */
    void set(int a, const Monoid &v) { dat[a + SIZE] = {v, a}; }
    void build() {
        for (int k = SIZE - 1; k > 0; --k)
            dat[k] = min(dat[k*2], dat[k*2+1]);
    }
    
    /* update [a, b) */
    inline void evaluate(int k) {
        if (lazy[k] == ZERO) return;
        if (k < SIZE) lazy[k*2] += lazy[k], lazy[k*2+1] += lazy[k];
        dat[k].first += lazy[k];
        lazy[k] = ZERO;
    }
    inline void update(int a, int b, const Action &v, int k, int l, int r) {
        evaluate(k);
        if (a <= l && r <= b) lazy[k] += v, evaluate(k);
        else if (a < r && l < b) {
            update(a, b, v, k*2, l, (l+r)>>1), update(a, b, v, k*2+1, (l+r)>>1, r);
            dat[k] = min(dat[k*2], dat[k*2+1]);
        }
    }
    inline void update(int a, int b, const Action &v) { update(a, b, v, 1, 0, SIZE); }
    
    /* get [a, b) */
    inline pair<Monoid,int> get(int a, int b, int k, int l, int r) {
        evaluate(k);
        if (a <= l && r <= b)
            return dat[k];
        else if (a < r && l < b)
            return min(get(a, b, k*2, l, (l+r)>>1), get(a, b, k*2+1, (l+r)>>1, r));
        else
            return {INF, -1};
    }
    inline pair<Monoid,int> get(int a, int b) { return get(a, b, 1, 0, SIZE); }
    inline Monoid operator [] (int a) { return get(a, a+1).first; }
    
    /* debug */
    void print() {
        for (int i = 0; i < SIZE; ++i) { cout << (*this)[i]; if (i != SIZE) cout << ","; }
        cout << endl;
    }
};

int main() {
  ll n,x;cin >>n>> x;
  vector<ll> a(n);
  StarrySky<long long, long long> sk(2*n, (1LL<<60), 0);

  for(int i = 0; i < n; ++i){
    cin >>a[i];
    sk.set(i, a[i]);
    sk.set(i+n,a[i]);
  }
  sk.build();

  ll ans = INF;
  for(int i = 0; i < n; ++i){
    ll tmp = i* x;
    for(int j = 0; j < n; ++j){
         ll b = sk.get(j+n-i, j+n+1).first ;
         tmp+=b;
    }
    ans  = min(ans, tmp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	int N,M;
	cin>>N>>M;
	int ans = 0;
	if(M%N==0) cout << M/N << endl;
	else{
		for(int i=1; i<=M/N; i++){
			if(M%i==0) ans = i; 
		}
		cout << ans << endl;
	}
}

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

#define FOR(idx, begin, end) for(int idx = (int)(begin); idx < (int)(end); ++idx)

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
typedef long long lint;

const int MOD = 1000000007, INF = 1111111111;
const double EPS = 1e-9;

template <class T>
class CuSum {
private:
	vector<T> cusum;

public:
	CuSum(vector<T> const &vec) : cusum(vec.size() + 1) { for (int i = 0; i < (int)(vec.size()); i++) cusum[i + 1] = cusum[i] + vec[i]; }
	CuSum(int N) : cusum(N + 1) {}

	void add(int i, T x) { cusum[i + 1] += x; }
	void init() { for (int i = 0; i < (int)(cusum.size()) - 1; i++) cusum[i + 1] += cusum[i]; }

	T query(int l, int r /*[l, r) */) { return cusum[r] - cusum[l]; }
};

int main() {

	cin.tie(0);

	int N;
	string S;
	cin >> N >> S;

	CuSum<int> cul(N);
	
	for (int i = 0; i < N; i++) {

		if (S[i] == '#') cul.add(i,1);

	}
	cul.init();

	int ans = INF, changes;
	for (int i = 0; i < N; i++) {

		changes = cul.query(0, i) + (N - 1 - i - cul.query(i + 1, N));
		ans = min(ans, changes);
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define all(obj) (obj).begin(), (obj).end()
static const int dx[4] = {0, 1, 0, -1};
static const int dy[4] = {1, 0, -1, 0};
static const char dir[4] = {'u', 'r', 'd', 'l'};
static const ll INF = 1ll << 60;
static const ll MOD = 1e9 + 7;

signed main() {
  ll n, sum = 0;
  cin >> n;
  for (auto i = 0; i <= n; ++i) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    sum += i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3632
def lcm(a, b):
    old_old_a = a
    old_old_b = b
    while b != 0:
        old_a = a
        a = b
        old_b = b
        b = old_a % b
    g = old_b
    return old_old_a / g * old_old_b


a, b = map(int, input().split())
print(int(lcm(a, b)))


Measured memory_bytes: 38384
n,m=list(map(int,input().split()))
val=[[] for i in range(8)]
for i in range(n):
        x,y,z=list(map(int,input().split()))
        val[0].append(x+y+z)
        val[1].append(-x+y+z)
        val[2].append(x-y+z)
        val[3].append(x+y-z)
        val[4].append(-x-y+z)
        val[5].append(-x+y-z)
        val[6].append(x-y-z)
        val[7].append(-x-y-z)
for i in range(8):
    val[i].sort()
    val[i].reverse()
ans=0
for i in range(8):
    abs_sum=0
    for j in range(m):
        abs_sum+=val[i][j]
    ans=max(ans,abs_sum)
print(ans)


Measured memory_bytes: 3432
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for(int i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VII;   // VII a(n,vector<int>(m)) n * m 
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;   //MP a;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
template <class T>  // chmax(max, a);
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> //chmin(min,a)
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}
template<typename T>
bool all_same(vector<T> v1,vector<T> v2)
{
    sort(ALL(v1));
    sort(ALL(v2),greater<T>());
    return v1 == v2;
}

// g++ -std=c++11 prac.cpp
ll Max=-1e9,Min=1e9+1;


int main(){
    ll a,b,n,m,l,w,sum=0,sum2=0,ans=0;
    string s,t;
    bool f=false;
    cin >> n >> m; 
    VL p(100000),y(100000);
    vector<int> x[100001];
    rep(i,m){
        cin >> p[i] >> y[i];
        x[p[i]].push_back(y[i]);
    }
    rep(i,n){
        sort(x[i+1].begin(), x[i+1].end());
    }
    rep(i,m){
        cout << setw(12) << setfill('0') << 
        to_string(p[i]*1000000  +  lower_bound(x[p[i]].begin(), x[p[i]].end(),y[i])  -  x[p[i]].begin()+1) 
        << endl;
    }
   
    return 0;
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pi (3.141592653589)
#define endl ("\n")
using namespace std;


int main() {
  ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<ll>vec;
    ll x=a*d;
    vec.push_back(x);
    ll y=a*c;
    vec.push_back(y);
    ll w=b*d;
    vec.push_back(w);
    ll z=b*c;
    vec.push_back(z);
ll ans=*max_element(vec.begin(),vec.end());
cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 3664
N,M = map(int, input().split())
linked = [[False] * N for _ in range(N)]
edges = []
for i in range(M):
    a, b = map(int, input().split())
    edges.append((a-1, b-1))
    linked[a-1][b-1] = linked[b-1][a-1] = True

def reach(s, g, visited):
    for i in range(N):
        if not linked[s][i]:
            continue
        if i == g:
            return True
        if i not in visited:
            if reach(i, g, visited | {i}):
                return True
    return False

cnt = 0
for i in range(M):
    a, b = edges[i]
    linked[a][b] = linked[b][a] = False
    if not reach(a, b, {a}):
        cnt += 1
    linked[a][b] = linked[b][a] = True
print(cnt)


Measured memory_bytes: 45404
#include<iostream>
#include<string.h>
#include<cmath>
short num[120];
long long int arr[120];
using namespace std;
int k;
inline long long qmi(long long int a,long long int b)
{
    if(a==1)
        return 1;
    int an = a;
    for (int i = 1; i < b;i++)
    {
        if(an>=k)
            return -1;
        else
            an = an * a;
    }
    return an;
}

int main()
{   
    string s;
    //int k;
    cin >> s;
    cin >> k;
    int l = s.length();
    int ans;
    for (int i = 0; i < l;i++)
    {
        num[i] = s[i] - '0';
        arr[i] = qmi(num[i],5000000000000000);
        if(arr[i]==-1)
        {
            ans = num[i];
            break;
        }
        if(arr[i]<k&&arr[i]>0)
            k = k - arr[i];
        else {
            ans = num[i];
            break;
        }

    }
    
        cout << ans;
        //system("pause");
    return 0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  
  int near = 1e5;
  rep(i, 0, s.size()-2) {
    string ss;
    ss += s.at(i);
    ss += s.at(i+1);
    ss += s.at(i+2);
    istringstream sss;
    int p = 0;
    sss = istringstream(ss);
    sss >> p;
    near = min(abs(753 -p), near);
  }
  
  cout << near << "\n";

}


Measured memory_bytes: 256
import javax.xml.crypto.Data;
import java.util.*;
import java.io.*;

public class Main {
    public static int SENTINEL = 100000007;
    public static int MAX = 10007;
    public static int NIL = -1;

    public static int[] dp = new int[100];


    public static void main(String[] args) throws IOException {

        //??\???
        /*
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] str = br.readLine().split(" ");
        */
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] r = new int[n];
        int[] c = new int[n];
        for(int i = 0; i < n; i++) {
            r[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        int[][] m = new int[n][n];
        for(int i = 0; i < n; i++) m[i][i] = 0;
        for(int l = 2; l < n + 1; l++) {
            for(int i = 0; i < n - l + 1; i++) {
                int j = i + l - 1;
                m[i][j] = 10000007;
                for(int k = i; k < j; k++) {
                    m[i][j] = Math.min(m[i][j], m[i][k] + m[k + 1][j] + r[i] * c[k] * c[j]);
                }
            }
        }
        System.out.println(m[0][n - 1]);
    }

    public static int solve(String X, String Y) {
        int m = X.length();
        int n = Y.length();
        int[][] dp = new int[m + 1][n + 1];
        for(int i = 0; i < m + 1; i++) dp[i][0] = 0;
        for(int j = 0; j < n + 1; j++) dp[0][j] = 0;
        for(int i = 1; i < m + 1; i++) {
            for(int j = 1; j < n + 1; j++) {
                if(X.charAt(i - 1) == Y.charAt(j - 1)) dp[i][j] = dp[i - 1][j - 1] + 1;
                else dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]);
            }
        }
        return dp[m][n];
    }
}

Measured memory_bytes: 26580
#include <bits/stdc++.h>
using namespace std;
#define int long long 
signed main() {
  int n,wt ;cin >> n>> wt;
  vector<int>w(n),v(n) ;
  for(int i=0;i<n;i++)
    cin >> w[i] >> v[i] ;
  vector<vector<int>>dp(n,vector<int>((int)1e5+1));
  // dp[i][j]->after processing first i wts. and having a value of j  
  //dp[i][j]=max(dp[i-1][j-w[i]]+v[i],dp[i-1][j])
  
  for(int i=0;i<(int)1e5+1;i++)
    dp[0][i]=(v[0]==i?w[0]:(int)1e12) ;
  dp[0][0]=0 ;
  for(int i=1;i<n;i++)
    for(int j=0;j<(int)1e5+1;j++)
      dp[i][j] =min(dp[i-1][j],(j>=v[i]?dp[i-1][j-v[i]]+w[i]:(int)1e12)) ;
  // for(int i=0;i<n;i++){
  //   for(int j=0;j<100;j++)
  //     cout << dp[i][j] <<  " " ;
  //   cout << endl ;
  // }
  int ans ;
  for(int i=0;i<(int)1e5+1;i++){
    // cout << dp[n-1][i] << /" " << wt << endl ;
    if(dp[n-1][i]<=wt){
      // cout << i << " /"<< dp[n-1][i] << " " << wt << endl ;
      ans=i ;
    }
  }
    // ans=(dp[n-1][i]<=wt?i:ans) ;
  cout << ans  ;
}

Measured memory_bytes: 82420
#include <bits/stdc++.h>
#include <ext/rope>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define int long long
//#define ll long long
#define pb push_back
#define x first
#define ld long double
#define y second
#define mk(a,b) make_pair(a,b)
#define rr return 0
#define sqr(a) ((a)*(a))
#define all(a) a.begin(),a.end()

using namespace std;

using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<class value, class cmp = less<value> >
using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class value, class cmp = less_equal<value> >
using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
template<class key, class value, class cmp = less<key> >
using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>;

/// find_by_order()
/// order_of_key()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
inline int randll(int l = INT_MIN, int r = INT_MAX) {
    return uniform_int_distribution<int>(l, r)(rng);
}
main()
{
    ios::sync_with_stdio(0);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    vector <int> a(n), b(n);
    for (auto &i : a) cin >> i;
    for (auto &i : b) cin >> i;
    set<pair<int, int>, greater<pair<int, int> > > c;
    for (int i = 0; i < n; i++) {
        c.insert({b[i], i});
    }
    while (!c.empty()) {
        int v = c.begin()->y;
        c.erase(c.begin());
        if (b[v] < a[v]) {
            cout << "-1\n";
            rr;
        }
        if (b[v] == a[v]) continue;
        int add = b[(v - 1 + n) % n] + b[(v + 1) % n];
        int cnt = (b[v] - a[v]) / add;
        if (!cnt) {
            cout << "-1\n";
            rr;
        }
        ans += cnt;
        b[v] -= cnt * add;
        c.insert({b[v], v});
    }
    cout << ans << '\n';
}


Measured memory_bytes: 17920
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define F first
#define S second
#define mod 1000000007
map<char,int>m;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        m[s[i]]=1;
    }

    if(m['N']!=m['S']||m['E']!=m['W'])cout<<"No";
    else cout<<"Yes";

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
static const long double pi = 3.141592653589793;



int main(){
    ll N;
    cin>>N;
    map<ll, ll> M;
    set<ll> S;
    vector<ll> A(N);
    rep(i, N){
        cin>>A[i];
        M[A[i]]++;
        S.insert(A[i]);
    }
    ll Ans=0;
    while(!S.empty()){
        auto itr=S.begin();
        if(M[*itr]%2)Ans++;
        S.erase(itr);
    }
    cout<<Ans<<endl;
}
     

Measured memory_bytes: 11904
"use strict";
function main(input) {
  const inputs = input.split("\n");
  const L = Number(inputs[0]);

  const A = [];
  for (let i = 0; i < L ; i++) {
    A.push( Number(inputs[i+1]));
  }
  
  const dp = Array(L + 1).fill().map(() => Array(5).fill());
  dp[0] = [0, 0, 0, 0, 0];

  for (let i = 1; i <= L; i++) {
    let cur = A[i-1];
    let curEven = A[i-1] === 0 ? 2 : cur % 2;
    let curOdd = (cur + 1) % 2;

    dp[i][0] = dp[i-1][0] + cur;
    dp[i][1] = Math.min(dp[i-1][0], dp[i-1][1]) + curEven;
    dp[i][2] = Math.min(dp[i-1][0], dp[i-1][1], dp[i-1][2]) + curOdd;
    dp[i][3] = Math.min(dp[i-1][2], dp[i-1][3]) + curEven;
    dp[i][4] = Math.min(dp[i-1][0], dp[i-1][1], dp[i-1][2], dp[i-1][3], dp[i-1][4]) + cur;
  }

  console.log(Math.min(...dp[L]));
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 86668
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(void) {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    cout << d[n/2] - d[n/2-1] << endl;
}



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

int main(){
	int n,k;
	while(cin>>n>>k,n,k){
		string sa[10];
		for(int i=0;i<n;i++){cin>>sa[i];}
		
		vector<string>ans;
		
		if(k==2){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					if(i!=j){
						string s=sa[i];
						s+=sa[j];
						
						int flg=0;
						for(int i=0;i<ans.size();i++){
							if(ans[i]==s){
								flg=1;
								break;
								}
							}
							
						if(flg==0)ans.push_back(s);	
						}
					}
				}
			}
			
		if(k==3){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					for(int k=0;k<n;k++){
						if(i!=j&&j!=k&&i!=k){
							string s=sa[i];
						s+=sa[j];
						s+=sa[k];
						
						int flg=0;
						for(int i=0;i<ans.size();i++){
							if(ans[i]==s){
								flg=1;
								break;
								}
							}
							
						if(flg==0)ans.push_back(s);	
							}
						}
					}
				}
			}	
			
		if(k==4){
			for(int i=0;i<n;i++){
				for(int j=0;j<n;j++){
					for(int k=0;k<n;k++){
						for(int l=0;l<n;l++){
							if(i!=j&&j!=k&&k!=l&&i!=k&&i!=l&&j!=l){
								string s=sa[i];
						s+=sa[j];
						s+=sa[k];
						s+=sa[l];
						
						int flg=0;
						for(int i=0;i<ans.size();i++){
							if(ans[i]==s){
								flg=1;
								break;
								}
							}
							
						if(flg==0)ans.push_back(s);	
								}
							}
						}
					}
				}
			}	
			
			cout<<ans.size()<<endl;
		}
		return 0;
	}

Measured memory_bytes: 3288
S = input()
len_S = len(S)
zero_lst = [S[i] for i in range(len_S) if S[i] == "0"]
one_lst = [S[i] for i in range(len_S) if S[i] == "1"]
ans = min(len(zero_lst), len(one_lst)) * 2
print(ans)

Measured memory_bytes: 3992
use std::io;

fn main() {
    let xy = read_vec::<usize>();

    println!("{}", gcd(xy[0], xy[1]));
}

// 最大公約数を返す
fn gcd(p: usize, q: usize) -> usize {
    if p % q == 0 {
        return q;
    } else {
        return gcd(q, p % q);
    }
}

/// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut line = String::new();
    io::stdin().read_line(&mut line)
        .ok()
        .expect("Faild to read Vec");
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
int main() {
    int N, M;
    cin >> N >> M;
    Graph Hole(N, vector<int>());
    for(int i = 0; i < M; i++) {
        int A, B;
        cin >> A >> B;
        A--;
        B--;
        Hole[A].push_back(B);
        Hole[B].push_back(A);
    }
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;
    que.push(0);
    dist[0] = 0;

    // 初期条件 (頂点 0 を初期ノードとする)
    while(!que.empty()) {
        int cur = que.front();
        que.pop();
        for(int i : Hole[cur]) {
            if(dist[i] == -1) {
                dist[i] = cur;
                que.push(i);
            }
        }
    }
    cout << "Yes" << endl;
    for(int i = 1; i < N; i++) {
        cout << dist[i]+1 << endl;
    }
    return 0;
}

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

using namespace std;

#define DUMP(x) std::cout << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()

using ll = std::int64_t;
using vint = std::vector<int>;
using pint = std::pair<int, int>;

constexpr std::int32_t INF = 1001001001;

void Main() {
    int d[5];
    rep(i, 5) {
        cin >> d[i];
    }

    int ans = 0;
    int last = 0;
    rep(i, 5) {
        ans += (d[i] + 9) / 10 * 10;
        if (d[i] % 10 == 0) continue;
        last = max(last, 10 - d[i] % 10);
    }
    cout << ans - last << endl;

}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
robot=array(N)
N.times do|i|
    x,l=get_i
    robot[i]=[x-l,x+l]
end
robot.sort!{|x,y| x[1]<=>y[1]}
ans=1
prev=0
(N-1).times do|i|
    if robot[prev][1]<=robot[i+1][0]
        ans+=1
        prev=i+1
    end
end
puts ans

Measured memory_bytes: 12024
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

int main() {
  char a;
  cin>>a;
  if(a=='A'){
    cout<<"T"<<endl;
  }else if(a=='T'){
    cout<<"A"<<endl;
  }else if(a=='C'){
    cout<<"G"<<endl;
  }else{
    cout<<"C"<<endl;
  }
  return 0;
}


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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		String s="";
		for(int i=0;i<3;i++){
			s+=nextString().substring(i,i+1);
		}

		System.out.println(s);

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

typedef long long ll;

const int lim = 1000000;

int res;

int main()
{
    ll n; cin >> n;
    for (ll i = 2; i <= lim && i <= n; i++) {
        ll num = n;
        while (num % i == 0) num /= i;
        if (num % i == 1) res++;
    }
    if (n > lim) res++;
    n--;
    for (ll i = 1; i * i <= n; i++) if (n % i == 0) {
        if (i > lim) res++;
        if (i * i < n && n / i > lim) res++;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
s = input()
# ABC -> BCA
# "BC"を纏めて考える
s = s.replace('BC', 'D')
# AとDだけからなる部分列において、各Dについて、左にあるAの数を数える
# 部分列は最終的に D...DA...Aとなる
ans = 0
cntA = 0
for i in range(len(s)):
    if s[i] == 'A':
        cntA += 1
    elif s[i] == 'D':
        ans += cntA
    # AとD以外(= B or C)の場合は一旦途切れる
    else:
        cntA = 0

print(ans)


Measured memory_bytes: 80040
N,Z,W = map(int, raw_input().split(" "))
cards = map(int, raw_input().split(" "))

if abs(cards[N-1]-W) >= abs(cards[N-1] - cards[N-2]):
    print abs(cards[N-1]-W)
else:
    print abs(cards[N-1] - cards[N-2])


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  int c, d;
  cin >> a >> b >> c >> d;
  pr(min(a, b) + min(c, d));
  return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>
int main(){
    int a[200],b[200],c[200],t,i,j;
    for(i=0;i < 200;i++){
        if( scanf("%d %d",&a[i],&b[i]) == EOF ){
            break;
        } else {
            c[i] = a[i] + b[i];
        }
    }
    for(j=0;j < i;j++){
        t = 1;
        while(c[j] >= 10){
            c[j] = c[j] / 10;
            t++;
        }
        printf("%d\n",t);
    }
    return 0;
}


Measured memory_bytes: 2104
using System;

class Atcoder42
{
    public static void Main()
    {
        string[] input = Console.ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        string op = input[1];
        int b = int.Parse(input[2]);

        if (op == "+")
            Console.WriteLine(a + b);
        else
            Console.WriteLine(a - b);
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int N){
    vector<int>S;
    rep(i,N)if(bit & (1<<i))S.push_back(i);
    return S;
}

int main(){
    int k;
    vector<int> vert = {0,1,2,3,4,5,6,7};

    while(cin>>k){
        vector<P>p;
        rep(i,k){
            int r,c;
            cin>>r>>c;
            p.emplace_back(r,c);
        }
        do{
            vector<vector<int>>board(8,vector<int>(8));
            rep(i,8)rep(j,8)board[i][j] = 0;
            vector<bool>f(15,false);
            vector<bool>g(15,false);
            bool f2 = true;

            rep(i,8){
                //cout<<'('<<i<<','<<vert[i]<<')';
                for(auto x : p){
                    if(x.first == i){
                        if(x.second != vert[i])f2 = false;
                        
                    }
                }
                if(!f2)break;
                board[i][vert[i]] = 1;
                if(f[i-vert[i]+7])f2 = false;
                if(g[i+vert[i]])f2 = false;
                f[i-vert[i]+7] = true;
                g[i+vert[i]] = true;
            }
            if(!f2)continue;

            rep(i,8){
                rep(j,8){
                    if(board[i][j])cout<<'Q';
                    else cout<<'.';
                }
                cout<<endl;
            }
            //cout<<endl;
        }while(next_permutation(ALL(vert)));
    }
}




Measured memory_bytes: 3168
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
#define ip(arr, n) for(int i=0; i<n; i++) cin>>arr[i];
#define op(arr, n) for(int i=0; i<n; i++) cout<<arr[i]<<" ";
#define fstIO ios_base::sync_with_stdio(false); cin.tie(NULL);

int main(){
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    
    for(int i=0; i<n; i++){
        cin>>a[i]>>b[i]>>c[i];
    }

    ll dp[n][3];
    
    memset(dp, 0, sizeof(dp));
    dp[0][0]=a[0];
    dp[0][1]=b[0];
    dp[0][2]=c[0];

    for(int i=1; i<n; i++){
        // if ith day I perform a activity, then what's the max points I have got on (i-1)th day,
        // by not performing a activity
        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][0], dp[i-1][1]); 
        // cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<endl;
    }

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

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define endl '\n'
ll ncr(int n, int k)
{
    ll res = 1;
    if (k > n - k)
        k = n - k;
    for(int i = 0; i < k; i++)
    {
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
int main()
{
    Hello
    int n;
    cin >> n;
    int arr[n + 5];
    ll ans = ncr(n, 3);
    for(int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n);
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int temp = arr[i] + arr[j];
            //fih kam rakam >= temp
            int low = 0, high = n - 1, mid, bs = 0;
            while(low <= high){
                mid = (low + high)/2;
                if(arr[mid] >= temp){
                    bs = n - mid;
                    high = mid - 1;
                }
                else
                    low = mid + 1;
            }
            ans -= bs;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int a1,b1;
    cin >> a1 >> b1;
    int a2,b2;
    cin >> a2 >> b2;
    if(a1==a2){
        pr(0);
    }else{
        pr(1);
    }
}

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

typedef long lint;
typedef long long llint;

// static const int MAX = 1e6;
// static const int NIL = -1;
// static const ll INF = 1<<21;
// static const ll MOD = 1e9 + 7;

bool compPair(const pair<int, int>& arg1, const pair<int, int>& arg2) { return arg1.first > arg2.first; }
template<class T> void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }

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

    if(n>=195) cout << 5 << endl;
    else if(n>=189) cout << 4 << endl;
    else if(n>=165) cout << 3 << endl;
    else if(n>=135) cout << 2 << endl;
    else if(n>=105) cout << 1 << endl;
    else cout << 0 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <string>
#define llint unsigned long long
#define H 1000000007

using namespace std;

llint n, m;
string s, t;
llint l, r;
set<llint> S;
llint Hash[300005], bekiH[300005];

int main(void)
{
  cin >> n >> m;
  cin >> s;
  s = "#" + s;
  l = r = 1;

  bekiH[0] = 1;
  for(int i = 1; i <= n; i++) bekiH[i] = bekiH[i-1] * H;
  for(int i = 1; i <= n; i++){
    Hash[i] = Hash[i-1] * H + s[i];
  }
  //for(int i = 1; i <= n; i++) cout <<Hash[i] << " "; cout << endl;
  for(int q = 0; q < m; q++){
    cin >> t;
    int d;
    if(t[1] == '+') d=1; else d=-1;
    if(t[0] == 'L') l+=d;
    else r+=d;
    //cout << l << " " << r << endl;
    S.insert(Hash[r] - Hash[l-1]*bekiH[r-l+1]);
    //cout << Hash[r] - Hash[l-1] << endl;
  }
  cout<< S.size() << endl;
  return 0;
}



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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  REP(i, N){
    cin >> A[i];
  }
  sort(A.rbegin(), A.rend());
  ll ans = A[0];
  FOR(i, 2, N){
    ans += A[i/2];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=205;
ll a[105];
map<int,int> ma;
int main() {
	ll x,d,k;
	cin>>x>>k>>d;
	if(x<0) x=-x;
	ll times=x/d;
	
	ll last=x%d;
	//cout<<last<<endl;
	ll tmp=k-times;
	//cout<<tmp<<endl;
	if(tmp<0) {
		cout<<x-k*d<<endl;
	} else if(tmp%2) {
		cout<<d-last<<endl;
	}
	else {
		cout<<last<<endl;
	}
	 
	
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100

int n;

// char X[100][100];
// int dp[1000000001];
string S,T;
int main(void){
    cin >> S >> T;
    // REP(i,0,n) {
        
    // }
    int sl = S.length();
    int tl = T.length();
    // if (sl < tl) cout << "UNRESTORABLE" << endl;
    
    vector<int> idxs;
    REP(i,0,sl) {
    bool flag = true;
        // cout << i << endl;
        REP(j,0,tl) {
            if (i+j >= sl) {
                flag = false;
                break;
            }
            
            if (S[i+j] != '?' && S[i+j] != T[j]) {
                flag = false;
            }
        }
        // 部分文字列かどうか
        if (flag) {
            idxs.push_back(i);
            // cout << i << endl;
        }
    }
    
    if (idxs.size() == 0) cout <<  "UNRESTORABLE"  << endl;
    
    else {
    vector<string> store;
    
    
    for(auto idx: idxs) {
        string temp = S;
        REP(i,0,tl) {
            temp[idx+i] = T[i]; 
        }
        REP(i,0,sl) {
            if (temp[i] == '?') temp[i] = 'a';
            // else temp[i] = S[i];
        }
        store.push_back(temp);
    }
    
    string res = store[0];
    for (auto s: store) {
        if (res >= s) res = s;
    }
    cout << res << endl;
    }
    // for (char c : S) {
    //     cout << c << endl;
    // }
    

    

}

Measured memory_bytes: 256