akhauriyash/Code-Regression huggingface dataset:
//Never stop trying
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;
typedef pair<int, int> pi;
#define fi first
#define se second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<str> vs;
typedef vector<ld> vd;
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

const int MOD = 1e9 + 7; //998244353
const ll INF = 1e18;
const int MX = 2e5 + 10;
const int nx[4] = {0, 0, 1, -1}, ny[4] = {1, -1, 0, 0}; //right left down up

template<class T> using V = vector<T>;
template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

ll cdiv(ll a, ll b) { return a / b + ((a ^ b) > 0 && a % b); } // divide a by b rounded up
constexpr int log2(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))

#define dbg(x) cerr << " - " << #x << " : " << x << endl;
#define dbgs(x,y) cerr << " - " << #x << " : " << x << " / " << #y << " : " << y << endl;
#define dbgv(v) cerr << " - " << #v << " : " << endl << "[ "; for(auto it : v) cerr << it << ' '; cerr << ']' << endl;

void IO() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}


int32_t main() {
	boost; IO();

	str s; cin>>s;
	if(s.back()=='s') s+="es";
	else s+="s";
	cout << s << endl;





	return 0;
}

/* Careful!!!
	.Array bounds
	.Infinite loops
	.Uninitialized variables / empty containers
	.Order of input

   Some insights:
	.Binary search
	.Graph representation
	.Write brute force code
	.Change your approach
*/


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

typedef long long ll;
#define dbg          cout<<"Freak"<<endl;
#define dbgg(i)      cout<<i<<endl;
#define N            1e9+7
#define pb           push_back
#define pi           acos(-1)


ll t;
vector<ll>v[100005];



int main()
{
    double a,b,c,d,e,f,g,i,j;
    cin>>a;
    a=a/3;
    b=a*a*a;
    printf("%0.12lf\n",b);
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int N; cin >> N;
	int a[N];
	rep(i, N) cin >> a[i];
	int ans = 0;
	rep(i, N) ans += a[i] - 1;
	cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    ll w, h, x, y;
    cin >> w >> h >> x >> y;
    cout << w * h / 2.0 << " ";
    if (x * 2 == w && y * 2 == h)
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3728
#include <stdio.h>

int main(void)
{
	int a, b, c;
	int k, i;

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

	for(i=0;i<3;i++)
	{
		if (a > b)
		{
			k = a;
			a = b;
			b = k;
		}
		k = 0;
		if (b > c)
		{
			k = b;
			b = c;
			c = k;
		}
	}
	printf("%d %d %d\n", a, b, c);
	return 0;
}


Measured memory_bytes: 2104
def solve(s):
    n = len(s)
    best = n
    for flip in range(2):
        cnt = 0
        for i in range(n):
            if (i+flip) % 2 == 0:
                if s[i] == '1':
                    cnt += 1
            else:
                if s[i] == '0':
                    cnt += 1
        best = min(best, cnt)
    return best

s = input()
print(solve(s))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
# define ll long long int
ll dp[3001][3001];
//vector<int>v;
ll rec(ll s, ll e, ll arr[],ll i)
{
  if(s>e)
  {
    //return arr[s];
    return 0;
  }

  if(dp[s][e]!=-1)
  {
    return dp[s][e];
  }

 if(i%2==0)
 {

    return dp[s][e]=max(arr[s]+rec(s+1,e,arr,i+1),arr[e]+rec(s,e-1,arr,i+1));
 }
 else{
   return dp[s][e]=min(rec(s+1,e,arr,i+1),rec(s,e-1,arr,i+1));
 }

 //return dp[s][e];
  //return v[v.size()-1];
}

int main()
{

  int n;
  cin>>n;
  ll arr[n];
  ll sum1=0;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
    sum1+=arr[i];
  }
  //cout<<"sum "<<sum1<<endl;
  memset(dp,-1,sizeof(dp));
  ll taro=rec(0,n-1,arr,0);
  //cout<<"Taro "<<taro<<endl;
  ll jiro= sum1-taro;
  cout<<taro-jiro<<endl;
// cout<<"Beginning of list "<<endl;
// for(int i=0;i<v.size();i++)
// {
//   cout<<v[i]<<endl;
// }
}


Measured memory_bytes: 74316
#include<bits/stdc++.h>
#define LL long long
using namespace std;
int n;
const int N=1000010,mod=1e9+7;
LL ans;
LL jc[N],inv[N],f[N];
inline LL ksm(LL a,LL b,LL mod)
{
	LL res=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)res=res*a%mod;
	return res;
}
inline int read()
{
	int res = 0; char ch = getchar(); bool XX = false;
	for (; !isdigit(ch); ch = getchar())(ch == '-') && (XX = true);
	for (; isdigit(ch); ch = getchar())res = (res << 3) + (res << 1) + (ch ^ 48);
	return XX ? -res : res;
}
inline void YYCH()
{
	jc[0]=jc[1]=inv[0]=inv[1]=1;
	for(int i=1;i<=n;++i)jc[i]=jc[i-1]*i%mod;
	inv[n]=ksm(jc[n],mod-2,mod);
	for(int i=n-1;i>=1;--i)inv[i]=inv[i+1]*(i+1)%mod;
}
inline LL C(LL n,LL m){return jc[n]*inv[m]%mod*inv[n-m]%mod;}
int main()
{
	cin>>n;
	YYCH();
	for(int i=(n+1)>>1;i<=n-1;++i)
	{
		f[i]=C(i-1,n-i-1)*jc[i]%mod*jc[n-1-i]%mod;
		(((ans+=(f[i]-f[i-1])*i%mod)%=mod)+=mod)%=mod;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 21632
import numpy as np

N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
A = np.array([])
count = 0
for _ in range(N):
    A = np.append(A, list(map(int, input().split())))
A = A.reshape(N, M)
for i in A.dot(B) + C:
    if i > 0:
        count += 1
print(count)

Measured memory_bytes: 26792
//
//  ROIGold.cpp
//  Main calisma
//
//  Created by Rakhman on 05/02/2019.
//  Copyright © 2019 Rakhman. All rights reserved.
//
 
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>
 
#define ios ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define S second
#define F first
#define pb push_back
#define nl '\n'
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define no_answer return cout << 0, 0;
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)
 
const int MXN = 1e7 + 200;
const long long MNN = 2e3 + 520;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const int OO = 1e9 + 500;
 
typedef long long llong;
typedef unsigned long long ullong;
 
using namespace std;

llong n;
vector<int> g[MXN];

void add(llong& a, llong b){
    a += b;
    //if(a < 0) a += MOD;
    while(a >= MOD) a -= MOD;
}

pair<llong, llong> dfs(int x, int p){
    llong all_white = 1, some_black = 0;
    for(int i = 0; i < g[x].size(); i++){
        int to = g[x][i];
        if(to == p) continue;
        pair<llong, llong> sinok = dfs(to, x);
        llong white = all_white;
        all_white = (all_white * sinok.F) % MOD;
        some_black = ((white * sinok.S % MOD) + (some_black * (sinok.F + sinok.S) % MOD)) % MOD;
    }
    return {(some_black + all_white) % MOD, all_white};
}

int main () {
    ios;
    cin >> n;
    for(int i = 1; i < n; i++){
        int a, b;
        cin >> a >> b;
        g[a].pb(b);
        g[b].pb(a);
    }
    pair<llong, llong> ans = dfs(1, 0);
    cout << (ans.F + ans.S) % MOD;
}


Measured memory_bytes: 244864
#include <bits/stdc++.h>
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define repr(i, j) for(int i = j; i >= 0; --i)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

int main() {
	string find, ring;
	int N;
	cin >> find >> N;
	int ans = 0;
	rep(i, N) {
		cin >> ring;
		ring += ring;
		if(ring.find(find) != string::npos) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 3276
#! env python
# -*- coding: utf-8 -*-

import os
import sys


# ac_py.main
# Date: 2020/06/12
# Filename: main 
# Author: acto_mini

def main():
    N, Y = map(int, input().split())
    print()

    for i in range(N + 1):
        for j in range(N + 1 - i):
            k = N - i - j
            if Y == (10000 * i + 5000 * j + 1000 * k):
                print(i, j, k)
                exit()
    print("-1 -1 -1")
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 38768
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdlib.h>
using namespace std;

int main (void){
	int n,i,a,j,flag,s[100001],t[100001],d[100001],value;
	cin >> n;
	flag=0;
	for(i=2;i<=1000;i++){
		if(i*(i-1)==2*n) {
			flag=1;
			a=i;
			break;
		}
	}
	if(flag==0){
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes" << endl;
	cout << a << endl;
	s[1]=1;
	t[1]=2;
	for(i=2;i<=n;i++){
		if(t[i-1]!=a){
			s[i]=s[i-1];
			t[i]=t[i-1]+1;
		} else {
			s[i]=s[i-1]+1;
			t[i]=s[i]+1;
		}
	}
	for(i=1;i<=a;i++){
		cout << a-1;
		value=1;
		for(j=1;j<=n;j++){
			if(s[j]==i||t[j]==i){
				d[value]=j;
				value++;
			}
		}
		for(j=1;j<=a-1;j++){
			cout << " " << d[j];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 2176
from collections import deque

def getStart(field):
    search_field = field[1:]     # cut the first [H,W,N] for min_path matrix
    for y in range(len(search_field)):
        for x in range(len(search_field[0])):
            if search_field[y][x] == "S":
                return x,y+1


def bfs(field,start_x,start_y,goal_N):
    direction = [[-1,0],[1,0],[0,-1],[0,1]]
    gotten_cheese = 1
    distance = 0
    que = []
    que.append([start_x,start_y])
    INF = 1000000
    min_path = [[INF] * field[0][1] for i in range(field[0][0])]
    min_path[start_y-1][start_x] = 0
    while len(que) != 0:
        current = que.pop(0)
        for d in direction:
            nx = current[0] + d[0]
            ny = current[1] + d[1]
            if 0 <= nx < field[0][1] and 1 <= ny < field[0][0]+1 and field[ny][nx] != "X" and min_path[ny-1][nx] == INF:
                min_path[ny-1][nx] = min_path[current[1]-1][current[0]] + 1
                if field[ny][nx] == gotten_cheese:
                    distance += min_path[ny-1][nx]
                    if field[ny][nx] == goal_N: # goal
                        print(distance)
                        return
                    else: # not goal, but could eat cheese
                        que = []
                        que.append([nx,ny])
                        gotten_cheese += 1
                        min_path = [[INF] * field[0][1] for i in range(field[0][0])]
                        min_path[ny-1][nx] = 0
                        break
                else:
                    que.append([nx,ny])


def main(field):
    sx,sy = getStart(field)
    bfs(field,sx,sy,field[0][2])

matrix = []
while True:
    row = input().rstrip().split()
    if len(row) == 3:
        re_row = []
        for i in row:
            re_row.append(int(i))
        matrix.append(re_row)
    else:
        re_row = []
        for char in row[0]:
            if char.isdigit():
                re_row.append(int(char))
            else:
                re_row.append(char)
        matrix.append(re_row)
    if len(matrix) == int(matrix[0][0]) + 1:
        main(matrix)
        break

Measured memory_bytes: 44200
#include<stdio.h>

int main(void){
    int i,j,k,D,x,r;

    scanf("%d%d%d",&r,&D,&x);

    for(i=0;i<10;i++){
        x=r*x-D;
        printf("%d\n",x);
    }
    
    return 0;
}


Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) ((y)<0||(x)<0||(y)>=(h)||(x)>=(w))
#define dump(...)
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct{template<class T> operator T(){T x;cin>>x;return x;}} IN;
struct before_main_function {
    before_main_function() {
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int a, b;
    cin >> a >> b;
    int i = b - a;
    int h = i * (i - 1) / 2;
    dump(i, h);
    cout << h - a << endl;
    return 0;
}



Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  val ls = List.fill(n)(sc.nextLong).sorted(Ordering[Long].reverse)

  def recur(ls: List[Long], a: Long, b: Long): Long = ls match {
    case x :: y :: rest if x == y =>
      if (a == -1) recur(rest, x, b)
      else a * x
    case _ :: rest =>
      recur(rest, a, b)
    case _ => 0
  }
  println(recur(ls, -1L, -1L))
}

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

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

    for(int i=0; i<k; i++){
        if(i%2==0){
            a = (a - a%2) / 2;
            b += a;
        }else{
            b = (b - b%2) / 2;
            a += b;
        }
    }

    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int l,r,d,c,i;
  	scanf("%d%d%d",&l,&r,&d);
  	c=0;
  	for(i=l;i<=r;i++){
    	if(i%d==0){
        	c++;
        }
    }
  	printf("%d\n",c);
}

Measured memory_bytes: 1724
//
//  B - Greedy Takahashi.cpp
//  Practice
//
//  Created by Hajime Sakamoto on 2019/12/30.
//  Copyright © 2019 Hajime Sakamoto. All rights reserved.
//

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <sstream>
#include <iterator>

using namespace std;

class Takahashi{
public:
    long A;
    long B;
    long K;
    
    long A_op;
    long B_op;

    
    void Greedy(){
        if (A >= K){
            A_op = A-K;
            B_op = B;
        }
        else if (A + B > K){
            A_op = 0;
            B_op = B - (K - A);
        }
        else if (A +B <= K){
            A_op = 0;
            B_op = 0;
        }
        
    };
};

int main(){
    Takahashi prc;
    
    cin >> prc.A >> prc.B >>prc.K;
    
    prc.Greedy();
    
    cout << prc.A_op <<' ';
    cout << prc.B_op;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;
const ll mod=1000000007,mod9=1000000009;
template <class T>inline T lcm(T a,T b){return (a*b/__gcd(a,b));}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n],b[n],c[n],d[n];
    vector<vector<ll> > v(20000);
    for(int i=0;i<n-1;i++){
        cin>>a[i]>>b[i];
        a[i]--;
        b[i]--;
        v[a[i]].pb(b[i]);
        v[b[i]].pb(a[i]);
    }
    for(int i=0;i<n;i++){
        cin>>c[i];
    }
    sort(c,c+n);
    reverse(c,c+n);
    ll index=0;
    bool maki[n];
    for(int i=0;i<n;i++){
        maki[i]=false;
    }
    queue<ll> q;
    q.push(0);
    while(!q.empty()){
        ll niko=q.front();
        q.pop();
        maki[niko]=true;
        d[niko]=c[index];
        index++;
        ll umi=v[niko].size();
        for(int i=0;i<umi;i++){
            if(maki[v[niko][i]]==false){
                q.push(v[niko][i]);
            }
        }
    }
    ll ans=0;
    //ll dis[n];
    for(int i=0;i<n-1;i++){
        ans+=min(d[a[i]],d[b[i]]);
    }
    cout << ans<<endl;
    for(int i=0;i<n;i++){
        cout << d[i]<<" ";
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 1536
n = int(input())
leaves = list(map(int, input().split()))

ans = 0
nodes_min = [0] * (n + 1)
nodes_max = [0] * (n + 1)
nodes_min[n] = leaves[n]
nodes_max[n] = leaves[n]

for depth in range(n, 0, -1):
    root_min = nodes_min[depth] // 2 + nodes_min[depth] % 2
    nodes_min[depth - 1] = leaves[depth - 1] + root_min
    root_max = nodes_max[depth]
    nodes_max[depth - 1] = leaves[depth - 1] + root_max
nodes = [0] * (n + 1)
nodes[0] = 1
for depth in range(n):
    roots = nodes[depth]-leaves[depth]
    if nodes[depth] < nodes_min[depth]:
        print(-1)
        break
    nodes[depth + 1] = min(roots * 2, nodes_max[depth + 1])
else:
    if nodes[n] < nodes_min[n]:
        print(-1)
    else:
        print(sum(nodes))

Measured memory_bytes: 26248
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;

namespace Atcoder
{
    class Program
    {
        static readonly long MOD = 1000000000 + 7;
        static void Main(string[] args)
        {
            var n = int.Parse(ReadLine());
            var a = ReadLine().Split(' ').Select(int.Parse).ToList();

            int ans = 0;
            int active = 0;
            for (int i = 0; i < n; i++)
            {
                if (active >= a[i])
                {
                    active = a[i];
                }
                else
                {
                    ans += a[i] - active;
                    active = a[i];
                }
            }
            WriteLine(ans);
        }
    }
}



Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(x) for(int i=0;i<x;i++)
#define reprev(x) for(int i=x-1;i>=0;i--)
#define repdef(x,n) for(int i=x;i<n;i++)
#define Debug(x) cout<<x<<"\n";
#define Debug2(x,y) cout<<x<<" "<<y<<"\n";
#define TEST(t) while(t--)
#define mod 1000000007
#define MAX 1000005
int fast_exp(ll base,ll exp){
    if(exp==1){
        return base%mod;
    }
    if(exp&1){
        int ans=fast_exp(base,exp-1);
        return (base%mod*ans%mod)%mod;
    }else{
        int ans=fast_exp(base,exp/2);
        return (ans%mod*ans%mod)%mod;
    }
}
int fast_exp_itr(ll base,ll exp,ll p){
    ll ans=1;
    base=base%p;
    while(exp>0){
        if(exp&1){
            ans=((ans%p)*(base%p))%p;
        }
        exp>>=1;
        base=((base%p)*(base%p))%p;
    }
    return ans;
}
ll euclid_gcd(ll a,ll b){
    if(b==0){
        return a;
    }
    return euclid_gcd(b,a%b);
}
vector<ll>primes;
bool arr[MAX];
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    memset(arr,true,sizeof(arr));
    arr[0]=arr[1]=false;
    primes.clear();
    for(ll i=2;i<MAX;i++){
    	if(arr[i]){
    		primes.push_back(i);
    		for(ll j=i*i;j<MAX;j+=i){
    			arr[j]=false;
    		}
    	}
    }
    ll a,b;
    cin>>a>>b;
    ll g=euclid_gcd(max(a,b),min(a,b));
    ll count=1;
    for(auto i:primes){
    	if(g%i==0){
    		count++;
    	}
    	while(g%i==0){
    		g/=i;
    	}
    }
    if(g!=1){
    	count++;
    }
    cout<<count<<"\n";
    return 0;
}

Measured memory_bytes: 2424
List = []
b = 0

N, K = map(int, input().split())
H = input().split()

for i in range(len(H)):
    a = int(H[i])
    List.append(a)
    
List.sort()

for i in range(K):
    List.pop()
    if len(List) == 0:
        break
        
for i in range(len(List)):
    b = b + List[i]

print(b)

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

using namespace std;

void doc()
{
    freopen("solve.inp","r",stdin);
    freopen("solve.out","w",stdout);
}

void solve() {
    int n, m;
    cin >> n >> m;
    priority_queue <int> Q;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        Q.push(x);
    }
    while (m--) {
        int x = Q.top(); Q.pop();
        Q.push(x / 2);
    }
    long long Res = 0;
    for (int i = 0; i < n; i++) {
        int x = Q.top(); Q.pop();
        Res += x;
    }
    cout << Res;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //doc();
    solve();
}


Measured memory_bytes: 892
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;

int main(){
  ll n;cin>>n;
  vll c(n-1),s(n-1),f(n-1);
  rep(i,0,n-1){
    cin>>c[i]>>s[i]>>f[i];
  }
  rep(i,0,n-1){
    ll now=s[i];
    rep(j,i,n-1){
      ll tmp=(now-s[j])/f[j];
      if(now-s[j]<0){
        now=s[j]+c[j];
      }
      else if((now-s[j])%f[j]==0){
        now=s[j]+f[j]*tmp+c[j];
      }
      else now=s[j]+f[j]*(tmp+1)+c[j];
      
    }
    cout<<now<<endl;
  }
  cout<<0<<endl;
}



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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
int help(int x,int y,int k)
{
	int res=1;
	while(y>0)
	{
		if(y&1)
		{
			(res*=x)%=k;
		}
		(x*=x)%=k;
		y/=2;
	}
	res%=k;
	//return res;
	int xxx = (res-1+k)%k;
	return (xxx==0);
}		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int k;
		cin>>k;
		if(k%2==0)
		{
			cout<<-1;
		}
		else
		{
			if(k%7==0)
			k/=7;
			for(int i=1;i<=k;++i)
			{
				if(help(10,i,9*k))
				{
					cout<<i;
					return 0;
				}
			}
			cout<<-1;
		}
		cout<<"\n";
		//cout<<help(2,5,mod);		
    }
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int n,m,x=0;
    cin >> n >> m >> x;
    vector<int> t(n+1,0);
    for(int i=0;i<m;i++){
        int a;
        cin >>a;
        t[a] =1;
    }
    int l=0,r=0;
    for(int i=0;i<x;i++){
        l += t[i];
    }
    for(int i=x;i<n;i++){
        r += t[i];
    }
    cout << min(l,r) <<endl;
}


Measured memory_bytes: 256
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		int n = reader.ni();
		long[] arr = new long[n];
		for (int i=0; i<n; i++) arr[i] = reader.nl();
		// Arrays.sort(arr);

		for (int i=0; i<n; i++) {
			if (arr[i] == 0) {
				out.println("0");
				return;
			}
		}

		long res = 1;
		long inf = (long)1e18;
		for (int i=0; i<n; i++) {
			long bound = inf / res;
			if (arr[i] > bound) {
				out.println("-1");
				return;
			}
			res *= arr[i];
		}

		out.println(res);
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 48884
#include "bits/stdc++.h"
using namespace std;

#define int long long
#define MAX_N (200005)
#define INF (1LL<<60)
#define EPS (1e-7)
#define DEBUG(x) cerr << #x <<":"<< x << endl;
#define DEBUGVC(x) cerr << #x <<": "; for(auto p:(x)) cerr << p <<" "; cerr << endl;
#define DEBUGVCP(x) for(auto p:(x)) cerr << #x <<": "<< p.first <<", "<< p.second << endl;
#define DEBUG2(x, y) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y << endl;
#define DEBUG3(x, y, z) cerr << #x <<" : "<< x <<", "<< #y <<" : "<< y <<", "<< #z <<" : "<< z << endl;
const int MOD = (int)1e9+7;


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

    cout << 180 * (N-2) << endl;

}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abc047/tasks/abc047_b
#include <bits/stdc++.h>
using namespace std;

int main() {
    int l=0,r,b=0,t,n;
    cin>>r>>t>>n;
    for(int i=0;i<n;i++) {
        int x,y,a;
        cin>>x>>y>>a;
        if(a==1) {
            l = max(l,x);
        } else if(a==2) {
            r = min(r,x);
        } else if(a==3) {
            b = max(b,y);
        } else if(a==4) {
            t = min(t,y);
        }
    }
    if(l>=r || b>=t) 
        cout<<"0\n";
    else
        cout<<(r-l)*(t-b)<<"\n";
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n,k;
  cin>>n>>k;
  int A[n];
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  int B[n];
  for(int i=0;i<n;i++){
    B[i]=INT_MAX;
  }
  B[0]=0;
  
  for(int i=0;i<n;i++){
    for(int j=i+1;j<=i+k;j++){
      if(j<n){
      B[j]=min(B[j],B[i]+abs(A[i]-A[j]));
        }
    }
    }
    cout<<B[n-1]<<endl;
}

Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		int n = int.Parse(Console.ReadLine());
        
        int[,] A = new int[10,10]; //n以下の数字で先頭がiで、末尾がjの数字の個数を格納
        for(int k=1;k<=n;k++){
            string strK = k.ToString();
            int start = int.Parse(strK.Substring(0,1));
            int end = int.Parse(strK.Substring(strK.Length-1,1));
            A[start,end]++;
        }
        
        long count = 0;
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                count += (long)A[i,j] * (long)A[j,i];
                //Console.Write(A[i,j] + " ");
            }
            //Console.WriteLine("");
        }
        Console.WriteLine(count);
	}
}


Measured memory_bytes: 15300
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod = 1e9+7;

//約数列挙
vector<int> comdiv(int x){
    vector<int> res;
    stack<int> big;
    for(int i = 1; i*i <= x; i++){
        if(x%i == 0){
            res.push_back(i);
            big.push(x/i);
        } 
    }
    while(!big.empty()){
        res.push_back(big.top());
        big.pop();
    }
    return res;
}

int main(){
    ll n,m;
    cin >> n >> m;
    vector<int> y = comdiv(m);
    int ans;
    for(auto p:y){
        if(m-p*(n-1) > 0) ans = p;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
AB = [list(map(int,input().split())) for _ in range(N)]
CD = [list(map(int,input().split())) for _ in range(M)]
for ab in AB:
    MIN = float('inf')
    MIN_I = 0
    for i,cd in enumerate(CD):
        distance = abs(ab[0]-cd[0])+abs(ab[1]-cd[1])
        if MIN > distance:
            MIN = distance
            MIN_I = i
    print(MIN_I+1)

Measured memory_bytes: 3064
N = gets.chomp.to_i

def f(a, b)
  [a.to_s.size, b.to_s.size].max
end

require 'prime'

def _divisors(primes, k)
  Enumerator.new do |y|
    if primes.size == k
      y << 1
    else
      p, e = primes[k]
      _divisors(primes, k + 1).each {|d|
        (e + 1).times {|e1|
          y << p ** e1 * d
        }
      }
    end
  end
end

def divisors(n)
  _divisors(Prime.prime_division(n), 0).to_a.sort
end

a = divisors(N)
b = []
a.each do |e|
  b.push(f(e, N/e))
end
p b.min


Measured memory_bytes: 2424
#include<iostream>
#include<vector>
#include<complex>
#include<algorithm>
#include<cmath>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P complex<double>
#define X real()
#define Y imag()
const double EPS = 1e-9;

int n;
vector<P> vv;

int count_points(P a, P b, double mx, double my){
    P v = (a - b);
    double d_v = abs(v);
    if(d_v >= 2.0 + EPS) return 0;
    P m = v / 2.0 + b;
    double half_d_v = d_v / 2;
    double d = sqrt(1.0 - half_d_v * half_d_v);
    P u = (v * P(mx, my)) / abs(v) * d;
    int cnt = 0;
    REP(i, n){
        P c = m + u;
        if(abs(c - vv[i]) <= 1.0 + EPS) cnt++;
    }
    return cnt;
}

int main(){
    while(cin >>n && n){
        vv = vector<P>(n);
        REP(i, n){
          double a, b; cin >>a >>b;
          vv[i] = P(a, b);
        }

        int ans = 1;
        REP(a, n){
            FOR(b, a + 1, n){
                ans = max(ans, count_points(vv[a], vv[b], 0, 1));
                ans = max(ans, count_points(vv[a], vv[b], 0, -1));
            }
        }
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1272
#include <stdio.h>

int main()
{
	// 変数定義
	int iDailyCoins;	// 日毎の獲得コイン
	int iWeeklyCoins;	// 週毎の獲得コイン
	int iGoalCoins;		// 目標獲得コイン
	int iTotalGetting;	// 総獲得コイン数
	int iTotalDays;		// 最低必要日数

	// 変数初期化
	iTotalGetting = 0;
	iTotalDays = 0;

	// 入力：1日毎の獲得コイン, 7日毎の獲得コイン, 目標獲得コイン数
	scanf("%d %d %d", &iDailyCoins, &iWeeklyCoins, &iGoalCoins);

	// 目標獲得数以上になるまで、1日ずつ総コイン獲得数を数える
	while (iTotalGetting < iGoalCoins)
	{
		iTotalDays++;
		iTotalGetting += iDailyCoins;
		if (iTotalDays % 7 == 0)
		{
			iTotalGetting += iWeeklyCoins;
		}
	}

	// 出力：最低必要日数
	printf("%d\n", iTotalDays);

	return 0;
}


Measured memory_bytes: 2104
import  heapq

n,m,s,t=map(int,raw_input().split())
src = [ tuple( map( int, raw_input().split() ) )   for i in range(m)]

nl=[ [ ] for j in range(n+1) ] 

for u,v,a,b in src:
	nl[u].append( (v,a,b) )
	nl[v].append( (u,a,b) )

#Dijkstra yen
d_y=[ float("inf") ]*(n+1)
d_y[s]=0

Q=[]
heapq.heappush(Q, (0,s) )

while Q:
	cost, u=heapq.heappop(Q)
	for v,yen,snuuk in nl[u]:
		if d_y[v] > cost+yen:
			d_y[v]=cost+yen
			heapq.heappush(Q, (d_y[v], v)  )

#Dijkstra snuuk
d_s=[ float("inf")]*(n+1)
d_s[t]=0

Q=[]
heapq.heappush(Q,(0,t) )

while Q:
	cost, u=heapq.heappop(Q)
	for v,yen,snuuk in nl[u]:
		if d_s[v] > cost+snuuk:
			d_s[v]=cost+snuuk
			heapq.heappush(Q, (d_s[v], v)  )


val=float("inf")
A=[]
for i in range(n,0,-1):
	tmp=d_y[i]+d_s[i]
	val=min(val, tmp)
	A.append(val)

for i in reversed(A):
	print 10**15-i

Measured memory_bytes: 101020
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	void set(int arg_task,int arg_num){
		task = arg_task;
		num = arg_num;
	}
	int task,num;
};

struct Data{
	Info unit_table[5];
	int clock,min_task,max_task;
};

char table[5][20];
int loc[20];
int N;

void func(){

	for(int i = 0; i < 5; i++)scanf("%s",table[i]);

	for(int i = 0; i < N; i++){
		for(int k = 0; k < 5; k++){
			if(table[k][i] == 'X'){
				loc[i] = k;
				break;
			}
		}
	}

	Data first;
	for(int unit = 0; unit < 5; unit++){
		if(table[unit][0] == 'X'){
			first.unit_table[unit].set(0,0);
		}else{
			first.unit_table[unit].set(BIG_NUM,BIG_NUM);
		}
	}
	first.clock = 1;
	first.min_task = 0;
	first.max_task = 0;

	queue<Data> Q;
	Q.push(first);

	int count;
	bool collide;

	while(!Q.empty()){

		Data new_data;
		for(int unit = 0; unit < 5; unit++)new_data.unit_table[unit].set(BIG_NUM,BIG_NUM);

		collide = false;
		count = 0;
		new_data.min_task = BIG_NUM,new_data.max_task = -BIG_NUM;

		for(int task = Q.front().min_task; task <= Q.front().max_task; task++){
			for(int unit = 0; unit < 5; unit++){
				if(Q.front().unit_table[unit].task == task){

					if(Q.front().unit_table[unit].num < N-1){
						new_data.min_task = min(new_data.min_task,task);
						new_data.max_task = max(new_data.max_task,task);

						int next_loc = loc[Q.front().unit_table[unit].num+1];
						if(new_data.unit_table[next_loc].task == BIG_NUM){
							count++;
							new_data.unit_table[next_loc].task = task;
							new_data.unit_table[next_loc].num = Q.front().unit_table[unit].num+1;

							if(task == 9 && Q.front().unit_table[unit].num+1 == N-1){
								printf("%d\n",Q.front().clock+1);
								return;
							}
						}else{
							collide = true;
							break;
						}
					}
					break;
				}
			}
			if(collide)break;
		}
		if(collide){
			Q.pop();
			continue;
		}

		if(new_data.unit_table[loc[0]].task == BIG_NUM && new_data.max_task < 9){
			Data new_data_add;
			for(int unit = 0; unit < 5; unit++){
				new_data_add.unit_table[unit].set(new_data.unit_table[unit].task,new_data.unit_table[unit].num);
			}
			new_data_add.unit_table[loc[0]].set(new_data.max_task+1,0);
			new_data_add.clock = Q.front().clock+1;
			new_data_add.min_task = new_data.min_task;
			new_data_add.max_task = new_data.max_task+1;

			Q.push(new_data_add);
		}

		if(count > 0){
			new_data.clock = Q.front().clock+1;
			Q.push(new_data);
		}
		Q.pop();
	}
}


int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 4456
// I can !

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

#define ll long long
#define pb push_back
#define mp make_pair
#define forn(i,n) for(ll i=0;i<n;i++)
#define fore(i,a,b) for(ll i=a;i<=b;i++)
#define ford(i,n) for(ll i=n-1;i>=0;i--)
#define fi first
#define se second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

const ll maxn=1e6+1,mod=1e9+7;

int minus(int x){
    x--;
    return x;

}

int main(){

   
    string s;
    cin>>s;
    ll ans = 0;
    if(s.size()<3){
        cout<<0;
        return 0;
    }
    ll continuee = 0;
    bool flag = false;
    for(int i=s.size()-2;i>=0;i--){
        if(s[i]=='B'){
            if(s[i+1]=='C'){
                flag = true;
                continuee+=1;
            }
            else{
                flag = false;
                continuee = 0;
            }
        }
        if(s[i]=='A'){
            if(flag&&(s[i+1]=='A'||s[i+1]=='B')) ans+=continuee;
            else continuee = 0, flag = false;
        }
        if(s[i]=='C'){
            if(s[i+1]=='A'){
                if(flag) continue;
            }
            else{
                if(s[i+1]=='C'){
                    flag = false;
                    continuee = 0;
                }
            }
        }
    }
    cout<<ans;
    return 0;
}

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

void print_array(int *A, int N)
{
	for (int i = 0; i < N; i++) {
		if (i)
			cout << " ";
		cout << A[i];
	}
	cout << endl;
}

int selection_sort(int *A, int N)
{
	int nswap = 0;
	for (int i = 0; i < N; i++) {
		int minj = i;
		for (int j = i + 1; j < N; j++) {
			if (A[minj] > A[j])
				minj = j;
		}
		if (minj != i)
			nswap++;
		swap(A[i], A[minj]);
	}
	return nswap;
}

int main()
{
	int N, A[100];
	
	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> A[i];

	int nswap = selection_sort(A, N);
	print_array(A, N);
	cout << nswap << endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
#define PAUSE \
	int t;    \
	cin >> t
#define int long long
#define vi vector<long long>
#define mapii map<long long, int>
#define mapci map<char, int>
#define append(x) push_back(x)
#define tcase          \
	long long t;       \
	scanf("%lld", &t); \
	while (t--)
#define prq priority_queue
#define fio                           \
	ios_base::sync_with_stdio(false); \
	cin.tie(NULL)
// #define debug(x, y) cout<<"case #"<<x<<" at itr #"<<y<<endl
#define debug(x) cout << "case #" << x << endl
#define ff first
#define ss second
#define range(ini, x) for (int itr = ini; itr < x; itr++)
#define takearr(x)    \
	for (auto &i : x) \
	cin >> i
#define print(x)     \
	for (auto i : x) \
		cout << i << " ";
#define FOR(x, y) for (int i = x; i < y; i++)
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define foreach(i, x) for (auto i : x)
#define setbitcount __builtin_popcount
//******************/
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
//******************/
// #define range(ini, x, step) for( int itr = ini, i < x; itr += step )
using namespace std;
// using namespace __gnu_pbds;
// template < class type > using oset=tree<type, null_type,less<type>, rb_tree_tag,tree_order_statistics_node_update>;
const int mmx = 1e5 + 1;
const int mnx = 1e4 + 1;
const int mmod = 1e9 + 7;

int n;
int dp[mmx];
vi arr;

int jump( int index ){

	if( dp[index] != -1 ) return dp[index];

	if( index == n - 1 ){
		dp[index] = 0;
		return dp[index];
	}
	if( index == n - 2 ){
		dp[index] = abs( arr[index] - arr[index + 1] );
		return dp[index];
	}
	else{
		dp[index] = min( abs( arr[index] - arr[index + 1] ) + jump(index + 1), abs( arr[index] - arr[index + 2] ) + jump(index + 2) );
		return dp[index];
	}
}

signed main()
{

	memset(dp, -1, sizeof dp);

	cin>>n;

	for0(i,n){
		int in;
		cin>>in;
		arr.push_back(in);
	}
	cout<<jump(0)<<endl;
	return 0;
}

Measured memory_bytes: 4340
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <queue>
#include <stack>
using namespace std;

typedef long long ll;
#define pb push_back

#define rep(i, n) for (int i=0;i<(n);++i)
#define rep2(i, s, n) for (int i=s;i<(n);++i)
#define rev(i, n) for (int i=(n);i>0;--i)
#define INF (1e9+1e9)

/* SegTree */
const int N = 1e5;
int t[N<<1];
int n;

void build() {
    rev(i,n-1) t[i] = t[i<<1] + t[i<<1|1];
}
void modify(int p, int value) {
    for(t[p += n] += value; p > 1; p >>= 1) t[p>>1] = t[p] + t[p^1];
}
int query(int l, int r) {
    int res = 0;
    for(l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if (l&1) res += t[l++];
        if (r&1) res += t[--r];
    }
    return res;
}


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

    rep(i,n) t[n+i] = 0;
    build();
    vector<int> C,X,Y;
    rep(i,Q) {
        int c,x,y; cin>>c>>x>>y;
        C.pb(c); X.pb(x); Y.pb(y);
    }
    rep(i,Q) if (C[i]==0) modify(X[i]-1, Y[i]); else cout << query(X[i]-1, Y[i]) << endl;
}

Measured memory_bytes: 5004
import re

s = input()
if s[0] != "A":
    print("WA")
elif s[2:-1].count("C") != 1:
    print("WA")
else:
    i = 2 + s[2:-1].index("C")
    print("AC" if re.match("^[a-z]*$", s[1] + s[2:i] + s[i+1:]) else "WA")


Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

int main()
{
  int n,a,b;
  string s;
  cin>>n>>a>>b>>s;

  int temp=0,temp_b=0;
  REP(i,n){
    if(s[i]=='c'){
      cout<<"No"<<endl;
      continue;
    }
    if(s[i]=='a'){
      if(temp<a+b){
        cout<<"Yes"<<endl;
        temp++;
      }
      else cout<<"No"<<endl;
    }else{
      if(temp<a+b && temp_b<b){
        cout<<"Yes"<<endl;
        temp++;
        temp_b++;
      }
      else cout<<"No"<<endl;
    }
  }
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
 
#define sws ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define INFINITO 1000000000
#define ll long long
#define vi vector<int>
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define fo(i, n) for( int i = 0; i < n; i++ )


int main() {

    ll n;
    cin >> n;

    cout << (n * (n - 1)) / 2 << endl;

    return 0;
}

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

int A[3][3];
bool ok[3][3];

int main(){
  for (int i=0;i<3;++i){
    for (int j=0;j<3;++j){
      cin >> A[i][j];
    }
  }
  int n;
  cin >> n;
  for (int i=0;i<n;++i){
    int b;
    cin >> b;
    for (int j=0;j<3;++j){
      for (int k=0;k<3;++k){
        if(A[j][k] == b) ok[j][k] = true;
      }
    }
  }
  //ここまででマルバツの配列に変換できた
  
  bool bingo = false;
  for (int i=0;i<3;++i){
    int cnt = 0;
    for (int j=0;j<3;++j) if(ok[i][j]) cnt++;
    if (cnt == 3) bingo = true;
  }
  for (int j=0;j<3;++j){
    int cnt = 0;
    for (int i=0;i<3;++i) if(ok[i][j]) cnt++;
    if (cnt == 3) bingo = true;
  }
  //ここまでで縦横
  int cnt = 0;
  for (int i=0;i<3;++i){
    if(ok[i][i]) cnt++;
    if (cnt == 3) bingo = true;
  }
  //ここまでで縦横斜め
  if (ok[0][2] && ok[1][1] && ok[2][0]) bingo = true;

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


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
using namespace std;
int main(){
    string S;
    cin >> S;
int A=0,B=0,C=0;
    for(int i = 0;i<S.size();i++){
        if (S[i] ==  'A' || S[i]== 'T' ||S[i] == 'G' || S[i] == 'C')
        {
            A++;
        } else {
            B=max(A,B);
            A=0;
        }

    }
    cout << max (A,B) << endl;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
X=list(map(int,input().split()))
if(len(X)<=N):
  print(0)
else:
  #print(N,M,X)
  sort_X=sorted(X)
  #print(sort_X)
  #print(sort_X[1:],sort_X[0:len(sort_X)-1])
  X_sa=[x - y for (x, y) in zip(sort_X[1:], sort_X[0:len(X)-1])]
  #print(X_sa)
  sort_X_sa=sorted(X_sa)
  #print(sort_X_sa)
  #print(sort_X_sa[:M-N])
  print(sum(sort_X_sa[:M-N]))

Measured memory_bytes: 13968
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;
const int D = 60;
int to[D][200000];

int main(void){
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) cin >> to[0][i], to[0][i]--;
  REP(i, D-1) REP(j, n) to[i+1][j] = to[i][to[i][j]];
  ll ans = 0;
  REP(i, D) if(1ll<<i & k) ans = to[i][ans];
  cout << ans+1 << endl;
  return 0;
}

Measured memory_bytes: 51832
s = input()
count = 0
if s[0] == 'R':
  count += 1
  if s[1] == 'R':
    count += 1
    if s[2] == 'R':
      count += 1
elif s[1] == 'R':
  count += 1
  if s[2] == 'R':
    count += 1
elif s[2] == 'R':
  count += 1
print(count)

Measured memory_bytes: 9140
// ABC092 - D
// Grid Components

#include <iostream>
#include <vector>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;

    vector<vector<char>> table(100, vector<char>(100));
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (i < 50) table[i][j] = '.';
            else table[i][j] = '#';
        }
    }

    for (int b = 0; b < B - 1; ++b) {
        int i = b / 50;
        i *= 2;
        int j = (b % 50) * 2;
        table[i][j] = '#';
    }

    for (int a = 0; a < A - 1; ++a) {
        int i = a / 50;
        i *= 2;
        i += 51;
        int j = (a % 50) * 2;
        table[i][j] = '.';
    }

    cout << 100 << ' ' << 100 << endl;
    for (int i = 0; i < 100; ++i) {
        for (int j = 0; j < 100; ++j) {
            cout << table[i][j];
        }
        cout << endl;
    }
}

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

int main() {
  string s;
  cin>>s;
  vector<int> ans;
  for (char c: s) {
    if (c == '0') {
      ans.push_back(0);
    } else if (c == '1') {
      ans.push_back(1);
    } else {
      if (ans.size() > 0) {
        ans.pop_back();
      }
    }
  }
  for (int c: ans) {
    cout<<c;
  }
  cout<<endl;
}

Measured memory_bytes: 256