akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,x,m;
    cin >> n >> x >> m;
    vector<ll> spare(m, -1);
    ll now = x;

    if(n <= 1e7){
        ll ans = 0;
        ll now = x;
        rep(i,n){
            ans += now;
            now = now*now%m;
        }
        cout << ans << endl;
        return 0;
    }

    rep(i,m){
        if(spare[now] != -1) break;
        else{
            spare[now] = i;
            now = now*now%m; 
        }
    }
    ll start = spare[now];
    ll end = i;
    ll shuuki = end-start;
    now = x;
    ll ans = 0;
    for(i = 0;i < start;++i){
        ans += now;
        now = now*now%m;
        --n;
        if(n == 0){
            cout << ans << endl;
            return 0;
        }
    }
    ll kurikaesi = 0;
    for(i = start;i < end;++i){
        kurikaesi += now;
        now = now*now%m;
    }
    ans += n/shuuki*kurikaesi;
    n %= shuuki;
    while(n){
        ans += now;
        now = now*now%m;
        --n;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4044
import java.util.*;

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

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();

		int min = A < C ? C : A;
		int max = B < D ? B : D;

		int out = max < min ? 0 : max - min;
		System.out.println(out);
	}
}


Measured memory_bytes: 21716
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for(int i = 0;i<n;i++){
            a[i] = sc.nextInt();
            sum +=a[i];
        }


        if(sum>=h){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 50840
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{static false_type c(string v);template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
template<class T,enable_if_t<iterable<T>::value,int> =0>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}
template<class T,enable_if_t<is_integral<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-(-a%b);}
template<class T,enable_if_t<is_floating_point<T>::value,int> =0>T mod(T a, T b){if(a>0)return a%b;return b-fmod(-a,b);}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    cout<<setprecision(10);
    int n;
    cin>>n;
    vi a(n);
    cin>>a;
    ll ans=1;
    int c[3]={};
    REP(i,n){
        int d=0;
        REP(j,3)d+=c[j]==a[i];
        ans*=d;
        ans%=MOD;
        if(ans==0){
            print(0);
            return 0;
        }
        REP(j,3)if(c[j]==a[i]){
            ++c[j];
            break;
        }
    }
    //int d=0;
    //REP(j,3)d+=!!c[j];
    //REP(i,d)ans*=i+1;
    cout<<ans<<endl;
}


Measured memory_bytes: 640
N, C = map(int, input().split())

D = [[int(x) for x in input().split()] for i in range(C)]
grid = [[int(x) for x in input().split()] for i in range(N)]

from collections import Counter
groups = [Counter(), Counter(), Counter()]
for x in range(N):
    for y in range(N):
        groups[(x + y) % 3][grid[x][y]] += 1

# N <= 500
# Choose(N, 3) = 500 * 500 * 500 / 6
from itertools import permutations
import sys
m = 500 * 500 * 2000
for c1, c2, c3 in permutations(list(range(0, C)), 3):
    score = sum(D[c-1][c1] *cnt for c, cnt in groups[0].items())
    score += sum(D[c-1][c2] *cnt for c, cnt in groups[1].items())
    score += sum(D[c-1][c3] *cnt for c, cnt in groups[2].items())
    m = min(m, score)

print(m)


Measured memory_bytes: 5748
import java.util.*;
class Main
{
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
          
    if(1<n&&n<4){
      System.out.println(2);
    }else if(4<=n&&n<8){
      System.out.println(4);
    }else if(8<=n&&n<16){
      System.out.println(8);
    }else if(16<=n&&n<32){
      System.out.println(16);
    }else if(32<=n&&n<64){
      System.out.println(32);
    }else if(n==1){
      System.out.println(1);
    }else{
      System.out.println(64);
    }
  }
}

Measured memory_bytes: 23764
#include<stdio.h>

main()
{
	char ch;
	int counter[26] = {0};
	
	
	while(scanf("%c",&ch) != EOF){
		if('a'<= ch && ch <= 'z'){
			counter[ch-'a']++;
		} else if('A'<=ch && ch <= 'Z'){
			counter[ch-'A']++;
		}
	}
	
	
	short i;
	
	for(i=0;i<26;i++){
		printf("%c : %d\n",'a'+i,counter[i]);
	}
	return 0;
}

Measured memory_bytes: 540
#include<bits/stdc++.h>
using namespace std;
#define int int64_t

signed main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int n,i,j,w,ans,re;
    cin>>n;

    string str;
    cin>>str;

    w=0;ans=0;
    for(auto j : str)
        if(j=='W')
            w++;

    re=0;
    for(int i=0;i<n-w;i++)
    {
        if(str[i]=='W')
            re++;
    }
    

    map<int,bool> ok;
    i=0;j=str.size()-1;    while(i<j)
    {
        while(i<n and str[i]=='R')
            i++;

        while(j>i and str[j]=='W')
        {
            ok[j]=true;
            j--;
        }

        if(i<j)
        {
            swap(str[i],str[j]);
            ans++;
            re--;
        }
    }
    
    cout<<min({w,n-w,ans+re})<<endl;

    return 0;
}

Measured memory_bytes: 16100
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
sys.setrecursionlimit(100000)


SIZE = 105
table = [[False]*SIZE for _ in range(SIZE)]


while True:

    N = int(input())
    if N == 0:
        break

    for i in range(N):
        for k in range(N):
            table[i][k] = False

    for i in range(N):
        input_array = list(map(int,input().split()))
        num = input_array[0]
        for k in range(1,(num+1)):
            table[i][input_array[k]-1] = True

    people = list(map(int,input().split()))
    num = people[0]

    candidate = 0
    ans = -1

    for i in range(N):
        FLG = True
        for k in range(1,num+1):
            if table[i][people[k]-1] == False:
                FLG = False
                break
        if FLG == True:
            candidate += 1
            ans = i

    if candidate != 1:
        print("-1")
    else:
        print("%d"%(ans+1))




Measured memory_bytes: 13952
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map> // pair
#include <numeric> // accumulate(begin,end,初期値)

typedef long long ll;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<x<<endl;
#define rep(i,n) for(ll i = 0;i < n;++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0);

const ll INF = 1e9+7;

// 各桁の和
template<typename T>
T digit(T num){
  T sum = 0;
  while(num){
    sum += num % 10;
    num /= 10;
  }
  return sum;
}

template<typename T>T gcd(T a,T b){
  if(b == 0)
    return a;
  return gcd(b,a%b);
}
template<typename T>T lcm(T a, T b){
  T g = gcd(a,b);
  return a/g*b; 
}
template<typename T>T power(T a,T b){
  T tmp = 1;
  rep(i,b){
    tmp *= a;
  }
  return tmp;
}
int main(){
  int n;cin>>n;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  sort(all(a));
  
  ll one = 0,two = 0;
  rep(i,n-1){
    if(a[i] == a[i + 1]){
      two = one;
      one = a[i];
      ++i;
    }
  }
  ll ans = one * two;
  print(ans)
  return 0;
}


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

main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long i,j,k,l,m,n,o,p;
 while(cin>>p){
    int x[p],y[p];
    for(i=0;i<p;i++){
        cin>>x[i]>>y[i];
    }
    j=0,l=0;
    for(i=0;i<p;i++){
        if(x[i]==y[i])j++;
        else j=0;
        if(j>=3)l++;
    }
    if(l>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
 }
    return 0;
}


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

typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int i=0; i<n; ++i) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int d=a[n-1]-a[0];
    if (d>=2) {
        cout << "No";
    } else if (d==1) {
        int chi=upper_bound(a.begin(), a.end(), a[0])-a.begin();
        if (2*(a[0]-chi+1)<=n-chi&&a[0]>chi-1) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    } else {
        if (2*a[0]<=n||a[0]==n-1) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    }
    return 0;
}

Measured memory_bytes: 640
C = [list(map(int, input().split())) for _ in range(3)]

for i in range(3):
    minint = min(C[i])
    for j in range(3):
        C[i][j] -= minint

ans = True

for j in range(3):
    t = C[0][j]
    for i in range(3):
        if t != C[i][j]:
            ans = False
            break

if ans:
    print("Yes")
else:
    print("No")

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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル

	int K, A, B;
	cin >> K >> A >> B;

	FOR(i,A,B+1){
		if(i % K == 0){
			cout << "OK" << endl;
			return;
		}
	}

	cout << "NG" << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;


#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define ub(a,b) upper_bound(all(a),b)
#define lb(a,b) lower_bound(all(a),b)
#define bs(a,b) binary_search(all(a),b)
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) f(i,0,n-1)cin>>a[i]
#define in1(a,n) f(i,1,n)cin>>a[i]
#define out(a,n) f(i,0,n-1)cout<<fixed<<setprecision(20)<<a[i]<<" ";cout<<"\n"
#define ff first
#define ss second
#define f(i,a,b) for (int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define rep(i,n) f(i,0,n-1)
#define clr(a) (a).clear()
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin() ,(a).rend()
#define endl '\n'

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

int n;

vvll multiply(vvll A, vvll B)
{
	vvll C(n,vll(n,0LL));

	rep(i,n)
	{
		rep(j,n)
		{
			rep(k,n)
			{
				C[i][j]+=A[i][k]*B[k][j];
				C[i][j]%=M;
			}
		}
	}

	return C;

}


vvll matrixexpo(vvll M, ll k)
{
	vvll res(n,vll(n,0LL));
	rep(i,n)
		res[i][i]=1;

	while (k>0)
	{
		if (k%2)
		{
			res=multiply(res,M);
		}
		M=multiply(M,M);
		k/=2;
	}

	return res;
}


int main(int argc, char const *argv[])
{
	crap;
	cin>>n;
	ll k;
	cin>>k;
	vvll A(n,vll(n,0));

	rep(i,n)
		rep(j,n)
			cin>>A[i][j];

	vvll ans=matrixexpo(A,k);

	ll paths=0LL;

	rep(i,n)
	{
		rep(j,n)
		{
			paths+=ans[i][j];
			paths%=M;
		}
	}

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

Measured memory_bytes: 384
#include <cstdio>

int main() {
  int N;
  int A[200];
  scanf("%d", &N);
  int ans = 999999999;
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    int tmp = 0;
    while (A[i] % 2 == 0) {
      tmp++;
      A[i] /= 2;
    }
    if (ans > tmp) ans = tmp;
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs, x0) vector<vector<T>> xs(n, vector<T>(m, x0))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n);
    Cin(string, s);
    vector<int> p;
    For(i, n){
        if(i < n-1 && s[i] == s[i+1]){
            p.push_back(2);
            i ++;
        }
        else p.push_back(1);
    }

    ll ans = 3*p[0];
    For(i, (int)p.size()-1){
        if(p[i] == 1 && p[i+1] == 1) ans = (ans * 2) % MOD;
        if(p[i] == 1 && p[i+1] == 2) ans = (ans * 2) % MOD;
        if(p[i] == 2 && p[i+1] == 1) ans = (ans * 1) % MOD;
        if(p[i] == 2 && p[i+1] == 2) ans = (ans * 3) % MOD;
    }
    Cout(ans);
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char a[100];
	char b[100];
	int len1, len2;
	int i, j;
	int flag = 0 ;
	scanf("%s", a);
	scanf("%s", b);
	len1 = strlen(a);
	len2 = strlen(b);

	if (len1 != len2) printf("No");
	else {
		for (i = 0,j = 0; j < len2; i++)
		{
			if (a[i] != b[j] && flag == 0) 
			{
				 continue;
			}
			else 
			{
				flag++;
				if (a[i%len1] != b[j]) 
				{
					printf("No"); break;
				}
				j++;
			}
		}
		if (flag == len2) printf("Yes");

	}
}

Measured memory_bytes: 128
import sys
X, K, D = map(int, input().split())
X = abs(X)
# ずっとマイナスにいく
if X-K*D >= 0:
    print(X-K*D)
    sys.exit()

ans = X % D
K=K-(X//D)
if K%2==0:
    print(ans)
else:
    print(abs(ans-D))


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 2e5 + 7, MOD = 1000 * 1000 * 1000 + 7;
int f[N], c[N], w[N];
vector <int> g[N], a[N];
bool used[N];
map <int, int> cnt;
int dfs(int u) {
    used[u] = 1;
    ++cnt[c[u]];
    int ans = 1;
    for (int v : g[u]) if (!used[v]) ans += dfs(v);
    return ans;
}   
bool comp(int i, int j) { return w[i] < w[j]; }
int n, X, Y;
void check(int i, int j) {
    if ((c[i] == c[j] && w[i] + w[j] <= X) || (c[i] != c[j] && w[i] + w[j] <= Y)) {
        g[i].app(j); g[j].app(i);
    }   
}   
int fp(int a, int n) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= n; ++i) {
        if ((n >> i) & 1) ans = (ans * c) % MOD;
        c = (c * c) % MOD;
    }   
    return ans;
}   
int dv(int a, int b) { return (a * fp(b, MOD - 2)) % MOD; }
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    f[0] = 1;
    for (int i = 1; i < N; ++i) f[i] = (f[i - 1] * i) % MOD;
    cin >> n >> X >> Y;
    for (int i = 1; i <= n; ++i) {
        cin >> c[i] >> w[i];
        a[c[i]].app(i);
    }   
    vector <int> l;
    for (int i = 1; i < N; ++i) {
        if (a[i].size()) {
            sort(all(a[i]), comp);
            l.app(a[i][0]);
            for (int j = 1; j < a[i].size(); ++j) if (w[a[i][0]] + w[a[i][j]] <= X) check(a[i][0], a[i][j]);
        }   
    }   
    sort(all(l), comp);
    if (l.size() > 1) {
        for (int i = 1; i <= n; ++i) {
            check(i, l[0]); 
            check(i, l[1]);
        }   
    }   
    int ans = 1;
    for (int i = 1; i <= n; ++i) {
        if (!used[i]) {
            cnt.clear();
            ans = (ans * f[dfs(i)]) % MOD;
            for (auto e : cnt) ans = dv(ans, f[e.s]);
        }
    }
    cout << ans << '\n';    
}

Measured memory_bytes: 36972
import scala.annotation.tailrec
import scala.io.StdIn._
object Main extends App {
  loop()
  @tailrec def loop(): Unit = {
    val Array(ax1, ay1, bx1, by1) = readLine.trim.split(' ').map(_.toInt)
    if (ax1 == 0 && ay1 == 0 && bx1 == 0 && by1 == 0) return
    val line1 = Line(Point(ax1, ay1), Point(bx1, by1))
    val Array(line2, line3) = Array.tabulate(2){_ ⇒
      val Array(ax, ay, bx, by) = readLine.trim.split(' ').map(_.toInt)
      Line(Point(ax, ay), Point(bx, by))
    }
    println(Some((areas _).curried).flatMap(line1.crossPoint(line2).map).flatMap(line2.crossPoint(line3).map).flatMap(line3.crossPoint(line1).map) match {
      case Some(area) if area >= 1900000 ⇒ "dai-kichi"
      case Some(area) if area >= 1000000 ⇒ "chu-kichi"
      case Some(area) if area >= 100000 ⇒ "kichi"
      case Some(area) if area >= 0.000001 ⇒ "syo-kichi"
      case _ ⇒ "kyo"
    })
    loop()
  }
  def areas(a: Point, b: Point, c: Point): Double = {
    val s = (a.distance(b) + b.distance(c) + c.distance(a)) / 2
    math.sqrt(s * (s - a.distance(b)) * (s - b.distance(c)) * (s - c.distance(a)))
  }
}

case class Point(x: Double, y: Double) {
  def -(that: Point): Vector = Vector(x - that.x, y - that.y)
  def distance(that: Point): Double = (this - that).length
}
case class Vector(x: Double, y: Double) {
  def dot(that: Vector): Double = x * that.x + y * that.y
  def cross(that: Vector): Double = x * that.y - y * that.x
  def length: Double = math.sqrt(x * x + y * y)
  def sin(that: Vector): Double = {
    cross(that) / length / that.length
  }
  def cos(that: Vector): Double = {
    dot(that) / length / that.length
  }
}
case class Line(endA: Point, endB: Point) {
  private val a = endB.y - endA.y
  private val b = endA.x - endB.x
  private val c = endA.y * endB.x - endA.x * endB.y
  def crossPoint(that: Line): Option[Point] = {
    val d = a * that.b - b * that.a
    if (math.abs(d) < 0.0000001) None
    else {
      val cp = Point((b * that.c - c * that.b) / d, (c * that.a - a * that.c) / d)
      Some(cp).filter(isOnLine).filter(that.isOnLine)
    }
  }
  private def isOnLine(that: Point): Boolean = {
    val am = endA - that
    val mb = endB - that
    am.sin(mb).abs <= 0.000001 && (am.cos(mb) + 1 ).abs <= 0.000001
  }
}


Measured memory_bytes: 44396
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
#define ll long long
#define pb push_back

int main()
{
    int n;
    vector<int> x;

    while (1)
    {
        cin >> n;
        if (n == 0)
        {
            break;
        }
        int sum = 0;
        vector<int> a(n);
        for (int i = 0; i < n; i++)
        {
            cin >> a[i];
            sum += a[i];
        }
        int ave = sum / n;
        int cnt = 0;
        for (int j = 0; j < n; j++)
        {
            if (a[j] <= ave)
            {
                cnt++;
            }
        }
        x.push_back(cnt);
    }
    for (int i=0; i< x.size(); i++)
    {
        cout << x[i] << endl;
    }
}



Measured memory_bytes: 3144
#include<iostream>
#include<algorithm>
#include <stdio.h>
#include <cmath>
#include <cstring>
#include<string>
using namespace std;
long long a[100004];
 long long yueshuo(long long x,long long y)
 {
     long long a,b,t;
     a=x,b=y;
     while(b)
     {
         t=a%b;
         a=b;
         b=t;
     }
     return a;
 }
int main()
{
    long long  n,x,t,maxs,mins;
    int i,j,k,step;
    cin>>n>>x;
    a[0]=x;
    for(i=1; i<=n; i++)
    {
           cin>>a[i];
    }
    sort(a,a+n+1);
    t=a[1]-a[0];
    for(j=1;j<=n;j++)
    {
        t=yueshuo(t,a[j]-a[j-1]);
    }
    cout<<t<<endl;
    return 0;
    }


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

long long lcm (long long a, long long b) {
  return (a / __gcd(a, b)) * b;
}

int main () {
  int N;
  cin >> N;
  vector<long long> T(N);
  for (int i = 0; i < N; i++) {
    cin >> T[i];
  }

  long long ans = 1;
  for (int i = 0; i < N; i++) {
    ans = lcm(ans, T[i]);
  }
  cout << ans << endl;
};


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

using namespace std;
#define MOD 1000000007
#define pi 3.1415926535897932384626433832795028841971693993751058209749445923078164062
#define ll long long
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define popb pop_back()
#define popf pop_front()
#define ff first
#define ss second
#define vl vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vll vector< pair<ll,ll> >
#define vii vector< pair<int,int> >
#define viii vector< tuple <int,int,int> >
#define vlll vector< tuple <ll,ll,ll> >
#define vvl vector<vector<ll>>
#define vv vector<vector<int>>
#define all(v) v.begin(),v.end()
#define sqrt sqrtl
#define cbrt cbrtl
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mapcl map<char,ll>
#define mapci map<char,int>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define seti set<int>
ifstream fin("input.txt");
ofstream fout("output.txt");

ll pows(int a , int b)
{
	ll res=1;
	for(int i=0; i<b; ++i)
	{
		res*=a;
	}
	return res;
}

int main()
{	
    std::ios::sync_with_stdio(false);
    //cin.tie(NULL);
    //cout.tie(NULL);
    int x;
    cin>>x;
    ll sum=0;
    vs vec;
    map<string,ll> mps;
    while(x--)
    {
    	string s;
    	cin>>s;
    	sort(all(s));
    	++mps[s];
    }
    for(auto x : mps)
    {
    	sum+=(x.second*(x.second-1))/2;
    }
    cout<<sum;


}

Measured memory_bytes: 11264
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
int N;
ll sum[214514]={0};
ll sumrev[2145145]={0};
int main(){
	ll L;
	int N;
	cin>>L>>N;
	vector<ll> X;
	rep(i,N){
		ll hoge;
		cin>>hoge;
		X.pb(hoge);
	}
	ll ans=max(L-X[0],X[N-1]);
	//cout<<ans<<endl;
	rep(i,N){
		sum[i+1]=sum[i]+X[i];
		sumrev[i+1]=sumrev[i]+(L-X[i]);
	}
	for(int k=1;k<=N-1;k++){
		if(N-k>=k){
			ans=max(ans,2*(sum[k]-sum[0]+sumrev[2*k]-sumrev[k])-X[k-1]);
			//cout<<"j"<<" "<<2*(sum[k]-sum[0]+sumrev[2*k]-sumrev[k])-X[k-1]<<endl;
		}else{
			
			ans=max(ans,2*(sum[k]-sum[2*k-N-1]+sumrev[N]-sumrev[k])-X[k-1]);
		}
		
		if(N-k>k){
			ans=max(ans,2*(sum[k]-sum[0]+sumrev[2*k+1]-sumrev[k])-L+X[k]);
		}
		else{
			
			ans=max(ans,2*(sum[k]-sum[2*k-N]+sumrev[N]-sumrev[k])-L+X[k]);
		}
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 5488
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	vector<int> a;
	vector<int> b;
	int s;
	for(int i=0;i<20;i++){
		scanf("%d",&s);
		(i < 10?a:b).push_back(s);
	}
	sort(a.begin(),a.end());
	sort(b.begin(),b.end());
	printf("%d %d\n",a[7] + a[8] + a[9],b[7] + b[8] + b[9]);
}

Measured memory_bytes: 0
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define pb push_back
using namespace std;
vector<int>a,b,p;
int N;
bool iscmp(){
  int i,t=0;
  for(i=1;i<=N;i++){
    if(t>=a[p[i]]+b[p[i]]) return false;
    t=a[p[i]]+b[p[i]];
  }
  return true;
}
 
int main(void){
  int i,j,k,t,tmp;
  int c,c2;
  a.clear(); b.clear(); p.clear();
  cin>>N;
  a.pb(-1); b.pb(-1); p.pb(-1);
  for(i=1;i<=N;i++){
    cin>>tmp;
    p.pb(tmp);
    a.pb(i*30000);
    b.pb((N-i+1)*30000);
  }
  
  while(!iscmp()){
    t=p[1];
    for(i=2;i<=N;i++){
      
      if((c=a[t]+b[t]) >=  (c2=a[p[i]]+b[p[i]])){
        a[p[i]]+=(c-c2+1);
      }
      t=p[i]; 
    }
  }
 
  for(i=1;i<=N;i++){
    cout<<a[i]<<" ";
  }
  cout<<endl;
 
  for(i=1;i<=N;i++){
    cout<<b[i]<<" ";
  }
  cout<<endl;
 
  return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using pii = pair<int, int>;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main(){
    ll k, a, b;
    cin >> k >> a >> b;
    ll ans = k+1;
    ll u = k - (a - 1);
    if (u > 0) {
        ll y = a + u%2 + u/2*(b-a);
        ans = max(ans, y);
    }
    cout << ans << nl;
}


Measured memory_bytes: 256
#define ll long long
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b)
{
    if (!b)
        return a;
    return gcd(b, a % b);
}
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif //*/
    long double h, w, n;
    cin >> h >> w >> n;
    cout << ceil(n / max(h, w));
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 256
#A
from collections import deque
H,W = map(int,input().split())
A = [list(str(input())) for h in range(H)]

C = [[-1 for w in range(W)] for h in range(H)]


start = deque([])
for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            start.append([h,w])
            C[h][w] = 0
            
while start:
    h,w = start.popleft()
    c_old = C[h][w]
    
    if h > 0:
        c_new = C[h-1][w]
        
        if c_new == -1:
            C[h-1][w] = c_old+1
            start.append([h-1,w])
            
    if w > 0:
        c_new = C[h][w-1]
        
        if c_new == -1:
            C[h][w-1] = c_old+1
            start.append([h,w-1])
            
    if w < W-1:
        c_new = C[h][w+1]
        
        if c_new == -1:
            C[h][w+1] = c_old+1
            start.append([h,w+1])
            
    if h < H-1:
        c_new = C[h+1][w]
        
        if c_new == -1:
            C[h+1][w] = c_old+1
            start.append([h+1,w])
            
            
ans = 0
for h in range(H):
    for w in range(W):
        ans = max(ans,C[h][w])
        
        
print(ans)        
    




Measured memory_bytes: 177884
# -*- coding: utf-8 -*-
s = input()

f = len(s) % 2 == 0
for c in s[0::2]:
    if c != 'h':
        f = False

for c in s[1::2]:
    if c != 'i':
        f = False

if f:
    print('Yes')
else:
    print('No')


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

int main() {
	string S;
	cin >> S;
	if(S == "ABC")
		cout << "ARC" << endl;
	else if(S == "ARC")
		cout << "ABC" << endl;

	return 0;
}

Measured memory_bytes: 3548
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

typedef unsigned long long lu;
typedef vector<int> Poly;

const int mod = 1e9 + 7;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x = Sub(x - y); }
inline int Mul(int x, int y) { return (int)((lu)x * y % mod); }
inline int Mul(int x, int y, int z) { return (int)((lu)x * y % mod * z % mod); }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

int Inv(int x) { return Pow(x, mod - 2); }

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

const int maxn = 600;

int n, m;
int match[maxn];
int min_m[maxn][maxn], max_m[maxn][maxn];
int sum_m[maxn][maxn];
int arr[maxn + 1];
int dp[maxn][maxn];

int main(void) {
  scanf("%d%d", &n, &m);
  n *= 2;
  FILLA(match, -1);
  for (int i = 0; i < m; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    --a; --b;
    match[a] = b;
    match[b] = a;
  }

  for (int i = 0; i < n; ++i) {
    min_m[i][i] = max_m[i][i] = (match[i] == -1 ? i : match[i]);
    sum_m[i][i] = (match[i] != -1);
  }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      sum_m[i][j] = sum_m[i][j - 1] + sum_m[j][j];
      min_m[i][j] = min(min_m[i][j - 1], min_m[j][j]);
      max_m[i][j] = max(max_m[i][j - 1], max_m[j][j]);
    }
  }

  FILLA(arr, 0);
  arr[0] = 1;
  for (int i = 2; i <= n; i += 2) {
    arr[i] = Mul(arr[i - 2], i - 1);
  }

  int ans = 0;
  for (int d = 1; d < n; d += 2) {
    for (int l = 0, r = d; r < n; ++l, ++r) {
      int cnt_match = sum_m[l][r];
      int c_i = (r - l + 1) - cnt_match;
      int c_o = (n - (r - l + 1)) - (2 * m - cnt_match);
      if (min_m[l][r] < l || max_m[l][r] > r) {
        dp[l][r] = 0;
        continue;
      }

      dp[l][r] = arr[c_i];
      // Mul(arr[c_i], arr[c_o]);
      for (int k = l + 1; k < r; k += 2) {
        int c_t = (r - k) - sum_m[k + 1][r];
        // Sub(dp[l][r], Mul(dp[l][k], arr[c_o], arr[c_t]));
        Sub(dp[l][r], Mul(dp[l][k], arr[c_t]));
      }
      Add(ans, Mul(dp[l][r], arr[c_o]));
    }
  }

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


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,sum=0;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n; i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=0; i<k; i++)
        sum+=a[i];
    cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3596
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

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

cnt = [0] * 100010
for a in A:
    if a > 0:
        cnt[a - 1] += 1
    cnt[a] += 1
    cnt[a + 1] += 1

print(max(cnt))

Measured memory_bytes: 14476
#include<cstdio>
#include<algorithm>
using namespace std;
int a[2010][2010];
char str[2010];
int b[2010][2010];
int Max(int x,int y){
	return x>y?x:y;
}
struct node{
	int p,v;
}c[2010];
bool cmp(const node &A,const node &B){
	return A.v>B.v;
}
int f[2010];
int fa(int x){
	if(f[x]==x) return x;
	return f[x]=fa(f[x]);
}
int len[2010];
int main(){
//	freopen("D.in","r",stdin);
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for(int j=1;j<=m;j++)
		{
			if(str[j]=='#')
				a[i][j]=1;
			else
				a[i][j]=0;
		}
	}
	int ans=Max(n,m);
	for(int i=1;i<n;i++){
		b[i][m]=1;
		for(int j=m-1;j>=1;j--){
			if((a[i][j]==a[i+1][j])==(a[i][j+1]==a[i+1][j+1]))
				b[i][j]=b[i][j+1]+1;
			else
				b[i][j]=1;
		}
	}
	int maxlen;
	for(int i=1;i<=m;i++){
		for(int j=1;j<n;j++)
			c[j]=(node){j,b[j][i]};
		for(int j=1;j<=n;j++)
			f[j]=j,len[j]=1;
		maxlen=1;
		sort(c+1,c+n,cmp);
		for(int j=1;j<n;j++){
			len[fa(c[j].p)]+=len[fa(c[j].p+1)];
			f[fa(c[j].p+1)]=fa(c[j].p);
			if(len[fa(c[j].p)]>maxlen)
				maxlen=len[fa(c[j].p)];
			if(maxlen*c[j].v>ans)
				ans=maxlen*c[j].v;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 31744
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int d[2222][2222],ans[2222];
vector<int> g[2222];
queue<int> que;

int main(void){
	int n,i,j,u,v,x,y;
	fill(d[0],d[2222],INF);
	cin >> n >> x >> y; --x; --y;
	g[x].push_back(y);
	g[y].push_back(x);
	for(i=1; i<n; ++i){
		g[i].push_back(i-1);
		g[i-1].push_back(i);
	}
	for(i=0; i<n; ++i){
		d[i][i] = 0;
		que.push(i);
		while(!que.empty()){
			u = que.front();
			que.pop();
			for(j=(g[u].l_ength()-1); j>=0; --j){
				v = g[u][j];
				if(d[i][v] > d[i][u] + 1){
					d[i][v] = d[i][u]+1;
					que.push(v);
				}
			}
		}
	}
	for(i=0; i<n; ++i){
		for(j=0; j<i; ++j){
			++ans[d[j][i]];
		}
	}
	for(i=1; i<n; ++i){
		cout << ans[i] << endl;
	}
	return 0;
}


Measured memory_bytes: 19712
import java.util.Scanner;

class Main {
	int a, b, c;
	int x, y;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Main m = new Main(sc);
		m.solve();
		sc.close();
	}

	Main(Scanner sc) {
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
	}

	void solve() {
		int cost = 0;
		if (a + b > 2 * c) {
			int min = Math.min(x, y);
			cost += 2 * c * min;
			x -= min;
			y -= min;
			if (a > 2 * c) {
				cost += 2 * c * x;
			} else {
				cost += a * x;
			}
			if (b > 2 * c) {
				cost += 2 * c * y;
			} else {
				cost += b * y;
			}
		} else {
			cost += a * x;
			cost += b * y;
		}
		System.out.println(cost);
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll mod = 1e9+7;

int main(void){
  int n;
  cin >> n;
  int a = n / 100;
  int b = n % 100;
  cout << (b <= a * 5 ? '1' : '0') << endl;
  return 0;
}


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

if N < 105:
  print('0')
elif N >= 105 and N < 135:
  print('1')
elif N >= 135 and N < 165:
  print('2')
elif N >= 165 and N < 189:
  print('3')
elif N >= 189 and N < 195:
  print('4')
else:
  print('5')

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


int main(){
    int win[20], N, M, a, c;
    cin >> N >> M;
    a = 1;
    while( M + N > 0 ){
        for(int x = 1; x < 20; x++){
            win[x] = 0;
        }
        win[0] = N;
        c = 0;
        while( !win[M] ){
            int loser = 0;
            for(int x = M-1; x >= 0; x--){
                win[x+1] += win[x]/2;
                loser += win[x]/2;
                win[x] %= 2;
            }
            win[0] += loser;
            c++;
        }
        cout << "Case " << a << ": " << c << endl;
        cin >> N >> M;
        a++;
    }
    return 0;
}

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

const int64_t MOD = 998244353;
void add(int64_t& a, int64_t b){
    a = (a+b) % MOD;
}
void mul(int64_t& a, int64_t b){
    a = a*b % MOD;
}

vector<int64_t> fact, seq_inv, fact_inv;

void create_fact_mod(int num){
    fact[0] = fact[1] = 1;
    for(int i=2; i<=num; i++) fact[i] = fact[i-1] * i % MOD;
}

void create_seq_inv_mod(int num){
    seq_inv[0] = seq_inv[1] = 1;
    for(int i=2; i<=num; i++) seq_inv[i] = (MOD - MOD/i) * seq_inv[MOD%i] % MOD;
}

void create_fact_inv_mod(int num){
    fact_inv[0] = fact_inv[1] = 1;
    for(int i=2; i<=num; i++) fact_inv[i] = fact_inv[i-1] * seq_inv[i] % MOD;
}

void create_mod_tables(int num){
    fact.resize(num+1);
    seq_inv.resize(num+1);
    fact_inv.resize(num+1);
    create_fact_mod(num);
    create_seq_inv_mod(num);
    create_fact_inv_mod(num);
}

int64_t comb_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD * fact_inv[k] % MOD;
}

int64_t perm_mod(int n, int k){
    return fact[n] * fact_inv[n-k] % MOD;
}

int64_t power_mod(int64_t num, int64_t power){
    int64_t prod = 1;
    num %= MOD;
    while(power > 0){
        if(power&1) prod = prod * num % MOD;
        num = num * num % MOD;
        power >>= 1;
    }
    return prod;
}

int64_t extgcd(int64_t a, int64_t b, int64_t& x, int64_t& y){
    int64_t d = a;
    if(b != 0){
        d = extgcd(b, a%b, y, x);
        y -= (a/b) * x;
    }else{
        x = 1; y = 0;
    }
    return d;
}

int64_t inv_mod(int64_t a){
    int64_t x, y;
    extgcd(a, MOD, x, y);
    return (MOD + x%MOD) % MOD;
}

int main(){
    int N;
    cin >> N;
    const int MX = 1e6;
    static int64_t sum[MX+1];
    int64_t ans = 0;
    for(int i=0; i<N; i++){
        int a;
        scanf("%d", &a);
        add(ans, MOD - a);
        for(int i=1; i*i<=a; i++) if(a%i == 0){
            add(sum[i], a);
            if(i < a/i) add(sum[a/i], a);
        }
    }

    static int64_t C[MX+1];
    for(int i=1; i<=MX; i++){
        int64_t v = sum[i]*sum[i] % MOD;
        add(C[i], inv_mod(i));
        add(ans, C[i]*v);
        for(int j=2; j*i<=MX; j++) add(C[i*j], MOD - C[i]);
    }
    mul(ans, inv_mod(2));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define mod 1000000007
#define endl "\n"
#define infinity 1000000000000000000
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
struct compare {//priority q ascending
    bool operator()(const int l, const int r) {
        return l > r;
    }
};
struct hash_pair { //unordered map of pairs
    template <class T1, class T2> 
    size_t operator()(const pair<T1, T2>& p) const
    { 
        auto hash1 = hash<T1>{}(p.first); 
        auto hash2 = hash<T2>{}(p.second); 
        return hash1 ^ hash2; 
    } 
}; 
int32_t main()
{
    fast;
    int n,maxwt;
    cin>>n>>maxwt;
    int wt[n+1],val[n+1];
    for(int i=0;i<n;i++)
        cin>>wt[i]>>val[i];
    int dp[n+1][maxwt+1];//rows are elements of array..columns are 0 to maxwt
    for(int i=0;i<n;i++)
        dp[i][0]=0;//when maxwt is 0 then ans is always 0 coz wts>=1

    for(int i=1;i<=maxwt;i++)//for filling the first row
    {
        if(i>=wt[0])
            dp[0][i]=val[0];
        else dp[0][i]=0;
    }
    for(int i=1;i<n;i++)
    {
        for(int j=1;j<=maxwt;j++)
        {
            if(j<wt[i]) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
        }
    }
   cout<<dp[n-1][maxwt];
}

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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ASC(x) sort(ALL((x)))
#define DESC(x) sort(ALL((x)),greater<ll>())
#define pb push_back

int main()
{
    ll N, K;
    cin >> N >> K;
    vec p(N);
    REP(i,0,N) cin >> p[i];

    ll sum = 0;
    REP(i,0,K) sum += p[i]; 

    ll m = sum;
    REP(i,K,N) {
        sum = sum + p[i] - p[i-K];
        m = MAX(m,sum);
    }
    cout << setprecision(12) << (K + m) / 2.0 << endl;

    return 0;
}

/*



*/

Measured memory_bytes: 1792
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int ans = 1001;
    string s , t;
    cin >> s >> t;
    for (int i = 0 ; i <= s.size() - t.size() ; i++){
        int cnt = 0;
        for (int j = 0 ; j < t.size() ; j++)
            if (s[i + j] != t[j])
                ++cnt;
        ans = min(ans , cnt);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3596
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from math import gcd, ceil
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    N = int(input())
    Bs = []
    As = []
    for i in range(N):
        a, b = map(int, input().split())
        As.append(a)
        Bs.append(b)
    min_med = np.median(As)
    max_med = np.median(Bs)
    if N % 2 == 0:
        print(int(2 * (max_med - min_med) + 1))
    else:
        print(int((max_med - min_med) + 1))
    


if __name__ == '__main__':
    main()


Measured memory_bytes: 45832
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

ll comb(int n, int k)
{
	if(n<0 || k<0 || n<k) return 0;
  ll table[n + 1][n + 1];
  for (int i = 0; i <= n; i++)
    table[i][0] = 1;
  for (int i = 1; i <= k; i++)
    table[i][i] = 1;

  for (int i = 2; i <= n; i++)
  {
    for (int j = 1; j < min(i, k + 1); j++)
    {
      table[i][j] = table[i - 1][j - 1] + table[i - 1][j];
    }
  }
  return table[n][k];
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,a,b;
	cin >> n >> a >> b;
	vector<ll> v(n);
	map<ll, int> mp, mp_a;
	REP(i,n){ 
		cin >> v[i];
		mp[v[i]]++;
	}
	sort(ALL(v), greater<ll>());

	ll sum = 0;
	REP(i,a){
		sum += v[i];
		mp_a[v[i]]++;
	}
	ll pat = comb(mp[v[a-1]], mp_a[v[a-1]]);
	if(mp_a.size()==1){
		FOR(k,a+1,b+1){
			//cout << mp[v[a-1]] << " " << mp_a[v[a-1]]+k-a << '\n';
			pat += comb(mp[v[a-1]], mp_a[v[a-1]]+(k-a));
		}
	}
	printf("%.6f\n%lld\n", (double)sum/a, pat);
	return 0;
}



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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    // cout << fixed << setprecision(5);

    // 入力
    int n;
    cin >> n;

    // 処理
    if (n == 1) {
        cout << "Hello World" << endl;
    } else if (n == 2) {
        int a, b;
        cin >> a >> b;

        cout << a + b << endl;
    }
    // 出力

    return 0;
}


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

int main()
{
    int d[2000000];
    int alphabet_max = 26;
    long long N;
    const long long MOD = 1000000007;
    cin >> N;
    string S;
    cin >> S;
    long long kosuu[26];
    for (int i = 0; i < alphabet_max; i++)
    {
        kosuu[i] = 0;
        for (int j = 0; j < N; j++)
        {
            if (S.at(j) == 'a' + i)
            {
                kosuu[i]++;
            }
        }
        kosuu[i]++;
    }
    long long ans = 1;
    for (int i = 0; i < alphabet_max; i++)
    {
        ans *= kosuu[i];
        ans %= MOD;
    }
    if (ans == 0)
    {
        cout << MOD - 1 << endl;
        return 0;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512