akhauriyash/Code-Regression huggingface dataset:
<?php
// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d %d", $N, $M, $Q);

// N×Nをまず作る
for ($i = 1; $i <= $N; $i++) {
	$array[$i] = array_pad(array(), $N + 1, 0);
}

for ($i = 1; $i <= $M; $i++) {
	fscanf(STDIN, "%d %d", $L, $R);
	$array[$L][$R]++;
}

if (DEBUG) {
	var_dump($array);
}

if (DEBUG) {
	echo "syukei====\n";
}

for ($y = $N; $y > 0; $y--) {
	for ($x = 1; $x <= $N; $x++) {
		if (DEBUG) {
			echo "{$x} {$y}\n";
		}

		if ($y == $N && $x == 1) {

		} elseif ($x == 1) {
			$array[$y][$x] += $array[$y + 1][$x];
		} elseif ($y == $N) {
			$array[$y][$x] += $array[$y][$x - 1];
		} else {
			$array[$y][$x] += $array[$y][$x - 1] + $array[$y + 1][$x] - $array[$y + 1][$x - 1];
		}
	}
}
if (DEBUG) {
	var_dump($array);
}

for ($i = 0; $i < $Q; $i++) {
	fscanf(STDIN, "%d %d", $p, $q);
	echo $array[$p][$q] . PHP_EOL;
}

Measured memory_bytes: 15480
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

ll query(string &s)
{
	cout<<"? "<<s<<'\n';
	fflush(stdout);
	ll x; cin>>x;
	return x;
}

vector<ii> edges;

void out()
{
	cout<<"! ";
	for(int i=0;i<edges.size();i++)
	{
		cout<<"(";
		cout<<edges[i].fi<<","<<edges[i].se<<")";
		if(i+1<edges.size()) cout<<' ';
	}
	cout<<'\n';
	fflush(stdout);
}

struct DSU
{
	int S;
	
	struct node
	{
		int p; ll sum;
	};
	vector<node> dsu;
	
	DSU(int n)
	{
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	void reset(int n)
	{
		dsu.clear();
		S = n;
		for(int i = 0; i < n; i++)
		{
			node tmp;
			tmp.p = i; tmp.sum = 0;
			dsu.pb(tmp);
		}
	}
	
	int rt(int u)
	{
		if(dsu[u].p == u) return u;
		dsu[u].p = rt(dsu[u].p);
		return dsu[u].p;
	}
	
	void merge(int u, int v)
	{
		u = rt(u); v = rt(v);
		if(u == v) return ;
		if(rand()&1) swap(u, v);
		dsu[v].p = u;
		dsu[u].sum += dsu[v].sum;
	}
	
	bool sameset(int u, int v)
	{
		if(rt(u) == rt(v)) return true;
		return false;
	}
	
	ll getstat(int u)
	{
		return dsu[rt(u)].sum;
	}
};

int main()
{
	vector<ii> possible;
	srand(173);
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			possible.pb(mp(i,j));
		}
	}
	random_shuffle(possible.begin(),possible.end());
	DSU dsu(n);
	for(int i=0;i<possible.size();i++)
	{
		if(dsu.sameset(possible[i].fi,possible[i].se)) continue;
		string s(n,'0');
		s[possible[i].fi]=s[possible[i].se]='1';
		if(query(s)==1)
		{
			dsu.merge(possible[i].fi,possible[i].se);
			edges.pb(possible[i]);
		}
		if(int(edges.size())>=n-1)
		{
			out();
			return 0;
		}
	}
		
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////	
	int n,m;
	cin >> n >> m;
	int a[n],b[n],c[m],d[m];
	REP(i,n) cin >> a[i] >> b[i];
	REP(j,m) cin >> c[j] >> d[j];
	int mint=1e10+1;
	int ans=0;
	REP(i,n){
		REP(j,m){
			if(mint>abs(a[i]-c[j])+abs(b[i]-d[j])){
				ans=j;
				mint=abs(a[i]-c[j])+abs(b[i]-d[j]);
			}
		}
		cout << ans+1 << endl;
		ans=0;
		mint=1e10+1;
	}
//////////////////////////////////////////////
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using vi = vector<int64_t>;
using vvi = vector<vi>;
int64_t INF = 1000000007;
// int64_t INF = 9223372036854775807;

int main() {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n;
    cin >> n;
    vi a(n);
    rep(i,n) cin >> a.at(i);
    int64_t res = 0;
    rep(i,n){
        if(a.at(a.at(i)-1)-1 == i){
            res++;
        }
    }
    cout << res/2 << endl;
}

Measured memory_bytes: 1024
#pragma region
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <list>
#include <iomanip>
#include <cstdint>
#include <cstdlib>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s[0] == '7' || s[1] == '7' || s[2] == '7')cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int a = sc.nextInt();
	        int b = sc.nextInt();
			int X = 0;
	       if(b % a ==0){
	        	X= a + b;
	        }else {
	        	X= b - a;
	        }
	        
	        System.out.println(X);
	}
}

Measured memory_bytes: 21844
/*
 * written by Yaqi Zhang
 * University of Wisconsin-Madison
 * 2020
 */

#include<algorithm>
#include<cstring>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stdio.h>
#include<vector>

#define INF 0x3f3f3f3f

using namespace std;


int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int R;
    cin >> R;
    printf("%.4lf\n", 3.1415926 * 2 * R);
    return 0;

}



Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  for (int i = 0; i < D; i++){
    cout << i % 26 + 1 << endl;
  }
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define ll unsigned long long

int main(){
	int W, H, x, y; // W = total x // H = total y // x = cut x // y = cut y
	cin >> W >> H >> x >> y;
	double ans1 = 0;
	int ans2 = -1;
	ans1 = (double)W * H / 2;
	if(W - x != x or H - y != y){
		ans2 = 0;
	}
	else{
		ans2 = 1;
	}
	cout << fixed << setprecision(6) << ans1; 
	cout << " " << ans2 << endl;
	return 0;
}

Measured memory_bytes: 256
from sys import stdin
from functools import lru_cache

@lru_cache(None)
def solver(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    m, r = divmod(N,10)
    ans = 0
    if K >= 1:
        ans += solver(m, K-1) * r
        ans += solver(m-1, K-1) * (9-r)
    ans += solver(m, K)
    return ans


n = int(input())
k = int(input())
print(solver(n,k))


Measured memory_bytes: 3940
#include<bits/stdc++.h>
#define ll long long
using namespace std;
 
const int MM = 1e9 + 7;
 
int n, m;
int K;
ll pw[2222];
ll f[2222][2222];
ll sum[2222][2222];
 
void solve(int casi){
	cin>>n>>K;
	pw[0] = 1;
	for(int i = 1; i <= 2000; i++){
		pw[i] = (2 * pw[i-1]) % MM;
	}
	f[0][0] = 1;
	for(int i = 0; i <= n; i++)
		sum[0][i] = 1;
	for(int i = 1; i < K; i++){
		for(int j = 0; j <= n - i; j++){
			f[i][j] = sum[i-1][j+1];
		}
		sum[i][0] = f[i][0];
		for(int j = 1; j <= n - i; j++)
			sum[i][j] = (sum[i][j-1] + f[i][j]) % MM;
	}
	cout<<((K!=n)?(sum[K - 1][n - K] * pw[n-K-1] % MM):sum[K - 1][n - K])<<endl;
}
 
 
int main(){
	solve(1);
	return 0;
}

Measured memory_bytes: 46848
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

using ll = long long;
using P = pair<ll,ll>;

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll IMF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//




//配るDP


//入力
int N;
ll h[100010];

//DPテーブル
ll dp[100010];

int main(){
        int N;
        cin >> N;
        for(int i = 0; i < N; i++) cin >> h[i];

        //初期化（最小化問題だからIMFで初期化する。)
        for(int i = 0; i < 100010; i++) dp[i] = IMF;

        //初期条件
        dp[0] = 0;

        //ループ
        for(int i = 0; i < N; i++){
                chmin(dp[i+1], dp[i] + abs(h[i] - h[i+1]));
                chmin(dp[i+2], dp[i] + abs(h[i] - h[i+2]));
        }

        //答え
        cout << dp[N-1] << endl;
}


















































Measured memory_bytes: 1792
import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	long f(long n) {
		if (n < 2) {
			return 1;
		} else {
			return n * f(n - 2);
		}
	}

	long calc(long n) {
		if (n % 2 != 0) {
			return 0;
		}
		long result = n / 10;

		for (int i = 1; i < 1000; i++) {
			long x = (long) Math.pow(5, i) * 10;
			if (x > n) {
				break;
			}
			result += n / x;
		}
		return result;
	}

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		long N = sc.nextLong();

		sc.close();

		out.println(calc(N));

//		for(int i=0;i<100;i++) {
//			System.err.println(i + " : " + f(i));
//		}
//		System.err.println("--");

//		calc(250);

//		for(int i=0;i<10000;i++) {
//			BigDecimal d = f2(new BigDecimal(i));
////			System.err.println(i  + " : " + cntZero(d.toPlainString()));//+ " : " + d);
//			System.err.println(i  + " : " + cntZero(d.toPlainString()) + " : " + calc(i)  );//+ " : " + d);
//		}
//		System.err.println("--");		

	}

	BigDecimal f2(BigDecimal n) {
		if (n.compareTo(new BigDecimal(2)) < 0) {
			return BigDecimal.ONE;
		} else {
			return n.multiply(f2(n.subtract(new BigDecimal(2))));
		}
	}

	long cntZero(String s) {
		if (s.isEmpty()) {
			return 0;
		}
		if (s.endsWith("0")) {
			return 1 + cntZero(s.substring(0, s.length() - 1));
		} else {
			return 0;
		}
	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 23124
/*
Author : Vidish Joshi
*/

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

//#include<boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;

#define ll long long int
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007
#define FOR1(i, m, n) for(i=m; i<n; i++)
#define FOR2(i, n, m) for(i=n-1; i>=m; i--)
#define re(v) ll v; cin>>v
#define mod 1000000007
#define mod2 998244353
#define mp make_pair
#define pb push_back
#define fill(a) memset(a, 0, sizeof(a))
#define start ll t; cin>>t; while(t--)
#define br "\n"

int main(){
    FIO;
    ll k, a, b; cin>>k>>a>>b;
    for(ll i=a; i<=b; i++){
        if(i%k==0){
            cout<<"OK\n";
            return 0;
        }
    }
    cout<<"NG\n";
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int max_len = 0;
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i < n; ++i) {
        for (int j = i + 1; j <= n; ++j) {
            if (s[i-1] == s[j-1]) {
                int len = min(dp[i-1][j-1]+1, j-i);
                dp[i][j] = len;
                if (len > max_len) {
                    max_len = len;
                }
            }
        }
    }
    cout << max_len << "\n";
    return 0;
}


Measured memory_bytes: 98176
import numpy as np


def cumprod(arr, MOD):
    L = len(arr)
    Lsq = int(L**.5 + 1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n - 1]
        arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n - 1, -1]
        arr[n] %= MOD
    return arr.ravel()[:L]


def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64)
    x[0] = 1
    fact = cumprod(x, MOD)
    return fact[-1]


N, M = map(int, input().split())
if N > M:
    N, M = M, N
if N + 1 < M:
    print(0)
    exit()
elif N + 1 == M:
    c = 1
else:
    c = 2
MOD = 10**9 + 7
# print("make_fact(N, MOD)", make_fact(N + 1, MOD), N)
ans = ((make_fact(N + 1, MOD) * make_fact(M + 1, MOD) % MOD) * c) % MOD
print(ans)


Measured memory_bytes: 14556
H, W, D = map(int, input().split())
pos = [None]*(H*W)

for i in range(H):
    row = list(map(int, input().split()))
    for j in range(W):
        pos[row[j]-1] = (i, j)

costs = [0]*(H*W)
for i in range(1, D+1):
    current = i + D
    while current <= H*W:
        costs[current - 1] = costs[current - 1 - D] + abs(pos[current - 1][0] - pos[current - 1 - D][0]) + abs(pos[current - 1][1] - pos[current - 1 - D][1])
        current += D

Q = int(input())
for _ in range(Q):
    L, R = map(int, input().split())
    MP = costs[R-1] - costs[L-1]
    print(MP)

Measured memory_bytes: 14256
/*input
async layered coding
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int main()
{
	IOS;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b<c+d) cout<<"Right";
	else if(a+b==c+d) cout<<"Balanced";
	else cout<<"Left";
	return 0;
}


Measured memory_bytes: 256
function Main(input) {
    var n = parseInt(input, 10);
    var j = 1;
    var i = 1;
    var k = [];
        while(n >= i) {
        var i = Math.pow(j, 2);
        k.push(i);
        j++
    }
    console.log(k[k.length-2]);
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

long long saiki(vector<bool> plus, string &s) {
	int n = s.size();
	if (plus.size() == n - 1) {
		long long now = s[0] - '0';
		long long all = 0;
		FOR(i, 0, plus.size()) {
			if (plus[i]) {
				all += now;
				now = s[i + 1] - '0';
			}
			else {
				now = 10 * now + s[i + 1] - '0';
			}
		}
		all += now;
		return all;
	}
	vector<bool> plus2(plus);
	plus.push_back(true);
	plus2.push_back(false);
	return saiki(plus, s) + saiki(plus2, s);
}

int main() {
	string s;
	cin >> s;
	int n = s.size();

	long long sumx = saiki(vector<bool>(), s);
	cout << sumx << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

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

    int n = sc.nextInt();

    int count = 0;
    int max = 0;
    long a = sc.nextLong();
    long b ;

    for(int i=0; i<n-1; i++){
      b = sc.nextLong();
      if(a>=b){
        count += 1;
        if(max<count){
          max = count;
        }
      }else{
        count = 0;
      }
      a = b;
    }
    System.out.println(max);




  }
}

Measured memory_bytes: 48600
#include<iostream>
using namespace std;
int main(){
	int num1[] = {1,3,5,7,8,10,12};
	int num2[] = {4,6,9,11};
	int x, y, i;
	cin >> x >> y;
	if(x==2||y==2){
		cout << "No" << endl; 
	}else{
		int is1 = 0, is2 = 0;
		for(i = 0; i < 7; i++){
			if(x==num1[i]){
				is1 = 1;
			}
			if(y==num1[i]){
				is2 = 1;
			}
		}
		if(is1&&is2){
			cout << "Yes" << endl;
		}else{
			is1 = 0, is2 = 0;
			for(i = 0; i < 4; i++){
				if(x==num2[i]){
					is1 = 1;
				}
				if(y==num2[i]){
					is2 = 1;
				}
			}
			if(is1&&is2){
				cout << "Yes" << endl;
			}else{
				cout << "No" << endl;
			}
		}
	}
	return 0; 
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000

int main()
{
    // ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
   vector<double> v;
   double x;
   ll n;
   cin>>n;
   for(ll i=0; i<n; i++) {
        cin>>x;
        v.push_back(x);
   }

    sort(v.begin(), v.end());
   double ans = (v[0]+v[1])/2;
   for(ll i=2; i<n; i++) {
        ans = (ans + v[i])/2;
   }

   cout<<fixed<<setprecision(10)<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <stack>
using namespace std;

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

  int count = 0;
  int point = 0;
  while(1) {
    count++;
    point+=a;
    //cout << count << " " << point << endl;
    if(count % 7 == 0) point+=b;
    if(point >= c) {
      cout << count << endl;
      break;
    }
  }

  return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 10005
#define INF 1000000005LL
//#define INF 1e18
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int n,m;
int v[105],w[105];
int dp[105][SIZE];

int main(){
  cin >> n >> m;
  rep(i,0,n){
    cin >> v[i+1] >> w[i+1];
  }

  rep(i,1,n+1){
    rep(j,1,m+1){
      int a=0,b=0;
      if(j-w[i] >= 0)a = dp[i][j-w[i]] + v[i];

      b = dp[i-1][j];
      dp[i][j] = max(a,b);
      //cout << i << j << dp[i][j] << endl;
    }
  }
  cout << dp[n][m] << endl;

  return 0;
}



Measured memory_bytes: 7016
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vll ans(50);
    ll k;
    cin >> k;
    ll x = k / 50;
    ll r = k % 50;
    rep(i, 50) {
        if (i < r) ans[i] = 49 + x + 51 - r;
        else ans[i] = 49 + x - r;
    }
    cout << 50 << endl;
    rep(i, 50) {
        if (i != 0) cout << " " << endl;
        cout << ans[i];
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; string s;
    cin >> n >> s;
    map<char, ll> cnt;
    rep(i, n) cnt[s[i]]++;
    ll pattern = 1;
    for(auto &num: cnt) pattern = (pattern * (num.second+1))%MODV;
    cout << pattern-1 << endl;
}

Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

ll N;
ll ga, sa, ba, gb, sb, bb;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cin >> N >> ga >> sa >> ba >> gb >> sb >> bb;
	VLL DP1(N+1,0);
	for (ll n = 0; n <= N; n++) {
		DP1[n] = n;
		if (n >= ga)DP1[n] = max(DP1[n], DP1[n - ga] + gb);
		if (n >= sa)DP1[n] = max(DP1[n], DP1[n - sa] + sb);
		if (n >= ba)DP1[n] = max(DP1[n], DP1[n - ba] + bb);
	}
	ll max1 = 0;
	for (ll n = 0; n <= N; n++) {
		max1 = max(max1, DP1[n]);
	}
	VLL DP2(max1+1, 0);
	for (ll n = 0; n <= max1; n++) {
		DP2[n] = n;
		if (n >= gb)DP2[n] = max(DP2[n], DP2[n - gb] + ga);
		if (n >= sb)DP2[n] = max(DP2[n], DP2[n - sb] + sa);
		if (n >= bb)DP2[n] = max(DP2[n], DP2[n - bb] + ba);
	}
	ll max2 = 0;
	for (ll n = 0; n <= max1; n++) {
		max2 = max(max2, DP2[n]);
	}
	cout << max2 << "\n";
	return 0;
}

Measured memory_bytes: 195584
import java.util.*;

public class Main {

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

    if (a > 8 || b > 8) {
      System.out.println(":(");
      return;
    } else {
      System.out.println("Yay!");
    }
  }
}


Measured memory_bytes: 21716
#include<cstdio>
#include<cstring> 
#include<iostream>
#include<algorithm>
using namespace std;
const int M=1200000;
int n,m,w[M],v[M],sum;long long dp[M];
int main(){
	scanf("%d%d",&n,&m);
	dp[0]=0;
	for(int i=1;i<=n;i++) scanf("%d%d",&w[i],&v[i]),sum+=v[i];
	for(int i=1;i<=sum;i++) dp[i]=1000000000ll*100ll+1ll;
	for(int i=1;i<=n;i++)
	for(int j=sum;j>=v[i];j--)
		dp[j]=min(dp[j-v[i]]+w[i],dp[j]);
	for(int i=sum;i>=0;i--) if(dp[i]<=m){
		printf("%d",i) ;break;
	}
	
}

Measured memory_bytes: 5120
import sys

readline = sys.stdin.readline

def solve():
    R, C, K = map(int, readline().split())
    items = [[0] * C for i in range(R)]
    for i in range(K):
        r,c,k = map(int, readline().split())
        items[r - 1][c - 1] = k
    
    dp = [[[0] * C for i in range(R)] for j in range(4)]

    for i in range(R):
        for j in range(C):
            for k in range(4):
                if i == 0 and j == 0:
                    if k == 0:
                        dp[k][i][j] = 0
                    else:
                        dp[k][i][j] = items[i][j]
                elif i == 0:
                    if k == 0:
                        dp[k][i][j] = dp[k][i][j - 1]
                    else:
                        dp[k][i][j] = max(dp[k - 1][i][j - 1] + items[i][j], dp[k][i][j - 1])
                elif j == 0:
                    if k == 0:
                        dp[k][i][j] = dp[3][i - 1][j]
                    else:
                        dp[k][i][j] = dp[3][i - 1][j] + items[i][j]
                else:
                    if k == 0:
                        dp[k][i][j] = max(dp[3][i - 1][j], dp[k][i][j - 1])
                    else:
                        dp[k][i][j] = max(
                            dp[3][i - 1][j] + items[i][j],
                            dp[k - 1][i][j - 1] + items[i][j],
                            dp[k][i][j - 1]
                        )

    print(dp[-1][-1][-1])

solve()

Measured memory_bytes: 421792
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter

sys.setrecursionlimit(10**7)
n = int(input())
v = list(map(int, input().split()))

v1 = v[0::2]
v2 = v[1::2]

c1 = Counter(v1).most_common()
c2 = Counter(v2).most_common()

cnt1 = c1[0][1]
cnt2 = c2[0][1]

if c1[0][0] != c2[0][0]:
    print(n-cnt1-cnt2)
else:
    if len(c1)==1 or len(c2)==2:
        print(n//2)
    else:
        cnt11 = n - c1[1][1] - c2[0][1]
        cnt22 = n - c1[0][1] - c2[1][1]
        print(min(cnt11, cnt22))


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

using ll = long long;
using ull = unsigned long long;
using namespace std;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;


int main(){
    cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    
    int m,k;
    cin>>m>>k;
    if(1<<m <= k){
        cout << -1 << endl;
        return 0;
    }
    if(m == 1 and k == 1){
        cout << -1 << endl;
        return 0;
    }
    if(m == 1 and k == 0){
        cout << "0 0 1 1" << endl;
        return 0;
    }
    for(int i=0;i<1<<m;++i)if(i!=k)cout << i << " ";
    cout << k << " ";
    for(int i=(1<<m)-1;i>=0;--i)if(i!=k)cout << i << " ";
    cout << k << endl;
    return 0;
    
}

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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

ll dp[60][2];

signed main() {
    LCIN(N, K);
    VL A(N);
    VECCIN(A);
    Fill(dp, -1);
    dp[59][0] = 0;
    REPR(d, 58) {
        ll now = 1LL << d;
        ll num = 0;
        REP(i, N) if(A[i] & now) num++;
        if(dp[d + 1][1] >= 0)
            dp[d][1] = max(dp[d][1], dp[d + 1][1] + now * max(num, N - num));
        if(K & now) {
            dp[d][0] = max(dp[d][0], dp[d + 1][0] + now * (N - num));
            dp[d][1] = max(dp[d][1], dp[d + 1][0] + now * num);
        } else {
            dp[d][0] = max(dp[d][0], dp[d + 1][0] + now * num);
        }
    }
    cout << max(dp[0][1], dp[0][0]) << "\n";
}


Measured memory_bytes: 1024
#include<iostream> 

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

int main() {
	int a, b;
	char s;
	cin >> a >> s >> b;
	if (s == '+') {
		cout << a + b << endl;

	}if (s == '-') {
		cout << a - b << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3608
#include <cstdio>

int f(char *t, char *h){
    if (t[0] == '\0' && h[0] == '\0'){
        return 0;
    }else if(t[0] == h[0]){
        return f(&t[1], &h[1]);
    }else if(t[0] < h[0]){
        return 1;
    }else{
        return -1;
    }
}

int main(){
    int n, r, tp = 0, hp = 0;
    char t[100], h[100];
    scanf("%d", &n);
    for(int i = 0; i<n; i++){
        scanf("%s", t);
        scanf("%s", h);
        r = f(t, h);
        if (r == -1){
            hp += 3;
        }else if(r == 1){
            tp += 3;
        }else{
            hp ++;
            tp ++;
        }
    }
    printf("%d %d\n", hp, tp);
    return 0;
}


Measured memory_bytes: 2756
N, K, Q = map(int, input().split())
A = []

for i in range(Q):
    a = int(input())
    A.append(a)

R = [K-Q] * (N + 1)

for ai in A:
    R[ai] += 1

for ri in R[1:]:
    if ri >= 1:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 11240
from fractions import gcd
import sys

N, X = map(int,input().split())
lis = list(map(int,input().split()))
diff = []


for i in range(N):
	diff.append(abs(X-lis[i]))

x=diff[0]
for j in range(N-1):
	x = gcd(x,diff[j+1])
print(x)

Measured memory_bytes: 16280
using System;
using System.Collections;
using System.Collections.Generic;
 
class TEST{
	static void Main(){
		while(true){
			var n=long.Parse(Console.ReadLine());
			if(n==0)break;
			Sol mySol =new Sol(n);
			mySol.Solve();
		}
	}
}

class Sol{
	public void Solve(){
		if(N==1){
			Console.WriteLine("deficient number");
			return;
		}
		Dictionary<long,long> PD=PrimDec(N);
		
		long Sum=1;
		foreach(long i in PD.Keys){
			long d=1;
			for(int j=0;j<PD[i]+1;j++)d*=i;
			d-=1;
			d/=(i-1);
			Sum*=d;
			if(Sum>2*N)break;
		}
		Sum-=N;
		
		if(Sum==N)Console.WriteLine("perfect number");
		if(Sum<N)Console.WriteLine("deficient number");
		if(Sum>N)Console.WriteLine("abundant number");
		
		return;
	}

	long N;
	public Sol(long n){
		N=n;
	}


	Dictionary<long,long> PrimDec(long A){
		Dictionary<long,long> D=new Dictionary<long,long>();
		if(A==1)return null;
		long rem=A;
		for(long i=2;i<=(long)Math.Sqrt((double)A);i++){
			if(rem%i==0){
				long cnt=0;
				while(rem%i==0){cnt++;rem/=i;}
				D.Add(i,cnt);
			}
			if(rem==1)break;
	    	}
		if(rem!=1)D.Add(rem,1);
		return D;
	}


	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(){return Console.ReadLine().Split(' ');}
	static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
	static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
	static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}

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

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


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

typedef long long ll;
typedef unsigned long long ull;

ll dfs(ll X, ll iL, const vector<ll>& nP, const vector<ll>& nB){
    if(X==0) return 0;
    if(iL==0) return 1;

    X--;
    ll res = 0;
    if(X >= nP[iL-1]+nB[iL-1]){
        res += nP[iL-1];
        X -= nP[iL-1]+nB[iL-1];
    }else{
        return res + dfs(X, iL-1, nP, nB);
    }

    if(X==0) return res;
    X--; res++;

    if(X >= nP[iL-1]+nB[iL-1]){
        res += nP[iL-1];
        X -= nP[iL-1]+nB[iL-1];
    }else{
        return res + dfs(X, iL-1, nP, nB);
    }
    X--;

    return res;
}

int main()
{
    ll N, X;
    cin >> N >> X;
    vector<ll> nP(51, 0);
    vector<ll> nB(51, 0);
    nP[0] = 1;
    for(int i=1;i<=50;i++){
        nP[i] = 1 + 2 * nP[i-1];
        nB[i] = 2 + 2 * nB[i-1];
    }
    auto res = dfs(X, N, nP, nB);
    cout<<res<<endl;

    return 0;
}

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

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

const int INF = 1e9;
const int MOD = 1e9+7;

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

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

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

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

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


int main(){
    double N,a,b;
    cin>>N;
    for(double i=floor(sqrt(N));i>=1;i--){
        a=floor(N/i);
        b=i;
        if(a*b==N) break;
    }
    ll ans=a+b-2;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,m,k;
  cin >> n;//カードの枚数2n
  cin >> m;//操作の回数
  int mnt[2*n];
  int kazu[2*n];
  for(int i=0; i<2*n; i++){
    mnt[i] = i+1;
  }
  for(int i=0; i<m; i++){
    cin >> k ;
    if(k==0){
      for(int l=0; l<n; l++){
          kazu[2*l] = mnt[l];
          kazu[2*l+1] = mnt[l+n];
        }
      for(int l=0; l<2*n; l++){
        mnt[l]=kazu[l];
      }
      }

    else{
      for(int l=0; l<2*n-k; l++){
        kazu[l] = mnt[k+l];
      }
      for(int l=0; l<k; l++){
        kazu[2*n-k+l] = mnt[l];
      }
      for(int l=0; l<2*n; l++){
        mnt[l]=kazu[l];
      }
    }
    }
    for(int i=0; i<2*n; i++){
    cout << kazu[i] <<endl;
    }
    }


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define vec vector
#define pb push_back
#define ft first
#define sd second
#define all(vec) vec.begin(), vec.end()
#define endl "\n"

typedef pair<int, int> P;

const int MOD = 1e9 + 7;
const int INF = 1e9;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};

// char to int
int ctoi(char c) {if (c >= '0' && c <= '9') {return c - '0';}return 0;}

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



int main(){

	//input and initialization//
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll ac = a*c;
	ll ad = a*d;
	ll bc = b*c;
	ll bd = b*d;

	cout << max(max(ac,ad),max(bc,bd));

	return 0;
}

Measured memory_bytes: 3644
N = int(input())
I = []

for _ in range(N):
  I.append(list(map(int, input().split())))

L = sorted(I)
R = sorted(I, key = lambda x: x[1])

if N%2 == 1:
  x = N//2
  print(R[x][1] - L[x][0] + 1)
else:
  x = N//2
  M = R[x][1] - L[x][0] + 1
  m = R[x-1][1] - L[x-1][0] + 1
  print(M + m - 1)

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

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

using namespace std;
using ll = long long;


int main(void)
{
  ll a, b, c, d;
  cin >> a >> b >> c >> d;

  if (max(a*c, a*d) >= max(b*c, b*d)) {
    cout << max(a*c, a*d) << endl;
  } else {
    cout << max(b*c, b*d) << endl;
  }
}

Measured memory_bytes: 3628
n = int(input())
heap = [-1] + list(map(int,input().split()))

for i in range(1,n+1):
    print("node {}: key = {}, " .format(i, heap[i]), end = '')
    if i!=1:
        print("parent key = {}, " .format(heap[i//2]), end = '')
    if i*2<=n:
        print("left key = {}, " .format(heap[i*2]), end ='')
    if i*2+1<=n:
        print("right key = {}, ".format(heap[i*2+1]), end='')
    print()

Measured memory_bytes: 7760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int a[n];
    map<int, int> mp;
    bool all0 = true;
    rep(i, 0, n) {
        cin >> a[i];
        if (a[i] != 0) all0 = false;
        mp[a[i]]++;
    }

    if (n % 3 == 0) {
        if (mp.size() >= 4) {
            cout << "No" << endl;
        } else if (mp.size() == 3) {
            int x[3];
            int cnt = 0;
            for (auto i : mp) {
                if (i.second != n / 3) {
                    cout << "No" << endl;
                    return 0;
                }
                x[cnt] = i.first;
                cnt++;
            }
            if ((x[0] ^ x[1]) == x[2]) cout << "Yes" << endl;
            else cout << "No" << endl;
        } else if (mp.size() == 2) {
            bool f1 = false;
            bool f2 = false;
            for (auto i : mp) {
                if (i.first == 0 && i.second == n / 3) f1 = true;
                if (i.second == n * 2 / 3) f2 = true;
            }
            if (f1 && f2) cout << "Yes" << endl;
            else cout << "No" << endl;
        } else {
            if (all0) cout << "Yes" << endl;
            else cout << "No" << endl;
        }
    } else {
        if (all0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}


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

int main() {
  int N, Q;
  cin >> N >> Q;
  string S;
  cin >> S;
  int wa[N + 1];
  wa[0] = 0;
  wa[1] = 0;
  for (int i = 2; i <= N; i++) {
    wa[i] = wa[i - 1];
    if (S[i - 1] == 'C' && S[i - 2] == 'A') wa[i]++;
  }
  int l, r, ans;
  for (int i = 0; i < Q; i++) {
    cin >> l >> r;
    ans = wa[r] - wa[l];
    cout << ans << '\n';
  }
  return 0;
}

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

void findPermutations(vector<int> v1, vector<int> v2,int n)
{
	int idx1, idx2, flag1, flag2, k = 0;
	vector<int> v3(v1), v4(v2);
	sort(v1.begin(), v1.end());
    for (int i = 0; i < n; i++) {
        if (v3[i] != v1[i]) {
            flag1 = 1;
            break;
        }
    }
    if (flag1 == 0)
        idx1 = 0;
    for (int i = 0; i < n; i++) {
        if (v4[i] != v1[i]) {
            flag2 = 1;
            break;
        }
    }
    if (flag2 == 0)
        idx2 = 0;
	do {
		k++;
		flag1 = flag2 = 0;
        for (int i = 0; i < n; i++) {
            if (v3[i] != v1[i]) {
                flag1 = 1;
            }
            if (v4[i] != v1[i]) {
                flag2 = 1;
            }
        }
        if (flag1 == 0)
            idx1 = k;
        if (flag2 == 0)
            idx2 = k;

	} while (next_permutation(v1.begin(), v1.end()));
	cout << abs(idx1 - idx2) << endl;
}
int main() {
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> v1(n), v2(n);
    for (int i = 0; i < n; i++) {
        cin >> v1[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> v2[i];
    }
    findPermutations(v1, v2, n);
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (1) {
		int t;
		string s;
		cin >> t >> s;
		if (!t)break;
		int n = s.size(), cnt = 0, cmax = -1;
		vi ans;
		REP(i, (1 << n - 1)) {
			int sum = 0;
			int tmp = 0;
			vi x;
			REP(j, n) {
				tmp *= 10;
				tmp += s[j] - '0';
				if (i & 1 << j) {
					sum += tmp;
					x.push_back(tmp);
					tmp = 0;

				}
			}
			sum += tmp;
			x.push_back(tmp);
			if (sum <= t) {
				if (sum == cmax)cnt++;
				else if (sum > cmax) {
					cnt = 1;
					cmax = sum;
					ans = x;
				}
			}
		}
		if (cmax == -1)cout << "error" << endl;
		else if (cnt > 1)cout << "rejected" << endl;
		else {
			cout << cmax << " ";
			DUMP(ans);
		}
	}
	return 0;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()
#define m_p make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n,cnt=1;
    string s;
    cin >> n >> s;
    char tmp = s[0];
    REP(i,1,s.size()){
        if(tmp != s[i]) cnt++;
        tmp = s[i];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 512
h,w = map(int,input().split())
n = int(input())
a = (list(map(int,input().split())))
l = []
for i in range(n):
    s = i+1
    t = a[i]
    #s:色　t:その色の個数
    for j in range(t):
        l.append(s)
for i in range(h):
    a = l[w*i:w*i+w]
    if i%2==0:
        print(*a)
    else:
        print(*a[::-1])

Measured memory_bytes: 3828
from collections import defaultdict
import math


def kari():
    map(int, input().split())
    list(map(int, input().split()))
    math.ceil()

def main():
    num, coust_num, start = map(int, input().split())
    data = set(list(map(int, input().split())))

    left = 0
    for i in range(1, start):
        if i in data:
            left += 1


    right = 0
    for i in range(start + 1, num):
        if i in data:
            right += 1

    print(min(right, left))








if __name__ == '__main__':
    main()



Measured memory_bytes: 38256
if __name__ == "__main__":
    N = int(input())
    if N <= 1:
        print (1)
        exit()

    res_cnt = 0
    res = 0
    for x in range(N + 1):
        cnt = 0
        y = x
        while (y > 1):
            if y % 2 == 0:
                y //= 2
                cnt += 1
            else:
                break
        if cnt > res_cnt:
            res_cnt = cnt
            res = x
    print (res)


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
 
 
 
int main() {
  df(n);
  rrep(i,INF) {
    int x = i*(i+1)/2;
    if (x > n) {
      rrep(j,i) {
        if (x-n == j) continue;
        printf("%d\n", j);
      }
      break;
    }
  }
  return 0;
}
 
 
 
 
 

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		
		if(S.equals("ABC")) {
			System.out.println("ARC");
		}else if(S.equals("ARC")) {
			System.out.println("ABC");
		}

	}

}


Measured memory_bytes: 35684