akhauriyash/Code-Regression huggingface dataset:
# jsc2019-qualB - Kleene Inversion
class BIT:  # Binary Indexed Tree (Fenwick Tree)
    def __init__(self, lim):
        self.size = lim
        self.tree = [0] * (lim + 1)  # 1-idx

    def add(self, i, x):  # add x to tree[i], O(logN)
        while i <= self.size:
            self.tree[i] += x
            i += i & -i

    def sum(self, i):  # sum of [1, i], O(logN)
        ret = 0
        while i > 0:
            ret += self.tree[i]
            i -= i & -i
        return ret

    def range_sum(self, l, r):  # range sum of [l, r]
        return self.sum(r) - self.sum(l - 1)


def main():
    N, K = tuple(map(int, input().split()))
    A = tuple(map(int, input().split()))
    MOD = 10 ** 9 + 7
    bit = BIT(2000)
    x = 0
    for i, a in enumerate(A, 1):  # internal inversion
        bit.add(a, 1)
        x += i - bit.sum(a)
    y = -x
    for i, a in enumerate(A, 1):  # external inversion
        bit.add(a, 1)
        y += i + N - bit.sum(a)
    ans = (x * K + y * K * (K - 1) // 2) % MOD
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
n = int(input())
w = [int(i) for i in input().split()]

A = []
for i in range(1,n):
  s_1 = sum(w[:i])
  s_2 = sum(w[i:])
  tmp = abs(s_1 - s_2)
  A.append(tmp)

print(min(A))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <string>
#include <functional>
#include <algorithm>
using namespace std;

string cards[10];
set<string> s;
vector<int> vi, vi2;

template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first1 ,
                        BidirectionalIterator last1 ,
                        BidirectionalIterator first2 ,
                        BidirectionalIterator last2 )
{
    if (( first1 == last1 ) || ( first2 == last2 )) {
        return false ;
    }
    BidirectionalIterator m1 = last1 ;
    BidirectionalIterator m2 = last2 ; --m2;
    while (--m1 != first1 && !(* m1 < *m2 )){
    }
    bool result = (m1 == first1 ) && !(* first1 < *m2 );
    if (! result ) {
        // â 
        while ( first2 != m2 && !(* m1 < * first2 )) {
            ++ first2 ;
        }
        first1 = m1;
        std :: iter_swap (first1 , first2 );
        ++ first1 ;
        ++ first2 ;
    }
    if (( first1 != last1 ) && ( first2 != last2 )) {
        // â¡
        m1 = last1 ; m2 = first2 ;
        while (( m1 != first1 ) && (m2 != last2 )) {
            std :: iter_swap (--m1 , m2 );
            ++ m2;
        }
        // â¢
        std :: reverse (first1 , m1 );
        std :: reverse (first1 , last1 );
        std :: reverse (m2 , last2 );
        std :: reverse (first2 , last2 );
    }
    return ! result ;
}

template < class BidirectionalIterator >
bool next_combination ( BidirectionalIterator first ,
                        BidirectionalIterator middle ,
                        BidirectionalIterator last )
{
    return next_combination (first , middle , middle , last );
}

int main()
{
    int n, k;
    while(cin >> n >> k && n && k) {
        s.clear(); vi.clear();
        for(int i = 0; i < n; i++) {
            cin >> cards[i];
            vi.push_back(i);
        }

        int ret = 0;
        do {
            vi2.clear();
            for(int i = 0; i < k; i++) {
                vi2.push_back(vi[i]);
            }
            sort(vi2.begin(), vi2.end());
            do {
                string str = "";
                for(int i = 0; i < k; i++) {
                    str += cards[vi2[i]];
                }
                if(s.find(str) == s.end()) {
                    ret++;
                    s.insert(str);
                }
            } while(next_permutation(vi2.begin(), vi2.end()));
        } while(next_combination(vi.begin(), vi.begin() + k, vi.end()));
        cout << ret << endl;
        
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define endl '\n'
#define int long long int
using namespace std;
#define pii pair <int, int>
#define mii map<int, int>
#define pb push_back
#define deb(x) cout << #x << " " << x << endl
#define deb2(x, y) cout << #x << " " << x << " " << #y << " " << y << endl
#define Loop(s, e, itr) for (int itr = s; itr < e; itr++)
#define loop(n) for(int i = 0; i < n; i++)
#define vin vector<int>
#define w(t) int tc; cin >> tc; for(int t = 1; t <= tc; t++)
#define vec vector
#define mod 1000000007
#define all(x) x.begin(), x.end()

int n, k;
int heights[100005];
int dp[100005];

void solve_itr(){
    cin >> n >> k;
    loop(n) cin >> heights[i+1];
    dp[n] = 0;
    for(int i = n-1; i > 0; i--){
        int temp = INT_MAX;
        for(int j = 1; j <= k; j++){
            if(i+j > n) break;
            temp = min(temp, dp[i+j] + abs(heights[i] - heights[i+j]));
        }
        dp[i] = temp;
    }
    
    cout << dp[1] << endl;
}

int go(int step){
    if(step > n) return INT_MAX;
    if(step == n) return 0;
    if(dp[step] == -1){
        dp[step] = min(
            abs(heights[step] - heights[step+1]) + go(step+1),
            abs(heights[step] - heights[step+2]) + go(step+2)
        );
    }
    return dp[step];
}

void solve_rec(){
    cin >> n >> k;
    loop(n) cin >> heights[i+1];
    memset(dp, -1, sizeof(dp));
    cout << go(1) << endl;
}

int32_t main(){
    solve_itr();
    // solve_rec();
}

Measured memory_bytes: 5172
import java.io.*;
import java.util.Arrays;

class Main{
	public static void main(String[] args) throws Exception{
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(reader.readLine());
		int[] arr = new int[100003];
		for(int i = 0; i < n; i++) {
			String[] input = reader.readLine().split(" ");
			int a = Integer.parseInt(input[0]);
			int b = Integer.parseInt(input[1]);
			arr[a] ++;
			arr[b+1]--;
		}
		for(int i = 0; i < arr.length-1; i++) {
			arr[i+1] += arr[i];
		}

		int result = 0;
		for(int i = 0; i < arr.length-1; i++) {
			if(i<=arr[i]+1) result=i-1;
		}

		System.out.println(result);
	}
}

Measured memory_bytes: 64112
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int a, b, c, k; cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k - a >= 0)
    {
        ans += a;
        k -= a;
    }
    else
    {
        ans += k;
        k = 0;
    }
    if(k == 0)
    {
        cout << ans << endl;
        return;
    }
    if(k - b >= 0)
    {
        k -= b;
    }
    else
    {
        k = 0;
    }
    if(k == 0)
    {
        cout << ans << endl;
        return;
    }
    if(k - c >= 0)
    {
        ans -= c;
        k -= c;
    }
    else
    {
        ans -= k;
        k = 0; 
    }
    cout << ans << endl;
    
    
    
}

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

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
						
#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'
#define int long long

bool check(int val, int k, const vector<int> &a) {
	int n = a.size();
	int cost = 0;
	for (int i = 0; i < n; ++i) {
		if (a[i] > val) {
			cost += (a[i] / val - 1);
			if (a[i] % val) ++cost;
		}
	}
	return cost <= k;
}
				
int32_t main() {
	fast_cin();  
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int &i : a) cin >> i;
	sort(a.begin(), a.end());
	int l = 0, r = a[n - 1] + 1;
	while (r > l + 1) {
		int mid = r + l >> 1;
		if (check(mid, k, a)) r = mid;
		else l = mid;
	}
	cout << r << endl;
	return 0;
}

Measured memory_bytes: 4776
import java.util.Scanner;


public class Main {

    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        if(s.equals("ABC")){
            System.out.println("ARC");
        }else{
            System.out.println("ABC");
        }
        

    }
}

Measured memory_bytes: 35600
#include<stdio.h>
#include<string.h>
typedef struct{
  char name[35];
  int page[1001];
  int flg;
}P;

main(){
  int i=0,j,k,pa,flg2,cnt=0,l,tmp;
  char str[35];
  P index[1000];
  P temp;
  while(scanf("%s %d",str,&pa)!=EOF){
    flg2=0;
    for(j=0;j<cnt;j++){
      if(strcmp(str,index[j].name)==0){
	index[j].page[pa]=1;
	flg2++;
	index[j].flg++;
	break;
      }
    }
    if(flg2==0){
      strcpy(index[cnt].name,str);
      index[cnt].page[pa]=1;
      cnt++;
      index[cnt].flg=1;
    }
  }
  for(i=0;i<cnt-1;i++){
    for(j=cnt-1;j>i;j--){
      if(strcmp(index[j].name,index[j-1].name)<0){
	temp=index[j];
	index[j]=index[j-1];
	index[j-1]=temp;
      }
    }
  }

  for(i=0;i<cnt;i++){
    printf("%s\n",index[i].name);
    for(j=1,tmp=0;j<=1000;j++){
      if(index[i].page[j]==1){
	if(tmp!=0)printf(" ");
	printf("%d",j);
	tmp=1;
      }
    }
    printf("\n");
  }
    
  return 0;
}

Measured memory_bytes: 788
n, m = map(int, input().split())

A = list(map(int, input().split()))

import heapq

A = list(map(lambda x: x*(-1), A))

heapq.heapify(A)

for i in range(m):
    val = heapq.heappop(A)
    val = (-1 * val)//2 * (-1)
    heapq.heappush(A, val)

print(sum(list(map(lambda x: x*(-1), A))))

Measured memory_bytes: 91412
import java.util.*;
import javax.lang.model.util.ElementScanner6;
//import java.lang.Math;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        // 入力
        int k = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        //String s = sc.next();

        // 処理
        String out = "NG";
        if(b/k * k >= a) {
            out = "OK";
        }

        // 出力
        System.out.println(out);
    }
}

Measured memory_bytes: 35980
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        vec[i]=x;
    }
    vector<int> ans(n,-1);
   // bool hantei=1;
    for(int i=n-1;i>=0;i--){
        int count=0;
        int m=i+1;
        int p;
        int k=2;
        while(1){
            p = m*k;
           // cout<<p<<endl;
            if(p>n){
                break;
            }
            count += ans[p-1];
            k++;
          //  cout<< i <<" "<<count<<endl;
        }
        count = count%2;
        if(vec[i]==count){
            ans[i]=0;
        }else{
            ans[i]=1;
        }
    }
    //cout<<ans[3]<<endl;
    int c=0;
    for(int i=0;i<n;i++){
        if(ans[i]==1){
            c++;
        }
    }
    cout<<c<<endl;
    for(int i=0;i<n;i++){
        if(ans[i]==1){
            cout<<i+1<<" ";
        }
    }
    cout<<endl;
}


Measured memory_bytes: 2432
// D - Binomial Coefficients
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vi A(N); rpz(i, N) cin>>A[i];
	sort(all(A));
	int n = A[N-1], r = 0;
	int mindiff = INT_MAX;
	for(int i=N-2; i>=0; --i){
		int diff = abs(n/2 - A[i]);// |⌊n/2⌋ - ai|
		if(mindiff > diff){
			mindiff = diff;
			r = A[i];
		}
	}
	cout<< n <<" "<< r <<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long

    /// 11 55
    /// 13 55 kucanje

    map<int,int> cnt;
    int a[200010];
    vector<int> vec;

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

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

            int  step=1;
            while( step <= a[n-1] ){
                vec.pb( step );
                step*=2;
            }
            vec.pb( step );

            int res=0;

            for( int i=n-1;i>=0;i-- ){
                for( int j = 0;j<vec.size();j++ ){
                 //   cout << a[i] << " " << j << " " << vec[j ]<<endl;
                    if( vec[j] > a[i] ){
                     //   cout << a[i] << " " << vec[j] <<endl;
                     if( a[i] != vec[j]-a[i] ){
                        while( cnt[ a[i] ] > 0 && cnt[ vec[j] - a[i] ] > 0 ){
                            cnt[ a[i] ]--;
                            cnt[ vec[j]-a[i] ]--;
                            res++;
                        }
                     }
                     else{
                        while( cnt[ a[i] ] > 1 ){
                            cnt[ a[i] ]-=2;
                            res++;
                        }
                     }
                        break;
                    }
                }
            }

            cout<<res<<endl;

            return 0;
}































Measured memory_bytes: 19840
#include <iostream>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <numeric>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>


using namespace std;
using ll = long long;
const ll INF = 1e9;

// Kattobi Editorial Rider
// でんででんででんwwwはやいぜ解説www
// ソートして累積和までわかった
int main() {
    int N;
    cin >> N;
    vector<ll> a(N), sum(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    sort(a.begin(), a.end());
    sum[0] = a[0];
    for (int i = 1; i < N; i++) {
        sum[i] = sum[i-1] + a[i];
    }

    int ans = 1;
    for (int i = N - 2; i >= 0; i--) {
        if (sum[i] * 2 >= a[i+1]) {
            ans++;
        } else {
            break;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
	int a,b,c;
	int t = 0;
	cin >> a >> b >> c;
	for(int i = a; i <= b; i++){
		if(c % i == 0) t++;
	}
	
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 3104
import fractions
def c2(a):
    ans = 0
    while True:
        q,r = divmod(a,2)
        if r==0:
             ans+=1
             a = q
        else:break
    return ans
gcd =  fractions.gcd
n,m= map(int,input().split())
A = list(map(lambda x:int(x)//2,input().split()))
A.sort()
ma = 0
cp = c2(A[0])
for i in range(n):
    if cp!=c2(A[i]):
        print(0)
        exit()
lcm = A[0]
for i in range(1,n):
    lcm = A[i]*lcm//gcd(A[i],lcm)

print((m//lcm +1)//2)


Measured memory_bytes: 16316
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
using namespace std;

typedef long long ll;

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

int m[1010];

int main() {
  int n, d, x;
  cin >> n >> d >> x;
  int tmp;
  int res = x;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    for (int j = 1; j <= d; j += tmp) {
      ++res;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
#include <ctype.h>
using namespace std;
int n,p,ans=0;
int main(){
	while(cin>>n){
		if(n==0){break;}
		for(int i=0;i<n/4;i++){
		cin>>p;ans+=p;}
	cout<<ans<<endl;
	ans=0;}
    return 0;}


Measured memory_bytes: 1160
using System;
using System.Text;

namespace AOJ.Volume0
{
    public class EraNameTransformation
    {
        private class Gengo
        {
            public DateTime StartDate { get; set; }
            public DateTime EndDate { get; set; }
            public string Name { get; set; }

            public Gengo(DateTime s, DateTime e, string n)
            {
                StartDate = s;
                EndDate = e;
                Name = n;
            }
        }

        public static int Main()
        {
            var list = new Gengo[4];
            list[0] = new Gengo(DateTime.Parse("1868/9/8"), DateTime.Parse("1912/7/29"), "meiji");
            list[1] = new Gengo(DateTime.Parse("1912/7/30"), DateTime.Parse("1926/12/24"), "taisho");
            list[2] = new Gengo(DateTime.Parse("1926/12/25"), DateTime.Parse("1989/1/7"), "showa");
            list[3] = new Gengo(DateTime.Parse("1989/1/8"), DateTime.MaxValue, "heisei");

            var output = new StringBuilder();
            while (true)
            {
                var input = Console.ReadLine();
                if (string.IsNullOrEmpty(input)) { break; }

                var data = input.Split(' ');
                int y = int.Parse(data[0]);
                int m = int.Parse(data[1]);
                int d = int.Parse(data[2]);
                var tmp = new DateTime(y, m, d);
                if(tmp < list[0].StartDate) { output.AppendLine("pre-meiji"); }
                else
                {
                    Gengo g = null;
                    if(tmp <= list[0].EndDate) { g = list[0]; }
                    else if(tmp <= list[1].EndDate) { g = list[1]; }
                    else if(tmp <= list[2].EndDate) { g = list[2]; }
                    else { g = list[3]; }
                    // ??´????????´
                    y = y - g.StartDate.Year + 1;

                    string era = g.Name + " " + y + " " + m + " " + d;
                    output.AppendLine(era);
                }
            }

            Console.Write(output);
            return 0;
        }
    }
}

Measured memory_bytes: 9908
//............Created by:- Arth Raj...........................//
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define vii vector<pair<int,int>>
#define tez ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define lp(i,a,b) for(int i=a;i<b;i++)
#define rlp(i,a,b) for(int i=b;i>=a;i--)
#define ld long double
#define tl tuple<ll,ll,ll>
#define all(x) (x).begin(),(x).end()
#define bs(x,b) binary_search(all(x),b)
#define vip vector<pair<int,pair<int,int>>>
#define pip pair<int,pair<int,int>>
#define INF 1e18
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
ll abm(ll a, ll b, ll m) {ll ans = 1; a = a % m; while (b > 0) {if (b & 1)ans = (ans * a) % m; a = (a * a) % m; b = b / 2;} return ans % m;}
ll ncr(ll n, ll r, ll m) {if (r == 0)return 1; ll fac[n + 5]; fac[0] = 1; lp(i, 1, n + 1) {fac[i] = fac[i - 1] * i % m;} return (((fac[n] * abm(fac[r], m - 2, m)) % m) * (abm(fac[n - r], m - 2, m))) % m;}
int main()
{
	int n, w;
	cin >> n >> w;
	int wt[n + 1], v[n + 1];
	lp(i, 1, n + 1)
	{
		cin >> wt[i] >> v[i];
	}
	ll dp[n + 1][w + 1];
	lp(i, 0, w + 1)
	{
		dp[0][i] = 0;
	}
	lp(i, 0, n + 1)
	{
		dp[i][0] = 0;
	}
	lp(i, 1, n + 1)
	{
		lp(j, 1, w + 1)
		{
			if ((j - wt[i]) < 0)
				dp[i][j] = dp[i - 1][j]; 
			else
				dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wt[i]] + v[i]);
		}
	}
	cout << dp[n][w] << endl;
	return 0;
}

Measured memory_bytes: 82344
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int ans[] = new int[n];
    for (int i = 0; i < n - 1; i++) {
      int b = Integer.parseInt(sc.next());
      ans[b - 1] += 1;
    }
    Arrays.stream(ans).forEach(pw::println);
  }
}


Measured memory_bytes: 60584
#include <stdio.h>

int main(){
  int x,y,xy;
  int temp;
  scanf("%d",&x);
  scanf("%d",&y);

  if(x < y){
    temp = x;
    x = y;
    y = temp;
  }
  xy = x % y;
  while(xy!=0){
    x = y;
    y = xy;
    xy = x % y;
  }

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



Measured memory_bytes: 2080
#include <iostream>
#include <set>

using namespace std;

int main() {
	int n;
	cin >> n;
	set<int> st;
	int d;
	for (int i = 0; i < n; i++) {
		cin >> d;
		st.insert(d);
	}
	cout << st.size() << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int x = scan.nextInt();
		int y = scan.nextInt();
		int cost = 0;
		for(int i = 0; i < n; i++) {
			if(i < k) {
				cost = cost + x;
			} else {
				cost = cost + y;
			}
		}
		System.out.println(cost);
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    long long sum = 0;
    long long count = 0;
    for(int i = 1; i <= n; i++)
    {
        if(i % 3 == 0 || i % 5 == 0)
        {
            count++;
        }
        else
        {
            sum += i;
        }
        
    }
    cout<<sum;


}

Measured memory_bytes: 3608
//086B
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string a,b;
    int num;
    cin >> a >> b;
    a+=b;
    num = stoi(a);
    if(sqrt(num)==floor(sqrt(num))){
        cout << "Yes";
    }else{
        cout << "No";
    }
}

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

namespace ABC085_B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] array = new int[N];

            for (int i = 0; i < N; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }

            Array.Sort(array);
            int count = 1;
            for (int i = 1; i < N; i++)
            {
                if (array[i] != array[i - 1])
                {
                    count++;
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 27020
import java.util.Scanner;
public class Main {

  public static void reverseSubarray(String[] ary, int i, int j) {
    while (i < j) {
      String temp = ary[i];
      ary[i] = ary[j];
      ary[j] = temp;
      i++;
      j--;
    }
  }

  public static void shuffle(String[] ary, int h) {
    // reverse up to h
    reverseSubarray(ary, 0, h-1);
    // reverse h to end
    reverseSubarray(ary, h, ary.length-1);
    // reverse entire ary
    reverseSubarray(ary, 0, ary.length-1);
  }

  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    String deck = s.next();
    while (!deck.equals("-")) {
      String[] deckAry = deck.split("");
      int nShuffles = s.nextInt();
      for (int i = 0; i < nShuffles; i++) {
        int h = s.nextInt();
        shuffle(deckAry, h);
      }
      System.out.println(String.join("", deckAry));
      deck = s.next();
    }
    s.close();
  }
}



Measured memory_bytes: 26456
def main():
    from collections import defaultdict
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    N, M = map(int, input().split())
    A = map(int, input().split())

    ctr = defaultdict(int)
    for x in A:
        ctr[x] += 1

    for _ in range(M):
        num_of_cards, int_written_on_cards = map(int, input().split())
        ctr[int_written_on_cards] += num_of_cards

    rest = N
    total = 0
    for int_written_on_cards, num_of_cards in sorted(ctr.items(), key=itemgetter(0), reverse=True):
        take = min(rest, num_of_cards)

        total += int_written_on_cards * take
        rest -= take

        if rest == 0:
            break

    print(total)


if __name__ == '__main__':
    main()


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

int main()
{
    int n; cin >> n;
    string s;
    int ac = 0, wa = 0, tle = 0, re = 0;
    for(int i=0; i<n; i++){
        cin >> s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE") tle++;
        else re++;
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll A,B,N;
  cin >> A >> B >> N;
  ll x = min(B - 1,N);
  cout << ((A * x) / B) - (A * (x / B)) << endl;
  return 0;
}

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

int main(){
    long long X;
    cin >> X;

    long long Ans = 0;
    double M = 100;

    while(X > M){
        M*=1.01;
      M = floor(M);
        Ans ++;
    }

    cout << Ans << endl;
}

Measured memory_bytes: 3636
<?php
    fscanf(STDIN,"%d%d",$N,$M);
    
    for($i=0;$i<$M;$i++){
        list($p,$s) = array_map(null,explode(" ",trim(fgets(STDIN))));
        
        $INFO[intval($p)][] = $s;
    }
    if($M==0){
        echo "0 0";
        exit;
    }
    

    $clear = 0;
    $miss_sum =0;
    
    //各問いに対して初めてACするまでするのにかかった提出回数を出す
    foreach($INFO as $value1){
        $miss = 0;
        $flg=0;
        foreach($value1 as $value2){
            if($value2 == "WA"){
                //正解だ出るまではミスの数を数える。
                $miss++;
            }else{
                //一度正解が出たらあとは見る必要がない
                $clear++;
                $flg=1;
                goto next;
            }
        }
        
        next:
        if($flg==1){
            $miss_sum += $miss;
        }
        
    }
    echo $clear." ".$miss_sum;
    

?>

Measured memory_bytes: 60192
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int m = sc.nextInt();
      Map<Integer, List<Integer>> graph = new HashMap<>();
      for(int i = 0; i < m; i++) {
        int u = sc.nextInt();
        int v = sc.nextInt();
        if(!graph.containsKey(u))
          graph.put(u, new ArrayList<>());
        if(!graph.containsKey(v))
          graph.put(v, new ArrayList<>());
        graph.get(u).add(v);
        graph.get(v).add(u);
      }
      Set<Integer> visited = new HashSet<>();
      visited.add(1);
      int res = dfs(graph, visited, 1);
      System.out.println(res);
  }

  private static int dfs(Map<Integer, List<Integer>> graph, Set<Integer> visited, int curNode) {
    if(visited.size() == graph.size()) {
      return 1;
    }
    int res = 0;
    for(int child : graph.get(curNode)) {
      if(visited.contains(child)) continue;
      visited.add(child);
      res += dfs(graph, visited, child);
      visited.remove(child);
    }
    return res;
  }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int long long int
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%lld",&x)
#define ss(s)   scanf("%s",s)
#define pi(x)   printf("%d\n",x)
#define pl(x)   printf("%lld\n",x)
#define ps(s)   printf("%s\n",s)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define INF 1e9+7
typedef pair<int, int>  pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
int mpow(int base, int exp);
void ipgraph(int m);
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
const int mod = 1000000007;
//const int N = 2e5+5, M = N;
//=========================================

const int MAXN = 3010;

string s, t;
int dp[MAXN][MAXN], N, M;
stack<char> resposta;

int solve(int a, int b){
    if(a < 0 || b < 0) return 0;

    if(dp[a][b] != -1) return dp[a][b];

    if(s[a] == t[b]) return dp[a][b] = 1 + solve(a - 1, b - 1);

    return dp[a][b] = max(solve(a - 1, b), solve(a, b - 1));
}

void build(int a, int b){
    if(a < 0 || b < 0) return;

    if(s[a] == t[b]){
        resposta.push(s[a]);
        build(a - 1, b - 1);
        return;
    }

    if(solve(a - 1, b) > solve(a, b - 1)) build(a - 1, b);
    else build(a, b - 1);
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    memset(dp, -1, sizeof(dp));

    cin >> s;
    cin >> t;
    N = (int)s.size();
    M = (int)t.size();

    build(N - 1, M - 1);

    while(!resposta.empty()){
        cout << resposta.top();
        resposta.pop();
    }

    cout << endl;

    return 0;
}


Measured memory_bytes: 71296
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define F .first
#define S .second 
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
/*
ll a[110];
int main(){
    ll n,a1=0,a2=0,a3=0,a4=0,a5=0,a6=0,a7=0,a8=0;
    ll ans=0;
    cin>>n;
    rep(i,0,n)cin>>a[i];
    rep(i,0,n){
        if(a[i]>=3200)a1++;
        else if(a[i]>=2400)a2++;
        else if(a[i]>=2000)a3++;
        else if(a[i]>=1600)a4++;
        else if(a[i]>=1200)a5++;
        else if(a[i]>=800)a6++;
        else if(a[i]>=400)a7++;
        else a8++;
    }
    if(a2>0)ans++;
    if(a3>0)ans++;
    if(a4>0)ans++;
    if(a5>0)ans++;
    if(a6>0)ans++;
    if(a7>0)ans++;
    if(a8>0)ans++;

    if(ans==0)cout<<"1"<<" ";
    else cout<<ans<<" ";
    cout<<ans+a1;
}*/
ll b[220000];
ll m1[220000],m2[220000];
int main(){
    ll n;
    cin>>n;
    rep(i,0,n)cin>>b[i];
    m2[n-1]=b[n-1];
    m1[0]=b[0];
    rep(i,1,n)m1[i]=max(m1[i-1],b[i]);
    irep(i,n-2,0)m2[i]=max(m2[i+1],b[i]);
    rep(i,0,n)cout<<max(m1[i-1],m2[i+1])<<endl;

}

Measured memory_bytes: 6400
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    string num;
    cin >> num;
    int res = 0;
    for(int i = 0; i < 3; i++){
        res += (int)num[i] - 48;
    }
    cout << res;
    cout << endl;    
}


Measured memory_bytes: 256
S = input()
fast = int(S[0:2])
end = int(S[2:4])

if 0 < fast < 13 and 0 < end < 13:
  print('AMBIGUOUS')
elif 0 <= fast and 0 < end < 13:
  print('YYMM')
elif 0 < fast < 13 and 0 <= end:
  print('MMYY')
else:
  print('NA')

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>

int main(){
  int i, j, n, s1=0, s2=0, min;
  int *w;

  scanf("%d", &n);
  w = malloc(sizeof(int)*n);
  for(i=0; i<n; i++){
    scanf("%d", &w[i]);
    s2 += w[i];
  }

//printf("%d\n", s2);
  for(i=0; i<n; i++){
    s1 += w[i];
    s2 -= w[i];
    if(i == 0) min = abs(s1-s2);
    if(min > abs(s1-s2)) min = abs(s1-s2);
  }

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


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

typedef pair<int, int> ii;

map<int, int> cnt[2];

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	for (int i = 0; i < n; i++) {
        int x; cin >> x;
        cnt[i % 2][x]++;
	}
	vector<ii> best = {{-1, -1}, {-1, -1}};
	for (int k = 0; k < 2; k++) {
	    for (auto x : cnt[k]) {
            if (x.second > cnt[k][best[k].first]) {
                best[k].second = best[k].first;
                best[k].first = x.first;
            } else if (x.second > cnt[k][best[k].second]) {
                best[k].second = x.first;
            }
	    }
	}
	int ans = 0;
	if (best[0].first != best[1].first) {
        ans = n - cnt[0][best[0].first] - cnt[1][best[1].first];
	} else {
	    ans = n - cnt[0][best[0].first] - cnt[1][best[1].second];
	    ans = min(ans, n - cnt[0][best[0].second] - cnt[1][best[1].first]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4992
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = n * 800;
		int a = n / 15;
		int y = a * 200;

		System.out.println(x-y);

}
}

Measured memory_bytes: 19924
import java.util.*;
import java.io.*;
import java.text.*;
public class Main{
    //SOLUTION BEGIN
    //This code is not meant for understanding, you have been warned.
    void pre() throws Exception{}
    void solve(int TC) throws Exception{
        int n = ni(), k = ni();
        double ans = 0.0;
        for(int i = 1; i<= n; i++){
            double prob = 1.0;
            int cur = i;
            while(cur<k){
                cur<<=1;
                prob/=2;
            }
            ans+=prob;
        }
        pn(df.format(ans/n));
    }
    //SOLUTION END
    void hold(boolean b)throws Exception{if(!b)throw new Exception("Hold right there, Sparky!");}
    long mod = (long)998244353, IINF = (long)1e18;
    final int INF = (int)1e9, MX = (int)5e5+1;
    DecimalFormat df = new DecimalFormat("0.00000000000");
    double PI = 3.141592653589793238462643383279502884197169399, eps = 1e-8;
    static boolean multipleTC = false, memory = false;
    FastReader in;PrintWriter out;
    void run() throws Exception{
        in = new FastReader();
        out = new PrintWriter(System.out);
        //Solution Credits: Taranpreet Singh
        int T = (multipleTC)?ni():1;
        pre();for(int t = 1; t<= T; t++)solve(t);
        out.flush();
        out.close();
    }
    public static void main(String[] args) throws Exception{
        if(memory)new Thread(null, new Runnable() {public void run(){try{new Main().run();}catch(Exception e){e.printStackTrace();}}}, "1", 1 << 28).start();
        else new Main().run();
    }
    long gcd(long a, long b){return (b==0)?a:gcd(b,a%b);}
    int gcd(int a, int b){return (b==0)?a:gcd(b,a%b);}
    int bit(long n){return (n==0)?0:(1+bit(n&(n-1)));}
    void p(Object o){out.print(o);}
    void pn(Object o){out.println(o);}
    void pni(Object o){out.println(o);out.flush();}
    String n()throws Exception{return in.next();}
    String nln()throws Exception{return in.nextLine();}
    int ni()throws Exception{return Integer.parseInt(in.next());}
    long nl()throws Exception{return Long.parseLong(in.next());}
    double nd()throws Exception{return Double.parseDouble(in.next());}

    class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public FastReader(String s) throws Exception{
            br = new BufferedReader(new FileReader(s));
        }

        String next() throws Exception{
            while (st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (IOException  e){
                    throw new Exception(e.toString());
                }
            }
            return st.nextToken();
        }

        String nextLine() throws Exception{
            String str = "";
            try{   
                str = br.readLine();
            }catch (IOException e){
                throw new Exception(e.toString());
            }  
            return str;
        }
    }
}

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


// type definitions
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vi > vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef complex<int> ci;
typedef complex<double> cd;
typedef complex<long double> cld;

// macros
#define rep(i, a, b) for(int i=a; i<b; i++)
#define TIME clock() * 1.0 / CLOCKS_PER_SEC
#define all(c) c.begin(), c.end()
#define tr(c, it) for(auto it=(c).begin(); it!=c.end(); it++)
#define pb push_back
#define mp make_pair
#define bitcount __builtin_popcount
#define ispresent(c, x) ((c).find(x) != (c).end())
#define watch(x) cout<< (#x) << " is " << (x) <<"\n";
#define sz(x) ((int)((x).size()))
#define UNIQUE(c) (c).resize(unique(all(c)) - (c).begin())
#define pii2ll(p) ((ll)(p).first<<32 | (p).second)

// template functions
template <typename T>
inline void printV(vector<T>& a) { rep(i, 0, sz(a)) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printV(vector<T>& a, int n) { rep(i, 0, n) { cout<<a[i]<<" "; } cout<<"\n"; }
template <typename T>
inline void printVV(vector<vector<T>>& a)
{
	rep(i, 0, sz(a)) {
		printV(a[i]);
	}
	cout<<"\n";
}

template <typename T>
inline void clearVV(vector<vector<T>>& a)
{
	for(auto& x:a) {
		x.clear();
	}
	a.clear();
}
template <typename T>
inline void assignVV(vector<vector<T>> &a, T val)
{
	for(int i=0; i<sz(a); i++) {
		for(int j=0; j<sz(a[i]); j++) {
			a[i][j]=val;
		}
	}
}


// constants
const long double eps = 1e-9;
const int inf = 5e8;
const int modn = 1e9+7;
const int MAX = 1e5;

inline int add(int a, int b)
{
	return ((ll)a+b)%modn;
}

inline int mul(int a, int b)
{
	return ((ll)a*b)%modn;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // Your code here
	int n, m;
	cin>>n>>m;
	vector<vector<char>> mat(n, vector<char>(m));
	for(int i=0; i<n; i++) {
		for(int j=0; j<m; j++) {
			cin>>mat[i][j];
		}
	}
	vector<vector<int>> dp(n, vector<int>(m));
	assignVV(dp, -1);
	function<int(int , int)> solve = [&](int i, int j)
	{
		if(i>n-1 or j>m-1) return 0;
		if(i==n-1 and j==m-1) return 1;
		if(mat[i][j]=='#') return 0;
		if(dp[i][j]!=-1) return dp[i][j];
		return dp[i][j]=add(solve(i+1, j),solve(i, j+1));
	};
	int ans=solve(0, 0);
	cout<<ans<<"\n";
    return 0;
}



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

using namespace std;

void solve(void)
{
	string s, ans;
	while(cin >> s)
	{
		ans += s[0];
	}
	cout << ans << endl;
}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,m,i,j,all,max=0;
    scanf("%d %d",&n,&m);
    while(n!=0||m!=0)
    {
        int a[m][n];
        for(i=0;i<m;i++)
           for(j=0;j<n;j++)
             scanf("%d",&a[i][j]);
        max=0;
    for(i=0;i<n;i++)
    {
        all=0;
        for(j=0;j<m;j++)
        {
            all+=a[j][i];
        }
        if(all>max)
          max=all;
    }
    printf("%d\n",max);
    scanf("%d %d",&n,&m);
    }
    return 0;
}


Measured memory_bytes: 2056
import java.util.Scanner;

public class Main {
	static int[] LIS;
	static int INF=1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N=sc.nextInt();

		LIS=new int[N];
		for(int i=0; i<N; i++) {
			LIS[i]=INF;
		}
		for(int i=0; i<N; i++) {
			int tmp=sc.nextInt();
			if(i==0) {
				LIS[0]=tmp;
			}
			else {
				int insert=LIS_BinSearch(tmp);
				//System.out.println(insert+" !"+tmp);
				if(insert>=0) {
					LIS[insert]=Math.min(tmp, LIS[insert]);
				}
			}
		}
		int counter=0;
		for(int i=0; i<N; i++) {
			if(LIS[i]==INF) {
				break;
			}
			else {
				counter++;
			}
		}
		System.out.println(counter);
	}
    public static final int LIS_BinSearch(final int value) {
		int low = 0;
		int high = LIS.length;
		int mid;
		while (low < high) {
			mid = ((high - low) >>> 1) + low;    //(low + high) / 2 (オーバーフロー対策)
			if (LIS[mid] < value) {
				low = mid + 1;
			} else {
				high = mid;
			}
		}
		if(low<LIS.length) {
			return low;
		}
		else {
			return -1;
		}
	}
}



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

int main()
{
    string s;
    cin >> s ;
    long a , z;
    for(long i = 0 ; i < s.length() ; i++){
        if(s[i]== 'A'){
            a = i;
            break;
        }
    }
    for(long i = s.length() - 1 ; i >= 0 ; i--){
        if(s[i]== 'Z'){
            z = i;
            break;
        }
    }
    cout << (z - a + 1) << endl;
    return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env pypy3


import itertools


def solve(n, m, sss, ps):
    res = 0
    for switches in itertools.product((True, False), repeat=n):
        num_on = 0
        for i in range(m):
            if sum(switches[s] for s in sss[i]) % 2 == ps[i]:
                num_on += 1
            else:
                break
        if num_on == m:
            res += 1
    return res


def main():
    n, m = (int(z) for z in input().split())
    sss = [tuple(int(x) - 1 for x in input().split())[1:] for _ in range(m)]
    ps = [int(p) for p in input().split()]
    res = solve(n, m, sss, ps)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 42076
a, b, c, d = map(str, list(input()))
op = ['+', '-']
eval_ary = []
for i in range(2):
    for j in range(2):
        for k in range(2):
            eval_ary.append(a+op[i]+b+op[j]+c+op[k]+d)
for test in eval_ary:
    if eval(test) == 7:
        print(test+'=7')
        break


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n;
    cin >> n;
    ll l[n+1] = {2, 1};
    fore(i,2,n+1) {
        l[i] = l[i-1]+l[i-2];
    }
    cout << l[n] << endl;
}


Measured memory_bytes: 256
N,M,K=map(int,input().split())
At=list(map(int,input().split()))
Bt=list(map(int,input().split()))

#０冊を初期値にする
A=[0]
B=[0]


for a in At:
    if A[-1]+a<=K:
        A.append(A[-1]+a)
    else:
        break
for b in Bt:
    if B[-1]+b<=K:
        B.append(B[-1]+b)
    else:
        break

def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    if Ak+B[arg]<=K:
        return True
    else:
        return False


def meguru_bisect(ng, ok):
    '''
    めぐる2分探査
    okはBの冊数たりうる値
    ngはBの冊数たり得ない値を入れる。
    '''

    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
    return ok


Ak=0

maxBooks=0
for Ai in range(len(A)): 
    Ak=A[Ai]
    Bi=meguru_bisect(len(B),0) #len(B)は配列の要素数として使われるとき最大＋１
    if maxBooks<(Ai+Bi):
        maxBooks=Ai+Bi
print( maxBooks )




Measured memory_bytes: 133128
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	ll x;
	ll ans=0LL;
	cin >>x;

	ll y=100LL;
	int i;
	for( i=0;y <x;i++){
		y+=((double)y*0.01);
	}
	cout<<i<<endl;
}

Measured memory_bytes: 3580
// " --- IN THE NAME OF ALLAH --- " // ;)
// ------------sphr_agz------------ // ;)

#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <math.h>
#include <cmath>
#include <list>
#include <stack>
#include <bitset>
#include <ctime>
using namespace std;

typedef long double ld;
typedef long long int lli;
#define pb(x) push_back(x)
#define recout(x) return cout << (x), 0
#define fr first
#define sc second
#define fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define stp(x) cout << setprecision(x) << fixed
#define mk make_pair
const lli N = 1e6, N2 = 5e3, delta = 46639, mod = 1e9 + 7, oo = 1e16;
const ld PI = 3.141592653589793;

lli dp[N][4], a[N][3];

int main(){
	lli n, mx = 0;
	cin >> n;
	for (lli i = 0; i < n; i++) {
		for (lli j = 0; j < 3; j++)
			cin >> a[i][j];
		dp[i][0] = mx;
		if (i == 0) {
			dp[i][1] = a[i][0];
			dp[i][2] = a[i][1];
			dp[i][3] = a[i][2];
		}
		else {
			dp[i][1] = max (dp[i - 1][0], max (dp[i - 1][2], dp[i - 1][3])) + a[i][0];
			dp[i][2] = max (dp[i - 1][0], max (dp[i - 1][1], dp[i - 1][3])) + a[i][1];
			dp[i][3] = max (dp[i - 1][0], max (dp[i - 1][1], dp[i - 1][2])) + a[i][2];
		}
		for (lli j = 0; j < 4; j++)
			mx = max (mx, dp[i][j]);
	}
	cout << mx;
	return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
char ch[100005];
long long cnt[100005];
int main()
{
    long long n,m,i,j,k,a,b,c,z=1,mod=(1e9)+7,x;
    cin>>n;
    scanf(" %s",ch);
    for(i=0;i<n;i++)
    {
        x=(int)ch[i];
        cnt[x]++;
    }
    for(i=0;i<100000;i++)
    {
        z=(z*(cnt[i]+1))%mod;
    }
    cout<<z-1<<endl;

}


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

using namespace std;

int n,tree[100005][2], ptr = 1;
long long int height[100005], l, gr = 0;

void addStr(string &s){
    int t = 0;
    for(size_t i = 0; i < s.size(); i++){
        if(tree[t][s[i] - '0'] != -1){
            t = tree[t][s[i] - '0'];
        }else{
            tree[t][s[i] - '0'] = ptr;
            height[ptr] = height[t] - 1;
            t = ptr++;
        }
    }
}

long long int findMax2(long long int s){
    if(s == 0)return 0;
    long long int ans = 1;
    while(s%2 == 0){
        s /= 2;
        ans *= 2;
    }
    return ans;
}

void processTrie(){
    for(int i = 0; i < ptr; i++){
        if(tree[i][0] == -1){
            gr ^= findMax2(height[i] - 1);
        }
        if(tree[i][1] == -1){
            gr ^= findMax2(height[i] - 1);
        }
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>l;
    string s;
    memset(tree, -1, sizeof(tree));
    height[0] = l+1;
    for(int i = 0; i < n; i++){
        cin>>s;
        addStr(s);
    }
    processTrie();
    if(gr == 0){
        cout<<"Bob"<<endl;
    }else{
        cout<<"Alice"<<endl;
    }
}


Measured memory_bytes: 2000
import std.algorithm;
import std.array;
import std.bigint;
import std.bitmanip;
import std.conv;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T diff(T)(const ref T a, const ref T b) { return a > b ? a - b : b - a; }

T[] readToArray(T)() {
    return readln.split.to!(T[]);
}

void readInto(T...)(ref T ts) {
    auto ss = readln.split;
    foreach(ref t; ts) {
        t = ss.front.to!(typeof(t));
        ss.popFront;
    }
}

// 冪乗をmod取りつつ計算
pure ulong modPow(ulong a, ulong n, ulong m) {
    ulong r = 1;
    while (n > 0) {
        if(n % 2 != 0) r = r * a % m;
        a = a * a % m;
        n /= 2;
    }
    return r;
}

// フェルマーの小定理から乗法逆元を計算
// 定理の要請により法は素数
pure ulong modInv(ulong a, ulong m) {
    return modPow(a, m-2, m);
}

// mod取りつつ組み合わせを計算
// modInvを使っているので法は素数
pure ulong modComb(ulong n, ulong r, ulong m) {
    if (n == r) return 1;
    if (r == 0) return 1;
    if (n < r) return 0;

    ulong up = 1;
    ulong down = 1;
    for(ulong i = n-r+1; i <= n; i++) {
        up *= i;
        up %= m;
    }
    for(ulong i = 2; i <= r; i++) {
        down *= i;
        down %= m;
    }
    return up*modInv(down, m) % m;
}

immutable ulong MOD = 1000000007;

void main() {
    ulong n, k;
    readInto(n, k);
    for (ulong i = 1; i <= k; i++) {
        writeln(modComb(n-k+1, i, MOD)*modComb(k-1, i-1, MOD) % MOD);
    }
}


Measured memory_bytes: 256