akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N, X;
	cin >> N >> X;
	VI S(N);
	REP(i, N)
		cin >> S[i];

	rSORT(S);
	int dp[205][100010] = { 0 };
	dp[0][X] = 1;
	REP(i, N) {
		eREP(j, 100000) {
			dp[i + 1][j%S[i]] = (dp[i + 1][j%S[i]] + dp[i][j]) % mod;
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j] * (N - i - 1)) % mod;
		}
	}

	int ans = 0;
	eREP(i, 100000) {
		ans = (ans + i * dp[N][i]) % mod;
	}

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



Measured memory_bytes: 160512
#include<iostream>
#include<vector>
#include<algorithm>
#include<sstream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main(){
	int table[] = {1000,500,100};
	int n,m;
	while(cin >> n >> m , n && m){
		int s = m-n;
		int ret[3] = {0};
		rep(i,3){
			while(s>=table[i]){
				s-=table[i];
				ret[i]++;
			}
		}
		rep(i,3)cout << (i?" ":"") << ret[2-i];
		cout << endl;
	}
}

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

int main(){
  int N;
  cin >> N;
  if(N<=111)
    cout << 111;
  if(N>111&&N<=222)
    cout << 222;
  if(N>222&&N<=333)
    cout << 333;
  if(N>333&&N<=444)
    cout << 444;
  if(N>444&&N<=555)
    cout << 555;
  if(N>555&&N<=666)
    cout << 666;
  if(N>666&&N<=777)
    cout << 777;
  if(N>777&&N<=888)
    cout << 888;
  if(N>888&&N<=999)
    cout << 999;
}

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

class Main {
	static class Graph {
		int vertices;
		ArrayList<ArrayList<Integer>> adjList;

		public Graph(int v) {
			vertices = v;
			adjList = new ArrayList<ArrayList<Integer>>();
			for(int i = 0; i < vertices; i++)
				adjList.add(new ArrayList<>());
		}

		public boolean addEdge(int start, int end) {
			if(start > vertices) 
				return false;
			
			adjList.get(start).add(end);
			return true;
		}

		public boolean isCycle() {
			boolean visited[] = new boolean[vertices];
			boolean recursiveArr[] = new boolean[vertices];

			// Do Depth First Search
			for (int i = 0; i < vertices; i++) {
				if (isCycleUtil(i, visited, recursiveArr))
					return true;
			}

			return false;
		}

		private boolean isCycleUtil(int vertex, boolean[] visited, boolean recursiveArr[]) {
			visited[vertex] = true;
			recursiveArr[vertex] = true;

			// Traverse through all adjacent vertices
			for(int i = 0; i < adjList.get(vertex).size(); i++) {
				int adjVertex = adjList.get(vertex).get(i);

				if(!visited[adjVertex] && isCycleUtil(adjVertex, visited, recursiveArr)) {
					return true;
				} else if(recursiveArr[adjVertex]) {
					return true;
				}
			}

			// Cannot find any cycle from current vertex
			recursiveArr[vertex] = false;
			return false;
		}
	}

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

		int numV = scanner.nextInt();
		int numE = scanner.nextInt();
		
		// Create new graph
		Graph g = new Graph(numV);

		// Read and add edges to graph
		for(int i = 0; i < numE; i++) {
			g.addEdge(scanner.nextInt(), scanner.nextInt());
		}

		System.out.println(g.isCycle() ? 1 : 0);

	}
}


Measured memory_bytes: 31500
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ans = new int[n];
        for(int i = 0;i<n;i++){
            ans[sc.nextInt()-1] = i;
        }
        for(int i = 0;i<n;i++){
            System.out.print((ans[i]+1)+" ");
        }
    }
}

Measured memory_bytes: 63636
#include<iostream>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int x = 0, N;
  cin >> N;

  char c; int ans = x;
  rep(i,0,N-1) {
    cin >> c;
    if (c == 'I') x++;
    else x--;
    ans = max(ans, x);
  }

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


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

using namespace std;
int main()
{
	int cnt = 0;
	int ans = 0;
	string a;
	cin >> a;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == 'A' || a[i] == 'G' || a[i] == 'C' || a[i] == 'T')
			cnt++;
		else
			cnt = 0;
		ans = max(cnt, ans);
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
c = Counter(a)
p = [True] * (10 ** 6 + 1)
s = list(set(a))
for x in s:
    t = x * 2
    while t <= 10 ** 6:
        p[t] = False
        t += x
ans = 0
for x in a:
    if c[x] == 1 and p[x] == True:
        ans += 1
print(ans)


Measured memory_bytes: 52712
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

#define l long // -2^31 to +2^31-1 (upper limit ~ 2*(10^9))
#define ul unsigned long // 0 to +2^32-1
#define ll long long // -2^63 to +2^63-1 (upper limit ~ 9*(10^18))
#define ull unsigned long long // 0 to +2^64-1
#define mod(x, m) ((((x)%(m))+(m))%(m))
#define vi vector<int>
#define pi pair<int,int>
#define vl vector<ll int>
#define pl pair<ll int,ll int>
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const ll MOD = 1e9 + 7;
const double pie = 3.141592653589793;
const ll int MD = 998244353 ;

#define setcount(x) __builtin_popcount(x) // counts set bits
#define parity(x) __builtin_parity(x) // checks parity of the number
#define lzcount(x) __builtin_clz(x) // count leading zeros in binary representation of number
#define tzcount(x) __builtin_ctz(x) // count trailing zeros in binary representation of number

template<typename T> T inf() { return (T)__builtin_inf();} // syntax for use inf<datatype>();
template<typename T> T gcd(T a,T b){ if(b>a) return gcd(b,a);return b==0?a:gcd(b,a%b); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b); }
template<typename T> T fast_power(T x,T y,ll m=MOD){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

string IntToString(ll a){ ostringstream temp; temp << a; return temp.str();}
ll findMMI_fermat(ll n,ll M) {ll ans= fast_power(n,M-2,M);return ans;}//i.e In (a/b)%M..it calculates MMI of b wrt M,only if M is prime
ll add(ll a,ll b,ll M) { return ( mod(a,M ) + mod(b,M ))%M; }
ll sub(ll a, ll b,ll M) { return (mod(a,M ) + M - mod(b,M ))%M; }
ll mult(ll a,ll b,ll M) { return  ( mod(a,M)*mod(b,M) ) %M ; }
bool isprime(ll a){ if(a==2) {return 1;}if(!(a&1) ) {return 0;}for(ll i=3;i*i<=a;i+=2){if(a%i==0) {return 0;} } return 1;} 

/************************** main program **************************/

int main()
{
	FASTIO
	//code
	string s;
	cin>>s;
	if(s == "MON")	cout<<6;
	else if(s == "TUE")	cout<<5;
	else if(s == "WED")	cout<<4;
	else if(s == "THU")	cout<<3;
	else if(s == "FRI")	cout<<2;
	else if(s == "SAT")	cout<<1;
	else if(s == "SUN")	cout<<7;
	return 0;
}

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

int main(){
  int sum1=0,sum2=0;  

  for(int a,i=0;i<4;++i){
    cin>>a;sum1+=a;
  }
  for(int a,i=0;i<4;++i){
    cin>>a; sum2+=a;
  }

  if(sum1>sum2) cout<<sum1<<endl;
  else cout<<sum2<<endl;
  return 0;
}

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

int main(){

//初期値
int x = 0;

//文字の長さ
int N; 
cin >> N;

//文字列
string S;
cin >> S;

int max_x = 0; 
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'I')
		{
			x++;
		}else if(S.at(i) == 'D'){
			x--;	
		}
		
		max_x = max(max_x, x);
	}	
cout << max_x << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(1 + N), ans(1 + N);
	for (int i = 1; i <= N; ++i) cin >> a[i];
	for (int i = N; i > 0; --i) {
		int sum = 0;
		for (int j = 2 * i; j <= N; j += i) {
			if (ans[j] == 1) ++sum;
		}
		if (a[i] == 0) {
			if (sum % 2) ans[i] = 1;
		}
		else {
			if (sum % 2 == 0) ans[i] = 1;
		}
	}
	vector<int> b;
	for (int i = 1; i <= N; ++i) {
		if (ans[i]) b.push_back(i);
	}
	cout << b.size() << endl;
	for (int i = 0; i < (int)b.size() - 1; ++i) cout << b[i] << ' ';
	if (b.size()) cout << b.back() << endl;
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        ll a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
        cin>>k;
        cout<<a[k-1];
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;

int64_t divceil(int64_t a, int64_t b) {
    return a / b + (a > 0 && a % b ? 1 : 0);
}

// O(N log N)
int main() {
    int N;
    cin >> N;
    // 頂点を探すpqueue
    priority_queue<pair<i64, int>> q;
    vector<i64> A(N), B(N);
    for(auto &x : A) cin >> x;
    for(int i = 0; i < N; i++) {
        cin >> B[i];
        q.push({B[i], i});
    }
    i64 ans = 0;
    // 互除法の改造
    while(!q.empty()) {
        auto x = q.top(); q.pop();
        i64 a, b, c, d; int i;
        tie(b, i) = x;
        if(b < A[i]) {
            cout << -1 << endl;
            return 0;
        }
        c = B[(i + 1) % N];
        a = B[(i - 1 + N) % N];
        d = max({a, c, A[i]});
        i64 S = a + c;
        int j = divceil(b - d, S);
        i64 v = B[i] - j * S;
        if(A[i] < v) {
            q.push({v, i});
            ans += j;
        } else if((A[i] - v) % S == 0) {
            ans += j - (A[i] - v) / S;
        } else {
            cout << -1 << endl;
            return 0;
        }
        B[i] = v;
    }
    cout << ans << endl;
    return 0;
}

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


int main() {
    int n, t1=0, t2=0;
    cin >> n;
    vector<int> buf;
    for (int i = 0;i < n; ++i) {
        int x; 
        cin >> x;
        if (x > t1) t1 = x;
        else if (x > t2) t2 = x;
        buf.push_back(x);
    }
    for (int i = 0; i < n; ++i) {
        int x = buf[i];
        if (x == t1) cout << t2 << endl;
        else cout << t1 << endl;
    }
    return 0;
}



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

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1; finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  int n, k;
  cin>>n>>k;
  int a[n];
  for (int i=0; i<n; i++) cin>>a[i];
  sort(a, a + n);
  COMinit();
  long long ans = 0;
  for (int i=k-1; i<n; i++) {
    long tmp = COM(i, k-1) * a[i];
    ans += tmp;
    if (ans < 0) {
      ans += ((abs(tmp) - 1) / MOD + 1) * MOD;
    }
    ans %= MOD;
  }
  for (int i=0; i<n-k+1; i++) {
    long long tmp = COM(n-i-1, k-1) * a[i];
    ans -= tmp;
    if (ans < 0) {
      ans += ((abs(tmp) - 1) / MOD + 1) * MOD;
    }
    ans %= MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12544
#include "bits/stdc++.h"
using namespace std;

// fundamental
using ll = long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,s,n) for (ll i = (s); i < (n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(x) ((ll)1e##x)
#define MAXC(c,x) (c = max(c, x))
#define MINC(c,x) (c = min(c, x))
const ll mod = TEN(9) + 7;

// vector
using vl = vector<ll>; using vvl = vector<vl>; using vvvl = vector<vvl>;
template<class T, size_t N, class A = size_t> auto mdv(A size = 0) -> typename enable_if<N==1, vector<T>>::type { return vector<T>(size); }
template<class T, size_t N, class A = size_t> auto mdv(A size = 0) -> vector<decltype(mdv<T, N - 1>())> { return vector<decltype(mdv<T, N - 1>())>(size); }
template<class T, size_t N, class A, class... B> auto mdv(A size, B... rest) -> typename enable_if<N!=1, vector<decltype(mdv<T, N - 1>(rest...))>>::type { return vector<decltype(mdv<T, N - 1>(rest...))>(size, mdv<T, N - 1>(rest...)); }
template<class T, class... A> auto mdv(A... size) -> decltype(mdv<T, sizeof...(size), A...>(size...)) { return mdv<T, sizeof...(size), A...>(size...); }
// template<size_t N, class A, class... B> auto mdvl(A size, B... rest) -> decltype(mdv<N, ll, A, B...>(size, rest...)) { return mdv<N, ll, A, B...>(size, rest...); }

// template<class T, class A> auto mdv(A size) -> vector<T> { return vector<T>(size); }
// template<class T, class A, class... B> auto mdv(A size, B... rest) -> vector<decltype(mdv<T>(rest...))> { return vector<decltype(mdv<T>(rest...))>(size, mdv<T>(rest...)); }

// io
template<class T> istream& operator >>(istream& is, vector<T>& vec){ for(T& x: vec) is >> x; return is; }
template<class T, class U> istream& operator >>(istream& is, pair<T, U>& p){ is >> p.first >> p.second; return is; }
template<class T> void input(T& t) { cin >> t; assert(cin); } template<class T, class... Ts> void input(T& t, Ts&... ts) { cin >> t; input(ts...); }
template<class T> void print(T&& t) { cout << t; } template<class T, class... Ts> void print(T&& t, Ts&&... ts) { cout << t; print(ts...); }
template<class T> void println(T&& t) { cout << t << endl; } template<class T, class... Ts> void println(T&& t, Ts&&... ts) { cout << t; println(ts...); }
template<class T> string join(const vector<T>& v, const string & sep) { stringstream ss; REP(i, v.size()) ss << (i != 0 ? sep : "") << v[i]; return ss.str(); }

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(50);
	ll n; cin >> n;
	vl s(n);
	REP(i, n) cin >> s[i];
	ll ans = 0;
	FOR(step, 1, (n + 1) / 2) {
		ll sum = 0;
		for(ll idx = 0; idx + step + 1 < n; idx += step) {
			if (idx >= n - 1 - idx && (n - 1) % step == 0) break; 
			sum += s[idx] + s[n - idx - 1];
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;
int main()
{
    int n;

    cin >> n;
    int sum = 0;
    int a;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a != i + 1)sum++;
    }
    if (sum == 0 || sum == 2)cout << "YES" << endl;
    else cout << "NO" << endl;
}



Measured memory_bytes: 3596
#include <array>
#include <iostream>

using namespace std;

int main() {
  array<array<int, 4001>, 4> arr = {};

  for (int i = 0; i <= 1000; ++i)
    arr[0][i] = 1;

  for (int k = 1; k < 4; ++k)
    for (int i = 0; i <= 4000; ++i)
      for (int j = i; 0 <= j; --j)
        arr[k][i] += arr[0][j] * arr[k - 1][i - j];

  int n;
  while (cin >> n)
    cout << arr[3][n] << endl;
}


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

int main() {
    int N;
    int h[100];
    cin >> N;
    int ans = 0;
    for(int i=0; i<N; ++i) cin >> h[i];
    for(int l=0; l<N; ++l) {
        while(h[l]) {
            int r = l;
            --h[l];
            while(r+1 < N && h[r+1] > 0) {
                ++r;
                --h[r];
            }
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
def check(candidate, conditions):
    for m in range(M):
        if(candidate[conditions[m][0]-1] != conditions[m][1]):
            return False
    return True

N, M = list(map(int, input().split()))

conditions = [list(map(int, input().split())) for m in range(M)]

ans = [-1 for n in range(N)] 

success = False
for num in range(10**N):
    ans = [(num // 10**(N-i)) % 10 for i in range(1, N+1)]
    if(check(ans, conditions)):
        if(N != 1 and ans[0] == 0):
            continue
        print("".join([str(c) for c in ans]))
        success = True
        break
if(success == False):
        print(-1)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define rep(i,n) for(int i=0;i<n;i++)
int gcd(int a, int b){
    int r=1;
    while(r!=0){
        r=a%b;
        a=b;
        b=r;
    }
    return a;
}
typedef long long ll;
void revStr(char* str){
    int size = strlen(str);
    int i,j;
    char tmp = {0};
    for(i = 0, j = size - 1; i < size / 2; i++, j--){
        tmp = str[i];
        str[i] = str[j];
        str[j] = tmp;
    }return;
}
typedef struct{
    int a,b;
}data;

//昇順
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}
//構造体降順
int comp( const void *c1, const void *c2 )
{
  data test1 = *(data *)c1;
  data test2 = *(data *)c2;
  int tmp1 = test1.b;   /* b を基準とする */
  int tmp2 = test2.b;
  return tmp2 - tmp1;
}


int kai(int n){
    if(n==0){
        return 1;
    }
    int sum=1;
    for(int i=1;i<=n;i++){
        sum*=i;
    }
    return sum;
}

int main(){
    int N;
    scanf("%d",&N);
    long long at[100];
    at[0]=2;at[1]=1;
    for(int i=2;i<=N;i++){
        at[i]=at[i-1]+at[i-2];
    }
    printf("%lld",at[N]);
}


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

int main(){
  int a[3],b[3],x[4];
  for(int i=0; i<3; ++i) cin >> a[i] >> b[i];
  bool ans=false;
  for(int i=0; i<3; ++i) x[i]=0;
  for(int i=0; i<3; ++i){
    x[a[i]-1] += 1;
    x[b[i]-1] += 1;
  }
  if(x[0]==2 && x[1]==2 && x[2]==1 && x[3]==1) ans=true;
  if(x[0]==2 && x[1]==1 && x[2]==2 && x[3]==1) ans=true;
  if(x[0]==2 && x[1]==1 && x[2]==1 && x[3]==2) ans=true;
  if(x[0]==1 && x[1]==2 && x[2]==2 && x[3]==1) ans=true;
  if(x[0]==1 && x[1]==2 && x[2]==1 && x[3]==2) ans=true;
  if(x[0]==1 && x[1]==1 && x[2]==2 && x[3]==2) ans=true;
  if(ans) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[3];
	cin>>a;
	if(a[0]=='a'||a[1]=='a'||a[2]=='a')
	{
		if(a[0]=='b'||a[1]=='b'||a[2]=='b')
		{
			if(a[0]=='c'||a[1]=='c'||a[2]=='c')
			{
				cout<<"Yes";
			}
			else
			{
				cout<<"No";
				return 0;
			}
		}
		else
		{
			cout<<"No";
			return 0;
		}
	}
	else
	{
		cout<<"No";
		return 0;
	}
	return 0;
}

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

#define sint(a) scanf("%d", &a)
#define sint2(a, b) scanf("%d %d", &a, &b)
#define sll(a) scanf("%lld", &a)
#define sll2(a, b) scanf("%lld %lld", &a, &b)
#define mem(a, i) memset(a, i, sizeof(a))
#define pb push_back
#define int long long
#define ll long long
#define lson node << 1
#define rson (node << 1) + 1
#define endl "\n"

const int maxn = 5e5 + 10;
const int mod = 998244353;
const double pi = acos(-1);

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

int lcm(int a, int b)
{
  return a * b / gcd(a, b);
}

int qpow(int a, int n)
{
  int b = 1;
  while (n)
  {
    if (n & 1)
      b = a * b % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return b;
}

class Prime_Number
{
public:
  int prime[maxn], s, v[maxn];
  void prime_init(int n)
  {
    for (int i = 2; i <= n; i++)
    {
      if (!v[i])
      {
        prime[s++] = i;
        for (int j = 1; j * i <= n; j++)
          v[i * j] = 1;
      }
    }
  }
};

//**************************

void solve()
{
 int n;
 sll(n);
 int x=0,sum=0;
 for(int i=0;i<n;i++)
  {
    int a;
    sll(a);
    if(a<x)
      sum+=x-a;
    x=max(x,a);
  }
  cout<<sum;
}
signed main()
{
  solve();
  return 0;
}


Measured memory_bytes: 3680
#include <bits/stdc++.h>
#define For(i,n) for(int i=0; i<n; i++)
#define M0D 1000000007
using namespace std;

int main(){

  long long N,A,B;
  long long ans=0;
  cin >> N >> A >> B;
  int X[N];
  For(i,N) cin >> X[i];

  For(i,N-1) ans += min((X[i+1]-X[i])*A, B);

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



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

typedef long long ll;
typedef pair<int, int> pi;

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep_op(i, a, b) for (int i = a; i < b; i++)
#define rep_d(j, n) for (int j = n; j >= 0; j--)
#define rep_d_op(j, e, n) for (int j = n; j >= e; j--)


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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s; cin >> s;
    string temp_s = "";
    ll ans = 0;
    rep(i, s.length() / 2) {
        temp_s += s[i];
        string temp_s_out = "";
        rep_op(j, i+1, i+1+temp_s.length()) {
            temp_s_out += s[j];
        } 
        if (temp_s == temp_s_out && temp_s_out.length() != s.length()/2) {
            ans = temp_s.length();
        }
    }
    cout << ans*2 << endl;
} 


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<map>
#include<string>
#define ll long long
using namespace std;
int read()
{
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*f;
}
int a[100005],b,n;
ll ans;
int main()
{
/*	a=read();b=read();
	if(b==100) ++b;
	if(a==0)
	{
		cout<<b;
	}
	else if(a==1)
	{
		cout<<b<<"00";
	}
	else 
	{
		cout<<b<<"0000";
	}*/
	n=read();
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
		while(a[i]%2==0)
		{
			ans++;
			a[i]/=2;
		}
	}
	cout<<ans;
	return 0;
 } 

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

int main() {
    int a[10];
    for (int i=0; i<3; ++i) {
        cin >> a[i];
    }
    sort(a, a+3);
    
    cout << a[2] - a[0] << endl;

    return 0;
}
    /*
    int a, b, c;
    cin >> a >> b >> c;
    */




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}

bool f(int t,vi &a,int m){
  int cnt=0;
  int n=a.size();
  rep(i,n){
    int it=lower_bound(all(a),t-a[i])-a.begin();
    cnt+=n-it;
  }

  return cnt>=m;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n,m;
  cin>>n>>m;
  vi a(n);
  rep(i,n){
    cin>>a[i];
  }
  sort(all(a));
  
  int l=0,r=INF;
  while(r-l>1){
    int mi=(r+l)/2;
    if(f(mi,a,m)) l=mi;
    else r=mi;
  }


  vi sum(n+1,0);
  rep(i,n){
    sum[i+1]=sum[i]+a[i];
  }

  int ans=0;
  int e=0;
  rep(i,n){
    int it=lower_bound(all(a),l-a[i])-a.begin();
    ans+=sum[n]-sum[it];
    ans+=(n-it)*a[i];
    e+=(n-it);
  }

  ans-=(e-m)*l;
  cout<<ans<<endl;


}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;

long long ans;

int main()
{
	long long n,T,biu,pia;
	while(~scanf("%lld %lld",&n,&T))
	{
		ans = 0;
		scanf("%lld",&pia);
		for(int i = 2;i <= n;i++)
		{
			scanf("%lld",&biu);
			if(biu-pia > T) ans += T;
			else ans += biu-pia;
			pia = biu;
		}
		ans += T;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

main(){
	int a,b;
	char op;
	
	while(1){
		
		scanf("%d %c %d",&a,&op,&b);
		
		if(op=='?')break;
		
		else if(op=='+'){
			printf("%d\n",a+b);
		}
		else if(op=='-'){
			printf("%d\n",a-b);
		}
		else if(op=='*'){
			printf("%d\n",a*b);
		}
		else if(op=='/'){
			printf("%d\n",a/b);
		}
	}
	
	return 0;
}

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

int main() {
	int i;
	char a[16];
	char b[16];
	scanf("%s", &a,16);
	scanf("%s", &b,16);
	//printf("入力された文字列は：%s, %s\n", a, b);
	for (i = 0; a[i] != '\0'; ++i);

	if (strncmp(a,b,i) == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 1680
#include <cstdio>
#include <string>
#include <stack>
#include <iostream>
#define INT long long
using namespace std;

INT a, b, x;

int main()
{
    cin>>a>>b>>x;
    if( a == 0 ) cout<<b/x+1<<endl;
    else cout<<(b/x)-((a-1)/x)<<endl;
}


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

using ll = long long;
#define int long long
using P = pair<int, int>;

#define LOG(variable) cerr << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cerr << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
template<typename T = int>
T in() {T a; cin >> a; return a;}
map<int,int> GetPrimeFactors(int n) {
  map<int,int> mp;
  // divide by 2, 3, 5, ...
  while(n%2 == 0) {
    ++mp[2];
    n /= 2;
  }
  while(n%5 == 0) {
    ++mp[5];
    n /= 5;
  }
  return mp;
}
/***** MAIN *****/
int counter_counter[20][20];
signed main() {
  int n; cin >> n;
  double tmp;
  int tmpi;
  map<int, int> mp;
  int ans = 0;
  for(int i = 0; i < n; ++i) {
    cin >> tmp;
    tmpi = tmp * 10000000000;
    if(tmpi % 10 == 9) {
      ++tmpi;
    }
    tmpi /= 10;
    mp = GetPrimeFactors(tmpi);
    int two = mp[2];
    int five = mp[5];
    if(two >= 18 && five >= 18) {
      ans += i;
    } else if(two >= 18) {
      for(int j = 0; j <= 18; ++j) {
        for(int k = max(0LL, 18-five); k <= 18; ++k) {
          ans += counter_counter[j][k];
        }
      }
    } else if(five >= 18) {
      for(int j = max(0LL, 18-two); j <= 18; ++j) {
        for(int k = 0; k <= 18; ++k) {
          ans += counter_counter[j][k];
        }
      }
    } else {
      for(int j = max(0LL, 18-two); j <= 18; ++j) {
        for(int k = max(0LL, 18-five); k <= 18; ++k) {
          ans += counter_counter[j][k];
        }
      }
    }
    ++counter_counter[min(18LL, two)][min(18LL, five)];
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

int N, M;
vector<int> memo;
vector<vector<int>> edges;
vector<bool> root_p;
vector<bool> end_p;

int ma(int i) {
    if (memo[i] != -INF) return memo[i];

    if (root_p[i]) return memo[i] = 0;
    int ret = -1;
    for (auto u : edges[i]) {
        ret = max(ret, ma(u) + 1);
    }
    return memo[i] = ret;
}

int main() {
    cin >> N >> M;
    memo   = vector<int>(N, -INF);
    edges  = vector<vector<int>>(N, vector<int>(0));
    root_p = vector<bool>(N, true);
    end_p  = vector<bool>(N, true);

    rep(i, M) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        edges[v].push_back(u);
        root_p[v] = false;
        end_p[u]  = false;
    }

    int ans = -1;
    for (int i = 0; i < N; i++) {
        if (!end_p[i]) continue;
        ans = max(ans, ma(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 13628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
  ll N;
  cin >> N;
  string judge;
  vector<ll> C(4,0);
  for(ll i=0;i<N;i++){
    cin >> judge;
    if(judge == "AC"){
      C[0]++;
    }else if(judge == "WA"){
        C[1]++;
    }else if(judge == "TLE"){
        C[2]++;
    }else{
        C[3]++;
    }
  }
  cout << "AC x " << C[0] << "\n";
  cout << "WA x " << C[1] << "\n";
  cout << "TLE x " << C[2] << "\n";
  cout << "RE x " << C[3] << "\n";
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
int main()
{
     string s;
     cin>>s;
     ll i = 1;
     string pre = "";
     pre += s[0];
     ll ans = 1;
     ll n = s.size();
     string crt="";
     while(i<n)
     {
          crt += s[i];
          if(crt!=pre)
          {
               pre = crt;
               ans++;
               crt.clear();
          }
          i++;
     }
     cout<<ans;
}
     

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

int main() {
    int n,k;
    cin>>n>>k;
    int a[n];
    int ans=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        if(a[i]>=k)
        {
            ans++;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

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

  string S,s2=s;
  S=s+s2;
  //  cout <<S<<endl;

  if(S.find(p)!=string::npos){
    cout <<"Yes"<<endl;
  }
  else{
    cout <<"No"<<endl;
  }


  return 0;
}



Measured memory_bytes: 3208
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define pii pair<int, int>
#define pll pair<long long, long long>
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<pii> A(N);
    rep(i,N) {
        int a; cin >> a;
        A[i] = make_pair(a,i);
    }

    sort(all(A));

    int cnt = 0;
    rep(i,N) if (A[i].second%2 != i%2) cnt++;

    cout << cnt/2 << endl;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  static constexpr T mod = MOD;
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  Mint inv(){return pow(MOD-2);}

  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}

  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}


template<typename T>
struct BIT{
  Int n;
  vector<T> bit;
  //1-indexed
  BIT():n(-1){}
  BIT(Int n_,T d):n(n_),bit(n_+1,d){}

  T sum(Int i){
    T s=bit[0];
    for(Int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  void add(Int i,T a){
    if(i==0) return;
    for(Int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }

  Int lower_bound(Int w){
    if(w<=0) return 0;
    Int x=0,r=1;
    while(r<n) r<<=1;
    for(Int k=r;k>0;k>>=1){
      if(x+k<=n&&bit[x+k]<w){
        w-=bit[x+k];
        x+=k;
      }
    }
    return x+1;
  }

  T sum0(Int i){
    return sum(i+1);
  }
  void add0(Int i,T a){
    add(i+1,a);
  }

  T query(Int l,Int r){
    return sum(r-1)-sum(l-1);
  }

  T query0(Int l,Int r){
    return sum(r)-sum(l);
  }
};

//INSERT ABOVE HERE
const Int MAX = 2020;
using M = Mint<Int>;
M dp[MAX][MAX]={};
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> ss(n),ts(m);
  for(Int i=0;i<n;i++) cin>>ss[i];
  for(Int i=0;i<m;i++) cin>>ts[i];

  M ans{1};
  BIT<M> bit(m+100,M(0));

  for(Int i=0;i<n;i++){
    for(Int j=m-1;j>=0;j--){
      if(ss[i]!=ts[j]) continue;
      dp[i][j]=M(1);
      if(j) dp[i][j]+=bit.sum0(j-1);

      ans+=dp[i][j];
      bit.add0(j,dp[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 32128
#include <algorithm>
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> a(n);
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    cout << a[n - 1] - a[0] << '\n';
    return 0;
}


Measured memory_bytes: 256
N, Y = map(int, input().split())
ans = [-1, -1, -1]
for x in range(N + 1):
    for y in range(N + 1):
        if x + y <= N and 10000 * x + 5000 * y + 1000 * (N - x - y) == Y:
            ans = [x, y, N - x - y]
            
print(*ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int MOD = 1e9+7;
const int N = 2e5 + 10;

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

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

  vector<int> dp(N,0); //i番目までの場合の数
  vector<int> dp2(N,0); //直前のdp[c[i]]の場合の数
  dp[0] = 1;

  for(int i = 0; i < n; i++){
    if(c[i-1] == c[i]){
      dp[i+1] = dp[i];
      continue;
    }
    dp[i+1] = (dp[i] + dp2[c[i]]) % MOD;
    dp2[c[i]] = dp[i+1];
  }
  cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 4992
// #include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <stack>
#include <numeric>
// #include <windows.h>
using namespace std;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = V<VV<T>>;
template<class T1, class T2> using P = pair<T1, T2>;
using I = int;
using D = double;
using B = bool;
using C = char;
using S = string;
using LL = long long;
using LD = long double;
using ULL = unsigned long long;
using PII = P<I, I>;
using VPII = V<PII>;
using PLL = P<LL, LL>;
using VPLL = V<PLL>;
using VI = V<I>;
using VVI = VV<I>;
using VLL = V<LL>;
using VVLL = VV<LL>;
using VC = V<C>;
using VVC = VV<C>;
using VS = V<S>;
using VVS = VV<S>;
using VB = V<B>;
using VVB = VV<B>;
#define REP(type, i, n) for (type i = 0; i < (type)(n); ++i)
#define REP2(type, i, m, n) for (type i = (m); i < (type)(n); ++i)
#define REPR(type, i, n) for (type i = (n)-1; i >= 0; --i)
#define REPR2(type, i, m, n) for (type i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a, type) sort(ALL(a), greater<type>())
#define SORTF(a, comp) sort(ALL(a), comp)
#define REVERSE(a) reverse(ALL(a))
#define SIZE(a, type) ((type)(a).size())
#define bit_search(bit, n) REP(LL, bit, 1LL<<(n))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) (lower_bound(ALL(a), (x)) - a.begin())
#define bisect_right(a, x) (upper_bound(ALL(a), (x)) - a.begin())
#define INPUT(a) REPx(&x, a) cin >> x;
#define INPUT2(a) REPx(&x, a) INPUT(x);
#define INPUTP(a) REPx(&x, a) cin >> x.first >> x.second;
#define ENDL cout << endl;

// const int INF = 2e9;
const LL INF = 9e18;
const LL MOD = 1e9+7;

template<class T> using PRIORITY_QUEUE = priority_queue< T, V<T>, greater<T> >;
template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}
template<class T> inline void debug1(V<T> A){REP(int, i, SIZE(A, int)){if (A[i] == INF) cout << "I ";else cout << A[i] << " ";}ENDL}
template<class T> inline void debug2(VV<T> A){REP(int, i, SIZE(A, int)){REP(int, j, SIZE(A[i], int)){if (A[i][j] == INF) cout << "I "; else cout << A[i][j] << " ";}ENDL}}

int k;

bool dfs(int depth, int r, int g, int b)
{
  if (depth > k) return false;
  if (g > r && b > g)
  {
    cout << "Yes" << endl;
    exit(0);
  }
  if (dfs(depth+1, r*2, g, b)) return true;
  if (dfs(depth+1, r, g*2, b)) return true;
  if (dfs(depth+1, r, g, b*2)) return true;
  return false;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int r, g, b;
  cin >> r >> g >> b >> k;
  dfs(0, r, g, b);
  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
int main()
{
    int sum;
    char num[1100];
    for (int i = 0; i < 1100; i++){
        num[i] = 0;
    }
    while (1){
        scanf(" %s", num);
        if (strcmp(num, "0") == 0)
            break;
        sum = 0;
        for (int i = 0; num[i] != '\0'; i++){
            sum += num[i] - '0';
	}
        printf("%d\n", sum);
    }
    return 0;
}


Measured memory_bytes: 2044
# ABC141E - Who Says a Pun?
class RollingHash:
    def __init__(self, source: str, base=1007, mod=10 ** 9 + 7):
        self.source = source
        self.length = len(source)
        self.base = base
        self.mod = mod
        self.hash = self._get_hash_from_zero()
        self.power = self._get_base_pow()

    def _get_hash_from_zero(self):  # compute hash of interval [0, right)
        cur, hash_from_zero = 0, [0]
        for e in self.source:
            cur = (cur * self.base + ord(e)) % self.mod
            hash_from_zero.append(cur)
        return hash_from_zero

    def _get_base_pow(self):  # computer mod of power of base
        cur, power = 1, [1]
        for i in range(self.length):
            cur *= self.base % self.mod
            power.append(cur)
        return power

    def get_hash(self, l: int, r: int):  # compute hash of interval [left, right)
        return (self.hash[r] - self.hash[l] * self.power[r - l]) % self.mod


def main():
    N = int(input())
    S = input().rstrip()
    rh, ok, ng = RollingHash(S), 0, N // 2 + 1
    while ng - ok > 1:
        mid = (ok + ng) // 2
        flg, memo = 0, set()
        for i in range(N - 2 * mid + 1):
            memo.add(rh.get_hash(i, i + mid))
            if rh.get_hash(i + mid, i + 2 * mid) in memo:
                flg = 1
                break
        if flg:
            ok = mid  # next mid will be longer
        else:
            ng = mid  # next mid will be shorter
    print(ok)  # max length of substrings appeared twice or more


if __name__ == "__main__":
    main()

Measured memory_bytes: 60124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;



struct range_path{
    using pli = pair<long long,int>;
    int n; 
    int N;
    int V;
    vector<vector<pli>> Graph;
    range_path(int n):n(n){
        N=1;
        while(N<n) N*=2;
        Graph.resize(3*N-2);
        V=3*N-2;
        for(int i=0;i<N-1;++i){
            Graph[i].emplace_back(0,2*i+1);
            Graph[i].emplace_back(0,2*i+2);
            Graph[2*i+N-1].emplace_back(0,i+2*N-1);
            Graph[2*i+N].emplace_back(0,i+2*N-1);
        }
    }
    void add_edge_from(int k,int l,int r,int p,int q,int v){
        if(r <= p || q <= l) return;
        if(l <= p && q <= r) Graph[3*N-3-k].emplace_back(0LL,v);
        else{
            add_edge_from(2*k+2,l,r,p,(p+q)/2,v);
            add_edge_from(2*k+1,l,r,(p+q)/2,q,v);
        }
    }
    void add_edge_to(int k,int L,int R,int p,int q,int v){
        if(R <= p || q <= L) return;
        if(L <= p && q <= R) Graph[v].emplace_back(0LL,k);
        else{
            add_edge_to(2*k+1,L,R,p,(p+q)/2,v);
            add_edge_to(2*k+2,L,R,(p+q)/2,q,v);
        }
    }
    //[l,r) -> [L,R)
    void add_edge(int l,int r,int L,int R,long long cost){
        if(l>=r||L>=R) return;
        Graph.emplace_back();
        Graph.emplace_back();
        V+=2;
        add_edge_from(0,l,r,0,N,V-2);
        add_edge_to(0,L,R,0,N,V-1);
        Graph[V-2].emplace_back(cost,V-1);
    }
    vector<long long> Dijkstra(int start){
        vector<long long> shortest(V,-1);
        priority_queue<pli,vector<pli>,greater<pli>> pq;
        pq.push(pli(0,start+N-1));
        while(!pq.empty()){
            long long d = pq.top().first;
            int v = pq.top().second;
            pq.pop();
            if(shortest[v]>=0) continue;
            shortest[v] = d;
            for(pli next:Graph[v]){
                if(shortest[next.second]>=0) continue;
                pq.push(pli(d+next.first,next.second));
            }
        }
        vector<long long> res(n);
        rep(i,n) res[i] = shortest[i+N-1];
        return res;
    }
};


int main(){
    int n,m;
    cin >> n >> m;
    range_path G(n);
    rep(i,m){
        int l,r,c;
        cin >> l >> r >> c;
        --l;--r;
        G.add_edge(l,r+1,l,r+1,c);
    }
    vector<ll> d = G.Dijkstra(0);
    cout << d[n-1] << endl;
    return 0;
}

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

int main(){
  int x, y;
  while(true){
    cin >> x >> y;
    if (x == 0 && y == 0){
      break;
    }else{
      if (x >= y){
        cout << y << " " << x << endl;
      }else{
        cout << x << " " << y << endl;
      }
    }
  }
}


Measured memory_bytes: 3084
a, b, c, x = map(int, [input() for _ in range(4)])
ans = 0
# コインの枚数なので、offsetとして+1
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500 * i + 100 * j + 50 * k == x:
                ans += 1
print(ans)


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

//定数
const long long MOD1=1000000007;
const long long MOD2=998244353;
const long double PI=3.1415926535897932;
const long long MAXLL=9223372036854775807;
const long long INF=2305843009213693951;
const long long dx[]={0,1,0,-1,1,-1,1,-1};
const long long dy[]={1,0,-1,0,1,1,-1,-1};

//型名省略
#define ll long long
#define ull unsigned long long
#define ld long double
#define uld unsigned long double
#define pll pair<long long,long long>
#define tll(n) array<long long,(int)(n)>
#define pcc pair<char,char>
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<pair<long long,long long>>
#define vt(n) vector<array<long long,(int)(n)>>
#define umap unordered_map
#define uset unordered_set
#define Lqueue priority_queue<long long>
#define Squeue priority_queue<long long,vector<long long>,greater<long long>>
#define Fi first
#define Se second
#define mp make_pair
#define eb emplace_back

//マクロ
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rbf(a,x) for(auto& a:x)
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s);i<(long long)(n);i++)
#define bitrep(i,s,n) for(long long i=(s);i<(1LL<<(n));i++)
#define Maxe(x) *max_element((x).begin(),(x).end())
#define Mine(x) *min_element((x).begin(),(x).end())
#define Size(x) ((long long)(x).size())
#define lin(s) getline(cin,(s))
#define Ssort(v) sort((v).begin(),(v).end(),[](auto &left,auto &right){return left.second<right.second;})

//Yes,No
void Yes(bool a){cout<<(a?"Yes":"No")<<endl;}
//YES.NO
void YES(bool a){cout<<(a?"YES":"NO")<<endl;}

//MAX,MIN
template<class T,class U> auto max(T a,U b){return a>b?a:b;}
template<class T,class U> auto min(T a,U b){return a<b?a:b;}

//最大公約数,最小公倍数
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a,long long b){return a/gcd(a,b)*b;}

//累乗
template<typename t>
constexpr t mypow(t a,long long b){
    if(b==0)return 1;
    if(a==0)return 0;
    t x=1;
    while(b>0){
        if(b&1LL)x*=a;
        a*=a;
        b>>=1LL;
        }
    return x;
}
#define pow mypow

//chmin,chmax
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}

//組み合わせ O(r)
template<typename t>
constexpr t nCr(t n,long long r){
    if(r==0)return 1;
    if(n==0)return 0;
    if(n<r)return 0;
    t x=1;
    for(long long i=1;i<=r;i++){
        x*=n-i+1;
        x/=i;
    }
    return x;
}

//main関数
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin>>s;
    rep(i,(Size(s)+1)/2)cout<<s[i*2];
}

Measured memory_bytes: 3756