akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか
int main() {
	int n;
	cin >> n;
	vector<pair<int, int>> s;
	for (int i = 0; i < n; i++) {
		int x, l;
		cin >> x >> l;
		int a = x - l;
		int b = x + l;
		s.push_back(make_pair(a, b));
	}
	sort(s.begin(), s.end());
	long long int ans = 0;
	long long int last = -1000000000000;
	for (int i = 0; i < n; i++) {
		if (last <= s[i].first) {
			ans++;
			last = s[i].second;
		}
		else if (last >= s[i].second) {
			last = s[i].second;
		}
	}
	cout << ans;
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int solve(string s)
{
    int res = 0;
    for (int i = 0; i < s.size(); i++)
    {
        if (s[i] == 'm')
        {
            if (i == 0 || !(s[i - 1] >= '1' && s[i - 1] <= '9'))
                res += 1000;
            else
                res += 1000 * (s[i - 1] - '0');
        }
        if (s[i] == 'c')
        {
            if (i == 0 || !(s[i - 1] >= '1' && s[i - 1] <= '9'))
                res += 100;
            else
                res += 100 * (s[i - 1] - '0');
        }
        if (s[i] == 'x')
        {
            if (i == 0 || !(s[i - 1] >= '1' && s[i - 1] <= '9'))
                res += 10;
            else
                res += 10 * (s[i - 1] - '0');
        }
        if (s[i] == 'i')
        {
            if (i == 0 || !(s[i - 1] >= '1' && s[i - 1] <= '9'))
                res += 1;
            else
                res += 1 * (s[i - 1] - '0');
        }
    }
    return res;
}

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

    int n;
    cin >> n;
    rep(i, n)
    {
        string s, t;
        cin >> s >> t;
        int N = solve(s), M = solve(t);
        int sum = N + M;
        string ans = "";
        int cnt = 0;
        char c[4] = {'m', 'c', 'x', 'i'};
        while (sum > 0)
        {
            int num = sum % 10;
            sum /= 10;
            if (num == 0)
            {
                cnt++;
                continue;
            }
            ans.push_back(c[3 - cnt]);
            if (num != 1)
                ans.push_back((char)(num + '0'));
            cnt++;
        }
        reverse(all(ans));
        cout << ans << endl;
    }
}


Measured memory_bytes: 3124
/**Bismillahir Rahmanir Rahim.**/
#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<cstring>
using namespace std;
typedef long long int            ll;
typedef long double              ld;
#define Faster  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pi                 acos(-1);
#define test        int t; cin>>t; while(t--)
//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());
//cin.getline(array,size);
int main()
{
    int a,ans;
    for(int i=1;i<=5;i++)
    {
        cin>>a;
        if(a==0)
            ans=i;
    }
    cout<<ans<<endl;
}


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

int K,S;

int main() {
    cin >> K >> S;
    int ans=0;
    for(int x=0;x<=K;x++){
      for(int y=0;y<=K;y++){
          if(S-(x+y) >= 0 && S-(x+y) <= K) ans++;
      }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

list_A_B =range(A,B)
list_C_D =range(C,D)

list_judge =[]

# print(list_A_B)
# print(list_C_D)

for i in list_A_B:
    for j in list_C_D:
        if i == j:
            list_judge.append(i)
        else:
            pass

print(len(list_judge))



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(vec) vec.begin(),vec.end()
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
const ll INF=1LL<<31;
const ll LINF=1LL<<60;
const double eps=1e-9;
const ll MOD=1000000007LL;
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 dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0}; 
int main(){
    ll n,m;cin>>n>>m;
    vector<P> v;
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        v.push_back(P(a,b));
    }
    sort(all(v));
    ll ans=0;
    ll c=0;
    for(int i=0;i<n;i++){
        if(m<=c+v[i].second){
            ans+=(m-c)*v[i].first;
            break;
        }else{
            ans+=v[i].second*v[i].first;
        }
        m-=v[i].second;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 100000000;
const ll half_inf = 0x3f3f3f3f;
const ll inf = 0x7fffffff;
const ll mod = 998244353;
const ll maxn = 2000005;

int main(){  
	cin.tie(0);
    ios::sync_with_stdio(false);
	int n,k;
	scanf("%d",&n);
	ll sum=0;
	for(int i=1;i<=n;i++){
		if(i%3!=0&&i%5!=0) sum+=i;
	} 
	printf("%lld",sum);

    return 0;
}




Measured memory_bytes: 3868
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <ctime>
#include <climits>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <cstdlib>

using namespace std;
long int pow107 = (int)pow(10, 9) + 7;
int ilimit = INT_MAX;
long int llimit = LONG_MAX;

bool comp(pair<int, string> a, pair<int, string> b){
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

long int jou(long int x, long int y){
    long int f = 1;
    for(int i = 0; i < y; ++i){
        f = f * x % pow107;
    }
    return f;
}

bool pn(long int x){
    if(x != 2 && x % 2 == 0)
        return false;
    for(int i = 3; i < x; ++i){
        if(x != i && x % i == 0)
            return false;
    }
    return true;
}

long int factorial(long int n){
    long int f = 1;
    for(long int i = 1; i <= n; ++i){
        f = f * i % pow107;
    }
    return f;
}

//最大limit
//10^9+7    pow107
//素数pn
//n乗jou
//コンビネーションfactorial
//

int main(){
    int r;
    int t = 0;
    for(int i = 0; i < 3; ++i){
        cin >> r;
        t += r * (int)pow(10,2-i);
    }
    if(t % 4 == 0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}

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

using namespace std;

int main() {
  int n, k, q;
  vector<int> v;
  
  cin >> n >> k >> q;
  
  if (k > q) {
    for(int i = 0; i < n; i++) {
    	cout << "Yes" << endl;
  	}
    return 0;
  }
  
  for(int i = 0; i < n; i++) {
  	v.push_back(0);
  }
  
  int tmp;
  for(int i = 0; i < q; i++) {
    cin >> tmp;
    v[tmp - 1]++;
  }
  
  int border = q - k;
  for(int i = 0; i < n; i++) {
  	if(v[i] > border) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1016
def custom_print(building):
    for i in range(3):
        print(' ' + ' '.join([str(o) for o in building[i]]))


SEPARATOR = "####################"

if __name__ == '__main__':

    n = int(input())

    building_1 = [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ]
    building_2 = [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ]
    building_3 = [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ]
    building_4 = [
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
        [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
    ]

    for i in range(n):
        input_line = input().split()
        b = int(input_line[0])
        f = int(input_line[1])
        r = int(input_line[2])
        v = int(input_line[3])

        if b == 1:
            building_1[f - 1][r - 1] += v
        elif b == 2:
            building_2[f - 1][r - 1] += v
        elif b == 3:
            building_3[f - 1][r - 1] += v
        else:
            building_4[f - 1][r - 1] += v

    custom_print(building_1)
    print(SEPARATOR)
    custom_print(building_2)
    print(SEPARATOR)
    custom_print(building_3)
    print(SEPARATOR)
    custom_print(building_4)



Measured memory_bytes: 5632
c=[list(map(int,input().split())) for _ in range(3)]
s=0
for i in range(3):
    for j in range(3):
        s+=c[i][j]
if 3*(c[0][0]+c[1][1]+c[2][2])==s:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  s=list(S())

  l=[['d', 'r', 'e', 'a', 'm'],
  ['d', 'r', 'e', 'a', 'm', 'e', 'r'],
  ['e', 'r', 'a', 's', 'e'],
  ['e', 'r', 'a', 's', 'e', 'r']]

  while True:
    if len(s)<=4:
      break
    else:
      if l[0]==s[-5:]:
        [s.pop() for _ in ' '*5]
      elif l[1]==s[-7:]:
        [s.pop() for _ in ' '*7]
      elif l[2]==s[-5:]:
        [s.pop() for _ in ' '*5]
      elif l[3]==s[-6:]:
        [s.pop() for _ in ' '*6]
      else:
        return 'NO'

  if len(s)==0:
    return 'YES'
  return 'NO'

print(main())


Measured memory_bytes: 6360
s = input()
def isPalindrome(l, r):
    i = l
    j = r
    while i <= j:
        if s[i] != s[j]:
            return False
        i += 1
        j -= 1
    return True
n = len(s)
if isPalindrome(0, (n - 3) // 2) and isPalindrome(0, n - 1):
    print("Yes\n")
else:
    print("No\n")

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> s[i] >> a[i];
  vector<int> ord(n);
  iota(ord.begin(), ord.end(), 0);
  sort(ord.begin(), ord.end(), [&](int x, int y) {
    if(s[x]==s[y]) return a[x] > a[y];
    return s[x] < s[y];
  } );
  for (auto e : ord) cout << e + 1 << endl;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f t s = isInfixOf t $ s ++ s

main = do
    t <- getLine
    n <- getInt
    replicateM n getLine >>= print . length . filter (f t)

Measured memory_bytes: 3868
#include<cstdio>
#include<set>

using namespace std;

int a;
int other;
set<int> colors;

void get(int i) {
	if (i >= 1 && i < 400)
		colors.insert(0);
	else if (i >= 400 && i < 800)
		colors.insert(1);
	else if (i >= 800 && i < 1200)
		colors.insert(7);
	else if (i >= 1200 && i < 1600)
		colors.insert(2);
	else if (i >= 1600 && i < 2000)
		colors.insert(3);
	else if (i >= 2000 && i < 2400)
		colors.insert(4);
	else if (i >= 2400 && i < 2800)
		colors.insert(5);
	else if (i >= 2800 && i < 3200)
		colors.insert(6);
	else
		++other;
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		get(a);
	}

	int min = colors.size();
	int max = colors.size() + other;

	if (min == 0 && other > 0)
		min = 1;

	printf("%d %d\n", min, max);
}

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

int main(){
	string a,t;
	cin>>a>>t;
	int f=t.length();
	for(int i=0;i<(a.length()-t.length())+1;i++){
		int k=t.length();
		for(int j=0;j<t.length();j++){
			a[j+i]==t[j]?k--:i=i;
		}
		f=min(f,k);
	}
	cout<<f<<endl;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> from1;
  vector<int> toN;
  
  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;

    if (x == 1) from1.push_back(y);
    if (y == N) toN.push_back(x);
    
  }
  
  sort(from1.begin(), from1.end());
  sort(toN.begin(), toN.end());
  

  vector<int> v;
  set_intersection(from1.begin(), from1.end(), toN.begin(), toN.end(), back_inserter(v));
  
  if (v.size()) {
    cout << "POSSIBLE" << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 4256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
   	cin>>s;
    {
        int ans=0;
        int cc=0;
        for(int i=0;i<s.size();i++)
            s[i]=s[i]-'0';
        for(int i=s.size()-1;i>=0;i--)//989
        {
            
            int tmp=s[i]+cc;
            if(tmp<5)
            {
                ans+=tmp;
                cc=0;
            }    
            else if(tmp>5) 
            {
                ans+=10-tmp;
                cc = 1;
            }
            else 
            {
                ans+=5;
                if(s[i-1]>=5&&i>0)
                    cc=1;
                else
                    cc=0;
            }   
        }
        cout<<ans+cc<<endl;
    }
  	return 0;
}


Measured memory_bytes: 1412
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define ii pair<ll,ll>
#define vii vector<ii>
#define F first
#define S second
#define INF -1000000000
using namespace std;


int score(char a,char b){
	if(a == b){
		return 1;
	}
	if(a != b && (b == '_' || a == '_')) return 0;
	return INF;
}

int main(){
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n,m;
	string temp = "_",s,t;
	cin >> s >> t;
	
	n = s.size()+1;
	m = t.size()+1;
	temp += s;
	s = temp;
	temp = "_";
	temp += t;
	t = temp;

	ll V[n+5][m+5];
	V[0][0] = 0;
	
	for (int i = 1; i < n; ++i){
		V[i][0] = i*score(s[i],'_'); 
	}
	for (int i = 1; i < m; ++i){
		V[0][i] = i*score('_',t[i]);
	}
	for (int i = 1; i < n; ++i){
		for (int j = 1; j < m; ++j){
			V[i][j] = max(V[i-1][j-1]+score(s[i],t[j]),max(V[i-1][j]+score(s[i],'_'),V[i][j-1]+score('_',t[j])));
		}
	}

	stack<char> p;
	int i = n-1,j = m-1;
	temp = "";
	while(i && j){
		if(V[i][j] == V[i-1][j-1]+score(s[i],t[j])){
			p.push(s[i]);
			i--;
			j--;
		}else if(V[i][j] == V[i-1][j]+score(s[i],'_')){
			i--;
		}else if(V[i][j] == V[i][j-1]+score('_',t[j])){
			j--;
		}else{
			i--;j--;
		}
	}
	while(!p.empty()){
		temp += p.top();p.pop();
	}
	cout << temp << '\n';
	return 0;
}

Measured memory_bytes: 70784
#include <stdio.h>

int main(void)
{
	int n[100];
	
	int i;
	int num;
	
	scanf("%d",&num);
	
	for(i=0;i<num;i++)
	{
		scanf("%d",&n[i]);
	}
	
	for(i=num-1;i>=0;i--)
	{
		printf("%d",n[i]);
		if(i!=0)
		{
			printf(" ");
		}
	}
	
	printf("\n");
	
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;
const ll INF = 1LL<<60;
//int INF = numeric_limits<int>::max();

int main(int, char**) {
	map<string, ll> M;
	int n; cin >> n;
	for (int i=0; i<n; i++) {
		string s; cin >> s;
		sort(s.begin(), s.end());
		M[s]++;
	}
	ll ret = 0;
	for (auto p : M) {
		ret += p.second * (p.second - 1) / 2;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 11364
# coding: utf-8
# NとSの入力
N = int(input())
S = list(input())
#解答の初期化
ans = 0
#Nが小さいので愚直に求めてもTLEにならないと判断
for i in range(N):
  #Sをi番目までとその後で分割しXとYに
  #文字種の重複がないsetを使用する
  X = list(set(S[0 : i + 1]))
  Y = list(set(S[i + 1 : N]))
  #i番目で分けた場合の値の初期化
  temp = 0
  #1文字ずつ見ていく
  for x in X:
    for y in Y:
      if x == y:
        temp += 1
        break
  #tempが今までの値よりも大きい場合上書き
  if temp > ans:
    ans = temp
#解答の出力
print(ans)

Measured memory_bytes: 3060
#[allow(unused_imports)]
use proconio::{
    fastout, input,
    marker::{Bytes, Chars, Isize1, Usize1},
};

fn pow(mut s: usize, mut n: usize, m: usize) -> usize {
    if m == 0 {
        return 1;
    }
    let mut temp = s;
    s = 1;
    while n > 0 {
        if n & 1 != 0 {
            s *= temp;
            s %= m;
        }
        n >>= 1;
        temp *= temp;
        temp %= m;
    }
    s
}

fn func(n: usize) -> usize {
    if n == 0 {
        return 0;
    }
    1 + func(n % n.count_ones() as usize)
}

#[fastout]
fn main() {
    input! {
        n:usize,
        x:Chars
    }
    let one_count = x.iter().filter(|&&z| z == '1').count();

    if one_count == 0 {
        for _ in 0..n {
            println!("{}", 1);
        }
        return;
    }

    //let mut table = vec![0_usize; n + 1];
    let mut tablep1 = vec![0_usize; n + 1];
    let mut tablem1 = vec![0_usize; n + 1];
    for i in 0..n {
        if x[i] == '1' {
            //table[i + 1] = pow(2, n - i - 1, one_count);
            tablep1[i + 1] = pow(2, n - i - 1, one_count + 1);
            tablem1[i + 1] = pow(2, n - i - 1, one_count - 1);
        }
    }

    for i in 1..=n {
        //table[i] = (table[i - 1] + table[i]) % one_count;
        tablep1[i] = (tablep1[i - 1] + tablep1[i]) % (one_count + 1);
        tablem1[i] = if one_count == 1 {
            0
        } else {
            (tablem1[i - 1] + tablem1[i]) % (one_count - 1)
        };
    }

    for i in 0..n {
        if x[i] == '1' {
            if one_count == 1 {
                println!("{}", 0);
            } else {
                let buf =
                    (tablem1[i] + tablem1[n] + (one_count - 1) - tablem1[i + 1]) % (one_count - 1);
                println!("{}", 1 + func(buf));
            }
        } else {
            let buf = (tablep1[i] + tablep1[n] + (one_count + 1) - tablep1[i + 1]
                + pow(2, n - i - 1, one_count + 1))
                % (one_count + 1);
            println!("{}", 1 + func(buf));
        }
    }
}


Measured memory_bytes: 6224
#include <iostream>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;

int main() {
	int n;
	cin >> n;
	int c['{'][52]={};
	string temp;
	char t;
	string ans="";
	for (int i=0;i<n;i++){
		cin >> temp;
		for (int j=0;j<temp.length();j++){
			c[temp[j]][i]++;
		}
	}
	int a,b;
	for (char j='a';j<='z';j++){
		b=2147483647;
		for (int i=0;i<n;i++){
			a=c[j][i];
			if (a<b){
				b=a;
			}
		}
		if (b!=0){
			for (int o=1;o<=b;o++){
				ans=ans+j;	
			}
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> L(m);
    vector<int> R(m);
    rep(i,m){
        cin >> L[i] >> R[i];
        L[i]--;
        R[i]--;
    } 

    // rep(i,m){
    //     cout << L[i] << " " << R[i] << endl;
    // } 

    vector<int> V(n+1,0);
    rep(i,m){
        V[L[i]]+=1;
        V[R[i]+1]-=1;
        // rep(i,n+1){
        // cout << V[i]  << " ";
        // }
        // cout << endl;
    }

    // rep(i,n+1){
    //     cout << V[i]  << " ";
    // }
    // cout << endl;


    rep(i,n){
        V[i+1]+=V[i];
    }

    // rep(i,n){
    //     cout << V[i]  << " ";
    // } 
    // cout << endl;

    int cnt=0;
    rep(i,n){
        if(V[i]==m) cnt++;
    }


    cout << cnt << endl;
    return 0;

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
const std::string ans[2] = { "No\n", "Yes\n" };
int main() {
    using namespace std;
    int a[3][3];
    for(int i=0; i<3; i++)
        for(int j=0; j<3; j++)
            cin >> a[i][j];

    int n,b;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> b;
        for(int i=0; i<3; i++)
            for(int j=0; j<3; j++)
                if(a[i][j]==b)a[i][j]=-1;
    }

    bool isBingo=false;
    // tate
    for(int i=0; i<3; i++)
        if(a[i][0]==-1 && a[i][1]==-1 && a[i][2]==-1)isBingo = true;
    // yoko
    for(int i=0; i<3; i++)
        if(a[0][i]==-1 && a[1][i]==-1 && a[2][i]==-1)isBingo = true;
    // naname
    if(a[0][0]==-1 && a[1][1]==-1 && a[2][2]==-1)isBingo=true;
    if(a[0][2]==-1 && a[1][1]==-1 && a[2][0]==-1)isBingo=true;

    cout << ans[isBingo] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
#define SORTD(s) sort((s).rbegin(),(s).rend())

int gcd(int a, int b) {
    if (!b) return a;
    return gcd(b, a % b);
}

int main() {
	ll a,b,c,d,sum;
  
  	cin>>a>>b>>c>>d;
  
  	sum +=b/c-(a-1)/c;
  	sum +=b/d-(a-1)/d;
  	int e=gcd(c,d);
  	sum-=b/(c*d/e)-(a-1)/(c*d/e);
  	cout<<b-a+1-sum<<endl;
  

}

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

using namespace std;

int main() {
  string S;
  cin >> S;
  
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
n, m, l = list(map(int, input().split()))
a = [list(map(int, input().split())) for _ in range(n)]
b = [list(map(int, input().split())) for _ in range(m)]

c = [[0] * l for i in range(n)]
# print(c)
for i in range(n):
    for j in range(l):
        for k in range(m):
            c[i][j] += a[i][k] * b[k][j]
# print(c)
for i in range(n):
    print(c[i][0], end="")
    for j in range(1, l):
        print("", c[i][j], end="")
    print()



Measured memory_bytes: 7148
import java.util.Scanner;
import java.util.Set;

public class Main{

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		int n        = Integer.parseInt(scanner.nextLine());
		String[] tmp = scanner.nextLine().split(" ");
		int ans      = 0;

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

			if((i + 1) % 2 == 1) {
				if(Integer.parseInt(tmp[i]) % 2 == 1) {
					ans++;
				}
			}
		}

		System.out.println(ans);
	}
}


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

int main() {
	string text;
	cin >> text;
	if (text == "Sunny") {
		cout << "Cloudy" << endl;
	}
	if (text == "Cloudy") {
		cout << "Rainy" << endl;
	}
	if (text == "Rainy") {
		cout << "Sunny" << endl;
	}
}


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

int main()
{
    long long n,k;
    cin >> n;
    while(n>0)
    {
        k=n%10;
        n=n/10;
        if(k==9)
        {
            ans=true;
            break;
        }
    }
    if(ans==true)
        cout << "Yes";
    else 
        cout << "No";
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int Q = sc.nextInt();

        long[] s = new long[A + 2];
        s[0] = (long) - 1e12;
        s[A + 1] = (long) 1e12;
        for (int a = 0; a < A; a += 1) {
            s[a + 1] = Long.parseLong(sc.next());
        }
        long[] t = new long[B + 2];
        t[0] = (long) - 1e12;
        t[B + 1] = (long) 1e12;
        for (int b = 0; b < B; b += 1) {
            t[b + 1] = Long.parseLong(sc.next());
        }

        for (int q = 0; q < Q; q += 1) {
            long xq = Long.parseLong(sc.next());
            long eastS = east(s, xq);
            long westS = west(s, xq);
            long eastT = east(t, xq);
            long westT = west(t, xq);
            search(xq, eastS, westS, eastT, westT);
        }
    }


    private static void search(long x, long eastS, long westS, long eastT, long westT) {
        long sFirst;
        long sFirstE = search(x, eastS, eastT, westT);
        long sFirstW = search(x, westS, eastT, westT);
        if (sFirstE < sFirstW) {
            sFirst = sFirstE;
        } else {
            sFirst = sFirstW;
        }

        long tFirst;
        long tFirstE = search(x, eastT, eastS, westS);
        long tFirstW = search(x, westT, eastS, westS);
        if (tFirstE < tFirstW) {
            tFirst = tFirstE;
        } else {
            tFirst = tFirstW;
        }

        if (sFirst < tFirst) {
            System.out.println(sFirst);
        } else {
            System.out.println(tFirst);
        }
    }

    private static long search(long x, long first, long toE, long toW) {
        long dist = Math.abs(first - x);
        long toEast = Math.abs(toE - first);
        long toWest = Math.abs(toW - first);
        if (toEast < toWest) {
            return dist + toEast;
        } else {
            return dist + toWest;
        }
    }


    private static long east(long[] st, long x) {
        int index = Arrays.binarySearch(st, x);
        if (index < 0) {
            index = -(index + 1);
        }

        if (st[index] - x > 0) {
            return st[index - 1];
        } else {
            return st[index];
        }
    }

    private static long west(long[] st, long x) {
        int index = Arrays.binarySearch(st, x);
        if (index < 0) {
            index = -(index + 1);
        }

        if (st[index] - x < 0) {
            return st[index + 1];
        } else {
            return st[index];
        }
    }

}


Measured memory_bytes: 96432
// Created by new_sm
//
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define vi vector<int>
#define si set<int> 
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define chotu 1000000007
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) s.size()
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
void solve()
{
fastio
map<string,int>mp;
int n;
cin>>n;while(n--)
{
	string s;
	cin>>s;
	mp[s]++;
}
int mx=-1;
for(auto x:mp)
{
	mx=max(mx,x.second);
}
for(auto x:mp)
{
	if(x.second==mx)
		cout<<x.first<<endl;
}
}

int main()
{
//code

fastio	
int t;
t=1;
while(t--)
{
	solve();
	cout<<endl;
}
}


Measured memory_bytes: 19196
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun _ -> Scanf.scanf " %d" pred
let c = ref 0
let _ = for i = 0 to n - 1 do if a_s.(a_s.(i)) = i then incr c done; Printf.printf "%d\n" @@ !c / 2

Measured memory_bytes: 5248
import sys

a, b, c, d = map(int, sys.stdin.readline().split())

def main(a, b, c, d):
    while True:
        c -= b
        if c <= 0:
            print('Yes')
            return 
        a -= d
        if a <= 0:
            print('No')
            return
    


if __name__ == '__main__':
    main(a, b, c, d)

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

lint count_multiple(lint l, lint r, lint x)
{
    //l以上r以下の整数に含まれるxの倍数の数を返す
    lint ans;
    ans = r / x - (l - 1) / x;
    //cout << ans << "\n";
    return ans;
}

lint count_multiple2(lint l, lint r, lint x)
{
    //l以上r以下の整数に含まれるxの倍数の数を返す
    lint n, ans;
    n = r - l + 1;
    ans = n / x;
    if (n % x + l % x >= x)
    {
        ans += 1;
    }
    //cout << ans << "\n";
    return ans;
}

lint gcd(lint m, lint n)
{
    // 引数に０がある場合は０を返す
    if ((0 == m) || (0 == n))
        return 0;

    // ユークリッドの方法
    while (m != n)
    {
        if (m > n)
            m = m - n;
        else
            n = n - m;
    }
    return m;
} //gcd

lint lcm(lint m, lint n)
{
    // 引数に０がある場合は０を返す
    if ((0 == m) || (0 == n))
        return 0;

    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
} //lcm

int main()
{

    lint a, b, c, d;
    cin >> a >> b >> c >> d;
    lint n, ans;
    n = b - a + 1;
    lint cd;
    cd = lcm(c, d);
    lint tmp = count_multiple(a, b, c) + count_multiple(a, b, d) - count_multiple(a, b, cd);
    ans = n - tmp;
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

N = inp()


def kiku(a):
    print("?",' '.join(map(str,list(range(a,a+N)))))


kiku(1)

T = input()
if T == '-1':
    sys.exit(-1)

baseT = T

setL = {1}
setR = {N+1}
bmid = INF
bbmid = INF
while True:
    L = max(setL)
    R = min(setR)

    if abs(R-L) == 1:
        break

    mid = (L + R)//2
    kiku(mid)
    T = input()
    if T == baseT:
        setL.add(mid)
    else:
        setR.add(mid)

X = R

def kikuX(i,X):
    print("?",' '.join(map(str,list(range(X,X+N-1)))),str(i))

ans = [0]*(2*N)

Reds = []
Blues = []

for i in range(1,X):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T

for i in range(X+N-1,N*2+1):
    kikuX(i,X)
    T = input()[0]
    if T == "R":
        Reds.append(i)
    else:
        Blues.append(i)
    ans[i-1] = T




for i in range(X,X+N-1):
    k = Reds[:N//2] + Blues[:N//2] + [i]
    print("?", ' '.join(map(str,k)))
    ans[i-1] = input()[0]

print('!', ''.join(map(str,ans)))


Measured memory_bytes: 4564
#include<stdio.h>
int main(void)
{
	int i,a,b,cnt;
	char s[1000];
	scanf("%d%d%s",&a,&b,s);
	cnt=0;
	for(i=0;i<a+b+1;i++){
		if(s[i]!='-') cnt++;
	}
	if(s[a]=='-'&&a+b==cnt) printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(NULL);
  ios::sync_with_stdio(false);
  int a,b,c,sum=0;
  string s;
  cin>>s;
  for(int i=0;i<4;i++){
    if(s[i]=='+') sum++;
    else sum--;
  }
  cout<<sum<<'\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include<math.h>
#include <typeinfo>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double    ld;
typedef pair <ll,ll>  pll;
typedef pair <int,int> pii;
#define rep(h)    for (long long int e=0; e<h; e++)
#define srep(a,b) for (int e=a; e<b; e++)
#define rrep(a,b) for (int e=a; e>b; e--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

// int binsearch(int l,int r, int arr,int x)
// {  int m= (l+r)/2;
//  while (l<r)
//  {
//        if(x==arr[m]) return x;
//        else if (x<arr[m]) binsearch(l,m,arr,x);
//        else binsearch(m+1,r,arr,x);

//  }
// ll mod (string str, int k)
// { ll rem;
  




// 	return rem;
// }
// ll mod(string num, ll m) 
// { 
//     // Store the modulus of big number 
//     vector<int> vec; 
//     ll moda = 0; 
  
//     // Do step by step division 
//     for (int i = 0; i < num.size(); i++) { 
           
//         int digit = num[i] - '0'; 
  
//         // Update modulo by concatenating 
//         // current digit. 
//         moda = moda * 10 + digit; 
  
//         // Update quotient  
//         int quo = moda / m; 
//         vec.push_back(quo); 
  
//         // Update mod for next iteration. 
//         moda = moda % m;         
//     } 
//       return moda; 
// } 
//  while(t--)
//  {  cin >> n >> k;
//       vector <ll> val(n);
//       rep (n) cin >> val[e];
//       rep (n)
//       { 
//       	if (fl>0) {cout <<  "NO"; return 0;}
//         string str =to_string( val[e]);
// //        int l = str.size();

//          while (mod (str,k)!=0)
//          {      cout<<"F";
// //            //  if (mod (str,k)==1) 
// //             //  continue;      
//                   if (mod (str,k)<k) break;
//                     str = to_string(mod (str,k));
//          cout << mod(str,k)<<"  ";
//          }
//         if ( mod (str,k) >1) {cout <<  "NO"; return 0;} 
//             val[e]= mod (str,k);
//       }
//  //cout<<"DF";
//  rep (n) {if (val[e]<=1)  cout << val[e]<<")";}
//  cout<<endl;
 // }     
   bool check(string s)
{  int l = ceil((float)(s.length()-1)/2);
	//cout << s.length();
    if ( s.length()==2) {if(s[0]==s[1]) return true; else return false;} 
  
    int i=0,j=s.length()-1;// cout << l<<j<<s<<" ";
  while (i<=l-1 and j>=l and i<j)
  {  // cout <<s[i]<<s[j]<<j<<i;
      if ( s[i] == s[j] ) { i++; j--; continue;}
      else return false;
  }
 	return true;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 //int n,m;
  string s;
  cin >>s; //cout <<s.length();
 int l = ceil((float)(s.length()-1)/2); 
 //cout << s.length();
if (!check(s) ) {cout <<"No"; return 0;}
else {
 if ( check(s.substr(0,l)) and check(s.substr(s.length()-l,s.length()-1)) ) cout << "Yes";
 else cout << "No";
}



    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n;
  cin>>n;
  int x[n], y[n];
  REP(i, n) cin>>x[i]>>y[i];
  
  typedef pair<int, int> P;
  typedef pair<P, int> Pi;
  vector<Pi> vec;
  vector<int> ans(n, -1);
  REP(i, n) vec.push_back(Pi(P(x[i], y[i]), i));
  sort(ALL(vec));
  int min_v = 1'000'000'000;
  int cnt = 0;
  queue<int> q;
  REP(i, n){
    int ny = vec[i].first.second;
    int idx = vec[i].second;
    min_v = min(min_v, ny);
    cnt++;
    q.push(idx);
    if(min_v == n - i){
      while(!q.empty()){
        int id = q.front();
        q.pop();
        ans[id] = cnt;
      }
      cnt = 0;
    }
  }
  while(!q.empty()){
    int id = q.front();
    q.pop();
    ans[id] = cnt;
  }
  
  REP(i, n) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 8832
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=1e5+5;

int n,m;
int dp[maxn],f[maxn],ans[maxn];
vector<int> g[maxn];

inline int add(int a,int b){return (a+b)-((a+b>=m)?(m):(0));}
inline int mul(int a,int b){return 1ll*a*b%m;}
inline void uadd(int &a,int b){a=(a+b)-((a+b>=m)?(m):(0));return;}
inline void umul(int &a,int b){a=1ll*a*b%m;}

inline void dfs(int u,int p){
	dp[u]=1;
	FOR(i,0,g[u].size()){
		int v=g[u][i];
		if(v==p) continue;
		dfs(v,u);
		umul(dp[u],add(dp[v],1));
	}
	return;
}

inline void dfs2(int u,int p){
	if(~p) ans[u]=mul(dp[u],f[u]);
	else f[u]=1,ans[u]=dp[u];
	vector<int> pre(g[u].size(),0),suf(g[u].size(),0);
	FOR(i,0,g[u].size()){
		int v=g[u][i];
		if(!i){
			if(v==p) pre[i]=1;
			else pre[i]=add(dp[v],1);
		}else{
			if(v==p) pre[i]=pre[i-1];
			else pre[i]=mul(pre[i-1],add(dp[v],1));
		}
	}
	for(int i=g[u].size()-1;i>=0;--i){
		int v=g[u][i];
		if(i==g[u].size()-1){
			if(v==p) suf[i]=1;
			else suf[i]=add(dp[v],1);
		}else{
			if(v==p) suf[i]=suf[i+1];
			else suf[i]=mul(suf[i+1],add(dp[v],1));
		}
	}
/*	printf("u=%d\n",u);
	FOR(i,0,g[u].size()) printf("%d ",pre[i]);
	puts("");
	FOR(i,0,g[u].size()) printf("%d ",suf[i]);
	puts("");
*/	FOR(i,0,g[u].size()){
		int v=g[u][i];
		if(v==p) continue;
		int &res=f[v];
		res=f[u];
		if(i) umul(res,pre[i-1]);
		if(i!=g[u].size()-1) umul(res,suf[i+1]);
		uadd(res,1);
//		printf("v=%d res=%d %d %d %d\n",v,res,f[u],(i)?(pre[i-1]):(1),(i!=g[u].size()-1)?(suf[i+1]):(1));
		dfs2(v,u);
	}
	return;
}

int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,n){
		int u,v;
		scanf("%d%d",&u,&v);
		--u;--v;
		g[u].PB(v);
		g[v].PB(u);
	}
	dfs(0,-1);
	dfs2(0,-1);
/*	FOR(i,0,n) printf("%d ",dp[i]);
	puts("");
	FOR(i,0,n) printf("%d ",f[i]);
	puts("");
*/	FOR(i,0,n) printf("%d\n",ans[i]);
	return 0;
}


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

#define REP(i,num) for(int i=0;i<(num);++i)

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}

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

  array<int,5> a;
  for(auto& x:a) x=in();
  
  int mind = 10,index=-1;
  for(int i=0;i<5;i++){
    int d = a[i]%10;
    if(d && d<mind){
      mind = d;
      index = i;
    }
  }
  int sum=0;
  for(int i=0;i<5;i++){
    if(i==index) sum += a[i];
    else{
      int d = a[i]%10;
      if(d) sum += (a[i]/10)*10+10;
      else sum += a[i];
    }
  }
  
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,ans;
int main(){
	n=read();m=read();
	if(m>=n)puts("unsafe");
	else puts("safe");
}


Measured memory_bytes: 3620
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> q(n);
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> q[i];
        sum += q[i];
    }
    int a;
    cin >> a;

    for (int i = 0; i < a; i++)
    {
        int aaa;
        cin >> aaa;
        bool k = false;
        if(sum < aaa)
        {
            cout << "no" << "\n";
            continue;
        }
        for (int bit = 0; bit < (1 << n); bit++)
        {
            int sum = 0;
            for (int j = 0; j < n; j++)
            {
                if (bit & (1 << j))
                    sum += q[j];
            }
            if (sum == aaa)
                k = true;
        }
        cout << (k ? "yes" : "no") << "\n";
    }
}


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

int main(){
    int N, W;  cin >> N >> W;
    map<ll, vector<ll>> cnt;
    for(int i=0; i<N; i++){
        ll w, v;  cin >> w >> v;
        cnt[w].push_back(v);
    }

    vector<pair<ll, vector<ll>>> P;
    for(auto p : cnt){
        vector<ll> c = p.second;
        sort(c.begin(), c.end(), greater<ll>());
        c.insert(c.begin(), 0);
        for(int i=1; i<c.size(); i++){
            c[i] += c[i-1];
        }
        P.push_back({p.first, c});
    }
    while(P.size() < 4){
        P.push_back({P.back().first + 1, vector<ll>(1, 0)});
    }
    // cout << "---------" << endl;
    // for(auto p : P){
    //     cout << p.first << " : ";
    //     for(auto v : p.second){
    //         cout << v << " ";
    //     }cout << endl;
    // }

    ll ans = 0;
    for(int i=0; i<=N; i++) for(int j=0; j<=N; j++) for(int k=0; k<=N; k++){
        int maxL = N - (i+j+k);
        if(maxL < 0) continue;
        if(P[0].second.size() - 1 < i) continue;
        if(P[1].second.size() - 1 < j) continue;
        if(P[2].second.size() - 1 < k) continue;
        ll sumW = P[0].first*i + P[1].first*j + P[2].first*k;
        if(sumW > W) continue;
        int l = min((W - sumW)/P[3].first, (ll)P[3].second.size() - 1);
        
        ll sumV = 0;
        sumV += P[0].second[i] + P[1].second[j] + P[2].second[k] + P[3].second[l];
        // cout << i << " " << j << " " << k << " " << l << " " << sumV << endl;
        ans = max(ans, sumV);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <set>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;

class UnionFind{
private:
  vector<int> id;

  int getId(int i){
    if(i == id[i]) return i;
    return id[i] = getId(id[i]);
  }
public:
  UnionFind(int size = 0){ init(size); }
  ~UnionFind(){}
  void init(int size){
    id = vector<int>(size);
    for(int i = 0; i < size; i++)
      id[i] = i;
  }
  void unite(int i, int j){
    int next = min( getId(i), getId(j) );
    id[getId(i)] = id[getId(j)] = next;
  }
  int operator [](int i){ return getId(i); }
  int count(){
    set<int> s;
    for(int i = 0; i < (int)id.size(); i++)
      s.insert(getId(i));
    return s.size();
  }
};

int main(){
  for(int cc = 1; ; ++cc){
    int n = getInt();
    int t = getInt();
    int k = getInt();

    if(n + t + k == 0) break;

    vector<vector<pair<int, int> > > g(n);
    vector<int> base(n);
    UnionFind uf(n);
    vector<int> a(n - 1);
    vector<int> b(n - 1);
    vector<int> c(n - 1);

    REP(i,n - 1){
      a[i] = getInt() - 1;
      b[i] = getInt() - 1;
      c[i] = getInt();
    }

    vector<pair<int, int> > s(n);
    REP(i,n) s[i] = make_pair(1, i);

    REP(i,t) s[getInt() - 1].first = 0;
    sort(s.begin(), s.end());
    vector<int> m(n);
    REP(i,n) m[s[i].second] = i;

    priority_queue<pair<int, pair<int, int> > > pq;
    REP(i,n - 1){
      a[i] = m[a[i]];
      b[i] = m[b[i]];

      pq.push(make_pair(c[i], make_pair(a[i], b[i])));
    }

    vector<int> candidate;
    while(pq.size()){
      int cost = pq.top().first;
      int aa   = pq.top().second.first;
      int bb   = pq.top().second.second;
      pq.pop();

      if(uf[aa] < t && uf[bb] < t){
	candidate.push_back(cost);
      }

      uf.unite(aa, bb);
    }

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

    int ans = 0;
    REP(i,k) ans += candidate[i];

    printf("Case %d: %d\n", cc, ans);
  }
  return 0;
}

Measured memory_bytes: 1668
#include<stdio.h>

int main(){
  int month,day;
  int i;
  int sum;
  while(1){
    sum=0;
    scanf("%d %d",&month,&day);
    if(month==0)
      break;
    for(i=1; i<=month; i++){

      if(i==month){
	sum+=day;
	continue;
      }
      
      if(i==2)
	sum+=29;
      else if(i==4 || i==6 || i==9 || i==11)
	sum+=30;
      else
	sum+=31;

    }
    switch(sum%7){
    case 0: printf("Wednesday\n"); break;
    case 1: printf("Thursday\n"); break;
    case 2: printf("Friday\n"); break;
    case 3: printf("Saturday\n"); break;
    case 4: printf("Sunday\n"); break;
    case 5: printf("Monday\n"); break;
    case 6: printf("Tuesday\n"); break;
    }
  }
  return 0;
}



Measured memory_bytes: 2048
#include <iostream>
#include <utility>

using namespace std;

int square(int x) {return x*x;}

bool comp(pair<int, int> p, pair<int, int> q) {
    int hai = square(p.first)+square(p.second);
    int iie = square(q.first)+square(q.second);
    if (hai < iie) return true;
    if (hai > iie) return false;
    if (p.first < q.first) return true;
    return false;
}

void solve(int h, int w) {
    pair<int, int> target;
    target.first = h; target.second = w;
    pair<int, int> ans;
    ans.first = 201, ans.second = 201;
    for (int i = 1; i <= 200; i++) for (int j = i+1; j <= 200; j++) {
        pair<int, int> tmp;
        tmp.first = i; tmp.second = j;
        if (comp(target, tmp)) {
            if (comp(tmp, ans)) ans = tmp;
        }
    }
    cout << ans.first << " " << ans.second << endl;
}

int main() {
    int h, w;
    while (cin >> h >> w) {
        if (h == 0 && w == 0) break;
        solve(h, w);
    }
    return 0;
}

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

int main(void) {
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    a *= 100;
    b *= 100;

    vector<int> water;
    for (int i = 0; a*i <= f; i++) {
        for (int j = 0; b*j <= f; j++) {
            water.push_back(a*i + b*j);
        }
    }
    vector<int> sugar;
    for (int i = 0; c*i <= f; i++) {
        for (int j = 0; d*j <= f; j++) {
            sugar.push_back(c*i + d*j);
        }
    }
    double conc = 0, ans = 0;
    int water_max = 0, sugar_max = 0;
    for (int i = 0; i < water.size(); i++) {
        water_max = max (water_max, water.at(i));
    }
    for (int i = 0; i < water.size(); i++) {
        for (int j = 0; j < sugar.size(); j++) {
            if (water.at(i) + sugar.at(j) == 0) {
                continue;
            }
            conc = (double)(100 * sugar.at(j)) / (double)(water.at(i) + sugar.at(j));
            if (ans < conc) {
                if (f < water.at(i) + sugar.at(j)) {
                    continue;
                }
                if (e * water.at(i) / 100 < sugar.at(j)) {
                    continue;
                }
                ans = conc;
                water_max = water.at(i);
                sugar_max = sugar.at(j);
            }
        }
    }
    cout << water_max + sugar_max << " " << sugar_max << endl;
}

Measured memory_bytes: 2420