akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=0;i<int(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

template<class T> void read(T &x){
	int f=0; x=0; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) f|=(ch=='-');
	for(;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	if(f) x=-x;
}



int main(){
	int h1,m1,h2,m2,s,t,K;
	read(h1),read(m1);
	s=h1*60+m1;
	read(h2),read(m2);
	t=h2*60+m2;
	read(K);
	cout<<max(0,t-s-K)<<endl;
	return 0;
}


Measured memory_bytes: 3564
#include<iostream>

typedef long long ll;
using namespace std;

int N;

ll lcm(ll a, ll b){
	if(b == 0) return a;
	return lcm(b, a % b);
}

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


int main(){
	cin >> N;

	ll x, ans = 1;
	for(int i = 0; i < N; i++){
		cin >> x;
		ans = gcd(ans, x);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	return c - '0';
}
int keta(int a) {
	return to_string(a).size();
}
signed main() {
	int n;
	cin >> n;
	int sum = 1;
	int ans = 0;
	while (sum < n) {
		sum *= 2;
		if(sum<=n)ans++;
	}
	int ans2 = 1;
	rep(i, ans+1) {
		ans2 *= 2;
	}
	cout << ans2 - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define EFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i, n) FOR(i,0,n)
#define IINF 1e9

int DFS(Graph& q, vector<bool>& vis, int x, int n){
    bool can = true;
    int tot = 0;
    REP(i,n){
        if(!vis[i]) can = false;
    }
    if(can) return 1;
    REP(i,n){
        if(q[x][i] == -1) continue;
        if(vis[i]) continue;
        vis[i] = true;
        tot += DFS(q,vis,i,n);
        vis[i] = false;        
    }
    return tot;
}

int main(void){
    int n,m;
    cin >> n >> m;
    Graph q(n,vector<int>(n,-1));
    vector<bool> vis(n,false);

    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--; b--;
        q[a][b] = 1;
        q[b][a] = 1;
    }
    vis[0] = true;
    cout << DFS(q,vis,0,n) << endl;
    return 0;
}

Measured memory_bytes: 3616
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <limits>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

template<typename T>
class lazy_segment_tree{
	int n;
	T fval;
	vector<T> dat, lazy;
	
public:
	
	lazy_segment_tree(){
		
	}
	
	lazy_segment_tree(int n_, T val){
		init(n_, val);
	}
	
	~lazy_segment_tree(){
		
	}
	
	void init(int n_, T val){
		fval = val;
		
		n = 1;
		
		while(n < n_) n *= 2;
		
		dat.resize(2 * n - 1);
		lazy.resize(2 * n - 1, fval);
	
		for(int i = 0; i < 2 * n - 1; i++) dat[i] = fval;
	}
	
	void eval(int k, int l, int r){
		
		if(lazy[k] != fval){
			dat[k] = dat[k] + lazy[k];
			
			if(r - l > 1) {
				lazy[2*k+1] = lazy[2*k+1] + lazy[k]/2;
				lazy[2*k+2] = lazy[2*k+2] + lazy[k]/2;
			}
			
			lazy[k] = fval;
		}
	}
	
	void update(int a, int b, T x, int k = 0, int l = 0, int r = -1){
		if(r < 0) r = n;
		eval(k, l, r);
		if(b <= l || r <= a) {return ;}
		if(a <= l && r <= b){
			lazy[k] = lazy[k] + (r - l) * x;
			eval(k, l, r);
		} else {
			update(a, b, x, 2*k+1, l, (l+r)/2);
			update(a, b, x, 2*k+2, (l+r)/2, r);
			dat[k] = dat[2*k+1] + dat[2*k+2];
		}
	}
	
	T query(int a, int b, int k = 0, int l = 0, int r = -1){
		if(r < 0) r = n;
		eval(k, l, r);
		if(r <= a || b <= l){
			return fval;
		}
		if(a <= l && r <= b){
			return dat[k];
		}else {
			T vl = query(a, b, k * 2 + 1, l, (l + r) / 2 );
			T vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return vl + vr;
		}
	}
};

#define l first
#define r second

signed main(){
	cout<<fixed<<setprecision(10);
	
	int N, Q;
	vector<int> c;
	vector<pair<int,int>> in;
	vector<int> pre;
	vector<pair<int,int>> ans;
	
	lazy_segment_tree<long long> lseg;
	vector<vector<pair<int,int>>> hoge;
	
	cin>>N>>Q;
	
	
	// seg.init(N+10,0, [](int first, int second){ return (first+second);});
	
	lseg.init(N+10, 0);
	
	
	c.resize(N);
	in.resize(Q);
	pre.resize(N+1);
	hoge.resize(N+1);
	
	for(int i = 0; i < N; i++){
		cin>>c[i];
	}
	
	for(int i = 0; i < Q; i++){
		cin>>in[i].l>>in[i].r;
		in[i].l--;
		in[i].r--;
		
		hoge[in[i].r].push_back({i, in[i].l});
	}
	
	for(int i = 0; i < N; i++){
		// cout<<"i = "<<i<<" c = "<<c[i]<<endl;
		// seg.update(pre[c[i]], 1);
		lseg.update(pre[c[i]], i+1, 1);
		
		// cout<<pre[c[i]]<<" "<<i<<endl;
		pre[c[i]] = i+1;
		
		// for(int j = 0; j < N+1; j++){
			// cout<<lseg.query(j,j+1)<<" ";
		// }
		// cout<<endl;
		
		for(int j = 0; j < hoge[i].size(); j++){
			// ans.push_back({hoge[i][j].first, lseg.query(hoge[i][j].second, i+1)});
			ans.push_back({hoge[i][j].first, lseg.query(hoge[i][j].second, hoge[i][j].second+1)});
			// cout<<"<><> "<<hoge[i][j].second<<endl;
		}
	}
	
	sort(ans.begin(), ans.end());
	
	for(int i = 0; i < Q; i++){
		cout<<ans[i].second<<endl;
	}
	
	
	return 0;
}

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

int N;
vector<vector<int>> a;

int S;
vector<ll> score, memo;

ll f(int s) {
  if (memo[s] != -1) return memo[s];

  ll res = -1e20;
  for (int t = (-s) & s; t != 0; t = (t - s) & s) {
    res = max(res, score[t] + f(s & ~t));
  }
  return memo[s] = res;
}

int main() {
  cin >> N;
  a.resize(N, vector<int>(N));
  rep(i, N) rep(j, N) cin >> a[i][j];

  S = 1 << N;
  memo.resize(S, -1);
  memo[0] = 0;
  score.resize(S, 0);

  rep(s, S) {
    rep(i, N) for (int j = i + 1; j < N; ++j) {
      if (((s >> i) & 1) && ((s >> j) & 1)) score[s] += a[i][j];
    }
  }

  cout << f(S - 1) << endl;

  return 0;
}


Measured memory_bytes: 1280
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{ 
   static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter pw = new PrintWriter(System.out);
    static StringTokenizer st;
    
    static String next()
        {
            while(st==null || !st.hasMoreElements()) 
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   static int gcd(int a,int b)
     {
       if(b==0)
        return a;
       else
        return gcd(b,a%b);
     }
  public static void main (String[] args) throws java.lang.Exception
   {
	try{
	   
		 
		       int n=Integer.parseInt(next());
		       String a="hon";
		       String b="pon";
		       String c="bon";
		       String tot="";
		             int d=n%10;
		             switch(d)
		               {
		                  case 0 :
		                     tot=b;
		                     break;
		                   case 1: 
                             tot=b;
                            break; 
                         case 2: 
                            tot=a;
                          break; 
                         case 3: 
                          tot=c;
                            break; 
                         case 4: 
                          tot=a;
                         break; 
                         case 5: 
                             tot=a;
                            break; 
                         case 6: 
                            tot=b;
                          break; 
                            case 7: 
                          tot=a;
                           break; 
                        case 8: 
                        tot=b;
                        break; 
                      case 9: 
                       tot=a;
                       break;
		               
		          }
		      System.out.println(tot);
		    
	   }     
	catch(Exception e)
		 {}
	}
}


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

class P {
public:
    int x, y;
    P(int x, int y) : x(x), y(y) {}
    bool operator!=(const P &p) {
        return x!=p.x || y!=p.y;
    }
};

class Poly {
public:
    int n;
    vector<int> dx, dy;
    Poly(): n(0) {}
    bool operator==(const Poly &p) {
        if (n != p.n) return false;
        for (int i=0; i<n; ++i) {
            if (dx[i] != p.dx[i] || dy[i] != p.dy[i]) return false;
        }
        return true;
    }
    void add(P p) {
        ps.push_back(p);
    }
    void vectorize() {
        n = (int)ps.size() - 1;
        dx.resize(n);
        dy.resize(n);
        for (int i=0; i<n; ++i) {
            dx[i] = ps[i+1].x - ps[i].x;
            dy[i] = ps[i+1].y - ps[i].y;
        }
    }
    void rotate() {
        for (int i=0; i<n; ++i) {
            swap(dx[i], dy[i]);
            dx[i] = -dx[i];
        }
    }
    void rev() {
        reverse(dx.begin(), dx.end());
        reverse(dy.begin(), dy.end());
        for (int i=0; i<n; ++i) {
            dx[i] = -dx[i];
            dy[i] = -dy[i];
        }
    }
private:
    vector<P> ps;
};

bool equals(Poly a, Poly b) {
    for (int i=0; i<4; ++i) {
        if (a == b) return true;
        b.rotate();
    }
    b.rev();
    for (int i=0; i<4; ++i) {
        if (a == b) return true;
        b.rotate();
    }
    return false;
}

Poly polyInput() {
    int m, x, y;
    cin >> m;
    Poly pl;
    for (int i=0; i<m; ++i) {
        cin >> x >> y;
        pl.add(P(x, y));
    }
    pl.vectorize();
    return pl;
}

int main() {
    int n;
    while (cin >> n, n) {
        Poly pl0 = polyInput(); 
        for (int i=1; i<=n; ++i) {
            Poly pl = polyInput();
            if (equals(pl0, pl)) cout << i << endl;
        }
        cout << "+++++" << endl;
    }
    return 0;
}


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

int partition(vector<int>& A, int p, int r) {
    int x = A[r];
    int i = p-1;
    for (int j=p; j <= r - 1; j++) {
        if (A[j] <= x) {
            i = i + 1;
            int tmp_i = A[i];
            A[i] = A[j];
            A[j] = tmp_i;
        }
    }
    int tmp_i_ = A[i+1];
    A[i+1] = x;
    A[r] = tmp_i_;
    return i+1;
}

int main()
{
    int N;
    cin >> N;

    vector<int>vec(N);
    for (int i=0; i < N; i++) {
        cin >> vec.at(i);
    }

    int q = partition(vec, 0, N-1);
    for (int i =0; i < N; i++) {
        if (i) {
            printf(" ");
        }

        if (i == q) {
            printf("[");
        }
        printf("%d", vec[i]);
        if (i == q) {
            printf("]");
        }
    }
    printf("\n");
    return 0;
}


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

#define NIL -1
#define MAX 101

int main(){
  int A[MAX][MAX];
  int V[MAX]={0};
  int Aij[MAX];
  int E[MAX]={NIL};
  int i,j,n,sum=0,max=0,min=0;

  scanf("%d",&n);
  for(i=0 ; i<n ; i++){
    for(j=0 ; j<n ; j++){
      scanf("%d",&A[i][j]);
    }
  }

  Aij[0] = 0;
  for(i=1; i<n; i++) Aij[i] = 2001;

  while(max != 2001){
    max = 2001;
    for(i=0 ; i<n ; i++){
      if(V[i] != 2 && Aij[i] < max){
        max = Aij[i];
        min = i;
      }
    }
    V[min] = 2;
    for(i=0 ; i<n ; i++){
      if(A[min][i] != NIL && V[i] != 2 && A[min][i] < Aij[i]){
        E[i] = min;
        Aij[i] = A[min][i];
        V[i] = 1;
      }
    }
  }

  for(i=0 ; i<n ; i++){
    if(E[i] != NIL) sum += A[i][E[i]];
  }

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

  return 0;
}

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

int main(){

    int n,i;
    cin >> n ;
    int a[n];
    
    for(i=0; i<n; i++){
       cin >> a[i];}
    
    int max=a[0];
    int min=a[0];
    long long int sum=a[0];
    
    for(i=1; i<n; i++){
        if(max<a[i]){
            max = a[i];
        }
        if(min>a[i]){
            min = a[i];
        }
    
    sum += a[i];
        
    }
    
    cout << min << " "<< max << " " << sum << endl;
    
    return 0;
    
}

Measured memory_bytes: 3136
<?php
fscanf(STDIN,"%d %d",$k,$x);

$min=$x-$k+1;
if($min<-1000000){
	$min=-1000000;
}
$max=$x+$k-1;
if($max>1000000){
	$max=1000000;
}

$ans="";
for($i=$min;$i<=$max;$i++){
	$ans.=$i." ";
}
rtrim(" ",$ans);
echo $ans;
?>

Measured memory_bytes: 4728
# Vicfred
# https://atcoder.jp/contests/abc142/tasks/abc142_c
# implementation
n = int(input())
a = list(map(int,input().split()))

students = list()
for i in range(1,n+1):
    students.append((i,a[i-1]))

#print(sorted(students, key=lambda x: x[1]))
students.sort(key=lambda x: x[1])

for student in students:
    print(student[0], end=' ')
print()



Measured memory_bytes: 24768
#include<iostream>

using namespace std;

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

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

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main()
{
    int H,W,A,B;
    cin >> H >> W >> A >> B;
    COMinit();
    long long int ans = 0;

    for (int i=1; i<W-B+1; ++i)
    {
        // long long tmp = fac[H-A-1+B+i-1] * (finv[H-A-1] * finv[B+i-1] % MOD) % MOD;
        // tmp *= fac[A-1+W-B-i] * (finv[A-1] * finv[W-B-i] % MOD) % MOD;
        // tmp %= MOD;
        // ans %= MOD;
        // ans += tmp;
        long long tmp = COM(H-A-1+B+i-1,B+i-1)%MOD * COM(A-1+W-B-i,W-B-i)%MOD;
        tmp %= MOD;
        ans %= MOD;
        ans += tmp;

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

Measured memory_bytes: 12160
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

int main() {
  int a, b;
  cin >> a >> b;
  int ans{};
  if (a < b) swap(a, b);
  ans = a;
  a--;
  if (a > b)
    ans += a;
  else
    ans += b;
  cout << ans << endl;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> P(N);
    rep(i, N) {
        int A, B;
        cin >> A >> B;
        pair<int, int> p = make_pair(A, B);
        P[i] = p;
    }
    sort(P.begin(), P.end());
    ll ans = 0;
    rep(i, N) {
        ll buy = min(M, P[i].second);
        ans += P[i].first*buy;
        M = M - buy;
        if (M == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

//find_by_order gives kth-largest element
//order_of_key gives the number of items in the set that are strictly smaller!!

// OT.find_by_order(k-1)
// 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define db4(x, y, z, w) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << "," << #w << "=" << w << endl
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define mp make_pair
#define X first
#define Y second
#define sz(x) (int)((x).size())
#define pii pair<int,int>
#define MOD (ll)(998244353)
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
typedef vector<int> vi;
#define inf (ll)(1e18)
#define double long double
#define int long long

//////////////////////
const int N = 2005;


int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(0); 
    cout.tie(0);
    int a,b,c; cin >> a >> b >> c;
    cout << min(b/a, c) << '\n';
}

Measured memory_bytes: 256
a,b,k=[int(x) for x in input().split()]
#print(a,b,k)#
ans = []
for i in range(k):
  if a+i<=b:ans.append(a+i)
  if b-i>=a:ans.append(b-i)
#print(ans)#
ans = list(set(ans))
ans.sort()
for e in ans: print(e)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
int main() {
  int n, k;
  cin>>n>>k;
  vector<int> Ventrada, Vcusto;
  for(int i=0;i<n;i++){
    int w;
    cin>>w;
    Ventrada.push_back(w);
  }
  Vcusto.push_back(0);
  int menor;
  for(int i=1;i<n;i++){
    menor = Vcusto[i-1]+abs(Ventrada[i]-Ventrada[i-1]);
    for(int j=i-k;j<i;j++){
      if(j>=0 && Vcusto[j]+abs(Ventrada[i]-Ventrada[j])<menor){
        menor=abs(Ventrada[i]-Ventrada[j]) + Vcusto[j];
      }
    }
    Vcusto.push_back(menor);
  }
  
  cout<<Vcusto[Vcusto.size()-1]<<endl;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M;
    cin >> N >> M;
    scc_graph graph(N);
    ll ai, bi;
    for(int i=0;i<M;i++){
        cin >> ai >> bi;
        graph.add_edge(ai, bi);
    }
    auto ret = graph.scc();
    cout << ret.size() << endl;
    for(auto g : ret){
        cout << g.size() << " ";
        for(auto v : g){
            cout << v << " ";
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 40564
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
pub fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
pub fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
pub fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}


fn main() {
    input!{
        n: usize,
        m: usize,
        a: [i32; n],
    }
    let mut b = a;
    b.sort();
    b.reverse();
    let sum: i32 = b.iter().sum();
    if b[m-1] * 4 * (m as i32) < sum {
        println!("No");
    }
    else {
        println!("Yes");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define INF 1000000000
#define M 1000000007
#define ll long long
#define MAX 5000001
using namespace std;

int main(){
	int n;
	cin >> n;
	int cn = 0;
	for (int i=0;i<n;i++){
		int x;
		cin >> x;
		if (x&1) cn++;
	}
	if (cn%2==0) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

Measured memory_bytes: 384
from sys import maxsize
from heapq import heappop, heappush


class Node:
    WHITE = 0
    GRAY = 1
    BLACK = 2

    def __init__(self):
        self.adjs = []
        self.color = Node.WHITE
        self.dist = maxsize

    def __lt__(self, other):
        return self.dist < other.dist

    def __repr__(self):
        return "Node({},{},{})".format(self.adjs, self.color, self.dist)


def read_adj():
    n = int(input())
    nodes = [Node() for _ in range(n)]

    for i in range(n):
        u, _, *rest = [int(x) for x in input().split()]
        for i in range(0, len(rest) - 1, 2):
            nodes[u].adjs.append((rest[i], rest[i+1]))

    return nodes


def shortest_path(nodes):
    h = []

    nodes[0].dist = 0
    nodes[0].color = Node.GRAY
    heappush(h, (0, 0))

    while len(h) > 0:
        min_dist, min_node = heappop(h)

        nodes[min_node].color = Node.BLACK
        if nodes[min_node].dist < min_dist:
            continue

        for adj, c in nodes[min_node].adjs:
            if nodes[adj].color == Node.BLACK:
                continue
            if nodes[min_node].dist + c < nodes[adj].dist:
                nodes[adj].dist = nodes[min_node].dist + c
                nodes[adj].color = Node.GRAY
                heappush(h, (nodes[adj].dist, adj))


def print_dist(nodes):
    for u, n in enumerate(nodes):
        print(u, n.dist)


def main():
    nodes = read_adj()
    shortest_path(nodes)
    print_dist(nodes)


if __name__ == '__main__':
    main()



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

int main()
{
    stack<int> S1;
    stack<pair<int, int> > S2;
    char ch;
    int sum = 0;
    for(int i = 0; cin >> ch; i++){
        if(ch == '\\') S1.push(i);
        else if(ch == '/' && S1.size() > 0){
            int j = S1.top(); S1.pop();
            sum += i - j;
            int a = i - j;
            while(S2.size() > 0 && S2.top().first > j){
                a+= S2.top().second; S2.pop();
            }
            S2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    int t = 0;
    while(S2.size() > 0){ans.push_back(S2.top().second); S2.pop();}
    reverse(ans.begin(), ans.end());
    cout << sum << endl;
    cout << ans.size();
    for(int i = 0; i < ans.size(); i++){
        cout << " ";
        t += ans[i];
        cout << ans[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 3240
# include <iostream>
# include <cmath>
# include <numeric>
using namespace std;

int main() {
    int n; cin >> n;
    while (n != 0) {
        int s[n]; for(int i = 0; i < n; ++i) cin >> s[i];
        int s_sum = accumulate(s, s + n, 0);
        double average = 1.0 * s_sum / n;
        
        double sum = 0;
        for (int s_i = 0; s_i < n; ++s_i) {
            double diff = 1.0 * s[s_i] - average;
            sum += diff * diff;
        }
        double normal_deviation = sqrt(sum / n);
        printf("%.8f\n", normal_deviation);
        
        cin >> n;
    }
    
    return 0;
}


Measured memory_bytes: 3156
import math
org_str=input()
new_str = org_str[::-1]
if(new_str==org_str):
  org_str2=org_str[0:math.ceil((len(org_str)-1)/2)]
  new_str2=org_str2[::-1]
  if(new_str2==org_str2):
    org_str3=org_str[math.ceil((len(org_str)+3)/2):-1]
    new_str3=org_str3[::-1]
    if(new_str3==org_str3):
      print('Yes')
    else:
      print('No')
  else:
    print('No')
else:
  print('No')

Measured memory_bytes: 38640
#include<cstdio>
#include<algorithm>
using namespace std;
int ans=99999999,n;
int sum(int x)
{
	int re=0;
	while(x)
	{
		re+=x%10;
		x/=10;
	}
	return re;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<n;i++)
	{
		int re=sum(i)+sum(n-i);
		ans=min(ans,re);
	}
	printf("%d",ans);
}

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

using namespace std;
long long MOD = 1000000007LL;
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LONGLONGMAX 3000000
long long fac[LONGLONGMAX], finv[LONGLONGMAX], inv[LONGLONGMAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < LONGLONGMAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD; // inverse of i
		//MOD - inv[MOD % i] * (MOD / i) % MOD   拡張Euclidの互除法
		finv[i] = finv[i - 1] * inv[i] % MOD; //invers of finv[i]
	}
}

// 二項係数計算
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() {
	long long N;
	int P;
	string s;
	cin >> N >> P;
	cin >> s;
	COMinit();
	if (P == 2 || P == 5) {
		long long count = 0;
		for (int i = 0;i < N; ++i) {
			if((s[N - i - 1] - 0x30) % P == 0)count += N - i;
		}
		cout << count << endl;
		return 0;
	}
	else {
		vector<long long> val(P, 0);
		long long a = 0;
		long long tenfactor = 1;
		++val[a];
		for (int i = 0; i < N; ++i) {
			a = (a + (s[N - i - 1] - 0x30) * tenfactor) % P;
			tenfactor = (tenfactor * 10) % P;
			++val[a];
		}
		long long count = 0;
		for (int p = 0; p < P; ++p) {
			count += val[p] * (val[p] - 1) / 2;
		}
		cout << count << endl;
		return 0;
	}
	return 0;
}

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

using namespace std;

int main() {
	int n; cin >> n;
	if(n < 600) puts("8");
	else if(n < 800) puts("7");
	else if(n < 1000) puts("6");
	else if(n < 1200) puts("5");
	else if(n < 1400) puts("4");
	else if(n < 1600) puts("3");
	else if(n < 1800) puts("2");
	else puts("1");
	return 0;
}

Measured memory_bytes: 3620
import java.util.*;

public class Main {

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

	public void run() {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		double b = sc.nextDouble();
		long lb = Math.round(b*100);
		long ans = a*lb/100;
		System.out.println(ans);
		sc.close();
	}


}

Measured memory_bytes: 37176
N = int(input())
ab = [list(map(int,input().split())) for _ in range(N)]

ab.sort(key = lambda x:x[1])

tmp = 0
flag = True
for i in range(N):
    tmp += ab[i][0]
    if tmp > ab[i][1]:
        flag = False
        break
    
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 54076
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
#include <iomanip>

using namespace std;
#define int long long

signed main(){
    int X,t;
    cin >> X >> t;
    
    if(X-t>=0){
        cout << X-t << endl;
    }else{
        cout << 0 << endl;
    }
    
    return 0;
}


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

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

Measured memory_bytes: 256
N = int(input())
S = input()

key = []
 
for i in range(10):
    for j in range(10):
        for k in range(10):
            key.append([i,j,k])
            
flag1 = 0
flag2 = 0
flag3 = 0
ans = 0

for i in range(len(key)):
    flag1 = 0
    flag2 = 0
    flag3 = 0
    
    flag1 = S.find(str(key[i][0]))
    
    if flag1 == -1:
        continue
        
    flag2 = S.find(str(key[i][1]),flag1+1)
    
    if flag2 == -1:
        continue
        
    flag3 = S.find(str(key[i][2]),flag2+1)
    
    if flag3 == -1:
        continue
                            
    if flag1 != -1 and flag2 != -1 and flag3 != -1:
        ans += 1
        
print(ans)

Measured memory_bytes: 3188
until (n = $<.gets.to_i) == -1
  x, y = 1.0, 0.0
  x1, y1 = x, y
  (n - 1).times do
    l = Math.sqrt(x ** 2 + y ** 2)
    x1 += -y / l
    y1 +=  x / l
    x, y = x1, y1
  end
  puts x, y
end


Measured memory_bytes: 6876
import java.util.Scanner;
public class Main {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a = s.nextInt();
    
        int b = s.nextInt();
        int c = s.nextInt();
        int d = a * 100 + b * 10 + c;
        Boolean h = (d % 4 == 0);
        if (h == true){ 
        System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21844
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*
import java.lang.Double.parseDouble as parseDoubleJVM
import java.lang.Integer.parseInt as parseIntJVM
import java.lang.Long.parseLong as parseLongJVM

fun main(args: Array<String>) = yorukatsu14e()

fun yorukatsu14e() = IO_yorukatsu14e().exec {
    val n = readInt()
    val k = readLong()

    val graph = IntArray(n)
    repeat(n - 1) {
        val from = readInt() - 1
        val to = readInt() - 1
        graph[from]++
        graph[to]++
    }

    var answer = k

    for ((index, r) in graph.withIndex()) {
        val n1 = if (index == 0) k - 1 else k - 2
        val r1 = if (index == 0) r else r - 1
        for (p in n1 downTo n1 - r1 + 1) {
            answer *= p
            answer %= MOD
        }
    }

    println(answer)
}

private const val MOD = (1e9 + 7).toLong()

@Suppress("unused", "ClassName", "SpellCheckingInspection")
class IO_yorukatsu14e {
    val br = BufferedReader(InputStreamReader(System.`in`))
    var st = StringTokenizer("")
    val pw = PrintWriter(System.out)

    fun readString(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())
        return st.nextToken()!!
    }

    fun readInt() = parseIntJVM(readString())
    fun readLong() = parseLongJVM(readString())
    fun readDouble() = parseDoubleJVM(readString())

    //    fun readStringList(size: Int) = readList(size) { readString() }
    //    fun readIntList(size: Int) = readList(size) { readInt() }
    //    fun readLongList(size: Int) = readList(size) { readLong() }
    //    fun readDoubleList(size: Int) = readList(size) { readDouble() }
    fun readIntArray(size: Int) = IntArray(size) { readInt() }
    fun readLongArray(size: Int) = LongArray(size) { readLong() }
    fun readDoubleArray(size: Int) = DoubleArray(size) { readDouble() }
    inline fun <reified T> readArray(size: Int, init: () -> T) = Array(size) { init() }

    //    inline fun <T> readList(size: Int, init: () -> T) = List(size) { init() }
    fun readLine() = br.readLine()!!
    fun println() = pw.println()
    fun print(o: Any?) = pw.print(o)
    fun println(o: Any?) = pw.println(o)
    inline fun exec(code: IO_yorukatsu14e.() -> Unit) {
        code()
        pw.flush()
    }
}


Measured memory_bytes: 48328
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll,ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define	sz(c) ll((c).size())
#define	all(c) begin(c),end(c)
#define	mp make_pair
#define mt make_tuple
#define	pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define	has(c,i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define	FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)

int main(){
	ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vl a(n,0);
  FOR(i,0,n) cin >> a[i];
  ll res = 0;
  FOR(i,0,n){
    if(a[i] == i+1){
      res++;
      i++;
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main() {
  long long int n,k;
  scanf("%lld",&n);
  scanf("%lld",&k);
  long long int ans;
  if(k%2==1) {
    ans = (n/k)*(n/k)*(n/k);
    printf("%lld\n",ans);
  } else {
    long long int p = n/(k/2);
    ans = (p/2)*(p/2)*(p/2) + (p-(p/2))*(p-(p/2))*(p-(p/2));
    printf("%lld\n",ans);
  }
  return 0;
}


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

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

    int ans = 0;
    ans += n / 500;
    n -= n / 500 * 500;

    cout << ans * 1000 + n / 5 * 5 << '\n';

    return 0;
}


Measured memory_bytes: 256
def II():return int(input())
def LI():return list(map(int,input().split()))                     
from collections import Counter, deque

n=II()
a=LI()
b=LI()



ac=Counter(a)
bc=Counter(b)
abc=ac+bc
for i in abc.values():
  if i>n:
    print("No")
    exit()
    
print("Yes")
a=deque(a)
b=deque(b)
ans=[]
b.rotate(n//2)
while a:
  if a[0]!=b[0]:
    a.popleft()
    ans.append(b.popleft())
  else:
    b.rotate()
print(*ans)


Measured memory_bytes: 191844
/*
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
*/
#include <bits/stdc++.h>
#define LL              long long
#define ll              long long
#define SL(n)           scanf("%lld",&n)
#define LF              double
#define SF(n)           scanf("%lf",&n)
 
#define pb              push_back
#define mp              make_pair
 
#define ON(n,i)         (n|(1LL<<i))
#define OFF(n,i)        (n&(~(1LL<<i)))
#define CHK(n,i)        (n&(1LL<<i))
 
#define ff              first
#define ss              second
 
#define SET(arr)        memset( arr , -1 , sizeof arr)
#define RESET(arr)      memset( arr,0,sizeof arr)
 
#define srt(v)          sort(v.begin(),v.end())
#define uniq(v)			v.resize(distance(v.begin(),unique(v.begin(),v.end())))
#define found( s,d )    (s.find(d) != s.end())
 
#define FOR(i,s,e)      for( LL i = s ; i<=e ; i++ )
#define RFOR(i,e,s)     for( LL i = e ; i>=s ; i-- )
         
 
#define FILEIN          freopen("in.txt","r",stdin)
#define FILEOUT         freopen("WA.txt","w",stdout)
 
#define DEBUG(x)        cerr<<#x<<" = "<<x<<endl
#define PRINTALL(v)     {cerr<<endl<<"Printing: "<<#v<<endl;for(LL i = 0 ; i<v.size(); i++) DEBUG(v[i]); cerr<<endl;}
 
using namespace std;


vector < LL > v;
int main(){
   

   LL n,k;
   SL(n); SL(k);
   FOR(i,1,n){
       LL a;
       SL(a);
       v.pb(a);
   }

   srt(v);
   LL sum = 0;
   FOR(i,0,k-1) sum+=v[i];
   cout<<sum<<endl;
 
    
return 0;}

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

using namespace std;

string S;
long get_sum(long index, long part_sum, long sum)
{
    if (index >= S.length())
        return part_sum == 0 ? sum : 0;
    long res = (get_sum(index + 1, 0, sum + part_sum * 10 + (int)(S[index] - '0'))) + get_sum(index + 1, part_sum * 10 + (int)(S[index] - '0'), sum);
    // cout << index << " " << part_sum << " " << res << endl;
    return res;
}

int main()
{
    cin >> S;
    cout << get_sum(0, 0, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef long double ld;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

int main(void)
{
    ll a, b;

    cin >> a >> b;

    cout << a*b << endl;

    return 0;
}

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

int main(){
	string s="snuke";
	ll h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			string t;
			cin>>t;
			if(s==t){
				cout << char('A'+j);
				cout << i+1;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int n;
   string s,t;
   cin >> n;
   cin >> s >> t;
   string ans = "";
   for(int i = 0;i < n;i++){
       ans += s[i];
       ans += t[i];
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int a;
    string s;
    cin >> a >> s;
    cout << (a >= 3200 ? s : "red") << endl;
    return 0;
}

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

int main(){
	int n;
	cin >> n;
	if(n == 1) cout << "Hello World" << endl;
	else {
		int a, b;
		cin >> a >> b;
		cout << a + b << endl;
	}
	
	
	
	
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  while (true) {
    int h, w; cin >> h >> w;
    if (!h) break;
    VV<> a(h, V<>(w));
    for (auto&& v : a) for (auto&& e : v) cin >> e;
    int res = 0;
    for (int i0 = 0; i0 < h; ++i0) for (int i1 = 0; i1 < h; ++i1) if (i0 < i1) {
      for (int j0 = 0; j0 < w; ++j0) for (int j1 = 0; j1 < w; ++j1) if (j0 < j1) {
        int mn = 1e9;
        for (int j = j0; j <= j1; ++j) mn = min({mn, a[i0][j], a[i1][j]});
        for (int i = i0; i <= i1; ++i) mn = min({mn, a[i][j0], a[i][j1]});
        int mx = -1e9, s = 0;
        for (int i = i0 + 1; i < i1; ++i) for (int j = j0 + 1; j < j1; ++j) {
          mx = max(mx, a[i][j]);
          s += mn - a[i][j];
        }
        if (mn > mx) res = max(res, s);
      }
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 3116
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <deque>
#include <numeric>
#include <sstream>
#include <iomanip>
#define ALL(X) X.begin(), X.end()
using lint = long long;
template <typename T>
void print_container(std::vector<T> vec)
{
    for (auto iter = vec.begin(); iter != vec.end(); ++iter)
    {
        std::cout << *iter << " ";
    }
    std::cout << std::endl;
}

long long modpow(long long a, long long n, long long p)
{
    long long out = 1;
    while (n)
    {
        if (n & 1)
        {
            out = out * a % p;
        }
        a = a * a % p;
        n >>= 1;
    }
    return out;
}

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

    std::vector<lint> a(n);

    for (int i = 0; i < n; ++i)
    {
        scanf("%lld", &a[i]);
    }

    std::sort(ALL(a));

    if (n % 2 == 0)
    {
        lint comp = -1;
        for (int i = 0; i < n; ++i)
        {
            if (i % 2 == 0)
            {
                comp += 2;
            }
            if (a[i] != comp)
            {
                std::cout << 0 << "\n";
                return 0;
            }
        }
        std::cout << modpow(2, n / 2, 1e9 + 7) << "\n";
        return 0;
    }
    else
    {
        if (a[0] != 0)
        {
            std::cout << 0 << "\n";
            return 0;
        }
        lint comp = 0;
        for (int i = 1; i < n; ++i)
        {
            if (i % 2 == 1)
            {
                comp += 2;
            }
            if (a[i] != comp)
            {
                std::cout << 0 << "\n";
                return 0;
            }
        }
        std::cout << modpow(2, n / 2, 1e9 + 7) << "\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  long long int n,a,b,c;
  cin>>a>>b>>n;

  long long int l=0;
  long long int h=n;
  long long int res=0;
  while(l<=h){
    long long int x=l+(h-l)/2;
    long long int calc=((a*x)/b)-a*(x/b);
    if(calc>=res){
        res=calc;
        l=x+1;
    }else{
        h=x-1;
    }
  }
  cout<<res<<endl;
  return 0;
}


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

int n;
int h[16], w[16];
int c[16];

int main()
{
	int cv[256];
	for (int i = 0; i < 3; i++){
		cv["RGB"[i]] = i + 1;
	}

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> h[i] >> w[i];
	}
	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 4; j++){
			char d;
			cin >> d;
			c[i * 4 + j] = cv[d];
		}
	}
	
	vector<pair<int, int>> v;
	for (int i = 0; i < n; i++){
		for (int col = 1; col <= 3; col++){
			for (int bx = -3; bx < 4; bx++){
				for (int by = -3; by < 4; by++){
					int mask = (1 << 16) - 1, bit = 0;
					for (int x = bx; x < bx + h[i]; x++){
						for (int y = by; y < by + w[i]; y++){
							if (x < 0 || x >= 4 || y < 0 || y >= 4) continue;
							mask &= ~(1 << (x * 4 + y));
							bit |= (int(c[x * 4 + y] == col)) << (x * 4 + y);
						}
					}
					v.emplace_back(mask, bit);
				}
			}
		}
	}
	sort(begin(v), end(v));
	v.erase(unique(begin(v), end(v)), end(v));
	
	vector<int> dist(1 << 16, -1);
	queue<int> q;
	dist[0] = 0;
	q.push(0);
	while (q.size()){
		int cur = q.front(); q.pop();
		for (int i = 0; i < v.size(); i++){
			int x = (cur & v[i].first) | v[i].second;
			if (dist[x] == -1){
				dist[x] = dist[cur] + 1;
				q.push(x);
			}
		}
	}

	cout << dist[(1 << 16) - 1] << endl;
}

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

using namespace std;

#ifdef WIN32
	#define I64 "%I64d"
#else
	#define I64 "%lld"
#endif

typedef long long ll;

#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(s) s.begin(), s.end()
#define sz(s) (int(s.size()))
#define fname "a"
#define MAXN 808

int n, m, k;
char s[MAXN][MAXN];
int d[MAXN][MAXN];
queue < pair<int, int> > q;

int main()
{
	#ifdef LOCAL
	freopen(fname".in", "r", stdin);
	freopen(fname".out", "w", stdout);
	#endif

	scanf("%d%d%d", &n, &m, &k);
	for (int i = 0; i < n; ++i) {
		scanf("%s", s[i]);
	}

	memset(d, -1, sizeof(d));

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j)
			if (s[i][j] == 'S') {
				d[i][j]= 0;
				q.push(mp(i, j));
			}

	while(!q.empty()) {
		int x = q.front().f;
		int y = q.front().s;
		q.pop();
		if (d[x][y] == k) continue;
		for (int dx = -1; dx <= 1; ++dx)
			for (int dy = -1; dy <= 1; ++dy) {
				if (abs(dx) + abs(dy) != 1) continue;
				int sx = x + dx;
				int sy = y + dy;
				if (sx < 0 || sx >= n || sy < 0 || sy >= m || s[sx][sy] == '#' || d[sx][sy] != -1) continue;
				d[sx][sy] = d[x][y] + 1;
				q.push(mp(sx, sy));
		}
	}

	int ans = int(1e9);

	for (int i = 0; i < n; ++i)
		for (int j = 0; j < m; ++j) {
			if (d[i][j] == -1) continue;
			ans = min(ans, (i + k - 1) / k + 1);
			ans = min(ans, (j + k - 1) / k + 1);
			ans = min(ans, (n - 1 - i + k - 1) / k + 1);
			ans = min(ans, (m - 1 - j + k - 1) / k + 1);
		}

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

	return 0;
}


Measured memory_bytes: 3456
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
c = [2]

x, y = map(int, input().split())

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include<iostream>
#include<queue>
#define MAX 100
using namespace std;

int map[MAX+2][MAX+2];
bool check[MAX+2][MAX+2];
int dx[4] = { -1,1,0,0};
int dy[4] = { 0,0,-1,1};

int main () {

  while ( true ) {

    queue<int> next;

    while( !next.empty() ) {
      next.pop();
    }
    
    int w,h;
    cin >> w >> h ;

    if ( w == 0 )
      break;

    int xs,ys;
    cin >> xs >> ys;
    
    int xg, yg;
    cin >> xg >> yg;

    int n;
    cin >> n;

    int c,d,x,y;

    for ( int i=0; i<MAX+2; i++ ) {
      for ( int j=0; j<MAX+2; j++ ) {
	map[i][j] = 0;
	check[i][j] = true;
      }
    }

    for ( int i=0; i<n; i++ ) {
      cin >> c >> d >> x >> y;
      
      //int count = 0;
      for ( int j=0; j<2; j++ ) {
	for ( int k=0; k<4; k++ ) {
	  //cout << count;
	  if ( d == 0 ) {
	    map[y+j][x+k] = c;
	  } else {
	    map[y+k][x+j] = c;
	  }
	}
      }
      //cout << endl;
    }

    next.push(ys*1000 + xs );

    int point;
    bool goal = false;

    int sc = map[ys][xs];

    /*
      for ( int i=0; i<=h; i++ ) {
      for ( int j=0; j<=w; j++ ) {
      cout << map[i+1][j+1];
      }
      cout << endl;
      }
      cout << endl;
    */
    int xn,yn;
    if ( map[yg][xg] == sc ) {
      if ( sc == 0 || map[yg][xg] == 0 ) {
      }
      else {
	while ( !next.empty() ) {
	  point = next.front();
	  next.pop();
	  xn = point%1000;
	  yn = point/1000;

	  if (map[yn][xn] == 0 )
	    continue;

	  if (point == yg*1000+xg) {
	    goal = true;
	    break;
	  }

	  for ( int i=0; i<4; i++ ) {
	    if ( check[yn+dy[i]][xn+dx[i]] ) {
	      check[yn+dy[i]][xn+dx[i]] = false;
	      if ( map[yn+dy[i]][xn+dx[i]] == sc ) {
		next.push((yn+dy[i])*1000+ xn +dx[i]);
	      }
	    }
	  }
	}
      }
    }

    if ( goal )
      cout << "OK\n";
    else
      cout << "NG\n";
  }
}
    
      
      

Measured memory_bytes: 0
import java.util.*;

class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String S = sc.next();
		String T = sc.next();

		int Len = S.length();

		for(int i = 0; i<Len; i++){
			String Ssub = S.substring(Len-1,Len) + S.substring(0, Len-1);

			S = Ssub;

			if(S.equals(T)){
				System.out.println("Yes");
				return;
			}
		}

		System.out.println("No");
	}

}

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

void affine(char *str, int a, int b){
	int i;
	int len;
	
	len = strlen(str);
	
	for (i = 0; i < len; i++){
		if ('a' <= str[i] && str[i] <= 'z'){
			str[i] = (((str[i] - 'a') * a + b) % 26) + 'a';
		}
	}
}

int main(void)
{
	char str[300];
	char temp[300];
	int n;
	int i, j, k;
	int flag;
	
	scanf("%d", &n);
	getchar();
	
	while (n--){
		scanf("%[^\n]", str);
		getchar();
		strcpy(temp, str);
		
		flag = 0;
		for (i = 1; i < 26; i++){
			if (26 % i == 0 && i != 1){
				continue;
			}
			for (j = 0; j < 26; j++){
				affine(str, i, j);
				k = 0;
				while (str[k + 3] != '\0'){
					if (strncmp(&str[k], "this", 4) == 0 || strncmp(&str[k], "that", 4) == 0){
						printf("%s\n", str);
						flag = 1;
						break;
					}
					k++;
				}
				
				strcpy(str, temp);
			}
			if (flag == 1){
				break;
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 0