akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();
        int[] a = new int[Q];
        int[] b = new int[Q];
        int[] c = new int[Q];
        int[] d = new int[Q];

        for(int i = 0 ; i < Q ; i++){
            a[i] = sc.nextInt() -1;
            b[i] = sc.nextInt() -1;
            c[i] = sc.nextInt();
            d[i] = sc.nextInt();
        }

        int A[] = new int[N];
        for(int i = 0 ; i < N ; i++){
            A[i] = 1;
        }

        long ans = 0;
        while(true) {
            int pos = N;
            for(int i = N-1 ; i >= 1 ; i--){
                if(A[i] > M){
                    A[i-1]++;
                    pos = i;
                }else{
                    break;
                }
            }
            while(pos < N){
                A[pos] = A[pos-1];
                pos++;
            }
            if(A[0] > M){
                break;
            }

            long score = 0;
            for (int q = 0; q < Q; q++) {
                if (A[b[q]] - A[a[q]] == c[q]) {
                    score += d[q];
                }
            }
            ans = Math.max(ans, score);
            A[N-1]++;
        }

        System.out.println(ans);
    }
}


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

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    
    scanf("%d%d", &a, &b);
    
    if (500*a>=b) {
        printf("Yes");
    } else {
        printf("No");
    }

    return 0;
}



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

int n, a[10010][10010], z;
bool vis[10010], flag;
bool ok() {
  for (int i = 1; i <= n; ++i)
    if (a[i][0] != n) return 0;
  return 1;
}

int main() {
  // ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n - 1; ++j) cin >> a[i][j];
    a[i][0] = 1;
  }
  while (1) {
    if (ok()) {
      printf("%d\n", z);
      return 0;
    }
    flag = 0;
    z++;
    memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; ++i) {
      if (vis[i] || a[i][0] == n) continue;
      int x = a[i][a[i][0]];
      if (a[x][a[x][0]] == i && !vis[i] && !vis[x]) {
        ++a[i][0];
        ++a[x][0];
        vis[i] = vis[x] = 1;
        flag = 1;
      }
    }
    if (!flag) {
      printf("-1\n");
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 39552
#define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
int dp[100001] = {};

int main() {
    cin >> n;
    dp[0] = 0;
    for (int i = 1; i <= n; i++) dp[i] = 114514;
    for (int i = 0; i < n; i++) {
        int r = 0;
        while(i + (int)pow(6,r) <= n) {
            int tmp = (int)pow(6, r);
            dp[i + tmp] = min(dp[i] + 1, dp[i + tmp]);
            r++;
        }
        r = 0;
        while(i + (int)pow(9,r) <= n) {
            int tmp = (int)pow(9, r);
            dp[i + tmp] = min(dp[i] + 1, dp[i + tmp]);
            r++;
        }
    }
    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 640
w = input()
d = {}

for c in w:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1
flag = True
for key in d.keys():
    if d[key]%2 == 1:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.*
import kotlin.math.acos
import kotlin.math.cos
import kotlin.math.round
import kotlin.math.sin

fun main(args: Array<String>) {
    val (h, w) = readIntList()
    val a = List(h) { readString() }

    var cnt = 0
    for (i in 0 until h) {
        for (j in 0 until w) {
            if (a[i][j] == '#') cnt++
        }
    }
    if (cnt == h + w - 1) println("Possible")
    else println("Impossible")
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

int main() {
  int N; cin >> N;
  vector<int> A(0);
  for(int i=0;i<4;i++){
    A.push_back(N%10);
    N/=10;
  }
  reverse(A.begin(),A.end());
  //3ビット(000~111)を全探索
  for (int tmp = 0; tmp < (1 << 3); tmp++) {
    bitset<3> s(tmp);
    int result=A.at(0);
    for (int i=0;i<3;i++){
      if (s.test(i)){
        result-=A.at(i+1);
      }else{
        result+=A.at(i+1);
      }
    }
    if (result==7){
      for(int i=0;i<3;i++){
        cout << A.at(i);
        if (s.test(i)){
          cout << "-";
        }else{
          cout << "+";
        }
      }
      cout << A.at(3) << "=7" << endl;
      break;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string s;
  getline(cin,s);
  string ans="";
  rep(i,s.size()){
    if(i+4<s.size() && s.substr(i,5)=="apple"){
      ans+="peach";
      i+=4;
    }else if(i+4<s.size() && s.substr(i,5)=="peach"){
      ans+="apple";
      i+=4;
    }else{
      ans+=s[i];
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using Library;
using static Library.Input;

namespace AtCoderTemplate
{
    class ProgramA
    {
        static void Main()
        {
            System.Console.WriteLine((double)NextInt * 2 * Math.PI);
        }
    }
}

namespace Library
{
    class Input
    {
        static IEnumerator<string> enumerator = new string[] { }.AsEnumerable().GetEnumerator();

        public static string Line => Console.ReadLine();

        public static string[] StrArr => Line.Split(' ');

        public static int NextInt => int.Parse(NextWord());

        public static long NextLong => long.Parse(NextWord());

        public static List<int> IntList => StrArr.Select(int.Parse).ToList();

        public static List<long> LongList => StrArr.Select(long.Parse).ToList();

        public static IEnumerable<long[]> TakeLine(int N)
        {
            return Enumerable.Repeat(0, N).Select(_ => Console.ReadLine().Split(' ').Select(long.Parse).ToArray());
        }

        public static string NextWord()
        {
            while (!enumerator.MoveNext())
            {
                enumerator = StrArr.AsEnumerable().GetEnumerator();
            }
            return enumerator.Current;
        }
    }
}


Measured memory_bytes: 27956
# 169A
# 値 A × B を整数として出力せよ。

# １．標準入力をプログラムで扱えるように受け取る
a, b = map(int, input().split())
# print(a, b)

# ２．受け取った入力値を使って、適切に処理（計算）する
answer = a * b

# ３．計算結果を出力する
print(answer)


Measured memory_bytes: 9044
/*
    Author - Param Kothari
    Ah shit, here we go again
*/

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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back
#define mk make_pair

typedef long long ll;
typedef long double ld;

void solve(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int i = 0, j = n - 1;
    int res = 0;
    while(i < j){
        while(i < j && s[i] == 'R'){
            i++;
        }
        while(j > i && s[j] == 'W'){
            j--;
        }
        if(i == j)
            break;
        swap(s[i], s[j]);
        res++;
        i++;
        j--;
    }
    cout << res << "\n";
    return;
}

int main(){
    IOS;
    int t = 1;
    // cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3720
/*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  string s;
  int n;
  cin >> n >> s;
  int ans=0;
  for(int i=0; i<s.size(); i++) {
    if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C') {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i, j, k, H, W;
    for(k=0; k<300; k++){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0){
            break ;
        }
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                if( (i+j)%2==0){
                    printf("#");
                }else{
                    printf(".");
                }
            }printf("\n");
        }printf("\n");
    }
    return 0;
}



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

using namespace std;

using ll = long long;

const ll inf = 1e16;

int main() {
	ll n, x, d;
	cin >> n >> x >> d;
	
	if(d == 0) {
		if(x == 0) {
			cout << 1 << '\n';
		} else {
			cout << n + 1 << '\n';
		}
		return 0;
	}

	if(d < 0) {
		d = -d;
		x = -x;
	}

	map<ll, vector<pair<ll, ll> > > mp;

	for(int i = 0; i < n + 1; ++i) {
		ll s = x * i;
		ll l = 1LL * i * (i - 1) / 2;
		ll r = 1LL * (2 * n - i - 1) * i / 2;
		mp[(s % d + d) % d].emplace_back(s + l * d, r - l);
	}		

	ll ans = 0;

	for(auto& p : mp) {
		auto &a = p.second;
		int m = a.size();

		for(int i = 0; i < m; ++i) {
			a[i].first = (a[i].first - p.first) / d;
		}

		vector<pair<ll, int> > v;

		for(int i = 0; i < m; ++i) {
			v.emplace_back(a[i].first, 1);
			v.emplace_back(a[i].first + a[i].second + 1, -1);
		}

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

		ll cnt = 0;
		ll pre = -inf;

		for(auto& x : v) {
			ll len = x.first - pre;
			if(cnt > 0) {
				ans += len;
			}
			cnt += x.second;
			pre = x.first;
		}
	}

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 22144
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const int INF = 1e8;

vector<int> g[100000];
int low[100000], high[100000];

bool impossible;
void __dfs(int cur, int pre, int num){
	if(high[cur] != INF and high[cur] % 2 != num % 2){
		impossible = true;
		return;
	}

	for(auto to : g[cur]){
		if(to == pre) continue;
		__dfs(to, cur, num + 1);
	}
}

void dfs(int cur, int pre){
	for(auto to : g[cur]){
		if(to == pre) continue;

		dfs(to, cur);
		high[cur] = min(high[cur], high[to] + 1);
		low[cur] = max(low[cur], low[to] - 1);
	}
}

void _dfs(int cur, int pre){
	for(auto to : g[cur]){
		if(to == pre) continue;
		high[to] = min(high[to], high[cur] + 1);
		low[to] = max(low[to], low[cur] - 1);
		_dfs(to, cur);
	}
}

int main(){
	fill(low, low + 100000, -INF);
	fill(high, high + 100000, INF);

	int n;
	cin >> n;

	rep(i,n - 1){
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	int k;
	cin >> k;

	int s;
	rep(i,k){
		int V, p;
		cin >> V >> p;
		V--;
		low[V] = high[V] = p;
		s = V;
	}

	dfs(s, -1);
	_dfs(s, -1);
	__dfs(s, -1, high[s]);

	if(impossible){
		cout << "No" << endl;
		return 0;
	}

	rep(i,n){
		if(high[i] < low[i]){
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	rep(i,n){
		cout << high[i] << endl;
	}
}


Measured memory_bytes: 13440
import math
N = int(input())
X = []
for _ in range(N):
  x, l = map(int,input().split())
  X.append([x+l, x-l])
sorted_X = sorted(X, key=lambda x:(x[0], x[1]))
ans = 1
cnt = sorted_X[0][0]
for i in range(N):
  if sorted_X[i][1] >= cnt:
    ans += 1
    cnt = sorted_X[i][0]
print(ans)

Measured memory_bytes: 30480
s = input()[::-1]
sum_of_digits = 0
cnts = [0] * 2019
cnts[0] = 1

d = 1
for c in s:
    sum_of_digits += int(c) * d
    d *= 10
    d %= 2019
    sum_of_digits %= 2019
    cnts[sum_of_digits] += 1

ans = 0
for cnt in cnts:
    ans += cnt * (cnt - 1) // 2

print(ans)


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

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

  int num0 = count(str.cbegin(), str.cend(), '0');
  int num1 = count(str.cbegin(), str.cend(), '1');
  
  cout << min(num0, num1)*2;
                      
  return 0;  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    string A, B, C;
    cin >> A >> B >> C;

    int ans = 0;
    for(int i=0;i<N;i++){
        map<char, int> cnt;
        cnt[A[i]]++;
        cnt[B[i]]++;
        cnt[C[i]]++;
        int max_v = 0;
        for(auto& p : cnt){
            max_v = max(max_v, p.second);
        }
        ans += 3 - max_v;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n;
    int b, f, r, v;
    int count[4][3][10];

    for (int i = 0; i < 4; i++) {
         for (int j = 0; j < 3; j++) {
	      for (int k = 0; k < 10; k++) {
		   count[i][j][k] = 0;
              }
	 }
    }
    
    cin >> n;

    for (int i = 0; i < n; i++) {
         do {
             cin >> b >> f >> r >> v;
         } while ((b < 1 || b > 4) || (f < 1 || f > 3) || (r < 1 || r > 10) ||
                  (count[b - 1][f - 1][r - 1] + v > 9));
 
	 count[b - 1][f - 1][r - 1] += v;     
    }

    for (int i = 0; i < 4; i++) {         
	 for (int j = 0; j < 3; j++) {
              cout << " ";

	      for (int k = 0; k < 10; k++) {
	           cout << count[i][j][k];

                   if (k != 9) {
                       cout << " ";
                   }
              }     

              cout << endl;                     
	 }   

         if (i != 3) {
             cout << "####################" << endl;
         }
    }
    
    return (0);
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll N = 205, mod = 1e9+7;

ll n, k, a[205], ans;

struct cand {
	vector<ll> x;
	ll c;
	cand(vector<ll> &T, ll C) {
		x = T; c = C;
	}
	bool operator == (cand &T) {
		for(ll i=1;i<n;i++) {
			if(x[i]-x[i-1] != T.x[i]-T.x[i-1]) return false;
		}
		return true;
	}
	bool operator < (cand &T) {
		for(ll i=1;i<n;i++) {
			ll A = x[i]-x[i-1], B = T.x[i]-T.x[i-1];
			if(A < B) return true;
			if(A > B) return false;
		}
		return (x[0] > T.x[0]);
	}
};

vector<cand> c;

ll mincnt (ll A, ll B) {
	ll R = 0;
	for(ll i=60;i--;) {
		ll X = A&(1ll<<i), Y = B&(1ll<<i);
		if(X == Y) R += !!X;
		else return R + 1;
	}
	return -1;
}

void solve (ll I) {
	if(I > k) return;
	vector<pll> V;
	for(ll i=1;i<=n;i++) {
		V.push_back({a[i]%(1ll<<I), a[i]/(1ll<<I)});
	}
	sort(V.begin(), V.end());
	{
		vector<ll> T;
		for(ll j=0;j<n;j++) {
			T.push_back(V[j].Y);
		}
		sort(T.begin(), T.end());
		c.push_back(cand(T, k-I));
	}
	for(ll i=0;i<n-1;i++) {
		if(V[i].X == V[i+1].X) continue;
		ll C = I + mincnt(V[i].X, V[i+1].X);
		if(C > k) continue;
		vector<ll> T;
		for(ll j=0;j<=i;j++) {
			if(!V[j].Y) return;
			T.push_back(V[j].Y-1);
		}
		for(ll j=i+1;j<n;j++) {
			T.push_back(V[j].Y);
		}
		sort(T.begin(), T.end());
		c.push_back(cand(T, k-C));
	}
}

int main()
{
	scanf("%lld%lld",&n,&k);
	for(ll i=1;i<=n;i++) {
		scanf("%lld",&a[i]);
	}
	sort(a+1, a+1+n);
	for(ll i=0;i<=60;i++) {
		solve(i);
	}
	sort(c.begin(), c.end());
	for(ll i=0,S=0;i<c.size();i++) {
		if(i+1 < c.size() && c[i] == c[i+1]) continue;
		for(ll j=S;j<=i;j++) {
			if(j == i) {
				ans = (ans + min(c[j].x[0], c[j].c) + 1) % mod;
				continue;
			}
			if(c[j].x[0]-c[j+1].x[0] <= c[j].c) {
				c[j+1].c = max(c[j+1].c, c[j].c-c[j].x[0]+c[j+1].x[0]);
				c[j].c = c[j].x[0]-c[j+1].x[0]-1;
			}
			ans = (ans + c[j].c + 1) % mod;
		}
		S = i+1;
	}
	printf("%lld\n",ans);
}


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

const int maxn=1001;
const double EPS =1e-6;
const double PI =3.141592653589793;
using namespace std;
const int MOD=1e9;
typedef long long ll;
typedef long double ld;
vector<pair<int,int>> ed;
vector<int> v;
vector<pair<int,int>> g[maxn];

int conv(string s){
    int res=0;
    for(char c:s)
        res=res*2+c-'0';
    return res;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int l;
    cin>>l;
    --l;
    int x=l;
    string s;
    int k=0;
    while(l){
        s+=((l%2)+'0');
        l/=2;
        k++;
    }
    reverse(s.begin(),s.end());
    int n=k+1;
    g[1].push_back(make_pair(n,x));
    for(int i=0; i<s.size(); ++i){
        if (s[i]=='1'){
            string t=s.substr(0,i);
            while(t.size()<s.size())
                t+='0';
            g[1].push_back(make_pair(i+2,conv(t)));
        }
    }
    for(int i=2; i<n; ++i){
        g[i].push_back(make_pair(i+1,0));
        g[i].push_back(make_pair(i+1,(1<<(k-i))));
    }
    int m=0;
    for(int i=1; i<=n; ++i)
        m+=g[i].size();
    if (n>10) {
        cout << n-1 << " " << m-1 << endl;
        for(auto it:g[1])
            if (it.first!=2)
                cout<<1<<" "<<it.first-1<<" "<<it.second<<"\n";
        for (int i = 2; i <= n; ++i) {
            for (auto it:g[i])
                cout << i-1 << " " << it.first-1 << " " << it.second << "\n";
        }
    }
    else{
        cout << n << " " << m << endl;
        for (int i = 1; i <= n; ++i) {
            for (auto it:g[i])
                cout << i << " " << it.first << " " << it.second << "\n";
        }
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    string S;
    ll K;
    cin >> S >> K;
    for (int i = 0; i < min(K, (ll)S.size()); i++) {
        if (S[i] >= '2') {
            cout << S[i] << '\n';
            return 0;
        }
    }
    cout << 1 << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;

int main(void){
	int digit=0;
	ll res=1;
	for(;digit<10;digit++){
		printf("? %lld\n",res);
		fflush(stdout);
		string str;
		cin >> str;
		if(str=="N")break;
		res*=10LL;
	}
	if(digit==10){
		res=1;
		for(int i=0;i<10;i++){
			printf("? %lld\n",res+1LL);
			fflush(stdout);
			string str;
			cin >> str;
			if(str=="Y"){
				printf("! %lld\n",res);
				fflush(stdout);
				return 0;
			}
			res*=10LL;
		}
		return 0;
	}
	res=0;
	for(int i=0;i<digit;i++){
		int l=0,r=10;
		if(i==0)l=1;
		res*=10LL;
		while(l+1<r){
			int mid=(l+r)/2;
			ll rr2=(ll)res+mid;
			for(int j=i;j<digit;j++){
				rr2*=10LL;
			}
			printf("? %lld\n",rr2);
			fflush(stdout);
			string str;
			cin >> str;
			if(str=="Y"){
				r=mid;
			}else{
				l=mid;
			}
		}
		res+=(ll)l;
	}
	printf("! %lld\n",res+1LL);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 668
import numpy
import bisect
n,m,k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a = [0]+list(numpy.cumsum(A))
b = [0]+list(numpy.cumsum(B))
ans = 0
# print(a,b)
for i in range(len(a)):
    x = k - a[i]
    if x >= 0:
        j = bisect.bisect_right(b,x)-1
        ans = max(ans, i+j)
print(ans)

Measured memory_bytes: 60784
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n;
cin>>n;
bool flag=false;
for(int i=1;i<10;i++){
    for(int j=1;j<10;j++){
        if(i*j==n){
            flag=true;
        }
    }
}
if(flag){
    cout<<"Yes"<<endl;
}else{
    cout<<"No"<<endl;
}
}










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

#define mem(dp,a)       memset(dp,a,sizeof dp)
#define iOS           	ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb(x)           push_back(x)
#define all(c)          c.begin(), c.end()
#define int             long long
#define ff              first
#define ss              second
#define nl              '\n'

int32_t main()
{
	iOS
	int n; cin>>n;
    vector<int> a(100005);
    int x;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        a[x]=i+1;
    }
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
}



Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	int r;
	string ans;
	cin>>r;
	if(r<1200)ans="ABC";
	else if(r<2800)ans="ARC";
	else ans="AGC";
	cout<<ans<<endl;
}


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

namespace ConsoleApplication1
{
    class Program
    {

        static string[] s3 = { "dreamer", "dream", "eraser", "erase" };
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            if (f(s,0))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }

        static bool f(string s,int index)
        {
            while (true)
            {
                if (index == s.Length) return true;
                var next = s3.Where(str =>
                {
                    var a = s.IndexOf(str, index, Math.Min(7, s.Length - index));
                    return a == index;
                }).ToArray();
                if (next.Length == 1)
                {
                    index += next[0].Length;
                    continue;
                }
                for (int i = 0; i < next.Length; i++)
                {
                    if (f(s,index+next[i].Length))
                    {
                        return true;
                    }
                }
                return false;

            }
        }

    }
}


Measured memory_bytes: 9436
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int X = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int out = (X-A)%B;
		// 出力
		System.out.println(out);
	}
}

Measured memory_bytes: 21716
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define FILLA(a, x) memset((a), (x), sizeof (a))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
#define COPYA(a, b) memcpy((b), (a), sizeof (a))

typedef unsigned long long lu;
typedef long long li;
typedef pair<int, int> pii;
int mod;

inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x = Sub(x - y); }
inline int Mul(int x, int y) { return (int)((lu)x * y % mod); }
inline int Mul(int x, int y, int z) { return (int)((lu)x * y % mod * z % mod); }

int Pow(int x, int y) {
  int z = 1;
  for (; y; y >>= 1) {
    if (y & 1) z = Mul(z, x);
    x = Mul(x, x);
  }
  return z;
}

int Fix(int x) { return Sub(x % mod); }

int Inv(int x) { return Pow(x, mod - 2); }
template <class T> inline void Max(T &x, T y) { if (y > x) x = y; }
template <class T> inline void Min(T &x, T y) { if (y < x) x = y; }

// ----------------------------------------

const int maxn = 1e5, maxmod = 1e6;

int n, m, q;
bool four[maxmod];

struct Edge {
  int a, b, c;
} edge[maxn];

int ID(int u, int p, int q) {
  return u * 6 + p * 3 + q;
}

const int maxN = maxn * 6;
int N, par[maxN];

void InitDsu(void) {
  N = 6 * n;
  for (int i = 0; i < N; ++i) par[i] = i;
}

int Find(int x) {
  return x == par[x] ? x : par[x] = Find(par[x]);
}

void Unite(int x, int y) {
  par[Find(x)] = Find(y);
}

int main(void) {
  scanf("%d%d%d%d", &n, &m, &q, &mod);
  int g = mod;
  for (int i = 0; i < m; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a; --b;
    edge[i] = {a, b, c};
    g = __gcd(g, mod + edge[i].c - edge[0].c);
  }
  int z = edge[0].c % g;
  for (int i = 0; i < m; ++i) {
    edge[i].c = (edge[i].c - z) / g;
  }

  InitDsu();
  for (int i = 0; i < m; ++i) {
    int u = edge[i].a, v = edge[i].b;
    for (int p = 0; p < 2; ++p) {
      for (int q = 0; q < 3; ++q) {
        Unite(ID(u, p, q), ID(v, !p, (2 * q + edge[i].c) % 3));
      }
    }
  }

  mod = __gcd(mod, 3 * g);
  static bool is_pow[2][maxmod];
  FILLA(is_pow, 0);
  for (int i = z, j = 0; j < mod; ++j, i = Add(i << 1)) {
    is_pow[j & 1][i] = true;
  }
  while (q--) {
    int s, t, r;
    scanf("%d%d%d", &s, &t, &r);
    --s; --t;
    bool ans = false;
    for (int p = 0; p < 2; ++p) {
      for (int q = 0; q < 3; ++q) {
        if (Find(ID(s, p, q)) == Find(ID(t, 0, 0))) {
          ans |= is_pow[p][Fix(Add(r + z) - Mul(q, g))];
        }
      }
    }
    puts(ans ? "YES" : "NO");
  }

  return 0;
}


Measured memory_bytes: 5888
#include <stdio.h>
 
int main(){
    int dice_num[7];
     
    int i,j;
    for(i=1; i<=6; i++)
        scanf("%d", &dice_num[i]);
    getchar();
     
    int data_num;
    scanf("%d", &data_num);
     
    int right[7][7];
    right[1][2] = dice_num[3]; right[1][3] = dice_num[5]; 
    right[1][4] = dice_num[2]; right[1][5] = dice_num[4];
    right[2][1] = dice_num[4]; right[2][3] = dice_num[1]; 
    right[2][4] = dice_num[6]; right[2][6] = dice_num[3];
    right[3][1] = dice_num[2]; right[3][2] = dice_num[6]; 
    right[3][5] = dice_num[1]; right[3][6] = dice_num[5];
    right[4][1] = dice_num[5]; right[4][2] = dice_num[1]; 
    right[4][5] = dice_num[6]; right[4][6] = dice_num[2];
    right[5][1] = dice_num[3]; right[5][3] = dice_num[6]; 
    right[5][4] = dice_num[1]; right[5][6] = dice_num[4];
    right[6][2] = dice_num[4]; right[6][3] = dice_num[2]; 
    right[6][4] = dice_num[5]; right[6][5] = dice_num[3];
     
    int up, front;
    for(i=0; i<data_num; i++){
        scanf("%d %d", &up, &front);
        for(j=1; j<=6; j++){
            if(up == dice_num[j]) up = j;
            if(front == dice_num[j]) front = j;
        }
        printf("%d\n", right[up][front]);
    }
}




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

int main()
{
  vector<ll> A(3);
  for (int i=0; i<3; i++){
    cin >> A[i];
  }

  if (A[0]+A[1]+A[2]>=22) cout << "bust" << endl;
  else cout << "win" << endl;

  return 0;
}


Measured memory_bytes: 764
#include<stdio.h>
#include<algorithm>
using namespace std;
struct point{
    int x, y;
    bool operator<(const point &p)const{
        return x!=p.x?x<p.x:y<p.y;
    }
}w[101000];
int n;
long long Res[101000];
int main(){
    scanf("%d",&n);
    int i, a=n;
    for(i=1;i<=n;i++){
        scanf("%d",&w[i].x);
        w[i].y = i;
    }
    sort(w+1,w+n+1);
    for(i=n;i>=1;i--){
        a = min(a,w[i].y);
        Res[a] += 1ll*(w[i].x-w[i-1].x)*(n-i+1);
    }
    for(i=1;i<=n;i++)printf("%lld\n",Res[i]);
}

Measured memory_bytes: 2560
import java.util.Scanner;
 
class Main {

	public static void main(String[] args) {


		        Scanner sc = new Scanner(System.in);
		        int a = sc.nextInt();
		        int b = sc.nextInt();
		        System.out.println((a*b) + (" ") + ((a+b)*2));
		    }
}


Measured memory_bytes: 26112
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;



int main()
{
	int D, N;

	cin >> D >> N;

	int ans = 0;
	switch (D) {
	case 0:
		if (N == 100) {
			ans = 101;
		}
		else {
			ans = N;
		}
		break;
	case 1:
		if (N == 100) {
			ans = 10100;
		}
		else {
			ans = 100 * N;
		}
		break;
	case 2:
		if (N == 100) {
			ans = 1010000;
		}
		else {
			ans = 10000 * N;
		}
		break;
	}

	printf("%d", ans);

	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

using namespace std;

#define MOD 1000000007
#define M 108
typedef long long Int;

int a, b, c, d, e;
Int dp[108][21600];
Int dp1[108][21600];
Int dp2[108][21600];
int main(){
  cin >> a >> b >> c >> d >> e;
  b -= a;
  e -= a*d;
  dp[0][0] = 1;
  dp1[0][0] = 1;
  dp2[0][0] = 1;
  for(int i = 0;i <= d;i++){
    for(int j = 0;j < 21500;j++){
      if(i == 0 && j == 0)continue;
      dp[i%M][j] = 0;    
      int l = max(0, i - j);
      int r = min(c, i);
	  if(l <= r){
	      if(i-l>=0 && j - (i-l) >= 0)dp[i%M][j] += dp1[(i-l)%M][j-(i-l)];
	      if(i-(r+1) >= 0 && j-(i-(r+1)) >= 0)dp[i%M][j] -= dp1[(i-(r+1))%M][j-(i-(r+1))];
	  }
/*      for(int k = l;k <= r;k++){
	dp[i][j] += dp[i-k][j-(i-k)];
	} */
      l = 1;
      r = min(c, i);
      r = min(r, j / (b+1));
      if(l <= r){
	      if(i-l >= 0 && j-(b+1)*l >= 0)dp[i%M][j] -= dp2[(i-l)%M][j-(b+1)*l];
	      if(i-(r+1) >= 0 && j-(b+1)*(r+1) >= 0)dp[i%M][j] += dp2[(i-(r+1))%M][j-(b+1)*(r+1)];
	  }
/*      for(int k = l;k <= r;k++){
	dp[i][j] -= dp[i-k][j-(b+1)*k];
	}*/
      dp[i%M][j] %= MOD;
      if(dp[i%M][j] < 0)dp[i%M][j] += MOD;
      dp1[i%M][j] = dp2[i%M][j] = dp[i%M][j];
      if(i)(dp1[i%M][j] += dp1[(i-1)%M][j+1])%=MOD;
      if(i && j-(b+1)>=0)(dp2[i%M][j] += dp2[(i-1)%M][j-(b+1)])%=MOD;
    }
  }
  cout << dp[d%M][e] << endl;
  return 0;
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    
    if(a<b&&b<c) cout<<a<<" "<<b<<" "<<c<<endl;
    else if(a<b&&c<b)
        if(a<c) cout<<a<<" "<<c<<" "<<b<<endl;
        else cout<<c<<" "<<a<<" "<<b<<endl;
    else if(b<a&&a<c) cout<<b<<" "<<a<<" "<<c<<endl;
    else if(b<a&&c<a)
        if(b<c) cout<<b<<" "<<c<<" "<<a<<endl;
        else cout<<c<<" "<<b<<" "<<a<<endl;
}


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

int main(){
	int x[4][3][10]={0};
	int b,f,r,v;
	int n;
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >>b>>f>>r>>v;
		b--;f--;r--;
		x[b][f][r] += v;
	}
	for(int i=0;i<4;i++){
		for(int j=0;j<3;j++){
			for(int k=0;k<10;k++){
				cout << ' ' <<x[i][j][k] ;
			}
			cout << endl;
		}
		if(i<3){
			cout << "####################" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n, m;
    cin >> n >> m;
    int x[m];
    rep(i, 0, m) {
        cin >> x[i];
    }

    if (m <= n) {
        cout << 0 << endl;
        return 0;
    }

    sort(x, x + m);
    int dif[m - 1];
    ll sum = 0;
    rep(i, 0, m - 1) {
        dif[i] = x[i + 1] - x[i];
        sum += dif[i];
    }

    sort(dif, dif + m - 1, greater<int>());

    rep(i, 0, n - 1) {
        sum -= dif[i];
    }

    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <map>
#include <math.h>
using namespace std;

long long int memo[110][110];
char board[110][110];

int main(){
    int H, W;
    cin >> H >> W;
    for (int i = 0; i < 110; i++) {
        for (int j = 0; j < 110; j++) {
            memo[i][j] = 0;
        }
    }
    for (int j = 0; j < 110; j ++) board[0][j] = '.';
    for (int i = 0; i < 110; i ++) board[i][0] = '.';
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> board[i][j];
        }
    }
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (i == 1 && j == 1) {
                long long int add = board[i][j] == '#' ? 1 : 0;
                memo[i][j] = add;
            } else if (i == 1) {
                long long int leftAdd = board[i][j-1] == '.' && board[i][j] == '#' ? 1 : 0;
                memo[i][j] = memo[i][j-1] + leftAdd;
            } else if (j == 1) {
                long long int topAdd = board[i-1][j] == '.' && board[i][j] == '#' ? 1 : 0;
                memo[i][j] = memo[i-1][j] + topAdd;
            } else {
                long long int leftAdd = board[i][j-1] == '.' && board[i][j] == '#' ? 1 : 0;
                long long int left = memo[i][j-1] + leftAdd;
                long long int topAdd = board[i-1][j] == '.' && board[i][j] == '#' ? 1 : 0;
                long long int top = memo[i-1][j] + topAdd;
                memo[i][j] = min(left, top);
            }
        }
    }
    cout << memo[H][W] << endl;
    return 0;
}


Measured memory_bytes: 384
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;


int main() {
	long long int N,D;cin>>N>>D;
	if (D == 1) {
		cout<<N*(N-1)/2<<endl;
	}
	else if (D == 2) {
		cout<<N*(N-1)/2-1<<endl;
	}
	else {
		cout<<(N-D)*(N-D-1)/2+2*(N-D)+(D-2)<<endl;
	}
	return 0;
}

Measured memory_bytes: 3096
alpha = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']
DP = [[] for i in range(10)]
DP[0] = ['a']
for i in range(9):
    for w in DP[i]:
        num = alpha.index(w[0])
        for i in range(1,len(w)):
            num = max(num, alpha.index(w[i]))
        for j in range(num+1):
            DP[i+1].append(w + alpha[j])
        if num + 1 <= 9:
            DP[i+1].append(w + alpha[num+1])
N  = int(input())
for w in DP[N-1]:
    print(w)

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

 int main()
{
    char S[255];
    scanf("%s", S);
    if ((S[2] == S[3]) && (S[4] == S[5]))
    {
        puts("Yes");
    }
    else {
        puts("No");
    }
    return 0;
} 

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

#include <math.h>
#include <stdlib.h>


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

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

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    double ans;
    if(n % 2 == 0) ans = 0.5;
    else ans = 1.0 - (n-1)/2/double(n);

    printf("%.8f", ans);

    return 0;
}


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

int n, s;

int dp[1 << 10][10010];

int dfs(int bit = 0, int cnt = 0, int sum = 0) {
  if (cnt == n) return s == sum;
  if (sum > s) return 0;

  int &ret = dp[bit][sum];
  if (~ret) return ret;
  ret = 0;

  for (int i = 0; i < 10; ++i) {
    if ((1 << i) & bit) continue;
    ret += dfs(bit + (1 << i), cnt + 1, sum + (cnt + 1) * i);
  }

  return ret;
}

int main() {
  while (cin >> n >> s) {
    memset(dp, -1, sizeof(dp));
    cout << dfs() << endl;
  }
}

Measured memory_bytes: 43096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
const int maxn = 200100;
map<int, bool> mark[maxn];
int h, w, n;
int x[maxn], y[maxn];
int mx[maxn] = {0};
int ans;
int main()
{
	std::ios::sync_with_stdio(false);
	cin >> h >> w >> n;
	for(int i = 1; i <= n; i ++)
	{
		cin >> x[i] >> y[i];
		mark[x[i]][y[i]] = 1;
	}
	ans = h + 1;
	int nowx = 1, nowy = 1;
	mx[2] = 1;
	for(int i = 2; i <= h; i ++)
	{
		nowx ++;
		if(mark[nowx][nowy])
		{
			ans = i;
			break;
		}
		if(!mark[nowx][nowy + 1])
			nowy ++;
		mx[i + 1] = nowy;
	}
	for(int i = 1; i <= n; i ++)
		if(x[i] < ans && mx[x[i]] >= y[i])
			ans = x[i];
	cout << ans - 1 << endl;
	return 0;
}

Measured memory_bytes: 37632
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector <int> a(n), b(n);
    vector <pair <pair <int,int>, int> > c(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i] >> b[i];
        c[i] = {{b[i],a[i]},i};
    }
    sort(c.begin(), c.end());
    int t = 0;
    bool q = 1;
    for(auto g : c){
        t += g.first.second;
        if(t > g.first.first) q = 0;
    }
    if(q){
        cout <<"Yes\n";
    }
    else cout << "No\n";
}

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

#define MAXOP 100
#define NUMBER '0'

int getop(char []);
void push(double);
double pop(void);

/*逆ポーランド電卓プログラム*/
int main(){
	int type;
	double op2;
	char s[MAXOP];

	while((type = getop(s)) != EOF) {
		switch (type) {
		case NUMBER:
			push(atof(s));
			break;
		case '+':
			push(pop() + pop());
			break;
		case '*':
			push(pop() * pop());
			break;
		case '-':
			op2 = pop();
			push(pop() - op2);
			break;
		case '/':
			op2 = pop();
			if (op2 != 0.0)
				push(pop() / op2);
			else
				printf("error: zero divisor\n");
			break;
		case '\n':
			printf("%.8g\n", pop());
			break;
		default:
			printf("error: unknown command %s\n", s);
			break;
		}
		if(type=='\n')break;
	
	}
	return 0;
}

#define MAXVAL 100

int sp = 0;
double val[MAXVAL];

/* push: fを値スタックにプッシュする*/
void push(double f){
  if (sp < MAXVAL)
    val[sp++] = f;
  else  printf("error: stack full, can't push %g\n", f);
}

/* pop: スタックをポップし，一番上の値を返す*/
double pop(void){
  if (sp > 0)return val[--sp];
  else {
    printf("error: stack empty\n");
    return 0.0;
  }
}

#include <ctype.h>

int getch(void);
void ungetch(int);

/* getop:　次の演算子あるいは数値の被演算数をとってくる*/
int getop(char s[]){
  int i, c;

  while ((s[0]= c = getch()) == ' ' || c == '\t');
    
  s[1] = '\0';
  if (!isdigit(c) && c != '.')
    return c;	/*　cは数ではない */
  i = 0;
  if (isdigit(c)) /*　整数部を集める　*/
    while (isdigit(s[++i] = c = getch()))
      ;
  if (c == '.') /*　小数部を集める　*/
    while (isdigit(s[++i] = c = getch()))
      ;
  s[i] = '\0';
  if (c != EOF)
    ungetch(c);
  return NUMBER;
}

#define BUFSIZE 100

char buf[BUFSIZE];
int bufp =0;

int getch(void) /* 1文字を取ってくる */
{
	return (bufp > 0) ? buf[--bufp] : getchar();
}

void ungetch(int c) { /* 文字を入力に戻す */
	if (bufp >= BUFSIZE)
		printf("ungetch: too many characters\n");
	else  buf[bufp++] = c;
}



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

int main() {
  int n;
  cin >> n;
  int res = 50;
  for (int i = 0; i < n; i++) {
    int a, cnt = 0;
    cin >> a;
    while (a % 2 == 0) {
      cnt++;
      a /= 2;
    }
    if (cnt < res) {
      res = cnt;
    }
  }
  cout << res << endl;
}

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

int N, M, L, R;
int ma = 100002;
int mi;

int main() {
  cin >> N >> M;
  for(int i = 0; i < M; i++){
    cin >> L >> R;
    mi = max(mi, L);
    ma = min(ma, R);
  }
  int cnt = ma - mi + 1;
  if(cnt < 0){
    cout << 0 << endl;
  }else{
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n,m;
  while(cin>>n>>m,n){
    vector<pair<int,int>> pr;
    REP(i,n){
      int d,p;
      cin>>d>>p;
      pr.PB(MP(p,d));
    }
    sort(ALL(pr));
    int i;
    for(i=n-1;i>=0;i--){
      if(m-pr[i].SC<0){
        int tmp=pr[i].SC-m;
        pr[i].SC=tmp;
        break;
      }
      m-=pr[i].SC;
    }
    //i--;
    int ans=0;
    for(;i>=0;i--){
      ans+=pr[i].FR*pr[i].SC;
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3320
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ls x<<1
#define rs x<<1|1
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
char s[maxn];
void solve()
{
    scanf("%s",s+1);
    int n=strlen(s+1);int ans=0;
    rep1(i,n/2)if(s[i]!=s[n-i+1])ans++;ac;
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}

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

int main(void){
    int x,i;
    int dp[100010] = {};
    cin >> x;

    dp[0] = 1;

    for(i=100; i<=105; i++){
        dp[i] = 1;
    }

    for(i=106; i<=x; i++){
        dp[i] = max(dp[i-100],max(dp[i-101],max(dp[i-102],max(dp[i-103],max(dp[i-104],dp[i-105])))));
    }
    cout << dp[x] << endl;

    return 0;
}

Measured memory_bytes: 640
#-swank
(unless (member :child-sbcl *features*)
  (quit
   :unix-status
   (process-exit-code
    (run-program *runtime-pathname*
                 `("--control-stack-size" "128MB"
                   "--noinform" "--disable-ldb" "--lose-on-corruption" "--end-runtime-options"
                   "--eval" "(push :child-sbcl *features*)"
                   "--script" ,(namestring *load-pathname*))
                 :output t :error t :input t))))
(defmacro dp (name args memo-size &body body)
  (let ((memo (gensym)))
    `(let ((,memo (make-array ,memo-size :initial-element nil)))
       (defun ,name ,args
         (or (aref ,memo ,@args)
             (setf (aref ,memo ,@args)
                   ,@body))))))

(defun split (x str)
  (let ((pos (search x str))
        (size (length x)))
    (if pos
        (cons (subseq str 0 pos)
              (split x (subseq str (+ pos size))))
        (list str))))

(defun main (names)
  (labels ((line (names)
             (labels ((f (a b)
                        (let ((a-back (aref a (1- (length a))))
                              (b-front (aref b 0)))
                          (char= a-back b-front))))
               (if (cdr names)
                   (and (f (car names) (cadr names))
                        (line (cdr names)))
                   t)))
           (double (names)
             (= (length names) (length (remove-duplicates names :test #'equal)))))
    (and (line names) (double names))))

(let* ((n (read))
       (names (loop repeat n collect (read-line))))
  (princ (if (main names) "Yes" "No")))


Measured memory_bytes: 19768
#include <iostream>
#include <cmath>
#include <cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int main()
{
  int a,b;
  cin >>a >> b;

  if(a < 10 && b< 10)
    {
      cout << a*b << endl;
    }
      else
        {
          cout << "-1" << endl;
        }
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const long long int DIV = 1000000007;

int main(int argc, char const *argv[]) {
  long long int n, ans=1;
  cin >> n;
  for (long long int i = 1; i <= n; i++) {
    ans *= i;
    ans %= DIV;
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define sp(x) cout<<setprecision(x);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define all(a) (a).begin(), (a).end()
#define inf 10000000
#define linf INT64_MAX*0.99
#define print(s) cout<<(s)<<endl
#define lint long long
#define yes "Yes"
#define no "No"

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    int a=0;
    int z;
    bool flag = false;
    REP(i,s.length()){
        if(s[i]=='A'&&flag==false){
            a = i;
            flag = true;
        } 
        else if(s[i]=='Z') z = i;
    }
    print(z-a+1); 
    return 0;
}

Measured memory_bytes: 720