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

using namespace std;

int main(){
        int N;
        while(cin>>N,N){
                int ans=INT_MAX;
                for (int i = 0; i*500 <= N; i++) {
                        for (int j = 0; i*500+j*300 <= N; j++) {
                                if(!((N-i*500-j*300)%200)){
                                        int k=(N-i*500-j*300)/200;
                                        int ans2=0;
                                        ans2+=(k%5)*380;
                                        ans2+=(k/5)*1520;
                                        ans2+=(j%4)*550;
                                        ans2+=(j/4)*1870;
                                        ans2+=(i%3)*850;
                                        ans2+=(i/3)*2244;
                                        ans=min(ans,ans2);
                                }
                        }
                }
                cout<<ans<<endl;
        }
        return 0;
}

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

int main(){
  string s;cin>>s;
  int N=s.size();
  int count=0;
  for(int i=0;i<N;i++){
    if(s.at(i)=='p')
      count++;
  }
  
  cout<<N/2-count<<endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
using namespace std;
char maze[213][213];
int usi[123], uiop[123];
signed main() {
	int n, m, ans = 0; char a;
	cin >> n >> m;
	const int INF = 1000000000;
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= m; i++) {
			cin >> a; maze[h][i] = a;
		}
	}
	for (int g = 1; g <= n; g++) {
		for (int h = 1; h <= m; h++) {
			int sx = g, sy = h;
			if (maze[g][h] == '#') { continue; }
			int d[123][123], dx[4] = { 1, 0, -1, 0 }, dy[4] = { 0, 1, 0, -1 };
			typedef pair<int, int>P; queue<P> que;
			for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= m; j++) {
					d[i][j] = INF;
				}
			}
			que.push(P(sx, sy));
			d[sx][sy] = 0;
			while (que.size()) {
				P p = que.front(); que.pop();
				for (int i = 0; i < 4; i++) {
					int nx = p.first + dx[i], ny = p.second + dy[i];
					if (0 < nx && nx <= n && 0 < ny && ny <= m && maze[nx][ny] != '#' && d[nx][ny] == INF) {
						que.push(P(nx, ny));
						d[nx][ny] = d[p.first][p.second] + 1;
						ans = max(ans, d[nx][ny]);
					}
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
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;
}
const long double P=acos(-1.0);
long double a[105],b[105],ans;
int n;
int main() {
	in(n);
    for(int i=1;i<=n;i++)cin>>a[i]>>b[i];
    for(int i=0;i<10000;i++){
        long double sum=rand(),x,y,tot=0,tmp=0;
    	sum/=RAND_MAX;
    	sum*=2*P;
    	for(int i=1;i<=n;i++){
            x=cos(sum)*a[i]-sin(sum)*b[i];
            y=sin(sum)*a[i]+cos(sum)*b[i];
            if(x>=0){
                tot+=x;
                tmp+=y;
            }
    	}
    	long double g=sqrt(tot*tot+tmp*tmp);
        ans=max(ans,g);
    }
    cout<<setprecision(13)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
N,K = map(int,input().split())
S = list(input())
S = list(map(int,S))
A = []
cnt1 = 0
for i in range(N):
    if S[i]==1:
        cnt1 += 1
    else:
        if cnt1>0:
            A.append(cnt1)
            cnt1 = 0
if S[N-1]==1:
    A.append(cnt1)
B = []
cnt0 = 0
for i in range(N):
    if S[i]==0:
        cnt0 += 1
    else:
        if cnt0>0:
            B.append(cnt0)
            cnt0 = 0
if S[N-1]==0:
    B.append(cnt0)
if S[0]==1:
    B.insert(0,0)
if S[-1]==1:
    B.append(0)
k = min(len(B),K)
a = sum(A[:k])+sum(B[:k])
d = a
for i in range(k,len(B)):
    if i==len(B)-1 and i-k-1>=0:
        d = d-A[i-k-1]+B[i]-B[i-k]
    elif i==len(B)-1 and i-k-1<0:
        d = d+B[i]-B[i-k]
    elif i==k:
        d = d+A[i]+B[i]-B[i-k]
    else:
        d = d+A[i]-A[i-k-1]+B[i]-B[i-k]
    a = max(a,d)
print(a)

Measured memory_bytes: 4904
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
using ll = long long int;
constexpr ll MOD = 1000000007;
constexpr int MAX = 2001;
ll n, k;
ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
ll COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(void) {
	cin >> n >> k;
	ll tmp = n - k + 1;
	COMinit();
	for (int i = 1; i <= k; i++) {
		ll ret = COM(tmp, i)%MOD;
		ret = ret * COM(k - 1, i - 1) % MOD;
		cout << ret << endl;
	}
	return 0;

}

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

#define int long long
#define flash ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 5e5+5;
		
signed main()
{
    flash
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int a,b,c,d;
		cin>>a>>b>>c>>d;
		int maxx = max({b*d,a*c,a*d,b*c});
		cout<<maxx;		
    }
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = int(A); I < int(B); ++I)
#define FORR(I,A,B) for(ll I = int((B)-1); I >= int(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=1e18+7;
const ll MOD=1e9+7;

ll maxbit(ll x){
	ll ans = 0;
	while(x){
		x/=2;
		ans++;
	}
	return ans;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,K;
	cin >> N >> K;
	vector<ll> A(N),bit(47,0);
	FOR(i,0,N)cin>>A[i];
	ll max_bit = maxbit(K);
	FOR(i,0,max_bit+1){
		FOR(j,0,N){
			if(A[j]&(1LL<<i))bit[i]++;
		}
	}
	priority_queue<P> Q;
	ll v = 1;
	FOR(i,0,max_bit+1){
		Q.push({max(N-bit[i],bit[i])*v,-i});
		v *= 2;
	}
	ll X = 0;
	while(not Q.empty()){
		ll i = -Q.top().second;
		Q.pop();
		if(N-bit[i]>bit[i])if(X+(1LL<<i) <= K)X += (1LL<<i);
	}
	ll ans = 0;
	FOR(i,0,N){
		ans += (A[i]^X);
	}
	cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <stack>
#include <queue>
#include <cctype>
#include <complex>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <cassert>
#include <iomanip>

using namespace std;

#define pb push_back
typedef long long ll;
typedef complex<int> P;
typedef pair<int, int> Pii;



bool solve(){
	int n, k, m;
	cin>> n>> k>> m;
	if(n==0 && k==0 && m==0) return false;
	
	vector<int> a(n), a2(n);
	for(int i=0;i<n;i++){
		a[i] = (i+1) % n;
		a2[i] = (n+i-1) % n;
	}
	
	int p = m - 1;
	for(int j=0;j<n-1;j++){
		//cout<< p<< endl; for(int i=0;i<n;i++) cout<< a[i]; cout<< endl;
		a[a2[p]] = a[p];
		a2[a[p]] = a2[p];
		for(int i=0;i<k;i++) p = a[p];
	}
	
	cout<< p+1<< endl;
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	
	while(solve());

	return 0;
}

 

Measured memory_bytes: 1272
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

vector<ll> V[100001];

vector<ll> path;
stack<ll> s;

bool pass[100001];

ll n,m;

bool judge(void){
    ll i;

    for(i = 0;i < V[path[0]].size();i++){
       if(pass[V[path[0]][i]] == 0)
          break; 
    }

    ll j;
    for(j = 0;j < V[path[path.size() - 1]].size();j++){
        if(pass[V[path[path.size() - 1]][j]] == 0)
            break;
    }

    if(i != V[path[0]].size() && j ==  V[path[path.size() - 1]].size()){
        REP(i,path.size())
            s.push(path[i]);
        REP(i,path.size()){
            path[i] = s.top();
            s.pop();
        }
    }

    return i == V[path[0]].size() && j ==  V[path[path.size() - 1]].size();
}


int main(void){
    scanf("%lld%lld",&n,&m);
    REP(i,m){
        ll a,b;
        scanf("%lld%lld",&a,&b);

        V[a].pb(b);
        V[b].pb(a);
    }

    ll a = rand() % n + 1;

    path.pb(a);

    pass[a] = 1;

    while(judge() == false){
        while(pass[a = V[path[path.size() - 1]][rand() % V[path[path.size() - 1]].size()]]);
        path.pb(a);
        pass[a] = 1;

    }

    printf("%d\n",path.size());
    REP(i,path.size()){
        printf("%lld ",path[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 7796
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
const int maxn = 1e5 + 5;
typedef struct Node {
    int id, p, y, s;
} Node;
Node node[maxn] = { 0 };
bool cmp(Node &a, Node &b) {
    if (a.p == b.p) return a.y < b.y;
    return a.p < b.p;
}
bool cov(Node &a, Node &b) {
    return a.id < b.id;
}

int main() {
    int n, m;
    scanf("%d%d", &m, &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d%d", &node[i].p, &node[i].y);
        node[i].id = i;
    }
    sort(node + 1, node + n + 1, cmp);
    int cnt = 1;
    for (int i = 1; i <= n; i++)
        if (node[i].p == node[i - 1].p) node[i].s = ++cnt;
        else node[i].s = cnt = 1;
    sort(node + 1, node + n + 1, cov);
    for (int i = 1; i <= n; i++)
        printf("%06d%06d\n", node[i].p, node[i].s);
    return 0;
}


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

int main() {
    int n, m; cin >> n >> m;
    vector<vector<int>> a(m,vector<int>(3));
    rep(i,m){
        int pi, yi; cin >> pi >> yi;
        a[i] = {pi, yi, i};
    }

    sort(a.begin(), a.end());
    vector<string> ans(m);
    int cntj;
    rep(i,m){
        int pj = a[i][0];
        int j = a[i][2];
        if(i == 0 || pj != a[i-1][0]) cntj = 1;
        else cntj++;
        int64_t ansji = 1000000ll*pj+cntj;
        string ansjs = to_string(ansji);
        int b = ansjs.size();
        rep(k,12-b){
            ansjs = '0'+ansjs;
        }
        ans[j] = ansjs;
    }

    for(string s : ans){
        cout << s << endl;
    }
}


Measured memory_bytes: 12416
s,t = 2.times.map{gets.chomp.split("").sort!}
u,v = s.size,t.size
for i in 0..[u-1,v-1].min
  if s[i] < t[v-1-i]
    puts "Yes"
    exit
  elsif s[i] > t[v-1-i]
    puts "No"
    exit
  end
end
if u < v
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include <stdio.h>

int main(){
    int n, a[2][100], i, j, sum=0, max=0;

    scanf("%d", &n);

    for(i=0; i<2; i++){
        for(j=0; j<n; j++)
            scanf("%d", &a[i][j]);
    }
    
    for(i=0; i<n; i++){
        sum = 0;
        for(j=0; j<=i; j++){
            sum += a[0][j];
        }
        for(j=i; j<n; j++){
            sum += a[1][j];
        }

        if(max < sum)
            max = sum;
    }

    printf("%d\n", max);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

vector<vector<int>>adj;
vector<int>dp;
vector<bool> vis;

void dfs(int s) {
  vis[s] = true;
  for(auto i : adj[s]) {
    if(!vis[i])
      dfs(i);
    dp[s] = max(dp[i]+1, dp[s]);
  }
}

void solve(){
	int n, m;
  cin >> n >> m;
  adj.resize(n);
  dp.resize(n, 0);
  vis.assign(n, false);
  for(int i = 0; i < m; i++) {
    int u, v; 
    cin >> u >> v;
    u--, v--;
    adj[u].push_back(v);
  }
  for(int i = 0; i < n; i++) {
    if(!vis[i])
      dfs(i);
  }
  //for(int &i : dp)
  // cout << i << ' ' ;
  //cout << endl;
  cout << *max_element(dp.begin(), dp.end()) << endl;
}

int main(){
		ios::sync_with_stdio(false);
		cin.tie(nullptr);
		int t = 1, tt = 0;
	//	cin >> t;
		while(t--){
			//tt++;
			//cout << "Case #" << t << ": ";
			solve();
		}
	return 0;
}


Measured memory_bytes: 11764
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String sString = sc.next();

		char[] sArray = sString.toCharArray();
		int ans = 0;

		ArrayList<Character> ansArray = new ArrayList<>();

		for (int i = 0; i < sArray.length; i++) {
			if (ansArray.size() == 0){
				ansArray.add(sArray[i]);
			}else if (ansArray.get(ansArray.size()-1) != sArray[i]){
				ansArray.remove(ansArray.size()-1);
				ans += 2;
			}else {
				ansArray.add(sArray[i]);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 26892
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <list>
#include <set>
#include <queue>
#include <iterator>
#include <bitset>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#define ll             long long
#define _              ios_base::sync_with_stdio(0);cin.tie(0);
#define loop           for(i=0;i<n;i++)
#define pb             push_back
#define tc()           int t;cin>>t;while(t--)

using namespace std;

ll i,j,temp;

int main()
{_

    set<int> myset;
    int x=3,i,k;
    //cin>>x;
    for(i=0;i<x;i++){
        cin>>k;
        myset.insert(k);
    }
    cout<<myset.size()<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
 #define rep(i, n) for (int i = 0; i < (int)(n); i++)
 #define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
int func(int n){
    if(n%2==0){
        return n/2;
    }
    else{
        return 3*n+1;
    }
}
int main(){
    int s;
    cin>>s;
    map<int,int> p;
    int i=1;
    int a=s;
    p[a]++;
    int ans=0;
    while(1){
        a=func(a);
        p[a]++;
        i++;
        if(p[a]==2){
            ans = i;
            break;
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i, a, b)  for(int i = (a); i < (b); i++)
#define rrep(i, a, b) for(int i = (a); i > (b); i--)
#define sq(x) ((x) * (x))
#define bit(x) bitset<32>(x)
#define vsort(v)  sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<llint>())
#define debug(x) cout << #x << " " << (x) << endl
#define ci cin
#define co cout
#define en endl
#define ln cout<< '\n'
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007

typedef long long int llint;
typedef pair<int, int> pii;
typedef pair<llint, llint> pll;
typedef vector<int> vi;
typedef vector<llint> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


template<typename Tn> Tn __lcm(Tn a, Tn b)
{
    return a / __gcd(a, b) * b;
}

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

int main()
{
    int n, m;
    ci >> n >> m;

    vi a(n);
    vii bc(m);
    int b, c;
    
    rep(i, 0, n) ci >> a[i];
    rep(i, 0, m) {
	ci >> b >> c;
	bc.pb((pii){c, b});
    }
    
    vsort(a);
    sort(bc.begin(), bc.end(), greater<pii>());

    llint sum = 0;
    int idx = 0;
    rep(i, 0, m) {
	if(idx >= n) break;
	
	rep(j, 0, bc[i].se) {
	    if(idx >= n) break;
		
	    if(a[idx] < bc[i].fi) sum += a[idx] = bc[i].fi;
	    else sum += a[idx];
	    idx++;
	}
    }

    rep(i, idx, n) sum += a[i];
    
    co << sum << en;
    
    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	int a, b; cin >> a >> b;
	vector<int> v;
	v.push_back(a-b);
	v.push_back(a+b);
	v.push_back(a*b);
	print(*max_element(all(v)));
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		string s = cin.next();
		for (int i = 0; i < s.Length - 1; i++)
		{
			if(s[i] == s[i + 1])
			{
				Console.WriteLine("{0} {1}", i + 1, i + 2);
				return;
			}
		}
		for (int i = 0; i < s.Length - 2; i++)
		{
			if (s[i] == s[i + 2])
			{
				Console.WriteLine("{0} {1}", i + 1, i + 3);
				return;
			}
		}
		Console.WriteLine("-1 -1");
	}
}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

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

using namespace std;
typedef long long ll;

int main () {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	string s; cin >> s;
  	cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
  	return 0;
}


Measured memory_bytes: 3616
from collections import defaultdict
vis = [0 for i in range(0 , 2000)]
lt = [0 for i in range(0 , 2000)]
dis = [0 for i in range(0 , 2000)]
adj = defaultdict(list)
time = 0
ans = 0
def dfs(u , p):
	global time , ans
	time = time+1
	lt[u]= dis[u]=time
	vis[u]=1
	for v in adj[u]:
		if v==p:
			continue
		if vis[v]==0:
			dfs(v , u)
			lt[u]=min(lt[u] , lt[v])
			if lt[v]>dis[u]:
				ans = ans+1
		else:
			lt[u]=min(lt[u] , dis[v])
def main():
	n , m = map(int , input().split())
	for i in range(0 , m):
		u, v= map(int , input().split())
		adj[u].append((v))
		adj[v].append((u))
	dfs(1, 0)
	print(ans)
if __name__=="__main__":
	main()

Measured memory_bytes: 67244
n,m,q = map(int,input().split())
g = [[0]*(n+1) for _ in range(n+1)]
for _ in range(m):
  l,r = map(int,input().split())
  g[l][r] += 1
for i in range(n+1):
  for j in range(n):
    g[i][j+1] += g[i][j]
for j in range(n+1):
  for i in range(n):
    g[i+1][j] += g[i][j]
for _ in range(q):
  l,r = map(int,input().split())
  print(g[r][r]-g[l-1][r]-g[r][l-1]+g[l-1][l-1])

Measured memory_bytes: 13300
N, Q = map(int, input().split())
S = input()

cnt, buf = [0] * (N + 1), None
for i in range(N):
    s = S[i]
    cnt[i + 1] = cnt[i]
    if buf == 'A' and s == 'C':
        cnt[i + 1] += 1
    buf = s

for _ in range(Q):
    l, r = map(int, input().split())
    print(cnt[r] - cnt[l])


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


int main() {
    
    int m,f,b,ans;
    cin >> m>> f>>b;
    
    ans = b - m;
    
    if(ans <= f){
        if(ans <0)
        {
            ans = 0;
        }
        cout<< ans << endl;
    }
    else{
        cout << "NA"<<endl;
    }
    
    
    

}


Measured memory_bytes: 3088
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

#define ABS(X) \
  ( (X) < 0 ? -(X) : (X) )
#define DIST(A,B,W) \
  ( ABS( (A) / (W) - (B) / (W) ) \
  + ABS( (A) % (W) - (B) % (W) ) )
#define MIN(A,B) \
  ( (B) < (A) ? (B) : (A) )

static int n;
static int a;
static int b;
static int c;
static int d;

int
main (
  int   argc,
  char *argv[ ]
  )
{
  int res = INT_MAX;
  int w;

  scanf ( "%d", &n );
  scanf ( "%d%d%d%d", &a, &b, &c, &d );
  --a; --b; --c; --d;

  for ( w = 1; w <= n; ++w )
  {
    res = MIN( res, DIST( a, b, w ) + DIST( c, d, w ) );
  }
  printf ( "%d\n", res );

  return ( EXIT_SUCCESS );
}

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}
void Remove(ll a, ll n, ll b[n]){
    ll i;
    for(i=a-1;i<n-1;i++){
        b[i]=b[i+1];
    }
    b[n-1]=0;
}

int main(void){
    ll n,i;
    scanf("%lld",&n);
    ll b[n],same,process[n],ele=n;
    same=0;
    for(i=0;i<n;i++){
        scanf("%lld",&b[i]);
        if(i+1==b[i]) same=max2(same,b[i]);
    }
    if(same==0){
        printf("-1\n");
        return 0;
    }
    // printf("%lld\n",same);
    Remove(same,n,b);
    process[ele-1]=same;
    ele--;
    // for(i=0;i<n;i++){
    //     printf("%lld ",b[i]);
    // }
    // printf("\n");
    while(ele>0){
        same=0;
        for(i=0;i<ele;i++){
            if(i+1==b[i]) same=max2(same,b[i]);
        }
        if(same==0){
            printf("-1\n");
            return 0;
        }
        Remove(same,n,b);
        process[ele-1]=same;
        ele--;
        // printf("%lld\n",same);
        // for(i=0;i<n;i++){
        //     printf("%lld ",b[i]);
        // }
        // printf("\n");
    }
    for(i=0;i<n;i++){
        printf("%lld\n",process[i]);
    }
    // printf("\n");
    return 0;
}


Measured memory_bytes: 128
def bubbleSort(A, N):
    cnt = 0
    flag = 1
    
    while flag:
        flag = 0
        for j in reversed(range(1, N)):
            if A[j] < A[j-1]:
                A = A[:j-1] + A[j-1:j+1][::-1] + A[j+1:]
                cnt += 1
                flag = 1
                
    print(*A)
    print(cnt)
                
n = int(input())
a = list(map(int, input().split()))
bubbleSort(a, n)


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

const ll MX = 1e18;

int main() {
  int n;
  cin >> n;
  ll ans = 1;
  bool ng = false;
  rep(i,n) {
    ll a;
    cin >> a;
    if (a == 0) {
      cout << 0 << endl;
      return 0;
    }
    if (ng || __int128(ans)*a > MX) {
      ng = true;
    }
    ans *= a;
  }
  if (ng) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

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

    
}   
   



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

typedef pair<int, int> P;


int main() {
    int AN, BN, R, x, y, d2, i, j, dx, dy, res;
    while (cin >> AN >> BN >> R, AN, BN, R) {
        P A[100001];
        P B[100001];
        vector<P> sp[250][250];
        vector<P> blo_el;
        res = 0;

        for (i=0; i<AN; i++) {
            cin >> A[i].first >> A[i].second;
        }

        for (i=0; i<BN; i++) {
            cin >> B[i].first >> B[i].second;
            sp[B[i].second/40][B[i].first/40].push_back(P(B[i].first, B[i].second));
        }

        for (i=0; i<AN; i++) {
            int block_x = A[i].first / 40;
            int block_y = A[i].second / 40;
            for (dx=-1; dx<=1; dx++) {
                for (dy=-1; dy<=1; dy++) {
                    if (block_x+dx<0||block_x+dx>=250||block_y+dy<0||block_y+dy>=250) continue;
                    blo_el = sp[block_y+dy][block_x+dx];
                    for (j=0; j<blo_el.size(); j++) {
                        d2 = (A[i].first - blo_el[j].first) * (A[i].first - blo_el[j].first)
                            + (A[i].second - blo_el[j].second) * (A[i].second - blo_el[j].second);
                        if (d2 <= 16*R*R) {
                            res += 1;
                        }
                    }
                }
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define ll long long
//map<key,value>

int main(){
  int n,m;
  int mini=1000000;
  int maxi = 0;
  ll ans=0;
  cin >> n >> m;
  int f,s;
  for(int i=1;i<=m;i++){
    cin >> f >> s;
    mini = min(mini,s);
    maxi = max(maxi,f);
  }
  if(mini >= maxi){
    cout << mini - maxi + 1;
  }
  else cout << 0 << "\n";
  return 0;
}


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

unsigned int xor128() {
    static unsigned int x=123456789, y=362436069, z=521288629, w=88675123;
    unsigned int t;
    t=(x^(x<<11)); x=y; y=z; z=w;
    return (w=(w^(w>>19))^(t^(t>>8)));
}

int m[30][1000];

string calc_hash(string& str) {
    string ret(30, 0);
    for (int i = 0; i < 30; i++) {
        int s = 0;
        for (int j = 0; j < 1000; j++)
            s += m[i][j] * (str[j] - '0');
        ret[i] = '0' + s % 2;
    }
    return ret;
}

int main() {
    string s; cin >> s;
    for (int i = 0; i < 30; i++)
        for (int j = 0; j < 1000; j++)
            m[i][j] = xor128()%2;
    if (s == "Alice" || s == "Bob") {
        for (int t = 0; t < 100; t++) {
            cin >> s;
            cout << calc_hash(s);
        }
        cout << endl;
    } else {
        string X, Y; cin >> X >> Y;
        int A[100], B[100];
        for (int i = 0; i < 100; i++) {
            A[i] = stoi(X.substr(30 * i, 30), nullptr, 2);
            B[i] = stoi(Y.substr(30 * i, 30), nullptr, 2);
        }
        map<int, pair<int, int> > dict;
        for (int i = 0; i < 100; i++)
            for (int j = 0; j < 100; j++)
                dict[A[i]^B[j]] = {i, j};
        for (int t = 0; t < 100; t++) {
            cin >> s;
            int h = stoi(calc_hash(s), nullptr, 2);
            cout << dict[h].first+1 << ' ' << dict[h].second+1 << endl;
        }
    }
}



Measured memory_bytes: 3944
n = int(input())
MOD = 10**9 + 7
# dp[i][x][y][z] 0:A 1:C 2:G 3:T
dp = [[[[0] * 4 for _ in range(4)] for _ in range(4)] for _ in range(n + 1)]
dp[0][3][3][3] = 1
for i in range(1, n+1):
    for x in range(4):
        for y in range(4):
            for z in range(4):
                for w in range(4):
                    if x == 0 and z == 2 and w == 1:
                        continue
                    elif y == 0 and z == 2 and w == 1:
                        continue
                    elif y == 2 and z == 0 and w == 1:
                        continue
                    elif y == 0 and z == 1 and w == 2:
                        continue
                    elif x == 0 and y == 2 and w == 1:
                        continue

                    dp[i][y][z][w] += dp[i-1][x][y][z]
                    dp[i][y][z][w] %= MOD

ans = 0
for x in range(4):
    for y in range(4):
        for z in range(4):
            ans += dp[n][x][y][z]
            ans %= MOD

print(ans)

Measured memory_bytes: 75136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

int main() {
    int a, b;
    while (cin >> a >> b) {
        cout << (b % a == 0 ? a + b : b - a) << endl;
    }
}


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

using namespace std;

int main()
{
	int N;
	cin >> N;
	int tmp;
	long long count = 0;
	vector<int> H;
	int res;
	//vector < vector<int>> A(N, vector<int>(N));
	map<int, int> Hmap; 



	for (int i = 0; i < N; ++i)
	{
		cin >> tmp;
		H.push_back(tmp);
	}

	for (int i = 0; i < N; ++i)
	{
		
		int sa = i - H[i];
		count += Hmap[sa];
		int wa = H[i] + i;
		Hmap[wa]++;
	}

	cout << count << endl;
}

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

int main(){
	int n,m;
	cin >> n >> m;
	vector<int> path(n);
	rep(i, m){
		int a,b;
		cin >> a >> b;
		path.at(a-1)++;
		path.at(b-1)++;
	}

	rep(i, n){
		cout << path.at(i) << endl;
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int r, d, x; cin >> r >> d >> x;
    int ans = x;
    for(int i = 1; i <= 10; i++){
        ans = r * ans - d;
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5;
int a[N],n;
struct State{
	int s0,p1,p2;// p0 = 0
};

State Do(int pos, int sum,int A,int B){
	int _s[2] = {B-(A-pos)+1,pos+1};
	sort(_s,_s+2);
	while(_s[0]<=0){
		++sum;_s[0] = _s[1], _s[1] = B+1;
	}
	return (State){sum, min(_s[0],B+1), min(B+1,_s[1])};
}

State merge(State a, State b,int Len){
	while(a.s0 < b.s0){
		b.s0--, b.p2 = b.p1, b.p1 = 0;
	}
	while(a.s0 > b.s0){
		a.s0--, a.p2 = a.p1, a.p1 = 0;
	}
	a.p1 = max(a.p1, b.p1), a.p2 = max(a.p2,b.p2);
	return a;
}

State transfer(State pst, int A, int B){
	int _s = pst.s0;
	int p0 = pst.p1-1, p1 = pst.p2-1, p2 = A;
	return merge(Do(p0, _s, A, B), merge(Do(p1, _s+1, A, B), Do(p2, _s+2, A, B),B),B);
}

State cur = (State){0,1,1};

int main()
{
	cin >> n ;
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	int pst = 0;
	for(int i=1;i<=n+1;i++){
		
		cur = transfer(cur, pst, a[i]);

		pst = a[i];
	}
	cout << cur.s0 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <math.h>
#include <regex>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
ld n , d;
vector<vector<ld>> x(n,vector<ld>(d));

int main(){
    ll n ; cin >> n;
    bool flag = 0;
    ll x = 3;
    while(x--){
    if(n%10==7){
        flag = 1;
    }
    n/=10;
    }
    if(flag){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#define int long long
using namespace std;
int h, w;
string map[3456];
int a[3456][3456], b[3456][3456];
signed main() {
	cin >> h >> w;
	for (int i = 0; i < h; i++)cin >> map[i];
	for (int i = 0; i < h; i++) {
		for (int j = w - 1; j >= 0; j--) {
			a[i][j] = a[i][j + 1];
			if (map[i][j] == 'O')a[i][j]++;
		}
	}
	for (int i = h - 1; i >= 0; i--) {
		for (int j = 0; j < w; j++) {
			b[i][j] = b[i + 1][j];
			if (map[i][j] == 'I')b[i][j]++;
		}
	}
	int ans = 0; for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)if (map[i][j] == 'J')ans += a[i][j] * b[i][j];
	cout << ans << endl;
}


Measured memory_bytes: 185900
using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            //input
            var tenki1 = Console.ReadLine();
            var tenki2 = Console.ReadLine();
            int x = 0;
            for (int i = 0; i < 3; i++)
            {
                if (tenki1[i] == tenki2[i]) x++;
            }
            Console.WriteLine(x);
        }
    }
}


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

int main()
{
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		cout << a[i];
		if (i < b.size()) { cout << b[i]; }
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
char b;
int main(){
    cin>>b;
    char ans;
    switch (b) {
        case 'A':
        ans='T';
        break;
        case 'G':
        ans='C';
        break;
        case 'C':
        ans='G';
        break;
        case 'T':
        ans='A';
        default:
        break;
    }
    cout<<ans<<endl;
}


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

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#include <map>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int a,b;
    cin >> a >> b;
    string ans;
    if (a == 1 || b == 1){
        if (a == 1 && b == 1){
            ans = "Draw";
        } else if (a == 1){
            ans = "Alice";
        } else {
            ans = "Bob";
        }
    } else {
        if (a == b){
            ans = "Draw";
        } else if (a > b){
            ans = "Alice";
        } else {
            ans = "Bob";
        }
    }
    cout << ans << endl;



    return 0;
}


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

#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define FOR(i, a, b) for (int i = a; i <= (int)(b); i++)
#define FORD(i, a, b) for (int i = a; i >= (int)(b); i--)

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
using Lint = long long;
#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define PB push_back
#define MP make_pair
using P=pair<int, int>;
using V=vector<int>;
using M=map<int, int>;
using S=set<int>;

#define COUT(x) cout << (x) << endl
#define SCOUT(x) cout << (x) << " "

#define DUMP(x) cout << #x << " = " << (x) << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
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;}
/* vector<T>のイテレータはvector<T>::iterator型
vector<int>::iterator it = vc.begin();  // begin()はvectorの最初の要素を指すイテレータを返す。
vector<int>::iterator endIt = vc.end(); // end()はvectorの終端位置を指すイテレータを返す。
while (it != endIt)
{
  cout << *it << '\n'; // イテレータの指す要素は、ポインタのように*演算子でアクセスします。
  it++;                // インクリメントすることで次の要素を指します。
}

}*/
 string solve(Lint n){
    if(n==0)return "";
    n--;
    return solve(n/26)+string(1,'a'+n%26);
  }
int main()
{
  
  Lint n;
  cin >>n;
  
  COUT(solve(n)); 
  return 0;
}

Measured memory_bytes: 3596
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(n:usize)(list:[i64]));
    let mut list = list.into_iter().map(Some).collect::<Vec<_>>();
    let mut res = Vec::new();
    //後ろから
    for _ in 0..n {
        for i in 0..n {
            let i = n - i - 1;
            //前の個数
            let mut count = 0;
            for i in 0..i {
                if list[i].is_none() {
                    count += 1;
                }
            }
            if Some(count + 1) == list[i] {
                res.push(list[i].unwrap().to_string());
                list[i] = None;
                break;
            }
        }
    }
    if res.len() == n {
        res.join("\n")
    } else {
        "-1".to_string()
    }
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3\n1 2 1\n" => "1\n1\n2\n",
    test2: "2\n2 2\n" => "-1\n",
    test3: "9\n1 1 1 2 2 1 2 3 2\n" => "1\n2\n2\n3\n1\n2\n2\n1\n1\n",
}


Measured memory_bytes: 4352
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define N 44

int fib(int);

int main(){
  int n,k;

  scanf("%d",&n);

  k=fib(n);
  
  printf("%d\n",k);

  return 0;
}


int fib(int n){
  int i,F[N];

  F[0]=1;
  F[1]=1;
  
  if((n==0)||(n==1)){
    return 1;
  }
  else{
    for(i=2;i<n;i++){
      F[i]=F[i-2]+F[i-1];
    }
    return F[i-2]+F[i-1];
  }
}



Measured memory_bytes: 2052
# 500yen
A = int(input())
# 100
B = int(input())
# 50
C = int(input())
# total amount and 50 multiple of 50
X = int(input())

res = 0
for c500 in range(A+1):
    for c100 in range(B+1):
        for c50 in range(C+1):
            total = 500*c500 + 100*c100 + 50*c50
            if ( X == total):
                res += 1

print(res)

Measured memory_bytes: 9084
package main

import "fmt"

func main() {
	var h, a, tec int
	fmt.Scan(&h, &a)

	for i := 0; i < a; i++ {
		fmt.Scan(&tec)
		if h == 0 {
			fmt.Println("Yes")
			return
		}

		h -= tec
		if h <= 0 {
			fmt.Println("Yes")
			return
		} else if a == i+1 && h > 0 {
			fmt.Println("No")
		}
	}
}


Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
#define int long long

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int n;
string s[100000 + 5];
vector<string> vs;

struct Tnode {
    vector<int> nx;
    bool exist;
    char fr, to;

    Tnode(char fr = 'a', char to = 'z')
        :fr(fr), to(to)
    {
        nx.resize(to - fr + 1, -1);
    }
};

struct Trie {
    int root;
    vector<Tnode> node;
    char fr, to;

    Trie(char fr = 'a', char to = 'z')
        :root(0), fr(fr), to(to)
    {
        node.push_back(Tnode(fr, to));
    }

    void add(const string &s) {
        int now = root;
        for (auto c : s) {
            c -= fr;
            if (node[now].nx[c] == -1) {
                node[now].nx[c] = node.size();
                node.push_back(Tnode(fr, to));
            }
            now = node[now].nx[c];
        }
        node[now].exist = true;
    }

    int match(const string &s) {
        int now = root;
        for (auto c : s) {
            c -= fr;
            if (node[now].nx[c] == -1) return 0;
            now = node[now].nx[c];
        }
        return node[now].exist;
    }
};

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n) cin >> s[i];
    queue<string> q;
    q.push("");
    while (!q.empty()) {
        string p = q.front(); q.pop();
        rep(i, 26) {
            string tmp = p + char('a' + i);
            if (tmp.size() != 4) q.push(tmp);
            vs.push_back(tmp);
        }
    }
    Trie tr;
    rep(i, n)rep(j, s[i].size())rep2(k, 1, 5) {
        if (j + k  - 1 >= s[i].size()) break;
        tr.add(s[i].substr(j, k));
    }
    int size = vs.size();
    rep(i, size) {
        if (!tr.match(vs[i])) {
            cout << vs[i] << endl;
            break;
        }
    }
}

Measured memory_bytes: 134376
#include <iostream>
#include <algorithm>
#include <cstdio>
#define f first
#define s second
const int N=5e5+5;
const int K=1e6+5;
using namespace std;
 
pair <int, pair <int, int> > q[N];
int n, m, a[N], ans[N];
int st[5*N], used[K];
int cmp(pair <int, pair <int, int> > a, pair <int, pair <int, int> > b)
{
    if (a.s.f != b.s.f)
        return a.s.f < b.s.f;
    return a.f < b.f;
}
void update(int v, int l, int r, int x, int d)
{
    if (l == r)
    {
        st[v] = d;
        return;
    }
    int mid = (l + r) / 2;
    if (x <= mid)
        update(v * 2, l, mid, x, d);
    else
        update(v * 2 + 1, mid + 1, r, x, d);
    st[v] = st[v * 2] + st[v * 2 + 1];
}
int Find(int v, int A, int B, int l, int r)
{
    if (l > B || r < A)
        return 0;
    if (A == l && B == r)
        return st[v];
    int mid = (A + B) / 2;
    return Find(v * 2, A, mid, l, min(mid, r)) + Find(v * 2 + 1, mid + 1, B, max(mid + 1, l), r);
}
 
int main()
{
    cin >> n >> m;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= m; i++) cin >> q[i].f >> q[i].s.f, q[i].s.s=i;
    sort(q + 1, q + m + 1, cmp);
    int j = 1;
    for (int i = 1; i <= m; i++)
    {
        while(j <= q[i].s.f)
        {
            if (!used[a[j]])
            {
                update(1, 1, n, j, 1);
                used[a[j]] = j;
            }
            else
            {
                update(1, 1, n, used[a[j]], 0);
                update(1, 1, n, j, 1);
                used[a[j]] = j;
            }
            j++;
        }
        ans[q[i].s.s] = Find(1, 1, n, q[i].f, q[i].s.f);
    }
    for (int i = 1; i <= m; i++) cout << ans[i] << endl;
 
    return 0;
}

Measured memory_bytes: 19544
//author:luckYrat(twitter:@luckYrat_)

//#include <bits/stdc++.h>
//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
#define MOD 1000000007

#define pb push_back
#define fir first
#define scn second

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int a,b,c,d;cin>>a>>b>>c>>d;
  if(b < d){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }

}




Measured memory_bytes: 256
program main
	implicit none
    integer :: n, m
    integer(8), allocatable :: a(:), b(:)
    integer :: i, j
    integer(8) :: tenpo, kosu, amari
	integer(8) :: kakaku
	read(*, *) n, m
    allocate(a(n)); allocate(b(n))
    do i = 1, n
    	read(*, *) a(i), b(i)
    enddo
	call heapsort2(n, a, b)
    amari = m
    tenpo = 0
    do while (amari.gt.0)
    	tenpo = tenpo + 1
		amari = amari - b(tenpo)
    enddo
    kakaku = 0
    do i = 1, tenpo-1
    	kakaku = kakaku + a(i)*b(i)
    enddo
    kakaku = kakaku + a(tenpo)*(b(tenpo)+amari)
    write(*, *) kakaku
stop
end program main

subroutine heapsort2(n,a,b)
  implicit none
  integer,intent(in) :: n
  integer(8),intent(inout) :: a(n), b(n)
  integer :: i, j, k, l
  integer(8) :: tmp1, tmp2
  l = n/2 + 1
  k = n
  do while (k.ne.1)
     if (l.gt.1) then
        l = l - 1
        tmp1 = a(l)
        tmp2 = b(l)
     else
        tmp1 = a(k)
        tmp2 = b(k)
        a(k) = a(1)
        b(k) = b(1)
        k = k - 1
        if (k.eq.1) then
           a(1) = tmp1
           b(1) = tmp2
           exit
        endif
     endif
     i = l
     j = l + l
     do while (j.le.k)
        if (j.lt.k) then
           if (a(j).lt.a(j+1)) j=j+1
        endif
        if (tmp1.lt.a(j)) then
           a(i) = a(j)
           b(i) = b(j)
           i = j
           j = j + j
        else
           j = k + 1
        endif
     enddo
     a(i) = tmp1
     b(i) = tmp2
  enddo
  return
end subroutine heapsort2

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>

int main(){
	int a[30];
	int b;
	memset(a,-1,sizeof(a));
	for(int i=0;i<30;i++){
		scanf("%d",&b);
		a[--b]=false;
		}
	for(int i=0;i<30;i++){
		if(a[i])printf("%d\n",i+1);
		}



	return 0;
	}

Measured memory_bytes: 1024
var
	n:Longint;
function f(x:int64;a,b,c:Longint):Longint;
begin
	f:=0;
	if x<=n then f:=a*b*c+f(x*10+3,1,b,c)+f(x*10+5,a,1,c)+f(x*10+7,a,b,1);
end;
begin
	read(n);
	writeln(f(0,0,0,0));
end.

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

typedef unsigned long long ull;
typedef long long ll;

#define rep(i,x) for(int i=0;i<x;i++)

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

  cout << (n-1)*(m-1) << endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
 
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	long h,w;
    h=sc.nextInt();
    w=sc.nextInt();
    long sum=0;
    if(h==1||w==1){
      sum=1;
    }else{
      
      if((h%2)==0){
        sum=(h/2)*w;
      }else{
        if((w%2)==0){
          sum=(w/2)*h;
        }else{
        sum=((w-1)/2)*h+(h+1)/2;
        }
      }
    }
    System.out.print(sum);
  }
}

Measured memory_bytes: 21844