akhauriyash/Code-Regression huggingface dataset:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from heapq import heappush, heappop

def dijkstra(graph:list, node:int, start:int) -> list:
    # 未探索のノードは距離INF
    INF = float("inf")
    dist = [INF]*node
    
    # 始点ノードの距離を0とし、dfsのためのpriority queを作成
    dist[start] = 0
    heap = [(0,start)]
    
    # 未探索のノードをpriority queueに入れる
    while heap:
        cost, cur_node = heappop(heap)
        
        for nex_cost, nex_node in graph[cur_node]:
            dist_cand = dist[cur_node] + nex_cost
            if dist_cand < dist[nex_node]:
                dist[nex_node] = dist_cand
                heappush(heap, (dist[nex_node], nex_node))
    
    return dist

n = ni()
abc = []
for _ in range(n-1):
    a,b,c = li()
    a -= 1
    b -= 1
    abc.append((a,b,c))
q,k = li()
k -= 1
query = [li_() for _ in range(q)]

# 隣接リストつくる
graph = [[] for _ in range(n)]
for frm,to,cost in abc:
    graph[frm].append((cost,to))
    graph[to].append((cost,frm))

# 頂点Kをスタートとするダイクストラ
dist = dijkstra(graph, n, k)

# クエリ処理
for frm,to in query:
    print(dist[frm] + dist[to])

Measured memory_bytes: 113816
#include <iostream>

int main()
{
	int n, m, l;
	int matA[100][100], matB[100][100];
	long int matC[100][100] = {};
	std::cin >> n >> m >> l;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			std::cin >> matA[i][j];
		}
	}
	for (int i = 0; i < m; ++i) {
		for (int j = 0; j < l; ++j) {
			std::cin >> matB[i][j];
		}
	}

	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < l; ++j) {
			//行列の要素計算
			for (int k = 0; k < m; ++k) {
				matC[i][j] += matA[i][k] * matB[k][j];
			}
			if(j == 0)
				std::cout << matC[i][j];
			else
				std::cout << " " << matC[i][j];
			
		}
		std::cout << std::endl;
	}
}



Measured memory_bytes: 3212
#pragma GCC optimize("Ofast")
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define yzh 2333333
#define bql 2147483647
using namespace std;
int r,g,b,n;
long long ans;
int main()
{
	  fast;
    cin>>r>>g>>b>>n;
    for (int i=0;i<=n;i++)
       for (int j=0;j<=n;j++)
          if ((n-(i*r+j*g))%b==0 && n>=(i*r+j*g))
					   ans++;
    cout<<ans<<endl;
    return 0;
}


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

using ll=long long;
using Graph=map<ll,vector<ll>>;
int main(){
    ll n,w,h;
    cin>>n>>w>>h;
    bool sumi=false;
    Graph g;
    for(int i=0;i<n;i++){
        ll x,y;
        cin>>x>>y;
        if(x==1 || x==w || y==1 || y==h) sumi=true;
        x--,y--;
        ll from=x*h+y;
        ll to0=h*w+x;
        ll to1=h*w+w+y;
        g[from].push_back(to0);
        g[from].push_back(to1);
        g[to0].push_back(from);
        g[to1].push_back(from);
    }
    set<ll> s;
    int cnt=0;

    function<void(ll)> dfs=[&](ll v){
        if(s.count(v)) return;
        s.insert(v);
        for(auto &to:g[v]) dfs(to);
    };
    for(auto &vertex:g){
        ll v=vertex.first;
        if(!s.count(v)){
            cnt++;
            dfs(v);
        }
    }
    if(cnt==1){
        cout<<n-1<<endl;
    }
    else{
        if(sumi) cout<<n-1+cnt-1<<endl;
        else cout<<n-1+cnt<<endl;
    }
    return 0;
    
    return 0;
}


Measured memory_bytes: 19712
def m():
    N, X, Y = map(int, input().split())
    ans = [0] * (N+1)
    for i in range(1, N + 1):
        for j in range(1, N + 1):
            p = min(abs(j - i), abs(X - i) + 1 + abs(Y - j), abs(Y - i) + 1 + abs(X - j))
            ans[p] += 1
    for a in range(1, N):
        print(ans[a]//2)

m()


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define repi(i, n) for(int i=0;i<(int)(n);i++)
#define rep2i(i, s, n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

const ll INF = (1LL<<60);
const int INFi = (1<<29);

int main(){

    ll l, r; cin >> l >> r;

    ll ii, jj, ans = INF;
    for(ll i=l, ii=0;(i<=r-1)&&(ii<2019);i++, ii++){
        for(ll j=i+1, jj=0;(j<=r)&&(jj<2019);j++,  jj++){
            ans = min(ans, (i*j)%2019);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
const int N=100100,M=400400;
int i,j,k,n,m,ch,ff,Fg,En;
int a[N],h[N],z[N];
struct edge { int s,n,v;} E[M];
void R(int &x) {
	ff=x=0;ch=getchar();
	while (ch<'0' || '9'<ch) { if (ch=='-') ff=1;ch=getchar();}
	while ('0'<=ch && ch<='9') x=x*10+ch-'0',ch=getchar();
	if (ff) x=-x;
}
void W(int x) {
	if (x<0) putchar('-'),x=-x;
	if (x>=10) W(x/10);
	putchar(x%10+'0');
}
void E_add(int x,int y,int v) {
	E[++En].s=y;E[En].v=v;
	E[En].n=h[x];h[x]=En;
	E[++En].s=x;E[En].v=-v;
	E[En].n=h[y];h[y]=En;
}
void dfs(int x) {
	z[x]=1;
	for (int k=h[x];k;k=E[k].n) {
		if (!z[E[k].s]) {
			a[E[k].s]=a[x]+E[k].v;
			dfs(E[k].s);
		}
		else {
			if (a[E[k].s]!=a[x]+E[k].v) Fg=1;
		}
	}
}
int main() {
	R(n);R(m);
	for (i=1;i<=m;i++) {
		int x,y,v;
		R(x);R(y);R(v);
		E_add(x,y,v);
	}
	for (i=1;i<=n;i++) if (!z[i]) dfs(i);
	if (Fg) puts("No");
	else puts("Yes");
} 

Measured memory_bytes: 8448
#include <iostream>
using namespace std;
int a[200005];
int main() {
    int n, odd = 0, even = 0;
    cin >> n;
    for(int i = 1; i <= n; i++)
        cin >> a[i], odd += (a[i] % 2 == 0), even += (a[i] % 2 == 1);
 //   cout << odd << " " << even << endl;
    if(odd == 0 || even == 0)
        cout << "0" << endl;
    else if(even % 2 == 0)
        cout << n - 2 << endl;
    else
        cout << n - 1 << endl;
    return 0;
}



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

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
// #define MOD 1000000007
#define MOD 998244353 
#define MEM_SIZE 101010
#define DEBUG_OUT true

#define ALL(x) (x).begin(), (x).end()


template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n,x,t;
  cin>>n>>x>>t;
  cout<<(n/x + (n%x > 0))*t<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3636
local n, a, b, c = io.read("*n", "*n", "*n", "*n")
local t = {}
for i = 1, n do
  t[i] = io.read("*n")
end
local minscore = 3000
local tot = 4^n
local mabs, mmin = math.abs, math.min
for i = 0, tot - 1 do
  local ti = i
  local score = 0
  local ts = {0, 0, 0}
  for j = 1, n do
    local rem = ti % 4
    if(0 < rem) then
      if(ts[rem] == 0) then ts[rem] = t[j]
      else ts[rem] = ts[rem] + t[j]; score = score + 10 end
    end
    ti = ti // 4
  end
  score = score + mabs(a - ts[1]) + mabs(b - ts[2]) + mabs(c - ts[3])
  if(0 < ts[1] * ts[2] * ts[3]) then
    minscore = mmin(minscore, score)
  end
end
print(minscore)


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

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin>>s;
    ll n = s.size();
    vector<ll> cum_sum;
    cum_sum.push_back(0); //cum_sum stores cumulative sum assuming 0s and ?s are -1
    for(auto c:s)
        cum_sum.push_back(cum_sum.back() + (c=='1'?1:-1));
    vector<ll> max_sum_to_right = cum_sum;
    for(ll i=n-1;i>=0;i--)
        max_sum_to_right[i] = max(max_sum_to_right[i],max_sum_to_right[i+1]);
    
    ll mx = -1;
    for(ll i=0;i<=n;i++)
        mx = max(mx,cum_sum[i]);
    ll ans = INT64_MAX;
    for(ll random_variable=0;random_variable<2;random_variable++){
        ll cur = 0,mn = 0;
        for(ll i=0;i<n;i++){
            if(s[i] == '?'){
                if(cur + max_sum_to_right[i+1] - cum_sum[i] +2 <=mx)
                    cur++;
                else
                    cur--;
            }
            else if(s[i] == '0')
                cur--;
            else 
                cur++;
            mn = min(mn,cur);
        }
        ans = min(ans,mx-mn);
        mx++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n, k, x;
    int d = 0, m = 0;
    
    cin>>n>>k;
    
    while (n--)
	{
		cin>>x;
		d = __gcd(d, x);
		m = max(m, x);
	}
	
	cout<<(k % d || k > m ? "IMPOSSIBLE" : "POSSIBLE")<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define N 1005
#define M 2005

using namespace std;

int n, m;
int dep[N];
int head[N], nex[M], to[M], e;
int stk[N], top;
bool instack[N], vis[N], G[N][N];
vector<int> res;

inline int Rd() {
    int x = 0;
    char ch = getchar();
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
    return x;
}
inline void Ae(int u, int v) {
    nex[++e] = head[u], head[u] = e;
    to[e] = v;
}

void calc(int u, int v) {
    do {
        res.push_back(stk[top]);
    } while (stk[top--] != v);
    int ans = res.size();
    printf("%d\n", ans);
    for (int i = 0; i < ans; ++i) printf("%d\n", res[i]);
    exit(0);
}
void dfs(int u) {
    stk[++top] = u;
    instack[u] = vis[u] = true;
    for (int i = head[u]; i; i = nex[i]) {
        int v = to[i];
        if (vis[v]) {
            if (instack[v])
                calc(u, v);
        } else {
            dfs(v);
        }
    }
    instack[u] = false, --top;
    return;
}

int main() {
    n = Rd(), m = Rd();
    for (int i = 1; i <= m; ++i) {
        int u = Rd(), v = Rd();
        G[u][v] = true;
        Ae(u, v);
    }

    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            if (G[i][j] && G[j][i]) {
                puts("2");
                printf("%d\n%d\n", i, j);
                return 0;
            }
        }
    }
    for (int i = 1; i <= n; ++i)
        if (!vis[i])
            dfs(i);
    puts("-1");
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
#define ull unsigned long long int
using namespace std;

ll n,m,ar[N],sum,t;

string s[N],ans[N];

map<string,int> mark,vis;

int main()
{
	fast;
	cin>>n;
	int mk=0;
	fo(i,1,n)
	{
		cin>>s[i],mark[s[i]]++;
		mk=max(mark[s[i]],mk);
	}
	fo(i,1,n)
		if(mark[s[i]]==mk && !vis[s[i]])
		{
			vis[s[i]]++;
			sum++;
			ans[sum]=s[i];
		}
	sort(ans+1,ans+sum+1);
	for(int i=1;i<=sum;i++)
		cout<<ans[i]<<endl;

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 52864
/*
    Author: Jerry Yang C.H. (tico88612)
    Date: 2019/12/20
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef pair<double,double> pdd;
#define SQ(i) ((i)*(i))
#define MEM(a, b) memset(a, (b), sizeof(a))
#define SZ(i) int(i.size())
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define REP1(i,j) FOR(i, 1, j+1, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define ALL(_a) _a.begin(),_a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define X first
#define Y second
#ifdef tmd
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,deque<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
#endif

const ll MOD = 1000000007;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int iNF = 0x3f3f3f3f;
// const ll MAXN = 

/********** Good Luck :) **********/
int main()
{
    IOS();
    ll findd[2] = {-1, -1};
    int N;
    cin >> N;
    vector<ll> enter(N);
    REP(i, N){
        cin >> enter[i];
    }
    sort(ALL(enter));
    int f = 0;
    for(int i = N - 1; i >= 1 && f < 2; i--){
        if(enter[i] == enter[i - 1]){
            findd[f] = enter[i];
            i--;
            f++;
        }
    }
    if(f == 2)
        cout << (ll)(findd[0] * findd[1]) << '\n';
    else
        cout << "0" << '\n';
    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int N;  cin >> N;
    int div_four = 0, div_two = 0, div_else = 0;
    for(int i = 0 ; i < N ; i++){
        int a;  cin >> a;
        if(a % 4 == 0){ div_four += 1;  continue; }
        else if(a % 2 == 0){ div_two += 1;  continue; }
        else{ div_else += 1;  continue; }
    }

    if(div_two == 0){
      if(div_four - div_else + 1 < 0)  cout << "No" << endl;
      else                             cout << "Yes" << endl;
    }else{
      if(div_four < div_else)          cout << "No" << endl;
      else                             cout << "Yes" << endl;
    }

    return 0;
}

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

int main() {
	int a, b;

	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else if (a == b) {
		cout << "a == b" << endl;
	}

	return 0;
}


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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> ans(n, -1);
  bool no = false;
  for (int i=0; i<m; i++){
    int s, c;
    cin >> s >> c;
    s--;
    if (ans[s] != -1 && ans[s] != c){
      no = true;
      continue;
    }
    ans[s] = c;
  }
  if (ans[0] == 0 && n != 1) no = true;
  if (no){
    cout << -1 << endl;
  }
  else{
    for (int i=0; i<n; i++){
      if(ans[i] == -1){
        if (i == 0 && n != 1){
          ans[i] = 1;
        }
        else{
          ans[i] = 0;
        }
      }
      cout << ans[i];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
 
typedef signed long long ll;
const int MX = 1e6 + 5;

int main() {
	string S;
	int n, cnt = 0;
	cin >> S;
	n = S.size();
	for(int i = 0, j = n - 1; i < j; i++, j--) {
		if(S[i] != S[j]) cnt++;
	}
	cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int N, X, T;
		cin >> N >> X >> T;
		cout << (N+X-1)/X * T << endl;
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


Measured memory_bytes: 3572
#include<stdio.h>
int main()
{
    long long int a,b,c;
    char s;
    scanf("%lld %c %lld",&a,&s,&b);
    if(s=='+')
    {
        c=a+b;
        printf("%lld\n",c);
    }
    else if(s=='-')
    {
        c=a-b;
        printf("%lld\n",c);
    }
    return 0;
}

Measured memory_bytes: 128
a, b, c, d = map(int, input().split())
answer = 0

if a < 0 and 0 <= b:
    if c < 0 and 0 <= d:
        answer = max(a * c, b * d)
    elif 0 <= c and 0 <= d:
        answer = b * d 
    elif c < 0 and d < 0:
        answer = a * c

elif 0 <= a and 0 <= b:
    if c < 0 and 0 <= d:
        answer = b * d
    elif 0 <= c and 0 <= d:
        answer = b * d
    elif c < 0 and d < 0:
        answer = a * d

elif a < 0 and b < 0:
    if c < 0 and 0 <= d:
        answer = a * c
    elif 0 <= c and 0 <= d:
        answer = b * c
    elif c < 0 and d < 0:
        answer = a * c

print(answer)

Measured memory_bytes: 9228
#include<bits/stdc++.h>
#define ddd printf("ddd\n")
#define see(x) (cerr<<(#x)<<'='<<(x)<<endl)
using namespace std;

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

const int maxn = 1e5+20;
const int inf = 0x3f3f3f3f;
const int modd = 1e9+7;

inline int read() {int x=0,f=1;char c=getchar();while(c!='-'&&(c<'0'||c>'9'))c=getchar();if(c=='-')f=-1,c=getchar();while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return f*x;}
template <class T> inline void sc(T &x){char c;x=0;while((c=getchar())<'0');while(c>='0'&&c<='9')x=x*10+(c-48),c=getchar();}
inline ll gcd(ll a,ll b){ return b==0? a: gcd(b,a%b); }
inline ll exgcd(ll a,ll b,ll &x,ll &y){ll d; (b==0? (x=1,y=0,d=a): (d=exgcd(b,a%b,y,x),y-=a/b*x)); return d;}
inline ll qpow(ll a,ll n){ll sum=1;while(n){if(n&1)sum=sum*a%modd;a=a*a%modd;n>>=1;}return sum;}
inline ll qmul(ll a,ll n){ll sum=0;while(n){if(n&1)sum=(sum+a)%modd;a=(a+a)%modd;n>>=1;}return sum;}
inline ll inv(ll a) {return qpow(a,modd-2);}

int n,Aoka,Taka,mx=0;
vector<int> vec[maxn];
bool vis[maxn];

int dfs1(int x,int zhong,int fa,int &len)
{
	if(x==zhong) {return true;} 
	for(auto it:vec[x])
	{
		if(it==fa) continue;
		vis[it]=1;
		if(dfs1(it,zhong,x,len)) {len++;return true;} 
		vis[it]=0;
	}
	return false;
}

int dfs2(int x,int fa,int len,int step)
{
	if(step==len) {return x;} 
	for(auto it:vec[x])
	{
		if(it==fa) continue;
		if(vis[it]==0) continue;
		vis[it]=0;
		return dfs2(it,x,len,step+1);
	}
}

int zhong;
void dfs3(int x,int fa,int step)
{
	if(step>mx) mx=step,zhong=x;
	for(auto it:vec[x])
	{
		if(it==fa) continue;
		if(vis[it]) continue;
		dfs3(it,x,step+1);
	}
}

int main()
{
	scanf("%d%d%d",&n,&Aoka,&Taka);
	for(int i=1;i<=n-1;i++) 
	{
		int u,v;scanf("%d%d",&u,&v);
		vec[u].push_back(v);
		vec[v].push_back(u);
	}
	int len=0;//vis[Aoka]=1;
	dfs1(Aoka,Taka,-1,len);
	
	//int ans1=len/2;
	int ans=(len-1)/2;
	//cout<<len<<endl;
	int k=dfs2(Aoka,-1,ans,0);
	zhong=Aoka;
	dfs3(k,-1,0);
//	ans+=mx;
//	ans=max(ans,ans1); 

	ans=0; 
	dfs1(Taka,zhong,-1,ans);ans--;
	printf("%d\n",ans);
}



Measured memory_bytes: 12288
#include <iostream>

using namespace std;

int main()
{

       double h,a,b,z;
int attacks;

cin>>b>>z;
h=b;
a=z;
attacks=0;
for(int i=1;h>0&&h!=0;i++){
    h=h-a;
    attacks+=1;
}cout<<attacks;
    return 0;
}


Measured memory_bytes: 256
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def findMaximum(low, high):
    # Base Case: Only one element is present in arr[low..high]*/
    if low == high:
        return fun(low)

        # If there are two elements and first is greater then
    # the first element is maximum */
    if high == low + 1 and fun(low) >= fun(high):
        return fun(high);

        # If there are two elements and second is greater then
    # the second element is maximum */
    if high == low + 1 and fun(low) < fun(high):
        return fun(low)

    mid = (low + high) // 2  # low + (high - low)/2;*/

    # If we reach a point where arr[mid] is greater than both of
    # its adjacent elements arr[mid-1] and arr[mid+1], then arr[mid]
    # is the maximum element*/
    if fun(mid) <= fun(mid+1) and fun(mid) <= fun(mid-1):
        return fun(mid)

        # If arr[mid] is greater than the next element and smaller than the previous
    # element then maximum lies on left side of mid */
    if fun(mid) >= fun(mid+1) and fun(mid) <= fun(mid-1):
        return findMaximum(mid+1,high)
    else:  # when arr[mid] is greater than arr[mid-1] and smaller than arr[mid+1]
        return findMaximum(low, mid-1)

def fun(zz):
    return abs(x+d*(2*zz-k))

x,k,d = MAP()

l = 0
r = k

print(findMaximum(l, r))

Measured memory_bytes: 70984
n,d = map(int, input().split())
a = []
for i in range(n):
  a.append(list(map(int,input().split())))
e = int(0)
for i in range(n):
  f = a[i]
  n = f[0]
  m = f[1]
  r = n**2 + m**2
  if r <= d**2:
    e = e + 1
  else:
    continue
print(e)  

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

void Main()
{
    int n, m;
    cin >> n >> m;
    int a[m], b[m];
    int j = 0;

    int sp = 0;
    for (int i = 0; i < m/2; i++)
    {
        a[i] = j;
        j++;
        sp++;
    }
    int sp2 = sp;
    if(m % 2 == 1){
        a[sp] = j;
        j++;
        b[sp] = j;
        j++;
        sp++;
    }
    for (int i = 0; i < m/2; i++)
    {
        b[sp2-i-1] = j;
        j++;
    }

    for (int i = 0; i < m/2; i++)
    {
        a[i+sp] = j;
        j++;
    }
    j++;
    for (int i = 0; i < m/2; i++)
    {
        b[sp2-i-1+sp] = j;
        j++;
    }
    for (int i = 0; i < m; i++){
        cout << a[i]+1 << " " << b[i]+1 << endl;
    }

}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

int main() {
  int a,b,k;
  cin>>a>>b;
  k=log10(b)+1;
  a *= pow(10,k);
  a += b;
  for(int i=1; i<317; i++){
    if(pow(i,2)==a) {
      cout<<"Yes";
      return 0;
    }
  }
  cout<<"No";
}

Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue

//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

//-----end of template-----//

double absd(double a){
    if(a < 0) return -1.0 * a;
    else return a;
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    int sum = 0;
    REP(i, n){
        cin >> a[i];
        sum += a[i]*1000;
    }
    int ave = sum / n;
    int dif = 1000000000;
    int ans = -1;
    REP(i, n){
        if(dif > abs(ave - a[i]*1000)){
            ans = i;
            dif = abs(ave - a[i]*1000);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lli=long long int;
using vi=vector<int>;  using vs=vector<string>; using gi=greater<int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define soao(c) sort((c).begin(),(c).end()) //昇順
#define sodo(c) sort((c).begin(),(c).end(),gi()) //降順
#define rev(c) reverse((c).begin(), (c).end())


int main(){
    int N,count=0; 
    double D;
    cin>>N>>D;
    double x[N],y[N],d[N];
    rep(i,N) cin>>x[i]>>y[i];
    rep(i,N){
        d[i]=sqrt(x[i]*x[i]+y[i]*y[i]);
        if(d[i]<=D) count++; 
    }
    cout<<count<<endl;
}


Measured memory_bytes: 8540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to k'th element (0-based), order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int N = 2e5 + 10;

int n;
int color[N], sub[N], under[N];
LL ans[N];
vector<int> adj[N];

void dfs(int u, int par) {
    sub[u] = 1;
    int cu = color[u];
    under[cu]++;
    for (int v : adj[u]) {
        if (v == par) continue;
        int pre_under = under[cu];
        dfs(v, u);
        sub[u] += sub[v];
        LL cnt = sub[v] - (under[cu] - pre_under);
        ans[cu] += cnt + cnt * (cnt - 1) / 2;
        under[cu] += cnt; 
    }
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> color[i];
    REP(rep, n-1) {
        int u, v; cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1, 0);
    for (int i = 1; i <= n; i++) {
        LL cnt = n - under[i];
        ans[i] += cnt + cnt * (cnt - 1) / 2;
        cout << n + (LL) n * (n-1) / 2 - ans[i] << '\n';
    }
}






























Measured memory_bytes: 37244
#include <iostream>
 #include <algorithm>
 #include <string>
 #include <set>
 using namespace std;

string PopFront(string X)
{
	string Y;
	for(int i = 1; i < X.size(); i++){
		Y.push_back(X[i]);
	}
	return Y;
}

bool operator<(string &A, string &B)
{
	int a = 0;
	int b = 0;
	while(!A.empty() && !B.empty()){
		if('A[0]' < 'B[0]'){
			a = 1;
			break;
		}else if('A[0]' > 'B[0]'){
			b = 1;
			break;
		}
		A = PopFront(A);
		B = PopFront(B);
	}
	if(!A.empty()){
		a = 1;
	}else if(!B.empty()){
		b = 1;
	}
    return a < b;
}

void Judge(set<string>& RWord, string& Command, string& Word)
{
	if(Command == "insert"){
		RWord.insert(Word);
	}else{
		set<string>::iterator it = RWord.find(Word);
		if(it != RWord.end()){
		    cout << "yes" << endl;    
		}else{
		    cout << "no" << endl;
		}
	}
}

 int main()
 {
 	cin.tie(0);
	ios::sync_with_stdio(false);
 	int n;
 	cin >> n;
 	set<string> RWord;
 	for(int i = 0; i < n; i++){
 		string Command;
 		string Word;
 		cin >> Command;
 		cin >> Word;
 		Judge(RWord, Command, Word);
 	}
 	return 0;
 }

Measured memory_bytes: 27056
#include<stdio.h>

int main() {
   
   int W,H,x,y,r;

   scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
   
   if (x+r<=W && x-r>=0 && y+r<=H && y-r>=0) {
      printf("Yes\n");
   
   } else {
      
      printf("No\n");
   
   }
 
   return 0;

}

Measured memory_bytes: 588
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


int main(){fastio
    string s;cin>>s;
    ll n=s.size();
    bool dp[n+1];memset(dp,0,sizeof(dp));
    dp[0]=true;
    rep(i,1,n){
        string k;
        if(i-5>=0&&dp[i-5]){
            k=s.substr(i-5,5);
            if(k=="dream"||k=="erase")dp[i]=true;
        }
        if(i-6>=0&&dp[i-6]){
            k=s.substr(i-6,6);
            if(k=="eraser")dp[i]=true;
        }
        if(i-7>=0&&dp[i-7]){
            k=s.substr(i-7,7);
            if(k=="dreamer")dp[i]=true;
        }
    }
    //rep(i,0,n)cout<<dp[i]<<" ";cout<<endl;
    
    if(dp[n])cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    
    return 0;
}


Measured memory_bytes: 592
n,a,b = map(int, input().split())
mod = 10**9+7
 
def minus(n,k):
    x,y =1,1
    for i in range(k):
        x*=(n-i)
        y*=(k-i)
        x%=mod
        y%=mod
    return x*pow(y, mod-2, mod)%mod
 
ans = pow(2,n,mod)-1-minus(n,a)-minus(n,b)
while ans<0:
    ans+=mod
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int n; scanf("%d", &n);
	printf("%d\n", (n+1)/2);
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n; cin >> n;
    map<int, int> mp;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        mp[a]++;
    }

    int ans = 0;
    for (auto &e: mp) {
        if (e.second % 2 == 1) ans++;
    }

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

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

int n,a,b,t=0,st[4010],p[4010];
char s[10];

int main()
{
	scanf("%d%d",&a,&b);n=a+b;
	if(a<=b)return printf("Impossible"),0;
	for(int i=1;i<=n;i++){
		if(!t){
			st[++t]=i;continue;
		}
		printf("? %d %d\n",st[t]-1,i-1);
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='N')t--;
		else st[++t]=i;
	}
	for(int i=1;i<=n;i++){
		printf("? %d %d\n",st[t]-1,i-1);
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='Y')p[i]=1;
	}
	printf("! ");
	for(int i=1;i<=n;i++)printf("%d",p[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 724
x = input()
ans = 0

count = 0
for i in range(len(x)):
    if x[i] == "S":
        count += 1
    else:
        count -= 1
    if count < 0:
        ans+=1
        count = 0
count = 0
for i in range(len(x)-1,-1,-1):
    if x[i] == "T":
        count += 1
    else:
        count -= 1
    if count <0 :
        ans+=1
        count = 0
print(ans)

Measured memory_bytes: 40288
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	ll A, B;
	cin >> N >> A >> B;
	ans += (N / (A + B)) * A;
	ll pre = N % (A + B);
	ans += min(pre, A);
	cout << ans;
}


Measured memory_bytes: 256
n, m = map(int, input().split())

broken = [0] * (n+1)
dp = [0] * (n+1)

for _ in range(m):
  broken[int(input())] = 1
  if broken[-1] == 1 and broken[-2] == 1:
    print(0)
    exit()

dp[0] = 1

if broken[1] == 1:
  dp[1] = 0
else:
  dp[1] = 1

if n == 1:
  print(dp[n])
  exit()
else:
  for i in range(2, n+1):
    if broken[i] == 1:
      continue
    else:
      dp[i] = (dp[i-1] + dp[i-2]) % 1000000007

print(dp[n])

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

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

    string S;
    cin >> S;

    int cnt[n]={};
    int count=0;
    for(int i=0;i<S.size();i++){
        if(S[i]=='A'&&S[i+1]=='C'){
            count++;
        }
        cnt[i+1]=count;
    }

    int ans;
    for(int i=0;i<q;i++){
        int l,r;
        cin >> l >> r;

        ans=cnt[r-1]-cnt[l-1];

        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
def solve_base(n, a_list):
    # 2 not in a_list
    # odd or even
    factorial_count_2 = [0] * n
    for i in range(1, n):
        p = i
        cnt = 0
        while p % 2 == 0:
            p = p // 2
            cnt += 1
        factorial_count_2[i] = factorial_count_2[i - 1] + cnt

    mod_2 = 0
    for i in range(n):
        if factorial_count_2[n - 1] == factorial_count_2[i] + factorial_count_2[n - 1 - i]:
            mod_2 += a_list[i] % 2
            mod_2 %= 2

    return mod_2


def solve(n, a_list):
    if 2 in a_list:
        return solve_base(n, a_list)
    else:
        return 2 * solve_base(n - 1, [abs(a_list[i] - a_list[i + 1]) // 2 for i in range(n - 1)])


def main():
    n = int(input())
    a_list = list(map(int, list(input())))
    res = solve(n, a_list)
    print(res)


def test():
    assert solve(4, [1, 2, 3, 1]) == 1
    assert solve(10, [2, 3, 1, 1, 3, 1, 2, 3, 1, 2]) == 0
    # assert solve(100, [2] * 100) == 0


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 58752
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    int n3 = n*3;
    priority_queue<ll,vector<ll>,greater<ll>> pql;
    priority_queue<ll,vector<ll>> pqr;
    vector<ll> v(n3);
    vector<ll> suml({0}),sumr({0});

    REP(i,n3) cin >> v[i];

    int l = 0, r = n3-1;
    REP(i,n) {
        suml[0] += v[l];
        sumr[0] += v[r];
        pql.push(v[l]);
        pqr.push(v[r]);
        l++;
        r--;
    }

    REP(i,n) {
        ll x = suml.back() + v[l];
        pql.push(v[l]);
        x -= pql.top(); pql.pop();
        suml.push_back(x);
        l++;

        x = sumr.back() + v[r];
        pqr.push(v[r]);
        x -= pqr.top(); pqr.pop();
        sumr.push_back(x);
        r--;
    }

    ll ans = suml[0] - sumr[n];
    REP(i,n) {
        ans = max(ans,suml[i+1]- sumr[n-1-i]);
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 6636
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    char b;
    cin >> b;
    if(b=='A') cout << "T" << endl;
    else if(b=='T') cout << "A" << endl;
    else if(b=='C') cout << "G" << endl;
    else cout << "C" << endl;
}


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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

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

void f(int &n)
{
	if(n % 2 == 0) n /= 2;
	else n = n * 3 + 1;
}

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;

	int i;
	vector<bool> v(1000'000, true);
	for(i = 1; i <= 1000'000; i++)
	{
		cerr << n << ' ';
		if(v[n]) v[n] = false;
		else break;
		f(n);
	}
	cerr << endl;
	cout << i << endl;
	return 0;
}

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

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static int gcd(int a, int b) {
        int temp = 0;
        while (b > 0) {
            temp = b;
            b = a % b;
            a = temp;
        }
        return a;
    }

    public static int lcm(int a, int b) {
        return a * b / gcd(a, b);
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        out.println(lcm(2, n));
    }

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd 
#define mod 1000000007
/****************************/
using namespace std;
bool isprime[1000010];
int n;
int a[1000010];
int cnt[1000010];
vi pr;
int main()
{
	memset(isprime,1,sizeof(isprime));
	zero(cnt);
	pr.clear();
	rep3(i,2,1e6+1)
	{
		if(isprime[i])
		{
			if(i<=1000)
			{
				pr.pb(i);
			}
			for(ll j=2*i;j<=1e6;j+=i)
			{
				isprime[j]=0;
			}
		}
	}
	cin>>n;
	cin>>a[0];
	int now=a[0];
	rep3(i,1,n)
	{
		cin>>a[i];
		now=__gcd(now,a[i]);
	}
	if(now!=1)
	{
		cout<<"not coprime";
		return 0;
	}
	rep(i,n)
	{
		rep(j,pr.size())
		{
			if(a[i]%pr[j]==0&&a[i]!=pr[j])
			{
				cnt[pr[j]]++;
				while(a[i]%pr[j]==0)
				{
					a[i]/=pr[j];
				}
			}
			if(a[i]<pr[j]) break;
		}
	}
	rep(i,n)
	{
		cnt[a[i]]++;
	}
	rep3(i,2,1e6)
	{
		if(cnt[i]>1)
		{
			cout<<"setwise coprime";
			return 0;
		}
	}
	cout<<"pairwise coprime";
	return 0;
}

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

// マクロ
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) x * x

// 型エイリアス
using lint = long long;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;

int main() {

	int N;
	cin >> N;

	string s, t;
	cin >> s >> t;
	string S;

	rep(i, N) {
		S += s[i];
		S += t[i];
	}
	cou(S);
}

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

int main(){
	int n=0;
	int a[10000];
	while(1){
		n++;
		cin >> a[n];
		if(a[n] == 0)break;
	}
	for(int i=1; i<n; i++){
		cout << "Case " << i << ": " << a[i] << endl;
	}
}  

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

using namespace std;

int big = 1e9, memo[101][101][101];

int solve(int a, int b, int c) {
    if (a == b && b == c)
        return 0;

    if (a > 100 || b > 100 || c > 100)
        return big;

    int &r = memo[a][b][c];

    if (r == -1) {
        int r1 = min(solve(a + 2, b, c), min(solve(a, b + 2, c), solve(a, b, c + 2))), r2;
        r2 = min(solve(a + 1, b + 1, c), min(solve(a + 1, b, c + 1), solve(a, b + 1, c + 1)));

        r = 1 + min(r1, r2);
    }

    return r;
}

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

    memset(memo, -1, sizeof memo);
    int a, b, c;
    cin >> a >> b >> c;

    cout << solve(a, b, c) << '\n';

    return 0;
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef pair<int,int> pii;
#define INF 1e9
struct data{
    int r,a,w,t;
    bool operator<(const data &another) const
    {
        return r+t < another.r + another.t;
    };
};

int main(){
    int n;
    cin >> n;
    vector<data> v(n);
    rep(i,n){
        cin >> v[i].r >> v[i].a >> v[i].w >> v[i].t;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int dp[2][2005][2];
    rep(i,2)rep(j,2005)rep(k,2)dp[i][j][k] = -INF;
    rep(i,n){
        int now = i%2;
        int ne = 1 - now;
        dp[now][v[i].t][1] = max(dp[now][v[i].t][1], v[i].a);
        for(int j = 2000; j >= 0; j--)rep(k,2)if(dp[now][j][k] != -INF){
            int nxt = min(j-v[i].r, v[i].t);
            if(nxt > 0){
                if(k){
                    dp[now][nxt][1] = max(dp[now][nxt][1], dp[now][j][1] + v[i].w);
                }else{
                    dp[now][nxt][1] = max(dp[now][nxt][1], dp[now][j][0] + v[i].a);
                }
            }
            dp[ne][j][0] = max(dp[ne][j][0], dp[now][j][k]);
            dp[now][j][k] = -INF;
        }
    }
    int ans = 0;
    rep(i,2)rep(j,2005)rep(k,2)ans = max(ans, dp[i][j][k]);
    cout << ans << endl;
}


Measured memory_bytes: 3228
package main

import (
	"fmt"
)

func main() {
	var k, a, b int
	fmt.Scan(&k, &a, &b)

	result := "NG"
	for i := a; i <= b; i++ {
		if i%k == 0 {
			result = "OK"
			break
		}
	}

	fmt.Println(result)

}


Measured memory_bytes: 1752
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

using namespace std;

signed main() {
  IOS;
  int A,B,T;
  cin >> A >> B >> T;
  
  cout << (int)((T+0.5)/A)*B << endl;
  return 0;
}


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

using namespace std;

#define i64 int64_t
#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < n; ++i)
#define fore(i,a) for (auto &i : a)
#define repr(i, n) for (int i = n; i >= 0; --i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

const static int mod = 1000000000 + 7;
const static int inf = INT_MAX / 2;
const static llong INF = LLONG_MAX / 2;
const static double eps = 1e-10;
const static int dx[] = {1, 0, -1, 0};
const static int dy[] = {0, 1, 0, -1};

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

signed main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int used[101][101];
    rep(i, 101) {
        rep(j, 101) {
            used[i][j] = 0;
        }
    }

    cout << n * (n - 1) / 2 - n / 2 << endl;
    if (n % 2 == 0) {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (i == j) continue;
                if (i + j == n + 1) continue;
                if (used[i][j] != 0) continue;
                cout << i << " " << j << endl;
                used[i][j] = used[j][i] = 1;
            }
        }
    } else {
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                if (i == j) continue;
                if (i + j == n) continue;
                if (used[i][j] != 0) continue;
                cout << i << " " << j << endl;
                used[i][j] = used[j][i] = 1;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 384