akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP2_7_C
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            SortedSet<int> ss = new SortedSet<int>();
            for (int i = 0 ; i < n ; i++)
            {
                int[] line = ReadIntAr();
                switch (line[0])
                {
                    case 0:
                        ss.Add(line[1]);
                        Console.WriteLine(ss.Count());
                        break;
                    case 1:
                        Console.WriteLine(ss.Contains(line[1]) ? 1 : 0);
                        break;
                    case 2:
                        ss.Remove(line[1]);
                        break;
                    case 3:               
                        foreach (var item in ss.GetViewBetween(line[1], line[2]))
                        {

                            Console.WriteLine(item);
                        }
                        break;
                }

            }
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



Measured memory_bytes: 32828
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

xs = [a,b,c,d,e]
divs = [10 if x % 10 == 0 else x % 10 for x in xs]
mindiv = min(divs)
result = sum([math.ceil(x/10) * 10 for x in xs]) - 10 + mindiv
print(result)

Measured memory_bytes: 3064
/* author   : mpily :-()
title : Competing.cpp
time :Sat May 16 10:36:41 2020

*/
#include<bits/stdc++.h>
using namespace std;
const int64_t mod = 1e9+7;

int main(){
	int64_t n,a,b;
	cin >> n >> a >>b;
	if(a == 0){
		cout << 0 << "\n";
		return 0;
	}
	int64_t ans = n/(a+b);
	ans*=a;
	ans+=min(n%(a+b),a);
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100010];

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

	int n;
	cin>>n;
	if(n<6){
		cout<<n<<endl;return 0;
	}
	for(int i=1;i<=n;i++)dp[i]=1000000;
	dp[0]=0;
	for(int i=1;i<=n;i++){
		int cnt=6;
		while(cnt<=i){
			dp[i]=min(dp[i],dp[i-cnt]+1);
			cnt*=6;
		}
		cnt=9;
		while(cnt<=i){
			dp[i]=min(dp[i],dp[i-cnt]+1);
			cnt*=9;
		}
	}
	int ans=10000;
	for(int i=1;i<=n;i++)ans=min(ans,dp[i]+(n-i));
	
	 cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define dbg(x) cout << #x"="<< (x) << endl

int main(){
  string s;
  string last;
  set<string> st;
  int n;cin>>n;
  cin>>s;
  last=s;
  st.insert(s);
  rep(i,n-1){
    cin>>s;
    if(st.insert(s).second==false||s[0]!=last[last.size()-1]){
      cout<<"No"<<endl;
      return 0;
    }
    last=s;
  }
  cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define INF 1<<28
using namespace std;
 
int p[222];
int memo[1000001];
int memo2[1000001];
 
int solve(int n){

  if(!n) return 0;
  if(memo[n]) return memo[n];
   
  int ans = INF;
  for(int i=1;p[i]<=n; i++) ans = min(ans, solve(n-p[i])+1);
   
  return memo[n] = ans;
}
 
int solve2(int n){
   
  if(!n) return 0;
  if(memo2[n]) return memo2[n];
   
  int ans = INF;
  for(int i=1;p[i]<=n;i++){
    if(p[i]&1) ans = min(ans, solve2(n-p[i])+1);
  }
   
  return memo2[n] = ans;
}
 
int main(){
   
  int n;
   
  for(int i=0;i<=181;i++) p[i] = i*(i+1)*(i+2)/6;
  for(int i=1;i<=1000000;i++) solve(i), solve2(i);
   
  while(cin >> n, n) cout << solve(n) << " " << solve2(n) << endl;
}

Measured memory_bytes: 8972
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int mx = 0;
vi a, b, c, d;
int n, m, q;
vector<int> tmp;

void dfs(vi& v) {
    if (sz(v) == n) {
        int now = 0;
        rep(i, q) {
            if (v[b[i]] - v[a[i]] == c[i]) {
                now += d[i];
            }
        }
        chmax(mx, now);
        return;
    }
    int s = 1;
    if (sz(v) != 0) s = v.back();
    for (int i = s; i <= m; ++i) {
        v.pb(i);
        dfs(v);
        v.pop_back();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--;
        b[i]--;
    }

    tmp.resize(0);
    dfs(tmp);
    cout << mx << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;

long long mod = 1000000007;

long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t / 2;
    } else {
        return modpow(m, n - 1) * m % mod;
    }
}



int main() {
  	long long N,K;
    cin >> N >> K;
  	vector<long> H(N);
  	for (long i = 0; i < N; i++) cin >> H[i]; 
	sort(H.begin(), H.end());
  	long sum = 0;
  	for(long i = 0; i < N - K; i++){
      sum += H[i];
    }
  	cout << sum << endl;
}

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

#ifdef _LOCAL_DEBUG
#include "templates/debug.h"
#else
#define debug(...) 
#endif

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int& it : a)
        cin >> it;
    sort(a.begin(), a.end(), greater<int>());
    int low = 1, high = 1e9 + 4;
    while (low < high) {
        int mid = low + (high - low) / 2;
        int cuts = 0;
        for (int x : a) {
            if (x <= mid)
                break;
            cuts += (x - 1) / mid;
        }
        if (cuts <= k) {
            high = mid;
        } else {
            low = mid + 1;
        }
    }
    cout << low << '\n';
    return 0;
}

Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D ,E, k;
  cin >> A >> B >> C >> D >> E >> k;
  bool a = true;
  
  int q,w,e,r,t,y,u,i,o,p;
  q=k-abs(A-B);
  w=k-abs(A-C);
  e=k-abs(A-D);
  r=k-abs(A-E);
  t=k-abs(B-C);
  y=k-abs(B-D);
  u=k-abs(B-E);
  i=k-abs(C-D);
  o=k-abs(C-E);
  p=k-abs(D-E);
  
  if (q<0||w<0||e<0||r<0||t<0||y<0||u<0||i<0||o<0||p<0){
    a=false;
  }
  if (a) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
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 long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}



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

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

    sort(a.begin(),a.end());

    int tmp=10000000;
    rep(i,n-1){
        tmp=min(tmp,k-(a[i+1]-a[i]));
    }
    tmp=min(tmp,a[n-1]-a[0]);

    cout<<tmp<<endl;

    

    return 0;

}




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    int n;
    cin >> n;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i * j == n) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int count = 0;
    int ans = 0;

    for(int i=0 ; i<3 ; i++){
      if(s.charAt(i) == 'R'){
        count++;
      }else{
        count = 0;
      }
      ans = Math.max(count,ans);
    }
    System.out.println(ans);
  }
}


Measured memory_bytes: 35536
#include <vector>
#include <iostream>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <string>
#include <sstream>
using namespace std;

#ifndef MDEBUG
#define NDEBUG
#endif

#define x first
#define y second
#define ll long long
#define d double
#define ld long double
#define pii pair<int,int>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pll pair<ll,ll>
#define pss pair<string,string>
#define psi pair<string,int>
#define pis pair<int,string>
#define psl pair<string,ll>
#define pls pair<ll,string>
#define wh(x) (x).begin(),(x).end()
#define ri(x) int x;cin>>x;
#define rii(x,y) int x,y;cin>>x>>y;
#define rl(x) ll x;cin>>x;
#define rv(v) for(auto&_cinv:v) cin>>_cinv;
#define wv(v) for(auto&_coutv:v) cout << _coutv << ' '; cout << endl;
#define ev(v) for(auto&_cerrv:v) cerr << _cerrv << ' '; cerr << endl;
#define MOD 1000000007

namespace std { 
template<typename T,typename U>struct hash<pair<T,U>>{hash<T>t;hash<U>u;size_t operator()(const pair<T,U>&p)const{return t(p.x)^(u(p.y)<<7);}};
}
// auto fraclt = [](auto&a,auto&b) { return (ll)a.x * b.y < (ll)b.x * a.y; };
template<typename T,typename F>T bsh(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){l=m+1;r=m;}else{h=m-1;}}return r;}
template<typename T,typename F>T bsl(T l,T h,const F&f){T r=-1,m;while(l<=h){m=(l+h)/2;if(f(m)){h=m-1;r=m;}else{l=m+1;}}return r;}
template<typename T> T gcd(T a,T b) { if (a<b) swap(a,b); return b?gcd(b,a%b):a; }
template<typename T> void fracn(pair<T,T>&a) {auto g=gcd(a.x,a.y);a.x/=g;a.y/=g;}
template<typename T> struct Index { int operator[](const T&t){auto i=m.find(t);return i!=m.end()?i->y:m[t]=m.size();}int s(){return m.size();} unordered_map<T,int> m; };


int main(int,char**) {
    ios_base::sync_with_stdio(false);

    int N, K; cin >> N >> K;
    vector<int> A(N); rv(A);
    for(int&a:A) --a;
    vector<int> D(N, -1);

    int ans = 0;

    if (A[0] != 0) { A[0] = 0; ++ans; }
    D[0] = 0;

    for (int i = 1; i < N; i++) {
        if (D[i] != -1) continue;
        
        int j = i;
        int dist = 0;
        while (D[j] == -1) {
            j = A[j];
            ++dist;
        }

        dist = dist + D[j];
        j = i;
        while (D[j] == -1) {
            D[j] = dist;
            --dist;
            j = A[j];
        }
    }

    vector<pii> X(N);
    for (int i = 0; i < N; i++) {
        X[i] = {D[i],i};
    }
    sort(wh(X));
 
    vector<int> H(N,0);
    for (int i = N-1; i > 0; i--) {
        int j = X[i].y;
        if (H[j] == K-1) {
            if (A[j] != 0) ++ans;    
        } else {
            H[A[j]] = max(H[A[j]], H[j]+1);
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 2176
x, n = (int(each) for each in input().split())
if n == 0:
    print(x)
else:
    p = [int(each) for each in input().split()]
    candidate = 0
    for i in range(210):
        j = i - 105
        if j not in p and abs(j-x) < abs(candidate-x):
            candidate = j
            # print('replaced')
    print(candidate)

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

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

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint a,b; cin >> a >> b;
  cout << a*b << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>
#include <cassert>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
  int N;
  cin >> N;
  map<string, int> counts;
  for (int i = 0; i < N; ++i) {
    string S;
    cin >> S;
    counts[S]++;
  }
  vector<string> keys({"AC", "WA", "TLE", "RE"});
  for (auto key : keys) {
    cout << key << " x " << counts[key] << endl;
  }
  return 0;
}


Measured memory_bytes: 3256
eval"H,W,*A="+`dd`.split*?,
d=[1<<t=10**4]+[i=0]*~-W
A.pop(H*W).zip(A){|a,b|a=(a-b).abs;i%W<1&&N=0;N|=d[-W];d<<N=N<<a|N>>a;i+=1}
p (0..2*t).map{|i|(t-i*N[i]).abs}.min

Measured memory_bytes: 37124
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#include <stdlib.h>
#include <time.h>
#include <chrono>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

ll d;
vector<ll> c(26 + 1);
vector<vector<ll>> s(365 + 1, vector<ll>(26 + 1, 0));

ll scoring(vector<int> t)
{
    ll ans = 0;
    vector<ll> last(d + 1, 0);

    for (int i = 1; i <= d; i++)
    {
        ans += s[i][t[i]];
        last[t[i]] = i;

        for (int j = 1; j <= 26; j++)
        {
            ans -= c[j] * (i - last[j]);
        }
    }

    return ans;
}

int main(void)
{
    srand(time(NULL));
    cin >> d;

    for (int i = 1; i <= 26; i++)
    {
        cin >> c[i];
    }

    for (int i = 1; i <= d; i++)
    {
        for (int j = 1; j <= 26; j++)
        {
            cin >> s[i][j];
        }
    }

    vector<int> BestT(d + 1, 1);

    for (int i = 1; i <= d; i++)
    {
        BestT[i] = rand() % 26 + 1;
    }

    // printf("%lld\n", scoring(BestT));

    double BestScore = scoring(BestT);

    auto start = chrono::system_clock::now();
    vector<int> t(d + 1);

    double T0 = 1e9;
    double T1 = 1;
    double TL = 1950;

    ll count = 0;

    while (1)
    {
        auto end = chrono::system_clock::now(); // 計測終了時刻を保存
        auto dur = end - start;                 // 要した時間を計算
        auto msec = chrono::duration_cast<chrono::milliseconds>(dur).count();

        if (msec >= 1950)
        {
            break;
        }

        double T = powf(T0, 1 - msec / TL) * powf(T1, msec / TL);

        t = BestT;

        t[rand() % d + 1] = rand() % 26 + 1;

        double score = scoring(t);

        if (exp((score - BestScore) / T) > 0.5)
        {
            BestT = t;
            BestScore = score;
        }
    }

    for (int i = 1; i <= d; i++)
    {
        printf("%d\n", BestT[i]);
    }

    // printf("%lld\n", scoring(BestT));
}


Measured memory_bytes: 4436
A, B, C, X, Y = map(int, input().split())
AB = [A, B]
XY = [X, Y]
ans = []
minXY = min(X, Y)
maxXY = max(X, Y)
maxid = XY.index(max(X, Y))

ans.append(A*X+B*Y)
print(min(A*X+B*Y, 2*C*minXY+(maxXY-minXY)*AB[maxid], maxXY*2*C))

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

const (
	initialBufSize = 1e4
	maxBufSize     = 1e6 + 7
)

var buf []byte = make([]byte, maxBufSize)
var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBufSize)
}

func main() {
	N := nextInt()
	pf := primeFuctorize(N)
	cnt := map[int]int{}
	for i := 1; i <= 40; i++ {
		tmp := 0
		for j := 1; j <= 9; j++ {
			tmp += j
			if i < tmp {
				cnt[i] = j - 1
				break
			}
		}
	}
	var ans int
	for _, v := range pf {
		ans += cnt[v]
	}
	fmt.Println(ans)
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func abs(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func pow(p, q int) int {
	res := p
	if q == 0 {
		return 1
	}
	for i := 0; i < q-1; i++ {
		res *= p
	}
	return res
}

func MinOf(vars ...int) int {
	min := vars[0]
	for _, i := range vars {
		if min > i {
			min = i
		}
	}
	return min
}

func MaxOf(vars ...int) int {
	max := vars[0]
	for _, i := range vars {
		if max < i {
			max = i
		}
	}
	return max
}

func gcdof2numbers(a int, b int) int {
	if b == 0 {
		return a
	}
	return gcdof2numbers(b, a%b)
}

func lcmof2numbers(a int, b int) int {
	return a / gcdof2numbers(a, b) * b
}

// マイナスの場合は考慮していない
func fuctorial(a int) int {
	if a == 1 || a == 0 {
		return 1
	} else {
		return fuctorial(a-1) * a
	}
}

func NextPermutation(x sort.Interface) bool {
	n := x.Len() - 1
	if n < 1 {
		return false
	}
	j := n - 1
	for ; !x.Less(j, j+1); j-- {
		if j == 0 {
			return false
		}
	}
	l := n
	for !x.Less(j, l) {
		l--
	}
	x.Swap(j, l)
	for k, l := j+1, n; k < l; {
		x.Swap(k, l)
		k++
		l--
	}
	return true
}

// 素因数分解したmapを返す
func primeFuctorize(n int) map[int]int {
	pf := map[int]int{}
	for i := 2; i*i <= n; i++ {
		for n%i == 0 {
			pf[i]++
			n /= i
		}
	}
	if n != 1 {
		pf[n]++
	}
	return pf
}


Measured memory_bytes: 1852
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[200010],b[200010];
int main() {
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++){
		cin>>a[i];
	}
	priority_queue<pair<ll,ll>>ch;
	for(ll i=0;i<n;i++){
		cin>>b[i];
		ch.push(make_pair(b[i],i));
	}
	ll ans=0;
	while(!ch.empty()){
		ll val=ch.top().first;
		ll i=ch.top().second;
		ch.pop();
		ll l=i-1;
		if(l<0){
			l=n-1;
		}
		ll r=i+1;
		if(r==n){
			r=0;
		}
		if(val<a[i]){
			cout << -1;
			return 0;
		}
		if(val==a[i]){
			continue;
		}
		ll m=((val)-a[i])/(b[l]+b[r]);
		if(m==0){
			cout << -1;
			return 0;
		}
		ans+=m;
		val=val-m*(b[l]+b[r]);
		ch.push(make_pair(val,i));
		b[i]=val;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 9072
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<int,int>
#define vint vector<int>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
int read(){
	int g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const int N=20;
int n,m,hav[N+5][2<<N],s[2<<N],ne[2<<N][2],ans;
signed main(){
	n=read(),m=read();
	for(int i=0;i<=n;i++)for(int x=0;x<1<<i;x++)scanf("%1d",&hav[i][1<<i^x]);
	s[0]=-1;for(int i=1;i<2<<n;i++)s[i]=s[i>>1]+1;
	for(int i=2;i<2<<n;i++){
		if(i>>(s[i]-1)&1)ne[i][1]=i^1<<s[i],ne[i][0]=ne[ne[i][1]][0];
		else ne[i][0]=i^3<<(s[i]-1),ne[i][1]=ne[ne[i][0]][1];
	}
	for(int i=n;i>=1;i--)for(int sta=1<<i;sta<2<<n;sta++){
		if(!hav[i][sta])continue;
		int re=sta>>i,to=(sta&((1<<i)-1))^1<<i;
		if(ne[to][0])hav[s[ne[to][0]]][(re<<1^1)<<s[ne[to][0]]^ne[to][0]]+=hav[i][sta];
		if(ne[to][1])hav[s[ne[to][1]]][(re<<1^0)<<s[ne[to][1]]^ne[to][1]]+=hav[i][sta];
		hav[0][re]+=hav[i][sta];
	}ans=1;
	for(int sta=2;sta<2<<n;sta++)if(hav[0][sta]>=m&&s[sta]>s[ans])ans=sta;
	int j=n;while(~ans>>j&1)j--;while(j--)cout<<(ans>>j&1);return signed();
}

Measured memory_bytes: 192204
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    int n;
    string s;
    cin >> s;
    s[3] = '8';
    cout << s << endl;
    return 0;
    
}

Measured memory_bytes: 256
import * as fs from 'fs'

const getInput = (): string => {
  const input = (fs.readFileSync('/dev/stdin', 'utf8') as string).trim()
  return input
}
export const solveA = () => {
  const input = getInput()

  const arr = input.trim().split(' ').map(Number)
  const A = arr[0]
  const B = arr[1]
  const C = arr[2]
  if (A === B) {
    console.log(C)
  } else {
    if (B === C) {
      console.log(A)
    } else {
      console.log(B)
    }
  }
}
solveA()


Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
int main(){
    string c_ary_1[3];
    string c_ary[3][3];
    rep(i,3){
        cin >> c_ary_1[i];
        rep(j,3){
            c_ary[i][j] = c_ary_1[i].substr(j,1);
        }
    }
/*
    rep(i,3){
        rep(j,3){
            cout << c_ary[i][j];
        }
        cout << endl;
    }
*/
    cout << c_ary[0][0] << c_ary[1][1] << c_ary[2][2] << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;

vector<vector<ll>> dp;

ll modpow(ll a, ll n) {
	ll r=1;
	while(n) r=r*((n%2)?a:1)%MOD,a=a*a%MOD,n>>=1;
	return r;
}
 
ll comb(ll P_,ll Q_) {
	if(P_<0 || Q_<0 || Q_>P_) return 0;
	ll p=1,q=1;
	Q_=min(Q_,P_-Q_);
	for(int i=1;i<=Q_;i++) p=p*P_%MOD, q=q*i%MOD,P_--;
	
	return p*modpow(q, MOD -2)% MOD;
}

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

	ll N, M;
	cin >> N >> M;
	ll Msqmax = (ll)ceil(sqrt(M));

	vector<bool> pnlf(Msqmax+1, true);
	pnlf[0] = true;

	vector<ll> pnl;
	//pnl.push_back(1);

	for (ll i = 2; i <= Msqmax; ++i)
	{
		if (pnlf[i]) pnl.push_back(i);
		for (ll j = 2; j * i <= Msqmax; ++j)
		{
			pnlf[j * i] = false;
		}
	}

	vector<ll> pn_fact;

	ll tmp = M;
	for (const auto p : pnl)
	{
		ll tmp2 = 0;
		while (true)
		{
			if (tmp % p != 0)
			{
				break;
			}
			tmp /= p;
			tmp2++;
		}
		if (tmp2 > 0) pn_fact.push_back(tmp2);
	}
	if (tmp != 1)
	{
		pn_fact.push_back(1);
	}

	ll ans = 1;

	for (auto e : pn_fact)
	{
		ll kk = e;
		ll nn = N - 1 + kk;

		ans *= comb(nn, kk) % MOD;
		ans %= MOD;
	}

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 384
from sys import exit

n = int(input())
a = list(map(int, input().split()))

sm = sum(a)
ans = 1

if n == 0:
  print(1 if a[0] == 1 else -1)
  exit()

if a[0] != 0 or a[n] == 0:
  print(-1)
  exit()
  
s = 1
for i in range(1, n+1):
  if a[i] > s * 2:
    print(-1)
    exit()
  s = min(s*2, sm)
  ans += s
  sm -= a[i]
  s -= a[i]
  
print(ans)

Measured memory_bytes: 20012
# include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;

struct PP {
	ll a, b;
} p[maxx];

void Init() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld %lld", &p[i].a, &p[i].b);
}

bool cmp(PP x, PP y) {
	if(x.b == y.b) return x.a < y.a;
	return x.b < y.b;
}

int main() {
	Init();
	sort(p + 1, p + n + 1, cmp);
	//for(int i = 1; i <= n; i++) printf("%lld %lld\n", p[i].a, p[i].b);
	bool flg = 1;
	ll sum = 0;
	for(int i = 1; i <= n; i++) {
		sum += p[i].a;
		if(sum > p[i].b) {
			flg = 0;
			break;
		}
	}
	if(flg) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N, M; cin >> N >> M;
    vec L(N), R(N);
    vector<Pii> p(N);
    REP(i, N){
        cin >> L[i] >> R[i];
        p[i] = Pii(L[i], R[i]);
    }
    SORT(p);

    int n = 0;
    priority_queue<Pii> qL, qR;
    while(n < N && p[n].first == 0){
        qR.push(Pii(-p[n].second, p[n].first));
        n++;
    }
    FOR(i, 1, M + 1){
        while(n < N && p[n].first == i){
            qL.push(Pii(-p[n].second, p[n].first));
            n++;
        }
        int m = qL.size() - i;
        if(m > 0){
            REP(k, m){
                Pii tmp = qL.top(); qL.pop();
                qR.push(tmp);
            }
        }
    }
    n = qL.size();
    //cout << n << endl;
    int ans = N - n;
    FOR(i, n + 1, M + 1){
        if(qR.empty()) break;
        Pii tmp = qR.top();
        if(-tmp.first <= i){
            ans--;
            qR.pop();
        }
    }
    cout << ans;
    
    return 0;
}

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

struct Card { char suit, value; };

void bubble(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    for ( int j = N - 1; j >= i + 1; j-- ) {
      if ( A[j].value < A[j - 1].value ) {
        Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
      }
    }
  }
}

void selection(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    int minj = i;
    for ( int j = i; j < N; j++ ) {
      if ( A[j].value < A[minj].value ) minj = j;
    }
    Card t = A[i]; A[i] = A[minj]; A[minj] = t;
  }
}

void print(struct Card A[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( i > 0 ) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}

bool isStable( struct Card C1[], struct Card C2[], int N) {
  for ( int i = 0; i < N; i++ ) {
    if ( C1[i].suit != C2[i].suit ) return false;
  }
  return true;
}

int main() {
  Card C1[100], C2[100];
  int N;
  char ch;

  cin >> N;
  for ( int i = 0; i < N; i++ ) {
    cin >> C1[i].suit >> C1[i].value;
  }

  for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

  bubble(C1, N);
  selection(C2, N);

  print(C1, N);
  cout << "Stable" << endl;
  print(C2, N);
  if ( isStable(C1, C2, N) ) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }

  return 0;
}
  


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> pair;
bool seen[505][505];

//dpTable
int dp[100050];

int main(){
    int N;
    cin >> N;
    vector<int> p(N);
    int cnt = 0;
    rep (i,N) {
        cin >> p.at(i);
    }
    rep (i,N) {
        if ((p.at(i) == i + 1) && i < N - 1) {
            swap(p.at(i),p.at(i + 1));
            cnt++;
        }
        if ((p.at(i) == i + 1) && i == N - 1) {
            swap(p.at(i - 1),p.at(i));
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

const double EPS = 1e-10;
const double PI  = acos(-1.0);

int main(int argc, char *argv[]) {
  int n, m;
  cin >> n >> m;
  if (n + m == 15) cout << "+" << endl;
  else if (n * m == 15) cout << "*" << endl;
  else cout << "x" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rbf(a, x) for (auto& a : x)
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define drep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define Maxe(x) *max_element(all(x))
#define Mine(x) *min_element(all(x))
#define Size(x) ((ll)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
#define Fi first
#define Se second
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

    template<typename Num>
        constexpr Num mypow(Num a, long long b) {
            if(b==0)return 1;
            if (a==0)return 0;
            Num x = 1;
              while (b > 0) {
                if(b & 1)x*=a;
                a*=a;
                b >>= 1;
              }
              return x;
        }

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo
//mint,dijkstra,gyakugen

    bool isPrime(long long x){
        for(long long i=2;i*i<=x;i++){
            if(x%i==0)return false;
        }
        return true;
    }

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll q;
        cin>>q;
        vl Ans(100005,0);
        rep(i,100004){
            if(i==1)continue;
            if(i%2==1){
                if(isPrime(i)){
                    if(isPrime((i+1)/2)){
                        Ans[i]++;
                    }
                }
            }
            Ans[i+1]+=Ans[i];
        }
        rep(i,q){
            ll l,q;
            cin>>l>>q;
            cout<<Ans[q]-Ans[l-1]<<endl;
        }
    }

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

/*int lyca(int n){
  if(n==0) return 2;
  else if(n==1) return 1;
  else return lyca(n-1)+lyca(n-2);
}*/

void main(){
  int n=readln().chomp().to!int;
  
  ulong k=2UL,l=1UL,ans=1UL;
  
  for(int i=1;i<n;i++){
    ans=k+l; //ansはl(i+1)に対応
    k=l;
    l=ans;
  }
  
  writeln(ans);
}

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

int main(){
    int a , b,x;
    int flag;

    cin >> a >>b;
    
    if(a>b){
        int tmp = a;
        a = b;
        b = tmp;
    }

    for(int i=a;i<b;i++){
        int  p_harmony = -(a-i);
        int  m_harmony = b - i;

          if(p_harmony==m_harmony){
            flag =i;
            break;
        }else{
            flag = 0;
        }
    }

    if(flag>0){
        cout << flag<<endl;
    }else
    {
        cout << "IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  
  int N =0;
  std::string S;
  
  std::cin >> N >> S;
  
  // 一つ目の条件が当てはまるものを数える
  std::int64_t R = 0;
  std::int64_t G = 0;
  std::int64_t B = 0;
  for(char c : S){
    if(c == 'R'){
      R++;
    }
    else if(c == 'G'){
      G++;
    }
    else{
      B++;
    }
  }
  std::int64_t first_sum = R*G*B;
  
  // 二つ目の対象に当てはまらないものを数える
  std::int64_t second_sum = 0;
  
  if( 3 <= N ){
    for(int i = 0; i < N-2; i++){
      for(int j = i+1; j < N-1; j++){
        int k = 2*j-i;
        if( N <= k ){
          continue;
        }
        else if(S.at(i) != S.at(j)){
          if(S.at(i) != S.at(k)){
            if(S.at(j) != S.at(k)){
              second_sum++;
            }
          }
        }
      }
    }
  }
  
  std::cout << first_sum-second_sum << std::endl;
  
  return 0;
}

Measured memory_bytes: 3620
from collections import deque

A = deque(list(input()))
B = deque(list(input()))
C = deque(list(input()))

def res(turn,str="NULL"):
    if len(turn) == 0: print(str.upper())
    else:
        str=turn.popleft()
        if str=="a": res(A,str)
        elif str=="b": res(B,str)
        elif str=="c": res(C,str)

res(A,"NULL")

Measured memory_bytes: 3444
a,b,c,d=map(int,input().split())
while True:
 a=a-d
 c=c-b
 if a<=0 and c>0:
  print("No")
  exit()
 elif a>0 and c<=0:
  print("Yes")
  exit()
 elif a<=0 and c<=0:
  print("Yes")
  exit()

Measured memory_bytes: 9172
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line[] = br.readLine().split(" ");
		int a = Integer.parseInt(line[0]);
		int b = Integer.parseInt(line[1]);
		int c = Integer.parseInt(line[2]);
		int sum = a + b;
		String ans = "No";

		if (sum >= c) {
			ans = "Yes";
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 23124
#include <iostream>
using namespace std;
int a,b,x,y;
int main(void){
    cin>>a>>b;
    x=max(-1000000,b-a+1);
    y=min(1000000,a+b-1);
    for(int i=x;i<=y;i++){
        cout<<i<<" ";
    }
    cout<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int m,n,a[101000];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int L,R,l,r;
		scanf("%d%d",&L,&R);L--;
		for(l=1;l<=L;l=r+1){
			r=min(L/(L/l),R/(R/l));
			if(L/l!=R/l)a[l]++,a[r+1]--;
		}
		a[l]++;a[R+1]--;
	}
	for(int i=1;i<=m;i++){
		a[i]+=a[i-1];
		printf("%d\n",a[i]);
	}
}

Measured memory_bytes: 2128
x,y=map(int,input().split())

z=abs(abs(x)-abs(y))

if x * y < 0 :
    print(z+1)
elif x *y ==0:
    if y > x :
        print(z)
    else:
        print(z+1)
elif y >= x:
    print(z)
else:
    print(z+2)


Measured memory_bytes: 38512
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x,t,ans=0,p=0;
    cin>>n>>x>>t;
    while(ans<n)
    {
        ans+=(x);
        p+=(t);
    }
    cout<<p;
    return 0;
}


Measured memory_bytes: 3608
import sys
from itertools import combinations as combi
input = sys.stdin.readline
N = int(input())
a = [list(map(int, input().split())) for _ in range(N)]
mod = 10 ** 9 + 7
dp = [0] * (1 << N)
dp[0] = 1
for t in range(N):
  for c in combi([x for x in range(N)], t):
    x = 0
    table = [0] * N
    for i in c:
      x += 1 << i
      table[i] = 1
    for i in range(N):
      if table[i]: continue
      if a[t][i]:
        tt = 1 << i
        dp[x + tt] += dp[x]
        dp[x + tt] %= mod
print(dp[-1])

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

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; ++i) cin >> S[i];

	sort(S.begin(), S.end());

	string ans = "";
	for (int i = 0; i < N; i++) ans += S[i];
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3576
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner reader = new Scanner(System.in);
		String str = reader.next();
		Set<Character> set = new HashSet<Character>();
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			set.add(ch);
		}
		String ans = "yes";
		if (set.size() != str.length()) {
			ans = "no";
		}

		System.out.println(ans);
		reader.close();

	}
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main(int argc, char const* argv[]) {
    int                      N, L;
    std::vector<std::string> str;
    std::string              a;

    std::cin >> N >> L;

    for (size_t i = 0; i < N; i++) {
        std::cin >> a;
        str.push_back(a);
    }

    sort(str.begin(), str.end());
    a = "";
    for (size_t i = 0; i < N; i++) {
        a += str.at(i);
    }

    std::cout << a << '\n';


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int a,n;
    cin>>n>>a;
    cout<<(n%500<=a?"Yes":"No")<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int main(){
	int n;
	while(true){
		int a=0,b=0;
		cin >> n;
		if(n == 0){
			break;
		}
		rep(i,n){
			int buf,buf2;
			cin >> buf >> buf2;

			if(buf > buf2){
				a += buf + buf2;
			}else if(buf < buf2){
				b += buf + buf2;
			}else{
				a += buf;
				b += buf2;
			}
		}
		cout << a << " " << b << endl;
	}
}

Measured memory_bytes: 1160
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
flg=False
if all(a[i]==0 for i in range(n)):flg=True
if n%3==0:
    l=Counter(a)
    ans=l.most_common()
    if len(ans)==2:
        flg1,flg2=False,False
        for i,j in ans:
            if i==0 and n%j==0 and n//j==3:
                flg1=True
            if j/n==2/3:
                flg2=True
            if flg1 and flg2:
                flg=True
    if len(ans)==3:
        flg3=True
        tmp=0
        for i in range(3):
            tmp^=ans[i][0]
            if ans[i][1]*3!=n:
                flg3=False
            if flg3 and tmp==0:
                flg=True
if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 20892
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))

ll N, C, s[200000], t[200000], c[200000];
P<ll, ll> tp[200000];
ll us[100], usc[100];

int main()
{
    //
    cin >> N >> C;
    rep(i, 0, N)
    {
        cin >> s[i] >> t[i] >> c[i];
        tp[i] = mp(s[i], i);
    }

    ll ans = 0;
    cbuf(us, -1);
    cbuf(usc, -1);
    sort(tp, tp + N);
    rep(i, 0, N)
    {
        ll S = s[tp[i].second], T = t[tp[i].second], ch = c[tp[i].second];
        ll usi = 0;
        rep(j, 0, C)
        {
            if (us[j] < S || (us[j] == S && usc[j] == ch)) {
                usi = j;
                break;
            }
            if (j == C - 1) throw std::runtime_error("");
        }
        us[usi] = T;
        usc[usi] = ch;
        ans = max(ans, usi);
    }

    cout << ans + 1 << endl;
}


Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl


namespace atcoder {
	template<typename T>
	T ncr(T left, T right) {
		right = min(left - right, right);
		T ans = 1;
		for (T i = 1; i <= right; i++) {
			ans = ans * (left - right + i) / i;
		}
		return ans;
	}

	const int LIMIT = 1000000007;
	const int tenfive = 100000;
}

using namespace atcoder;

int main() {
	map<int, int> m;
	int stk;
	for (int i = 0; i < 6; i++) {
		cin >> stk;
		m[stk]++;
	}
	int o = 0, t = 0;
	for (int i = 1; i < 5; i++) {
		if (m[i] == 1) {
			o++;
		}
		else if (m[i] == 2) {
			t++;
		}
	}
	if (o == 2 && t == 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
 
vector<pair<int, int>> to[100010];
bool visited[100010];
ll dist[100010];


int main() {
  int N;
  cin >> N;
  for (int i = 0; i < N - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--;
    to[u].push_back({v, w});
    to[v].push_back({u, w});
  }
   //bfs
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int v = que.front();
        que.pop();
        ll d = dist[v];
        for (auto p : to[v]) {
            if (visited[p.first]){ continue;}
            dist[p.first] =  d+p.second;
            que.push(p.first);
            visited[p.first] = true;
        }
    }
  for (int i = 0; i < N; i++) cout << dist[i] % 2 << endl;
}

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

using namespace std;

const long long N = 2e5 + 5, M = 998244353;
int n, m, j;
long long dist[N];
pair<pair<int, int>, int> p[N];
priority_queue<pair<long long, int> > pq;

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

    cin >> n >> m;
    for (int i = 0; i < m; i++)
    {
        int u, v, c;
        cin >> u >> v >> c;
        p[i] = {{u, v}, c};
    }

    for (int i = 1; i <= n; i++)
    {
        dist[i] = LONG_LONG_MAX;
    }

    sort(p, p + m);

    pq.push({0, 1});
    dist[1] = 0;

    while (!pq.empty())
    {
        int u = pq.top().second;
        long long dis = -pq.top().first;
        pq.pop();

        while (j < m && p[j].first.first <= u)
        {
            if (dist[p[j].first.second] > dis + p[j].second)
            {
                dist[p[j].first.second] = dis + p[j].second;
                pq.push({-dist[p[j].first.second], p[j].first.second});
            }
            j++;
        }
    }

    cout << (dist[n] >= 1e17 ? -1 : dist[n]) << "\n";
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
template<class T> bool chmax(T &a, const T &b) { if(a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if(a > b) { a = b; return true; } return false; }
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int a,b,c;
int main() {
  cin >> a >> b >> c;
  cout << min(c, b/a) << endl;
  return 0;
}

Measured memory_bytes: 3572