akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//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())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

int tls[88888];

int main(){
	int n;
	while(cin>>n,n){
		memset(tls, 0, sizeof(tls));
		int x,y,z;
		REP(i,n){
			scanf("%d:%d:%d", &x, &y, &z);
			int t1 = x*3600+60*y+z;
			tls[t1]++;
			scanf("%d:%d:%d", &x, &y, &z);
			int t2 = x*3600+60*y+z;
			tls[t2]--;
		}
		int tmp=0, ret=0;
		REP(i, 86400){
			tmp += tls[i];
			ret=max(ret,tmp);
		}
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 1596
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
int n,t,cnt;
int main(){
	scanf("%d",&n);
	rep(i,1,n){
		if(i%2==0) continue;
		int t=0;
		rep(j,1,i)
			if(i%j==0) ++t;
		if(t==8) ++cnt;
	}
	printf("%d",cnt);
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main()
{
  int W, H, x, y, r;
  int i, xc, yc;
  int yes=1;
  double rad;
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  for(i = 0; i <= 360; i++){
   rad=i*M_PI/180;
   xc=x+r*cos(rad);
   yc=y+r*sin(rad);
   if(xc < 0 || yc < 0 || W < xc || H < yc){
    yes=0;
    break;
   }
  }
  if(yes){
   printf("Yes\n");
  }else{
   printf("No\n");
  }
  return(0);
}

Measured memory_bytes: 584
#include <iostream>
#include <vector>
 
using namespace std;
 
const int MAX_V=1000;
const int INF=1e9;
const int unko=50;
 
int dist[MAX_V][MAX_V];
int n,m;

bool flag;
 
bool graph[unko][unko];
bool visited[unko];

void dfs(int v){
    visited[v]=true;
    for(int manko=0;manko<n;++manko){

        // cout<<" v i "<<v<<" "<<manko<<endl;

        if(graph[v][manko]==false)continue;//連結されていない場合には行かない
        if(visited[manko]==true)continue;//既に到達済みなので関係ない




        // cout<<"----------"<<endl;        
        // for(int z=0;z<n;z++){
        //     cout<<visited[z]<<" ";
        // }
        // cout<<endl;
        
        // cout<<"移動"<<endl;
        // cout<<"i:"<<manko<<endl;
        
        dfs(manko);

    }
}

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

int main(){
    int ans=0;

    
    cin>>n>>m;
 
    int a[10000];
    int b[10000];
    int c[10000];

    //隣接行列
    for(int i=0;i<m;i++){
        cin>>a[i]>>b[i];        
        a[i]--;
        b[i]--;
        
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;
        
    }


    // for(int i=0;i<n;i++){
    //     cout<<a[i]<<" "<<b[i]<<endl;
    // }

    // cout<<"----------"<<endl;
    // for(int x=0;x<n;x++){
    //     for(int y=0;y<n;y++){
    //         cout<<graph[x][y]<<" ";
    //     }cout<<endl;
    // }
    // cout<<"----------"<<endl;




    for(int i=0;i<m;i++){

        // cout<<"START"<<endl;

        //橋を落とすと仮定する
        graph[a[i]][b[i]]=false;
        graph[b[i]][a[i]]=false;
        // cout<<a[i]<<" "<<b[i]<<endl;

        // cout<<"----------"<<endl;
        // for(int x=0;x<n;x++){
        //     for(int y=0;y<n;y++){
        //         cout<<graph[x][y]<<" ";
        //     }cout<<endl;
        // }
        // cout<<"----------"<<endl;






        for(int j=0;j<n;j++){
            visited[j]=false;
        }

        dfs(0);



        // cout<<"----------"<<endl;        
        // for(int z=0;z<n;z++){
        //     cout<<visited[z]<<" ";
        // }cout<<endl;
        // cout<<"----------"<<endl;


    


        // cout<<"----------"<<endl;        
        // for(int z=0;z<10;z++){
        //     cout<<visited[z]<<" ";
        // }cout<<endl;
        // cout<<"----------"<<endl;



        flag=false;

        for(int j=0;j<n;j++){
            if(visited[j]==false){
                flag=true;
            }

        }
        if(flag){
            ans++;
            // cout<<"UUUNNNKKKKOOOOooo!!!"<<endl;
        }

        // cout<<"FIN"<<endl;

        //橋を戻す
        graph[a[i]][b[i]]=true;
        graph[b[i]][a[i]]=true;

    }

    cout<<ans<<endl;

}


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

using ll = long long;

#define MOD 1000000007

#define FOR(i, m, n) for (ll i = m; i <= n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)

ll gcd(ll a, ll b) { if (a < b) { a ^= b; b ^= a; a ^= b; } return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

int main() {
    ll X, Y, Z;
    cin >> X >> Y >> Z;
    cout << Z << " " << X << " " << Y << endl;
    return 0;
}


Measured memory_bytes: 256
import collections as cl

# 正解して1ポイント得ることと、
# 正解して全員を1ポイント減らすのは相対的に等価では？

# K問中、他人が1問正解したらK+1問正解してないといけない？
# Q問の他者回答と、自分の獲得ポイントの合計が0をこえてるかどうか。


N,K,Q = map(int, input().split())
A_list = []
for i in range(Q) :
    A_list.append(int(input()))

c = cl.Counter(A_list)
# print(c)
# print(c[3])

for user in range(1,N+1) :
    atari = c[user]
    # K+atari-(Q-atari) > 0
    # K+atari-Q+atari
    # print(user,K-(Q-atari))
    if (K-(Q-atari) > 0) :
        print("Yes")
    else :
        print("No")



Measured memory_bytes: 11900
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <set>
#include <map>
#include <stack>
#include <cmath>
#include <regex>
#include <iomanip>
#include <climits>
#include <utility>
#include <queue>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;
const dd PI = 3.1415926435;

class UnionFind
{
public:
    UnionFind(int N) : par(N)
    {
        for (ll i = 0; i < N; i++)
        {
            par[i] = i;
        }
    }

    int root(int x)
    {
        if (par[x] == x)
            return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry)
            return;
        par[rx] = ry;
    }

    bool same(int x, int y)
    {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

private:
    vector<int> par;
};

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

ll fact(ll n)
{
    if (n == 0)
    {
        return 1;
    }
    if (n == 1)
    {
        return 1;
    }
    return n * fact(n - 1) % MOD;
}

ll pow_fast(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    if (k == 1)
    {
        return n;
    }

    if (k % 2 == 0)
    {
        ll tmp = pow_fast(n, k / 2LL);
        return tmp * tmp % MOD;
    }
    else
    {
        ll tmp = pow_fast(n, k / 2LL);
        tmp *= tmp;
        tmp %= MOD;
        return tmp * n % MOD;
    }
}

map<ll, ll> sosuu(ll n)
{
    map<ll, ll> res;
    for (ll i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            res[i] += 1;
            n /= i;
        }
    }
    if (n != 1)
    {
        res[n] += 1;
    }
    return res;
}

struct Dish
{
    ll time;
    ll taste;
};

int main()
{
    ll N, K;
    cin >> N >> K;

    ll ans = 1;
    for (ll i = 0; i < N; i++)
    {
        if (ans * 2 < ans + K) {
            ans *= 2;
        } else {
            ans += K;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3608
class UnionFind():
  def __init__(self,n):
    self.n=n
    self.root=[-1]*(n+1)
    self.rank=[0]*(n+1)
  def FindRoot(self,x):
    if self.root[x]<0:
      return x
    else:
      self.root[x]=self.FindRoot(self.root[x])
      return self.root[x]
  def Unite(self,x,y):
    x=self.FindRoot(x)
    y=self.FindRoot(y)
    if x==y:
      return
    else:
      if self.rank[x]>self.rank[y]:
        self.root[x]+=self.root[y]
        self.root[y]=x
      elif self.rank[x]<=self.rank[y]:
        self.root[y]+=self.root[x]
        self.root[x]=y
        if self.rank[x]==self.rank[y]:
          self.rank[y]+=1
  def isSameGroup(self,x,y):
    return self.FindRoot(x)==self.FindRoot(y)
  def Count(self,x):
    return -self.root[self.FindRoot(x)]
  
n=int(input())
uf=UnionFind(n)
arr=[list(map(int,input().split()))+[i+1] for i in range(n)]
arr=sorted(arr,key=lambda x:x[0])
x,y,i=arr[0]
tmp=[]
for tx,ty,j in arr:
  if y<=ty:
    uf.Unite(i,j)
    for tx2,ty2,j2 in tmp:
      if ty2<=ty:
        uf.Unite(j,j2)
    tmp=[]
  else:
    tmp.append([x,y,i])
    x=tx
    y=ty
    i=j
arr=sorted(arr,key=lambda x:x[1])
x,y,i=arr[0]
tmp=[]
for tx,ty,j in arr:
  if x<=tx:
    uf.Unite(i,j)
    for tx2,ty2,j2 in tmp:
      if tx2<=tx:
        uf.Unite(j,j2)
    tmp=[]
  else:
    tmp.append([x,y,i])
    x=tx
    y=ty
    i=j
arr=sorted(arr,reverse=True,key=lambda x:x[0])
x,y,i=arr[0]
tmp=[]
for tx,ty,j in arr:
  if y>=ty:
    uf.Unite(i,j)
    for tx2,ty2,j2 in tmp:
      if ty2>=ty:
        uf.Unite(j,j2)
    tmp=[]
  else:
    tmp.append([x,y,i])
    x=tx
    y=ty
    i=j
arr=sorted(arr,reverse=True,key=lambda x:x[1])
x,y,i=arr[0]
tmp=[]
for tx,ty,j in arr:
  if x>=tx:
    uf.Unite(i,j)
    for tx2,ty2,j2 in tmp:
      if tx2>=tx:
        uf.Unite(j,j2)
    tmp=[]
  else:
    tmp.append([x,y,i])
    x=tx
    y=ty
    i=j
for i in range(1,n+1):
  print(uf.Count(i))

Measured memory_bytes: 154804
#include <bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define endl "\n"
using namespace std;

int power(int x,int n,int mod){
    //(x^n)%mod
    int result=1;
    while(n){
        if(n%2)
            result=(result*x)%mod;
        x=(x*x)%mod;
        n/=2;
    }
    return result;
}



int32_t main() {

    fast

    int n,k;
    cin>>n>>k;

    vector<int>arr(n);
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }
    for(int i=k;i<n;i++){
        if(arr[i]>arr[i-k]){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }




    return 0;
}



Measured memory_bytes: 4780
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

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

    vector<ld> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];

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

    ld ans = v[0];

    for(int i = 1; i < n; i++){
        ans = (ans + v[i]) / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;

int main(){
  int N,count[3];
  ll temp;
  cin>>N;
  set<ll> S;
  map<ll,int> M;
  for(int i=0;i<N;i++){
    cin>>temp;
    S.insert(temp);
    if(M.find(temp)==M.end()) M[temp]=1;
    else M[temp]++;
  }
  //cout<<"Yes"<<endl; return 0;
  if(S.size()==1 && temp==0) cout<<"Yes"<<endl;
  else if(M.find(0)!=M.end() && M[0]==(N/3) && N%3==0 && S.size()==2) cout<<"Yes"<<endl;
  else if(S.size()!=3) cout<<"No"<<endl;
  else{
    set<ll>::iterator it=S.begin();
    map<ll,int>::iterator mt=M.begin();
    int i=0;
    for(;mt!=M.end();mt++){
      count[i]=mt->second;
      i++;
    }
    //cout<<count[0]<<endl; cout<<count[1]<<endl; cout<<count[2]<<endl;
    ll a=*it; it++;
    ll b=*it; it++;
    ll c=*it;
    //cout<<a<<endl; cout<<b<<endl; cout<<c<<endl;
    a=a^b;
    //cout<<a<<endl;
    if(a==c && N%3==0 && count[0]==N/3 && count[1]==N/3 && count[2]==N/3) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }

}


Measured memory_bytes: 8704
import itertools
import copy

H, W, K = map(int, input().split())
graph = []

for i in range(H):
    graph.append(list(input()))

b = [1, 0]
Bit = list(itertools.product(b, repeat = H+W))
#print(Bit)

ans = 0

for i in range(len(Bit)):
    tmp = copy.deepcopy(graph)
    
    cnt = 0
    for h in range(H):
        if Bit[i][h] == 1:
            for j in range(W):
                tmp[h][j] = "."
    for w in range(H, H+W):
        if Bit[i][w] == 1:
            for j in range(H):
                tmp[j][w-H] = "."
    for j in range(H):
        cnt += tmp[j].count("#")
    #print(tmp)
    if cnt == K:
        ans += 1
    #print(cnt)
        
print(ans)

Measured memory_bytes: 79660
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = unlines . (:[]) . show

solver [a,b] = sumn (b-a) - b

sumn n = (n+1) * n `div` 2

Measured memory_bytes: 508
// #include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
using namespace std;
 
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ALL(a) begin(a), end(a)
#define SZ(a) ((int)(a).size())
 
#ifdef __DEBUG
#define debug if (true)
#else
#define debug if (false)
#endif
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b;
  cin >> a >> b;
  cout << max(0, a-b) << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll p[70],q[70];
ll a[100500];
int st[70];
ll ans;
ll x;
ll mx;
int main() {
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++) {
        scanf("%lld",&a[i]);
        ans = ans^a[i];
    }
    int tot=0;
    for(int i=61;i>=0;i--)
        if(!(ans&(1ll<<i)))
            st[tot++]=i;
    for(int i=n-1;i>=0;i--) {
        ll x = a[i];
        for(int j=0;j<tot;j++) {
                    if((1ll<<st[j])&x) {
                        if(!p[j]) {
                            p[j]=x;
                            break;
                    }
                    else
                        x^=p[j];
                }
        }
    }
    ll a=0;
    for(int i=0;i<tot;i++) {
            if(!(a&(1ll<<st[i]))) {
                a^=p[i];
            }
    }
    cout<<a+(ans^a)<<endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll n,i;cin>>n;vll d(n);
  for(i=0;i<n;i++){cin>>d[i];}
  //caricurate
  vsort(d);
  ll ans;ans=(d[n/2]-d[(n/2)-1]);
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include<algorithm>
#include<vector>
#include<list>
#include<iostream>
#include<utility>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<iterator>
#include<map>
#include<limits>
#include<iomanip>
#include<ctime>
#include<cmath>
 
const int INF=2147483647;
const long long MOD=1e9+7;
 
using namespace std;




int main(){
    int n,m;
    cin>>n>>m;
    
    
    
    vector<vector<int>> graph(n+1);
    vector<bool> visited(n+1, false);
    vector<int> cols(n+1,-1);
    vector<int> preds(n+1,0);
    
    for(int i=0; i<m; i++){
        int x,y;
        cin>>x>>y;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    
    long long  isoCt=0, bpct=0, nbpct=0;

    
    for(int i=1; i<=n; i++){
        if(!visited[i]){
            long long ect(0), vct(0);
            queue<int> q;
            q.push(i);
            cols[i]=0;
            bool isBp=true;
            while(!q.empty()){
                int cur=q.front();
                q.pop();
                visited[cur]=true;
                vct++;
                
                for(int i:graph[cur]){
                    if(!visited[i]){
                        q.push(i);
                        visited[i]=true;
                        preds[i]=cur;
                        cols[i]=!cols[cur];
                    }
                    else if(cols[i]==cols[cur]) isBp=false;
                    
                }
            }
            
            if(vct==1) isoCt++;
            else if(isBp) bpct++;
            else nbpct++;
        }
    }
    
    //cout<<bpct<<endl;
    cout<<2*n*isoCt-isoCt*isoCt+2*bpct*bpct+2*bpct*nbpct+nbpct*nbpct;
    
    
    return 0;
}

Measured memory_bytes: 7768
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////
struct edge {
	int from;
	int to;
	int cost;
};
int main() {
	int V, E, r;
	cin >> V >> E >> r;
	vector<edge>G;
	REP(i, E) {
		edge add;
		int s, t, d;
		cin >> s >> t >> d;
		add.from = s;
		add.to = t;
		add.cost = d;
		G.push_back(add);
	}
	int d[1010];
	REP(i, 1010)d[i] = INF;
	d[r] = 0;
	REP(i, V) {
		REP(j, E) {
			edge e = G[j];
			if (d[e.from] == INF)continue;
			if (d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				if (i == V - 1) {
					cout << "NEGATIVE CYCLE" << endl;
					return 0;
				}
			}
		}
	}
	REP(i, V) {
		if (d[i] == INF)cout << "INF" << endl;
		else cout << d[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define ff first
#define ss second
#define pi pair<ll,ll>
#define maxn 1000002
#define mod 1000000007

//vector<ll>adj[maxn];
//ll vis[maxn];
//ll cc[maxn];

//ll curr_cc;



int main(){
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans=0;
	for(int i=l;i<=r;i++){
		if(i%d == 0)ans++;
	}
	cout<<ans;
}
	
	
	
	



Measured memory_bytes: 3588
from bisect import bisect_left
import sys
def main():
    input = sys.stdin.readline
    N=int(input())
    *A,=map(int, input().split())
    G=[[] for _ in range(N)]
    for _ in range(N-1):
        u,v=map(int, input().split())
        u,v=u-1,v-1
        G[u].append(v)
        G[v].append(u)

    INF=10**10
    ans=[0]*N
    l=[INF]*(N+1)
    stk=[(0,0,0)]
    while stk:
        s,a,b=stk.pop()
        if s==0:
            i=bisect_left(l,A[a])
            stk.append((1,i,l[i]))
            l[i]=A[a]
            ans[a]=bisect_left(l,INF)
            for to in G[a]:
                if ans[to]>0: continue
                stk.append((0,to,0))
        else:
            l[a]=b
    for a in ans:
        print(a)

if __name__ == '__main__':
    main()

Measured memory_bytes: 144708
#include <stdio.h>

int main(void)
{
    int a, b, c;
    int sum = 0, i;

    scanf("%d %d %d", &a, &b, &c);
    if (a >= 1 && a <= 10000 && b >= 1 && b <= 10000 && c >= 1 && c <= 10000 && a <= b) {
        for (i = a; i <= b; i++) {
            if (c % i == 0) sum++;
        }
        printf("%d\n", sum);
    }
    
    return 0;
}

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

using ll = long long;

int main() {
    ios::sync_with_stdio(false);

    ll n, a, b; cin >> n >> a >> b;
    if(a > b) swap(a,b);

    if((b - a) % 2 == 1) {
        ll b2 = b - (a - 1) - 1;
        ll s1 = (a - 1) + 1 + (b2 / 2);
        ll a2 = a + (n - b) + 1;
        ll s2 = (n - b) + 1 + ((n - a2) / 2);
        ll s3 = b - 1;
        ll s4 = n - a;
        cout << min({s1, s2, s3, s4}) << '\n';
    }
    else {
        cout << (b - a) / 2 << '\n';
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define max 30
#define nil -1

typedef struct{
  int parent;
  int lleaf;
  int leaf;
  int next;
  int sibling;
}node;

node t[max];
int n;

int rmax(int l, int r){
  if(l < r) return r;
  else return l;
}

int deg(int id){
  int deg = 0;
  if(t[id].lleaf != nil) deg++;
  if(t[id].leaf != nil) deg++;
  return deg;
}

int dep(int id){
  int depth = 0;
  if(t[id].parent != nil){
    depth = dep(t[id].parent);
    return depth+1;
  }
  else return 0;
}

int hei(int id){
  return rmax(lhei(id), rhei(id));
} 

int lhei(int id){
  int height = 0;

  if(t[id].lleaf == nil) return 0;
  height = hei(t[id].lleaf);
  return height+1;
}

int rhei(int id){
  int height = 0;

  if(t[id].leaf == nil) return 0;
  height = hei(t[id].leaf);
  return height+1;
}

int Preorder(int u){
  if(u == nil) return 0;
  printf(" %d", u);
  Preorder(t[u].lleaf);
  Preorder(t[u].leaf);
}

int Inorder(int u){
  if(u == nil) return 0;
  Inorder(t[u].lleaf);
  printf(" %d", u);
  Inorder(t[u].leaf);
}

int Postorder(int u){
  if(u == nil) return 0;
  Postorder(t[u].lleaf);
  Postorder(t[u].leaf);
  printf(" %d", u);
}


int main(void){
  int i, j, id, left, right, mheight;

  scanf("%d", &n);
  //init
  for(i = 0; i < max; i++)
    t[i].parent = t[i].leaf = t[i].next = t[i].sibling = nil;

  for(i = 0; i < n; i++){
    scanf("%d", &id);
    scanf("%d", &left);
    scanf("%d", &right);
      t[left].parent = id;
      t[left].sibling = right;
      t[left].next = right;
      t[id].lleaf = left;

      t[right].parent = id;
      t[id].leaf = right;
      t[right].sibling = left;
  }


  for(i = 0; i < n; i++)
    if(t[i].parent == nil) break;
  

  printf("Preorder\n");
  Preorder(i);
  printf("\nInorder\n");
  Inorder(i);
  printf("\nPostorder\n");
  Postorder(i);
  printf("\n");

  return 0;
}

Measured memory_bytes: 616
#include<stdio.h>

int main(){

int H,W;
scanf("%d%d",&H,&W);
char a[H+2][W+2];
for (int i = 0; i < H+2; i++){
  for (int j = 0; j < W+2; j++){
    a[i][j]='#';
  }
}

for (int i = 1; i <= H; i++){
  for (int j = 1; j <= W; j++){
    a[i][j]=getchar();
    if (a[i][j]=='\n'){ j--;}
  }
}

for (int i = 0; i < H+2; i++){
  for (int j = 0; j < W+2; j++){
    printf("%c",a[i][j]);
  }
  printf("\n");
}

return 0;

}

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

using namespace std;

typedef long long int ll;
typedef pair<int,int> P;

#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<(b);i++)
#define repr(i,b,a) for(int i=int(b);i>=(a);i--)
#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool valid(int lx,int ux,int ly,int uy,int x,int y){
	return lx<=x&&x<ux&&ly<=y&&y<uy; 
}
ll power(ll x,ll p){
	if(p==0)return 1;
	ll res=power(x*x%mod,p/2);
	if(p%2==1)res=res*x%mod;
	return res;
}

int main()
{
	int x;
	cin>>x;
	int target = x%100;
	int num=0;
	repr(i,5,1){
		int res=target/i;
		target -= res*i;
		num+=res;
	}

	x -= (x%100);
	int now = 100*num;
	if(now>x)cout<<0<<endl;
	else cout<<1<<endl;

	return 0;
}

Measured memory_bytes: 256
#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  FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define  inf 2e18
#define  mod 1000000007
#define  bg begin()
#define  en end()
#define  ll long long int
#define  pb push_back
#define  mp make_pair
#define  pii pair<int,int>
#define  pll pair<ll,ll>
#define  vi vector<int>
#define  vll vector<long long int>
#define  vpll vector<pair<long long int,long long int> >
#define  vpii vector<pair<int,int> >
#define  vstr vector<string>
#define  mpii map<int ,int>
#define  mpll map<long long int,long long int >
#define  max3(v,b,ser) max(v,max(b,ser))
#define  min3(v,b,ser) min(v,min(b,ser))
#define  setbits(x) __builtin_popcountll(x)
#define  zerobits(x) __builtinctzll(x) //zeros after rightmost set bit
#define  w(t) ll t; cin>>t; while(t--)
#define  vin(v,m) for(int i=0;i<m;i++){ll x;cin>>x; v.pb(x);}
#define  for0(i,m) for(int i=0;i<m;i++)
#define  for1(i,m) for(int i=1;i<=m;i++)
#define  forn(i,v,b) for(int i=v;i<=b;i++)
#define  forv(it,v) for(auto it=v.begin();it!=v.end();it++)
#define  mem(v,val) memset(v,val,sizeof(v))
#define  Sort(vec) sort(vec.begin(),vec.end())
#define  RSort(vec) sort(vec.rbegin(),vec.rend())
#define  eb emplace_back
#define  bs binary_search
#define  deb1(x) cerr<<#x<<": "<<x<<" "<<endl
#define  deb2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define  deb3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define  deb4(v, b, ser, d) cerr<<#v<<": "<<v<<" | "<<#b<<": "<<b<<" | "<<#ser<<": "<<ser<<" | "<<#d<<": "<<d<<endl
#define  FF first
#define  SS second
#define  yes "YES"
#define  no "NO"
#define  PI 3.141592653589793238462643383279502884L
#define printv(v) for(int i=0;i<v.size();i++) cout<<v[i]<<" "
// find_by_order(p)  returns iterator to kth element starting from 0;
// order_of_key(p) returns count of elements strictly smaller than p;
//order of key returns the index if the element was present.(If not present)
template <typename T>
using pbds = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll Ceil(ll v, ll b) {return v / b + (v % b != 0);}
ll Logn(ll m, ll r) {return (m > r - 1) ? 1 + Logn(m / r, r) : 0;}
ll fastModExp(ll v, ll b) { ll res = 1; while (b > 0) { if (b & 1)res = (res * v) % mod; v = (v * v) % mod; b = b >> 1; } return res;}
ll GCD(ll a, ll b) { if (b == 0)return a; else  return GCD(b, a % b);}
//Chrnlgy: Binary Search,Greedy,XY,dfs and similar
ll LCM(ll v, ll b) {return v / GCD(v, b) * b;}


int main()
{
   FIFO;
   ll n;
   cin >> n;
   ll sum[n];
   vll v;
   vin(v, n);
   ll ans = 0;
   sum[0] = v[0];
   for (int i = 1; i < n; i++)
   {
      sum[i] = (sum[i - 1] + v[i]);
   }
   ll sm = sum[n - 1];
   for0(i, n)
   {
      ans = (ans + mod + (((sm - sum[i]) % mod) * v[i]) % mod) % mod;
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 6376
#include <stdio.h>
#include <math.h>
int main(void){
    long int n,i;
    scanf("%ld",&n);
    for(i=(int)sqrt(n);i>0;i--){
        if(n%i==0){
            printf("%ld\n",i+n/i-2);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;
  vl p(N);
  rep(i, N) cin >> p[i];

  stable_sort(p.begin(), p.end());

  ll ans = 0;

  rep(i, K) ans += p[i];

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


Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(10 ** 7)

N, M = map(int, input().split())
edges = [[] for _ in range(N)]
for _ in range(M):
    x, y, z = map(int, input().split())
    x -= 1
    y -= 1
    edges[x].append(y)
    edges[y].append(x)

visited = [False] * N

def dfs(u):
    if visited[u]:
        return

    visited[u] = True
    for v in edges[u]:
        if visited[v]:
            continue
        dfs(v)

ans = 0
for u in range(N):
    if visited[u]:
        continue
    ans += 1
    dfs(u)
print(ans)

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;


const int maxn = 110;
const ll inf = 1e18;

struct edge {
    ll to, cost, cap, rev;
};

struct min_cost_max_flow {

    int n;
    vector<vector<edge>> g;
    min_cost_max_flow(int n) {
	this->n = n;
	g.resize(n);
    }


    void add_edge(ll from, ll to, ll ecost, ll ecap) {
	assert(from>=0 && from<n);
	assert(to>=0 && to<n);

	edge fwd = { to, ecost, ecap, int(g[to].size()) };
	edge bak = { from, -ecost, 0, int(g[from].size()) };

	g[from].push_back(fwd);
	g[to].push_back(bak);
    }



    void sp(ll source, vector<ll>& dist, vector<pair<ll,ll>>& par) {
	dist.resize(n, inf);
	par.resize(n);
	dist[source] = 0;
	vector<bool> inq(n, false);
	queue<ll> qq;
	qq.push(0);
	while (!qq.empty()) {
	    ll at = qq.front();
	    qq.pop();
	    inq[at] = false;
	    for (int i=0; i<(int)g[at].size(); i++) {
		edge &ed = g[at][i];
		ll to = ed.to;
		if (ed.cap > 0 && dist[to] > dist[at] + ed.cost) {
		    dist[to] = dist[at] + ed.cost;
		    par[to] = {at, i};
		    if (!inq[to]) {
			inq[to] = true;
			qq.push(to);
		    }
		}
	    }
	}
    }

    pair<ll, ll> compute(int source, int sink, ll k=inf) {
	ll mincost = 0;
	ll maxflow = 0;
	
	while (maxflow < k) {
	    vector<ll> dist;
	    vector<pair<ll,ll>> par;
	    sp(source, dist, par);

	    
	    if (dist[sink] == inf) {
		break;
	    }

	    ll f = k - maxflow;
	    ll at = sink;
	    while (at != source) {
		ll to = par[at].first;
		ll id = par[at].second;
		f = min(f, g[to][id].cap);
		at = to;
	    }

	    at = sink;
	    while (at != source) {
		ll to = par[at].first;
		ll id = par[at].second;
		mincost += f*g[to][id].cost;
		g[to][id].cap -= f;
		ll revid = g[to][id].rev;
		g[at][revid].cap += f;
		at = to;
	    }
	    maxflow += f;
	}

	return make_pair(mincost, maxflow);
    }
};


int n;
ll a[maxn];


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

    cin>>n;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
    }
    int S = 0;
    int T = n+1;
    min_cost_max_flow flow(n+2);


    ll psum = 0;

    for (int i=1; i<=n; i++) {
	if (a[i]<=0) {
	    flow.add_edge(S, i, 0, -a[i]);
	} else {
	    psum += a[i];
	    flow.add_edge(i, T, 0, a[i]);
	}

	for (int j=i+i; j<=n; j+=i) {
	    flow.add_edge(i, j, 0, inf);
	}
    }


    pair<ll,ll> res = flow.compute(S, T);
    ll mincut = res.second;

    // watch(psum);
    // watch(mincut);

    out(psum - mincut);
    return 0;
}


Measured memory_bytes: 3732
H, N = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]

INF = 10**10+1

dp = [[INF]*(H+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
    dp[i][0] = 0
    A = AB[i-1][0]
    for j in range(1, H+1):
        if j-AB[i-1][0]>=0:
            dp[i][j] = min(dp[i-1][j], dp[i][j-AB[i-1][0]]+AB[i-1][1])
        else:
            dp[i][j] = min(dp[i-1][j], AB[i-1][1])

print(dp[N][H])

Measured memory_bytes: 119644
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b;
  cin >> a >> b;
  if (a==1) a=100;
  if (b==1) b=100;
  if (a>b) cout << "Alice" <<endl;
  else if (a==b) cout <<"Draw"<<endl;
  else cout << "Bob" <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main()
{
  int N = 0;
  scanf("%d",&N);
  if (N % 2 == 0 && ( N >= 1 && N <= 100))
    printf("%d",N / 2);
  else if (N % 2 == 1 && ( N >= 1 && N <= 100))
    printf("%d",N / 2 + 1);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
    char S[10];
    scanf("%s", S);
    if (S[0]=='S' && S[1]=='U') {
        printf("%d", 7);
        return 0;
    }
    if (S[0]=='M') {
        printf("%d", 6);
        return 0;
    }
    if (S[0]=='T' && S[1]=='U') {
        printf("%d", 5);
        return 0;
    }
    if (S[0]=='W') {
        printf("%d", 4);
        return 0;
    }
    if (S[0]=='T' && S[1]=='H') {
        printf("%d", 3);
        return 0;
    }
    if (S[0]=='F') {
        printf("%d", 2);
        return 0;
    }
    if (S[0]=='S' && S[1]=='A') {
        printf("%d", 1);
        return 0;
    }
}


Measured memory_bytes: 128
"""
参考    yy4さん 2019-11-24 21:24:43
516 ms          PyPy3 (2.4.0)
"""
#def solve():
from collections import deque
import sys

input = sys.stdin.readline

n = int(input())

g = tuple(set() for _ in range(n))
for idx in range(n - 1):
    a, b = (int(x) - 1 for x in input().split())
    g[a].add((b, idx))
    g[b].add((a, idx))

q = deque()
q.append((0, -1, -1))

e = [-1] * n  # e[-1]は使わない
used = [False] * n
used[0] = True
while q:
    v, v_idx, prev_color = q.popleft()
    curr = 1 if prev_color != 1 else 2
    for u, u_idx in g[v]:
        if used[u]:
            continue
        used[u] = True
        e[u_idx] = curr
        q.append((u, u_idx, curr))
        curr += 1
        if curr == prev_color:
            curr += 1

ret = e[:-1]
#return len(set(ret)), ret

    
#l, ret = solve()
l=len(set(ret))
print(l)
print(*ret, sep='\n')

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

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

    short a, b;
    cin >> a >> b;

    int counter = 0;
    if(a <= b){
        counter = a;
    }
    else{
        counter = a - 1;
    }

    cout << counter << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
const int mod=1e9+7;

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i=0; i<a.size(); i++)
		cin >> a[i];
	cout << (n+k-3)/(k-1) << endl;
	return 0;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// a^b mod M
long myPow(long a,long b,int M) {
    long ret = 1;
    long tmp = a;
    while(b>0) {
        if((b&1)==1) ret = (ret * tmp) % M;
        tmp = (tmp * tmp) % M;
        b = b>>1;
    }
    return ret;
}

 // nCk mod M
int nCk(int n,int k,int M) {
    long ret = 1;
    int mi = min(k, n-k);
    for(int i=1;i<=mi;i++) {
        ret = (ret * myPow(i,M-2,M)) % M;
    }
    for(int i=n-mi+1;i<=n;i++) {
        ret = (ret * i) % M;
    }
    return (int)ret;
};

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}


int main() {
    int N;
    cin >> N;

    string s,t;
    cin >> s >> t;    

    int len_st = s.size() + t.size();
    for(int i = len_st - N ; i >= 0 ; i--){
        if(s.substr(s.size()-i,i)==t.substr(0,i)) {
            pl(len_st-i);
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){
  int n, i, j, k, l, count;

  while(1){
    if(scanf("%d", &n)==EOF) break;
    count=0;
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	for(k=0;k<10;k++){
	  for(l=0;l<10;l++){
	    if(i+j+k+l==n) count++;
	  }
	}
      }
    }

    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
  // freopen("input.txt","r",stdin);
  // freopen("output.txt","w",stdout);
  ll t;
  cin>>t;
  if(t%1000==0){
    cout<<"0\n";
  }else{
    cout<< 1000 - (t%1000)<<"\n";
  }
  return 0;
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

int main(){
    ll n, k;
    cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    vl pos, neg, zero;
    rep(i, n) {
        if(a[i] > 0) pos.pb(a[i]);
        else if(a[i] == 0) zero.pb(a[i]);
        else neg.pb(-a[i]);
    }
    sort(all(pos));
    sort(all(neg));
    auto check = [&](ll m) {
        ll cnt = 0;
        {
            if(m >= 0) cnt += (ll)pos.size()*neg.size();
            else {
                ll x = abs(m);
                rep(i, pos.size()) {
                    auto it = lower_bound(all(neg), (x+pos[i]-1)/pos[i]);
                    cnt += neg.end() - it;
                }
            }
        }
        // cout << " " << cnt;
        if(m >= 0) {
            cnt += (ll)zero.size()*(n-zero.size());
            ll z = zero.size();
            if(z > 0) cnt += z*(z-1)/2;
        }
        // cout << " " << cnt << " ";

        if(m > 0) {
            for(auto cur = pos.begin(); cur != pos.end(); ++ cur) {
                auto nxt = upper_bound(cur+1, pos.end(), m / *cur);
                cnt += nxt - cur - 1;
            }
            for(auto cur = neg.begin(); cur != neg.end(); ++ cur) {
                auto nxt = upper_bound(cur+1, neg.end(), m / *cur);
                cnt += nxt - cur - 1;
            }
        }
        // cout << " " << cnt << endl;
        return cnt >= k;
    };
    ll l = -1e18, r = 1e18; 
    rep(i, 128) {
        ll m = (l + r) / 2;
        // cout << m << " " << l << " " << r  << " ";
        if(check(m)) r = m;
        else l = m;
    }
    cout << r << endl;
    // cout << check(6) << endl;
    // cout << check(7) << endl;
    return 0;
}

Measured memory_bytes: 4468
#if loc||local
#define _GLIBCXX_DEBUG
#endif

#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  string s;
  cin>>s;
  int n = size(s);
  vector<int> a(n);
  rep(i,n)a[i]=s[i]-'0';
  ll sum = 0;
  rep(i,n){
    sum += a[i];
    sum %= 9;
  }
  cout<<(sum==0?"Yes":"No")<<endl;

}


Measured memory_bytes: 4356
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[100005];

void solve()
{
    scanf("%s", str);
    int cnt = 0;
    while (1) {
        int n = strlen(str);
        if (n == 0) break;
        if (strncmp(&str[n - 5], "dream", 5) == 0) {
            str[n - 5] = '\0'; continue;
        }
        if (strncmp(&str[n-7], "dreamer", 7) == 0) {
            str[n - 7] = '\0'; continue;
        }
        if (strncmp(&str[n-5], "erase", 5) == 0) {
            str[n - 5] = '\0'; continue;
        }
        if (strncmp(&str[n-6], "eraser", 6) == 0) {
            str[n - 6] = '\0'; continue;
        }
        printf("NO\n"); return;
    }
    printf("YES\n");
    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d%d", &T, &B);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



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

int main()
{
	string s;
	cin >> s;
	int count = 0;

	for (int i = 0; i < s.size(); i++)
	{
		if (s.at(i) == '+')
		{
			count++;
		}
		else
		{
			count--;
		}
	}

	cout << count << endl;
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  for (int i = 0; i < S.size(); i++) {
    S.at(i) = 'A' + (S.at(i) - 'A' + N) % 26;
  }
  cout << S << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int a, b, k;
  cin >> a >> b >> k;
  int maxv = min(a, b);

  int c = 0;
  repr(i, 0, maxv + 1) {
    if (a % i == 0 && b % i == 0)
      c++;
    if (c == k) {
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A1,A2,A3;
    scanf("%d%d%d",&A1,&A2,&A3);
    if(A1>=1&&A1<=13&&A2>=1&&A2<=13&&A3>=1&&A3<=13){
        if(A1+A2+A3<=21){
            printf("win");
        }else{
            printf("bust");
        }
    }
    
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll n;cin >> n;
    vvl v(9,vl(9,0));
    ll i=1;
    while(i<=n){
        ll p=i;
        ll x=log10(p);
        ll b=p%10;
        ll c=1;
        rep(i,x)c*=10;
        ll a=p/c;
        a--;b--;
        if(b!=-1)v[a][b]++;
        i++;
    }
    ll ans=0;
    rep(i,9){
        rep(j,9){
            ans+=v[i][j]*v[j][i];
        }
    }
    cout << ans <<endl;
}

Measured memory_bytes: 640