akhauriyash/Code-Regression huggingface dataset:
/*
* @Author: 王文宇
* @Date:   2018-03-17 23:59:48
* @Last Modified by:   王文宇
* @Last Modified time: 2018-03-18 00:00:52
*/
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
using namespace std;

typedef unsigned long long ll;
const int maxn=(int)2e5+5;
int n;
ll a[maxn],b[maxn],c[maxn];

void merge (ll *p,ll mod) {   //在给定的mod下归并排序
	int i,j,k,m;
	for(i=1;i<=n;i++) {
		c[i]=p[i];
		if(p[i]>=mod)
			break;
	}
	m=j=i;
	for(i=j;i<=n;i++)
		c[i]=p[i]%mod;
	i=1;c[n+1]=mod<<1;
	for(k=1;k<=n;k++) {
		if(c[i]<c[j]&&i<m) p[k]=c[i++];
		else p[k]=c[j++];
	}
}

ll bigthan (ll m) {             //大于m的数对对数
	int i,j=n;ll ans=0;
	for (i=1;i<=n;i++) {
		while ((a[i]+b[j])>=m&&j>0) j--;
		ans+=n-j;
	}
	return ans;
}

bool get (ll mod) {               //考虑mod位是否为1
	merge (a,mod<<1);
	merge (b,mod<<1);
	ll ans = bigthan(mod) + bigthan(3*mod) - bigthan(mod<<1);
	if ( ans%2 ) return true;
	return false;
}

int main () 
{
//	freopen("aa.txt","r",stdin);
	int cas,T,i;ll mod,ans;
	scanf("%d",&n);
	for(i=1;i<=n;i++) scanf("%I64d",a+i);
	for(i=1;i<=n;i++) scanf("%I64d",b+i);
	sort(a+1,a+n+1);sort(b+1,b+n+1);
	ans=0;mod=(ll)1<<28;
	while(mod) {
		if (get(mod)) 
			ans+=mod;
		mod=mod>>1;
	}
	cout<<ans<<endl;
}

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

int compare(const void *a, const void *b){
	long long int *A = (long long int *)a;
	long long int *B = (long long int *)b;
	if (*A > *B) return 1;
	if (*A < *B) return -1;
	return 0;
}


int main(){
	int N;
	scanf("%d",&N);
	long long A[N];
	for(int i=0;i<N;i++)scanf("%lld",&A[i]);
	qsort(A,N,sizeof(long long),compare);
	long long len[N];
	int c=0;
	for(int i=0;i<N-1;i++){
		if(A[i]==A[i+1]){
			len[c]=A[i];
			c++;
			i++;
		}
	}
	if(c<2)printf("0\n");
	else printf("%lld\n",len[c-1]*len[c-2]);
	return 0;
}

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

using namespace std;

#define sz(x) (int) x.size()
#define all(a) a.begin(), a.end()

const int mod = (int) 1e9 + 7;

int n, k;

int main() {

    scanf("%d %d", &n, &k);

    int l = 0, r = n;
    long long ans = 0;
    long long mn = 0, mx = 0;
    for (int i = 0; i < n + 1; i++) {
        mn += l; l++;
        mx += r; r--;
        if (i + 1 >= k) {
            ans = (ans + mx - mn + 1) % mod;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3760
import sys

dictionary = dict()

for line in sys.stdin.readlines():
    line = line.strip()
    num = int(line)
    if not dictionary.has_key(num):
        dictionary[num] = 0
    dictionary[num] += 1

lastValue = max(dictionary.values())
for key, value in sorted(dictionary.items(), key=lambda x: x[1], reverse=True):
    if value == lastValue:
        print key

Measured memory_bytes: 5396
import math
N, D = map(int, input().split())

arr = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1, N, 1):
        kyori = 0
        for k in range(D):
            kyori += (arr[i][k]-arr[j][k])**2
        if math.sqrt(kyori) == int(math.sqrt(kyori)):
            ans += 1

print(ans)


Measured memory_bytes: 62452
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int L; cin >> L;
	int N = 0;
	vector<vector<int>> ans;
	while (1 << N <= L) N++;

	//2進数の辺を作る
	for (int i = 1; i < N; ++i) {
		ans.push_back({i, i + 1, 1 << (i - 1)});
		ans.push_back({i, i + 1, 0});
	}	

	//今現在つないでいる辺の最大長、これがL-1になるまでショートカットをつなぐ
	int now = (1 << (N - 1)) - 1;

	for (int i = N - 1; i >= 1; --i) {
		if (now == L - 1) break;
		//頂点iからのショートカットで増える最大長
		int gain = 1 << (i - 1);
		if (now + gain <= (L - 1)) {
			ans.push_back({i, N, now + 1});
			now += gain;
		}
	}
	int M = ans.size();
	cout << N << " " << M << endl;
	for (auto v : ans) {
		cout << v[0] << " " << v[1] << " " << v[2] << endl;
	}
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;

int main(){
    int a,b,C;
    cin>>a>>b>>C;
    double S,L,h;
    double c=C*3.141592653589/180;
    S=a*b*sin(c)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(c));
    h=2*S/a;
    cout<<fixed<<setprecision(8);
    cout<<S<<'\n'<<L<<'\n'<<h<<endl;
    return 0;
}


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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vv (H+2, vector<char>(W+2));
  for (int i = 0; i < H+2; i++) {
    for (int j = 0; j < W+2; j++) {
      if (i == 0 || i == H+1 || j == 0 || j == W+1) {
        vv.at(i).at(j) = '.';
      }
      else {
        char c;
        cin >> c;
        vv.at(i).at(j) = c;
      }
    }
  }
  bool can = true;
  for (int i = 1; i < H+1; i++) {
    for (int j = 1; j < W+1; j++) {
      if (vv.at(i).at(j) == '#') {
        if (vv.at(i-1).at(j) == '.' && vv.at(i).at(j-1) == '.' && vv.at(i).at(j+1) == '.' && vv.at(i+1).at(j) == '.' ) {
          can = false;
          break;
        }
      }
    }
  }
  if (can) cout << "Yes" << endl;
  if (!can) cout << " No" << endl;
}


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

import numpy as np
import time
import random
start = time.time()
D = int(input())
Cs = np.array(list(mapint()))
Ss = np.array([list(mapint()) for _ in range(D)], dtype=np.float64)
last = np.zeros(26, dtype=np.float64)

lis = []
for i in range(D):
    last_2 = i-last
    last_2.astype(np.float64)
    arr = Ss[i] + Cs*last_2
    idx = np.argmax(arr)
    last[idx] = i+1
    lis.append(idx+1)

def check(Ts):
    last_day = np.zeros(26)
    sati = 0
    for i in range(D):
        t = Ts[i]-1
        sati += Ss[i][t]
        last_day[t] = i+1
        sati += sum((last_day-(i+1))*Cs)
    return sati

now = check(lis)
while time.time()-start<1.7:
    lis_2 = lis[:]
    for i in range(10):
        num = random.randint(1, 26)
        num2 = random.randint(0, 364)
        if num==num2:
            continue
        lis_2[num2] = num
    nx = check(lis_2)
    if nx>now:
        lis = lis_2
        now = nx

for d in lis:
    print(d)

Measured memory_bytes: 27412
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define ALL(x) (x).begin(),(x).end()

int mygcd(int m, int n) {
  if(n==0) {
    return m;
  }
  else {
    return mygcd(n, m % n);
  }
}

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

  long long acc = 0;

  REP(i,n){
    REP(j,n) {
      REP(k,n) {
        int tmp = mygcd(i+1, j+1);
        acc += mygcd(tmp, k+1);
      }
    }
  }

  cout << acc << endl;
  return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
inline ll Function(ll n,ll k)
{
    if(k==0)
    {
        return n*n;
    }
    ll sum=0;
    for(ll i=k+1;i<=n;i++){
        sum+=(i-k)*(n/i);
        if(n%i>=k)sum+=(n%i-k+1);
    }
    return sum;
}

int main()
{
    ll n,k;
    while (scanf("%lld%lld",&n,&k)!=EOF) {
        printf("%lld\n",Function(n,k));
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define MAX 100005

typedef long long ll;

using namespace std;

int A[MAX], B[MAX];

int main() {
	int n, m, v, p;
	cin >> n >> m >> v >> p;
	for (int i = 0; i < n; ++i) {
		cin >> A[i];
	}
	sort(A, A + n);
	int lo = 0;
	int hi = n - 1;
	while (lo < hi) {
		int mid = (lo + hi) / 2;
		for (int i = 0; i < n; ++i) {
			B[i] = A[i];
		}
		ll total(0);
		for (int i = 0; i < n; ++i) {
			if (B[i] <= A[mid] + m) {
				int x = min(m, A[mid] + m - B[i]);
				B[i] += x;
				total += x;
			}
		}
		int gt(0);
		for (int i = n - 1; i >= 0; --i) {
			if (i == mid) {
				continue;
			}
			if (B[i] > A[mid] + m) {
				++gt;
				B[i] += m;
				total += m;
			} else if (gt < p - 1) {
				int x = m - B[i] + A[i];
				B[i] += x;
				total += x;
				if (B[i] > A[mid] + m) {
					++gt;
				}
			}
		}
		if (total < (ll)m * v || gt > p - 1) {
			lo = mid + 1;
		} else {
			hi = mid;
		}
	}
	cout << n - lo << endl;
	return 0;
}

// 0 1 1 2 2 3


Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int N; cin >> N;
    ll ans = 0;
    ll a = 0;
    vector<ll> A(N);

    for (ll i = 0; i < N-1; i++)
    {
      cin >> a;
      A[a]++;
    }
    
    for (ll i = 1; i < N; i++)
    {
      cout << A[i] << endl;
    }

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

Measured memory_bytes: 4796
#include <stdio.h> 
int main(void)
{
	int S,mm,ss;
	
	scanf("%d",&S);
	
	if(S>=0 && S<86400)
	{
		ss= S % 60;
		S /=60;
	
		mm = S % 60;
		S /=60;
	
		printf("%d:%d:%d\n",S,mm,ss);
	}
	
	return 0;
}

Measured memory_bytes: 592
let n = Scanf.scanf " %d" (+) 0
let a_s = Array.init n @@ fun i -> Scanf.scanf " %d" pred
let ans = ref 0
let _ = Array.iteri (fun i a -> if a_s.(a_s.(i)) = i then incr ans) a_s; Printf.printf "%d\n" @@ !ans / 2

Measured memory_bytes: 5248
#include<bits/stdc++.h>
#define task "LIS"

const long long maxn=1e6+5;
const long long w=1e8;

using namespace std;

int n;

inline void init(){
    cin>>n;
}

inline void solve(){
    cout<<48-n;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //freopen(task".INP","r",stdin);
    //freopen(task".OUT","w",stdout);
    init();
    solve();
    return 0;
}


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

string today_weather;

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

Measured memory_bytes: 256
#include <stdio.h>

int GCD(int, int);

int main(void)
{
    int x, y;
    scanf("%d %d", &x, &y);
    printf("%d\n", GCD(x, y));

    return 0;
}

int GCD(int p, int q)
{
    if (q == 0)
        return p;
    return GCD(q, p % q);
}


Measured memory_bytes: 2056
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        
        String line = scanner.nextLine();
        
        String arr[] = line.split(" ", 0);
        
        int X = Integer.parseInt(arr[0]);
        int Y = Integer.parseInt(arr[1]);
        int Z = Integer.parseInt(arr[2]);
        
        System.out.println((X-Z)/(Y+Z));

    }
}

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

int main()
{
    long long int a,sum,pre,aager,n;
    int t;
    cin>>t;
    for(int i=0;i<t;i++){
        cin>>n;
        if(i==0){sum=0;a=n;aager=0;}
        else{
            if(n<a){
                //pre = (a-n)+aager;
                pre = (a-n);
                aager = pre;
                sum+=pre;
                a=n+pre;
                //cout<<pre<<endl;
            }
            else{
                aager = 0;
                a=n;
               // cout<<a<<endl;
            }

        }
    }
    cout<<sum<<endl;



    return 0;
}


Measured memory_bytes: 3592
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>
const int INF = 0x7fffffff;
using lll = long long;
using ull = unsigned long long;
using namespace std;


int main(){
  lll ii,jj,kk;
  vector<int> ret;

  int n;

  cin >> n;
  vector<lll> a(n);
  vector<lll> num(n+1);

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

  lll sum;
  sum = 0;

  for(ii=1;ii<=n;ii++){
    if(num[ii] >= 2){
      sum += num[ii] * (num[ii] -1) / 2;
    }
  }

  //cout << "sum:" << sum << endl;
  lll ans;

  for(ii=0;ii<n;ii++){
    if(num[a[ii]] >= 2){
      ans = sum;
      ans -= num[a[ii]] * (num[a[ii]] -1) / 2;
      ans += (num[a[ii]] -1) * (num[a[ii]] -2) / 2;
    }
    else{
      ans = sum;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 6404
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n;
    int a[200005];
    int b[200005] = {0};
    int ans = 0;
    
    cin >> n;
    for (int i = 1;i <= n;i++){
        cin >> a[i];
    }
    
    int k;
    for (int i = n;i >= 1;i--){
        k = 0;
        for (int j = i;j <= n;j = j+i){
            k += b[j];
        }
        
        if (k%2 == a[i]){
            b[i] = 0;
        }
        else {
            b[i] = 1;
            ans++;
        }
    }
    
    cout << ans << endl;
    for (int i = 1;i <= n;i++){
        if (b[i]){
            cout << i << " ";
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
using namespace std;
 
int main(){
  char X, Y;
  int x,y;
	string a = "ABCDEF";
	cin >> X >> Y;
	for (int k = 0; k < 6; k++) {
 
		if (X == a.at(k)) {
			x = k;
		}
		else if (Y == a.at(k)) {
			y = k;
		}
	}
 
 
 
 
	if (X<Y) {
		cout << "<" << endl;
	}
	else if (X>Y) {
		cout << ">" << endl;
	}
	else if (X==Y) {
		cout << "=" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e7+1;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector < pair<ll, ll > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
typedef list <ll> lst;

ll n,m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main()
{
	while (1) {
		cin >> n >> m;
		if (n == 0 && m == 0) {
			return 0;
		} else {
			ll a, b;
			vp v;
			REP(i, n)
			{
				cin >> a >> b;
				v.push_back(make_pair(b, a));
			}
			sort(RALL(v));
			ans = 0;
			REP(i, n)
			{
				if (m >= v[i].second) {
					m -= v[i].second;
				} else {
					ans += (v[i].second - m)*v[i].first;
					m = 0;
				}
			}
			cout << ans << endl;
			v.clear();
		}
	}
}

Measured memory_bytes: 3264
h, w = gets.split(' ').map(&:to_i)
s = []
h.times do 
  s.push(gets.chomp.split(''))
end
h.times do |row|
  w.times do |col|
    if s[row][col] == '#'
      if row - 1 >= 0 && s[row-1][col] == '#'
        next
      end
      if row + 1 < h && s[row+1][col] == '#'
        next
      end
      if col - 1 >= 0 && s[row][col-1] == '#'
        next
      end
      if col + 1 < w && s[row][col+1] == '#'
        next
      end
    else
      next
    end
    puts 'No'
    exit
  end
end
puts 'Yes'
exit

Measured memory_bytes: 2044
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> numbers = new ArrayList<>();
        
        for (int i = 0; i < n; i++) {
            numbers.add(sc.nextInt());
        }

        int count = 1000000;
        for (Integer number : numbers) {
            int newCount = 0;
            boolean isEven = true;
            while (isEven) {
                if (number % 2 == 0) {
                    number = number / 2;
                    newCount++;
                } else {
                    isEven = false;
                }
            }
            if (count > newCount) {
                count = newCount;
            }
        }

        System.out.println(count);
    }
}

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

int N;

int main()
{
	scanf("%d",&N);
	vector< pair<int,int> > P(N);
	vector<int> ans(N * N,-1);
	for(int i = 0;i < N;i++){
		scanf("%d",&P [i].first);
		P [i].first--;
		ans [P [i].first] = i;
		P [i].second = i;
	}
	sort(P.begin(),P.end());

	vector< queue<int> > q1(N,queue<int>());
	queue<int> q2;
	for(int i = 0;i < N;i++){
		for(int j = 0;j < P [i].second;j++){
			q1 [P [i].second].push(P [i].second);
		}
	}
	int idx = 0;
	for(int i = 0;i < N * N;i++){
		if(ans [i] != -1){
			if(q1 [ans [i]].empty() == false){
				printf("No\n");
				return 0;
			}
			else{
				for(int j = 0;j < N - ans [i] - 1;j++){
					q2.push(ans [i]);
				}
			}
		}
		else{
			while(idx < N && q1 [P [idx].second].empty() == true) idx++;
			if(q1 [P [idx].second].empty() == false){
				ans [i] = q1 [P [idx].second].front();
				q1 [P [idx].second].pop();
			}
			else if(q2.empty() == false){
				ans [i] = q2.front();
				q2.pop();
			}
			else{
				printf("No\n");
				return 0;
			}
		}
	}

	printf("Yes\n");
	for(int i = 0;i < N * N;i++){
		printf("%d%s",ans [i] + 1,i == N * N - 1 ? "\n" : " ");
	}

	return 0;
}


Measured memory_bytes: 3200
fun main(args: Array<String>) {
    agc014a()
}

private data class Cookie(var a: Long, var b: Long, var c: Long)

fun agc014a() {
    val cookie = readLine()!!.split(' ').map { it.toLong() }.toLongArray()
        .let { Cookie(it[0], it[1], it[2]) }

    var answer = 0L

    while (cookie.a % 2 == 0L && cookie.b % 2 == 0L && cookie.c % 2 == 0L) {
        val prev = cookie.copy()
        val tempB = (cookie.a / 2) + (cookie.c / 2)
        val tempC = (cookie.a / 2) + (cookie.c / 2)

        cookie.a = (cookie.b / 2) + (cookie.c / 2)
        cookie.c = tempC
        cookie.b = tempB

        if (cookie == prev) return println(-1)

        answer++
    }

    println(answer)
}


Measured memory_bytes: 38000
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pint;
const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
const ll waru = 1e9 + 7;
const int intmax = 0x7fffffff, intmin = ~intmax;

int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << m << endl;
  } else {
    int re = 1, imax = m / n;
    for (int i = 2; i <= imax; i++) {
      int x = m - (n - 1) * i;
      if (x > 0 && x % i == 0) re = i;
    }
    cout << re << endl;
  }
}


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

using ll = long long;
int a[25], b[25], c[25];

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

  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  for (int i = 1; i <= n-1; i++) cin >> c[i];

  int sat = 0;

  for (int i = 1; i <= n; i++) {
    sat += b[a[i]];
  }

  for (int i = 2; i <= n; i++)
    if (a[i] == a[i - 1] + 1) sat += c[a[i - 1]];

  cout << sat << endl;
}

Measured memory_bytes: 256
s = int(input())

l = [1,2,4]
if s in l:
    print(4)
else:
    cnt = 1
    while s != 4:
        cnt += 1
        if s%2 == 0:
            s = s//2
        else:
            s = 3*s+1
    print(cnt+3)
        

Measured memory_bytes: 2940
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	num, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return num
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	x := nextInt()
	ans := func() int {
		dep := 100
		year := 0
		for {
			dep = dep + dep/100
			year++
			if dep >= x {
				return year
			}
		}
	}()

	fmt.Println(ans)

}


Measured memory_bytes: 1756
h, w, k = gets.split.map(&:to_i)
x1, y1, x2, y2 = gets.split.map(&:to_i)

d = Array.new(h+2) {Array.new(w+2, 1 << 50)}
d[0].fill(0)
1.upto(h) do |i|
    d[i][0] = d[i][-1] = 0

    gets.chomp.each_char.with_index(1) do |ch, j|
        d[i][j] = 0 if ch == ?@
    end
end
d[-1].fill(0)

s = [[x1, y1]]
d[x1][y1] = 1
(1..).each do |n|
    break if s.empty?
    t = []

    s.each do |x,y|
        1.upto(k) do |i|
            break if d[x+i][y] < n
            if d[x+i][y] > n
                d[x+i][y] = n
                t << [x+i, y]
            end
        end

        1.upto(k) do |i|
            break if d[x-i][y] < n
            if d[x-i][y] > n
                d[x-i][y] = n
                t << [x-i, y]
            end
        end

        1.upto(k) do |i|
            break if d[x][y+i] < n
            if d[x][y+i] > n
                d[x][y+i] = n
                t << [x, y+i]
            end
        end

        1.upto(k) do |i|
            break if d[x][y-i] < n
            if d[x][y-i] > n
                d[x][y-i] = n
                t << [x, y-i]
            end
        end
    end
    s = t
end

p d[x2][y2] < 1 << 50 ? d[x2][y2] : -1

Measured memory_bytes: 40084
def abc():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    while True:
        if len([x for x in a if x % 2]) > 0:
            break
        for i in range(n):
            a[i] //= 2
        cnt += 1
    print(cnt)


abc()


Measured memory_bytes: 2940
#define MAX 10
#include <stdio.h>

void score_plass(int puz[][5], int *score, int count, int i,int j){
    int k;
    *score+=(puz[i][j]*(count+1));
    for(k=0;k<=count;k++)
        puz[i][j-k]=0;
}

void drop_puzzle(int puz[][5], int i, int j){
    for(;i>0;i--){
        puz[i][j] = puz[i-1][j];
    }
    puz[0][j]=0;
}

int main(void) {
    int h,score,total_score,i,j,count;
    int puz[MAX][5] = {};
    score = 0;
    
    while(1){
        total_score=0;
        count=0;
        scanf("%d",&h);
        if(h==0)
            break;
        for(i=0;i<h;i++){
            for(j=0;j<5;j++)
                scanf("%d",&puz[i][j]);
        }
        while(1){
            for(i=0;i<h;i++){
                for(j=0;j<4;j++){
                    if(puz[i][j] == puz[i][j+1])
                        count++;
                    else if (count >= 2){
                        score_plass(puz,&score,count,i,j);
                        count = 0;
                    }else
                        count=0;
                }
                if(count>=2)
                    score_plass(puz,&score,count,i,j);
                count=0;
            }
            if(score==0)
                break;
            total_score += score;
            score = 0;
            for(i=0;i<h;i++){
                for(j=0;j<5;j++)
                    if(puz[i][j]==0)
                        drop_puzzle(puz,i,j);
            }
        }
        printf("%d\n",total_score);
    }
    
    return 0;
}

Measured memory_bytes: 600
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a =sc.nextInt();
		int b =sc.nextInt();
		int area = a*b;
		int length = 2*(a+b);
		System.out.println(area+" "+length);
				
	}
}

Measured memory_bytes: 26024
#include <stdio.h>
int main(void){
  int n,l,i,sum=0;
  scanf("%d%d",&n,&l);
  for(i=0;i<n;i++) sum+=l+i;
  if(l>0) printf("%d",sum-l);
  else if(l+n-1>0) printf("%d",sum);
  else printf("%d",sum-(l+n-1));
  return 0;
}

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

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

	int count=0 ;

	while(h>a*count){
		count++ ;
	}

	cout<<count ;

}

int main(){

	int y ;

	y=1 ;
	//cin>>y ;

	while(y--)
	{	
		solve() ;
	}

}

Measured memory_bytes: 3620
/**
 *    author        : Saurav Paul 
 *    created       : August 21, 2020 12:18 PM
 *    Problem Name  : C - Tsundoku
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc172/tasks/abc172_c
 *    @genarated by : ai-virtual-assistant
**/

#include<bits/stdc++.h>
using namespace std;

using ll = long long int ;

void solve(){

    int N , M , K ;
    cin >> N >> M >> K ;

    vector<int> deskA(N) , deskB(M) ;

    for(auto& x: deskA) cin >> x ;
    for(auto& x: deskB) cin >> x ;

    vector<ll> ca , cb ;

    ca.push_back(0) ;
    cb.push_back(0) ;

    for(auto x : deskA) ca.push_back(x + ca.back()) ;
    for(auto x : deskB) cb.push_back(x + cb.back()) ;

    int can_read = 0 ;

    for(int i = 0 , j = M ; i <= N ; i++ ){
        if(ca[i] > K) break ;

        while(ca[i] + cb[j] > K) j--;

        can_read = max(can_read,i + j) ;
    }

    cout << can_read << endl ;

}

int main(){
    ios_base::sync_with_stdio(false);

    int testcases = 1;
    for(int i = 1 ; i <= testcases ; i ++){
        solve();
    }

    return 0 ;
}


Measured memory_bytes: 9480
nk = input().split(' ')
n = int(nk[0])
k = int(nk[1])

arr = []

for i in range(0, n):
	ab = input().split(' ')
	arr.append((int(ab[0]), int(ab[1])))

arr = sorted(arr)

pos = 0
while True:
	if k > arr[pos][1]:
		k -= arr[pos][1]
	else:
		print(arr[pos][0])
		break
	pos += 1


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

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

int main(){
    int n,m,q; cin>>n>>m;
    vector<vector<int>> path(n),dp(n,vector<int>(11,0));
    rep(i,m){
        int a,b; cin>>a>>b;
        a--; b--;
        path[a].push_back(b);
        path[b].push_back(a);
    }
    cin>>q;
    vector<vector<int>> Q(q,vector<int>(3,0));
    rep(i,q)rep(j,3){
        cin>>Q[i][j];
        if(j==0) Q[i][j]--;
    }
    int v,d;
    for(int i=q-1;i>=0;i--){
        queue<pp> que;
        v=Q[i][0]; d=Q[i][1];
        if(d==0){
            if(dp[v][d]==0) dp[v][d]=Q[i][2];
            continue;
        }
        if(dp[v][d]==0){
            dp[v][d]=Q[i][2];
            que.push(mk(v,d));
        }
        while(!(que.empty())){
            int u,k;
            tie(u,k)=que.front();
            que.pop();
            if(dp[u][k-1]==0){
                dp[u][k-1]=Q[i][2];
                if(k>1) que.push(mk(u,k-1));
            } 
            for(auto to:path[u]){
                if(dp[to][k-1]==0){
                    dp[to][k-1]=Q[i][2];
                    if(k>1) que.push(mk(to,k-1));
                }
            }
        }
    }
    rep(i,n) cout<<dp[i][0]<<endl;
}

Measured memory_bytes: 21784
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define mygc(c) (c)=getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
inline void reader(int& x) { int k, m = 0; x = 0; for (;;) { mygc(k); if (k == '-') { m = 1; break; }if ('0' <= k&&k <= '9') { x = k - '0'; break; } }for (;;) { mygc(k); if (k<'0' || k>'9')break; x = x * 10 + k - '0'; }if (m) x = -x; }
inline void writer(int x, char c) { int s = 0, m = 0; char f[10]; if (x<0)m = 1, x = -x; while (x)f[s++] = x % 10, x /= 10; if (!s)f[s++] = 0; if (m)mypc('-'); while (s--)mypc(f[s] + '0'); mypc(c); }
using namespace std;
typedef pair<int, int>P;

vector<P>E[100000];
int l[100000], d[100000], b[100000], cnt[200001], u[200000], v[200000], r[200000], que[100000];
int main() {
	int n, m, q; reader(n); reader(m); reader(q);
	rep(i, m) {
		reader(u[i]); reader(v[i]); u[i]--; v[i]--; r[i] = q;
		l[u[i]]++; l[v[i]]++;
	}
	rep(i, n)E[i].reserve(l[i]), l[i] = 0;
	rep(i, q) {
		int a; reader(a); r[a - 1] = i;
	}
	rep(i, m) {
		E[u[i]][l[u[i]]++] = P(v[i], r[i]);
		E[v[i]][l[v[i]]++] = P(u[i], r[i]);
	}
	d[0] = 1; b[0] = q;
	int s = 0, g = 1;
	while (s != g) {
		int p = que[s++];
		rep(i, l[p]) {
			P v = E[p][i];
			if (d[v.first] == 0) {
				d[v.first] = d[p] + 1; que[g++] = v.first;
			}
			if (d[v.first] == d[p] + 1)
				b[v.first] = max(b[v.first], min(b[p], v.second));
		}
	}
	rep(i, n)cnt[b[i]]++;
	int ans = 0;
	rep(i, q) {
		ans += cnt[i];
		writer(ans, '\n');
	}
}

Measured memory_bytes: 14600
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>

const int INF = 1000000009;
const long LINF = 1123456789012345678;

int n;
char s[100005];
std::vector<int> edge[100005];
int end1, end2;

int main(){
	std::cin >> s;
	n = strlen(s);
	for(int i = n+1; i >= 0; i--){
		s[i+1] = s[i];
	}
	s[0] = '0';
	if(s[1] == '0' || s[n] == '1'){
		printf("-1\n");
		return 0;
	}
	for(int i = 1; i <= (n+1)/2; i++){
		if(s[i] != s[n-i]){
			printf("-1\n");
			return 0;
		}
	}
	int top = 1;
	for(int i = 1; i < n; i++){
		printf("%d %d\n", top, i+1);
		if(s[i] == '1'){
			top = i+1;
		}
	}
	return 0;
}
			


Measured memory_bytes: 3840
import Queue
def is_bridge(_a, _b, neighbors, N, M):
    q = Queue.Queue()
    q.put(_a)
    used = {_a}
    for _ in range(M):
        if q.empty():
            break
        fr = q.get()
        for to, is_nei in enumerate(neighbors[fr]):
            if  is_nei and (fr != _a or to != _b) and to not in used:
                q.put(to)
                used.add(to)
    return len(used) < N


N, M = map(int, raw_input().split())
neighbors = [[False] * N for _ in range(N)]
ab = []
for _ in range(M):
    _a, _b = map(int, raw_input().split())
    _a -= 1
    _b -= 1
    neighbors[_a][_b] = True
    neighbors[_b][_a] = True
    ab.append((_a, _b))

res = 0
for _a, _b in ab:
    if is_bridge(_a, _b, neighbors, N, M):
        res += 1
print res

Measured memory_bytes: 3052
#include <iostream>
using namespace std;
using int64 = long long;

int main() {
  string S; int64 K; cin >> S >> K;
  int number = 1;
  for (int i = 0; i < K; i++) {
    if (S[i] != '1') {
      number = S[i]-'0';
      break;
    }
  }
  cout << number << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
 
int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();   
	int n, m;
	cin >> n >> m;
	if(n == m) cout << "Yes";
	else cout << "No";
}                                

Measured memory_bytes: 256
n, x = gets.split.map(&:to_i)
s = [1]
pp = [1]
n.times do 
    s << s[-1] * 2 + 3
    pp << pp[-1] * 2 + 1
end

def calc(s, pp, k, i)
    if k == 0
        0
    elsif k >= s[i]
        pp[i]
    elsif k >= s[i - 1] + 2
        pp[i - 1] + 1 + calc(s, pp, k - s[i - 1] - 2, i - 1)
    elsif k >= s[i - 1] - i + 2
        pp[i - 1]
    else
        calc(s, pp, k - 1, i - 1)
    end
end

puts calc(s, pp, x, n)

Measured memory_bytes: 1788
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = {}
    for i, a in enumerate(A):
        B[i - a] = B.get(i - a, 0) + 1
    r = 0
    for i, a in enumerate(A):
        B[i - a] -= 1
        r += B.get(a + i, 0)
    return r

print(main())


Measured memory_bytes: 40556
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();

        s = s.replace("eraser", "");
        s = s.replace("erase", "");
        s = s.replace("dreamer", "");
        s = s.replace("dream", "");

        if (s.length() > 0) {
            System.out.println("NO");
        } else {
            System.out.println("YES");
        }
    }
}


Measured memory_bytes: 28588
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
string s;
int ruiW[200001];
int ruiR[200001];

signed main() {
	int i;
	
	cin >> n >> s;
	rep(i, n) {
		ruiW[i + 1] = ruiW[i] + (s[i] == 'W');
		ruiR[i + 1] = ruiR[i] + (s[i] == 'R');
	}
	
	int ans = 1145141919;
	rep(i, n + 1) {
		int a = ruiW[i];
		int b = ruiR[n] - ruiR[i];
		int res = max(a, b);
		ans = min(ans, res);
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5280
using System;
using System.Collections.Generic;

namespace atcorder
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            atcorder.Test.Run();
        }
    }



    public class Test
    {
        public static void Run()
        {
            string s = Console.ReadLine();
            long N = long.Parse(s);
            long[] l = new long[N];
            s = Console.ReadLine();
            long sum = 0;
            long max = -1;
            string[] ss = s.Split(' ');
            for (long i = 0; i < N;i++){
                l[i] = long.Parse(ss[i]);
                sum += l[i];
                if (max < l[i]) max = l[i];
            }
            sum -= max;
            Console.WriteLine(max < sum ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13140
import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))

ans = np.zeros(1, dtype=np.uint64)
even_odd = 0
mini = 1000000000

for i in A:
    if(i < 0):
        even_odd = (even_odd + 1) % 2
    ans += abs(i)
    if(mini > abs(i)):
        mini = abs(i)
        
if(even_odd == 0):
    print(ans[0])
else:
    print((ans - (mini * 2))[0])

Measured memory_bytes: 23304
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=9e18;
typedef pair<ll,ll> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,k,h[100005]={},dp[100005]={};
  cin >> n >> k;
  for(int i=0; i<n; i++) {
    cin >> h[i];
    dp[i]=inf;
  }
  dp[0]=0;
  for(int i=1; i<n; i++) {
    for(int j=1; j<=k; j++) {
      if(i-j>=0) {
        dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
    }
  }
  cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
	int n,m,p,q,r,x,y;
	vector<int>::iterator itx,ity,it;
	for(;cin>>n>>m>>p>>q>>r;cout<<x<<endl){
		vector<int> v1,v2;
		v1.push_back(0);
		for(v1.push_back(r);m--;v2.clear()){
			cin>>x>>y;
			itx=upper_bound(v1.begin(),v1.end(),x);
			ity=upper_bound(v1.begin(),v1.end(),y);
			
//			if( ity-v1.begin()+1 & 1 )v2.push_back(0);
//			v2.push_back(0);
			v2.insert(v2.end(),ity-v1.begin()&1?1:2,0);
			for(it=ity;it!=v1.end();++it)
				v2.push_back(*it - y);
			
			if(v1.end()-itx & 1)v2.push_back(n-y);
			for(it=itx;it!=ity;++it)
				v2.push_back(*it-x+n-y);
			
			it = v1.begin();
			if(ity-v1.begin() & 1)++it;
			if(!it[1])it+=2;
			if(*it+n-x==v2.back()){++it;v2.pop_back();}
			for(;it!=itx;++it)
				v2.push_back(*it+n-x);
			
			v1.swap(v2);
		}
		v1.insert( upper_bound(v1.begin(),v1.end(),p-1), 2, p-1);
		v1.insert( lower_bound(v1.begin(),v1.end(),q), q );
		v1.push_back(n);
		it = upper_bound(v1.begin(),v1.end(),p-1);
		if(it-v1.begin() & 1) --it;
		for(x=0;*it<q;it+=2)
			x+=it[1]-*it;
	}
}

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

ll chk(ll x, ll b) {
  ll sum = 0;
  while (x) {
    sum += x % b;
    x /= b;
  }
  return sum;
}

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

  ll n, s;
  cin >> n >> s;
  ll ans = (n == s ? n + 1 : -1);
  for (ll b = 2; b <= 1000000; ++b)
    if (chk(n, b) == s) ans = (ans == -1 ? b : min(ans, b));

  for (ll b = 1; b <= 1000000; ++b) {
    auto bb = (n - s) / b + 1;
    if (bb >= 2 && chk(n, bb) == s) ans = (ans == -1 ? bb : min(ans, bb));
  }
  cout << ans;
}

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

void solve(std::string X, std::string Y){
    if (X < Y) cout << '<' << '\n';
    else if (X > Y) cout << '>' << '\n';
    else cout << '=' << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::string X;
    std::cin >> X;
    std::string Y;
    std::cin >> Y;
    solve(X, Y);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
typedef long long int ll;
std::vector<int> v;

int getNum(int n,int k,ll p){
	ll cnt=0,sum=0;
	for(int i=0;i<k;i++){
		while(sum + v[cnt] <= p){
			sum+=v[cnt++];
			if(cnt==n) return n;
		}
		sum = 0;
	}
	return cnt;
}

int getMinP(int n,int k){
	for(int p=1;;p++){
		if(getNum(n,k,p)==n){
			return p;
		}
	}
	return 0;
}

int dfs(int n,int k, ll left, ll right){
	ll mid = (left + right ) / 2;
	// cout <<left << " " << right << endl;
	int num = getNum(n,k,mid);
	if(left>=right)	return mid;
	if(num >= n) return dfs(n,k,left,mid);
	else return dfs(n,k,mid+1,right);
}

int main(){
	int n,k,w;
	cin >> n >>k;
	for(int i=0;i<n;i++){
		cin >> w;
		v.push_back(w);
	}

	cout << dfs(n,k,0,100000*10000) << endl;

	return 0;
}

Measured memory_bytes: 1672
N,M = map(int,input().split())  #Nスイッチの数,M電球の数

S = [list(map(int, input().split())) for _ in range(M)]
P = [int(i) for i in input().split()]

ans = 0
for i in range(1<<N):
    flg = True
    for j in range(M):
        cnt = 0
        for k in S[j][1:]:
            if ((i >> k-1) & 1):  #1:点灯 0:消灯
                cnt += 1
        if cnt % 2 != P[j]:
            flg = False
    if flg:
        ans += 1
print(ans)


Measured memory_bytes: 3064
<?php
fscanf(STDIN, "%d%d%d%d", $hp, $at, $ahp, $aat);

while(true){
    $ahp -= $at;
    if($ahp <= 0){
        echo "Yes";
        exit;
    }
    $hp -= $aat;
    if($hp <= 0){
        echo "No";
        exit;
    }
}

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

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

  int cntr=0,cntb=0;
  for (int i=0; i<n; i++) {
    if (s[i]=='R') cntr++;
    else cntb++;
  }
  if (cntr>cntb) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

int		main() {
	int			n;
	int			m;
	int			size;
	int			k;

	cin >> n;
	vector<string>	s(n);
	vector<int>		count(n);	

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

		cin >> str;
		s.at(i) = str;
	}
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < i; j++)
		{
			if (s.at(j) == s.at(i))
			{
				count.at(j)++;
				/* break; */
			}
		}
	}
	cin >> m;
	for (int i = 0; i < m; i++)
	{
		string	str;

		cin >> str;
		for (int j = 0; j < n; j++)
		{
			if (s.at(j) == str)
			{
				count.at(j)--;
				/* break; */
			}
		}
	}
	k = count.at(0);
	for (int i = 1; i < n; i++)
	{
		if (count.at(i) > k)
			k = count.at(i);
	}
	if (k >= 0)
		cout << k + 1;
	else
		cout << 0;
	cout << endl;	
}


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

int dfs(std::vector<std::vector<char> > map, int w, int h, char self_color, char other_color) {
    int dx[] = {0, 0, 1, -1};
    int dy[] = {1, -1, 0, 0};

    int first;
    int second;

    int total = 0;
    int count; 
    bool check_surrounded;
    bool check_only_wall;

    for (int i = 1; i <= h; i++) {
        for (int j = 1; j <= w; j++) {
            if (map[i][j] == '.') {
                count = 0;
                check_surrounded = true;
                check_only_wall = false;
                std::stack<std::pair<int, int> > st;
                st.push(std::make_pair(i, j));
                map[i][j] = '$';

                while (1) {
                    if (st.empty() == 1) {
                        break; 
                    }
                    first = st.top().first;
                    second = st.top().second;
                    st.pop();
                    ++count;
                    for (int k = 0; k < 4; k++) {
                        if (map[first + dx[k]][second + dy[k]] == '.') {
                            st.push(std::make_pair(first + dx[k], second + dy[k])); 
                            map[first + dx[k]][second + dy[k]] = '$';
                        } else if (map[first + dx[k]][second + dy[k]] == other_color) {
                            check_surrounded = false; 
                        }
                        if (map[first + dx[k]][second + dy[k]] == self_color) {
                            check_only_wall = true;
                        }

                    }
                }
                if (check_surrounded == true && check_only_wall == true) {
                    total += count;
                } else {
                    check_surrounded = true;
                    check_only_wall = false;
                }
            }
            /*
               for (int a = 0; a <= h + 1; a++) {
               for (int b = 0; b <= w + 1; b++) {
               std::cout << map[a][b];
               }
               std::cout << std::endl;
               }
               std::cout << "COUNT = " << count << std::endl;
               std::cout << "TOTAL = " << total << std::endl;
               std::cout << std::endl;
             */
        }
    }
    return total; 
}

int main(void) {
    int w;
    int h;

    while (1) {
        std::cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }

        std::vector<std::vector<char> > map_b(h+2, std::vector<char>(w+2, '#'));
        std::vector<std::vector<char> > map_w(h+2, std::vector<char>(w+2, '#'));

        for (int i = 1; i <= h; i++) {
            for (int j = 1; j <= w; j++) {
                std::cin >> map_b[i][j];
                map_w[i][j] = map_b[i][j];
            }
        }
        std::cout << dfs(map_b, w, h, 'B', 'W') << " " << dfs(map_w, w, h, 'W', 'B') << std::endl;
    }


    return 0;
}

Measured memory_bytes: 3100
N, K = map(int, input().split())  # 0~NのN+1個の整数, K個以上選ぶ, 注意 ; 3, 5 と 1, 3, 4は別物になる。0と5, 2と3 を選んだパターンは同じになる

MOD = 10**9+7
ans = 0
for k in range(K, N+2):
    ans += k*(2*N-(k-1))//2 - k*(k-1)//2 + 1
    ans %= MOD
print(ans)


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

int main() {
  int D, T, S;
  cin >> D >> T >> S;
  if (D/S < T)
    cout << "Yes" << endl;
  else if (D/S == T && D%S == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define lli long long int
#define vec2 vector<vector<lli>> 
#define fio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define FRE freopen("explicit.in","r",stdin);freopen("explicit.out","w",stdout)
#define mp make_pair
#define pll pair <lli,lli>
#define vll vector <lli>
#define pq2 priority_queue<pair<lli,lli>>
#define f first
#define s second
#define pb push_back
#define pf push_front
#define minii LLONG_MAX
#define all(x) x.begin(), x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define ld long double 
const long double pi = 3.1415926535898;
#define dec greater<lli>()
const lli mod=1000000007;
//const lli mod=100000000;
using namespace std;
lli lcm (lli a, lli b) {return ((a*b)/__gcd(a,b));}
lli modpower (lli a,lli b)
{
    if(b==0) return 1;
    lli c=modpower(a,b/2)%mod;
    if (b%2) return (((a*c)%mod)*c)%mod;
    else return (c*c)%mod;
}
lli power (lli a,lli b)
{
    if(b==0) return 1;
    lli c=power(a,b/2);
    if (b%2) return (a*c*c);
    else return c*c;
}
lli sieve (int n)
{
    bool qrr[n+1];
    for (int i=0;i<=n;i++)
    qrr[i]=1;qrr[0]=0;qrr[1]=0;
    for (int i=2;i*i<=n;i++)
    {
        if (qrr[i]==1)
        {
            for (int j=i*i;j<=n;j+=i)
            {qrr[j]=0;}
        }
    }
    return 0;
}
int main()
{
    fio;
    lli n,k;
    cin>>n;
    lli a[n];
    for (int i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    lli sum=0;
    sum+=a[n-1];
    k=n-1;
    //cout<<sum<<"\n";
    int i=n-2;
    for (int j=2;j<=k;j+=2)
    {
        if (j!=k)
        sum+=(2*a[i]);
        else
        {sum+=a[i];}
        //cout<<sum<<" "<<j<<"\n";
        i--;
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 5192
<?php
//Request Question
function getq($get_word=null){
	if($get_word===null){
		return str_replace("\n","",fgets(STDIN));
	}else if($get_word===1){
		return explode(" ",str_replace("\n","",fgets(STDIN)));
	}
}
 
/*		START		*/
$a=getq();
echo $a[0];
$a=getq();
echo $a[1];
$a=getq();
echo $a[2];
echo "\n";
?>

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

int main(){
  
  int n; cin >> n;
  int x, i, j;
  vector<int> vec(n);
  long long ans = 0;
  
  for(x = 0; x < n; x++){

    cin >> vec[x];
    
  }
  

  for(i = 0; i < n; i ++){
    
    for(j = i + 1; j < n; j++){
      
      ans = vec[i] * vec[j] + ans;
    }
    
  }
  
  cout << ans << endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(void){
    // Your code here!
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    
    int b=0; int c=0;
    for(int i=0; i<3; i++){
        if(a[i]==5){
            b++;
        }
        if(a[i]==7){
            c++;
        }
    }
     
    if(b==2&&c==1){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	
	public static long nCk(int n, int k) {
		if(n < k)
			return 0;
		double res = 1;
		for(int i = 1; i <= k; i++)
			res = (n - k + i) * res / i;
		return (long)(0.01 + res);
	}
	
	
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		
		int n = sc.nextInt(), m = sc.nextInt();
		System.out.println(nCk(n, 2) + nCk(m, 2));
		
		
		pw.flush();
	}

	public static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 21204