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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
double a[maxn];
void run_case()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    sort(a + 1, a + 1 + n);
    double ans = a[1];
    for (int i = 2; i <= n; i++)
    {
        ans = (ans + a[i]) / 2;
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

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

using namespace std;


int main(){
	
	while(1){
		int r,w,c,a;
		
		cin >>r>>w>>c>>a;
		
		if(r==0) break;
		
		for(int i=0;;i++){
			if(c*w<=r+a*i){
				cout << i << endl;
				break;
			}
		}
	}
	
	
	return 0;
}


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


struct num{
  int d[256];
  num(){ memset(d,0,sizeof(d)); }
  num(int flag){
    if( flag == -1 ) memset(d,-1,sizeof(d));
  }
};

num tas( num a,num b){
  num ret;
  for(int i=0;i<256;i++)
    for(int j=0;j<256;j++)
      if( a.d[i] == 1 && b.d[j] == 1 )
	ret.d[(i+j)%256] = 1;
  return ret;
}

num mina(num a,num b){
  num ret;
  for(int i=0;i<256;i++)
    for(int j=0;j<256;j++)
      if( a.d[i] == 1 && b.d[j] == 1 )
	ret.d[(i-j+256)%256] = 1;
  return ret;
}


num kake(num a,num b){
  num ret;
  for(int i=0;i<256;i++)
    for(int j=0;j<256;j++)
      if( a.d[i] == 1 && b.d[j] == 1 )
	ret.d[(i*j)%256] = 1;
  return ret;
}

num waru(num a,num b){
  num ret;
  for(int i=0;i<256;i++){
    for(int j=0;j<256;j++){
      if( a.d[i] == 1 && b.d[j] == 1 ){
	if( j == 0 ) return num(-1);
	ret.d[(i/j)%256] = 1;
      }
    }
  }
  return ret;
}


int M,N;
map<string,num> fie;

int main(){

  cin >> M;
  for(int i=0;i<M;i++){
    string name;
    int u,b;
    cin >> name >> u >> b;
    for(int i=u;i<=b;i++)
      fie[name].d[i] = 1;
  }

  cin >> N;
  stack<num> st;
  bool f = false;
  for(int i=0;i<N;i++){
    string s;
    cin >> s;
    if( s == "+" ) {
      num b = st.top(); st.pop();
      num a = st.top(); st.pop();
      st.push( tas(a,b) );
    } else if (  s== "-" ){
      num b = st.top(); st.pop();
      num a = st.top(); st.pop();
      st.push( mina(a,b) );
    } else if ( s=="/" ){
      num b = st.top(); st.pop();
      num a = st.top(); st.pop();
      num tmp = waru(a,b);
      if( tmp.d[0] == -1 ) f = true;
      st.push( tmp );      
    } else if ( s=="*" ){
      num b = st.top(); st.pop();
      num a = st.top(); st.pop();
      st.push( kake(a,b) );
    } else if ( '0' <= s[0] && s[0] <= '9' ){
      stringstream sin(s);
      int at;
      sin >> at;
      num tmp; tmp.d[at] = 1;
      st.push( tmp );
    } else {
      st.push( fie[s] );
    }
  }
 
  cout << (f?"error":"correct") << endl; 

}

Measured memory_bytes: 1304
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define all(v) v.begin(),v.end()
#define mem(arr) memset(arr, 0, sizeof(arr))
#define ff first
#define ss second
#define int long long int
const int MOD = 1e9 + 7;
const int INF = 1e18;
const int N = 1e6 + 20;
vector<int> g[N];
vector<int> vis(N);
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tc = 1;
    while(tc--){
        int n;
        cin >> n;
        set<string> st;
        for(int i = 1; i <= n; i++){
            string s;
            cin >> s;
            st.insert(s);
        }
        cout << (int)st.size() << '\n';
    }
}

Measured memory_bytes: 50096
import java.util.Scanner;

public class Main {
	  
	public static void main(String args[]) {
		    Scanner scanner = new Scanner(System.in);
		    
		   int N = scanner.nextInt();
		   System.out.println(800 * N - 200 * (N/15) );
		   
		    scanner.close(); }
		  }

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

using namespace std;

typedef long long ll;
const int maxn = 310;
const int mod = 998244353;

ll dp[2][maxn*maxn][2], ans = 1;
int n, sum;

void add(ll &x, ll y) { x += y; if(x >= mod) x -= mod; }

int main() {
    scanf("%d", &n);
    dp[0][0][0] = dp[0][0][1] = 1;
    int now=1, pre= 0;
    for (int x, i=1; i<=n; ++i) {
        scanf("%d", &x);
        sum += x;
        ans = ans*3%mod;

        for (int j=0; j<=sum; ++j) {
            dp[now][j][0] = dp[pre][j][0];
            dp[now][j][1] = dp[pre][j][1]*2%mod;
            if(j>=x) {
                add(dp[now][j][0], dp[pre][j-x][0]);
                add(dp[now][j][1], dp[pre][j-x][1]);
            }
        }

        swap(now, pre);
        memset(dp[now], 0, sizeof(dp[now]));
    }

    for (int i=(sum+1)/2; i<=sum; ++i) add(ans, mod-dp[pre][i][1]*3%mod);
    if(sum%2==0) add(ans, dp[pre][sum/2][0]*3%mod);
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3200
N = gets.to_i
x = 0
y = 0
t = 0
ans = 'Yes'
N.times do 
  u, a, b = gets.split(' ').map(&:to_i)
  d = (x - a).abs + (y - b).abs
  time = u - t
  if  d <= time && d % 2 == time % 2
    t, x, y = u, a, b
    next
  else
    ans = 'No'
    break
  end
end

puts ans

Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

typedef long long unsigned int ll;
typedef pair<ll, ll> P;

int main(){
	int N,M,C;
	cin >> N >> M >> C;
	int a,B[M];
	int res = 0;
	REP(i,M){
		cin >> B[i];
	}
	REP(i,N){
		int sum = 0;
		REP(j,M){
			cin >> a;
			sum += a*B[j];
		}
		if(sum > -C){
			res++;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
num, yen = map(int, input().split())

for i in range(num + 1):
    cal1 = yen
    if cal1 < 10000 * i:
        break
    else:
        cal1 -= 10000 * i
        
        for j in range(num + 1):
            cal2 = cal1
            if i + j > num:
                break
            elif cal2 < 5000 * j:
                break
            else:
                cal2 -= 5000 * j
                if cal2 % 1000 == 0:
                    z = cal2 // 1000
                    if i + j + z == num:
                        print(i, j, z)
                        exit()

print(-1, -1, -1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int N; 
long long A[110]; 
long long INF = 1145141919810364; 
struct edge{
	int to; 
	long long cap;
	int rev; 
}; 
vector<edge> E[110]; // 0がS, [1,N]が宝石, N+1がT
int level[110]; 
int iter[110]; 
void add_edge(int from, int to, long long cap){
	E[from].push_back((edge){to, cap, (int) E[to].size()}); 
	E[to].push_back((edge){from, 0, (int) E[from].size()-1}); 
}
void bfs(int s){
	fill(level, level + N+2, -1); 
	queue<int> que; 
	level[s] = 0; 
	que.push(s); 
	while(que.size()){
		int v = que.front(); que.pop(); 
		for(auto i : E[v]){
			edge &e = i; 
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v] + 1; 
				que.push(e.to); 
			}
		}
	}
}
long long dfs(int v, int t, long long f){
	if(v == t) return f; 
	for(int &i = iter[v]; i < (int) E[v].size(); i++){
		edge &e = E[v].at(i); 
		if(e.cap > 0 && level[v] < level[e.to]){
			long long d = dfs(e.to, t, min(f, e.cap)); 
			if(d > 0){
				e.cap -= d; 
				E[e.to].at(e.rev).cap += d; 
				return d; 
			}
		}
	}
	return 0; 
}
long long max_flow(int s, int t){
	long long flow = 0; 
	while(1){
		bfs(s); 
		if(level[t] < 0) return flow; 
		fill(iter, iter + N+2, 0); 
		long long f; 
		while((f = dfs(s, t, INF)) > 0){
			flow += f; 
		}
	}
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	cin >> N;
	long long mx = 0; 
	for(int i = 1; i <= N; i++){
		cin >> A[i];
		if(A[i] > 0) mx += A[i]; 
		if(A[i] >= 0){
			add_edge(0, i, A[i]); 
			add_edge(i, N+1, 0); 
		}else{
			add_edge(0, i, 0); 
			add_edge(i, N+1, -A[i]); 
		}
	}
	for(int i = 1; i <= N; i++){
		for(int j = i+1; j <= N; j++){
			if(j % i) continue; 
			add_edge(j, i, INF); 
		}
	}
	long long ans = max_flow(0, N+1); 
	cout << mx - ans << "\n"; 
}

Measured memory_bytes: 3696
#include <stdio.h>
#include <string.h>
#define lop(i, n) for(i=0; i<n; i++)

int main()
{
	int A, B, max=1, cnt=0;
    
    scanf("%d %d", &A, &B);
   
    while(max<B){
        max+=A-1;
        cnt++;
    }
	
    printf("%d", cnt);
    
return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { d, r, u, l , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D array to 1D array. (Zero-indexed)
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) {
	int r = n / nCol, c = n % nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

void inter(string s) {
	cout << s << endl;
	fflush(stdout);
}


int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin >> n;
	int num = (ll)floor(log(25 * (n + 1)) / log(26));
	string ans = "";
	for (int i = num - 1; i >= 0; i--) {
		n--;
		ans += ('a' + n % 26);
		n /= 26;
	}
	rev(ans);
	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 3864
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  int n;
  ll a[3001]={},lc=1,ans=0;
  vector<ll> v;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a[i];
    ans+=a[i]-1;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
def main():
    n, a, b = map(int, input().split())
    
    sum = 0
    for i in range(1, n+1):
        digit_sum = 0
        num = i
        while(num > 0):
            if num >= 1 and num <= 9:
                digit_sum += num
                num //= 10
            else:
                digit_sum += num % 10
                num //= 10

        if (digit_sum >= a) and (digit_sum <= b):
            sum += i

    print(sum)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#include <iostream>

int main(void){
    std::string S, T; std::cin >> S >> T;
    const int n = S.size(), m = T.size();
    int res = m;
    for(int i = 0; i + m <= n; ++i){
        int diff = 0;
        for(int j = 0; j < m; ++j) if(S[i + j] != T[j]) ++diff;
        if(diff < res) res = diff;
    }
    std::cout << res << '\n';
    return 0;
}

Measured memory_bytes: 3632
//AUTHOR: *Akash Shrivastva*
//Birla Institute of Technology,Mesra,India
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define M 1000000007
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define pll vector< pair <ll,ll> >
#define F first
#define S second
#define PII pair <ll,ll>

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
  
    ll r;cin>>r;cout<<r*r<<endl;
}

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

int main() {
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  
  for (int i = 0; i < vec.size(); i++) {
    if (vec.at(i) == 0) {
      cout << i + 1 << endl;
    }
  }
 }

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
using namespace std;
int n,m,sum1,sum2,a[110];
int main() {
	scanf("%d",&n);
	sum1=0;
	for(int i=0; i<n; i++) {
		scanf("%d",&a[i]);
		sum1+=a[i];
	}
	scanf("%d",&m);
	sum2=sum1;
	while(m--) {
		int p,x;
		scanf("%d%d",&p,&x);
		if(x>=a[p-1]) sum1+=x-a[p-1];
		else sum1-=a[p-1]-x;
		printf("%d\n",sum1);
		sum1=sum2;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

void maxHeapify(int *,int,int);
void buildMaxHeap(int *,int);

int main()
{
  int H,*A,i;
  
  scanf("%d",&H);

  A = (int *)malloc((H+1) * sizeof(int));

  for(i=1;i<H+1;i++){
    scanf("%d",&A[i]);
  }

  buildMaxHeap(A,H);

  for(i=1;i<H+1;i++){
    printf(" %d",A[i]);
    if(i==H) printf("\n");
  }

  free(A);
      
  return 0;
}

void buildMaxHeap(int *A,int H)
{
  int i;

  for(i=H/2;i>0;i--){
    maxHeapify(A,i,H);
  }
}

void maxHeapify(int *A,int i,int H)
{
  int l,r,largest,m;

  l = i*2;
  r = i*2+1;

  if(l<=H && A[l]>A[i]) largest = l;
  else largest = i;

  if(r<=H && A[r]>A[largest]) largest = r;

  if(largest!=i){
    m = A[i];
    A[i] = A[largest];
    A[largest] = m;
    maxHeapify(A,largest,H);
  }
}





Measured memory_bytes: 3400
#逆ポーランド記法(Reverse Polish Notation, RPN)
class RPN():
    def __init__(self):
        self.top = 0
        self.S = []
        self.MAX = 100

    def isEmpty(self):
        return self.top == 0

    def isFull(self):
        #return self.top >= self.MAX - 1
        return self.top >= self.MAX

    def push(self,x):
        if self.isFull():
            raise ValueError("オーバーフロー")
        self.top+=1
        self.S.append(x)

    def pop(self):
        if self.isEmpty():
            raise ValueError("アンダーフロー")
        self.top-=1
        #print("self.top:{}".format(self.top))
        #print("S:{}".format(self.S))
        return self.S.pop(self.top)


X = input().split(" ")
rpn = RPN()
for x in X:
    #print(x)
    if x.isnumeric():
        #print("num")
        rpn.push(x)
    else:
        #print("dig")
        num_2 =rpn.pop()
        num_1 =rpn.pop()
        res = eval(str(num_1) + x + str(num_2))
        rpn.push(res)

print(rpn.pop())


Measured memory_bytes: 5560
#include <iostream>
#include <string>
using namespace std;
int main() {
    int alen, blen;
    string a, b;
    cin >> a >> b;
    alen = a.length();
    blen = b.length();
    if (alen != blen) cout << (alen > blen ? "GREATER" : "LESS") << endl;
    else {
        for (int i = 0; i < alen; i++) {
            if (a[i] == b[i]) continue;
            cout << (a[i] > b[i] ? "GREATER" : "LESS") << endl;
            return 0;
        }
        cout << "EQUAL" << endl;
    }
}

Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from copy import deepcopy

INF = float('inf')


def LI(): return list(map(int, sys.stdin.readline().split()))


def I(): return int(sys.stdin.readline())


def LS(): return sys.stdin.readline().split()


def S(): return sys.stdin.readline().strip()


def IR(n): return [I() for i in range(n)]


def LIR(n): return [LI() for i in range(n)]


def SR(n): return [S() for i in range(n)]


def LSR(n): return [LS() for i in range(n)]


def SRL(n): return [list(S()) for i in range(n)]


def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


mod = 10 ** 9 + 7

n = S()
ret = 0
for i in n:
    ret += int(i)

if ret % 9:
    print("No")
else:
    print("Yes")


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

map<long long,int>prime_factor(long long n) {
  map<long long,int>res;
  for(long long i=2; i*i<=n; i++) {
    while(n%i==0) {
      ++res[i];
      n /= i;
    }
  }
  if(n!=1)res[n]=1;
  return res;
}

int main(void) {
  long long N, P;
  cin >> N >> P;
  map<long long,int> primes = prime_factor(P);
  long long ret = 1;
  for (auto it : primes) {
    // cerr << it.first << " " << it.second << endl;
    if (it.second >= N) {
      for (int i = 0; i < it.second / N; i++) {
        ret *= it.first;
      }
    }
  }
  cout << ret << endl;

  return 0;
}

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

using namespace std;
#define long long long

int const N = 1e5 + 10;

int n;
long h[N], f[N];

int main()
{
//    freopen("tam.inp", "r", stdin);
    cin.tie(nullptr); ios_base::sync_with_stdio(false);

    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> h[i];
    f[2] = abs(h[2] - h[1]);
    for (int i = 3; i <= n; ++i) f[i] = min(f[i - 1] + abs(h[i] - h[i - 1]), f[i - 2] + abs(h[i] - h[i - 2]));
    cout << f[n];

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#ifndef ONLINE_JUDGE
#include <custom/prettyprint.hpp>
#endif
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<db,db> pd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<db> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<pd> vpd;

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b) - 1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define rb(i,x) for (auto& i : x)
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define UNIQUE(x) (x).resize(unique(all(x)) - begin(x))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define pow10(n) stoll("1"+string(n,'0'))
#define dbg(x) cout << ">>> " << #x << ": " << x << '\n'

const int MOD = 1e9+7; //998244353
const int inf = 1e9+3;
const ll INF = ll(3e18)+3;
const ld PI = acos((ld)-1);
const int dx[8] = {1,0,-1,0,1,1,-1,-1}, dy[8] = {0,1,0,-1,-1,1,1,-1};
mt19937_64 rng((uint64_t)chrono::steady_clock::now().time_since_epoch().count());
ll rnd(ll n) { return uniform_int_distribution<ll>(0, n)(rng); }
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }
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);
    }
};
template <class T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 

void setIO(const string& s) {
	ios_base::sync_with_stdio(false); cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen((s+".in").c_str(),"r",stdin);
//	freopen((s+".out").c_str(),"w",stdout);
#endif
}

int main() {
    
    setIO("input");
    string s; cin >> s;
    int sum = 0;
    for(auto& i : s) {
        sum += i - '0';
    }
    cout << (sum % 9 ? "No" : "Yes") << '\n';
    
}

/*  ! CHECK THIS IF YOU GET IT WRONG !
	* int overflow, array bounds, NO VLAs
	* uninitialized local variables, rounding errors
	* intermediate result type, scientific
	* special cases (n = 0 or 1?)
	* reset your variables in scope
	* INF not large enough for ans, adding value to _MAX
	* using wrong variables, sorting extra 0s in global array
	* comment out input from file
	* operator precedence
*/

Measured memory_bytes: 3732
#include <iostream>
#include <vector>

using namespace std;

const int INF = INT32_MAX;

struct SegmentTree {
    vector<int> node;
    int n = 1;

    explicit SegmentTree(int sz) {
        while (n < sz) {
            n *= 2;
        }

        node.resize(2 * n - 1, INF);
    }

    void Update(int k, int a) {
        k += n - 1;
        node[k] = a;

        while (k > 0) {
            k = (k - 1) / 2;

            node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
        }
    }

    int GetMin(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) {
            r = n;
        }

        if (r <= a || b <= l) {
            return INF;
        }
        if (a <= l && r <= b) {
            return node[k];
        }

        int vl = GetMin(a, b, k * 2 + 1, l, (l + r) / 2);
        int vr = GetMin(a, b, k * 2 + 2, (l + r) / 2, r);
        return min(vl, vr);
    }

    int Node(int x) {
        return node[x + n - 1];
    }
};

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

    int n, q;
    cin >> n >> q;

    SegmentTree seg(n);

    while (q--) {
        int com, x, y;
        cin >> com >> x >> y;

        if (com == 0) {
            seg.Update(x, y);
        }
        else {
            cout << seg.GetMin(x, y + 1) << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 3760
#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
	long long int A, B, N;
	
	scanf("%ld %ld %ld", &A, &B, &N);
	
	long long int x;
	
	if(N>=B) x = B-1;
	else x = N;
	
	long long int S = A*x / B;
	
	printf("%ld", S);
	
	return 0;
	
}


Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  bool flag=true;
  for(int i=0;i<N;i++){
    if(A.at(i)%2==0){
      if(A.at(i)%3==0||A.at(i)%5==0){
      }
      else{
        flag=false;
      }
    }
  }
  if(flag){
    cout<<"APPROVED"<<endl;
  }
  else{
    cout<<"DENIED"<<endl;
  }
}

Measured memory_bytes: 256
n, m = map(int, input().split())
A = []
for i in range(n):
    A.append(list(map(int, input().split())))

b = []
for i in range(m):
    b.append(int(input()))

c = 0
for line in A:
    for i, j in zip(line, b):
        c += i * j
    print(c)
    c = 0



Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>a>>b;

    if(a.size()>b.size())
    {
        cout<<"GREATER\n";
    }
    else if(a.size()<b.size())
    {
        cout<<"LESS\n";
    }
    else if(a>b)
    {
        cout<<"GREATER\n";
    }
    else if(a<b)
    {
        cout<<"LESS\n";
    }
    else
    {
        cout<<"EQUAL\n";
    }
   //cout<<c<<endl;

    return 0;
}


Measured memory_bytes: 3600
# 具体例は入力例1: 817181712114で作成
# 考え方：問題文を「右からi桁目までの数とj桁目までの数の余りが等しいなら条件を満たす」と読み替えて、格桁での余りを求めて余りの配列(L)に格納していく

S = input()
size = len(S)
L = [0] * 2019  # 余りに対応する配列

# 1桁目だけ事前に準備（817181712114の最後の4）
tmp = int(S[size - 1])  # 1桁目の数　ループで書き換えていくのでtmpと命名
tmp_r = 1  # 10のn乗を2019で割った余り(n初期値: 1)
L[0] += 1  # 余り0はiとjを同じ数値にセットしたときに必ず発生しているため予め1にセットしておく
# 余りtmp(4) なお、もし入力例が817181712114でなくて0だとすると、一行上とあわせてL[0]=2となり、ansは1となることからも一行上が必要とわかる
L[tmp] += 1

# (右から)2桁目からループを回す（累積和）
for i in reversed(range(size - 1)):  # 以下、例えばi=2で考える
    n = int(S[i])  # 対象桁の数字(例えば817181712114の右から2桁目は1)
    # 対象桁でのtmp_rは、1個前の桁のtmp_rに10かけて2019で割るだけ。2桁目の場合は10
    tmp_r = (tmp_r * 10) % 2019
    r = (n * tmp_r) % 2019  # 下記の準備
    # 対象桁までを2019で割った際の余り。817181712114の場合、右2桁(14)を2019で割った余りなので14。
    tmp = (tmp + r) % 2019
    L[tmp] += 1  # 余り14の桁があるので追加

ans = 0
for i in range(2019):
    tmp = L[i]
    if (tmp > 1):
        ans += tmp * (tmp - 1) // 2
        # comb(tmp,2)をハードコーディングしてるだけ

print(ans)


Measured memory_bytes: 9312
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
int n,k,ans;
string a;
vector<int>v,sum;
int main(){
	in(n);in(k);
	cin>>a;
	if(a[0]=='0')v.push_back(0);
	int now=0;
	for(int i=0;i<n;i++){
		if(i>0&&a[i]!=a[i-1]){
			v.push_back(now);
			now=1;
		}
		else now++;
	}
	v.push_back(now);
	sum.resize(v.size()+1);
	sum[0]=0;
	for(int i=0;i<v.size();i++){
		sum[i+1]=sum[i]+v[i];
	}
	for(int i=0;i<sum.size();i+=2){
		int x=sum[min((int)v.size(),i+2*k+1)]-sum[i];
		ans=max(ans,x);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1272
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	int N, X, L[110] = {0};
	
	cin >> N >> X;

	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}

	int D = 0, ans = 0;
	for (int i = 0; i < N + 1; i++) {
		if (D <= X) {
			ans++;
		}
		D = D + L[i];
	}
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
	 
	Scanner sc= new Scanner (System.in);
	int a=0;
	int b=0;
	int c=0;
	while (sc.hasNext()) {
		a = sc.nextInt();
		b = sc.nextInt();
		c = a + b;
		int	count = 0;
		do {
			c /= 10;
			count++;
		} while(c != 0);
		System.out.println(count);
	}	
		
	 
	
	}

}

Measured memory_bytes: 20440
#include<cstdio>  
#include<cstring>  
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<string>
#include<algorithm>  
#include<map>
#include<iomanip>
using namespace std;  
typedef long long LL;

struct good  
{  
    int w, v;  
}g[110];  
  
bool cmp(good a, good b)  
{  
    return a.v > b.v;  
}  
good A[110], B[110], C[110], D[110];  
  
LL swa[110], swb[110], swc[110], swd[110];
LL sva[110], svb[110], svc[110], svd[110];
  
int main()  
{  
    int n, w, i, j, k, l;  
    int a, b, c, d;  
    scanf("%d%d", &n, &w);
    {  
        a = b = c = d = 0;  
        for(i = 1; i <= n; i++)  
        {  
            scanf("%d%d", &g[i].w, &g[i].v);  
            if(g[i].w == g[1].w)  
                A[++a] = g[i];  
            if(g[i].w == g[1].w + 1)  
                B[++b] = g[i];  
            if(g[i].w == g[1].w + 2)  
                C[++c] = g[i];  
            if(g[i].w == g[1].w + 3)  
                D[++d] = g[i];  
        }  
        sort(A+1,A+a+1,cmp);  
        sort(B+1,B+b+1,cmp);  
        sort(C+1,C+c+1,cmp);  
        sort(D+1,D+d+1,cmp);  
        swa[0] = swb[0] = swc[0] = swd[0] = 0;  
        sva[0] = svb[0] = svc[0] = svd[0] = 0;  
        for(i = 1; i <= a; i++)  
        {  
            swa[i] = swa[i-1] + A[i].w;  
            sva[i] = sva[i-1] + A[i].v;  
        }  
        for(i = 1; i <= b; i++)  
        {  
            swb[i] = swb[i-1] + B[i].w;  
            svb[i] = svb[i-1] + B[i].v;  
        }  
        for(i = 1; i <= c; i++)  
        {  
            swc[i] = swc[i-1] + C[i].w;  
            svc[i] = svc[i-1] + C[i].v;  
        }  
        for(i = 1; i <= d; i++)  
        {  
            swd[i] = swd[i-1] + D[i].w;  
            svd[i] = svd[i-1] + D[i].v;  
        }  
        int sumv = 0;  
        int ans = 0;  
        for(i = 0; i <= a; i++)  
        {  
            for(j = 0; j <= b; j++)  
            {  
                for(k = 0; k <= c; k++)  
                {  
                    for(l =0 ; l <= d; l++)  
                    {  
                        LL sum = swa[i] + swb[j] + swc[k] + swd[l];  
                        if(sum <= (LL)w)  
                        {  
                            ans = max((LL)ans, sva[i] + svb[j] + svc[k] + svd[l]);  
                        }  
                    }  
                }  
            }  
        }  
        cout << ans << endl;  
    }  
  
    return 0;  
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<vector<int>> book(10);
  for(int i = 0; i < N; ++i) {
    int C, G;
    cin >> C >> G;
    --G;
    book[G].push_back(C);
  }
  for(auto& b: book) sort(begin(b), end(b), greater<int>());
  for(auto& b: book) for(int i = 1; i < b.size(); ++i) b[i] += b[i - 1] + i + i;
  for(auto& b: book) b.insert(begin(b), 0);

  vector<vector<int>> dp(2, vector<int>(K + 1));
  auto cur = dp[0], nex = dp[1];
  for(const auto& b: book) {
    for(int i = 0; i < b.size(); ++i) for(int j = i; j <= K; ++j) nex[j] = max(nex[j], cur[j - i] + b[i]);
    swap(cur, nex);
  }
  cout << cur[K] << endl;
}

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


int draw(int h,int w){
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(j!=0 && i != 0 && j!=w-1 && i != h-1){
                cout << '.';
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }
    cout << endl;
    return 0;
}

int main(){
    int h[300];
    int w[300];
    int cnt;
    for(int i=0;;i++){
        cin >> h[i] >> w[i];
        cnt = i;
        if(h[i] == 0 && w[i] == 0){
            break;
        }
    }
    for(int i=0;i<cnt;i++){
        draw(h[i],w[i]);
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


Measured memory_bytes: 3092
s = input()[::-1]
counts = [0]*2019
counts[0] = 1
sum = 0
d = 1
for c in s:
  sum += int(c)*d
  remain = sum%2019
  d *= 10
  d %= 2019
  counts[remain] += 1

ans = 0
for count in counts:
  ans += count*(count - 1) / 2
print(int(ans))

Measured memory_bytes: 9256
import sys
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())

lst1 = list(map(int,readline().split()))
plus = []
minus = []
for i in lst1:
    if i < 0:
        minus.append(-i)
    else:
        plus.append(i)
minus.reverse() #[1,2,3]
ans = 10**18
if len(minus) >= k:
    ans = min(ans,minus[k-1])
if len(plus) >= k:
    ans = min(ans,plus[k-1])

if len(plus) == 0 or len(minus) == 0:
    print(ans)
    exit()
for i in range(1,k):
    if i > len(plus) or k-i > len(minus):
        continue
    p = plus[i-1]
    m = minus[k-i-1]
    res = min(p*2+m,p+m*2)
    ans = min(ans,res)

print(ans)

Measured memory_bytes: 56816
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a;
 cin >> a;
 if(a==3||a==5||a==7){
   cout << "YES" << endl;
 }else{
   cout << "NO" << endl;
 }
  return 0;
}

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

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}

template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

long long modsub(long long val, long long m) {
  long long res = val % m;
  if (res < 0) res += m;
  return res;
}

signed main(void) {
	int n;
	cin >> n;
	vector<int> a(n);
	int sum=0;
	rep(i, n) {
		cin >> a[i];
		sum += a[i];
		sum%=mod;
	}
	int ret=0;
	rep(i,n-1){
		sum = modsub((sum%mod)-(a[i]%mod),mod);
		int sub = sum*a[i]%mod;
	//	print(sub);
		ret+=sub;
		ret%=mod;
	}
	print(ret);
}

Measured memory_bytes: 4832
from collections import *
import sys
inp = raw_input

def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]

N, K, Q = nl()
A = [ni() for _ in range(Q)]

Score = [K - Q for _ in range(N)]

for a in A:
    a -= 1
    Score[a] += 1
for i, s in enumerate(Score):
    if s > 0:
        print('Yes')
    else:
        print('No')


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

using namespace std;

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

int n;
string s;

int main(){
	cin >> n;
	cin >> s;
	
	int ans = 1;
	rep(i, n-1) if(s[i] != s[i+1]) ans++;
	
	cout << ans << endl;
}

Measured memory_bytes: 512
use proconio::input;
use proconio::marker::Chars;

fn main() {
	input!{
		ca: Chars,
		cb: Chars,
		cc: Chars,
	}

	if ca.last().unwrap() == &cb[0] && cb.last().unwrap() == &cc[0] {
		println!("YES");
	}
	else {
		println!("NO");
	}
}


Measured memory_bytes: 2132
#include "bits/stdc++.h"
using namespace std;
#define PIGRECO 3.141592653589793

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c> {i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
	~debug() { cerr << endl; }
	eni( != ) cerr << boolalpha << i; ris;
}
eni( == ) ris << range(begin(i), end(i));
}
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
///////////////////////////////////////////////////////////////////////////
//////////////////// DO NOT TOUCH BEFORE THIS LINE ////////////////////////
///////////////////////////////////////////////////////////////////////////
#define double long double

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	std::cout << std::setprecision(9);


	int n;
	cin >> n;

	vector<double>p(n + 1);

	vector<vector<double>>dp(n + 1, vector<double>(n + 1));


	for (int i = 1; i <= n; i++) {
		cin >> p[i];
	}

	dp[1][0] = 1 - p[1];

	dp[1][1] = p[1];


	for (int i = 2; i <= n; i++) { //numero di monete

		for (int j = 0; j <= i; j++) { //numero teste


			if (j == 0) {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]);
			}

			else if (j == i) {
				dp[i][j] = dp[i - 1][j - 1] * p[i];
			}

			else {
				dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];

			}




		}


	}



	double ans = 0.0;

	for (int j = n / 2 + 1; j <= n; j++) {

		ans += dp[n][j];


	}

	cout << ans << endl;







}

Measured memory_bytes: 144100
/**
*   @Author : MeGaCrazy
*   @InitTime : Sat Jan 05 03:05:19 2019
*   @Idea :
*
*
*
*
*
*  Happy Solving :)
**/
#include <bits/stdc++.h>
using namespace std;
int main(){
#ifndef ONLINE_JUDGE
   //freopen("in","r",stdin);
   //freopen("out","w",stdout);
#endif
  int n;
  cin>>n;
  vector<int>v(n);
  long long sum=0;
  for(int i=0;i<n;i++){
  	cin>>v[i];
  	sum+=v[i];
  }
//  sort(v.rbegin(),v.rend());
  long long ans=2e18,cur=0,tmp=sum;
  for(int j=0;j<n-1;j++){
       cur+=v[j];
       sum-=v[j];                                                                                                                                                                                                                                       
       ans=min(ans,abs(sum-cur)); 
  }
  cout<<ans<<endl;



}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using pqin=priority_queue<int>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG
int main()
{
    ll k;
    cin>>k;
    ll sum=0;
    for(ll a=1;a<=k;a++){
        for(ll b=1;b<=k;b++){
            for(ll c=1;c<=k;c++){
                sum+=__gcd(a,__gcd(b,c));
            }
        }
    }
    cout<<sum<<endl;
}

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

using namespace std;

typedef tuple<int, int, int, int> T;

int x[100010][2], y[100010][2];
bool ok[100010];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int R, C, N;
	cin >> R >> C >> N;

	vector<T> v;
	for (int i = 0; i < N; i++) {
		cin >> x[i][0] >> y[i][0] >> x[i][1] >> y[i][1];
		if (x[i][0] != 0 && x[i][0] != R && y[i][0] != 0 && y[i][0] != C) continue;
		if (x[i][1] != 0 && x[i][1] != R && y[i][1] != 0 && y[i][1] != C) continue;
		for (int j = 0; j < 2; j++) {
			int hoge;
			if (y[i][j] == 0) hoge = 0;
			else if (x[i][j] == R) hoge = 1;
			else if (y[i][j] == C) {
				hoge = 2;
				x[i][j] = -x[i][j];
			}
			else {
				hoge = 3;
				y[i][j] = -y[i][j];
			}
			v.emplace_back(hoge, x[i][j], y[i][j], i);
		}
	}

	sort(v.begin(), v.end());
	stack<int> s;
	for (T& t : v) {
		if (!s.empty() && s.top() == get<3>(t)) {
			s.pop();
		} else {
			s.push(get<3>(t));
		}
	}

	cout << (s.empty() ? "YES" : "NO") << endl;
	return 0;
}

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

typedef long long LL;

LL N,M;

int main()
{
    while(scanf("%lld%lld",&N,&M)!=EOF)
    {
        if((M/2)<=N) //M<=N的情况要考虑到
            printf("%lld\n",M/2);
        else
        {
            M -= N*2;
            M /=4;
            printf("%lld\n",N+M);
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
bool cmp(const ii &a,const ii &b)
{
    return a.first<b.first||(a.first==b.first&&a.second<b.second);
}
void s2()
{
    int n;
    cin>>n;
    vector<ii> p(n,{0,0});
    for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        p[i]=(ii{a-b,a+b});
    }
    sort(p.begin(),p.end(),cmp);
    //for(auto i:p) cout<<i.first<<" "<<i.second<<endl;
    vector<int> dp(n+1,1);
    int res=1;
    for(int i=1;i<n;i++){
        for(int j=i-1;j>=0;j--){
            //cout<<p[j].second<<endl;
            if(p[j].second<=p[i].first) {
                dp[i]=max(dp[i],dp[j]+1);
                res=max(res,dp[i]);
                break;
            }
        }
    }
    cout<<res<<endl;
}
int main()
{
    s2();
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;

typedef double real;

struct matrix {
    real * a;
    long ld;		      // leading dimension
    long n_rows;		      // number of rows
    long n_cols;		      // number of columns

    matrix() {}
    matrix(long n_rows, long n_cols, long ld, real * a) {
        init(n_rows,  n_cols, ld, a);
    }
    matrix(long n_rows, long n_cols, long ld) {
        init(n_rows,  n_cols, ld);
    }
    matrix(long n_rows, long n_cols) {
        init(n_rows,  n_cols);
    }

    void init(long n_rows_, long n_cols_, long ld_, real * a_) {
        n_rows = n_rows_;
        n_cols = n_cols_;
        ld = ld_;
        a = a_;
    }

    void init(long n_rows, long n_cols, long ld) {
        real * a = new real[n_rows * ld];
        init(n_rows, n_cols, ld, a);
    }
  
    void init(long n_rows, long n_cols) {
        init(n_rows, n_cols, n_cols);
    }

    real & operator ()(long i, long j) {
        return a[i * ld + j];
    }
};

void print_matrix(matrix A) {
    long M = A.n_rows;
    long N = A.n_cols;
    long i, j;
    for (i = 0; i < M; i++) {
        for (j = 0; j < N; j++) {
            //printf("%.2f ", A(i, j));
            printf("%d ", (int)A(i,j));
        }
        printf("\n");
    }
}

void mm(matrix &A, matrix &B, matrix &C){
    if( A.n_cols != B.n_rows ||
        A.n_rows != C.n_rows ||
        B.n_cols != C.n_cols ){
        cout << "Error: Uncomputable matrix size. \n";
        exit(1);
    }

    for(int i=0; i<A.n_rows; i++){
        for(int j=0; j<B.n_cols; j++){
            real ct = 0.0;
            for(int k=0; k<A.n_cols; k++){
                ct += A(i,k) * B(k,j);
            }
            C(i,j) = ct;
        }
    }
}

int main(){
    int n, m;
    int input;
    cin >> n >> m;
    matrix A(n, m);
    matrix b(m, 1);

    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            cin >> input;
            A(i, j) = input;
        }
    }
    for(int i=0; i<m; i++){
        cin >> input;
        b(i, 0) = input;
    }

    //print_matrix(A);
    //print_matrix(b);
    
    matrix C(n, 1);

    mm(A,b,C);

    for(int i=0; i<n; i++){
        printf("%d\n", (int)C(i,0));
    }
    
    return 0;
}
    

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n,m;
int main()
{
    n=read();m=read();reg int i,gs=0;
    for(i=1;i<=n;++i)if(read()>=m)gs++;
    cout<<gs<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
vector<ll> road[200005],train[200005];
ll ridx[200005]={0},tidx[200005]={0};
bool used1[200005],used2[200005];
void dfs_road(ll pos,ll k){
  used1[pos]=true;
  ridx[pos]=k;
  for(int i=0;i<road[pos].size();i++){
    ll to=road[pos][i];
    if(!used1[to]){
      used1[to]=true;
      dfs_road(to,k);
    }
  }
}
void dfs_train(ll pos,ll k){
  used2[pos]=true;
  tidx[pos]=k;
  for(int i=0;i<train[pos].size();i++){
    ll to=train[pos][i];
    if(!used2[to]){
      used2[to]=true;
      dfs_train(to,k);
    }
  }
}
int main(){
  ll n,k,l;
  cin>>n>>k>>l;
  for(int i=0;i<=n;i++){
    used1[i]=0;
    used2[i]=0;
  }
  for(int i=0;i<k;i++){
    ll a,b;
    cin>>a>>b;
    road[a].push_back(b);
    road[b].push_back(a);
  }
  for(int i=0;i<l;i++){
    ll a,b;
    cin>>a>>b;
    train[a].push_back(b);
    train[b].push_back(a);
  }

  ll k1=1,k2=1;
  for(int i=1;i<=n;i++){
    if(!used1[i]){
      dfs_road(i,k1);
      k1++;
    }
    if(!used2[i]){
      dfs_train(i,k2);
      k2++;
    }
  }
  map<P,ll> mp;
  for(int i=1;i<=n;i++){
    P p=P(ridx[i],tidx[i]);
    if(mp.find(p)!=mp.end()) mp[p]++;
    else mp[p]=1;
  }

  for(int i=1;i<=n;i++){
    P p=P(ridx[i],tidx[i]);
    cout<<mp[p]<<(i==n?"\n":" ");
  }
}


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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028L;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

string S;
signed main() {
    cin >> S;
    if (S == "SUN") { cout << 7 << endl; }
    if (S == "MON") { cout << 6 << endl; }
    if (S == "TUE") { cout << 5 << endl; }
    if (S == "WED") { cout << 4 << endl; }
    if (S == "THU") { cout << 3 << endl; }
    if (S == "FRI") { cout << 2 << endl; }
    if (S == "SAT") { cout << 1 << endl; }
}


Measured memory_bytes: 768
#include <iostream>
#include<cmath>
using namespace std;
int main(void){
    long long A,B,C,D,E,F,G,H,I,J;
    long long X,Y,Z,T;
    cin>>A>>B>>C>>D;
    E=A/C;
    F=B/C;
    G=A/D;
    H=B/D;
    
    long long K,L,M,N;
    if(C<D){
        K=C;
        L=D;
    }else{
        K=D;
        L=C;
    }
    M=L%K;
    while(M!=0){
        L=K;
        K=M;
        M=L%K;
    }
    
    N=C*D/K;
    
    I=A/N;
    J=B/N;
    if(A%C==0){
        X=F-E+1;
    }else{
        X=F-E;
    }
    if(A%D==0){
        Y=H-G+1;
    }else{
        Y=H-G;
    }
    if(A%N==0){
        Z=J-I+1;
    }else{
        Z=J-I;
    }
        
    T=B-A+1-(X+Y-Z);
    cout<<T<<endl;
    
    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int n,a,b;
    
    cin>>n>>a>>b;
    
    string s;
    cin>>s;
    int cnt = 0;
    int fct = 0;
    for(int i=0;i<s.size();i++){
        if(s[i] == 'a') {
            if(cnt < a+b) {
                cout<<"Yes"<<endl;
                ++cnt;
            }
            else cout<<"No"<<endl;
        } 
        else if(s[i] == 'b') {
            if(cnt < a+b && fct < b){
                cout<<"Yes"<<endl;
                ++cnt;
                ++fct;
            }
            else cout<<"No"<<endl;
        }
        else {
            cout<<"No"<<endl;
        }
    }
}


Measured memory_bytes: 3708
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

main()
{
    int n=0;
    int num[100];
    int t;
    while(scanf("%d",&t)!=EOF)
    {
        num[n++]=t;
    }
    sort(num,num+n);
    printf("%d\n%d\n%d\n",num[n-1],num[n-2],num[n-3]);
}

Measured memory_bytes: 1204
f=0
while 1:
  n=input()
  if n==0: break
  if f>0: print
  C=[()]*n
  for i in range(n):
    s=raw_input()
    p=s.index(" ")
    a,b,c=map(int,s[p+1:].split(" "))
    C[i]=(i,a*3+c,s[:p])
  C=sorted(C,key=lambda x:(-x[1],x[0]))
  for e in C: print e[2]+","+str(e[1])
  f=1

Measured memory_bytes: 4236
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define x first
#define y second
const int N=1e7+5;
ll cnt[N];
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //assert(freopen("input.txt","r",stdin));
    //assert(freopen("output.txt","w",stdout));
    int n,i,j;
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=i;j<=n;j+=i){
            cnt[j]++;
        }
    }
    ll ans=0;
    for(i=1;i<=n;i++){
        ans+=(i*cnt[i]);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 81688