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

int main(){
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> time;
    ll n;
    cin >> n;
    for(int i = 0; i < 5; i++){
        ll t;
        cin >> t;
        time.push_back(t);
    }
    sort(time.begin(), time.end());
    ll ans = 5;
    ans += (n / time[0]);
    if(n % time[0] == 0){
        ans--;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n, a, b = map(int, input().split())

p = 10**9+7

def f(x, n, p):
    if n == 1:
        return x % p
    if n % 2 == 1:
        return (x * f(x, n-1, p)) % p
    y = f(x, n//2, p)
    return (y**2) % p

def ff(n, m):
    x = 1
    for i in range(n-m+1, n+1):
        x *= i
        x %= p
    return x

res = f(2, n, p) - 1
res -= (ff(n, a) * f(ff(a, a), p-2, p)) % p
res -= (ff(n, b) * f(ff(b, b), p-2, p)) % p

while res < 0:
    res += p

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime> 

using namespace std;

char tile[101][101];

void loop(int x,int y){
	if(tile[x][y]=='.'){
		cout << y << ' ' << x << endl;
		return;
	}
	if(tile[x][y]=='#'){
		cout << "LOOP" << endl;
		return;
	}
	if(tile[x][y]=='>'){
		tile[x][y]='#';
		loop(x,y+1);
	}
	if(tile[x][y]=='<'){
		tile[x][y]='#';
		loop(x,y-1);
	}
	if(tile[x][y]=='^'){
		tile[x][y]='#';
		loop(x-1,y);
	}
	if(tile[x][y]=='v'){
		tile[x][y]='#';
		loop(x+1,y);

	}
}

int main(void){
	int h,w;
	int x,y;
	int a;
	while(1){
		x=0,y=0;
		cin >> h >> w;
		if(h==0 && w==0)break;
		for(a=0;a<h;a++){
			cin >> tile[a];
		}
		loop(0,0);
	}
	return 0;
}

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

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

int main() {
    int N;
    cin >> N;
    int d1[N], d2[N];
    rep(i, N) cin >> d1[i] >> d2[i];
    int cnt = 0;
    bool flag = false;
    rep(i, N) {
        if(d1[i] == d2[i]) {
            cnt++;
        } else {
            cnt = 0;
        }
        if(cnt >= 3) {
            flag = true;
        }
    }
    if(flag) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <string>
#include <queue>
#include <stack>
#include <tuple>
#include <list>
#include <set>
#include <map>
#include <functional>
#include <cmath>
#include <cstring>
#include <cstdlib>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

#define xx first
#define yy second
#define $1 first
#define $2 second

typedef struct _schedule {
	int s, t;
	int idx;
	char c;
} schedule;

bool operator < (const schedule& a, const schedule& b) {
	return a.t < b.t;
}

bool cmp(schedule& a, schedule& b) {
	return a.idx < b.idx;
}

void solveCase() {
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n; cin >> n;
	set<string> s;
	for (int i = 0; i < n; i++) {
		string t;
		cin >> t;
		s.insert(t);
	}
	cout << s.size();

}

int main() {

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif
	solveCase();
}

Measured memory_bytes: 19236
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
class Person{
    public:
        int h, p;
        Person(int a, int b){
            h = a;
            p = b;
        }
        bool operator<(const Person &o) const{
            int x1 = (h+p);
            int x2 = (o.h+o.p);
            return x1<x2;
        }
};
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    vector<Person> li;
    int n;
    cin >> n;
    long long inf = 3000000001;
    for(int i = 0; i<n; i++){
        int a, b;
        cin >> a >> b;
        li.push_back(Person(a,b));
    }
    long long can[n+1];
    for(int i = 1; i<=n; i++){
        can[i] = inf;
    }
    can[0] = 0LL;
    sort(li.begin(),li.end());
    for(int i = 0; i<n; i++){
        for(int j = n-1; j>=0; j--){
            if((long long)li[i].h>=can[j]){
                can[j+1] = min(can[j+1],can[j]+(long long)li[i].p);
            }
        }
    }
    for(int i = n; i>=0; i--){
        if(can[i]!=inf){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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


int main(){
	string S,T;
	cin>>S>>T;
	
	map<char,int> mp[2];
	int a=1,b=1;
	for(int i=0;i<S.size();i++){
		if(!mp[0][S[i]]){
			mp[0][S[i]]=a;
			S[i]='a'-1+a;
			a++;
		}
		else{
			S[i]='a'-1+mp[0][S[i]];
		}
		
		if(!mp[1][T[i]]){
			mp[1][T[i]]=b;
			T[i]='a'-1+b;
			b++;
		}
		else{
			T[i]='a'-1+mp[1][T[i]];
		}
		
	}
	
	if(S==T)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	
	return 0;
}

Measured memory_bytes: 776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)
#define l_ength size

ll sq(ll x){
	return x*x;
}

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

bool isvowel(char c){
	int i;
	string v="aeiou";
	for(i = (v.size()-1); i>=0; --i){
		if(c == v[i]){
			return true;
		}
	}
	return false;
}

ll manhattan(ll x1, ll y1, ll x2, ll y2){
	return ((ll)(abs(x1-x2)+abs(y1-y2)));
}

ll digit(ll x){
	ll ans = 0ll;
	if(!x){
		return 0ll;
	}
	while(x>0){
		ans++;
		x /= 10;
	}
	return ans;
}

ll f(ll a, ll b){
	return max(digit(a),digit(b));
}

char ltou(char c){
	c -= 'a';
	c += 'A';
	return c;
}

int main(void){
	string a,b,c;
	cin >> a >> b >> c;
	cout << ((a[a.l_ength()-1] == b[0] && b[b.l_ength()-1] == c[0])?"YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int num;
    scanf("%d",&num);
    int rem = 0, sum = 0, n;
    n = num;

    while(num > 0){
        rem = num%10;
        sum = sum + rem;
        num = num/10;
    }
    if(n%sum == 0)
        printf("Yes", n);
    else
        printf("No", n);

    return 0;
}


Measured memory_bytes: 128
from collections import Counter, defaultdict
import sys

sys.setrecursionlimit(10 ** 5 + 10)
# input = sys.stdin.readline
from math import factorial
import heapq, bisect
import math
import itertools

import queue
from collections import deque

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

def main():
    num = int(input())
    data1 = tuple(map(int, input().split()))
    data2 = tuple(map(int, input().split()))

    p = list(itertools.permutations([i + 1 for i in range(num)], num))

    print(abs(p.index(data1) - p.index(data2)))




if __name__ == '__main__':
    main()


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

int main(){
    int N,D,X,ans=0;
    int A;
    
    cin>>N>>D>>X;
    
    for(int i=0;i<N;i++){
        cin>>A;
        ans++;
        for(int j=1;j<=D;j++){
            if(A*j+1<=D)ans++;
        }
    }
    
    cout<<ans+X<<endl;
    
    return 0;
    
    
    
    
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define x first
#define y second
#define nax (int)1e5+2
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n" 
#define INF (int)1e9
#define eps (long double)1e-9
using namespace std;


int main(){
	fast;
	int n,k;
	cin >> n >> k;
	set<int> s;
	for(int i =0;i<k;i++){
		int cnt;
		cin >> cnt;
		for(int j =0;j<cnt;j++){
			int temp;
			cin >> temp;
			s.insert(temp);
		}
	}
	cout<<n - s.size();

	return 0;
}
	


Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <string>
using namespace std;

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

    int n, r, b;
    n = s.size();
    r = 0; b = 0;
    for (int i = 0; i < n; i++){
        if (s[i] == '0') r += 1;
        else b += 1;
    }
    cout << 2 * fmin(r, b) << endl;
}


Measured memory_bytes: 512
#include<stdio.h>
int main(){
  int n,i,j,k,s,a,b,ans,ma,t,min,mi,max;
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    int m[10][10]={{0}};
    for(i=0;i<100;i++)m[i/10][i%10]=-1;
    for(i=max=0;i<n;i++){
      scanf("%d %d %d",&a,&b,&t);
      m[a][b]=t;
      m[b][a]=t;
      if(max<a)max=a;
      if(max<b)max=b;
    }//printf("%d ",max);
    ans=2100000000;
    for(i=0;i<=max;i++){
      int c[10]={0};
      for(j=0;j<10;j++)c[j]=100000000;
      c[i]=0;
      char f[10]={0};
      mi=i;
      for(k=0;k<=max;k++){
	f[mi]=1;
	for(j=0;j<=max;j++){
	  if(m[mi][j]==-1||f[j])continue;
	  if(c[mi]+m[mi][j]<c[j]){
	    c[j]=c[mi]+m[mi][j];
	  }
	}
	min=2100000000;
	//printf("%d:",i);
	for(j=0;j<=max;j++){//printf(" %d",c[j]);
	  if(f[j])continue;
	  if(min>c[j]){
	    mi=j;
	    min=c[j];
	  }
	}//printf("mi:%d\n",mi);
      }
      for(j=s=0;j<=max;j++)s+=c[j];
      if(ans>s){
	ans=s;
	ma=i;
      }
    }
    printf("%d %d\n",ma,ans);
  }
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int a, b; scanf("%d%d", &a, &b);
	
	printf("%d\n", std::max({a + b, a - b, a * b}));
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int n;
    cin >> n;
    vector<long> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    sort(a, greater<long>());
    long ans = 0;
    ans += a[0];
    for (int i = 1; i <= (n - 2) / 2; i++) {
        ans += a[i] * 2;
    }
    if ((n - 2) % 2 == 1) {
        ans += a[(n - 2) / 2 + 1];
    }
    cout << ans << endl;
}


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

using namespace std;

#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define mod 1000000007
#define ff first
#define ss second
#define pb push_back
#define mp make_pair




int main()
{
    fast;
    //openin;
    //openout;

     //cout<<"sdjvhbsdjbsjd"<<endl;
     string s;
     cin>>s;
     stack<char> text;
     vector<char> res;
     for(int i=0;i<s.length();i++){
            if(s[i]=='0'||s[i]=='1')    text.push(s[i]);
            if(!text.empty()){
                if(s[i]=='B')   text.pop();
        }
     }
     while(!text.empty()){
        res.push_back(text.top());
        text.pop();
     }
     for(int i=res.size()-1;i>=0;i--)     cout<<res[i];
    return 0;
}


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


int main(){
  string S;
  int K;
  
  cin >> K >> S;
  
  if(S.size()<=K)
    cout << S <<endl;
  else{
    rep(i,K)
    	cout <<	S.at(i);
    cout << "..." <<endl;
  }
  
  
 
  
}

Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	
	public static void main(String[] args) {
		try {
			BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
			int i = 1;
			while (true) {
				String str = reader.readLine();
				String[] arr = str.split(" ");
				int x = Integer.parseInt(arr[0]);
				int y = Integer.parseInt(arr[1]);

				if (x == 0 && y == 0) {
					break;
				}
				
				if (x < y) {
					System.out.println(x + " " + y);
				} else {
					System.out.println(y + " " + x);
				}
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

}

Measured memory_bytes: 26996
array = [];
ans = 0;

for i in range(6):
    array.append(int(input()));

if abs(array[0] - array[1]) > array[5]: ans += 1;
if abs(array[0] - array[2]) > array[5]: ans += 1;
if abs(array[0] - array[3]) > array[5]: ans += 1;
if abs(array[0] - array[4]) > array[5]: ans += 1;

if abs(array[1] - array[2]) > array[5]: ans += 1;
if abs(array[1] - array[3]) > array[5]: ans += 1;
if abs(array[1] - array[4]) > array[5]: ans += 1;

if abs(array[2] - array[3]) > array[5]: ans += 1;
if abs(array[2] - array[4]) > array[5]: ans += 1;

if abs(array[3] - array[4]) > array[5]: ans += 1;

if ans == 0: print("Yay!");
else: print(":(")



Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000000LL;
const int MAX_N = 105;
const int MAX_W = 100005;

int n, W;
ll w[MAX_N], v[MAX_N];
ll dp[MAX_N][MAX_W];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> W;
	for (int i = 0; i < n; i++)
		cin >> w[i] >> v[i];

	for (int i = 0; i < n; i++)
		for (int j = 0; j <= W; j++)
			dp[i][j] = -INF;
	dp[0][0] = 0;
	dp[0][w[0]] = v[0];

	for (int i = 0; i < n - 1; i++)
		for (int j = 0; j <= W; j++)
		{
			if (dp[i][j] == -INF)
				continue;
			dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
			if (j + w[i + 1] <= W)
				dp[i + 1][j + w[i + 1]] = max(dp[i + 1][j + w[i + 1]], dp[i][j] + v[i + 1]);
		}

	ll result = -INF;
	for (int i = 0; i <= W; i++)
		result = max(result, dp[n - 1][i]);
	cout << result << endl;
}

Measured memory_bytes: 80256
#include <iostream>

using namespace std;

int main(void){
  int n, m, c, sum, a, counter = 0;
  int b[20];
  cin >> n >> m >> c;
  for(int i = 0; i < m; i++){
    cin >> b[i];
  }
  for(int i = 0; i < n; i++){
    sum = c;
    for(int j = 0; j < m; j++){
      cin >> a;
      sum += a*b[j];
    }
    if(sum > 0) counter++;
  }
  cout << counter << endl;
}


Measured memory_bytes: 256
<?php
$S=fgets(STDIN);
$l=strlen($S);
$s='';
for($i=0;$i<$l;$i++){
	$n=ord($S[$i]);
	if(64<$n && $n<91) $s.=chr($n+32);
	elseif(96<$n && $n<123) $s.=chr($n-32);
	else $s.=$S[$i];
}
echo $s;

Measured memory_bytes: 15332
#include<bits/stdc++.h>
using namespace std;
char s[100000+10];
int red,blue;
int main()
{
    cin>>s;
    int len=strlen(s);
    for(int i=0;i<len;i++)
    {
        if(s[i]=='0')   red++;
        else blue++;
    }
    cout<<min(red,blue)*2;
    return 0;
}

Measured memory_bytes: 384
// HARE KRISHNA
# include <iostream>
using namespace std;
int main()
{
	int x,y,c;
	cin>>x>>y;
	if(y%2==0)
	{
		c=y/2;
		if(x>c)
		{
			cout<<"No";
			return 0;
		}
		if((y/4+(y%4)/2)>x)
		{
			cout<<"No";
			return 0;
		}
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
		return 0;
	}
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

map<ll,ll> res_a;

map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for  (ll i=2;i*i<=n;i++){
        while (n%i == 0){
            ++ res[i];
            n /= i;
        }
    }
    if(n!=1){
        res[n] += 1;
    }
    return res;
}

int main() {
    
    ll n,p;
    cin >> n >> p;
    res_a = prime_factor(p);
    ll ans = 1;

    for (auto itr = res_a.begin();itr != res_a.end();itr++){
        for (ll i=1;i<=(itr ->second)/n;i++){
            ans *= (itr -> first);

        }
    }
    cout << ans << endl;


}




Measured memory_bytes: 256
import sys
from fractions import gcd
from functools import reduce
def input(): return sys.stdin.readline().rstrip()

def main():
    MOD = 10 ** 9 + 7
    n = int(input())
    A = tuple(map(int, input().split()))
    gcd_v = reduce(lcm, A)

    ans = 0
    for i in A:
        ans += gcd_v * pow(i, MOD-2, MOD) % MOD
        ans %= MOD
    print(ans)

def lcm(n, m):
    return (n * m) // gcd(n, m)    

if __name__ == '__main__':
    main()


Measured memory_bytes: 6100
from collections import Counter
n,*v=map(int,open(0).read().split())
s=sorted(Counter(v[::2]).items(),key=lambda x:x[1])
t=sorted(Counter(v[1::2]).items(),key=lambda x:x[1])
if s[-1][0]==t[-1][0]:
  if len(s)==1 and len(t)==1:
    print(n//2)
  elif len(s)==1:
    print(n-s[0][1]-t[-2][1])
  elif len(t)==1:
    print(n-s[-2][1]-t[0][1])
  else:
    if s[-2][1]<t[-2][1]:
      print(n-s[-1][1]-t[-2][1])
    else:
      print(n-s[-2][1]-t[-1][1])
else:
  print(n-s[-1][1]-t[-1][1])

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

int	main()
{
	string	str;
	getline(cin, str);
	for (char &x : str) {
		if ('a' <= x && x <= 'z')
			x += 'A' - 'a';
		else if ('A' <= x && x <= 'Z')
			x += 'a' - 'A';
	}
	cout << str << endl;
}



Measured memory_bytes: 3104
#B問題
import bisect

N = int(input())
S = list(str(input()))
mod = 998244353
N_factorial = 1
for i in range(N):
    N_factorial*=(i+1)
    N_factorial%=mod

r,g,b = [],[],[]
for i,s in enumerate(S):
    if s == "R":
        r.append(i)
    if s == "G":
        g.append(i)
    if s == "B":
        b.append(i)
        
A,B,C = [],[],[]
for i in range(N):
    rgb = [r[i],g[i],b[i]]
    rgb.sort()
    A.append(rgb[0])
    B.append(rgb[1])
    C.append(rgb[2])

ans = N_factorial
for i,B_ind in enumerate(B):
    x = bisect.bisect_left(A,B_ind)-i
    y = i+1-bisect.bisect_left(C,B_ind)
    ans*=(x*y)
    ans%=mod

print(ans)

Measured memory_bytes: 75048
#include<iostream>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int t=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='-')
		t--;
		else
		t++;
	}
	cout<<t;
	return 0;
}

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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, size_t size> void fill(T (&ary)[size], const T& val){
    fill_n((T*)ary, size, val);
}

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

i64 mod_inverse(i64 a, i64 m) {
    i64 x, y;
    if (extgcd(a, m, x, y) == 1) return (x + m) % m;
    return 0;
}

vector<i64> fact;
void init_fact(i64 n, i64 m) {
    fact.resize(n + 1);
    fact[0] = fact[1] = 1;
    for (i64 i = 2; i <= n; ++i) fact[i] = (i * fact[i - 1]) % m;
}

i64 mod_comb(i64 n, i64 k, i64 p) {
    if (n < 0 or k < 0 or n < k) return 0;

    if(n>=p) return 0;

    if(n-k<k) return mod_comb(n,n-k,p);

    i64 num = 1, den = 1;
    for (i64 i = 0; i < k; ++i) {
        num = num * ((n - i) % p) % p;
        den = den * (i + 1) % p;
    }
    return num * mod_inverse(den, p) % p;
}

void solve() {
    const i64 mod = 1'000'000'007;

    i64 N,M,K;
    cin >> N >> M >> K;

    i64 ans=0,tmp=mod_comb(N*M-2,K-2,mod);
    {
        i64 sum=0;
        rep(d,1,M){
            i64 cnt=M-d;
            sum+=d*cnt%mod*N%mod*N%mod*tmp%mod;
        }
        ans+=sum;
        ans%=mod;
    }
    {
        i64 sum=0;
        rep(d,1,N){
            i64 cnt=N-d;
            sum+=d*cnt%mod*M%mod*M%mod*tmp%mod;
        }
        ans+=sum;
        ans%=mod;
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

using namespace std;

const int INF = numeric_limits<int>::max()/2;

struct State{
    int x,y,dir,d;
    State(int x, int y, int dir, int d): x(x),y(y),dir(dir),d(d){}
};

bool operator < (const State &e, const State &f){
    return e.d > f.d;
}

int dis[40][40][4];
int dx[4] = {0,1,0,-1},dy[4]={1,0,-1,0};
vector<vector<int>> inst(40,vector<int>(40));
vector<int> c(4);
int w,h;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(cin>>w>>h,w||h){
        for(int i=0;i<h;i++) for(int j=0;j<w;j++) for(int k=0;k<4;k++) dis[i][j][k]=INF;
        for(int i=0;i<h;i++) for(int j=0;j<w;j++) cin>>inst[i][j];
        for(int i=0;i<4;i++) cin>>c[i];
        priority_queue<State> q;
        q.push(State(0,0,0,0));
        dis[0][0][0]=0;
        while(!q.empty()){
            State s = q.top();q.pop();
            int x=s.x, y=s.y,dir=s.dir,dist=s.d;
            if(dis[x][y][dir]<dist) continue;
            //cout<<x<<" "<<y<<" "<<dir<<endl;
            for(int i=0;i<4;i++){
                int nx=x+dx[i],ny=y+dy[i];
                if(nx<0 || h<=nx || ny<0 || w<=ny) continue;
                int cost;
                if(inst[x][y]!=4 && (dir+inst[x][y])%4==i) cost=0;
                else cost = c[(4+i-dir)%4];

                if(dis[nx][ny][i]<=dist+cost) continue;
                dis[nx][ny][i]=dist + cost;
                q.push(State(nx,ny,i,dis[nx][ny][i]));
                //cout<<nx<<" "<<ny<<" "<<i<<" "<<dis[nx][ny][i]<<endl;
            }
        }
        int res=INF;
        for(int i=0;i<4;i++) res=min(res,dis[h-1][w-1][i]);
        cout<<res<<endl;
    }
}


Measured memory_bytes: 3272
import sys
input = sys.stdin.readline
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
# A = [ int(input()) for _ in range(N) ]
##############################

N = int(input())

def dfs(X, bit, count):
    if bit == 7:
        if X <= N:
            count += 1

    if X >= N:
        return count


    count = dfs(X*10+7, bit|4, count)
    count = dfs(X*10+5, bit|2, count)
    count = dfs(X*10+3, bit|1, count)

    return count


count = dfs(0, 0, 0)
print(count)


Measured memory_bytes: 3064
n = int(input())
def factorization(n): #素因数分解のプログラム([素因数,指数]のリストのリストで出力→24→[[2, 3], [3, 1]])
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            for _ in range(cnt):
                arr.append(i)

    if temp!=1:
        arr.append(temp)

    if arr==[]:
        arr.append(n)
    
    return arr 
if n == 1:
    print(1)
else:
    di = [1]*1000
    for i in range(2,n+1):
        a = factorization(i)
        for j in a:
            di[j-1] += 1
    p = 1
    for k in di:
        p *= k
        if p >= 10**9+7:
            p %= 10**9+7
    print(p)
    

Measured memory_bytes: 74484
#!/usr/bin/env python3

def solv(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return b // 2
    else:
        return 0


if __name__ == '__main__':

    a, b = map(int, input().split())

    ans = solv(a, b)

    print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b,k;
    cin >> k;
    cin >> a >> b;
    int i = 0;
    while(k*i < 1001){
        if(a <= k*i && k*i <= b){
            cout << "OK" << endl;
            return 0;
        }
        i++;
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3600
#include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define INFTY 2000000001
#define MAX 101

int n = 0;
int adl[MAX][MAX], deg[MAX];
int adm[MAX][MAX];

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      adm[i][j] = 0;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int num;
    scanf("%d", &num);
    num--;
    scanf("%d", &deg[num]);
    for ( int j = 0; j < deg[num]; j++) {
      scanf("%d", &adl[num][j]);
      adl[num][j]--;
      adm[num][adl[num][j]] = 1;
    }
  }

  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n-1; j++ ) {
      printf("%d ", adm[i][j]);
    }
    printf("%d\n", adm[i][n-1]);
  }

  return 0;
}



Measured memory_bytes: 2744
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;

class Program {
    internal static void Main(string[] args) {
        var N = int.Parse(ReadLine());
        var A = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var B = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var C = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        Array.Sort(A);
        Array.Sort(C);

        long ans = 0;
        for (int i = 0; i < N; i++) {
            long ACnt = LowerBound(A, B[i]);
            long CCnt = C.Length - UpperBound(C, B[i]);
            ans += ACnt * CCnt;
        }
        WriteLine(ans);

    }

    static int UpperBound(int[] array, int value) {
        int low = 0;
        int high = array.Length;
        while (low < high) {
            var mid = (high + low) / 2;
            if (value < array[mid]) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return high;
    }

    static int LowerBound(int[] array, int value) {
        int low = 0;
        int high = array.Length;
        while (low < high) {
            var mid = (high + low) / 2;
            if (value <= array[mid]) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }
        return low;
    }
}

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

template<typename T>
istream& operator >> (istream& istr, vector<T>& v){
    for(T& x: v) istr >> x;
    return istr;
}

template<typename T, typename U>
istream& operator >> (istream& istr, pair<T,U>& p){
    istr >> p.first >> p.second;
    return istr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<T>& v){
    if(!v.empty()){
        ostr << v.front();
        for(auto itr = ++v.begin(); itr != v.end(); itr++)
            // ostr << *itr;
            ostr << " " << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, pair<T,U>& p){
    // ostr << p.first << p.second;
    ostr << p.first << ", " << p.second;
    return ostr;
}

template<typename T>
ostream& operator << (ostream& ostr, vector<vector<T>>& vv){
    if(!vv.empty()){
        ostr << vv.front();
        for(auto itr = ++vv.begin(); itr != vv.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

template<typename T, typename U>
ostream& operator << (ostream& ostr, vector<pair<T,U>>& vp){
    if(!vp.empty()){
        ostr << vp.front();
        for(auto itr = ++vp.begin(); itr != vp.end(); itr++)
            ostr << endl << *itr;
    }
    return ostr;
}

typedef long long ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<double> vd;
// vll x(n); x[i]=a;
typedef vector<vll> vvll;
typedef vector<vc> vvc;
typedef vector<vd> vvd;
// vvll x(m,vi(n)); x[i][j]=a;
typedef pair<ll,ll> pll;
typedef pair<double,double> pd;
typedef vector<pll> vpll;
typedef vector<pd> vpd;
// vpll x(n); x[i]={a,b}; x[i].first/second;

#define PI 3.1415926535897932
#define EPS 1e-12
#define INF (ll)1e+12
#define REP(i,n) for(ll i=0; i<(n); i++)
#define RREP(i,n) for(ll i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORR(i,a,b) for(ll i=(b)-1; i>=(a); i--)
#define fix(x) cout << fixed << setprecision(x)
#define dump(x) cout << #x << " = " << (x) << endl
#define all(x) (x).begin(),(x).end()

template<typename T> T sum(vector<T>& v){return accumulate(all(v), (T)0);}
template<typename T> inline void sort(vector<T>& v){sort(all(v));}
template<typename T> inline void rsort(vector<T>& v){sort(all(v), greater<T>());}
template<typename T> inline void chmin(T& a, T b){if(a>b) a=b;}
template<typename T> inline void chmax(T& a, T b){if(a<b) a=b;}

int main(){
    ll n, k, ans;
    cin >> n >> k;
    ans = n%k;
    if(ans>k/2) ans=abs(ans-k);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
x = int(input())
if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
elif x <= 1999:
    print(1)

Measured memory_bytes: 9116
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
using namespace std;
  
int main () {
  int n, m, x, y;
  cin >> n >> m >> x >> y;
  vector<int> a(n), b(m);
  rep(i,n) cin >> a.at(i);
  rep(i,m) cin >> b.at(i);
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  if(a.at(n-1) > x && a.at(n-1) < y) {
    if(b.at(0) > a.at(n-1)) {
      cout << "No War";
      return 0;
    }
  }
  cout << "War";
}

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

void sort( int* a )
{
    for( int i = 0; i < 2; i++ )
        for( int j = i + 1; j < 3; j++ )
            if( a[i] > a[j] )
            {
                int temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
}

int main()
{
    int t[3];
    int t1 = 0, t2 = 0, t3 = 0, t4 = 0;

    while( cin >> t[0] >> t[1] >> t[2] )
    {
        sort( t );

        if( t[0] + t[1] > t[2] )                                            //三角形の存在条件
        {
            t1++;
            if( t[0] * t[0] + t[1] * t[1] == t[2] * t[2] )                  //直角三角形
                t2++;
            else if( t[0] * t[0] + t[1] * t[1] > t[2] * t[2] )              //鋭角三角形
                t3++;
            else                                                            //鈍角三角形
                t4++;
        }
        else
        {
            cout << t1 << " " << t2 << " " << t3 << " " << t4 << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>
#define INF 1000000
#define M 101
int main(){
    
  int num[M][M],n,a[M]={};
  int t[M],i,j,c;
  int min1,min2,mini,sum;

  t[1]=0;
  scanf("%d",&n);
    
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      scanf("%d",&num[i][j]);
    }
  }
  for(i=1;i<=100;i++){
    t[i]=INF;
  }
  
  min2=1;
  sum=0;
  a[1]=1;
  
  while(1){
    
    c=0;
    for(i=1;i<=n;i++){
      if(a[i]==1){
	c++;
      }
    }
    if(c==n){
      break;
    }	
    
    
    min1=10000000;
    
    for(i=1;i<=n;i++){
      if(a[i]!=1 && num[min2][i]!=-1 && t[i] > num[min2][i]){
	t[i] = num[min2][i];
      }
      if(a[i]!=1 && min1>t[i]){
	mini=i;
	min1=t[i];
      }
    }
  sum += min1;
  a[mini]=1;
  t[mini] = min1;
  min2 = mini;
  }
  printf("%d\n",sum);
  
  return 0;
}



Measured memory_bytes: 2112
#include <vector>
#include <string.h>
#include<iostream>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string.h>
#include<algorithm>
#include <stdlib.h>
using namespace std;

const int mod=1e9+7;
typedef long long ll;

#define out_vector(v) for(auto a:v)cout<<a<<" "; cout<<endl;

ll k,m,n;
string str,s,s1,s2;
set<pair<ll,pair<ll,ll> > >se;

int main()
{
    ll a,b,c;
    cin>>a>>b>>c;
    ll ans=0;
    while(1){
        if(a%2||b%2||c%2){
            break;
        }
        if(se.find(make_pair(a, make_pair(b,c)))!=se.end()){
            cout<<-1<<endl;
            return 0;
        }
        se.insert(make_pair(a, make_pair(b,c)));
        ll a1,b1,c1;
        a1=(b/2)+(c/2);
        b1=(a/2)+(c/2);
        c1=(a/2)+(b/2);
        a=a1,b=b1,c=c1;
        ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int main () {
  int N;
  cin >> N;
  int ans = 0;
  for (auto i = 1; i <= N; ++i) {
    ans += 800;
    if (i%15 == 0) ans -= 200;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
x, n, *P = map(int, open(0).read().split())
A = list(range(102))
P = set(P)
B = []
m = 10**4
for a in A:
    if a not in P:
        if abs(x-a) < m:
            m = abs(x-a)
            B.append((m, a))
B.sort()
print(min([k for v, k in B if v == B[0][0]]))

Measured memory_bytes: 9156
#include<stdio.h>
int main(){
	int a;
    int b;
    int c;
    int i;
    int s;
    s = 0;
    scanf("%d %d %d", &a, &b, &c);
    for(i = a; i <= b; i++){
        if(c % i == 0){
            s++;
        }
    }
    printf("%d\n", s);
    return 0;
}


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

def check():
  flag=True
  for i in range(2):
    for j in range(2):
      flag &= (mat[i+1][j]-mat[i][j])==(mat[i+1][j+1]-mat[i][j+1])
      flag &= (mat[i][j+1]-mat[i][j])==(mat[i+1][j+1]-mat[i+1][j])
  return flag


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

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N, M, X, Y;
	int x[101];
	int y[101];
	bool ans = false;
	cin >> N >> M >> X >> Y;
	int xmax = -120;
	int ymin = 120;
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
		xmax = max(xmax, x[i]);
	}
	for (int i = 0; i < M; ++i) {
		cin >> y[i];
		ymin = min(ymin, y[i]);
	}
	for (int i = -100; i <= 100; ++i) {
		if (X < i&&i <= Y && xmax < i&&ymin >= i) {
			ans = true;
			break;
		}
	}
	if (ans)
		cout << "No War" << endl;
	else
		cout << "War" << endl;
	return 0;
}

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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.length();
  int m = t.length();
  vector<vector<int>> mp(26);
  for (int i = 0; i < 2 * n; i++) {
    mp[s[i % n] - 'a'].push_back(i);
  }
  for (auto c : t) {
    if (mp[c - 'a'].size() > 0) continue;
    cout << -1 << endl;
    return 0;
  }
  vector<vector<int>> g(n, vector<int>(26, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 26; j++) {
      if (mp[j].size() == 0) continue;
      auto ub = upper_bound(begin(mp[j]), end(mp[j]), i);
      g[i][j] = (*ub - i) % n;
      if (g[i][j] == 0) g[i][j] = n;
    }
  }
  ll ans = 1;
  int p = 0;
  for (int i = 0; i < m; i++) {
    int d = g[p][t[i] - 'a'];
    if (i == 0 && s[0] == t[0]) d = 0;
    ans += d;
    p = (p + d) % n;
  }
  cout << ans << endl;
}


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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt() ;
		long fillArray[] = new long[N + 1];
		Arrays.fill(fillArray, 1);
		for(int i = 2 ; i <= N ; ++i){
			for(int j = i ; j <= N ; j += i){
				fillArray[j]++;
			}
		}
		long ans = 0;
		for(int i = 1 ; i <= N ; ++i){
			ans += i * fillArray[i];
		}
		System.out.println(ans);
//		long te = System.currentTimeMillis();
//		System.out.println(te - ts);
	}
}


Measured memory_bytes: 116168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[100010][2];

int main() {
  string s;
  cin >> s;
  int n = s.length();
  dp[0][0] = 1;
  rep(i, n)rep(j, 2) {
    int ni = i + 1;
    int nj = j;
    if (s[i] == '1') {
      if (nj == 0) {
        dp[ni][nj] += dp[i][j] * 2;
        dp[ni][1] += dp[i][j]; 
      } else {
        dp[ni][nj] += dp[i][j] * 3;
      }
    } else {
      if (nj == 1) dp[ni][nj] += dp[i][j] * 3;
      else dp[ni][nj] += dp[i][j];
    }
  }
  cout << dp[n][0] + dp[n][1] << endl;
}

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

#define ll long long int

	
	
int main(){
	
	string s;
	cin>>s;
	
	int ansa = -1;
	int ansb = -1;
	if(s.length() == 2){
		if(s[0] == s[1])
			ansa = 1 , ansb = 2;
	}else if(s.length() > 2){
		for(int i=0;i<s.length()-2;i++){
				if(s[i] == s[i+1] || s[i] == s[i+2] || s[i+1] == s[i+2]){
					ansa = i+1;
					ansb = i+1+2;
					break;
				}
		}
}
	cout<<ansa<<" "<<ansb<<endl;
	
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int n;
    cin >> n;
    int d[n + 5];
    for(int i = 0; i < n; i++)
        cin >> d[i];
    //1 4 4 5 5 9 14 14
    sort(d, d + n);
    cout << d[n/2] - d[(n/2) - 1];
    return 0;
}


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

int X;
int main(){
	cin >> X;
	int ans = 1;
	for(int i=2;i<=35;i++){
		int now = i;
		for(int j=1;j<=10;j++){
			now *= i;
			if(now<=X) ans = max(ans,now);
			else break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int tall_enough = 0;
    for (int i = 0; i < n; ++i){
        int h;
        cin >> h;
        if (h >= k) ++tall_enough;
    }

    cout << tall_enough;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
signed main(){
  int n,m,q;
  cin>>n>>m>>q;
  int h=n+1,w=n+1;
  int a[n+1][n+1];
  r(i,n+1)r(j,n+1)a[i][j]=0;
  r(i,m){
    int x,y;
    cin>>x>>y;
    a[y][x]++;
  }
  r(i,h-1)r(j,w)a[i+1][j]+=a[i][j];
  r(i,h)r(j,w-1)a[i][j+1]+=a[i][j];
  while(q--){
    int x,y;
    cin>>x>>y;
    cout<<a[y][y]-a[x-1][y]-a[y][x-1]+a[x-1][x-1]<<endl;
  }
}

Measured memory_bytes: 2944
using System;
class MainClass
{
    public static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        int n = int.Parse(input[0]);
        int k = int.Parse(input[1]);
        int ans = 0;
        if(n % k != 0)
        {
            ans = 1;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
// Ver19.03
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF (1 << 29) * 2
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  char s[100];
  scanf("%s", s);
  int len = strlen(s), partialLen = (len - 1) / 2, isYes = 1;

  for (int i = 0; i < (int)floor(len / 2); i++)
  {
    if (s[i] != s[len - 1 - i])
      isYes = 0;
  }
  for (int i = 0; i < (int)floor(partialLen / 2); i++)
  {
    if ((s[i] != s[partialLen - 1 - i]) || (s[i + partialLen + 1] != s[2 * partialLen - i]))
      isYes = 0;
  }
  puts(isYes ? "Yes" : "No");
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

string base[4] = {
	"maerd","remaerd","esare","resare"
};


int main(){
	string S;
	string str;
	cin >> S;
	str = S;
	for (int i = 0; i < S.length(); i++) {
		str[(S.length() - 1) - i] = S[i];
	}

	bool flag[4] = {};
	int tmp = 0;
	bool tmp_flag = 0;
	for (int i = 0; i < str.length(); i++) {
		if (i == 0 || tmp_flag == true) {
			tmp_flag = false;
			for (int j = 0; j < 4; j++) {
				if (str[i] == base[j][0]) {
					flag[j] = true;
				}
			}
			tmp++;
		}

		else {
			int cnt = 0;
			for (int j = 0; j < 4; j++) {
				if (flag[j] == true) {
					if (str[i] == base[j][tmp]) {
						cnt++;
						
						if (base[j].length() == tmp+1) {
							tmp = -1;
							for (int k = 0; k < 4; k++) {
								flag[k] = false;
							}
							tmp_flag = true;
							break;
						}
					}
					else {
						flag[j] = false;
					}
				}
			}
			tmp++;
			if (cnt == 0) {
				cout << "NO" << endl;
				return 0;
			}
		}
	}

	cout << "YES" << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long ll;
const int INF = 1<<31; 
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> vec;
	for(int i = 0; i < n; i++)
	{
		ll x;
		cin >> x;
		vec.push_back(x);
	}
	reverse(vec.begin(), vec.end());
	vector<ll> num(n + 1, 0);
	for(int i = 0; i < n; i++)
	{
		if(i == 0)
			num[i] += vec[i];
		else
			num[i] += num[i - 1] + vec[i];
	}
	ll ans = 1LL<<60;
	ll x, y;
	for(int i = 0; i < n - 1; i++)
	{
		x = num[i];
		y = num[n - 1] - x;
		ans = min(abs(x - y), ans);
		//cout << x << " " << y << " " << ans << endl;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////
ll PowMod_RepeatSquaring(ll N, ll P, ll M) {
	if (P == 0)return 1;
	if (P % 2 == 0) {
		ll t = PowMod_RepeatSquaring(N, P / 2, M);
		return t * t%M;
	}
	return N * PowMod_RepeatSquaring(N, P - 1, M);
}
const double PI = 3.14159265358979323846;
int main() {
	double R; cin >> R;
	cout << fixed << setprecision(12) << 2 * R*PI << endl;
	return 0;
}


Measured memory_bytes: 3796
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	const c = parseInt(args[0][2], 10)
	if (a === b) console.log(c)
	else if (b === c) console.log(a)
	else console.log(b)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))


Measured memory_bytes: 21064
#!python3

iim = lambda: map(int, input().rstrip().split())

def d10(n):
    a = []
    while n:
        n, m = divmod(n, 10)
        a.append(m)

    return a

def resolve():
    N = int(input())

    if N < 10:
        print(N)
        return

    k = N // 10
    A = d10(N)

    a = A[-1]
    b = A[0]

    ans = k ** 2 + 8
    if b:
        c = len(A)
        d = d0 = 0
        for i in range(c-1):
            d, d0 = 10 ** i + d, d

        if a > b:
            ans += 2 * d * b
        else:
            e = k - a*10**(c-2)
            ans += 2 * d * (a-1)
            ans += 2 * (d0 + e + 1) + 1
            ans += 2 * d0 * (b - a)
    print(ans)



if __name__ == "__main__":
    resolve()


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

Measured memory_bytes: 256