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

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

ll lcm(ll a, ll b)
{
   return a / gcd(a, b)* b ;
}
int main(){
  ll n;
  ll ans=1;
  cin >>n;
  vector<ll> clock(100);

  for(int i =0;i<n;i++){
	  cin >>clock.at(i);
	  ans= lcm(ans,clock.at(i));
  }
  cout <<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vl c(n),s(n),b(n);
    rep(i,n-1)cin >> c[i] >> s[i] >> b[i];
    rep(i,n){
        ll t=0;
        for(int j=i;j<n-1;j++){
            if(t<s[j]){
                t=s[j]+c[j];
                continue;
            }
            while(t%b[j]!=0)t++;
            t+=c[j];
        }
        cout << t <<endl;
    }
}


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

typedef long double ld;

int main()
{
	ld N;
	cin >> N;
	for(ld i=1;i<=3500;i+=1)
	{
		for(ld j=1;j<=3500;j+=1)
		{
			if(4*i*j-N*j-N*i==0)
				continue;
			ld w=(N*i*j)/(4*i*j-N*j-N*i);
			if(w==(long long)w&&w>0)
			{
				printf("%.0Lf %.0Lf %.0Lf\n",i,j,w);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
  int N;
  long long ans = 0;
  cin >> N;
  vector<int> A(N, 0), B(N, 0), C(N, 0);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> B.at(i);
  }
  for (int i = 0; i < N; i++)
  {
    cin >> C.at(i);
  }
  vector<int>::iterator itrB = B.end(), itrC = C.end();
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());
  sort(C.begin(), C.end());
  for (int i = 0; i < N; i++)
  {
    itrB = lower_bound(A.begin(), A.end(), B[i]);
    itrC = upper_bound(C.begin(), C.end(), B[i]);
    ans += distance(A.begin(), itrB) * distance(itrC, C.end());
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
# A - Sorted Arrays

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

if N == 1:
    print(1)
    exit()

increase_flg = False
decrease_flg = False
ans = 1

for i in range(1, N):
    if A[i] > A[i-1] and not decrease_flg:
        increase_flg = True
    elif A[i] > A[i-1] and decrease_flg:
        decrease_flg = False
        increase_flg = False
        ans += 1
    elif A[i] < A[i-1] and not increase_flg:
        decrease_flg = True
    elif A[i] < A[i-1] and increase_flg:
        increase_flg = False
        decrease_flg = False
        ans += 1

print(ans)

Measured memory_bytes: 15020
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	ll N,X,D;
	scan(N>>X>>D);
	ll ans=0;
	map<ll,vpll> kXkukan;
	if(D==0){
		if(X==0) prin(1);
		else prin(N+1);
	}
	else{
		if(D<0){
			X=-X;
			D=-D;
		}
		rep(k,N+1){
			ll mini=k*X+(ll)k*(k-1)*D/2;
			ll maxi=k*X+(ll)k*(2*N-k-1)*D/2;
			kXkukan[((k*X)%D+D)%D].push_back({mini,maxi});
		}
		for(auto K:kXkukan){
			vpll V=K.second;
			ll nowmax=-INFl;
			sort(ALL(V));
			rep(j,V.size()){
				if(V[j].first>nowmax){
					ans+=(V[j].second-V[j].first)/D+1;
					nowmax=V[j].second;
				}
				else if(V[j].second>nowmax){
					ans+=(V[j].second-nowmax)/D;
					nowmax=V[j].second;
				}
				//printf("amari:%lld f:%lld s:%lld ans:%lld\n",K.first,V[j].first,V[j].second,ans);

			}
		}
		prin(ans);
	}
	return 0;
}


Measured memory_bytes: 22144
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let n = read_as_vec::<i32>()[0];

    for n4 in 0..n/4+1{
        if (n-n4*4)%7 == 0{
            println!("Yes");
            return;
        }
    }
    println!("No");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1LL << 60;

ll N, Q;
vector<tuple<ll, ll, ll>> v;
set<P> st;

int main() {
    cin >> N >> Q;
    v.resize(N);

    rep(i, N) {
        ll s, t, x;
        cin >> s >> t >> x;
        v[i] = make_tuple(x, s, t);
    }
    sort(v.begin(), v.end());

    rep(i, Q) {
        ll d; cin >> d;
        st.insert(P(d, i));        
    }

    vector<ll> ans(Q);

    rep(i, N) {
        ll x, l, r;
        tie(x, l, r) = v[i];

        auto iter = st.lower_bound(P(l - x, -1));
        while (iter != st.end()) {
            if (iter->first >= r - x) break; 
            ans[iter->second] = x;
            st.erase(iter++);
        }
    }

    rep(i, Q) {
        if (ans[i] == 0) {
            cout << -1 << endl;
        } else {
            cout << ans[i] << endl;
        }
    }
}

Measured memory_bytes: 21876
//自称高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//この提出は解説の写経です。
int main() {
    int ans = 0;
    //int tmp;
    int n, a, b;
    vector< pair<int,int> > link; //枝の両端を順番に記述 大きさはn-1
    cin >> n;
    vector<vector<int>> g(n); //g[k]を見ると隣接するノードが列挙されている(大きさ2n?)
    REP(i, n-1){
        cin >> a >> b;
        a--; //1オリジンなのでデクリメントする
        b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
        link.emplace_back(a, b);
    }
    map< pair <int,int>, int> I; //枝に対して色を呼びだすmap
    vector<int> cs (n, 0); //親との間の色を記録する
    vector<int> used(n,0); //探索済みのノード
    queue <int> que; 
    used[0]=1; //0番のノードを親にする
    que.emplace(0); //0番のノードをキューに積む
    while(!que.empty()){
        int v = que.front();
        que.pop();
        if(ans < (int)g[v].size()) ans = g[v].size(); //最大次数をみる
        int cur = 1;  //今の色を1にする
        for(int u:g[v]){ //vの隣接してるやつをみる
            if(used[u]) continue; //チェック済み(親)だったら見ない
            if(cur == cs[v]) cur++; //いま使おうとしている色が親との間の枝の色ならインクリメント
            cs[u]=I[make_pair(u,v)]= I[make_pair(v,u)] = cur++; //まだ使っていない最小の色で塗る
            used[u] = 1;
            que.emplace(u);
        }
    }

    cout << ans << endl;
    for(auto p:link) cout << I[p] << endl;
    return 0;
}

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

int c[25];
int memo[50100];

int n,m;

const int inf = 1e15;

int dfs(int a){
  if( a < 0 ){ return inf;}
  if( memo[a] != -1 ){ return memo[a];}
  
  int res = inf;
  
  for(int i = 0; i < m; i++){ 
    res = min(dfs(a-c[i])+1,res);
  }
  
  return memo[a] = res;
}


signed main(void){
  cin >> n >> m;
  for(int i = 0; i < 50100; i++){ memo[i] = -1;}
  for(int i = 0; i < m; i++){
    cin >> c[i]; memo[c[i]] = 1;
  }
  memo[0] = 0;
  cout << dfs(n) << endl;
  
  return 0;
}


Measured memory_bytes: 5024
# -*- coding: utf-8 -*-

def input_one_number():
    return int(input())

def input_multiple_number():
    return map(int, input().split())

def input_multiple_number_as_list():
    return list(map(int, input().split()))

S = input()

if S == "ABC":
	print("ARC")
else:
	print("ABC")

Measured memory_bytes: 9064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
long long dp[100010];
  
int main()
{
  string s,t;
  cin >> s >> t;
  vector<vector<int>> vec(26,vector<int> (s.size(),-1));
  REP(i,26){
    int cnt = 0;
    int flag2 = 0;
    REPR(j,s.size()-1){
      if(s.at(j)==i+'a'){
        cnt=0;
        vec.at(i).at(j)=cnt;
        flag2=1;
      }else{
        cnt++;
        vec.at(i).at(j)=cnt;
      }
    }
    REPR(j,s.size()-1){
      if(flag2==0){
        vec.at(i).at(j)=-1;
      }else if(s.at(j)==i+'a'){
        break;
      }else{
        cnt++;
        vec.at(i).at(j)=cnt;
      }
    }
  }

  dp[0]=-1;
  int flag = 0;
  FOR(i,1,t.size()+1){
    if(vec.at(t.at(i-1)-'a').at(dp[i-1]%s.size())!=-1){
      dp[i]=dp[i-1]+1+vec.at(t.at(i-1)-'a').at((dp[i-1]+1)%s.size());
    }else{
      flag=1;
      break;
    }
  }

  if(flag==0){
    cout << dp[t.size()]+1 << endl;
  }else{
    cout << -1 << endl;
  }
}

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

int f(int n,int a,int b){
    int r = n;
    int sum = 0;
    int digit = log10(n);
    for(int i=digit;i>=0;i--){
        sum += r / int(pow(10,i));
        r %= int(pow(10,i));
    }
    if(a <= sum && sum <= b){
        return n;
    }
    return 0;
}

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

    int sum=0;
    for(int i=1;i<=n;i++){
        sum += f(i,a,b);
    }

    cout << sum<< endl;

    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    ll q, h, s, d;
    ll n;
    ll ans = 0;
    cin >> q >> h >> s >> d >> n;
    ll L = min({q * 4, 2 * h, s});
    ll L2 = min(L * 2, d);
    if (n % 2 == 0)
    {
        ans = L2 * n / 2;
    }
    else
    {
        ans = L2 * (n / 2) + L;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main(){
  int n;
  int sum=0;

  while(true){
    int score[1009]={0};
    sum = 0;
    double result;
    double bunsan=0;
    
    cin >> n;
    if(n==0)
      break;
    for(int i=0;i<n;i++){
      cin >> score[i];
      sum += score[i];
    }

    double m = (double)sum / n;

    for(int i=0;i<n;i++)
      bunsan+=pow(score[i]-m,2)/(double)n;

    result=sqrt(bunsan);

    cout << fixed << setprecision(8) << result << endl;
  }
}

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

string s;

int main()
{
    cin >> s;

    int a = s[0] - '0';
    int b = s[1] - '0';
    int c = s[2] - '0';
    int d = s[3] - '0';

    if (a + b + c + d == 7)
    {
        cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if (a + b + c - d == 7)
    {
        cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if (a + b - c + d == 7)
    {
        cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if (a + b - c - d == 7)
    {
        cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    }
    else if (a - b + c + d == 7)
    {
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if (a - b + c + d == 7)
    {
        cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    }
    else if (a - b + c - d == 7)
    {
        cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    }
    else if (a - b - c + d == 7)
    {
        cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    }
    else if (a - b - c - d == 7)
    {
        cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
    }
    return 0;
}


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

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

	int card[13]; // A ~ 13
	int data[5];
	while(cin >> data[0]){
		fill(card, card + 13, 0);
		++card[data[0] - 1];
		char c0;
		for(int i = 1; i < 5; ++i){
			cin >> c0 >> data[i];
			++card[data[i] - 1];
		}

		sort(card, card + 13, greater<int>());
		/*
		for(int i = 0; i < 13; ++i){
			cout << card[i] << " ";
		}
		cout << endl;
		*/
		switch(card[0]){
			case 4 :
				cout << "four card" << endl;
				break;

			case 3 :
				if(card[1] == 2)
					cout << "full house" << endl;
				else
					cout << "three card" << endl;
				break;

			case 2 :
				if(card[1] == 2)
					cout << "two pair" << endl;
				else
					cout << "one pair" << endl;
				break;

			default :
				sort(data, data + 5);
				if((data[0] == 1 && data[1] == 10 && data[4] == 13) || (data[0] + 4 == data[4]))
					cout << "straight" << endl;
				else
					cout << "null" << endl;
				break;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cstdio>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007
#define MAXS(x,y) (x = max(x,y))
#define MINS(x,y) (x = min(x,y))

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;


int N;
struct Node{
  int parent;
  int left;
  int right;
};

vector<Node> nodes;
vector<int> H,D;

void setDepth(int n, int d){
  if(n == -1)return;

  D[n] = d;
  setDepth(nodes[n].left, d+1);
  setDepth(nodes[n].right, d+1);
}

int setHeight(int n){
  int h1 = 0, h2 = 0;
  if(nodes[n].left != -1){
    h1 = setHeight(nodes[n].left) + 1;
  }
  if(nodes[n].right != -1){
    h2 = setHeight(nodes[n].right) + 1;
  }
  return H[n] = ( h1 > h2) ? h1 : h2;
}

string getType(int n){
  if(nodes[n].parent == -1)return "root";

  if(nodes[n].left == -1 && nodes[n].right == - 1)return "leaf";

  return "internal node";
}

int getDegree(int n){
  if(nodes[n].left == -1 && nodes[n].right == -1){
    return 0;
  }else if(nodes[n].left != -1 && nodes[n].right != -1){
    return 2;
  }else{
    return 1;
  }
}
int getSibling(int n){
  if(nodes[n].parent == -1){
    return -1;
  }else if(nodes[nodes[n].parent].left == n && nodes[nodes[n].parent].right != -1){
    return nodes[nodes[n].parent].right;
  }else if(nodes[nodes[n].parent].right == n && nodes[nodes[n].parent].left != -1){
    return nodes[nodes[n].parent].left;
  }

  return -1;
}

int main(){
  cin >> N;

  nodes.resize(N);
  H.resize(N);
  D.resize(N);

  REP(i,N)nodes[i].parent = -1;

  REP(i,N){
    int n,l,r;
    cin >> n >> l >> r;
    nodes[n].left = l;
    nodes[n].right = r;
    nodes[l].parent = n;
    nodes[r].parent = n;
  }

  int root;
  REP(i,N) if(nodes[i].parent == -1)root = i;

  setDepth(root,0);
  setHeight(root);

  REP(i,N){
    printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, %s\n", 
    i, nodes[i].parent, getSibling(i), getDegree(i), D[i], H[i], getType(i).c_str());
  }
}


Measured memory_bytes: 3336
readline
ts = readline.split.map{|n|n.to_i*2} + [1]
vs = readline.split.map{|n|n.to_i*2} + [0]

total_t = ts.reduce(:+)
result = Array.new(total_t+1){0}

sum = 0
cums = ts.map{|n| sum+=n}

i = 0

(1..total_t-1).each{|now|
  if now == cums[i] then
    i+=1
    reg_v = [vs[i],vs[i-1]].min
  else
    reg_v = vs[i]
  end
  prev_v = result[now-1]
  room_v = reg_v - prev_v
  result[now] = if room_v >= 1
    prev_v + 1
  elsif room_v == 0
    prev_v
  elsif room_v == -1
    prev_v -1
  else
    back_v = reg_v
    [*0..now-1].reverse.each{|back|
      back_v += 1
      if back_v >= result[back]
        break
      else
        result[back] = back_v
      end
    }
    reg_v
  end
}

res = result.each_cons(2).map{|(a, b)|
  (a + b) * 0.5 /2 /2
}.reduce(:+)

p res

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

#define ull unsigned long long

struct fenwick_tree {
  // using U = internal::to_unsigned_t<T>;
  // using U = T;
 private:
  int _n;
  std::vector<ull> data;

  ull sum(int r) {
    ull s = 0;
    while (r > 0) {
      s += data[r - 1];
      r -= r & -r;
    }
    return s;
  }

 public:
  fenwick_tree() : _n(0) {}
  fenwick_tree(int n) : _n(n), data(n) {}

  void add(int p, ll x) {
    assert(0 <= p && p < _n);
    p++;
    while (p <= _n) {
      data[p - 1] += (ull)(x);
      p += p & -p;
    }
  }

  ll sum(int l, int r) {
    assert(0 <= l && l <= r && r <= _n);
    return sum(r) - sum(l);
  }
};

using namespace std;
// using namespace atcoder;

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

  fenwick_tree fw(N);

  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    fw.add(i, v);
  }

  for (ll i = 0; i < Q; i++) {
    ll a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);

    if (a == 0) {
      fw.add(b, c);
    } else {
      cout << (fw.sum(b, c)) << endl;
    }
  }

  // cout << (fw.sum(0, 9)) << endl;  // 0
  // fw.add(0, 1);
  // fw.add(3, 2);
  // fw.add(5, 3);
  // fw.add(7, 4);
  // fw.add(9, 5);
  // cout << (fw.sum(0, 9)) << endl;   // 10
  // cout << (fw.sum(0, 5)) << endl;   // 3 // [5]は含まない
  // cout << (fw.sum(5, 10)) << endl;  // 7

  // for (int i = 0; i < n; i++) {
  //   int a;
  //   scanf("%d", &a);
  //   fw.add(i, a);
  // }

  // for (int i = 0; i < q; i++) {
  //   int t;
  //   scanf("%d", &t);
  //   if (t == 0) {
  //     int p, x;
  //     scanf("%d %d", &p, &x);
  //     fw.add(p, x);
  //   } else {
  //     int l, r;
  //     scanf("%d %d", &l, &r);
  //     printf("%lld\n", fw.sum(l, r));
  //   }
  // }
}


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

int main(){
int n;cin>>n;
  int x=n;
  int fx;
  while(n>0)
  {
    fx+=n%10;
    n=n/10;
    
    
  }
 
  if(x%fx==0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
}
}
  
    
  


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    string s;
    cin >> s;
    int l = s.size();
    string t = "";
    rep(i, l) {
        if(s[i] == '0') t += '0';
        else if(s[i] == '1') t += '1';
        else {
            if(t.empty()) continue;
            else t.pop_back();
        }
    }
    cout << t << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int absyai(int a){return a<0?-a:a;}

int H(int x,int y,int i,int j,int h){
    return h-absyai(x-i)-absyai(y-j)>0?h-absyai(x-i)-absyai(y-j):0;
}

int main(void){
    int N;
    scanf("%d",&N);
    int x[N],y[N],h[N];
    int ok;
    for(int i=0;i<N;i++){
        scanf("%d%d%d",&x[i],&y[i],&h[i]);
        if(h[i]!=0)ok=i;
    }
    for(int i=0;i<=100;i++)for(int j=0;j<=100;j++){
        int unti=h[ok]+absyai(x[ok]-i)+absyai(y[ok]-j);
        int flag=1;
        for(int k=0;k<N;k++){
            if(H(x[k],y[k],i,j,unti)!=h[k])flag=0;
        }
        if(flag==1){
            printf("%d %d %d",i,j,unti);
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int MOD = 1e9 + 7;
int main() {
	int N, K;
	cin >> N >> K;
	ll ans = 0;
	for (int b = 1; b <= N; b++) {
		int x = N / b, y = N % b;
		if (b >= K)ans += x * (b - K);
		if (y >= K)ans += y - K + 1;
	}
	if(K==0)ans -= N;
	cout << ans << endl;
}

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

int query(int i, int j) {
	cout << "? " << i << " " << j << endl;
	cout.flush();
	int data;
	cin >> data;
	return data;
} 

void output(vector<int> ans) {
	cout << "!" ;
	for(int i=0; i<ans.size() ; i++) {
		cout <<" "<< ans[i]  ;
		
	}
	cout << endl;
}
 

int main() {
	int N;
	cin >> N;
	int maxim = -1;
	int cand = -1;
	for(int i=1; i<=N; i++) {
		int dist = query(1,i);
		if(dist > maxim) {
			maxim = dist;
			cand = i;
		}
	}
	vector<int> ans(N,0);
	for(int i=1; i<=N; i++) {
		int dist = query(cand, i);
		ans[dist] = i;
	}
 	output(ans);
	
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin>>K;
  int countodd = 0;
  int counteven = 0;
  for(int i=1;i<=K;i++){
    if(i%2==0){
      counteven++;
    }
    else{
      countodd++;
    }
  }
  cout<<countodd*counteven<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.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 ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int n, m; cin >> n >> m;
  vvi adj(n,vi(n));
  int a, b;
  rep(i,m){
    cin >> a >> b;
    a--; b--;
    adj[a][b] = adj[b][a] = 1;
  }

  vi path(n-1);
  iota(all(path),1);
  int prev, ans = 0;
  bool f;
  do{
    f = true;
    prev = 0;
    rep(i,path.size())
      if(adj[prev][path[i]] == 1) prev = path[i];
      else f = false;
    if(f){
      ans++;
    }
  }while(next_permutation(all(path)));
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
import math

def main():

    input = sys.stdin.readline

    a,b = map(int, input().split())
    a_total = 1 
    ans = 0
    while (a_total < b):
        a_total += a-1
        ans +=1
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 8764
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
sys.setrecursionlimit(10**9)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

R,G,B,N = imn()

cnt = 0
for i in range(0,N+1):
    if i*R > N: break
    for j in range(0, N+1-i):
        if i*R + j*G > N: break
        if (N - (i*R + j*G)) % B == 0: cnt += 1
print(cnt)


Measured memory_bytes: 66408
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int Pow(int a, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1)ans *= a;
		a *= a;
		n >>= 1;
	}
	return ans;
}

int main() {
	int x;
	while (cin >> x) {
		bitset<10> b = x;
		VI print;
		rep(i, 10) {
			if (b.test(i))print.pb(Pow(2, i));
		}
		rep(i, sz(print)) {
			cout << print[i];
			printf(i == sz(print) - 1 ? "\n" : " ");
		}
	}
}


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

using namespace std;

typedef long long LL;

struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define fin "\n"


#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)

template <typename T>
inline void chmin(T &l,T r){l=min(l,r);}

template <typename T>
inline void chmax(T &l,T r){l=max(l,r);}

LL pow(LL a,LL n){
    LL res=1;
    while(n){
        if(n&1)res*=a;
        a=a*a;
        n>>=1;
    }
    return res;
}
int main(){
    LL N,A;
    cin>>N>>A;
    LL res=N;
    FOR(k,2,40){
        LL i=1;
        for(;pow(i+1,k)<N;i++);
        LL m=pow(i,k);
        LL ans=i*k+A*(k-1);
        while(m<N){
            m/=i;
            m*=i+1;
            ans++;
        }
        chmin(res,ans);
    }
    cout<<res<<endl;
    
    return 0;
}


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

int main()
{
	int a, b, c;
	int x;
	int n=0;

	while (1)
	{
		cin >> a >> b >> c;
		if (a <= b)
			break;
	}

	for (x = a; x <= b; x++){
		if (c%x==0)
			n++;
	}

	cout << n << endl;

	return 0;
}

Measured memory_bytes: 1160
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
	si.Scan()
	r, _ := strconv.Atoi(si.Text())
	return r
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func main() {
	si.Split(bufio.ScanWords)
	si.Buffer(make([]byte, 0), 10000000)

	var T, x, y [100001]int
	ans := true
	N := readInt()
	for i := 1; i <= N; i++ {
		T[i], x[i], y[i] = readInt(), readInt(), readInt()
	}
	for i := 0; i < N; i++ {
		t := T[i+1] - T[i]
		l := abs(x[i+1]-x[i]) + abs(y[i+1]-y[i])
		if t < l {
			ans = false
			break
		}
		if (t-l)%2 != 0 {
			ans = false
			break
		}
	}
	if ans {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int case1(int h, int w){
  if(h<3) return INT_MAX;
  int i=h/3, j=(h-i)/2, k=h-i-j;
  return (k-i)*w;
}

int case2(int h, int w){
  int i=w/3, j=h/2;
  int a=(h-j)*(w-i)-min(i*h, j*(w-i));
  i+=1;
  int s1=i*h, s2=j*(w-i), s3=(h-j)*(w-i);
  int b;
  if(s1<s2) b=s3-s1;
  else if(s1>s3) b=s1-s2;
  else b=s3-s2;
  return min(a,b);
}

int main(){
  int h,w;
  cin >> h >> w;
  if(!(h%3) || !(w%3)){
    cout << "0" << endl;
    return 0;
  }
  int minS=INT_MAX;
  minS=min(minS,case1(h,w));
  minS=min(minS,case2(h,w));
  minS=min(minS,case1(w,h));
  minS=min(minS,case2(w,h));

  cout << minS << endl;
}


Measured memory_bytes: 764
#include <stdio.h>

int main(int argc, const char * argv[])
{
    int i = 0, data, a, b, c;
    scanf("%d\n", &data);
    while (i < data) {
        scanf("%d %d %d",&a ,&b ,&c);
        if (a * a == b * b + c * c || b * b == a * a + c * c || c * c == a * a + b * b) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 580
n, m = gets.split.map(&:to_i)
student = []
n.times do
  student << gets.split.map(&:to_i)
end
checkpoint = []
m.times do
  checkpoint << gets.split.map(&:to_i)
end

n.times do |i|
  ans = 0
  min = 10 ** 9
  m.times do |j|
    d = (student[i][0] - checkpoint[j][0]).abs + (student[i][1] - checkpoint[j][1]).abs
    if d < min
      min = d
      ans = j + 1
    end
  end
  puts ans
end


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

int main() {
  string s;
  cin >> s;
  int sum = 0;
  int ans = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'R') {
      sum++;
      ans = max(ans, sum);
    }
    else sum = 0;
  }
  
  cout << ans;
}

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

int main(void){
    int N, Abuf, Bbuf;
    vector<int> A, B;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> Abuf >> Bbuf;
        A.push_back(Abuf);
        B.push_back(Bbuf);
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    if(N%2 == 0){
        cout << B[N/2-1]+B[N/2]-A[N/2-1]-A[N/2]+1 << endl;
    }else{
        cout << B[(N-1)/2]-A[(N-1)/2]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 5092
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#define h 1000010
#define ll long long
#define pb push_back
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll int n, m, i, cnt=0;
  cin>>n;
  for(i=0;i<n;i++) 
  {
  	cin>>m;
  	if(i%2==0 && m%2==1)cnt++;
 } 
  cout<<cnt<<endl;
  return 0;
} 


Measured memory_bytes: 3648
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let n: u64 = read();
    if n % 2 == 1 {
        println!("0");
    } else {
        let mut ans = 0;
        let mut p5 = 1;
        loop {
            p5 *= 5;
            let tmp = (n / p5) / 2;
            if tmp == 0 {
                break;
            }
            ans += tmp;
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 4352
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	long long ans;
	char c;
	long long n;
	cin>>ans;
	while(cin>>c,c!='='){
		cin>>n;
		if(c=='+')ans+=n;
		else if(c=='-')ans-=n;
		else if(c=='*')ans*=n;
		else if(c=='/')ans/=n;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1156
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll A, B, K; cin >> A >> B >> K;
    ll X = min(A, K);
    A -= X; K -= X;
    X = min(B, K);
    B -= X;
    cout << A << " " << B << endl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n;
	scanf("%d",&n);
	if(n<=111){
		n=111;
	}else if(n<=222){
		n=222;
	}else if(n<=333){
		n=333;
	}else if(n<=444){
		n=444;
	}else if(n<=555){
		n=555;
	}else if(n<=666){
		n=666;
	}else if(n<=777){
		n=777;
	}else if(n<=888){
		n=888;
	}else{
		n=999;
	}
	printf("%d",n);
	return 0;
}

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

unsigned long long fight(unsigned long long N){
  unsigned long long result=0;
  if (N==1) return 1;
  else{
    // if caracal attacks, the enemy splits into two. i.e. the number of attacks would be doubled.
    // Note that one attack is required to split the enemy.
    return result+=2*fight(N/2)+1;
  }  
}
 
int main(){
  unsigned long long H;
  cin >>H;
  cout << fight(H) <<endl;
}

Measured memory_bytes: 256
let solve n k =
  let rec aux res n =
    if n = 0 then res else begin
      if res < k then aux (res * 2) (n - 1)
      else aux (res + k) (n - 1)
    end in
  aux 1 n

let () = 
  Scanf.scanf "%d\n%d" solve |> print_int ;
  print_newline ()

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

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

const int MOD = 1000000007;

struct Pony
{
    long a, b;
 
    Pony(long a_, long b_)
    {
        a = a_;
        b = b_;
    }
 
    bool operator<(const Pony &another) const
    {
        return b < another.b;
    };
};

int fac(int k){
    int sum = 0;
    for (int i = 1; i <= k; ++i)
    {
        sum += i;
    }
    return sum;
}

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

  int n,d;

  cin >> n >> d;

  cout << ceil((double)n/(double)(d*2+1)) <<endl;
}


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

int main() {
  string s;
  cin >> s;
  int c=0;
    for (int i=0;i<3;i++){
      if (s[i]=='o'){
        c=c+1;
      }
    }
  cout <<700+c*100<<endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;

int main() {
	cout << fixed << setprecision(0);
	int N, M;
	cin >> N >> M;
	double passable = pow(0.5, M);
	//1回で通る確率:
	double pass = 0;
	for (size_t i = 1; i<550; i++)
	{
		pass += (double)((N-M)*100+M * 1900)*i * pow((1.0 - passable), i - 1) * passable;
		//100 5cout << pass << endl;
	}
	
	cout << pass;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int n;
    cin >> n;
    if (n >= 3)         cout << 0 << endl;
    else if (n == 1)    cout << 2 << endl;
    else                cout << 1 << endl;
}

Measured memory_bytes: 3152
import sys
texts=sys.stdin.read()
texts=texts.lower()
cnt=[0]*26

letters=list('abcdefghijklmnopqrstuvwxyz')
for x in texts:
    i=0
    for y in letters:
        if x==y:
            cnt[i]+=1
        i+=1
for i in range(26):
    print(letters[i]+" : "+str(cnt[i]))


Measured memory_bytes: 5560
from math import cos, pi

A, B, H, M = map(int, input().split())

t1 = 30 * H + M / 60 * 30
t2 = 6 * M
ans = A ** 2 + B ** 2 - 2 * A * B * cos(abs(t1 - t2) * pi / 180)
print(ans ** 0.5)


Measured memory_bytes: 62688
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,b ;
    
  cin >> a >> b;
  
  int c=a*b ;
  
  
  if (c% 2 ==0){
	cout << "Even" <<endl;
  }
  else {
    cout << "Odd" << endl;
  }
  }
    

Measured memory_bytes: 256
def main():
    N = int(input())
    P_list = list(map(int,input().split()))
    i_num = 0
    min_P = P_list[0]
    for p in P_list:
        if p <= min_P:
            min_P = p
            i_num += 1
    print(i_num)

if __name__ == "__main__":
    main()

Measured memory_bytes: 26012
N = int(input())
S1 = input()
S2 = input()
MOD = 1000000007

c = 0
ans = 1
if S1[c] == S2[c]:
    ans *= 3
    c += 1
else:
    ans *= 6
    c += 2
while c < N:
    if S1[c] == S2[c]:
        ans *= 2 if S1[c - 1] == S2[c - 1] else 1
        c += 1
    else:
        ans *= 2 if S1[c - 1] == S2[c - 1] else 3
        c += 2
    ans %= MOD
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
	int i, N, flag = 0;
	long long A, ans = 1;
	long double X = 1.0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%lld", &A);
		if (A == 0) {
			flag = 0;
			ans = 0;
			break;
		}
		ans *= A;
		X *= A;
		if (X > 1e+18) flag = 1;
	}
	if (flag == 0) printf("%lld\n", ans);
	else printf("-1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1704
n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
	s,c=map(int,input().split())
	if a[s-1]==-1 or a[s-1]==c:
		a[s-1]=c
	else:
		print(-1)
		exit()

for i in range(n-1):
	if a[i]==0:
		print(-1)
		exit()
	else:
		break
if n==1:
	if a[0]==-1:
		print(0)
	else:
		print(a[0])
	exit()
ans=0
f=0
for i in range(n):
	if a[i]==-1:
		if f:
			a[i]=0
		else:
			a[i]=1
			f=1
	else:
		f=1
ans=""
for i in range(n):
	ans+=str(a[i])
print(ans)


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

int main() {
  int R;
  cin>>R;
  string ans;
  if (R<1200) {
    ans="ABC";
  }
  else if (R<2800) {
    ans="ARC";
  }
  else {
    ans="AGC";
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void){
    
   string a,b;
   cin >> a >> b;
   if(a.size() > b.size()){
       cout << "GREATER" << endl;
   }
   else if(a.size() < b.size()){
       cout << "LESS" << endl;
   }
   else{
       string ans = "EQUAL";
       int size = a.size();
       
       for(int i=0;i<size;i++){
           if(a[i] > b[i]){
               ans = "GREATER";
               break;
           }
           else if(a[i] < b[i]){
               ans = "LESS";
               break;
           }
       }
       cout << ans << endl;
   }
}

Measured memory_bytes: 3600
A, B, C = sorted(list(map(int, input().split())))
#print(A,B,C)

dA = C - A
dB = C - B

ans = 0
if dA%2==0 and dB%2!=0:
    A += 1
    C += 1
    ans += 1
elif dA%2!=0 and dB%2==0:
    B += 1
    C += 1
    ans += 1
elif dA%2!=0 and dB%2!=0:
    A += 1
    B += 1
    ans += 1

dA = C - A
dB = C - B
ans += dA//2 + dB//2

print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
    int x[5];
    scanf("%d %d %d %d %d", &x[0], &x[1], &x[2], &x[3], &x[4]);
    
    for (int i = 0; i < 5; i++)
    {
        if (x[i] == 0)
        {
            printf("%d\n", (i + 1));
        }
        else
        {
            continue;
        }
    }
    return 0;
}

Measured memory_bytes: 2148
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func getInput() ([]int, bool) {
	sc.Split(bufio.ScanWords)

	// read num of input.
	N := 0
	if sc.Scan() {
		n, err := strconv.Atoi(sc.Text())
		if err != nil {
			return nil, false
		}
		N = n
	}

	A := make([]int, N)
	for i := range A {
		if !sc.Scan() {
			return nil, false
		}
		a, err := strconv.Atoi(sc.Text())
		if err != nil {
			return nil, false
		}
		A[i] = a
	}
	return A, true
}

func main() {

	A, b := getInput()
	if !b {
		return
	}

	num := 0
	for {
		isAllEnv := true
		for i := range A {
			// 奇数
			if A[i]&0x00000001 == 1 {
				isAllEnv = false
				break
			}
			A[i] = A[i] >> 1
		}
		if !isAllEnv {
			break
		}
		num++
	}

	fmt.Println(num)
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>

typedef long long int lli;
char prime[8000000];

int main(void) {
    while(1) {
        lli m,n;
        scanf("%lld%lld",&m,&n);
        if(!m) break;

        memset(prime, 1, sizeof(prime));
        prime[0] = prime[1] = 0;
        lli cnt=0;
        lli i;
        for(i=m; cnt<=n; i++)
            if(prime[i]) {
                cnt++;
                for(lli j=2; i*j<8000000; j++)
                    prime[i*j] = 0;
            }
        printf("%lld\n",i-1);
    }
    return 0;
}

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

int main(){
  int H, W;
  cin >> H >> W;
  char A[H+2][W+2];
  for(int i=0;i<=H+1;i++){
    for(int j=0;j<=W+1;j++){
      A[i][j] = '#';
    }
  }
  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
    cin >> A[i][j];
    }
  }
  for(int i=0;i<=H+1;i++){
    for(int j=0;j<=W+1;j++){
      cout << A[i][j];
    }
    cout << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;

int main() {
  string s;
  cin >> s;
  vector<char> v;
  map<char, int> mp;
  rep(i, 4) {
    if(mp[s[i]] == 0) {
      v.push_back(s[i]);
    }
    mp[s[i]]++;
  }
  if(v.size() != 2) cout << "No" << endl;
  else {
    bool f = true;
    rep(i, v.size()) {
      if(mp[v[i]] != 2) f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  string S; cin >> S;
  map<char, int> m;
  m['N'] = 0; m['S'] = 0; m['E'] = 0; m['W'] = 0;
  REP(i, S.size()) {
    m[S[i]]++;
  }
  if((m['N'] > 0 && m['S'] > 0 && m['E'] == 0 && m['W'] == 0) || 
     (m['N'] == 0 && m['S'] == 0 && m['E'] > 0 && m['W'] > 0) ||
     (m['N'] > 0 && m['S'] > 0 && m['E'] > 0 && m['W'] > 0) ) {
       cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

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

  sort(p, &p[N]);
  int ans = 0;
  for(int i = 0; i < N; i++){
    if(i == N-1) p[i] /= 2;
    ans += p[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
N,M=list(map(int,input().split()))
A=list(map(int,input().split()))
limit=sum(A)/(4*M)
A.sort()
c=0
for a in A:
  if a >= limit:
    c+=1
    if c==M:
      break
if c==M:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 38384