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

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int x = in.readInt();
		int y = in.readInt();
		int group[] = {0,1,3,1,2,1,2,1,1,2,1,2,1}; 
		System.out.println(group[x] == group[y] ? "Yes": "No");
		
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}

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

int main(){
    int N; cin >> N;
    int X; cin >> X;
    int L[10000];
    for(int i=0;i<N;i++){
        cin >> L[i];
    }
    int ans = 0;
    int kai = 1;
    for(int i=0;i<N;i++){
        ans += L[i];
        if(ans > X) break;
        kai += 1;
    }
    cout << kai << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int count=0;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        if(a!=i+1)
            count++;
        if(count>2)
        {
            count++;
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}


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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli a[3][3];
bool vis[3][3];

signed main(){

	REP(i,0,3)REP(j,0,3)cin>>a[i][j];

	lli n;
	cin>>n;

	REP(i,0,n){
		lli tmp;
		cin>>tmp;
		REP(j,0,3)REP(k,0,3){
			if(a[j][k]==tmp){
				vis[j][k] = true;
			}
		}
	}

	//tate
	REP(i,0,3){
		if(vis[0][i] && vis[1][i] && vis[2][i]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	//yoko
	REP(i,0,3){
		if(vis[i][0] && vis[i][1]&&vis[i][2]){
			cout<<"Yes"<<endl;
			return 0;
		}
	}

	//naname
	if(vis[0][0]&&vis[1][1]&&vis[2][2]){
			cout<<"Yes"<<endl;
			return 0;
	}
	if(vis[2][0]&&vis[1][1]&&vis[0][2]){
			cout<<"Yes"<<endl;
			return 0;
	}
	cout<<"No"<<endl;

	return 0;
}

Measured memory_bytes: 256
/* 	* In the name of GOD 
	* Thanks God */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second

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

int32_t main() {
	int t = 1;
//	cin >> t;
	while (t--) {
		solve();
	}
}


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

int main(){
    long long n, m;
    cin >> n >> m;
    if(n > m){
        int tmp = n;
        n = m;
        m = tmp;
    }

    long long num;
    if(n == 1){
        if(m == 1){
            num = 1;
        }else{
            num = m-2;
        }
    }else{
        num = (n-2)*(m-2);
    }
    cout << num << endl;
  
    return 0;
}


Measured memory_bytes: 256
from heapq import heappop, heappush
INF = float('inf')

N, M, S = map(int,input().split())
graph = [[] for _ in range(N)]
for _ in range(M):
	U, V, A, B = map(int,input().split())
	graph[U-1].append((V-1, A, B))
	graph[V-1].append((U-1, A, B))

C, D = [0]*N, [0]*N
for i in range(N):
    c, d = map(int,input().split())
    C[i], D[i] = c, d

def Extdijkstra(start):
    global S
    N_d = len(graph)
    M = 2500

    if S >= M:
        S = M-1
    
    dist = [[INF]*M for _ in range(N_d)]
    dist[start][S] = 0
    q = [(0, S, start)]

    while q:
        d, num, v = heappop(q)
        if num+C[v] < M and d+D[v] < dist[v][num+C[v]]:  # 自己ループ
            dist[v][num+C[v]] = d+D[v]
            heappush(q, (d+D[v], num+C[v], v))
        for node, c, t in graph[v]:
            if num >= c and d + t < dist[node][num-c]:
                dist[node][num-c] = d+t
                heappush(q, (d+t, num-c, node))
    return dist

d = Extdijkstra(0)
for i in range(1, N):
	print(min(d[i]))

Measured memory_bytes: 26128
#include <stdio.h>
#include <climits>
#include <iostream>
#include <cmath>
//wlanguest2009

int main()
{
    long long int n;
    scanf("%lld", &n);

    long long int min = LLONG_MAX;

    for (int i = 1; i <= std::sqrt(n); i++)
    {
        if (n % i != 0)
        {
            continue;
        }
        if (n % i == 0)
        {
            long long int a = n / i;
            long long int b = i + a - 2;
            if (min > b)
            {
                min = b;
            }
        }
    }

    printf("%lld\n", min);
    return 0;
}

Measured memory_bytes: 256
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B
# Queue
# Result:
import sys

class Process:
    def __init__(self, name, time):
        self.name = name
        self.time = time

    def __str__(self):
        return '%s(%d)' % (self.name, self.time)


class Queue:
    def __init__(self):
        self.store = []

    def __str__(self):
        """From head to tail"""
        str_val = ''
        for var in self.store:
            str_val += str(var) + '\n'
        return str_val.rstrip()

    def enqueue(self, v):
        self.store.append(v)

    def dequeue(self):
        if self.is_empty():
            return None
        return self.store.pop(0)

    def is_empty(self):
        if len(self.store) == 0:
            return True
        else:
            return False


### main
vals = sys.stdin.readline().rstrip().split(' ')
n, q = map(int, vals)

queue = Queue()
for i in range(0, n):
    pname, ptime = sys.stdin.readline().rstrip().split(' ')
    queue.enqueue(Process(pname, int(ptime)))

time = 0
while not queue.is_empty():
    p = queue.dequeue()
    if p.time > q:
        p.time -= q
        queue.enqueue(p)
        time += q
    else:
        time += p.time
        print '%s %d' % (p.name, time)

Measured memory_bytes: 26188
#include <cstdio>
#include <cmath>
#include <string>

#define rep( i, n, m ) for (int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for (int i = ( n ); i < ( m ); i--)

int main( void ){
	int a,b;
	if (!scanf( "%d %d", &a, &b ))
		return -1;
	if (a%2 == 0 || b %2 ==0){
		printf("Even\n");
		return 0;
	}
	printf("Odd\n");
	return 0;
}


Measured memory_bytes: 128
n,d = map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]

import numpy as np

def dist(a,b):
  arr_a=np.array(a)
  arr_b=np.array(b)
  return np.sqrt(np.sum((arr_a - arr_b)  ** 2))

count = 0

for i in range(n-1):
  for j in range(i+1,n):
    if dist(x[i],x[j]).is_integer():
      count += 1
print(count)

Measured memory_bytes: 12424
#include <bits/stdc++.h>
using namespace std;
#define reup(a, b) for(int i = a; i < b; ++i)
#define ll long long
const int maxn = 1e5 + 10;
int a[maxn], b[maxn], c[maxn];
int n;
int main(void) {
    std::ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    while(cin >> n) {
        reup(0, n) cin >> a[i];
        reup(0, n) cin >> b[i];
        reup(0, n) cin >> c[i];
        sort(a, a + n);
        sort(b, b + n);
        sort(c, c + n);
        ll ans = 0;
        int p1 = 0, p2 = 0;
        reup(0, n) {
            p1 = lower_bound(a + p1, a + n, b[i]) - a;
            if(p1 > n) break;
            //if(a[p1] > b[i]) p1--;
            p2 = upper_bound(c + p2, c + n, b[i]) - c;
            if(p2 > n) break;
            ans += (ll)(p1) * (ll)(n - p2);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 1408
package main

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

const Mod = int(1e9) + 7

func main() {
	S := ReadString()

	baser := make([]int, len(S))
	b := 1
	for i := 0; i < len(S); i++ {
		baser[i] = b
		b *= 10
		b %= 13
	}
	dp := make([][]int, len(S)+1)
	for i := 0; i < len(S)+1; i++ {
		dp[i] = make([]int, 13)
	}
	dp[0][0] = 1
	for i := 0; i < len(S); i++ {
		for r := 0; r < 13; r++ {
			base := baser[len(S)-i-1]
			if S[i] == '?' {
				for x := 0; x <= 9; x++ {
					prev := (13 + (r-base*x)%13) % 13
					dp[i+1][r] += dp[i][prev]
					dp[i+1][r] %= Mod
				}
			} else {
				x := int(S[i] - '0')
				prev := (13 + (r-base*x)%13) % 13
				dp[i+1][r] += dp[i][prev]
			}
		}
	}
	fmt.Println(dp[len(S)][5])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 16780
#include <iostream>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if (a<=b) {
		if (a<=c) {
			if (b<=c) {
				cout << a << " " << b << " " << c << endl;
			} else {
				cout << a << " " << c << " " << b <<endl;
				
			}
			
		} else {
			cout << c << " " << a << " " << b <<endl;	
		}
    } else {
    	if (b>=c){
    		cout << c << " " << b << " " << a <<endl;
		} else {
			if (a<=c) {
				cout << b << " " << a << " " << c << endl;
			}else {
				cout << b << " " << c << " " << a << endl;
			}
			
		}
    	
	}

	return 0;
}
	
	
		
		
	
	



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

int main()
{
	char a[105];
	int sum=0;
	scanf("%s",a);
	int len1=strlen(a);
	printf("%c",a[0]);
	printf("%d",len1-2);
	printf("%c",a[len1-1]);
	return 0;
}

Measured memory_bytes: 128
# BFS
from collections import deque


def main():
    dx = [1, 0, -1, 0]
    dy = [0, 1, 0, -1]
    # 頂点数と辺数
    H, W = map(int, input().split())
    A = [list(input()) for _ in range(H)]
    # 全頂点を未訪問に初期化
    dist = [[-1] * W for _ in range(H)]

    ans = float('inf')
    que = deque()
    for h in range(H):
        for w in range(W):
            if A[h][w] == '#':
                que.append([h, w])
                dist[h][w] = 0

    # bfs開始 (キューが空になるまで探索を行う)
    while len(que) > 0:
        v = que.popleft()  # キューから先頭頂点を取り出す
        for i in range(4):
            nx = v[0] + dx[i]
            ny = v[1] + dy[i]
            if (0 <= nx and nx < H and 0 <= ny and ny < W and dist[nx][ny] == -1):
                que.append([nx, ny])
                dist[nx][ny] = dist[v[0]][v[1]] + 1
    ans = 0
    for h in range(H):
        for w in range(W):
            ans = max(ans, dist[h][w])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 176860
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,nn) for(int i=0;i<nn;i++)
#define MOD 1000000007
typedef long long ll;
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}else{return 0;}}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}else{return 0;}}
template <class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <class T> inline T LCM(T a,T b){return a*b/GCD(a,b);}


vector<ll> g[100010];
bool reached[100010]={0};
ll ans=1;
int n,k;

void dfs(ll c,ll x){
  ans*=x;
  ans%=MOD;
  reached[c]=1;
  if(x<=k-2)x=k-1;
  int cnt=1;
  FOR(i,g[c].size()){
    if(reached[g[c][i]])continue;
      
      dfs(g[c][i],x-cnt);
      cnt++;
    
    
  }
} 

int main(){
  
  cin >> n >> k;
  int a[100010],b[100010];
  FOR(i,n-1){
    cin >> a[i] >> b[i];
    g[a[i]].push_back(b[i]);
    g[b[i]].push_back(a[i]);
  }

  dfs(1,k);

  cout << ans << endl;



  
}


Measured memory_bytes: 10112
#include <stdio.h>


int mini(a, b){
  return a < b ? a : b;
}

int maxi(int a, int b){
  return a > b ? a : b;
}
int main()
{
  int n, m;
  scanf("%d%d", &m, &n);
  int smaller = mini(n, m);
  int bigger = maxi(n, m);
  for(int i = 0; i< bigger; i++){
     printf("%d", smaller);
  }
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define NA -1
typedef long long ll;
void fail()
{
  cout << -1 << endl;
}

int main()
{
  int n, m;
  int sc[3] = {NA,NA,NA};

  cin >> n >> m;
  int s, c;
  rep(i, m)
  {
    cin >> s >> c;
    //同じ桁で重複がないか
    if((sc[s-1] !=  NA && sc[s-1] != c) ||
    //N桁以上の入力がないか
        (n < s))
    {
      fail();
      return 0;
    }
    sc[s-1] = c;
  }
  //1番上の桁が0でないか
  if(n > 1 && sc[0] == 0)
  {
    fail();
    return 0;
  }
  int p = 1;
  for(int i = 0; i < n-1; ++i) p*=10;
    
  int ans = 0;
  rep(i, n)
  {
    int x = sc[i] == NA ? 0 : sc[i];
    if(n > 1 && i == 0 && sc[i] == NA) x = 1;
    ans += x * p;
    p /= 10;
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

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


int main() {
	string s, t, u;
	cin >> s >> t;
	int a,b;
	cin >> a >> b;
	cin >> u;

	if (s == u) {
		a --;
	} else if (t == u) {
		b --;
	}
	cout << a << " " << b << endl;


	
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

int main(){
  int N,A,B;
  cin >> N >> A>> B;
  cout << min(N*A, B) << endl;

  return 0;

}


Measured memory_bytes: 256
/*input
10
8 5
10 8
6 5
1 5
4 8
2 10
3 6
9 2
1 7

*/
/*

  ####   #    #    ##    #####    ####           #    #
 #       #    #   #  #   #    #  #    #          #    #
  ####   ######  #    #  #    #  #    #          #    #
      #  #    #  ######  #    #  #    #          # ## #
 #    #  #    #  #    #  #    #  #    #          ##  ##
  ####   #    #  #    #  #####    ####  #######  #    #

*/
#include<bits/stdc++.h>
#define lld          long long int
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<lld,lld>
#define msi         map<string,lld>
#define mis         map<lld, string>
#define mpi         map<pair<lld ,lld >,lld >
#define pii         pair<lld,lld>
#define vi          vector<lld>
#define vpi 		vector<pii>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (lld)x.size()
#define hell        1000000007
#define rep(i,m,n)	for(lld i=m;i<n;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define pr(x) 		cout<< x << " ";
#define pre(x)		cout<< x << endl ;
using namespace std;
#define N  1000005
lld dfs2(lld node ,lld par);
vi v[N];
lld n;
lld dp[N][2];
bool vis[N],vis2[N];
void init()
{
	rep(i,0,N)
	{
		dp[i][0]=-1;
		dp[i][1]=-1;
		vis[i]=false;
		vis2[i]=false;
	}
}
lld dfs(lld node,lld par,lld col)
{
	lld ans=1;
	if(dp[node][col]!=-1)
	{
		return dp[node][col];
	}
	for(auto it:v[node])
	{
		if(it!=par)
		{
			lld anss=0;
			if(col==0)
			{
				anss+=dfs(it,node,1);
				anss%=hell;
			}
			else
			{
				anss+=dfs(it,node,0);
				anss%=hell;
				anss+=dfs(it,node,1);
				anss%=hell;
			}
			ans=(ans*anss)%hell;
		}
	}
	dp[node][col]=ans;
	return ans;
}
// lld dfs2(lld node,lld par)
// {
// 	lld ans2=1;
// 	for(auto it:v[node])
// 	{
// 		lld anss=0;
// 		if(it!=par)
// 		{
// 			anss=dfs(it,node);
// 			anss%=hell;
// 		}
// 		if(it!=par)
// 		{
// 			anss+=dfs2(it,node);
// 			anss%=hell;
// 		}
// 		if(anss)
// 		{
// 			ans2=(anss*ans2)%hell;
// 		}
// 	}
// 	dp2[node]=ans2;
// }
inline void solve()
{
	init();
	cin >> n;
	rep(i,1,n)
	{
		lld x,y;
		cin >> x >> y;
		v[x].pb(y);
		v[y].pb(x);
	}	
	cout << (dfs(1,0,0)+dfs(1,0,1))%hell;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int tests=1;
	//cin>>tests;
	while(tests--)
	{
		solve();
	}
}

Measured memory_bytes: 52736
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
	#define debug(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
	#define debug(...) 42
#endif

#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

inline string getString(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string getLine(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
typedef long long ll;

const int S=100100;
int main()
{
	ll x,k,d;
	while(~sf("%lld %lld %lld",&x,&k,&d))
	{
		ll X=abs(x);
		ll move=min(k,X/d);
		k-=move;
		X-=(move*d);

		if(k%2==0)pf("%lld\n",X);
		else pf("%lld\n",abs(X-d));
	}
    return 0;
}



































Measured memory_bytes: 3824
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    cin>>n;
    string s;
    cin>>s;
    int r=0,g=0,b=0;
    ll ans=0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
        //cout<<r<<" "<<g<<" "<<b<<endl;
        if(r>0 && g>0 && b>0){
            /*cout<<"kasan"<<endl;
            cout<<i<<endl;
            cout<<r<<" "<<g<<" "<<b<<endl;*/
            if(s[i]=='R'){
                ans+=g*b;
            }
            else if(s[i]=='G'){
                ans+=b*r;
            }
            else{
                ans+=r*g;
            }
        }
    }
    //cout<<ans<<endl;
    ll out=0;
    for(int j=1;j<s.size()-1;j++){
        for(int dis=1;dis<=s.size();dis++){
            int i = j-dis;
            int k = j+dis;
            if(i>=0 && k<s.size()){
                if(s[i]!=s[j] && s[i]!=s[k] && s[k]!=s[j]) out++;
            }
        }
    }
    //cout<<out<<endl;
    cout<<ans-out<<endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    fill(dp,dp+n,INF);
    for(int i=n-1;i>=0;--i){
        *upper_bound(dp,dp+n,a[i])=a[i];
    }
    cout<<lower_bound(dp,dp+n,INF)-dp<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
int main()
{
    ll p;
    cin>>p;
    ll cnt=100;
    int ans=0;
    while(cnt<p)
    {
        cnt+=cnt/100;
        ans++;
    }
    cout<<ans<<endl;





}



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


int main() {
	string s ; 
	cin >> s ; 
	int sum = 0 ; 
	for(char x : s) {
		sum += x -'0' ; 
	}
	if(sum % 9) cout << "No" ;
	else cout << "Yes" ; 
	return 0 ; 
}

Measured memory_bytes: 3748
N = int(input())
A = list(map(int, input().split()))

import fractions
gcd_forward  = [A[0]]*N
gcd_backward = [A[N-1]]*N
for i in range(1,N):
    gcd_forward[i]  = fractions.gcd(A[i],gcd_forward[i-1])
for i in range(N-2,0,-1):
    gcd_backward[i] = fractions.gcd(A[i],gcd_backward[i+1])

ans = gcd_backward[1]
for i in range(1,N-1):
    ans = max(ans, fractions.gcd(gcd_forward[i-1], gcd_backward[i+1]))
ans = max(ans, gcd_forward[N-2])
print(ans)

Measured memory_bytes: 14524
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let nk: Vec<usize> = util::gets();
    let k = nk[1];

    let a: Vec<usize> = {
        let mut v = util::gets();
        v.sort();
        v
    };

    println!("{}", search(0, a.len(), &a, k));
}

fn search(low: usize, high: usize, a: &Vec<usize>, k: usize) -> usize {
    if low == high {
        return low;
    }

    let mid = (low + high) / 2;

    if !check(a[mid], k, a) {
        search(mid + 1, high, a, k)
    } else {
        search(low, mid, a, k)
    }
}

fn check(a: usize, k: usize, aa: &Vec<usize>) -> bool {
    if a >= k {
        return true;
    }

    let mut skipped = false;
    let mut dp = vec![false; k];
    dp[a] = true;

    for &x in aa {
        if !skipped && x == a {
            skipped = true;
            continue;
        }

        for i in 0..k as usize {
            let i = k - i - 1;
            if dp[i] {
                let s = i + x;
                if s >= k && s < k + a {
                    return true;
                } else if s < k {
                    dp[s] = true;
                }
            }
        }
    }

    return false;
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		sc.close();
		String s2 = s.replaceAll("ABC", "");
		System.out.println((n - s2.length()) / 3);
	}

	public static int arrayMax(int[] array) {
		int ans = Integer.MIN_VALUE;
		for (int i = 0; i < array.length; i++) {
			if (array[i] > ans)
				ans = array[i];
		}
		return ans;
	}

	public static int[] arrayInt(Scanner sc, int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextInt();
		}
		return array;
	}

	public static long[] arrayLong(Scanner sc, int n) {
		long[] array = new long[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextLong();
		}
		return array;
	}

	public static double[] arrayDouble(Scanner sc, int n) {
		double[] array = new double[n];
		for (int i = 0; i < n; i++) {
			array[i] = sc.nextDouble();
		}
		return array;
	}
}


Measured memory_bytes: 21844
object Main extends App {
  import scala.io.StdIn._
  val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
  val section = Array.fill(n){
    val Array(l, r) = readLine.trim.split(' ').map(_.toInt)
    Array(l, -r)
  }.flatten.sortWith{(a, b) ⇒ if (a.abs != b.abs) a.abs < b.abs else b < a}
  var maxSection = 0
  var minPos = m
  var maxPos = 0
  var current = 0
  for (i ← section) {
    if (i > 0) {
      current += 1
      if (maxSection == current) {
        maxPos = i
      }else if (maxSection < current) {
        minPos = i
        maxPos = i
        maxSection = current
      }
    }else {
      current -= 1
      if (maxSection == current + 1) {
        maxPos = -i
      }
    }
  }
  println(
    if (maxSection % 2 == 0) maxSection.toLong * m - minPos
    else maxSection.toLong * m + maxPos - m
  )
}


Measured memory_bytes: 269928
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>

typedef long long ll;
#define fi first
#define se second

using namespace std;

///////////////////////////////////////
//
//
///////////////////////////////////////
//

string S;

int num[26];
string key = "abcdefghijklmnopqrstuvwxyz";

int main(){
  
  cin>>S;
  
  int ans = 100;
  int cnt = 0;
  int big;
  int i;
  int j;
  int idx;
  
  fill( num, num+26, 0 );
  for( j = 0; j < 26; j++ ){
  	cnt = 0;
  	big = 0;
    for( i = 0; i < S.size(); i++ ){
  		cnt++;
  		if( key[j] == S[i] ) cnt = 0;
  		big = max( cnt, big );
  	}
  	ans = min( big, ans );
  }
  
  cout<<ans<<endl;  
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
using namespace std;

int main()
{
    long long H, W, ans = 0;
    cin >> H >> W;
    if(H == 1 || W == 1) ans = 1;
    else if((H * W) % 2 == 0) ans = (H * W) / 2;
    else ans = (H * W) / 2 + 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int D;
	int[] c;
	int[][] s;

	Main(BufferedReader in) throws IOException {
		D = Integer.parseInt(in.readLine());
		String[] tokens = in.readLine().split(" ");
		c = new int[tokens.length];
		for (int i = 0; i < tokens.length; ++i) {
			c[i] = Integer.parseInt(tokens[i]);
		}
		s = new int[D][c.length];
		for (int i = 0; i < D; ++i) {
			tokens = in.readLine().split(" ");
			for (int j = 0; j < tokens.length; ++j) {
				s[i][j] = Integer.parseInt(tokens[j]);
			}
		}

	}

	int sub(int[] array) {
		int result = -1;
		int max = -1;
		for (int i = 0; i < array.length; ++i) {
			if (max < array[i]) {
				result = i;
				max = array[i];
			}
		}
		return result;
	}

	void calc() {
		// まずは最大のSを選ぶことにする
		for (int i = 0; i < D; ++i) {
			int r = sub(s[i]);
			System.out.println((r + 1));
		}
	}

	void showResult() {
	}
}


Measured memory_bytes: 35968
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>

using namespace std;

#define int long long

const int INF=1e9;
const int MAX_V=1000;

signed main(){

	int n;
	cin>>n;

	for(int i=1;i<3600;i++){
		for(int j=1;j<3600;j++){
			if(4*i*j-(i+j)*n>0&&(n*i*j)%(4*i*j-(i+j)*n)==0){
				cout<<i<<" "<<j<<" "<<(n*i*j)/(4*i*j-(i+j)*n)<<endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int H,W,N;
    int a[114514],b[114514];
    int Ans[10]={};
    cin >> H >> W >> N;
    REP(i,N){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
    }
    map<pair<int,int>,int> MP;
    REP(i,N){
        for(int j=-1;j<=1;j++){
            for(int k=-1;k<=1;k++){
                int x=a[i]+j,y=b[i]+k;
                if(1<=x&&x<=H-2&&1<=y&&y<=W-2){
                    MP[make_pair(x,y)]++;
                }
            }
        }
    }
    REP(i,N){
        for(int j=-1;j<=1;j++){
            for(int k=-1;k<=1;k++){
                int x=a[i]+j,y=b[i]+k;
                Ans[MP[make_pair(x,y)]]++;
                MP[make_pair(x,y)]=0;
            }
        }
    }
    
    //REP(i,H){REP(j,W){cout << MP[make_pair(i,j)] << " ";}cout << endl;}cout << endl;
    Ans[0]=0;
    for(int i=1;i<=9;i++){
        Ans[0]-=Ans[i];
    }
    Ans[0]+=(H-2)*(W-2);
    
    REP(i,10){
        cout << Ans[i] << Endl;
    }
    return 0;
}   


Measured memory_bytes: 58112
#![allow(unused_imports)]
#![allow(dead_code)]

use proconio::input;
use proconio::marker::{Bytes, Chars};
use std::collections::*;

fn main() {
    input! {
        r1:i64,
        c1:i64,
        r2:i64,
        c2:i64,
    }
    let modulo = 1e+9 as i64 + 7;
    let comb = CombinationMod::new((r2 + c2) as usize + 2, modulo);
    let square_sum = |r, c| (comb.query(r + c + 2, r + 1) + modulo - 1) % modulo;
    let mut ans = 0;
    ans = (ans + square_sum(r2, c2)) % modulo;
    ans = (ans - square_sum(r1 - 1, c2)) % modulo;
    ans = (ans - square_sum(r2, c1 - 1)) % modulo;
    ans = (ans + square_sum(r1 - 1, c1 - 1)) % modulo;
    if ans < 0 {
        ans = (ans % modulo + modulo) % modulo;
    }
    println!("{}", ans);
}

struct CombinationMod {
    fac: Vec<i64>,
    inv: Vec<i64>,
    inv_fac: Vec<i64>,
    modulo: i64,
}
impl CombinationMod {
    pub fn new(size: usize, modulo: i64) -> CombinationMod {
        let mut fac = vec![1; size + 1];
        let mut inv = vec![1; size + 1];
        let mut inv_fac = vec![1; size + 1];
        for i in 2..=size {
            fac[i] = fac[i - 1] * i as i64 % modulo;
            inv[i] = modulo - inv[modulo as usize % i] * (modulo / i as i64) % modulo;
            inv_fac[i] = inv_fac[i - 1] * inv[i] % modulo;
        }
        CombinationMod {
            fac: fac,
            inv: inv,
            inv_fac: inv_fac,
            modulo: modulo,
        }
    }
    fn query(&self, n: i64, r: i64) -> i64 {
        self.fac[n as usize] * self.inv_fac[r as usize] % self.modulo
            * self.inv_fac[(n - r) as usize]
            % self.modulo
    }
    fn inverse(&self, n: i64) -> i64 {
        self.inv[n as usize]
    }
}

Measured memory_bytes: 48664
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>
#include <bitset>
#include <list>
#include <iomanip>
#include <cctype>

#define for0(i, N)    for (long long i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (long long i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (long long i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (long long i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (long long i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (long long i = (x), a = 0; a < (N);    \
                              i = (i + 1) % (N), ++a)
#define int long long

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b + 1;
}

template<size_t i>
std::bitset<i> operator++(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b++;
    return temp;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b, signed){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    return b = (unsigned long long)b - 1;
}

template<size_t i>
std::bitset<i> operator--(std::bitset<i> b){
    static_assert(i <= 64, "Cannot cast 64bit int.");
    auto temp = b;
    b--;
    return temp;
}

long long constexpr inf = std::numeric_limits<long long>::max();

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<vector<ll>> vvll;


signed main(void){
    cin.tie(0); ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);
    string s;
    cin >> s;
    int q;
    cin >> q;

    list<char> ss;

    for(auto &c : s){
        ss.push_back(c);
    }

    bool reverse = false;
    for0(i, q){
        int t;
        cin >> t;
        if(t == 1){reverse = !reverse; continue;}

        int f;
        char c;
        cin >> f >> c;

        if ((f == 1) ^ reverse) {
            ss.push_front(c);
        } else {
            ss.push_back(c);
        }
    }

    if (!reverse) {
        for(auto &c : ss){
            cout << c;
        }
    } else {
        for (auto &&c = ss.rbegin(); c != ss.rend(); ++c) {
            cout << *c;
        }
    }

    cout << "\n";

    return 0;
}


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

typedef unsigned long long ull;

ull Lucas(int n, ull* L)
{
  if (!L[n])
  {
    L[n] = (Lucas(n-1,L) + Lucas(n-2,L));
  }

  return L[n];
}

int main()
{
  int N;
  cin >> N;

  ull L[100];
  for (int i = 0; i < 100; ++i) L[i] = 0;

  L[0] = 2;
  L[1] = 1;

  ull ans = Lucas(N, L);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
n=int(input())
s=[]
for i in range(n):
    s.append(int(input()))
s.sort()
S=sum(s)
ans=S
min=-1
if S % 10 == 0:
    for i in s:
        if i % 10 != 0:
            min=i
            break
else:
  min=0
  
if min >= 0:
    print(ans-min)
else:
    print(0)



Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,s,e) for(int (i)=s;(i)<(e);++i)
#define mrep(i,s,e) for(int (i)=s;(i)>(e);--i)
typedef long long ll;
const ll INF=1e18,MOD=1e9+7;
const int iINF=1e9;
int main(){
    string s;
    cin>>s;
    bool flag=true;
    for(int i=0;i<s.size();i++){
        int cnt=0;
        for(int j=0;j<s.size();j++){
            if(s[i]==s[j])cnt++;
        }
        if(cnt!=2)flag=false;
    }
    if(flag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    abs(x - a) < abs(x - b) ? OP("A") : OP("B");
    return 0;
}

Measured memory_bytes: 256
#1行目
hoge = gets.chomp.to_i

#2行目読み込み
b = gets.chomp.split(" ").map!{|i| i.to_i}

c = b.max(hoge)
unchi = 0

for i in 0..(hoge-1) do
  unchi = unchi + c[i] / (2.0**(i+1))
end
 print unchi + c[hoge-1] / 2.0**hoge

Measured memory_bytes: 3836
#include <iostream>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
  int N; cin >> N;
  string s; cin >> s;
  int r = 0, b = 0;
  for (int i=0; i<N; i++) {
    if (s[i] == 'R') {
      r++;
    }
  }
  b = N-r;
  if(r>b)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 100005;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));

void solve()
{
    ll n;
    cin >> n;
    ll a[n];
    for(ll i=0;i<n;i++)   cin >> a[i];
        sort(a,a+n);
    ll ans = a[n-1];
    ll rem = n-2;
    for(ll i=n-2;i>=0;i--)
    {
        ll now = min(2LL,rem);
        ans += now*a[i];
        rem-=now;
    }
    cout<<ans;
}

int main()
{
    FAST;
    ll t = 1;
  //  cin >> t;
    while(t--)
    {
      solve();
    }
}

Measured memory_bytes: 5220
#include<stdio.h>

int main(void){
    int S;
    int h, m, s;
    scanf("%d",&S);
    h = S/(60*60);
    m = S%(60*60)/60;
    s = S%60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2092
while n = gets.chomp.to_i
  break if n.zero?

  sales = Hash.new{0}

  n.times do
    e, p, q = gets.chomp.split.map(&:to_i)
    sales[e] += p * q
  end

  achieved = sales.select{|k, v| v >= 1_000_000}
  achieved.each{|k, v| puts k}
  puts 'NA' if achieved.empty?
end

Measured memory_bytes: 8820
#include <bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long

main()
{
    fastio;
    int k, a, b;
    cin>>k>>a>>b;
    for(int i=a; i<=b; i++) {
        if(i%k==0) {
            cout<<"OK";
            return 0;
        }
    }
    cout<<"NG";
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define fatafat ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long
#define MOD ((long long)(1e9)+7)
#define excl(i,a,b) for(int i=a;i<b;i++)
#define incl(i,a,b) for(int i=a;i<=b;i++)
#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define PII pair<int,int>

using namespace std;

int binexp(int a,int b)
{
    if(b)
    {
        if(b%2)
            return a*binexp(a*a,b/2);
        return binexp(a*a,b/2);
    }
    return 1;
}

int modexp(int a,int b,int m)
{
    if(b)
    {
        if(b%2)
            return (a*modexp((a*a)%m,b/2,m))%m;
        return modexp((a*a)%m,b/2,m);
    }
    return 1;
}

int mygcd(int a,int b)
{
    if(b==0)
        return a;
    return mygcd(b,a%b);
}

int euclidgcd,euclidx,euclidy;

void exteuclid(int a,int b)
{
    if(b==0)
    {
        euclidgcd=a;
        euclidx=1;
        euclidy=0;
    }
    else
    {
        exteuclid(b,a%b);
        int temp=euclidx;
        euclidx=euclidy;
        euclidy=temp-euclidy*(a/b);
    }
}

int modinv(int a,int m)
{
    exteuclid(a,m);
    return (euclidx%m + m)%m;
}

int pmodinv(int a,int m)
{
    return modexp(a,m-2,m);
}

bool checkprime(int a)
{
    for(int i=2;i*i<=a;i++)
        if(a%i==0)
            return false;
    return true;
}

vector<bool> seive(int n)
{
    vector<bool> ret(n+1,true);
    ret[0]=ret[1]=false;
    for(int i=2;i*i<=n;i++)
        if(ret[i])
            for(int j=i*i;j<=n;j+=i)
                ret[j]=false;
    return ret;
}

vector<bool> seivelims(int l,int r)
{
    vector<bool> ret(r-l+1,true);
    for(int i=2;i*i<=r;i++)
    {
        for(int j=max(i*i,((l+i-1)/i)*i);j<=r;j+=i)
        {
            ret[j-l]=false;
        }
    }
    return ret;
}

vector<int> rootnfact(int n)
{
    vector<int> ret;
    for(long i=2;i*i<=n;i++)
        while(n%i==0)
        {
            ret.push_back(i);
            n/=i;
        }
    if(n!=1)
        ret.push_back(n);
    return ret;
}

vector<int> prelognfact(int n)
{
    vector<int> minprime(n+1,0);
    minprime[0]=minprime[1]=0;
    for(int i=2;i*i<=n;i++)
    {
        if(minprime[i]==0)
        {
            for(int j=i*i;j<=n;j+=i)
            {
                if(minprime[j]==0)
                    minprime[j]=i;
            }
        }
    }
    for(int i=2;i<=n;i++)
        if(minprime[i]==0)
            minprime[i]=i;
    return minprime;
}

vector<int> lognfact(int n,vector<int> minprime)
{
    vector<int> ret;
    while(n!=1)
    {
        ret.push_back(minprime[n]);
        n/=minprime[n];
    }
    return ret;
}

signed main()
{
    fatafat;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max(0LL,c-a+b);
}

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

using namespace std;

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

    int n, a;
    cin >> n >> a;
    cout << (n % 500 <= a ? "Yes" : "No");

    return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD 1000000007

vector<int> adj[100010];
ll dp1[100010], dp2[100010];

//dp1[u] = number of ways where u is painted black
//dp2[u] = number of ways where u is painted white

void dfs(int u, int p) {
    ll sum1 = 1, sum2 = 1;

    for(auto v : adj[u]) {
        if(p == v) continue;
        dfs(v, u);

        sum1 *= dp2[v] % MOD;
        sum1 %= MOD;
        
        sum2 *= (dp1[v] + dp2[v]) % MOD;
        sum2 %= MOD;
    }


    dp1[u] = sum1;
    dp2[u] = sum2;

}

int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    for(int i = 0; i + 1 < n; i++) {
        int u, v;
        cin >> u >> v;

        u--, v--;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }

//    for(int i = 0; i < n; i++) {
//        cout << i << " > ";
//        for(int x : adj[i]) cout << x << " ";
//        cout << endl;
//    }

    dfs(0, -1);
    cout << (dp1[0] + dp2[0]) % MOD << endl;
}

/*
 * P
 **/


Measured memory_bytes: 14208
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[200010];
ll kai[200010];
ll m;
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=m;
    }
    now*=now;
    now%=m;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}
void nckinit(ll n){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  gya[n]=gyaku(kai[n]);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=mod;
  }
  gya[0]=1;
}    
ll nck(ll n,ll k){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  ret*=gya[k];
  ret%=mod;
  return ret;
}
ll npk(ll n,ll k){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  return ret;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin>>s>>t;
  int ans=0;
  rep(i,0,3){
    if(s[i]==t[i])ans++;
  }
  cout<<ans<<endl;
}


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

using namespace std;

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

typedef pair<int, int> P;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    int a=0, b=0, c=0;
    REP(i,s.length()){
        if(s[i]=='a') a++;
        else if(s[i]=='b') b++;
        else if(s[i]=='c') c++;
    }
    if(abs(a-b)>1||abs(b-c)>1||abs(c-a)>1) print("NO");
    else print("YES");
    return 0;
}

Measured memory_bytes: 512
import java.util.*;
class Main{
 static int help(int a){
 int s=a;
    while(s>91){
      int p=0;
      while(a>0){
        p=p+a%10;
        a=a/10;
      }
      s=p;
    }
   return s;
  }
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
   String n=sc.nextLine();
    int a=0;
    for(int i=0;i<n.length();i++){
    a=a+n.charAt(i)-'0';
     
    }
    if(a<91){
      if(a%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }}
    
    else{
      int b=help(a);
         if(b%9==0){
      System.out.println("Yes");
      }else{
        System.out.println("No");
      }
   
  }}}


Measured memory_bytes: 41564
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T,T MOD = 1000000007>
struct Mint{
  T v;
  Mint():v(0){}
  Mint(signed v):v(v){}
  Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

  Mint pow(long long k){
    Mint res(1),tmp(v);
    while(k){
      if(k&1) res*=tmp;
      tmp*=tmp;
      k>>=1;
    }
    return res;
  }
  
  Mint inv(){return pow(MOD-2);}
  
  Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
  Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
  Mint& operator/=(Mint a){return (*this)*=a.inv();}
  
  Mint operator+(Mint a) const{return Mint(v)+=a;};
  Mint operator-(Mint a) const{return Mint(v)-=a;};
  Mint operator*(Mint a) const{return Mint(v)*=a;};
  Mint operator/(Mint a) const{return Mint(v)/=a;};

  Mint operator-(){return v?MOD-v:v;}

  bool operator==(const Mint a)const{return v==a.v;}
  bool operator!=(const Mint a)const{return v!=a.v;}
  bool operator <(const Mint a)const{return v <a.v;}

};

//INSERT ABOVE HERE
signed main(){
  int n,k;
  cin>>n>>k;
  using M = Mint<int>;
  vector<M> dp(n+1,0);
  dp[0]=M(1);
  for(int i=0;i<k-1;i++){
    for(int j=1;j<=n;j++) dp[j]+=dp[j-1];
    dp[i]=M(0);    
  }
  M ans;
  for(int i=0;i<n;i++) ans+=dp[i];
  ans*=M(2).pow(n==k?0:n-k-1);
  cout<<ans.v<<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++)

int main() {
  int an[9];
  rep(i,9) cin >> an[i];
  int n, b;
  cin >> n;
  int bn[9];rep(i,9) bn[i] = 0;
  rep(k,n) {
    cin >> b;
    rep(i,9) if (an[i] == b) bn[i] = 1;
  }
  bool flg = false;
  rep(i,3) {
    if (bn[3*i] + bn[3*i+1] + bn[3*i+2] == 3) flg = true;
    else if (bn[i] + bn[3+i] + bn[6+i] == 3) flg = true;
  }
  if (bn[0] + bn[4] + bn[8] == 3) flg = true;
  if (bn[2] + bn[4] + bn[6] == 3) flg = true;
  
  if (flg) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
import sys
from operator import itemgetter
input = sys.stdin.readline

N = int(input())
IN = []
for _ in range(N):
    s = input().split()
    A = int(s[0])
    B = int(s[1])
    R = A + B
    IN.append((A,B,R))

sortedIN = sorted(IN, key=itemgetter(2), reverse=True)
sortedIN.append((0,0,0))

sum_A = 0
sum_B = 0

for i in range(0, N, 2):
    sum_A += sortedIN[i][0]
    sum_B += sortedIN[i+1][1]

print(sum_A - sum_B)



Measured memory_bytes: 61280