akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,-1,sizeof(x))
const int INF = 1000000001;

int main(){
  string a;
  cin >> a;
  sort(all(a));
  if(a=="abc") cout << "Yes" <<endl;
  else cout << "No" <<endl;
}

Measured memory_bytes: 256
main :: IO()
main = do
    [a,b,c,d] <- map read . words <$> getLine
    print $ getsolve (a,b) (c,d)
    
getsolve :: (Int, Int) -> (Int, Int) -> Int
getsolve (a,b) (c,d)
    | start < end		= end - start 
    | otherwise			= 0
    where start = max a c
          end = min b d

Measured memory_bytes: 508
# include<iostream>
using namespace std;
 
int main () {
  int N, A[100];
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  for (int i = 0; i < N; i++) {
    if (A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) {
      cout << "DENIED" << endl;
      return 0;
    }
  }
  cout << "APPROVED" << endl;
  
  return 0;
}

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

int main(){
	int n,cnt=0,num=0;
	int base[4]={0};
	cin>>n;
	string s;
	while(1){
		cin>>s;
		if(s=="HIT"){
			base[3]+=base[2];
			base[2]=base[1];
			base[1]=base[0];
			base[0]=1;
		}
		if(s=="HOMERUN"){
			for(int i=0;i<3;i++){
				base[3]+=base[i];
				base[i]=0;
			}
			base[3]++;
		}
		if(s=="OUT"){
			cnt++;
		}
		if(cnt==3){
			cout<<base[3]<<endl;
			cnt=0;
			num++;
			base[0]=base[1]=base[2]=base[3]=0;
		}
		if(num==n)break;
	}
	return 0;
}

Measured memory_bytes: 1208
N,M = map(int, input().split())
PY=[]
for i in range(M):
    _list=list(map(int, input().split()))
    _list.append(i)
    PY.append(_list)
    #PY.extend([list(map(int, input().split()))])
    ##PY = [list(map(int, input().split())) for _ in range(M)]
PY.sort(key=lambda x: (x[0], x[1]))
#print(PY)
cnt=0
for i in range(M):
    if i==0:
        cnt=1
        forward = (6-len(str(PY[i][0])))*'0'+str(PY[i][0])
        backward = (6-len(str(cnt)))*'0'+str(cnt)
        PY[i].append(forward+backward)
        #print(forward+backward)
    else:
        if PY[i][0]==PY[i-1][0]:
            cnt+=1
            forward = (6-len(str(PY[i][0])))*'0'+str(PY[i][0])
            backward = (6-len(str(cnt)))*'0'+str(cnt)
            PY[i].append(forward+backward)
            #print(forward+backward)
        else:
            cnt=1
            forward = (6-len(str(PY[i][0])))*'0'+str(PY[i][0])
            backward = (6-len(str(cnt)))*'0'+str(cnt)
            PY[i].append(forward+backward)
            #print(forward+backward)
#print(PY)
PY.sort(key=lambda x: x[2])
for i in range(M):
    print(PY[i][3])

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 1e5+1;
int n, m, deg[N], pa[N];
vector <int> a[N];

int main()
{
	fastio;
	cin >> n >> m;
	for (int i = 1; i <= n + m; i++){
		int u, v; cin >> u >> v;
		a[u].push_back(v);
		deg[v]++;		
	}
	
	queue <int> Q;
	
	for (int i = 1; i <= n; i++){
		if (deg[i] == 0) Q.push(i);
	}

	while (Q.size()){
		int u = Q.front();
		Q.pop();
		for (int v : a[u]){
			deg[v]--;
			if (deg[v] == 0){
				pa[v] = u;
				Q.push(v);
			}
		}
	}

	for (int i = 1; i <= n; i++) cout << pa[i] << '\n';

	return 0;
}

Measured memory_bytes: 7040
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main() {
  int N;
  cin>>N;
  
  // string型のN要素の配列 
  vector<string> blue(N);
  for(int i=0;i<N;++i){
    cin>>blue[i];
  }
  
  int M;
  cin>>M;
  
  vector<string> red(M);
  for(int i=0;i<M;++i){
    cin>>red[i];
  }
  
  int max=-100;
  string word;
  
  for(int i=0;i<N;++i){
    int count=0;
    word=blue[i];
    for(int i=0;i<N;i++){
      if(word==blue[i])
        ++count;
    }
    for(int i=0;i<M;i++){
      if(word==red[i])
        --count;
    }
    
    if(max<count)
      max=count;
  }
  
  if(max<0)
    cout<<0<<endl;
  else
    cout<<max<<endl;
}


Measured memory_bytes: 256
def func():

    n = int(input())
    data = []
    for i in range(n):
        data.append(list(map(int,input().split())))

    for cx in range(101):
        for cy in range(101):
            for line in data:
                if line[2] != 0:
                    x = line[0]
                    y = line[1]
                    h = line[2]
                    H_max = h + abs(cx - x) + abs(cy - y)
                    break
            flag = True
            for i in range(n):
                    x = data[i][0]
                    y = data[i][1]
                    h = data[i][2]
                    if h != 0:
                        if not H_max == h + abs(cx-x) + abs(cy-y):
                            flag = False
                            break
                    else:
                        if not H_max <=  abs(cx-x) + abs(cy-y):
                            flag = False
                            break
            if flag:
                print(cx,cy,H_max)
                return 0

func()



Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define M ((int)1e9+7)
#define N 1007
using namespace std;

long long h, w, dp[N][N];
string grid[N];

int main() {
	cin>>h>>w;
	for (int i=0; i<h; i++) cin>>grid[i];
	dp[1][1]=1;
	for (int i=1; i<=h; i++) {
		for (int j=1; j<=w; j++) {
			if (i==1 && j==1) continue;
			if (grid[i-1][j-1]=='#') continue;
			dp[i][j]=(dp[i][j-1]+dp[i-1][j])%M;
		}
	}
	cout<<dp[h][w]<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}
int gcd(int a, int b)
{
	if (a % b == 0) { return b; }
	else { return gcd(b, a % b); }
}
int ketawa(int a)
{
	if (a < 10)return a;
	else return a % 10 + ketawa(a / 10);
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0,ans=0;
string s, t;


int main()
{
	cin >> a >> b;
	cout << a * (a - 1) / 2 + b * (b - 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <cctype>
#include <algorithm>
#include <cstdlib>
using namespace std;
char f(int a, int b, int c) { return (a*c + b) % 26 + 'a'; }
int main()
{
	string p; getline(cin, p);
	int N = atoi(p.c_str());
	while (N--) {
		string s; getline(cin, s);
		for (int a=0; a<26; ++a) {
			if (__gcd(a, 26) != 1) continue;
			for (int b=0; b<26; ++b) {
				string t = s;
				bool ok = true;
				for (int i=0; i<s.size(); ++i) {
					if (isalpha(s[i])) {
						t[i] = f(a, b, s[i]-'a');
						if (!isalpha(t[i])) { ok = false; break; }
					}
					else t[i] = s[i];
				}
				if (ok && t.find("that") != string::npos || t.find("this") != string::npos) {
					cout << t << endl;
					goto BREAK;
				}
			}
		}
BREAK:;
	}
	return 0;
}

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

	ll ans = 1e11;
	ans = min(ans, w*(h%3==0 ? 0 : 1));
	ans = min(ans, h*(w%3==0 ? 0 : 1));

	FOR(hh,1,h){
		ll s1 = hh*w;
		ll s2 = (h-hh)*((w+1)/2);
		ll s3 = (h-hh)*(w/2);
		ll smax = max(s1, max(s2, s3));
		ll smin = min(s1, min(s2, s3));
		//cout << hh << " " << s2 << " " << s3 << '\n';
		ans = min(ans, smax-smin);
	}
	
	FOR(ww,1,w){
		ll s1 = h*ww;
		ll s2 = (w-ww)*((h+1)/2);
		ll s3 = (w-ww)*(h/2);
		ll smax = max(s1, max(s2, s3));
		ll smin = min(s1, min(s2, s3));
		ans = min(ans, smax-smin);
	}
	cout << ans << '\n';
	return 0;
}



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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll N, K;
  cin >> N >> K;
  ll a[N];
  for (int i = 0; i < N; i++) cin >> a[i];

  ll a1 = 0;
  for (int i = 0; i < N - 1; i++) {
    for (int j = i + 1; j < N; j++) {
      if (a[i] > a[j]) a1++;
    }
  }

  ll a2 = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (a[i] < a[j]) a2++;
    }
  }

  ll ans = a1 * K % MOD;
  ans += a2 * ((K * (K - 1) / 2) % MOD) % MOD;
  
  cout << ans % MOD << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <climits>
#include <vector>
#include <numeric>
#include <complex>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
using namespace std;

#define __int64 long long
#define long __int64
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
const int Vec = 4;
const int Vecy[Vec] = {0,-1,0,1};
const int Vecx[Vec] = {1,0,-1,0};
const int Modd = 1000000007;

long dp[100005][2] = {0};

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

    dp[0][0] = 1;
    dp[0][1] = 0;
    for(int i=1; i<=l.length(); i++){
        { // i桁目を0にするよ。
            if(l[i-1] == '0'){
                dp[i][0] = dp[i-1][0];
                dp[i][1] = dp[i-1][1];
            }else{
                dp[i][0] = 0;
                dp[i][1] = dp[i-1][0] + dp[i-1][1];
            }
            dp[i][0] %= Modd;
            dp[i][1] %= Modd;
        }
        { // i桁目を1にするよ。
            if(l[i-1] == '0'){
                dp[i][0] += 0;
                dp[i][1] += dp[i-1][1] * 2;
            }else{
                dp[i][0] += dp[i-1][0] * 2;
                dp[i][1] += dp[i-1][1] * 2;
            }
            
            dp[i][0] %= Modd;
            dp[i][1] %= Modd;
        }
    }

    cout << (dp[l.length()][0] + dp[l.length()][1]) % Modd << endl;

    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 1005, mod = 1e9+7;

ll n, a, b, c, d, dt[N][N];
ll fac[N] = {1}, inv[N] = {1}, cmb[N][N] = {1};

ll calc (ll X, ll Y) {
	if(!Y) return 1;
	ll R = calc(X, Y/2);
	R = R * R % mod;
	if(Y&1) R = R * X % mod;
	return R;
}

int main()
{
	scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
	for(ll i=1;i<=n;i++) {
		fac[i] = fac[i-1] * i % mod;
		inv[i] = calc(fac[i], mod-2);
		cmb[i][0] = 1;
		for(ll j=1;j<=i;j++) {
			cmb[i][j] = (cmb[i-1][j-1] + cmb[i-1][j]) % mod;
		}
	}
	dt[a-1][n] = 1;
	for(ll i=a;i<=b;i++) {
		for(ll j=0;j<=n;j++) {
			ll T = 1;
			dt[i][j] = dt[i-1][j];
			for(ll k=1;j+i*k<=n && k<=d;k++) {
				T = T * cmb[j+i*k][i] % mod;
				if(k < c) continue;
				dt[i][j] += dt[i-1][j+i*k] * T % mod * inv[k];
				dt[i][j] %= mod;
			}
		}
	}
	printf("%lld\n",dt[b][0]);
}


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

void Main()
{
    long n, d , a;
    cin >> n >> d >> a;
    vector<pair<long, long>> xh;
    for (int i = 0; i < n; i++)
    {
        long x, h;
        cin >> x >> h;
        xh.push_back(make_pair(x, h));
    }
    sort(xh.begin(), xh.end());
    xh.push_back(make_pair(10000000000, 0));
    long bomb = 0;
    vector<long> sum_damage(n+1);
    vector<long> bomb_right;
    for (int i = 0; i < n; i++)
    {
        long total_damage = 0;
        if(i > 0) {
            auto it = lower_bound(bomb_right.begin(), bomb_right.end(), xh[i].first);
            if(it != bomb_right.end()){
                total_damage = sum_damage[i] - sum_damage[it-bomb_right.begin()];
            }
        }
        long nb = (max(0L, xh[i].second-total_damage)+a-1)/a; 
        bomb += nb;
        long b = xh[i].first+2*d;
        bomb_right.push_back(b);
        long damage = nb * a;
        if(i > 0) sum_damage[i+1] = sum_damage[i] + damage;
        else sum_damage[i+1] = damage;
    }

    cout << bomb << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 11620
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ll> pdl;
typedef pair<ld, ld> pdd;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	ll X;
	cin >> X;
	vector<bool> DP(X + 1, false);
	DP[0] = true;
	for (ll x = 1; x <= X; x++) {
		if (x >= 100)DP[x] = DP[x] | DP[x - 100];
		if (x >= 101)DP[x] = DP[x] | DP[x - 101];
		if (x >= 102)DP[x] = DP[x] | DP[x - 102];
		if (x >= 103)DP[x] = DP[x] | DP[x - 103];
		if (x >= 104)DP[x] = DP[x] | DP[x - 104];
		if (x >= 105)DP[x] = DP[x] | DP[x - 105];
	}
	if (DP[X])cout << 1 << "\n";
	else cout << 0 << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod = (int)1e9+7;
int add(int a, int b) {
    return (a += b) >= mod ? a -= mod : a;
}
int mul(int a, int b) {
    return int(1LL * a * b % mod);
}
int pow(int a, int n) {
    if (n == 0) return 1;
    if (a <= 1) return a;
    int r(1);
    while (n > 0) {
        if (n & 1) r = mul(r,a);
        a = mul(a,a);
        n >>= 1;
    }
    return r;
}
const int NMAX = 100100;
int fact[NMAX], ifact[NMAX];
int C(int n, int k) {
    return mul(fact[n], mul(ifact[k], ifact[n-k]));
}
int main() {
    fact[0] = 1;
    for (int i = 1; i < NMAX; i++) {
        fact[i] = mul(fact[i-1], i);
    }
    for (int i = 0; i < NMAX; i++) {
        ifact[i] = pow(fact[i], mod-2);
    }
    int n, m;
    while (std::cin >> n >> m) {
        int answ(1);
        auto update = [&](int k) {
            answ = mul(answ, C(n+k-1,n-1));
        };
        for (int p = 2; p * p <= m; p++) {
            if (m % p == 0) {
                int cnt = 1; m /= p;
                while (m % p == 0) m /= p, cnt++;
                update(cnt);
            }
        }
        if (m > 1) update(1);
        std::cout << answ << std::endl;
    }
    return 0;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using P = pair<llong, llong>;

#define BE(x) x.begin(), x.end()

const llong inf = llong(1e18)+7;
const llong mod = 1e9+7;

int main(){
	int N;
	string s;

	cin >> N >> s;
	int r = 0, b = 0;
	for(auto x: s)
		if(x == 'R')
			r++;
		else
			b++;

	if(r > b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
int main(){

	int n,m;
	cin>>n>>m;
	char maze[n][m];
	long long dp[n][m];
	for(int i=0;i<n;i++){
		for (int j=0;j<m;j++)
		{
			cin>>maze[i][j];
		}
	}
	for(int i=0;i<n;i++){
		for (int j=0;j<m;j++)
		{
			dp[i][j]=0;
		}
	}
	dp[0][0]=1;
	int i=0;
	int j=1;
	while(maze[i][j]=='.'){
		dp[i][j]=1;
		j++;
	}

	i=1;
	j=0;
	while(maze[i][j]=='.'){
		dp[i][j]=1;
		i++;
	}

	for(int i=1;i<n;i++){
		for(int j=1;j<m;j++){

			if(maze[i][j]=='#'){
				continue;
			}
			if(maze[i][j]=='.'){
				if(maze[i-1][j]!='#' && maze[i][j-1]!='#'){
					dp[i][j]=(dp[i][j-1]+dp[i-1][j])%mod;
				}
				else
					if(maze[i-1][j]!='#'){
					dp[i][j]=(dp[i][j]+dp[i-1][j])%mod;
				}
				else
					if(maze[i][j-1]!='#'){
					dp[i][j]=(dp[i][j-1]+dp[i][j])%mod;
				}
				else
				{
					dp[i][j]=0;
				}
			}

		}
	}

	// for(int i=0;i<n;i++){
	// 	for (int j=0;j<m;j++)
	// 	{
	// 		cout<<dp[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }
	cout<<dp[n-1][m-1];


	return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;
public class Main{
    int n;
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		
		for(int i=0; i<n; i++){
			int x = sc.nextInt();
		    int y = sc.nextInt();
			int b = sc.nextInt();
			int p = sc.nextInt();
        
		int kei = x*b+y*p;
		
		if(b >= 5 && p >= 2){
			kei = (x*b+y*p) * 4/5;
		}else{
			 if(b < 5){
			 	b = 5;
			 }
			 if(p < 2){
			 	p = 2;
			 }
			 
			int wari = (x*b+y*p) * 4/5;
			
			if(kei > wari){
				kei = wari;
			}
		}
	    System.out.println(kei);
		}
    }
			
	public static void main(String[] args){
        Main obj = new Main();
        obj.solve();
    }
    
}

Measured memory_bytes: 23276
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	ll Tnow, Anow;
	Tnow = Anow = 1;
	rep(i, 1, n)
	{
		ll t, a; cin >> t >> a;
		ll Tcan1, Acan1, Tcan2, Acan2;
		Tcan1 = ((Tnow + t - 1) / t)*t;
		Acan1 = ((Tnow + t - 1) / t)*a;
		Tcan2 = ((Anow + a - 1) / a)*t;
		Acan2 = ((Anow + a - 1) / a)*a;
		if (Tcan1 < Tnow || Acan1 < Anow)Tnow = Tcan2, Anow = Acan2;
		else if (Tcan2 < Tnow || Acan2 < Anow)Tnow = Tcan1, Anow = Acan1;
		else Tnow = min(Tcan1, Tcan2), Anow = min(Acan1, Acan2);
	}
	cout << Tnow + Anow << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <cassert>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
#define pi 3.141592653589793
using namespace std;
int sdkys(int a,int b){
    if(b==0) return a;
    return sdkys(b,a%b);
}
int sskbs(int a,int b){
    return a*b/sdkys(a,b);
}
int sosu(int a){
    if(a==2){
        return 1;
    }
    for(int i=2;i<sqrt(a)+1;i++){
        if(a%i==0){
            return 0;
        }
    }
    return 1;
}
vector<int> aa,ab;
int n,m,cnt=0,ans=0;
pair<int,char> pp[220000];
string s,sa[220000];
char ch;
queue<int> que;
signed main(){
    cin>>n>>m;
    rep(i,m){
        cin>>pp[i].first>>pp[i].second;
    }
    rep(i,1000){
        s=to_string(i);
        rep(j,m){
            if(s[pp[j].first-1]!=pp[j].second){
                goto no;
            }
        }
        if(i>=pow(10,n-1)){
            cout<<i<<endl;
            return 0;
        }elif(i==0&&n==1){
            cout<<0<<endl;
            return 0;
        }
        no:;
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 10788
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n = int(input())
    a = list(map(int, input().split()))
    b = []
    for i in range(n):
        b.append(a[i]-i-1)
    b.sort()
    if n%2==0:
        c = b[n//2]
        d = b[n//2-1]
        res1 = 0
        res2 = 0
        for i in b:
            res1 += abs(i-c)
            res2 += abs(i-d)
        print(min(res1, res2))
        exit()
    else:
        c = b[n//2]
        res = 0
        for i in b:
            res += abs(i-c)
        print(res)
        exit()
if __name__ == '__main__':
    main()

Measured memory_bytes: 26756
#include <iostream>
#include <set>
#include <vector>
#include <map>

#define N 1000000

using namespace std;

typedef unsigned long long int BigInt;

BigInt phi(int n) {
    int m = n;
    BigInt retval = 1;
    for (int p=2; p*p <= m; p++) {
        int count = 0;
        while (m%p == 0) {
            count++;
            m /= p;
        }
        if (count > 0) {
            retval *= p-1;
            for (int i=0; i<count-1; i++) {
                retval *= p;
            }
        }
    }
    if (m > 1) {
        retval *= m-1;
    }
    return retval;
}

int main() {
    int t;
    int n[10000];
    BigInt f[N+1];
    cin >> t;
    for (int i=0; i<t; i++) {
        cin >> n[i];
    }
    f[1] = 2;
    for (int i=2; i<=N; i++) {
        if (phi(i) > 1000000) {
            cout << i << endl;
        }
        f[i] = f[i-1]+phi(i);
    }
    for (int i=0; i<t; i++) {
        cout << f[n[i]] << endl;
    }
    return 0;
}

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

using Edge = pair<int , int>; //次の頂点、頂点までの距離
using Graph = vector<vector<Edge>>;

//入力
int N; //頂点の個数
Graph G;

//答え
vector<int> ans;

//v：現在の頂点　, p：vの親の頂点 , c：距離
void dfs(int v, int p, int c){
    ans[v] = c;
    for(auto e : G[v]){
        if(e.first == p) continue;
        if(e.second & 1) dfs(e.first,v,1-c);
        else dfs(e.first,v,c);
    }
}

int main(){
    cin >> N;
    G.assign(N,vector<Edge>());

    for(int i=0; i<N-1; i++){
        int u,v,w; cin >> u >> v >> w;
        --u,--v;
        G[u].push_back(Edge(v,w));
        G[v].push_back(Edge(u,w));
    }

    ans.assign(N,0);
    dfs(0,-1,1);
    for(auto v : ans) cout << v << endl;

}

Measured memory_bytes: 8960
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

    int x; cin>>x;

    bool valid = false;
    for(int i=1; i<=1000000; i++){
        if(100 * i <= x && x <= 105 * i){
            valid = true;
        }
    }

    cout << valid << endl;

    return 0;
}

Measured memory_bytes: 256
import math
n = int(input())

#Prime factoring
pf = []
for i in range(2,math.ceil(n**0.5)+1):
    temp = 0
    while n%i==0:
        n /= i
        temp += 1
    if temp:
        pf.append(temp)
    if n==1:
        break
if n!=1:
    pf.append(1)

ans =  0
for i in range(len(pf)):
    j = 1
    while pf[i]-j>=0:
        ans += 1
        pf[i] -= j
        j += 1
print(ans)

Measured memory_bytes: 9460
"use strict";
const Main = (input) =>{
	let xs = input.trim().split(' ').map(v=>parseInt(v,10));
    if(xs[0] < 1200){
		console.log('ABC');
    }else{
    	console.log('ARC');
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7372
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	string a, b;
	cin >> a >> b;
	int k = stoi(a+b);
	bool s = false;
	for(int i = 1; i*i <= k; i++){
		if(k % i == 0 && k / i == i)s = true;
	}
	if (s) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	//cout << ans << endl;
}

Measured memory_bytes: 256
n,m = map(int, input().split())
a = set([int(input()) for _ in range(m)])

mod = 1000000007
nums = [0]*(n+1)
nums[0] = 1
if 1 not in a: nums[1] = 1
for i in range(2,n+1):
  if i in a: continue
  nums[i] = nums[i-1] + nums[i-2]

print(nums[n]%mod)

Measured memory_bytes: 460020
#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
typedef long long int ll;
typedef vector<ll> vl;
typedef map<ll,ll> ii;
typedef vector<vl> vvl;

void sieve(ll x,vl &v){
    ll i=2;
    while(i*i<=x){
        if(v[i]){
            for(ll j=i+i;j<=x;j+=i){
                v[j]=0;
            }
        }
        i++;    
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    
    ll x,y;cin>>x>>y;
    multiset<ll> v;
    while(x--){
        ll k;cin>>k;
        v.insert(k);
    }
    while(y--){
        auto it=v.end();
        v.erase(--it);
        v.insert(*it/2);
    }
    ll s=0;
    for(ll i:v) s+=i;
    cout<<s;
    
    return 0;
}

Measured memory_bytes: 4992
N, P = map(int, input().split())
A = list(map(int, input().split()))

d = [1, 0]

for a in A:
    v = d[:]
    if a % 2 == 0:
        v[0] = d[0] + d[0]
        v[1] = d[1] + d[1]
    else:
        v[0] = d[0] + d[1]
        v[1] = d[0] + d[1]
    d = v[:]
    
print(d[P])


Measured memory_bytes: 3060
N = int(input())
count = 0
for i in range(1, N + 1, 2):
    c = 0
    j = 1
    while j*j <= i:
        if j*j == i:
            c += 1
        elif i % j == 0:
            c += 2
        j += 1
    if c == 8:
        count += 1
print(count)

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

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

	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int a, b;
	cin >> a >> b;
	cout << a*b << endl;
	return 0;
}

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

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

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

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

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

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

	int i = 0, ans = 0;
	for (i = 1; i <= X; i++) {
		int t = i;
		int k = X - t;
		if (Y == (t * 2) + (k * 4)) {
			ans = 1;
			break;
		}
		if (Y == (k * 2) + (t * 4)) {
			ans = 1;
			break;
		}
	}

	yesno(ans);
	//okng(ans);
	return 0;
}


Measured memory_bytes: 1664
#include <cstdio>
#include <cmath>
#include <limits>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric> // 最大公約数が使える
#define rep(i, s, g) for (i = s; i < g; i++)
using namespace std;
using ll = long long;
const int inf = 1000000000; //10^9

int main()
{
    ll K;
    cin >> K;
    ll A,B;
    cin >> A >> B;
    for (int i = A; i <= B; i++)
    {
        if (i%K==0)
        {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
}

Measured memory_bytes: 3584
N = int(input())
a = [int(i) for i in input().split() ]
for j in range(len(a)):
  if j == len(a) -1:
    print(a[j],end = "")
  else:
    print(a[j],end = " ")    
print()
for i in range(1,len(a)):
  tmp = a[i]
  j = i- 1
  while j >= 0 and a[j] > tmp:
    a[j+1] = a[j]
    j -= 1
  a[j+1] = tmp
  for j in range(len(a)):
      if  j == len(a)-1 :
        print(a[j],end = "")
      else:
        print(a[j],end = " ")
  print()


Measured memory_bytes: 5976
def sell(m,s,a):
  return m+s*a,0

def buy(m,a):
  return m%a,m//a

def solve():
  m = 1000
  s = 0
  N = int(input())
  A = list(map(int, input().split()))
  for i in range(N-1):
    m,s = sell(m,s,A[i])
    if A[i]<A[i+1]:
      m,s = buy(m,A[i])
  m,s = sell(m,s,A[-1])
  return m
print(solve())

Measured memory_bytes: 9196
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define ll long long
int line(const void*a,const void*b)
{
    return *(ll*)a-*(ll*)b;
}
int main()
{
    ll s1[100100];
    ll n,c,k,a,sum,star,fina,judge,pa;
    while(scanf("%lld%lld%lld",&n,&c,&k)!=EOF)
    {
        sum=0;judge=0;pa=0;
        for(a=1;a<=n;a++)
        {
            scanf("%lld",&s1[a]);
        }
        qsort(s1+1,n,sizeof(s1[1]),line);
        for(a=1;a<=n;a++)
        {
            if(judge==0)
            {
                star=s1[a];
                judge=1;
                pa=1;
            }
            else
            {
                if(s1[a]-star<=k)
                {
                    pa++;
                }
                else
                {
                    sum++;
                    star=s1[a];
                    pa=1;
                    judge=1;
                }
            }
            if(pa==c)
            {
                pa=0;
                sum++;
                judge=0;
            }
        }
        if(pa>0)
            sum++;
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 1788
N = int(input())
H = list(map(int, input().split()))
if N == 1:
    print(0)
    exit()
reverse_H = H[::-1]
ans = 0
result = []
for i in range(N-1):
    if reverse_H[i] <= reverse_H[i+1]:
        ans += 1
    else:
        result.append(ans)
        ans = 0
if ans > 0:
    result.append(ans)
if result:
    print(max(result))
else:
    print(0)

Measured memory_bytes: 14252
import java.util.*
fun main () {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val maze = MutableList(h) {
        readLine()!!.toString().toCharArray()
    }
    val dx = listOf(1, 0, -1, 0)
    val dy = listOf(0, 1, 0, -1)
    var res_max = 0
    fun bfs(sx: Int, sy: Int) {
        if (maze[sy][sx] == '#') return
        var d: MutableList<MutableList<Int>> = mutableListOf()
        var queue = ArrayDeque<Pair<Int, Int>>()
        for (i in 0 until h) {
            d.add(mutableListOf())
            for (j in 0 until w) {
                d[i].add(-1)
            }
        }
        queue.add(Pair(sy, sx))
        d[sy][sx] = 0
        //println("$sx, $sy, $gx, $gy")
        while (queue.size > 0) {
            var p = queue.removeLast()
            //println(p)
            //if(p.first == gy && p.second == gx) break
            for (i in 0 until 4) {
                val nx = p.second + dx[i]
                val ny = p.first + dy[i]
                if (nx in 0 until w &&  ny in 0 until h && maze[ny][nx] == '.' && d[ny][nx] == -1) {
                    queue.push(Pair(ny, nx))
                    d[ny][nx] = d[p.first][p.second] + 1
                    if(res_max < d[ny][nx]) res_max = d[ny][nx]
                    //println(d[ny][nx].toString()+ " " + ny.toString() + "," + nx.toString())
                }
            }
        }
    }
    for(i in 0 until w){
        for(j in 0 until h){
            val res = bfs(i, j)
        }
    }
    println(res_max)
}



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

using namespace std;

int n,i,t,sum,k;

int main()
{
    string s;
    for(i=0; i<4; i++){
        cin>>s[i];
        if(s[i]=='+'){
            sum++;
        }
        else{
            sum--;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func cluc(x int) int  {
	var num int
	for 0<x{
		num+=x%10
		x/=10
	}
	return num
}

func main() {


	var n,a,b int
	fmt.Scan(&n,&a,&b)

	var ans int
	for i:=1;i<=n;i++{
		num:=cluc(i)

		if num>=a&&num<=b{
			ans+=i
		}
	}

	fmt.Println(ans)
}

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

class DisjointSet{
    public:
        vector<int> rank,p;

        DisjointSet(){}        
        DisjointSet(int size){
            rank.resize(size,0);
            p.resize(size,0);
            for(int i=0;i<size;i++) makeSet(i);
        }

        void makeSet(int x){
            p[x]=x;
            rank[x]=0;
        }

        bool same(int x,int y){
            return findSet(x)==findSet(y);
        }

        void unite(int x,int y){
            link(findSet(x),findSet(y));
        }

        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y]=x;
            }
            else{
                p[x]=y;
                if(rank[x]==rank[y]) rank[y]++;
            }
        }

        int findSet(int x){
            if(x!=p[x]){
                p[x]=findSet(p[x]);
            }
            return p[x];
        }
};

int main(){
    int n,q,c,x,y;
    cin>>n>>q;
    DisjointSet ds(n);
    for(int i=0;i<q;i++){
        cin>>c>>x>>y;
        if(c){
            cout<<ds.same(x,y)<<endl;
        }
        else{
            ds.unite(x,y);
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int k;
    cin >> k;
    cout << (k / 2) * (k - k / 2) << endl;
    // end

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

int a, b, c;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> a >> b >> c;
  if (a + b + c >= 22)
    cout << "bust" << endl;
  else
    cout << "win" << endl;

  return 0;
}


Measured memory_bytes: 256
l1 = list(map(int, input().split()))
l2 = list(map(int, input().split()))
l3 = list(map(int, input().split()))
n=int(input())
b = [int(input()) for i in range(n)]
f=False
for i in range(3):
    for j in range(n):
        if l1[i]==b[j]:
            l1[i]=0
        elif l2[i]==b[j]:
            l2[i]=0
        elif l3[i]==b[j]:
            l3[i]=0
for i in range(3):
    if l1[i]==l2[i] and l2[i]==l3[i] and l1[i]==l3[i]:
        f=True
if l1[0]==l1[1] and l1[1]==l1[2] and l1[0]==l1[2]:
    f=True
elif l2[0]==l2[1] and l2[1]==l2[2] and l2[0]==l2[2]:
    f=True
elif l3[0]==l3[1] and l3[1]==l3[2] and l3[0]==l3[2]:
    f=True
elif l1[0]==0 and l2[1]==0 and l3[2]==0:
    f=True
elif l3[0]==0 and l1[2]==0 and l2[1]==0:
    f=True
    
if f==True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main (final String[] args)
    {
        try
        {
            final int[] m = new int[50];
            final int[] f = new int[50];
            final int[] r = new int[50];
            final char[] g = new char[50];

            int i;

            final Scanner sc = new Scanner(System.in);

            for (i = 0; true; i++)
            {
                m[i] = sc.nextInt();
                f[i] = sc.nextInt();
                r[i] = sc.nextInt();

                if (m[i] + f[i] + r[i] == -3) break;
            }
            sc.close();

            final int I = i;

            for (i = 0; i < I; i++)
            {
                if (m[i] == -1 || f[i] == -1) g[i] = 'F';
                else 
                {
                    if (m[i] + f[i] >= 80) g[i] = 'A';
                    else
                    {
                        if (m[i] + f[i] >= 65) g[i] = 'B';
                        else
                        {
                            if (m[i] + f[i] >= 50) g[i] = 'C';
                            else
                            {
                                if (m[i] + f[i] >= 30)
                                {
                                    if (r[i] >= 50) g[i] = 'C';
                                    else g[i] = 'D';
                                } else {
                                    g[i] = 'F';
                                }
                            }
                        }
                    }
                }
            }

            for (i = 0; i < I; i++)
            {
                System.out.println(g[i]);
            }
        }
        catch (final NumberFormatException e)
        {
            System.out.println(e);
        }
    }
}


Measured memory_bytes: 26212
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#include <string>
#include <vector>
#include <algorithm>
#define ll long long int
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define vali 1000000000000000000
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,c1=0,c2=0,c3=0,c4=0;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="AC")
        c1++;
        else if(s=="WA")
        c2++;
        else if(s=="TLE")
        c3++;
        else
        c4++;
    }
    cout<<"AC x "<<c1<<endl;
    cout<<"WA x "<<c2<<endl;
    cout<<"TLE x "<<c3<<endl;
    cout<<"RE x "<<c4<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <nmmintrin.h>
#include <chrono>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#ifdef _MSC_VER
#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

struct UnionFind{
	vector<int> data;
	UnionFind (int n) : data(n, -1){}

	void Unite(int a, int b){
		a = root(a), b = root(b);
		if (a == b)return;
		if (data[a] > data[b])
			swap(a,b);
		
		data[b] += data[a];
		data[a] = b;
	}

	bool Find(int a, int b){
		return root(a) == root(b);
	}

	int root(int a){
		return data[a] < 0 ? a : data[a] = root(data[a]);
	}

	int size(int a){
		return -data[root(a)];
	}
};

signed main() {
	ll n, m;
	cin >> n >> m;

	ll ans = min(n, m / 2);
	
	n -= ans;
	m -= ans * 2;

	ans += m / 4;

	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
int N, Q, sum[100010];
string S;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> N >> Q >> S;
	for (int i = 1; i < S.length(); i++)
	{
		if (S[i - 1] == 'A' && S[i] == 'C')
		{
			sum[i + 1] = sum[i] + 1;
		}
		else
		{
			sum[i + 1] = sum[i];
		}
	}
	for (int i = 0; i < Q; i++)
	{
		int l, r;
		cin >> l >> r;
		if (l == 1)
		{
			cout << sum[r] << endl;
		}
		else if (S[l - 2] == 'A' && S[l - 1] == 'C')
		{
			cout << sum[r] - sum[l - 1] - 1 << endl;
		}
		else
		{
			cout << sum[r] - sum[l - 1] << endl;
		}
	}
	int www;
	cin >> www;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner scanner = new Scanner(System.in);
		String c = scanner.next();
		if (c.equals("a") || c.equals("e") || c.equals("i") || c.equals("u") || c.equals("o")) {
			System.out.println("vowel");
		}else {
			System.out.println("consonant");
		}
	}
} 

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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; }

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n; cin>>n;
  vpll p(n);
  rep(i,n){
    ll a,b; cin>>a>>b;
    p[i]={a,b};
  }
  vsort(p);
  
  double ans=0;
  do{
    double tmp=0;
    rep(i,n-1){
      double x=(p[i].first-p[i+1].first), y=(p[i].second-p[i+1].second);
      tmp+=sqrt(x*x+y*y);
    }
    ans+=tmp;
  }while(next_permutation(all(p)));
  
  ll d=1;
  rep(i,n) d*=(i+1);
  ans/=d;
  
  cout<<std::setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 3796
/*

This Submission is to determine how many 120/240 min const. delivery point there are.

//info
120 req. steps <= 5
*/
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 1e18
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 1000000007
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)

unsigned long xor128() {
	static unsigned long x = time(NULL), y = 362436069, z = 521288629, w = 88675123;
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
vector<int> vertexs[300000];
long long pre[300000];
long long ans[300000];
long long go(long long now, long long back) {
	if (back != -1) {
		ans[now] = ans[back] + pre[now];
	}
	else {
		ans[now] = pre[now];
	}
	REP(q, vertexs[now].size()) {
		if (vertexs[now][q] != back) {
			go(vertexs[now][q], now);
		}
	}
	return 0;
}
int main() {
	int n;
	cin >> n;
	int query;
	cin >> query;
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		vertexs[a].push_back(b);
		vertexs[b].push_back(a);
	}
	REP(i, query) {
		int a, b;
		cin >> a >> b;
		pre[a] += b;
	}
	go(1,-1);
	REP(i, n) {
		cout << ans[i + 1] << " ";
	}
	cout << endl;
}


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

const long long mod =1e9+7 ;
const int N = 1e6+5;


#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define fr(i,l,m) for(int i=l;i<m;i++)
# define vii vector<int>
#define vpr vector<pair<int,int> >
#define dbg(x) cout << #x << " is " << x << endl;
#define spk(x) cout<<x<<endl;
#define inf INT_MAX
/*
stoi - sting to int;
stol - string to long;
stoll - string to ll;
*/

////
////
////
int dp[N],dif[N];
vii v;
int n,k;
int ad(int& a,int b)
{
    a+=b;
    if(a>=mod)a-=mod;
}
int sb(int& a,int b )
{
    a-=b;
    if(a<0)a+=mod;
}
void solve()
{
    dp[0]=1;
    for(int i=0;i<n;i++)
    {
        memset(dif,0,sizeof(dif));
        for(int u=k;u>=0;u--)
            {
                int l=u+1;
                int r=u+min(v[i],k-u);
                ad(dif[l],dp[u]);
                sb(dif[r+1],dp[u]);
            }
            int p_sum=0;
            fr(i,0,k+1)
            {
                ad(p_sum,dif[i]);
                ad(dp[i],p_sum);
            }
    }
}
////
///
int main()
{
ios_base::sync_with_stdio(false);cin.tie(NULL);


cin>>n>>k;
fr(i,0,n)
{int x;
    cin>>x;
    v.pb(x);
}
solve();
cout<<dp[k]<<endl;
    return 0;
}


Measured memory_bytes: 6400
import math

def cceil(x,y):
	res = x //y
	if x % y != 0:res += 1
	return res

def gcd(x, y):
	if(x == 0):return y
	return gcd(y % x, x)
 
def main():
    votes = int(input())
    ratio = [[ int(i) for i in input().split() ] for j in range(votes)]
 
    votesTemp = [0, 0]
    for i in range(votes):
        if i == 0:
            votesTemp = ratio[i]
            continue
        if(gcd(ratio[i][0], ratio[i][1]) != 1):
        	x = 1 / 0
        ceil = [ cceil(votesTemp[j], ratio[i][j]) for j in range(2)]
 
        votesTemp = [ max(ceil) * ratio[i][j] for j in range(2) ]
        
        #print("turn: " + str(i))
        #print("votes: " + str(ratio[i][0]) + ":" + str(ratio[i][1]) )
        #print("Temp: " +str(votesTemp[0])+":"+str(votesTemp[1]))
        
    print(sum(votesTemp))
 
if __name__ == '__main__':
  main()


Measured memory_bytes: 3188
poland = input().split()
num = []
for p in poland:
    if p.isdigit():
        num.append(int(p))
    else:
        b = num.pop()
        a = num.pop()
        if p == '*':
            num.append(a * b)
        elif p == '/':
            num.append(a / b)
        elif p == '+':
            num.append(a + b)
        elif p == '-':
            num.append(a - b)
print(num.pop())

Measured memory_bytes: 7680