akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;

void solve(){
	int n,k;
	cin>>n>>k;
	int x;
	int r=n;
	int sum=0;
	int m=1e8;
	while(n--){
		cin>>x;
		sum+=x;
		m=min(m,x);

	}
	cout<<r+max(k-sum,0)/m;
}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#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 SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int c1, c5, c10, c50, c100, c500;
	cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;

	int ans = 1000 <= c1 + c5 * 5 + c10 * 10 + c50 * 50 + c100 * 100 + c500 * 500;

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




Measured memory_bytes: 3160
import           Control.Monad
main = do
    [w, h, n] <- map read . words <$> getLine
    v <- map (map read . words) <$> replicateM n getLine :: IO [[Int]]
    let m = [0, w, 0, h]
    print . g $ foldr f m v
  where
    f [x, y, a] [w1, w2, h1, h2] =
        case a of
            1 -> [max w1 x, w2, h1, h2]
            2 -> [w1, min w2 x, h1, h2]
            3 -> [w1, w2, max h1 y, h2]
            4 -> [w1, w2, h1, min h2 y]
    g [w1, w2, h1, h2] = max 0 (w2 - w1) * max 0 (h2 - h1)


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

int n;
vi m;
vii dp;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    cin >> n;
    m.resize(n+1);
    dp.resize(n+1, vi(n+1));

    rep(i,n) cin >> m[i] >> m[i+1];

    /*対象とする行列の数を l としてインクリメントしていく
     * 　( ↑　このように区間の大きさ順に処理することでfor文で回しても更新順序の整合性が保たれる )
     * 対象とする行列の範囲を i ~ j とし、その区間を i ~ k , k+1 ~ j として dp loop をまわす
     */
    for(int l = 2; l <= n; ++l) {
        for(int i = 1; i <= n-l+1; ++i) {
            int j = i+l-1;
            dp[i][j] = inf;
            for(int k = i; k < j; ++k) {
                chmin(dp[i][j], dp[i][k] + dp[k+1][j] + m[i-1]*m[k]*m[j]);
            }
        }
    }
//    rep1(i,n)rep1(j,n) cout << dp[i][j] << (j==n ? '\n' : ' ');

    cout << dp[1][n] << '\n';

    // printf("ExcutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3192
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    string s;
    Int q;
    cin >> s >> q;

    bool rev = false;
    string fr = "", ba = "";
    for (Int i = 0; i < q; i++) {
        int t;
        cin >> t;

        if (t == 1) {
            rev = !rev;
        } else {
            int f = 0;
            char c = '\0';
            cin >> f >> c;

            if (!rev) {
                if (f == 1) {
                    fr.push_back(c);
                } else {
                    ba.push_back(c);
                }
            } else {
                if (f == 1) {
                    ba.push_back(c);
                } else {
                    fr.push_back(c);
                }
            }
        }
    }

    if (rev) {
        reverse(ba.begin(), ba.end());
        reverse(s.begin(), s.end());
        s = ba + s + fr;
    } else {
        reverse(fr.begin(), fr.end());
        s = fr + s + ba;
    }

    cout << s << endl;
}


Measured memory_bytes: 1348
import sys
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))

n = INT()
strings = [[]*10 for i in range(n)]
for i in range(n):
    strings[i] = sorted(list(input()))

strings = sorted(strings)

succession = [0]*n
counter = 0
for i in range(1,n):
    if strings[i] == strings[i-1]:
        succession[i] = succession[i-1]+1
    if strings[i] != strings[i-1] and succession[i-1]>0:
        counter += (succession[i-1]+1)*succession[i-1]//2
    if i == n-1 and succession[i] >0:
        counter += (succession[i]+1)*succession[i]//2

print(counter)
        

Measured memory_bytes: 94640
#include <vector>
#include <utility>
#include <tuple>
#include <cstdio>
#include <iterator>
#include <algorithm>
int main()
{
	int n,c; ~scanf("%d%d",&n,&c);
	std::vector< std::tuple<int,int,int> > v(n);
	std::vector< std::pair<int,int> > rec;
	for(int i=0;i<n;i++) ~scanf("%d%d%d",&std::get<0>(v[i]),&std::get<1>(v[i]),&std::get<2>(v[i]));
	std::sort(v.begin(),v.end());
	for(int i=0;i<n;i++) {
		int k = 0;
		while(k < rec.size() and std::get<2>(v[i]) != rec[k].second and std::get<0>(v[i]) <= rec[k].first) k+=1;
		if(k == rec.size()) rec.push_back(std::make_pair(std::get<1>(v[i]),std::get<2>(v[i])));
		else rec[k].first = std::get<1>(v[i]) , rec[k].second = std::get<2>(v[i]);
	}
	printf("%lu\n",rec.size());
	return 0;
}

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

A, B, K = map(int, input().split())

if A >= K : 
    A = A - K
    K = 0
else : 
    K = K - A
    A = 0

if B >= K : 
    B = B - K
    K = 0
else : 
    K = K - B
    B = 0
    
print(A, B)

Measured memory_bytes: 3060
n = gets.to_i
tests = []
n.times { tests << gets.to_i }
tests.sort!
sum = tests.inject(:+)
if sum % 10 == 0
  if deduction = tests.find { |i| i % 10 != 0 }
    sum -= deduction
  else
    sum = 0
  end
end
puts sum


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
string A,B;
char Path[3001];
int dp[3001][3001],n,m;
void Print()
{
    int i=n,j=m,cnt=0;
    while(i>0 && j>0)
        if(A[i-1]==B[j-1])
        {
            Path[cnt++]=A[i-1];
            i--;j--;
        }
        else if(dp[i-1][j]>dp[i][j-1]) i--;
        else j--;
    for(i=cnt-1;i>=0;i--) cout<<Path[i];
}
int main()
{
    cin>>A>>B;
    n=A.size();
    m=B.size();
    for(int i=0;i<=n;i++)
        for(int j=0;j<=m;j++)
            if(i==0 || j==0) dp[i][j]=0;
            else if(A[i-1] == B[j-1]) dp[i][j]=dp[i-1][j-1]+1;
            else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
    Print();
    return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


class BIT2D{
private:
    vector<vector<int> > b2;
    int n,m;
public:
    BIT2D(){}
    BIT2D(int h, int w){
        n = h, m = w;
        b2 = vector<vector<int> >(n+1, vector<int>(m+1,0));
    }
    //0-indexedで v[h][w] に +a する
    void add(int h, int w, int a){
        h++,w++;
        for(int i = h; i <= n; i += i&-i){
            for(int j = w; j <= m; j+= j&-j){
                b2[i][j] += a;
            }
        }
    }
    //0-indexedで半開
    int sum(int h, int w){
        int ret = 0;
        for(int i = h; i; i -= i&-i){
            for(int j = w; j; j -= j&-j){
                ret += b2[i][j];
            }
        }
        return ret;
    }
    //左上(x1,y1)右下(x2,y2)（0-indexedで半開）の値を求める
    //sum(0,0,h,w) == sum(h,w)
    int sum(int x1, int y1, int x2, int y2){
        return sum(x2,y2) + sum(x1,y1) - sum(x2,y1) - sum(x1,y2);
    }
    int get(int h, int w){
        return sum(h, w, h+1, w+1);
    }

};

typedef pair<int,pii> pip;

signed main(void) {
    int h,w,tim,q;
    cin >> h >> w >> tim >> q;
    BIT2D yet(h,w), done(h,w);
    deque<pip> d;
    while(q--){
        int t,c,h1,w1;
        cin >> t >> c >> h1 >> w1;
        h1--,w1--;
        while(d.size() && d[0].first <= t-tim){
            int x = d[0].second.first;
            int y = d[0].second.second;
            yet.add(x,y,-1);
            done.add(x,y,1);
            d.pop_front();
        }
        if(c == 0){
            yet.add(h1,w1,1);
            d.push_back(pip(t,pii(h1,w1)));
        }else if(c == 1){
            if(done.get(h1,w1)){
                done.add(h1,w1,-1);
            }
        }else{
            int h2,w2;
            cin >> h2 >> w2;
            cout << done.sum(h1,w1,h2,w2) << " " << yet.sum(h1,w1,h2,w2) << endl;
        }
    }
}



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

constexpr int NG = -1;
constexpr int OK = 0;

int main(void) {
    int N,M;
    string result = "No\n";
    int chk;

    cin >> N >> M;

    vector<string> sn(N);
    vector<string> sm(M);

    for(int i=0;i<N;i++) {
        cin >> sn[i];
    }
    for(int i=0;i<M;i++) {
        cin >> sm[i];
    }
    
    for(int i=0;i<=(N-M);i++) {
    //縦
        for(int j=0;j<=(N-M);j++) {
        // 横
            // M x Mをチェック
            chk = OK;
            for(int k=0;k<M;k++) {
                if(strncmp(&sn[i+k][j],&sm[k][0], M)) {
                    chk = NG;
                    break;
                }
            }
            if(chk == OK) {
                result = "Yes\n";
                goto output;
            }
        }
        
    }

output:
    cout << result;
    return 0;
}


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

int main()
{
    float N,M,C,P,S=0,T=0;
    int A[1001];
    cin >> N >> M;
    C = 1/(4*M);
    for(int i=1;i<=N;i++)
    {
        cin >> A[i];
        T+=A[i];
    }
    for(int i=1;i<=N;i++)
    {
        P = A[i]/T;
        if(P>=C)
        {
            S++;
        }
    }
    if(S>=M)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def abc088d_grid_repainting():
    import heapq
    h, w = map(int, input().split())
    maze = []
    cnt = h * w
    for _ in range(h):
        s = input()
        maze.append(s)
        cnt -= s.count('#')
    q = [(1, 0, 0)]
    heapq.heapify(q)
    check = [[False] * w for _ in range(h)]
    while len(q) != 0:
        dis, x, y = heapq.heappop(q)
        if (x, y) == (h - 1, w - 1):
            print(cnt - dis)
            return
        for dx, dy in zip([0, 0, 1, -1], [1, -1, 0, 0]):
            if 0 <= x + dx < h and 0 <= y + dy < w and maze[x + dx][y + dy] != '#' and not check[x + dx][y + dy]:
                check[x + dx][y + dy] = True
                heapq.heappush(q, (dis+1, x + dx, y + dy))
    print('-1')
abc088d_grid_repainting()

Measured memory_bytes: 9256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define en '\n'
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;
// int power(int x,int n) return x^n; O(logN);
// using_ordered_set (template for using ordered set , replace first 2 lines of this page with this code..);
const int gf = 1e6 + 9;

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	int ans = 0;


	rep(i, 1, n)
	{
		rep(j, i, n)
		{
			if (i * j >= n)
				break;
			if (j == i)
			{
				ans++;
			}
			else
			{
				ans += 2;
			}

		}
	}
	cout << ans << en;


	// rep(i,1,n)
	// {
	// 	int x=n-i;
	// 	// a*b=x;

	// }


	return 0;
}




Measured memory_bytes: 3648
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}/*char to int*/
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}/*MAX*/
int lcm(ll a,ll b){return a*b/gcd(a,b);}/*MIN*/
bool primecheck(ll n){/*sosuu*/if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
int  main(){
string s;
cin >> s;
while(1){    
    string t;
    for(int i=0;i<s.size()-1;i++){
        t+=s.at(i);
    }
    s=t;
    if(s.size()%2==1)continue;
    string che,cheb;
    for(int i=0;i<s.size()/2;i++){
        che+=s.at(i);
    }
    for(int i=s.size()/2;i<s.size();i++){
        cheb+=s.at(i);
    }
    if(che==cheb){
        cout << s.size()<<endl;
        break;
    }

}
}





Measured memory_bytes: 256
from collections import deque
s = deque(input())
Q = int(input())
forward = 0
for _ in range(Q):
    q = input()
    if q=='1':
        forward ^= 1
    else:
        _, f, c = q.split()
        if (int(f)-1)^forward==0:
            s.appendleft(c)
        else:
            s.append(c)
s = list(s)
if forward:
    for i in reversed(s):
        print(i, end='')
else:
    for i in s:
        print(i, end='')
print()


Measured memory_bytes: 8436
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():

    n, m = LI()
    a = LI()
    b = [0 for _ in range(m)]
    c = [0 for _ in range(m)]

    for i in range(m):
        b[i], c[i] = LI()

    dic = collections.Counter(a)
    queue = collections.deque(sorted(list(set(a)|set(c))))

    mn = min(a)
    while queue[0] < mn:
        queue.popleft()

    for i in range(m):
        cnt = 0
        for x in queue:
            if x < c[i]:
                tem = dic[x]
                dic[x] = max(dic[x]-b[i], 0)
                b[i] -= tem-dic[x]
                dic[c[i]] += tem-dic[x]
                if dic[x] == 0:
                    cnt += 1
                if b[i] == 0:
                    break
            else:
                break
        for _ in range(cnt):
            queue.popleft()
    ans = 0
    for k, v in dic.items():
        ans += k*v

    print(ans)

        


main()


Measured memory_bytes: 158580
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#define dump(x) cerr << "LINE" << __LINE__ << " : " << #x << " = {";  \
	for(auto v: x) cerr << v << ","; cerr << "}" << endl;
#else
#define show(x) true
#define dump(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N; cin >> N;
	V<string> s(N);
	V<int> t(N);
	rep(i,N) cin >> s[i] >> t[i];
	string S; cin >> S;
	rep(i,N) if(s[i] == S){
		int ans = 0;
		for(int j=i+1;j<N;j++) ans += t[j];
		cout << ans << endl;
	}
}


Measured memory_bytes: 256
n = gets.to_i
a = n.times.map{gets.to_i}

$cnt = 0

def insertionSort(a, n, g)
    for i in g..n-1
        v = a[i]
        j = i - g
        while j >= 0 && a[j] > v
            a[j+g] = a[j]
            j = j -g
            $cnt += 1
        end
        a[j+g] = v
    end
end

k = 1
k_ary = []
while k <= n
    k_ary.push(k)
    k = 3*k + 1
end

k_ary.reverse!

puts k_ary.length
puts k_ary.join(" ")

for i in 0..k_ary.length-1
    insertionSort(a, n, k_ary[i])
end

puts $cnt
puts a


Measured memory_bytes: 14820
def gcd(a,b):
    if a < b:
        return gcd(b,a)
    else:
        if a%b == 0:
            return b
        else:
            return gcd(b,a%b)
N = int(input())
src = sorted(list(map(int,input().split())))
ans = src[0]
for i in range(1,N)[::-1]:
    ans = gcd(ans,src[i])
print(ans)

Measured memory_bytes: 15020
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> h(N,1e9);
    rep(i,N) cin>>h[i];
    vector<int> dp(N,1e9);
    dp[0]=0;
    for(int i=1; i<N; i++){
        for(int j=1; j<=K; j++){
            if(i-j<0) break;
            dp[i] = min(dp[i-j]+abs(h[i-j]-h[i]),dp[i]);
        }
    }
    cout<<dp[N-1]<<endl;
}

Measured memory_bytes: 1024
import java.util.Scanner;

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

    System.out.println(solve(a, b, x));
  }

  static long solve(long a, long b, long x) {
    long r = a / x;
    long q = (a % x == 0 ? 1 : 0);

    return (b - r * x) / x + q;
  }
}


Measured memory_bytes: 23892
import static java.lang.Math.sqrt;
import java.util.Scanner;

/**
 *
 * @author cs18097
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int d = sc.nextInt();
        int count = 0;
        int sum = 0;
        int del[] = new int[d];
        //int count = 0;
        int[][] point = new int[n][d];
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < d; j++) {
                point[i][j] = sc.nextInt();
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = 0; k < d; k++) {
                    sum += (point[i][k] -point[j][k])*(point[i][k] -point[j][k]);
                }
                double k = sqrt(sum);
                if ( k== (int) k) {
                    count++;
                }
                sum = 0;
            }
        }
        System.out.print(count);
    }

}


Measured memory_bytes: 21844
import java.util.*;
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    // this should be DP Frog.
    // we aslo can use queue
    // Lunlun Number abcde
    // we can build from abcd

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
 
        useQueue();
        //useDP();
    }
    public static void useDP() throws IOException {
        int K = nextInt();
        
        long dp[] = new long[3*K+1]; //max
   
        for (int x=1; x<10; x++) {
            dp[x] = x;
        }

        int index = 10;
        for (int x=1; x<=K; x++) {
            long cur = dp[x];
            long mod = cur % 10;
            if(mod != 0){
                dp[index] = 10*cur+mod-1;
                index++;
                if(index>K){break;}
            }
            dp[index] = 10*cur+mod;
            index++;
            if(index>K){break;}
            if(mod != 9){
                dp[index] = 10*cur+mod+1;
                index++;
                if(index>K){break;}
            }
        }

        System.out.println(dp[K]); 
    }

    public static void useQueue() throws IOException {
        int K = nextInt();
        
        LinkedList<Long> queue = new LinkedList<Long>();

        for (int x=1; x<10; x++) {
            queue.add((long)x);
        }

        for (int x=1; x<K; x++) {
            long cur = queue.poll();
            long mod = cur % 10;
            if(mod != 0){
                queue.add(10*cur+mod-1);
            }
            queue.add(10*cur+mod);
            if(mod != 9){
                queue.add(10*cur+mod+1);
            }
        }

        System.out.println(queue.poll()); 
    }
 

    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 46272
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define pb push_back
#define ub upper_bound
#define lb upper_bound
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define ve vector
#define vi vector<int>
#define vp vector<pair<int,int>>
#define vvi vector<vector<int>>
 
typedef long long ll;
const ll INF = LLONG_MAX - 100;
const ll mod = 1e9 + 7;
const int MAX_N = 2e5 + 5;
int dx[] = {-1,0,1,0}, dy[] = {0,1,0,-1};
vector<ll> prime;
 
int fac[MAX_N], inv[MAX_N];
 
template <class T = ll> T in() {T x; cin >> x; return (x);}
void DEBUG(vector<int> a) {for(int i=0;i<a.size();i++)cout<<a[i]<<" ";cout<<endl;}
void EMP(int x) {cout<<"!!!"<<x<<"!!!"<<endl;}
ll GCD(ll a, ll b) {ll c; while (b != 0) {c = a % b; a = b; b = c;}return a;}
ll LCM(ll a, ll b) {return a * b / GCD(a, b);}
ll POW(ll a, ll b, bool usemod = true) {ll c = 1LL; while (b > 0) {if (b & 1LL) {if(!usemod)c*=a;else c = a * c%mod;}if (!usemod) a*=a;else a = a * a%mod; b >>= 1LL;}return c;}
void _nCr() {fac[0] = 1LL; for (int i = 1LL; i < MAX_N; i++) {fac[i] = fac[i - 1LL] * i%mod;}for (int i = 0; i < MAX_N; i++) {inv[i] = POW(fac[i], mod - 2);}}
ll nCr(ll n, ll r) {return (fac[n] * inv[r] % mod)*inv[n - r] % mod;}
void PRI(ll n) {bool a[n + 1LL]; for (int i = 0; i < n + 1LL; i++) {a[i] = 1LL;}for (int i = 2; i < n + 1LL; i++) {if (a[i]) {prime.pb(i); ll b = i; while (b <= n) {a[b] = 0; b += i;}}}}
template <typename T> T chmin(T& a, T b) {if(a>b)a=b;return a;}
template <typename T> T chmax(T& a, T b) {if(a<b)a=b;return b;}

bool solve() {
	string s; cin >> s;
	map<char,int> m;
	REP (i,4) {
		FOR (j,i+1,4) {
			if (s[i] == s[j]) {
				m[s[i]]++;
			}
		}
	}
	if (m.size() == 2) {
		if (m.begin()->second == 1) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else cout << "No" << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
	int a, b, x;

	cin >> a >> b >> x;

	int max = a + b;
	int min = a;

	if (x >= min && x <= max)
	{
		cout << "YES" << endl;
		return 0;
	}

	cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main() {
    int w, h, x, y;
    scanf("%d%d%d%d", &w, &h, &x, &y);
    printf("%lf %d\n", double(w)*double(h) / 2, x + x == w&&y + y == h);
}

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

using namespace std;

//
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
//

const long long INF = 1LL << 60;

int N, M;
vector<vector<int> > G;

int dp[100100];
int rec(int v){
  if(dp[v] != -1) return dp[v];

  int res = 0;
  for(auto nv : G[v]){
    chmax(res, rec(nv) + 1);
  }

  return dp[v] = res;
}

int main() {
  cin >> N >> M;
  G.assign(N, vector<int>());
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    G[x].push_back(y);
  }

  for (int i = 0; i < N; i++) dp[i] = -1;

  int res = 0;
  for (int v = 0; v < N; v++) chmax(res, rec(v));

  cout << res << endl;

  return 0;
}

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

int main(){
	// sengen
	int x;
	// nyuryoku
	cin >> x;
	// keisan
	if(x){
		cout << "0" << endl;
	}else{
		cout << "1" << endl;
	}
	// syutsuryoku
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main(){
    int n ,x, t;
    cin>>n>>x>>t;
    cout<<((n/x)+((n%x==0?0:1)))*t<<endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

const int INF = 1<<30;

vector<vector<int>> dist,dist2;

void warshall_floyd(int n,auto &d){ //nはノード数
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      for(int k = 0; k < n; k++){
        if(d[j][i] == INF || d[i][k] == INF) continue;
        d[j][k] = min(d[j][k],d[j][i]+d[i][k]);
      }
    }
  }
}

int main(){
  int n,m,l; cin >> n >> m >> l;
  
  dist.resize(n,vector<int>(n,INF));
  dist2.resize(n,vector<int>(n,INF));
  rep(i,n) dist[i][i] = 0,dist2[i][i] = 0;
  rep(i,m){
    int from,to,cost; cin >> from >> to >> cost;
    from--;to--;
    dist[from][to] = cost;
    dist[to][from] = cost; //無向グラフなら
  }
  
  warshall_floyd(n,dist);
  
  rep(i,n)rep(j,n){
    if(i==j) continue;
    if(dist[i][j] <= l){
      dist2[i][j] = 1;
      dist2[j][i] = 1;
    }
  }

  warshall_floyd(n,dist2);
  int q; cin >> q;
  rep(i,q){
    int s,t; cin >> s >> t;
    s--,t--;
    if(dist2[s][t] == INF) cout << "-1" << endl;
    else cout << dist2[s][t]-1 << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
A, B, C, X, Y = [int(x) for x in input().split()]
ans = 10 ** 10
C *= 2
for i in range(1 + 10 ** 5):
    cnt = C * i
    cnt += A * max(X - i, 0) + B * max(Y - i, 0)
    ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 39664
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int a;
	string b;
	cin>>a>>b;
	int size = b.size();
	for(int i=0;i<size;++i){
		a*=10;
		a+=b[i]-'0';
	}
	for(int i=2;i*i<=a;++i){
		if(i*i==a){
			cout<<"Yes"<<endl;
			return;
		}
	}
	cout<<"No"<<endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::chrono;
#define idfc ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
//:/
#define pb push_back
#define mp make_pair
#define nt _ll128
#define ld long double
long double PI =3.14159265358979323846;
using ll = long long;



const ll modo=998244353;
const ll inf=1e17;
const ll ms=(1e5)+5;


int ar[ms];
int br[200][200];


int main()
{
    idfc;


    int r,c;
    cin>>r>>c;
    int n;
    cin>>n;
    int i;


    for(i=1;i<=n;i++)cin>>ar[i];

    int p=1;
    int j;
    i=1;
    j=1;
    n=r*c;
    int tt=c;
    c=1;

    while(n--)
    {
        br[i][j]=c;
        ar[c]--;
        if(!ar[c])c++;
        if(j%2)i++;
        else i--;
        if(i>r){j++; i=r;}
        if(1>i){i=1;j++;}
    }

    for(i=1;i<=r;i++)
    {
        for(j=1;j<=tt;j++)cout<<br[i][j]<<" ";
        cout<<"\n";
    }

    return 0;
}

Measured memory_bytes: 3692
let d =
    new System.Collections.Generic.Dictionary<int * int, char>()

let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

let readCharArray _ = stdin.ReadLine().ToCharArray()

let getMineNum row col (d: System.Collections.Generic.Dictionary<int * int, char>) (r, c) =
    [ (r - 1, c - 1)
      (r - 1, c)
      (r - 1, c + 1)
      (r, c - 1)
      (r, c + 1)
      (r + 1, c - 1)
      (r + 1, c)
      (r + 1, c + 1) ]
    |> List.filter (fun (r, c) -> 0 < r && r <= row && 0 < c && c <= col)
    |> List.map (fun x -> d.Item(x))
    |> List.filter (fun c -> c = '#')
    |> List.length
    |> string
    |> char

()
|> readIntArray
|> fun [| row; col |] ->
    let getMnum = getMineNum row col d
    for x in 1 .. row do
        for (y, ch) in (() |> readCharArray |> Array.indexed) do
            let coord = (x, y + 1)
            d.Add(coord, ch)
    d.Keys
    |> Seq.map (fun (r, c) ->
        if d.Item((r, c)) = '#' then
            (r, c, '#')
        else
            let ch = (r, c) |> getMnum
            (r, c, ch))
    |> Seq.groupBy (fun (r, _, _) -> r)
    |> Seq.map (fun x ->
        x
        |> snd
        |> Seq.sortBy (fun (_, c, _) -> c)
        |> Seq.map (fun (_, _, ch) -> ch)
        |> Seq.toArray
        |> System.String)
    |> Seq.toArray
    |> String.concat "\n"
    |> printfn "%s"


Measured memory_bytes: 37164
#include<stdio.h>

int main(){
  long X[3];
  scanf("%ld%ld%ld",&X[0],&X[1],&X[2]);
  if (X[0]%2==0||X[1]%2==0||X[2]%2==0){
    puts("0");
  }else{
    int m,max=0;
    for (int i = 0; i < 3; i++){
      if(max<X[i]){
        max = X[i];
        m = i;
        }
    }
    X[m]=1;
    printf("%ld",X[0]*X[1]*X[2]);
  }
  
  return 0;
}

Measured memory_bytes: 1732
def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]

def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)

    if x != y:
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def Same(x, y, par):
    return Find(x, par) == Find(y, par)

def Size(x, par):
    return -par[Find(x, par)]

import sys
input = sys.stdin.readline

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

par = [-1]* n
rank = [0]*n

for i in range(m):
    a,b = map(int, input().split())
    a, b =a-1, b-1
    Unite(a,b,par,rank)

cnt = 0
for i in range(n):
    if par[i] < 0:
        cnt += 1
print(cnt-1)


Measured memory_bytes: 74704
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  string s;cin >> s;
  ll N = s.length();
  ll ans = 0;
  ll l=0,r=N-1;
  while(l<r){
    debug(l);
    ll a=0,b=0;
    while(l+a<N&&s[l+a]=='x'){
      a++;
    }
    while(r-b>=0&&s[r-b]=='x'){
      b++;
    }
    if(l+a>r-b){
      break;
    }
    if(s[l+a]!=s[r-b]){
      ans=-1;
      break;
    }
    ans+=abs(a-b);
    l+=a+1;r-=b+1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <iomanip>

using namespace std;

void solve(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b || b == c || a == c){
        if(a == b && b == c && a == c){
            cout << "No" << endl;
            return;
        }
        else
            cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(16);
    
    solve();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
#include <math.h>
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
typedef long long ll;
using namespace std;

int main() {
    ll n;
    cin >> n;
    map<ll, ll> a;
    rep(i,0,n) {
        int x;
        cin >> x;
        a[x]++;
    }
    int ans=0;
    for (auto p:a) {
        if (p.first==p.second) continue;
        else if (p.first<p.second) ans+=(p.second-p.first);
        else ans+=p.second;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6272
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    auto nmc = readints;
    int n = nmc[0], m = nmc[1], c = nmc[2];
    auto b = readints;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        auto a = readints;
        if (a.zip(b).map!(e => e[0] * e[1]).sum + c > 0) {
            ans++;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
n=list(map(int,input().split()))
p=['2354','3146','2651','1562','1364','2453']
for _ in range(int(input())):
    t,m=map(int,input().split())
    t=n.index(t)
    m=str(n.index(m)+1)
    print(n[int(p[t][(p[t].index(m)+1)%4])-1])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
#define MOD 998244353

int main() {
	int N, s;
	cin >> N;
	string S;
	vector<pair<int, int>> VM, VP;
	int le, res;
	for (int i = 0;i < N;i++) {
		cin >> S;
		s = S.size();
		le = 0, res = 0;
		for (int j = 0;j < s;j++) {
			if (S[j] == '(') {
				res++;
			}
			else {
				res--;
			}
			le = min(le, res);
		}
		if (res < 0) {
			VM.push_back({ res - le,-res });
		}
		else {
			VP.push_back({ -le,res });
		}
	}
	sort(all(VM));
	sort(all(VP));
	res = 0;
	for (auto x : VP) {
		if (res - x.first < 0) {
			cout << "No" << endl;
			return 0;
		}
		res += x.second;
	}
	le = 0;
	for (auto x : VM) {
		if (le - x.first < 0) {
			cout << "No" << endl;
			return 0;
		}
		le += x.second;
	}
	if (res != le) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 11276
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std;

int main() {
  
  int a,b,c,d;
  string s,ss,sss;
  
  int ans = 0;
  string anss = "";
  
  int ab [] = {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
  
  cin >> a >> b;

  int result3 = std::max({a, b, c});
  

  cout << (a-1) * (b-1) << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

int main() {
    int x;
    cin >> x;
    cout << (x<1200? "ABC" : "ARC") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
        int a,b,k,i,n=0;

        scanf("%d%d%d",&a,&b,&k);
        for(i=100;i>=1;i--){
                if((a%i==0)&&(b%i==0))
                        n++;
                if(n==k){
                        printf("%d\n",i);
                        break;
                        }
                }
        return 0;
        }

Measured memory_bytes: 128
/*⠄⢰⣧⣼⣯⠄⣸⣠⣶⣶⣦⣾⠄⠄⠄⠄⡀⠄⢀⣿⣿⠄⠄⠄⢸⡇⠄⠄
⠄⠄⠄⣾⣿⠿⠿⠶⠿⢿⣿⣿⣿⣿⣦⣤⣄⢀⡅⢠⣾⣛⡉⠄⠄⠄⠸⢀⣿⠄
⠄⠄⢀⡋⣡⣴⣶⣶⡀⠄⠄⠙⢿⣿⣿⣿⣿⣿⣴⣿⣿⣿⢃⣤⣄⣀⣥⣿⣿⠄
⠄⠄⢸⣇⠻⣿⣿⣿⣧⣀⢀⣠⡌⢻⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠿⠿⣿⣿⣿⠄
⠄⢀⢸⣿⣷⣤⣤⣤⣬⣙⣛⢿⣿⣿⣿⣿⣿⣿⡿⣿⣿⡍⠄⠄⢀⣤⣄⠉⠋⣰
⠄⣼⣖⣿⣿⣿⣿⣿⣿⣿⣿⣿⢿⣿⣿⣿⣿⣿⢇⣿⣿⡷⠶⠶⢿⣿⣿⠇⢀⣤
⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣽⣿⣿⣿⡇⣿⣿⣿⣿⣿⣿⣷⣶⣥⣴⣿⡗
⢀⠈⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠄
⢸⣿⣦⣌⣛⣻⣿⣿⣧⠙⠛⠛⡭⠅⠒⠦⠭⣭⡻⣿⣿⣿⣿⣿⣿⣿⣿⡿⠃⠄
⠘⣿⣿⣿⣿⣿⣿⣿⣿⡆⠄⠄⠄⠄⠄⠄⠄⠄⠹⠈⢋⣽⣿⣿⣿⣿⣵⣾⠃⠄
⠄⠘⣿⣿⣿⣿⣿⣿⣿⣿⠄⣴⣿⣶⣄⠄⣴⣶⠄⢀⣾⣿⣿⣿⣿⣿⣿⠃⠄⠄
⠄⠄⠈⠻⣿⣿⣿⣿⣿⣿⡄⢻⣿⣿⣿⠄⣿⣿⡀⣾⣿⣿⣿⣿⣛⠛⠁⠄⠄⠄
⠄⠄⠄⠄⠈⠛⢿⣿⣿⣿⠁⠞⢿⣿⣿⡄⢿⣿⡇⣸⣿⣿⠿⠛⠁⠄⠄⠄⠄⠄
⠄⠄⠄⠄⠄⠄⠄⠉⠻⣿⣿⣾⣦⡙⠻⣷⣾⣿⠃⠿⠋⠁⠄⠄⠄⠄⠄⢀⣠⣴
⣿⣿⣿⣶⣶⣮⣥⣒⠲⢮⣝⡿⣿⣿⡆⣿⡿⠃⠄⠄⠄⠄⠄⠄⠄⣠⣴⣿*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define endl '\n'
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

map<ll,ll> m;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	
	ll ans=0;
	
	rep(x,0,n){
		int t;
		cin>>t;
		m[t]++;
		ans+=t;
	}
	
	int q;
	cin>>q;
	
	ll a,b;
	while (q--){
		cin>>a>>b;
		
		ans+=(b-a)*m[a];
		m[b]+=m[a];
		m[a]=0;
		
		cout<<ans<<endl;
	}
	
}


Measured memory_bytes: 9480
#include<bits/stdc++.h>
using namespace std;
int n;
int a[20000010];
#define big(x,y,z) a[x]>z&&a[y]>z
#define small(x,y,z) a[x]<=z&&a[y]<=z
bool check(int k){
	 for(int i=0;i<n-1;i++){
	 	int t1=n+i,t2=n+i+1;
	 	int t3=n-i,t4=n-i-1;
        if(big(t1,t2,k)||big(t3,t4,k)) return 0;
        if(small(t1,t2,k)||small(t3,t4,k)) return 1;
    }
    return small(1,1,k);
}
int main(){
	cin>>n;
	for(int i=1;i<=2*n-1;++i){
		scanf("%d",&a[i]);
	}
	int l=0,r=2*n+1;
	int ans;
	while(l<=r){
		int mid=l+r>>1;
		if(check(mid)){
			ans=mid;
			r=mid-1;
		}
		else l=mid+1;
	}
	cout<<ans<<endl;
}

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


int main() {
	int N, x;
	int a[100000];
	scanf("%d %d", &N, &x);
	int i;
	for(i = 0; i < N; i++) {
		scanf("%d", &a[i]);
	}
	long count = 0;
	
	for ( i = 0; i < (N - 1); i++) {
		if ( (a[i] + a[i+1]) <= x )
			continue;
		else if (x <= a[i]) {
			count += a[i+1];
			count += a[i] - x;
			a[i] = x;
			a[i+1] = 0;
		} else {
			count += (a[i] + a[i+1] - x);
			a[i+1] = x - a[i]; 
		}
	}
	printf("%ld", count);
	
	return 0;
}
	

Measured memory_bytes: 512
#３の倍数か、個数桁に３を含むかを確認する


def check_num(n):
    #３の倍数か、最下位に3を含むかをチェックする
    return 1 if (n%10 == 3 or n%3 ==0) else 0

def include_3(n):
    #３の倍数か、最下位に3を含むかをチェックする
    return 1 if (n%10 == 3 ) else 0

str_n = input()
int_n = int(str_n)

for i in range(1,int_n+1):
    #最下位桁チェック
    if check_num(i):
        print('',i, end="")
        continue
    else: #上位桁チェック
        x = i
        while True:
            x = x//10
            if x == 0:#上位桁もない
                break
            if include_3(x):
                print('',i, end="")
                break

print()


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

int main(){
    int N; cin >> N;
    rep(i, 1, 10){
        if(N % i == 0 && (N / i) <= 9){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
}

Measured memory_bytes: 256
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_B main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif


int main_B() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;
    vi A(N); REP(i, N) cin >> A[i];

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

    int ans = A[N - 1] - A[0];

    cout << ans << endl;

    return 0;
}

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

int main(){
    int h,w;
    cin >> h >> w;
    char math[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            cin >> math[i][j];    
        }
    }
    int wid[h][w];
    int hig[h][w];
    queue<int> q_wid[h],q_hig[w];
    for(int i=0; i<h; i++){
        int cnt=0;
        for(int j=0; j<w; j++){
            if(math[i][j]=='.')cnt++;
            else if(math[i][j]=='#'){
                q_wid[i].push(cnt);
                cnt=0;
            }
            if(j==w-1)q_wid[i].push(cnt);
        }
    }
    for(int i=0; i<w; i++){
        int cnt=0;
        for(int j=0; j<h; j++){
            if(math[j][i]=='.')cnt++;
            else if(math[j][i]=='#'){
                q_hig[i].push(cnt);
                cnt=0;
            }
            if(j==h-1)q_hig[i].push(cnt);
        }
    }
    int mx=-1;
    int ans[h][w];
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            ans[i][j]=0;
        }
    }
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(math[i][j]=='.'){
                int tmp=q_wid[i].front();
                ans[i][j]+=tmp;
            }
            else q_wid[i].pop();
        }
    }
    for(int i=0; i<w; i++){
        for(int j=0; j<h; j++){
            if(math[j][i]=='.'){
                int tmp=q_hig[i].front();
                ans[j][i]+=tmp-1;
            }
            else q_hig[i].pop();
            if(mx<ans[j][i])mx=ans[j][i];
        }
    }
    cout << mx << endl;
}

Measured memory_bytes: 54656