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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 40;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

map<ll, int>  prime_factorization_map(ll x) {
  map<ll, int> res;
  for(ll i = 2; i*i <= x; ++i) {
    if(x % i == 0) {
      while(x % i == 0) {
        if(res.find(i) == res.end()) res[i] = 0;
        ++res[i];
        x /= i;
      }
    }
  }
  if(x != 1) res[x] = 1;
  return res;
}

int main()
{
  ll n; cin >> n;
  auto primes = prime_factorization_map(n);
  ll ans = 0;
  vector<ll> num(1001);
  for(int i = 1; i <= 1000; ++i) num[i] = i*(i+1)/2;
  for(auto x : primes) {
    auto it = upper_bound(ALL(num), x.second);
    --it;
    ans += distance(num.begin(), it);
  }
  cout << ans << endl;
}


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

using namespace std;
struct pp
{
    double x,y;
}a[10];
int main()
{
    int n;
    double s=0,num=1,num2=1;
    scanf("%d",&n);
    for(int i=n;i>=1;i--)
        num*=i;
    num2=num/n;
    for(int i=0;i<n;i++)
        scanf("%lf%lf",&a[i].x,&a[i].y);
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            s+=sqrt((a[i].x-a[j].x)*(a[i].x-a[j].x)+(a[i].y-a[j].y)*(a[i].y-a[j].y));
        }
    }
    printf("%.10lf",s/num*num2*2);
    return 0;
}


Measured memory_bytes: 256
n=int(input())
P=[int(x) for x in input().split()]
Q=[int(x) for x in input().split()]
p=tuple(P)
q=tuple(Q)
l=list(range(1,n+1))
L=[]
import itertools
for v in itertools.permutations(l):
  L.append(v)
a=L.index(p)
b=L.index(q)
print(abs(a-b))

Measured memory_bytes: 13960
using System;
using System.Collections.Generic;
class Program
    {
        public class Node
        {
            static void Main(string[] args)
            {
                long mod = 1000000007;
                string[] s = Console.ReadLine().Split(' ');
                long n = long.Parse(s[0]);
                int k = int.Parse(s[1]);

                long rootN = (long)Math.Sqrt(n);
                int arrSize = (int)rootN * 2;
                if (rootN * rootN == n) arrSize--;

                long[] arr = new long[arrSize + 1];
                for (int i=1; i<=rootN; i++)
                {
                    arr[i] = i;
                    arr[arrSize + 1 - i] = n / i;
                }

                long[] comb_add = new long[arrSize + 1];
                comb_add[1] = 1;

                for (int i=1; i<k; i++)
                {
                    //foreach(int x in comb_add) Console.Error.WriteLine(x);
                    long[] new_comb_add = new long[arrSize + 1];
                    long[] comb = new long[arrSize + 1];
                    for (int j = 1; j<=arrSize; j++)
                    {
                        comb[j] = comb[j - 1] + comb_add[j];
                        comb[j] %= mod;
                        //Console.Error.WriteLine(arr[j] + " " + comb[j]);
                    }
                    for (int j=1; j<=arrSize; j++)
                    {
                        long num = comb[j] * (arr[j] - arr[j - 1]) % mod;
                        new_comb_add[1] += num;
                        new_comb_add[1] %= mod;
                        if (j > 1)
                        {
                            new_comb_add[arrSize + 2 - j] -= num;
                            new_comb_add[arrSize + 2 - j] %= mod;
                        }
                    }
                    comb_add = new_comb_add;
                }
                long ans = 0;
                long c = 0;
                for(int i=1; i<=arrSize; i++)
                {
                    c += comb_add[i];
                    c %= mod;
                    //Console.Error.WriteLine(arr[i] + " " + c);
                    ans += c * (arr[i] - arr[i - 1]) % mod;
                    ans %= mod;
                }
                if (ans < 0) ans += mod;
                Console.WriteLine(ans);
                
                
            }
            
        }
    
    }
    //mcs Main.cs
    //mono Main.exe

Measured memory_bytes: 29864
#include <iostream>
#include <algorithm>
#include <vector>
#define INF 1e9+7
using namespace std;
typedef long long int ll;

char c1[201], c2[101];
int num = 0;
bool ans = 0;

bool jud(int m = 0) {
	for (int i = 0; i < num; i++) {
		if (c1[m + i] != c2[i]) { break; }
		if (c1[m + i] == c2[i] && i == num - 1) { return true; }
	}

	return false;
}

int main() {

	cin >> c1 >> c2;

	for (int i = 0; c1[i] != '\0'; i++) {
		num++;
	}

	for (int i = 0; i < num; i++) {
		c1[num + i] = c1[i];
		c1[num+i+1] = '\0';
	}

	for (int i = 0; i < num*2; i++) {
		if (c1[i] == c2[0]) {
			ans = jud(i);
			if (ans) { break; }
		}
	}

	if (ans) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>

#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF = 1e18;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
int main()
{
	ll n,x,i;
	cin>>n;
	umap<ll,ll> m;
	rep(i,n)
	{
		cin>>x;
		m[x]++;
	}
	if(m.size()==n)
		cout<<"YES";
	else
		cout<<"NO";
}

Measured memory_bytes: 8520
fun main(args: Array<String>) {
    // Your code here!
    val n = readLine()!!.toLong()
    var cnt = 0L 
    val keta = n.toString().length.toLong()
    
    if(keta % 2 == 0L){
        for(i in 0..keta.toInt()-1){
            if(i % 2 != 0){
                continue
            }
            cnt += 9L * (Math.pow(10.toDouble(),i.toDouble()).toLong())
        }
    }else{
        for(j in 0..keta.toInt()){
            if(j % 2 != 0){
                continue
            }
            
            if(j == (keta.toInt()-1)){
                cnt += n.toLong() - (Math.pow(10.toDouble(),j.toDouble()).toLong()) + 1L
                continue
            }
            
            cnt += 9L * (Math.pow(10.toDouble(),j.toDouble()).toLong())
        }
    }
    println(cnt)
}

Measured memory_bytes: 31796
N,M=map(int,input().split())
S,r,s=input(),[],N
for _ in range(2*N):
    if S[s]=='1':
        s+=1
    else:
        if N-s:
            r.append(N-s)
        N,s=s,max(0,s-M)
print(*[-1] if s else r[::-1])

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

int main()
{

    double a,b,x;
    cin >> a >> b >> x;

    double ans, tmp;

    double s, t;
    double pi = 3.14159265358979323846264338327950288;

    if(a*a*b/2.0  < x){
        s = b / a;
        t = x / (a * a * a);
        double v = 2.0 * (s - t);
        ans = atan(v);
    }else{
        s = a*b * b / 2.0;
        s /= x;
        ans = atan(s);
    }

    ans = (ans * 360.0) / 2.0;
    ans /= pi;


    cout << fixed;
    cout << setprecision(8) << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,x,y;
  cin >> n >> x >> y;
  int dist[n+1][n+1];
  int i,j;
  int dists[n+1];

  for(i=1;i<=n;i++){
    dists[i]=0;
  }

  for(i=1;i<n+1;i++){
    for(j=i+1;j<n+1;j++){
      dist[i][j] = min(j-i,abs(x-i)+1+abs(y-j));
      dists[dist[i][j]]++;
    }
  }
  for(i=1;i<n;i++){
    cout<<dists[i]<<endl;
  }

}


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

#define MAX_N 51

int n ,m;
int edge_id[MAX_N][MAX_N];
vector <int> adj[MAX_N] ,in_res[MAX_N];

vector <int> get_path(int a ,int b){
    queue <int> q{{a}};
    vector <int> from(n+1);
    while(!q.empty()){
        int u = q.front(); q.pop();
        if(u == b){
            vector <int> path;
            for(int v=u; v!=a; v=from[v])
                path.push_back(edge_id[v][from[v]]);
            return path;
        }
        for(int&v : adj[u])
            if(from[u] != v)
                q.push(v) ,from[v] = u;
    }
}
long long dp[MAX_N][1<<20];
long long solve(int e ,int b){
    if(e == n-1)
        return b == (1<<m)-1;
    auto&ret = dp[e][b];
    if(~ret)
        return ret;

    ret = solve(e+1 ,b);
    for(int&r : in_res[e])
        b |= (1<<r);
    return ret += solve(e+1 ,b);
}

int main()
{
    scanf("%d",&n);
    for(int a,b,i=1; i<n; i++){
        scanf("%d%d",&a,&b);
        edge_id[a][b] = i-1;
        edge_id[b][a] = i-1;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    scanf("%d",&m);
    for(int a,b,i=0; i<m; i++){
        scanf("%d%d",&a,&b);
        for(int&e : get_path(a ,b))
            in_res[e].push_back(i);
    }

    memset(dp ,-1 ,sizeof dp);
    printf("%lld\n",solve(0 ,0));
}


Measured memory_bytes: 418048
import sys
S = sys.stdin.readline().rstrip()
N = len(S)

ans = [0] * N
cum = 0
for i, s in enumerate(S):
    if s == "R":
        cum += 1
    else:
        kisu = cum // 2
        gusu = cum - kisu
        ans[i - 1] += gusu
        ans[i] += kisu
        cum = 0
cum = 0
for i, s in enumerate(S[::-1]):
    if s == "L":
        cum += 1
    else:
        kisu = cum // 2
        gusu = cum - kisu
        ans[N - 1 - i] += kisu
        ans[N - i] += gusu
        cum = 0
print(" ".join(map(str, ans)))

Measured memory_bytes: 51312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;



#include <bits/stdc++.h>
using namespace std;

//このSegmentTreeは最小値を扱う仕様になっている
struct SegmentTree {
private:
    ll n;
    vector<ll> node;
    ll INF = 1e18;
public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(vector<ll> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        ll sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }
    void update(ll x, ll val) {
        // x番目をvalに変える
        // 最下段のノードにアクセスする
        x += (n - 1);

        // 最下段のノードを更新したら、あとは親に上って更新していく
        node[x] = val;
        while(x > 0) {
            x = (x - 1) / 2;
            node[x] = min(node[2*x+1], node[2*x+2]);
        }
    }
    ll get_X(ll x){
        return node[x];
    }
    
    // 要求区間 [a, b) 中の要素の最小値を答える
    // k := 自分がいるノードのインデックス
    // 対象区間は [l, r) にあたる

    ll get_min(ll a, ll b, ll k=0, ll l=0, ll r=-1) {
        // 最初に呼び出されたときの対象区間は [0, n)
        if(r < 0) r = n;

        // 要求区間と対象区間が交わらない -> 適当に返す
        if(r <= a || b <= l) return INF;

        // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
        if(a <= l && r <= b) return node[k];

        // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
        // 左側の子を vl ・ 右側の子を vr としている
        // 新しい対象区間は、現在の対象区間を半分に割ったもの
        ll vl = get_min(a, b, 2*k+1, l, (l+r)/2);
        ll vr = get_min(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }

};



// DP : Nこめまで読んだ時のMax
// tail : DPの時の部分列の最大値
// Max : 部分列の末尾がNの時のAの合計のMax




int main() {
    ll N; cin >> N;
    vector<ll> A(N), H(N), DP(N+1), tail(N+1), Max(N+2);
    
    for(int i = 0; i < N; i++) cin >> H[i];
    for(int i = 0; i < N; i++) cin >> A[i];
    DP[1] = A[0];
    tail[1] = H[0];
    Max[H[0]] = -A[0];
    SegmentTree tree(Max);

    for(int i = 2; i <= N; i++) {
        if(tail[i-1] < H[i-1]) { // 即決で使う
            DP[i] = DP[i-1] + A[i-1];
            tail[i] = H[i-1];
            tree.update(tail[i], -DP[i]);
        }
        else { // 使うか使わないかわからない
        // 今までのDPの値と、A[N]を使った場合の値を比べて決めたい

            ll comp1 = DP[i-1]; // 使わなかった場合
            ll temp = tree.get_min(0, H[i-1])*(-1);
            ll comp2 = A[i-1] + temp; // 使った場合

            if(comp1 < comp2){ //使った場合
                DP[i] = comp2;
                tail[i] = H[i-1];
                Max[tail[i]] = DP[i];
                tree.update(tail[i], -DP[i]);
            }
            else{
                DP[i] = DP[i-1];
                tail[i] = tail[i-1];
                Max[H[i-1]] = Max[H[i-1]-1]+A[i-1];
                //tree.update(Max[H[i-1]], -temp-A[i-1]);
                //cout << H[i-1] << endl;
                //cout << tree.get_X(H[i-1]) << endl;
                tree.update(H[i-1], -temp-A[i-1]);

            }
        }
    }
    cout << DP[N] << endl;
    

}


Measured memory_bytes: 13696
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        long k = Long.parseLong(sc.next());
        sc.close();

        // 主処理
        String result = "0";

        int index = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == '1') {
                index++;
            } else {
                break;
            }
        }

        if (k <= index) {
            result = "1";
        } else {
            result = String.valueOf(s.charAt(index));
        }

        // 出力
        System.out.println(result);
    }
}


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

int main(){
    long N,A,B,cnt=0,n=0;
    cin >> N >> A >> B;
    n=N/(A+B);
    if(N-n*(A+B) > A){
        cnt = A*(n+1);
    }else{
        cnt = N- B*n;
    }
    cout << cnt;
}

Measured memory_bytes: 256
from statistics import mean, median,variance,stdev
import sys
import math
import fractions

def j(q):
    if q==1: print("YES")
    else:print("NO")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

x = ip()                              #入力整数1つ
#x,y= (int(i) for i in input().split())      #入力整数横2つ
#x,y,z = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列

#jの変数はしようできないので注意
num=0
while sum(a):
    l = 0
    while a[l] == 0: l+=1
    r=l
 #   print("left:",l)
    if l != len(a)-1:
        while a[r+1]!=0:
 #           print("right:",r)
            r+=1
            if r == len(a)-1:break
    for i in range(l,r+1):
        a[i]-=1
    num+=1
  #  print(a)
print(num)


Measured memory_bytes: 5724
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif

//改造
typedef long long int ll;
using namespace std;

//ここから編集する

int main() {
    string str;
    cin >> str;
    if(str[0] == str[2]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
def solve(X, N, K):
    if N <= K:
        return 0

    output = []
    for i in range(1, N):
        output.append(X[i] - X[i-1])
    output.sort(reverse=True)
    del output[0:K-1]
    return sum(output)

n = int(input())
for j in range(n):
    N, K = map(int,input().strip().split())
    X = list(map(int, input().strip().split()))
    if N==0:
        break;
    print(solve(X, N, K))


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

ll roundup(ll a, ll b){
    return (a + (b - 1)) / b;
}

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

    ll t, a, T, A, m, newt, newa, c;
    cin >> T >> A;
    m = max(T, A);
    for(int i=0;i<N-1;i++){
        cin >> t >> a;
        newt = t;
        newa = a;
        /*
        while(newt < T || newa < A){
            newt += t;
            newa += a;
        }
        */
        c = max( roundup(T, t), roundup(A, a));
        newt = t*c;
        newa = a*c;
        T = newt;
        A = newa;
    }
    
    cout << T + A << endl;

}

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

#define CL(N) cout << N << endl
#define DCT(N) cout << "debug " << N << endl
#define REP(i, N) for (int i = 0; i < N; i++)

int main()
{
	int n, a = 0;

	cin >> n;

	string s, t;

	cin >> s >> t;

	for (int i = 0; i < n; i++){
		if (s.substr(i, n - i) == t.substr(0, n - i)){
			a = max(a, (int)s.substr(i, n - i).size());
		}
	}

	CL(2 * n - a);

	return (0);
}


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

int main(void){
  char b, ans;
  cin >> b;
  if(b == 'A') ans = 'T';
  else if(b == 'T') ans = 'A';
  else if(b == 'G') ans = 'C';
  else ans = 'G';
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cmath>
#include <queue>
#include <limits>
#include <map>
#include <cassert>
#include <iterator>
using namespace std;
using VI = vector<long>;
constexpr long MOD = 998244353;

int main() {
    int x, y, z;
    cin >> x >> y >> z;
    
    int i = 0;
    while (1) {
        if (y * i + z * (i + 1) <= x) {
            i++;
        } else {
            break;
        }
    }
    cout << i - 1 << endl;
}


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

    cin >> n >> l;

    vector<string> moji(n);
    
    for (int i = 0; i < n; i++) {
        cin >> moji.at(i);
    }
    
    sort(moji.begin(), moji.end());
    
    for (int i = 0; i < n; i++) {
        cout << moji.at(i);
    }

    cout << endl;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

int main() {
  int n;
  std::string s;
  std::cin >> n >> s;
  int r = 0;
  int b = 0;
  for (auto c : s) {
    if (c == 'R')
      ++r;
    if (c == 'B')
      ++b;
  }
  if (r > b)
    std::cout << "Yes" << std::endl;
  else
    std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 101

int main() {
  int flag=1, n, i, j, temp, a[N],count=0;
  scanf("%d",&n);

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

  while(flag) {
    flag = 0;
    for(j = n - 1; j >= 0; j-- )
    if(a[j] < a[j-1]){
      temp = a[j];
      a[j] = a[j-1];
      a[j-1] = temp;
      count++;
      flag = 1;
    }
  }

  for(i = 0; i < n; i++) {
    printf("%d", a[i]);
    if(i < n-1) {
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n", count);
  return 0;
}

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

int keta(int N){
  if(N < 10) return N;
  return keta(N / 10) + N % 10;
}

int main(){
  int N;
  cin >> N;
  int S = keta(N);
  if(N % S == 0) cout << "Yes" << '\n';
  else cout << "No" << '\n';

}


Measured memory_bytes: 3620
from bisect import bisect

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

def make_cum(ary):
    cum = [0]
    for v in ary:
        cum.append(cum[-1] + v)
    return cum


def solve():
    ans = 0
    cuma = make_cum(A)
    cumb = make_cum(B)
    for ia in range(N+1):
        if cuma[ia] > K:
            break
        ib = bisect(cumb, K-cuma[ia]) - 1
        ans = max(ans, ia + ib)
    return ans
        

if __name__ == "__main__":
    print(solve())


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

int main(){
    int N;
    cin>>N;
    for(int i=1; i<=N; i++){
        int x=i;
        int flag=0;
        if(x%3==0){
            cout<<" "<<i;
            flag=1;
        }
        while(x>0&&flag==0){
            if(x%10==3){
                cout<<" "<<i;
                flag=1;
            }
            x/=10;
        }
    }
    cout<<endl;
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<string,int>;

const int MOD = 1e9 + 7;

int main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int n;
    string s;
    cin >> n >> s;

    int r = 0, b = 0;
    rep(i, n){
        if(s[i] == 'R'){
            r++;
        }else{
            b++;
        }
    }

    if(r > b){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val l = (0 until n).map { sc.next().toInt() }
    println(problem117b(n, l))
}

fun problem117b(n: Int, l: List<Int>): String {
    val l = l.sorted()
    return if (l.max()!! < l.dropLast(1).sum()) "Yes" else "No"
}

Measured memory_bytes: 35964
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <array>
#include <bitset>
#include <assert.h>
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<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

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

int main() {
    int n, d, x;
    cin >> n >> d >> x;
    REP(i,n){
        int a;
        cin >> a;
        x += 1 + (d - 1) / a;
    }
    cout << x << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include <functional>
#include <queue>
#include <regex>

using namespace std;

constexpr int MOD = 1000000007;
constexpr int INF = 1050000000;

#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl

#define Tof(x) (x) ? Yes : No
#define TOF(x) (x) ? YES : NO
#define tof(x) (x) ? yes : no

using ll = long long;


/*vectorの要素を全部確認するやつだよ。


for (vector<int>::iterator itr = ans.begin(); itr != ans.end(); ++itr) {
	cout << *itr << " ";
}


*/


/*for文でx,yを上下左右確認するやつだよ。

int dy[] = { 0, 1, 0, -1 };
int dx[] = { 1, 0, -1, 0 };


for (int i = 0; i < 4; i++) {
	int ny = y + dy[i];
	int nx = x + dx[i];
}
*/

/*繰り返し二乗法だよ。modもとってくれるよ。n^kをmodで割った余りでやってくれるよ。

ll POW_MOD(ll n, ll k, ll mod) {
	ll r = 1;

	for (; k > 0; k >>= 1) {
		if (k & 1) {
			r = (r * n) % mod;
		}
		n = (n * n) % mod;
	}
	return r;
}


*/

/*2重for文書くのめんどくなった時用だよ。

for (int i = 0; i < h; i++) {
	for (int j = 0; j < w; j++) {

	}
}

*/

int cc[100];

int main(void) {
	int n; cin >> n;
	string s; cin >> s;

	int check = 0;

	for (int i = 0; i < n; i++) {
		if (s[i] == '(') {
			check++;
			
		}
		else {
			check--;
		}
		cc[i] = check;
	}
	int mi = INF;
	for (int i = 0; i < n; i++) {
		mi = min(mi, cc[i]);
	}

	int x = mi;
	int y = cc[n - 1] - mi;

	if (x > 0) {
		y = cc[n - 1] + mi - 1;
	}

	//cout << x << y << endl;

	for (int i = 0; i < -x; i++) {
		cout << '(';
	}
	cout << s;
	for (int i = 0; i < y; i++) {
		cout << ')';
	}

	cout << endl;


}

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

int main(){
	ll n, k;
	cin >> n >> k;
	vector<ll> h(n);
	rep(i, n) cin >> h.at(i);

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

	ll ans = 0;
	rep(i, n-k) ans += h.at(i);

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

typedef ll Weight;
struct Edge {
  ll src, dst;
  Weight weight;
  Edge(ll src, ll dst, Weight weight) : src(src), dst(dst), weight(weight) {}
};

bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
             e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  REP(i, N) {
    FOR(j, i + 1, N) {
      ll po = i ^ j;
      ll yo = 1;
      while (po % 2 == 0) {
        po /= 2;
        yo++;
      }
      cout << yo << " ";
    }
    cout << endl;
  }

  return 0;
}


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

// 1927426???1927428???WA???????????????????????????????????§???
auto dodo() {
  for(auto i=0; i<9; i++)
    for(auto j=0; j<9; j++)
      cout << i+1 << 'x' << j+1 << '=' << (i+1)*(j+1) << endl;
}

int main() {
  dodo();
  return 0;
}

Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 10000010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 998244353;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

ll fac[MAX_N], inv[MAX_N], fiv[MAX_N]; //fiv:inv(fac(i))

ll mod_pow(ll a, ll n) {
	if(n == 0) return 1;
	ll res = mod_pow(a, n / 2);
	if(n % 2 == 0) return res * res % mod;
	else return a * res % mod * res % mod;
}

ll invf(ll a) {
	return mod_pow(a, mod - 2);
}


void C_init(int n) {
	fac[0] = fac[1] = 1; inv[1] = 1;
	fiv[0] = fiv[1] = 1;
	rep(i, 2, n + 1) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		fiv[i] = fiv[i - 1] * inv[i] % mod;
	}
}

ll C(int a, int b) { //assume a >= b
	if(a < b || a < 0 || b < 0) return 0;
	return fac[a] * fiv[b] % mod * fiv[a - b] % mod;
}

int N;

void solve() {
	cin >> N;
	C_init(N);
	ll res = mod_pow(3, N);
	rep(i, N / 2 + 1, N + 1) {
		ADD(res, mod - 2 * mod_pow(2, N - i) * C(N, i) % mod);
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



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

int main(void)
{
	int N,K,i,ans,cnt=0;

	string S;

	cin >> N >> K;

	cin >> S;

	for(i=0;i<N-1;i++)
		{
			if(S[i]==S[i+1])
				cnt++;

		}

	ans=min(N-1,cnt+2*K);

	cout << ans << endl;

		
}



Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string n;

    cin >> n;

    if (n[0] == '7' || n[1] == '7' || n[2] == '7')
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3596
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[100002],t[100002];
int a[100002],b[100002];
int main() {
	scanf("%s%s",s+1,t+1);
	int n=strlen(s+1),m=strlen(t+1);
	fup(i,1,n,1)
	{
		if(s[i]=='A')a[i]=a[i-1]+1;
		else a[i]=a[i-1]+2;
	}
	fup(i,1,m,1)
	{
		if(t[i]=='A')b[i]=b[i-1]+1;
		else b[i]=b[i-1]+2;
	}
	int q;
	scanf("%d",&q);
	while(q--)
	{
		int l1,r1,l2,r2;
		scanf("%d%d%d%d",&l1,&r1,&l2,&r2);
		int t1=(a[r1]-a[l1-1])%3,t2=(b[r2]-b[l2-1])%3;
		puts(t1==t2?"YES":"NO");
	}
}

Measured memory_bytes: 1536
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,c=0,d=0,x=0,y=1,z=0;
  string s="",t="";
  //

  // ここから
  IN3(a,b,x);
  Vi ANS;
  FOR(i,1,min(a,b)+1){
    if(a%i==0 && b%i==0){
      ANS.pb(i);
    }
  }
  RSORT(ANS);
  OUT(ANS[x-1]);
}

Measured memory_bytes: 256
#include<iostream>
#include<utility>
 
int main(){
    unsigned int a, b, tmp, GCD;
    while ( std::cin >> a >> b){
        if( b > a )std::swap( a , b );
        unsigned long int LCM = a;
        GCD = b;
        while(a % GCD != 0){
            tmp = a % GCD;
            a = GCD;
            GCD = tmp;
        }
        LCM = ( LCM / GCD ) * b;
        std::cout << GCD << " " << LCM << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<bitset>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>


using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))

const ll MOD = 1e+9+7;
const double PI  = acos(-1.0);


int main(){
  int n;
  cin>>n;
  vl sum;
  sum.push_back(0);
  ll input;
  REP(i,n){
    cin>>input;
    sum.push_back(sum[i]+input);
  }
  sort(sum.begin(),sum.end());
  ll ret=0;
  ll cnt=1;
  REP(i,n){
    if(sum[i]==sum[i+1]) cnt++;
    else{
      ret+=cnt*(cnt-1)/2;
      cnt=1;
    }
  }
  ret+=cnt*(cnt-1)/2;
  cout<<ret<<"\n";
}


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

using namespace std;

int ac, tle, wa, re;

int main()
{
    int n;
    cin >> n;
    while(n--)
    {
        string a;
        cin >> a;
        if(a[0] == 'A')
            ac++;
        else if(a[0] == 'W')
            wa++;
        else if(a[0] == 'T')
            tle++;
        else
            re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;
}

Measured memory_bytes: 3620
/*
Problem 0013 : Switching Railroad Cars
*/
#include <stdio.h>

int main(void){
	int i , a[100] = {0} , b[100] = {0} , buf , a_count = 0 , b_count = 0;
	while(scanf("%d" , &buf)!=EOF){
		if(buf != 0){
			a[a_count] = buf;
			a_count++;
		}else{
			b[b_count] = a[a_count-1];
			a_count--;
			b_count++;
		}
	}
	for(i=0;b[i]!=0;i++){
		printf("%d\n" , b[i]);
	}

	return 0;
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


int main()
{
	char buf[1024];
	scanf("%s", buf);
	for (int i = 0; buf[i]; ++i)
		printf("%c", (buf[i]-'A'-3+26)%26 + 'A');
	puts("");
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main()
{
	/*int r;
	cin >> r;
	cout << 2 * r * acos(-1);*/


	/*int n, m;
	cin >> n >> m;
	int sum = 0;
	int a;
	rep(i, m) {
		cin >> a;
		sum += a;
	}
	if (sum > n)cout << -1;
	else cout << n - sum;*/


	int n;
	cin >> n;
	vector<int>ans(n);
	int a;
	rep(i, n-1) {
		cin >> a;
		a--;
		ans[a]++;
	}
	rep(i, n)cout << ans[i] << "\n";
	return 0;
}

Measured memory_bytes: 3680
#! /usr/bin/env python3
# -*- coding:utf-8 -*-

def get_result(N, A, B, S):
    result = []
    num_passed = 0
    rank_global = 1
    for x in S:
        if num_passed >= A+B:
            result.append(False)
            continue
        if x == "a":
            result.append(True)
            num_passed += 1
            continue
        if x == "b":
            if rank_global > B:
                result.append(False)
            else:
                result.append(True)
                num_passed += 1
                rank_global += 1
            continue
        else:
            result.append(False)
    return result

def main():
    N, A, B = map(int, input().split())
    S = input()
    result = get_result(N, A, B, S)
    for x in result:
        if x == True: print("Yes")
        elif x == False: print("No")

if __name__ == "__main__":
    try:
        assert get_result(10, 2, 3, "abccabaabb") == [True, True, False, False, True, True, True, False, False, False]
        assert get_result(12, 5, 2, "cabbabaacaba") == [False, True, True, True, True, False, True, True, False, True, False, False]
    except:
        import traceback
        traceback.print_exc()
        exit()
    main()


Measured memory_bytes: 4784
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#define ull unsigned long long
using namespace std;

const int N=500005;
const ull P=20010425;
const int M=5557;
const int mod=998244853;

struct node{
	ull hs; int ms;
	node(){}
	node(ull hs,int ms):hs(hs),ms(ms){}
	friend bool operator<(node a,node b){
		return a.hs<b.hs||(a.hs==b.hs&&a.ms<b.ms);
	}
	friend bool operator==(node a,node b){
		return a.hs==b.hs&&a.ms==b.ms;
	}
	friend node operator*(node a,node b){
		return node(a.hs*b.hs,1ll*a.ms*b.ms%mod);
	}
	friend node operator+(node a,node b){
		return node(a.hs+b.hs,(a.ms+b.ms)%mod);
	}
	friend node operator-(node a,node b){
		return node(a.hs-b.hs,(a.ms-b.ms+mod)%mod);
	}
}p[N],hs[N];
int n,l,r,mid,tag,ans;
bool b1[N],b2[N];
char s[N];

node geths(int l,int r){
	return hs[r]-hs[l-1]*p[r-l+1];
}

void init(){
	int i,j;
	p[0]=node(1,1); for (i=1;i<=n;i++) p[i]=p[i-1]*node(P,M);
	for (i=1;i<=n;i++) hs[i]=hs[i-1]*node(P,M)+node(s[i],s[i]);
	for (i=1;i<=n;i++)
		for (j=i+i;j<=n;j+=i)
			if (geths(j-i+1,j)==geths(1,i)) b1[j]=1;
		else break;
	for (i=1;i<=n;i++)
		for (j=n-i-i+1;j>0;j-=i)
			if (geths(j,j+i-1)==geths(n-i+1,n)) b2[j]=1;
		else break;
}

int main(){
	int i; tag=0;
	scanf("%s",s+1); n=strlen(s+1);
	for (i=2;i<=n;i++)
		if (s[i]!=s[1]){
			tag=1; break;
		}
	if (!tag){
		printf("%d\n",n); printf("1\n");
		return 0;
	}
	init();
	if (!b1[n]){
		printf("1\n"); printf("1\n");
		return 0;
	}
	for (i=1;i<n;i++)
		if (!b1[i]&&!b2[i+1]) ans++;
	printf("2\n"); printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 17280