akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <list>
#include <cstring>
#include <stack>
   
using namespace std;

struct Data
{
    int x;
    int y;
    int r;
    int c;
};

typedef struct Data D;

char result[1 << 25];
vector<D> input;

int solve(int now)
{
    // cout << now << endl;
    // cout << (m.find(now) == m.end()) << endl;
    if(result[now] != -1) return result[now];
    // cout << "hey" << endl;
    result[now] = 0;
    vector<vector<int> >  colornum(5);
    // cout << "ho" << n << endl;
    for(int i = 0; i < input.size(); i++){
        if((now & (1 << i)) == 0) continue;
        bool notcovered = true;
        // cout << i << " : " << input[i].x << " " << input[i].y << " " << input[i].r << " " << input[i].c << endl;
        for(int j = 0; j < i; j++){
            if((now & (1 << j)) == 0) continue;
            // cout << i << "," << j << ":" << pow(input[i].x - input[j].x, 2) + pow(input[i].y - input[j].y, 2) << " " << pow(input[i].r + input[j].r, 2) << endl;
            if(pow(input[i].x - input[j].x, 2) + pow(input[i].y - input[j].y, 2) < pow(input[i].r + input[j].r, 2)){
                notcovered = false;
                break;
            }
        }
        if(notcovered) colornum[input[i].c].push_back(i);
    }
    for(int i = 1; i < 5; i++){
        // cout << "colornumsize " << colornum[i].size() << endl;
        if(colornum[i].size() > 1){
            for(int j = 0; j < colornum[i].size(); j++){
                for(int k = j + 1; k < colornum[i].size(); k++){
                    int newinput = now;
                    for(int l = 0; l < input.size(); l++){
                        if((now & (1 << l)) == 0 || l == colornum[i][j] || l == colornum[i][k]) newinput &= ~(1 << l);
                    }
                    // cout << "newinput:" << newinput << endl;
                    result[now] = max((int)result[now], solve(newinput) + 2);   
                }
            }
        }
    }
    return (int)result[now];
}



int main()
{
    int n;
    while(1){
        cin >> n;
        if(n == 0) break;
        input.clear();
        for(int i = 0; i < n; i++){
            D tmpd;
            cin >> tmpd.x >> tmpd.y >> tmpd.r >> tmpd.c;
            input.push_back(tmpd);
        }
        for(int i = 0; i < (1 << n) + 1; i++){
            result[i] = -1;
        }
        int start = 0;
        for(int i = 0; i < n; i++){
            start |= 1 << i;
        }
        cout << solve(start) << endl;
    }
    return 0;
}

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

int main(){
 int n;
 cin >> n;
 int a[n];
 for(int i=0; i<n; i++) cin >> a[i];
 
 int ans = 1001001001;
 for(int i=0; i<101; i++){
 int sum = 0;
  for(int k=0; k<n; k++){
    sum += (a[k]-i)*(a[k]-i);
  }
  if(sum < ans) ans = sum;
 }
 cout << ans << endl;
 return 0;
}

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

#define rep(i, s, n) for(int i = s; i < n; ++i)
#define rrep(i, n) for(int i = n - 1; i > -1; --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const long long INF = 1000000000;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int n, r;
    cin >> n >> r;
    if(n <= 10){
        cout << r + 100 * (10 - n) << endl;
    }else{
        cout << r << endl;
    }
}

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

void Main() {
  int h, n;
  cin >> h >> n;
  int a[n], b[n];
  int max_attack = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
    max_attack = max(max_attack, a[i]);
  }

  long long dp[h + max_attack];
  for (int i = 0; i < h + max_attack; i++) {
    dp[i] = 10000000000;
  }
  dp[0] = 0;
  for (int i = 1; i < h + max_attack; i++) {
    for (int j = 0; j < n; j++) {
      if (i - a[j] < 0) continue;
      dp[i] = min(dp[i], dp[i - a[j]] + b[j]);
    }
  }

  long long ans = 10000000000;
  for (int i = h; i < h + max_attack; i++) {
    ans = min(ans, dp[i]);
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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

string encode[] = 
{" 101",
"'000000",
",000011",
"-10010001",
".010001",
"?000001",
"A100101",
"B10011010",
"C0101",
"D0001",
"E110",
"F01001",
"G10011011",
"H010000",
"I0111",
"J10011000",
"K0110",
"L00100",
"M10011001",
"N10011110",
"O00101",
"P111",
"Q10011111",
"R1000",
"S00110",
"T00111",
"U10011100",
"V10011101",
"W000010",
"X10010010",
"Y10010011",
"Z10010000"
};

string decode[] =
{"00000A",
"00001B",
"00010C",
"00011D",
"00100E",
"00101F",
"00110G",
"00111H",
"01000I",
"01001J",
"01010K",
"01011L",
"01100M",
"01101N",
"01110O",
"01111P",
"10000Q",
"10001R",
"10010S",
"10011T",
"10100U",
"10101V",
"10110W",
"10111X",
"11000Y",
"11001Z",
"11010 ",
"11011.",
"11100,",
"11101-",
"11110'",
"11111?"
};

int main(){
	map<char,string> enc_m;
	map<string,char> dec_m;
	for(int i = 0 ; i < 32 ; i++){
		enc_m[encode[i][0]] = encode[i].substr(1);
		dec_m[decode[i].substr(0,5)] = decode[i][5];
	}
	string ln;
	while(getline(cin,ln)){
		string to,ans;
		for(int i = 0 ; i < ln.size() ; i++)
			to  += enc_m[ln[i]];
		while(to.size()%5)to += "0";
		for(int i = 0 ; i < to.size() ; i+=5)
			ans += dec_m[to.substr(i,5)];
		cout << ans << endl;
	}
}

Measured memory_bytes: 0
#include <stdio.h>

int		main()
{
	int		N, M;
	int		val, ans;

	ans = 0;
	val = 0;
	scanf("%d %d\n", &N, &M);
	if (N > 1)
		ans = N * (N - 1) / 2;
	if (M > 1)
		val = M * (M - 1) / 2;
	ans += val;
	printf("%d\n", ans);
	return (0);
}


Measured memory_bytes: 128
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t;
    cin>>s>>t;
    
    map<char,int> stock;
    for(char c='a'; c<='z'; c++){
        stock[c] = 1;
    }
    
    map<char,char>  def;
    rep(i,s.size()){
        if(def.count(s[i])==1){
            if(def[s[i]]!=t[i]){
                cout1("No");
                return 0;
            }
        }else{
            if(stock[t[i]]==0){
                cout1("No");
                return 0;
            }else{
                def[s[i]] = t[i];
                stock[t[i]] = 0;
            }
        }
    }
    cout1("Yes");
}

Measured memory_bytes: 916
//sieu nhan
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define inp "test.inp"
#define out "test.out"
#define oo 3004
#define inf 1e15
#define mod 1000000007
#define pii pair<int,int>
#define reset(x,y) memset(x,y,sizeof(x))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define y1 hungdzno1
int n;
double res,p[oo],f[oo];
void nhap(){
  cin>>n;
  for(int i=1;i<=n;++i) cin>>p[i];
}
void xuly(){
  f[0]=double(1);
  for(int i=1;i<=n;++i) for(int j=i;j>=0;--j) f[j]=(j==0 ? double(0) : f[j-1]*p[i])+f[j]*(1-p[i]);
  for(int i=n/2+1;i<=n;++i) res+=f[i];
  cout<<fixed<<setprecision(9)<<res;
}
main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  //freopen(inp,"r",stdin);
  //freopen(out,"w",stdout);
  nhap();
  xuly();
}


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

bool mod10(int a, int b) {
  if (a % 10 == 0) return false;
  else if (b % 10 == 0) return true;
  else return a % 10 <= b % 10;
}

int main() {
  vector<int> abc(5);
  cin >> abc[0] >> abc[1] >> abc[2] >> abc[3] >> abc[4];

  sort(abc.begin(), abc.end(), mod10);
  int total = 0;
  for (int i=0; i<5; ++i) {
    total += abc[i];
    if (i != 0 and abc[i] % 10 != 0) {
      total += 10 - (abc[i] % 10);
    }
  }
  cout << total << "\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	string s;
	cin >> s;
	int n = s.size();

	int che = 0;

	int k1 = (n - 1) / 2;
	rep(i, k1 / 2) {
		if (s[i] != s[k1 - i - 1]) {
			che++;
		}
	}

	rep(i, n / 2) {
		if (s[i] != s[n - 1 - i]) {
			che++;
		}
	}
	int k2 = (n + 3) / 2;
	for (int i = k2; i < n - k2; i++)
	{
		if (s[i] != s[n - i - 1]) {
			che++;
		}
	}
	if (!che) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

map<string,string> nxt;

void solve(){  
	nxt["Sunny"]="Cloudy";
	nxt["Cloudy"]="Rainy";
	nxt["Rainy"]="Sunny";
	string s;
	cin>>s;
	cout<<nxt[s]<<endl;  
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    char SS[51], T[51];

    scanf("%s%s", SS, T);

    int lenS = strlen(SS);
    int lenT = strlen(T);

    int s = 0;
    int t = 0;

    for(int i = 0; i <= lenS - lenT; i++){
        int f = 0;
        for(int j = 0; j < lenT; j++){
            if(SS[lenS - i - 1 - j] != '?' && SS[lenS-i-1-j] != T[lenT-j-1]){
                f = 1;
                break;
            }
        }
        if(f == 0){
            s = lenS-i-lenT;
            t = 1;
            break;
        }
    }

    if(t == 0){
        printf("UNRESTORABLE\n");
    }else{
        for(int i = 0; i < s; i++){
            if(SS[i] == '?'){
                printf("a");
            }else{
                printf("%c", SS[i]);
            }
        }
        for(int i = s; i < s + lenT; i++){
            printf("%c", T[i-s]);
        }
        for(int i = s + lenT; i < lenS; i++){
            if(SS[i] == '?'){
                printf("a");
            }else{
                printf("%c", SS[i]);
            }
        }
        printf("\n");
    }

    return 0;
}

Measured memory_bytes: 1620
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL long long
#define mem(a , x) memset(a , x , sizeof(a))
using namespace std;
const int maxn = 1e5 + 5;
int a[maxn] , ex[maxn];
int sgn(int x)
{
    if(x < 0)
        return -1;
    else if(x > 0)
        return 1;
    else
        return 0;
}
int main()
{
    int n ;
    while(scanf("%d" , &n) != EOF){
        for(int i = 1 ; i <= n ; i++)scanf("%d" , &a[i]);
        a[0] = a[n + 1] =  0;
        int last = 0 , nt;
        int sum = 0;
        for(int i = 1 ; i <= n + 1 ; i++){
            sum += abs(a[i] - a[i - 1]);
        }
        for(int i = 1 ; i <= n ; last = a[i] , ++i){
            nt = a[i + 1];
            int len1 = a[i] - last;
            int len2 = nt - a[i];
            //printf("%d %d\n" , len1 , len2);
            if(len1 == 0 || len2 == 0 || sgn(len1) == sgn(len2)){
                ex[i] = 0;
            }
            else{
                ex[i] = abs(len1) + abs(len2) - abs(len1 + len2);
            }
        }
        for(int i = 1 ; i <= n ;i++){
            printf("%d\n" , sum - ex[i]);
        }
    }
    return 0;
}

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

int main(){
    int n;cin>>n;
    string s;cin>>s;
    int r=n/2,l=0,ans=0;
    while(r-l>1){
        int m=(r+l)/2,length=0;
        map<string,pair<int,int>>a;
        for(int j=0;j<n-m+1;j++){
            string t=s.substr(j,m);
            if(a[t].second>0){
                if(a[t].first+m<=j){length=m;break;}
                a[t].second++;
            }
            else{
                a[t].first=j;
                a[t].second++;
            }
        }
        if(length>0){
            l=m;
            ans=length;
        }
        else{r=m;}
    }
    map<string,pair<int,int>>a;
    for(int j=0;j<n-r+1;j++){
        string t=s.substr(j,r);
        if(a[t].second>0){
            if(a[t].first+r<=j){ans=r;break;}
            a[t].second++;
        }
        else{
            a[t].first=j;
            a[t].second++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589;

int main(){
  string s;
  cin >> s;
  int ans=0;
  int c[200000];
  rep(i, s.size()){
    c[i] = s.at(i) - '0';
    if(c[i]==0) ans++;
  }
  int a = s.size();
  int dp[2][2019];
  dp[0][c[0]]++;
  
  for(int i = 1; i < a; i++){
    if(c[i] == 0){
       for(int j = 0; j<2019; j++){
         dp[1][(10*j + c[i]) % 2019] = dp[0][j];
       }
      for(int j = 0; j < 2019; j++){
        dp[0][j] = dp[1][j];
      }
      continue;
    }else{
       for(int j = 0; j<2019; j++){
         dp[1][(10*j + c[i]) % 2019] = (10*j + c[i])%2019==c[i] ? dp[0][j]+1: dp[0][j];
       }
      for(int j = 0; j < 2019; j++){
        dp[0][j] = dp[1][j];
      }
    }
    ans+=dp[0][0];
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4480
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>

using namespace std;

int main(void){
    int n, len;
    while (cin>>n>>len && n) {   
        int l = -1, r = -1;
        vector<int> vr(len+1, 0);
        vector<int> vl(len+1, 0);
        for (int i = 0; i < n; i++) {
            char a; int b; cin >> a >> b;
            if (a == 'R' && r == -1) r = b;
            if (a == 'L') l = b;
            
            if (a == 'R') vr[b] = i+1;
            if (a == 'L') vl[b] = i+1;
        }
        int ans1 = max(len-r, l), ans2;
        
        while (1) {
            int cnt = 0;
            for (int i = 1; i < len; i++) {
                if (vl[i]) {
                    cnt++;
                    swap(vl[i-1], vl[i]);
                }
            }
            for (int i = len-1; i >= 0; i--) {
                if (vr[i]) {
                    cnt++;
                    swap(vr[i+1], vr[i]);
                }
            }
            if (cnt == 2 && vl[0] && vr[len]) {
                ans2 = vl[0];
                break;
            }
            if (cnt == 1 && vl[0]) {
                ans2 = vl[0];
                break;
            }
            if (cnt == 1 && vr[len]) {
                ans2 = vr[len];
                break;
            }
            
            vl[0] = 0;
            vr[len] = 0;
            for (int i = 1; i < len-1; i++) {
                if (vl[i] && vr[i]) swap(vl[i], vr[i]);
            }
        }
        cout << ans1 << " " << ans2 << endl;
    }
}

Measured memory_bytes: 3012
def gcd(x, y):
    z = max(x, y)
    d = min(x, y)

    i = 1
    while z % d*i != 0:
        # print('z, d = ', z, ",", d)
        # print('i = ', i )
        if z >= d*(i+1):
            i += 1
            continue
        else:
            z, d = d, z - d*i
            i = 1
        
    
    return d

x, y = map(int, input().split())
print(gcd(x, y))



Measured memory_bytes: 5600
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ull unsigned long long int
#define cincout ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main()
{
    cincout;

	int a;

	cin>>a;

	int val = 0;
	for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==a){
                val = 1;
            }
        }
	}

	if(val==1){
        cout<<"Yes"<<endl;
	}
	else{
        cout<<"No"<<endl;
	}

	return 0;
}


Measured memory_bytes: 256
def lcm(a,b):
    return a*b//(gcd(a,b))
def gcd(a,b):
    if b==0:
        return a
    else:
        return gcd(b,a%b)

n=int(input())
a=[int(i) for i in input().split()]
l=1
for i in range(n):
    l=lcm(a[i],l)
s=0
l-=1
for i in range(n):
    s+=l%a[i]
print(s)

Measured memory_bytes: 3316
import copy

INF = 10000000000

def merge(A, left, mid, right):
    count = 0
    L = A[left:mid] + [(INF, INF)]
    R = A[mid:right] + [(INF, INF)]

    i, j = 0, 0
    for k in range(left, right):
        count = count + 1
        if L[i][1] <= R[j][1]:
            A[k] = L[i]
            i = i + 1
        else:
            A[k] = R[j]
            j = j + 1
    return count


def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        countL = mergeSort(A, left, mid)
        countR = mergeSort(A, mid, right)
        return merge(A, left, mid, right) + countL + countR
    return 0

def partition(A, p, r):
    x = A[r][1]
    i = p - 1
    for j in range(p, r):
        if A[j][1] <= x:
            i = i + 1
            A[i], A[j] = A[j], A[i]

    A[i + 1], A[r] = A[r], A[i + 1]
    return i + 1

def quickSort(A, p, r):
    if p < r:
        q = partition(A, p, r)
        quickSort(A, p, q - 1)
        quickSort(A, q + 1, r)

n = int(input())
#A = [None for i in range(n)]
A = []
for i in range(n):
    a, b = input().split()
    A.append([a, int(b)])

B = copy.deepcopy(A)
quickSort(A, 0, n-1)
mergeSort(B, 0, n)
if A == B:
    print("Stable")
else:
    print("Not stable")

ans = [str(x[0]) +" "+str(x[1]) for x in A]
ans = '\n'.join(ans)
print(ans)



Measured memory_bytes: 39528
n,a=int(input())-1,list(map(lambda x:int(x)-1,list(input())));b=[i%2for i in a]
def c(x):
 a=0
 for j,i in enumerate(x):a^=(n|j==n)*i
 return a
if c(b):k=1
elif 1in a:k=0
else:k=c([i//2for i in a])*2
print(k)

Measured memory_bytes: 28896
t = input()
s = "AKIHABARA"
posA = [0, 4, 6, 8]
ok = 0
pos = [0, 3, 4, 5]
for i in range(2 ** 4):
    tmp = ""
    now = 0
    for j in range(9):
        if j == posA[now]:
            if i >> now & 1:
                tmp = tmp + s[j]
            now += 1
        else:
            tmp = tmp + s[j]

    if t == tmp:
        ok = 1
        break

if ok == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 61928
#include<stdio.h>

int main(){
  int a,b,c,d,e,aa,bb,cc,dd,ee,t=1,num;
  int az,bz,cz,dz,ez;
  scanf("%d", &a);
  scanf("%d", &b);
  scanf("%d", &c);
  scanf("%d", &d);
  scanf("%d", &e);

  aa=a%10; bb=b%10; cc=c%10; dd=d%10; ee=e%10;

  if(aa>0){
    num=a;
  }else if(bb>0){
    num=b;
  }else if(cc>0){
    num=c;
  }else if(dd>0){
    num=d;
  }else if(ee>0){
    num=e;
  }else{
    printf("%d",a+b+c+d+e);
    return 0;
  }

  if(num%10>bb&&bb>0){
    num=b;
    t=2;
  }
  if(num%10>cc&&cc>0){
    num=c;
    t=3;
  }
  if(num%10>dd&&dd>0){
    num=d;
    t=4;
  }
  if(num%10>ee&&ee>0){
    num=e;
    t=5;
  }

  if(a%10!=0){
    az=a+10-a%10;
  }else{
    az=a;
  }
  if(b%10!=0){
    bz=b+10-b%10;
  }else{
    bz=b;
  }
  if(c%10!=0){
    cz=c+10-c%10;
  }else{
    cz=c;
  }
  if(d%10!=0){
    dz=d+10-d%10;
  }else{
    dz=d;
  }
  if(e%10!=0){
    ez=e+10-e%10;
  }else{
    ez=e;
  }

  if(t==1){
    printf("%d\n",num+bz+cz+dz+ez);
  }
  if(t==2){
    printf("%d\n",num+az+cz+dz+ez);
  }
  if(t==3){
    printf("%d\n",num+bz+az+dz+ez);
  }
  if(t==4){
    printf("%d\n",num+bz+cz+az+ez);
  }
  if(t==5){
    printf("%d\n",num+bz+cz+dz+az);
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <algorithm>
using namespace std;

char S[3][2020]; int L[3];
bool D[3][8080];
const int bias = 4004;

void mk(int u, int p, int q)
{
	for (int j = -bias; j <= bias; j++){
		bool good = true;
		for (int i = 0; i < L[q]; i++){
			if (j + i < 0 || j + i >= L[p]) continue;
			if (S[q][i] == '?' || S[p][j + i] == '?') continue;
			if (S[q][i] != S[p][j + i]){ good = false; break; }
		}
		D[u][j + bias] = good;
	}
}

int main()
{
	scanf ("%s %s %s", S[0], S[1], S[2]);
	for (int k = 0; k < 3; k++) while (S[k][L[k]]) L[k]++;

	mk(0, 0, 1);
	mk(1, 0, 2);
	mk(2, 1, 2);

	int ans = bias * 3;
	for (int j = -bias; j <= bias; j++) if (D[0][j + bias]){
		for (int k = -bias; k <= bias; k++) if (D[1][k + bias]){
			if (k - j < -bias || k - j > bias || D[2][k - j + bias]){
				int l = min({ 0, j, k });
				int r = max({ L[0], j + L[1], k + L[2] });
				ans = min(ans, r - l);
			}
		}
	}
	printf ("%d\n", ans);

	return 0;
}

Measured memory_bytes: 128
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    A, B = map(int, input().split())
    print(A * B - A - B + 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <stdio.h>
#include <math.h>
#include <stdlib.h>

int main(){
    int num = 0;
    int* point;
    int i;
    double avg = 0.0;
    double ans = 0.0;
    
    while(1){
		scanf( "%d", &num );
    
		if( num == 0 ){
			break;
		}
    
		avg = 0.0;
		ans = 0.0;
	    point = ( int* )malloc( sizeof( int ) * num );
	    
	    for( i = 0; i < num; i++ ){
		    scanf( "%d", &point[i] );
			avg += (double)point[i];
		}
		
		avg /= num;
    
		for( i = 0; i < num; i++ ){
			ans += ((double)point[i] - avg) * ((double)point[i] - avg);
		}
		
		ans = sqrt( ans / (double)num );
    
		printf( "%lf\n", ans );
    
		free( point );
	}
    return 0;
}


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

using ll = long long;

int main() {
  ll n;
  cin >> n;
  
  ll ans = 1e13;
  for(ll i = 1; i * i <= n; i++){
    if(n % i == 0) ans = min(ans, (i - 1) + (n / i) - 1);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

a, b, x = map(int, input().split())
V = a * a * b
ta = 0.0
if x > V / 2.0:
    ta = 2.0 * (V - x) / (a ** 3)
else:
    ta = b * b * a / (2.0 * x)

print(math.degrees(math.atan(ta)))


Measured memory_bytes: 2940
#include<stdio.h>
#include<stdlib.h>
int judge(int [],int );
int fun(int [],int );
int judge(int a[],int n)
{
    int i;
    for(i=0;i<n;i++)
    {
        if(a[i]%2==1)
        {
            return 0;
        }
    }
    return 1;
}
int fun(int a[],int n)
{
    int ans=0,i;
    while(judge(a,n)==1)
    {
        for(i=0;i<n;i++)
        {
            a[i]=a[i]/2;
        }
        ans++;
    }
    return ans;
}
int main()
{
    int a[200];
    int n,i;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    printf("%d\n",fun(a,n));
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
            int[] S = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int q = int.Parse(Console.ReadLine());
            int[] T = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            int cnt = 0;

            for(int i= 0; i < q; i++)
            {
                if (S.Contains(T[i])) cnt++;
            }

            Console.WriteLine(cnt);
        }
    }
}

Measured memory_bytes: 10204
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> bool get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'&&t!=EOF; t=getchar());
	if(t=='-')neg=true,t=getchar();if(t==EOF)return false;
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;return true;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) (get1(a)&&get1(b))
#define get3(a,b,c) (get1(a)&&get2(b,c))
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,k;map<int,int> cnt;
int main()
{
	get2(n,k);for(int i=1;i<=n;i++){int x;get1(x);cnt[x]++;}
	vector<int> p;for(auto v:cnt)p.pb(-v.ss);
	sort(p.begin(),p.end());
	int ans=n;for(int i=0;i<(int)p.size()&&i<k;i++)ans+=p[i];printendl(ans);
	return 0;
}

Measured memory_bytes: 10748
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll t,p,q,x,c1,c2,c3;
    ll n,m,z;
    ll v1[10],v2[10],v3[10];
     v1[0]=1;v1[1]=3;v1[2]=5;v1[3]=7;v1[4]=8;v1[5]=10;v1[6]=12;
     v2[0]=4;v2[1]=6;v2[2]=9;v2[3]=11;
     v3[0]=2;
    cin>>n>>m;
    c1=0;
    for(ll i=0; i<7; i++)
    {
       if(v1[i]==n) c1++;
       if(v1[i]==m) c1++;
    }
    c2=0;
    for(ll i=0; i<4; i++)
    {
       if(v2[i]==n) c2++;
       if(v2[i]==m) c2++;
    }
    c3=0;
    for(ll i=0; i<1; i++)
    {
       if(v3[i]==n) c3++;
       if(v3[i]==m) c3++;
    }


    if(c1==2 || c2==2 || c3==2) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}








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

E = []

for i in range(N):
    E.append((P[i]+1)/2)

tnt = sum(E[:K])
ans = tnt

for i in range(N-K):
    tnt = tnt + E[K+i] - E[i]
    ans = max(ans, tnt)

print(ans)


Measured memory_bytes: 32144
#include <stdio.h>

#define MOD 1000000007

int dp[100][64];

int main(void) {
	for (int i = 0; i < 64; i++) dp[0][i] = 1;
	dp[0][6] = dp[0][9] = dp[0][18] = 0;

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

	for (int i = 1; i < n-2; i++) {
		for (int j = 0; j < 64; j++) {
			dp[i][j] = 0;
			if (j == 6 || j == 9 || j == 18) continue;

			for (int k = 0; k < 64; k++) {
				if (j%4 == 2 && k%16 == 1) continue; // *AB + C
				if (j%4 == 1 && k%16 == 2) continue; // *AC + B
				if (j%4 == 2 && k%16 == 4) continue; // *BA + C
				if (j%4 == 2 && k>>2 == 1) continue; // AB* + C
				if (j%4 == 2 && k>>4 == 0 && k%4 == 1) continue; // A*B + C
				if ((j>>2) == (k%16))
					dp[i][j] = (dp[i][j] + dp[i-1][k]) % MOD;
			}
		}
	}

	int sum = 0;
	for (int i = 0; i < 64; i++) sum = (sum + dp[n-3][i]) % MOD;
	printf("%d\n", sum);
}


Measured memory_bytes: 128
//Love and Freedom.
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#define ll long long
#define inf 20021225
#define N 1010
#define M 2010
#define mdn 1000000007
using namespace std;
ll read()
{
	ll s=0,t=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')	t=-1; ch=getchar();}
	while(ch>='0' && ch<='9')	s=s*10+ch-'0',ch=getchar();
	return s*t;
}
struct edge{int x,y,v;}e[M];
bool operator<(edge a,edge b){return a.v<b.v;}
int fa[N],n,m; ll w[M];
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
bool merge(int x,int y)
{
	int fx=find(x),fy=find(y);
	if(fx==fy)	return 0;
	fa[fx]=fy; return 1;
}
ll kruskal(int k)
{
	for(int i=1;i<=n;i++)	fa[i]=i; ll ans=merge(e[k].x,e[k].y)*e[k].v;
	for(int i=1;i<=m;i++)	ans+=merge(e[i].x,e[i].y)*e[i].v;
	return ans;
}
int ksm(int bs,int mi)
{
	int ans=1;
	while(mi)
	{
		if(mi&1)	ans=1ll*ans*bs%mdn;
		bs=1ll*bs*bs%mdn; mi>>=1;
	}
	return ans;
}
int main()
{
	n=read(),m=read(); ll X=read();
	for(int i=1;i<=m;i++)	e[i].x=read(),e[i].y=read(),e[i].v=read();
	sort(e+1,e+m+1); for(int i=1;i<=m;i++)	w[i]=kruskal(i);
	if(w[1]>X)	return puts("0"),0;
	if(w[1]==X)
	{
		int s=0; for(int i=1;i<=m;i++)	s+=w[i]==X;
		printf("%d\n",1ll*(ksm(2,s)-2)*ksm(2,m-s)%mdn);
		return 0;
	}
	else
	{
		int spc=0,s=0; for(int i=1;i<=m;i++)	s+=w[i]<X,spc+=w[i]==X;
		printf("%d\n",2ll*(ksm(2,spc)-1)%mdn*ksm(2,m-s-spc)%mdn);
	}
	return 0;
}

Measured memory_bytes: 256
function main(input){

  	var document = input[0].split(/\r\n/);
	document = input[1].split(' ');
	var ary = document.filter(
		function(e) {
    		return e != ' '
    	}
    )

	var num = ary.map( str => parseInt(str, 10) );
  	var result = 'APPROVED';
 	for (var i = 0; i < num.length; i++) {
    	if (num[i]%2 === 0) {
        	if(!(num[i]%3 === 0 || num[i]%5 === 0)) {
            	result = 'DENIED';
            }
        }
    }
	console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int H, W;
    cin >> H >> W;
    int count=0;
    vector<vector<char>> s(H, vector<char>(W));
    rep(i,H){
        rep(j,W){
            cin >> s[i][j];
            if(s[i][j]=='.') count++;
        }
    }
    
    vector<vector<int>> dist(H, vector<int>(W, -1));
    dist[0][0]=0;
    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    
    while(!que.empty()){
        pair<int, int> v;
        v=que.front();
        que.pop();
        for(int i=0; i<4; i++){
            if(v.F+dx[i]<0 || v.F+dx[i]<0){
                continue;
            }
            if(v.F+dx[i]>=H || v.S+dy[i]>=W) continue;
            if(dist[v.F+dx[i]][v.S+dy[i]]!=-1){
                continue;
            }
            if(s[v.F+dx[i]][v.S+dy[i]]=='#') continue;
            dist[v.F+dx[i]][v.S+dy[i]]=dist[v.F][v.S]+1;
            que.push(make_pair(v.F+dx[i],v.S+dy[i]));
        }
    }
    if(dist[H-1][W-1]==-1){
        cout << -1 << endl;
    }
    else{
        cout << count-dist[H-1][W-1]-1 << endl;
    }
}

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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

int N;

int main() {
    cin >> N;

    vvi X(N, vi(2, 0));
    int x, y;
    for (int i = 0; i < N; i++) {
        cin >> x >> y;
        X[i] = {x, y};
    }

    vvi PList(0);
    int nP = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            vi P = {X[i][0] - X[j][0], X[i][1] - X[j][1]};

            if (P[0] < 0) {
                P[0] = -P[0];
                P[1] = -P[1];
            }
            if (P[0] == 0 && P[1] < 0) {
                P[1] = -P[1];
            }
            PList.push_back(P);
            nP++;
        }
    }

    sort(PList.begin(), PList.end(), [](vi l, vi r) {
        if (l[0] != r[0])
            return l[0] < r[0];
        else
            return l[1] < r[1];
    });

    vi Q(2, INF);
    int ans = 0;
    int count = 0;
    for (int i = 0; i < nP; i++) {
        if (PList[i][0] == Q[0] && PList[i][1] == Q[1]) {
            count++;
        } else {
            ans = max(ans, count);
            count = 1;
            Q = PList[i];
        }
    }
    ans = max(ans, count);

    cout << N - ans << endl;
    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, w;
    cin >> n >> w;
    ll w1, v1;
    cin >> w1 >> v1;
    vector<ll> stuff[4];
    stuff[0].push_back(v1);
    rep (i, n - 1) {
        int w, v;
        cin >> w >> v;
        stuff[w - w1].push_back(v);
    }
    rep (i, 4) sort(stuff[i].begin(), stuff[i].end(), greater<int>());

    ll ans = 0;
    int i, j, k, l; 
    for (i = 0; i < stuff[0].size() + 1; ++i) {
        for (j = 0; j < stuff[1].size() + 1; ++j) {
            for (k = 0; k < stuff[2].size() + 1; ++k) {
                for (l = 0; l < stuff[3].size() + 1; ++l) {
                    ll tmp, value = 0;
                    tmp = w1 * i + (w1 + 1) * j + (w1 + 2) * k + (w1 + 3) * l;
                    if (tmp > w) continue;
                    rep (v, i) value += stuff[0][v];
                    rep (v, j) value += stuff[1][v];
                    rep (v, k) value += stuff[2][v];
                    rep (v, l) value += stuff[3][v];
                    ans = (ll)max(ans, value);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String data = scanner.nextLine();
    String[] array = data.split(" ");

    char[] chars = new char[3];

    for(int i=0; i<array.length; i++) {
        chars[i] += array[i].charAt(0);
    }
    String output = new String(chars);
    System.out.println(output.toUpperCase());
  }
}


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

vector<int> r_max(vector<int> v){
  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  vector<int> ret (2);
  ret.at(0) = v.at(0);
  ret.at(1) = v.at(1);
  return ret;
}

int main() {
  int n;
  cin >> n;
  vector<int> a (n);
  for(int i=0; i<n; i++){
    cin >> a.at(i);
  }
  int ma,ma_s;
  ma = r_max(a).at(0);
  ma_s = r_max(a).at(1);
  for(int i=0; i<n; i++){
    if(a.at(i) == ma){
      cout << ma_s << endl;
    }
    else{
      cout << ma << endl;
    }
  }
}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

class UnionFind {
public:
  const static int MAX_N = 100010;
  int par[MAX_N];
  int s[MAX_N];
  UnionFind() { init(); }
  UnionFind(int n) { init(n); }
  void init() { for(int i=0; i<MAX_N; ++i) par[i] = i, s[i] = 1; }
  void init(int n) { for(int i=0; i<n; ++i) par[i] = i, s[i] = 1; }
  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }
  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(s[x] < s[y]) par[x] = y, s[y] = s[x] + s[y];
    else par[y] = x, s[x] = s[x] + s[y];
  }
  bool same(int x, int y) { return find(x) == find(y); }
  int size(int x) { return s[find(x)]; }
};
UnionFind uf;

ll binpow(ll x, ll e, ll mo=MOD) {
  ll a = 1, p = x;
  while(e > 0) {
    if(e%2 == 0) {p = (p*p) % mo; e /= 2;}
    else {a = (a*p) % mo; e--;}
  }
  return a;
}

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

  int n, m, x;
  cin >> n >> m >> x;
  VV<int> e(m, V<int>(3));
  REP(i, m) cin >> e[i][1] >> e[i][2] >> e[i][0], e[i][1]--, e[i][2]--;
  
  map<int, int> mp;
  sort(ALL(e));
  REP(i, m) {
    uf.init(n);
    uf.unite(e[i][1], e[i][2]);
    int ret = e[i][0];
    REP(j, m) {
      if(i==j) continue;
      if(!uf.same(e[j][1], e[j][2])) {
        uf.unite(e[j][1], e[j][2]);
        ret += e[j][0];
      }
    }
    mp[ret]++;
  }

  for(auto i=next(mp.begin()); i!=mp.end(); i++) {
    i->second += prev(i)->second;
  }

  auto f = [&](int x) {
    auto itr = mp.upper_bound(x);
    int c;
    if(itr == mp.begin()) c = 0;
    else itr--, c = itr->second;
    if(c == 0) return binpow(2, m);
    return binpow(2, m-c+1);
  };

  cout << (((f(x-1) - f(x)) % MOD) + MOD) % MOD << endl;

  return 0;
}


Measured memory_bytes: 2048
#include <stdio.h>

int main(){
    int a, b;
    scanf("%d %d", &a, &b);
    if (a==1)
        a += 13;
    if (b == 1)
        b += 13;

    if (a > b)
        printf("Alice\n");
    else if(b>a)
        printf("Bob\n");
    else
        printf("Draw\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>

#define N 2

using namespace std;

int main(){
	double a[N][N+1];
	double d;
	int i, j, k;
	bool flag = 1;

	while(cin >> a[0][0] >> a[0][1] >> a[0][2] >> a[1][0] >> a[1][1] >> a[1][2]){
		for(k = 0; k < N - 1; k++){
			for(i = k+1; i < N; i++){
				d = a[i][k] / a[k][k];
				for(j = k + 1; j <= N; j++){
					a[i][j] = a[i][j] - a[k][j] * d;
				}
			}
		}
		for(i = N - 1; i >= 0; i--){
			d = a[i][N];
			for(j = i + 1; j < N; j++){
				d = d - a[i][j] * a[j][N];
			}
			a[i][N] = d / a[i][i];
		}
		printf("%.3f %.3f\n", a[0][N], a[1][N]);
	}
	return 0;
}

Measured memory_bytes: 3156
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        while(true){
            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();

            if(m == -1 && f == -1 && r == -1)break;
            if(m==-1 || f==-1)System.out.println("F");
            else if(m+f >= 80)System.out.println("A");
            else if(m+f >= 65)System.out.println("B");
            else if(m+f >= 50)System.out.println("C");
            else if(m+f >= 30){
                if(r>=50)System.out.println("C");
                else System.out.println("D");
            }
            else System.out.println("F");
        }

    }
}


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

using namespace std;

int main(void) {
  int N; cin >> N;
  vector<pair<int, int>> rng;
  for (int i = 0; i < N; i++) {
    int x, l; cin >> x >> l;
    rng.push_back(make_pair(x-l, x+l));
  }
  sort(rng.begin(), rng.end());

  int end = rng[0].second;
  int ans = 1;
  for (auto it = begin(rng) + 1; it != rng.end(); ++it) {
    if (end <= it->first) {
      ans++;
      end = it->second;
    } else {
      end = end < it->second ? end : it->second;
    }
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
// C - Traveling Salesman around Lake

int main()
{
    long long N, K;
    cin >> N >> K;

    long long bn, n;
    bn = N + 1;
    n = N;

    long long rrr = N % K;

    cout << min(rrr,abs(rrr-K)) << endl;
}

Measured memory_bytes: 256
using System; 
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq; 
using E = System.Linq.Enumerable; 
class Program {
    
    static void Main(string[] args) {
        
        //var NM = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = long.Parse(Console.ReadLine());
        
        var ans = 1;
        
        while(ans*(ans+1)/2 < N){
            ans++;
        }
        var res = ans*(ans+1)/2 - N;
        
        for(int i =1;i <= ans;i++){
            if(res == i)continue;
            Console.WriteLine(i);
        }
        
        
     }
}


Measured memory_bytes: 27460
n=int(input())
ai=[]
for i in map(int,input().split()):
    ai.append(i)
bi=[]
for i in map(int,input().split()):
    bi.append(i)

asum=0
for i in range(n+1):
    asum=asum+ai[i]    

i=0
if ai[i]<=bi[i]:
    bi[i]=bi[i]-ai[i]
    ai[i]=0
else :
    ai[i]=ai[i]-bi[i]
    bi[i]=0
for i in range(1,n,1):
    if ai[i]<=bi[i-1]:
        bi[i-1]=bi[i-1]-ai[i]
        ai[i]=0
    else :
        ai[i]=ai[i]-bi[i-1]
        bi[i-1]=0
    if ai[i]<=bi[i]:
        bi[i]=bi[i]-ai[i]
        ai[i]=0
    else :
        ai[i]=ai[i]-bi[i]
        bi[i]=0
i=n
if ai[i]<=bi[i-1]:
    bi[i-1]=bi[i-1]-ai[i]
    ai[i]=0
else :
    ai[i]=ai[i]-bi[i-1]
    bi[i-1]=0

asum2=0
for i in range(n+1):
    asum2=asum2+ai[i]    

print(asum-asum2)        

Measured memory_bytes: 19372
#include<iostream>
using namespace std;
int main(){
	string str;
	cin >> str;
	
	for (char c = 'a'; c <= 'z'; c++){
		bool found=false;
		for (int i = 0; i < str.length(); i++){
			if (str[i] == c){
				found = true;
			}
		}
		if (found == false){
			cout << c << endl;
			return 0;
		}
	}
	cout << "None" << endl;
	return 0;


}

Measured memory_bytes: 512
n, k = map(int, input().split())
a = list(map(int, input().split()))
count = 0
mod = 10 ** 9 + 7
for i in range(n):
    for j in range(i + 1, n):
        if a[i] > a[j]:
            count += k * (k + 1) // 2
            count %= mod
        elif a[i] < a[j]:
            count += k * (k - 1) // 2
            count %= mod
count %= mod
print(count)

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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    int h, w; cin >> h >> w;
    int row, col;
    REP(i, h) REP(j, w) {
        string s; cin >> s;
        if (s == "snuke") {
            row = i;
            col = j;
        }
    }

    char A = 'A' + col;
    cout << A << row + 1 << '\n';
    return 0;
}

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

int check(int n){
  int cnt = 0;
  while (n) {
    n /= 10;
    cnt++;
  }
  if (cnt % 2 == 1) return 1;
  else
    return 0;
}

int main() {
    int n, out=0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
      out += check(i);
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3632
#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>;

int main() {
  string s;
  cin >> s;
  vector<bool> used(26, false);
  bool varied = true;
  rep(i, s.size()) {
    if (used[s[i]-'a']) varied = false;
    used[s[i]-'a'] = true;
  }
  if (varied) cout << "yes" << endl;
  else cout << "no" << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second

int main(){
    FAST
    string s; cin >> s;
    if(s[s.size() - 1] == 's')s += "es";
    else s += "s";
    cout << s;
    return 0;
}


Measured memory_bytes: 3656