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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define INF 1e9
int N,X[101];

int main(){
	fast;
	
	cin>>N;
	
	FOR(i,0,N-1) cin>>X[i];
	
	
	int ans = INF;
	
	FOR(i,1,100){
		int cur = 0;
		FOR(j,0,N-1) cur += pow(X[j] - i,2);
		
		ans = min(ans,cur);
	}
	cout<<ans;
}




Measured memory_bytes: 256
N,P = map(int,input().split())
lst=[int(d) for d in input()]
chk=[0]*P
t=0
c=1
if P==2:
 ans=0 
 a=N
 for x in lst[::-1]:
  if x%2==0:
   ans+=a
  a-=1
 print(ans)
elif P==5:
 ans=0 
 a=N
 for x in lst[::-1]:
  if x%5==0:
   ans+=a
  a-=1  
 print(ans)
else:
 for x in lst[::-1]:
  t+=c*x
  t%=P
  chk[t]+=1
  c*=10
  c%=P 
 md=0
 ans=chk[0]
 d=1
 for i in range(N-1):
  md=(md+lst[N-1-i]*d)%P
  if chk[md]>0:
   chk[md]-=1
  ans+=chk[md]
  d*=10
  d%=P
 print(ans)


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
// template starts
typedef long long int ll;
ll fact(ll n, ll p){
	ll ans = 1;
	for(ll i = 1; i <= n; i++){
		ans *= i;
		ans %= p;
	}
	return ans;
}
ll power(ll x, ll n, ll p){
	ll res = 1;
	if(n == 1) return x%p;
	if(n%2 == 1) res = x%p;

	ll temp = power(x,n/2,p);
	return res*((temp*temp)%p)%p;
}
ll inv(ll a, ll p){
	return power(a,p-2,p);
}
ll nCr(ll n, ll r, ll p){
	if(r > n) return 0;
	ll t1 = fact(n,p);
	ll t2 = inv(fact(r,p),p);
	ll t3 = inv(fact(n-r,p),p);

	return (((t1*t2)%p)*t3)%p;
}
vector<vector<ll> > multiply(vector<vector<ll> > &a, vector<vector<ll> > &b, ll p){
	int r1,c1,r2,c2;
	r1 = a.size(); c1 = a[0].size();
	r2 = b.size(); c2 = b[0].size();

	vector<vector<ll> > result(r1,vector<ll>(c2,0));

	if(c1 != r2) return result;

	for(int i = 0; i < r1; i++){
		for(int j = 0; j < c2; j++){
			for(int k = 0; k < c1; k++){
				result[i][j] += a[i][k]*b[k][j];
				result[i][j] %= p;
			}
		}
	}
	return result;
}

vector<vector<ll> > power(vector<vector<ll> >&a,ll n, ll p){
	int r = a.size();
	vector<vector<ll> > result(r,vector<ll>(r,0));
	for(int i = 0; i < r; i++) result[i][i] = 1;

	while(n > 0){
		if(n%2 == 1){
			result = multiply(result,a,p);
		}
		n /= 2;
		a = multiply(a,a,p);
	}
	return result;
}
// template ends here

void solve(){
	// code starts from here
	ll N,M;
	cin >> M>> N;
	vector<ll> vec(N);
	ll sum = 0;
	for(int i = 0; i < N; i++){
		ll temp;
		cin >> temp;
		sum += temp;
	}
	if(sum > M){
		cout << -1 << endl;
	}
	else cout << M-sum << endl;
}

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

	int T;
	T = 1;
	while(T--){
		solve();
	}

	return 0;
}


Measured memory_bytes: 3704
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define pb            push_back
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>

const int INF = 1e9;

// code
// ------------------------------------------------
int main() {

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

  if(a == b)
    cout << c;
  else if(a == c)
    cout << b;
  else
  {
    cout << a;
  }
  
  return 0;
}

// funcの実体
// ------------------------------------------------
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n) ; ++i)
#define rrep(i,n) for(int i = (n-1); i>=0; --i)
#define PI 3.14159265
#define INF 1e9
#define LINF 1e18
using namespace std;
using ll = long long;
void self_max(int &a,int b){
	a = max(a,b);
}
void self_min(int &a,int b){
	a = min(a,b);
}

int main(){
	int n,w; cin >>n >> w;
	vector<int> weight(n),val(n); 
	rep(i,n){
		cin >> weight[i] >> val[i];
	}	

	vector<vector<ll>> dp(n+1,vector<ll> (100001,LINF));
	dp[0][0] = 0;

	rep(i,n) rep(j,100001){
		if(j>=val[i]){
			dp[i+1][j] = min(dp[i][j-val[i]]+weight[i],dp[i][j]);
		}else{
			dp[i+1][j] = dp[i][j];
		}
	}

	rrep(i,100001){
		if(dp[n][i] <= w){
			cout << i << endl;
			break;
		}
	}


	

	return 0;
}

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

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    reverse(a.begin(),a.end());
    for(int i=0; i<n; i++) {
        cout << a[i];
        if(i != n - 1) cout << " ";
    }
    cout << endl;
}


Measured memory_bytes: 3080
#include <iostream>
#include <vector>
#include <algorithm>

#ifdef _MSC_VER
#pragma warning(disable:4996)
#endif

using namespace std;

int length_no_shortcut(int i, int j);
int length_shortcut(int i, int j, int x, int y);

struct DATA{
	int i;
	int j;
	int length;
};

int main() {
	int n, x, y;
	cin >> n >> x >> y;

	x--;
	y--;

	vector<DATA> data;

	for (int i = 0; i < n - 1; i++) {
		for (int j = i + 1; j < n; j++) {
			data.push_back({ i, j, min(length_no_shortcut(i, j), length_shortcut(i, j, x, y)) });
		}
	}

	sort(data.begin(), data.end(), [](const DATA& a, const DATA& b) { return a.length < b.length; });

	int i = 0;
	for (int k = 1; k < n; k++) {
		int cnt = 0;
		for (; i < (int)data.size() && data[i].length == k; i++)  cnt++;
		cout << cnt << "\n";
	}

	
	return 0;
}

int length_no_shortcut(int i, int j) {
	return abs(i - j);
}

int length_shortcut(int i, int j, int x, int y) {
	return abs(i - x) + 1 + abs(j - y);
}


Measured memory_bytes: 26856
#include<bits/stdc++.h>
#define int			long long
#define ll 			long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<int,int>
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define dep(i,a,b)	for(int i=a;i>=b;i--)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
using namespace std;

#define N  100005

void solve()
{
	string s;
	cin>>s;
	if(s[2]==s[3] and s[4]==s[5])
		cout<<"Yes";
	else
		cout<<"No";
}

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

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

using namespace std;

int main() {
	vector<int> ans;
	int n,a;
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (i % 2 == 0) {
			ans.push_back(a);
		}
		else {
			ans.insert(ans.begin(), a);
		}
	}
	if (n % 2 == 1) {
		cout << ans[n-1];
	}
	else {
		cout << ans[0];
	}

	for (int i = 1; i < n;i++) {
		cout << " ";
		if (n % 2 == 1) {
			cout << ans[n - 1 - i];
		}
		else {
			cout << ans[i];
		}
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 3060
C=input()
alph=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(alph)):
    if C in alph[i]:
        ans=alph[i+1]
print(ans)

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

int main(){
	int r, g, b;
	cin >> r >> g >> b;
	if((10*g+b) % 4 == 0) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

int main(){
    int xdir[5]={1,0,-1,0},ydir[5]={0,1,0,-1};
    int h,w,n;
    int x,y,col;
    int arr[10005];
    int paint[105][105]={};
    queue<tuple<int,int,int> > q;//y,x,color
    scanf("%d%d%d",&h,&w,&n);
    for(int i =1 ; i <= n ;i++){
        scanf("%d",&arr[i]);
    }
    q.push( make_tuple(0,0,1) );
    while(!q.empty()){
        tie(y,x,col)=q.front();
        q.pop();
        paint[y][x]=col;
        if( !(--arr[col]) ){
            col++;
        }
        if(col>n){
            break;
        }
        for(int i =0 ; i < 4 ;i++){
            if(y + ydir[i]>=0 && y + ydir[i]<h && x + xdir[i]>=0 && x + xdir[i]<w && !paint[y + ydir[i]][x + xdir[i]]){
                q.push( make_tuple(y+ydir[i],x+xdir[i],col) );
                break;
            }
        }
    }
    for(int i = 0 ; i < h ; i++){
        for(int j =0 ; j < w ; j++){
            printf("%d ",paint[i][j]);
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
c=[list(map(int,input().split())) for _ in range(3)]
a_a=set()
a_b=set()
a_c=set()

for i in range(3):
    a_a.add(c[i][0]-c[i][1])
    a_b.add(c[i][1]-c[i][2])
    a_c.add(c[i][2]-c[i][0])
if len(a_a)==1 and len(a_b)==1 and len(a_c)==1:
    print('Yes')
else:
    print('No')

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

int main()
{
    int N;
    string S;
    cin >> N >> S;

    int64_t R = 0;
    int64_t G = 0;
    int64_t B = 0;

    for (int i = 0; i < N; i++)
    {
        if (S[i] == 'R')
            R++;
        if (S[i] == 'G')
            G++;
        if (S[i] == 'B')
            B++;
    }
    int64_t count = R * G * B;

    //jを固定
    for (int j = 1; j < N - 1; j++)
    {
        //ここでのiは問題文のj - i、k - j
        for (int i = 1; j - i >= 0 && j + i < N; i++)
        {
            if (S[j - i] != S[j] && S[j - i] != S[j + i] && S[j] != S[j + i])
                count--;
        }
    }
    cout << count;
}
    

Measured memory_bytes: 3600
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        int num1 = 0;
        char last = s.charAt(0);
        for (int i = 1; i < s.length(); ++i) {
            if (s.charAt(i) == last) {
                ++num1;
                last = (s.charAt(i) == '0') ? '1' : '0';
            } else {
                last = s.charAt(i);
            }
        }

        int num2 = 1;
        last = (s.charAt(0) == '0') ? '1' : '0';
        for (int i = 1; i < s.length(); ++i) {
            if (s.charAt(i) == last) {
                ++num2;
                last = (s.charAt(i) == '0') ? '1' : '0';
            } else {
                last = s.charAt(i);
            }
        }
        System.out.println(Math.min(num1, num2));
    }
}


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

public class Main {
	static Scanner sc = new Scanner(System.in);
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

	static String alphabet = "abcdefghijklmnopqrstuvwxyz";

	public static void main(String[] args) throws IOException {
		int n = sc.nextInt();
		sc.nextLine();
		int[] counts = new int[26];
		Arrays.fill(counts, 50);
		for(int i = 0; i < n; i++) {
			String curr = sc.nextLine();
			int[] countsCurr = new int[26];
			for(int j = 0; j < curr.length(); j++) {
				String letter = curr.substring(j, j+1);
				int index = alphabet.indexOf(letter);
				countsCurr[index]++;
			}
			for(int j = 0; j < 26; j++) {
				counts[j] = Math.min(counts[j], countsCurr[j]);
			}
		}

		String ans = "";
		for(int i = 0; i < 26; i++) {
			if(counts[i] > 0) {
				int countLetter = counts[i];
				for(int j = 0; j < countLetter; j++) {
					ans += alphabet.charAt(i);
				}
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
ll mod = 1000000007;
ll mod9 = 1000000009;

signed main(){
    ll n;
    cin>>n;
    ll a;
    a = divup(n,2);
    cout<<a<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
using vii = vector<vector<int>>;
using vi = vector<int>;
vii dist;
vi dx = { 1, 0, -1, 0 };
vi dy = { 0, -1, 0, 1 };
int h, w;
vector<string> s;

int dfs(int i, int j, int d = 0) {
    dist[i][j] = d;
    int ni, nj;
    rep(k, 4) {
        ni = i + dx[k];
        nj = j + dy[k];
        if (ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
        if (s[ni][nj] == '#') continue;
        if (dist[ni][nj] != -1 && dist[ni][nj] <= d+1) continue;
        
        dfs(ni, nj, d + 1);
    }
    return 0;
}

int main()
{    
    cin >> h >> w;
    s = vector<string>(h);
    rep(i, h) {
        cin >> s.at(i);
    }
    dist = vii(h, vi(w, -1));

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            if (s[i][j] != '#') {
                dist = vii(h, vi(w, -1));
                dfs(i, j);
                
                int tans = 0;
                rep(ti, h) {
                    rep(tj, w) {
                        tans = max(tans, dist[ti][tj]);
                    }
                }

                ans = max(tans, ans);
            }            
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<functional>
#include<string>
#include<vector>
#include<cstring>
#include<utility>
#include<set>
#include<map>

#define ll long long
#define ull unsigned long long
#define MOD 1000000007
#define MAX 2e9
#define pii pair<int, int>
#define pll pair<ll, ll>
#define all(v) v.begin(), v.end()
const double PI = acos(-1);

using namespace std;

int main(void) {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	//	freopen("input.txt", "r", stdin);

	int x; cin >> x;
	if (x == 1) cout << 0;
	else cout << 1;
}


Measured memory_bytes: 3540
from math import sqrt, factorial

N = int(input())
x = [list(map(int, input().split())) for _ in range(N)]

distance = 0
for i in range(N):
    for j in range(N):
        distance += sqrt((x[j][0]-x[i][0])**2 + (x[j][1]-x[i][1])**2)

print(distance/N)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,s=0,t=101010;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
    s=max(s,a[i]);
    t=min(t,a[i]);
  }
  cout<<s-t<<endl;
  return 0;
}

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

using namespace std;

int add(int N){
  int S=0,a;
  for(int i=0;i<10;i++){
    a=N%10;
    S+=a;
    N/=10;
  }
  return S;
}

int main(){
  int N;
  cin >> N;
  int S=0;
  S=add(N);
  if(N%S==0)  cout << "Yes" << endl;
  else  cout << "No" << endl;

  return 0;
}


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

int main() {

    int n,m,k,answer=0;
    cin>>n>>m>>k;

    char a[n][m];
    for(int i=0;i<n;i++) {
        for(int j=0;j<m;j++) {
            cin>>a[i][j];
        }
    }
    for(int i=0;i<(1<<n);i++) {
        for(int j=0;j<(1<<m);j++) {
            int nOfBlack = 0;
            for(int k=0;k<n;k++) {
                for(int v = 0;v<m;v++) {
                    if(i >> k & 1 && j >> v & 1) {
                        if(a[k][v] == '#') {
                            nOfBlack++;
                        }
                    }
                }
            }
            if(nOfBlack == k) {
                answer++;
            }

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



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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N % 500 == 0){
    cout << "Yes" << endl;
  }
  
  else if (N % 500 <= A){
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" <<endl;
  }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	int r,w;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			r++;
		}
	}
	int cnt=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='R'){
			if(i>r-1){
				cnt++;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    vector<pair<int,int> >v;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        int a,b;
        cin>>a>>b;
        v.push_back({b,a});
    }
    sort(all(v));
    ll t=0;
    for(int i=0;i<n;i++){
        t+=v[i].second;
        if(t>v[i].first)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 5308
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
ll A(pair<ll, ll> a, pair<ll, ll> b){
	return (ll)abs(a.first - b.first) + (ll)abs(a.second - b.second);
}
int main(){
	ll h, w, d;
	cin >> h >> w >> d;
	map<ll, pair<ll, ll>> m;
	for(ll i = 0; i < h; i++){
		for(ll j = 0; j < w; j++){
			ll a;
			cin >> a;
			m[a] = pair<ll, ll>(i, j);
		}
	}
	ll q;
	cin >> q;
	ll memo[h * w + 1] = {};
	pair<ll, ll> anabi[q];
	for(ll i = 0; i < q; i++){
		ll l, r;
		cin >> l >> r;
		anabi[i] = pair<ll, ll>(l, r);
	}
	for(ll i = 1; i <= h * w; i++) memo[i] = (i - d > 0 ? A(m[i], m[i - d]) + memo[i -d] : 0);
	for(ll i = 0; i < q; i++) cout << memo[anabi[i].second] - memo[anabi[i].first] << endl;
	return 0;
}

Measured memory_bytes: 8960
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

const ll mod = 1000000007;

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

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll T;

mint comb( ll n, ll k ) {
  mint ret = 1;

  rep( i, k )
    ret *= n-i;

  rep( i, k )
    ret /= i+1;

  return ret;
}

int main()
{
  std::cin >> T;

  rep( t, T ) {
    ll N;
    std::cin >> N;
    N -= 5;

    mint ans = 0;

    rep( o, 12 ) {
      ll M = N-o;
      
      if( M < 0 || M % 2 )
        continue;

      ans += comb(M/2+15, 15)*comb(11, o);
    }

    std::cout << ans.x << std::endl;
  }

  return 0;
}

Measured memory_bytes: 3628
n=int(input())
if n==1:
    print(1)
    exit()
l=[0]*(n+1)#約数0~1000の各総数
for i in range(2,n+1):
    x=i
    j=2
    while j<n+1:
        if x%j==0:
            x//=j
            l[j]+=1
        else:
            j+=1
#print(l)
ans=1
for i in range(len(l)):
    ans*=(l[i]+1)
    ans%=(10**9 +7)
print(ans)

Measured memory_bytes: 9232
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
int gcd(int a,int b){
	return b>0 ? gcd(b,a%b):a;
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int k;
	cin>>k;
	ll sum=0;
	for(int i=1;i<=k;i++){
		for(int j=1;j<=k;j++){
			for(int c=1;c<=k;c++){
				int cnt=gcd(c,gcd(i,j));
				sum+=cnt;
			}
		}
	}
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 3664
from collections import deque

n, q = map(int, input().split())
# 隣接リストを作成
adj = [[] for i in range(n)]
for i in range(n-1):
    a, b = map(int, input().split())
    adj[a-1].append(b-1)
    adj[b-1].append(a-1)

queries = [0 for i in range(n)]
for i in range(q):
    p, x = map(int, input().split())
    queries[p-1] += x

ans = [0 for i in range(n)]

# スタックによるdfs(位置, 上からの加算, 親の位置)
st = deque([(0,0,-1)])
# stが空になるまで操作
while st:
    l = st.pop()
    ans[l[0]] = l[1] + queries[l[0]]
    for v in adj[l[0]]:
        if v != l[2]:
            st.append((v, ans[l[0]], l[0]))
print(*ans)

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

int main() {
	long long n;
	cin >> n;
	long long memo=-1;
	long long x[n],y[n],h[n];
	for(long long i=0;i<n;i++){
		cin >> x[i] >> y[i] >> h[i];
		if(h[i]!=0) memo=i;
	}
	if(n==1){
		cout << x[0] << " " << y[0] << " " << h[0] << endl;
		return 0;
	}
	for(long long i=0;i<=100;i++){
		for(long long j=0;j<=100;j++){
			bool ok=true;
			long long hh=h[memo]+abs(x[memo]-i)+abs(y[memo]-j);
			for(long long k=0;k<n;k++){
				if(h[k]!=max(hh-abs(x[k]-i)-abs(y[k]-j),0LL)){
					ok=false;
				}
			}
			if(ok){
				cout << i << " " << j << " " << hh << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int x;
  int a;
  int b;
  cin >> x >> a >> b;
  if(b-a>x){
    cout << "dangerous" << endl;
  }
  else if(b>a){
   cout << "safe" << endl; 
  }
  else{
    cout << "delicious" << endl;
  }

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func Reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func reverseInts(s []int) []int {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s

}

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s sortRunes) Len() int {
	return len(s)
}

func SortString(s string) string {
	r := []rune(s)
	sort.Sort(sortRunes(r))
	return string(r)
}

func main() {
	var N int
	fmt.Scan(&N)

	var ai []float64 = make([]float64, N)

	for i := range ai {
		fmt.Scan(&ai[i])
	}

	ans := 0.0

	for _, i := range ai {
		ans += 1 / i
	}

	fmt.Println(1 / ans)

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char N;
  cin >>N;
  if ((N=='a')||(N=='i')||(N=='u')||(N=='e')||(N=='o')){
    cout <<"vowel"<< endl;
  }
  else{
    cout << "consonant"<< endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define  all(x) (x).begin(),(x).end()
typedef long long ll;

typedef struct Node{
    ll key;
    Node *parent, *left, *right;
} Node;

Node* newNode(ll key){
    Node *newN = (Node *)malloc(sizeof(Node));
    newN->key = key;
    newN->parent = NULL;
    newN->left = NULL;
    newN->right = NULL;
    return newN;
}

Node* insert(Node *n, Node *z){
    Node *y = NULL;
    Node *x = n;
    while(x != NULL){
        y = x;
        if (z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    z->parent = y;
    if (y == NULL){
        n = z;
    }else if(z->key < y->key){
        y->left = z;
    }else {
        y->right = z;
    }
    return n;
}

void inorder(Node *n){
    if(n != NULL){
        inorder(n->left);
        cout << " " << n->key;
        inorder(n->right);
    }
}

void preorder(Node *n){
    if(n != NULL){
        cout << " " << n->key;
        preorder(n->left);
        preorder(n->right);
    }
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    Node *root = NULL;
    rep(i,n){
        string o;
        cin >> o;
        if (o == "insert"){
            ll key;
            cin >> key;
            Node *newN = newNode(key);
            root = insert(root, newN);
        } else{
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
}


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

int main()
{
	int X, N; cin >> X >> N;
	set<int> ps;
	for (int i = 0; i < N; ++i) {
		int p;
		cin >> p;
		ps.insert(p);
	}
	for (int i = 0; i < 101; ++i) {
		if (!ps.count(X - i)) {
			cout << X - i << endl;
			break;
		}
		else if (!ps.count(X + i))
		{
			cout << X + i << endl;
			break;
		}
	}

}


Measured memory_bytes: 3184
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;


int bbit(int ii,int t){
  return (ii>>t)%2;
}

//vi ki(18);
//vi gu(18);
vector<int> nmn(18);
vector<pair<int, int>> nm(18);
vector<pair<int, int>> ki(18);
vector<pair<int, int>> gu(18);
//vector<pair<int, int>> ki(18);


int solve(vector<int> &v,vi &a,vi &b)
{
  int wki=0;
  int wgu=0;
  for(int i=0;i<n;i++){
    if ((v[i]+i%2)%2==0){
      if (v[i]==0){
        gu[wgu].first=a[i];
        nmn[i]=a[i];
      }else{
        gu[wgu].first=b[i];
        nmn[i]=b[i];
      }
      gu[wgu].second=i;
      wgu++;
      
    }else{
      if (v[i]==1){
        ki[wki].first=b[i];
        nmn[i]=b[i];
      }else{
        ki[wki].first=a[i];
        nmn[i]=a[i];
      }
      ki[wki].second=i;
      wki++;
    }
  }
  if (wki!=(n/2)) 
    return -1;



  int an=0;
  
  sort(gu.begin(), gu.begin()+wgu);
  sort(ki.begin(), ki.begin()+wki);
  int tmp=0,flag=0,ttmp=0;
  for(int i=0;i<n;i++){
    if (i%2==0){
      if (tmp>gu[i/2].first)flag=1;
      tmp=gu[i/2].first;
      ttmp=gu[i/2].second;
    }else{
      if (tmp>ki[i/2].first)flag=1;
      tmp=ki[i/2].first;
      ttmp=ki[i/2].second;
    }
    nm[i].first=tmp;
    nm[i].second=ttmp;
  }
  if (flag==1)return -1;
  

  /*
  REP(i,n){
    tmp=nm[i].first;

    for(int j=0;j<n;j++){
      if (nmn[j]==tmp){
        //an+=j-i;
        //an+=nm[i].second-i;
        //cout<<"!>"<<j<<"!"<<i<<"<!";
        for(int k=j-1;k>=0;k--){
          nmn[k+1]=nmn[k];
        }
        nmn[0]=-1;
        break;
      }
    }

  }
  */
 
  REP(i,n){
    an+=nm[i].second-i;
    for(int j=i+1;j<n;j++){
      if (nm[j].second<nm[i].second)nm[j].second++;
    }
  }

  /*
  REP(i,n){
    cout<<nm[i].first<<" ";
  }
  cout<<"    "<<an<<endl;
  */


  return an;
}


int main(){
  int ans=(1<<19)+1;
  cin >> n ;
  vi a(n),b(n);
  REP(i,n){
    cin>>a[i];
  }
  
  REP(i,n){
    cin>>b[i];
  }
  



  ll nn=1<<n;
  vector<int> v(n);
  int sm=0;
  int tmpans=0;
  //裏が1
  for(int i=0;i<nn;i++){
    sm=0;
    for(int j=0;j<n;j++){
      v[j]=bbit(i,j);
      sm+=v[j];
    }
    if (sm%2==1)continue;


    tmpans=solve(v,a,b);
    if (tmpans!=-1){
      ans=min(ans,tmpans);
    }
  }



  if (ans!=((1<<19)+1)){
    cout<<ans<<endl;
  }else{
    cout<<-1<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
const ll inf = 1e18;
const ll mod = 1e9 + 7;

ll pow (ll x, ll n){
    ll ans = 1;
    while(n>0){
        if(n & 1 == 1){
            ans *= x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

int a[110][110];
int main(){
    int w,h,n; cin >> w >> h >> n;
    rep(i,n){
        int x, y, c;    cin >> x >> y >> c;
        if(c==1){
            rep(i,x)    rep(j,h)    a[i][j]++;
        }
        if(c==2){
            for(int i=w-1; i>=x; i--)    rep(j,h)    a[i][j]++;
        }
        if(c==3){
            rep(i,w)    rep(j,y)    a[i][j]++;
        }
        if(c==4){
            rep(i,w)    for(int j=h-1; j>=y; j--)    a[i][j]++;
        }
    }

    int ans=0;
    rep(i,w)    rep(j,h){

        if(a[i][j] ==0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/*
ID: varunra2
LANG: C++
TASK: codechef
*/
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits.h>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

using namespace std;

#define EPS 1e-9
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert(B <= A && A <= C)
#define INF (int)1e9
#define MEM(a, b) memset(a, (b), sizeof(a))
#define MOD 1000000007
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()

typedef pair<int, int> PII;
typedef vector<int> VI;

const double pi = acos(-1.0);
typedef long int int32;
typedef long long int int64;
typedef map<int, int> MPII;
typedef multiset<int> MSETI;
typedef set<int> SETI;
typedef set<string> SETS;
typedef unsigned long int uint32;
typedef unsigned long long int uint64;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef vector<string> VS;

#define watch(x) cerr << (#x) << " is " << (x) << endl
#define printvii(v)                                    \
  cerr << (#v) << "=";                                 \
  for_each(v.begin(), v.end(), [](PII i) -> void {     \
    cerr << "(" << i.first << "," << i.second << "),"; \
  });                                                  \
  cerr << endl;
#define printvi(v)                                                       \
  cerr << (#v) << "=";                                                   \
  for_each(v.begin(), v.end(), [](int i) -> void { cerr << i << ","; }); \
  cerr << endl;

int main(int argc, char const *argv[]) {

    int n, k, q;
    cin >> n >> k >> q;

    VI vals(n, k - q);

    for(int i = 0; i < q; i++) {
      int x;
      cin >> x;
      x--;
      vals[x]++;
    }

    for(int i = 0; i < n; i++) {
      if(vals[i] > 0) {
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }

  return 0;
}


Measured memory_bytes: 1024
//package cf;

import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) throws IOException {
        Scanner io = new Scanner(System.in);
        int n = io.nextInt(), m = io.nextInt();
        int c = 0, s = 0;
        int[] arr = new int[n];
        for(int i = 0; i < n; i++)
            s += (arr[i] = io.nextInt());
        for(int i = 0; i < n; i++)
            if((double)arr[i] >= (double)s/4/m) c++;
        System.out.println(c >= m ? "Yes" : "No");
    }
}



Measured memory_bytes: 23380
from collections import deque
n, m = map(int, input().split())
route =[[] for i in range(n+1)]
for i in range(m):
    a, b = map(int, input().split())
    route[a].append(b)
    route[b].append(a)
visited = [0 for i in range(n+1)]
visited[1] = 1
ans = [0 for i in range(n+1)]
D = deque()
D.append(1)
while D:
    visit = D.popleft()
    for i in route[visit]:
        if visited[i] == 0:
            D.append(i)
            visited[i] = 1
            ans[i] = visit
print('Yes')
for i in range(2, n+1):
    print(ans[i])

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep_r(i, n) for(int i = n-1; i >= 0; i--)
#define rep1(i, n) for(int i = 1; i <= (int)(n); i++)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((ll)(x).size())
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define INF bit(60)
#define pb push_back
#define mod 1000000007

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

using namespace std;
using uif=uint_fast64_t;
using ll=long long int;
using tTree=__gnu_pbds::tree< ll , __gnu_pbds::null_type, less< ll >, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mod;a=1ll*a*a%mod;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


#define FACSIZE 2002

ll invfac[FACSIZE];
ll fac[FACSIZE];

ll mod_pow(ll ,ll );
ll mod_add(ll ,ll );
ll mod_mul(ll ,ll );
ll mod_div(ll ,ll );
void make_fact(ll );
void make_invfact(ll );

//unordered_map<string,ll> um;

int main(void){

  string s;
  cin>>s;
  ll n=s.size();
  bool cont=false;
  char prev=-1;
  ll num_A=0;
  ll ans=0;
  for(ll i=0;i<n;i++){
    auto c=s[i];
    
    if(c=='A'&&prev=='B'){
      num_A=1;
    }
    else if(c=='A'){
      num_A++;
    }
    else if(c=='C'&&prev=='B'){
      ans+=num_A;
    }
    else if(c=='C'&&prev!='B'){
      cont=false;
      num_A=0;
    }
    else if(c=='B'&&prev=='B'){
      cont=false;
      num_A=0;
    }
    prev=c;
  }

  cout << ans << endl;

  return 0;

}

ll mod_pow(ll x,ll r){
  if(r==0) return 1;
  else if(r==1) return x%mod;
  else if(r%2==0){
    ll t=mod_pow(x,r/2)%mod;
    return t*t %mod;
  } 
  else{
    ll t=mod_pow(x,r/2)%mod;
    ll k= t*t %mod;
    return k*x%mod;
  } 
}
ll mod_add(ll a,ll b){
  return (a+b)%mod;
}

ll mod_mul(ll a,ll b){
  return (a*b)%mod;
}

ll mod_div(ll a,ll b){
  return mod_mul(a,mod_pow(b,mod-2));
}

void make_fact(ll n){
  fac[0]=1;
  rep(i,n){
    fac[i+1]=mod_mul(fac[i],i+1);
  }  
}

void make_invfact(ll n){
  invfac[n]= mod_pow( fac[n] ,mod-2);
  for(int i=n-1;i>=0;i--){
    invfac[i]=mod_mul(invfac[i+1],i+1);
  }

}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int  N;
ll K;
int A[200010];

int lastX[200010];

int jump[200010];
int first2first[200010];

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

  cin >> N >> K;
  rep(i,N) cin >> A[i];

  rep(i, 200010) lastX[i] = -1;
  drep(i,N){
    if (lastX[A[i]] >= 0) {
      jump[i] = lastX[A[i]] + 1;
    }
    lastX[A[i]] = i;
  }
  rep(i, 200010) first2first[i] = -1;
  {
      int x = 0;
      while(jump[x] != 0) {
        x = jump[x];
      }
      first2first[0] = A[x];
  }
  rep(i, N) {
    if (first2first[A[i]] == -1) {
      int x = i+1;
      while(jump[x] != 0) {
        x = jump[x];
      }
      first2first[A[i]] = A[x];
    }
  }
  int loop = 1;
  int p = 0;
  while(first2first[p] != 0) {
    p = first2first[p];
    ++loop;
  }
  K = K % loop;
  if (K==0) K += loop;
  int f = 0;
  rep(i, K-1) f = first2first[f];
  vi ans;
  int x = 0;
  if (f != 0) {
    x = lastX[f] + 1;
  }
  while (true) {
    if (x>=N) break;
    if (jump[x] > 0) {
      x = jump[x];
    } else {
      ans.pb(A[x]);
      ++x;
    }
  }
  rep(i, ans.size()) cout << ans[i] << ((i==ans.size()-1) ? "" : " ");
  cout << "\n";
  return 0;
}


Measured memory_bytes: 4724
/* 
 * Author: aps
 * Time: 20-06-2019 02:16:27
**/
#include<bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll inf = 1e18;
const ll mod = 1e9+7;

inline ll add(ll x, ll y) { x += y; if (x >= mod) x -= mod; return x;}
inline ll sub(ll x, ll y) { x -= y; if (x < 0) x += mod; return x;}
inline ll mul(ll x, ll y) { return ((x % mod) * (y % mod)) % mod;}
inline ll power(ll a, ll b) {
    ll x = 1;
    while (b) {
        if (b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline ll inv(ll a) { return power(a, mod - 2);}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0);
    
    vector<tuple<int,int,int,int>> evs;

    int n,q; cin >> n >> q;
    for(int i=0;i<n;i++){
        int s,t,x; cin >> s >> t >> x;
        evs.emplace_back(s-x,0,x,i);
        evs.emplace_back(t-x,1,x,i);
    }
    for(int i=0;i<q;i++){
        int d; cin >> d;
        evs.emplace_back(d,2,0,i);
    }

    sort(all(evs));

    set<pii> st;
    for(auto ev : evs){
        int t,x,type,id;
        tie(t,type,x,id) = ev;
        if(type == 0) st.insert({x,id});
        else if (type == 1) st.erase({x,id});
        else{
            if(st.empty()) cout << -1 << endl;
            else cout << (*st.begin()).fi << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 21604
# -*- coding: utf-8 -*-

# Tenka1 Programmer Beginner Contest
# Problem B

if __name__ == '__main__':
    n = int(input())
    worst_rank, worst_score = 0, 0

    # See:
    # https://beta.atcoder.jp/contests/tenka1-2017-beginner/submissions/1637273
    # https://beta.atcoder.jp/contests/tenka1-2017-beginner/submissions/1655004
    for i in range(n):
        ai, bi = map(int, input().split())

        if ai > worst_rank:
            worst_rank = ai
            worst_score = bi

    print(worst_rank + worst_score)


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

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

int main()
{
    int n, x, ans = 0;
    cin >> n >> x;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end());
    
    rep(i, n)
    {
        if (a[i] > x) break;
        else if (i >= n - 1 && a[i] < x) break;
        else
        {
            x -= a[i];
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

ans = 1
if 0 in A:
  print("0")
else:
  for i in A:
    ans = ans * i
    if ans > 10 ** 18:
      print("-1")
      break
    else:
      continue
  else:
    print(ans)


Measured memory_bytes: 21664
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int a,b,k,x; cin>>a>>b>>k;
  if(a<k){
    k-=a;
  }else{
    cout<<a-k<<" "<<b<<endl;
    exit(0);
  }
  if(b<k){
    cout<<"0 0"<<endl;
  }else{
    cout<<"0 "<<b-k<<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <math.h>
#include <bitset>
#include <cmath>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <vector>
#include <random>
using namespace std;

/////////////////////////////////////////////////////////////////////////////////////////////
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

//initial : call init_uf();
//unite x and y : unite(ll x, ll y)
//same x and y : uf(x) == uf(y);
//size s[uf(a)];

static const ll MAX_N = 100001;
ll p[MAX_N] = {};//i: node ID, p[i]: root node id 
ll s[MAX_N] = {};//i: node ID, s[i]: size of group which has node i 
ll v[MAX_N] = {};
ll uf(ll i) { return (p[i] == i) ? i : p[i] = uf(p[i]); }
void init_uf() { rep(i, 1, MAX_N) { p[i] = i; s[i] = 1; } }
void unite(ll x, ll y) {
	x = uf(x); y = uf(y);
	if (x == y) return;
	if (p[x] > p[y]) swap(x, y); // merge technique
	s[x] += s[y];
	p[y] = x;
}



int main()
{
	init_uf();
	ll n, m; cin >> n >> m;
	rep(i, 0, m) {
		ll x, y, z; cin >> x >> y >> z;
		unite(x, y);
		v[x] = 1;
		v[y] = 1;
	}
 
	set<int> s;
	int a= 0;
	repe(i, 1, n) {
		if(v[i])s.insert(uf(i));
		if (!v[i]) a++;
	}
	cout << s.size() + a<< endl;
    return 0;
}


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

int main() {
  string N;
  cin >> N;
  if(N=="Sunny") cout<< "Cloudy"<<endl;
  if(N=="Rainy") cout<< "Sunny"<<endl;
  if(N=="Cloudy") cout<< "Rainy"<<endl;

  }


Measured memory_bytes: 256
import sys
n = int(input())
a = list(map(int,input().split()))
ans = 1

if 0 in a:
	print(0)
	sys.exit()

for i in range(n):
	ans = ans * a[i]
	if ans > 1000000000000000000:
		print(-1)
		sys.exit()

print(ans)

Measured memory_bytes: 21632
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,a[55];
int main(){
	in(n);
	for(int i=1;i<=n;i++)in(a[i]);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			swap(a[i],a[j]);
			bool flag=0;
			for(int k=2;k<=n;k++){
				if(a[k]<a[k-1]){
					flag=1;
					break;
				}
			}
			if(flag==0){
				puts("YES");
				return 0;
			}
			swap(a[i],a[j]);
		}
	}
	puts("NO");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1005
using namespace std;
typedef pair<int,int> P;

int m, n, sx[N], sy[N], gx[N], gy[N];

set<P> star;

int main(){

  while(1){
    
    cin>>m;
    if(!m) break;

    for(int i=0;i<m;i++) cin>>sx[i]>>sy[i];
    
    cin>>n;

    star.clear();
    
    for(int i=0;i<n;i++){
      cin>>gx[i]>>gy[i];
      star.insert(P(gx[i],gy[i]));
    }
    
    int ansx, ansy;
    
    for(int i=0;i<n;i++){ // g[0] to taiousurumono

      int X=gx[i]-sx[0], Y=gy[i]-sy[0], flag=0;
      
      for(int j=0;j<m;j++)
	
	if(!star.count(P(sx[j]+X,sy[j]+Y))) flag=1;
	
      if(!flag) ansx=X, ansy=Y;
      
    }

    cout<<ansx<<' '<<ansy<<endl;
    
  }
  
  return 0;
}

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

#define EPS 1e-6
#define MOD 1000000007

#define fi first
#define se second
#define pb push_back
#define ende '\n'

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define mset(x, y) memset(&x, (y), sizeof(x))

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); i++) {
    cout << (char)('A' + (s[i]-'A' + n) % 26);
  }
  cout << ende;


  return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)

#define mod 1e9+7;
#define inf 1e18+7;

typedef long long ll;


int main() {
    int n;cin>>n;
    vector<int>a(n);
    rep(i,n){
        cin>>a[i];
    }

    sort(a.begin(),a.end());

    vector<int>A(100001);
    rep(i,n){
        A[a[i]]++;
    }

    int MAX=0;
    for (int i=1;i<100001;i++) {
        MAX=max(MAX,A[i-1]+A[i]+A[i+1]);
    }

    cout<<MAX<<endl;
}



Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#define fo(i,n) for(int i  = 0 ; i<n;i++)
#define p(x) push_back(x)
#define lld long long int
#define v<lld>  vector <lld>
using namespace std;
vector <lld> t[1000000];
vector <lld> tcount[1000000];
vector <lld> input(1000000,0);

void inp(int k){
	fo(jjj, k){
			lld temp;
			cin >> temp;
			input[jjj] = (temp);
			}
}


int main(){	
		string input;
		lld t,s,n,n1,n2,n3,k;
		cin >> n;
		
		n = n%10;
		
		if(n == 1 || n == 0 ||n == 6 ||n == 8 ){
		cout << "pon";	
		}
		if(n == 3){
		cout << "bon";	
		}
		
		if(n == 2 || n == 4 ||n ==5 ||n == 7 || n==9 ){
		cout << "hon";	
		}
		
		
		
}

Measured memory_bytes: 57284
#include <iostream>
#include <cstdio>
#include <vector>
#include <complex>
#include <cmath>
using namespace std;
using xy_t = complex<double>;

int main(){
  vector<xy_t> V;
  double x_in, y_in;
  while(scanf("%lf,%lf", &x_in, &y_in) != EOF){
    V.push_back(xy_t(x_in, y_in));
  }
  int n = V.size();
  double sum = 0.0;
  for(int i=1;i<n-1;i++){
    xy_t vec[2] = {V[i] - V[0], V[i+1] - V[0]};
    sum += abs((conj(vec[0]) * vec[1]).imag() * 0.5);
  }
  cout << sum << endl;
}


Measured memory_bytes: 3264