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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<ll, ll>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define nl "\n"
#define fat 1000000007

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % p;  // Update x if it is more than or 
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll nCr(ll n, ll r, ll p) 
{ 
   // Base case
   if(r > n) return 0;
   if (r==0) 
      return 1; 
  
    // Fill factorial array so that we 
    // can find all factorial of r, n 
    // and n-r 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 

int main()
{
    boost
    ll n, k;
    cin >> n >> k;

    vi a(n);
    loop(z, a) cin >> z;

    sort(a.B, a.E);

    vi comb(n + 1, 0);
    ll nCk_1 = nCr(n, k - 1, fat);

    comb[n] = nCk_1;
    for(int i = n - 1; i >= k - 1; i--) comb[i] = (((comb[i + 1]*(i + 2 - k))%fat)*modInverse(i + 1, fat))%fat;

    ll ans = 0;
    for(ll i = 0; i < n; i++) ans = (ans + ((comb[i] - comb[n - i - 1])*a[i])%fat)%fat;

    cout << ans%fat << nl;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e9;
const long long int mod = 1e9+7;
typedef pair<ll,ll> pairs;
vector<pairs> p;


ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

vector<vector<ll>> combination(ll n, ll r){
    vector<vector<ll>> v(n + 1, vector<ll>(n + 1, 0));
    for(ll i=0;i<v.size();++i){
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for(ll i=1;i<v.size();++i){
        for(ll j=0;j<i;++j){
            v[i][j] = (v[i - 1][j - 1] + v[i - 1][j]);
        }
    }
    return v;
}
// ------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> d(n);
    for(ll i=0;i<n;++i){
        cin>>d[i];
    }
    ll m;
    cin>>m;
    vector<ll> t(m);
    for(ll i=0;i<m;++i){
        cin>>t[i];
    }

    map<ll, ll> a;
    for(ll i=0;i<n;++i){
        a[d[i]]++;
    }
    for(ll i=0;i<m;++i){
        a[t[i]]--;
    }

    string ans = "YES";
    for(auto val : a){
        if(val.second < 0){
            ans = "NO";
            break;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 15872
#include <iostream>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k, t;
    cin >> n >> k;
    t = 1;
    for (int a = 0; a < n; ++a) {
        t += min(t, k);
    }
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int d,n,e;
int main(){
	scanf("%d%d",&d,&n);
	if(d==0)e=1;
	if(d==1)e=100;
	if(d==2)e=10000;
	if(n==100)n=101;
	printf("%d\n",n*e);
}

Measured memory_bytes: 128
import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = list(input())
    l = len(s)
    dp1 = [0 for _ in range(l + 1)]
    dp2 = [0 for _ in range(l + 1)]
    dp1[0] = 1

    for i in range(l):
        if s[i] == "1":
            dp1[i + 1] = dp1[i] * 2
            dp2[i + 1] = dp1[i] + dp2[i] * 3
        else:
            dp1[i + 1] = dp1[i]
            dp2[i + 1] = dp2[i] * 3
        dp1[i + 1] %= MOD
        dp2[i + 1] %= MOD

    print((dp1[l] + dp2[l]) % MOD)


if __name__ == '__main__':
    main()


Measured memory_bytes: 19772
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr int MOD = 998244353;

int main() {
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  for (auto& e : a) cin >> e;

  ll r = 0;
  vector<vector<ll>> dp(n + 1, vector<ll>(2 * 3000 + 1));
  for (int i = 0; i < n; i++) {
    for (int k = 0; k < s; k++) {
      (dp[i + 1][k] += dp[i][k]) %= MOD;
      (dp[i + 1][k + a[i]] += dp[i][k]) %= MOD;
    }
    (dp[i + 1][a[i]] += i + 1) %= MOD;

    r += dp[i + 1][s] * (n - i) % MOD;
    r %= MOD;
  }
  cout << r << endl;

  // for (int i = 0; i < n; i++) {
  //   for (int k = 0; k <= s; k++) cerr << dp[i + 1][k] << ' ';
  //   cerr << endl;
  // }
}


Measured memory_bytes: 141056
package main

import (
	"fmt"
	"strconv"
)

var queue = [][]int{}

func add(p []int) {
	n := p[len(p)-1]
	if n == 9 {
		np1 := make([]int, len(p))
		copy(np1, p)
		np2 := make([]int, len(p))
		copy(np2, p)

		np1 = append(np1, 8)
		np2 = append(np2, 9)

		queue = append(queue, np1, np2)
	} else if n == 0 {
		np1 := make([]int, len(p))
		copy(np1, p)
		np2 := make([]int, len(p))
		copy(np2, p)
		np1 = append(np1, 0)
		np2 = append(np2, 1)
		queue = append(queue, np1, np2)
	} else {
		np1 := make([]int, len(p))
		copy(np1, p)
		np2 := make([]int, len(p))
		copy(np2, p)
		np3 := make([]int, len(p))
		copy(np3, p)

		np1 = append(np1, n - 1)
		np2 = append(np2, n)
		np3 = append(np3, n + 1)
		queue = append(queue, np1, np2, np3)
	}
}

func show(p []int) {
	str := ""
	for _, e := range p {
		str += strconv.Itoa(e)
	}
	fmt.Println(str)
}

func main() {
	// Code for D - Lunlun Number
	var k int
	fmt.Scanf("%d", &k)

	for i := 1; i <= 9; i++ {
		queue = append(queue, []int{i})
	}

	for i := 1; i <= k; i++ {
		p := queue[0]
		queue = queue[1:]
		add(p)

		if i == k {
			show(p)
		}
	}
}


Measured memory_bytes: 54400
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) {	printf("Yes\n");
	} else {		printf("No\n");	}
	return;
}

void okng(int ans) {
	if (ans == 1) { printf("OK\n");
	} else { 		printf("NG\n");	}
	return;
}

int main()
{
	int N = 0;
	scanf("%d", &N);

	int ans = N%1000;
	if (ans != 0) {
		ans = 1000 - ans;
	}
	printf("%d\n", ans);
	//yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1728
def main():
    n = [int(i) for i in input().split()]
    bridge = set()
    counter = 0
    reqs = [[int(j) for j in input().split()] for i in range(n[1])]
    reqs.sort(key=lambda x:(x[0],x[1]))
    
    preset = 0
    for i in range(1, n[0]+1):
        if i in bridge:
            bridge.clear()
            counter += 1
        for j in range(preset, len(reqs)):
            if reqs[j][0] == i:
                bridge.add(reqs[j][1])
            else:
                preset = j
                break
    
    print(counter)

main()


Measured memory_bytes: 30192
def input_int():
    return map(int, input().split())

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

import itertools as it

H, W, K = input_int()

maps = []



for h in range(H):
    maps.append(list(one_str()))

maps

#cols
cols_dict={i:[] for i in range(W+1)}

#rows
rows_dict={i:[] for i in range(H+1)}

sums = 0

for x in range(W):
    for y in range(H):
        if maps[y][x]=="#":
            cols_dict[x].append((y,x))
            rows_dict[y].append((y,x))
            sums+=1

count = 0
for x in range(W+1):
    xx = list(it.combinations([i for i in range(W)], x))
    
    for y in range(H+1):
        yy = list(it.combinations([i for i in range(H)], y))

        for xxx in xx:
            sum_set_x = set([])

            for xxxx in xxx:
                sum_set_x = sum_set_x | set(cols_dict[xxxx])
        
            for yyy in yy:
                sum_set_y = set([])
                for yyyy in yyy:
                    sum_set_y = sum_set_y | set(rows_dict[yyyy])

                sum_set = sum_set_x | sum_set_y
                if sums-len(sum_set) == K:
                    count+=1

print(count)

Measured memory_bytes: 9232
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 自分の得意な言語で
		// Let's チャレンジ！！

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int cnt = 0;
		int curMin = 0;
		for (int i = 0; i < n; i++) {
			int p = sc.nextInt();
			if (i == 0) {
				curMin = p;
				cnt++;
				continue;
			}
			if (p < curMin) {
				curMin = p;
				cnt++;
			}
		}

		System.out.println(cnt);

	}

}

Measured memory_bytes: 64060
#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)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#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 Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) 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")

int main(void){
    Cin(int, n, m);
    Vec2(bool, n+1, n+1, a);
    Rep(m){
        Cin(int, i, j);
        a[i][j] = a[j][i] = true;
    }
    vector<int> r(n);
    For(i, n) r[i] = i+1;
    int ans = 0;
    do{
        bool f = true;
        For(i, n-1){
            if(!a[r[i]][r[i+1]]){
                f = false; break;
            }
        }
        if(f) ans ++;
    }
    while(next_permutation(r.begin() + 1, r.end()));
    Cout(ans);
}


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

using namespace std;

int main(){

	int n;
	cin >> n;
	int k[102]={0};
	int s[102]={0};
	for(int i = 0;i < n*(n-1)/2;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		if(c > d){
			k[a] += 3;
		}else if(d > c){
			k[b] += 3;
		}else{
			k[a] += 1;
			k[b] += 1;
		}
		s[a-1] = k[a];
		s[b-1] = k[b];
	}
	sort(s,s+n,greater<int>());
	for(int i = 1;i <= n;i++){
		for(int j = 0;j < n;j++){
			if(s[j] == k[i]){
				cout << j+1 << endl;
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
int main(){
	unsigned long a,b,c;
   cin>>a>>b>>c;
  if(4*a*b<(c-a-b)*(c-a-b) && a+b<c)
   cout<<"Yes";
	else
 cout<<"No";
 return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for (int &i : p) cin >> i;
  sort(p.begin(), p.end());
  int ans = 0;
  for (int i = 0; i < k; i++) ans += p[i];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main(int argc, char **argv)
{
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a+b+c == 17 && a*b*c == 175) {
        puts("YES");
    } else {
        puts("NO");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
  int a[150][150];
  int b[150];
  int c[150]={0};
  int n,m;

  cin >> n >> m;

  int i,j;
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      cin >> a[i][j];

  for(j=0;j<m;j++)
    cin >> b[j];

  
  for(i=0;i<n;i++)
    for(j=0;j<m;j++)
      c[i]+=a[i][j]*b[j];

  for(i=0;i<n;i++)
    cout << c[i] << endl;
}

Measured memory_bytes: 3152
import sys
import math
import bisect
def input():
    return sys.stdin.readline()[:-1]

n=int(input())
s=list(input())
q=int(input())
ans=[]
dic = {}

for i in range(97,97+26):
    dic[chr(i)]=[]

for num,i in enumerate(s):
    dic[i].append(num)

for i in range(q):
    num,l,r = map(str,input().split())
    if int(num)==1:
        l=int(l)-1
        if s[l] == r:
            continue
        else:
            dic[s[l]].pop(bisect.bisect_left(dic[s[l]],l))
            bisect.insort_left(dic[r],l)
            s[l] = r
    else:
        cnt=0
        l=int(l)
        r=int(r)
        for li in dic.values():
            ind = bisect.bisect_left(li,l-1)
            if ind>=len(li):continue
            if li[ind]<=r-1:
                cnt+=1
        ans.append(cnt)

print(*ans,sep="\n")


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

int main() {
  int n, m, sum=0;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) {cin >> a[i]; sum += a[i];}
  sort(a.begin(), a.end());
  if (a[n-m] * 4 * m >= sum) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main()
{
  int k;
  cin >> k;
  
  string s;
  cin >> s;
  
  int n = s.size();
  if(n <=k){
    cout << s << endl;
    return 0;
  }else{
    int i = 0;
    string x = "";
    while(i < k){
      x += s[i];
      i++;
    }
    cout << x << "..." << endl;
  }
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    if (s.charAt(2) == s.charAt(3) && s.charAt(4) == s.charAt(5)) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}


Measured memory_bytes: 21844
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
int const MAXN=100100;
int memo[MAXN], v[MAXN], n, k;
bool win(int i){
	if(memo[i]!=-1)
		return memo[i];
	if(i==0)
		return false;
	memo[i]=0;
	for(int j=0;j<n;j++)
		if(i-v[j]>=0 && !win(i-v[j]))
			memo[i]=1;
	return memo[i];
}
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>v[i];
	memset(memo,-1,sizeof(memo));
	cout<<(win(k)==true?"First":"Second");
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int a,b,c;
    cin >>a>>b>>c;

    if(!(a==b && b==c && c==a)){
        if(a==b || c==b || c==a){
            flag=true;
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout<<ans<<endl;
    if(flag)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


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

int main(){
    int a,b,c;  cin>>a>>b>>c;
    if(a>b)swap(a,b);
    if(b>c)swap(b,c);
    if(a>b)swap(a,b);

    cout<<a*b/2<<endl;


    return 0;
}


Measured memory_bytes: 256
m, d = gets.split.map(&:to_i)
count = 0
4.upto(m).each {|i|
    22.upto(d).each {|j|
        if j / 10 >= 2 && j % 10 >= 2 then
            if i == (j / 10) * (j % 10) then
                count += 1
            end
        end
    }
}
puts count


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <set>

using namespace std;

int strlength;

bool check(string str, int k){
	int count[256] = {0}, d = 0;
	count['a']++;
	count['z'+1]++;
	for(int i=0; i<strlength; i++){
		if( !count[ str[i] + ((k&(1<<i))?1:0) ]++ )
			d |= (1<<i);
	}
	return k == d;
}

int main(){
	string str;
	while(cin >> str, str[0] != '#'){
		set<string> ans;
		set<string>::iterator it;
		strlength = str.length();
		for(int k=0; k<(1<<strlength); k++){
			if( check(str, k) ){
				string str2 = str;
				for(int l=0; l<strlength; l++){
					if( k & (1<<l) && str[l] != 'z' ){
						str2[l]++;
					}
				}
				ans.insert( str2 );
			}
		}
		// ??????
		cout << ans.size() << endl;
		if( ans.size() <= 10 ){
			for(it = ans.begin(); it != ans.end(); it++)
				cout << *it << endl;
		}else{
			int count = 0;
			for(it = ans.begin(); count < 5; it++, count++)
				cout << *it << endl;
			for(it = ans.end(); count > 0; it--, count--){}
			for(; count < 5; it++, count++)
				cout << *it << endl;
		}
	}
}

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

//Compiler version g++ 6.3.0

int main()
{
    //cout << "Hello, Dcoder!";
    int m1,d1,m2,d2;
    cin>>m1>>d1>>m2>>d2;
    if(m2-m1==1&&(d1-d2==30||d1-d2==29))
    cout<<"1"<<"\n";
    else if((m2==3&&m1==2&&d1-d2==27)||(m2==3&&m1==2&&d1-d2==28))
    cout<<"1"<<"\n";
    else
    cout<<"0"<<"\n";
    
    return 0;
}

Measured memory_bytes: 256
import java.io.PrintWriter
import java.util.*
import java.math.*
import java.lang.*
import kotlin.comparisons.*

val pw = PrintWriter(System.out)
val MOD: Long = (1e+9 + 7).toLong()

fun main(args: Array<String>) {
    val (n, a, b) = readListOfInt() 
    val max = Math.min(a, b)
    val min = if(n-(a+b) >= 0) 0 else a + b - n 
    println("$max $min")
    pw.flush()
}

/****** Declared Functions and Data Structures ******/
// IO
fun read() = readLine()!!
fun readInt() = read().toInt()
fun readLong() = read().toLong()
fun readDouble() = read().toDouble()
fun readListOfString() = read().split(" ")
fun readListOfInt() = readListOfString().map { it.toInt() }
fun readListOfLong() = readListOfString().map { it.toLong() }
fun readListOfDouble() = readListOfString().map { it.toDouble() }

fun Double.format(digits: Int) = String.format("%.${digits}f", this)
fun Float.format(digits: Int) = String.format("%.${digits}f", this)

fun print(value: Any) { pw.print(value) }
fun println(value : Any) { pw.println(value) }


// Extensions
fun<T> List<T>.toBuckets(bucketKeys: List<T>): Map<T, Int> {
    val buckets = bucketKeys.associate { t -> Pair(t, 0) }.toMutableMap()
    this.forEach { t ->
        buckets[t] = buckets[t]!! + 1
    }
    return buckets
}

fun <K, V> Map<K, V>.toMutableMap(): MutableMap<K, V> = HashMap(this)

// Util Functions
fun<T> permutations(src: List<T>): List<List<T>> {
    if(src.size == 1) return listOf(src)
    val perms = mutableListOf<List<T>>()
    val insertElement = src[0]
    permutations(src.drop(1)).forEach { perm ->
        for(i in 0..perm.size) {
            val newPerm = perm.toMutableList()
            newPerm.add(i, insertElement)
            perms.add(newPerm.toList())
        }
    }
    return perms
}

// return nCr, if you want nCr, please access v[n][r]
fun combinations(n: Long): List<List<Long>> {
    val v = (0..n).map { (0..n).map{0L}.toMutableList() }.toMutableList()
    for(i in 0 until v.size) {
        v[i][0] = 1L
        v[i][i] = 1L
    }
    for(i in 0 until v.size) {
        for(j in 1 until i) {
            v[i][j] = (v[i-1][j-1] + v[i-1][j]) % MOD
        }
    }
    return v.map { it.toList() }.toList()
}

// should be a >= b
fun gcd(a: Long, b: Long): Long = 
    if(b == 0L) a else gcd(b, a % b)

// shoud be a >= b
fun lcm(a: Long, b: Long): Long = 
    a / gcd(a, b) * b

fun sumDigits(num_: Long): Long {
    var num = num_
    var rtn: Long = 0
    while(num != 0.toLong()) {
        val tmp = num % 10
        rtn += tmp
        num /= 10
    }
    return rtn
}

fun isDecimal(v: Double): Boolean = ((v - Math.floor(v)) != 0.0)

// Data Structures
class Stack<T>(private var st: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = st.isEmpty()
    fun top(): T = st.last()
    fun push(e: T) { st.add(e) }
    fun pop() { st = st.dropLast(1).toMutableList() }
}

class Queue<T>(private var que: MutableList<T> = mutableListOf<T>()) {
    fun isEmpty() = que.isEmpty()
    fun top(): T = que.first()
    fun push(e: T) { que.add(e) }
    fun pop() { que = que.drop(1).toMutableList() }
}


Measured memory_bytes: 37880
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n, k;
	cin >> n >> k;
	ll k2 = k * (n/k);
	cout << min(n - k2, (k2+k)-n);


}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    int main(){
        int N, K, h, x;
            x = 0;
                cin >> N >> K;
                    for(int i = 0; i < N; i++){
                        cin >> h;
                            if(h >= K){
                                x += 1;
                            }
                    }
                        cout << x;
    return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000



int main(){
	
	string S,T;
	cin>>S>>T;
	cout<<T<<S<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define repr(i,x,n) for(int i=x; i<(n); i++)
#define ALL(x) (x).begin(),(x).end()
typedef long long ll;
#define INF 1e9
typedef vector<int> VI;
typedef vector<string> VS;
int main() {
int N;
cin>>N;
    VI tyokkei(N);
    rep(i,N){
    cin>>tyokkei.at(i);
    }
    sort(ALL(tyokkei));
    int ans=0;
    for (int i = 0; i < N-1; i++)
    {
    if (tyokkei.at(i)==tyokkei.at(i+1))
     {
        ans++;
     }
    
    }

        cout<<N-ans<<endl;
}

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

int main()
{
    int n;
    cin>>n;
    n--;
    ll ans=0;
    for(int i=1; i<=n; i++)
    {
        ans+=n/i;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main() {
	string S;
	int ans;
	cin >> S;
	if (S == "SAT")
		ans = 1;
	if (S == "FRI")
		ans = 2;
	if (S == "THU")
		ans = 3;
	if (S == "WED")
		ans = 4;
	if (S == "TUE")
		ans = 5;
	if (S == "MON")
		ans = 6;
	if (S == "SUN")
		ans = 7;
	
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
total_medians = N*(N+1)//2
# n件のデータ
# (上側中央値 >= x) iff (a > x となる a が(n-1)//2以下)

def BIT_update(BIT,x,value):
  # 番号xにvalueを加える
  L = len(BIT)
  while x < L:
    BIT[x] += value
    bottom_bit = x & (-x)
    x += bottom_bit
  return

def BIT_sum(BIT,x):
  # 番号1～xの和を求める
  result = 0
  while x:
    result += BIT[x]
    bottom_bit = x & (-x)
    x -= bottom_bit
  return result

def test(x):
  # 「答はx以下である」
  # 「xより真に大きな区間中央値が(total_medians-1)//2個以下」
  B = [0]
  for a in A:
    B.append(B[-1] + (1 if a>x else -1))
  m = min(B)-1
  B = [x-m for x in B]

  BIT = [0]*(N+1)
  
  cnt = 0
  for R in range(1,N+1):
    BIT_update(BIT,B[R-1],1)
    cnt += BIT_sum(BIT,B[R]) # 右端がRとなる(L,R)対
  return cnt <= (total_medians-1)//2

AA = sorted(A)
left = -1 # 答はAA[left]より大きい
right = len(AA)-1 # 答はAA[right]以下である
while right - left > 1:
  mid = (left+right)//2
  if test(AA[mid]):
    right = mid
  else:
    left = mid
answer = AA[right]

print(answer)


Measured memory_bytes: 106280
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i, s) for (int i = 0; i < s; ++i)
#define all(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main() {
    int n,k;
    cin>>n>>k;
    //n=7,k=1だとすると、例えばb=3で固定すると、a=0~nまで動かすとあまりは0,1,2,0,1,2,0,1となる。
    //つまり、あるbにおいて、求める数は、(n/b)*(b-k)+n%b-k+1個をbについて足せば良い。
    //最後にa=0の場合を引けば良い。
    ll ans=0;
    for(int b=1;b<=n;b++){
        ans+=(n/b)*max((b-k),0)+max(n%b-k+1,0);
        // cout<<ans<<endl;
    }
    if(k==0){
        ans-=n;
    }
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 764
#include <stdio.h>
#include <string.h>

int main(){
	int H, W, N, X, Sum=0, Count=0;
	scanf ("%d %d %d", &H, &W, &N);
	
	if (H>=W){
		X=H;
	}
	else{
		X=W;
	}
	
	while (Sum<N){
		Sum+=X;
		Count++;
	}
	
	printf ("%d\n", Count);
	return 0;
}


Measured memory_bytes: 1732
#include <stdio.h>

int main(){
    int group[13] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    
    scanf("%d %d", &x, &y);

    if(group[x] == group[y])
        printf("Yes\n");
    else
        printf("No\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin >> n >> m;
	if (n == m) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
/**
 *    author        : Saurav Paul 
 *    created       : August 14, 2020 8:26 PM
 *    Problem Name  : H - Grid 1
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/dp/tasks/dp_h
 *    @genarated by : ai-virtual-assistant
**/

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

using ll = long long int ;
int N , M ;
ll MOD = 1e9 + 7 ;
vector<string> grid ;
vector<vector<ll>> dp ;

ll get(int i , int j){
    if(i < 1 || j < 1) return 0LL ;
    return dp[i][j] ;
    
}

void solve(){
    cin >> N >> M ;
    grid = vector<string>(N) ;

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

    dp = vector<vector<ll>> (N+1,vector<ll>(M+1)) ;
    dp[1][1] = 1;

    for(int i = 0 ; i < N ; i++){
        for(int j = 0 ; j < M ; j++){
            if(grid[i][j] == '#') continue ;
            dp[i+1][j+1] = (dp[i+1][j+1] + get(i,j+1) + get(i+1,j)) % MOD ;
        }
    }

    cout << dp[N][M] << endl ;

}

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

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

    return 0 ;
}


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

int N;
int L[15];

int main(void) {

	cin >> N;
	string ans = "Yes";

	for (int i = 1; i <= N; i++) {
		cin >> L[i];
	}

	int sum = 0;
	for (int i = 1; i <= N; i++) {
		sum += L[i];
	}
	int max_L = 0;
	for (int i=1;i<=N;i++){
		if (max_L < L[i]) { max_L = L[i]; }
	}

	if(max_L<sum-max_L){}
	else { ans = "No"; }

	cout << ans << endl;
	//system("pause");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}

}


int main(){
  int n;cin>>n;
  vector<int> d(n);for(int i=0;i<n;i++)cin>>d[i];
  ndifix::sort(d);
  int m=n/2-1;
  cout<<d[m+1]-d[m]<<endl;
  return 0;
}


Measured memory_bytes: 768
// Problem : C - H and V
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_c
// Memory Limit : 1024 MB
// Time Limit : 1000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define DEBUG fprintf(stderr, "Passing [%s] line %d\n", __FUNCTION__, __LINE__)
#define File(x) freopen(x".in","r",stdin); freopen(x".out","w",stdout)

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair <int, int> PII;
typedef pair <int, PII> PIII;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

inline LL gl()
{
    LL f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 10, M = N << 1;

int n, m, k;
char s[N][N], g[N][N];
bool vis[N + N];
LL ans;

inline void check()
{
	memcpy(g, s, sizeof g);
	for (int i = 1; i <= n; i+=1)
		if (vis[i])
		{
			for (int j = 1; j <= m; j+=1)
				g[i][j] = 'R';
		}
	for (int i = n + 1; i <= n + m; i+=1)
		if (vis[i])
		{
			for (int j = 1; j <= n; j+=1)
				g[j][i - n] = 'R';
		}
	int cnt = 0;
	for (int i = 1; i <= n; i+=1)
		for (int j = 1; j <= m; j+=1)
			if (g[i][j] == '#')
				++cnt;
	if (cnt == k) ++ans;
}

void dfs(int u)
{
	if (u > n + m) {check(); return;}
	vis[u] = false;
	dfs(u + 1);
	vis[u] = true;
	dfs(u + 1);
	vis[u] = false;
}

int main()
{
    //File("");
    n = gi(), m = gi(), k = gi();
    for (int i = 1; i <= n; i+=1)
    	scanf("%s", s[i] + 1);
    dfs(1);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,ll>> g[55];
const ll max_v=100000, max_log_v=20;
ll root, parent[max_log_v][max_v], depth[max_v];
void lca_dfs(ll w, ll p, ll d){
    parent[0][w] = p;
    depth[w] = d;
    for(ll i = 0; i < g[w].size(); i++){
        if(g[w][i].first != p) lca_dfs(g[w][i].first, w, d + 1);
    }
}
//初期化
void lca_init(ll w){
    lca_dfs(root, -1, 0);
    for(ll k = 0; k + 1 < max_log_v; k++){
        for(ll i = 0; i < w; i++){
            if(parent[k][i] < 0) parent[k + 1][i] = -1;
            else parent[k + 1][i] = parent[k][parent[k][i]];
        }
    }
}
ll lca(ll u, ll w){
    if(depth[u] > depth[w]) swap(u,w);
    for(ll k = 0; k < max_log_v; k++){
        if((depth[w] - depth[u]) >> k & 1){
            w = parent[k][w];
        }
    }
    if(u == w) return u;
    for(ll k = max_log_v - 1; k >= 0; k--){
        if(parent[k][u] != parent[k][w]){
            u = parent[k][u];
            w = parent[k][w];
        }
    }
    return parent[0][u];
}
int main() {
    // your code goes here
    ll n,m,i,ii,j,ls,aa,bb,u[25],v[25],bit,ans=0,pm,en[55][55];
    vector<ll> es[55];
    cin >> n;
    root=0;
    for(i=1;i<n;i++){
        cin >> aa >> bb;
        aa--; bb--;
        g[aa].push_back({bb,i});
        g[bb].push_back({aa,i});
        en[aa][bb]=i;
        en[bb][aa]=i;
    }
    lca_init(n);
    cin >> m;
    for(ii=0;ii<m;ii++){
        cin >> u[ii] >> v[ii];
        u[ii]--; v[ii]--;
        ls=lca(u[ii],v[ii]);
        pm=u[ii];
        while(pm!=ls){
            es[ii].push_back(en[pm][parent[0][pm]]);
            pm=parent[0][pm];
        }
        pm=v[ii];
        while(pm!=ls){
            es[ii].push_back(en[pm][parent[0][pm]]);
            pm=parent[0][pm];
        }
    }
    for(bit=1;bit<(1<<m);bit++){
        ll popcnt=__builtin_popcount(bit);
        ll mul=1;
        bool used[55]={0};
        ll kom=0;
        for(i=0;i<m;i++){
            if(bit>>i&1){
                for(j=0;j<es[i].size();j++){
                    if(!used[es[i][j]]){
                        kom++;
                        used[es[i][j]]=true;
                    }
                }
            }
        }
        mul=pow(2,n-1-kom);
        if(popcnt%2==1) ans+=mul;
        else ans-=mul;
    }
    ans=pow(2,n-1)-ans;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 14592
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF = 1e17+7;
const long long MOD = 1e9+7;
const int SIZE=1e6+10;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	char a;
	cin >> a;
	if('a' <= a && a <= 'z'){
		cout << "a" << endl;
	}else{
		cout << "A" << endl;
	}
	return 0;
}


Measured memory_bytes: 3656
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        n: usize,
        c: usize,
        k: i64,
        mut ts: [i64; n],
    }
    ts.sort();
    let mut ans = 0;
    let mut i = 0usize;
    while i < n {
        i += min(c, ts[i..].iter().copied().position(|t| t > ts[i] + k).unwrap_or(n - i));
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4288
package main

import "fmt"

func gcd(A int, B int) int {

	if B == 0 {
		return A
	}
	return gcd(B, A%B)
}

func main() {

	var A, B int
	fmt.Scanf("%d %d", &A, &B)

	var result int
	result = gcd(A, B)

	result = A * B / result
	fmt.Println(result)
}


Measured memory_bytes: 1832
N,x=map(int,input().split())
a=sorted(list(map(int,input().split())))
total=sum(a)
#おかしが余る場合
if total<x:
  print(N-1)
#配りきれる場合
elif total==x:
  print(N)
#子供が余る場合
else:
  ans=0
  d=[0]*N
  for i in range(N):
    if x>=a[i]:
      x-=a[i]
      d[i]=1
  ans=d.count(1)
  print(ans)



Measured memory_bytes: 3060
#include <cstdio>
using namespace std;
const int N=1000010;
const int MOD=1e9+7;
int n;
int fact[N],iact[N];
int f[N];
int fmi(int x,int y){
	int res=1;
	for(;y;x=1ll*x*x%MOD,y>>=1)
		if(y&1)
			res=1ll*res*x%MOD;
	return res;
}
void init(){
	fact[0]=fact[1]=1;
	for(int i=2;i<=n;i++) fact[i]=1ll*fact[i-1]*i%MOD;
	iact[0]=iact[1]=1;
	iact[n]=fmi(fact[n],MOD-2);
	for(int i=n-1;i>=2;i--) iact[i]=1ll*iact[i+1]*(i+1)%MOD;
}
inline int C(int n,int m){
	return m<=n?1ll*fact[n]*iact[m]%MOD*iact[n-m]%MOD:0;
}
void solve(){
	int ans=0,presum=0;
	for(int k=(n+1)>>1;k<n;k++){
		int num=(1ll*C(k-1,n-1-k)*fact[k]%MOD*fact[n-1-k]%MOD-presum)%MOD;
		(ans+=1ll*num*k%MOD)%=MOD;
		(presum+=num)%=MOD;
	}
	printf("%d\n",ans<0?ans+MOD:ans);
}
int main(){
	scanf("%d",&n);
	init();
	solve();
	return 0;
}

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

using namespace std;

int main()
{
    int n,a[101],i;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    cout<<a[n-1]-a[0];
    return 0;
}


Measured memory_bytes: 3536
#include <stdio.h>
int main(void){
	int n,T,c[1001],t[1001],i,ans=1001,f=0;
	scanf("%d %d",&n,&T);
	for(i=1;i<=n;i++){
		scanf("%d %d",&c[i],&t[i]);
	}
	for(i=1;i<=n;i++){
		if(t[i]<=T){
			if(f=0){
				ans=c[i];
				f=1;
			}else{
				if(c[i]<ans){
					ans=c[i];
				}
			}
		}
	}
	if(ans==1001){
		printf("TLE\n");
	}else{
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define SORT(x) sort(x.begin(),x.end())
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
#define No cout<<"No"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    string s,ans;
    cin>>s;
    for(int i=0;i<s.size();i+=2){
        ans+=s[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<list>
#include<set>
#include<algorithm>
#include<map>
#include<string>
#include<unordered_map>
#include<math.h>
#include<random>
#include<unordered_set>
#include<set>
#include<stdlib.h>
#include<memory>

using namespace std;

int main(void) {
	vector<int> in;

	int fiveCounter = 0;
	int nineCounter = 0;

	in.resize(3);

	cin >> in[0] >> in[1] >> in[2];

	for (const auto &x : in) {
		if (x == 5) {
			fiveCounter++;
		}
		if (x == 7) {
			nineCounter++;
		}
	}

	if (fiveCounter == 2&& nineCounter == 1) {
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, K;
    cin >> N >> K;
    ll ans = 0;
    if (K % 2 == 0) {
        ll c;
        if (N * 2 == K) c = 1;
        else if (N * 2 < K) c = 0;
        else c = 1 + (N - K / 2) / K;
        ans += c * c * c;
    }
    ll c = N / K;
    ans += c * c * c;
    cout << ans << endl;
    return 0;
}

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

//Kaeru Jump
public class Main{

	int h, w, n;
	char[][] m;
	int[][] d = {{-1,0},{0,1},{1,0},{0,-1}};
	char[] str = {'U','R','D','L'};
	char[] res;

	int[][] near(int i, int j){
		int[][] r = new int[4][2];
		for(int[]a:r)Arrays.fill(a, -1);
		for(int k=0;k<4;k++){
			int pi = i+d[k][0], pj = j+d[k][1];
			while(0<=pi&&pi<h&&0<=pj&&pj<w){
				if(m[pi][pj]=='o'){
					r[k][0] = pi; r[k][1] = pj; break;
				}
				pi += d[k][0]; pj += d[k][1];
			}
		}
		return r;
	}

	boolean dfs(int i, int j, int D, int c){
		if(c==n-1)return true;
		int[][] e = near(i, j);
		for(int k=0;k<4;k++){
			if(e[k][0]==-1||D==(k+2)%4)continue;
			res[c] = str[k];
			m[i][j] = '.';
			boolean ok = true;
			if(c<n-2){
				for(int dir=0;dir<4;dir++){
					if(e[dir][0]==-1)continue;
					int[][] adj = near(e[dir][0], e[dir][1]);
					boolean exist = false;
					for(int x=0;x<4;x++)if(adj[x][0]!=-1)exist = true;
					if(!exist)ok = false;
				}
			}
			if(ok){
				if(dfs(e[k][0], e[k][1], k, c+1))return true;
			}
			m[i][j] = 'o';
		}
		return false;
	}

	void run(){
		Scanner sc = new Scanner(System.in);
		h = sc.nextInt(); w = sc.nextInt();
		n = 0;
		m = new char[h][];
		int si = -1, sj = -1, sd = -1;
		for(int i=0;i<h;i++){
			m[i] = sc.next().toCharArray();
			for(int j=0;j<w;j++){
				if(m[i][j]=='.')continue;
				n++;
				if(m[i][j]=='o')continue;
				si = i; sj = j;
				sd = m[i][j]=='U'?0:m[i][j]=='R'?1:m[i][j]=='D'?2:3;
				m[i][j] = 'o';
			}
		}
		res = new char[n-1];
		dfs(si, sj, sd, 0);
		System.out.println(new String(res));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

#define X first
#define Y second

//#include <boost/unordered_map.hpp>
//using namespace boost;

/*
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;
rbtree T;
*/

namespace io{
	const int L = (1 << 20) + 1;

	char buf[L], *S , *T, c;

	char getchar() {
		if(__builtin_expect(S == T, 0)) {
			T = (S = buf) + fread(buf, 1, L, stdin);
			return (S == T ? EOF : *S++);
		}
		return *S++;
	}

	int inp() {
		int x = 0, f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	unsigned inpu()
	{
		unsigned x = 0; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar());
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x;
	}

	ll inp_ll() {
		ll x = 0; int f = 1; char ch;
		for(ch = getchar(); !isdigit(ch); ch = getchar())
			if(ch == '-') f = -1;
		for(; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
		return x * f;
	}

	char B[45], *outs=B+40, *outr=B+40;
	template<class T>
	inline void print(register T a,register char x=0){
		if(x) *--outs = x, x = 0;

		if(!a)*--outs = '0';
		else
			while(a)
				*--outs = (a % 10) + 48, a /= 10;

		if(x)
			*--outs = x;

		fwrite(outs, outr - outs , 1, stdout);
		outs = outr;
	}
};

using io :: print;
using io :: inp;
using io :: inpu;
using io :: inp_ll;

using i32 = int;
using i64 = long long;
using u8 = unsigned char;
using u32 = unsigned;
using u64 = unsigned long long;
using f64 = double;
using f80 = long double;
//using i128 = __int128_t;
//using u128 = __uint128_t;
using i128 = i64;
using u128 = u64;

ll power(ll a, ll b, ll p)
{
	if (!b) return 1;
	ll t = power(a, b/2, p);
	t = t*t%p;
	if (b&1) t = t*a%p;
	return t;
}

ll exgcd(ll a, ll b, ll &x, ll &y)
{
	if (b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll px, py;
	ll d = exgcd(b, a%b, px, py);
	x = py;
	y = px-a/b*py;
	return d;
}

template<class T>
inline void freshmin(T &a, const T &b)
{
	if (a > b) a = b;
}

template<class T>
inline void freshmax(T &a, const T &b)
{
	if (a < b) a = b;
}

const int MOD = 1000000007;
const int INF = 1000000010;
const int MAXN = 200010;

vector<pair<pair<string, int>, int> > v;

int main()
{
	
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++ i)
	{
		string s;
		int p;
		cin >> s >> p;
		v.push_back(pair<pair<string, int>, int>({s, p}, i));
	}
	sort(v.begin(), v.end(), [](pair<pair<string, int>, int> a, pair<pair<string, int>, int> b)
	{
		return a.X.X == b.X.X ? a.X.Y > b.X.Y : a.X.X < b.X.X;
	});
	for (int i = 1; i <= n; ++ i)
		printf("%d\n", v[i-1].Y);
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;


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

   int n, m;
   cin >> n >> m;
   vector<int> h(n), H(n);
   rep(i, 0, n) cin >> h[i];

   
   rep(i, 0, m) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      H[a] = max(H[a], h[b]);
      H[b] = max(H[b], h[a]);
   }

   int ans = 0;
   rep(i, 0, n) {
      if (h[i] > H[i]) ans++;
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 3980
import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines

import numpy as np

N=int(readline())

U=10**6+100
div=np.arange(1,U,dtype=np.int64)
div=div[N%div==0]
print((div+N//div).min()-2)

Measured memory_bytes: 29012
#include<stdio.h>

void reset(char *p){
    int i;
    for(i=0;i<81;i++)p[i]=0;
}

int to(int *p,int n,int i){
    if(n==i)return p[0];
    else return p[n-i]+10*to(p,n,i+1);
}

int main(){
    int sum=0,i,j,n[6];
    char s[82];

    reset(s);
    while(scanf("%s",s)!=EOF){
        for(i=0;s[i]!='\0';i++){
            if('0'<=s[i]&&s[i]<='9'){
                for(j=0;'0'<=s[i+j]&&s[i+j]<='9';j++){
                    n[j]=s[i+j]-'0';
                }
                //puts("#");
                sum+=to(n,j-1,0);
                i+=j-1;
            }
        }
        reset(s);
    }
    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 540