akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




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

  int n,m;
  cin>>n>>m;

//———————ワーシャルフロイド法　O(N^3)—————————————————

  vector<vector<ll>> dist(n,vector<ll>(n,INF));
  rep(i,n){
    dist[i][i]=0;
  }

  vector<pair<pair<int,int>,ll>> p(m);

  rep(i,m){
    ll a,b,c;
    cin>>a>>b>>c;
    a--;b--;
    dist[a][b]=c;
    dist[b][a]=c;
    p[i]={{a,b},c};
  }

  rep(i,n){
    rep(j,n){
      rep(k,n){
        dist[j][k]=min(dist[j][k],dist[j][i]+dist[i][k]);
        dist[k][j]=dist[j][k];
      }
    }
  }

  int ans=0;
  rep(i,m){
    int x=p[i].fi.fi;
    int y=p[i].fi.se;
    ll z=p[i].se;
    bool sute=false;
    rep(j,n){
        if(dist[x][j]+dist[j][y]<z) sute=true;
    }
    if(sute) ans++;
  }


  cout << ans << endl;
}

Measured memory_bytes: 3752
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<vector>
#include<string.h>
#include<math.h>
#include<stdio.h>
#include<queue>
#include<utility>
#include<cstdio>
#include<cstring>
#include<new>
#include<float.h>
#include<ctype.h>
#include<cfloat>
#include<cmath>
#include<cctype>
#include<sstream>
#define fo(i,w,n) for(int i=(int) w;i<(int) n;i++)
#define qi queue<int>
#define vi vector<int>
#define ll long long
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define mp make_pair
#define sz size()
#define em empty()
#define all(a) (a).begin(),(a).end()
#define fi first
#define se second
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
int m,n,x[505050],y,cnt[505050];
pair<pii,int> a[505050];
string ans[505050];
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	cin>>m>>n;
	fo(i,0,n){
		cin>>x[i]>>y;
		a[i]=mp(mp(x[i],y),i);
	}
	mem(cnt,0);
	sort(a,a+n);
	fo(i,0,n){
		string s="",t="";
		int c=a[i].fi.fi,d=a[i].se,b=++cnt[c];
		while(b){
			s+=(b%10+'0');
			b/=10;
		}
		while(c){
			t+=(c%10+'0');
			c/=10;
		}
		while(s.sz<6)s+='0';
		while(t.sz<6)t+='0';
		reverse(all(s));
		reverse(all(t));
		ans[d]=t+s;
	}
	fo(i,0,n)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 17664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>
#include <numeric>

#include <map>
#include <math.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <bitset>
#include <math.h>

#define INF 100100100

typedef long long int llint;

using namespace std;

typedef pair<int, int>Pii;

#define pi 3.141592653589793

string abc = "abcdefghijklmnopqrstuvwxyz";

queue<char>Sa, Sb, Sc;

char game(char p) {
	char n;
	if (p == 'a') {
		if (Sa.size() == 0)return 'A';
		n = Sa.front(); Sa.pop();
	}
	else if (p == 'b') {
		if (Sb.size() == 0)return 'B';
		n = Sb.front(); Sb.pop();
	}
	else if (p == 'c') {
		if (Sc.size() == 0)return 'C';
		n = Sc.front(); Sc.pop();
	}
	return game(n);
}

int main() {
	string sa, sb, sc;
	cin >> sa >> sb >> sc;
	for (int i = 0; i < sa.size(); i++)Sa.push(sa[i]);
	for (int i = 0; i < sb.size(); i++)Sb.push(sb[i]);
	for (int i = 0; i < sc.size(); i++)Sc.push(sc[i]);
	cout << game('a') <<endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

b = [a[i] + i + 1 for i in range(n)]
memo = {}
memo[b[0]] = 1

ans = 0
for i in range(1, n):
  if 2 * i + 2 - b[i] in memo:
    ans += memo[2 * i + 2 - b[i]]
  
  if b[i] in memo:
    memo[b[i]] += 1
  else:
    memo[b[i]] = 1

print(ans)

Measured memory_bytes: 42484
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    ans = 0
    if op == "+":
        ans = a + b
    elif op == "-":
        ans = a - b
    elif op == "*":
        ans = a * b
    elif op == "/":
        ans = a // b
    elif op == "?":
        break
    print(ans)





Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =1e+18*9;
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

ll fn(ll W,ll H){
	ll dmin=INF,tmax,tmin;
	FOR(i,1,W){
		ll j=H/2;
		tmax=0,tmin=INF;
		chmin(tmin,i*H); 
		chmax(tmax,i*H);
		chmin(tmin,(W-i)*j); 
		chmax(tmax,(W-i)*j);
		chmin(tmin,(W-i)*(H-j)); 
		chmax(tmax,(W-i)*(H-j));
		
		chmin(dmin,tmax-tmin);	
	}
	return dmin;
}

int main(void){
	ll W,H,dmin;
	cin>>W>>H;

	if(W%3==0||H%3==0){
		dmin=0;
	}else{
		dmin=min(fn(W,H),fn(H,W));
		chmin(dmin,H);
		chmin(dmin,W);
	}
	print(dmin);
	return 0;
}


Measured memory_bytes: 256
main :: IO()
main = do
    [a,b,x] <- map read . words <$> getLine
    print $ (div b x) - (kiriageDiv a x) + 1


kiriageDiv :: Integer -> Integer -> Integer
kiriageDiv a b
    | mod a b == 0					= div a b
    | otherwise						= div a b + 1

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int main()
{
    int a,b;
    cin>>a>>b;
    if(a==1)a=14;
    if(b==1)b=14;
    if(a>b) cout << "Alice" <<endl;
    else if(a<b) cout << "Bob"<<endl;
    else cout << "Draw"<<endl;

    return 0;
}

Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
			　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <climits>
#include <tuple>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <algorithm>
#include <memory>
#include <iomanip>
#include <type_traits>

#define rep(i, n) for(Int (i) = 0; (i) < (n); ++(i))
#define all(n) std::begin(n), std::end(n)
#define debug(var) std::cout << #var << ": " << var << "\n"
using Int = int64_t;
constexpr Int INF = INT_MAX;
constexpr Int mod = 1e9 + 7;


void calc() {

	Int N, M; std::cin >> N >> M;
	Int sum = 0;
	rep(i, M) {
		Int A; std::cin >> A;
		sum += A;
	}

	if (sum > N)std::cout << -1;
	else std::cout << N - sum;

}


int main() {

	calc();

	return 0;
}

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

wl = [0]
bl = [0]

w=0
b=0

for i in S:
    if i==".":
        w+=1;
    else:
        b+=1;
    wl.append(w)
    bl.append(b)

wmax = wl[-1]
min = wmax;
for i in range(N+1):
    if wmax+bl[i]-wl[i] < min:
        min = wmax+bl[i]-wl[i]

print(min)


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

int main(){
  int k, x;
  cin >> k >> x;
  if(500*k >= x){
    cout << "Yes" << endl;
  }
  else{
  	cout << "No" <<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main() {
    int N;
    int X;
    int T;

    cin >> N >> X >> T;

    cout << (N+X-1) / X * T << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
using namespace std;
#include<vector>
#include<map>
#include<set>
#include<cmath>

int main(){
  long long int n,m;
  cin>>n>>m;
  if(abs(n-m)>1){
    cout<<0<<endl;
    return 0;
  }

  if(n==m){
    long long int ans=1;
    for(int i=2;i<=n;i++){
      ans*=i;
      ans=ans%1000000007;
    }
    ans=ans*ans;
    ans=ans%1000000007;
    ans*=2;
    ans=ans%1000000007;
    cout<<ans<<endl;
    return 0;
  }else{
    long long int ans=1;
    for(int i=2;i<=n;i++){
      ans*=i;
      ans=ans%1000000007;
    }
    for(int i=2;i<=m;i++){
      ans*=i;
      ans=ans%1000000007;
    }
    cout<<ans<<endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define rev(a,b,c) for(int a=b;a>=c;a--)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define F first
#define S second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define get(a) cin>>a
#define nextl cout<<"\n"
#define deb(x) cout<<#x<<"="<<x<<"\n";
const ll mod = 1000000007;
const ll maxn = 20;
const ll mm = 1e+18;
ll power(ll x, ll y)
{
    ll res = 1;
    x = x % mod;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % mod;
        y = y>>1;
        x = (x*x) % mod;
    }
    return res;
}
ll ncr(ll n, ll k)
{
    ll C[k+1];
    memset(C, 0, sizeof(C));

    C[0] = 1;

    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, k); j > 0; j--)
            C[j] = (C[j] + C[j-1])%mod;
    }
    return C[k];
}
vector<pair<int,int>>v[maxn];
vector<int>go(int x,int n){
    vector<int>ok;
    while(n--){
        ok.pb(x%2);
        x/=2;
    }
    reverse(ok.beg,ok.en);
    return ok;
}
bool p;
void check(vector<int>vv,int n){
    rep1(i,n){
        int xx=0;
        for(auto pp:v[i]){
            int x=pp.F;
            int y=pp.S;
            if(vv[i-1]){
                if(vv[x-1]!=y){
                    p=false;
                    return;
                }
            }
            else{
                if(vv[x-1]==y){
                    xx++;
                }
            }
        }
        if(vv[i-1]==0&&xx==v[i].si){
            p=false;
            break;
        }
    }
}
void solve()
{
    int n;
    cin>>n;
    rep1(i,n){
        int x;
        cin>>x;
        while(x--){
            int x,y;
            cin>>x>>y;
            v[i].pb({x,y});
        }
    }
    int mx=-1;
    rep0(i,(1<<n)){
        p=true;
        vector<int>v1=go(i,n);
        check(v1,n);
        //if(p&&i==0) mx=0;
        if(p) mx=max(mx,__builtin_popcount(i));
    }
    pr(mx);
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--){
        solve();
        //nextl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
char fg[101][101];
int H,W;
int a[4]={-1,0,0,1};
int b[4]={0,-1,1,0};
char nowfruit;
int cnt=0;
void func(int x,int y);
main(){
  while(1){
    cnt=0;
  cin>> H>> W;
  if(H==0&&W==0) break;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>> fg[i][j];
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(fg[i][j]!='.'){
	nowfruit=fg[i][j];
	func(i,j);
	cnt++;
      }
    }
  }
  cout<< cnt<< endl;
  }
}
void func(int x,int y){
  fg[x][y]='.';
  for(int vh=0;vh<4;vh++){
    int nx=x+a[vh];
    int ny=y+b[vh];
    if(nx>=0 && nx<H && ny>=0 && ny<W && fg[nx][ny]==nowfruit){
      func(nx,ny);
    }
  }
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;

int main() {
	int N;
	cin >> N;
	N *= 2;
	vector<int> v(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
	}

	sort(v.begin(), v.end());
	int ans = 0;
	for (int i = 0; i < N; i += 2) {
		ans += min(v[i], v[i + 1]);
	}
	cout << ans << endl;

	return 0;
}


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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();

        Console.WriteLine(s[0] == s[1] && s[0] != s[2] && s[2] == s[3] || s[0] == s[2] && s[0] != s[1] && s[1] == s[3] || s[0] == s[3] && s[0] != s[1] && s[1] == s[2] ? "Yes" : "No");
    }
}


Measured memory_bytes: 11092
s = list(input())
n = len(s)

res = 0
for i in range(n):
    if i % 2 == 0 and s[i] == "0":
        res += 1
    elif i % 2 == 1 and s[i] == "1":
        res += 1

res2 = 0
for i in range(n):
    if i % 2 == 0 and s[i] == "1":
        res2 += 1
    elif i % 2 == 1 and s[i] == "0":
        res2 += 1

print(min(res, res2))

Measured memory_bytes: 3956
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

string simulate(string S) {
    int cur = 0, dir = 1;
    while (cur >= 0 && cur < sz(S)) {
        if (S[cur] == 'A') {
            dir *= -1;
            S[cur] = 'B';
        } else {
            S[cur] = 'A';
        }
        cur += dir;
    }
    return S;
}

void test() {
    srand(100);
    rep(ii, 10) {
        string s;
        rep(i, 10) {
            s += (rand() % 2 ? 'A' : 'B');
        }

        cout << s << endl << simulate(s) << endl << endl;
    }
}


int N, K;
int s[200001];
string S;

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

    // test();

    cin >> N >> K >> S;
    rep(i, N) {
        s[i] = S[i] == 'A' ? 0:1;
    }

    int cur = 0, rev = 0;

    while (K--) {
        int x = s[cur] ^ rev;
        if (x) {// B
            ++cur;
            if (cur == N)cur = 0;
            rev = 1 - rev;
        } else {
            s[cur] = 1 - s[cur];
        }
    }

    rep(i, N) {
        int x = s[cur++] ^ rev;
        if (cur == N)cur = 0;
        cout << (x ? 'B' : 'A');
    }
    cout << endl;
}


Measured memory_bytes: 1560
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line printf("-----------------------------\n")
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
int  main()
{
    double  a,b;
    cin>>a>>b;
    double  ans=0;
    for(int i=1;i<=a;i++)
    {
        int   c=ceil(b/double (i));
        int   d=ceil(log2(c));
        if(d==0)
        {
            ans+=(1/double(a));
            continue;
        }
        ans+=(1/double (a))*powl(.5,d);
        //cout<<i<<' '<<d<<endl;
    }
        printf("%.15f\n",ans);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;

int main(void){
    int N;
    long long K;
    cin >> N >> K;
    vector<pair<long long, long long>> v(N);
    for(int i = 0; i < N; i++){
        long long a, b;
        cin >> a >> b;
        v[i] = make_pair(a, b);
    }
    sort(v.begin(), v.end());
    long long pos = 0;
    for(int i = 0; i < N; i++){
        pos += v[i].second;
        if(pos >= K){
            cout << v[i].first;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

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

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;

int main(){
  string s;
  while(cin>>s && s != "0"){
    int dp[80001][11] = {};
    int N = s.size();
    int ans = 0;
    for(int i = 0; i < N; i++){
      for(int j = 0; j < 11; j++){
        dp[i + 1][(j * 10 + s[i] - '0') % 11] += dp[i][j];
      }
      if(s[i] != '0') dp[i + 1][s[i] - '0'] += 1;
      ans += dp[i + 1][0];
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> PII;
const int N = 3e5+7;

int r[N],c[N];
map<PII,int> mp;

int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	int xx=0,yy=0;
	for(int i=0;i<k;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		mp[{x,y}]=1;
		r[x]++,c[y]++;
		xx = max(xx,r[x]);
		yy = max(yy,c[y]);
	}
	vector<int> vx,vy;
	for(int i=1;i<=n;i++) if(r[i]==xx) vx.push_back(i);
	for(int i=1;i<=m;i++) if(c[i]==yy) vy.push_back(i);
	int flag=0;
	for(int i=0;i<vx.size();i++){
		for(int j=0;j<vy.size();j++){
			if(!mp[{vx[i],vy[j]}]){
				flag=1;break;
			}
		}
		if(flag) break;
	}
	if(flag) printf("%d\n",xx+yy);
	else printf("%d\n",xx+yy-1);
	return 0;
}


Measured memory_bytes: 28552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,x); REP(i,sizeof(a)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

int main(){
  int h[10];
  REP(i,10){ cin>>h[i];}
  sort(h,h+10,greater<int>());
  REP(i,3){ cout << h[i] <<"\n";}
}





Measured memory_bytes: 3164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    private static FastReader fr = new FastReader();
    private static PrintWriter out=new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        StringBuilder sb = new StringBuilder();
        // code goes here
        int x = fr.nextInt();
        sb.append(x == 0 ? 1 : 0);
        System.out.print(sb.toString());
    }

    static class FastReader{
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st=new StringTokenizer("");

        public String next() {
            while (!st.hasMoreTokens())
                try {
                    st=new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[] nextIntArray(int n) {
            int[] a=new int[n];
            for (int i=0; i<n; i++) a[i]=nextInt();
            return a;
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public long[] nextLongArray(int n) {
            long[] a=new long[n];
            for (int i=0; i<n; i++) a[i]=nextLong();
            return a;
        }
    }

    static class Pair<A, B>{
        A first;
        B second;
        public Pair(A first, B second){
            this.first = first;
            this.second = second;
        }
    }
}


Measured memory_bytes: 32864
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int X, Y;
    cin >> X >> Y;
    int ans = 0;
    if (X == 1 && Y == 1) {
        ans += 400000;
    }
    ans += max(0, (4-X)*100000)+max(0, (4-Y)*100000);
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = int.Parse(ReadLine());
        var L = ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(L);
        var ans = 0L;
        for (int i = 0; i < N; i++)
        {
            for (int j = i + 1; j < N; j++)
            {
                var d = L[i] + L[j];
                var ok = 0;
                var ng = N;
                while (ng - ok > 1)
                {
                    var m = (ok + ng) / 2;
                    if (L[m] < d)
                    {
                        ok = m;
                    }
                    else
                    {
                        ng = m;
                    }
                }
                ans += ok - j;
            }
        }
        WriteLine(ans);
    }
}


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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> p(n), pos(n);

  for (int i = 0; i < n; ++i) {
    scanf("%d", &p[i]);
    p[i]--;
    pos[p[i]] = i;
  }

  vector<array<int, 2>> st(n * 4);
  vector<int> sz(n * 4);
  constexpr int kInf = 1'000'000'000;

  auto Build = [&](auto self, int l, int r, int o = 0) {
    if (r - l == 1) {
      sz[o] = 1;
      st[o][0] = p[l];
      st[o][1] = kInf;
      return;
    }
    int m = (l + r) >> 1;
    self(self, l, m, o * 2 + 1);
    self(self, m, r, o * 2 + 2);
    sz[o] = sz[o * 2 + 1] + sz[o * 2 + 2];
    st[o][0] = min(st[o * 2 + 1][0], st[o * 2 + 2][sz[o * 2 + 1] & 1]);
    st[o][1] = min(st[o * 2 + 1][1], st[o * 2 + 2][sz[o * 2 + 1] & 1 ^ 1]);
  };

  auto Erase = [&](auto self, int l, int r, int p, int o = 0) {
    if (r - l == 1) {
      sz[o]--;
      st[o][0] = kInf;
      return;
    }
    int m = (l + r) >> 1;
    if (p < m) {
      self(self, l, m, p, o * 2 + 1);
    } else {
      self(self, m, r, p, o * 2 + 2);
    }
    sz[o] = sz[o * 2 + 1] + sz[o * 2 + 2];
    st[o][0] = min(st[o * 2 + 1][0], st[o * 2 + 2][sz[o * 2 + 1] & 1]);
    st[o][1] = min(st[o * 2 + 1][1], st[o * 2 + 2][sz[o * 2 + 1] & 1 ^ 1]);
  };

  auto QuerySize = [&](auto self, int l, int r, int ql, int qr, int o = 0) {
    if (l >= qr || ql >= r) return 0;
    if (l >= ql && r <= qr) return sz[o];
    int m = (l + r) >> 1;
    return self(self, l, m, ql, qr, o * 2 + 1) +
           self(self, m, r, ql, qr, o * 2 + 2);
  };

  auto Query = [&](auto self, int l, int r, int ql, int qr, int p, int o = 0) {
    if (l >= qr || ql >= r) return kInf;
    if (l >= ql && r <= qr) return st[o][p];
    int m = (l + r) >> 1;
    return min(self(self, l, m, ql, qr, p, o * 2 + 1),
               self(self, m, r, ql, qr, p ^ (sz[o * 2 + 1] & 1), o * 2 + 2));
  };

  Build(Build, 0, n);
  set<int> s;
  s.insert(n + 1);
  for (int it = 0; it < n / 2; ++it) {
    int a = Query(Query, 0, n, 0, n, 0);
    Erase(Erase, 0, n, pos[a]);
    s.insert(pos[a]);
    int p = QuerySize(QuerySize, 0, n, 0, pos[a]) & 1;
    int b = Query(Query, 0, n, pos[a], *s.upper_bound(pos[a]), p);
    Erase(Erase, 0, n, pos[b]);
    s.insert(pos[b]);
    printf("%d %d ", a + 1, b + 1);
  }
  puts("");
}


Measured memory_bytes: 21888
#include <iostream>

using namespace std;

int main(){
    int x,y;
    cin >> x >> y;
    for (int i = y/4; i<=x && i>=0; i--){
        if(i*4+(x-i)*2==y){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3672
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    if (N == M) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}
    

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k ;
    int ans = 0;
    ans += min(a,k);
    k -= min(a,k);
    k -= min(b,k);
    ans -= k;
    cout << ans << endl;
}

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

typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;

#define all(x) x.begin(), x.end()

const int MOD = 1000000009;
const int INF = 2e9;

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
	string s;
	s += ch;
	return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
  	to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
  	to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define pb push_back
#define fi first
#define se second  

void solve() {
  int n;
  cin >> n;
  ll sum = 0;
  for (int i = 1; i <= n; i++) {
    if (i % 3 != 0 && i % 5 != 0) {
      sum += i;
    }
  }
  cout << sum << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);	
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
} 


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

int main() {
  int N;
  cin >> N;
  vector<int> L(N);
  for(int i=0;i<N;i++){
    cin >> L.at(i);
  }
  long long count=0;
  for(int i=0;i<N-2;i++){
    for(int j=i+1;j<N-1;j++){
      for(int k=j+1;k<N;k++){
        int A=L.at(i);
        int B=L.at(j);
        int C=L.at(k);
        if(A==B || B==C || C==A){
          continue;
        }
        if(A<B+C && B<C+A && C<A+B){
          count++;
        }
      }
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cstdio>
using namespace std;
int main()
{
    char a[100000+10];
    cin>>a;
    int len=strlen(a);
    int flag=0;
    for(int i=0;i<len;i++)
    {
        if(a[i]==a[i+1])
        {
            cout<<i+1<<" "<<i+2<<endl;
            flag=1;
            break;
        }
        if(a[i]==a[i+2])
        {
            cout<<i+1<<" "<<i+3<<endl;
            flag=1;
            break;
        }
    }
    if(flag==0)
        cout<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 3720
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

int main(){
    int n;
    cin>>n;
    int ans=1,m=1;
    for(int i=0;i<n;++i){
        ans*=3;
        int a;
        cin>>a;
        if(a%2==0)m*=2;
    }
    cout<<ans-m<<endl;
}

Measured memory_bytes: 256
x,n= map(int, input().split())

if n == 0:
  print(x)
  exit(0)
  
p = [int(x) for x in input().split()]

a = x
b = x

if x not in p:
  print(x)
  exit(0)

for i in range(1,101):
  a = a + 1
  b = b - 1
  if b not in p:
    print(b)
    exit(0)
  elif a not in p:
    print(a)
    exit(0)

Measured memory_bytes: 9204
#include <stdio.h>

int main(void)
{
	char N[4];
	scanf("%s",N);
	if(N[0]=='7' || N[1]=='7' || N[2]=='7'){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 1660
N = int(input())
seq = list(map(int, input().split()))

def BubbleSort(seq):
    count = 0
    for i in range(N):
        for j in range(1, N):
            if seq[j] < seq[j-1]:
                swp = seq[j]
                seq[j], seq[j-1] = seq[j-1], swp
                count += 1

    print(" ".join([str(x) for x in seq]))
    print(count)

BubbleSort(seq)


Measured memory_bytes: 5608
import java.util.*;


class Main{

    Main(){
        Scanner sc = new Scanner(System.in);
        
        int x=sc.nextInt(),y=sc.nextInt();
        int ans=0;
        
        for(int i=0;i<10000000;i++){
            ans++;
            ans--;
        }
        
        for(int i=0;i<x;i++){
            for(int j=0;j<y;j++){
                ans++;
            }
        }
            
        System.out.println(ans);
    }
    
    public static void main(String[] args){
        new Main();
    }
}

Measured memory_bytes: 18940
#include<iostream>
#include<string>

using namespace std;

int S(int N) {
	int _N = N;
	int sum = 0;
	int digit = 0;

	while (_N) {
		sum += _N % 10;
		_N /= 10;
	}

	return sum;
}

int main() {
	int N;

	cin >> N;

	if (N%S(N) == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
def factorization(n):
    L=[]
    temp=n
    print(n,end='')
    print(':',end='')
    for i in range(2,int(n**(1/2)//1)+1):
        if temp%i==0:
            c=0
            while temp%i==0:
                c+=1
                temp//=i
            L.append([i,c])
            for j in range(c):
                print('',i,end='')
    
    if temp!=1:
        print('',temp,end='')
        
    print( )
    
n=int(input())
factorization(n)


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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if ((a == (b + c)) || (b == (c + a)) || (c == (b + a))) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php
// 標準入力から取得
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
 
class SubmitAnswer {
    public static function println($answer = "") {
        echo $answer . PHP_EOL;
    }
}
 
$sc = new Scanner();
$n = $sc->next();
//$n = "rrededeaeaebe";
$array = str_split($n);
$numbersOfExists = [];
$isPossible = true;

foreach($array As $key => $value){
//    (array_key_exists('first', $search_array))
    if (array_key_exists("$value", $numbersOfExists)) {
        $numbersOfExists["$value"]++;
    } else {
        $numbersOfExists += array($value => 1);
    }
}

foreach($numbersOfExists As $key => $value){
    if($value % 2 != 0){
        $isPossible = false;
    }
}

if($isPossible){
    $answer = "Yes";
} else {
    $answer = "No";
}

//var_dump($numbersOfExists);

SubmitAnswer::println("$answer");

Measured memory_bytes: 3828
#include<bits/stdc++.h>
//#define int long long
using namespace std;

signed main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	for (int i = 0; i < m; ++i)cin >> x[i];
	sort(x.begin(), x.end());
	vector<int> dif;
	for (int i = 1; i < m; ++i) {
		dif.push_back(x[i] - x[i - 1]);
	}
	sort(dif.rbegin(), dif.rend());
	if (m <= n)cout << 0 << endl;
	else cout << accumulate(dif.begin() + n - 1, dif.end(), 0ll) << endl;
}

Measured memory_bytes: 1276
#include <stdio.h>

int main(void){
	while(1){
		int a[5], x, y, i, flag=0, max=0, p=-1;;
		
		for(i=0; i<5; i++) {
			scanf(" %d %d", &x, &y);
			if(x==0 && y==0) {
				flag=1;
				break;
			}
				
			a[i] = x+y;
			if(max < a[i]) {
				max = a[i];
				p=i;
			}
			
		}
		if(flag==1) break;
		
		printf("%c %d\n", 'A'+p, a[p]);	
	}

	return 0;
}

Measured memory_bytes: 600
N = int(input())


def Harshad(N):
  pro = 0
  N_list = list(str(N))
  for i in range(len(N_list)):
    pro += int(N_list[i])
  return pro

if N % Harshad(N) == 0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 2940
#pragma GCC optimize(2)
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<set>
#define ll long long
#define maxn 200005
#define re register
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int main()
{
	int a,b; cin>>a>>b;
	int c=6-a-b;
	cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
 
class Main{
        int high,low,sa;
     
    public void solve(){
        Scanner sc=new Scanner(System.in);
         
        for(int i=0;i<7;i++){
        high=sc.nextInt();
        low=sc.nextInt();
        sa=high-low;
        System.out.println(sa);
        }
    }
    public static void main(String[]args){
        Main obj=new Main();
        obj.solve();
    }
}

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

fn main() {
	let a: u32 = read();
	let b: u32 = read();

	if a < 10 && b < 10 {
		println!("{}", a*b);
	} else {
		println!("{}", -1);
	}
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n, k;
	cin >> n >> k;
	int row[12] = {0}, sum = 0;
	
	for (int i = 0; i < 11; i++) {
		int cnt = 0;
		for (int j = 9; j < 14; j++) {
			int num = 7*i + j;
			if((num*9) % 11 == k) {
				cnt++;
				sum++;
			}
		}
		row[i+1] = cnt;
	}
	int ans = (n-2)/11*sum, r = (n-2)%11;
	if(r == 0){
		cout << ans << endl;
		return 0;
	}
	for (int i = 1; i <= r; i++) {
		ans += row[i];
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!int;
  auto d = new int[](n);
  foreach (i; 0..n) d[i] = readln.chomp.to!int;
  writeln(d.sort().uniq.walkLength);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define ll long long
#define REP(a,b,c) for(int a=b;a<=c;a++)
#define re register
#define file(a) freopen(a".in","r",stdin);freopen(a".out","w",stdout)
typedef pair<int,int> pii;
#define mp make_pair
inline int gi()
{
	int f=1,sum=0;char ch=getchar();
	while(ch>'9' || ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return f*sum;
}
const int N=2010;
int n,a[N],d[N],ans[N],vis[N];
vector<int>G[N],g[N];
void Add(int u,int v){d[v]++;g[u].push_back(v);}
void dfs(int u){vis[u]=1;for(int v:G[u])if(!vis[v])Add(u,v),dfs(v);}
priority_queue<int>q;
int main()
{
	n=gi();
	for(int i=1;i<=n;i++)a[i]=gi();sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(__gcd(a[i],a[j])!=1)G[i].push_back(j),G[j].push_back(i);
	for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
	for(int i=1;i<=n;i++)if(!d[i])q.push(i);
	int tot=0;
	while(!q.empty())
	{
		int u;ans[++tot]=u=q.top();q.pop();
		for(int v:g[u])
			if(!--d[v])q.push(v);
	}
	for(int i=1;i<=n;i++)printf("%d%c",a[ans[i]],i==n?'\n':' ');
	return 0;
}


Measured memory_bytes: 17792
import numpy as np
def main():
    
    n,m = map(int, input().split())
    
    pena_list = np.zeros(n)
    ac_list = np.zeros(n)

    for i in range(m):
        p,s = map(str, input().split())
        if s == 'WA':
            if ac_list[int(p)-1] == 0:
                pena_list[int(p)-1] += 1
        
        elif s == 'AC':
            ac_list[int(p)-1] = 1
    
    ans = 0
    for j in range(n):
        if ac_list[j] == 1:
            ans += pena_list[j]
    
    print(str(int(sum(ac_list))), str(int(ans)))



    


if __name__ == '__main__':
    main()



Measured memory_bytes: 13892
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <vector>
using namespace std;
int main(){
  int h,w,hw,n,ans;
  cin >> h >> w >> n;
  hw = max(h,w);
  ans = (n + hw - 1)/hw;
  cout << ans <<endl;
  }


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

vector<int> vec(0);

int bin_search(int left, int right, int x){
    int mid=(left+right)/2 + (left+right)%2;
    mid=max(mid,0);
    if (mid==right){
        vec[mid]=x;
        return mid;
    }

    if (vec[mid] > x){
        return bin_search(left, mid, x);
    }else{
        return bin_search(mid, right, x);
    }
}

void cout_vec(vector<int> &vec){
    for(int i=0; i<vec.size(); i++){
        if (i!=0){
            cout << ' ';
        }
        cout << vec[i];
    }
    cout << endl;
}

int main(){
    int N;
    cin >> N;
    vector<long long> A(N,0);
    for(int i=0; i<N; i++){
        cin >> A[i];
    }

    vec.push_back(A[N-1]);

    for(int i=N-2; i>=0; i--){
        int size = vec.size();
        if(vec[size-1]<=A[i]){
            vec.push_back(A[i]);
            //cout << A[i] << endl;
            continue;
        }
        bin_search(-1,size-1,A[i]);
    }
    //cout_vec(vec);
    int ans = vec.size();
    cout << ans << endl;
}

Measured memory_bytes: 1660
#include "iostream"
#include "map"
#include "vector"
#include "algorithm"

using namespace std;

string s;
int K;
vector<string> sub;

int main() {

    cin >> s >> K;


    for (int i = 0; i < s.length(); i++) {
        for (int j = 1; j <= s.length() - i && j <= K; j++) {
            sub.push_back(s.substr(i,j));
        }
    }

    sort(sub.begin(), sub.end());
    unique(sub.begin(), sub.end());

    cout << sub[K - 1] << endl;
}

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

int main() {
    double A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    double ans_water = 0, ans_sugar = 0, ans_p = 0, max_p = 100 * E / (100 + E);
    for (int a = 0; 100 * a < F + 1; a++) {
        for (int b = 0; 100 * (A * a + B * b) < F + 1; b++) {
            for (int c = 0; 100 * (A * a + B * b) + c < F + 1; c++) {
                for (int d = 0; 100 * (A * a + B * b) + (C * c + D * d) < F + 1; d++) {
                    double water = 100 * (A * a + B * b);
                    double sugar = C * c + D * d;
                    double sum = water + sugar;
                    double p = 100 * sugar / sum;
                    if (ans_p <= p && p <= max_p) {
                        ans_p = p;
                        ans_water = water;
                        ans_sugar = sugar;
                    }
                }
            }
        }
    }
    cout << ans_water + ans_sugar << " " << ans_sugar << endl;
}

Measured memory_bytes: 384
gets.to_i
array1=gets.chomp.split(" ").map(&:to_i)
gets.to_i
array2=gets.chomp.split(" ").map(&:to_i)

array = array1.uniq + array2.uniq
puts array.group_by {|e| e }.select{|k,v| v.length == 2 }.length


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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("%d %d",&a,&b)
#define sfff(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int zz=1 ; zz<=t ; zz++)
#define PRINT_CASE printf("Case %d: ",zz)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)2e5+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n,l;
    cin >> n >> l;

    int L=l,R= (l+n-1),eat=0;

    if(R<=0) eat=R;
    else if(L>=0) eat=L;
    else eat=0;

    int ans=0;
    for(int i=L ; i<=R ; i++){
        ans+=i;
    }
    cout << ans - eat << endl;

    return 0;
}



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

using namespace std;


int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


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

static const int INFTY = 1e+9;
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
static const int VERTEX_MAX = 801;
static const int MAX_ORDER = 10001;

int cost_matrix[VERTEX_MAX][VERTEX_MAX];
int V, E, u, v, cost, Tmax, Nnew, new_id, dst;
int d[VERTEX_MAX], via[VERTEX_MAX];
int output_count = 0;

struct shop
{
	int shop_position = 1;
	deque<tuple<int, int, int>> order;
} Shop;

void dijkstra(int start, int end)
{
	int minv;
	int color[VERTEX_MAX];
	
	for (int i = 0; i < V+1; ++i)
	{
		d[i] = INFTY;
		color[i] = WHITE;
		via[i] = -1;
	}
	
	d[start] = 0;
	color[start] = GRAY;
	
	while(1)
	{
		minv = INFTY;
		int u = -1;
		
		for (int i = 0; i < V+1; ++i)
		{
			if (color[i] != BLACK && d[i] < minv)
			{
				u = i;
				minv = d[i];
			}
		}
		
		if (u == end)
		{
			break;
		}
		
		color[u] = BLACK;
		
		for (int v = 0; v < V+1; ++v)
		{
			if (color[v] != BLACK && cost_matrix[u][v] != INFTY)
			{
				if (d[v] > d[u] + cost_matrix[u][v])
				{
					d[v] = d[u] + cost_matrix[u][v];
					color[v] = GRAY;
					via[v] = u;
				}
			}
		}
	}
}

void delivery(int start, int end)
{
	dijkstra(start, end);
	
	vector<int> start_to_end;
	int node = end;
	start_to_end.push_back(node);
	
	while(1)
	{
		if (start == end)
		{
			break;
		}
		
		node = via[node];
		start_to_end.push_back(node);
		
		if (node == start)
		{
			break;
		}
	}
	
	reverse(start_to_end.begin(), start_to_end.end());
	
	int next_cost[VERTEX_MAX];
	for (int i = 1; i < start_to_end.size(); ++i)
	{
		next_cost[i] = d[start_to_end[i]] - d[start_to_end[i-1]];
		
		for (int j = 0; j < next_cost[i]; ++j)
		{
			if (output_count >= Tmax)
			{
				break;
			}
			cout << start_to_end[i] << endl;
			output_count++;
		}
	}
}

int main() 
{
	cin >> V >> E;
	
	for (int i = 0; i < E; ++i)
	{
		for (int j = 0; j < E; ++j)
		{
			cost_matrix[i][j] = INFTY;
		}
	}
	
	for(int i = 0; i < E; i++)
	{
		cin >> u >> v >> cost;
		
		cost_matrix[u][v] = cost;
		cost_matrix[v][u] = cost;
	}
	
	cin >> Tmax;
	
	for(int i = 0; i < Tmax; i++)
	{
		cin >> Nnew;
		
		for(int j = 0; j < Nnew; j++)
		{
			cin >> new_id >> dst;
			
			Shop.order.emplace_back(i, new_id, dst);
		}
	}
	
	for (int t = 0; t < get<0>(Shop.order[0]); ++t)
	{
		cout << "-1" << endl;
		output_count++;
	}
	
	int order_update = 0;
	int start = Shop.shop_position;
	int end;
	
	for (int t = get<0>(Shop.order[0]); t < Tmax; ++t)
	{
		end = get<2>(Shop.order[order_update]);
		
		delivery(start, end);
		
		delivery(end, start);
		
		if (output_count >= Tmax)
		{
			break;
		}
		
		order_update++;
	}
	
	return 0;
}

Measured memory_bytes: 2688