akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[5]; rep(i, 5) cin >> a[i];
    int smaller = inf;
    rep(i, 5) {
        rep(j, 5) {
            if (j == i) continue;
            rep(k, 5) {
                if (k == i || k == j) continue;
                rep(l, 5) {
                    if (l == i || l == j || l == k) continue;
                    rep(m, 5) {
                        if (m == i || m == j || m == k || m == l) continue;
                        int tmp = 0;
                        tmp += (a[i] % 10 == 0 ? a[i] : a[i] - a[i] % 10 + 10);
                        
                        tmp += (a[j] % 10 == 0 ? a[j] : a[j] - a[j] % 10 + 10);
                        tmp += (a[k] % 10 == 0 ? a[k] : a[k] - a[k] % 10 + 10);
                        tmp += (a[l] % 10 == 0 ? a[l] : a[l] - a[l] % 10 + 10);
                        tmp += a[m];
                        smaller = min(smaller, tmp);
                    }
                }
            }
        }
    }
    cout << smaller << endl;
    
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define chmax(p,q)(p=max(p,q))
int a[1010];
int b[1010];

int main(){
	int h,w;
	scanf("%d%d",&h,&w);
	int ans=0;
	rep(i,0,h){
		char s[1010];
		scanf(" %s",s);
		rep(j,0,w)if(s[j]=='B'){
			chmax(ans,a[j]-(h-i)-(w-j));
			chmax(ans,b[j]-(h-i)-   j );
		}
		rep(j,0,w)if(s[j]=='B'){
			chmax(a[j],(h-i)+(w-j));
			chmax(b[j],(h-i)+   j );
		}
		rep(j,0,w-1){
			chmax(a[j+1],a[j]);
			chmax(b[w-1-(j+1)],b[w-1-j]);
		}
	}
	printf("%d\n",ans);
}


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

int main(){
    ll H;
  cin >>H;
  ll count=1;
  ll ans=0;
while(H!=0){
 ans=ans+count;
 H=(H-H%2)/2;
 count=count*2;

}
  
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int[] a = new int[n];
        for(int i=0; i<n; i++) {
            a[i] = sc.nextInt();
        }

        int count = 0;
        boolean isBreak = false;
        while(!isBreak) {
            for(int i=0; i<a.length; i++) {
                if(a[i] % 2 == 0) {
                    a[i] = a[i] / 2;
                } else {
                    isBreak = true;
                    break;
                }
                if(i == a.length-1) {
                    count++;
                }
            }
        }
        System.out.println(count);
        sc.close();
    }
}


Measured memory_bytes: 22100
n=int(input())
s=list(map(int,input().split()))
num=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            if (s[i]!=s[j]) and (s[i]!=s[k]) and (s[j]!=s[k]) and (s[i]+s[j]>s[k]) and (s[i]+s[k]>s[j]) and (s[k]+s[j]>s[i]) :
                num+=1

print(num)

Measured memory_bytes: 73660
import sys
sys.setrecursionlimit(10 ** 7)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

def gcd(a, b):
    while b:
        a, b = b, a%b
    return a
#リストの最小公倍数
def lcm(a):    
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N = ir()
A = lr()
A.sort()
if N == 1:
    print(1)
    exit()
MOD = 10 ** 9 + 7
l = []
first = A[0]
l = [x//gcd(x, first) for x in A[1:]]
x = lcm(l) #B[0]
answer = x%MOD

for i in range(1, N):
    answer += first * x // A[i]

print(answer%MOD)


Measured memory_bytes: 4208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

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() {
	ll n,k;
	cin>>n>>k;
    COMinit();
    for(ll i=0;i<k;i++){
    	ll one=COM(k-1,i);
    	ll two=COM(n+1-k,i+1);
    	cout << (one*two)%inf<<endl;
    }
  //  cout << COM(100000, 50000) << endl;	
	// your code goes here
	return 0;
}

Measured memory_bytes: 12160
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<iomanip>
using namespace std;
int n,num[10005],a[105][105],x,y,cnt=1,t=0;
int read(){
    int ans=0,f=1;
    char ch=getchar();
    while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){ans=ans*10+ch-'0';ch=getchar();}
    return ans*f;
}
int main(){
	std::ios::sync_with_stdio(false);
	x=read(),y=read(),n=read();
	for (int i=1;i<=n;i++)	num[i]=read();
	bool hp=true;
	for (int i=1;i<=x;i++)
		for (int j=1;j<=y+1;j++){
				if (j>y) {hp=!hp;continue;}
				if (hp){a[i][j]=cnt;t++;}else {a[i][y+1-j]=cnt;t++;}
				if (t==num[cnt]) {t=0;cnt++;}
		}
	for (int i=1;i<=x;i++){
		for (int j=1;j<=y;j++)	cout<<a[i][j]<<" ";	
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  
  cin >> a >> b;
 
  if (a * b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else
  {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3592
# coding: utf-8
# Your code here!

num = int(input())

a=0
b=0

for _ in range(num):
    input2 = input().split()
    if input2[0]>input2[1]:
       a=a+3 
    elif input2[0]<input2[1]:
        b=b+3
    else:
        a=a+1
        b=b+1
print(a,b)


Measured memory_bytes: 5600
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int V = Integer.parseInt(sc.next());
        int E = Integer.parseInt(sc.next());
        ArrayList<int[]> edge = new ArrayList<int[]>();
        for (int i=0;i<E;i++) {
            int s = Integer.parseInt(sc.next());
            int t = Integer.parseInt(sc.next());
            int d = Integer.parseInt(sc.next());
            int[] add = {s, t, d};
            edge.add(add);
        }
        Comparator<int[]> comparator = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return Integer.compare(o1[2], o2[2]);
            }
        };
        Collections.sort(edge, comparator);

        UnionFind uf = new UnionFind(V);
        long ans = 0L;
        for (int i=0;i<E;i++) {
            if (uf.root(edge.get(i)[0])!=uf.root(edge.get(i)[1])) {
                ans += edge.get(i)[2];
            }
            uf.connect(edge.get(i)[0], edge.get(i)[1]);
        }
        System.out.println(ans);
    }

    static class UnionFind {
        List<Integer> Parent;
        UnionFind(int N) {
            Parent = new ArrayList<Integer>();
            Integer[] values = new Integer[N];
            Arrays.fill(values, -1);
            Parent.addAll(Arrays.asList(values));
        }
        int root(int A) {
            if (Parent.get(A) < 0)
                return A;
            int root = root(Parent.get(A));
            Parent.set(A, root);
            return root;
        }
        int size(int A) {
            return -Parent.get(root(A));
        }

        boolean connect(int A, int B) {
            A = root(A);
            B = root(B);
            if (A == B) {
                return false;
            }

            if (size(A) < size(B)) {
                int temp = A;
                A = B;
                B = temp;
            }

            Parent.set(A, Parent.get(A) + Parent.get(B));
            Parent.set(B, A);

            return true;
        }
    }
}


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

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

	sort(p, p+n);
	int ans = p[n-1] / 2;
	for (int i = 0; i < n-1; i++) {
		ans += p[i];
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string n;
    int k;
    cin >> n >> k;
    
    vector<char> d(k);
    for(int i = 0; i < k; i++){
        cin >> d.at(i);
    }

    int result;
    int tmp;
    int flag = 0;

    while(1){
        for(int i = 0; i < k; i++){
            for(int j = 0; j < n.size(); j++){
                if(n.at(j) == d.at(i)){
                    flag = 1;
                    break;
                }
            }
        }
        if(flag == 0){
            break;
        }
        tmp = stoi(n);
        tmp++;
        n = to_string(tmp);
        flag = 0;
    }

    result = stoi(n);
    cout << result << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
 
class Main {
	public static void main(String[] args) {
 
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    String S = "";
	    Integer count = 0;
	    HashMap<String, Integer> map = new HashMap<>();
	    
	    for (int i = 1; i <= N ; i++) {
	      S = sc.next();
	      count = map.get(S);
	      if (count == null) count = 1; else count++;
	      map.put(S, count);
	    }
	    
	    Integer AC = map.get("AC"); if (AC == null) AC = 0;
	    Integer WA = map.get("WA"); if (WA == null) WA = 0;
	    Integer TLE = map.get("TLE"); if (TLE == null) TLE = 0;
	    Integer RE = map.get("RE"); if (RE == null) RE = 0;
	    
	    System.out.println("AC x " + AC);
	    System.out.println("WA x " + WA);
	    System.out.println("TLE x " + TLE);
	    System.out.println("RE x " + RE);
  }
}

Measured memory_bytes: 58452
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 5e5 + 5;

ll fact[maxn];

ll C(ll n, ll k) {
	return mul(fact[n], inv(mul(fact[n - k], fact[k])));
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	fact[0] = 1;
	for (ll i = 1; i < maxn; i++) {
		fact[i] = mul(fact[i - 1], i);
	}

	ll n, k; cin >> n >> k;

	if (k >= n - 1) {
		cout << C(n + n - 1, n);
	} else {
		ll sum = 0;
		for (ll cnt = 0; cnt <= k; cnt++) {
			ll ans = 1;
			ans = mul(ans, C(n, cnt));
			ans = mul(ans, C(n - 1, cnt));
			(sum += ans) %= mod;
		}
		cout << sum << endl;
	}
	cout << endl;
	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 4224
using System;
using System.Linq;

public class Program
{
    static public void Main()
    {
        var s = new Sol();
        s.Solve1();
        s.Solve2();
        s.Solve3();
    }
}
public class Sol
{
    //ABC 083 C Multiple Gift
    //https://atcoder.jp/contests/abc083/tasks/arc088_a
    public void Solve1()
    {
        long[] In = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        long x = In[0];
        long y = In[1];
        int cnt = 0;
        while (x  <=  y)
        {
            x *= 2;
            cnt++;
        }
        Console.WriteLine(cnt);
    }

    //
    //
    public void Solve2()
    {

    }

    //
    //
    public void Solve3()
    {

    }
}

Measured memory_bytes: 28080
n,m,v,p = map(int, input().split())
a = list(map(int, input().split()))
a.sort(reverse=True)
def binary_search(left, right):
    if right - left <= 1:
        return left
    middle = (left + right) // 2
    if check(middle):
        return binary_search(middle, right)
    else:
        return binary_search(left, middle)

def check(target):
    used_vote = (p + n - target - 1) * m
    sum_vote = 0
    for i in range(target-1, p-2, -1):
        if a[target] + m < a[i]:
            return False
        sum_vote += (a[target] + m) - a[i]
    if sum_vote >= (m * v - used_vote): 
        return True
    else:
        return False
print(binary_search(0,n) + 1)

Measured memory_bytes: 14480
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <map>
#include <string>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <queue>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

using namespace std;

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

    if (A + B > C + D)
    {
        cout << "Left" << endl;
    }
    else if (A + B < C + D)
    {
        cout << "Right" << endl;
    }
    else
    {
        cout << "Balanced" << endl;
    }

    return 0;
}


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

#define int long long
#define endl '\n'

const int MOD = 1e9 + 7;

int add(int a, int b, int m = MOD) {
    a %= m, b %= m;
    return (a + b) % m;
}

int sub(int a, int b, int m = MOD) {
    return add(a, m - b, m);
}

int mult(int a, int b, int m = MOD) {
    a %= m, b %= m;
    return 1ll * a * b % m;
}

int fpow(int x, int y, int m = MOD) { 
    int res = 1;
    if (y < 0)   y += m - 1;   //only if m is prime
    while (y > 0) {
        if (y & 1)   res = mult(res, x, m);
        x = mult(x, x, m);
        y >>= 1;
    }
    return res;
}

int inv(int a, int md = MOD) {
    a %= md;
    if (a < 0)   a += md;
    int b = md, u = 0, v = 1;
    while (a) {
        int t = b / a;
        b -= t * a; swap(a, b);
        u -= t * v; swap(u, v);
    }
    if (u < 0)   u += md;
    return u;
}

vector<int> fac, ifac;

void precomp(int N = 1e5 + 5) {
    fac.assign(N, 1);
    ifac.assign(N, 1);
    for (int i = 1; i < N; i++)    fac[i] = mult(fac[i - 1], i);
    ifac[N - 1] = inv(fac[N - 1]);
    for (int i = N - 2; i > 0; i--)    ifac[i] = mult(ifac[i + 1], i + 1);
}

int ncr(int n, int r) {
    if (r > n)   return 0;
    return mult(fac[n], mult(ifac[r], ifac[n - r]));
}

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    int n, k; cin >> n >> k;
    vector<int> dp(k + 1, 0);
    int ans = 0;
    for (int i = k; i > 0; i--) {
        dp[i] = fpow(k / i, n);
        for (int j = 2 * i; j <= k; j += i)
            dp[i] = sub(dp[i], dp[j]);
        ans = add(ans, mult(i, dp[i]));
    }
    cout << ans;
}

Measured memory_bytes: 3984
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
const ll MAX = 200010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
vector<bool> done(55,0);
vector<vector<ll>> g(55);
void dfs(ll v,ll a,ll b){
    done[v] = true;
    for (ll u:g[v]){
        if (done[u] || (v == a && u == b) || (u == a && v == b)) continue;
        dfs(u,a,b);
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,a,b;
    cin >> n >> m;
    vector<P> edge(m);
    rep(i,m){
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
        edge[i] = P(a,b);
    }
    ll ans = 0;
    rep(i,m){
        tie(a,b) = edge[i];
        bool ok = 1;
        done.assign(n,0);
        dfs(0,a,b);
        rep(i,n){
            if (!done[i]) ok = 0;
        }
        if (!ok) ans++;
    }
    PRINT(ans);
}

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

int main()
{

    vector<ll> v;
    int N;
    cin >> N;
    int k = 3;
    for (int i = 0; i < N; ++i)
    {
        ll temp;
        cin >> temp;
        v.push_back(temp);
    }
    sort(v.begin(), v.end());
    ll ans = 0;
    for (int i = 0; i < N; ++i)
    {
        for (int j = i + 1; j < N; ++j)
        {
            for (int k = j + 1; k < N; ++k)
            {
                if (v[i] != v[j] && v[j] != v[k])
                {
                    if (v[i] + v[j] > v[k])
                    {
                        ++ans;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}


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

int main(void){
    int N, M;
    cin >> N >> M;
    vector<int> k(M, 0);
    vector<vector<int>> s(M);
    vector<int> p(M, 0);

    // load k and s
    for(int i{0}; i<M; ++i){
        cin >> k.at(i);
        s.at(i) = vector<int>(k.at(i), 0);
        for(int j{0}; j<k.at(i); ++j){
            cin >> s.at(i).at(j);
        }
    }

    // load p
    for(int i{0}; i<M; ++i){
        cin >> p.at(i);
    }

    int n{0};
    for(int biti{0}; biti<(1<<N); ++biti){
        bitset<10> bit(biti);
        bool result{true};
        for(int i{0}; i<M; ++i){
            int sum{0};
            for(int j{0}; j<k.at(i); ++j){
                if(bit.test(s.at(i).at(j)-1)){
                    ++sum;
                }
            }
            if(sum%2 != p.at(i)){
                result = false;
                break;
            }
        }
        if(result){
            ++n;
        }

    }

    cout << n << endl;
}


Measured memory_bytes: 3644
import java.util.*;

public class Main{
	public static void main(String[] args){
		final int MAX = 1 << 15;
		Scanner sc = new Scanner(System.in);
		int[] ans = new int[MAX+1];

		for(int i=0;i*i<=MAX;i++){
			for(int j=i;j*j<=MAX;j++){
				for(int k=j;k*k<=MAX;k++){
					for(int l=k;l*l<=MAX;l++){
						if(i*i+j*j+k*k+l*l <= MAX) ans[i*i+j*j+k*k+l*l]++;
					}
				}
			}
		}

		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			System.out.println(ans[n]);
		}
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#include <cmath>
#define NMAX 102
#define MMAX 10005

//??????????????¢??????????????¨debug()??????????????????
#define DEBUG

using namespace std;

int A[NMAX],B[NMAX],N,M,ans,dp[NMAX][MMAX]={};

void solve(){
	for (int i = 0; i < N; ++i)
	{
		for (int j = 0; j < M+1; ++j)
		{
			if(i == 0){
				if(j != 0){
					if(B[i] <= j){
						dp[i][j] = A[i];
					}else{
						dp[i][j] = dp[i][j-1];
					}
				}
			}else if(B[i] <= j){
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-B[i]] + A[i]);
				dp[i][j] = max(dp[i][j],dp[i][j-1]);
			}else{
				dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
			}
		}
	}
	ans = dp[N-1][M];
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i] >> B[i];
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 6940
n = int(input())
info = [list(map(int, input().split())) for i in range(n)]
info = sorted(info)

t = 0
x = 0
y = 0
for t1, x1, y1 in info:
    diff = abs(x - x1) + abs(y - y1)
    diff_t = abs(t - t1)
    if diff_t >= diff and diff % 2 == diff_t % 2:
        continue
    else:
        print("No")
        exit()
print("Yes")


Measured memory_bytes: 61016
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
    std::string S;
    cin >> S;
    char first = S[0];
    char last = S[S.size()-1];
    cout << first << S.size() - 2 << last << endl;
    return 0;
}

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

int N, Q, ans[MAXN + 3];
vector<int> adj[MAXN + 3];

void DFS(int u, int prv) {
    for (auto v: adj[u]) {
        if (v != prv) {
            ans[v] += ans[u];
            DFS(v, u);
        }
    }
}

int main() {
    cin >> N >> Q;
    for (int i = 1; i < N; i++) {
        int a, b;
        cin >> a >> b;

        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    for (int i = 1; i <= Q; i++) {
        int p, x;
        cin >> p >> x;

        ans[p] += x;
    }

    DFS(1, 1);

    for (int i = 1; i <= N; i++)
        cout << ans[i] << " ";
    cout << endl;
}


Measured memory_bytes: 23424
from fractions import gcd
from itertools import accumulate

n, x, d = map(int, input().split())

if d == 0:
    if x == 0:
        print(1)
    else:
        print(n + 1)
    exit()
elif d < 0:
    x, d = -x, -d

g = gcd(x, d)
back_k = d // g
offset = x // g

lowers = [0] + list(accumulate(range(n)))
uppers = [0] + list(accumulate(range(n - 1, -1, -1)))
min_memo = [10 ** 18] * min(n + 1, back_k)
max_memo = [-(10 ** 18)] * min(n + 1, back_k)
# print(n, x, d, g, back_k, offset)
# print(lowers)
# print(uppers)

ans = 0
for k in range(n + 1):
    min_acc = lowers[k]
    max_acc = uppers[k]

    if k < back_k:
        min_memo[k] = min_acc - offset
        max_memo[k] = max_acc - offset
        ans += max_acc - min_acc + 1
        # print(k, ans, min_acc, max_acc, max_acc - min_acc + 1)
        continue

    kk = k % back_k
    back_min = min_memo[kk]
    back_max = max_memo[kk]

    if back_max < min_acc or max_acc < back_min:
        min_memo[kk] = min_acc - offset
        max_memo[kk] = max_acc - offset
        ans += max_acc - min_acc + 1
    else:
        current = max_acc - min_acc + 1
        duplicated = min(max_acc, back_max) - max(min_acc, back_min) + 1
        ans += current - duplicated
        min_memo[kk] = min(min_acc, back_min) - offset
        max_memo[kk] = max(max_acc, back_max) - offset

    # print(k, ans, min_acc, max_acc, back_min, back_max)

print(ans)


Measured memory_bytes: 42184
import sys
from collections import deque

readline = sys.stdin.readline

ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))

def solve():
  k = ni()
  q = deque()
  q.append(1)
  dist = [k]*k
  dist[1] = 1
  while q:
    v = q.popleft()
    if dist[(v + 1) % k] > dist[v] + 1:
      dist[(v + 1) % k] = dist[v] + 1
      q.append((v + 1) % k)
    if dist[v*10%k] > dist[v]:
      dist[v*10%k] = dist[v]
      q.appendleft(v*10%k)
  print(dist[0])
  return

solve()

Measured memory_bytes: 6064
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index++];return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var s = next();
  var map = {};
  for(var i = 0; i < 4; i++){
    if(map[s[i]] == null){
      map[s[i]] = 0;
    }
    map[s[i]]++;
  }
  var keys = Object.keys(map);
  for(var i = 0; i < keys.length; i++){
    if(map[keys[i]] != 2){
      myout("No");
      return;
    }
  }
  myout((keys.length != 2) ? "No" : "Yes");
}


Measured memory_bytes: 31032
#include <iostream>
// #include <vector> 
#include <algorithm>
#include <queue>
#include <cstdio> 
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<20);
int d[MAX],color[MAX];
int n;
vector<pair<int, int> > adj[MAX];

void dijkstra()
{
    priority_queue<pair<int, int> > PQ;
    for (int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        color[i] = 0;
    } 
    d[0] = 0;
    PQ.push(make_pair(0,0));
    color[0] = 1;
    while (!PQ.empty())
    { 
        pair<int, int> f = PQ.top(); PQ.pop();
        int u = f.second;
        color[u] = 2;
        
        if (d[u] < f.first * (-1)) continue;
        
        for (int j = 0; j < adj[u].size(); j++)
        {
            int v = adj[u][j].first;
            if (color[v] == 2) continue;
            if (d[v] > d[u] + adj[u][j].second)
            { 
                d[v] = d[u] + adj[u][j].second;
                PQ.push(make_pair(d[v] * (-1), v));
                color[v] = 1;
            } 
        } 
    } 

    return;
}


int main()
{
    //freopen("in3.txt","r",stdin);
    int u,k,v,c;
    cin>>n;
    for (int i = 0; i < n; i++)
    {
        cin>>u>>k;
        for (int j = 0; j < k; j++)
        {
            cin>>v>>c;
            adj[u].push_back(make_pair(v,c));
        } 
    } 
    dijkstra();
    for (int i = 0; i < n; i++)
    {
        cout<<i<<" "<<d[i]<<endl; 
    } 
    return 0;
}

Measured memory_bytes: 7968
def main():
    N, M, X = map(int, input().split())

    info = [tuple(map(int, input().split())) for _ in range(N)]
    INF = 10 ** 18
    ans = INF

    for bit in range(1<<N):
        cost = 0
        x = [0] * M
        for i in range(N):
            if (bit>>i) & 1:
                cost += info[i][0]
                for j in range(M):
                    x[j] += info[i][j+1]
        
        
        if all([True if X <= y else False for y in x]):
            ans = min(ans, cost)
    
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9228
n,k = map(int,input().split())
h = sorted([int(input()) for _ in range(n)])
ans = h[k - 1] - h[0]
for i in range(n-k+1):
    if ans >= h[i + k - 1] - h[i]:
        ans = h[i + k - 1] - h[i]
print(ans)

Measured memory_bytes: 8280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

pair<int, int> AB[100000];

int main()
{
	int N;

	cin >> N;
	rep(i, N) cin >> AB[i].first >> AB[i].second;

	sort(AB, AB + N);

	cout << (ll)AB[N - 1].first + (ll)AB[N - 1].second << endl;

	return 0;
}


Measured memory_bytes: 1532
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		char[][] weather = new char[h][w + 1];
		int[][] result = new int[h][w + 1];
		for (int i = 0; i < h; i++) {
			weather[i] = sc.next().toCharArray();
		}
		int cnt;
		for(int i = 0; i < h; i++) {
			cnt = -1;
			for(int k = 0; k < w; k++) {
				if(weather[i][k] == 'c') {
					cnt = 0;
					result[i][k] = cnt;
					cnt = cnt + 1;
				} else if(cnt >= 0) {
					result[i][k] = cnt;
					cnt = cnt + 1;
				} else {
					result[i][k] = cnt;
				}
				
			}
		}
		for(int i = 0; i < h; i++) {
			for(int k = 0; k < w; k++) {
				if(k == w - 1) {
					System.out.println(result[i][k]);
				} else {
					System.out.print(result[i][k] + " ");
				}
			}
		}
	}

}

Measured memory_bytes: 33332
import java.util.Scanner;

//IOIOI
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int m = sc.nextInt();
			char[] s = sc.next().toCharArray();
			int[] c = new int[m];
			int a = 0;
			for(int i=2;i<m;i++){
				if(s[i]=='I'&&s[i-1]=='O'&&s[i-2]=='I'){
					c[i] = c[i-2]+1;
					if(n<=c[i])a++;
				}
			}
			System.out.println(a);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

class Player{
private:
    bool played;
    queue<int> games;
    int id;
public:
    void Set_ID(int i);
    int Get_ID();
    void New_Day(vector<Player*>& active_players);
    bool Can_Play();
    int Next_Game();
    void Play();
    void Input(int i);
};

void Player::Set_ID(int i) {
  id = i;
}

int Player::Get_ID() {
  return id;
}

void Player::New_Day(vector<Player*>& active_players){
  if (played) active_players.push_back(this);
  played = false;
}

bool Player::Can_Play(){
  return !(played or games.empty());
}

int Player::Next_Game() {
  return games.front();
}

void Player::Play() {
  games.pop();
  played = true;
}

void Player::Input(int i) {
  games.push(i);
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<Player> players(n);
  vector<Player*> active_players(n);
  for (int i = 0; i < n; ++i) {
    players[i].Set_ID(i);
    active_players[i] = &players[i];
    for (int j = 0; j < n - 1; ++j) {
      int a;
      cin >> a;
      players[i].Input(a - 1);
    }
  }

  int game = 0;
  int day = 0;
  int prev_game = 0;

  while (game < n * (n - 1) / 2) {
    for (Player* player : active_players) {
      if (not player->Can_Play()) continue;
      Player* opponent = &players[player->Next_Game()];
      if (not opponent->Can_Play()) continue;
      if (player->Get_ID() == opponent->Next_Game()) {
        player->Play();
        opponent->Play();
        ++game;
      }
    }
    if (game == prev_game) {
      cout << -1 << endl;
      return 0;
    }
    prev_game = game;
    ++day;
    active_players.clear();
    for (Player& player: players) {
      player.New_Day(active_players);
    }
  }
  cout << day << endl;
  return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
long long int l,r;
int ans=2019;
int main()
{
	cin>>l>>r;
	if(r-l>=2019)
		ans=0;
	else
		for(long long int i=l;i<=r;i++)
			for(long long int j=l;j<i;j++)
			{
				int z=(i*j)%2019;
				if(z<ans)
					ans=z;
			}
				
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define maxn 100002
int read()
{
	int x=0;char s;
	s=getchar();
	while(!isdigit(s))s=getchar();
	while(isdigit(s))x=(x<<3)+(x<<1)+s-'0',s=getchar();
	return x;
}
int n,m,s,vis[maxn];
vector <int> edg[maxn];
void dfs(int x)
{
	vis[x]=1;
	for(int i=0;i<edg[x].size();i++)
		if(!vis[edg[x][i]])
			dfs(edg[x][i]);
}
int main()
{
	n=read(),m=read();
	for(int i=0;i<m;i++){
		int x,y,z;
		x=read(),y=read(),z=read();
		edg[x].push_back(y);
		edg[y].push_back(x);
	}
	for(int i=1;i<=n;i++)
		if(!vis[i])
			dfs(i),s++;
	cout<<s;
    return 0;
}

Measured memory_bytes: 9216
from collections import defaultdict
n,k=map(int,input().split())
dd=defaultdict(lambda: 0)
for i in range(n):
  a,b=map(int,input().split())
  dd[a]+=b
cur_k=k
for k in sorted(dd.keys()):
  v=dd[k]
  cur_k-=v
  if cur_k <= 0:
    print(k)
    exit()


Measured memory_bytes: 16468
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    for a in A:
        while a % 2 == 0:
            ans += 1
            a //= 2
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 4084
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

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

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

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

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

  vector<int> p(n);
  rep(i, n) {
    cin >> p[i];
    p[i]--;
  }

  UnionFind uf(n);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--;y--;
    uf.unite(p[x], p[y]);
  }

  int res = 0;
  rep(i, n) {
    if(uf.same(p[i], i)) res++;
  }

  cout << res << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<int,int> P;
using vi=vector<int>;
using vvi=vector<vector<int>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
void chmin(int a,int b){if(b<a)a=b;}
void chmax(int a,int b){if(a<b)a=b;}

int main(){
  int n,m;cin>>n>>m;
  vector<P> v(m);
  rep(i,m){
    int a,b;cin>>a>>b;
    v[i]=P(b,a);
  }
  sort(v.begin(),v.end());
  int c=v[0].first;
  int ans=1;
  rep(i,m){
    if(v[i].second>=c){
      c=v[i].first;
      ans++;
    }
  }
  cout<<ans<<endl;
}

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

using namespace std;

int N;

long long lcm(long long a, long long b){
 if(a == 0 || b == 0)
   return max(a, b);
 long long gg = __gcd(a, b);
 return a*(b/gg);
}

int main(){
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  long long res = 1LL;
  for(int i=0; i<N; ++i){
    long long x;
    cin >> x;
    res = lcm(res, x);
  }
  cout << res << "\n";
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N, K;
  cin >> N >> K;
  long long ans = 0;
  long long t = N/K;
  ans += t*t*t;
  if(K%2 == 0){
    t = (N+K/2)/K;
    ans += t*t*t;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORR(i,a,b) for (int i = (a);i>=(b);--i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int H,W;
string S[2010];
int L[2010][2010],R[2010][2010],U[2010][2010],D[2010][2010];

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

  cin >> H >> W;
  REP(i,H) cin >> S[i];
  REP(i,H) {
    REP(j,W) {
      if (S[i][j] == '#') {
        L[i][j] = 0;
      } else {
        L[i][j] = (j == 0 ? 1 : L[i][j-1]+1);
      }
    }
    FORR(j,W-1,0) {
      if (S[i][j] == '#') {
        R[i][j] = 0;
      } else {
        R[i][j] = (j == W-1 ? 1 : R[i][j+1]+1);
      }
    }
  }
  REP(j,W) {
    REP(i,H) {
      if (S[i][j] == '#') {
        U[i][j] = 0;
      } else {
        U[i][j] = (i == 0 ? 1 : U[i-1][j]+1);
      }
    }
    FORR(i,H-1,0) {
      if (S[i][j] == '#') {
        D[i][j] = 0;
      } else {
        D[i][j] = (i == H-1 ? 1 : D[i+1][j]+1);
      }
    }
  }
  int ans = 0;
  REP(i,H) REP(j,W) if (S[i][j] == '.') {
    CHMAX(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3);
  }
  cout << ans << endl;

  return 0;
}

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

long long N, L, T;
long long X[100005];
long long W[100005];

int main(){
	cin >> N >> L >> T;
	bool same = true;
	for(long long i = 0; i < N; i++){
		cin >> X[i] >> W[i];
	}


	long long to = 0;
	for(long long i = 1; i < N; i++){
		if(W[0] == W[i]){
			continue;
		}
		if(W[0] == 1){
			long long dis = 2 * T;
			if(dis >= X[i] - X[0]){
				to++;
				dis -= (X[i] - X[0]);
				to += dis/L;
			}
			to %= N;
		}else{
			long long dis = 2 * T;
			if(dis >= L - (X[i] - X[0])){
				to--;
				dis -= L - (X[i] - X[0]);
				to -= (dis/L)%N;
			}
			to = (to + N)%N;
		}
	}


	for(long long i = 0; i < N; i++){
		if(W[i] == 1){
			X[i] += T;
			X[i] %= L;
		}else{
			X[i] -= T%L;
			X[i] = (X[i] + L) % L;
		}
	}

	long long toval = X[0];
	sort(X, X + N);

	/*
	bool ok = false;
	for(long long i = 0; i < N; i++){
		if(i != N - 1 &&  X[i] > X[i+1]){
			return 1;
		}
		if(X[i] == toval){
			if(ok == true){
				return 1;
			}
			ok = true;
		}
	}
	*/


	long long pos;
	for(long long topos = 0; topos < N; topos++){
		//cout << X[zeropos] << endl;
		if(toval == X[topos]){
			pos = topos;
			if(W[0] == 2){
				break;
			}
		}
	}

	for(long long i = 0; i < N; i++){
		cout << X[(pos - to + i + N)%N] << endl;
	}
	return 0;





}


Measured memory_bytes: 2816
N = int(input())
V = list(map(int, input().split()))

ki = {}
guu = {}

for i in range(len(V)):
    if i % 2 == 0:
        guu.setdefault(str(V[i]), 0)
        guu[str(V[i])] += 1
    else:
        ki.setdefault(str(V[i]), 0)
        ki[str(V[i])] += 1

guu = sorted(guu.items(), key=lambda x: -x[1])
ki = sorted(ki.items(), key=lambda x: -x[1])

if len(guu) == 1 and len(ki) != 1:
    if ki[0][0] != guu[0][0]:
        print(N//2 - ki[0][1])
        exit()
    else:
        print(N//2 - ki[1][1])
        exit()

if len(ki) == 1 and len(guu) != 1:
    if guu[0][0] != ki[0][0]:
        print(N//2 - guu[0][1])
        exit()
    else:
        print(N//2 - guu[1][1])
        exit()

if len(ki) == 1 and len(guu) == 1:
    if ki[0][0] == guu[0][0]:
        print(N//2)
        exit()
    else:
        print(0)
        exit()

if guu[0][0] != ki[0][0]:
    print(N - guu[0][1]-ki[0][1])
    exit()

if guu[0][1] > ki[0][1]:  # guuを採用する
    print(N - guu[0][1] - ki[1][1])
    exit()
if ki[0][1] > guu[0][1]:  # kiを採用する
    print(N - ki[0][1] - guu[1][1])
    exit()

if ki[0][1] == guu[0][1]:  # もし等しいなら
    print(N - ki[0][1] - max(ki[1][1], guu[1][1]))
    exit()


Measured memory_bytes: 23260
#include <stdio.h>

int main() {
	int d, n;

	scanf("%d %d", &d, &n);

	if(n == 100) {
		n += 1;
	}

	for(int i=0;i<d;i++) {
		n = n * 100;
	}

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

	return 0;
}




Measured memory_bytes: 128
S = str(input())
F = S[:2]
L = S[2:]
if F == "00" or int(F)>12:
    if L == "00" or int(L) > 12:
        ans = "NA"
    else:
        ans = "YYMM"
elif int(F) <= 12:
    if int(L) >= 1 and int(L) <=12:
        ans = "AMBIGUOUS"
    else:
        ans = "MMYY"    
print(ans)

Measured memory_bytes: 9032
//Acknowledgement:  Xiaoyu Han, for his "brute-force" proposal

#include <cstdio>
#include <algorithm>
#include <cstdlib>

using std::max;  using std::abs;
using std::min;

const int MAXN=105;

int N,cx,cy,ch=0,c_point;                     //c_point: calculable point
int x[MAXN],y[MAXN],h[MAXN];

int main()
{
    scanf("%d",&N);
    for (int i=1;i<=N;++i)
        scanf("%d%d%d",&x[i],&y[i],&h[i]);
    for (cx=0;cx<=100&&ch<=0;++cx)
        for (cy=0;cy<=100&&ch<=0;++cy)
        {
            for (c_point=1;c_point<=N&&h[c_point]==0;++c_point);
            ch=h[c_point]+abs(x[c_point]-cx)+abs(y[c_point]-cy);
            int i;
            for (i=1;i<=N&&h[i]==max(ch-abs(x[i]-cx)-abs(y[i]-cy),0);++i);
            if (i<=N) ch=0;
        }
    printf("%d %d %d",--cx,--cy,ch);

    return 0;
}


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

int main()
{
	int N;
	cin >> N;
	int res = 0;
	for(int i = 0;i < N;i++){
		int A;
		cin >> A;
		res = __gcd(res, A);
	}
	cout << res << endl;
	return 0;
}


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

int main() {
    long long a, b, x;
    cin >> a >> b >> x;
    long long ans = 0LL;
    long long A = 0LL, B = 0LL;
    if(a == 0LL){
        A = 0;
    } else {
        A = (a-1)/x + 1;
    }
 
    B = b/x + 1;

    cout << B - A << endl;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            bool b = false;

            for (int i=1; i<10; i++)
            {
                for (int j=1; j<10; j++)
                {
                    if (N == i*j) {
                        b = true;
                        break;
                    }
                }
            }
            if (b) {
                Console.WriteLine("Yes");
                }
            else{
                Console.WriteLine("No");
            }
        }
    }
}

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

using namespace std;

int main() {
	string S;
	int N;
	cin >> N;
	cin >> S;
	int cnt = 0;
	for (int i; i < N; i++) {
		if (S[i] == 'R') {
			cnt++;
		}
	}
	if (cnt > N / 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int Q = scan.nextInt();
		int[] A = new int[N];
		for(int i=0;i<Q;i++){
			A[scan.nextInt()-1]++;
		}
		for(int i=0;i<N;i++){
			if(A[i]+K-Q>0){
				System.out.println("Yes");
			}else{
				System.out.println("No");
			}
		}
	}
}

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

int main(){
	int N;
  	cin >> N;
  vector<tuple<string, int, int>>R(N);
  for (int i = 0;i < N;i++){
  	string S;
    int P;
    cin >> S >> P;
    R[i] = make_tuple(S, -P,i+1);
  }
  sort(R.begin(),R.end());
  for(int i = 0;i < N; i++){
  	cout << get<2>(R[i]) << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args){
	Scanner scn = new Scanner(System.in);
	int a = scn.nextInt();
      int b = scn.nextInt();
      int c = scn.nextInt();
      int d = scn.nextInt();
      int x = Math.abs(b-a);
      int y = Math.abs(c-b);
      int z = Math.abs(c-a);
      int check = 0;
      if(z<=d){
        check = 1;
      }
      if(x<=d && y<=d){
        check = 1;
      }
      if(check==1){
        System.out.println("Yes");
      }
      if(check==0){
        System.out.println("No");
      }
	}
}


Measured memory_bytes: 35516
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  string S;
  cin >> S;
  int ans = 0;
  for(int i=0;i<S.size();i++){
    if(S[i] == '+') ans++;
    else ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
steps = [1, 2, 4]
(3..30).to_a.each do |i|
  steps[i] = steps[i-1] + steps[i-2] + steps[i-3]
end

while gets
  n = $_.to_i
  break if n == 0
  puts (steps[n-1]/3650.0).ceil
end

Measured memory_bytes: 6112
from sys import stdin
s = str(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#S = [list(map(int, stdin.readline().rstrip().split())) for _ in range(h)]#hの定義を忘れずに

if s == "ARC":
    print("ABC")
else:
    print("ARC")


Measured memory_bytes: 9084