akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(ll i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end();++it)
#define pb push_back
#define fs first
#define sc second
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;

const ll INF = ~(1<<31);
const double pi = acos(-1);
const double EPS = 1e-9;
typedef unsigned long long ull;

template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

string s;
ll md = 1000000000+7;
ll memo[200'020][2];

ll dp(ll at, ll smaller) {
    if(at >= ll(s.size())) return 1;
    if(memo[at][smaller] != -1) return memo[at][smaller];
    ll sm = 0;
    if(smaller) {
        sm += dp(at+1,1)*3;
    } else {
        if(s[at] == '0') {
            sm += dp(at+1,0);
        } else {
            sm += dp(at+1,0)*2+dp(at+1,1);
        }
    }
    sm %= md;
    return memo[at][smaller] = sm;
}

int main() {
    cin.sync_with_stdio(false);
    cin >> s;
    memset(memo,-1,sizeof(memo));
    cout << dp(0,0) << endl;
    return 0;
}


Measured memory_bytes: 8272
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
input = sys.stdin.readline

setrecursionlimit(1000000)

dp = defaultdict(lambda x:-1)

def main():
	a,b = map(int,input().split())
	if(a<10 and b<10):
		print(a*b)
	else:
		print(-1)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()


Measured memory_bytes: 65516
//ABC084 - C
#include <iostream>
#include <algorithm>
using namespace std;

int main() {
    int N,K;
    cin >> N >> K;
    int A[N+1];
    int count[N+1];
    A[0] = count[0] = 0;
    for(int i=1;i<=N;i++) count[i] = 0;
    for(int i=1;i<=N;i++){
        cin >> A[i];
        count[A[i]]++;
    }
    sort(count,count+N+1);
    int p = 0;
    for(int i=N;i>N-K;i--){
        p = p + count[i];
    }
    cout << N-p <<"\n";
    return 0;
}

Measured memory_bytes: 1792
use std::cmp::max;

fn main() {
    let n = {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let n: usize = buf.trim_end().parse().unwrap();
        n
    };
    let mut t: i64 = 1;
    let mut a: i64 = 1;
    for i in 0..n {
        let mut buf = String::new();
        std::io::stdin().read_line(&mut buf).unwrap();
        let mut it = buf.trim_end().split_whitespace();
        let t_r: i64 = it.next().unwrap().parse().unwrap();
        let a_r: i64 = it.next().unwrap().parse().unwrap();

        let mut r = max(t / t_r, a / a_r);
        if r * t_r < t || r * a_r < a {
            r += 1;
        }
        t = r * t_r;
        a = r * a_r;
    }
    println!("{}", t + a);
}


Measured memory_bytes: 2116
N = int(input())
S = list(input())
left = [0]*N
for i in range(1,N):
    if S[i-1] == 'W':
        left[i] = left[i-1]+1
    else:
        left[i] = left[i-1]
right = [0]*N
for i in range(N-1)[::-1]:
    if S[i+1] == 'E':
        right[i] = right[i+1]+1
    else:
        right[i] = right[i+1]
leftright = [left[i]+right[i] for i in range(N)]
print(min(leftright))

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

public class Main {
	static int head = 0;
	static int tail = 0;
	static Process[] queue = new Process[100005];

	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			String nq[] = br.readLine().split(" ");
			int n = Integer.parseInt(nq[0]);
			int q = Integer.parseInt(nq[1]);
			int total = 0;
			for (int i = 0; i < n; i++) {
				String[] tmp = br.readLine().split(" ");
				String name = tmp[0];
				int time = Integer.parseInt(tmp[1]);
				Process p = new Process(name, time);
				enqueue(p);
			}
			while (head != tail) {
				Process cur = dequeue();
				int leftTime = Math.min(cur.time, q);
				cur.time -= leftTime;
				total += leftTime;
				if (cur.time > 0) {
					enqueue(cur);
				} else {
					System.out.println(cur.name + " " + total);
				}

			}

		} catch (IOException e) {
			e.printStackTrace();
		}

	}

	static void enqueue(Process p) {
		if ((tail + 1) % queue.length == head) {
			System.err.println("キューが満タンです");
			return;
		}
		queue[tail] = p;
		tail = (tail + 1) % queue.length;
	}

	static Process dequeue() {
		Process ret = null;
		if (head == tail) {
			System.err.println("キューが空です");
		} else {
			ret = queue[head];
			head = (head + 1) % queue.length;
		}

		return ret;
	}

}

class Process {
	String name;
	int time;

	public Process(String name, int time) {
		this.name = name;
		this.time = time;
	}
}


Measured memory_bytes: 61056
#include <iostream>
#include <string>
using namespace std;
int main(void){
  char a,b;
  cin >> a >> b;
  
  if(a == 'H')
    cout << b << endl;
  else if(b == 'H')
    cout << "D" << endl;
  else
    cout << "H" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL read(){
	LL x=0;
	char ch=getchar();
	while (!isdigit(ch))
		ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return x;
}
const int N=100005;
int n,k=0;
vector <int> v[N];
int main(){
	n=read();
	while (k*(k-1)/2<n)
		k++;
	if (k*(k-1)/2!=n)
		return puts("No"),0;
	int t=0;
	for (int i=1;i<k;i++)
		for (int j=i+1;j<=k;j++){
			v[i].push_back(++t);
			v[j].push_back(t);
		}
	puts("Yes");
	printf("%d\n",k);
	for (int i=1;i<=k;i++){
		printf("%d ",(int)v[i].size());
		for (auto x : v[i])
			printf("%d ",x);
		puts("");
	}
	return 0;
}

Measured memory_bytes: 4608
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define sll set<ll>
#define str string
#define rev reverse
#define mp make_pair
#define pb push_back
#define acc accumulate
#define vll vector<ll>
#define eb emplace_back
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll> >
#define dq deque<ll>
#define puf push_front
#define pub push_back
#define pof pop_front
#define pob pop_back

vll adj[100000];
bool visited[100000];
ll ans[100000];

void initilaize()
{
    for(ll i=0;i<100000;i++)
    {
        visited[i]=false;
        ans[i]=0;
    }
}

void dfs(ll s)
{
    visited[s]=true;
    //cout << s << endl;
    for(ll i=0;i<adj[s].size();i++)
    {
        if(visited[adj[s][i]]==false)
            dfs(adj[s][i]);
        ans[s]=max(ans[s],1+ans[adj[s][i]]);
    }
}

void solve()
{
    ll n,m,i,p,q;
    cin >> n >> m;
    initilaize();
    for(i=0;i<m;i++)
    {
        cin >> p >> q;
        adj[p-1].pb(q-1);
    }
    /*for(i=0;i<n;i++)
    {
        cout << i << " -> ";
        for(ll j=0;j<adj[i].size();j++)
        {
            cout << adj[i][j] << " ";
        }
        cout << endl;
    }*/
    for(i=0;i<n;i++)
    {
        if(visited[i]==false)
            dfs(i);
        //cout << ans[i] << " ";
    }
    //cout << endl;
    ll maxi=0;
    for(i=0;i<n;i++)
    {
        maxi=max(maxi,ans[i]);
    }
    cout << maxi << endl;
}

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll cases;
    //cin >> cases;
    cases=1;
    for(ll i=0;i<cases;i++)
        solve();

    return 0;
}

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

def solve():
    A, B, K = list(map(int, input().split()))

    for i in range(101, 0, -1):
        if A%i==0 and B%i==0:
            K -= 1
            if K==0:
                print(i)
                return



if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
#include<algorithm>
#include<queue>
#include<map>
#include<iomanip>

using namespace std;
int main(void){
 int x1,y1;
 int x2,y2;
 int dx,dy;
 int x3,y3;
 int x4,y4;

 cin>>x1>>y1;
 cin>>x2>>y2;

 dx=x2-x1; 
 dy=y2-y1;
 
 x3=x2-dy;
 y3=y2+dx;

 x4=x3-dx;
 y4=y3-dy;

 std::cout<<x3<<" "<<y3<<std::endl;
 std::cout<<x4<<" "<<y4<<std::endl;
 return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int infty = 1e9;
struct segment_tree {
  public:
    int n, N;
    vector<pair<int, int>> tr;
    segment_tree (vector<pair<int, int>> v) {
      n = v.size();
      N = 1;
      while (N < n) {
        N <<= 1;
      }
      tr.resize(2 * N, {infty, -1});
      for (int i = 0; i < n; i++) {
        tr[N + i] = v[i];
      }
      for (int i = N - 1; i >= 1; i--) {
        tr[i] = min(tr[2 * i], tr[2 * i + 1]);
      }
    }
    pair<int, int> pairMin (pair<int, int>a, pair<int, int>b) {
      if (a.first < b.first) return a;
      if (a.first == b.first && a.second < b.second) return a;
      return b;
    }
    void update (int i, pair<int, int> x) {
      i += N;
      tr[i] = x;
      i >>= 1;
      for (; i; i >>= 1) {
        tr[i] = min(tr[2 * i], tr[2 * i + 1]);
      }
    }
    pair<int, int> getMin (int l, int r, int k = 1, int L = 0, int R = -1) {
      if (R == -1) R = N;
      if (l <= L && R <= r) {
        return tr[k];
      } else if (r <= L || R <= l) {
        return {infty, -1};
      } else {
        int C = (L + R) >> 1;
        return min(getMin(l, r, 2 * k, L, C), getMin(l, r, 2 * k + 1, C, R));
      }
    }
};
vector<vector<int>> grh;
vector<int> pos;
vector<pair<int, int>> ord;
void dfs (int crr, int d) {
  pos[crr] = ord.size();
  ord.push_back({d, crr});
  for (int nxt : grh[crr]) {
    dfs(nxt, d + 1);
    ord.push_back({d, crr});
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  grh.resize(n);
  pos.resize(n);
  for (int i = 0; i < n; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int c;
      cin >> c;
      grh[i].push_back(c);
    }
  }
  dfs(0, 0);
  segment_tree sgt(ord);
  int q;
  cin >> q;
  while (q--) {
    int u, v;
    cin >> u >> v;
    int l = pos[u];
    int r = pos[v];
    if (l > r) swap(l, r);
    r++;
    auto p = sgt.getMin(l, r);
    cout << p.second << '\n';
  }
  return 0;
}


Measured memory_bytes: 22244
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<list>
#define lli long long int
#define h 1000000007
#define pf push_front
#define pb push_back
#define ub upper_bound
#define lb lower_bound
#define pi 3.14159
using namespace std;
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL) ;
  lli n, ans=0,cnt=0,i;
  cin>>n;
  vector<lli>a(n),b(n);
  for(i=0;i<n;i++) {cin>>a[i];cin>>b[i];} 
  for(i=0;i<n;i++) 
  {
  	if(a[i]==b[i]) cnt+=1;
  	else
  	{
  		ans=max(ans,cnt);
  		cnt=0;
  	} 
  } 
  ans=max(ans,cnt);
  if(ans>=3)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
} 


Measured memory_bytes: 3656
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
#include<map>

using namespace std;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)
 
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(b,c) << " " << max(0,min(b,c) - (a-max(b,c))) << endl;

}


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

int main() {
    vector<string> Ss(3, "");
    cin >> Ss[0] >> Ss[1] >> Ss[2];
    vector<int> ps(3, 0);
    int p = 0;
    while (ps[p] < Ss[p].size()){
        auto next_p = Ss[p][ps[p]];
        ps[p] += 1;
        if (next_p == 'a'){
            p = 0;
        }else if (next_p == 'b'){
            p = 1;
        }else if (next_p == 'c'){
            p = 2;
        }else {
            cout << "Unexpected result." << endl;
            return 0;
        }
    }
    cout << string("ABC")[p] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    
    ll n;
    cin>>n;
    string ans;
    while(n){
        n--;
        ans += ('a'+n%26);
        n /= 26;
    }
    reverse(ans.begin(),ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////


int main(){fastio
    ll n,a,b;cin>>n>>a>>b;
    a=a*n;
    if(a>b)swap(a,b);
    cout<<a<<endl;
    
    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long


vector<vector<ll> >v;
vector<vector<ll> >dp;

bool compare(vector<ll>&a,vector<ll>&b){
    ll w1 = a[0],s1=a[1],w2=b[0],s2=b[1];
    return w1+s1 > w2+s2;
}
void printdp(){
    cout <<"--------------start---------------\n";
    for(ll i=0;i<dp.size();i++){
        for(ll j=0;j<dp[0].size();j++){
            cout << dp[i][j]<<" ";
        }
        cout <<"\n";
    }
    cout <<"--------------end---------------\n";
}
void solve(){
  ll n;cin>>n;
  v.resize(n,vector<ll>(3));
  dp.resize(n,vector<ll>(10002));
  for(ll i=0;i<n;i++){
    cin>>v[i][0]>>v[i][1]>>v[i][2];
  }
  sort(v.begin(),v.end(),compare);
  for(ll i=0;i<=v[0][1];i++){
    dp[0][i]=v[0][2];
  }
  //printdp();
  for(ll i=1;i<n;i++){
        //cout<<v[i][2]<<"n";
    for(ll j=0;j<10002;j++){
        //cout << i<<" "<<j<<"\n";
        ll a = dp[i-1][j];
        ll b=0;
        if(j<=v[i][1]){
            b = v[i][2] + ((j+v[i][0]<10002) ? (dp[i-1][j+v[i][0]]):0);
        }
        dp[i][j] = max(a,b);
        //cout <<"dpij: " <<dp[i-1][j]<<" "<<dp[i][j]<<"\n";
    }
    //printdp();
  }
  cout <<dp[n-1][0]<<"\n";
}

int main(){
//    cin.tie(0);
//    cout.tie(0);
//    cin.sync_with_stdio(0);
//    cout.sync_with_stdio(0);

    //cout.precision(10);
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 78592
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <utility>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
using namespace std;
int N, M;

int main(){
  cin.sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  
  cin >> N >> M;

  vector<pair<int, int> > conflicts(M);
  rep(i,M){
    cin >> conflicts[i].second >> conflicts[i].first;
  }

  sort(conflicts.begin(), conflicts.end());
  int ans = 0;
  int tmp_first,tmp_second; 
  rep(i, M){
    int i_cf = conflicts[i].first;
    int i_cs = conflicts[i].second;
    if(i==0){
        ans++;
        tmp_first = i_cf;
        tmp_second = i_cs;
        continue;
    }
    if (i_cf == tmp_first){
        if (tmp_second < i_cs) tmp_second = i_cs;
        continue;
    }
    if (i_cs < tmp_first) continue;
    ans++;
    tmp_first = i_cf;
    tmp_second = i_cs;
  }

  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1024
package main

import "fmt"

func min(x int, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func max(x int, y int) int {
	if x < y {
		return y
	} else {
		return x
	}
}

func main() {
	var a, b int
	var answers [30000][2]int
	var i int
	for i = 0; i != -1; i++ {

		fmt.Scan(&a, &b)
		if a == 0 && b == 0 {
			break
		}
		answers[i][0] = min(a, b)
		answers[i][1] = max(a, b)
	}

	for j := 0; j < i; j++ {
		fmt.Println(answers[j][0], answers[j][1])
	}
}



Measured memory_bytes: 1772
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
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<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n, m, ans=0;

	cin>>n;

	vs s(n), st;

	rep(i, n) cin>>s[i];

	st=s;

	cin>>m;

	vs t(m);

	rep(i, m){
		cin>>t[i];
		st.push_back(t[i]);
	}

	rep(i, st.size()){
		int temp=0;
		rep(j, n){
			if(s[j]==st[i]) temp++;
		}
		rep(j, m){
			if(t[j]==st[i]) temp--;
		}
		if(temp>ans) ans=temp;
	}
	cout<<ans<<endl;
}

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

int n;
long long int k;
int cnt[41];

long long int dfs(int i, int f) {
    if(i < 0){
        return 0;
    }
    long long int m = 1LL << i;
    if(f){  // greedy
        return dfs(i-1, 1) + m*max(n - cnt[i], cnt[i]);
    }else{  // not greedy
        if(k >> i & 1){
            return max(dfs(i-1, 1) + m*(cnt[i]),
                       dfs(i-1, 0) + m*(n - cnt[i]));
        }else{
            return dfs(i-1, 0) + m*(cnt[i]);
        }
    }
}

int main() {
    // input
    cin >> n >> k;
    for(int i=0;i<n;i++){
        long long int a; cin >> a;
        for(int j=0;j<40;j++){
            cnt[j] += a >> j & 1;
        }
    }
    // output
    cout << dfs(41, 0) << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;

int main(){
	int N;
	char s[300000];

	scanf("%d", &N);
	scanf("%s", s);

	int E = 0, W = 0;
	FOR(i,1, N){
		if(s[i]=='E'){
			E++;
		}
	}

	int ans = E;

	FOR(i, 1, N){
		if (s[i] == 'E'){
			E--;
		}
		if (s[i - 1] == 'W'){
			W++;
		}
		if (ans > E + W){
			ans = E + W;
		}
      
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e16;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll H, W; cin >> H >> W;
    ll N; cin >> N;
    queue<ll> q;
    REP(i, N) {
        ll a; cin >> a;
        REP(j, a) q.push(i+1);
    }

    vvl c(H, vl(W, 0)); ll h = 0, w = 0;
    while(q.size() > 0){
        ll v = q.front(); q.pop();
        c[h][w] = v;
        // move next
        if(h%2 == 0){
            if(w < W-1){
                w++; continue;
            }
            else if(w == W-1){
                h++; continue;
            }
        }
        else{
            if(w > 0){
                w--; continue;
            }
            else if(w==0){
                h++; continue;
            }
        }
    }
    REP(h, H){
        REP(w, W) cout << c[h][w] << " ";
        cout << endl;
    }
    
    
    return 0;
}


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

using ll = long long;
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

#define INF 1e9

int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(S == U){
    A--;
  }
  else{
    B--;
  }
  cout << A << " " << B << endl;
  return 0;
}


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


int main(){
	int n;
	cin >> n;
	int dp[n+1] = {0},memo = 100000000,tmp = 0,cnt = 0;
	int n_6[6] = {6,36,216,1296,7776,46656},
		n_9[5] = {9,81,729,6561,59049};
	dp[0] = 0;
	
	rep(i,1,n+1){
		memo = 100000000;
		tmp = i;
		
		if(i-1 >= 0){
			memo = min(memo,dp[i-1]+1);
		}
		
		rep(j,0,6){
			if(i-n_6[j] >= 0){
				memo = min(memo,dp[i-n_6[j]]+1);
			}
			else{
				break;
			}
		}
		
		rep(j,0,5){
			if(i-n_9[j] >= 0){
				memo = min(memo,dp[i-n_9[j]]+1);
			}
			else{
				break;
			}
		}
		
		dp[i] = memo;
	}
	
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main(){
  int N, M, X; cin >> N >> M >> X;
  vector<int> C(N);
  vector<vector<int>> A(N, vector<int>(M));
  rep(i, N){
    cin >> C.at(i);
    rep(j, M){
      cin >> A.at(i).at(j);
    }
  }
  vector<int> understand(M, 0);
  bool ok = true;
  int ans = 1000000000;
  rep(i, N){
    rep(j, M){
      understand.at(j) += A.at(i).at(j);
    }
  }
  rep(i, M){
    if(understand.at(i) < X){
      ok = false;
    }
  }
  if(ok){
    int num = pow(2, N);
    rep(i, num){
      int a = i;
      vector<int> sankou(N);
      int b = 0;
      while(a > 0){
        sankou.at(b) = a % 2;
        a /= 2;
        b++;
      }
      vector<int> us(M, 0);
      int money = 0;
      rep(j, N){
        if(sankou.at(j)){
          money += C.at(j);
          rep(k, M){
            us.at(k) += A.at(j).at(k);
          }
        }
      }
      bool okok = true;
      rep(j, M){
        if(us.at(j) < X){
          okok = false;
        }
      }
      if(okok){
        ans = min(ans, money);
      }
    }
  } else {
    ans = -1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4112
#include<stdio.h>
int main(void)
{
	int a,b,c,s,i;
	scanf("%d",&a);
	for(i=0;i<a;i++){
		scanf("%d %d",&b,&c);
		s=b%c;
			if(s==0){
				printf("%d\n",c);
			}
			else{
			printf("%d\n",s);
			}
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
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...));
}

const int MOD = 1000000007;

int ans = 100000000;

int main(){
    int A, B; cin >> A >> B;
    string S; cin >> S;
    int n = S.size();

    if (A+B+1 != n){
        cout << "No" << endl;
        return 0;
    }

    rep(i,n){
        if (i != A){
            if (!('0' <= S[i] && S[i] <= '9')){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if (S[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3624
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n=int(input())
if n==1:
    print(0)
    exit()
ans=0
t=factorization(n)

fg=[]
for i in range(1,16):
    fg.append(i*(i+1)//2)

tmp=[]
for i in range(len(t)):
    cnt=0
    for j in range(len(fg)):
        if t[i][1]>=fg[j]:
            cnt=(j+1)
    ans+=cnt

print(ans)

Measured memory_bytes: 9508
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        var scaner = new Scanner(System.in);
        var a_b_n = scaner.nextLine().split(" ");
        var a = Long.parseLong(a_b_n[0]);
        var b = Long.parseLong(a_b_n[1]);
        var n = Long.parseLong(a_b_n[2]);
        scaner.close();

        long x = n;

        if(n >= b-1) x = b-1;
        long ans = a*x/b - a*(x/b);
        System.out.println(ans);
    }

}


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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  cout << n * n * n << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mpr make_pair
#define mt make_tuple
 
using namespace std;
 
const ll N = 100010;
const ll mod = 1e9 + 7;
ll power(ll x, ll   y, ll p){ ll res = 1; x = x % p;while (y > 0){ if (y & 1) res = (res*x) % p; y = y>>1; x = (x*x) % p;} return res; }

ll dp[N];

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    ll arr[N];
    cin>>n>>k;
    for(int i=0;i<n;i++)   cin>>arr[i];
    memset(dp, mod, sizeof(dp));
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=min(n-1,i+k);j++){
            dp[j] = min(dp[j], dp[i] + abs(arr[i] - arr[j]));
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
using namespace std;
int n,m,l,p;
int a[100][100];
int D[100];
void bfs( int src) {
	queue<int> Q;
	Q.push(src);
	D[src]=0;
	while( ! Q.empty() ) {
		int cur = Q.front();
		Q.pop();
		for(int dst = 0; dst < n; dst++ ) {
			if( D[dst] < 0 && a[cur][dst] == 1 ) {
				D[dst] = D[cur] + 1;
				Q.push(dst);
			}
		}
	}
	for (int i = 0; i < n;i++) {
	cout << i+1 <<  " " << D[i] <<  endl;
	}
}

int main() {
	cin >> n;
	for ( int i = 0;i < n;i++) {
		D[i] = -1;
		for(int j= 0; j < n;j++) {
			a[i][j] = 0;
		}
	}
	for (int i = 0;i < n; i++){
		cin >> m;
		cin >> l;
		for(int j = 0; j < l;j++) {
			cin >> p;
			a[m-1][p-1] = 1;
		}
	}
	bfs(0);
}
		

Measured memory_bytes: 1240
a = input()
mylist = list(map(int, a.split(" ")))
A = mylist[0]
B = mylist[1]
C = mylist[2]
 
if (A == B and B != C):
  print("Yes")
elif (A == C and B != C):
  print("Yes")
elif (B == C and A != B):
  print("Yes")
else:
  print("No")


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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

const int MAX_N = 100000;
const int INF = 1001001001;
int N;
int dp[MAX_N+1];

void solve() {

    cin >> N;
    vector<int> H(N);
    REP(i, N) cin >> H[i];

    for (int i = 0; i < MAX_N+1; i++) {
        dp[i] = INF;
    }
    dp[0] = 0;
    dp[1] = 0;
    for (int i = 1; i < N; i++) {
        if (i == 1) {
            dp[i+1] = dp[i] + abs(H[i] - H[i-1]);
        } else {
            dp[i+1] = min(dp[i] + abs(H[i] - H[i-1]), dp[i-1] + abs(H[i] - H[i-2]));
        }
    }

    print(dp[N]);

}

signed main() {
    solve();
}


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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int) 1e9 + 7;
const int N = 300000;
void solve() {
	int h, w, m;
	cin >> h >> w >> m;
	map<int, int> row, col;
	map<pair<int, int>, int> mm;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		row[x]++;
		col[y]++;
		mm[{x, y}] = 1;
	}
	int rowmax = -1, colmax = -1;
	map<int, vector<int>> rr, cc;
	for (auto [key, value] : row) {
		if (value == rowmax) {
			rr[value].push_back(key);
			rowmax = value;
		}
		else if (value > rowmax) {
			rr[value].clear();
			rr[value].push_back(key);
			rowmax = value;
		}
	}
	for (auto [key, value] : col) {
		if (value == colmax) {
			cc[value].push_back(key);
			colmax = value;
		}
		else if (value > colmax) {
			cc[value].clear();
			cc[value].push_back(key);
			colmax = value;
		}
	}
	int maxi = colmax + rowmax;
	for (auto i : rr[rowmax]) {
		for (int j : cc[colmax]) {
			if (mm[{i, j}] != 1) {
				cout << maxi << "\n";
				return;
			}
		}
	}
	cout << maxi - 1 << "\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int tt = 1;
	//cin >> tt;
	while (tt--) {
		solve();
	}
	return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)

const int MAX = 3501;
ll N;

void solve() {
    FOR (h, 1, MAX) FOR (n, 1, MAX) {
        ll a = N*h*n;
        ll b = 4*h*n - N*n - N*h;
        if (a >= 1 && b >= 1 && a%b == 0) {
            cout << h << " " <<  n << " " << (a/b) << endl;
            return;
        }
    }
}

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

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

struct Problem {
public:

	void Solve() {
		while (true) {
			UL N, M; scanf("%d%d", &N, &M);
			if (N == 0) break;
			M /= N;
			UL ans = 0;
			rep(i, N) {
				UL A; scanf("%d", &A);
				ans += min(A, M);
			}
			printf("%d\n", ans);
		}
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}



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

int main(){
    int x1,y1,x2,y2,x3,y3,x4,y4;
    cin>>x1>>y1>>x2>>y2;
    x3=x2-(y2-y1);
    y3=y2+(x2-x1);
    x4=x1-(y2-y1);
    y4=y1+(x2-x1);
    cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;

    return 0;
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		long  a =scn.nextLong();
		long b =scn.nextLong();
		long n =scn.nextLong();
		long val = Math.min(b-1, n);
		System.out.println(a*val/b);

	}

}

Measured memory_bytes: 35668
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int M=1e9+7;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,w;
    cin>>n>>w;
    char c[n][w];
    for(int i=0;i<n;i++)
        for(int j=0;j<w;j++)
            cin>>c[i][j];
    ll dp[n+1][w+1];
    for(int i=0;i<=n;i++)
        for(int j=0;j<=w;j++)
        {
            if(i==0 || j==0)
                dp[i][j]=0;
            else if(i==1 && j==1)
                dp[i][j]=1;
            else if(c[i-1][j-1]=='#')
                dp[i][j]=0;
            else 
                dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
        }
    cout<<dp[n][w];
    return 0;
}

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

int main(){
	int n;cin >> n;
	int cnt = 0,cnt1 = 0, cnt2= 0;
	int a;
	for(int i = 0; i < n; i++){
		cin >> a;
		if(a% 4 == 0) cnt ++;
		else{
			if(a&1) cnt1++;
			else cnt2++;
		}
	}
	if(cnt2>0 && cnt1<=cnt)
		printf("Yes\n");
	else if(cnt2==0 && cnt1<=cnt+1)
		printf("Yes\n");
	else
		printf("No\n");

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
void dfs(int j,vector<int>a[],int ans[],bool vis[])
{
    vis[j]=true;
    int i;
    for(i=0;i<a[j].size();i++)
    {
        if(!vis[a[j][i]])
        dfs(a[j][i],a,ans,vis);
        ans[j]=max(ans[j],ans[a[j][i]]+1);
    }
}
int main() {
    int i,j,n,m,p,q;
    
    cin>>n>>m;
    vector<int>a[n+1];
    for(i=0;i<m;i++)
    {
        cin>>p>>q;
        a[p].push_back(q);
    }
    bool vis[n+1];
    memset(vis,false,sizeof(vis));
    int ans[n+1];
    memset(ans,0,sizeof(ans));
    for(i=1;i<=n;i++)
    {
        if(vis[i]==false)
        {
            dfs(i,a,ans,vis);
        }
    }
    int z=0;
    for(i=1;i<=n;i++)
    z=max(z,ans[i]);
    cout<<z;
	return 0;
}

Measured memory_bytes: 12892
package main

import "fmt"

func main() {
	var s, t string
	var a, b int
	var u string
	fmt.Scanf("%s %s", &s, &t)
	fmt.Scanf("%d %d", &a, &b)
	fmt.Scanf("%s", &u)
	if u == s {
		a--
	} else if u == t {
		b--
	}
	fmt.Printf("%d %d", a, b)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
#define endl "\n"
#define F first
#define S second
#define pb push_back
#define loop(n) for(int i=0; i<n; i++)
void solve()
{
	float r;
	cin>>r;
	float ans=float(2*r*3.14159);
	cout<<ans<<"\n";
	
	return;
}
int32_t main() 
{ 
	fast;
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0; 
}

Measured memory_bytes: 3800
#include <iostream>
using namespace std;
int main()
{
	int a,b,c=1;
	cin>>a>>b;
	if(a==1&&b==1&&a==b)
	{
		cout<<"Draw";
		return 0;
	}
	if(a==1){
		cout<<"Alice";
		return 0;
	}
	if(b==1){
		cout<<"Bob";
		return 0;
	}
	if(a>b)
	{
		cout<<"Alice";
	}
	if(b>a){
		cout<<"Bob";
	}
	if(a==b)
	cout<<"Draw";
	return 0;
}

Measured memory_bytes: 256
import sys
s = input()
a  = 7
n = len(s)
for i in range(2**(n-1)):
    total = int(s[0])
    ans = [s[0]]
    for j in range(n-1):
        if (i >> j) & 1:
            total += int(s[j+1])
            ans.append('+' + s[j+1])
        else:
            total -= int(s[j+1])
            ans.append('-'+s[j+1])
    if total == 7:
        print(''.join(ans) + '=7')
        sys.exit()


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

int convert(string& s) {
    map<char, char> c_s;    // 変換テーブル
    char to = 'a';
    REP(i, s.length()) {
        if(c_s.count(s[i]) == 0) {
            c_s[s[i]] = to;
            s[i] = to;
            to++;
        } else {
            s[i] = c_s[s[i]];
        }
    }
}

signed main()
{
    string S, T;
    cin >> S >> T;

    convert(S);
    convert(T);
    if(S == T) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll k,n,t=0;
	cin >> k >> n;

	ll a[n],ans=0;
	for(int i=0;i<n;i++)
		cin >> a[i];

	sort(a,a+n);
	t = (k-a[n-1]) + a[0];

	for(int i=1;i<n;i++) {
		t = max(t, a[i]-a[i-1]);
	}
	cout << k-t;
}

Measured memory_bytes: 1792
d = {"A": 0, "AB": 0, "B": 0, "O": 0}
flag = 1
while flag:
    try:
        _, blood_type = input().split(',')
        d[blood_type] += 1
    except:
        for blood_type in ["A", "B", "AB", "O"]:
            print(d[blood_type])
        flag = 0

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

int main()
{
	double n; cin >> n;
	int sum = 0;
	for(int i=1; i<n; i++){
		sum += ceil(n/i) - 1;
		//cout << ceil(n/i) - 1 << ' ';
	}
	//cout << endl;
	cout << sum;

    return 0;
}


Measured memory_bytes: 3716
#include <cstdio>
#include <vector>
using namespace std;

class Problem {
 public:
  int N, M, x, y, z;
  vector<int> adj[100002];
  vector<int> visit;
  
  Problem() {
    scanf("%d%d", &N, &M);
    visit = vector<int>(N+10);
    for(int i = 0; i < M; i++) {
      scanf("%d%d%d", &x, &y, &z);
      adj[x].push_back(y);
      adj[y].push_back(x);
    }
  }

  int dfs(int n) {
    if (visit[n]) return 0;
    visit[n] = 1;
    for(int d: adj[n])
      dfs(d);
    return 1;
  }
  
  void solve() {
    int ans = 0;
    for(int i = 1; i <= N; i++)
      ans += dfs(i);
    printf("%d", ans);
  }
};

int main() {
  Problem().solve();
}
      

Measured memory_bytes: 10752
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAX_N = 1e7;

int n;
int tot = 0;
LL fac[MAX_N + 5], minp[MAX_N + 5], p[MAX_N + 5];
bool vis[MAX_N + 5];
LL ans = 0;

void init(int n)
{
    memset(vis, 0, sizeof(vis));
    fac[1] = 1; minp[1] = 0;
    for (int i = 2; i <= n; i++)
    {
        if (!vis[i])
        {
            p[++tot] = i; fac[i] = 2; minp[i] = 1;
        }
        for (int j = 1; j <= tot && i*p[j] <= n; j++)
        {
            vis[i*p[j]] = 1;
            if (i%p[j] == 0)
            {
                fac[i*p[j]] = fac[i]/(minp[i]+1)*(minp[i]+2);
                minp[i*p[j]] = minp[i]+1;
                break;
            }
            else
            {
                fac[i*p[j]] = fac[i]*2;
                minp[i*p[j]] = 1;
            }
        }
    }
}

int main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(0); cout.tie(0);
	scanf("%d", &n);
	init(n);
	for (int i = 1; i <= n; i++)
    {
        ans += i*fac[i];
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 175032
t_hlth, t_atk, a_hlth, a_atk = [int(x) for x in input().split(' ')]

t_kill_turn = (a_hlth + t_atk - 1) // t_atk
a_kill_turn = (t_hlth + a_atk - 1) // a_atk

if t_kill_turn > a_kill_turn:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 9172
import heapq
d = []
while True:
    s = input().split()
    if s[0] == "end":
        break
    if s[0] == "insert":
        heapq.heappush(d, -int(s[1]))
    if s[0] == "extract":
        c = heapq.heappop(d)
        print(-c)



Measured memory_bytes: 45308
length = int(input())
target = [int(n) for n in input().split(" ")]
splitter = target[-1]
border = 0
for i, n in enumerate(target):
    if n <= splitter:
        target[i], target[border] = target[border], target[i]
        border += 1
target[border - 1] = [splitter]
print(*target)

Measured memory_bytes: 18440
#include<stdio.h>
#define N 1000
#define M 100

int main(void){
  int i,num,j;
  char ch[M],hoge;
  int digit,c,co,count[N][M],cdigit[N];

  for(i=0;;i++){
    for(j=0;;j++){
      scanf("%c",&ch[j]);
      if(ch[j]=='\n')
        break;
    }
    digit=j;
    ch[j]=0;
    if(ch[0]=='E' &&
        ch[1]=='N' &&
        ch[2]=='D' &&
        ch[3]==' ' &&
        ch[4]=='O' &&
        ch[5]=='F' &&
        ch[6]==' ' &&
        ch[7]=='I' &&
        ch[8]=='N' &&
        ch[9]=='P' &&
        ch[10]=='U' &&
        ch[11]=='T')
      break;
    for(j=0,c=0,co=0;j<=digit;j++,co++){
      if(ch[j]==' ' || ch[j]==0){
        count[i][c]=co-1;
        c++;
        co=0;
      }
    }
    count[i][0]++;
    cdigit[i]=c;
  }

  num=i;
  for(i=0;i<num;i++){
    for(j=0;j<cdigit[i];j++)
      printf("%d",count[i][j]);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
       if(i>0) printf(" ");
         printf("%d",A[i]);
	}
	printf("\n");
}

void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


Measured memory_bytes: 2040
N = int(input())
alpha = 'abcdefghijklmnopqrstuvwxyz'

def src(s):
  i = 0
  while s != alpha[i]:
    i += 1
  return i
def super_troop(n):
  if n == 1:
    return ['a']
  else:
    L = super_troop(n-1)
    LL = []
    for i in L:
      S = [j for j in i]
      S.sort(reverse=True)
      for k in range(src(S[0])+2):
        LL.append(i + alpha[k])
    return LL
X = super_troop(N)
X.sort()
for i in range(len(X)):
  print(X[i])

Measured memory_bytes: 12984
N, M, X, Y = map(int, input().split())
x = [int(a) for a in input().split()]
y = [int(a) for a in input().split()]
x.append(X)
y.append(Y)
x_max = max(x)
y_min = min(y)

if x_max < y_min:
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
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...));
}

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    if (c - a - b < 0)
        cout << "No" << endl;
    else
        cout << (4 * a * b < (c - a - b) * (c - a - b) ? "Yes" : "No") << endl;
}


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

namespace abc057
{
    class Program
    {
        static void Main(string[] args)
        {
            var t = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var ans = t[0]+t[1];
            if (ans >= 24)
                ans = ans - 24;
            Console.WriteLine(ans); 
        }
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	char b; cin >> b;

	char res = 0;
	if (b == 'A'){
		res = 'T';
	}else
	if (b == 'T'){
		res = 'A';
	}else
	if (b == 'C'){
		res = 'G';
	}else{
		res = 'C';
	} // end if
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(int argc, char **argv)
{
  //読み込み
  int n;
  scanf("%d",&n);
  //sの計算
  int xxx,s,nn;
  xxx = 1;
  s = 0;
  nn = n;
  while(xxx == 1){
    s += n % 10;
    n = n / 10;
    if(n == 0){
      xxx = 0;
    }
  }
  //割り切れるかどうか
  if(nn % s == 0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 128