akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int INF = 19191919;

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

    const int N = 1<<n;
    vector<int> dp(N,INF);
    dp[0] = 0;
    rep(i,m){
        int a,b;
        cin >>a >>b;

        int mask = 0;
        rep(j,b){
            int x;
            cin >>x;
            --x;
            mask |= (1<<x);
        }

        for(int j=N-1; j>=0; --j){
            int nx = j|mask;
            dp[nx] = min(dp[nx], dp[j]+a);
        }
    }

    int ans = dp[N-1];
    if(ans == INF) ans = -1;
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(A: "List[List[int]]", N: int, b: "List[int]"):
    f = [[False] * (N) for i in range(N)]
    for i in range(N):
        for j in range(3):
            for k in range(3):
                if b[i] == A[j][k]:
                    f[j][k] = True
    t = False
    for i in range(3):
        if all([f[i][k] for k in range(3)]):
            t = True

    for i in range(3):
        if all([f[k][i] for k in range(3)]):
            t = True
    
    if all([f[k][k] for k in range(3)]):
        t = True

    if f[0][2] and f[1][1] and f[2][0]:
        t = True

    if t:
        print(YES)
    else:
        print(NO)

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    N = int(next(tokens))  # type: int
    b = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(A, N, b)

if __name__ == '__main__':
    main()


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

def zehnpaard():
    from collections import Counter

    n, k = map(int, input().split())
    c = Counter(int(x) for x in input().split())
    print(sum(val for key, val in c.most_common()[k:]))

def main():
    """WA"""
    N, K = list(map(int, input().split()))
    a_list = list(map(int, input().split()))

    import collections
    c_dict = collections.Counter(a_list)
    diff = len(c_dict) - K
    if diff <= 0:
        print(0)
        exit()

    # diff個消す。カウント数が少ないやつを。
    ans = 0
    c_list = sorted(c_dict.items(), key=lambda x: x[1])
    for i in range(diff):
        ans += c_list[i][1]
    print(ans)

def main2():
    N, K = list(map(int, input().split()))
    a_list = list(map(int, input().split()))

    import collections
    c_dict = collections.Counter(a_list)
    print(sum(value for key, value in c_dict.most_common()[K:]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 40016
#include <iostream>

using namespace std;

int N;

int main() {

    cin >> N;
    
    int ans = 0;
    if(N < 105){
        cout << 0 << endl;
        return 0;
    }

    for(int i = 105; i <= N ; i+=2){
        int g = 0;
        for(int j = 1; j <= i; j++){
            if(i % j == 0)
                ++g;
        }
        if(g == 8)
             ans++;;
    }
    
    cout << ans << endl;


}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = new int[5];
            for (int b = 0; b < 5; b++)
                a[b] = int.Parse(Console.ReadLine());
            int c, d;
            c = a[0] * a[4];
            if (a[4] > a[2])
                d = a[1] + ((a[4] - a[2]) * a[3]);
            else
                d = a[1];
            if (c <= d)
                Console.WriteLine(c);
            else
                Console.WriteLine(d);
        }
    }
}

Measured memory_bytes: 9032
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <climits>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define revrep(i, n) for(int i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
#define chmin(x, y) x = min(x, y);
#define chmax(x, y) x = max(x, y);

//const ll INFL = LLONG_MAX;//10^18 = 2^60
const ll INFL = 1LL<<60;
//const int INF = INT_MAX;
const ll INF = 1 << 30;//10^9
ll MOD = 1000000007;
//ll MOD = 998244353;

vector<ll> dy = {0, 1, 0, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, 0, -1, 0, 1, -1, 1, -1, 0};

void pres(double A){printf("%.9lf\n", A);}
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}
ll cnt_bit(ll x){return __builtin_popcountll(x);}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x; k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){
  ll res = x / gcd(x, y);
  res *= y;
  return res;
};


//コンビネーション
const int MAXcomb = 2000010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

const int MAXkai = 200010;
ll kai_memo[MAXkai];
ll kai(ll N){
  if(kai_memo[N] != 0) return kai_memo[N];
  if(N <= 1) return 1;
  return kai_memo[N] = N * kai(N-1) % MOD;
}

ll disit(ll s, ll base = 10){
  ll res = 0;
  while(s){
    res++;
    s /= base;
  }
  return res;
}

ll N, K;

ll A[110];
ll dp[110][256][110];
void solve(){
  cin >> N >> K;
  rep(i, N) cin >> A[i];
  dp[0][0][0] = 1;
  rep(i, N)rep(j, 256)rep(k, N){
    dp[i+1][j^A[i]][k+1] += dp[i][j][k];
    dp[i+1][j^A[i]][k+1] %= MOD;
    dp[i+1][j][k] += dp[i][j][k];
    dp[i+1][j][k] %= MOD;
  }
  ll ans = 0;
  rep(i, N+1){
    ans += dp[N][K][i] * kai(i) % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}


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


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

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
//constexpr long long MOD = (ll) 1e9 + 7;
constexpr long long MOD = 998244353LL;
typedef vector<ll> Array;
typedef vector<Array> Matrix;


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

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}


void solve(){
    ll n;
    cin>>n;

    Array a(n,0);
    REP(i,n-1){
        ll b;
        cin>>b;
        b--;
        a[b]++;
    }

    for(auto i:a) cout<<i<<en;
}

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

    solve();
    //ll t;cin>>t;REP(i,t) solve();

    return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <string.h>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <stack>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#define ll long long int
#define pb push_back
#define x first
#define y second
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORR(i, a, b) for(int i = a; i>b; i--)
#define ri(x) scanf("%d", &x)
#define rl(x) scanf("%lld", &x)
using namespace std;

vector<ll> A;

ll solve(){
    int n = 3;
    FOR(i, 0, n){
    	ll u;
    	rl(u);
    	A.pb(u);
    }
    sort(A.begin(), A.end());
    ll cost = 0;
    FOR(i, 0, n-1){
    	cost += A[i+1] - A[i];
    }
    return cost;
}

int main(){
	ll ans = solve();
	printf("%lld", ans);
	return 0;
}

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

#define N_MAX 200000

int N;
long A[N_MAX];

void input(){
    cin >> N;
    for (int i=0;i<N;i++)
        cin >> A[i];
}

void solve(){
    //いままでの最大値からの差が、必要最低限の踏み台の高さ。
    long total = 0;
    long A_max = 0;
    for (int i=0;i<N;i++){
        A_max = max(A[i],A_max);
        total += A_max - A[i];
    }
    cout << total << endl;
}

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


Measured memory_bytes: 4656
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int w, a, b;
  cin >> w >> a >> b;
  int c = a + w;
  int d = b + w;
  if (c < b) {
	cout << b - c << endl;
	return 0;
  }
  if (a > d) {
	cout << a - d << endl;
	return 0;
  }
  else {
	cout << 0 << endl;
	return 0;
  }
  return 0;
}



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

n,m=map(int,input().split())

d={}
for i in range(m):
    a,b=map(int,input().split())
    if a in d:
        d[a]=d[a]+1
    else:
        d[a]=1

    if b in d:
        d[b]=d[b]+1
    else:
        d[b]=1

for i in range(n):
    if i+1 in d:
        print(d[i+1])
    else:
        print(0)


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int N, T;
	cin >> N >> T;
	int a[N];
	rep(i, 0, N) cin >> a[i];

	int min_v[N];
	int min_tmp = a[0];
	min_v[0] = min_tmp;
	rep(i, 1, N) {
		if(min_tmp > a[i]) {
			min_tmp = a[i];
		}
		min_v[i] = min_tmp;
	}

	vector<int> v;
	v.push_back(0);
	rep(i, 1, N) v.push_back(a[i] - min_v[i]);
	vsort(v);
	;
	cout << v.end() - lower_bound(v.begin(), v.end(), v[v.size() - 1]) << endl;



}


Measured memory_bytes: 1660
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>
using namespace std;

int main(void)
{
	int a, b, c;
	cin >> a >> b >> c;
	if (c <= a - b) { cout << 0 << endl; }
	else { cout << c - a + b << endl; }
}

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

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;

int main() {
    string s;
    cin >> s;
    int count = 0;
    int n = s.size();
    vector<long long> dp1(n);
    vector<long long> dp2(n);
    dp1[0] = s[0] - '0';
    dp2[0] = 11 - (s[0] - '0');
    rep(i, 1, n) {
        int t = s[i] - '0';
        dp1[i] = min(dp1[i - 1] + t, dp2[i - 1] + t);
        dp2[i] = min(dp1[i - 1] + 11 - t, dp2[i - 1] + 9 - t);
    }
    // rep(i, 0, n) {
    //     int t = s[0] - '0';
    //     cout << dp1[i] << "," << dp2[i] << endl;
    // }
    cout << min(dp1[n - 1], dp2[n - 1]) << endl;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

typedef long long ll;
typedef pair <int, int> pii;
const int maxn=3e5+10;
int R,C,n;

struct node{
  int x,y;
}A[maxn];

set<pii>S;

int c1[maxn],c2[maxn];
vector<node>vx[maxn],vy[maxn];

void solve() {
  cin>>R>>C>>n;
  rep(i,1,n){
    A[i].x=read(),A[i].y=read();
    c1[A[i].x]++,c2[A[i].y]++;
    S.insert({A[i].x,A[i].y});
    vx[A[i].x].push_back(A[i]);
    vy[A[i].y].push_back(A[i]);
  }
  multiset<int>val;
  rep(i,0,300000)val.insert(c2[i]);
  int ans=0;
  rep(i,1,n){
    chkmax(ans,c1[A[i].x]+c2[A[i].y]-1);
  }
  rep(i,1,300000)if(c1[i]){
    vector<int>vec;
    for(node p:vx[i]){
      vec.push_back(p.y);
      val.erase(val.find(c2[p.y]));
    }
    chkmax(ans,c1[i]+*val.rbegin());
    for(int x:vec)val.insert(c2[x]);
  }
  val.clear();
  rep(i,0,300000)val.insert(c1[i]);
  rep(i,1,300000)if(c2[i]){
    vector<int>vec;
    for(node p:vy[i]){
      vec.push_back(p.x);
      val.erase(val.find(c1[p.x]));
    }
    chkmax(ans,c2[i]+*val.rbegin());
    for(int x:vec)val.insert(c1[x]);
  }
  cout<<ans<<endl;
}

signed main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;

  if (A + B == 3) {
    cout << 3 << endl;
  } else if (A + B == 4) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}


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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i <= _##i poi i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i < _##i poi i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i >= _##i poi i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i > _##i poi i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

int main(){
    double a, b, c, d, e, f poi
    while(cin >> a >> b >> c >> d >> e >> f)
        printf("%.3f %.3f\n", lov_yet((b * f - c * e) / (b * d - a * e)), lov_yet((a * f - c * d) / (a * e - b * d))) poi
    return 0 poi
}

Measured memory_bytes: 1228
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int N,K;
int main(){
  cin>>N>>K;
  prin(N-K+1);
  return 0;
}


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

#define ran 1001001

int n;
bool used[ran];
vector<int> e[ran];
int deg[ran];

int q[ran], l, r;
int len[ran];

void add_edge(int a1, int b1, int a2, int b2) {
	if(a1>b1) swap(a1, b1);
	if(a2>b2) swap(a2, b2);
	int id1 = (a1-1)*n+b1;
	int id2 = (a2-1)*n+b2;
	
	used[id1] = used[id2] = true;
	e[id1].push_back(id2);
	deg[id2]++;
}

int main() {
	scanf("%d", &n);
	for(int i=1;i<=n;i++) {
		int last = -1;
		for(int j=1;j<n;j++) {
			int x; scanf("%d", &x);
			if (j>1) 
				add_edge(i, last, i, x);
			last = x;
		}
	}
	if(n==2) used[2] = true;
	
	int ans = 1;
	l = r = 0;
	for(int i=1;i<=n*n;i++)
		if(used[i] && !deg[i]) {
			q[r++] = i;
			len[i] = 1;
		}
	while(l<r) {
		int cur = q[l++];
		for(int i=0;i<(int)e[cur].size();i++) {
			int nxt = e[cur][i];
			deg[nxt]--;
			if (!deg[nxt]) q[r++] = nxt;
			
			len[nxt] = max(len[nxt], len[cur]+1);
			ans = max(ans, len[nxt]);
		}
	}
	if (l<n*(n-1)/2) puts("-1");
	else printf("%d\n", ans);
	
	return 0;
}

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

int ex(char c){
	int rtn;
	if(c == 'A') rtn = 0;
	if(c == 'B') rtn = 1;
	if(c == 'C') rtn = 2;
	return rtn;
}

void disp(bool cup[]){
	if(cup[0] == true) cout <<'A';
	if(cup[1] == true) cout <<'B';
	if(cup[2] == true) cout <<'C';
	cout <<endl;
}

int main(){
	bool cup[3] = {false};
	char cng1, cng2;
	cup[0] = true;
	while(scanf("%c,%c", &cng1, &cng2) != EOF){
		cng1 = ex(cng1);
		cng2 = ex(cng2);
		swap(cup[cng1], cup[cng2]);
	}
	disp(cup);
	return 0;
}

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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        vector<vector<pair<int,int>>> info(N);
        for(int i=0;i<N;i++){
            int A; cin >> A;
            if(A > 0){
                info[i] = vector<pair<int, int>>(A);
                for(auto& p : info[i]) cin >> p.first >> p.second;
            }
        }
        int res = 0;
        for(int i=1;i<(1<<N);i++){
            bool ok = true;
            int v = 0;
            for(int j=0;j<N;j++){
                if(!(i&(1<<j))) continue;
                ++v;
                for(auto& p : info[j]){
                    if((i>>(p.first-1))%2 != p.second) ok = false;
                }
            }
            if(ok){
                res = max(res, v);
            }
        }
        cout << res << endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

char cnt[1000];
signed main(){
    string s;
    cin >> s;
    int n = s.size();
    sort(all(s));
    reps(i,n-1){
        if(s[i] == s[i-1]){
            cout << "no\n";
            return 0;
        }
    }   
    cout << "yes\n";
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    
    string ans = "";
    
    int delta_x = tx - sx;
    int delta_y = ty - sy;
    
    //1回目
    for (int i = 0; i < delta_y; i++) ans += 'U';
    for (int i = 0; i < delta_x; i++) ans += 'R';
    
    //2回目
    for (int i = 0; i < delta_y; i++) ans += 'D';
    for (int i = 0; i < delta_x; i++) ans += 'L';
    
    
    //3回目
    ans += 'L';
    for (int i = 0; i < delta_y+1; i++) ans += 'U';
    for (int i = 0; i < delta_x+1; i++) ans += 'R';
    ans += 'D';
    
    //４回目
    ans += 'R';
    for (int i = 0; i < delta_y+1; i++) ans += 'D';
    for (int i = 0; i < delta_x+1; i++) ans += 'L';
    ans += 'U';
    
    cout << ans << 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() {
  ll n, k, q, tmp;
  cin >> n >> k >> q;
  vector<int>a(n);
  rep(i,n) a[i] = k-q;
  rep(i,q) {
    cin >> tmp;
    tmp--;
    a[tmp]++;
  }
  
  rep(i,n) {
    if(a[i]<=0) {
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
  }
  return 0;
}
  
  
  
  

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main() {

    string s; cin >> s;
    ll sum = 0;
    rep(i,s.size()) sum += s[i] - '0';
    if (sum % 9 == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}





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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;
#define vv vector

/////////////////////////////////////////////////////
#define Nmx 202020

ll N;
ll X[202020], Y[202020];
ll U[202020];
pair<pll,ll> xyst[202020],yxst[202020];
set<pll> mk1[404040],mk2[404040];
ll i, j, k;

set<pll>& gt1(const ll& x,const ll& y){
    return mk1[x + y];
}

set<pll>& gt2(const ll&x,const ll& y){
    return mk2[Nmx - x + y];
}


int main(){
    scanf("%lld", &N);
    rep(i,0,N){
        char u[10];
        scanf("%lld%lld%s", &X[i], &Y[i], u);
        U[i] = u[0];
        yxst[i] = {{Y[i], X[i]}, i};
        xyst[i] = {{X[i], Y[i]}, i};
        gt1(X[i], Y[i]).insert({X[i], i});
        gt2(X[i], Y[i]).insert({X[i], i});
    }
    ll ans = 1e9;
    sort(yxst, yxst + N);
    sort(xyst, xyst + N);
    j = -1;
    k = -1;
    rep(i,0,N){
        ll ii = xyst[i].second;
        if(j!=X[ii]){
            j = X[ii];
            k = -1;
        }
        if('U'==U[ii])
            k = Y[ii];
        if(k!=-1&&'D'==U[ii])
            ans = min(ans, abs(Y[ii] - k) * 5);
    }
    //printf("%lld\n", ans);
    j = -1;
    k = -1;
    rep(i,0,N){
        ll ii = yxst[i].second;
        if(j!=Y[ii]){
            j = Y[ii];
            k = -1;
        }
        if('R'==U[ii])
            k = X[ii];
        if(k!=-1&&'L'==U[ii])
            ans = min(ans, abs(X[ii] - k) * 5);
    }
    
    //printf("%lld\n", ans);

    rep(i,0,Nmx*2){
        if(mk1[i].size()==0)
            continue;
        
        ll r = -1, d = -1;
        for(auto a:mk1[i]){
            ll ii = a.second;
            if('R'==U[ii])
                r = X[ii];
            if('D'==U[ii])
                d = X[ii];
            if(r!=-1&&'U'==U[ii])
                ans = min(ans, abs(r - X[ii])*10);
            if(d!=-1&&'L'==U[ii])
                ans = min(ans, abs(d - X[ii])*10);
        }
    }
    rep(i,0,Nmx*2){
        if(mk2[i].size()==0)
            continue;
        
        ll r = -1, u = -1;
        for(auto a:mk2[i]){
            ll ii = a.second;
            if('R'==U[ii])
                r = X[ii];
            if('U'==U[ii])
                u = X[ii];
            if(r!=-1&&'D'==U[ii])
                ans = min(ans, abs(r - X[ii])*10);
            if(u!=-1&&'L'==U[ii])
                ans = min(ans, abs(u - X[ii])*10);
        }
        //printf("%lld:%lld\n", i, ans);
    }
    


    if(ans==1e9){
        printf("SAFE\n");
    }else{
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 80776
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[20];
char s[20];
int main(){
	int a,b,c;
	while(scanf("%d%d%d",&a,&b,&c),~a){
		bool ok=false;
		sprintf(str,"%d",b);
		for(int i=2;i<17;i++){
			long long tmp=0;
			for(int j=0;str[j];j++){
				tmp*=i;
				tmp+=str[j]-'0';
			}
			bool OK=true;
			for(int j=0;str[j];j++){
				if(str[j]-'0'>=i)OK=false;
			}
			if(tmp==a&&OK)ok=true;
		}
		if(!ok){
			printf("-1\n");continue;
		}
		for(int i=a+1;i<=c;i++){
			int to=999999999;
			for(int j=2;j<17;j++){
				int tmp=i;
				int at=0;
				while(tmp){
					s[at++]='0'+tmp%j;
					tmp/=j;
				}
				ok=true;
				for(int k=0;k<at;k++){
					if(s[k]>'9')ok=false;
					str[at-1-k]=s[k];
				}
				if(ok){
					str[at]=0;
					int val;
					sscanf(str,"%d",&val);
					if(b<=val)to=min(to,val);
				}
			}
			b=to;
		}
		printf("%d\n",b);
	}
}

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

using namespace std;

int main(){
  int d;
  int t;
  int s;
  cin >> d >> t >> s;
  int ans = d-(t*s);
  if( ans <= 0 ){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;

using edge= struct{int to;ll cost;};


template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;//昇順

//A 65
//a 97

int main(){
  int n;cin>>n;
  ll w[n];
  ll sum=0;
  REP(i,n){
    cin>>w[i];
    sum+=w[i];
  }
  ll min=11000000;
  ll rest=0;
  for(int i=0;i<n;i++){
    rest+=w[i];
    sum-=w[i];
    if(abs(rest-sum)<min){
      min=abs(rest-sum);
    }
  }
  cout<<min<<endl;
}

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

ll dp[310][310][310];

bool check(int L, int R, int X, int r, int g, int b) {
	int cnt = 0;
	if (L <= r && r <= R) cnt++;
	if (L <= g && g <= R) cnt++;
	if (L <= b && b <= R) cnt++;
	return (cnt == X) ? true : false;
}

int main(int argc, char const *argv[])
{
	int n, m; cin >> n >> m;
	vector<int> L(m), R(m), X(m); {
		rep(i, m) {
			cin >> L[i] >> R[i] >> X[i];
		}
	}
	map<int, vector<int>> r2i; {
		rep(i, m) r2i[R[i]].push_back(i);
	}

	dp[0][0][0] = 1;	
	rep(r, n)rep(g, n)rep(b, n) {
		if (dp[r][g][b] == 0) continue;
		int k = max({r, g, b});
		(dp[k + 1][g][b] += dp[r][g][b]) %= MOD;
		(dp[r][k + 1][b] += dp[r][g][b]) %= MOD;
		(dp[r][g][k + 1] += dp[r][g][b]) %= MOD;

		// printf("dp[%d][%d][%d] = %lld\n", r, g, b, dp[r][g][b]);
		// printf("%lld %lld %lld\n", dp[k + 1][g][b], dp[r][k + 1][b], dp[r][g][k + 1]);
		for (auto i : r2i[k + 1]) {
			if (!check(L[i], R[i], X[i], k + 1, g, b)) dp[k + 1][g][b] = 0;
			if (!check(L[i], R[i], X[i], r, k + 1, b)) dp[r][k + 1][b] = 0;
			if (!check(L[i], R[i], X[i], r, g, k + 1)) dp[r][g][k + 1] = 0;
		}
	}

	ll ans = 0;
	rep(i, n)rep(j, n) (ans += dp[n][i][j]) %= MOD;
	rep(i, n)rep(j, n) (ans += dp[i][n][j]) %= MOD;
	rep(i, n)rep(j, n) (ans += dp[i][n][j]) %= MOD;
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 227584
function Main(input) {
    input = input.trim();
    input = input.split(" ");
    var a = parseInt(input[0]);        

    var bool = true;
    while(bool){
        var flag = false;
        for(var i=2;i<a;i++){
            if(a%i==0){
                flag = true;
                break;
            }
        }
        
        if(!flag){
            bool = false;
        }else{
                a+=1;
            }
    }
    
    console.log(a);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 


Measured memory_bytes: 7372
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>

ll a, b;

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

	REP(i, 1000) {
		if (i * a - i + 1 >= b) {
			cout << i << endl;
			return 0;
		}
	}
}

	

Measured memory_bytes: 256
#include<stdio.h>//２つの整数 a と b を読み込んで、以下の値を計算するプログラム
#include<math.h>

int main(void){
 
	double x,y;
     
	scanf("%lf %lf",&x,&y);
	printf("%d %d %f",(int)(x/y),(int)fmod(x,y),x/y);
	return 0;
}

Measured memory_bytes: 648
a = input().split()
if a[0] == a[1] and a[0] != a[2]:
    print("Yes")
elif a[0] == a[2] and a[0] != a[1]:
    print("Yes")
elif a[1] == a[2] and a[1] != a[0]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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

const ll mod = 1e9+7;

int main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll>a(n);
    ll sum = 0,sum2 = 0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
        sum2 += a[i]*a[i];
        sum %= mod;
        sum2 %= mod;
    }
    ll ans = sum*sum-sum2;
    if(ans%2 == 0){
        ans = ans/2%mod;
    }else{
        ans += mod;
        ans = ans/2%mod;
    }

    cout << ans << endl;
    
    



    return 0;
}


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

#define rep(i,n) for (int i = 0; i < (n); ++i)

int n, a[1005], ans;

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

    while (cin >> n, n) {
        ans = (int)1e9 + 7;
        rep(i,n) cin >> a[i];
        rep(i,n) {
            for (int j = i+1; j < n; ++j) {
                if (ans > abs(a[i] - a[j])) ans = abs(a[i] - a[j]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3092
import math
A,B,H,M = map(int,input().split())
tmp_a = ((H%12)*30+0.5*M)%360
tmp_b = 6*M
tmp = abs(tmp_a-tmp_b)
r_2 = A**2 + B**2 -2*A*B*math.cos(math.radians(tmp))
print(math.sqrt(r_2))

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

using namespace std;

int MinCostTopDownDP(int source, int destination, int * height, vector<int> &Memo);



int main() {
  int n;
  cin >> n;
  int height[n];
  for (int i = 0; i < n; i++) {
    cin >> height[i];
  }
  vector<int> Memo(n, -1);
  cout << MinCostTopDownDP(0, n - 1, height, Memo) << endl;
  return 0;
}

int MinCostTopDownDP(int source, int destination, int * height, vector<int> &Memo) { // Memoized
  if (source < destination) {

    if (Memo[source] == -1) {
      if (source == destination - 1)
        return abs(height[source] - height[destination]);
      int route1_min_value = MinCostTopDownDP(source + 1, destination, height, Memo) + abs(height[source] - height[source + 1]);

      int route2_min_value = MinCostTopDownDP(source + 2, destination, height, Memo) + abs(height[source] - height[source + 2]);

      Memo[source] = min(route1_min_value, route2_min_value);
    }
    return Memo[source];    
  }
  return 0;
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
int main(){
    int S;
    cin >> S;
    string N;
    cin >> N;
    long long int r=0, g=0, b=0;
    for (int i = 0; i < N.size(); i++)
    {
        if(N.at(i) == 'R') r++;
        else if(N.at(i) == 'G') g++;
        else b++;
    }
    
    long long int ans = r * g * b;
    for (int i = 0; i < N.size(); i++)
    {
        for (int j = i + 1; j < N.size(); j++)
        {
            int k = j * 2 - i;
            if(k < N.size() && N.at(i) != N.at(j) && N.at(j) != N.at(k) && N.at(k) != N.at(i))
                ans--;
        }
    }
    cout << ans << endl;   
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin>>s;
  if(s[0]==s[2] && s[0]!=s[1] && s[1]==s[3]){
    cout<<"Yes"<<endl;
  }else if(s[0]==s[1] && s[0]!=s[2] && s[2]==s[3]){
    cout<<"Yes"<<endl;
  }else if(s[0]==s[3] && s[0]!=s[1] && s[1]==s[2]){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

string S;
vector<string>candidate;

void dfs(string cur){
	if(cur.size() > S.size()){
		return;
	}
	candidate.push_back(cur);
	dfs(cur + "3");
	dfs(cur + "5");
	dfs(cur + "7");
}

bool check(string str){
	bool three = false;
	bool five = false;
	bool seven = false;
	for(auto ch : str){
		if(ch == '3'){
			three = true;
		}else if(ch =='5'){
			five = true;
		}else if(ch =='7'){
			seven = true;
		}else {
			return false;
		}
	}
	return (three && five && seven && atol(str.c_str()) <= atol(S.c_str()));
}

int main(){
	cin >> S;
	dfs("");
	long long count = 0;
	for(long long i = 0; i < candidate.size(); i++){
		if(check(candidate[i])){
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 2172
#include <stdio.h>

int a,b,c ;

int main(void){

    scanf ("%d%d%d",&a,&b,&c) ;
    
    if ( a==b ){
        printf ("%d",c) ;
        
    } else if ( b==c ){
        printf ("%d",a) ;
        
    } else if ( c==a ){
        printf ("%d",b) ;
        
    }
    
    return 0 ;
    
}

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

typedef long long ll;
typedef double ld;
typedef pair <ll, ll> pll;

#define pb push_back
#define mp make_pair
#define all(_c) _c.begin(), _c.end()

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

    map <string, ld> val {
        {"JPY", 1.0},
        {"BTC", 380000.0}
    };

    int n;
    cin >> n;

    ld ans = 0;
    while (n--) {
        string u; ld x;
        cin >> x >> u;
        ans += val[u]*x;
    }

    cout << fixed << setprecision(20) << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
#include<cstdio>
#include<iostream>
#include<math.h>
#include<algorithm>
using namespace std;
long long n,m,sum;
long long num[200003],b[200003],c[200003];
int main(){
	cin>>n>>m;
    for(int i=1;i<=n;i++){
    	cin>>num[i];
	}
    for(int i=2;i<=n;i++){
        int l=num[i-1],r=num[i];
        if(l<r){
        	b[l+1]++,b[r+1]--,c[r+1]-=r-l;
		}else{
			b[l+1]++,b[r+m+1]--,c[r+m+1]-=r+m-l;
		}
    }
    for(int i=1;i<=2*m;i++){
    	b[i]+=b[i-1];
	}
    for(int i=1;i<=2*m;i++){
    	c[i]+=c[i-1]+b[i];
	}
    for(int i=1;i<=m;i++){
    	b[i]+=b[i+m],c[i]+=c[i+m],sum+=b[i];
	}
	long long ans=9999999999999;
    for(int i=1;i<=m;i++){
    	ans=min(ans,sum-c[i]+b[i]);
	}
    cout<<ans<<endl;
    return 0;
}
/*

in:
10 10
10 9 8 7 6 5 4 3 2 1
out:
45

*/
//沈♂哲贝是最强的！！！
//大佬祝您AK
//周♂雨扬是最强的！！！
/*
题意：有个M个档的台灯，有N个目标档，需要按顺序调到相应目标档，
每次只能按按钮一步一步进档，或者按一下按钮跳到x档，问x档初始化为最优档时，
完成任务按的最少次数按钮。
*/

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    ll d,a;
    cin >> n >> d >> a;
    vector<pair<ll, ll>> v(n);
    rep(i,n){
        cin >> v[i].first >> v[i].second;
    }
    sort(ALL(v));
    ll ans = 0, now = 0;
    deque<pair<ll, ll>> que;
    rep(i,n){
        while(!que.empty() && que.front().first < v[i].first - 2 * d){
            now -= que.front().second;
            que.pop_front();
        }
        ll cnt = max(0LL, (v[i].second - a * now + a - 1) / a);
        ans += cnt;
        que.emplace_back(v[i].first, cnt);
        now += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6656
#include <iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#define INF 114514810

using namespace std;

int n, m;
int d[510][510];
int main(void)
{
    while(1) {
        scanf("%d %d", &n, &m);
        if(n==0 && m==0) break;
        for(int i=0; i<n; i++)
            for(int j=0; j<n; j++)
                d[i][j] = INF;

        int a, b;
        for(int i=0; i<m; i++) {
            scanf("%d %d", &a, &b);
            a--; b--;
            d[a][b] = d[b][a] = 1;
        }
        // Warshall-Floyd
        for(int k=0; k<n; k++)
            for(int i=0; i<n; i++)
                for(int j=0; j<n; j++)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        // the cost from 0 to i == 1or2
        int ans = 0;
        for(int i=1; i<n; i++) {
            if(d[0][i] == 1 || d[0][i] == 2)
                ans++;
        }
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 2188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
ll inf = 1e18;
int a[3];
int n,m;
int main() {
    cin >> n >> m;
    for (int i = 0; i < n; i++) a[i] = -1;
    for (int i = 0; i < m; i++) {
        int s,c;
        cin >> s >> c;
        s--;
        if (a[s] == -1) {
            a[s] = c;
        } else {
            if (a[s] != c) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    if (a[0] == 0 && n == 1) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1 && a[0] == -1) {
        cout << 0 << endl;
        return 0;
    }
    if (a[0] == -1) {
        a[0] = 1;
    } else if (a[0] == 0) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i < n; i++) {
        if (a[i] == -1) a[i] = 0;
    }
    for (int i = 0; i < n; i++) {
        cout << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
bool latte[10000000];
int main(){
    fill(latte,latte+10000000,true);
    latte[0]=latte[1]=false;
    for(int i=2;i*i<10000000;i++){
        if(latte[i]){
            for(int j=i+i;j<10000000;j+=i)latte[j]=false;
        }
    }

    int n;
    while(scanf("%d",&n)&&n){
        for(int i=n;i>0;i--){
            if(latte[i]&&latte[i-2]&&latte[i-6]&&latte[i-8]){
                printf("%d\n",i);
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 10792
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
char s[] = "1001010111001010";
int main()
{
    long long i,n,x,y,c1=0,c2=0;
    ios::sync_with_stdio(0),cin.tie(0);
    cin>>i>>n;
    cout<<2*n-i;
    return 0;
}


Measured memory_bytes: 256
local a = io.read()
local b = io.read()
local at, bt = {}, {}
for i = 1, #a do at[i] = a:sub(i, i) end
for i = 1, #b do bt[i] = b:sub(i, i) end
table.sort(at)
table.sort(bt, function(x, y) return x > y end)
a = ""
for i = 1, #at do a = a .. at[i] end
b = ""
for i = 1, #bt do b = b .. bt[i] end
print(a < b and "Yes" or "No")


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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#define INF numeric_limits<int>::infinity()
#pragma endregion


int main()
{
    rep(i, 3) {
        int a, b, c, d, e, f;
        cin >> a >> b >> c >> d >> e >> f;
        int at1 = a * 3600 + b * 60 + c;
        int at2 = d * 3600 + e * 60 + f;

        int dif = at2 - at1;
        int h = dif / 3600;
        dif = dif % 3600;
        int m = dif / 60;
        dif = dif % 60;
        int s = dif;
        printf("%d %d %d\n", h, m, s);
    }
    return 0;
}

Measured memory_bytes: 3172
import numpy as np

H,W=list(map(int,input().split(" ")))
A=np.full((H,W),".",np.str)

# 入力を格納
for h in range(H):
    A[h,:]=list(input())

# 各行について
for h in reversed(range(H)):
    if (A[h,:]==".").all()==True: # 全ての要素が"."の場合行を削除
        A=np.delete(A,h,axis=0)

# 各列について
for w in reversed(range(A.shape[1])):
    if (A[:,w]==".").all()==True: # 全ての要素が"."の場合列を削除
        A=np.delete(A,w,axis=1)

# 出力
for a in A:
    print("".join(a))

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

using ll = long long;

// 2以上の整数を素因数分解
vector<pair<ll, int>> decompositPrime(ll x) {
  vector<pair<ll, int>> ret;
  ll now = x, div = 2, count = 0;
  while(x >= div * div){
    if(now % div == 0){
      count++;
      now /= div;
    }
    else{
      if(count > 0){
        ret.push_back(make_pair(div, count));
      }
      count = 0;
      div++;
    }
  }
  if(now > 1) ret.push_back(make_pair(now, 1));
  return ret;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, p;
  cin >> n >> p;
  
  vector<pair<ll, int>> x = decompositPrime(p);
  
  ll ans = 1;
  for(int i = 0; i < x.size(); i++){
    if(x.at(i).second >= n){
      ans *= pow(x.at(i).first, x.at(i).second / n);
    }
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 512
#!/usr/bin/env python3
import sys
import math

MOD = 2  # type: int

def solve(N: int, a: "List[int]"):
    b = [0] * N
    res = []
    balls = 0
    for i in range(N-1, -1, -1):
        k = i + 1
        c = 0
        for j in range(2, N // k + 1):
            c += b[j*k-1]
        b[i] = (a[i] + c) % 2
        if b[i]:
            res.append(str(k))
            balls += 1
    print(balls)
    if balls > 0:
        print(' '.join(res))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()


Measured memory_bytes: 78200
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
using namespace std;
int main() {
	int n, m, ma = 0, mi = 100000, l, r;
	cin >> n >>m;
	for (int i = 0; i < m; ++i) {
		cin >> l >> r;
		mi = min(r, mi);
		ma = max(l, ma);
	}
	if (mi - ma < 0)cout << 0 << endl;
	else cout << mi - ma + 1 << endl;
	return 0;
}

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

int main() {
  ll n; cin>>n;
  ll ans=0;
  rep(i,n){
    ans+=(n/i)*((n/i)+1)*i/2;
  }
  cout<<ans;
}

Measured memory_bytes: 3568
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    X = int(input())

    goods = (100, 101, 102, 103, 104, 105)
    dp = [float('inf')] * (X + 1)
    dp[0] = 0
    for i in range(X + 1):
        for j in range(6):
            if i - goods[j] >= 0:
                dp[i] = min(dp[i], dp[i - goods[j]] + 1)
    if type(dp[X]) is int:
        print(1)
    else:
        print(0)


main()


Measured memory_bytes: 6104
# UnionFindで参考にしたページ
# http://www.geocities.jp/m_hiroi/light/pyalgo61.html


# 集合の代表を求める
def find(x):
    if link[x] < 0:
        return x
    else:
        # 経路の圧縮
        link[x] = find(link[x])
        return link[x]


# 併合
def union(x, y):
    s1 = find(x)
    s2 = find(y)
    if s1 != s2:
        if link[s1] >= link[s2]:
            # 小さいほうが個数が多い
            link[s1] += link[s2]
            link[s2] = s1
        else:
            link[s2] += link[s1]
            link[s1] = s2
        return True
    return False


N, M = map(int, input().split())
p = list(map(int, input().split()))
link = [-1 for _ in range(N + 1)]

for _ in range(M):
    x, y = map(int, input().split())
    union(x, y)

cnt = 0
for i in range(1, N + 1):
    if find(i) == find(p[i - 1]):
        cnt += 1
print(cnt)


Measured memory_bytes: 13812
from math import factorial as f
S = raw_input()
lS = len(S)
d = [S.count(i) for i in set(list(S))]
dd = sum([i%2 for i in d])
if (lS%2 == 0 and dd != 0 ) or (lS%2 == 1 and dd != 1): 
		print 0
else:
	dnm = 1
	for i in d:
		dnm *= f(i/2)
	print f(lS/2)/dnm

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

int main()
{
	int w,h,x,y,r;

	cin >> w >> h >> x >> y >> r;

	if(r <= x && x <= w-r && r <= y && y <= h-r){
		
		cout << "Yes" << endl;

	}
	else{

		cout << "No" << endl;

	}

	return 0;
}

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

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

Measured memory_bytes: 256