akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

int main(){
    std::string s;
    int x, y;
    std::cin >> s >> x >> y;
    
    std::vector< int > X_move;
    std::vector< int > Y_move;
    bool XY = true;
    int initial_X = 0;
    int a = 0;
    
    for(; a<s.size(); a++){
        if(s[a] == 'F'){
            initial_X++;
        }else{
            break;
        }
    }
    
    for(; a<s.size(); a++){
        if(s[a] == 'F'){
            if(XY){
                X_move[X_move.size() - 1]++;
            }else{
                Y_move[Y_move.size() - 1]++;
            }
        }else{
            XY = XY ^ 1;
            if(XY){
                X_move.push_back(0);
            }else{
                Y_move.push_back(0);
            }
        }
    }
    
    std::map< int, int > X_list;
    X_list[initial_X] = 1;
    for(int i=0; i<X_move.size(); i++){
        std::map< int, int > new_X_list;
        for(auto j=X_list.begin(); j!=X_list.end(); j++){
            new_X_list[j->first + X_move[i]] = 1;
            new_X_list[j->first - X_move[i]] = 1;
        }
        X_list = new_X_list;
    }
    
    std::map< int, int > Y_list;
    Y_list[0] = 1;
    for(int i=0; i<Y_move.size(); i++){
        std::map< int, int > new_Y_list;
        for(auto j=Y_list.begin(); j!=Y_list.end(); j++){
            new_Y_list[j->first + Y_move[i]] = 1;
            new_Y_list[j->first - Y_move[i]] = 1;
        }
        Y_list = new_Y_list;
    }
    
    bool ok = true;
    auto itr = X_list.find(x);
    if(itr == X_list.end()){
        ok = false;
    }
    itr = Y_list.find(y);
    if(itr == Y_list.end()){
        ok = false;
    }
    
    if(ok){
        std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    
    return 0;
    
}


Measured memory_bytes: 4148
#include<stdio.h>
#include<cstdlib>

int main(){
    int n;
    scanf("%d", &n);

    int w[n + 1];
    for(int i = 1; i < n + 1; i++){
        scanf("%d", w + i);
    }

    
    int sum[n + 1];
    sum[1] = w[1];
    for(int t = 2; t < n + 1; t++){
        sum[t] = sum[t - 1] + w[t];
    }

    int min = 10000000;
    int max = sum[n];
    for(int t = 1; t < n + 1; t++){
        if(std::abs(sum[t] - (max - sum[t])) < min){
            min = std::abs(2 * sum[t] - max);
        }
    }
    printf("%d", min);
}

Measured memory_bytes: 128
a = [int(num) for num in input().split()]
counts = [0 for i in range(a[0])]
for i in range(0,a[1]):
    b = [int(num) for num in input().split()]
    counts[b[0]-1]+=1
    counts[b[1]-1]+=1
for i in counts:
    print(i)

Measured memory_bytes: 3060
#include <cstdio>
 
 
int main(){
 
 
int n;
int a;
 
scanf("%d %d",&n,&a);
 
if(n<500){
if(n<=a) printf("Yes");
else printf("No");
return 0;
}else {
n = n - (n/500)*500;
if(n<=a) printf("Yes");
else printf("No");
}
 
 
return 0;
}


Measured memory_bytes: 128
n, x = map(int, input().split())

level = [1]
p = [1]
for i in range(n):
    level.append(level[i]*2 + 3)
    p.append(p[i]*2 + 1)
#print(level)
#print(p)


def f(N, X):
    # 終了条件
    if N == 0:
        if X <= 0:
            return 0
        else:
            return 1
    mid = (level[N]+1)//2
    if X < mid:
        return f(N-1, X-1)
    elif X == mid:
        return p[N-1] + 1
    elif mid < X:
        return p[N-1] + 1 + f(N-1, X-mid)


ans = f(n, x)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


ull e[210000];
ull n;
ull x;
ull a[210000];
ull ans=ULLONG_MAX;


main(){
  cin>>n>>x;
  rep(i,n){
    cin>>a[i];
  }

  rrep(i,n){
    e[i]+=a[i]+e[i+1];
    //cout<<e[i]<<' ';
  }
  //cout<<endl;

  FOR(k,1,n+1){
    ull res=0;
    int j=1;
    for(int i=n;i>=0;i-=k){
      if(j==1){
        res+=5*(e[max(0LL,i-k)]-e[i]);
      }else{
        res+=(2*j+1)*(e[max(0LL,i-k)]-e[i]);
      }
      j++;
    }
    //cout<<res<<endl;
    ans=min(ans,k*x+res);
  }

  cout<<n*x+ans<<endl;
}


Measured memory_bytes: 3328
//https://dwacon5th-prelims.contest.atcoder.jp/tasks/dwacon5th_prelims_a
#include<bits/stdc++.h>
using namespace std;

int main(){
    double ans=0.0,n,arr[105];
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> arr[i];
        ans +=arr[i];
    }
    ans/=n;
    double mins = 105;
    int idx=0;
    for(int i=0; i<n; i++){
        if(abs(ans-arr[i])<mins){
            mins = abs(ans-arr[i]);
            idx=i;
        }
    }
    cout << idx <<endl;
}


Measured memory_bytes: 256
#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 rep(i,a,b) for(i=(a);i<=(b);i++)
#define ll int64_t
#define pll pair<ll, ll>
#define pii pair<int,int>
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define maxn 100005
#define inf 4e18
#define boost ios::sync_with_stdio(false);cin.tie(0)
#define fr freopen("source.txt","r",stdin),freopen("output.txt","w",stdout)
#define SET(a,b) memset(a,b,sizeof(a))
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define all(x) x.begin(), x.end()
#define ps(x,y) fixed<<setprecision(y)<<x
//template<typename T>
//using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out <<  "(" << a.F << ", " << a.S << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {
	out << "[";
	for (auto it = a.begin(); it != a.end(); ++it) {
		if (it != a.begin())
			out << ", ";
		out << *it;
	}
	return out << "]";
}
map<ll,ll>dp;
ll n,a,b,c,d;
ll go(ll i){
	if(i==0) return 0;
	if(dp.count(i)) return dp[i];
	dp[i]=inf;
	if(i<(inf)/d) dp[i]=d*i;
	ll x,y;
	x=i;
	y=0;
	while(x%2!=0){
		x--;
		y++;
	}
	dp[i]=min(dp[i],d*y+a+go(x/2));
	x=i;
	y=0;
	while(x%2!=0){
		x++;
		y++;
	}
	dp[i]=min(dp[i],d*y+a+go(x/2));

	x=i;
	y=0;
	while(x%3!=0){
		x--;
		y++;
	}
	dp[i]=min(dp[i],d*y+b+go(x/3));
	x=i;
	y=0;
	while(x%3!=0){
		x++;
		y++;
	}
	dp[i]=min(dp[i],d*y+b+go(x/3));

	x=i;
	y=0;
	while(x%5!=0){
		x--;
		y++;
	}
	dp[i]=min(dp[i],d*y+c+go(x/5));
	x=i;
	y=0;
	while(x%5!=0){
		x++;
		y++;
	}
	dp[i]=min(dp[i],d*y+c+go(x/5));
	return dp[i];
}
int main()
{
	boost;
	ll i,j,x,t,y;
	cin>>t;
	while(t--){
		dp.clear();
		cin>>n>>a>>b>>c>>d;
		cout<<go(n)<<"\n";
	}
}

Measured memory_bytes: 4496
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, m, c = 0, d = 0; lint s = 0;
  scanf("%d %d", &n, &m);
  v1li a(n), p(n+1, 0), q(n+1, 0); vector<pii> b(m);
  rep(i, n) scanf("%ld", &a[i]);
  rep(i, m) scanf("%d %d", &b[i].se, &b[i].fi);
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  priority_queue<int> pq;
  rep(i, n){
    if(c >= m) break;
    pq.push(b[c].fi); ++d;
    if(d == b[c].se){
      ++c;
      d = 0;
    }
  }
  rep(i, n){
    p[i+1] += p[i] + a[i];
    if(pq.empty()) q[i+1] = q[i];
    else{
      q[i+1] += q[i] + pq.top();
      pq.pop();
    }
  }
  rep(i, n+1) s = max(s, p[i]+q[n-i]);
  printf("%ld\n", s);
  return 0;
}

Measured memory_bytes: 3964
import math
n = int(input())
xy = [list(map(int,input().split())) for i in range(n)]
a = math.factorial(n)
cnt = 0
for i in range(n):
	for j in range(n):
		if i == j:
			continue
		cnt += math.sqrt(((xy[i][0]-xy[j][0])**2 + (xy[i][1] - xy[j][1])**2))
print (cnt/n)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1LL << 60;

template <typename T>
void print(const T &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

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

// 約数列挙
vector<ll> factorization(ll N)
{
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++)
    {
        if (N % i == 0)
        {
            if (i != 1)
            {
                ret.push_back(i);
            }
            if (i != N / i)
            {
                ret.push_back(N / i);
            }
        }
    }
    return ret;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    auto fac1 = factorization(n - 1);
    ans += fac1.size();
    auto fac2 = factorization(n);
    for (ll f : fac2)
    {
        ll ncp = n;
        while (ncp % f == 0)
        {
            ncp /= f;
        }
        if (ncp % f == 1)
        {
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define int long long
#define endl '\n'
#define ll long long
#define ld long double
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vpi vector<pi>

const int MOD = 1e9 + 7;
const ll INF = 1ll<<60;
const int MX = 1e5 + 5;
const ld PI = 4 * atan((ld)1);
int dp[MX];
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n,wt;
	cin>>n>>wt;
	memset(dp,MOD,sizeof(dp));
	dp[0]=0;
	for(int i=0;i<n;i++){
		int w,v;
		cin>>w>>v;
		for(int j=MX-1;j>=v;j--)
			dp[j]=min(dp[j],dp[j-v]+w);
	}
	int ans=0;
	for(int i=0;i<MX;i++)
		if(dp[i]<=wt) ans=i;
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;

            WriteLine(Pow(N,3));
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

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

#define int 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; }

#define MOD 998244353

template<int64_t mod> struct Combination{
    vector<int64_t> f, rf;
 
    Combination(int max_n): f(max_n+1), rf(max_n+1){
        f[0] = 1;
        for(int i = 1;i <= max_n;i++) f[i] = f[i-1] * i % mod;
		int64_t a = f[max_n], inv = 1;
		for(int64_t b = mod-2;b > 0;b>>=1){
			if(b & 1) inv = inv*a % mod;
			a = a * a % mod;
		}
		for(int i = max_n;i >= 0;i--) inv = (rf[i] = inv) * i % MOD;
    }
 
    int64_t operator()(int n, int r){
        return (r < 0 || n < r) ? 0 : f[n] * rf[r] % mod * rf[n-r] % mod;
    }
};

int pow_mod(int n, int m){
	int ans = 1;
	while(m > 0){
		if(m & 1) ans = (ans * n) % MOD;
		n = (n * n) % MOD;
		m >>= 1;
	}
	return ans;
}

signed main(){
	int n, m, k;
	cin >> n >> m >> k;

	Combination<MOD> ncr(1000000);

	int ans = pow_mod(m, n);

	int tmp = 0;
	for(int i = k+1;i < n;i++){
		tmp = m * (pow_mod(m-1, n-i-1) * ncr(n-1, i) % MOD) % MOD;
		ans = (MOD +ans - tmp) % MOD;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 18836
a,b,c=map(int,input().split())
aa=[]
bb=[]
cc=[]
ans=0
while a%2==0 and b%2==0 and c%2==0:
  ans+=1
  aa.append(a)
  bb.append(b)
  cc.append(c)
  a,b,c=(b+c)//2,(c+a)//2,(a+b)//2
  if a in aa and b in bb and c in cc:
    print(-1)
    break
else:
  print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>

int top=0;
int z[100];
char s[100];

void push(int x)
{
	top++;
	z[top] = x;
}

int pop()
{
	top--;
	return z[top+1];
}

int main(void)
{
	int a=0, b=0, c=0, d=0;
	
	while(scanf("%s",s) != EOF)
	{
		if(s[0] == '+')
		{
			push(pop() + pop());
		}
		else if(s[0] == '-')
		{
			a = pop();
			b = pop();
			push(b - a);
		}
		else if(s[0] == '*')
		{
			push(pop() * pop());
		}
		else
		{
			push(atoi(s));
		}
	}
	
	printf("%d\n", pop());
	
	return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

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

    if(b == 1) {
        cout << 0 << endl;
    } else {
        cout << ((b - a) + (a - 1) - 1) / (a - 1) + 1 << endl;
    }

    return 0;
}


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

int main() {
  int a,b;
  cin >> a >> b;
  
  int prod;
  prod = a*b;
  
  if (prod % 2 ==1)
    cout << "Odd" << endl;
  
  else
    cout << "Even" << endl;
}

Measured memory_bytes: 256
input = readlines()

total = input.shift.to_i

orig = input.shift.chomp.split("\s").map{|x| x.to_i}
input_total = input.shift.to_i

list = {}
total = 0
orig.each do |n|
  list[n] = 0 if list[n].nil?
  list[n] += 1
  total += n
end

input.each do |l|
  v1, v2 = l.chomp.split("\s").map{|x| x.to_i}
  change_num = list[v1].to_i
  diff = (v2 - v1) * change_num
  total += diff
  puts total
  list[v1] = 0
  list[v2] = 0 if list[v2].nil?
  list[v2] += change_num
end


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

static const long MAX = 1000000L;
 
int main() {
    vector<long> prime;
    vector<long> dp;
    bool isPrime;
    long n, m;
 
    long i, len = sqrt(MAX) + 1;
    long j, lenJ;
    long k;
     
    prime.push_back(2);
    dp.push_back(0);
	dp.push_back(0);
	dp.push_back(1);

    for (i = 3; i <= len; i += 2) {
        isPrime = true;
        lenJ = prime.size();
        k = sqrt(i) + 1;
        for (j = 0; j < lenJ; j++) {
            if (k <= prime[j]) break;

            if (i % prime[j] == 0) {
                isPrime = false;

                break;
            }
	}

        if (isPrime) prime.push_back(i);
    }

    lenJ = prime.size();
     
    while (cin >> n) {
	if (n < dp.size()) {
		cout << dp[n] << endl;

		continue;
	}
         
	m = dp.size();
        for (i = m; i <= n; i += 2) {
            isPrime = true;

            k = sqrt(i) + 1;
            for (j = 0; j < lenJ; j++) {
                if (k <= prime[j]) break;

                if (i % prime[j] == 0) {
                    isPrime = false;

                    break;
                }
            }

            if (isPrime) {
		dp.push_back(dp.back() + 1);
		dp.push_back(dp.back());
	    } else {
		dp.push_back(dp.back());
		dp.push_back(dp.back());
	    }
        }
         
        cout << dp[n] << endl;
    }
 
    return 0;
}

Measured memory_bytes: 11104
#include<bits/stdc++.h>
#define lson now<<1
#define rson now<<1|1
using namespace std;
const int maxn=200009;
const int inf=1e9;

int n,m;

struct SegmentTree{
	int l,r;
	int tag,nt;
	int mn;
}tree[maxn<<2];
void pushup(int now){
	tree[now].mn=min(tree[lson].mn,tree[rson].mn);
}
void puttag(int now,int tag){
	tree[now].tag=tag;
	tree[now].nt=1;
	tree[now].mn=tag+tree[now].l;
}
void pushdown(int now){
	if(!tree[now].nt)return;
	puttag(lson,tree[now].tag);
	puttag(rson,tree[now].tag);
	tree[now].nt=0;
}
void build(int now,int l,int r){
	tree[now].l=l;tree[now].r=r;tree[now].tag=inf;tree[now].nt=0;
	if(l==r){
		tree[now].mn=1;return;
	}
	int mid=(l+r)>>1;
	build(lson,l,mid);
	build(rson,mid+1,r);
	pushup(now);
}
void update(int now,int ll,int rr,int tag){
	if(tree[now].l>=ll&&tree[now].r<=rr){
		puttag(now,tag);return;
	}
	pushdown(now);
	int mid=(tree[now].l+tree[now].r)>>1;
	if(ll<=mid)update(lson,ll,rr,tag);
	if(rr>mid)update(rson,ll,rr,tag);
	pushup(now);
}
int query(int now,int ll,int rr){
	if(tree[now].l>=ll&&tree[now].r<=rr){
		return tree[now].mn;
	}
	pushdown(now);
	int mid=(tree[now].l+tree[now].r)>>1,ret=inf;
	if(ll<=mid)ret=min(ret,query(lson,ll,rr));
	if(rr>mid)ret=min(ret,query(rson,ll,rr));
	return ret;
}

int main(){
	scanf("%d%d",&n,&m);
	build(1,1,m);
	for(int i=1;i<=n;++i){
		int l,r;scanf("%d%d",&l,&r);
		int t;
		t=l-1?query(1,l-1,l-1):inf;
		update(1,l,r,t-l+1);
		t=query(1,1,m);
		if(t>m)printf("-1\n");
		else printf("%d\n",t+i-1);
	}
	
	return 0;
}

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

int main() {
	char s[101] = { 0 }, p[101] = { 0 }, s2[202] = {0};

	scanf("%s %s", s,p);

	
	strcpy(s2,s);

	strcat(s2, s);

	if (strstr(s2,p) == NULL) printf("No\n");
	else printf("Yes\n");


	return 0;
}


Measured memory_bytes: 2100
#include <iostream>
using namespace std;
void solve()
{   int a,b,c,k; cin >> a >> b >> c >> k;
    if(k-a<=0) cout << k;
    else
    {
        if(k-a-b<=0) cout << a;
        else cout << a-(k-a-b);
    }
}

int main()
{
    solve();
}


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

typedef long long ll;

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,W;
    cin >> n >> W;
    vector<vector<ll>> dp(n+1,vector<ll>(100010,1LL<<40));
    dp[0][0] = 0;
    for (int i = 0;i < n;++i) {
        ll w,v;
        cin >> w >> v;
        for (int j = 0;j < 100010;++j) {
            dp[i+1][j] = dp[i][j];
            if (j-v >= 0 && dp[i+1][j] > dp[i][j-v]+w) dp[i+1][j] = dp[i][j-v]+w;
        }
    }
    int ans = 0;
    for (int i = 0;i < 100010;++i) if (dp[n][i] <= W) ans = i;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
int dp[100001],color[100001];
vector<int> e[100001];

void paint(int v,int d,int c){
	if(!color[v]) color[v]=c;
	if(dp[v]>=d || d==0)return;
	dp[v]=d;
	for(auto u:e[v]) paint(u,d-1,c);
}

int main(){
	int N,M,Q,a,b;
	cin>>N>>M;
	rep(i,M){
		cin>>a>>b;
		e[a].push_back(b);
		e[b].push_back(a);
	}
	cin>>Q;
	int v[Q],d[Q],c[Q];
	rep(i,Q)cin>>v[i]>>d[i]>>c[i];
	for(int i=Q-1;i>=0;i--)paint(v[i],d[i],c[i]);
	rep(i,N)cout<<color[i+1]<<endl;
}

Measured memory_bytes: 8440
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;

int main(){
	string s;
	cin >> s;
	while(1){
		if(s=="ABC"){
			cout << "Yes" << endl;
			return 0;
		}
		if(s.size()<=3){
			cout << "No" << endl;
			return 0;
		}
		int n = s.size();
		vector<bool> v(n);
		for(int i=1;i<n-1;i++){
			if(s[i-1]=='A'&&s[i]=='B'&&s[i+1]=='C'){
				v[i-1] = 1;
				v[i] = 1;
				v[i+1] = 1;
			}
		}
		int a=0,b=0,c=0;
		for(int i=0;i<n;i++){
			if(!v[i]){
				if(s[i]=='A'){
					a++;
				}else if(s[i]=='B'){
					b++;
				}else{
					c++;
				}
			}
		}

		string t;
		if(a==0){
			if(b!=0&&c!=0){
				int p=0;
				while(1){
					if(p==n)break;
					if(v[p]==1){
						t.push_back('A');
						p+=3;
					}else{
						t.push_back(s[p]);
						p++;
					}
				}
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
		if(b==0){
			if(a!=0&&c!=0){
				int p=0;
				while(1){
					if(p==n)break;
					if(v[p]==1){
						t.push_back('B');
						p+=3;
					}else{
						t.push_back(s[p]);
						p++;
					}
				}
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
		if(c==0){
			if(b!=0&&a!=0){
				int p=0;
				while(1){
					if(p==n)break;
					if(v[p]==1){
						t.push_back('C');
						p+=3;
					}else{
						t.push_back(s[p]);
						p++;
					}
				}
			}else{
				cout << "No" << endl;
				return 0;
			}
		}
		s = t;
	}
	return 0;
}


Measured memory_bytes: 3248
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    string s, t;
    cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if (s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000
typedef struct{
  int p,l,r;
}Node;

Node N[MAX];
int root;

void Preorder(int i){
  if(i==-1)return;
  printf(" %d",i);
  Preorder(N[i].l);
  Preorder(N[i].r);
}

void  Inorder(int i){
  if(i==-1)return;
  Inorder(N[i].l);
  printf(" %d",i);
  Inorder(N[i].r); 
}
 
void  Postorder(int i){
  if(i==-1)return;
  Postorder(N[i].l);
  Postorder(N[i].r);
  printf(" %d",i);
} 

int main(){
  int n;
  int i;
  int id;
 
  scanf("%d",&n);

  for(i=0;i<100000;i++){
    N[i].p = N[i].l = N[i].r = -1;
  }

  for(i=0;i<n;i++){//input
    scanf("%d",&id);
    scanf("%d",&N[id].l);
    scanf("%d",&N[id].r);
      
    if(N[id].l!=-1) N[N[id].l].p = id;
    if(N[id].r!=-1) N[N[id].r].p = id;
  }
 
  for(root=id;N[root].p!=-1;root=N[root].p){;}//あるものの、親をどんどん辿って、ルートのid発見

  printf("Preorder\n");//PRINT
  Preorder(root);printf("\n");
  printf("Inorder\n");
  Inorder(root);printf("\n");
  printf("Postorder\n");
  Postorder(root);printf("\n");

  return 0;
}



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

int main(){
  int n,k;cin>>n>>k;
  int p=1;
  int count = 0;
  for(int i; i<n;i++){
    p*=2;
    count++;
    if(p>k) break;
  }
  p += k*(n-count);
  cout << p << endl;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e13 + 5);

const int MAX_N = (int)(3e2 + 5);

int n, m;
ll l;

ll path[MAX_N][MAX_N];

ll jump[MAX_N][MAX_N];

int q;

void calc_shortest_paths() {
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (path[i][j] > path[i][k] + path[k][j]) {
          path[i][j] = path[i][k] + path[k][j];
        }
      }
    }
  }
}

void calc_shortest_jumps() {
  for (int k = 1; k <= n; ++k) {
    for (int i = 1; i <= n; ++i) {
      for (int j = 1; j <= n; ++j) {
        if (jump[i][j] > jump[i][k] + jump[k][j]) {
          jump[i][j] = jump[i][k] + jump[k][j];
        }
      }
    }
  }
}

int main(void) {
  // Here your code !
  scanf("%d %d %lld", &n, &m, &l);

  // initialize
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      path[i][j] = INF;
      path[j][i] = INF;
    }
    path[i][i] = 0L;
  }

  for (int i = 0; i < m; ++i) {
    int a, b;
    ll c;

    scanf("%d %d %lld", &a, &b, &c);

    path[a][b] = c;
    path[b][a] = c;
  }

  calc_shortest_paths();

  // prepare jump graph
  for (int i = 1; i <= n; ++i) {
    for (int j = i + 1; j <= n; ++j) {
      jump[i][j] = INF;
      jump[j][i] = INF;

      if (path[i][j] <= l) {
        jump[i][j] = 1L;
        jump[j][i] = 1L;
      }
    }
    jump[i][i] = 0L;
  }

  calc_shortest_jumps();

  scanf("%d", &q);

  for (int i = 0; i < q; ++i) {
    int s, t;
    scanf("%d %d", &s, &t);

    if (jump[s][t] == INF) {
      printf("%d\n", -1);
      continue;
    }

    ll ans = jump[s][t] - 1L;

    printf("%lld\n", ans);
  }

  return 0;
}


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

int gcd(int a, int b){
    if(a==0){
        return b;
    }
    return gcd(b%a, a);
}
int main() {
    // cout<<gcd(10,23);
    int x; cin>>x;
    cout<<360/gcd(360,x);
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int P = 998244353;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
template <typename T> void write(T x) {
	if (x < 0) x = -x, putchar('-');
	if (x > 9) write(x / 10);
	putchar(x % 10 + '0');
}
template <typename T> void writeln(T x) {
	write(x);
	puts("");
}
int n; char s[MAXN];
int dp[MAXN][2][3][3];
bool AllTheSame() {
	for (int i = 1; i <= n; i++)
		if (s[i] != s[1]) return false;
	return true;
}
bool NotAdjSame() {
	for (int i = 2; i <= n; i++)
		if (s[i] == s[i - 1]) return false;
	return true;
}
void update(int &x, int y) {
	x = (x + y) % P;
}
int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	if (AllTheSame()) {
		writeln(1);
		return 0;
	}
	if (n <= 3) {
		if (n == 2) writeln(2);
		else if (s[1] != s[2] && s[1] != s[3] && s[2] != s[3]) writeln(3);
		else if (s[1] == s[3]) writeln(7);
		else writeln(6);
		return 0;
	}
	for (int i = 0; i <= 2; i++)
		dp[1][0][i][i] = 1;
	for (int i = 2; i <= n; i++) {
		for (int e = 0; e <= 1; e++)
		for (int s = 0; s <= 2; s++)
		for (int f = 0; f <= 2; f++)
		for (int j = 0; j <= 2; j++)
			update(dp[i][e | (f == j)][(s + j) % 3][j], dp[i - 1][e][s][f]);
	}
	int ans = 0, sum = 0;
	for (int i = 1; i <= n; i++)
		sum = (sum + s[i] - 'a') % 3;
	for (int i = 0; i <= 2; i++)
		update(ans, dp[n][1][sum][i]);
	update(ans, NotAdjSame());
	writeln(ans);
	return 0;
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
//F6編譯，右上三角形執行，ctrl+c強制停止執行  F5開啟exe
#define ll long long
#define maxn 200005
#define mod 1000000007
using namespace std;

typedef pair<ll, ll> P;

int main()
{
    string s;
    cin >> s;
    int n = s.length();
    if (n % 2 == 1)
    {
        printf("No\n");
        return 0;
    }
    bool ok = 1;
    for (int i = 0; i < n; i++)
    {
        if (i % 2 == 0)
        {
            if (s[i] != 'h')
                ok = 0;
        }
        else
        {
            if (s[i] != 'i')
                ok = 0;
        }
    }
    if (ok)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
int main() {
	string s;cin >> s;
    int ans=0,cnt=0;
    for(int i=0;i<s.size();i++){
        if(s.at(i) == 'A'||s.at(i) == 'C'||s.at(i) == 'G'||s.at(i) == 'T'){
            cnt++;
            if(ans < cnt){
                ans = cnt;
            }
        }else{
            cnt=0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i = 0; i < n; i++)
#define pb push_back
#define all(c) c.begin(),c.end()



int main()
{
    map<string,int> m;
    int n;
    cin >> n;
    for(int i =0; i < n; i++)
    {
        string s;
        cin >> s;
        m[s]++;
    }
    cout << m.size();
}


Measured memory_bytes: 19228
#include <stdio.h>

int main(void) {
	int H,W,i,j;

	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0) break;
		for(i=1;i<=H;i++){
			putchar('#');
			for(j=1;j<W;j++){
				putchar('#');
			}
			putchar('\n');
		}
		putchar('\n');
	}
	return 0;

}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
const int MOD = 1000000007;
const int INF = 1e9;
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    vector<int> ans(n);
    rep(i,n){
        cin >> s[i] >> p[i];
    }
    rep(i,n){
        ans[i]=1;
    }

    // vector<pair<int,int>> sp;
    // for(int i=0;i<n;i++){
    //     sp[i] = make_pair(s[i],p[i]);
    // }
    // // 前の要素から比較される
    // sort(sp.begin(),sp.end());

    // rep(i,n){
    //     ans[i] = i;
    // }

    // vector<pair<int,int>> ians;
    // for(int i=0;i<n;i++){
    //     ians[i] = make_pair(i,ans[i]);
    // }
    
    rep(i,n){
        rep(j,n){
            if(s[i] > s[j]){
                ans[i]++;
            }
            else if(s[i] == s[j]){
                if(p[i] < p[j]){
                    ans[i]++;
                }
            }
        }
    }\

    vector<pair<int,int>> ansi(n);
    for(int i=0;i<n;i++){
        ansi[i] = make_pair(ans[i],i);
    }

    sort(ansi.begin(),ansi.end());

    
    rep(i,n){
        cout << ansi[i].second+1<< endl;
    }
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

typedef vector<int> vi;
typedef vector<pair<int,int> > vii;
typedef long long ll;
typedef pair<int, int> pii;



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n , m;
    cin >> n >> m;
    vi v(n);
    for(int &x : v)cin >> x;
    vii op(m);
    for(auto &p : op)cin >> p.sc >> p.fr;


    sort(ALL(v));
    sort(RALL(op));
    int idx = 0;
    for(auto p : op){
        while(idx < n && p.sc && p.fr > v[idx]){
            v[idx] = p.fr;
            idx++;
            p.sc--;
        }
    }

    ll sum = 0;
    loop(i,n)sum += v[i];
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
#define MAX 10000
#define NIL -1

struct Node {
  int p;
  int l;
  int r;
};
struct Node T[MAX];
int n;

void preParse(int u){
  if(u==NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u==NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u==NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v,l,r,root;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].p=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d %d %d", &v, &l, &r);
    T[v].l=l;
    T[v].r=r;
    if(l!=NIL) T[l].p=v;
    if(r!=NIL) T[r].p=v;
  }

  for(i=0;i<n;i++){
    if(T[i].p==NIL) root=i;
  }
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
fun main() {
    val (x, n) = readLine()!!.split(" ").map{ it.toInt() }
    val p = readLine()
    if (p.isNullOrEmpty()) {
        print(x)
        return
    }
    
    val pList = p.split(" ").map{ it.toInt() }
    var i = 0
    while (true) {
        if (!pList.contains(x - i)) {
            println(x - i)
            return
        }
        if (!pList.contains(x + i)) {
            println(x + i)
            return
        }
        i++
    }
}

Measured memory_bytes: 36104
#include<stdio.h>
#include<string>
#include<string.h>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>
#include <cmath>
#include <limits>
#include <numeric>
#include <cmath>
#include <limits>

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)

int main(){
    ll x;
    scanf("%lld",&x);
    for(int i=0;i<=x/100;i++){
        ll zan=x-i*100;
        if(zan>=0 && zan<=5*i){
            printf("1\n");
            return 0;
        }
    }
    printf("0\n");
    return 0;
}

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

#define endl "\n"

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal variable
//------------------------------------------
int N,M;
VI Vec;

//動的計画法で役に立つ関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

//最大公約数と最小公倍数
ll gcd(ll a, ll b) {
    if(b==0)return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a/g*b;
}

int main() 
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string S; cin >> S;
    SORT(S);

    if (S.at(0) == S.at(1) and S.at(2) == S.at(3)) 
    {
        if (S.at(0) != S.at(2))
        {
        cout << "Yes" << endl; 
        }
        else cout << "No" << endl;
    }
    else cout << "No" << endl;
  
    return 0;
}



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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int a, b, c, ans;
  cin >> a >> b >> c;
  ans = min({a + b, a + c, b + c});

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

// 0-index

vector<int> G[MAX]; //グラフ
list<int> out;  //トポロジカルソートされたもの
bool V[MAX]; //そのノードが使用されたかどうか
int N;  //頂点数
int indeg[MAX]; //各ノードに入る辺の数

void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s]=true;
    while(!q.empty()){
        int u=q.front();
        q.pop();
        out.push_back(u);
        for(int i=0;i<(ll)G[u].size();i++){
            int v=G[u][i];
            indeg[v]--;
            if(indeg[v]==0 && !V[v]){
                V[v]=true;
                q.push(v);
            }
        }
    }
}

void  tsort(){
    // indegを0で初期化
    for(int i=0;i<N;i++){
        indeg[i]=0;
    }
    // 各頂点のindegを求める
    for(int u=0;u<N;u++){
        for(int i=0;i<(ll)G[u].size();i++){
            int v= G[u][i];
            indeg[v]++;
        }
    }
    // 入る辺がない頂点から全探索を始める
    for(int u=0;u<N;u++){
        if(indeg[u]==0 && !V[u]) bfs(u);
    }
    if((ll)out.size()!=N) cout<<1<<endl;
    else cout<<0<<endl;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s,t,M;
    cin>>N>>M;
    rep(i,N) V[i]=false;
    rep(i,M){
        cin>>s>>t;
        G[s].pb(t);
    }
    tsort(); 
    return 0;
}


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




int main(){
    ll N;cin>>N;
    ll a[100010],sum=0,x[100010];
    rep(i,0,N){
        cin>>a[i];
        sum+=a[i];
    }
    sum/=2;
    for(int i=0;2*i+1<N;i++){
        sum-=a[2*i+1];
    }
    x[0]=sum;
    rep(i,1,N){
        x[i]=a[i-1]-x[i-1];
    }
    rep(i,0,N){
        cout<<2*x[i];
        if(i!=N-1)cout<<" ";
    }
    cout<<endl;
    
}







Measured memory_bytes: 2816
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;

int main(void) {
  int scan; // scanf result
  double answer; // to output 
  int n; // to input 

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

  answer = n * 2 * 3.141592;

  printf("%lf", answer);
  return (0);
}


Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000010LL;
const int MAX=310;
const double EPS=1e-9;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
	int n;cin>>n;
	ll a[300010];
	for(int i=0;i<3*n;i++){
		cin>>a[i];
	}
	sort(a,a+3*n);
	ll ans=0;
	for(int i=n;i<3*n-1;i+=2){
		ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2560
import java.io.PrintWriter;
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        final Scanner sc = new Scanner(System.in);
        final PrintWriter out = new PrintWriter(System.out);
        final int n = Integer.parseInt(sc.next());
        final int[] a = new int[n];
        for(int i = 0; i<n; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        sc.close();
        out.print(a[0]);
        for(int i = 1; i<n; i++)
            out.print(" "+a[i]);
        out.println();
        for(int i = 1; i<n; i++){
            final int v = a[i];
            int j = i-1;
            while(j>=0&&a[j]>v){
                a[j+1] = a[j];
                j--;
            }
            a[j+1] = v;
            out.print(a[0]);
            for(int k = 1; k<n; k++)
                out.print(" "+a[k]);
            out.println();
        }
        out.flush();
    }
}

Measured memory_bytes: 28516
def main():
    n, a, b = map(int, input().split())
    if (b-a) % 2 == 0:
        print((b-a)//2)
    else:
        temp = [(min(n-a, b-1))]

        cnt1 = 0
        cnt2 = 0
        for i in range(0, (min(n-a, b-1))):
            if (b-(a-1) - i) % 2 == 0 and cnt1 == 0:
                temp.append(a - 1 + i + (b-(a-1) - i) // 2)
                cnt1 += 1
            elif (n - (a+(n-b)+i)) % 2 == 0 and cnt2 == 0:
                temp.append(n - b + i + (n - (a+(n-b)+i)) // 2)
                cnt2 += 1

            if cnt1 == 1 and cnt2 == 1:
                break

        print(min(temp))

if __name__ == "__main__":
    main()

Measured memory_bytes: 62052
n,c=map(int,input().split())
xv = list(list(map(int, input().split())) for i in range(n))
vx=xv[::-1]
sushi1, max1, sushi2, max2 = [0], [0], [0], [0]
import numpy as np

sum1,sum2=0,0
for x,v in xv:
        sum1+=v
        sushi1.append(max(sum1 - x, sushi1[-1]))
        max1.append(max(sum1 - 2*x, max1[-1]))
for x, v in vx:
    sum2 += v
    sushi2.append(max(sum2 - (c-x), sushi2[-1]))
    max2.append(max(sum2 - 2*(c-x), max2[-1]))
ans1 = max(np.array(sushi1) + np.array(max2[::-1]))
ans2 = max(np.array(sushi2) + np.array(max1[::-1]))
print(max(0, ans1, ans2))

Measured memory_bytes: 52224
from collections import deque
S = []
while True:
    s = input()
    if s == '-':
        break
    s = deque(reversed(list(s)))
    m = int(input())
    for i in range(m):
        s.rotate(int(input()))
    s.reverse()
    s = ''.join(s)
    S.append(s)
for s in S:
    print(s)


Measured memory_bytes: 6000
import java.text.*;
import java.math.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int kazu = scan.nextInt();
		int[] num= new int[kazu];
		int i = 0;
		
		while(i != kazu) {
			num[i] = scan.nextInt();
			i++;
		}
		i--;
		while(i >= 0) {
			System.out.print(num[i]);
			if(i != 0) System.out.print(" ");
			i--;
		}
		System.out.println();

		/*num[0] = scan.nextInt();
		int hako = 0;
		int keta = 1;
		int w = 1;
		for(int i = 1;i <= num[0]; i++) {
			int x = i;
			if(i % 3 == 0) {
				System.out.print(" " + i);
			}else {
				/*while(true) {
					if(i / w == 0) break;
					keta++;
					w = w * 10;
				}
				while(x != 0) {
					if(x % 10 == 3) {
						System.out.print(" " + i);	
						break;
					}else {
						hako = x /w;
						x = x/10;
					}
					
				}
			}
		}*/
	}
}

Measured memory_bytes: 19636
N = int(input())

check = []
for i in range(N):
    inp = input().split()
    check.append([i, int(inp[0]), int(inp[1]), int(inp[0])+int(inp[1])])

check = sorted(check, key=lambda x:x[3])
check.reverse()
#print(check)

count = 0
ans = 0
while(count+1 < N):
    ans += check[count][1]
    ans -= check[count+1][2]
    count += 2

if count+1==N:
    ans += check[count][1]

print(ans)


Measured memory_bytes: 29984
class Factorial():
    def __init__(self, n, mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n + 1)]
        self.inv = [0 for _ in range(n + 1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i + 1] = self.factorial[i] * (i + 1) % mod
        self.inv[n] = pow(self.factorial[n], mod - 2, mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i + 1] * (i + 1) % mod

    def fact(self, m):
        return self.factorial[m]

    def invfact(self, m):
        return self.inv[m]

    def perm(self, m, k):
        if m < k: return 0
        return self.factorial[m] * self.inv[m - k] % self.mod

    def comb(self, m, k):
        if m < k: return 0
        return self.factorial[m] * self.inv[k] * self.inv[m - k] % self.mod

    def hcomb(self, m, k):
        if m + k == 0: return 1
        return self.comb(m + k - 1, k)


N, A, B = map(int, input().split())
V = list(map(int, input().split()))

V.sort(reverse=True)

F = Factorial(100, 100000000000000000039)

res = 0
num = 1
val = 0

for n in range(A, B + 1):
    v = 0
    for i in range(n):
        v += V[i]
    m = 0
    k = 0
    for i in range(N):
        if V[i] == V[n - 1]:
            m += 1
            if i > n - 1:
                k += 1
    if val * n < v * num:
        res = F.comb(m, k)
        num = n
        val = v
    elif val * n == v * num:
        res += F.comb(m, k)
    else:
        pass

print(val / num)
print(res)

Measured memory_bytes: 38896
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn=2e5+100;
int n;
LL a[maxn];

int main()
{
    while (scanf("%d",&n)!=EOF)
    {
        for (int i=1;i<=n;i++)
        {
            scanf("%lld",&a[i]);
            a[i]-=i;
        }
        sort(a+1,a+n+1);
        LL ans1=0,ans2=0;
        for (int i=1;i<=n;i++)
        {
            ans1+=abs(a[i]-a[n/2]);
            ans2+=abs(a[i]-a[n/2+1]);
        }
        printf("%lld\n", min(ans1,ans2));
    }
    return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define LL long long

const int N = 2e5 + 5;

int n, k, a[N], l = 1, r, ans;

bool check(int cur) {
	int cur_ans = 0;
	for(int i = 1; i <= n; ++i) {
		int cnt = 0;
		cnt = (a[i] - 1) / cur + 1;
		cur_ans += cnt - 1;
	}
	return cur_ans <= k;
}

int32_t main() {
	std::cin >> n >> k;
	for(int i = 1 ; i <= n; ++i) {
		std::cin >> a[i];
		r = std::max(r, a[i]);
	}
	while(l <= r) {
		int mid = l + r + 1 >> 1;
		if(check(mid)) {
			ans = mid;
			r = mid - 1;
		}
		else
			l = mid + 1;
	}
	printf("%d", ans);
    return 0;
}


Measured memory_bytes: 4472
def sieve(n):
  is_prime = [True for _ in range(n+1)]
  is_prime[0] = False
  for i in range(2, n+1):
    if is_prime[i-1]:
      j = 2 * i
      while j <= n:
        is_prime[j-1] = False
        j += i
  table = [i for i in range(1, n+1) if is_prime[i-1]]
  return table

N = int(input())
A = list(map(int, input().split()))
Amax = max(A)
lis = [0]*(Amax+1)
for i in range(N):
  lis[A[i]] += 1
table = sieve(Amax)
setwise = False
for t in table:
  p = t
  cnt = 0
  while p<=Amax:
    cnt += lis[p]
    p += t
  if cnt==N:
    print('not coprime')
    break
  if 2<=cnt<N:
    setwise=True
else:
  if setwise==True:
    print('setwise coprime')
  else:
    print('pairwise coprime')


Measured memory_bytes: 218232