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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int h, w, d;
	cin >> h >> w >> d;
	vii a(h, vi(w));
	map<int, pii> num2iti;
	rep(i, h) {
		rep(j, w) {
			cin >> a[i][j];
			num2iti[a[i][j]] = pii(i, j);
		}
	}
	vii b(h, vi(w));
	rep1(i, d) {
		int num = i;
		pii pre = num2iti[num];
		while (num <= h*w) {
			pii now = num2iti[num];
			b[now.first][now.second] = b[pre.first][pre.second] + abs(now.first - pre.first) + abs(now.second - pre.second);
			pre = now;
			num += d;
		}
	}
	int q;
	cin >> q;
	rep(i, q) {
		int l, r;
		cin >> l >> r;
		pii s = num2iti[l], g = num2iti[r];
		cout << b[g.first][g.second] - b[s.first][s.second] << endl;
	}
}

Measured memory_bytes: 7424
import sys
input = sys.stdin.readline
N=int(input())
S=input().strip()
dp=[[0]*(N+1) for _ in range(N+1)]
for i in range(N-1,-1,-1):
    for j in range(N-1,i,-1):
        if S[i]==S[j]:
            dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1)
#print(dp)
ans=0
for i in range(N):
    for j in range(N):
        ans=max(ans,min(dp[i][j],j-i))
print(ans)


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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL<<60;
const ll mod =1000000009;





int main() {

	int n;
	cin >> n;
	int ans = 0;
	VI v(n);
	REP(i, n)cin >> v[i];

	REP(i, n) {
		int c;
		cin >> c;
		ans += max(0, v[i] - c);
	}

	cout << ans << endl;

	return 0;
}





Measured memory_bytes: 256
#include<stdio.h>
int main (void)
{
    int n,sum=0;
    int a[200000];
    int flag=1;
    int i,j,k=1;
    scanf("%d",&n);
    for(i=0; i<n; i++)
        scanf("%d",&a[i]);
    for(i=0; i<n; i++)
    {
        if(a[i]==k)
        {
            k++;
            flag=0;
        }
        else
            sum++;

    }
    if(flag)
        printf("-1\n");
    else
        printf("%d\n",sum);
    return 0;
}


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

typedef vector<int> veci;
typedef pair<int,int> pii;
typedef vector<pii> vecii;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vecl;
typedef vector<pll> vecll;
#define EPS (1e-9)
#define MOD (1e9+7)
#define fi first
#define se second
#define endl '\n'

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL_TEST    
    int tcs;
    cin >> tcs;
    while (tcs-->0)
#endif        
{
    ll q, h, s ,d;
    cin >> q >> h >> s >> d;

    q *= 8;
    h *= 4;
    s *= 2;

    ll n;
    cin >> n;

    vector<pll> m(4);
    m[0] = { q,0};
    m[1] = { h,1};
    m[2] = { s,2};
    m[3] = { d,3};

    sort(m.begin(), m.end());
    ll cnt = (n/2) * m.front().fi;
    if (n % 2) {
        if (q>h) {
            if (h>s) {
                cnt += s/2;
            } else {
                cnt += h/2;
            }
        } else {
            if (q>s) {
                cnt += s/2;
            } else {
                cnt += q/2;
            }
        }
    }

    cout << cnt << endl;
}}

Measured memory_bytes: 256
#コンビネーション。
def comb(n,m,p=10**9+7):
    if n < m : return 0
    if n < 0 or m < 0:return 0
    m = min(m, n-m)
    top = bot = 1
    for i in range(m):
        top = top*(n-i) % p
        bot = bot*(i+1) % p
    bot = pow(bot, p-2, p)
    return top*bot % p

#累乗
def mpow(x: int, k: int, MOD=1000000007) -> int:
    res = 1
    y = x
    while (k):
        if(k % 2 == 1):
            res = (res * y) % MOD
        y = (y ** 2) % MOD
        k = k // 2
    return res



[n,a,b] = list(map(int,input().split()))

CA = comb(n,a,10**9+7)
CB = comb(n,b,10**9+7)
X = mpow(2,n,10**9+7)
output = X-CA-CB-1
while output<0:
    output += 10**9+7
print(output)

Measured memory_bytes: 38512
long M=1e9+7,d[1<<17],i,j;s[222],n;main(x){for(scanf("%*d%d",&x);~scanf("%d",s+n);n++);for(qsort(s,n,4,"\x8b\7+\6Ð");j++<x;)d[j]=j;for(;j?:(j=x,++i<n);)d[j]=(d[j]*i+d[j--%s[i]])%M;printf("%d",d[x]);}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  string s;
  cin >> s;
  int siz = s.length();
  string c[4] = {"dream", "dreamer", "erase", "eraser"};
  vector<bool> dp(siz+5,false);
  string res = "";
  rep(i,7) {
    res += s[i];
    rep(j,4) {
      if (res == c[j]) dp[i] = true;
    }
    debug(dp[i]);
  }
  for (int i = 9; i < siz; ++i) {
    res = s[i];
    rep(k,7) {
      res = s[i-k-1] + res;
      rep(j,4) {
        if (res == c[j] && dp[i-k-2]) {
          dp[i] = true; break;
        }
      }
      if (dp[i]) break;
    }
    debug(res);
  }
  debug(dp[siz-1]);
  if (dp[siz-1]) cout << "YES\n";
  else cout << "NO\n";
  return 0;
}

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

int main(){
	ll x,k,d;
	cin>>x>>k>>d;
	x=abs(x);
    ll num = x/d ;
      num=min(num,k);
	  x=x-num*d;
	k=k-num;
		if(k%2==0){
			cout<<x;
		}else{
			cout<<abs(x-d);
		}		
	return 0;
}

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

const int N = 55;

int a[N];

int solve(vector<int> &cur, int bisa_delete_sebanyak) {
  int ans = 0;
  sort(cur.begin(), cur.end());
  int n = (int) cur.size();
  for (int i = 0; i < n; i++) {
    ans += cur[i];
  }
  int x = ans;
  for (int i = 0; i < min(n, bisa_delete_sebanyak); i++) {
    x -= cur[i];
    ans = max(ans, x);
  }
  return ans;
}

int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  for (int i = 0; i < n; i++) {
    scanf("%d", a + i);
  }
  int ans = 0;
  for (int x = 0; x <= min(n, k); x++) {
    for (int y = 0; y <= min(n, k) - x; y++) {
      vector<int> cur;
      for (int i = 0; i < x; i++) {
        cur.push_back(a[i]);
      }
      for (int i = n - 1; (int) cur.size() < x + y; i--) {
        cur.push_back(a[i]);
      }
      int bisa_delete_sebanyak = k - (int) cur.size();
      ans = max(ans, solve(cur, bisa_delete_sebanyak));
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int n;
	cin >> n;
	vi a(n);
	rep(i, n) cin >> a[i];
	vi ans(n);
	int f = 0, b = n;
	reverse(all(a));
	rep(i, n) {
		if(i & 1) {
			ans[--b] = a[i];
		}else{
			ans[f++] = a[i];
		}
	}
	rep(i, n) {
		if(i != 0) cout << " ";
		cout << ans[i];
	}
	cout << endl;
}


Measured memory_bytes: 3712
# coding: utf-8
# Your code here!
import math
l = list(map(int,input().split()))
N = l[0]
K = l[1]

ans = 0
 
for i in range(N):
    C = i + 1
    if C < K:
        n = math.log(K / C, 2)
        n = math.ceil(n)
        p = (1 / N) * ((1 / 2) ** n)
        
    else:
        p = 1 / N
    #print("C = " + str(C))
    #print(n)
    
    ans += p

print(ans)

Measured memory_bytes: 38896
import math
N,D=map(int,input().split())
X=[]
Y=[]
for i in range(N):
    inp=list(map(int,input().split()))
    X.append(inp[0])
    Y.append(inp[1])

cnt=0

for i in range(N):
    d=math.sqrt(X[i]**2+Y[i]**2)
    if d <= D:
        cnt = cnt+1

print(cnt)

Measured memory_bytes: 24936
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Pll;
typedef pair<P,P> PP;
#define rep(i,a,n) for(int i = a;i < n;i++)
#define LINF (ll)1e17
#define INF 1e9
#define MOD 1e9+7
#define sMOD 1e5
#define fs first
#define sc second

ll gcd(ll a,ll b){
	if(!b) return a;
	return gcd(b,a%b);
}


signed main(){
	
	
	ll n;
	cin >> n;
	
	double a,sum = 0;
	string s;
	rep(i,0,n){
		cin >> a >> s;
		
		if(s == "JPY") sum += a;
		else sum += (a*380000.0);
	}
	
	cout << setprecision(10) << sum << endl;
	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef  long long int ll ;
#define inf 9e18
#define mod 1000000007
#define mod1 998244353
#define mod2 999983
long long int power(long long int a,long long int n,long long int m) ;
long long int power(long long int a,long long int n,long long int m)
{  if(n==0)
   return 1 ;
   long long int x=power(a,n/2,m) ;
   if(n%2!=0)
    return (((a*x)%m)*(x)%m)%m ;
    else return (x*x)%m ;
}
//map<ll,ll>::iterator it ;

int main()
{ ll n,i,j,x,y,m,k,t,sum,count,cnt,b,c,d,j1,z,a,o,temp;
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s1,s2 ;
  cin>>n>>m>>y ;
  ll arr[n][m] ;
  ll brr[n] ;
  for(i=0;i<n;i++)
  {
      cin>>brr[i] ;
      for(j=0;j<m;j++)
        cin>>arr[i][j] ;
  }
  x=inf ;
  z=pow(2,n) ;
  vector<ll> v[z+1] ;
  for(i=0;i<pow(2,n);i++)
  {
      for(j=0;j<n;j++)
      {
          if((i&(1<<j))!=0)
            v[i].push_back(j) ;

      }
  }
  n=pow(2,n) ;
  for(i=0;i<n;i++)
  {
      ll crr[m]={0} ;
      z=0 ;
      for(j=0;j<v[i].size();j++)
      {
          z+=brr[v[i][j]] ;
          for(k=0;k<m;k++)
            crr[k]+=arr[v[i][j]][k] ;
      }
      for(j=0;j<m;j++)
      {
          if(crr[j]<y)
            break ;
      }
      if(j==m)
        x=min(x,z) ;
  }
  if(x==inf)
    cout<<"-1" ;
  else cout<<x<<"\n";
  return 0; }



Measured memory_bytes: 4416
#include <bits/stdc++.h>
#include <stdlib.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

int dp(int n, vector<int> h){
	vector<int> cost(n,100000);
	cost[0]=0;
	rep(i,n-2){
		cost[i+1]=min(cost[i]+abs(h[i+1]-h[i]),cost[i+1]);
		cost[i+2]=cost[i]+abs(h[i+2]-h[i]);
	}
	cost[n-1]=min(cost[n-2]+abs(h[n-1]-h[n-2]),cost[n-1]);
	return cost[n-1];
}



int main(){
	int n;
	cin >>n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	int ans;
	ans = dp(n,h);
	cout << ans << endl;
	return 0;
}




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

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

  int r, d, x;
  cin >> r >> d >> x;
  for (int i = 0; i < 10; i++) {
    x = r * x - d;
    cout << x << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db; 
typedef string str; 
typedef pair<ll,ll> pl; 
typedef vector<ll> vl; 
typedef vector<vl> vvl; 
#define mp make_pair
#define se second
#define pb push_back
#define pf push_front
#define nn <<"\n"
#define F0R(i,a) for(ll i=0;i<a;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
int INF=0x3f3f3f3f;
ll MOD=1000000007;

ll binpow(ll a,ll b, ll c=1e18){
	ll res=1;
	while(b>0){
		if(b & 1){
			res*=a;
			res%=c;
		}
		a*=a;
		a%=c;
		b>>=1;
	}
	return res;
}
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//ifstream cin("name.in");
	//ofstream cout("name.out");
	int a,b;
	cin>>a>>b;
	vl nums;
	F0R(i,a){
		int d;
		cin>>d;
		nums.pb(d);
	}
	sort(nums.begin(),nums.end());
	ll ans=0;
	for(ll i=0;i<b;i++){
		ans+=nums[i];
	}
	cout<<ans nn;
}


Measured memory_bytes: 3660
n, m = [int(n) for n in input().split(' ')]
A = [int(n) for n in input().split(' ')]

x = sum(A) /  (4 * m)

cnt = 0
for a in A:
  if x <= a:
    cnt += 1

if m <= cnt:
  print('Yes')
else:
  print('No')

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

int main(){
  int n,m;cin>>n>>m;
  priority_queue<int> pq;

  REP(i,n){
    int tmp;cin>>tmp;
    pq.push(tmp);
  }
  REP(i,m){
    int t=pq.top();pq.pop();
    t/=2;
    pq.push(t);
  }
  long long ans=0;
  REP(i,n){
    ans+=(long long)pq.top();
    pq.pop();
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 892
import sys
import math

inputs = [int(row.split()[0]) for row in sys.stdin.readlines()]

remainder = []
for val in inputs:
    if val % 10 != 0:
        remainder.append(val % 10)
    else:
        remainder.append(9)
min_remainder_index = remainder.index(min(remainder))
last_order_time = inputs.pop(min_remainder_index)
    
order_time_sum = 0
for remaind_time in inputs:
    remind = remaind_time%10
    if remind!=0:
        current_time = remaind_time+ (10 - remaind_time%10)
    else:
        current_time = remaind_time
    order_time_sum += current_time
    
print(order_time_sum +last_order_time)
    
    

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

int main () {
  int x , a , b ;
  cin >> x >> a >> b ;
  
  if ( b <= a ) {
    cout << "delicious" << endl ;
  } else if ( ( b - a ) <= x ){
    cout << "safe" << endl ;
  } else {
    cout << "dangerous" << endl ;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

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

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n;
    cin >> n;
    vector<ll> z(n);
    ll ao = 0;
    ll tk = 0;
    for (int i = 0; i < n; i++) {
        ll a, b;
        cin >> a >> b;
        ao += b;
        tk += a;
        z[i] = a + b;
    }
    sort(z.begin(), z.end());
    reverse(z.begin(), z.end());
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0)tk += z[i];
        else ao += z[i];
    }
    cout << (tk - ao)/2 << endl;
}

Measured memory_bytes: 1152
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9;
const double PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

long long h[N], dp[N];

void solve(){
    long long n, k; cin >> n >> k;

    for(long long i = 1; i <= n; i++){
        cin >> h[i];
        dp[i] = INF;
    }

    dp[1] = 0;
    for(long long i = 2; i <= n; i++){
        for(long long j = 1; j <= k; j++){
            if(i - j >= 1) dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
        }
    }

    cout << dp[n];
}

int main(){
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long q = 1; // cin >> q;

    while(q--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define SQ(a) (a)*(a)you
#define f first
#define s second
#define int long long
#define PB push_back
#define MP make_pair
#define db long double
#define all(a) a.begin(), a.end()
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define cases int testcases;cin>>testcases; while(testcases--)
#define mod 1000000007 
bool sortbysec(const pair<int,int> &a, 
              const pair<int,int> &b) 
{ 
      

    return (a.first<b.first); 
} 

int32_t main()
{
IOS


      int n,q;
      cin>>n>>q;
      string s;
      cin>>s;
      int answer[s.length()]={0};

          for(int i=0;i<s.length()-1;i++)
          {
            if((s[i]=='A')&&(s[i+1]=='C'))
            {
              answer[i+1]++;
            }
          }
            
          for(int i=1;i<s.length();i++)
          {
            answer[i]+=answer[i-1];
          }
        while(q--)
        {
          int x,y;
          cin>>x>>y;
          cout<<answer[y-1]-answer[x-1]<<endl;

        }

    return 0;
    }
    
    
  

  

Measured memory_bytes: 1872
N=str(input())

X=0
Y=0
n=0
for i in N:
  if n %2==0:
    if i =="0":
      X+=1
    
  else:
    if i =="1":
      X+=1
  n+=1
n=0
for i in N:
  if n %2==0:
    if i =="1":
      Y+=1
    
  else:
    if i =="0":
      Y+=1
  n+=1


ans=min(X,Y)
print(ans)

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

int main ()
{
    int T, P, R;
    while (cin >> T >> P >> R, (R || P || T)) {
        vector<vector<int> > w(T, vector<int>(P, 0));
        vector<int> c(T, 0);
        vector<int> s(T, 0);

        while (R--) {
            int id_t, id_p, time;
            string message;
            cin >> id_t >> id_p >> time >> message;
            if (message == "CORRECT") {
                s[id_t - 1] += time + w[id_t - 1][id_p - 1] * 1200;
                c[id_t - 1] += 1;
            } else {
                w[id_t - 1][id_p - 1] += 1;
            }
        }

        set<pair<int,int> > *rank = new set<pair<int,int> >[P + 1];
        for (int i = 0; i < T; i++) {
            rank[c[i]].insert(pair<int,int>(s[i], i));
        }
        for (int i = P; i >= 0; i--) {
            if (rank[i].size() != 0) {
                for (auto j : rank[i]) {
                    cout << j.second + 1 << " " << i << " " << j.first << endl;
                }
            }
        }

        delete [] rank;
    }

    return 0;
}

Measured memory_bytes: 1240
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

int i_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int i_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}


int i_gcd(int a, int b);
int i_gcd(int a, int b) {
	if (!b)return a;
	return i_gcd(b, a % b);
}
int i_lcm(int a, int b);
int i_lcm(int a, int b) {
	return (a * b) / i_gcd(a, b);
}
int ll_gcd(ll a, ll b);
int ll_gcd(ll a, ll b) {
	if (!b)return a;
	return ll_gcd(b, a % b);
}
int ll_lcm(ll a, ll b);
int ll_lcm(ll a, ll b) {
	return (a * b) / ll_gcd(a, b);
}

// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
//ll _pfact(ll a);
//static ll pf[100000000];
//static ll pc;
//
//ll _pfact(ll a) {
//	long i, r;
//	if (a % 2 == 0) {
//		pf[pc] = 2; pc++;
//		return(_pfact(a / 2));
//	}
//	r = sqrt(a);
//	for (i = 3; i <= r; i += 2) {
//		if (a % i == 0) {
//			pf[pc] = i; pc++;
//			return(_pfact(a / i));
//		}
//	}
//	if (a != 1) {
//		pf[pc] = a; pc++;
//	}
//	return 0;
//
//}

//同じものの最初の文字をNULLにして降順
int _sort(const void* a, const void* b);
int _sort(const void* a, const void* b) {
	char rc;

	rc = strcmp((char*)b, (char*)a);
	if (rc == 0) {
		*(char*)a = 0x00;
		return(1);
	}
	return(rc);
}

#pragma endregion



//ABC 085 C - Otoshidama
int main(void) {
	int i,j,k,ii,jj,kk,n;
	ll  y;
 
	scanf("%d %lld",&n,&y);
	y /= 1000;
	ii = y / 10;
	jj = (!ii) ? y / 5 : n;
	kk = (!jj) ? y : n;
//	printf("%d %d %d y:%d\n", ii, jj, kk,y);

	ll tmp = 0;
	for (i = ii; i >= 0; i--) {
		for (j = jj; j >= 0; j--) {
			if ((i + j) > n)  continue;
	        for (k = 0; k <= kk; k++) {
				if ((i + j + k) > n)  continue;
				if ((i + j + k) != n) continue;
				tmp = (ll)i * 10 + (ll)j * 5 + (ll)k;
				if (tmp == y) {
					printf("%d %d %d\n", i,j,k);
					return 0;
				}
			
			}
		}
	}
	printf("-1 -1 -1\n");

	return 0;
}




Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define pb emplace_back
#define inf (int)1e9
#define ff first
#define ss second
#define ll long long
#define sp(n) cout << setprecision(n) << fixed
#define hellcat ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define give(x) cout << #x << " " << x << endl
#define debug cout << "dddd" << '\n'
#define debarr(a, n) for (int i = 0; i < n; ++i) cout << a[i] << ' '; cout << endl
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;

#define int long long

template <class S, class T>
inline S smax(S &l, T r) {
  return l = max(l, (S)r);
}
template <class S, class T>
inline bool smin(S &l, T r) {
  return l = min(l, (S)r);
}

int32_t main () {
  hellcat;

	int a, b, n;
	cin >> a >> b >> n;

	if (n < b) {
		cout << (a * n) / b << '\n';
		return 0;
	}

	int k = (n + 1) / b;
	int nm = k * b - 1;
	int ans = (a * nm) / b - (a * (nm / b));
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
//using lint = long long;



struct P
{
    int x,y,z;

    bool operator<(const P &a)const{

        if(x!=a.x) return x>a.x;
        return y>a.y;
    }

};

vector<int> v;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c;

int o[1];
int l[1];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000009,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> se;
//priority_queue<int> q;
//queue<int> q;
//string r,r1;
//char r[1];
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;


//deque<int> de;
//srand((int)time(NULL));




bool as(P a,P b)
{
    if(a.x!=b.x)
       return a.x>b.x;
    return a.y<b.y;


}

int main()
{
    scanf("%d %d %d",&a,&b,&c);
    printf("%d %d",min(b,c),max(0,b+c-a));
}





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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N;
    cin >> N;
    vector<double> A(N);
    REP(i,0,N){
        cin >> A[i];
    }

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

    double ans=A[0];
    REP(i,1,N){
        ans=(ans+A[i])/2.0;
    }
    P(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

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

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




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

    long long a, b;
    while (cin >> a >> b) {
        cout << a-b + 1 << endl;
    }
    
}



















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;
const ll LINF=1e18;

int main(){
    int n,u,v;
    cin>>n>>u>>v;
    --u,--v;
    vector<vector<int>> e(n);
    for(int i=0;i<n-1;i++){
        int s,t;
        cin>>s>>t;
        --s,--t;
        e[s].push_back(t);
        e[t].push_back(s);
    }
    int du[n],dv[n];
    fill(du,du+n,INF);
    fill(dv,dv+n,INF);
    queue<int> q;
    du[u]=0;
    q.push(u);
    while(q.size()){
        int s=q.front();
        q.pop();
        for(int t:e[s]){
            if(du[t]==INF){
                du[t]=du[s]+1;
                q.push(t);
            }
        }
    }
    dv[v]=0;
    q.push(v);
    while(q.size()){
        int s=q.front();
        q.pop();
        for(int t:e[s]){
            if(dv[t]==INF){
                dv[t]=dv[s]+1;
                q.push(t);
            }
        }
    }
    int ans=-1;
    for(int i=0;i<n;i++){
        if(du[i]<dv[i]){
            ans=max(ans,dv[i]-1);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll x,y,z,k;cin>>x>>y>>z>>k;
  ll a[x],b[y],c[z];
  vector<ll> vv;
  for(ll i=0;i<x;i++)cin>>a[i];
  for(ll i=0;i<y;i++)cin>>b[i];
  for(ll i=0;i<z;i++){
    cin>>c[i];
    for(ll j=0;j<y;j++)vv.push_back(b[j]+c[i]);
  }
  sort(a,a+x);
  sort(vv.begin(),vv.end(),greater<ll>());
  vector<ll> v;
  for(ll i=0;i<min(k,(ll)vv.size());i++)v.push_back(vv[i]+a[x-1]);
  vector<ll> ans=v;
  for(ll i=x-2;i>=0;i--){
    ll u=a[x-1]-a[i];
    vector<ll> w;
    for(ll j=0;j<v.size();j++)w.push_back(v[j]-u);
    for(ll j=0;j<w.size();j++)ans.push_back(w[j]);
    sort(ans.begin(),ans.end(),greater<ll>());
    vector<ll> ww;
    for(ll j=0;j<min(k,(ll)ans.size());j++)ww.push_back(ans[j]);
    ans=ww;
  }
  for(ll i=0;i<ans.size();i++)cout<<ans[i]<<endl;
}
    
    
                                            
                                    

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    //cout.precision(10);
    int n;
    ll a[100500];
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    a[n + 1] = 0;
    for(int i = 1; i <= n; i++){
        ans += a[i] / 2;
        a[i] = a[i] % 2;
        if((a[i] == 1) && (a[i + 1] >= 1)){
            ans++;
            a[i + 1]--;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int N,M;
long long A[100010]={};
long long sum=0;
int main(){
  cin >> N >> M;
  pair<int, int> CB[M];
  for(int i=0;i<N;i++) cin >> A[i];
  sort(A,A+N);
  for(int i=0;i<M;i++) cin >> CB[i].second >> CB[i].first;
  sort(CB,CB+M);
  reverse(CB,CB+M);

  int start=0;
  bool flag=true;
  for(int i=0;i<N&&flag;i++){
    for(int j=start;j<M;j++){
      if(CB[j].second==0){
        start++;
        continue;
      }
      if(CB[j].first<=A[i]){
        flag=false;
        break;
      }
      CB[j].second--;
      A[i]=CB[j].first;
      break;
    }
  }
  for(int i=0;i<N;i++) sum += A[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
Scanner sc = new Scanner(System.in);
double r = sc.nextDouble();
double pi = Math.PI;
double area = r*r*pi;
double length = r*2*pi;
System.out.printf("%f %f",area,length);
    }
}


Measured memory_bytes: 28492
N, P = map(int, input().split())
ans = 1
 
if N >= 45:
  print(ans)
elif N == 1:
  print(P)
  
 
  
else:
  i = 1
  while(i**N <= P):
    if P % (i**N) == 0:
      ans = i
    i += 1
  print(ans)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		long h = fs.nextLong();
		
		ArrayList<Katana> katanaList = new ArrayList<>();
		
		long maxSwingDmg = 0;
		
		for(int i = 0; i < n; i++) {
			long swingDmg = fs.nextLong();
			long throwDmg = fs.nextLong();
			
			maxSwingDmg = Math.max(swingDmg, maxSwingDmg);
			katanaList.add(new Katana(i, swingDmg, throwDmg));
		}
		
		Comparator<Katana> katanaComparator = Comparator.comparing(Katana::getThrowDmg).reversed();
		katanaList.sort(katanaComparator);
		
		int lastIndex = 0;
		for(int i = 0; i < n; i++) {
			Katana katana = katanaList.get(i);
			if(katana.throwDmg > maxSwingDmg) {
				lastIndex++;
			}else {
				break;
			}
		}
		
		int ans = 0;
		long totalDmg = 0;
		for(int i = 0 ; i < lastIndex; i++) {
			Katana katana = katanaList.get(i);
			totalDmg += katana.throwDmg;
			ans++;
			if(totalDmg >= h) {
				break;
			}
		}
		
		if(totalDmg < h) {
			long hitPoint = h - totalDmg;
			if(hitPoint % maxSwingDmg == 0) {
				ans += hitPoint / maxSwingDmg ;
			}else {
				ans += hitPoint / maxSwingDmg + 1;
			}
		}
		
		System.out.println(ans);
	}
	
	class Katana{
		int id;
		long swingDmg;
		long throwDmg;
		
		Katana(int id, long swingDmg, long throwDmg){
			this.id = id;
			this.swingDmg = swingDmg;
			this.throwDmg = throwDmg;
		}
		
		long getThrowDmg() {
			return throwDmg;
		}
	}

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 64720
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++) 
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    cin >> S;
    reverse( ALL( S ) );
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>

typedef long long ll;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
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;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a, bool g){
	if(g){
		if(a[index]<key){
			return true;
		}
	}
	else{
		if(a[index]>key){
			return true;
		}
	}
	return false;
}

ll bin_search(ll key, vector<ll> &a, bool g){
	
	ll l=-1;
	ll r=a.size();

	if(g){
		l=a.size();
		r=-1;
	}

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a, g)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

int main(){

	double t,x;
	cin>>t>>x;

	cout<<t/x<<endl;
	
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
#define INF ( 1 << 30 )
int main(){
  int a;
  while(cin >> a ,a){
    for(int i = 0 ; i < 9 ; i++ ){
      int b;
      cin >> b;
      a -= b;
    }
    cout << a << endl;
  }
}

Measured memory_bytes: 1160
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt()*1;
		int b = sc.nextInt()*5;
		int c = sc.nextInt()*10;
		int d = sc.nextInt()*50;
		int e = sc.nextInt()*100;
		int f = sc.nextInt()*500;
		if(a+b+c+d+e+f >= 1000)
			System.out.println(1);
		else
			System.out.println(0);
	}
}

Measured memory_bytes: 17224
N, M = map(int, input().split())
A_B = []
for i in range(N):
    A_B.append([int(x) for x in input().split()])

money = 0
count = 0
A_B = sorted(A_B)
while count < M:
    if count+A_B[0][1] <= M:
        count += A_B[0][1]
        money += A_B[0][0] * A_B[0][1]
    else:
        money += A_B[0][0] * (M-count)
        count = M
    A_B.pop(0)
print(money)


Measured memory_bytes: 22384
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
int main()
{
	int N,c;
	c = 0;
	
	cin >> N;
	vector<int>a(2*N);
	for (int i = 0;i < 2 * N;i++) { cin >> a[i]; }
	sort(a.begin(),a.end());
	for (int j = 0;j < 2 * N;j = j + 2) { c += a[j]; }
	cout << c << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int N;
    cin >> N;
    
    int ans;
    
    if ( N % 2 == 0 ) {
        ans = N / 2;
    } else {
        ans = N / 2 + 1;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	

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

	String S=sc.next();
	int A=Integer.valueOf(S.substring(0,2));
	int B=Integer.valueOf(S.substring(2));
	boolean a1=(A>=1&&A<=12);
	boolean b1=(B>=1&&B<=12);
	
	if(a1&&b1) {
		System.out.println("AMBIGUOUS");
		
	}else if(!a1&&b1) {
		System.out.println("YYMM");
		
		
	}else if(a1&&!b1) {
		System.out.println("MMYY");
		
	}else if(!a1&&!b1) {
		System.out.println("NA");
		
	}
	
		
	}
	

	
}
		

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

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

    if(N==1){
        cout << "Hello World" << endl; return 0;
    }
    if(N==2){
        cin >> A >> B;
        cout << A+B << endl;
    }
return 0;
}


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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    int N; ll T; cin>>N>>T;
    vector<ll> A(N); rep(i,N)cin>>A[i];
    vector<ll> B(N,0);
    B[0] = A[0];
    ll diff = 0;
    vector<ll> res;
    rep1(i,N-1){
        if(A[i]>A[i-1]){
            diff = A[i] - B[i-1];
            B[i] = B[i-1];
        }else{
            res.push_back(diff);
            B[i] = min(B[i-1],A[i]);
            diff = 0;
        }
        if(i==N-1&&diff!=0){
            res.push_back(diff);
        }
    }
    sort(res.rbegin(),res.rend());
    ll ans = 0;
    for(auto i:res) if(res[0]==i)ans++;
    cout<<ans<<endl;
}


Measured memory_bytes: 5412
import java.io.*;
import java.math.*;
import java.util.*;


public class Main{
    static long MOD = 998244353 ;
    static long [] fac;
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));
        // Start writing your solution here. -------------------------------------
        //int t = sc.nextInt();
        int t = 1;
        while(t-- > 0)
        {
            int n = sc.nextInt();
            long k = sc.nextLong();
            long k2 = sc.nextLong();
            boolean find = false;
            for(long i = k; i <= k2; i++)
                if(i % n == 0) {
                    out.println("OK");
                    find = true;
                    break;
                }
            if(!find)
                out.println("NG");
        }
        out.close();
    }
    public static long C(int n, int m)
    {
        if(m == 0 || m == n) return 1l;
        if(m > n || m < 0) return 0l;
        long res = fac[n] * quickPOW((fac[m] * fac[n - m]) % MOD, MOD - 2) % MOD;

        return res;
    }
    public static long quickPOW(long n, long m)
    {
        long ans = 1l;
        while(m > 0)
        {
            if(m % 2 == 1)
                ans = (ans * n) % MOD;
            n = (n * n) % MOD;
            m >>= 1;
        }
        return ans;
    }
    public static int gcd(int a, int b)
    {
        if(a % b == 0) return b;
        return gcd(b, a % b);
    }
    public static long solve(long x, long[] res){
        int n = res.length;
        long a = x / n;
        int b = (int)(x % n);
        return res[n - 1] * a + res[b];
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 32916
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
const int inf=0x7fffffff;
const int mod=1e9+7;
const int eps=1e-6;
typedef long long ll;
typedef unsigned long long ull;
#define ls p<<1
#define rs p<<1|1
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define int long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl '\n'
#define null NULL
struct node
{
    node *pre;
    node *child[10];
    int num;
};
void init(node *&L)
{
    L=new node;
    L->pre=null;
    for(int i=1;i<=9;i++)
    {
        L->child[i]=null;
    }
}
signed main()
{
    IOS;
    int k;
    cin>>k;
    node *L;
    init(L);
    int cnt=0;
    queue<node *>q;
    for(int i=1;i<=9;i++)
    {
        node *p;p=new node;
        L->child[i]=p;p->num=i;p->pre=L;
        q.push(p);
        cnt++;
        if(cnt==k)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    while(!q.empty())
    {
        node *p=q.front();
        q.pop();
        for(int i=max(0LL,p->num-1);i<=min(9LL,p->num+1);i++)
        {
            node *t=new node;
            t->num=i;t->pre=p;
            p->child[i]=t;
            q.push(t);
            cnt++;
            if(cnt==k)
            {
                stack<int>s;
                node *tt;tt=t;
                while(tt!=L)
                {
                    s.push(tt->num);
                    tt=tt->pre;
                }
                while(!s.empty())
                {
                    cout<<s.top();s.pop();
                }
                cout<<endl;
                return 0;
            }
        }
    }
}


Measured memory_bytes: 11776