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

typedef pair<int, int> Data;
typedef pair<int, Data> Pair;

int n;
int m;
Pair ps[114514];
bool infected[114514];

int main() {
  while (1) {
    scanf("%d%d", &n, &m);
    if (n == 0 && m == 0) return 0; 

    fill(infected, infected+n+1, false);
    for (int i=0; i<m; i++) {
      int t, s, d;
      scanf("%d%d%d", &t, &s, &d);
      ps[i] = Pair(t, Data(s, d));
    }

    sort(ps, ps+m);

    infected[1] = true;
    int ans = 1;
    for (int i=0; i<m; i++) {
      Pair pa = ps[i];
      Data d = pa.second;
      int s = d.first;
      int t = d.second;

      if (infected[s] && !infected[t]) {
        infected[t] = true;
        ans++;
      }
    }

    printf("%d\n", ans);
  }
}

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

int main(){
    double r, ans;
    cin >> r;
    ans = r * 2 * 3.141592653589;
    cout << setprecision(12) << ans << endl;
    return 0;
}

Measured memory_bytes: 3804
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
// using mint = modint1000000007;

int op(int a, int b) { return max(a, b); }
int e() { return 0; }

void Main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    int a_max = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a_max = max(a_max, a[i]);
    }
    segtree<int, op, e> dp(a_max+1); // dp[j]=（a[i]まで見たときに、最後にa[i]=jを使った時の最大長）
    for (int i = 0; i < n; i++)
    {
        int l = a[i] - k;
        int r = a[i] + k + 1;
        l = max(0, l);
        r = min(r, a_max+1);
        dp.set(a[i], dp.prod(l, r)+1);
    }
    int ans = dp.all_prod();
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 9840
#include<iostream>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  int ans = 10000000, b;
  
  for(int i=0; i<n; i++){
    b = 0;
    while(a[i]%2==0){
      a[i] = a[i] / 2;
      b = b + 1; 
    }
    ans = min(ans, b);
  }
  
  cout << ans << endl;
  return 0;
}

    

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

using namespace std;

#define ll long long

//Tumhe kya laga me code nahi kar sakta, me sab kar sakta hai,
//kyunki hindustan ka yuva sirf hindustan ko nahi desh ko badal sakta hai

int main()
{
	string s,t,u;
	cin>>s>>t;
	ll a,b;
	cin>>a>>b;
	cin>>u;
	if(u == s)
	{
		a--;
		cout<<a<<" "<<b;
	}
	else
	{
		b--;
		cout<<a<<" "<<b;
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  long  long int h;
  long int n;
  cin>>h>>n;
  long int i,j;
  long int a[n];
  for(j=0;j<n;j++)
  		{		
    		cin>>a[j];
   		}
  for(i=0; ;i++)
  {
  		for(j=0;j<n;j++)
  		{		
    		h=h-a[j];
   		}
		if(h <= 0 )
    	{ 
	  		cout<<"Yes";
			break;
    	}
    	else
    	{
    		cout<<"No";
    		break;
		}
  }
}

Measured memory_bytes: 1024
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 

int main() {
  int A, B; // 変数の宣言
  cin >> A >> B; // 標準入力
  cout << A * B << endl; // 標準出力
}

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

using namespace std;

int main() {
	int N,M;
	cin >> N >> M;
	
	vector< vector<int> > road_network(N);
	int cityA, cityB;
	for (int i = 0; i < M; ++i) {
		cin >> cityA >> cityB;
		road_network[cityA-1].push_back(cityB);
		road_network[cityB-1].push_back(cityA);
	}
	
	for (int i = 0; i < N; ++i) {
		cout << road_network[i].size() << endl;
	}
	
	return 0;
}

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

inline int read(){
	int s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

int main(){
	int n = read(), m = read(), l = read();
	if (m * l >= n) puts("Yes");
	else puts("No");
	return 0;
}

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

int main() {
	int a, b;
	cin >> a >> b;
	int ans;
	if(a <= 5) {
		ans = 0;
	} else if (6 <= a && a <= 12) {
		ans = b / 2;
	} else {
		ans = b;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

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

}

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

struct UnionFind{
    v: Vec<usize>
}

impl UnionFind{
    fn new(n: usize) -> UnionFind{
        let mut v: Vec<usize> = Vec::new();
        for i in 0..n{
         v.push(i);
        }
        UnionFind{v:v}
    }

    fn find(&mut self, i: usize) -> usize{
        if self.v[i] == i{
            i
        }else{
            let ni = self.v[i];
            self.v[i] = self.find(ni);
            self.v[i]
        }
    }

    fn union(&mut self, i: usize, j: usize){
        let root_i = self.find(i);
        let root_j = self.find(j);
        self.v[root_i] = root_j;
    }

}

struct CombMod{
    fac: Vec<u64>,
    inv: Vec<u64>,
    finv: Vec<u64>,
    mmod: u64,
}

impl CombMod{
    pub fn new(max: u64, m: u64) -> CombMod{
        let max: usize = max as usize;
        let mut fac: Vec<u64> = vec![0;max+1];
        let mut finv: Vec<u64> = vec![0;max+1];
        let mut inv: Vec<u64> = vec![0;max+1];

        fac[0] = 1;
        fac[1] = 1;
        finv[0] = 1;
        finv[1] = 1;
        inv[1] = 1;

        for i in 2..max+1{
            fac[i] = fac[i-1] * i as u64 % m;
            inv[i] = m - inv[m as usize %i] * (m/(i as u64)) % m;
            finv[i] = finv[i-1] * inv[i] % m;
        }

        CombMod{
            fac: fac,
            finv: finv,
            inv: inv,
            mmod: m,
        }
    }

    fn get(&self, n: u64, m: u64) -> u64{
        assert!(n >= m && n != 0 && m != 0);
        self.fac[n as usize] * self.finv[m as usize] % self.mmod
            * self.finv[(n-m) as usize] % self.mmod
    }
}

fn main(){
    let r: i32 = read_as_vec()[0];

    println!("{}", r*r);
}


Measured memory_bytes: 4352
class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parent = [i for i in range(n)]
        self.height = [1] * n
        self.size = [1] * n

    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            self.parent[x] = self.find(self.parent[x])
            return self.parent[x]

    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.height[x] < self.height[y]:
                self.parent[x] = y
                self.size[y] += self.size[x]
            else:
                self.parent[y] = x
                self.size[x] += self.size[y]
                if self.height[x] == self.height[y]:
                    self.height[x] += 1

    def issame(self, x, y):
        return self.find(x) == self.find(y)

    def group_size(self, x):
        return self.size[self.find(x)]


N, M = map(int, input().split())
int1 = lambda x: int(x) - 1
X = [tuple(map(int1, input().split())) for _ in range(M)]

uf = UnionFind(N)
lst = [0]
for a, b in reversed(X):
    if uf.issame(a, b):
        lst.append(lst[-1])
    else:
        lst.append(lst[-1] + uf.group_size(a) * uf.group_size(b))
    uf.unite(a, b)

for i in range(M - 1, -1, -1):
    print(N * (N - 1) // 2 - lst[i])


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

typedef long long ll;
const ll mod = 998244353;

ll a, b, k;
int n;
ll f[300005], finv[300005];

ll powr(ll a, ll n){
    ll ret = 1, pv = a;
    for(;n;n>>=1){
        if(n & 1){
            ret = (ret * pv) % mod;
        }
        pv = (pv * pv) % mod;
    }
    return ret;
}

void init(){
    f[0] = f[1] = 1;
    finv[0] = finv[1] = 1;
    for(int i = 2; i <= 300000; i++){
        f[i] = (f[i-1] * i) % mod;
        finv[i] = (finv[i-1] * powr(i,mod-2)) % mod;
    }
}

ll C(int n, int r){
    return (f[n] * finv[r] % mod) * finv[n-r] % mod;
}

int main(){
    init();
    cin >> n >> a >> b >> k;
    ll ans = 0, tmp;
    for(int i = 0; i <= n && a * i <= k; i++){
        if((k - a * i) % b) continue;
        int j = (k - a * i) / b;
        if(j < 0 || j > n) continue;
        ans = (ans + (C(n,i) * C(n,j) % mod)) % mod;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const int N=100005;
typedef long long ll;
struct to{
    ll l,t;
};
vector<to> mp[N];
ll dis[N];
void dfs(ll u,ll fa){
    for(ll i=0; i<mp[u].size(); i++){
        ll v=mp[u][i].t;
        if(v==fa) continue;
        dis[v]=dis[u]+mp[u][i].l;
        dfs(v,u);
    }
    return;
}
int main(){
    ll n,a,b,c,q,k,x,y;
    cin>>n;
    for(ll i=1; i<n; i++){
        cin>>a>>b>>c;
        mp[a].push_back((to){c,b});
        mp[b].push_back((to){c,a});
    }
    cin>>q>>k;
    dfs(k,0);
    for(ll i=0; i<q; i++){
        cin>>x>>y;
        cout<<dis[x]+dis[y]<<endl;
    }
    return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int multi;
    int mxab = max(a,b);
    int mnab = min(a,b);
    long long copymx = max(a,b);
    while(copymx%mxab!=0 || copymx%mnab!=0){
        copymx += max(a,b);
        if(copymx%mxab==0 && copymx%mnab==0)
            break;
    }
    cout << copymx << endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

vector<int> primos;
void erat(unsigned int limit) {
    vector<bool> prime(limit + 1, true);
    const unsigned int n = sqrt(limit);
    unsigned int i, j;
    primos.push_back(2);
    for(i = 3; i <= n; i += 2) {
        if(prime[i]) {for(j = i * i; j <= limit; j += 2*i) prime[j] = false;}
    }
    for(i = 3; i <= limit; i += 2) {if(prime[i]) primos.push_back(i);}
}

set<ll> fact(ll n) { //O (cant primos)
    set<ll> ret;
    int idx=0;
    ll p=primos[0];
    while (p*p<=n) {
        if (!(n%p)){
            ret.insert(p);
            n /= p;
            while (n%p==0) n /= p;
        }
        p = primos[++idx];
    }
    if(n > 1) ret.insert(n);
    return ret;
}


int main() {
    READ(0);
    erat(1E6+1);
    ll a,b;cin>>a>>b;
    auto fa=fact(a);
    int ret=1;
    for(ll p:fa){
        if (b%p==0) ++ret;
    }

    cout << ret;

    return 0;
}



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

using namespace std;

int read() {
  int res = 0;
  char c = getchar();
  while (!isdigit(c)) c = getchar();
  while (isdigit(c)) res = res * 10 + c - '0', c = getchar();
  return res;
}

const int maxn = 1e5 + 5;
int N, A[maxn], Ans = 0;
long long sum;

int main() {
  //  freopen("b.in", "r", stdin);
  //  freopen("b.out", "w", stdout);
  N = read(), sum = 0;
  for (int i = 1; i <= N; i++) A[i] = read();
  sort(A + 1, A + N + 1);
  for (int i = 1; i <= N; i++) {
    Ans++, sum += A[i];
    if(sum + sum < A[i + 1]) Ans = 0;
  }
  printf("%d\n", Ans);
  return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

typedef struct{
    int n;
    double value;
}data;

//昇順
int asc(const void* a, const void* b){
    data p=*(data*)a;
    data q=*(data*)b;

    if(p.value-q.value>0) return 1;
    else if(p.value-q.value<0) return -1;
    else return p.n-q.n;
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    data* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        A[i].n=i;
        scanf("%lf",&A[i].value);
    }

    double avg=0;
    for(int i=0;i<N;i++) avg+=A[i].value;
    avg/=N;

    for(int i=0;i<N;i++) A[i].value=fabs(A[i].value-avg);
    qsort(A,N,sizeof(data),asc);

    printf("%d\n",A[0].n);

    return 0;
}

Measured memory_bytes: 384
// Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n, m;
		cin >> n >> m;

		if(n==0&&m==0)
			break;

		char C[10000];
		for(int i=0; i<n; i++){
			C[i] = '#';
		}

		for(int i=0; i<m; i++){
			char a;
			cin >> a;

			if(a=='A'){
				for(int j=0; j<n; j++){
					if(C[j]=='#'){
						C[j] = a;
						break;
					}
				}
			}
			else if(a=='B'){
				bool flg = false;
				for(int j=n-1; j>=0; j--){
					if(C[j]=='#'&&(j==0||C[j-1]!='A')&&(j==n-1||C[j+1]!='A')){
						C[j] = a;
						flg = true;
						break;
					}
				}

				if(!flg){
					for(int j=0; j<n; j++){
						if(C[j]=='#'){
							C[j] = a;
							break;
						}
					}
				}
			}
			else if(a=='C'){
				if(i==0){
					C[n/2] = a;
				}
				else{
					for(int j=0; j<n; j++){
						if(C[j]!='#'&&j!=n-1&&C[j+1]=='#'){
							C[j+1] = a;
							break;
						}
						else if(C[j]!='#'&&j!=0&&C[j-1]=='#'){
							C[j-1] = a;
							break;
						}
					}
				}
			}
			else if(a=='D'){
				if(i==0){
					C[0] = a;
				}
				else{
					int D[10000];
					int d = 10000;
					for(int j=0; j<n; j++){
						if(C[j]!='#'){
							d = 0;
							D[j] = d;
						}
						else{
							d++;
							D[j] = d;
						}
					}

					d = 10000;
					for(int j=n-1; j>=0; j--){
						if(C[j]!='#'){
							d = 0;
						}
						else{
							d++;
							if(D[j]>d){
								D[j] = d;
							}
						}
					}

					int d_max = -1;
					int j_max = -1;
					for(int j=0; j<n; j++){
						if(D[j]>d_max){
							d_max = D[j];
							j_max = j;
						}
					}

					C[j_max] = a;
				}
			}
		}

		for(int i=0; i<n; i++){
			cout << C[i];
		}
		cout << '\n';
	}

	return 0;
}

Measured memory_bytes: 0
import sys
from itertools import combinations_with_replacement

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


def main():
    N, M, Q = map(int, input().split())
    abcd = [None] * Q
    for i in range(Q):
        abcd[i] = tuple(map(int, input().split()))

    ans = 0
    for A in combinations_with_replacement(range(1, M+1), N):
        score = 0
        for q in abcd:
            a, b, c, d = q
            if A[b-1] - A[a-1] == c:
                score += d
        if score > ans:
            ans = score

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9008
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
    string s,t;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]!='/'){
            t+=s[i];
        }
    }
    int date=stoi(t);
    if(date<=20190430){
        cout<<"Heisei"<<endl;
    }else{
        cout<<"TBD"<<endl;
    }
    return 0;
}

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

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int main(){
  int a, b;
  cin >> a >> b;
  if((b-a)%2==1){
    if(a<0 && b>0) cout << "Zero" << endl;
    else cout << "Positive" << endl;
    return 0;
  }
  if((b-a)%2==0){
    if(a>0 && b>0) cout << "Positive" << endl;
    else if(a<0 && b<0) cout << "Negative" << endl;
    else cout << "Zero" << endl;
    return 0;
  }
  return 0;
}

Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)

int main(){
	string s;
	cin>>s;
	rep(i,s.size()){
		if(s[i]==',')s[i] = ' ';
	}
	cout<<s<<endl;
}

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

int main() {
	string S;
	cin >> S;
  	if(S=="SUN") cout << 7 << endl;
  	if(S=="MON") cout << 6 << endl;
  	if(S=="TUE") cout << 5 << endl;
  	if(S=="WED") cout << 4 << endl;
  	if(S=="THU") cout << 3 << endl;
  	if(S=="FRI") cout << 2 << endl;
  	if(S=="SAT") cout << 1 << endl;
  
  	return 0;
}


Measured memory_bytes: 3576
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int n,s,ans;
void func(int num,int goukei,int now){
    if(num==n&&goukei==s){
        //cout<<num<<" "<<goukei<<" "<<now<<endl;
        ans++;
        return;
    }
    if(num>n||goukei>s||now>9)return;
    func(num+1,goukei+now,now+1);
    func(num,goukei,now+1);
}
int main(){
    for(;;){
        ans=0;
        cin>>n>>s;
        if(n==0&&s==0)break;
        func(0,0,0);
        cout<<ans<<endl;
    }
    return 0;
}

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

using namespace std;

int n;
int MAX = 999999999;
vector<int> hi;
vector<vector<int>> gains, memo;

int happiness(int i_selected_day, int i_day)
{
  if (i_day == n)
    return 0;
  if (memo[i_day][i_selected_day] != -1 && i_selected_day != -1)
    return memo[i_day][i_selected_day];
  int mx = -1;
  for (int i = 0; i < 3; i++)
    if (i != i_selected_day)
    {
      mx = max(gains[i_day][i] + happiness(i, i_day + 1), mx);
    }
  if (i_selected_day != -1)
    memo[i_day][i_selected_day] = mx;
  return mx;
}

int main()
{

  cin >> n;
  gains.resize(n);
  memo.resize(n);
  for (int i = 0; i < n; i++)
    memo[i].resize(3, -1);
  for (int i = 0; i < n; i++)
  {
    int a, b, c;
    cin >> a >> b >> c;
    gains[i].push_back(a);
    gains[i].push_back(b);
    gains[i].push_back(c);
  }
  cout << happiness(-1, 0) << endl;
  return 0;
}

Measured memory_bytes: 18944
# -*- coding: utf-8 -*-
from collections import defaultdict

def solve():
    N = int(input())
    S = input()
    M = defaultdict(int)
    for s in S:
        M[s] += 1
    M = dict(M)
    res = 1
    for m in M.values():
        res *= (m+1)
        res %= (10**9+7)
    res -= 1
    return str(res)
if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const long long INF = (long long)1e18+1;
#define DIV 1000000007
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long idx=0;
    ll N, K, Q;
    cin >> N >> K >> Q;
    ll ans;
    vector<long> p(N, 0);
    for(size_t i=0;i<Q; i++)
    {
        cin >> ans;
        p[ans-1] ++;
    }
    //番号と保持ポイント
    for(size_t i=0;i<N; i++)
    {
        //cerr << i << "," << K  - (Q - p[i]) << endl;
        if(K  - (Q - p[i]) > 0) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

struct Dice{
  int id[6];
  /*index number:
    0:top, 1:front, 2:right, 3:left, 4:back, 5:bottom 
  */
  Dice(){
    id[0] = 1, id[1] = 2, id[2] = 3, id[3] = 5, id[4] = 4, id[5] = 6;
  }
  Dice(int a, int b, int c, int d, int e, int f){
    id[0] = a, id[1] = b, id[2] = c, id[3] = d, id[4] = e, id[5] = f;
  }
  void north(){
    int d[6];
    for(int i=0;i<6;i++) d[i]=id[i];
    id[0]=d[1];
    id[1]=d[5];
    id[2]=d[2];
    id[3]=d[0];
    id[4]=d[4];
    id[5]=d[3];
  }
  
  void south(){
    int d[6];
    for(int i=0;i<6;i++) d[i]=id[i];
    id[0]=d[3];
    id[1]=d[0];
    id[2]=d[2];
    id[3]=d[5];
    id[4]=d[4];
    id[5]=d[1];
  }
  
  void east(){
    int d[6];
    for(int i=0;i<6;i++) d[i]=id[i];
    id[0]=d[4];
    id[1]=d[1];
    id[2]=d[0];
    id[3]=d[3];
    id[4]=d[5];
    id[5]=d[2];
  }
  
  void west(){
    int d[6];
    for(int i=0;i<6;i++) d[i]=id[i];
    id[0]=d[2];
    id[1]=d[1];
    id[2]=d[5];
    id[3]=d[3];
    id[4]=d[0];
    id[5]=d[4];
  }
  
  void right(){
    int d[6];
    for(int i=0;i<6;i++) d[i]=id[i];
    id[0]=d[0];
    id[1]=d[2];
    id[2]=d[3];
    id[3]=d[4];
    id[4]=d[1];
    id[5]=d[5];
  }
  
  void left(){
    int d[6];
    for(int i=0;i<6;i++) d[i]=id[i];
    id[0]=d[0];
    id[1]=d[4];
    id[2]=d[1];
    id[3]=d[2];
    id[4]=d[3];
    id[5]=d[5];
  }
};

int main(){
  int n;
  while(cin >> n, n){
    Dice dice;
    string s;
    int ans = 1;
    for(int i = 0 ; i < n ; i++){
      cin >> s;
      if(s == "North") dice.north();
      if(s == "East") dice.east();
      if(s == "South") dice.south();
      if(s == "West") dice.west();
      if(s == "Left") dice.left();
      if(s == "Right") dice.right();
      ans += dice.id[0];
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1212
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
gcd = math.gcd
x = ni()
print(1-x)


Measured memory_bytes: 9456
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    double W, H, x, y; cin >> W >> H >> x>>y;
    double ans1 = W*H/2;
    int ans2 = 0;
    if(x*2 == W && y*2 == H) {
        ans2 = 1;
    }
    cout << ans1 << " " << ans2 << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
if n == 1:
	print('YES')
	exit()
tot = 0
for i in range(n):
	tot += a[i]
 
if tot % (n*(n+1)//2) != 0:
	print('NO')
	exit()
times = tot//(n*(n+1)//2)
 
x = a[n-1]-a[0]+times
if (x < 0) |(x % n != 0):
	print('NO')
	exit()
for i in range(1,n):
	x = a[i-1]-a[i]+times
	#print(i, x, times)
	if (x < 0) | (x % n != 0):
		print('NO')
		exit()
print('YES')

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int max = 0, min = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (i == 0) {
      max = A.at(i);
      min = A.at(i);
    }
    if (max < A.at(i)) max = A.at(i);
    if (min > A.at(i)) min = A.at(i);
  }
  cout << max - min << endl;
}


Measured memory_bytes: 256
// Standard I/O
#include <iostream>
#include <sstream>
#include <cstdio>
// Standard Library
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
// Template Class
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
// Container Control
#include <algorithm>

using namespace std;

#define rep( i, n ) for( int i = 0; i < n; ++i )
#define irep( i, n ) for( int i = n-1; i >= 0; --i )
#define reep( i, s, n ) for ( int i = s; i < n; ++i )
#define ireep( i, n, s ) for ( int i = n-1; i >= s; --i )
#define foreach(itr, x) for( typeof(x.begin()) itr = x.begin(); itr != x.end(); ++itr)

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all( v ) v.begin(), v.end()
#define fs first
#define sc second
#define vc vector

// for visualizer.html
double SCALE = 1.0;
double OFFSET_X = 0.0;
double OFFSET_Y = 0.0;
#define LINE(x,y,a,b) cerr << "line(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(a) + OFFSET_X << ","										\
	<< SCALE*(b) + OFFSET_Y << ")" << endl;
#define CIRCLE(x,y,r) cerr << "circle(" << SCALE*(x) + OFFSET_X << ","	\
	<< SCALE*(y) + OFFSET_Y << ","										\
	<< SCALE*(r) << ")" << endl;

typedef long long ll;
typedef complex<double> Point;

typedef pair<int, int> pii;
typedef pair<int, pii> ipii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector< vector<int> > vii;
typedef vector< vector<double> > vdd;

typedef vector<int>::iterator vi_itr;

const int IINF = 1 << 28;
const int MOD = 1e9+7;
const double INF = 1e30;
const double EPS = 1e-10;
const double PI = acos(-1.0);

// Direction : L U R D
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1 };

int main()
{
    int n;
    int a[100010];

    cin >> n;
    rep(i, n) cin >> a[i];

    int ans = a[0];
    reep(i, 1, n) ans ^= a[i];

    cout << (ans == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
package main

import "fmt"

func main() {
	var (
		N int
	)
	fmt.Scan(&N)
	A := make([]int, N)
	B := make([]int, N)
	for i := range A {
		fmt.Scanf("%d %d", &A[i], &B[i])
	}
	res := 0
	for i := N - 1; i >= 0; i-- {
		if (A[i]+res)%B[i] == 0 {
			continue
		}
		res += B[i] - (A[i]+res)%B[i]
	}
	fmt.Println(res)
}


Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int gcd(int n, int m) {
    if (n < m) swap(n, m);
    while (m != 0) {
        int r = n % m;
        n = m;
        m = r;
    }
    return n;
}

int main() {
    ll a, b;
    cin >> a >> b;
    a--;

    int c, d;
    cin >> c >> d;

    auto f = [=](ll c) {
        return b / c - a / c;
    };

    cout << f(1) - f(c) - f(d) + f(c / gcd(c, d) * (ll)d) << endl;

    return 0;
}

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

int ramp(int a){
    if(a>=0) return a;
    else return 0;
}

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

    int ans=1e7;
    for(int i=0; i<=3; i++){
        vector<int> q=p;
        int cnt=i;
        q[0]=ramp(q[0]-i);
        for(int j=0; j<n-1; j++){
            cnt += 2*q[j];
            q[j+1]=ramp(q[j+1]-q[j]);
        }
        cnt += q[n-1];
        ans=min(ans, cnt);
    }
	cout << ans << endl;
}


Measured memory_bytes: 3200
import bisect

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

numbers.sort()
maximum = numbers[-1]

half = maximum/2
index = bisect.bisect_left(numbers, half)
if index != 0:
    if numbers[index] - half < half - numbers[index-1]:
        print('{} {}'.format(maximum, numbers[index]))
    else:
        print('{} {}'.format(maximum, numbers[index-1]))
else:
        print('{} {}'.format(maximum, numbers[0]))


Measured memory_bytes: 14052
import kotlin.math.min

fun main() = abc167c()

@OptIn(ExperimentalStdlibApi::class)
fun abc167c() {
    data class Book(val price: Long, val exp: List<Long>)

    val (n, m, x) = readLine()!!.split(' ').map { it.toLong() }
    val books = (1..n).map {
        val line = readLine()!!.split(' ').map { it.toLong() }
        Book(line[0], line.drop(1))
    }

    var answer = Long.MAX_VALUE

    searchAllPatterns(2, n.toInt()) { pattern ->
        val filtered = books.filterIndexed { index, _ -> pattern[index] == 1 }

        val experiences = LongArray(m.toInt())
        filtered.forEach { it.exp.forEachIndexed { index, l -> experiences[index] += l } }

        if (experiences.all { it >= x }) {
            answer = min(answer, filtered.map { it.price }.sum())
        }
    }

    println(answer.takeIf { it < Long.MAX_VALUE } ?: -1)
}

@Suppress("SameParameterValue")
private inline fun searchAllPatterns(numberOfChoices: Int, length: Int, action: (IntArray) -> Unit) {
    val pow = (1..length).fold(1L) { acc: Long, _: Int -> acc * numberOfChoices }
    val patterns = if (pow in 1..Int.MAX_VALUE) pow.toInt() else error("$pow is too large!")
    for (i in 0 until patterns) {
        val array = IntArray(length)
        var div = 1
        for (j in 0 until length) {
            array[length - j - 1] = (i / div) % numberOfChoices
            div *= numberOfChoices
        }
        action(array)
    }
}


Measured memory_bytes: 43392
program ideone;
var
	l, k, n, i, q : integer;
	p : string;
begin
	readln(n,k);
	l := 1;
	for i := 1 to n do
	begin
		if (l*2) > (l+k) then
		begin
			l := l+k;
		end
		else begin
			l := l*2;
		end;
	end;
	writeln(l);
end.

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(int i=0;i<n;i++)
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())

int main(){

     int n;
     cin>>n;
     double prob[n+1];
     double dp[n+1][n+1];
     double res=0;
     FOR(i,1,n){
          cin>>prob[i];
     }
     FOR(i,0,n){
          FOR(j,0,n){
               dp[i][j]=0;
          }

     }
     dp[1][0]=1.0-prob[1];
     FOR(i,2,n)
     { dp[i][0]=dp[i-1][0]*(1.0-prob[i]);}
     dp[1][1]=prob[1];
     FOR(i,2,n){
          dp[i][i]=dp[i-1][i-1]*prob[i];
     }

     FOR(i,1,n){
          FOR(j,1,i-1){
               dp[i][j]=dp[i-1][j]*(1.0-prob[i])+dp[i - 1][j - 1] * prob[i];
          }
     }

      for(int i = n / 2 + 1; i <=n; ++i)
        res += dp[n][i];
    
    // print answer to the 10th precision
    cout << fixed << setprecision(10) << res;

    return 0;
}

Measured memory_bytes: 70528
N = int(input())
S = input()

stackString = ""
resultCount = 0
for s in S:
    if stackString == "" and s == "A":
        stackString += "a"
    elif stackString == "a" and s == "B":
        stackString += "b"
    elif stackString == "ab" and s == "C":
        stackString = ""
        resultCount += 1
    else:
        if not(stackString == "a" and s == "A"):
            stackString = ""
print(resultCount)

Measured memory_bytes: 38256
using System;
class Program
 {
        static void Main(string[] args)
        {
    　　int N,L;
            string[] str = Console.ReadLine().Split(' ');//2つ以上のスペース区切り入力の取得
            N = int.Parse(str[0]);  //数値で受け取りたい場合は変換する
            L = int.Parse(str[1]);
            int pickup_idx = -1;
            int pickup_val = 1000;
            int sum = 0;
            for(int i=0;i<N;i++)
            {
              int v = L+i;
              sum += v;
              if(Math.Abs(v)<Math.Abs(pickup_val))
              {
                pickup_idx = i;
                pickup_val = v;
              }
            }
            sum -= pickup_val;
            Console.WriteLine(sum);
        }
 }

Measured memory_bytes: 13140
import java.util.Scanner;;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt(),K=sc.nextInt();
		
		int max=N-(K-1);
		int min=1;
		
		if(K==1) {
			System.out.println(0);
		}else {
			System.out.println(max-min);
		}
		
		
		
		
		
		
		
	}

	
}
		

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n;   cin >> n;
    vector<ll> a(n);
    vector<vector<ll>> dp(n+2, vector<ll>(n+2, 0));
    rep(i, n){
        cin >> a[i];
        // dp[i][i] = a[i];
    }
    FOR(len, 1, n+1){
        for(int i=0; i<=n; i++){
            int j = i+len;
            if(n<j) continue;
            if((n-len)%2==0){
                dp[i][j] = max(dp[i+1][j]+a[i], dp[i][j-1]+a[j-1]);
            }else{
                dp[i][j] = min(dp[i+1][j]-a[i], dp[i][j-1]-a[j-1]);
            }
        }
    }
    cout << dp[0][n] << endl;
    
}


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

int main() {
  int A,B;
  cin >> A >> B;
  vector<int> V(3);
  V.at(0)=A+B;
  V.at(1)=A-B;
  V.at(2)=A*B;
  sort(V.begin(),V.end());
  cout << V.at(2) << endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
MOD = 10 ** 9 + 7
Broken = [0] * (N + 100)
for i in range(M):
    ai = int(input())
    Broken[ai] = 1


dp = [0] * (N + 100)
dp[0] = 1

for i in range(N):
    if (Broken[i + 1] == 0) and (i + 1 <= N):
        dp[i + 1] += dp[i]
        dp[i + 1] %= MOD

    if (Broken[i + 2] == 0) and (i + 2 <= N):
        dp[i + 2] += dp[i]
        dp[i + 2] %= MOD

print(dp[N] % MOD)


Measured memory_bytes: 7668
import sys
readline = sys.stdin.readline
write = sys.stdout.write

N = int(readline())
*A, = map(int, readline().split())

data = [0]*(N+1)
def add(k, v):
    while k <= N:
        data[k] += v
        k += k & -k
def get(k):
    s = 0
    while k:
        s += data[k]
        k -= k & -k
    return s


ans = N*(N-1)//2
for a in map({a: i+1 for i, a in enumerate(sorted(A))}.__getitem__, A):
    ans -= get(a)
    add(a, 1)
write("%d\n" % ans)




Measured memory_bytes: 39880
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int n;
set<int> s;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        int x;
        scanf("%d",&x);
        if(s.find(x)==s.end())s.insert(x);
        else s.erase(x);
    }
    printf("%d\n",(int)s.size());
    return 0;
}

Measured memory_bytes: 4864
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (a < b && b < c) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 26204
from fractions import gcd
 
def ceil(a, b):
  return -(-a//b)
 
a, b, c, d = map(int, input().split())
cd_lcm = c*d//gcd(c, d)
c_left, c_right = ceil(a,c), b//c
d_left, d_right = ceil(a,d), b//d
cd_left, cd_right = ceil(a,cd_lcm), b//(cd_lcm)
cv, dv, cdv = c_right - c_left + 1, d_right - d_left + 1, cd_right - cd_left + 1
print((b - a + 1) - (cv + dv - cdv))

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
const int N=100010;
int n,m;
int tot,bian[N<<1],zhi[N<<1],col[N<<1],nxt[N<<1],head[N];
int add(int a,int b,int c,int d){
    ++tot,bian[tot]=b,col[tot]=c,zhi[tot]=d,nxt[tot]=head[a],head[a]=tot;
}
int cnt,sum[N*60],lson[N*60],rson[N*60];
int updata(int pre,int l,int r,int x,int z){
	int rt=++cnt;
	sum[rt]=sum[pre]+z;
	lson[rt]=lson[pre],rson[rt]=rson[pre];
    if(l==r)return rt;
	int mid=(l+r)/2;
	if(x<=mid)lson[rt]=updata(lson[rt],l,mid,x,z);
	else rson[rt]=updata(rson[rt],mid+1,r,x,z);
    return rt;
}
int query(int rt,int l,int r,int x){
    if(l==r)return sum[rt];
    int mid=(l+r)/2;
    if(x<=mid)return query(lson[rt],l,mid,x);
    else return query(rson[rt],mid+1,r,x);
}
#define S 1,N-1
int cntroot[N],sumroot[N];
int fa[N],dep[N],top[N],hson[N],sz[N];
int dis[N];
void dfs(int x,int f){
	fa[x]=f;
	dep[x]=dep[f]+1;
	sz[x]=1;
    for(int i=head[x];i;i=nxt[i]){
        int y=bian[i];
        if(y==f)continue;
        cntroot[y]=updata(cntroot[x],S,col[i],1);
        sumroot[y]=updata(sumroot[x],S,col[i],zhi[i]);
        dis[y]=dis[x]+zhi[i];
        dfs(y,x);
        sz[x]+=y;
        if(sz[y]>sz[hson[x]])hson[x]=y;
	}
}
void dfs(int x,int f,int r){
    top[x]=r;
    if(hson[x]){
        dfs(hson[x],x,r);
	}
	for(int i=head[x];i;i=nxt[i]){
	    int y=bian[i];
	    if(y==f||y==hson[x])continue;
	    dfs(y,x,y);
	}
}
int lca(int x,int y){
	while(top[x]!=top[y]){
	    if(dep[top[x]]<dep[top[y]])swap(x,y);
	    x=fa[top[x]];
	}
	if(dep[x]>dep[y])swap(x,y);
	return x;
}
int main(){
//	freopen("1.in","r",stdin);
    cin>>n>>m;
    for(int i=1;i<n;++i){
    	int a,b,c,d;
        scanf("%d%d%d%d",&a,&b,&c,&d);
        add(a,b,c,d);
        add(b,a,c,d);
	}
	dfs(1,0);
	dfs(1,0,1);
	while(m--){
	    int a,b,c,d;
	    scanf("%d%d%d%d",&a,&b,&c,&d);
	    int l=lca(c,d);
	    int cnt=query(cntroot[c],S,a)+query(cntroot[d],S,a)-2*query(cntroot[l],S,a);
	    int sum=query(sumroot[c],S,a)+query(sumroot[d],S,a)-2*query(sumroot[l],S,a);
	    int di=dis[c]+dis[d]-2*dis[l];
	    printf("%d\n",di-sum+cnt*b);
	}
}

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

const int N = 4e5+1 , M = 5e3+5;

int n , m , a[N] , mx1[N] , mx2[N];

int main()
{
    cin>>n;
    mx1[0] = -1000;
    mx2[n+1] = -1000;
    for(int i = 1;i<=n;i++)
    {
        cin>>a[i];
        mx1[i] = max(mx1[i-1] , a[i]);
    }
    for(int i = n;i>0;i--)
    {
        mx2[i] = max(mx2[i+1] , a[i]);
    }
    for(int i = 1;i<=n;i++)
        cout<<max( mx1[i-1] , mx2[i+1] )<<"\n";

    return 0;
}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std ;
int main(){
    int n;
    int c;
    cin >> n;
    double sum=0.0;
    for(int i=0;i<n;i++){
        cin >> c;
        sum+=1.0/c;
    }
    double R = 1/sum;
    cout << setprecision(16) << R << endl;
}

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

int main(){

  int n;
  int a[100];

  cin >> n;
  for(int i=n-1; i>=0; i--){
    cin >> a[i];
  }

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



Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int vals[100001][3] = { 0 };

int search(int s, int t, multimap<int, int> & es)
{
	vals[s][0] = 1;

	queue<pair<int, int>> searched;
	searched.push({ s, 0 });

	while (!searched.empty()) {
		int c = searched.front().first;
		int cv = vals[c][searched.front().second];
		searched.pop();

		auto it0 = es.find(c);
		while (it0 != es.end() && it0->first == c) {
			int p1 = it0->second;
			if (vals[p1][cv % 3] != 0) {
				it0++;
				continue;
			}

			if (p1 == t && cv % 3 == 0) {
				return cv / 3;
			}

			int r = cv % 3;
			vals[p1][r] = cv + 1;
			searched.push({ p1,r });

			it0++;
		}
	}

	return -1;
}

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

	int n, m; cin >> n >> m;
	multimap<int, int> es;
	FOR_LT(i, 0, m) {
		int u, v; cin >> u >> v;
		es.insert({ u,v });
	}


	int s, t; cin >> s >> t;

	int ans = search(s, t, es);
	cout << ans << endl;

	return 0;
}

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

string a[200];
int main()
{
    int n,m;
    cin>>n>>m;
    for (int i=1; i<=n;i++)
        cin>>a[i];
    int i,j;
    while (1)
    {
        int ff=0;
        for ( i=1; i<=n; i++)
        {
            for (j=0; j<m; j++)
            {
                if (a[i][j]!='.') break;
            }
            if (j==m)
            {
                ff=1; break;
            }
        }
        if (ff==0) break;
        for ( i=1; i<=n; i++)
        {
            for (j=0; j<m; j++)
            {
                if (a[i][j]!='.') break;
            }
            if (j==m)
            {
                for (int k=i;k<=n;k++)
                    a[k]=a[k+1];
                n--;
            }
        }
    }
   /* cout<<endl;
    for (int i=1; i<=n; i++)
        cout<<a[i]<<endl;*/
    while (1)
    {
        int ff=0;
        for (j=0; j<m; j++)
        {
            for (i=1; i<=n;i++)
            {
                if (a[i][j]!='.') break;
            }
            if (i==n+1)
            {   ff=1; break;}
        }
        if (ff==0) break;
        for (j=0; j<m; j++)
        {
            for (i=1; i<=n;i++)
            {
                if (a[i][j]!='.') break;
            }
            if (i==n+1)
            {
                m--;
                for (int k=1;k<=n;k++)
                {
                    for (int u=j;u<m;u++)
                        a[k][u]=a[k][u+1];
                    a[k][m]=0;
                }
                //break;
            }
        }
    }

    for (int i=1; i<=n; i++)
    {
        for (int j=0;j<m;j++)
        {
            cout<<a[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const ll  MOD = 1000000007LL;
/*メモ 
*/
int main(){
    int n;std::cin >> n;
    VEC(int,a,n);
    int ans=INF;
    rep(i,102){
        int dum=0;
        rep(j,n){
            dum+=(i-a[j])*(i-a[j]);
        }
        ans=min(ans,dum);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S,A;
    for(int i = 0;i < 3;i++){
        cin >> S;
        A += S[i];
    }
    cout << A << endl;
}

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

int main()
{
   int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51} ;
   int n;
   cin>>n;
   for(int i=0;i<32;i++)
   {
       if(n==i+1)
       {
           cout<<a[i]<<endl;
       }
   }
}


Measured memory_bytes: 3516
#include <iostream>

using namespace std;

void get(int count,string s)
{
   if(count==3)
   {
    cout<<count<<endl;
    return;
   }
    if(count==1)
    {cout<<count<<endl;
    return;
    }
    else if(count==0)
    {cout<<count<<endl; return;
    }
    else
    {
        if(s[1]=='S')
        {cout<<"1"<<endl;
        return;
        }

        else {cout<<"2"<<endl;
        return;
        }
    }

}
int main()
{
    string s;
    cin>>s;
    int count=0;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='R')
        {
            count++;
        }

    }
    get(count,s);


    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
//using System.Linq;
//using System.Text;
//using System.Threading.Tasks;

//namespace _1_A
//{
    class Program
    {
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string[] array = a.Split(' ');

        int c = int.Parse(array[0]), d = int.Parse(array[1]);
        if (c < d)
            Console.WriteLine("a < b");
        else if (c > d)
            Console.WriteLine("a > b");
        else
            Console.WriteLine("a == b");
    }
    }
//}

Measured memory_bytes: 8816
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n, x, max int
	var s string
	fmt.Scan(&n, &s)
	slice := strings.Split(s, "")

	for _, c := range slice {
		if c == "I" {
			x++
		} else if c == "D" {
			x--
		}
		if x > max {
			max = x
		}
	}

	fmt.Println(max)
}


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

public class Main {
    public static final long mod = (long)1e9+7;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        long h = in.nl();
        long w = in.nl();
        if(h==1||w==1){
            out.println(1);
        }else{
            out.println(h/2*w+(h%2)*(w+1)/2);
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21204