akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string S;
    cin >> S;
    ll N = S.length();
    if(S[0] == '0'){
        printf("-1\n");
        return 0;
    }
    if(S[N-1] == '1'){
        printf("-1\n");
        return 0;
    }
    for (int i = 0; i < N-1; i++) {
        if(S[i] != S[N-2-i]){
            printf("-1\n");
            return 0;
        }
    }

    ll t = 0;
    ll u;
    for (int i = 0; i < (N+1)/2; i++) {
        if(S[i] == '1'){
            t = i;
        }
    }

    printf("1 2\n");
    u = 2;
    ll tmp = 1;
    t--;
    while(t >= 0){
        if(S[t] == '0'){
            tmp++;
            t--;
        }
        else{
            for (int i = 0; i < tmp; i++) {
                printf("%lld %lld\n", u, u+i+1);
            }
            u = u + tmp;
            tmp = 1;
            t--;
        }
    }
    for (ll i = u+1; i <= N; i++) {
        printf("1 %lld\n", i);
    }





}

Measured memory_bytes: 3812
#include <iostream>
using namespace std;
int main(){
	int sum,sold,num,count;char ch;
	sum=0;count=0;int nsum=0;
	while(cin >> sold >> ch >> num ){
		sum+=sold*num;count++;nsum+=num;
	};
	double ave;int ans;
	ave=(double)nsum/count;
	if((int)(ave*10)%10>=5) ans=(int)ave+1;
	else ans=(int)ave;
	cout << sum << '\n' << ans << '\n' ;
}

Measured memory_bytes: 1160
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf
# @pysnooper.snoop()
#import pysnooper # debug

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect

def solve(x, s):
    d = 0
    while d < 200: #TODO
        v = x - d
        if v not in s:
            return v
        v = x + d
        if v not in s:
            return v
        d += 1
    raise RuntimeError


if __name__ == '__main__':
    x, n = list(map(int, input().split()))
    if n == 0:
        print(x)
    else:
        s = set(map(int, input().split()))
        ans = solve(x, s)
        print(ans)


    #print('\33[32m' + 'end' + '\033[0m') # debug


Measured memory_bytes: 68464
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main()
{
  string s, t;
  cin >> s >> t;
  for (int i = s.size() - t.size(); i >= 0; i--)
  {
    // if (s[i] == t[0])
    // {
      bool ok = true;
      for (int j = 0; j < t.size(); j++)
      {
        if (s[i + j] != t[j] && s[i + j] != '?')
        {
          ok = false;
          break;
        }
      }
      if (ok)
      {
        for (int j = 0; j < t.size(); j++)
        {
          s[i + j] = t[j];
        }
        rep(j, s.size())
        {
          if (s[j] == '?')
          {
            s[j] = 'a';
          }
        }
        cout << s << endl;
        return 0;
      }
    // }
  }
  cout << "UNRESTORABLE" << endl;
  return 0;
}

Measured memory_bytes: 3600
inputs = [int(input()) for i in range(5)]
summ = 0
k = 10
for i in inputs:
    if i % 10 == 0:
        summ = summ + i
    else:
        s, m = divmod(i, 10)
        summ = summ + (s + 1) * 10
        if m < k:
            k = m

summ = summ -((10-k)%10)
print(summ)

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

using namespace std;

int main(void){
	int N;
	cin >> N;
	vector<int> c(25);
	c[0] ++;
	rep(i,N){
		int a;
		cin >> a;
		c[a]++;
	}
	rep(i,13){
		if(c[i] >=3){
			cout << 0 << endl;
			return 0;
		}
	}
	if(c[0] >= 2 || c[12] >=2){
		cout << 0 << endl;
		return 0;
	}
	int ans = 0;
	for(int bit=0;bit< (1<<13);bit++){
		vector<int> t(25);
		for(int i=0;i<13;i++){
			if(c[i]>=2){
				t[i]++;
				t[(24-i)%24]++;
				continue;
			}
			if(bit&(1<<i)){
				if(c[i]){
					t[(24-i)%24]++;
				}
			}else{
				if(c[i])t[i]++;
			}
		}
		int temp = 24;
		rep(i,24)rep(j,24){
			if(i==j)continue;
			if(t[i]==0 || t[j]==0)continue;
			temp = min({temp,abs(i-j),24-i+j,24-j+i});
		}
		ans = max(ans,temp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Apolloliu
 */
 
#include <iostream>
#include <fstream>
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define MEM(a,b)    memset(a, b, sizeof(a))
#define UN(a)       sort(all(a)), a.erase(unique(all(a)), a.end())
#define REV(a)      reverse(all(a))
#define MP(a, b)    make_pair(a, b)
#define PAIR(a, b)  pair<int, int>(a, b)
 
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, int> pii;
 
const int MOD = 1e9 + 7;
const int maxn = 1;
const double EPS = 1e-8;
 
int a[132456];
unordered_map<int,int>mp;
class CGCDOnBlackboard {
public:
    void solve(std::istream& in, std::ostream& out) {
        mp.clear();
        int N;
        in>>N;
        int t = 1;
        for(int i = 0; i < N; ++i){
            in>>a[i];
        }
        int res = 1;
        for(int i = 0; i < 2; ++i){
            int x = a[i];
            for(int j = 1; j * j <= x; ++j){
                if(x % j == 0){
                    t = 0;
                    for(int k = 0; k < N; ++k){
                        if(a[k] % j == 0)t++;
                    }
                    if(t >= N-1)res = max(res, j);
                    if(x/j == j)continue;
                    t = 0;
                    for(int k = 0; k < N; ++k){
                        if(a[k] % (x/j) == 0)t++;
                    }
                    if(t >= N-1)res = max(res, (x/j));
                }

            }
        }
        // int res = 1;
        // for(auto it = mp.begin(); it != mp.end(); ++it){
        //     if(it->second >= min(2, N-1))res = max(res, it->first);
        // }
        out<<res<<endl;
    }
};
 
 
int main() {
    // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    CGCDOnBlackboard solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
int main() {
    int x, y;
    cin >> x >> y;
    if ((y - 2 * x)/2 >= 0 && (4 * x - y ) / 2 >= 0) {
        if ((y - 2 * x) % 2 == 0 && (4 * x - y) % 2 == 0)
        cout << "Yes\n";
        else cout << "No\n";
    }
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 3620
import itertools
n, m, x = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(n)]

mn = 10**18
l = [i for i in range(n)]
for y in range(1, n+1):
    for v in itertools.combinations(l, y):
        tm = [0]*m
        k = 0
        for i in v:
            k += a[i][0]
            for j in range(1, m+1):
                tm[j-1] += a[i][j]
        flag = True
        for i in range(m):
            if tm[i] < x:
                flag = False
                break
        if flag:
            mn = min(k, mn)

if mn == 10**18:
    print(-1)
else:
    print(mn)


Measured memory_bytes: 9228
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  string t;
  cin>>s;
  cin>>t;
  int c=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i]){
    	c++;
    }
  }
  cout<<c<<endl;
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

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

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
vector<pii> X;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
        int x,y; cin >> x >> y;
        x--,y--;
        X.emplace_back(x,y);
    }
    
}

int solve(){
    set<int> p;
    p.insert(0);
    vector<int> cnt(N,1);
    for (int i = 0; i < M; i++)
    {
        cnt[X[i].first]--;
        cnt[X[i].second]++;
        if(p.find(X[i].first)!=p.end()){
            p.insert(X[i].second);
        }
        if(cnt[X[i].first]==0) p.erase(X[i].first);
    }
    cout << p.size() << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 6132
sub f{map{push@$_,$_[--$|]for@_=glob}<>;$Y[$_]=++$d;$Y[$_]//f()for@$_;--$d}@X=@Y,f@Y=0for(glob<>)[1,2];$X[$j++]<$_&&\$@[$_]for@Y;print@@-3

Measured memory_bytes: 163200
s=list(input())
t=list(input())
x=len(s)
y=len(t)
dp=[[0]*(y+1) for i in range(x+1)]

for i in range(x):
    for j in range(y):
        if s[i]==t[j]:
            dp[i+1][j+1]=dp[i][j]+1
        else:
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j])

# 文字列の復元、後ろから見て、目的の数字見つけたら斜め上に飛ぶ
v=dp[-1][-1]
# tの飛んだ時がtの何文字目かを記録する
ans=''
while x>0 and y>0:
    # 左に移動
    if dp[x][y]==dp[x][y-1]:
        y-=1
    # 下に移動
    elif dp[x][y]==dp[x-1][y]:
        x-=1
    # 斜めに移動
    else:
        x-=1
        y-=1
        ans=t[y]+ans
print(ans)

Measured memory_bytes: 112860
/*There's a possibility*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mod 1000000007
using namespace std;

ll n,dp[100005][2];
vector<int> v[100005];

ll fun(int i, int choice, int par)
{
    // dbg(i,choice,v[i].size(),par,v[i][0],dp[i][choice]);
    if(dp[i][choice]!=-1)
        return dp[i][choice];
    if(v[i].size()==1 and v[i][0]==par)
        return dp[i][choice]=1;
    
    ll ans=1;
    for(auto x:v[i])
    {
        if(x!=par)
        {
            if(choice==0)
                ans=(ans*fun(x,1,i))%mod;
            else ans=(ans*(fun(x,0,i)+fun(x,1,i))%mod)%mod;
        }
    }
    return dp[i][choice]=ans;
}

int main()
{
    fast;
    int i,x,y;
    cin>>n;
    f(i,0,n-1)
        cin>>x>>y,v[x].pb(y),v[y].pb(x);
    memset(dp,-1,sizeof(dp));
    cout<<(fun(1,0,-1)+fun(1,1,-1))%mod;
    // db(dp,0,n,0,3);
}

Measured memory_bytes: 18960
# include <bits/stdc++.h>
  typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second
#define all v.begin(),v.end()
#define fio ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
typedef unsigned long long ulll;
 
using namespace std ;
int main () {

   int n;
   cin>>n;
   
   cout<<n*800-((n/15)*200);
   
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int a, b, c;
	do{
		a = 0;
		b = 0;
		c = 0;
		cin >> a >> b;
		if (a == 0 && b == 0) break;
		for (int i = 1; i <= a; i++){
			for (int j = 1; j <= a; j++){
				for (int k = 1; k <= a; k++){
					if (i == j | j == k | i == k)c += 0;
					else if (i + j + k == b) c += 1;
				}
			}
		}
		c /= 6;
		cout << c << endl;
	} while (a + b != 0);
}


Measured memory_bytes: 3080
{-# LANGUAGE TypeFamilies, BangPatterns, FlexibleContexts #-}
import Data.Array
import Data.Array.Unboxed
import Data.Array.IO
import Data.Array.Unsafe
import qualified Data.Map.Strict as M
import qualified Data.Set as S
import qualified Data.Vector.Unboxed as U
import Data.Int
import Control.Monad.State.Strict
import qualified Data.ByteString.Char8 as B
import Data.ByteString(ByteString)
import Data.Char

type Scanner a = StateT ByteString IO a
type family Freeze a where
  Freeze (IOUArray i v) = UArray i v
  Freeze (IOArray i v) = Array i v

foldM :: Monad m => (b -> a -> m b) -> b -> [a] -> m b
foldM f z0 xs = foldr c return xs z0
    where c x k = \z -> f z x >>= k
          {-# INLINE c #-}

scan :: Read a => Scanner a
scan = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s 
        !v = read (B.unpack s1)
    in (v, B.dropWhile isSpace s2)

scanInt :: Scanner Int
scanInt = scan

scanString :: Scanner B.ByteString
scanString = state $ \s ->
    let (s1, s2) = B.span (not . isSpace) s in
    (s1, B.dropWhile isSpace s2)

scanReal :: Scanner Double
scanReal = scan

newtype M = M Int
    deriving Show

modulo = 1000000007

instance Num M where
    M a + M b = M $ (a + b) `mod` modulo
    M a - M b = M $ (a - b) `mod` modulo
    M a * M b = M $ (a * b) `mod` modulo
    fromInteger x = M $ fromInteger x `mod` modulo
    abs = id
    signum _ = M 1

instance Fractional M where
    recip (M x) = M (recipM x modulo)

data EGCD = EGCD !Int !Int !Int

{-# NOINLINE recipM #-}
recipM :: Int -> Int -> Int
recipM x m | g /= 1 = error $ "No inverse for " ++ show x ++ " % " ++ show m 
           | s <  0 = s + m
           | otherwise = s
    where 
    EGCD s _ g = extgcd x m

extgcd :: Int -> Int -> EGCD
extgcd = go
    where 
    go a 0 = EGCD 1 0 a
    go a b = EGCD t (s - q * t) g
        where
        (q, r) = quotRem a b
        EGCD s t g = go b r

main :: IO ()
main = B.getContents >>= \content -> flip evalStateT content $ do
    vB <- scanInt
    vW <- scanInt
    liftIO $ solve vB vW

solve :: Int -> Int -> IO ()
solve vB vW = do
    let n = vB + vW
    let factTbl = U.unfoldrN (n + 1) factGen (1,1)
        factGen :: (M, Int) -> Maybe (Int, (M, Int))
        factGen (M m, i) = Just (m, (M m * M i, i + 1))
        fact :: Int -> M
        fact n = M (factTbl U.! n )
        comb :: Int -> Int -> M
        comb x y = fact x / (fact y * fact (x - y)) 
    let go !i !b !p !q = when (i < n) $ do
            let M z = p + (1 / 2) * ( 1 - p - q)
                p' | i + 1 < vW = 0
                   | otherwise = p + b * comb i (vW-1)
                q' | i + 1 < vB = 0
                   | otherwise = q + b * comb i (vB-1)
            print z
            go (i + 1) (b/2) p' q'
    go 0 (1/2) 0 0


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

int main() {
  double n,k;
  cin >> n >> k;
  double ans=0.0;
  for(double i=1.0;i<=n;i++){
    if(i>=k)
    ans=ans+1.0;
    else{
      for(double j=1.0;j<20.0;j++){
        if(i*pow(2,j)>=k){
          ans=ans+1.0/(pow(2,j));
          break;
        }
      }
    }
  }
  cout << fixed << setprecision(10) << ans/n << endl;
}



Measured memory_bytes: 4208
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long k = sc.nextLong();
		long ans = 0;
		if(k>a) {
			ans +=a;
			if(k-a>b) {
				ans-=k-a-b;
			}
			else {

			}
		}
		else {
			ans+=k;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 35800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=5005,mod=1e9+7;
int n,tot,si[N],head[N],nex[N<<1],to[N<<1];
ll p[N],dp[N][N][2],f[N][2];
void add(int u,int v){to[++tot]=v;nex[tot]=head[u];head[u]=tot;}
ll g(int x){return p[x-1];}
void dfs(int u,int p)
{
    dp[u][1][1]=1;
    si[u]=1;
    for(int i=head[u];i;i=nex[i])
    {
        int v=to[i];if(v==p) continue;
        dfs(v,u);
        memset(f,0,sizeof(f));
        for(int i=1;i<=si[u];i++)
            for(int j=1;j<=si[v];j++)
            for(int k=0;k<2;k++)
                for(int h=0;h<2;h++)
            {
                f[i][k^h]=(f[i][k^h]+dp[u][i][k]*dp[v][j][h]%mod*g(j)%mod)%mod;
                f[i+j][k^h^1]=(f[i+j][k^h^1]+dp[u][i][k]*dp[v][j][h]%mod)%mod;
            }
        si[u]+=si[v];
        for(int i=1;i<=si[u];i++)
            dp[u][i][0]=f[i][0],dp[u][i][1]=f[i][1];
    }
}
int main()
{
    p[1]=1;
    for(int i=3;i<N;i+=2)
        p[i]=p[i-2]*i%mod;
    scanf("%d",&n);
    for(int i=1;i<n;i++)
    {
        int u,v;scanf("%d%d",&u,&v);
        add(u,v);add(v,u);
    }
    dfs(1,0);
    ll ans=0;
    for(int i=1;i<=si[1];i++)
        ans=(ans+dp[1][i][1]*g(i)%mod-dp[1][i][0]*g(i)%mod)%mod;
    ans=(ans+mod)%mod;
    printf("%lld\n",ans);
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, x;
    cin >> N >> x;
    if (x == 1 || x == 2 * N - 1) {
        cout << "No" << endl;
        return 0;
    }
    vector<bool> used(2 * N - 1, false);
    vector<int> ans(2 * N - 1, -1);
    int prev = x - 1, nxt = x + 1;
    auto check = [&](int pos, int num) {
        used[num - 1] = true;
        ans[pos - 1] = num;
    };

    check(N, x);
    check(N + 1, nxt++);
    check(N - 1, prev--);
    if (prev > 0) {
        check(N + 2, prev);
    }
    if (nxt <= 2 * N - 1) {
        check(N - 2, nxt);
    }
    int n = 1;
    REP(i, 0, 2 * N - 1) {
        while (n <= 2 * N - 1 && used[n - 1]) {
            n++;
        }
        if (ans[i] == -1) {
            check(i + 1, n++);
        }
    }
    cout << "Yes" << endl;
    REP(i, 0, 2 * N - 1) {
        cout << ans[i] << endl;
    }

    return 0;
}


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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int H, W;
	cin >> H >> W;

	vector <string> s(H);
	for (int ii = 0; ii < H; ++ii){
		cin >> s[ii];
	}

	vector<vector<int>> v(H, vector <int> (W, 0));

	for (int h = 0; h < H; ++h){
		for (int w = 0; w < W; ++w){
			if (s[h][w] == '#'){
				for (int hh = -1; hh <= 1; ++hh){
					for (int ww = -1; ww <= 1; ++ww){
						int y = h + hh;
						int x = w + ww;
						if ( y < 0 || y >= H || x < 0 || x >= W){
							continue;
						}
						v[y][x] += 1;
					}
				}

			}
		}
	}

	for (int h = 0; h < H; ++h){
		for (int w = 0; w < W; ++w){
			if (s[h][w] == '#'){
				cout << '#';
			} else {
				cout << v[h][w];
			}
		}
		cout << endl;
	}


	return 0;
}


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

int main(int argc, char** argv) {
  int N;
  std::string S;
  std::cin >> N >> S;
  int cnt {};
  for (auto i = 0;i < N-2;++i) {
    if (S[i] == 'A' && S[i+1] == 'B' && S[i+2] == 'C') ++cnt;
  }
  std::cout << cnt << '\n';
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int i,x[10000],n;
	for(i=1;i<=10000;i++){
		scanf("%d",&x[i]);
		if(x[i]==0){
			break;
		}
	}
	
	n=i;
	
	for(i=1;i<n;i++){
		printf("Case %d: %d\n",i,x[i]);
	}	
	
	
	return 0;
}



Measured memory_bytes: 2072
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int h, w, k;
int oriB[10][10];

int newB[10][10];

bool isPaint[20];

int wayCount = 0;

void doScan(int depth) {
	if (depth == (h + w)) {
		for (int r = 0 ; r < h ; r++) {
			for (int c = 0 ; c < w ; c++) {
				newB[r][c] = oriB[r][c];
			}
		}
		
		for (int i = 0 ; i < h ; i++) {
			if (isPaint[i] == false)
				continue;
			
			for (int c = 0 ; c < w ; c++) {
				newB[i][c] = -1;
			}
		}
		
		for (int i = h ; i < h + w ; i++) {
			if (isPaint[i] == false)
				continue;
			
			for (int r = 0 ; r < h ; r++) {
				newB[r][i - h] = -1;
			}
		}
		
		int numCount = 0;
		for (int r = 0 ; r < h ; r++) {
			for (int c = 0 ; c < w ; c++) {
				if (1 == newB[r][c])
					numCount++;
			}
		}
		
		if (numCount == k)
		 	wayCount++;
	} else {
		isPaint[depth] = false;
		doScan(depth + 1);
		isPaint[depth] = true;
		doScan(depth + 1);
		isPaint[depth] = false;
	}
	
}



int main()
{
	scanf("%d%d%d\n", &h, &w, &k);
	for (int r = 0 ; r < h ; r++) {
		char temp[10];
		scanf("%s\n", temp);
		for (int c = 0 ; c < w ; c++) {
			if (temp[c] == '.') {
				oriB[r][c] = 0;
				newB[r][c] = 0;
			} else {
				oriB[r][c] = 1;
				newB[r][c] = 1;
			}
		}
	}
	
	wayCount = 0;
	
	doScan(0);
	
	printf("%d", wayCount);
	
	return 0;
}



Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define RREP(i, n) for(int i = n; i >= n; i--)

#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))

#define endl "\n"
#define pb push_back
#define rtn return
#define elif else if

#define MOD 1000000007
 
const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};

typedef long long ll;
typedef unsigned long long ull;

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

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

	int n, k;
	cin >> n >> k;
	int ans = k;
	REP(i, n-1){
		ans *= k-1;
	}
	cout << ans << endl;
	rtn 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int  main(void){
         int h,w,i,j;
          while(1){
          scanf("%d %d",&h,&w);
           if( h==0 && w==0)
              break;
           for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              printf("#");
             }printf("\n");
            }printf("\n");
           }
            return 0;
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
string S;

int main(){
    cin >> N >> S;
    int ans = 0;
    map<char,int> C,T;
    rep(i,N) C[S[i]]++;
    
    rep(i,N){
        C[S[i]]--, T[S[i]]++;
        int ct = 0;
        repi(j,'a','z') if(C[j] > 0 && T[j] > 0) ct++;
        ans = max(ct,ans);
    }
    cout << ans << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in)) {

			int x = sc.nextInt();
			int y = sc.nextInt();
			int ans = 0;
			if(x == 1) {
				ans += 300000;
			} else if(x == 2) {
				ans += 200000;
			} else if(x == 3) {
				ans += 100000;
			}
			if(y == 1) {
				ans += 300000;
			} else if(y == 2) {
				ans += 200000;
			} else if(y == 3) {
				ans += 100000;
			}
			if(x == 1 && y == 1) {
				ans += 400000;
			}
			System.out.println(ans);
		}

	}

}


Measured memory_bytes: 23252
path=[]
for i in range(3):
    n, k = map(int, input().split())
    path.append(n)
    path.append(k)

if 0 < path.count(1) < 3 and 0 < path.count(2) < 3 and 0 < path.count(3) < 3 and 0 < path.count(4) < 3:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int a,b; cin>>a>>b;
  cout << (a-1)*(b-1) << endl;
}


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

def short_long_decisions(xs):
    return [ *map(lambda t: xs[t[0]] <= t[1], zip(range(len(xs)), xs[1:])), False ]

stocks  = 0
money   = 1000
actions = short_long_decisions(ai)

for i, action in enumerate(actions):
    if action:
        buy = money // ai[i]
        stocks += buy
        money -= buy * ai[i]

    else:
        money += stocks * ai[i]
        stocks = 0

print(money)

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE


void solve(void)
{
  int N,M;
  cin>>N>>M;
  vector<int> vec (N,0);
  for (int i = 0; i < N; i++)
  {
     cin>>vec[i];
  }
  vector<int> win (N,1);
  for (int i = 0; i < M; i++)
  {
    int A,B;cin>>A>>B;
    A--;B--;
    if(vec[A] < vec[B])
    {
      win[A] = -1;
    }
    else if(vec[B] < vec[A])
    {
      win[B] = -1;
    }
    else
    {
      win[A] = -1;
      win[B] = -1;
    }
    
    
  }
  int cnt = 0;
  for (auto &&i : win)
  {
    if(i != -1)cnt++;
  }
  cout<<cnt<<endl;
  // DEBUG(win);
  
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD = 1e9+7;
using P=pair<ll,ll>;
ll gcd(ll a,ll b){//aとbの最大公約数を返す//計算量は0(log(max(a,b))
  if(a%b==0){return b;}
  else{return gcd(b,a%b);}
}
ll lcm(ll a,ll b){//aとbの最小公倍数を返す//計算量は0(log(max(a,b))
  return a*b/gcd(a,b);
}
ll mod_pow(ll x,ll y){//x^yを返す//計算量は0(log(y))
  ll tmp=x,res=1;
  while(y){
    if(y%2){res=res*tmp%MOD;}
    y>>=1;
    tmp=tmp*tmp%MOD;
  }
  return res;
}
ll nature(ll a){//絶対値を返す
  if(a>=0){return(a);}
  else{return(-1*a);}
}
ll prime(ll a){//素数なら1を返す//計算量は0(sqrt(a))
  if(a==2){return 1;}
  else if(a%2==0 || a==1){return 0;}
  for(ll i=3;i*i<=a;i+=2){if(a%i==0){return 0;}}
  return 1;
}
int main(){
  int A,B,C;
  cin>>A>>B>>C;
  int K;
  cin>>K;
  for(int i=0;i<K;i++){
    if(A>=B){
      B*=2;
    }
    else{
      C*=2;
    }
  }
  if(A<B && B<C){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 3640
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	string S;
	cin >> S;

	for (int i = 0; i < S.length(); i++) {
		cout << "x";
	}
	cout << endl;
}

Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int n,a,b,c,ret=100000000,acnt,bcnt,ccnt,asum,bsum,csum;
vector<int> l;

void dfs(int turn){
  if(turn==n){
    if(acnt!=0 && bcnt!=0 && ccnt!=0)ret=min(ret,10*(max(acnt-1,0)+max(bcnt-1,0)+max(ccnt-1,0))+abs(asum-a)+abs(bsum-b)+abs(csum-c));
    return;
  }
  acnt++;
  asum+=l[turn];
  dfs(turn+1);
  acnt--;
  asum-=l[turn];
  bcnt++;
  bsum+=l[turn];
  dfs(turn+1);
  bcnt--;
  bsum-=l[turn];
  ccnt++;
  csum+=l[turn];
  dfs(turn+1);
  ccnt--;
  csum-=l[turn];
  dfs(turn+1);
  return;
}
int main(){
  int i,j,k;
  cin >> n >> a >> b >> c;
  l.resize(n);
  for(i=0;i<n;i++)cin >> l[i];
  dfs(0);
  cout << ret << endl;
  return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int x,a,b; cin>>x>>a>>b;
    cout<<(x-a)%b<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int selectionSort(int A[], int N) {
  int i, j, t, sw = 0, minj;
  for (i = 0; i < N - 1; i++) {
    minj = i;
    for (j = i; j < N; j++) {
      if (A[j] < A[minj]) minj = j;
    }
    t = A[i];
    A[i] = A[minj];
    A[minj] = t;

    if (i != minj) sw++;
  }
  return sw;
}

int main() {
  int A[100], N, i, sw;

  scanf("%d", &N);
  for (i = 0; i < N; i++) scanf("%d", &A[i]);

  sw = selectionSort(A, N);

  for (i = 0; i < N; i++) {
    if (i > 0) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
  printf("%d\n", sw);

  return 0;
}



Measured memory_bytes: 2108
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;



void main() {
    int n, m;
    scan(n, m);

    auto a = readln.split.to!(int[]);

    auto bh = new BinaryHeap!(Array!double, "a < b")();

    foreach (ai ; a) {
        bh.insert(ai * 1.0);
    }

    while (m--) {
        auto hlf = bh.front / 2.0;
        bh.popFront();
        bh.insert(hlf);
    }

    long ans;

    while (!bh.empty) {
        ans += bh.front.to!int;
        bh.popFront();
    }

    writeln(ans);
}

















void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 5544
#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__) << "] "

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	int c = 0;
	for (int &i : v) cin >> i;
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (v[i] == v[j]) continue;
			for (int k = j + 1; k < n; k++) {
				if (v[j] == v[k]) continue;
				//debug() << imie(v[i]) imie(v[j]) imie(v[k]);
				if (v[i] + v[j] > v[k]) c++;
			}
		}
	}
	cout << c << "\n";
}



Measured memory_bytes: 3616
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    string S; cin >> S;
    int n = static_cast<int>(S.size());
    // 部分文字列 XX がある場合
    for (int i = 0; i < n - 1; ++i)
    {
        if (S[i] == S[i + 1])
        {
            cout << i + 1 << ' ' << i + 2 << endl;
            return 0;
        }
    }
    // 部分文字列 XYX がある場合
    for (int i = 0; i < n - 2; ++i)
    {
        if (S[i] == S[i + 2])
        {
            cout << i + 1 << ' ' << i + 3 << endl;
            return 0;
        }
    }
    cout << "-1 -1" << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node {
  int p,r,l;
};

struct Node A[MAX];
int n,B[MAX];

void print(int x){
  int i,c;
 
  printf("node %d: ",x);
  printf("parent = %d, ",A[x].p);
  printf("depth = %d, ",B[x]);
	 
  if(A[x].p==NIL)printf("root, [");
  else if(A[x].l==NIL)printf("leaf, [");
  else printf("internal node, [");

  for(i=0,c=A[x].l;c!=NIL;i++,c=A[c].r){
    if(i!=0)printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
	 
	 
int depth(int x,int y){
  B[x]=y;
  if(A[x].r!=NIL)depth(A[x].r, y);
  if(A[x].l!=NIL)depth(A[x].l, y+1);
}

int main(){
  int i,j,d,v,c,l,r;

  scanf("%d",&n);
    
  for(i=0;i<n;i++)A[i].p=A[i].l=A[i].r=NIL;
    
  for(i=0;i<n;i++){
    scanf("%d %d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0)A[v].l=c;
      else A[l].r=c;
      l=c;
      A[c].p=v;
    }
  }
  for(i=0;i<n;i++){
    if(A[i].p==NIL)r=i;
  }
  depth(r,0);

  for(i=0;i<n;i++)print(i);

  return 0;
}



Measured memory_bytes: 6412
import math
N = int(input())
x = [list(map(int,input().split())) for i in range(N)]

l = []
for i in range(N):
    for j in range(N):
        l.append(math.sqrt((x[i][0]-x[j][0])**2+(x[i][1]-x[j][1])**2))

print(sum(l)/N)

Measured memory_bytes: 9196
#include <iostream>
#include<string>
using namespace std;
int main(void){
    string s;
    int c=-1,f=-1;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='C'){c=i;break;}
    }
    for(int i=0;i<s.size();i++){
        if(s[i]=='F'){f=i;}
    }
    if(c==-1||f==-1)cout<<"No"<<endl;
    else if(c<f)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;}

int n,k;

int main(){
    cin >> n >> k;
    if(((n+1)/2)>=k){
        put("YES");
    }else{
        put("NO");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define print(A,n) for(ll i=0;i<n;++i)cout<<A[i]<<' ';cout<<endl;
#define take(A,n) for(ll i=0;i<n;++i)cin>>A[i];
//    for(auto& it : m)
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);}
//  priority_queue<ll int> pq;
//  priority_queue <ll int, vector<ll int>, greater<ll int> > pq;
//  vector<ll int> v;
//  vector< pair<ll int,ll int> > v;
//  set<ll int>::iterator it=s.begin();
//  unordered_map<  pair<ll int,ll int>, ll int> mp;

 

ll int power(ll int x, ll int y, ll int p)  
{  
    ll int res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p 
   
    if (x == 0) return 0; // In case x is divisible by p; 
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  
 
int main()
{
  fastio();

 
ll int T;
T=1;
while(T--)
{
	int n;
	cin>>n;
	n=n%10;
	if(n==2||n==4||n==5||n==7||n==9)
	{
		cout<<"hon"<<endl;
	}
	else if(n==3)
	{
		cout<<"bon"<<endl;
	}
	else
		cout<<"pon"<<endl;

}
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(long long i=s;i<n;i++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

typedef long long ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<vll> vvll;
const double pi = acos(-1.0);
const ll mod = pow(10,9) + 7;
const ll INF = pow(2,31) - 1;

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll x,ll y)
{
    x /= gcd(x,y);
    y /= gcd(x,y);
    return (x*y);
}

int main()
{
    int a,b;
    cin >> a >> b;

    for(double i=1;i<1300;i+=1){
        //cout << i << " " << i*0.08 << " " << i*0.1 << endl;
        if((int)(i*0.08) == a && (int)(i*0.1) == b){
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
##### 解けた #####

H,W=list(map(int,input().split(" ")))

print("#"*(W+2)) # 一番上の行

# 入力を受け取って、両端に"#"をつけて出力する
for _ in range(H):
    print("#"+input()+"#")

print("#"*(W+2)) # 一番下の行

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Part(vec, b, e) vec.begin() + b, vec.begin() + e
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(vec, s) vec.find(s) != vec.end()
#define Set_union(A, B, res) set_union(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_intersection(A, B, res) set_intersection(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_difference(A, B, res) set_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));
#define Set_symmetric_difference(A, B, res) set_symmetric_difference(A.begin(), A.end(), B.begin(), B.end(), inserter(res, res.end()));

int main() {
	unsigned int a, b;
	cin >> a >> b;
	cout << bitset<32>(a & b) << endl;
	cout << bitset<32>(a | b) << endl;
	cout << bitset<32>(a ^ b) << endl;
	return 0;
}


Measured memory_bytes: 3156
import sys

a, b, c, k = map(int, input().split())
if a >= k:
    print(k)
    sys.exit()

total = a
k = k - a
if k <= 0:
    print(total)
    sys.exit()

k = k - b
if k <= 0:
    print(total)
    sys.exit()

print(total - k)


Measured memory_bytes: 9180
A, B, C, D, E, F = map(int, input().split())
M = 0
Sans = 0
Concmax = -1

for i in range(F//100//A+1):
  WA = i*100*A
  for k in range((F-WA)//100//B+1):
    WB = k*100*B
    W = WA+WB
    if W <= F:
      for j in range((F-W)//C+1):
        SC = j*C
        for l in range((F-W-C)//D+1):
          SD = l*D
          S = SC+SD
          if 0 < W+S <= F and S <= W*E/100:
            Conc = S/(S+W)
            if Conc > Concmax:
              Concmax= Conc
              Sans = S
              M = S+W
#              print(WA,WB,SC,SD,Conc)
print(M,Sans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;
int func(int d) { for(int i = 0; i < 31; ++i) if(d>>i&1) return i; return 32; }
int a, b, c;
int main()
{
    scanf("%d%d%d", &a, &b, &c);
    if(a&1||b&1||c&1) return puts("0"), 0;
    c = min(func(max(a-b, b-a)), func(max(b-c, c-b)));
    if(c == 32) return puts("-1"), 0;
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define sz(c)      int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;

int const MAXHW=2200;
int H,W;
char S[MAXHW][MAXHW];
int v[MAXHW][MAXHW];
int h[MAXHW][MAXHW];

int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	cout<<fixed<<setprecision(10);

	cin>>H>>W;
	rep(i,0,H) cin>>S[i];
	
	rep(i,0,H) rep(j,0,W) if (S[i][j]!='#') {
		v[i+1][j+1]=v[i][j+1]+1;
		h[i+1][j+1]=h[i+1][j]+1;
	}
	
	//~ rep(i,0,H) rep(j,0,W) cerr<<v[i+1][j+1]<<" \n"[j+1==W];
	//~ cerr<<endl;
	//~ rep(i,0,H) rep(j,0,W) cerr<<h[i+1][j+1]<<" \n"[j+1==W];
		
	int res=0;
	per(i,0,H) per(j,0,W) if (S[i][j]!='#') {
		v[i+1][j+1]=max(v[i+1][j+1],v[i+2][j+1]);
		h[i+1][j+1]=max(h[i+1][j+1],h[i+1][j+2]);
		res=max(res,v[i+1][j+1]+h[i+1][j+1]-1);
	}
	cout<<res<<"\n";
}


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

count = 0
for i in range(n):
    num = c
    for j in range(m):
        num += a[i][j] * b[j]
    if num > 0:
        count += 1

print(count)

Measured memory_bytes: 3064
/**Bismillahir Rahmanir Rahim.**/

/**
 *    author:  nasimnoob
**/

#include<bits/stdc++.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<math.h>
using namespace std;

//----------------------------------------------------------//

typedef long long int                        ll;
typedef unsigned long long int              ull;
typedef long double                          ld;

//-----------------------------------------------------------//
#define      test                       int t; cin>>t;  while(t--)

#define      cube(x)                    (x*x*x)
#define      sqr(x)                     (x*x)

#define      sc1(x)                     scanf("%lld",&x);
#define      sc2(x,y)                   scanf("%lld %lld", &x, &y)
#define      scf1(x)                    scanf("%lf",&x)
#define      scf2(x,y)                  scanf("%lf %lf", &x, &y)

#define      srev                       reverse(s.begin(),s.end())
#define      sortstr                    sort(s.begin(), s.end());
#define      gtl(x)                     getline(cin, (x))

#define      PI                         acos(-1) // 3.1415926535897932
#define      MIN                        9999999

#define      Faster                     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

//scanf("%[^\n]%*c", str);
//sort(s,s+n,greater<int>());

//-----------------------------------------------------------//

int main()
{
    Faster;
    //string ;
    int k , n;
    cin >> k >> n;
    int a[10000];
    for(int i = 0 ; i < k ; i++)
    {
        cin >> a[i];
    }
    sort(a,a+k);
    int sum = 0;
    for(int i = 0 ; i < n ; i++)
    {
        sum+=a[i];
    }
    cout << sum << endl;
    return 0;
}






Measured memory_bytes: 3628
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var n = int.Parse(spl[0]);
        var m = int.Parse(spl[1]);

        var tbl = new int[m];

        for(int i=0; i<n; i++) {
            spl = input.ReadLine().Split(' ');
            var k = int.Parse(spl[0]);
            for(int j=0; j<k; j++) {
                var a = int.Parse(spl[j + 1]);
                tbl[a-1] += 1;
            }
        }

        return tbl.Count(x => x == n);
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13268
import collections
n=int(input())
s=str(input())
s=list(s)
ans=collections.Counter(s)
for i in range(1,n):
  s=str(input())
  s=list(s)
  c=collections.Counter(s)
  ans=ans&c
ans="".join(sorted(ans.elements()))
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1000000000000
ll upper = 10000000;

int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        ll count = n / i;
        ll  upper = i * count;
        ans += (i+upper) * count / 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3532
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]
yusendo=[]
for i in range(n):
    yusendo.append([ab[i][0]+ab[i][1], ab[i][1]-ab[i][0], i])
yusendo.sort(reverse=True)
# print(yusendo)

takahashi=0
aoki=0
for i in range(n):
    if i%2==0:
        takahashi+=ab[yusendo[i][2]][0]
    else:
        aoki+=ab[yusendo[i][2]][1]
# print(takahashi, aoki)

print(takahashi-aoki)

Measured memory_bytes: 47452
#include<bits/stdc++.h>
#define N 105
using namespace std;
int n,u,k,v,e[N][N],cnt;
int ans1[N],ans2[N];
bool used[N];
 
void dfs(int x){
  if(used[x])return;
  used[x]=true;
  ans1[x]=cnt++;
  for(int i=0;i<n;i++)
    if(e[x][i])dfs(i);
  ans2[x]=cnt++;
}
 
int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++)
      cin>>v,e[u-1][v-1]=1;
  }
  cnt=1;
  for(int i=0;i<n;i++){
    if(!used[i])dfs(i);
  }
  for(int i=0;i<n;i++){
    cout<<i+1<<' '<<ans1[i]<<' '<<ans2[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 3148