akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> get_operator_inserted_formulas(string S) {
    // Sの桁数-1桁のビット列を考える
    int digits = S.size();
    int max_bits = (1 << (digits - 1)) - 1;
    vector<string> formulas;

    //cout << "digits = " << digits << endl; // **** debug ****
    //cout << "max_bits = " << max_bits << endl; // **** debug ****

    for (int bits = 0; bits <= max_bits; bits++) {
        string formula = "";
        for (int k = 0; k < digits - 1; k++) {
            formula.push_back(S.at(k));

            if (bits >> k & 1) {
                formula.push_back('+');
            }
        }
        formula.push_back(S.back());
        formulas.push_back(formula);
    }

    return formulas;
}

vector<string> split(string s, string c)
{
    vector<string> ret;
    for(int i = 0, n; i <= s.length(); i = n + 1){

        n = s.find_first_of(c, i);
        if(n == string::npos) n = s.length();
        string tmp = s.substr(i, n - i);
        ret.push_back(tmp);
    }
    return ret;
}

long long calculate_operator_inserted_formula(string formula) {
    vector<string> numbers = split(formula, "+");

    long long sum = 0;
    for (auto n : numbers) {
        sum += stoll(n);
    }
    return sum;
}

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

    vector<string> inserted_formulas = get_operator_inserted_formulas(S);

    long long ans = 0;
    for (auto formula : inserted_formulas) {
        ans += calculate_operator_inserted_formula(formula);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace ABC
{
    class ABC173D
    {
        const string FILE = "/tmp/data.txt";

        static void Main(string[] args)
        {
#if DEBUG
            Console.SetIn(new StreamReader(FILE));
#endif
            var N = RI();
            var Ia = RIa(N);

            Array.Sort(Ia);
            var Ias = Ia.Reverse().ToArray();

            long result = 0;    // A0
            // A1
            result += Ias[0];

            int idx = 1;

            for (int i = 2; i < N;)
            {
                result += Ias[idx];
                i += 1;

                if (i == N)
                {
                    break;
                }
                result += Ias[idx];
                i += 1;

                idx += 1;
            }
            Console.WriteLine(result);

#if DEBUG

            Console.WriteLine("*** end ***");
            Console.SetIn(Console.In);
            Console.ReadKey();
            Console.WriteLine();
#endif
        }

        static int RI()
        {
            return int.Parse(Console.ReadLine());
        }

        static int[] RIa(int n)
        {
            string[] sa = Console.ReadLine().Split(' ');
            int[] la = new int[n];
            for (int i = 0; i < n; ++i)
            {
                la[i] = int.Parse(sa[i]);
            }
            return la;
        }
    }
}


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

long long N;
long long V[30];
long long C[30];

int main(){
	cin >> N;
	for(long long i = 0; i < N; i++){
		cin >> V[i];
	}
	for(long long i = 0; i < N; i++){
		cin >> C[i];
	}
	long long count = 0;
	for(long long i = 0; i < N; i++){
		count += max((long long)0, V[i] - C[i]);
	}
	cout << count << endl;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	int N;
	cin >> N;
	map<char, ll> m;
	for(int i = 0; i < N; i++){
		string s;
		cin >> s;
		m[s[0]]++;
	}

	ll dp[6][4] = { 0 };
	dp[0][0] = 1;
	string march = "MARCH";
	for(int i = 0; i < 5; i++){
		ll num = m[march[i]];
		for(int j = 0; j <= 3; j++){
			dp[i + 1][j] += dp[i][j];
			dp[i + 1][j + 1] += dp[i][j] * num;
		}
	}
	cout << dp[5][3] << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main() {
	long n, x[200000], x2[200000], c[2];

	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x[i]); x2[i] = x[i];
	}
	sort(x2, x2+n);
	c[0] = x2[n/2-1];
	c[1] = x2[n / 2];
	for (int i = 0; i < n; ++i) {
		if (x[i] <= c[0])	printf("%d", c[1]);
		else				printf("%d", c[0]);
		printf("\n");
	}
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define MOD 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define M 1e6+9
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
#define int long long
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}

// ll n,k,a,b,c,d,x,y,z,m,l;
// ll ans;
// vecl arr(N);
// ll dp[509][509];
// ll pre[N];




void test_case() {
	
    int h, a;
    cin>>h >>a;

    int ans = h/a;

    if(h%a != 0) {
        ans++;
    }

    cout<<ans<<endl;



}


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

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);


    int t = 1;
    // cin >> t;
    while(t--)
    {   
        test_case();
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

const int N=100005;
const int mod=1e9+7;
int n, k;
VI adj[N], A(N,0);

LL mul_mod(LL a, LL b) {
    return (a*b+mod)%mod;
}

void dfs(int u, int p) {
    int nc=k-1;
    if(p!=-1) nc--;
    
    for(auto v:adj[u]) {
        if(v==p) continue;
        A[v]=nc--;
        dfs(v, u);
    }
}

int main() {
    cin >> n >> k;
    REP(i, n-1) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        adj[a].PB(b);
        adj[b].PB(a);
    }
    A[0]=k;
    dfs(0, -1);
    LL ans=1;

    // REP(i, n) cout << A[i] << ' '; cout << endl;
    REP(i,n) ans=mul_mod(ans, A[i]);
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
typedef long long ll;
typedef long double ld;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<cstring>
using namespace std;
 
int main(){

  long long int n;
  cin >> n;

  cout << 48-n << endl;

  return 0;
}


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

if m == 0:
    if n == 1:
        print(0)
    else:
        print(10**(n-1))
    exit()
elif n == 1:
    if len([i[1] for i in inputs if i[1] != inputs[0][1]]) > 0:
        print(-1)    
    else:
        print(max(0,inputs[0][1]))
    exit()
else:
    out = [-1] * n
    for item in inputs:
        s = item[0]
        c = item[1]
        if out[s-1] != -1 and out[s-1] != c:
            print(-1)
            exit()
        elif s == 1 and c == 0:
            print(-1)
            exit()
        else:
            out[s-1] = c

out[0] = max(out[0],1)
res = 0
for i in range(len(out)):
    if out[i] != -1:
        res += out[i] * 10 ** (n-i-1)
print(res)
        

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, e) for(int i = (int)(s); i < (int)(e); ++i)
#define rep(i, n) REP(i, 0, n)
using ll = long long int;
const int INF = 1e9;

int main() {
  int n;
  while(cin >> n ) {
    if(n == 0) break;
    vector<vector<int>> v(n, vector<int>(n+1));
    rep(i, n) rep(j, n+1) cin >> v[i][j];
    vector<int> dp((1<<n), INF);
    dp[0] = 0;
    rep(mask, 1<<n) {
      rep(i, n) {
	if(mask&(1<<i)) continue;
	int tmp = v[i][0];
	rep(j, n) {
	  if(mask&(1<<j)) {
	    tmp = min(tmp, v[i][j+1]);
	  }
	}
	int nxt = mask | (1<<i);
	dp[nxt] = min(dp[nxt], dp[mask] + tmp);
      }
    }
    cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3276
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <tuple>
#include <cstring>
#include <map>
#include <iomanip>
#include <ctime>
#include <complex>
#include <cassert>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _ << " " <<
#define all(X) (X).begin(), (X).end()
#define len(X) (X).size()
#define Pii pair<int, int>
#define Pll pair<ll, ll>
#define Tiii tuple<int, int, int>
#define Tlll tuple<ll, ll, ll>

int main() {
    int k, p[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cin >> k;
    cout << p[k - 1] << endl;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    int swap;
    long sum=0;

    for(int i=0;i<n;i++){
        cin>>a[i];
    }

    for(int i=0;i<n-1;i++){
        for(int j=1;j<n;j++){
            if(a[j]<a[j-1]){
                swap = a[j];
                a[j]=a[j-1];
                a[j-1]=swap;
            }
        }
    }

    for(int i=0;i<n;i++){
        sum += a[i];
    }
    
    cout<<a[0]<<" "<<a[n-1]<<" "<<sum<<endl;

    return 0;
}


Measured memory_bytes: 3116
from decimal import *
import sys
import copy

def main():
    getcontext().prec = 1000
    input = sys.stdin.readline
    n, k = input().split()
    n = int(n)
    k = Decimal(k)
    a = [Decimal(input()) for i in range(n)]
    if Decimal(0) in a:
        print(n)
        sys.exit()
    if k == Decimal(0):
        print(0)
        sys.exit()
    left = copy.copy(a)
    right = copy.copy(a)
    for i in range(n-1):
        left[i + 1] *= left[i]
    for i in reversed(range(n-1)):
        right[i] *= right[i + 1]
    mul = left[-1]
    right.append(Decimal(1))
    r = []
    for i, x in enumerate(right):
        while r and r[-1][1] <= x:
            r.pop()
        r.append((i, x))
    l = [(-1, Decimal(1))]
    for i, x in enumerate(left):
        if not l or l[-1][1] < x:
            l.append((i, x))
    ans = 0
    at = -1
    for i, x in l:
        while at + 1 < len(r) and x * r[at + 1][1] * k >= mul:
            at += 1
        if at >= 0 and ans < r[at][0] - i - 1:
            ans = r[at][0] - i - 1
    print(ans)
main()


Measured memory_bytes: 149764
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  string str;
  cin>>str;
  int fr=-1,to=-1;
  for(int i=0;i<str.size()-1;i++){
    if(str[i]==str[i+1]){
      fr=i+1;to=i+2;
      break;
    }
  }
  for(int i=0;i<str.size()-2;i++){
    if(str[i]==str[i+2]){
      fr=i+1;to=i+3;
      break;
    }
  }
  cout<<fr<<" "<<to<<endl;
  return 0;
}


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

int main() {
	int t;
	cin>>t;
	int arr[t],brr[t-1];
	int count=0;
	for(int i=0;i<t-1;i++){
		cin>>brr[i];
	}
  arr[0]=brr[0];
  arr[t-1]=brr[t-2];
	for(int i=1;i<t-1;i++){
		
			arr[i]=min(brr[i-1],brr[i]);
		
	}
  for(int i=0;i<t;i++){
  count+=arr[i];
  }
	cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

N, M = map(int, input().split())
nAC = [False for i in range(N)]
nWA  = [0 for i in range(N)]

for i in range(M):
    p, S = map(str, input().split())
    p = int(p) - 1

    if S == 'AC':
        if nAC[p]:
            pass
        else:
            nAC[p] = True
    else: #WA
        if nAC[p]:
            pass
        else:
            nWA[p] += 1

for i in range(N):
    if nAC[i]:
        pass
    else:
        nWA[i] = 0

print(sum(nAC), sum(nWA))

Measured memory_bytes: 14272
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 C = sc.nextInt();
    int D = sc.nextInt();
    System.out.println(Math.max(A * B, C * D));
  }
}

Measured memory_bytes: 9804
#include<bits/stdc++.h>
using namespace std;
long long powe(long long x , long long y , long long mod){
    long long ans = 1;
    while(y > 0){
        if(y & 1LL){
            ans = ans % mod * x % mod;
            ans = ans % mod;
        }
        y >>= 1LL;
        x = x % mod * x % mod;
        x = x % mod;
    }
    return ans;
}
long long ncr(long long n , long long r , long long mod){
    long long ans = 1 , i;
    if(r > n - r)
        r = n - r;
    for(i = 0 ; i < r ; i++){
        ans = ans % mod * (n - i) % mod;
        ans = ans % mod;
        ans = ans % mod * powe(i + 1 , mod - 2 , mod) % mod;
        ans = ans % mod;
    }
    return ans;
}
int main(){
    long long n , a , b , ans , mod = 1e9+7;
    cin >> n >> a >> b;
    ans = powe(2LL , n , mod) ;
    ans = ans - 1LL;
    ans = (ans + mod) % mod;
    ans = ans - ncr(n , a , mod) + mod;
    ans = ans % mod;
    ans = ans - ncr(n , b , mod) + mod;
    ans = ans % mod;
    cout << ans ;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
#include <chrono>
#include <cstdlib>
#include <bitset>
using namespace std;
int main(){
    char x[6];
    for(int i = 0; i < 6; i++) cin >> x[i];
    //for(int i = 0; i < 6; i++) cout << x[i] << endl;
    if(x[3] == x[2] and x[5] == x[4]) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if(a==5 && b==5 && c==7)
      printf("YES");
  
  else if(a==5 && c==5 && b==7)
         printf("YES");
  
  else if(a==7 && b==5 && c==5)
         printf("YES");
  
  else 
     printf("NO");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  string s;
  cin >> k >> s;
  cout << s.substr(0, k);
  if (s.size() > k)
    cout << "...";
  cout << endl;
  return 0;
}

Measured memory_bytes: 3656
import qualified Data.Map.Strict as Map
import Control.Applicative

main :: IO ()
main = do
  _ <- getLine
  s <- Map.fromList . map (\k -> (read k, 1)) . words <$> getLine
  _ <- getLine
  t <- map read . words <$> getLine
  let ans = solve s t
  print ans

solve :: Map.Map Int Int -> [Int] -> Int
solve s t = length $ filter (`Map.member` s) t



Measured memory_bytes: 89128
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int N; cin>>N;
	vector<int> A(N);
	vector<int> ans(N);
	for(int i=0;i<N;i++){
		cin>>A.at(i);
		ans.at(A.at(i)-1) = i+1;
	}

	for(int i=0;i<N;i++){
		cout<<ans.at(i);
		if(i!=N-1){
			cout<<" ";
		}else{
			cout<<endl;
		}
	}
}


Measured memory_bytes: 1664
import Control.Applicative

data Dice = Dice { diceTop    :: String
                 , diceFront  :: String
                 , diceRight  :: String
                 , diceLeft   :: String
                 , diceBack   :: String
                 , diceBottom :: String
                 } deriving Show

makeDice :: [String] -> Dice
makeDice (t:f:r:l:b:bo:[]) = Dice t f r l b bo

diceToN :: Dice -> Dice
diceToN dice = dice { diceTop    = diceFront dice
                    , diceFront  = diceBottom dice
                    , diceBottom = diceBack dice
                    , diceBack   = diceTop dice
                    }

diceToS :: Dice -> Dice
diceToS dice = dice { diceTop    = diceBack dice
                    , diceFront  = diceTop dice
                    , diceBottom = diceFront dice
                    , diceBack   = diceBottom dice
                    }

diceToE :: Dice -> Dice
diceToE dice = dice { diceTop    = diceLeft dice
                    , diceLeft   = diceBottom dice
                    , diceBottom = diceRight dice
                    , diceRight  = diceTop dice
                    }

diceToW :: Dice -> Dice
diceToW dice = dice { diceTop    = diceRight dice
                    , diceLeft   = diceTop dice
                    , diceBottom = diceLeft dice
                    , diceRight  = diceBottom dice
                    }

diceMoveTo :: Char -> Dice -> Dice
diceMoveTo 'N' = diceToN
diceMoveTo 'S' = diceToS
diceMoveTo 'E' = diceToE
diceMoveTo 'W' = diceToW

diceMoves :: String -> Dice -> Dice
diceMoves []     dice = dice
diceMoves (s:ss) dice = diceMoves ss $ diceMoveTo s dice

main :: IO ()
main = do
    nums <- words <$> getLine
    dirs <- getLine
    putStrLn $ diceTop (diceMoves dirs $ makeDice nums)



Measured memory_bytes: 3508
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<queue>
#include<stack>
#include<iomanip>
#include<cstring>
#include<string>
#include<set>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll = long long int;

const ll INF = 1<<30;
const ll LINF = 1LL<<60;
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 main(void) {
    int x, y; cin >> x >> y;
    bool t = false;
    for (int i = 0; i <= x; i++) {
        if (i * 2 + (x - i) * 4 == y) t = true;
    }
    if (t) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3632
def main():
    N, A, B = map(int, input().split())
    ans = 0
    for n in range(1, N+1):
        temp = n
        sum = 0
        while n > 0:
            sum += n % 10
            n = int(n / 10)
        if sum >= A and B >= sum:
            ans += temp
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = gets.to_i
until n == 0
    tate = Array.new(n,0)
    n.times do
        x = gets
        y = x.split(" ")
        z = y.map{|a| a.to_i}
        yokosum = z.sum
        i = 0
        while i < n
            tate[i] += z[i]
            i += 1
        end
        z << yokosum
        wwans1 = z.map{|w| w.to_s}
        wans1 = wwans1.map{|w| w.rjust(5," ")}
        ans1 = wans1.join
        puts ans1
    end
    tatesum = tate.sum
    tate << tatesum
    wwans2 = tate.map{|w| w.to_s}
    wans2 = wwans2.map{|w| w.rjust(5," ")}
    ans2 = wans2.join
    puts ans2
    n = gets.to_i
end



Measured memory_bytes: 6900
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
struct _IO { _IO() { ios::sync_with_stdio(0); cin.tie(0); } }_io;
typedef long long ll; typedef long double db;

int main()
{
	int H, W, M;
	cin >> H >> W >> M;
	vector<int> h(H + 1, 0), w(W + 1, 0);
	vector<pair<int, int>> pii;

	for (int i = 1; i <= M; ++i)
	{
		int a, b;
		cin >> a >> b;
		pii.push_back({ a,b });
		++h[a];
		++w[b];
	}
	ll hcnt = 0, wcnt = 0, pcnt = 0;
	ll mh = *max_element(h.begin(), h.end());
	ll mw = *max_element(w.begin(), w.end());
	for (int i = 1; i <= H; ++i) if (h[i] == mh) ++hcnt;
	for (int i = 1; i <= W; ++i) if (w[i] == mw) ++wcnt;
	for (auto i : pii) if (h[i.first] == mh && w[i.second] == mw) ++pcnt;

	if (pcnt == hcnt * wcnt) cout << mh + mw - 1 << endl;
	else cout << mh + mw << endl;

	return 0;
}

Measured memory_bytes: 9772
n,k=map(int,input().split())
p=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=[]
for i in range(n):
  ct=0
  score=0
  s=[]
  pos=i
  while ct<k:
    ct+=1
    pos=p[pos]-1
    score+=c[pos]
    s.append(score)
    if pos==i:
      break
  if s[-1]<0:
    ans.append(max(s))
  elif pos!=i:
    ans.append(max(s))
  elif k%len(s)==0:
    ans.append(s[-1]*(k//len(s)-1)+max(s))
  else:
    ans.append(max(s[-1]*(k//len(s)-1)+max(s),s[-1]*(k//len(s))+max(s[0:k%len(s)])))
print(max(ans))

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

int main(){
 int n ,a;
 int flag=0;
 cin >> n;
 for(int i=0;i<n;i++){
 	cin >> a;
   	if(a!=i+1) flag++;
 }
  
 if(flag==0||flag==2){
   cout << "YES" << endl;
 }else{
   cout << "NO" << endl;
 }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int_fast64_t;
#define rep(i, N) for(int (i) = 0; (i) < (N); (i)++)
#define all(v) (v).begin(), (v).end()
#define eb emplace_back
#define Cout(s) cout << s << endl
string Yes(bool b) {if(b){return "Yes";} else {return "No";}}
string YES(bool b) {if(b){return "YES";} else {return "NO";}}


int main(){
	int R, G;
	cin >> R >> G;
	Cout(2*G - R);
}


Measured memory_bytes: 256
using System;

namespace ALDS1
{
    class Program
    {
        private static int Prime(int a)
        {
            for(int i = 2; i <= Math.Sqrt(a); i++)
                if (a % i == 0) return 0;
            return 1;
        }

        static void Main()
        {
            int c = 0;
            int l = int.Parse(Console.ReadLine());
            for(int j = 0; j < l; j++)
                c += Prime(int.Parse(Console.ReadLine()));
            Console.WriteLine(c);
        }
    }
}

Measured memory_bytes: 9228
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define pi pair<int, int>

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	long long a, b, k;
	cin >> a >> b >> k;
	
	long long d = min(a, k);
	a -= d, k -= d;
	
	b -= min(b, k);
	
	cout << a << " " << b << endl;

	return 0;
}

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

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

    if (n % 1000 == 0)
        cout << 0 << endl;
    else
        cout << 1000 - n % 1000 << endl;
    return 0;
}


Measured memory_bytes: 3632
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
//#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> p(n);
	rep(i,n){
		cin >> p[i];
	}
	sort(p.rbegin(),p.rend());
	int sum = 0;
	p[0] /= 2;
	rep(i,n){
		sum += p[i];
	}
	cout << sum << '\n';
	return 0;	
}


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


void solve(std::string S){
  if(S[0]=='S'){
    cout<<"Cloudy"<<endl;
  } else if(S[0]=='C'){
    cout<<"Rainy"<<endl;
  } else{
    cout<<"Sunny"<<endl;
  }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}

Measured memory_bytes: 256
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
 c,s,f = map(int, input().split())
 C.append(c)
 S.append(s)
 F.append(f)

results = []
for i in range(N):
    x = 0
    for n in range(i, N-1):
        if x < S[n]:
            x = S[n]
        if not (x - S[n]) % F[n] == 0:
            x += F[n] - (x - S[n]) % F[n]
        x += C[n]
    results.append(x)

for result in results:
    print(result)

Measured memory_bytes: 3188
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define ll long long
using namespace std;
const long long INF = 1LL << 61;

// 状態が必要なときはこのPに複数の状態を入れておく
typedef pair<ll, ll> P;

// 入力
ll N, M;
ll sx, sy;  // start地点の座標
ll gx, gy;  // goal地点の座標
// ll d[MAX_N][MAX_M];
ll d[1000][1000];
char maze[1000][1000];
// 移動さきの四方向のベクトル
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// 移動さきの四方向のベクトル
int ldx[20] = {
    -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2,
};
int ldy[20] = {
    -2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2,
};

void printD() {
  cout << "--------------------------------" << endl;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < M; j++) {
      if (d[i][j] != INF) {
        cout << d[i][j] << " ";
      } else {
        cout << "-1"
             << " ";
      }
    }
    cout << endl;
  }
  cout << "--------------------------------" << endl;
}
queue<P> stock;

ll depth = 0;

ll bfs() {
  queue<P> que;
  // スタート地点をqueに入れてその点の距離を0にする
  que.push(P(sx, sy));
  stock.push(P(sx, sy));
  d[sx][sy] = depth;
  while (que.size()) {
    P p = que.front();
    que.pop();
    // 取り出してきた位置がゴールならば探索をやめる
    if (p.first == gx && p.second == gy) {
      break;
    }
    // 四方向をループ
    for (int i = 0; i < 4; i++) {
      ll nx = p.first + dx[i];
      ll ny = p.second + dy[i];

      // 移動が可能かとすでに訪れたことがあるかの判定
      if (0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#' &&
          d[nx][ny] == INF) {
        // 移動できるのであればqueに入れてその点からの距離をpからの距離+1で確定する
        que.push(P(nx, ny));
        stock.push(P(nx, ny));

        d[nx][ny] = depth;
      }
    }
  }
  return d[gx][gy];
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N >> M;
  cin >> sx >> sy;
  cin >> gx >> gy;
  sy--;
  sx--;
  gy--;
  gx--;
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < M; j++) {
      cin >> maze[i][j];
    }
  }
  for (ll i = 0; i < N; i++) {
    for (ll j = 0; j < M; j++) {
      d[i][j] = INF;
    }
  }
  queue<P> next;
  // bfsをする
  ll res = bfs();
  while (1) {
    // 0の位置を探す
    depth++;
    if (stock.size() == 0) {
      break;
    }
    while (stock.size()) {
      P p = stock.front();
      stock.pop();
      // 四方向をループ
      for (int i = 0; i < 20; i++) {
        ll nx = p.first + ldx[i];
        ll ny = p.second + ldy[i];

        // 移動が可能かとすでに訪れたことがあるかの判定
        if (0 <= nx && nx < N && 0 <= ny && ny < M && maze[nx][ny] != '#' &&
            d[nx][ny] == INF) {
          // 移動できるのであればqueに入れてその点からの距離をpからの距離+1で確定する
          next.push(P(nx, ny));
          d[nx][ny] = depth;
        }
      }
    }
    if (next.size() == 0) {
      break;
    }
    while (next.size()) {
      P p = next.front();
      next.pop();
      sx = p.first;
      sy = p.second;
      ll result = bfs();
    }
  }
  ll ans = d[gx][gy];
  if (d[gx][gy] != INF) {
    cout << d[gx][gy] << endl;
  } else {
    cout << -1 << endl;
  }
}

Measured memory_bytes: 12600
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#include <iterator>
#include <chrono>
#include <stack>
#define MOD 1000000007
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second
#define PI 3.1415926535

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int n, a, b, c, d;
	string s;

	cin >> n >> a >> b >> c >> d >> s;

	vector<int> twoRock(n + 1);

	for (int i = a; i < c; i++)
	{
		if (s[i - 1] == '#' && s[i] == '#')
		{
			printf("No\n");
			return 0;
		}
	}

	for (int i = b; i < d; i++)
	{
		if (s[i - 1] == '#' && s[i] == '#')
		{
			printf("No\n");
			return 0;
		}
	}

	if (c < d)
	{
		printf("Yes\n");
		return 0;
	}

	for (int i = b - 1; i <= d - 1; i++)
	{
		if (s[i - 1] != '.' || s[i] != '.' || s[i + 1] != '.')
			continue;

		printf("Yes\n");
		return 0;
	}
	
	printf("No\n");
	return 0;
}

Measured memory_bytes: 1284
#include "bits/stdc++.h"
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
#define db(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<'\n'
const int inf = 1e9+7;
const int N = 1e6+9;

int main() {
    ios_base::sync_with_stdio(0);
    int a,b,n;
    string s;
    cin>>n;
    cin>>s;
    s = "$"+s;
    int cnt=0;
    for(int i=1, j=n;i<j;) {
        if(s[i]=='W' && s[j]=='R') {
            ++cnt;
            ++i, --j;
        }
        else {
            if(s[i]=='R') ++i;
            if(s[j]=='W') --j;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 3852
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <array>
#include <vector>
#include <utility>
#include <bitset>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <numeric>

using namespace std;

using ll = long long;
using p = pair<ll, ll>;

constexpr ll INF = 1LL << 62;
constexpr ll MOD = 1e9 + 7;

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

    string S;
    cin >> S;

    ll l = 0, r = S.size() - 1;
    ll count = 0;
    while (l < r) {
        bool lx = S[l] == 'x';
        bool rx = S[r] == 'x';

        if (lx && rx) {
            l++;
            r--;
        } else if (lx) {
            count++;
            l++;
        } else if (rx) {
            count++;
            r--;
        } else if (S[l] == S[r]){
            l++;
            r--;
        } else {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 512
// Problem : D - Floor Function
// Contest : AtCoder - AtCoder Beginner Contest 165
// URL : https://atcoder.jp/contests/abc165/tasks/abc165_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;

signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int a,b,n;
		cin>>a>>b>>n;
		int x;
		if(n>=b)
		x = b-1;
		else if(n<b)
		x = n;
		int ans = (a*x)/b  - a*(x/b);
		//cout<<x;
		cout<<ans<<"\n";    	
    }
    return 0;
}



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

int N;
string s[100000];

int main() {
    cin >> N;

    map<string, long long> mp;
    rep(i, N) {
        string tmp; cin >> tmp;
        sort(tmp.begin(), tmp.end());
        mp[tmp]++;
    };

    long long ans = 0;
    for (auto iter = mp.begin(); iter != mp.end(); iter++) {
        if (iter->second < 2) continue;
        // cout << iter->first << " " << iter->second << endl;
        ans += (iter->second) * (iter->second - 1) / 2;
    }

    cout << ans << endl;
}

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

int main() {
  //気合で入力を受け取る
  int N,M;
  cin >> N;
  vector<string> S(N);
  for (int i=0;i<N;i++){
    cin >> S.at(i);
  }
  cin >> M;
  vector<string> T(M);
  for (int j=0;j<M;j++){
    cin >> T.at(j);
  }
  //頑張って点数を調べる
  vector<int> Ans(N+1,0);
  for (int i=0;i<N;i++){
    for (int j=0;j<N;j++){
      if (S.at(i)==S.at(j)){
        Ans.at(i)++;
      }
    }
    for (int j=0;j<M;j++){
      if (S.at(i)==T.at(j)){
        Ans.at(i)--;
      }
    }
  }
  cout << *max_element(Ans.begin(), Ans.end()) << endl;
}

Measured memory_bytes: 256
import copy
import collections
import math
 
N = int(input())
A = [int(i) for i in input().split()] 
 
maxnum = max(A)
lis = [-1] * maxnum
bigC = collections.Counter(A)
for i, a in enumerate(A):
  if lis[a-1] < 0:
    newA = copy.deepcopy(A)
    newA.pop(i)
    c = collections.Counter(newA)
    total = 0
    for idx in c:
      num = c[idx]
      total += num * (num-1) // 2
      
    lis[a-1] = total
    for x in bigC:
      if bigC[x] == bigC[a]:
        lis[x-1] = total
      
    print(total)
  else:
    print(lis[a-1])

Measured memory_bytes: 134136
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main() {
	int A, B;
	cin >> A >> B;

	if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
		cout << "Possible" << endl;
	} else {
		cout << "Impossible" << endl;
	}

	return 0;
}

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

int main() {
  int N,K,sum=0;
  cin >> N >> K;
  vector<int> vec(N);
  for(int i=0; i<N; i++) {
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());
  for(int i=0; i<K; i++) {
    sum+=vec[i];
  }
  cout << sum << endl;
}


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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, m;
string s;

int main() {
    cin >> n;
    Msi m;
    REP(i, n) {
        string s;
        cin >> s;
        if (m.count(s) == 0) {
            m[s] = 1;
        } else {
            m[s]++;
        }
    }

    int maxi = 0;
    FOR(i, m) {
        maxi = max(maxi, i->second);
    }

    Vs v;
    FOR(i, m) {
        if (i->second == maxi) {
            v.push_back(i->first);
        }
    }

    sort(ALL(v));

    FOR(i, v) {
        std::cout << *i << '\n';
    }

    return 0;
}


Measured memory_bytes: 26868
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
#define rnt re int
#define re register
#define I inline int
#define V inline void
#define isnum(ch) ('0'<=ch&&ch<='9')
#define FOR(i,a,b) for(rnt i=a;i<=b;i++)
#define ROF(i,a,b) for(rnt i=a;i>=b;i--)
#define gc (_op==_ed&&(_ed=(_op=_buf)+fread(_buf,1,100000,stdin),_op==_ed)?EOF:*_op++)
char _buf[100000],*_op(_buf),*_ed(_buf);
I getint(){
	rnt _s=0;re char _ch=gc;
	while(!isnum(_ch))_ch=gc;
	while(isnum(_ch))_s=_s*10+_ch-48,_ch=gc;
	return _s;
}
const int N=1e5+1,mod=998244353;
int n,dis[N],cnt[N];
V input(){
	n=getint();
	FOR(i,1,n)cnt[dis[i]=getint()]++;
}
V init(){
}
V work(){
	if(dis[1]!=0)return void(cout<<0);
	FOR(i,2,n)if(dis[i]==0)
		return void(cout<<0);
	int ans=1;
	FOR(i,2,n)
		ans=1ll*ans*cnt[dis[i]-1]%mod;
	cout<<ans;
}
int main(){
//	freopen("test.in","r",stdin);
//	freopen(".out","w",stdout);
	input();
	init();
	work();
	return 0;
}

Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
	char num_str[1002];
	int num;
	long sum = 0;
	int i;
	char tmp;
	
	while (1)
	{
		fgets(num_str,sizeof(num_str),stdin);
		if (num_str[0] == '0') break;
		for (i = 0; i < strlen(num_str)-1; i++)
		{
			tmp = num_str[i];
			num = atoi(&tmp);
			sum = sum + num;
		}
		printf("%ld\n",sum);
		sum = 0;
		memset(num_str,1002,0);
	}
	return 0;
}

Measured memory_bytes: 532
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(a + 1):
    # 500円玉の枚数を1枚ずつ増やす

    if x < (i * 500) :
        break

    for j in range(b + 1):
        # 100円玉の枚数を1枚ずつ増やす

        if x < ((i * 500) + (j * 100)):
            break

        for k in range(c + 1):
            # 50円玉の枚数を1枚ずつ増やす

            # print("500円玉 : {0} 枚".format(i))
            # print("100円玉 : {0} 枚".format(j))
            # print("50円玉  : {0} 枚".format(k))

            if x < (i * 500) + (j * 100) + (k * 50):
                break

            if (i * 500) + (j * 100) + (k * 50) == x :
                ans += 1
                # print('OK')

print(ans)


Measured memory_bytes: 8964
#include <iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl

using namespace std;
using ll = long long;


int main() {
    int n;
    ll Y;
    cin >> n >> Y;

    int tmpz = Y / 1000;

    int x = -1;
    int y = -1;
    int z = -1;
    if (tmpz == n) {
        z = tmpz;
        x = 0;
        y = 0;
    } else {
        for (int i = 0; i <= tmpz; ++i) {
            for (int j = 0; j <= tmpz; ++j) {
                if (i + j > tmpz) break;
                if (tmpz - (9 * i) - (4 * j) == n) {
                    x = i;
                    y = j;
                    z = n - i - j;
                    if (x >= 0 && y >= 0 && z >= 0) break;
                    else {
                        x = -1;
                        y = -1;
                        z = -1;
                    }
                }
            }
        }
    }
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
template<typename T> void read(T &num){
	char c=getchar();T f=1;num=0;
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){num=(num<<3)+(num<<1)+(c^48);c=getchar();}
	num*=f;
}
template<typename T> void qwq(T x){
	if(x>9)qwq(x/10);
	putchar(x%10+'0');
}
template<typename T> void write(T x){
	if(x<0){x=-x;putchar('-');}
	qwq(x);putchar('\n');
}
inline int gcd(int n,int m){
	return ((!m)?n:gcd(m,n%m));
}

int main(){
	int x;read(x);
	write(360/gcd(x,360)); 
	return 0;
}

Measured memory_bytes: 3644
N,K=map(int,input().split())
t=list(map(int,input().split()))
g=[1]
for i in range(N-1):
  g.append(t[g[i]-1])
if K>len(g):
  a=g.index(g[-1])
  b=len(g)-a-1
  K=(K-a)%b+a
print(g[K])

Measured memory_bytes: 32352
#include <bits/stdc++.h>
using namespace std;
#define long long long
#define read cin >>
#define echo cout <<
#define fin << endl
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)

// for debug macro
bool global_debug_flag = true;
#define DEBUG(val) \
  if (global_debug_flag) cout << #val << " = " << val << endl

bool judge(char s1, char s2, char s3, string str, int len) {
  int count = 0;
  int i = 0;
  for (; i < len; i++) {
    if (str[i] == s1) {
      count++;
      i++;
      break;
    }
  }
  for (; i < len; i++) {
    if (str[i] == s2) {
      count++;
      i++;
      break;
    }
  }
  for (; i < len; i++) {
    if (str[i] == s3) {
      count++;
      i++;
      break;
    }
  }
  return (count == 3);
}

int main() {
  int n;
  string s;
  cin >> n >> s;
  unordered_map<string, int> mp;
  REP(i, 10) {
    REP(j, 10) {
      REP(k, 10) {
        if (judge(i + '0', j + '0', k + '0', s, n)) {
          string s1;
          s1 = i + '0';
          string s2;
          s2 = j + '0';
          string s3;
          s3 = k + '0';
          mp[s1 + s2 + s3] += 1;
        }
      }
    }
  }
  cout << mp.size() << endl;
}


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

int main(){
  int A, B;
  cin >> A >> B;
  
  if ((A + B) % 2 == 0) {
    cout << (A + B) / 2 << endl;
  }

  else {
    cout << "IMPOSSIBLE" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#define pb push_back
#define ll long long
#include<bits/stdc++.h>
using namespace std;
int n, q;
string cmd;
struct node{
	node *l, *r;
	int key = 0;
	node(int k){
		key = k;
		l = r = NULL;
	}
};
node* insert(node* r, int key){
	if(r == NULL || r->key == key) return new node(key);
	if(r->key > key){
		r->l = insert(r->l, key);
	}else r->r = insert(r->r, key);
	return r;
}
void pre(node* r){
	if(!r) return;
//	if(ff) cout << " ";
	printf(" %d", r->key); 
	pre(r->l);
	pre(r->r);
}
void in(node* r){
	if(!r) return;
	in(r->l);
	printf(" %d", r->key); 
	in(r->r);
}
int cc = 0;
node* root = NULL;
bool search(int key, node* r){
	if(r == NULL) return false;
	if(r->key == key) return true;
	if(r->key > key) return search(key, r->l);
	else return search(key, r->r);
}
void solve(){
	root = NULL;
	cc = 0;
	cin >> q;
	while(q--){
		cin >> cmd;
		if(cmd[0] == 'i'){
			int x; cin >> x;
		//	cout << cmd << " " << x << endl;
			root = insert(root, x);
		}else if(cmd[0] == 'p'){
			in(root); 
			cout << endl;
			pre(root);
			cout << endl;
//			bool ok = false;
//			if(cc != 0) cout << endl, ok = true;
//			cc++;
//			if(q == 0 && ok == false) cout << endl;
		}else{
			int x; cin >> x;
			bool ok = search(x, root);
			if(ok) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
	//cout << "root: " << root->key << endl;
}
int main(){
	solve();
	return 0;
}


Measured memory_bytes: 15796
program sum_of_gcd_of_tuples_easy
  implicit none
  integer(8) :: k, a, b, c, s = 0_8, g
  read(*,*) k
  do a = 1_8, k
    do b = 1_8, k
      g = gcd(a,b)
      do c = 1_8, k
        s = s+gcd(g,c)
      end do
    end do
  end do
  write(*,'(i0)') s
contains
  integer(8) function gcd(a,b)
    integer(8), intent(in) :: a, b
    integer(8) :: x, y
    x = max(abs(a),abs(b))
    y = min(abs(a),abs(b))
    do while (y > 0)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
end program sum_of_gcd_of_tuples_easy

Measured memory_bytes: 2924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  yn       cout<<"Yes\n"; else cout<<"No\n";
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;
const ll LINF = 1e18;


int main()
{
    char c;
    int a=700;
    rep(i,3)cin>>c,a+=(c=='o')*100;
    cout<<a<<endl;
    return 0;
}


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

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

  vector<ll> A(3, 0);
  for (int i = 0; i < 3; i++) {
    cin >> A[i];
  }
  ll K; cin >> K;
  sort(A.begin(), A.end());
  ll ans = A[2];
  for (int i = 0; i < K; i++) {
    ans *= 2;
  }
  ans += (A[0] + A[1]);
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
N, C, K = map(int, input().split())
T = [int(input()) for i in range(N)]
T.sort()
#print(T)
Bcnt = 0
i = 0
while True:
    if len(T) <= i:
        break
    BS = T[i] + K
    Bcnt += 1
    i += 1
    cnt = 1
    while cnt < C and len(T) > i:
        if T[i] <= BS:
            i += 1
            cnt += 1
        else:
            break
print(Bcnt)


Measured memory_bytes: 7440
#include <bits/stdc++.h>
using namespace std;/*
long double X;
bool check(long double x){
    if (X <= 100 * pow(1.01,x) ) return true;
    else return false;
}

int main() {
    cin >> X;
    long double lo =1, hi =4000;
    for (int i =0; i<100; ++i){
        long long mid = (lo+hi)/2;
        if (check(mid)) hi=mid;
        else lo=mid;
    }
    cout << hi;
}*/
int main(){
    long long X,control=100,i=0;
    cin >> X;
    while (control<X){
        control+= 0.01*control;
        ++i;
    }
    cout << i;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree < pairs ,  null_type , greater<pairs>,  rb_tree_tag ,  tree_order_statistics_node_update > 
#define ll long long
#define lld long double
#define vc vector<ll>
const ll MOD=(1e9 +7);
typedef pair<ll,ll>pairs;
ll power(ll a, ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;b--;}a=(a*a)%MOD;b>>=1;}
    return res;}

int main() {
	// your code goes here
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	ll t,n,i,j,k,l,c,f,a,b;
	cin>>a>>b>>c>>k;f=1;
	while((k>0)&&(b<=a))
	{
	    b*=2;
	    k--;}
	while((k>0)&&(c<=b))
	{
	    c*=2;k--;}
	if((c>b)&&(b>a))cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 3648
#define max(a,b)(a>b?a:b)
a[5][5];main(n,i,j,k,l,m,M){
	for(scanf("%d",&n);n--;printf("%d\n",M)){
		for(i=0;i<5;i++)for(j=0;j<5;j++)scanf("%d",a[i]+j);
		for(M=i=0;i<5;i++)for(j=0;j<5;j++){
			for(k=i;k<5;k++){
				if(!a[k][j])break;
				for(l=j;l<5;l++){
					for(m=i;m<=k;m++){
						if(!a[m][l])goto end;
					}
				}
				end:
				l-=1;
				M=max(M,(k-i+1)*(l-j+1));
			}
		}
	}
exit(0);}

Measured memory_bytes: 600
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int cnt[200001];
int par[200001];
ll fact[200001]={1,};
ll inv[200001];
ll dp[200001];
ll rdp[200001];
vector<vector<int> > map;
const ll M = 1000000007;
ll modpow(ll a, ll n){
	ll ret = 1;
	for(int i=0;i<=30;i++){
		if(n&(1<<i)) ret=(a*ret)%M;
		a=(a*a)%M;
	}
	return ret;
}

int dfs(int x){
	cnt[x] = 1;
	for(int nx : map[x]){
		if(nx!=par[x]){
			par[nx] = x;
			cnt[x] += dfs(nx);
		}
	}
	return cnt[x];
}

ll sol(int x){
	if(dp[x]) return dp[x];
	ll ret = fact[cnt[x]-1];
	for(int nx : map[x]){
		if(nx!=par[x]){
			ret = (ret*sol(nx))%M;
			ret = (ret*inv[cnt[nx]])%M;
		}
	}
	return dp[x] = ret;
}
ll rsol(int x){
	if(rdp[x]) return rdp[x];
	ll ret = fact[N-1];
	for(int nx : map[x]){
		if(nx == par[x]){
			ll tmp[] = {rsol(nx),inv[N-1],fact[N-1-cnt[x]],fact[cnt[x]],modpow(sol(x),M-2),inv[N-cnt[x]]};
			for(int i=0;i<6;i++){
				ret *= tmp[i];
				ret %= M;
			}
		}
		else{
			ret = (ret*sol(nx))%M;
			ret = (ret*inv[cnt[nx]])%M;
		}
	}
	return rdp[x] = ret;
}
int main(){
	for(int i=1;i<=200000;i++) fact[i] = (fact[i-1]*i)%M;
	inv[200000] = modpow(fact[200000],M-2);
	for(int i=200000;i>0;i--) inv[i-1] = (inv[i]*i)%M;
	scanf("%d",&N);
	map.resize(N+1);
	for(int i=0;i<N-1;i++){
		int a,b;
		scanf("%d %d",&a,&b);
		map[a].push_back(b);
		map[b].push_back(a);
	}
	dfs(1);
	for(int i=1;i<=N;i++){
		printf("%lld\n",rsol(i));
	}
}

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

int main(){
    int n;
    int a;
    int num=-1000000;
    int ave=1000000;
    long sum=0;
    cin>>n;
    for(int i=0; i<n; i++){
        cin>>a;
        if(a>num)num=a;
        if(a<ave)ave=a;
        sum+=a;
    }
    cout<<ave<<" "<<num<<" "<<sum<<endl;
    return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  int ans=0;
  
  for(int i=0;i<n;i++){
    vector<int> a(26);
    vector<int> b(26);
    for(int j=0;j<i;j++) a.at(s.at(j)-'a')++;
    for(int j=i;j<n;j++) b.at(s.at(j)-'a')++;
    
    int k=0;
    for(int j=0;j<26;j++){
      if(a.at(j)*b.at(j)) k++;
    }
    
    ans=max(ans,k);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256