akhauriyash/Code-Regression huggingface dataset:
//#define TEST
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
    static void Main(){
        string[] s = Console.ReadLine().Split();
        long a,b,c;
        a = long.Parse(s[0]);
        b = long.Parse(s[1]);
        c = long.Parse(s[2]);
        long ans = 0;
        ans += Math.Min(a + b + 1,c) + b;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 11220
#include<stdio.h>
int main(void)
{
    int a;
	while(scanf("%d",&a)!=EOF){
		a=a%39;
		if(a==0){
			printf("3C39\n");
		}
		else{ 
			printf("3C%02d\n",a);
		}
	}
	return 0;
}

Measured memory_bytes: 2564
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define sii set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for(ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()
#define INF 1000000000
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
 
 
 
ll power(ll b,ll e,ll m)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(b==0) return 0;
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
}

int gcd(int x, int y)
{                     
        return (x==0)? y : gcd(y % x, x);
}

int vis[1000007];

void solve()
{
  int n;
  cin>>n;
  int a[n];
  cin>>a[0];
  int ans=a[0];
  rep(i,1,n)
  {
    cin>>a[i];
    ans=gcd(ans,a[i]);
  }
  rep(i,0,n)
  {
    for(int j=2;j*j<=a[i];j++)
    {
      if(a[i]%j==0)
      {
        while(a[i]%j==0)
          a[i]/=j;
        vis[j]++;
      }
    }
    if(a[i]>1) vis[a[i]]++;
  }
  bool flag=false;
  rep(i,2,1000001)
  {
    if(vis[i]>1)
    {
      flag=true;
      break;
    }
  }
  // cout<<gcd<<"\n";
  if(ans==1)
  {
    if(flag!=false) cout<<"setwise coprime";
    else cout<<"pairwise coprime";
  }
  else
    cout<<"not coprime";
}


int main()
{
  fastio
  int tt=1;
  // cin>>tt;
  while(tt--)
  {
    solve();
    cout<<"\n";
  }
  return 0;
}

Measured memory_bytes: 11296
#include <bits/stdc++.h>
#define lc rt << 1
#define rc rt << 1 | 1
using namespace std;
const int N = 6e5, M = N << 2;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
struct P
{
	int x, y;
}p[N],st1[N],st2[N];
bool cmpx(const P &a,const P &b)
{
	return a.x < b.x;
}
int x[N], ans, mx[M], tag[M];
void build(int rt, int l, int r)
{
	mx[rt] = -1 << 30;
	tag[rt] = 0;
	if(l == r) return;
	int mid = (l + r) >> 1;
	build(lc, l, mid);
	build(rc, mid + 1, r);
}
void modify(int rt,int l,int r,int L,int R,int d)
{
	if (L <= l && r <= R) tag[rt] += d, mx[rt] += d;
	else
	{
		int mid = (l + r) >> 1;
		if (tag[rt])
		{
			mx[lc] += tag[rt], tag[lc] += tag[rt];
			mx[rc] += tag[rt], tag[rc] += tag[rt];
			tag[rt] = 0;
		}
		if (L <= mid) modify(lc, l, mid, L, R, d);
		if (mid < R) modify(rc, mid + 1, r, L, R, d);
		mx[rt] = max(mx[lc], mx[rc]);
	}
}
void add(int rt, int l, int r, int k, int d)
{
	if (l == r) {mx[rt] = d; return;}
	int mid = (l + r) >> 1;
	if(k <= mid) add(lc, l, mid, k, d);
	else add(rc, mid + 1, r, k, d);
	mx[rt] = max(mx[lc], mx[rc]);
}
void solve(int n, int m, int T)
{
	int len = T, l1, l2, a, b, e, l, r, mid;
	P *st;
	sort(p + 1, p + 1 + T, cmpx);
	for (int i = 1; i <= T; i ++)
		x[i] = p[i].x;
	p[++ T] = (P){n, m >> 1};
	x[++ len] = 0;
	x[++ len] = n;
	sort(x + 1, x + 1 + len);
	len = unique(x + 1, x + 1 + len) - x - 1;
	build(1, 1, len);
	add(1, 1, len, 1, m);
	st1[l1 = 1] = st2[l2 = 1] = (P){1, m >> 1};
	for (int i = 1; i <= T; i ++)
	{
		int &top = p[i].y <= m >> 1 ? (st = st1,l1) : (st = st2, l2);
		a = p[i].x, b = abs(p[i].y - (m >> 1));
		for (l = 1, r = len; l != r; a <= x[mid = (l + r) >> 1] ? r = mid : l = mid + 1);
		a = l;
		e = a;
		ans = max(ans,x[a] + mx[1]);
		add(1, 1, len,a,m-x[a]);
		while (top && b < st[top].y)
		{
			if (st[top].x != e) modify(1, 1, len, st[top].x, e - 1, b - st[top].y);
			e = st[top --].x;
		}
		if (e != a) st[++ top] = (P){e,b};
		st[++ top] = (P){a, m >> 1};
		if (p[i].y > m >> 1) st1[++ l1] = (P){a, m >> 1};
		else st2[++ l2] = (P){a, m >> 1};
	}
}
int main()
{
	int n = read() << 1;
	int m = read() << 1;
	int T = read();
	for (int i = 1; i <= T; i ++)
		p[i].x = read() << 1, p[i].y = read() << 1;
	solve(n, m, T);
	for (int i = 1; i <= T; i ++)
		swap(p[i].x,p[i].y);
	solve(m, n, T);
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int a,b;
  cin>>a>>b;
  cout<<max(0,a-b*2)<<endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <vector>
using namespace std;
int main()
{
	long long n,l,s,p;
	cin>>n;
	int a[n];
	l=0;
	s=0;
	int b[1000000]={0};
	int c[n];
	for(int i=0; i<n; i++)
	{
		cin>>a[i];
		c[i]=a[i];
	}
	sort(a,a+n);
	p=a[0];
	for(int i=0; i<n; i++)
	{
		if(p==a[i])
		{
			l=l+1;
		}
		else
		{
			b[p]=l;
			p=a[i];
			if(l>=2)
			{
				s=s+l*(l-1)/2;
			}
			l=1;
		}
	}
	b[p]=l;
	if(l>=2)
	{
		s=s+l*(l-1)/2;
	}
	for(int i=0; i<n; i++)
	{
		cout<<(s-b[c[i]]+1)<<endl;
	}
}

Measured memory_bytes: 9060
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <list>

long long int INF = 1e18;
long long int MOD = 1000000007;
using namespace std;

typedef pair<long long int, long long int> P;

int main(){
	
	long long int m, n;
	cin >> m >> n;
	
	long long int pm = m;
	long long int ans = 1;
	for(int i = 0; i < 100; i++){
		if(n % 2 == 1){
			ans *= pm;
			ans %= MOD;
		}
		n /= 2;
		pm *= pm;
		pm %= MOD;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3116
#include<stdio.h>
#include <iostream>

#define N 100005
#define MOD 1000000007

using ll = long long;
ll x, y;

ll p[N];
int pn;

ll solve(ll, ll);

int main()
{
	
	std::cin >> x >> y;
	ll d = solve(x, y);

	int ans = 1;
	if (d % 2 == 0) ans++;
	while (d % 2 == 0)	d /= 2;

	for (ll i = 3; i * i <= d; i += 2) {
		if (d % i == 0)
		{
			ans++;
			while (d % i == 0)	d /= i;
		}
	}
	if (d != 1) ans++;

	std::cout << ans << "\n";
	return 0;
}

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

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int sum;
	int nownum;
	int onenum;
	int i;
	char nextcode;
	sum=0;
	onenum=0;
	while(1) {
		scanf("%d%c",&nownum,&nextcode);
		if(nownum>10)nownum=10;
		sum+=nownum;
		if(nownum==1)onenum++;
		if(nextcode=='\n') {
			if(sum==0)break;
			for(i=0;i<onenum;i++) {
				if(sum+10<=21)sum+=10;
			}
			if(sum>21)sum=0;
			printf("%d\n",sum);
			sum=0;
			onenum=0;
		}
	}
	return 0;
}

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

const int maxn = 3010;
int n, a[maxn];
vector<int> G[maxn];

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    for (int i = 1, u, v; i < n; i++) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v), G[v].push_back(u);
    }
    function<bool(int, int)> dfs = [&](int v, int f) {
        for (int u : G[v]) if (u ^ f) {
            if (a[u] < a[v] && !dfs(u, v)) return 1;
        }
        return 0;
    };
    for (int i = 1; i <= n; i++) {
        if (dfs(i, 0)) printf("%d ", i);
    }
    return 0;
}

Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define fi first
// #define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};

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

struct Timer{
    chrono::system_clock::time_point start, end;
    Timer(){ start = chrono::system_clock::now(); }
    ~Timer(){
        end = chrono::system_clock::now();
        auto msec = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cerr<<"time : "<<msec<<" ms"<<endl;
    }
};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    // Timer TM;
    
    string s;
    cin>>s;
    ll n=s.size();
    ll ans=LLINF;
    rep(i,n-2){
        ll x=stoi(s.substr(i,3));
        chmin(ans,abs(x-753));
    }
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	while((s = readln.chomp).length != 0)
	{
		bool flag = true;
		for(int i=0;i<7;i += 3)
		{
			if(s[i] != 's' && s[i] == s[i+1] && s[i+1] == s[i+2])
			{
				s[i].writeln;
				flag = false;
				break;
			}
		}
		
		if(flag)
		{
			foreach(i;0..3)
			{
				if(s[i] != 's' && s[i] == s[i+3] && s[i+3] == s[i+6])
				{
					s[i].writeln;
					flag = false;
					break;
				}
			}
		}
		
		if(flag)
		{
			if(s[0] != 's' && s[0] == s[4] && s[4] == s[8])
			{
				s[0].writeln;
				flag = false;
			}
		}
		
		if(flag)
		{
			if(s[2] != 's' && s[2] == s[4] && s[4] == s[6])
			{
				s[2].writeln;
				flag = false;
			}
		}
		
		if(flag)
		{
			writeln("d");
		}
	}
	return 0;
}

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

par = [-1] * (n + 1)


def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]


def size(x):
    X = find(x)
    return -par[X]


def unite(x, y):
    if find(x) == find(y):
        return False
    X = find(x)
    Y = find(y)
    if size(X) < size(Y):
        x, y = y, x
        X = find(x)
        Y = find(y)
    par[X] += par[Y]
    par[Y] = X
    return True


def is_same(x, y):
    return find(x) == find(y)


def calc(a):
    return a * (a - 1) // 2


goukei = calc(n)
ans = [-1] * (m + 1)
ans[-1] = calc(n)
cnt = 0
AB = [list(map(int, input().split())) for _ in range(m)]
for i in range(m - 1, -1, -1):
    a, b = AB[i]
    if is_same(a, b):
        ans[i] = goukei - cnt
    else:
        A = size(a)
        B = size(b)
        cnt += calc(A + B) - calc(A) - calc(B)
        unite(a, b)
        ans[i] = goukei - cnt
print(*ans[1::], sep="\n")


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

int main()
{
  ll a[3];
  cin >> a[0] >> a[1] >> a[2];
  if (a[0] == a[1] + a[2] || a[1] == a[0] + a[2] || a[2] == a[1] + a[0])
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 764
# include <stdio.h>

int main(void)
{
    long long int a, b, x, ans;
    scanf("%lld%lld%lld", &a, &b, &x);
    ans = 0;
    if (a == 0) {
        ans = b/x + 1;
    } else {
        ans = (b/x + 1) - ((a-1)/x + 1);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    *A,=map(int, input().split())
    dc=[[0]*20 for _ in range(N+1)]
    for i in range(N):
        a = A[i]
        d = dc[i+1]
        p = dc[i]
        for j in range(20):
            d[j]= p[j] + (1 if a&(1<<j) else 0)
    ans=0
    l,r=0,1
    for l in range(N):
        dcl=dc[l]
        while r<=N:
            dcr=dc[r]
            for i in range(20):
                if dcr[i]-dcl[i]>1: break
            else:
                r+=1
                continue
            break
        ans+=r-l-1
    print(ans)

if __name__ == '__main__':
    main()

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

int main(){
  int a,b,c;
  cin >>a >>b >>c;
  bool can = false;
  for(int i = 1; i<=b; i++){
    if(i*a%b==c) can = true;
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0; 
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, ans, u;
char s[200][205];
queue<int> qu;
int main(){
	scanf("%d", &n);
	rep(i,n) scanf("\n%s", s[i]);
	rep(i,n){
		int de[205] = {};
		de[i] = 1;
		qu.push(i);
		while(!qu.empty()){
			int t = qu.front(); qu.pop();
			rep(j,n) if(s[t][j] == '1'){
				if(de[j] == de[t]) return 0*puts("-1");
				if(!de[j]){
					u = de[j] = de[t]+1;
					qu.push(j);
				}
			}
		}
		ans = max(ans, u);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] p = new int[4];
		for(int i=0;i<n;i++){
			String line = br.readLine();
			String[] str = line.split(" ");
			int r = Integer.parseInt(str[0]);
			int t = Integer.parseInt(str[1]);
			boolean bR=false;
			boolean bT=false;
			if(r%100==0)bR=true;
			if(t%30==0)bT=true;
			if(bR&&bT){
				p[0]=(r/100)+(t/30)*5;
				System.out.println(p[0]);
			}else if(bR&&!bT){
				double tmp = (double)t/30;
				p[0]=(r/100)+((int)Math.floor(tmp))*5;
				p[1]=(r/100)+((int)Math.ceil(tmp))*5;
				System.out.println(p[0]+" "+p[1]);
			}else if(!bR&&bT){
				double tmp = (double)r/100;
				p[0]=((int)Math.floor(tmp))+(t/30)*5;
				p[1]=((int)Math.ceil(tmp))+(t/30)*5;
				System.out.println(p[0]+" "+p[1]);
			}else if(!bR&&!bT){
				double tr = (double)r/100;
				double tt = (double)t/30;
				p[0]=((int)Math.floor(tr))+((int)Math.floor(tt))*5;
				p[1]=((int)Math.ceil(tr))+((int)Math.floor(tt))*5;
				p[2]=((int)Math.floor(tr))+((int)Math.ceil(tt))*5;
				p[3]=((int)Math.ceil(tr))+((int)Math.ceil(tt))*5;
				System.out.println(p[0]+" "+p[1]+" "+p[2]+" "+p[3]);
			}
		}
	}
}

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

#define ll long long

int main()
{
    int a, b, n;
    cin >> a >> b;
    for(n=1; n<=100000; ++n){
        if(n*8/100 == a && n/10==b){
            printf("%d\n", n);
            return 0;
        }
    }
    printf("-1\n");
}

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

using namespace std;

int main(){
    int n, k;
    cin >>n>>k;
    vector<double> pre(n+1);

    for(int i =1;i<=n;i++){
        cin >>pre[i];
        pre[i] = (pre[i] + 1) / 2;
        pre[i] += pre[i-1];
    }

    double ans = 0;

    for(int i=k;i<=n;i++){
        ans = max(ans, pre[i] - pre[i-k]);
    }

    printf("%.8f\n", ans);
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int co = 0;
	if (a >= k) {
		cout << k << endl;
		return 0;
	}
	else {
		k -= a;
		co += a;
	}
	if (b >= k) {
		cout << co << endl;
		return 0;
	}
	else {
		k -= b;
	}
	cout << co - k << endl;
	return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
 
#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
 
using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;
 
const double eps = 1e-10;
 
template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}
 
//vector<vector<int64>> ds, dl; // ds: 海のみでi~j，dl: 陸のみでi~j
//vector<vector<PLL>> GL, GS;
int32 N, M, R;
vector<int32> r;
int64 dl[210][210], ds[210][210];
 
void dijkstra(int64 s, vector<int64>& d, const vector<vector<PLL>>& G){
    d[s] = 0;
    priority_queue<PLL, vector<PLL>, greater<PLL>> pq;
    pq.push({0, s});
    while(pq.size()){  
        int64 dd, v;
        tie(dd, v) = pq.top(); pq.pop();
        if(d[v] < dd) continue;
        REP(i, G[v].size()){
            if(dd+G[v][i].fs < d[G[v][i].sc]){
                d[G[v][i].sc] = dd+G[v][i].fs;
                pq.push({d[G[v][i].sc], G[v][i].sc});
            }
        }
    }
}
 
int main(void){
    while(cin >> N >> M && N+M){
        /*
        ds.clear(); dl.clear();
        GL.clear(); GS.clear();
        ds.resize(N, vector<int64>(N, INF_LL));
        dl.resize(N, vector<int64>(N, INF_LL));
        GL.resize(N); GS.resize(N);
        */
        REP(i, 210){
            REP(j, 210){
                ds[i][j] = dl[i][j] = INF_LL;
            }
            ds[i][i] = dl[i][i] = 0;
        }
        REP(i, M){  
            int64 u, v, d; char c;
            cin >> u >> v >> d >> c; u--; v--;
            if(c == 'L'){
                chmin(dl[u][v], d); chmin(dl[v][u], d);
            }else{
                chmin(ds[u][v], d); chmin(ds[v][u], d);
            }
        }
        cin >> R;
        r.resize(R);
        REP(i, R){ cin >> r[i]; r[i]--;}
        /*
        REP(i, N){
            dijkstra(i, ds[i], GS);
            dijkstra(i, dl[i], GL);
        }
        */
        REP(k, N){
            REP(i, N){
                REP(j, N){
                    chmin(dl[i][j], dl[i][k]+dl[k][j]);
                    chmin(ds[i][j], ds[i][k]+ds[k][j]);
                }
            }
        }
 
        vector<vector<int64>> dp(R+1, vector<int64>(N, INF_LL));
        dp[0][r[0]] = 0;
        REP(i, R-1){
            REP(j, N){
                REP(k, N){
                    chmin(dp[i+1][k], dp[i][j]+dl[r[i]][j]+ds[j][k]+dl[k][r[i+1]]);
chmin(dp[i+1][j], dp[i][j]+dl[r[i]][r[i+1]]);
                }
            }
        }
        cout << *min_element(all(dp[R-1])) << endl;
    }
}


Measured memory_bytes: 5244
#include "stdio.h"

int main()
{
    char input[3];
    scanf("%s", input);
    int a = 0, b = 0, c = 0;

    for (int i = 0; i < 3; ++i)
    {
        if (input[i] == 'a')
        {
            a++;
        } else if (input[i] == 'b')
        {
            b++;
        } else if (input[i] == 'c')
        {
            c++;
        }
    }

    if (a == 1 && b == 1 && c == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 128
// ABC078_A
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <tuple>  // std::tuple std::get
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <bitset>  // static_cast<std::bitset<8>>
#include <sstream>  // std::stringstream
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <iomanip>  // std::setprecision()
using namespace std;

#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (ll i=0; i < n; i++)  // 0 ~ n-1
#define REPN(i, n) for (ll i=1; i <= n; i++)  // 1 ~ n
#define MIN(vec) min_element(ALL((vec)))  // イテレータのため、値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0LL)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)

typedef long long ll;

const ll MOD7 = 1000000007;  // 1 000 000 007
const ll MOD9 = 1000000009;  // 1 000 000 009

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

    // input
    char N, M;
    cin >> N >> M;
    // vector<ll> vec(N);
    // REP(i, N) cin >> vec[i];
    
    // calculation
    if ((int)N == (int)M) {
        cout << "=" << "\n";
    } else if ((int)N > (int)M){
        cout << ">" << "\n";
    } else {
        cout << "<" << "\n";
    }
    
    
    return 0;
}


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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

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

    cout << a + a*a + a*a*a << endl;

    return 0;
}

Measured memory_bytes: 3580
s = gets.chomp
t = gets.chomp
for i in 0..s.length-t.length
  k = s.length-t.length-i
  f = true
  for j in 0..t.length-1
    if s[k+j] != t[j] && s[k+j] != "?"
      f = false
    end
  end
  if f == true
    s[k..k+t.length-1] = t
    for j in 0..s.size-1
      if s[j] == "?"
        print "a"
      else
        print s[j]
      end
    end
    print "\n"
    exit
  end
end
puts "UNRESTORABLE"

Measured memory_bytes: 1788
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 100005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
    string a;
    cin>>a;
    int len=a.size();
    //cout<<len<<endl;
    int c=0,d=0;
    for(int i=0;i<len;i++)
    {
        if(a[i]!='A')c++;
        else break;
    }
    for(int i=len-1;i>=0;i--)
    {
        if(a[i]!='Z')d++;
        else break;
    }
    cout<<len-(c+d);
}






Measured memory_bytes: 3736
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
 
long long cnt;
int i;
int A[1000000];
int n;
vector<int>G;
 
void insertionSort(int A[], int n, int g) {
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}
 
void shellSort(int A[], int n) {
    for (int h = 1;;) {
        if (h > n)break;
        G.push_back(h);
        h = 3 * h + 1;
    }
    for (int i = G.size() - 1; i >= 0; i--) {
        insertionSort(A, n, G[i]);
    }
}
 
int main() {
    cin >> n;
    for (int i = 0; i < n; i++)scanf("%d", &A[i]);
    cnt = 0;
 
    shellSort(A, n);
 
    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i)printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++)printf("%d\n",A[i]);
 
    return 0;
}


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


def main():
    s = input()
    k = int(input())
    count = 0

    for si in s:
        if si == '1':
            count += 1
        else:
            break

    if s[0] != '1':
        print(s[0])
    else:
        if k <= count:
            print(1)
        else:
            print(s[count])


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));
 
ll gcd(ll x, ll y){
	if(x<y) swap(x,y);
	if(y==0) return x;
	return gcd(y,x%y);
}
 
ll lcm(ll x, ll y){
	return (x*y/gcd(x,y));
}

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////
	int n,m,x,y,a,b;
    cin >> n >> m >> x >> y;
    int maxa=-100;
    int maxb=100;
    REP(i,n){
        cin >> a;
        maxa=max(maxa,a);
    }
    REP(i,m){
        cin >> b;
        maxb=min(maxb,b);
    }
    cout << (maxa>=maxb||maxa>=y||maxb<=x ? "War" : "No War") << endl;
  	
/////////////////////////////////////////////
}

Measured memory_bytes: 256
# ARC066C - Lining Up (ABC050C)
from collections import Counter


def main():
    n = int(input())
    a = tuple(map(int, input().rstrip().split()))
    MOD = 10 ** 9 + 7
    s = (n // 2) * 2
    l = (n + 1) // 2
    if sum(a) == s * l:
        print(2 ** (n // 2) % MOD)
    else:
        print(0)


if __name__ == "__main__":
    main()

Measured memory_bytes: 14324
#include <bits/stdc++.h>
using namespace std;
using u32 = uint32_t;
using u64 = uint64_t;

int main() {
	u32 X, Y, A, B, C;
	cin >> X >> Y >> A >> B >> C;

	vector<u32> p(A);
	vector<u32> q(B);
	vector<u32> r(C);
	for(u32 i=0; i<A; i++) cin >> p[i];
	for(u32 i=0; i<B; i++) cin >> q[i];
	for(u32 i=0; i<C; i++) cin >> r[i];
	
	sort(p.begin(), p.end(), greater<u32>());
	sort(q.begin(), q.end(), greater<u32>());
	sort(r.begin(), r.end(), greater<u32>());
	
	u64 ans = 0;
	u32 red = 0;
	u32 green = 0;
	u32 trans = 0;
	
	while(red + green + trans < X + Y) {
		u32 pv = (red < X) ? p[red] : 0;
		u32 qv = (green < Y) ? q[green] : 0;
		u32 rv = (trans < C) ? r[trans] : 0;
		
		if(pv >= qv && pv >= rv) {
			red++;
			ans += pv;
		} else if(qv >= pv && qv >= rv) {
			green++;
			ans += qv;
		} else {
			trans++;
			ans += rv;
		}
	}
	
	cout << ans;
	return 0;
}

Measured memory_bytes: 1408
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class FBracketSequencing {
public:
    static bool check(const vc<pii>& vec){
        int sum = 0;
        for(auto& p : vec){
            if(sum+p.first<0) return false;
            sum += p.second;
        }
        return true;
    }

    static void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N, op = 0, cl = 0;
        in>>N;
        string S;
        vc<pii> poss, negs;
        REP(i, N){
            in>>S;
            int mn = 0, sum = 0;
            for(auto& s : S){
                if(s=='(') ++sum, ++op;
                else{
                    --sum, ++cl;
                    chmin(mn, sum);
                }
            }
            if(sum>=0) poss.eb(mn, sum);
            else negs.eb(mn-sum, -sum);
        }
        if(op!=cl){
            out<<"No\n";
            return;
        }
        sort(RALL(poss));
        sort(RALL(negs));
        if(check(poss) and check(negs)) out<<"Yes\n";
        else out<<"No\n";
    }
};


int main() {
	FBracketSequencing solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 11252
#!/usr/bin/env python3

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

def main():
    p = []
    my_max = 0
    ans = 0
    for i in range(N):
        p = int(input())
        ans += p
        my_max = max(my_max, p)
    print(ans - my_max // 2)


if __name__ == "__main__":
    main()



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll             long long int
#define lb             lower_bound
#define fi             first
#define ub             upper_bound
#define se              second
#define mp             make_pair
#define vll            vector<ll>
#define mod            1000003
#define endl            "\n"
#define fast           ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb             push_back
#define sz               size()
#define all(v)         v.begin(),v.end()
#define allr(v)        v.rbegin(),v.rend()
#define inp(V,n)       for(int i=0;i<n;i++){cin >> V[i];}
#define oup(V,n)       {for(int i=0;i<n;i++){cout <<  V[i] << " "  ;} cout << endl;}
using namespace std;
ll factorial(ll n)
{
    return (n == 1 || n == 0) ? 1 : n * factorial(n - 1);
}
ll gcd(ll a, ll b)
{
    if (a == 0)
      return b;
    return gcd(b % a, a);
}
ll lcm(ll a, ll b)
{
   return (a*b)/gcd(a, b);
}
bool sortByVal(const pair<double,double> &a,
               const pair<double,double> &b)
{
    if(a.fi==b.fi)
    {
    return (a.second >b.second);
    }
    else
        return (a.fi<b.fi);
}
int main()
{ int t=1;
   //cin>>t;
   while(t--)
   {   ll n;
       cin>>n;
       ll sum=0,i;
       for(i=1;i<n-1;i++)
       { if(n%i==0)
         sum+=n/i-1;
           else
            {
                sum+=n/i;
           }

       }
       cout<<sum+1<<endl;
   }


return 0;
}


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

int main(){
  string s;
  cin >> s;
  if (s=="RRR") {
    cout << 3;
  } else if (s=="RRS" || s=="SRR") {
    cout << 2;
  } else if (s=="RSR" || s=="SSR" || s=="SRS" || s=="RSS") {
    cout << 1;
  } else {
    cout << 0;
  }
  cout << endl;   
}

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

int main(){
	int num;
  cin >> num;
  int input=0;
  int solve=0;
	for(int i=0;i<num;i++){
    cin >> input;
    if(input!=1){
      for(int j=2;j*j<=input;j++){
        if(input%j==0){
          solve--;
          break;
        }
      }
      solve++;
    }
  }
	cout << solve << endl;
	return 0;
}

Measured memory_bytes: 3080
#include<stdio.h>

int judg(int, int);

int main() {
	int dt[BUFSIZ];
	int i, num;

	int n, x;
	for (i = 0; i < BUFSIZ - 1; i++) {

		fflush(stdin);
		scanf("%d %d", &n, &x);

		if (!n)break;

		dt[i] = judg(n, x);

	}
	num = i;

	for (i = 0; i < num; i++) {
		printf("%d\n", dt[i]);
	}


	return 0;
}
int judg(int n, int x) {
	int i, j;
	int cnt = 0;


	for (i = 1; i < x / 3 && i < n - 1; i++) {
		for (j = i + 1; j < n; j++) {
// i,j,x,n is const
//  -> k (i+j+k==x) is const (k' (k'==x-i-j))
// ((i<)j<k<=n) ->( +=(i+j) )-> (i+j*2 < i+j+k(==x) <= i+j+n )

			if ((i + j * 2 < x) && (x <= i + j + n))cnt++;

		}//j/
	}//i/


	return cnt;
}

Measured memory_bytes: 2728
#include<bits/stdc++.h>
#define endl "\n"
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
int main()
{
	fastio;
	int n;
	cin>>n;
	vector<int> h(n+1);
	for(int i=0;i<n;i++)
		cin>>h[i+1];
	vector<int>dp(n+1);
	dp[0]=dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)
	{
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n]<<endl;

}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

typedef tuple<string, int, int> P;

int main()
{
	int n;
	vector<P> c;

	cin >> n;
	REP(i, n)
	{
		string s; int p;
		cin >> s >> p;
		c.emplace_back(P(s, p, i + 1));
	}

	sort(ALL(c), [](const P& left, const P& right) \
		{ return (get<0>(left)== get<0>(right)) ? (get<1>(left) > get<1>(right)) : (get<0>(left) < get<0>(right)); });

	REP(i, n)
		cout << get<2>(c[i]) << endl;

}


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

int main() {
	const ll d = 30000;
	ll N;
	cin >> N;
	vector<int> p(N + 1);
	for (int i = 1; i <= N; ++i) { cin >> p[i]; }

	vector<ll> a(N + 1, 0);
	vector<ll> b(N + 1, 0);
	for (int i = 1; i <= N; ++i) {
		a[p[i]] = d * p[i];
		b[p[i]] = d * (N - p[i]) + i;
	}

	for (int i = 1; i <= N; ++i) {
		cout << a[i];
		if (i < N) { cout << " "; }
		else { cout << endl; }
	}
	for (int i = 1; i <= N; ++i) {
		cout << b[i];
		if (i < N) { cout << " "; }
		else { cout << endl; }
	}

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <math.h>
using namespace std;

int main(){
  int X;
  cin >> X;
  //X以下のべき乗数を探す.
  //調べる整数の最大値.
  int threthold = floor(sqrt(X));
  int ans = 0;
  for(int i=1; i<threthold+1; ++i){
    for(int j=2; j<11; ++j){
        int power = pow(i,j);
      	//越えてたら次の数にする.
      	if(power > X){
           break;
        }
      	//答え更新.
    	if(X-ans > X-power){
          ans = power;
        }
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include "iostream"
#include "algorithm"
#include "cstring"
#include "cstdio"
#include "cmath"
#include "vector"
#include "map"
#include "set"
#include "queue"
using namespace std;
#define MAXN 200006
//#define int long long
#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define all(x) (x).begin() , (x).end()
#define mem( a ) memset( a , 0 , sizeof a )
typedef long long ll;
int n , m;
int A[MAXN] , ans[MAXN];
int dp[MAXN] , sz = 0;
vi G[MAXN];
void dfs( int u , int fa ) {
	int t = lower_bound( dp , dp + sz + 1 , A[u] ) - dp , bc = 0 , flg = 0;
	if( t == sz + 1 ) ++ sz , dp[sz] = A[u] , flg = 1;
	else bc = dp[t] , dp[t] = A[u];
	ans[u] = max( t , ans[fa] );
	for( int v : G[u] ) if( v != fa ) dfs( v , u );
	if( flg ) dp[sz] = 0 , -- sz;
	else dp[t] = bc;
}

void solve() {
	cin >> n;
	rep( i , 1 , n ) scanf("%d",A + i);
	int u , v;
	rep( i , 2 , n ) {
		scanf("%d%d",&u,&v) , G[u].pb( v ) , G[v].pb( u );
	}
	dfs( 1 , 1 );
	rep( i , 1 , n ) printf("%d\n",ans[i]);
}

signed main() {
//    int T;cin >> T;while( T-- ) solve();
    solve();
}

Measured memory_bytes: 30524
N = int(input())
A = list(map(int, input().split()))
# N = 10**6
# A = [10**6-i for i in range(N)]

def is_pairwise_coprime():
    l = [0]*(10**6+1)
    for a in A:
        for j in range(2, int(a**(1/2))+2):
            if a % j == 0:
                if l[j]:
                    return False
                l[j] = 1
            while a % j == 0:
                a //= j
        if a != 1:
            if l[a]:
                return False
            l[a] = 1
    return True

def gcd(a, b):
    if a > b:
        a, b = b, a
    if a == 0:
        return b
    return gcd(a, b%a)

def is_setwise_coprime():
    A_gcd = A[0]
    for a in A[1:]:
        A_gcd = gcd(A_gcd, a)
        if A_gcd == 1:
            break
    return (A_gcd == 1)

if is_pairwise_coprime():
    print("pairwise coprime")
elif is_setwise_coprime():
    print("setwise coprime")
else:
    print("not coprime")

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

int main(){
	int a, b;
	char op;
	cin >> a >> op >> b;
	while ( op != '?'){
		if (op == '+')cout << a + b << endl;
		else if(op == '-')cout << a - b << endl;
		else if(op == '*')cout << a * b << endl;
		else if(op == '/')cout << a / b << endl;
		cin >> a >> op >> b;
	}
	
	return 0;
	
}

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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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;
}

void solve() {
  int N;
  cin >> N;

  int a = N % 10;
  string fix;
  switch (a) {
    case 2:
    case 4:
    case 5:
    case 7:
    case 9:
      fix = "hon";
      break;
    case 0:
    case 1:
    case 6:
    case 8:
      fix = "pon";
      break;
    case 3:
      fix = "bon";
      break;
    default:
      fix = "";
      break;
  }

  cout << fix << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 3640
# include <cstdio>

main()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (a >= 13) {
        printf("%d\n", b);
    } else if (a >= 6){
        printf("%d\n", b / 2);
    } else {
        printf("%d\n", 0);
    }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
void dout(double d){printf("%.12f\n",d);}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, m;
V<int> e[N];
V<ll> DP[N];
ll ans[N];
ll dfs1(int a, int p){
  ll ret = 1;
  for(int b: e[a]){
    if(b==p){
      DP[a].pb(0);
      continue;
    }
    ll t = dfs1(b, a);
    DP[a].pb(t);
    ret = ret * (t+1) % m;
  }
  return ret;
}
void dfs2(int a, int p, ll t){
  int l = sz(e[a]);
  V<ll> v;
  {
    ll f = 1;
    FORR(i, l-1, 0){
      if(p==e[a][i]) DP[a][i] = t;
      v.pb(f);
      f = f * (DP[a][i]+1) % m;
    }
    ans[a] = f;
    reverse(all(v));
  }
  ll f = 1;
  FOR(i, 0, l){
    if(e[a][i]!=p) dfs2(e[a][i], a, f*v[i]%m);
    f = f * (DP[a][i]+1) % m;
  }
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  FOR(i, 0, n-1){
    int x, y;
    cin >> x >> y;
    x--; y--;
    e[x].pb(y);
    e[y].pb(x);
  }
  dfs1(0, -1);
  dfs2(0, -1, 0);
  FOR(i, 0, n) printf("%d\n", ans[i]);
}

Measured memory_bytes: 25600
import sys
import math
import collections
import bisect
import copy

# import numpy as np

sys.setrecursionlimit(10 ** 7)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
na1 = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, m = ns()
    d = []
    for _ in range(m):
        a, b = ns()
        d.append([a - 1, b - 1])

    d.sort(key=lambda x: x[1])

    down = []

    for a, b in d:
        idx = bisect.bisect_left(down, a)
        if idx == len(down):
            down.append(b - 1)
    print(len(down))


if __name__ == '__main__':
    main()


Measured memory_bytes: 26068
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a,int b)
{
    if(a==0)return b;
    return gcd(b%a,a);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    ll sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                sum+=gcd(i,gcd(j,k));
            }
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int a,b,k;
    cin >> a >> b >> k;
    rep(i,k){
        if(i%2==0){
            b += a/2;
            a /= 2;
        }else{
            a += b/2;
            b /= 2;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}



Measured memory_bytes: 3608
// AOJ 1327 One-Dimensional Cellular Automaton
// 2017.10.25 bal4u
// 2018.2.9

#include <stdio.h>
#include <string.h>

int s[2][52], d[32][52][52];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
	int n, m, a, b, c, t;
	int i, j, k, l, k1, k2;

	while (n = in()) {
		m = in(), a = in(), b = in(), c = in(), t = in();
		memset(d, 0, sizeof(d));
		for (i = 1; i <= n; i++) s[0][i] = in();
		for (i = 1; i <= n; i++) d[0][i][i+1] = a, d[0][i][i] = b, d[0][i][i-1] = c;
		for (k = 1; (1<<k) <= t; k++) for (i = 1; i <= n; i++) for (j = 1; j <= n; j++) {
			for (l = 1; l <= n; l++) d[k][i][j] += d[k-1][i][l] * d[k-1][l][j];
			d[k][i][j] %= m;
		}

		for (k1 = 0, k2 = 1, k = 0; (1<<k) <= t; k++) if (t & (1<<k)) {
			memset(s[k2], 0, sizeof(s[k2]));
			for (j = 1; j <= n; j++) {
				for (i = 1; i <= n; i++) s[k2][i] += s[k1][j] * d[k][j][i];
			}
			for (i = 1; i <= n; i++) s[k2][i] %= m;
			k1 = k2, k2 = !k2;
		}
		printf("%d", s[k1][1]);	for (i = 2; i <= n; i++) printf(" %d", s[k1][i]);
		putchar('\n');
	}
	return 0;
}



Measured memory_bytes: 2036
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var r = o.a();
  var d = o.a();
  var x = o.a();
  var ans = [r*x-d];
  for(var i = 1; i < 10; i++){
    ans[i] = ans[i-1]*r-d;
  }
  return ans.join("\n");
}

Measured memory_bytes: 21320