akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int n;
    cin >> n;
    vi a(n);
    vi b(n-1);
    for(int i=0; i<n-1; i++){
        cin >> b.at(i);
    }
    int sum = b.at(0);
    for(int i=0; i<n-2; i++){
        sum += min(b.at(i), b.at(i+1));
    }
    sum += b.at(n-2);
    cout << sum << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repeq(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define rep1eq(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using Int = long long;

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n-1) cin >> c[i];
    int ans = 0;
    rep(i,n){
        ans += b[a[i]-1];
    }

    rep1(i,1,n){
        if(a[i-1] < n && a[i] == a[i-1]+1){
            ans += c[a[i-1]-1];
        }
    } 

    cout << ans << endl;

}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int main()
{
    string o, e;
    cin >> o >> e;
    int s = 0, t = 0;
    rep(i, o.size() + e.size())
    {
        if (i % 2 == 0)
        {
            cout << o[s];
            s++;
        }
        else
        {
            cout << e[t];
            t++;
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
loop do
  n, k = gets.split.map(&:to_i)
  break if n == 0
  points =
    k.times.map do
      c, a, b = gets.split
      a = a.to_i; b = b.to_i
      case c
      when 'xy'
        [a, b, 0]
      when 'yz'
        [0, a, b]
      when 'xz'
        [a, 0, b]
      end
    end
 
  cross_points = {}
  points.combination(2).each do |a, b|
    c = a.zip(b)
    if c.all?{ |p, q| !(p == 0 && q == 0) } && c.any?{ |p, q| p == q }
      p = c.map{ |p, q| [p, q].max }
      cross_points[p] ||= 0
      cross_points[p] = (cross_points[p] + 1) / 2 + 1
    end
  end
  puts n * n * n - k * n + (cross_points.values.reduce(:+) || 0)
end

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

struct Number
{
	int a, max{}, second{};
	int sum_max{};
};

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

	std::vector<Number> num(1 << n);
	for (int i{}; i < 1 << n; i++)
		scanf("%lld", &num[i].a);

	for (int k{1}; k < 1 << n; k++)
	{
		num[k].max = k;
		num[k].second = 0;
		if (num[k].second > num[k].max)
			std::swap(num[k].second, num[k].max);
		for (int i{}; 1 << i <= k; i++)
		{
			if (~k & (1 << i) || k == 1 << i)
				continue;
			int sub[2];
			sub[0] = num[k - (1 << i)].max;
			sub[1] = num[k - (1 << i)].second;
			if (sub[0] == num[k].max)
				std::swap(sub[0], sub[1]);
			else if (num[sub[0]].a >= num[num[k].max].a)
			{
				num[k].second = num[k].max;
				num[k].max = sub[0];
				std::swap(sub[0], sub[1]);
			}
			if (sub[0] != num[k].second && num[sub[0]].a >= num[num[k].second].a)
				num[k].second = sub[0];
		}
		num[k].sum_max = std::max(num[num[k].max].a + num[num[k].second].a, num[k - 1].sum_max);
		printf("%d\n", num[k].sum_max);
	}

	return 0;
}

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


 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define cins(s,n) rep(i,n)cin>>s.at[i];
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int> > matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;



ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}




int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x,y;cin>>x>>y;
    ll tmp=x,count=0;
    while(tmp<=y)
    {
        count++;
        tmp*=2;
    }
    cout<<count;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;scanf("%d",&n);
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int l,r;scanf("%d %d",&l,&r);
        ans+=r-l+1;
    }
    printf("%d\n",ans);
    return 0;
}
//r-l+1

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define ll long long
const int w=3e5+5;
const ll mod=1e9+7;
int main()
{
    int i,j;
    ll a,b,c;
    cin>>a>>b>>c;
    int flag=0;
    if(a==b&&b!=c)
        flag=1;
    if(a==c&&a!=b)
        flag=1;
    if(b==c&&a!=b)
        flag=1;
    if(flag)
        puts("Yes");
    else
        puts("No");
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
    if a[i - 1] < 0:
        a[i - 1] *= -1
        a[i] *= -1

if a[-1] < 0:
    a[-1] *= -1
    print(sum(a) - min(a) * 2)
else:
    print(sum(a))


Measured memory_bytes: 14212
N, K = map(int, input().split())
As = list(map(lambda x: int(x)-1, input().split()))

cnt = 1
v = 0
checked = [-1]*N
checked[0] = 0
while True:
    v = As[v]
    if checked[v]!=-1:
        loop = cnt-checked[v]
        road = checked[v]
        break
    cnt += 1
    checked[v] = cnt-1

ite = K if K<=road else road+((K-road)%loop)

v = 0
for i in range(ite):
    v = As[v]

print(v+1)

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

long long Temp(long long n, long long k) {
	long long a = n; long long b = k;
	long long z = a;

	while (true) {
		if (a > b)
			a %= b;
		else
			a = abs(a - b);

		if (a >= z)
			return z;
		else
			z = a;
	}
}

int main() {
	long long n = 0, m = 0;
	cin >> n >> m;
	
	cout << Temp(n, m) << endl;

	return 0;
}

Measured memory_bytes: 256
//--------O&Oo&oO&O---------------

#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

using in=long long int;

void SOLVE()
{
	
   int x,y,a,b,c;
   cin>>x>>y>>a>>b>>c;
   in sum1=0,sum2=0;
   vector<int> A(a),B(b),C(c),v;
   for(int i=0;i<a;i++)
   {
   	cin>>A[i];
   }
   for(int i=0;i<b;i++)
   {
   	cin>>B[i];
   }
   for(int i=0;i<c;i++)
   {
   	cin>>C[i];
   }
   sort(A.begin(),A.end());
   sort(B.begin(),B.end());
   sort(C.begin(),C.end());
   for(int i=a-1;i>=a-x;i--)
   	v.push_back(A[i]);
   for(int i=b-1;i>=b-y;i--)
   {
   	v.push_back(B[i]);
   }
   for(int i=c-1;i>=max(0,c-x-y);i--)
   {
   	v.push_back(C[i]);
   }
   sort(v.begin(),v.end());
   for(int i=v.size()-1;i>=v.size()-x-y;i--)
   {
   	sum1+=v[i];
   }
   cout<<sum1<<"\n";






}

int main()
{
	FAST_IO
	
	SOLVE();

	return 0;
}


Measured memory_bytes: 3572
//In The Name of ALLAH//

/*      ______     _    _______
       |  ___ \   | |  |  ____/   /\
       | |   \ \  | |  | |       /  \
       | |___/ /  | |  | |___   / /\ \
       |     _/   | |  |  __/  / /__\ \
       | |\ \     | |  | |    / ______ \
       | | \ \    | |  | |   / /      \ \
       |_|  \_\   |_|  |_|  /_/        \_\
*/

#include<bits/stdc++.h>

//#define FILEIO
#define ll long long

using namespace std;

const int SZ = 52;
const int LIM = 1000000000;
const double EPS = 1e-9;
const int MOD = 100000008;
const int INF = ( 1 << 30 ) - 1;
const double PI = 2 * acos( 0.0 );

template <class T> T MIN(T a, T b) { return (a < b) ? a : b; }
template <class T> T MAX(T a, T b) { return (a > b) ? a : b; }
template <class T> void SWAP(T &a, T &b) { T c; c = a; a = b; b = c; }
template <class T> T GCD(T a, T b) { T c; while(b > 0) { c = a % b; a = b; b = c; } return a; }

bool CMP(int a, int b)
{
    return (a > b);
}

ll ans, mn, mx, n, x, len, sum, i, cnt, j, a[SZ];

void solve()
{
    cin >> n;
    cout << n + n * n + n * n * n << endl;
}
int main()
{
    #ifdef FILEIO
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

    ll tc, t = 0;

    //cin >> tc;
    //while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 3632
import math

if __name__ == '__main__':
    s = input().rstrip().split(' ')
    N,K = int(s[0]), int(s[1])
    if(N>=K):
        #cand1 = int(abs(N - int(K*math.ceil(N/float(K)))))
        #cand2 = int(abs(N - int(K*math.floor(N/float(K)))))
        cand1 = int(N%K)
        cand2 = int(K-(N%K))
        print(min(cand1, cand2))
    else:
        print(min(int(abs(N-K)),N))


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<char> p(H * W);
  for(int i = 0; i < H * W; i++) {
    cin >> p.at(i);
  }
  for(int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
  for(int i = 0; i < H * W; i++) {
    if(i % W == 0) {
      cout << '#';
    }
    cout << p.at(i);
    if(i % W == W - 1) {
      cout << '#' << endl;
    }
  }
  for(int i = 0; i < W + 2; i++) {
    cout << '#';
  }
  cout << endl;
}

Measured memory_bytes: 3608
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int ans=0;
	if(n>=9) ans+=9;
	if(n>=999) ans+=900;
	if(n>=99999) ans+=90000;
	if(n>=0&&n<9) ans+=n-0;
	if(n>=100&&n<999) ans+=n-100+1;
	if(n>=10000&&n<99999) ans+=n-10000+1;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

r = sum([b[x-1] for x in a])
for i in range(n-1):
    if a[i]+1 == a[i+1]:
        r += c[a[i]-1]
print(r)


Measured memory_bytes: 3060
import sys

stdin = sys.stdin

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

n,p = nm()
s = list(map(int, list(ns())))
ans = 0
if p == 2:
  for i in range(n):
    if s[i]%2 == 0:
      ans += i+1
  print(ans); exit(0)
if p == 5:
  for i in range(n):
    if s[i]%5 == 0:
      ans += i+1
  print(ans); exit(0)
   
g = [0]*(n+1)
d = [0]*p
d[0] = 1
t = 1
for i in range(n-1,-1,-1):
    g[i] = (g[i+1] + s[i]*t)%p
    ans += d[g[i]]
    d[g[i]] += 1
    t = (t*10)%p
print(ans)


Measured memory_bytes: 12416
n = int(input())
a = input()
b = input()
c = input()

count = 0

for i in range(n):
    if a[i] != b[i] and b[i] != c[i] and c[i] != a[i]:
        count = count + 2
    elif a[i] == b[i] and b[i] == c[i]:
        count = count
    else:
        count = count + 1

print(count)

Measured memory_bytes: 3064
// ?????¬???????????¬??????

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1000000007LL;

int N, K, L, R, a[50];

signed main() {
    cin >> N >> K >> L >> R;
    rep(i,0,N) cin >> a[i];

    vector<int> va[K+1], vb[K+1];
    int A = N / 2, B = N - A;
    rep(bit,0,1<<A) {
        int C = __builtin_popcount(bit);
        if(C > K) continue;
        int val = 0;
        rep(i,0,A) if(bit >> i & 1) val += a[i];
        va[C].push_back(val);
    }

    rep(bit,0,1<<B) {
        int C = __builtin_popcount(bit);
        if(C > K) continue;
        int val = 0;
        rep(i,0,B) if(bit >> i & 1) val += a[A+i];
        vb[C].push_back(val);
    }

    repq(i,0,K) {
        va[i].push_back(INF), vb[i].push_back(INF);
        sort(va[i].begin(), va[i].end());
        sort(vb[i].begin(), vb[i].end());
    }

    int ans = 0;
    repq(i,0,K) {
        rep(j,0,va[i].size()) {
            int val = va[i][j];
            int lb = lower_bound(vb[K-i].begin(), vb[K-i].end(), L-val) - vb[K-i].begin();
            int ub = upper_bound(vb[K-i].begin(), vb[K-i].end(), R-val) - vb[K-i].begin();
            // printf("i = %lld, A val = %lld, ub = %lld, lb = %lld\n", i, va[i][j], ub, lb);
            ans += (ub - lb);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23300
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;


int main(){
    int N;
    cin>>N;
    vector<int> a(N);
    int cnt=0;
    for(int i=0;i<N;i++){
        cin>>a[i];
        while(!(a[i]%2)){
            cnt++;
            a[i] /=2;
        }
    }
    cout<< cnt <<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int A,B,K;

  cin>>A>>B>>K;

  if((B-A)>=2*K){
    for(int i=0;i<K;i++){
      cout<<A+i<<"\n";
    }
    for(int i=0;i<K;i++){
      cout<<B+1-K+i<<"\n";
     }
  }
  else{
    for(int i=A;i<=B;i++){
       cout<<i<<"\n";
    }
  }
  return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    String S;
    String T;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.S = sc.next();
        this.T = sc.next();
    }
    
    //解答処理
    private int solve() {
        int count = 0;
        if (!(S.equals(T))) {
        	for (int i=0; i<S.length(); i++) {
        		if (S.charAt(i) != T.charAt(i)) {
        			count++;
        		}
        	}
        }
        
        return count;
    }
    
    //出力
    public void show(int answer) {
        System.out.println(answer);
    }

}


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

struct Plan {
  int t, x, y;
};

int main() {
  int n; cin >> n;
  vector<struct Plan> p(n);
  REP(i, n) cin >> p[i].t >> p[i].x >> p[i].y;
  struct Plan now;
  now.t = now.x = now.y = 0;
  REP(i, n) {
    int diff = p[i].t - now.t;
    int move = abs(p[i].x - now.x) + abs(p[i].y - now.y);
    if (diff < move or (diff - move) % 2) {
      cout << "No" << endl;
      return 0;
    }
    now.t = p[i].t;
    now.x = p[i].x;
    now.y = p[i].y;
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1536
/* ex7_1
   Sweet_Sweey_Soul*/

#include <stdio.h>

//座標用の構造体
typedef struct{
    int x_elem;
    int y_elem;
}point;

//a_1,a_2,a_3の順に反時計回りかつa_2が直角な直角二等辺となるa_3を出力
point shift_point(point a1,point a2);

int main(void){
    point apex1,apex2,apex3,apex4;
    //ドット演算子は優先度が最も高いので以下の書き方で入力可能
    scanf("%d%d%d%d",&apex1.x_elem,&apex1.y_elem,&apex2.x_elem,&apex2.y_elem);
    apex3=shift_point(apex1,apex2); //頂点1,2,3の順番で反時計回りになる
    apex4=shift_point(apex2,apex3); //頂点2,3,4の順番で反時計回りとなる
    printf("%d %d %d %d\n",apex3.x_elem,apex3.y_elem,apex4.x_elem,apex4.y_elem);
    return 0;
}

point shift_point(point a1,point a2){
    //答えの保存用の変数を用意
    point ans;
    //a_1からa_2に向かうベクトルのxy成分を計算
    int vec_x=a2.x_elem-a1.x_elem;
    int vec_y=a2.y_elem-a1.y_elem;
    //ベクトル(x,y)を反時計回りに90度回転したベクトルは(-y,x)
    //よってa2を(-vec_y,vec_x)を平行移動した点を出力すれば良い
    ans.x_elem=a2.x_elem-vec_y;
    ans.y_elem=a2.y_elem+vec_x;
    return ans;
}


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

int main()
{
	long long n, k; cin >> n >> k;

	vector<pair<long long,long long>> p;


	for (int i = 0; i < n; i++) {
		long long tmp_a;
		long long tmp_b;
		cin >> tmp_a >> tmp_b;
		p.emplace_back(tmp_a, tmp_b);
	}

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

	long long cnt = 0;
	long long ans;
	for (int i = 0; i < n; i++) {

		cnt += p[i].second;

		if (k <= cnt) {
			ans = p[i].first;
			break;
		}

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

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

class Dice {
public:
	Dice() {
		face[0] = &T;
		face[1] = &S;
		face[2] = &E;
		face[3] = &W;
		face[4] = &N;
		face[5] = &B;
	}
	void setNumber() {
		for (int i = 0; i < 6; i++)
			cin >> *face[i];
	}
	int getT() {
		return T;
	}
	int getE() {
		return E;
	}
	void setCommand() {
		cin >> command;
	}
	void move() {
		for (int i = 0; i < command.size(); i++) {
			switch (command[i]) {
			case 'E': move(E, T, W, B); break;
			case 'N': move(N, T, S, B); break;
			case 'S': move(S, T, N, B); break;
			case 'W': move(W, T, E, B); break;
			}
		}
	}
	void move(int& a, int& b, int& c, int& d) {
		int temp = a;
		a = b;
		b = c;
		c = d;
		d = temp;
	}
private:
	int* face[6];
	int T, S, E, W, N, B;
	string command;
};

int main() {
	Dice dice1;
	dice1.setNumber();
	dice1.setCommand();
	dice1.move();
	cout << dice1.getT() << endl;
	return 0;
}


Measured memory_bytes: 3204
#include<cstdio>
typedef long long ll;
const int N=2e5+3,K=19,M=924844033,G=5;
inline int Pow(int a,int m){int s=1;for(;m;m>>=1)m&1?s=(ll)s*a%M:0,a=(ll)a*a%M;return s;}
struct edge{int v,nxt;}g[N+N];
int n,f[N],invf[N],b[N],siz[N],head[N],k,t0[1<<K],t1[1<<K],rev[1<<K];
inline void Insert(int u,int v){g[++k]=(edge){v,head[u]};head[u]=k;}
void Dfs(int u,int fa){
	int v;
	siz[u]=1;
	for(int i=head[u];i;i=g[i].nxt)if((v=g[i].v)!=fa)
	  Dfs(v,u),siz[u]+=siz[v];
	if(fa)b[siz[u]]++,b[n-siz[u]]++; 
}
inline void Init(int K){
	for(int i=0;i<(1<<K);i++)rev[i]=rev[i>>1]>>1|(i&1)*(1<<K-1);
}
inline void Ntt(int*a,int f,int K){
	int tmp,tmp1,omega;
	for(int i=0;i<(1<<K);i++)if(i<rev[i])tmp=a[i],a[i]=a[rev[i]],a[rev[i]]=tmp;
	for(int k=1;k<(1<<K);k<<=1){
	  omega=Pow(G,f>0?M/2/k:M-1-M/2/k);
	  for(int i=0;i<(1<<K);i+=k+k)
		for(int j=0,s=1;j<k;j++,s=(ll)s*omega%M)
		  tmp=a[i+j],tmp1=(ll)a[i+k+j]*s%M,
		  a[i+j]=(tmp+tmp1)%M,a[i+k+j]=(tmp-tmp1+M)%M;
	  }
	if(f<0){
	  tmp=Pow(1<<K,M-2);
	  for(int i=0;i<(1<<K);i++)
		a[i]=(ll)a[i]*tmp%M;
	}
}
int main(){
	int u,v;
	scanf("%d",&n);
	f[0]=1;
	for(int i=1;i<=n;i++)f[i]=(ll)f[i-1]*i%M;
	invf[n]=Pow(f[n],M-2);
	for(int i=n;i;i--)invf[i-1]=(ll)invf[i]*i%M;
	for(int i=1;i<n;i++)scanf("%d%d",&u,&v),Insert(u,v),Insert(v,u);
	Dfs(1,0);
	for(int i=1;i<=n;i++)t0[i]=(ll)b[i]*f[i]%M;
	for(int i=0;i<=n;i++)t1[i]=invf[n-i];
	for(k=1;(1<<k)<=n+n;k++);
	Init(k);
	Ntt(t0,1,k),Ntt(t1,1,k);
	for(int i=0;i<(1<<K);i++)t0[i]=(ll)t0[i]*t1[i]%M;
	Ntt(t0,-1,k);
	for(int k=1;k<=n;k++)printf("%lld\n",((ll)n*f[n]%M*invf[k]%M*invf[n-k]%M-(ll)invf[k]*t0[n+k]%M+M)%M);
	return 0;
}

Measured memory_bytes: 28780
import sys
input = sys.stdin.readline

a = input().rstrip()
b = []
for i in a:
    b.append(int(i))

op = [""] * 3
for i in range(2 ** 3):
    cnt = b[0]
    for j in range(3):
        if ((i >> j) & 1):
            op[2-j] = "+"
        else:
            op[2-j] = "-"
    for j in range(3):
        if op[j] == "+":
            cnt += b[j+1]
        else:
            cnt -= b[j+1] 
    if cnt == 7:
        print(b[0], op[0], b[1], op[1], b[2], op[2], b[3], "="+str(cnt),sep="")
        break


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  ll n,l;
  cin>>n>>l;
  ll a[n+1]={};
  ll two[n+1]={};
  bool flag=0;
  int right=0;
  for(int i=1;i<=n;i++){
    cin>>a[i];
    two[i]=a[i]+a[i-1];
    if(two[i]>=l){
      flag=1;
      right=i;
    }
  }

  if(!flag){
    cout<<"Impossible"<<endl;
    return 0;
  }

  cout<<"Possible"<<endl;
  for(int i=1;i<right-1;i++){
    cout<<i<<endl;
  }
  for(int i=n-1;i>=right;i--){
    cout<<i<<endl;
  }
  if(right!=1) cout<<right-1<<endl; 

  return 0;
}


Measured memory_bytes: 2432
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 3e3 + 10;
int a[N];
int b[N];
int ans[N];
int powmod(int a, int b, int p = INF)
{
	int ret = 1;
	while (b)
	{
		if (b & 1) ret = ret * a % p;
		b >>= 1;
		a = a * a % p;
	}
	return ret;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int p;
	cin >> p;

	for (int i = 0; i < p; i++)
	{
		int x;
		cin >> x;
		if (x == 0) continue;
		MEM(a, 0);
		a[p] = 1;
		a[1] = p - 1;
		for (int j = p; j > 0; j--)
		{
			b[j - 1] = a[j];
			a[j - 1] = (a[j - 1] + a[j] * i) % p;
		}
		int cur = 0;
		for (int j = p - 1; j >= 0; j--)
		{
			cur = cur * i + b[j];
			cur %= p;
		}
		cur = powmod(cur, p - 2, p);
		for (int j = p - 1; j >= 0; j--)
		{
			ans[j] = (ans[j] + cur * b[j]) % p;
		}
	}
	for (int j = 0; j < p; j++)
		printf("%d%c", ans[j], " \n"[j == p - 1]);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

	int A, B, C;
	A = sc.nextInt();
	B = sc.nextInt();
	C = sc.nextInt();

	if (A == B) {
	    if (A == C)
		System.out.println("No");
	    else
		System.out.println("Yes");
	} else if (B == C) {
	    if (B == A)
		System.out.println("No");
	    else
		System.out.println("Yes");
	} else if (C == A) {
	    if (C == B)
		System.out.println("No");
	    else
		System.out.println("Yes");
	} else
	    System.out.println("No");

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
int B=350;
ll sum1[200005];
ll sum2[200005];
ll sq_sum[351][351];


int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		if(b<B){
			for(int j=0;j<b;j++){
				sq_sum[b][j]+=(a+j+1LL)%b;
				//printf("%lld ",(a+j+1LL)%b);
			}
			//printf("\n");
		}else{
			sum1[1]++;
			sum2[1]+=a;
			int j=b-a;
			while(j<=n){
				sum2[j]-=b;
				j+=b;
			}
		}
	}
	for(int i=1;i<=n;i++){
		sum1[i+1]+=sum1[i];
	}
	for(int i=1;i<=n;i++){
		sum2[i]+=sum1[i];
	}
	for(int i=1;i<=n;i++){
		sum2[i+1]+=sum2[i];
	}
	for(int i=1;i<=n;i++){
		ll res=sum2[i];
		for(int j=1;j<B;j++){
			int g=(i+j-1)%j;
			res+=sq_sum[j][g];
			if(sq_sum[j][g]>0){
				//printf("j=%d %d %lld\n",j,g,sq_sum[j][g]);
			}
		}
		printf("%lld\n",res);
	}
	return 0;
} 


Measured memory_bytes: 4844
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N, M, C;
	in >> N >> M >> C;
	std::vector<LL>B(M);
	std::vector<std::vector<LL>>A(N, std::vector<LL>(M));
	rep(i, M) in >> B[i];
	rep(i, N) rep(j, M) in >> A[i][j];

	LL ans = 0;
	rep(i, N)
	{
		LL sum = 0;
		rep(j, M)
		{
			sum += A[i][j] * B[j];
		}
		if (sum + C > 0) ++ans;
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();

    let n_k = lines.next().unwrap().unwrap();
    let mut n_k = n_k.split_whitespace();
    let n = n_k.next().unwrap().parse::<usize>().unwrap();
    let k = n_k.next().unwrap().parse::<usize>().unwrap();

    let r_s_p = lines.next().unwrap().unwrap();
    let mut r_s_p = r_s_p.split_whitespace();
    let r = r_s_p.next().unwrap().parse::<i32>().unwrap();
    let s = r_s_p.next().unwrap().parse::<i32>().unwrap();
    let p = r_s_p.next().unwrap().parse::<i32>().unwrap();

    let t = lines.next().unwrap().unwrap();
    let mut t = t.chars().collect::<Vec<char>>();

    for i in 0..n - k {
        if t[i] == t[i + k] {
            t[i + k] = ' ';
        }
    }

    let mut ans = 0;
    for &c in t.iter() {
        match c {
            'r' => ans += p,
            's' => ans += r,
            'p' => ans += s,
            _ => (),
        }
    }

    println!("{}", ans);
}


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

int main(){
	int sum,j;
	int i=0;
	int N =200;
	
	int a[N], b[N], dig[N];
	
	while(cin >> a[i] >> b[i]){
		dig[i]=1;
		if(0<=a[i] && a[i]<=1000000 && 0<=b[i] && b[i]<=1000000){
			sum = a[i]+b[i];
			while(sum/10 != 0){
				sum = sum/10;
				dig[i] += 1;
			}
			i++;
		}
	}
	
	for(j=0; j<i; j++){
		cout << dig[j] << "\n";
	}
}

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

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef long long ll;

set<int> mergeSet(set<int> s1, set<int> s2) {
	for (int ele : s2) {
		s1.insert(ele);
	}
	return s1;
}


void solve() {
#ifdef _WIN32
	istream &cin = ifstream("input.txt");
#endif

	char c;
	cin >> c;
	if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
	else cout << "consonant" << endl;
}




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


	solve();
#ifdef _WIN32
	system("PAUSE");
#endif
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.text.*;
public class Main {
    public static void main (String[]args) throws IOException{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        long a[] = Arrays.stream(in.readLine().split(" ")).mapToLong(Long::parseLong).toArray();
        long x = (a[2]-a[0]-a[1]);
        long y = 4*a[0]*a[1];

        System.out.println(x>0 && x*x>y?"Yes":"No");

   

    }
}

Measured memory_bytes: 31224
<?php
$n = trim(fgets(STDIN));
$a = explode(" ",trim(fgets(STDIN)));
$x = trim(fgets(STDIN));
$m = explode(" ",trim(fgets(STDIN)));


if($n < $x){
echo "NO";
}else{
$a = array_count_values($a);
$q = 0;
$i = 0;
while($i < $x){
$c = $m[$i];
if(isset($a[$c])){
--$a[$c];
}else{
++$q;
break;
}
++$i;
}

if($q != 0){
echo "NO";
}else{
echo min($a) < 0?"NO":"YES";
}
}

Measured memory_bytes: 102100
def f(a):
    return a * a % m


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

a = x
i = 1
li = [a]
num2index = {a: 1}
while f(a) not in num2index and i + 1 <= n:
    i += 1
    a = f(a)
    li.append(a)
    num2index[a] = i

if i == n:
    ans = sum(li)
else:
    before_loop = num2index[f(a)]
    loop, left = divmod(n - i, i - before_loop + 1)
    loop_sm = loop * sum(li[before_loop-1:])
    left_sm = sum(li[before_loop-1:before_loop-1+left])
    ans = sum(li) + loop_sm + left_sm

print(ans)


Measured memory_bytes: 15692
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const ll inf = 4523372036854775807;
const ld pi = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct S {//辺の情報を入れる変数
	int from, to, cost;
};
struct H {
	int x, y;
};
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(ld a, ld b, ld c, ld d) {
	return sqrt(pow(a - c, 2) + pow(b - d, 2));
}//rad＝座標上の2点間の距離
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
int n, m, r;
vector<int>f;
int a[201][201];
int solve(int i, int s, int t) {
	if (i == r)
		return 0;
	int res = inf;
	for (int j = 0; j < r; j++) {
		if (!(1 << j&s))
			res = min(res, a[f[t]][f[j]] + solve(i + 1, s | 1 << j, j));
	}
	return res;
}
signed main() {
	cin >> n >> m >> r;
	for (int i = 0; i<r; i++) {
		int t;
		cin >> t;
		f.push_back(t);
	}
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= n; j++)
			a[i][j] = inf;
	for (int i = 0; i < m; i++) {
		int u, o, p;
		cin >> u >> o >> p;
		a[u][o] = p;
		a[o][u] = p;
	}
	for (int i = 1; i <= n; i++)
		a[i][i] = 0;
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
			}
		}
	}
	int sum = inf;
	for (int i = 0; i < r; i++) {
		int res = solve(1, 1 << i, i);
		sum = min(sum, res);
	}
	cout << sum << endl;
	getchar(); getchar();
}

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

int main()
{
    int n, a[1009];
    cin >> n;
    rep(i, n) cin >> a[i];
    bool flag = true;
    rep(i, n)
    {
        if (a[i] % 2 == 1)
            continue;
        if (a[i] % 3 != 0 && a[i] % 5 != 0)
            flag = false;
    }
    if (flag)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 3636
/*input

*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 1005;
int a[N];
int n,k;
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> k;
	up(i,1,n) cin >> a[i];
	sort(a+1,a+1+n);
	int ans = 0;
	up(i,1,k) ans += a[i];
	cout << ans;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
using Graph=vector<vector<int>>;

int main()
{
  int N,K;cin>>N>>K;
  vector<int> s(N+1,0);
  for (int i=1;i<=N;i++)
  {
    int d;cin>>d;
    for (int j=0;j<d;j++)
    {
      int a;cin>>a;s[a]++; 
    }
  }
  
  int count=0;
  for (int i=1;i<=N;i++)
  {
    if (s[i]==0)count++; 
  }
  cout<<count<<endl;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	cout << a.back() - a.front() << endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    N = int(input())
    aList = list(map(lambda x: int(x), input().split()))

    aliceValue = 0
    bobValue = 0
    isAliceTurn = True
    while len(aList) > 0:
        maxValue = max(aList)
        aList.remove(maxValue)
        if isAliceTurn:
            aliceValue += maxValue
        else:
            bobValue += maxValue

        isAliceTurn = not isAliceTurn

    print(aliceValue - bobValue)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9184
#include <iostream>
using namespace std;
int main(){
  int K,Even,Odd,ans;
  cin>>K;
  if(K%2==0){
      Even=K/2;
      Odd=K/2;
  }else{
      Even=K/2;
      Odd=K/2+1;
  }
    ans=Even*Odd;
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	unsigned long long n, temp;
	cin >> n;
	string ans;

	while (n > 0)
	{
		n -= 1;
		if (n < 26)
			ans = static_cast<char>('a' + (n)) + ans;
		else
			ans = static_cast<char>('a' + (n % 26)) + ans;
		n /= 26;
	}

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int n;
double x,ans;
int main () {
	scanf("%d",&n);
	for (int i=1;i<=n;i++) {
		scanf("%lf",&x);
		ans+=1.0/x;
	}
	ans=1.0/ans;
	printf("%lf\n",ans);
}

Measured memory_bytes: 256
N=int(input())
S=[0]*N;p=0;f=0
for i in range(N):
  a,b=map(int,input().split())
  S[i]=[a,b]
  if a-b==0:
    p=p+1
    if p>=3:
      f=1
  else:
    p=0
if f==1:
  print("Yes")
else:
  print("No")

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

int main() {
  long long N;
  scanf("%lld", &N);

  int ans = 10000;
  for (long long i = 1LL; i <= sqrt(N); i++) {
    if (N % i != 0) continue;
    long long A = i;
    long long B = N / A;
    int A_digit = 0;
    int B_digit = 0;
    while (A > 0) {
      A_digit++;
      A /= 10;
    }
    while (B > 0) {
      B_digit++;
      B /= 10;
    }
    int cur = max(A_digit, B_digit);
    if (ans > cur) ans = cur;
  }
  printf("%d", ans);
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
int a[55];
ll dp[55][55*55][55];
int n,x;
ll go(int idx, int sm,int cnt){
    if(idx>n){
        if(sm%x==0 and sm/x==cnt)return 1;
        return 0;
    }
    ll &ret = dp[idx][sm][cnt];
    if(ret!=-1)return ret;
    ret = go(idx+1,sm,cnt);
    ret+= go(idx+1,sm+a[idx],cnt+1);
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>x;
    memset(dp,-1,sizeof dp);
    for(int i=1;i<=n;i++)cin>>a[i];
    cout<<go(1,0,0)-1<<endl;
    return 0;
}


Measured memory_bytes: 71808
#include <stdio.h>
#include <iostream>

using namespace std;

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

int main() {
    // N: スイッチ
    // M: 電球
    int N, M; cin >> N >> M; // 1 <= N, M <= 10

    int pSize = 1;
    REP(0, n, N) {
        pSize *= 2;
    }

    // スイッチのパターン
    // 0: OFF, 1: ON
    int b[pSize][N];
    REP(0, j, pSize) REP(0, n, N) b[j][n] = 0;
    REP(0, j, pSize) REP(0, n, N) b[j][n] = ((j >> n) & 0x1);

    // 電球に関連するスイッチ
    int s[M][N];
    REP(0, m, M) REP(0, n, N) s[m][n] = 0;
    REP(0, m, M) {
        int k; cin >> k;
        REP(0, i, k) {
            int tmp; cin >> tmp; tmp--; // 配列の添字に合わせる
            s[m][tmp] = 1;
        }
    }

    // 電球に関連する点灯条件
    int p[M]; REP(0, m, M) cin >> p[m];

    int cnt = 0;
    REP(0, j, pSize) {
        int lights[M]; REP(0, m, M) lights[m] = 0;
        REP(0, m, M) {
            REP(0, n, N) {
                if (b[j][n] == 1) { // スイッチがON
                    // 電球に関連したスイッチならばカウントアップ
                    lights[m] += s[m][n];
                }
            }
        }
        REP(0, m, M) {
            lights[m] = lights[m] % 2;
        }
        // すべて点灯か？
        bool flag = true;
        REP(0, m, M) {
            if (lights[m] != p[m]) {
                flag = false;
                break;
            }
        }
        if (flag) cnt++;
    }

    cout << cnt << 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;

string S, T;
vector<string> ans;

void search(int x) {
  string S_sub = S;
  rep(i, T.size()){
    if (S[x + i] == '?') S_sub[x + i] = T[i];
    else if (S[x + i] != T[i]) return;
  }
  rep(i, S_sub.size()) {
    if (S_sub[i] == '?') S_sub[i] = 'a';
  }
  
  ans.push_back(S_sub);
  return;
}

int main() {
  cin >> S >> T;
  
  if (S.size() < T.size()) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  rep(i, S.size() - T.size() + 1) search(i);
  
  sort(ans.begin(), ans.end());
  if (ans.size() == 0) cout << "UNRESTORABLE" << endl;
  else cout << ans[0] << endl;
  return 0;
}

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

/* 
 * g++ -std=c++17 main.cpp -o main
 */
int main() {
  ios::sync_with_stdio(false);
  string s;
  cin>>s;
  string output = "";
  for(char c : s) {
    if (c == 'B') {
      output=output.substr(0, output.size()-1);
    } else {
      output+=c;
    }
  }
  cout<<output<<endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int R;
    cin >> R;
    
    if (1200>R){
        cout << "ABC" <<endl;
    }else if(2800>R){
        cout <<"ARC"<<endl;
    }else {
        cout << "AGC"<<endl;
    }
}

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

int main() {
  int n,k,r,s,p;
  string t;
  cin >>n>>k>>r>>s>>p>>t;
  long long kotae=0;
  for(int i=0;i<t.size();i++){
    if(t[i]=='r')kotae+=p;
    else if(t[i]=='s')kotae+=r;
    else kotae+=s;
  }
  for(int i=0;i<t.size()-k;i++){
    if(t[i]=='r'&&t[i]==t[i+k]){
      kotae-=p;
      t[i+k]='o';
    }else if(t[i]=='s'&&t[i]==t[i+k]){
      kotae-=r;
      t[i+k]='o';
    }else if(t[i]=='p'&&t[i]==t[i+k]){
      kotae-=s;
      t[i+k]='o';
    }
  }
  cout<<kotae<<endl;
  return 0;
}
  

Measured memory_bytes: 512
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    string s;
    cin >> s;
    int n = s.length() + 1;
    VL a(n), c(n);
    REP(i,n-1){
        if (s[i] == '<') c[i+1]++;
        else c[i]++;
    }
    queue<int> que;
    REP(i,n) if (c[i] == 0) que.push(i);
    while (!que.empty()){
        int i = que.front();
        que.pop();
        if (i > 0){
            if (s[i - 1] == '<') chmax(a[i], a[i - 1] + 1);
            else {
                c[i - 1]--;
                if (c[i - 1] == 0) que.push(i - 1);
            }
        }
        if (i < n - 1){
            if (s[i] == '>') chmax(a[i], a[i + 1] + 1);
            else {
                c[i + 1]--;
                if (c[i + 1] == 0) que.push(i + 1);
            }
        }
    }
    ll ans = 0;
    REP(i,n) ans += a[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9220
solve :: Int -> String -> [Int]
solve _ [] = 0 : []
solve n (x:xs)
  | x == 'I' = (n + 1) : solve (n + 1) xs
  | otherwise = (n - 1) : solve (n - 1) xs

main = getContents >>= print . maximum . solve 0 . last . lines

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main() { 
    int n, m;
    cin >> n >> m;
    vector<int> s, c;
    rep(i, m){
        int a, b;
        cin >> a >> b;
        s.push_back(a);
        c.push_back(b);
    }

    int ten=10;
    rep2(i, 1, n){
        ten *= 10;
    }
    rep2(i, ten/10-1, ten){
        if(n!=1&&i==ten/10-1){
            continue;
        }
        bool flag = true;
        rep(j, m){
            int x;
            switch(s[j]+3-n){
                case 3:
                x = i % 10;
                break;
                case 2:
                x = (i/10) % 10;
                break;
                case 1:
                x = i/100;
            }
            if(x!=c[j]){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << i << endl;
            return 0;
        }
    }

    // if(ans==0&&n!=1){
    //     ans = -1;
    // }
    // if(n!=1&&ten/10>ans){
    //     rep(i, n-1){
    //         if(zero[i]){
    //           ans = -1;
    //         }
    //     }
    // }
    cout << -1 << endl;
    return 0; 
}

Measured memory_bytes: 256
S = input()

# 1 <= |S| <= 26
# lowercase

import sys
import copy

def next_permutation(a):
    for i in reversed(range(len(a) - 1)):
        if a[i] < a[i + 1]:
            break
    else:
        return False

    j = next(j for j in reversed(range(i + 1, len(a))) if a[i] < a[j])
    a[i], a[j] = a[j], a[i]
    a[i + 1:] = reversed(a[i + 1:])
    return True

if len(S) == 26:
    sl = list(S)
    if next_permutation(sl):
        np = "".join(sl)
        for b in range(0, 26):
            if np[b] != S[b]:
                print(np[:b+1])
                exit()

    else:
        print(-1)
        exit()
else:
    hist = set(S)
    for c in range(0, 27):
        cand = chr(c+ord('a'))
        if cand not in hist:
            print(S+cand)
            sys.exit()

Measured memory_bytes: 9216
fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn main() {
    let (a, b) = input_pair::<usize>();
    if a < b {
        println!("{}", format!("{}", a).chars().cycle().take(b).collect::<String>());
    } else {
        println!("{}", format!("{}", b).chars().cycle().take(a).collect::<String>());
    }
}


Measured memory_bytes: 2076
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX = 2e5;


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

    map<string, int> freq;


    int most = 0;
    string s;
    for (int i = 0; i < n; ++i) {
        cin >> s;
        auto it = freq.find(s);
        if (it == freq.end()) {
            it = freq.insert({s, 0}).first;

        }
        it->second++;
        most = max(most, it->second);
    }

    vector<string> ret;
    for (auto itr = freq.begin(); itr != freq.end(); ++itr) {
        if (itr->second == most) {
            ret.push_back(itr->first);
        }
    }

    sort(ret.begin(), ret.end());
    for (auto s : ret) {
        cout << s << "\n";
    }

    return 0;
}


Measured memory_bytes: 26868
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
//#define mod 1000000007
//#define maxn 100200
using namespace std;
int main()
{
	int n,o=0,a,b,c,u=1,m[4];
	scanf("%d",&n);
	scanf("%d",&a);
	m[1]=1;m[2]=0;m[3]=0;
	for(int i=1;i<n;i++)
	{
		int l;
		scanf("%d",&l);
		if(u==1)
		{
			if(l==a)
				m[1]++;
			if(l!=a)
			{

				b=l;
				u++;
			}
		}
		if(u==2)
		{
			if(l==a)
				m[1]++;
			if(l==b)
				m[2]++;
			if(l!=a&&l!=b)
			{
				c=l;
				u++;
			}
		}
		if(u==3)
		{
			if(l==a)
				m[1]++;
			if(l==b)
				m[2]++;
			if(l==c)
				m[3]++;
			if(l!=a&&l!=b&&l!=c)
				o++;
		}
		//printf("%d %d %d %d %d\n",u,o,m[1],m[2],m[3]);
	}
	//printf("%d %d %d %d %d\n",u,o,m[1],m[2],m[3]);
	if(u==1)
	{
		if((a^a)!=a)
			printf("No\n");
		else
			printf("Yes\n");
	}
	if(u==2)
	{
		if(((a^b)==a && m[1]==2*m[2])||((a^b)==b && m[2]==2*m[1]))
			printf("Yes\n");
		else
			printf("No\n");
	}
	if(u==3)
	{
		if((a^b)!=c||m[1]!=m[2]||m[2]!=m[3]||o)
			printf("No\n");
		else
			printf("Yes\n");
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
using namespace std;
typedef long long ll;
const int INF = int(0x7fffffff / 2);
const int maxn = 10010;

class Edge {
public:
	int from, to;
	double weight;
	Edge(int f, int t, double w):from(f), to(t), weight(w) {}
	Edge(){}
	bool operator < (const Edge& e) const {
		return weight < e.weight;
	}
};

int N, M;
pair<int, int> loc[maxn];
int parent[maxn];

int getParent(int i) {
	if (i == parent[i])
		return i;
	else {
		int tmp = parent[i];
		parent[i] = getParent(parent[i]);
	}
	return parent[i];
}
void merge(int i, int j) {
	int fi = getParent(i);
	int fj = getParent(j);
	if (fi != fj) {
		parent[fi] = fj;
	}
}
void init() {
	for (int i = 1; i <= N; ++i) {
		parent[i] = i;
	}
}
bool isBrother(int i, int j) {
	return getParent(i) == getParent(j);
}
double distance(int a, int b) {
	double re = (loc[a].first - loc[b].first) * (loc[a].first - loc[b].first)
		+ (loc[a].second - loc[b].second) * (loc[a].second - loc[b].second);
	return sqrt(re);
}

int main() {
////////////////////////////////////////////////////////////////////
	ios::sync_with_stdio(false); // 给 cin cout加速
	cin.tie(0);
	////////////////////////////////////////////////////////////////////////////
	while (scanf("%d%d", &N, &M) != EOF) {
		init();
		for (int i = 1; i <= N; ++i)
			scanf("%d%d", &loc[i].first, &loc[i].second);
		priority_queue<Edge> edges;
		int a, b;
		double cost = 0;
		for (int i = 1; i <= M; ++i) {
			scanf("%d%d", &a, &b);
			double weight = distance(a, b);
			//cout << weight << endl;
			cost += weight;
			edges.push(Edge(a, b, weight));
		}

		double result = 0;
		int cnt = 0;
		while (!edges.empty() && cnt < N-1) {
			Edge tmp = edges.top();
			edges.pop();
			if (!isBrother(tmp.from, tmp.to)) {
				result += tmp.weight;
				merge(tmp.from, tmp.to);
				cnt++;
			}
		}
		printf("%.3lf\n", cost - result);
	}

	return 0;
}



Measured memory_bytes: 3640