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

// 0-indexed
template <class T>
struct SegmentTree {
  // a,b,c: T, e:T(unit)
  // abc = (ab)c = a(bc)
  // ae = ea = a
  typedef function<T(T, T)> F;
  int n;
  F f;
  T unit;
  vector<T> dat;
  SegmentTree(){};
  SegmentTree(int newn, F f, T t) : f(f), unit(t) { init(newn); }
  SegmentTree(const vector<T> &v, F f, T t) : f(f), unit(t) {
    int _n = v.size();
    init(v.size());
    for (int i = 0; i < _n; ++i) dat[n + i] = v[i];
    for (int i = n - 1; i; --i) dat[i] = f(dat[i << 1], dat[(i << 1) | 1]);
  }
  void init(int newn) {
    n = 1;
    while (n < newn) n <<= 1;
    dat.assign(n << 1, unit);
  }

  // "go up" process
  void update(int k, T newdata) {
    dat[k += n] = newdata;
    while (k >>= 1) {
      dat[k] = f(dat[(k << 1) | 0], dat[(k << 1) | 1]);
    }
  }
  // [a,b)
  T query(int a, int b) {
    T vl = unit, vr = unit;
    for (int l = a + n, r = b + n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) vl = f(vl, dat[l++]);
      if (r & 1) vr = f(dat[--r], vr);
    }
    return f(vl, vr);
  }
  // func(unit) == false
  // min left: st <= res && func(seg.query(res,n))
  template <typename C>
  int find_left(int st, C &func, T acc, int k, int l, int r) {
    if (l + 1 == r) {
      acc = f(acc, dat[k]);
      return func(acc) ? l : -1;
    }
    int mid = (l + r) >> 1;
    if (mid <= st) return find_left(st, func, acc, (k << 1) | 1, mid, r);
    if (st <= l && !func(f(acc, dat[k]))) {
      acc = f(acc, dat[k]);
      return -1;
    }
    int nres = find_left(st, func, acc, (k << 1), l, mid);
    if (~nres) return nres;
    return find_left(st, func, acc, (k << 1) | 1, mid, r);
  }
  template <typename C>
  int find_left(int st, C &func) {
    T acc = unit;
    return find_left(st, func, acc, 1, 0, n);
  }

  // max right: res <= st && func(seg.query(0,res))
  template <typename C>
  int find_right(int st, C &func, T acc, int k, int l, int r) {
    if (l + 1 == r) {
      acc = f(dat[k], acc);
      return func(acc) ? r : -1;
    }
    int mid = (l + r) >> 1;
    if (st <= mid) return find_right(st, func, acc, k << 1, l, mid);
    if (r <= st && !func(f(dat[k], acc))) {
      acc = f(dat[k], acc);
      return -1;
    }
    int nres = find_right(st, func, acc, (k << 1) | 1, mid, r);
    if (~nres) return nres;
    return find_right(st, func, acc, k << 1, l, mid);
  }
  template <typename C>
  int find_right(int st, C &func) {
    T acc = unit;
    return find_right(st, func, acc, 1, 0, n);
  }
};

int n, k;
vector<int> a;
SegmentTree<int> seg;

int main() {
  cin >> n >> k;
  a.resize(n);
  for (auto &p : a) cin >> p;
  {
    auto f = [](int l, int r) { return max(l, r); };
    seg = SegmentTree<int>(300001, f, 0);
  }
  for (int i = 0; i < n; ++i) {
    int l = max(a[i] - k, 0), r = min(a[i] + k + 1, 300001);
    seg.update(a[i], seg.query(l, r) + 1);
  }
  cout << seg.query(0, 300001) << endl;
  return 0;
}

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

struct Centroid{
  Int n;
  vector<Int> sz,centroid,used;
  vector<vector<Int> > G;
  Centroid(){}
  Centroid(Int n):n(n),sz(n,1),used(n,0),G(n){}

  void add_edge(Int u,Int v){
    G[u].emplace_back(v);
    G[v].emplace_back(u);
  }

  void input(Int offset=0){
    for(Int i=1;i<n;i++){
      Int u,v;
      cin>>u>>v;
      add_edge(u+offset,v+offset);
    }
  }
  
  void dfs(Int v,Int p) {
    Int ok=1;
    for (Int u:G[v]){
      if(u==p||used[u]) continue;
      dfs(u,v);
      sz[v]+=sz[u];
      ok&=(sz[u]<=n/2);
    }
    ok&=(n-sz[v]<=n/2);
    if(ok) centroid.push_back(v);
  };
  
  vector<Int> build(Int r=0) {
    n=0;
    auto bfs=[&](Int k){      
      queue<Int> q;
      sz[r]=k;
      q.emplace(r);
      while(!q.empty()){
	Int v=q.front();q.pop();
	n+=k;
	for(Int u:G[v]){
	  if(sz[u]==k||used[u]) continue;
	  sz[u]=k;
	  q.emplace(u);
	}
      }
    };
    bfs(0);bfs(1);
    centroid.clear();
    dfs(r,-1);
    return centroid;
  }

  void disable(Int v){
    used[v]=1;
  }

  void enable(Int v){
    used[v]=0;
  }
};


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 n;
  cin>>n;
  Centroid G(n);
  vector<map<Int, Int> > cost(n);
  for(Int i=1;i<n;i++){
    Int a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    G.add_edge(a,b);
    cost[a][b]=cost[b][a]=c;
  }
  Int ans=0;
  vector<Int> sz(n);
  function<void(Int,Int)> dfs=[&](Int v,Int p){
    sz[v]=1;
    for(Int u:G.G[v]){
      if(u==p) continue;
      dfs(u,v);
      sz[v]+=sz[u];
    }
    if(~p) ans+=min(sz[v],n-sz[v])*2*cost[p][v];
  };
  dfs(0,-1);
  auto cs=G.build();
  if(cs.size()==2u){
    ans-=cost[cs[0]][cs[1]];
  }else{
    Int tmp=1e9;
    for(Int u:G.G[cs[0]])
      chmin(tmp,cost[cs[0]][u]);
    ans-=tmp;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 34560
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

vvl G;
vl dp;  // dp[v] : vを根とする部分木のトーナメントの深さの最小値

void dfs(ll v, ll p = -1) {
    // 行きの処理はこのへんに書く
    vl vec;  // vの子のdp値を要素とするvector
    for(auto u : G[v]) {
        if(u == p) {
            continue;
        }
        dfs(u, v);
        // 帰りの処理はこのへんに書く
        vec.pb(dp[u]);
    }
    if(vec.size() == 0) {  // 葉のときのdpの値は0
        dp[v] = 0;
    }
    else {
        sort(rall(vec));
        rep(i, vec.size()) {
            chmax(dp[v], vec[i] + i+1);
        }
    }
}

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

    vl a(n);
    exrep(i, 1, n-1) {
        cin >> a[i];
        a[i]--;
    }

    G.resize(n);
    exrep(v, 1, n-1) {
        G[v].pb(a[v]);
        G[a[v]].pb(v);
    }

    dp.resize(n);
    const ll root = 0;
    dfs(root);

    out(dp[root]);
    re0;
}

Measured memory_bytes: 18176
#include<cstdio>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef vector<int> vec;
const int N=1e5+10;
int n,k,k1;
vec p,q,t,a,b,c,s,t1,s1;
vec inv(vec a){
	vec b;
	b.resize(n);
	for (int i=0;i<n;i++)
		b[a[i]]=i;
	return b;
}
vec divi(vec a,vec b){
	vec c;
	c.resize(n);
	for (int i=0;i<n;i++)
		c[a[i]]=b[i];
	return c;
}
vec mult(vec a,vec b){
	return divi(inv(b),a);
}
void write(vec a){
	for (int i=0;i<n;i++)printf("%d ",a[i]+1);
	cout<<endl;
}
int main(){
	cin>>n>>k;
	p.resize(n),q.resize(n);
	for (int i=0;i<n;i++)scanf("%d",&p[i]),p[i]--;
	for (int i=0;i<n;i++)scanf("%d",&q[i]),q[i]--;
	s.resize(n);
	for (int i=0;i<n;i++)s[i]=i;
	s1=s;
	t=mult(mult(mult(q,inv(p)),inv(q)),p);
	t1=inv(t);
	k1=(k-1)/6;
	k=k-k1*6;
	while (k1){
		if (k1&1)s=mult(s,t),s1=mult(s1,t1);
		t=mult(t,t);
		t1=mult(t1,t1);
		k1>>=1;
	}
	a=mult(mult(s,p),s1);
	b=mult(mult(s,q),s1);
	if (k==1){
		write(a);
		return 0;
	}
	while (k>2){
		c=divi(a,b);
		a=b,b=c;k--;
	}
	write(b);
}

Measured memory_bytes: 6736
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace kp
{
    public class Program
    {
        //static long[,] cmb;
        static int MAX_INT = 1000000007;
        static void Main(string[] args)
        {
            //int N = Int32.Parse(Console.ReadLine());
            int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();
            int N = input[0];
            int M = input[1];

            HashSet<int> stair = new HashSet<int>();
            for(int i=0; i<M; i++)
            {
                int a = Int32.Parse(Console.ReadLine());
                stair.Add(a);
            }

            long[] dp = new long[N+1]; // i段目にたどり着く方法は何通り？
            dp[0] = 1;
            if (stair.Contains(1))
                dp[1] = 0;
            else
                dp[1] = 1;
            #region DP
            for (int i = 2; i <= N; i++ )
            {
                // i段目が壊れていたら0
                if(stair.Contains(i))
                {
                    dp[i] = 0;
                }
                else
                {
                    dp[i] = dp[i - 1] + dp[i - 2];
                    dp[i] %= MAX_INT;
                }
            }
                
            #endregion DP
            Console.WriteLine(dp[N] + "");


        }
    }
}


Measured memory_bytes: 18272
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;

ll dp[100];
ll power[64];

int main(void){
    dp[0]=1;
    for(ll i=1;i<=40;i++){
        dp[i]=2*dp[i-1]+1;
    }
    ll h;
    cin>>h;
    power[0]=1;
    for(ll i=1;i<=63;i++){
        power[i]=2*power[i-1];
    }
    for(ll i=0;i<63;i++){
        if(power[i]<=h){
            if(h<power[i+1]){
                cout<<dp[i]<<endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w, n;
    cin >> h >> w >> n;
    vector<P> d(n);
    set<P> st;
    rep(i, 0, n){
        int y, x;
        cin >> y >> x;
        y--; x--;
        d[i] = {y, x};
        st.insert({y, x});
    }
    sort(d.begin(), d.end());
    vector<int> yoko(h);
    yoko[0] = 0;
    rep(i, 1, h - 1){
        yoko[i] = yoko[i - 1];
        if(yoko[i] != w - 1){
            if(!st.count({i, yoko[i - 1] + 1})){
                yoko[i]++;
            }
        }
    }
    int ans = h;
    rep(i, 0, n){
        if(d[i].first == 0) continue;
        if(yoko[d[i].first - 1] >= d[i].second){
            ans = min(ans, d[i].first);
        }
    }
    cout << ans << endl;
}

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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	int I=1;
	while (I*2<=N)
		I *=2;
	cout <<I <<endl;
	return 0;
}



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



int main(){

	int W,H;
	scanf("%d %d",&W,&H);

	int num_0 = 0,num_1 = 0;
	int array[2][1000],tmp[1000];

	for(int i = 0; i < W; i++)scanf("%d",&array[0][i]);
	for(int i = 0; i < W; i++){
		if(array[0][i] == 0)num_0++;
		else{
			num_1++;
		}
	}

	if(abs(num_0-num_1) > 1){
		printf("no\n");
		return 0;
	}

	int index = 0;
	bool FLG;

	for(int loop = 1; loop < H; loop++){
		for(int i = 0; i < W; i++)scanf("%d",&tmp[i]);
		FLG = true;

		if(index == 0){
			for(int i = 0; i < W; i++){
				if(tmp[i] != array[0][i]){
					FLG = false;
					break;
				}
			}
			if(!FLG){
				num_0 = 0,num_1 = 0;
				for(int i = 0; i < W; i++){
					if(tmp[i] == 0)num_0++;
					else{
						num_1++;
					}
				}
				if(abs(num_0-num_1) > 1){
					printf("no\n");
					return 0;
				}
				for(int i = 0; i < W; i++){
					if(tmp[i] == array[0][i]){
						printf("no\n");
						return 0;
					}
				}
				for(int i = 0; i < W; i++){
					array[1][i] = tmp[i];
				}
				index = 1;
			}
		}else{ //index == 1

			for(int i = 0; i < W; i++){
				if(array[0][i] != tmp[i]){
					FLG = false;
					break;
				}
			}
			if(FLG)continue;

			FLG = true;
			for(int i = 0; i < W; i++){
				if(array[1][i] != tmp[i]){
					FLG = false;
					break;
				}
			}
			if(!FLG){
				printf("no\n");
				return 0;
			}
		}
	}

	if(index == 0){
		printf("no\n");
		return 0;
	}

	printf("yes\n");

	return 0;
}

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

int main() {
    int n;
    cin >> n;
    char marks[4] = {'S', 'H', 'C', 'D'};

    bool cards[4][13] = {};
    for (int i = 0; i < n; i++) {
        char mark;
        int rank;
        cin >> mark >> rank;
        int x;
        if (mark == 'S') x = 0;
        else if (mark == 'H') x = 1;
        else if (mark == 'C') x = 2;
        else x = 3;
        cards[x][rank - 1] = true;
    }
    for (int i = 0; i < 4; i++) {
        for (int j = 0; j < 13; j++) {
            if (!cards[i][j]) cout << marks[i] << ' ' << j + 1 << endl;
        }
    }
}

Measured memory_bytes: 1160
#include <iostream>
#include <algorithm>
#include <cstdlib>
using namespace std;

string add(string a, string b) {
  while(a.size() < b.size()) a.insert(0, "0");
  while(b.size() < a.size()) b.insert(0, "0");
  a.insert(0, "0");
  b.insert(0, "0");
  int n = a.size();
  string c(n, '0');
  for(int i = n-1, t = 0; i >= 0; --i) {
    int tmp = (a[i]-'0') + (b[i]-'0') + t;
    c[i] = tmp%10 + '0';
    t = tmp/10;
  }
  while(c[0] == '0') {
    c.erase(0, 1);
  }
  if(c.empty()) return "0";
  else return c;
}

int main() {
  string t;
  while(cin >> t) {
    string a, b, c;
    {
      int i = t.find('+');
      int j = t.find('=');
      a = t.substr(0, i);
      b = t.substr(i+1, j-(i+1));
      c = t.substr(j+1);
    }
    try {
      for(char x = '0'; x <= '9'; ++x) {
        string na = a;
        string nb = b;
        string nc = c;
        replace(na.begin(), na.end(), 'X', x);
        replace(nb.begin(), nb.end(), 'X', x);
        replace(nc.begin(), nc.end(), 'X', x);
        if(na[0] == '0' && na.size() >= 2) continue;
        if(nb[0] == '0' && nb.size() >= 2) continue;
        if(nc[0] == '0' && nc.size() >= 2) continue;
        if(add(na,nb) == nc) {
          cout << x << endl;
          throw 0;
        }
      }
      cout << "NA" << endl;
    } catch(...) {}
  }
  return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
  int data[2][4000],n,i,f,id;
  long long a,b;
  while(1){
    cin>>n;
    if(n==0) break;
    for(i=0;i<4000;i++) data[0][i]=-1,data[1][i]=0;
    for(i=0;i<n;i++){
      cin>>id>>a>>b;
      if(a*b>999999) a=1000000,b=1;
      for(f=0;f<i+1;f++){
	if(data[0][f]==id){
	  data[1][f]+=(a*b);
	  break;
	}else if(data[0][f]==-1){
	  data[0][f]=id;
	  data[1][f]=(a*b);
	  break;
	}
      }
    }
    for(i=0,f=0;i<n;i++)
      if(data[1][i]>=1000000)cout<<data[0][i]<<"\n",f=1;
    if(f==0)cout<<"NA"<<endl;
  }
}

Measured memory_bytes: 0
/*
    Mbak Sana Dong
    Mbak Chaeyoung Dong
*/
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    int n,i,j,k,x,y,ans,temp,curr,m;
    cin >> x >> y;
    for(i=1;i<=1000000;i++)
    {
        int chaeng = 8*i;
        chaeng /= 100;
        int sana = 10*i;
        sana /= 100;
        if(chaeng == x && sana ==  y)
        {
            printf("%d\n", i);
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using  namespace std;
 
int main()
{
    ll a,sum=0;
    cin >> a;
    
    for(ll i=1; i<=a; i++){
        for(ll j=i; j<=a; j=j+i){
            sum = sum + j;
        }
    }
    cout<< sum <<endl;
    return 0;
}

Measured memory_bytes: 3652
use std::io::*;
use std::str::FromStr;

const MOD: i32 = 1000000007;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n: usize = read();
    let m: usize = read();
    let mut b = vec![false; n + 1];

    for _ in 0..m {
        b[read::<usize>()] = true;
    }

    let mut dp = vec![0; n + 1];
    dp[0] = 1;
    for i in 1..n + 1 {
        dp[i] =
            if b[i] {
                0
            } else {
                dp[i - 1] + (if i >= 2 { dp[i - 2] } else { 0 })
            };
        dp[i] %= MOD;
    }

    println!("{:?}", dp[n]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	map<string,int>cnt;
	rep(i,n){
		string s;
		cin>>s;
		cnt[s]++;
	}
	vector<string>ans;
	ans.push_back("AC");
	ans.push_back("WA");
	ans.push_back("TLE");
	ans.push_back("RE");
	rep(i,4){
		cout<<ans[i]<<" x "<<cnt[ans[i]]<<endl;
	}
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int k;
    cin >> k;
    dump((k / 2) * ((k + 1) / 2));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = ll(1e15)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
    ll N, M; cin >> N >> M;
    vector<ll> S(5), C(5);

    rep(i, M) cin >> S[i] >> C[i];


    if (N == 1) {
        bool f = true;
        rep(i, M) {
            if (S[i] != 1) f = false;
            if (C[i] != 0) f = false;
        }
        if (f) {
            cout << "0" << endl;
            return 0;
        }
    }

    rep2(k, ll(pow(10, N-1)), ll(pow(10, N))) {
        bool f = true;
        rep(i, M) {
            // cout << k << endl;
            if (to_string(k).size() < S[i]) f = false;
            if (to_string(k)[S[i]-1] - '0' != C[i]) f = false;
        }
        if (f) {
            cout << k << endl;
            return 0;
        }
    }
    cout << "-1" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>

using namespace std;

int main(void)
{
	vector <long long int> v;
	long long int res = 0;
	long long int sign = 0; //0:+,1:-
	long long int n, t;
	long long int sum = 0;
	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> t;
		v.push_back(t);
	}

	sign = 0;
	for (int i = 0; i < v.size(); i++)
	{
		sum += v[i];
		if (sign == 0)
		{
			if (sum >= 0)
			{
				res += (sum + 1);
				sum = -1;
			}
		}
		else
		{
			if (sum <= 0)
			{
				res += (abs(sum) + 1);
				sum = 1;
			}
		}
		sign = 1 - sign;
	}
	t = 0;
	sign = 1;
	sum = 0;
	for (int i = 0; i < v.size(); i++)
	{
		sum += v[i];
		if (sign == 0)
		{
			if (sum >= 0)
			{
				t += (sum + 1);
				sum = -1;
			}
		}
		else
		{
			if (sum <= 0)
			{
				t += (abs(sum) + 1);
				sum = 1;
			}
		}
		sign = 1 - sign;
	}
	res = min(res, t);

	cout <<  res << endl;

	return 0;

}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
long long a,b,c,d;
int main()
{
	cin>>a>>b>>c>>d;
	cout<<(b-a+1)-(b/c-(a-1)/c)-(b/d-(a-1)/d)+(b/(c*d/__gcd(c, d))-(a-1)/(c*d/__gcd(c, d)));
}

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

bool is_prime(int n){
	if(n <= 1)
		return false;
	for(int i = 2; i * i <= n; i++)
		if(n % i == 0)
			return false;
	return true;
}

int main()
{
	int x;
	cin >> x;
	for(int i = x; i <= 200000; i++){
		if(is_prime(i)){
			cout << i << endl;
			break;
		}
	}
    return 0;
}

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

int main() {
  string o;
  string e;
  cin >> o >> e;
  
  string s;
  for(int i=0; i<e.size(); i++){
    s += o.at(i);
    s += e.at(i);
  }
  
  if(o.size() != e.size()){
    s += o.at(o.size()-1);
  }
  
  cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    int a,b;
    cin>>a>>b;
    cout<<(a+b)%24<<endl;

return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;
vector<pii> a[N];
int ans[N];
void dfs(int x,int p=-1,int colorp=0)
{
  int o=1;
  for(auto v:a[x])
  {
    if(v.fi==p) continue;
    if(o==colorp) o++;
    ans[v.se]=o;
    dfs(v.fi,x,o);
    o++;
  }
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);

      int n;
      cin>>n;
      for(int i=0;i<n-1;i++)
      {
        int x,y;
        cin>>x>>y;
        a[x].pb({y,i});
        a[y].pb({x,i});
      }
      dfs(1);
      int an=0;
      for(int i=0;i<n-1;i++) an=max(an,ans[i]);
      cout<<an<<"\n";
      for(int i=0;i<n-1;i++) cout<<ans[i]<<"\n";
}
// I never lose. I either win or I learn

Measured memory_bytes: 10752
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    int a,b,c; cin >> a >> b >> c;
    cout << ((a<b && a<c && c<b) || (a>b && a>c && c>b) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>

unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

#define LOCAL  1
#define UPLOAD 2

using namespace std;
typedef long long ll;

int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

  ll N;
  cin >> N;

  vector<ll> A, B;
  for(ll i=0;i<N+1;i++){
    ll a;
    cin >> a;
    A.push_back(a);
  }
  for(ll i=0;i<N;i++){
    ll b;
    cin >> b;
    B.push_back(b);
  }
  
  ll count = 0;
  for(ll i = 0;i<N;i++){
    ll m = min(A[i], B[i]);
    count += m;
    A[i] -= m;
    B[i] -= m;

    ll m2 = min(A[i+1], B[i]);
    count += m2;
    A[i+1] -= m2;
    B[i] -= m2;
  }

  cout << count << endl;

  
  return 0;
}

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

int N,D,X;
int A[101];
int main(){
	cin >> N >> D >> X;
	int ans = 0;
	for(int i=1;i<=N;i++){
		cin >> A[i];
	}
	for(int i=1;i<=D;i++){
		for(int j=1;j<=N;j++){
			if(i%A[j]==1 || A[j]==1) ans++;
		}
	}
	cout << ans+X << endl;
}

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


int main(){
    ll N,P,an=1;cin>>N>>P;
    map<ll,ll> m;
    rep(i,2,floor(sqrt(P))+1){
        while(P%i==0){
            P/=i;
            m[i]++;
        }
    }
    if(P!=1)m[P]++;
        
    for(auto it:m){
        if(it.first!=0){
            while(it.second>=N){
                an*=it.first;
                it.second-=N;
            }
        }
    }    
    cout<<an<<endl;
}






Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <utility>
#define maxn 5005
using namespace std;
typedef long long ll;

inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = getchar();c < '0' || c > '9';c = getchar()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = getchar()) res = res * 10 + (c - '0');
  return res * sig;
}
int n,a[4][2];
ll f[maxn * 5000];
int main(){
  n = getint();
  for(int pos = 0;pos <= 1;pos++){
    for(int item = 1;item <= 3;item++){
      a[item][pos] = getint();
    }
  }
  //A -> B
  for(int i = 1;i <= 3;i++){
    for(int j = 0;j <= n;j++){
      if(j >= a[i][0]) f[j] = max(f[j],f[j - a[i][0]] + a[i][1] - a[i][0]);
    }
  }
  ll tmp = f[n];
  for(int i = 0;i <= n;i++) f[i] = 0;
  n += tmp;
  for(int i = 1;i <= 3;i++){
    for(int j = 0;j <= n;j++){
      if(j >= a[i][1]) f[j] = max(f[j],f[j - a[i][1]] + a[i][0] - a[i][1]);
    }
  }
  printf("%lld\n",n + f[n]);
  return 0;
}


Measured memory_bytes: 195584
#include <iostream>

int
main(void)
{
  int w, h, x, y, r;
  std::cin >> w >> h >> x >> y >> r;

  if (x - r >= 0 && x + r <= w && y - r >= 0 && y + r <= h) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}



Measured memory_bytes: 3088
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (s1, s2, s3) = get!(String, String, String);
    println!("{}", vec![s1, s2, s3].into_iter().map(|s| s.chars().next().unwrap().to_uppercase().next().unwrap()).collect::<String>())
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <math.h>
int main(){
	int a,b,h,m,c,d,t;
	double e,ans;
	scanf("%d%d%d%d",&a,&b,&h,&m);//按顺时针方向，分针与12点的夹角是(m/60)*2*PI
	c=60*h+m,d=12*m;//按顺时针方向，时针与12点的夹角是(h+m/60)/12*2*PI
	//(h+m/60)/12*2*PI-(m/60)*2*PI=((60*h+m)-12*m)/720*2*PI
	if(c<d)t=c,c=d,d=t;//找出时针，分针，走过大的角度
	e=(c-d)*2*M_PI/720;//c-d，让大角减小角
	ans=sqrt(a*a+b*b-2*a*b*cos(e));//余弦定理
	printf("%.12lf\n",ans);
	return 0;
}
 

Measured memory_bytes: 2600
import java.math.BigDecimal;
import java.util.Scanner;

public class Main{
    
 
    public static void main(String[] args)  {
        new Main().solve();
    }

    void solve(){
        Scanner sc = new Scanner(System.in);        
        double L = sc.nextDouble();
        sc.close();

        double n1,n2,n3;
        
        n1 = L/3;
        n2 = L/3;
        n3 = L - n1 -n2;

        System.out.println(BigDecimal.valueOf(n1 * n2 * n3).toPlainString());

    }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    ll a,b,n;
    cin >> a >> b >> n;
    ll tmp = min(b-1,n);
    cout << (a*tmp)/b - 5*(tmp/b) << endl;
    

}


Measured memory_bytes: 3580
#include <stdio.h>
int main()
{
    int N,K,Q,x,A;
    int n[100000];
    scanf("%d %d %d",&N,&K,&Q);
    for (x=0;x<N;x++)
    {
    	n[x]=K;
	}
	for (x=0;x<Q;x++)
	{
		scanf("%d",&A);
		n[A-1]++;
	}
	for (x=0;x<N;x++)
	{
		n[x]-=Q;
	}
	for (x=0;x<N;x++)
	{
		if (n[x]>0)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	}
    return 0;
}

Measured memory_bytes: 896
#include <stdio.h>

int main(void) {
	int card[4][13];
	int n, num;
	char pic;
	
	//二次元配列を0で初期化する
	for(int i = 0; i < 4; i++) {
	    for(int j = 0; j < 13; j++) {
	        card[i][j] = 0;
	    }
	}
	
	//持っているカードの枚数を入力する
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
	    scanf("%c %d", &pic, &num);
	    //該当する箇所の値を1にする
	    //スペード(S)の場合
	    if(pic == 'S') {
	        card[0][num - 1] = 1;
	    }
	    //ハート(H)の場合
	    else if(pic == 'H') {
	        card[1][num - 1] = 1;
	    }
	    //クローバー(C)の場合
	    else if(pic == 'C') {
	        card[2][num - 1] = 1;
	    }
	    //ダイヤ(D)の場合
	    else if(pic == 'D') {
	        card[3][num - 1] = 1;
	    }
	    else{
	    i--;
	    }
	}
	
	//足りないカードを出力する
	for(int i = 0; i < 4; i++) {
	    for(int j = 0; j < 13; j++) {
	        if(card[i][j] == 0) {
	            if(i == 0) {
	                printf("%c %d\n", 'S', j + 1);
	            }
	            else if(i == 1) {
	                printf("%c %d\n", 'H', j + 1);
	            }
	            else if(i == 2) {
	                printf("%c %d\n", 'C', j + 1);
	            }
	            else if(i == 3) {
	                printf("%c %d\n", 'D', j + 1);
	            }
	        }
	    }
	}
	return 0;
}


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

int main() {
  int a, b, c, d, l, r;
  cin >> a >> b >> c >> d;
  l = a + b;
  r = c + d;
  if( l == r ) cout << "Balanced" << endl;
  if( l >  r ) cout << "Left" << endl;
  if( l <  r ) cout << "Right" << endl;
}

Measured memory_bytes: 256
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(ReadLine());
        string[] str = ReadLine().Split();
        var d = int.Parse(str[0]);
        var x = int.Parse(str[1]);
        var chocolate = x;
        var a = new int[n];
        for (var i = 0; i < n; i++)
        {
            a[i] = int.Parse(ReadLine());
            chocolate += (d - 1) / a[i] + 1;
        }
        WriteLine(chocolate);
    }
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

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

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  int h,w,n;
  cin >> h >> w >> n;
  int hw = max(h,w);
  cout << (n + hw - 1) / hw << endl;
}



Measured memory_bytes: 3640
// attr {{{
#![allow(
    dead_code,
    non_snake_case,
    unused_imports,
)]
// }}}

// use {{{
use std::io::{self,BufRead,Read,Write};
// }}}

const INF: i64 = 1_010_000_000_000_000_000;
const MOD: i64 = 1_000_000_007;
const EPS: f64 = 1e-9;

// util {{{
fn abs_diff(a: i64, b: i64) -> i64 {
    if a < b { b-a } else { a-b }
}

fn is_even(n: i64) -> bool { n % 2 == 0 }
fn is_odd (n: i64) -> bool { n % 2 != 0 }

fn div_ceil(a: i64, b: i64) -> i64 {
    let up = ((a<0) ^ (b>0)) && (a%b != 0);
    a/b + if up { 1 } else { 0 }
}

fn div_floor(a: i64, b: i64) -> i64 {
    let down = ((a>0) ^ (b>0)) && (a%b != 0);
    a/b - if down { 1 } else { 0 }
}

fn modulo(a: i64, b: i64) -> i64 {
    assert!(b > 0);
    let r = a % b;
    if r >= 0 { r } else { r+b }
}

fn chmax(xmax: &mut i64, x: i64) -> bool {
    if x > *xmax {
        *xmax = x;
        true
    }
    else {
        false
    }
}

fn chmin(xmin: &mut i64, x: i64) -> bool {
    if x < *xmin {
        *xmin = x;
        true
    }
    else {
        false
    }
}

fn _gcd(a: i64, b: i64) -> i64 {
    if b == 0 { a } else { _gcd(b, a%b) }
}

fn gcd(v: &[i64]) -> i64 {
    debug_assert!(v.len() >= 1);
    v.iter().fold(0, |a,&b| _gcd(a,b))
}

fn lcm(v: &[i64]) -> i64 {
    debug_assert!(v.len() >= 1);
    v.iter().fold(1, |a,&b| a / _gcd(a,b) * b)
}

fn _INPUT() -> String {
    let mut res = String::new();
    io::stdin().read_to_string(&mut res).expect("read_to_string()");
    res
}
// }}}

fn main() {
    let input  = _INPUT();
    let mut tokens = input.split_whitespace();
    macro_rules! RD { () => ( tokens.next().unwrap().parse().unwrap() ) }

    let s: String = RD!();
    let mut s = s.into_bytes();
    s[3] = b'8';
    let ans = String::from_utf8(s).unwrap();

    println!("{}", ans);
}


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

typedef long long ll;
#define pa pair<int, int> 
#define pal pair<long long, long long>
#define pad pair<double, double>
#define pb push_back
#define mp make_pair
#define VIN(v) for(int64_t i=0;i<(v).size();i++){cin >> (v).at(i);}

typedef vector<bool> bvec;
typedef vector<int> ivec;
typedef vector<long long> lvec;
typedef vector<double> dvec;
typedef vector<pa> pvec;



typedef vector< vector<bool> > bmat;
typedef vector< vector<int> > imat;
typedef vector<string> svec;
typedef vector< vector<string> > smat;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    int t = n;
    for(int i=1; i<n; i++){
        if (s[i]==s[i-1]) t--;
    }
    cout << t << endl;
}  


Measured memory_bytes: 512
import sys
x = int(input())
n = x % 100
maxbuy = x // 100
ans = 0
if maxbuy > 99:
	print(1)
	sys.exit()
ans += n//5
n %= 5
ans += n//4
n %= 4
ans += n//3
n %= 3
ans += n//2
n %= 2
if n == 1:
	if ans+1 <= maxbuy:
		print(1)
	else:
		print(0)
else:
	if ans <= maxbuy:
		print(1)
	else:
		print(0)

Measured memory_bytes: 3064
/* code of Ayush Tiwari
    codeforces- servermonk
    codechef- ayush572000
*/

#include <bits/stdc++.h>
#define ll long long

//STL
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define all(v) v.begin(), v.end()

//loops
#define forn(i,a,b) for(int i=a;  i<b; i++)
#define rforn(i,a,b) for(int i=a; i>=b; i--)

// defined values
#define maxn 200004
#define Mod 1000000007

// fast io
#define FIO() ios_base::sync_with_stdio(0);cin.tie(0);


using namespace std;


void solution(){

    // This is the main code
    int n;
    cin>>n;
    double dp[n+1][n+1],a[n+1];
    forn(i,1,n+1) cin>>a[i];
    memset(dp,0.0,sizeof(dp));
    dp[0][0]=1.0;
    forn(i,1,n+1){
        forn(j,0,i+1){
            if(j==0) dp[i][j]=dp[i-1][j]*(1.0-a[i]);
            else dp[i][j]=dp[i-1][j]*(1.0-a[i])+dp[i-1][j-1]*a[i];
        }
    }
    double ans=0.0;
    forn(i,(n+1)/2,n+1) ans+=dp[n][i];
    cout<<setprecision(9)<<ans;
}


int main(){
    
    #ifndef ONLINE_JUDGE
    freopen("E:/CP/input.txt","r",stdin);
    freopen("E:/CP/output.txt","w",stdout);
    #endif  
    
    FIO()   
    
    ll t=1;
    //cin>>t;
    while (t--)
    {
        solution();
    }
    return 0;
}

Measured memory_bytes: 74108
# # 整数の入力
# a = int(input())
# # スペース区切りの整数の入力
# b, c = map(int, input().split())
# # 文字列の入力
# s = input()
# a = []
# a = list(map(int, input().split()))
# import math
 
# 解説参照済み
 
n, k = map(int, input().split())
a = []
a = list(map(int, input().split()))
f = []
f = list(map(int, input().split()))
 
a.sort()
f.sort(reverse=True)
ans = 0
 
maxaf = 0
for i in range(n):
    maxaf = max(maxaf, a[i] * f[i])
 
left = 0
right = maxaf
 
while left < right:
    # print(left, right)
    mid = (left + right) // 2
    ktemp = k
    renewleft = False
    for i in range(n):
        if a[i] * f[i] > mid:
            if (a[i] * f[i] - mid + f[i] - 1) // f[i] > ktemp:
                left = mid + 1
                renewleft = True
                break
            else:
                ktemp -= (a[i] * f[i] - mid + f[i] - 1) // f[i]
    if not renewleft:
        right = mid
 
print(left)

Measured memory_bytes: 119884
import java.util.*;
import java.lang.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
      	int i;
      	for(i = 1; i<= 100; i++){
          if((a * i) % b == c){
            System.out.println("YES");
            System.exit(0); 
          }
        } 
            System.out.println("NO");
	}
} 

Measured memory_bytes: 35772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
using ll = long long;

int main() {
  double r;
  cin >> r;
  cout << acos(-1) * 2 * r << endl;
  return 0;
}


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

int n;
int x[24],y[24],r[24],c[24];
bool memo[1<<24];
char bit_count[1<<24];

bool ok(int a,int bit){
    for(int i=0;i<a;i++){
        if(((bit>>i)&1)==0)continue;
        int dist=(x[i]-x[a])*(x[i]-x[a])+(y[i]-y[a])*(y[i]-y[a]);
        int sum=(r[i]+r[a])*(r[i]+r[a]);
        if(dist<sum)return false;
    }
    return true;
}

int dfs(int bit){
    memo[bit]=true;

    int ret=n-bit_count[bit];

    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            if(((bit>>i)&1)==0)continue;
            if(((bit>>j)&1)==0)continue;
            int to_bit=(bit^(1<<i))^(1<<j);
            if(c[i]==c[j]&&ok(i,bit)&&ok(j,bit)&&!memo[to_bit]){
                ret=max(ret,dfs(to_bit));
            }
        }
    }


    return ret;
}

void solve(){
    fill_n(memo,1<<n,false);

    cout<<dfs((1<<n)-1)<<endl;
}

bool input(){
    cin>>n;
    if(!n)return false;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>r[i]>>c[i];
    return true;
}

void init(){
    for(int i=0;i<(1<<24);i++){
        for(int j=0;j<24;j++)if((i>>j)&1){
            bit_count[i]++;
        }
    }
}

int main(){
    init();
    while(input())solve();
    return 0;
}

Measured memory_bytes: 33928
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;
	FOR(i, 0, dx) {
		cout << "R";
	}
	FOR(i, 0, dy) {
		cout << "U";
	}
	FOR(i, 0, dx) {
		cout << "L";
	}
	FOR(i, 0, dy) {
		cout << "D";
	}
	cout << "L";
	FOR(i, 0, dy + 1)
		cout << "U";
	FOR(i, 0, dx + 1)
		cout << "R";
	cout << "DR";
	FOR(i, 0, dy + 1) {
		cout << "D";
	}
	FOR(i, 0, dx + 1) {
		cout << "L";
	}
	cout << "U" << endl;
	return 0;
}

Measured memory_bytes: 256
# Code for A - Kth Term
# Use input() to fetch data from STDIN
k = int(input())
a = [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]
print(a[k - 1])


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

const int N = 1e5 + 5;


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    string s;
    cin>>s;
    int len = s.length();
    for (int i = 0; i < len; i++){
        if(i+1<len&&s[i+1] == s[i]){
            cout<<i+1<<' '<<i+2<<endl;
            return 0;
        }
        if(i+2<len&&s[i] == s[i+2]){
            cout<<i+1<<' '<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<' '<<-1<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include <cstdio>
#include<cstring>
#include<string>
#include <cstdlib>  
#include<cmath>   
#include <cctype>
#include<string>
#include<set>
#include <iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

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



int main() {
	
	int n;
	cin >> n;
	int a, b, c;
	a = n / 100;
	c = n % 10;
	b = n - 100 * a - c;
	b = b / 10;
	if (a == 7 || b == 7 || c == 7)cout << "Yes" << endl;
	else cout << "No" << endl;



	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
    int w, h;
    while (cin >> h >> w, w) {
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                cout << "#."[(i + j) & 1];
            }
            cout << endl;
        }
		cout << endl;
    }
}


Measured memory_bytes: 3080
n = int(input())
ls = list(map(str,input()))
a=[]
b=[]
if n % 2 != 0:
    print('No')
else:
    for i in range(int(n/2)):
        a.append(ls[i])
    for j in range(int(n/2),n):
        b.append(ls[j])
    c = "".join(a)
    d = "".join(b)
    if c == d:
        print('Yes')
    else:
        print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
// 省略
#define ll long long
#define ld long double
// for
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Repp(i, a, b) for (int i = a; i <= (int)(b); i++)
#define Repm(i, a, b) for (int i = a; i <= (int)(b); i—-)
// 入力
#define IN(x) int x; cin >> x;
#define inll(x) ll x; cin >> x;
#define ind(x) double x; cin >> x;
#define inc(x) char x; cin >> x;
#define ins(x) string x; cin >> x;
// 出力
#define co(x) cout << x;
#define ce cout << endl;
#define cs cout << “ “;
#define keta(x) cout << fixed << setprecision(x);
// 配列
#define Sort(x) sort(x.begin(), x.end()); // 小順
#define Rev(x) reverse(x.begin(), x.end());

int main() {
  IN(N) IN(K)
  vector<int> ps(N);
  rep(i, N){
    IN(p) ps[i]=p;
  }
  int ans = 0;
  Sort(ps)
  rep(i, K){
    ans += ps[i];
  }
  co(ans)
}

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

int main(void){
    int r, D;
    vector<int> x(11);

    cin >> r >> D >> x[0];

    for(int i = 0; i < 10; i++){
        x[i + 1] = r * x[i] - D;
        cout << x[i + 1] << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

int main(void){
    int n[1000];
    int x[1000];
    int num = 0;
    int answer = 0;
    
    
    while(1){
        cin >> n[num] >> x[num];
        if(n[num] == 0 && x[num] == 0){
            break;
        }
        ++num;
    }

    for(int i = 0;i < num;++i){
        int sum = 0;
        answer = 0;
        // 1つ目の数値
        for(int j = n[i];j > 0;--j){
            if(j > x[i]){
                while(j > x[i]){
                    --j;
                }
            }
            for(int k = j - 1;k > 0;--k){
                if(k + j >= x[i]){
                    while(k + j  >= x[i]){
                        --k;
                    }
                }
                
                for(int l = k - 1;l > 0;--l){
                    sum = j + k + l;
                    if(sum == x[i]){
                        answer++;
                        l = 0;
                    }
                }
            }
        }
        cout << answer << endl;
    }
    return 0;
}



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

namespace ConsoleApp1
{
    static class AHarmony
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToList();
            int a = ab[0];
            int b = ab[1];

            int k = a + b;

            Console.WriteLine(k % 2 == 0 ? (k / 2).ToString() : "IMPOSSIBLE");
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 13396
#include <stdio.h>
int n, itr, x, a[100005], v[100005];
int main ()
{
	scanf ("%d", &n);
	for (int i = 1; i <= n; i++) scanf ("%d", a + i);
	x = 1;
	while (1) {
		if (x == 2) {
			printf ("%d\n", itr);
			return 0;
		}
		if (v[x]) {
			puts ("-1");
			return 0;
		}
		v[x] = 1;
		x = a[x], itr++;
	}
	return 0;
}

Measured memory_bytes: 896