akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 100000000
#define INF 300000000000000000
#define MOD 1000
#define mod 1000000007
#define INT_MAX_ 2147483647
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[5]={-1,0,1,0,0};
int dy[5]={0,-1,0,1,0};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //-------------------------------
    int k,a,b;
    cin>>k>>a>>b;
    bool abc=0;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            abc=1;
        }
    }
    if(abc)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------





































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

#define ll long long
using namespace std;

int main() {
	ll n, k, r, s, p;
	cin >> n >> k >> r >> s >> p;
	vector <char> a(n);
	for (ll i = 0; i < n; i++)
		cin >> a[i];
	vector <vector <char>> b(k);
	ll ans = 0;
	for (ll i = 0; i < n; i++)
		b[i % k].push_back(a[i]);
	for (ll i = 0; i < k; i++) 
		for (ll j = 0; j < b[i].size(); j++) {
			if (b[i][j] == 'r')
				ans += p;
			if (b[i][j] == 'p')
				ans += s;
			if (b[i][j] == 's')
				ans += r;
			if (j != b[i].size() - 1 && b[i][j] == b[i][j + 1])
				j++;
		}
	cout << ans;
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



const int MOD = 1000000007;
map<pair<int,vector<int>>, int> dp;

int solve(int column, vector<int> colors, const vector<string>& g) {
        if (dp.count({column, colors})) return dp[{column, colors}];
        if (column < 0) return 1;
        int ans = 0;
        if (g[0][column] == g[1][column]) {
                for (int i = 0; i < 3; i++) {
                        if (!count(all(colors), i)) {
                                ans += solve(column - 1, {i}, g);
                                ans %= MOD;
                        }
                }
        } else {
                for (int i = 0; i < 3; i++) {
                        for (int j = 0; j < 3; j++) {
                                if (i == j) continue;
                                if (colors.empty() || (colors.size() == 1 && i != colors.front() && j != colors.front()) ||
                                      (colors.size() == 2 && i != colors.front() && j != colors.back())) {
                                        ans += solve(column - 2, {i, j}, g);
                                        ans %= MOD;
                                }
                        }
                }
        }


        return dp[{column, colors}] = ans;
}


void _main() {
        int n; cin >> n;
        vector<string> g(2); cin >> g;
        cout << solve(n - 1, {}, g);
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3676
import java.util.*;

public class Main {

    static class Pair {
        int p, q;

        public Pair(int p, int q) {
            this.p = p;
            this.q = q;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        List<List<Pair>> li = new ArrayList<>();
        for (int i = 0; i < N; ++i) li.add(new ArrayList<>());
        for (int i = 0; i < N; ++i) {
            int A = sc.nextInt();
            for (int j = 0; j < A; ++j) {
                li.get(i).add(new Pair(sc.nextInt() - 1, sc.nextInt()));
            }
        }

        int res = 0;
        for (int bit = 0; bit < (1<<N); ++bit) {
            boolean flag = true;
            for (int i = 0; i < N; ++i) {
                if ((bit & (1<<i)) == 0) continue;
                for (Pair p : li.get(i)) {
                    if (p.q == 1 && (bit & (1<<p.p)) == 0) flag = false;
                    if (p.q == 0 && (bit & (1<<p.p)) != 0) flag = false;
                }
            }
            if (flag) {
                int cnt = 0;
                for (int i = 0; i < N; ++i) {
                    if ((bit & (1<<i)) != 0) ++cnt;
                }
                res = Math.max(res, cnt);
            }
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 31716
N=int(input())
s=[''.join(sorted(list(input()))) for i in range(N)]
s.sort()
i=0
out=0
while i<N:
  c=1
  while i+c<N and s[i]==s[i+c]:
    c+=1
    
  out+=c*(c-1)//2
  i+=c
  
print(out)

Measured memory_bytes: 10612
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

template <typename T>
bool chmax(T &a, T &b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

template <typename T>
bool chmin(T &a, T &b) {
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}



string S;
int N;

bool ispos(string s) {
  for(int i=0; i<=N; i++ ) {
    if(S[i] == s[0]) s.erase(0,1);
  }
  if(s.size() == 0) return true;
  else return false;
}


int main() {
  cin >> N >> S;
  //三桁の暗証番号を全列挙したのちにありうる番号なのかを判定する
  int ans = 0;
  for(char c = '0'; c <= '9'; c++) {
    string a = "";
    a += c;
    for(char d = '0'; d <= '9'; d++) {
      a += d;
      for(char e = '0'; e <= '9'; e++) {
	a+= e;
	if(ispos(a)) ans++;
	a.erase(2);
      }
      a.erase(1);
    }
    a.erase(0);
  }
  cout << ans << endl;
  return 0;
}





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

using namespace std;

const int maxn=1e5+5;

int main()
{
    int cost=700;
    string s;
    cin>>s;
    for(int i=0;i<3;i++)
        if(s[i]=='o')
        cost+=100;
    cout<<cost<<endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	auto f = [](ll n) {return n <= 1000 ? n + 1 : 2001 - n; };
	ll n;
	while (cin >> n) {
		ll beg = max(0LL, n - 2000), end = min(n, 2000LL);
		ll ans = 0;
		for (ll i = beg; i <= end; ++i)ans += f(i) * f(n - i);
		cout << ans << endl;
	}
}


Measured memory_bytes: 3100
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)

vector<int>prime(1000005,0);
vector<int>prime1(1000005,0);
vector<int>mark(1000005,0);
int nprime;

void sieve(int n)
{
    int limit=sqrt(n*1.0)+1,s=0;nprime=0;
    mark[1]=1;///1 if not prime.
    mark[2]=0;prime[nprime++]=2;
    for(int i=4;i<=n;i+=2)mark[i]=1;
    for(int i=3;i<=n;i+=2){
        if(!mark[i]){prime[nprime++]=i;
        if(i<=limit){///karon limit er upor theke n porjonto not prime gula already cuta hoise.
            for(int j=i*i;j<=n;j+=i*2){
                mark[j]=1;
            }
        }}
    }
//    for(int x=2;x<=n;x++){
//        if(!mark[x]){s++;prime1[x]=s;}
//        else prime1[x]=s;
//    }
    //return nprime;
}
map<long long,long long>m;

int main()
{
    ll t,t1,a,b,c,d,D,q,s=0,s2,s3=0,x4;
    ll n,k,e,r1,p1,x,x1,x2,x3,x5;
    //cin>>x4;
    //sieve(100005);
    cin>>n>>k>>r1>>s2>>p1;
    string s1;
    cin>>s1;
    for(int i=0;i<k;i++){
        if(s1[i]=='r'){s+=p1;m[i]=1;}
        else if(s1[i]=='s'){s+=r1;m[i]=1;}
        else {s+=s2;m[i]=1;}
    }
    for(int i=k;i<n;i++){
        if(s1[i]!=s1[i-k]){
            if(s1[i]=='r'){s+=p1;m[i]=1;}
            else if(s1[i]=='s'){s+=r1;m[i]=1;}
            else {s+=s2;m[i]=1;}
        }
        else{
            if(s1[i]=='r' && m[i-k]!=1){
            s+=p1;m[i]=1;
        }
        else if(s1[i]=='s' && m[i-k]!=1){
            s+=r1;m[i]=1;
        }
        else if(s1[i]=='p' && m[i-k]!=1){
            s+=s2;m[i]=1;
        }
        else{s+=0;m[i]=0;}
      }

    }
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 18304
N = gets.to_i

require 'prime'

@ps = (1 .. N).inject(:*).prime_division.map(&:last)
def f(x); @ps.count{|p| p >= x - 1}; end
def c(a, b); (a - b + 1 .. a).inject(:*) / (1 .. b).inject(:*); end
puts f(75) + f(25)*(f(3) - 1) + f(15)*(f(5) - 1) + c(f(5), 2)*(f(3) - 2)

Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define inf 1000000000000000000 //1E+18
using namespace std;


int main(){
	int n,m,R; cin>>n>>m>>R;
	int r[R],a[m],b[m],c[m];
	for(int i=0;i<R;i++){ cin>>r[i]; r[i]--; }
	for(int i=0;i<m;i++){ cin>>a[i]>>b[i]>>c[i]; a[i]--; b[i]--; }
	
	long long Map[n][n];
	for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
		if(i==j)Map[i][j]=0; else Map[i][j]=inf;
	}}
	for(int i=0;i<m;i++){ Map[a[i]][b[i]]=c[i]; Map[b[i]][a[i]]=c[i]; }

	for(int k=0;k<n;k++){
	for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
		Map[i][j] = min(Map[i][j], Map[i][k]+Map[k][j]);
	}}}

	sort(r,r+R);
	long long ans=inf, buf;
	do{	buf=0;
		for(int i=0;i<R-1;i++) buf+=Map[r[i]][r[i+1]];
		ans = min(ans, buf);
	}while(next_permutation(r,r+R));
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
mat = Array.new(14){Array.new(14){0}}
while input = gets
  x, y, s = input.split(",").map(&:to_i)
  x += 2
  y += 2
  mat[x][y] += 1
  mat[x+1][y] += 1
  mat[x][y+1] += 1
  mat[x-1][y] += 1
  mat[x][y-1] += 1
  if s > 1
    mat[x+1][y+1] += 1
    mat[x+1][y-1] += 1
    mat[x-1][y+1] += 1
    mat[x-1][y-1] += 1
  end
  if s > 2
    mat[x+2][y] += 1
    mat[x-2][y] += 1
    mat[x][y+2] += 1
    mat[x][y-2] += 1
  end
end

max = 0
white = 0
10.times{|i|
  10.times{|j|
    max = mat[i+2][j+2] if mat[i+2][j+2] > max
    white += 1 if mat[i+2][j+2] == 0
  }
}
puts white
puts max

Measured memory_bytes: 8592
#include <iostream>
#include <algorithm>
#include <array>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <deque>

#include <atcoder/all>

using namespace atcoder;
using namespace std;
typedef long long ll;

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

    int N, D;
    cin >> N >> D;

    vector<int> x(N), y(N);

    for (int i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
    }

    two_sat ts = two_sat(N);

    for (int i = 0; i < N; ++i) {
        for (int j = i + 1; j < N; ++j) {
            if (abs(x[i] - x[j]) < D) {
                ts.add_clause(i, false, j, false);
            }
            if (abs(x[i] - y[j]) < D) {
                ts.add_clause(i, false, j, true);
            }
            if (abs(y[i] - x[j]) < D) {
                ts.add_clause(i, true, j, false);
            }
            if (abs(y[i] - y[j]) < D) {
                ts.add_clause(i, true, j, true);
            }
        }
    }

    if (ts.satisfiable()) {
        cout << "Yes" << endl;
        auto ans = ts.answer();
        for (int i = 0; i < N; ++i) {
            if (ans[i]) {
                cout << x[i] << endl;
            } else {
                cout << y[i] << endl;
            }
        }
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3768
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ

int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	printf("%.1f %d\n",0.5*a*b,(c*2==a)&&(d*2==b));
}

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

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> vec(Q), minus(N, Q), point(N, K);
	for (int i = 0; i < Q; i++)
		cin >> vec.at(i);
	for (int i = 0; i < Q; i++)
		minus.at(vec.at(i) - 1)--;
	for (int i = 0; i < N; i++) {
		if (point.at(i) - minus.at(i) > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cmath>

using namespace std;

void agc_a_range_product(void) {
	long long a, b;
	cin >> a >> b;

	if (a > 0) cout << "Positive" << endl;
	else if ((a <= 0) && (b >= 0)) cout << "Zero" << endl;
	else {
		int step = abs(b - a)+1;
		if ((step & 0x1) == 0x0) cout << "Positive" << endl;
		else                     cout << "Negative" << endl;
	}

}

int main()
{
    agc_a_range_product();
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
typedef std::vector<long long> vll;
typedef std::vector<std::vector<long long>> vvll;
typedef long double ld;
typedef std::vector<long double> vld;
typedef std::vector<std::vector<long double>> vvld;
using namespace std;
void yesno(bool state);

void Main(){
    ll N;
    cin >> N;

    ll ans = 0;
    vll A(N+1); 
    for (ll i = 1; i <= N; i++)
    {
        ll n = floor(ld(N)/i);
        ans += i * (n+1)* n/2;
    }
    
    cout << ans << endl;

    
}

int main(int argc, char const *argv[])
{
    Main();
    return 0;
}

void yesno(bool state){
    if(state)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 81384
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  string s = to_string(N);
  int tmp = N, tot = 0;
  while (tmp > 0) {
    tot += tmp % 10;
    tmp /= 10;
  }

  if (N % tot == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 3712
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
#include<string>
using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<ll(n); i++)

int main(){
    unsigned long long X,a;
    int i;
    cin >> X;
    a = 100;
    for(i=0;i<3761;i++){
        if(a >= X){cout << i << endl;return 0;}
        else{a += a / 100;}
    }

    return 0;
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int x,y,i,j,k;
  cin>>x;
  y=x/500;
  i=(x-(y*500))/5;
  j=y*1000;
  k=i*5;
  if(x==0)
    cout<<"0";
  else
  cout<<j+k;

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(ll i=0;i<n;i++)
#define ll long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define inf 1145141919364364
#define double long double
using namespace std;
typedef pair<ll, ll>P;
ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
ll lcm(ll x, ll y) {
	return x * y / gcd(x, y);
}
ll cnt[26];
signed main() {
	string s;
	cin >> s;
	ll ans = 0;
	rep(i, s.size()) {
		cnt[s[i] - 'A']++;
	}
	rep(i, 26) {
		if (cnt[i] == 2)ans++;
	}
	if (ans == 2)puts("Yes");
	else puts("No");
	ggr
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    multiset<int> st;
    int a[100010];
    set<int> st2;
    rep(i, N) {
        cin >> a[i];
        st.insert(a[i]);
        st2.insert(a[i]);
    }
    if (st2.size() > 3) {
        cout << "No" << endl;
        return 0;
    }
    int num0 = a[0];
    int num1 = a[1];
    if (st2.size() > 1) {
        auto itr = st2.begin();
        num0 = *itr;
        itr++;
        num1 = *itr;
    }
    int s = num0;
    //dump(num0);
    //dump(num1);
    int t = num0 ^ num1;
    st.erase(st.find(num0));
    st.erase(st.find(num1));
    rep(i, N - 1) {
        if (i == N - 2) {
            if (t != s) {
                cout << "No" << endl;
                return 0;
            }
            break;
        }
        auto itr = st.find(t);
        if (itr == st.end()) {
            cout << "No" << endl;
            return 0;
        }
        
        st.erase(itr);
        num0 = num1;
        num1 = t;
        t = num0 ^ num1;
        //cout << t << endl;
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 11116
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<bitset>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<numeric>
#include<set>
#include<math.h>
using namespace std;

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};

#define rep(i,x) for(int i=0;i<x;i++)
#define re(i,x,y) for(int i=x;i<y;i++)

long long INF=1e9;
const long long mod=2019;
#define ll long long

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    vector<string>s(n);
    ll M=0,A=0,R=0,C=0,H=0;
    rep(i,n){
        cin>>s[i];
        if(s[i][0]=='M')M++;
        else if(s[i][0]=='A')A++;
        else if(s[i][0]=='R')R++;
        else if(s[i][0]=='C')C++;
        else if(s[i][0]=='H')H++;
    }
    ll ans;
    ans=M*A*R+A*R*C+R*C*H+C*H*M+H*M*A+M*R*C+M*R*H+A*C*H+A*R*H+M*A*C;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5760
N = input()

ops = ['+','-']
for op1 in ops:
  for op2 in ops:
    for op3 in ops:
      cal = N[0] + op1 + N[1] + op2 + N[2] + op3 + N[3]
      if(eval(cal) == 7):
        print(N[0] + op1 + N[1] + op2 + N[2] + op3 + N[3] + '=7')
        exit()

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#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())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code
int main(int argc, char const* argv[])
{
    int a,b,c;
    cin >> a >> b>> c;
    if (a == b) {
        cout << c << endl;
    }
    else if (b == c) {
        cout << a << endl;
    }
    else {
        cout << b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cmp::*;
use std::collections::*;

fn main() {
    let (a, b): (i64, i64) = readln();
    if a * b <= 0 {
        println!("Zero");
    } else if b < 0 && (b - a + 1) % 2 == 1 {
        println!("Negative");
    } else {
        println!("Positive");
    }
}


fn get_line() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_string()
}

fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}

fn readln<T: Read>() -> T {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();
    T::read(buf.trim_right())
}

trait Read {
    fn read(s: &str) -> Self;
}

macro_rules! read_impl{
    ($($t:ty)*) => ($(
        impl Read for $t {
            fn read(s: &str) -> $t{
                s.parse().unwrap()
            }
        }
    )*)
}
read_impl! { usize u8 u16 u32 u64 isize i8 i16 i32 i64 f32 f64 }

impl<T: Read> Read for Vec<T> {
    fn read(s: &str) -> Self {
        s.split_whitespace().map(T::read).collect()
    }
}

impl<A: Read, B: Read> Read for (A, B) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]))
    }
}

impl<A: Read, B: Read, C: Read> Read for (A, B, C) {
    fn read(s: &str) -> Self {
        let tokens: Vec<_> = s.split_whitespace().collect();
        (A::read(tokens[0]), B::read(tokens[1]), C::read(tokens[2]))
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int N;
cin >> N;
int count = 0;
int ans = 0;

for (int i = 1; i <= N; i++){
     if(i % 2 == 0){
          continue;
     }//偶数だったらコンティニュー

     for (int j = 1; j <= i; j++){
          if(i % j == 0){
               count++;
          }
     }
     if(count == 8){
          ans++;
     }
     count = 0;
}

cout << ans << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int n, m, Q;
static const int MAX = 501;
int train[MAX][MAX];

int main() {

    cin >> n >> m >> Q;

    for(int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r ;
        train[l][r]++;
    }

    for (int i = 0; i < MAX; i++) {
        for (int j = 1; j < MAX; j++) {
            train[i][j] += train[i][j-1];
        }
    }

    for (int i = 0; i < MAX; i++) {
        for (int j = 1; j < MAX; j++) {
            train[j][i] += train[j-1][i];
        }
    }

    for(int i = 0; i < Q; i++){
        int p, q;
        cin >> p >> q;
        cout << train[q][q] + train[p-1][p-1] - train[p-1][q] - train[q][p-1]<< '\n';

    }
}



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

int main() {
  int64_t A;
  double B;
  cin >> A >> B;
  
  double s = B * 100 + 0.5;
   int k = (int)s;
  int64_t t = A * k / 100;
  cout << t;
    
  
}
        


Measured memory_bytes: 3680
import sys
sys.setrecursionlimit(12345678)
import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop


def main():
    s1, s2, s3 = input().split()
    ans = s1[0] + s2[0] + s3[0]
    print(ans.upper())

if __name__ == '__main__':
    main()



Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int ans=0;
  int count=0;
  char x = s[0];
  for(int i=1; i<s.size(); i++){
    if(x==s[i]){
      count++;
      ans = max(ans,count);
    }else{
      count=0;
      x=s[i];
    }
  }
  
  if(ans>=2){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}
  

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

#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
#define Cpy(a, b) memcpy(a, b, sizeof(a))
#define debug(x) cout << #x << ": " << (x) << endl
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return b > a ? a = b, 1 : 0; }

namespace pb_ds
{   
    namespace io
    {
        const int MaxBuff = 1 << 22;
        const int Output = 1 << 24;
        char B[MaxBuff], *S = B, *T = B;
        #define getc() ((S == T) && (T = (S = B) + fread(B, 1, MaxBuff, stdin), S == T) ? 0 : *S++)
        char Out[Output], *iter = Out;
        inline void flush()
        {
            fwrite(Out, 1, iter - Out, stdout);
            iter = Out;
        }
    }

    template<class Type> inline Type read()
    {
        using namespace io;
        register char ch; register Type ans = 0; register bool neg = 0;
        while(ch = getc(), (ch < '0' || ch > '9') && ch != '-')     ;
        ch == '-' ? neg = 1 : ans = ch - '0';
        while(ch = getc(), '0' <= ch && ch <= '9') ans = ans * 10 + ch - '0';
        return neg ? -ans : ans;
    }

}

using namespace pb_ds;

void File() {
#ifdef zjp_shadow
	freopen ("duliu.in", "r", stdin);
	freopen ("duliu.out", "w", stdout);
#endif
}

const int N = 1e5 + 1e3;

int n, a[N], b[N], va[N], vb[N], fa[N];

int find(int x) { return x == fa[x] ? x : fa[x] = find(fa[x]); }

int tot;
inline int find_pos(int x) {
	return lower_bound(va + 1, va + tot + 1, x) - va;
}

bitset<N> vis;

int main () {

	File();

	n = read<int>() + 1;

	For (i, 1, n - 1)
		a[i] = read<int>(), a[n] ^= a[i];
	For (i, 1, n - 1)
		b[i] = read<int>(), b[n] ^= b[i];

	For (i, 1, n)
		va[i] = a[i], vb[i] = b[i];
	sort(va + 1, va + n + 1);
	sort(vb + 1, vb + n + 1);

	For (i, 1, n)
		if(va[i] != vb[i]) return puts("-1"), 0;

	tot = unique(va + 1, va + n + 1) - va - 1;
	For (i, 1, tot) fa[i] = i;

	For (i, 1, n) {
		a[i] = find_pos(a[i]); b[i] = find_pos(b[i]);
		int rtx = find(a[i]), rty = find(b[i]);
		if (rtx != rty) fa[rtx] = rty;
	}

	int ans = 0, sum = 0;
	For (i, 1, n - 1) if (a[i] != b[i])
		++ ans, vis[a[i]] = vis[b[i]] = true;
	vis[a[n]] = vis[b[n]] = true;

	For (i, 1, n) if (vis[i] && find(i) == i) ++ sum;

	printf ("%d\n", ans + max(0, sum - 1));

	return 0;

}


Measured memory_bytes: 7936
//package TaskB;

import java.io.FileInputStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    int R,G,B,N;
    void solve() throws Exception {
        Scanner sc = new Scanner(System.in);
        R = sc.nextInt(); G = sc.nextInt(); B=sc.nextInt(); N = sc.nextInt();
        int[][] dp = new int[4][N+1];
        for(int i=0; i<4; i++){
            for(int j=0; j<N+1; j++){
                dp[i][j] = 0;
            }
        }

        dp[0][0] = 1;
        for(int i=0; i*R<=N; i++){
            dp[0][i*R] = 1;
        }

        dp[1][0] = 1;
        for(int i=1; i<=N; i++){
            for(int j=0; j*G<=i; j++){
                dp[1][i] += dp[0][i-j*G];
            }
        }

        dp[2][0] = 1;
        for(int i=1; i<=N; i++){
            for(int j=0; j*B<=i; j++){
                dp[2][i] += dp[1][i - j*B];
            }
        }

        System.out.println(dp[2][N]);


    }

    public static void main(String[] args) throws Exception{
        //System.setIn(new FileInputStream("inputs/b.in"));
        Main s = new Main();
        s.solve();
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, sum;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if(x * 2 > (K-x) * 2){
      sum += (K-x) * 2;
    }
    
    else{
      sum += x * 2;
    }
    
  }
  cout << sum << endl;  
    
}



Measured memory_bytes: 256
from collections import deque
k=int(input())
queue=deque(range(1,10))
x=0
for _ in range(k):
  x=queue.popleft()
  if not x%10==0:
    queue.append(10*x+(x%10)-1)
  queue.append(10*x+(x%10))
  if not x%10==9:
    queue.append(10*x+(x%10)+1)
print(x)

Measured memory_bytes: 18684
/**
 * maybe ok
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define L 20
#define N (1<<L)

char cands[N][L+1];
int cands_ok[N];
int nok;

int main(int argc, char *argv[])
{
  char buf[L+2];
  int i, j, k;
  for(;;){
    int l, n, m, c;
    fgets(buf, L+2, stdin);
    l = strlen(buf) - 1;
    buf[l] = 0;  // to remove the newline
    n = 1 << l;
    if(buf[0]=='#') break;
    nok = 0;
    for(i = 0; i < n; i++) {
      char exec[L+1];
      char cand[L+1];
      for(j = 0; j < l; j++) {
        cand[j] = buf[j] + (((1<<(l-1-j)) & i) ? 1 : 0);
        exec[j] = cand[j];
      }
      cand[l] = 0;
      exec[l] = 0;
      //printf("cand = %s\n", cand);
      m = (1<<25)-1;
      for(j = 0; j < l; j++) {
        c = (1<<(exec[j] - 'b'));
        if(m&c) {
          exec[j]--;
          m &= ~c;
        }
      }
      //printf("exec = %s\n", exec);
      if(strcmp(exec, buf) == 0) {
        cands_ok[nok] = i;
        nok++;
        char *candsi = cands[i];
        for(j = 0; j <= l; j++) {
          candsi[j] = cand[j];
        }
      }
    }
    printf("%d\n", nok);
    if(nok < 10) {
      for(i = 0; i < nok; i++) {
        printf("%s\n", cands[cands_ok[i]]);
      }
    } else {
      for(i = 0; i < 5; i++) {
        printf("%s\n", cands[cands_ok[i]]);
      }
      for(i = nok - 5; i < nok; i++) {
        printf("%s\n", cands[cands_ok[i]]);
      }
    }
  }
  return 0;
}

Measured memory_bytes: 19840
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <unordered_map>
#include <functional>
using namespace std;
typedef unordered_map<string,string> mss;

unordered_map<string,function<bool(const string&,const string&,mss&)>>T={
	{"child",[](const string &x,const string &y,mss &parent){return parent[x]==y;}},
	{"parent",[](const string &x,const string &y,mss &parent){return parent[y]==x;}},
	{"sibling",[](const string &x,const string &y,mss &parent){return parent[x]==parent[y];}},
	{"descendant",[](const string &x,const string &y,mss &parent){
		string z=parent[x];
		for(;;){
			if(z==y)return true;
			if(parent[z]=="")return false;
			z=parent[z];
		}
	}},
	{"ancestor",[](const string &x,const string &y,mss &parent){
		string z=parent[y];
		for(;;){
			if(z==x)return true;
			if(parent[z]=="")return false;
			z=parent[z];
		}
	}},

};
int main(){
	int N,Q;
	string line;
	for(;cin>>N>>Q,N;){
		getline(cin,line);
		mss parent;
		vector<string>stack;
		getline(cin,line);
		parent[line]="";
		stack.push_back(line);
		for(int i=1;i<N;i++){
			getline(cin,line);
			int idx=0;
			for(;line[idx]==' ';idx++);
			string name=line.substr(idx);
			if(idx>stack.size())return 1;
			for(;idx<stack.size();stack.pop_back());
			parent[name]=stack[stack.size()-1];
			stack.push_back(name);
		}
		for(int i=0;i<Q;i++){
			getline(cin,line);
			istringstream ss(line);
			string x,z,y;
			ss>>x>>y>>y>>z>>y>>y;
			y=y.substr(0,y.size()-1);
			cout<<(T[z](x,y,parent)?"True":"False")<<endl;
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1340
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    for(int i=0;i<n;i++) cin >> a[i];
    for(int i=0;i<n;i++) cin >> b[i];
    ll ac = 0, bc = 0;
    for(int i=0;i<n;i++){
        if(a[i] < b[i]) ac += (b[i]-a[i])/2;
        if(a[i] > b[i]) bc += a[i]-b[i];
    }
    cout << (ac >= bc?"Yes":"No") << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

char z[2] = {'S','W'};
int a[100001];
int b[100001];
int n;
void out()
{
	for(int i =0;i<n;i++)
	{
		cout<<z[b[i]];
	}
	cout<<'\n';
}

void no()
{
	cout<<-1<<'\n';
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	 cin>>n;
	string s; cin>>s;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='o') a[i]=0;
		else a[i]=1;
	}
	if(n==3)
	{
		if(a[0]==a[1]&&a[1]==a[2])
		{
			b[0]=a[0];
			b[1]=b[2]=0;
			out();
		}
		else
		{
			no();
		}
		return 0;
	}
	for(int i = 0; i < (1<<3); i++)
	{
		for(int j = 0; j < 3; j++)
		{
			if(i&(1<<j)) b[j]=0;
			else b[j]=1;
		}
		for(int j = 0; j < n - 3; j++)
		{
			b[j+3] = (b[j]^(a[j+1]^a[j+2]));
		}
		bool pos=1;
		for(int j = 0; j < n; j++)
		{
			int l = b[(j-1+n)%n];
			int r = b[(j+1)%n];
			int cur = b[j];
			if(((l^r)^cur) != a[j])
			{
				pos=false;
				break;
			}
		}
		if(pos)
		{
			out();
			return 0;
		}
	}
	no();
}


Measured memory_bytes: 1360
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    string s; cin >> s;
    cout << s.front() << s.size() -2 << s.back() << endl;

    return 0;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(0); 
	cin.tie(0);
	int n;
	cin >> n;
	vector <int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	double now = (double)(a[0] + a[1]) / 2;
	for (int i = 2; i < n; i++) {
		now = (now + a[i]) / 2;
	}
	cout << setprecision(10) << now;
	return 0;
}


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];

    ll sum = 0;
    rep(i, n) sum += a[i];

    ll l = 0, r = *max_element(rng(a));

    while (r - l > 1) {
        ll m = (l + r) / 2;
        ll cnt = 0;

        rep(i, n) {
            if (a[i] % m == 0)
                cnt += (a[i] / m - 1);
            else
                cnt += (a[i] / m);
        }

        if (cnt > k)
            l = m;
        else
            r = m;
    }

    prt(r);

    return 0;
}


Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  rep(i, n + 1) rep(j, m + 1) {
    ll now = i * (m - j) + j * (n - i);
    if(now == k) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
input_1st=input()
input_2nd=input()

N, K = input_1st.split(" ")
D = input_2nd.split(" ")

for ans in range(int(N), 100000):
    flg = True
    for i in range(len(str(ans))):
        if str(ans)[i] in D:
          flg = False
          break

    if flg:
        print(ans)
        break


Measured memory_bytes: 2940
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

///////////////////////////////////////////////////////////////////////////

   
int main(){
    int x1,y1,x2,y2;
    cin >> x1 >> y1 >> x2 >> y2;

    x2 -= x1;
    y2 -= y1;
    
    int x3 = x2 - y2,y3 = y2 + x2;
    int x4 = x3 - x2,y4 = y3 - y2;

    cout << x3+x1 << " " << y3+y1 << " " << x4+x1 << " " << y4+y1 << endl;
    return  0;
}


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

using namespace std;
typedef long long ll;
#define MP make_pair

ll mod(ll mod_num){
    return mod_num % 2019;
}

int main(void) {
    ll mtmp,stmp,num[2020]={},tmp,ans=0,s_size;
    string s;
    cin>>s;

    mtmp = 1;

    s_size = (ll)(s.size());

    stmp = mod((stoll)(s.substr(s_size-1,1)));
    num[(stoll)(s.substr(s_size-1,1))]++;

    for (int i = 1; i < s_size; i++) {
        //cout<<i<<"\n";
        stmp = mod(mtmp * 10 * ((s[s_size-i-1])-'0') + stmp);
        mtmp = mod(mtmp*10);
        if((s[s_size-i-1])-'0'!=0)num[stmp]++;
    }

    //cout<<"\n";

    num[0]++;
    for (int i = 0; i <= 2019; i++) {
        tmp = num[i];
        
        if(tmp!=0){
            //cout<<i<<" "<<tmp<<"\n";
            ans += (tmp*(tmp-1))/2;
        }
        
    }

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

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N;
  int P=0,W=0,G=0,Y=0;
  for (int i = 0; i < N; ++i)
  {
   cin >> S;

   if(S== "P")
    P++;
  else if(S== "W")
    W++;
  else if(S== "G")
    G++;
  else if(S== "Y")
    Y++;
  }
  int kekka=0;

  if(P)
    kekka++;
  if(W)
    kekka++;
  if(G)
    kekka++;
  if(Y)
    kekka++;

  if(kekka==3)
    cout << "Three" << endl;
  else if(kekka==4)
    cout << "Four" << endl;
  else
    cout << "error" << kekka << G << W << P << Y << endl;
}

Measured memory_bytes: 256
/*
氏名：鈴木丈人
学籍番号：190441067
概要：2つの整数a、bを読み込んで、aとｂの大小関係を出力するプログラム
*/
#include<stdio.h>
int main(void)
{
	int A_input;   //入力値（a）
	int B_input;   //入力値（b）

	scanf("%d %d", &A_input, &B_input);   //a、b入力

	/*a>b*/
	if (A_input > B_input)
	{
		printf("a > b\n");
	}

	/*a<b*/
	if (A_input < B_input)
	{
		printf("a < b\n");
	}

	/*a==b*/
	if (A_input == B_input)
	{
		printf("a == b\n");
	}

	return 0;
}


Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {
	private Scanner sc;
	
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.nextLine());

		int[][] map = new int[n][n];
		for (int i = 0; i < n; i++) {
			String[] nico = sc.nextLine().split(" ");
			for (int j = 0; j < n; j++) {
				map[i][j] = Integer.parseInt(nico[j]);
			}
		}
		
		int[][] tmpj = new int[n][n + 1];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < tmpj[0].length; j++) {
				tmpj[i][j] = 0;
			}
		}
		
		for (int i = 0; i < n; i++) {
			for (int j = 1; j < tmpj[0].length; j++) {
				if (j > 0) tmpj[i][j] = tmpj[i][j - 1] + map[i][j - 1];
				else tmpj[i][j] = map[i][j];
			}
		}
		
		int max = Integer.MIN_VALUE;
		for (int si = 0; si < n; si++) {
			for (int ei = (si + 1); ei <= n; ei++) {

				for (int sj = 0; sj < n; sj++) {
					for (int ej = (sj + 1); ej <= n; ej++) {
						
						int sum = 0;
						for (int i = si; i < ei; i++) {
							sum = sum + tmpj[i][ej] - tmpj[i][sj];
						}
						if (max < sum) max = sum;
					}
				}
			}
		}
		
		System.out.println(max);
	}
}

Measured memory_bytes: 31196
n=int(input())
line=input().split()
for i in range (n):
    line[i]=int(line[i])

b=[]
for i in range (n):
    b.append(22000*i+1)
a=b[:]
b.reverse()

for i in range (1,n):
    a[line[i]-1]+=i

print (" ".join(map(str,a)))
print (" ".join(map(str,b)))


Measured memory_bytes: 7356