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

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

int main() {
    int N, K;
    cin >> N >> K;
    
    vector<int> h(N);

    rep(i, N) {
        cin >> h.at(i);
    }

    int ans = 0;

    for (int n : h) {
        if (n >= K)
            ans++;
    }

    cout << ans << endl;
}

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

int main(){
  
  while(1){
    
    int a;
    
    cin>>a;
    
    if(a == -1) break;
    
    if(a<=10){
      cout<<4280-1150<<endl;
    }else if(a<=20){
      cout<<4280-1150-(a-10)*125<<endl;
    }else if(a<=30){
      cout<<4280-1150-10*125-(a-20)*140<<endl;
    }else{
      cout<<4280-1150-10*125-10*140-(a-30)*160<<endl;
    }
    
  }
  return 0;
}



Measured memory_bytes: 3000
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func main() {
	n := readInt()
	h := make([]int, n)
	for i := range h {
		h[i] = readInt()
	}

	dp := make([]int, n)
	dp[1] = abs(h[1] - h[0])
	for i := 2; i < n; i++ {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
	}
	fmt.Println(dp[n-1])
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
  double x;
  cin >> x;
  int ans=0;
  //ans = log10(x/100.0)/log10(1.01);
  //ans = pow((x/100.0),0.01);
  long double kane=100.0;
  int i=0;
  while(true){
    kane = floor(kane * 1.01);
    //cout << kane << endl;
    i++;
    //if(kane < x*0.9) continue;
    ans = kane;
    if(kane >= x) break;
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 3740
#include<stdio.h>
int main()
{int H,W,i,j,k;
for(i=0;;i++){
scanf("%d%d",&H,&W);
if(H!=0&&W!=0){
for(j=0;j<H;j++){
for(k=0;k<W;k++){
if(j==0||j==(H-1))        
putchar('#');
else{
putchar('#');
for(k=1;k<(W-1);k++){
putchar('.');}
putchar('#');}}
putchar('\n');}
putchar('\n');}
else return 0;}}

Measured memory_bytes: 572
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String w = sc.next();
        int[] c = new int[26];
        int i;
        for(i=0;i<26;i++){
            c[i]=0;
        }
        for(i=0;i<w.length();i++)
            c[(int)w.charAt(i)-97]++;
        for(i=0;i<26;i++){
            if(c[i]%2!=0){
                System.out.println("No");
                break;
            }
        }
        if(i==26) System.out.println("Yes");
    }
}


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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;
	bool f=true;
	cin>>s>>t;
	for(int i=0;i<s.length();i++){
		if(s.substr(i,1)!=t.substr(i,1)) f=false;
	}
	if(f){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long sum =0;
		int K = sc.nextInt();
		Main main = new Main();
		for (int i=1;i<=K;i++) {
			for (int j=1;j<=K;j++) {
				for (int k=1;k<=K;k++) {
					int gcd= main.gcd(i, j);
					gcd =main.gcd(gcd, k);
					sum +=gcd;
				}
			}
		}
		System.out.println(sum);
  	}

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

	}
}

Measured memory_bytes: 35868
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int N; cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }
    sort(d.begin(),d.end());
    int cnt = N;
    for(int i = 0; i < N - 1; i++)
    {
        if(d.at(i) == d.at(i+1))
        {
            cnt--;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = list(input())

if S[K-1] == "A":
    S[K-1] = "a"
elif S[K-1] == "B":
    S[K-1] = "b"
else:
    S[K-1] = "c"

for i in range(N):
    print(S[i], end="")

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PI  3.14159265358979323846

ll gcd(ll a,ll b)
{
    if(a==0)
        return b;
    else
        return gcd(b%a,a);
}
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll res=fast(n/2,a,m)%m;
        if(n%2==0)
            return (((res%m)*(res%m))%m);
        else
            return (((((res%m)*a)%m)*res)%m);
    }
}
ll lcm(ll x,ll y)
{
    ll P=x*y;
    P/=gcd(x,y);
    return P;
}
int main()
{
  ll n,m;
  cin>>n>>m;
  if(m==0)
  {
      cout<<0<<" "<<0;
  }
  else
  {
     ll p[m];
     string S;
     vector<string> v;
     ll i;
     for(i=0;i<m;i++)
     {
         cin>>p[i]>>S;
         v.push_back(S);
     }
     ll b[n+1]={0};
     for(i=0;i<m;i++)
     {
         if(v[i]=="AC")
         {
             b[p[i]]++;
         }
     }
     ll ans=0,cnt=0;
     for(i=1;i<=n;i++)
     {
         if(b[i]>=1)
         {

             ans++;
         }
     }
     ll res[n+1]={0};
     for(i=0;i<m;i++)
     {
         if(v[i]=="WA"&&res[p[i]]==0&&b[p[i]]>=1)
         {
           cnt++;
         }
         else if(v[i]=="AC")
         {
             res[p[i]]=1;
         }
     }

     cout<<ans<<" "<<cnt;

  }

}




Measured memory_bytes: 8052
#include <stdio.h>
#include <math.h>

int main( void ) {
	int i, e, ee, cbrte, sqrtee, x, y, z, min;

	while ( scanf( "%d", &e ), e ) {
		min = e;

		cbrte = pow( e, 1.0 / 3 ) + 0.0000000001;
		for ( z = 0; z <= cbrte; z++ ) {
			ee = e - z * z * z;
			sqrtee = sqrt( ee );
			for ( y = 0; y <= sqrtee; y++ ) {
				x = ee - y * y;

				if ( x + y + z < min )
					min = x + y + z;
			}
		}

		printf( "%d\n", min );
	}

	return 0;
}

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

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

llt factdp[N];
llt fact(llt x)
{
  if(x == 0) return 1;
  if(x == 1) return 1;
  if(factdp[x] != -1) return factdp[x];
  return factdp[x] = (x*fact(x-1))%M;
}

llt ans = 0;
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     llt x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += x;
     return;
}

llt convertstrtob(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}
llt n, s;
void check(llt b)
{
  if(b < 2) return;
  llt sum = 0;
  llt t = n;
  while(t > 0)
  {
    sum += (t%b);
    t /= b;
  }
  if(s == sum)
  {
    cout<<b<<endl;
    exit(0);
  }
}

int main()
{

  cin>>n>>s;
  if(s > n)
  {
    cout<<"-1"<<endl;
    return 0;
  }
  if(n == s)
  {
    cout<<n+1<<endl;
    return 0;
  }

  for(int b=2; b*b <= (n+n); b++)
  {
    check(b);
  }

  vector<llt> fct;
  llt x = n -s;
  for(llt i = 1; i*i <= x; i++)
  {
    if(x%i == 0)
    {
      fct.pb(i);
      fct.pb(x / i);
    }
  }
  sort(fct.begin(), fct.end());
  for(llt i: fct)
  {
    check(i+1);
  }
  check(n);
  check(n + 1);
  cout<<"-1"<<endl;
  return 0;
}


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

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians, log10
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul, xor
from copy import copy, deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits
from datetime import date

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
A=LIST()
B=LIST()

cnt1=cnt2=0
for i in range(N):
    if A[i]>B[i]:
        # Bのが少ない合計*2(この分Aのどっかに足さないといけない)
        cnt1+=(A[i]-B[i])*2
    elif A[i]<B[i]:
        # Aのが少ない合計(この分で上記cnt1を受けきれるかどうか)
        # (こっちの合計が多い分には、同じ所でひたすら操作すれば帳尻が合うのでOK)
        # (同じ場所に2ないと意味ないので、1余る部分は数えない)
        cnt2+=(B[i]-A[i])-(B[i]-A[i])%2
if cnt1<=cnt2:
    Yes()
else:
    No()


Measured memory_bytes: 6908
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        for (int i = 0 ; i <= 1000 ; i++) {
            if (String.valueOf(i * i).equals(String.valueOf(a) +  String.valueOf(b))) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");
    }

}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S;
  cin >> S;
  bool hantei = false;
  //bool hantei2 = false;
  
  if ( S.at(0) == S.at(1) && S.at(2) == S.at(3) ) hantei = true;
  if ( S.at(0) == S.at(2) && S.at(1) == S.at(3)) hantei = true;
  if ( S.at(0) == S.at(3) && S.at(1) == S.at(2)) hantei = true;
  if ( S.at(0) == S.at(3) && S.at(1) == S.at(2)) hantei = true;
  if ( S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) == S.at(1)) hantei = false;
  
    
  //if ( S.at(0) == S.at(1) ) hantei2 = true;
  //if ( S.at(0) == S.at(2) ) hantei2 = true;
  //if ( S.at(0) == S.at(3) ) hantei2 = true;
  //if ( S.at(1) == S.at(3) ) hantei2 = true;
  //if ( S.at(2) == S.at(3) ) hantei2 = true;
  
  //if (( S.at(2) == S.at(3) ) hantei2 = true;)
  
  if( hantei ) cout << "Yes" << endl; 
  else cout << "No" << endl;
  
}

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

int main(void){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<vector<int> > dp(n+1, vector<int>(n+1));
    int ans=0;
    for(int i=1;i<n;i++){
        if(s[i]==s[0]) dp[0][i]=1;
        ans=max(ans, dp[0][i]);
    }
    rep(i, n-1){
        for(int j=i+1;j<n-1;j++){
            //cout<<dp[i][j]<<" "<<i<<" "<<j<<endl;
            if(s[i+1]==s[j+1]) {
                dp[i+1][j+1]=dp[i][j]+1;
                if(j+1-dp[i+1][j+1]+1<=i+1){
                    dp[i+1][j+1]=1;
                }
            }
            else {
                dp[i+1][j+1]=0;
            }   
            ans=max(ans, dp[i+1][j+1]);
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int dp[101][100001];


long long maxValue(int val[], int weight[], int capacity, int n)
{
	if(n<0)
		return 0;

	if(dp[n][capacity]!=-1)
	{
		return dp[n][capacity];
	}

	if(capacity-weight[n]<0)
		return dp[n][capacity] = maxValue(val, weight, capacity,n-1);

	return dp[n][capacity] = max( maxValue(val, weight, capacity,n-1), val[n] + maxValue(val, weight, capacity-weight[n], n-1));
}



int32_t main()
{
	int N,W;
	cin >> N >> W;
	vector<int> w,v;

	for(int i=0; i<101; i++)
	{
		for(int j=0; j< 100001; j++)
		{
			dp[i][j]=-1;	
		}
	}
	int val[N];
	int weight[N];

	for(int i=0;i<N;i++)
	{
		cin >> weight[i] >> val[i];
	}
	cout << maxValue(val,weight,W,N-1);
	
	return 0;
}

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

typedef long long LL;
LL n;

int check(LL p)
{
	LL m=n;
	while(m%p==0) m/=p;
	return m%p==1;
}

int main()
{
	
	cin>>n;
	if(n==2)
	{
		cout<<1<<endl;
		return 0;
	}
	int ans=2;
	for(LL i=2;i*i<=n;i++)
	{
		if(n%i) continue;
		ans+=check(i);
		if(i*i!=n) ans+=check(n/i);
	}
	n--;
	for(LL i=2;i*i<=n;i++)
	{
		if(n%i) continue;
		ans+=2;
		if(i*i==n) ans--;
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 998244353;

const int64 infll = (1LL << 60) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > A(N);
  cin >> A;
  vector< int > mx(A);
  sort(mx.rbegin(), mx.rend());
  for(int i = 0; i < N; i++) {
    cout << mx[mx[0] == A[i]] << endl;
  }
}







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

int main(){
	int a,b,c;
	cin>>a>>b>>c;
	int num=0;
	if(a==b) num++;
	if(a==c) num++;
	if(b==c) num++;
	if(num==1) cout<<"Yes\n";
	else cout<<"No\n";
} 

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

char ht[1<<25] = {};
char key[256];

int hashstr(char *str)
{
	int h = 1;
	while(*str) {
		h = (h<<2) + key[*str++];
	}
	return h;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, i, h;
	char com[8], str[13];
	key['A']=0, key['C']=1, key['G']=2, key['T']=3; 
	cin >> n;


	for (i=0; i<n; i++) {
		cin >> com >> str;
		h = hashstr(str);
		if(com[0] == 'i') {
			ht[h] = 1;
		} else {
			if (ht[h] == 1) {
				cout << "yes\n";
			} else {
				cout << "no\n";
			}
		}
	}

	return 0;
}


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

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
//const int MOD = (int) 1e9 + 7;
const int MOD = (int) 998244353;
const int maxn = (int) 2e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

int x, y;
int n, m, k;
int a[maxn], b[maxn], c[maxn];

priority_queue<pair<int, int> > Q;

void work()
{
    read(x); read(y);
    read(n); read(m); read(k);
    for(int i = 0; i < n; i++)
    {
        int x; read(x);
        Q.push(mk(x, 0));
    }
    for(int i = 0; i < m; i++)
    {
        int x; read(x);
        Q.push(mk(x, 1));
    }
    for(int i = 0; i < k; i++)
    {
        int x; read(x);
        Q.push(mk(x, 2));
    }

    LL ans = 0;
    int cnt[3] = {0};
    while(!Q.empty())
    {
        pair<int, int> t = Q.top();
        Q.pop();

        int val = t.fi, type = t.se;

        if(type == 0)
        {
            if(cnt[0] == x || cnt[0] + cnt[1] + cnt[2] == x + y) continue;
            ans += val;
            cnt[type]++;
        }
        if(type == 1)
        {
            if(cnt[1] == y || cnt[0] + cnt[1] + cnt[2] == x + y) continue;
            ans += val;
            cnt[type]++;
        }
        if(type == 2)
        {
            if(cnt[0] + cnt[1] + cnt[2] == x + y) continue;
            ans += val;
            cnt[type]++;
        }

//        cout <<ans <<" " <<val <<" " <<type <<endl;
    }

    cout <<ans <<endl;
}




int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
//    pre();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 6384
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
const int INF = 1 << 20;

typedef long long ll;




int main(){
  int a,b;
  cin >> a >> b;
  int sum = 0;
  for(int i = a;i <= b;i++){
    int t[5];
    int r = i;
    REP(j,5){
      t[j] = r%10;
      r /= 10;
    }
    if((t[0] == t[4]) && (t[1] == t[3]))
      sum++;
  }
  cout << sum << endl;
  return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    ll A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];

    ll ans = 0;
    for (int i=N-1; i>=0; i--) {
        if ((A[i] + ans)%B[i] != 0) {
            ans += B[i] - (A[i] + ans) % B[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

#define MAX 100

int main(void)
{
    int i = 0, j = 0;

    int data[MAX];
    while (scanf("%d", &data[i]) != EOF) {
        i++;
    }
    int data_num = i;

    int cnt[101] = {0};
    int datum;
    for (i = 0; i < data_num; i++) {
        datum = data[i];
        cnt[datum]++;
    }

    int mode = 0;
    for (i = 0; i < data_num; i++) {
        if (cnt[i] > mode) {
            mode = cnt[i];
        }
    }

    int mode_list[101];
    for (i = 1; i < data_num; i++) {
        if (cnt[i] == mode) {
            mode_list[j++] = i;
        }
    }
    int mode_num = j;

    for (i = 0; i < mode_num; i++) {
        printf("%d\n", mode_list[i]);
    }

    return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#define MAXN 100000
using namespace std;
typedef pair<int,int> PII;
vector<PII> seq;
int n,a[MAXN+5],opt[MAXN+5];
PII tmp0[MAXN+5],tmp1[MAXN+5];
int Solve(int l,int r,int z)
{
	if(l==r)
		return a[l];
	if(z==-1)	opt[l]=-opt[l];
	if(opt[l]==1)
	{
		int ret=Solve(l+1,r,-z);
		seq.push_back(PII(a[l],ret));
		return a[l]-ret;
	}
	else
	{
		int ret=Solve(l+1,r,z);
		seq.push_back(PII(ret,a[l]));
		return ret-a[l];
	}
}
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	int cnt0=0,cnt1=0;
	for(int i=1;i<=n;i++)
		if(a[i]<0)	opt[i]=-1,tmp0[++cnt0]=PII(opt[i],a[i]);
		else		opt[i]=1,tmp1[++cnt1]=PII(opt[i],a[i]);
	if(cnt0==n)
	{
		sort(a+1,a+1+n);
		cnt0=cnt1=0;
		for(int i=1;i<=n;i++)
		if(a[i]<0)	opt[i]=-1,tmp0[++cnt0]=PII(opt[i],a[i]);
		else		opt[i]=1,tmp1[++cnt1]=PII(opt[i],a[i]);
		tmp1[++cnt1]=tmp0[cnt0--],tmp1[cnt1].first=1;
	}
	if(cnt1==n)
	{
		sort(a+1,a+1+n,cmp);
		cnt0=cnt1=0;
		for(int i=1;i<=n;i++)
		if(a[i]<0)	opt[i]=-1,tmp0[++cnt0]=PII(opt[i],a[i]);
		else		opt[i]=1,tmp1[++cnt1]=PII(opt[i],a[i]);
		tmp0[++cnt0]=tmp1[cnt1--],tmp0[cnt0].first=-1;
	}
	
	int p=1,typ=0;
	while(cnt0>cnt1)
		a[p]=tmp0[cnt0].second,opt[p++]=tmp0[cnt0--].first,typ=0;
	while(cnt1>cnt0)
		a[p]=tmp1[cnt1].second,opt[p++]=tmp1[cnt1--].first,typ=1;
	for(;p<=n;p++)
		if(typ==0)
			a[p]=tmp1[cnt1].second,opt[p]=tmp1[cnt1--].first,typ=1;
		else
			a[p]=tmp0[cnt0].second,opt[p]=tmp0[cnt0--].first,typ=0;
	int ans=0;
	for(int i=1;i<=n;i++)
		if(opt[i]==-1)	ans-=a[i];
		else			ans+=a[i];
	//for(int i=1;i<=n;i++)
		//printf("opt[%d]:%d\n",i,opt[i]);
	printf("%d\n",ans);
	Solve(1,n,1);
	for(int i=0;i<(int)seq.size();i++)
		printf("%d %d\n",seq[i].first,seq[i].second);
	return 0;
}

Measured memory_bytes: 9076
#include <bits/stdc++.h> 
using namespace std; 
  
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
int n;
cin>>n;
vector<int> v(n+1);
for(int x=1;x<=100;x++){
	for(int y=1;y<=100;y++){
		for(int z=1;z<=100;z++){
			if(x*x+y*y+z*z+x*y+y*z+x*z<=n){
				v[x*x+y*y+z*z+x*y+y*z+x*z]++;
			}
		}
	}
}
for(int i=1;i<=n;i++){
	cout<<v[i]<<endl;
}




	return 0;
}

Measured memory_bytes: 3612
N, x = map(int, input().split())
a_list = list(map(int, input().split()))
 
a_list.sort()
sum_num = 0
for i in range(N):
    item = a_list[i]
    if x >= item:
        if i != N-1:
            sum_num += 1
            x -= item
        elif x == item:
            sum_num += 1
            x -= item
    else:
       break
print(sum_num)


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

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int v[100];
int w[100] = { 0 };
int d[100][10001] = { 0 };

int main()
{
	int N, W;

	cin >> N >> W;
	rep(i, N) cin >> v[i] >> w[i];

	rep(i, N) {
		rep(j, W + 1) {
			if (i == 0) {
				if (j >= w[i]) d[i][j] = v[i];
				continue;
			}

			if (j >= w[i]) d[i][j] = max(d[i - 1][j], v[i] + d[i - 1][j - w[i]]);
			else d[i][j] = d[i - 1][j];
		}
	}

	cout << d[N - 1][W] << endl;

	return 0;
}


Measured memory_bytes: 7020
//### In The Name Of GOD ###

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())

const int MOD = 1000000007;
const int INF = 30 * 1000 + 20;
const int MAXN = 401;
const int MLOG = 18;
const int NMAX = 60;

signed main(){
  int q;
  cin >> q;
  while(q--){
    int a, b;
    cin >> a >> b;
    int t = (ll)sqrt(a*b);
    int ans = 0;
    if( t * (t + 1) < a * b ){
      ans = 2 * t - 1;
    }else if(t*t == a*b){
        if(a == b)
          ans = t * 2 - 2;
        else
          ans = t * 2 - 3;
    }else
      ans = 2 * t - 2;
    cout << ans << endl;
  }
}


Measured memory_bytes: 256
// 2018/12/25 Tazoe

#include <iostream>
using namespace std;

int main()
{
	int N, M, D;
	cin >> N >> M >> D;

	int yoko[101][101] = { {0} };
	int tate[101][101] = { {0} };

	for(int y=1; y<=N; y++){
		for(int x=1; x<=M; x++){
			char c;
			cin >> c;

			if(c=='#'){
				yoko[y][x] = tate[y][x] = 0;
			}
			else{
				yoko[y][x] = yoko[y][x-1]+1;
				tate[y][x] = tate[y-1][x]+1;
			}
		}
	}

	int cnt = 0;

	for(int y=1; y<=N; y++){
		for(int x=1; x<=M; x++){
			if(yoko[y][x]>=D){
				cnt++;
			}
			if(tate[y][x]>=D){
				cnt++;
			}
		}
	}

	cout << cnt << endl;

	return 0;
}



Measured memory_bytes: 3152
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        long p=1000000007;
        long k=0+sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++)a[i]=sc.nextInt();
        long ans=sort(a)%p;
        int b[]=new int[2*n];
        for(int i=0;i<2*n;i++)b[i]=a[i%n];
        long ans2=sort(b)%p;
        long kk=((k*(k-1))/2)%p;
        System.out.println(((k*ans)%p+((ans2)*kk)%p)%p);
    }
    public static long sort(int[] array) {
        long ans=0;
        for (int i = 0; i < array.length - 1; i++) {
            for (int j = array.length - 1; j > i; j--) {
                if (array[j - 1] > array[j]) {
                    ans++;
                    int tmp = array[j - 1];
                    array[j - 1] = array[j];
                    array[j] = tmp;
                }
             }
        }
        return ans;
    }
}


Measured memory_bytes: 25956
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
using namespace std;
typedef pair<double,double> P;
int b[19][19];


int main(){
	
	int dx[]={1,-1,-4,4};
	
	string s="01234567";
	
	queue<string> que;
	map<string,int> ans;
	que.push(s);
	ans[s]=0;
	
	while(que.size()){
		string q=que.front();
		que.pop();
		int x=q.find("0");
		for(int i=0;i<4;i++){
			int next = x+dx[i];
			if(next>=0&&next<=7&&!(x==3&&next==4)&&!(x==4&&next==3)){
				string nextq = q;
				swap(nextq[x],nextq[next]);
				if(ans.find(nextq)==ans.end()){
					que.push(nextq);
					ans[nextq]=ans[q]+1;
				}
			}
		}
	}
	
	string input="";
	while(getline(cin,input)){
		input.erase(remove(input.begin(),input.end(),' '),input.end());
		cout<<ans[input]<<endl;
	}
}

Measured memory_bytes: 5236
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
 string S;
  cin>>S;

  ll count=0;
  for(auto x:S) {
    count+=x-'0';
  }
  if(count%9==0) {
cout<<"Yes"<<endl;
  }
  else {
cout<<"No"<<endl;
  }
}


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

pair<int, int> rotate(pair<int, int> v, int mode) {
    int x = v.first;
    int y = v.second;
    if (mode == 0) return {x, y};
    if (mode == 1) return {-y, x};
    if (mode == 2) return {-x, -y};
    if (mode == 3) return {y, -x};
}

vector<int> solve(int N) {
    vector<int> ret;
    vector<vector<pair<int, int>>> v(N);
    for (int i = 0; i < N; i++) {
        int k; cin >> k;
        for (int j = 0; j < k; j++) {
            int x, y; cin >> x >> y;
            v[i].push_back({x, y});
        }
    }
    
    vector<vector<pair<int, int>>> dv(N);
    vector<vector<pair<int, int>>> rev(N);
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < v[i].size(); j++) {
            dv[i].push_back({v[i][j].first - v[i][0].first, v[i][j].second - v[i][0].second});
        }
        for (int j = v[i].size() - 2; j >= 0; j--) {
            rev[i].push_back({v[i][j].first - v[i][v[i].size() - 1].first, v[i][j].second - v[i][v[i].size() - 1].second});
        }
    }
    
    for (int i = 1; i < N; i++) {
        if (dv[0].size() != dv[i].size()) continue;
        bool flag = 1;
        int mode = -1;
        for (int j = 0; j < dv[i].size(); j++) {
            int tmp = -1;
            for (int k = 0; k < 4; k++) {
                if (dv[0][j] == rotate(dv[i][j], k)) {
                    tmp = k;
                    break;
                }
            }
            if (j == 0) mode = tmp;
            if (tmp == -1) flag = 0;
            else if (tmp != mode) flag = 0;
            if (!flag) break;
        }
        if (flag) {
            ret.push_back(i);
            continue;
        }
        flag = 1;
        for (int j = 0; j < rev[i].size(); j++) {
            int tmp = -1;
            for (int k = 0; k < 4; k++) {
                if (dv[0][j] == rotate(rev[i][j], k)) {
                    tmp = k;
                    break;
                }
            }
            if (j == 0) mode = tmp;
            if (tmp == -1) flag = 0;
            else if (tmp != mode) flag = 0;
            if (!flag) break;
        }
        if (flag) {
            ret.push_back(i);
        }
    }
    return ret;
}

int main(void){
    // Your code here!
    int N, M;
    vector<vector<int>> ans;
    while (1) {
        cin >> N;
        if (!N) break;
        N++;
        ans.push_back(solve(N));
    }
    for (auto &i : ans) {
        for (auto &j : i) {
            cout << j << endl;
        }
        cout << "+++++" << endl;
    }
}



Measured memory_bytes: 3184
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,m,f[1005][1005];
char s[1005][1005];
int main()
{
	memset(f,0x3f,sizeof(f));
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	f[1][1]=0;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(i>1) f[i][j]=min(f[i][j],f[i-1][j]+(s[i][j]!=s[i-1][j]));
			if(j>1) f[i][j]=min(f[i][j],f[i][j-1]+(s[i][j]!=s[i][j-1]));
		}
	int ans=(s[1][1]=='#')+(s[n][m]=='#')+f[n][m];
	printf("%d",ans/2);
	return 0;
} 

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b,c;
    int hap[100001][3];
    cin >> n;
    for(int i=0;i<3;i++){
        cin >> hap[0][i];
    }
    for(int i=1;i<n;i++){
        cin >> a >> b >> c;
        hap[i][0]=max(hap[i-1][1]+a,hap[i-1][2]+a);
        hap[i][1]=max(hap[i-1][0]+b,hap[i-1][2]+b);
        hap[i][2]=max(hap[i-1][0]+c,hap[i-1][1]+c);
    }
    cout << max(hap[n-1][0],max(hap[n-1][1],hap[n-1][2])) << endl;
    return 0;
}

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

#define PI acos(-1.0)
#define nl '\n'

typedef long long int ll;
typedef unsigned long long int  llu;
const int mod = 1e9+7;

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

    ll n,i,j,k;
    cin>>n>>k;
    ll sum[n+5]= {0};
    ll a[n+5];
    for(i=1; i<=n+1; i++)
    {
        a[i]=i;
        sum[i]=sum[i-1]+a[i];
    }
    ll ans=0;
    for(i=k; i<=n+1; i++)
    {
        ll x=sum[i];
        ll y=sum[n+1]-sum[n+1-i];
        ans=ans+(y-x+1)%mod;
        ans=ans%mod;
    }
    cout<<ans<<nl;
    return 0;
}

Measured memory_bytes: 6764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Queue;
import java.util.StringTokenizer;

public class Main {
	
	
	static int[] di = {0, 0, 1, -1};
	static int[] dj = {1, -1, 0, 0};
	
	static int N;
	static boolean[][] left;
	static int[][] dist;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		N = sc.nextInt();
		left = new boolean[N][N];
		dist = new int[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				dist[i][j] = Math.min(Math.min(i, N - 1 - i), Math.min(j, N - 1 - j));
			}
		}
		
		int ans = 0;
		for (int idx = 0; idx < N * N; idx++) {
			int tmp = sc.nextInt() - 1;
			int iPos = tmp / N;
			int jPos = tmp % N;
			
			ans += dist[iPos][jPos];
			left[iPos][jPos] = true;
			Deque<Integer> queue = new ArrayDeque<>();
			queue.addLast(iPos * N + jPos);
			while (!queue.isEmpty()) {
				Integer val = queue.pollFirst();
				int ii = val / N;
				int jj = val % N;
				for (int k = 0; k < 4; k++) {
					int ni = ii + di[k];
					int nj = jj + dj[k];
					int nDist = dist[ii][jj] + (left[ii][jj] ? 0 : 1);
					if (0 <= ni && ni < N && 0 <= nj && nj < N && nDist < dist[ni][nj]) {
						dist[ni][nj] = nDist;
						if (left[ii][jj]) {
							queue.addFirst(ni * N + nj);
						} else {
							queue.addLast(ni * N + nj);
						}
					}
				}
			}
			
		}
		
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 63300
import java.util.Scanner;

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

        int max = 0;
        for (int i = 0; i < n-1; i++) {
            int count = 0;
            for (int j = 0; j < 26; j++) {
                String str1 = s.substring(0, i+1);
                String str2 = s.substring(i+1, n);
                if (str1.contains(String.valueOf((char)('a'+j))) && str2.contains(String.valueOf((char)('a'+j)))) {
                    count++;
                }
            }
            max = Math.max(max, count);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 23892
// atcoder/abc138/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);


  int a;
  string s;
  while (cin >> a >> s) {
    cout << (3200 <= a ? s : string("red")) << endl;
  }
  return 0;
}


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

using namespace std;

#define ll long long
#define INF 2000000000
#define LINF 9000000000000000000
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define dum(x) cout<<#x<<'='<<x<<endl
#define dum2(x,y) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<'\n'<<endl
#define dum3(x,y,z) cout<<#x<<'='<<x<<' '<<#y<<'='<<y<<' '<<#z<<'='<<z<<'\n'<<endl
#define darr(arr,n) rep(i,(n-arr)){cout<<*(arr+i)<<' ';}cout<<endl
#define ddarr(arr,a,b) rep(i,a){rep(j,b){cout<<*(arr+i*b+j)<<' ';}cout<<endl;}
#define ddd ifstream in("Text.txt");cin.rdbuf(in.rdbuf());


int main() {
    int N;
    cin >> N;
    int Nc = N;
    int Scou = 0;
    while (N > 0) {
        Scou += N % 10;
        N /= 10;
    }
    if (Nc%Scou == 0)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
a = input()
b = input()

ans = "EQUAL"
if len(a) > len(b):
    ans = "GREATER"
elif len(a) < len(b):
    ans = "LESS"
else:
    for i in range(len(a)):
        if a[i] != b[i]:
            if a[i] > b[i]:
                ans = 'GREATER'
                break
            else:
                ans = 'LESS'
                break

print(ans)


Measured memory_bytes: 3060
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<vector>
#include<queue>
#include<string.h>
using namespace std;
int main(){
 char t[200001];
 scanf("%s",t);
 int len=strlen(t);
 int i;
 for(i=0;i<len;i++){
  if(t[i]=='?')t[i]='D';
 }
 printf("%s\n",t);
return 0;}

Measured memory_bytes: 3836
package main

import (
	"bufio"
	"fmt"
	"io"
	"math/big"
	"os"
	"strconv"
)

func main() {
	sc := NewBufScanner(os.Stdin)
	n := int(sc.Int())
	sum := big.NewInt(1)

	upper := big.NewInt(1e18)
	as := make([]int64, n)
	for i := 0; i < n; i++ {
		as[i] = sc.Int()
		if as[i]== 0 {
			fmt.Println(0)
			return
		}
	}
	for i, v := range  as {
		if i == 0 {
			sum = big.NewInt(v)
			continue
		}
		sum.Mul(sum, big.NewInt(v))
		if sum.Cmp(upper) >0 {
			fmt.Println("-1")
			return
		}
	}
	fmt.Println(sum.Int64())
}

type BufScanner struct {
	*bufio.Scanner
}

func NewBufScanner(r io.Reader) *BufScanner {
	s := bufio.NewScanner(r)
	s.Split(bufio.ScanWords)
	// s.Split(scanWords)
	return &BufScanner{s}
}

func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i+1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}

func (s *BufScanner) String() string {
	s.Scan()
	return s.Text()
}

func (s *BufScanner) Int() int64 {
	return int64(s.UInt())
}


func (s *BufScanner) UInt() uint64 {
	s.Scan()
	i, e := strconv.ParseUint(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 5924
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int R;cin>>R;
  cout <<(R<1200? "ABC":R<2800? "ARC":"AGC")<<endl;
  return 0;
}


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

struct data{
  int p,t;
  data(int p=0, int t=0):p(p),t(t){}
  bool operator < (const data &d) const {
    return t < d.t;
  }
};

const int INF = 1 << 29;
int n;
data v[40];

void solve(){
  int dp[41][4], ans = INF;
  fill(dp[0],dp[n],INF);

  if(v[0].p > v[0].t){
    cout << "NG 1" << endl;
    return;
  } else if(n == 1){
    cout << "OK " << v[0].p*2 << endl;
    return;
  }

  dp[0][1] = v[0].p;
  for(int i=0;i<n-1;i++){
    bool f = false;
    for(int j=1;j<=3;j++){
      if(j < 3){
        if(abs(v[i+1].p-v[i].p)*(j+1) <= v[i+1].t-v[i].t && dp[i+1][j+1] > dp[i][j]+abs(v[i+1].p-v[i].p)){
          dp[i+1][j+1] = dp[i][j] + abs(v[i+1].p-v[i].p);
          f = true;
        }
      }
      if(v[i].p*(j+1) + v[i+1].p <= v[i+1].t-v[i].t && dp[i+1][1] > dp[i][j] + v[i+1].p+v[i].p){
        dp[i+1][1] = dp[i][j] + v[i+1].p+v[i].p;
        f = true;
      }
    }
    if(!f){
      cout << "NG " << i+2 << endl;
      return;
    }
  }

  for(int i=1;i<4;i++) ans = min(ans,dp[n-1][i]+v[n-1].p);
  cout << "OK " << ans << endl;
  assert(ans < INF);
}

int main(){
  while(cin >> n && n){
    for(int i=0;i<n;i++) cin >> v[i].p >> v[i].t;
    sort(v,v+n);
    solve();
  }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
  
#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,-1,1,-1};
const int dy[]={0,1,0,-1,1,1,-1,-1};
lol n,m,k,r,q;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  vector<int> a(n+1,0);
  for(int i=0;i<n;i++) cin >>a[i];
  sort(a.begin(),a.end()-1);
  lol ma=a[n-1];
  vector<int> dp(ma+1,0);
  lol ans=0;
  for(int i=0;i<n;i++){
    if(dp[a[i]]==0){
      
      if(a[i]!=a[i+1]) ans++;
      for(int j=a[i];j<=ma;j+=a[i]) dp[j]++;
    }
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
#include<unordered_map>	
#include<unordered_set>
#define pb emplace_back
#define rt(v) return cout<<v,0
#define sz(v) (int)(v.size())
#define all(a) a.begin(),a.end()
#define endl '\n'
#define space " "
typedef long long ll;
typedef unsigned long long ull;
const int N = 10 + 1e5;
const int mod = 1e9 + 7;
/*

███╗   ███╗███████╗███╗   ███╗███████╗    ██╗      ██████╗ ██████╗ ██████╗
████╗ ████║██╔════╝████╗ ████║██╔════╝    ██║     ██╔═══██╗██╔══██╗██╔══██╗
██╔████╔██║█████╗  ██╔████╔██║█████╗      ██║     ██║   ██║██████╔╝██║  ██║
██║╚██╔╝██║██╔══╝  ██║╚██╔╝██║██╔══╝      ██║     ██║   ██║██╔══██╗██║  ██║
██║ ╚═╝ ██║███████╗██║ ╚═╝ ██║███████╗    ███████╗╚██████╔╝██║  ██║██████╔╝
╚═╝     ╚═╝╚══════╝╚═╝     ╚═╝╚══════╝    ╚══════╝ ╚═════╝ ╚═╝  ╚═╝╚═════╝

*/

using namespace std;
void Ferrari() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int main() {
	Ferrari();
	long long t, a, k; cin >> t >> a >> k;
	long long temp = t;
	t = max(1LL * 0, t - k);
	k = max(k - temp, 1LL * 0);
	a = max(1LL * 0, a - k);
	cout << t << " " << a;
	return 0;
}





/* stuff you should look for
	* keepin sharp mind.
	* int overflow, array bounds.
	* special cases (n=1?), set tle , make sure you understand the proble correctly.
	* don`t stuck in a problem.
	* test the idea on samples.
	*/

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 20 16:39:29 2018

@author: Yuya
"""



N, H = map(int, input().split())

A_max = 0
D_seq = []

for i in range(N):
    A, D = map(int, input().split())
    if A>A_max:
        A_max = A
    D_seq.append(D)

D_sum = 0
D_count = 0
D_seq.sort()
D_seq.reverse()

for i in range(N):
    if D_seq[i] > A_max and D_sum < H:
        D_sum += D_seq[i]
        D_count += 1

A_sum = H-D_sum

if A_sum > 0:
    if A_sum%A_max == 0:
        print(A_sum//A_max + D_count)
    else:
        print(A_sum//A_max + D_count+1)
else:
    print(D_count)


Measured memory_bytes: 7384
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	string s;
	cin >> s;
	if (c < d) {
		loop(i, a - 1, d - 3) {
			if (s[i + 1] == '#' && s[i + 2] == '#') { cout << "No" << endl; return 0; }
		}
		cout << "Yes" << endl;
	}
	else {
		loop(i, a - 1, d - 3) {
			if (s[i + 1] == '#' && s[i + 2] == '#') { cout << "No" << endl; return 0; }
		}
		loop(i, b, d + 1) {
			if (s[i] == '.' && s[i - 1] == '.' && s[i - 2] == '.') {cout << "Yes" << endl; return 0;}
		}
		cout << "No" << endl;
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#ifdef JLOCAL
#include "stress.h"
#endif
using namespace std;

#define rep(i, z, n) for (int i = (z); i < int(n); ++i)
#define repr(i, n, z) for (int i = int(n) - 1; i >= (z); --i)
#define shl(n) (1 << (n))
#define hbit(n, i) (((n) >> (i)) & 1)

#define STRESS 0
using lint = long long;
template <typename T> using vc = std::vector<T>;

void solve(istream& cin, ostream& cout) {
    int n;
    cin >> n;
    rep(i, 0, n) {
        string s;
        cin >> s;
        if (s == "Y") {
            cout << "Four";
            return;
        }
    }
    cout << "Three";
}

int main() {
#if !defined(JLOCAL) || !STRESS
#ifdef JLOCAL
    freopen("input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve(cin, cout);
#else
    srand();
    for (int ti = 0; ti < 100; ti++) {
        stress::gen();
        stress::stupid();
        ifstream in("input.txt");
        ofstream out("output.txt");
        solve(in, out);
        out.flush();
        stress::check();
    }
    cout << "ok" << endl;
#endif
    return 0;
}

Measured memory_bytes: 256