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

using namespace std;

int main()
{
   int t,count=0,max=0;
   string s;
    cin>>t;
   cin>>s;
    for(int i=0;i<t;i++)
   {

    if(s[i]=='I')
    {
        count++;
    }
    else if(s[i]=='D')
    {
        count--;
    }
    if(max<count)
    {
        max=count;
    }
     }
     cout<<max;
    return 0;
}

Measured memory_bytes: 256
import Control.Monad

check :: String -> Bool
check xs
  | null xs = True
  | five == "dream" && seven == "dreamer" = base || check (drop 7 xs)
  | five == "erase" && six == "eraser" = base || check (drop 6 xs)
  | five == "erase" || five == "dream" = base
  | otherwise = False
              where five = take 5 xs
                    six = take 6 xs
                    seven = take 7 xs
                    base = check (drop 5 xs)

main = do
  string <- getLine :: IO String
  if check string then putStrLn "YES" else putStrLn "NO"

Measured memory_bytes: 7548
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define rep1(i, n) for (int i = 1; i < int(n); ++i)
#define repx(i, x, n) for (int i = int(x); i < int(n); ++i)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; --i)
#define ALL(n) begin(n), end(n)
#define IN(a, x, b) ((a) <= (x) && (x) < (b))
#define OUT(a, x, b) ((x) < (a) || (x) < (b))
typedef long long ll;
typedef long double ld;
const ll INF = 1e18;
const ll MOD = 1000000007;

int main()
{
    int a, b, ans = 0;
    cin >> a >> b;
    repx(i, a, b + 1)
    {
        if ((i / 10000 == i % 10) && ((i / 1000) % 10) == (i / 10) % 10)
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const int maxn=1E5+5; 
ll n,sum,pre[maxn];
struct pt
{
	ll x,y;
	bool operator<(const pt&A)const
	{
		return max(x,y)<max(A.x,A.y);
	}
}a[maxn];
inline int get(int pos)
{
	int l=0,r=n,mid;// !!!!!!!!!!!!!!!
	int d=max(a[pos].x,a[pos].y);
	while(l<r)
	{
		mid=(l+r+1)>>1;
		ll s=pre[mid]-(mid>=pos?d:0);
		if(s<=sum)
			l=mid;
		else
			r=mid-1;
	}
	return l;
}
ll gcd(ll x,ll y)
{
	if(y==0)
		return x;
	return x%y==0?y:gcd(y,x%y);
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;++i)
	{
		cin>>a[i].x>>a[i].y;
		sum+=max((ll)0,a[i].y-a[i].x);
	}
	sort(a+1,a+n+1);
	for(int i=1;i<=n;++i)
		pre[i]=pre[i-1]+max(a[i].x,a[i].y);
	ll ax=0,ay=1;
	for(int i=1;i<=n;++i)
	{
		int pos=get(i);
		ll s=sum-pre[pos];
		if(pos>=i)
			--pos,s+=max(a[i].x,a[i].y);
		if(a[i].y>a[i].x)
			s-=a[i].y-a[i].x;//!!!!!!!!!!!!! 
		ll x=(ll)pos*a[i].y+min(s+a[i].y-a[i].x,a[i].y);
		ll y=n*a[i].y;
		if(x<=0)
			continue;
		ll z=gcd(x,y);
		x/=z,y/=z;
		if((ld)ay*x>(ld)y*ax)
			ax=x,ay=y;
	}
	cout<<ax<<" "<<ay<<endl;
	return 0;
}


Measured memory_bytes: 6008
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


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

  long long num0 = N / K;
  if(K % 2 != 0) {
    cout << num0 * num0 * num0 << endl;
  }else {
    int k = K / 2;
    long long ans = 0;
    ans += num0 * num0 * num0;
    long long n = 0;
    for(int i = 1;i <= N;i++) {
      if(i % K == k) n++;
    }
    ans += n * n * n;
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
# from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
# n=1000000000000001

def num2alpha(num):
    if num<=26:
        return chr(64+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(90)
    else:
        return num2alpha(num//26)+chr(64+num%26)
print(num2alpha(n).lower())

Measured memory_bytes: 9180
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	string sa, sb, sc;
	cin >> sa >> sb >> sc;

	char turn = 'a';
	char ans;


	while (true) {
		if (turn == 'a') {
			if (sa.size() == 0) {
				ans = 'A';
				break;
			}
			turn = sa[0];
			sa.erase(sa.begin() + 0);
		}
		else if (turn == 'b') {
			if (sb.size()==0) {
				ans = 'B';
				break;
			}
			turn = sb[0];
			sb.erase(sb.begin() + 0);
		}
		else if (turn == 'c') {
			if (sc.size()==0) {
				ans = 'C';
				break;
			}
			turn = sc[0];
			sc.erase(sc.begin() + 0);

		}

	}

	cout << ans << endl;

}

Measured memory_bytes: 3636
def main():
    n = int(input())
    happy = []
    for i in range(n):
        happy.append(list(map(int, input().split())))
    
    dp = [[0 for i in range(3)] for j in range(100010)]

    def chmax(a, b):
        if a < b:
            a = b
        return a

    for i in range(n):
        for j in range(3):
            for k in range(3):
                if j == k:
                    continue
                dp[i + 1][k] = chmax(dp[i + 1][k], dp[i][j] + happy[i][k])
    
    print(max(dp[n]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 74840
//#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e6 + 50;
const int mod = 1e9 + 7;
int l,ans;
char s[N];
stack <int> st;
int main()
{
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdout);
//    ios::sync_with_stdio(false);
//    cin.tie(NULL);
    scanf("%s", s + 1);
    l = strlen(s + 1);
    for (int i = 1; i <= l; ++i)
    {
        if (st.empty() || st.top() == s[i] - '0')
            st.emplace(s[i] - '0');
        else
            ans += 2, st.pop();
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout<<'\n'
#define sor(x) sort(x.begin(),x.end())
#define rev(v) reverse(v.begin(),v.end())
#define llmax 100000000000000000
#define deb(x) cout<<"value here is "<<x<<"\n"
#define pll pair<ll,ll>
#define vll vector <ll>
#define rub cout<<"ohlala"<<'\n';
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    vll v;
    while(n--)
    {
        ll l;
        cin>>l;
        v.pb(l);
    }
    n=v.size();
    sor(v);
    ll count=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+2;j<n;j++)
        {
            auto it=upper_bound(v.begin()+i+1,v.begin()+j,v[j]-v[i]);
            //cout<<v[j]-v[i]<<" ";
            if(it!=v.end())
            count+=j-(it-v.begin());
        }
    }
    cout<<count;
}

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

#define M 1050000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key%M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
    long long  kkk;
    long long b, i;
    kkk = getKey(str);
    for(i=0; ; i++) {
        b=(h1(kkk)+i*h2(kkk))%M;
        if(strcmp(H[b],str)==0)return 1;
        else if(strlen(H[b])==0)return 0;
    }
    return 0;
}

int insert(char str[]){
long long x,i,h;
    x=getKey(str);
    for(i=0;;i++){
        h=(h1(x)+i*h2(x))%M;
        if(strcmp(H[h],str)==0)return 1;
        else if(strlen(H[h])==0) {
            strcpy(H[h],str);
            return 0;
        }
    }
    return 0;

    /* your task */

}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';

    scanf("%d", &n);

    for ( i = 0; i < n; i++ ){
	scanf("%s %s", com, str);

	if ( com[0] == 'i' ){
	    insert(str);
	} else {
	    if (find(str)){
		printf("yes\n");
	    } else {
		printf("no\n");
	    }
	}
    }

    return 0;
}


Measured memory_bytes: 16104
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdlib>
#include<cstdio>
#include<utility>
#include<list>
using namespace std;
int main(){
	int seat[110000];
	int n,cnt=0;
	cin>>n;
	int l[n],r[n];
	for(int i=0;i<n;i++){
		l[i]=0; r[i]=0;
	}
	for(int i=0;i<n;i++)cin>>l[i]>>r[i];

	for(int i=0;i<n;i++){
		for(int j=l[i]-1;j<r[i];j++){
			seat[j] = 1;
		}
	}
	for(int i=0;i<100000;i++){
		if(seat[i]==1) cnt++;
	}

	cout<< cnt <<endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u>
bool chmax(t &a, u b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class t, class u>
bool chmin(t &a, u b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    int n, y;
    cin >> n >> y;
    int ans = 0;
    rep(i, n + 1)
    {
        for (int j = 0; i + j <= n; j++)
        {
            if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y)
            {
                cout << i << " " << j << " " << n - i - j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int n;
    int a[1000];
    cin>>n;
    for (int i=0; i<n; i++) {
        cin>>a[i];
    }
    
    for (int i=1; i<=n;i++) {
        sort(a, a+i);
        for (int k=0;k<n-1;k++) {
            cout<<a[k]<<" ";
        }
        cout<<a[n-1]<<endl;
    }
}

Measured memory_bytes: 3064
import math
n = int(input())
ans = 10

def fun(a,b):
    if len(str(a)) <= len(str(b)):
        return(len(str(b)))
    else:
        return(len(str(a)))

#print(fun(125,80))

b =int(math.sqrt(n+1) // 1) + 1
#print(b)

for i in range(1,b):
    if n % i == 0:
#        print(i,int(n/i))
        if ans > fun(i,int(n/i)):
            ans = fun(i,int(n/i))
#            print(ans)

print(ans)


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

#define AndIamIronMan ios::sync_with_stdio(false); cin.tie(0);cout.tie(0); 
 
using namespace std;
 
typedef  long long int lli; 

int main(){
    
    lli i,x,j,k,n,y,m,t,a,b; 	
    AndIamIronMan;
//    cin>>t;
//    while(t--){
	cin>>n;
	lli ar[n];
	x=0;
	for(i=0;i<n;i++){
		cin>>ar[i];
		x=(lli)x^(lli)ar[i];
	}
//	cout<<"x"<<x;
	for(i=0;i<n;i++){
		cout<<((lli)ar[i]^(lli)x)<<" ";
	}
	
//	}
	return 0;
}


Measured memory_bytes: 5176
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#include<string.h>
#define pi acos(-1.0)
using namespace std;
int n,m;
const int maxn=2e5+10;
vector<int>vec[maxn];
int sum[maxn];int pre[maxn];
void bfs()
{
	queue<int>q;q.push(1);
	sum[1]=0;
	while(!q.empty())
	{
		int u=q.front();q.pop();
		for(int i=0;i<vec[u].size();i++)
		{
			int v=vec[u][i];
			//cout<<v<<endl;
			if(sum[v]>sum[u]+1)
			{
				pre[v]=u;
				sum[v]=sum[u]+1;
			//	cout<<sum[v]<<endl;
				q.push(v);
			}
		}
	}
	
}
int main()
{
  int n,m;cin>>n>>m;
  memset(sum,inf,sizeof(sum));
  for(int i=1;i<=m;i++)
  {
  	int x,y;cin>>x>>y;
  	vec[x].push_back(y);
	vec[y].push_back(x); 
  }
  bfs();bool f=true;
   for(int i=1;i<=n;i++)
   {
   //	cout<<sum[i]<<endl;
   	if(sum[i]==inf)f=false;
   }
  if(!f)cout<<"No"<<endl;
  else
  {
  	   cout<<"Yes"<<endl;
  	    for(int i=2;i<=n;i++)
  	    cout<<pre[i]<<endl;
  }
	return 0;
 } 

Measured memory_bytes: 13544
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
if 0 in a:
    print(0)
    quit()
ans = 1
for i in a:
    ans *= i
    if ans > 10**18:
        print(-1)
        quit()
print(ans)


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

vector<vector<int>> a(0, vector<int>(0));
vector<vector<int>> b(0, vector<int>(0));
int zre(int n){
	a.push_back({1});
	rep(ii, n-1){
		int k = a.size();
		int l = a.at(0).size();
		rep(i, k) a.at(i).push_back(l+1);
		rep(i, k){
			rep(j, l+1){
				b.push_back({});
				rep(m, l+1) b.at(i*(l+1)+j).push_back(a.at(i).at((m+j)%(l+1)));
			}
		}
		while(a.size() != 0){
			a.pop_back();
		}
		rep(i, b.size()) a.push_back(b.at(i));
		while(b.size() != 0){
			b.pop_back();
		}
	}
	sort(a.begin(), a.end());
	return 0;
}

int main(){
	int n;
	cin >> n;
    vector<int> ns0(n);
    vector<int> ns1(n);
    rep(i, n) cin >> ns0.at(i);
    rep(i, n) cin >> ns1.at(i);
    zre(n);
    int c, d;
    int f0 = 0;
    int f1 = 0;
    rep(i, a.size()){
      f0 = 0;
      f1 = 0;
      rep(j, n){
        if(a.at(i).at(j) != ns0.at(j)) f0 = 1;
        if(a.at(i).at(j) != ns1.at(j)) f1 = 1;
      }
      if(f0 == 0) c = i+1;
      if(f1 == 0) d = i+1;
    }
    cout << abs(c-d) << endl;
    return 0;
}

Measured memory_bytes: 6384
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
x=y=z=0
for i in range(n):
    if p[i]<=a :
        x+=1
    if p[i]>=a+1 and b>=p[i]:
        y+=1
    if p[i]>=b+1:
        z+=1
print(min(x,y,z))

Measured memory_bytes: 3064
import sys

N = int(input())
X = list(map(int, input().split()))
if min(X) == 0:
  print(0)
  sys.exit()
Y = X[0]
for i in range(1, N):
  Y = X[i] * Y
  if Y > 10 ** 18:
    print(-1)
    sys.exit()
print(Y)



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


if x == sum(A):
    print(N)
elif x > sum(A):
    print(N-1)
else:
    cnt = 0
    A.sort()
    for a in A:
        if x < a:
            break
        cnt += 1
        x -= a
    print(cnt)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline
x = int(input())
for oni in range(1001):
    cnt = oni * 100
    if cnt > x:
        break
    for sand in range(1001):
        cnt2 = cnt
        cnt2 += sand * 101
        if cnt2 > x:
            break
        for cookie in range(1001):
            cnt3 = cnt2
            cnt3 += cookie * 102
            if cnt3 > x:
                break
            for cake in range(1001):
                cnt4 = cnt3
                cnt4 += cake * 103
                if cnt4 > x:
                    break
                for candy in range(1001):
                    cnt5 = cnt4
                    cnt5 += candy *104
                    if cnt5 > x:
                        break
                    for pc in range(1001):
                        cnt6 = cnt5
                        cnt6 += pc * 105
                        if cnt6 == x:
                            print(1)
                            exit()
                        elif cnt6 > x:
                            break
print(0)
    



Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String args[])
    {
        Scanner in = new Scanner(System.in);
        int k = in.nextInt();
        int a = in.nextInt();
        int b = in.nextInt();
        boolean works = false;
        for(int i = a; i <= b; i++)
        {
            if(i % k == 0)
            {
                works = true;
            }
        }
        if(works)
        {
            System.out.println("OK");
        }
        else
        {
            System.out.println("NG");
        }
    }
}


Measured memory_bytes: 35672
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
   ll dp[2000000];
 int gcd(int a, int b)
{
  if (a%b == 0)
{
return(b);
}
else
{
return(gcd(b,a%b));
}
}
int main(){
  ll a,c;cin>>a>>c;
  ll b=a%500;
  if(b<=c)cout<<"Yes";
  else cout<<"No";
}



Measured memory_bytes: 27068
#include <stdio.h>
char a[15];
int main(){
	int ans = 0;
	scanf("%s",a);
	for(int i=0;a[i]!=0;i++){
		for(int j=i;a[j]!=0;j++){
			bool isACGT = true;
			for(int k=i;k<=j;k++){
				if(a[k]!='A'&&a[k]!='C'&&a[k]!='G'&&a[k]!='T'){
					isACGT = false;
				}
			}
			if(isACGT) ans = ans > j-i+1 ? ans : j-i+1;
		}
	}
	printf("%d\n",ans);
}

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

int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;

	int ans = 0;
	char mem = 'A';
	rep(i, n) {
		if (mem != s[i]) ans++;
		mem = s[i];
	}

	cout << ans << endl;
}

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

using namespace std;

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;

using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)

#define CHMIN(a,b) (a)=min((a),(b))
#define CHMAX(a,b) (a)=max((a),(b))
#define ALL(v) (v).begin(),(v).end()

#define DEBUG(x) cerr<<#x<<": "<<(x)<<endl
#define DEBUG_VEC(v) cerr<<#v<<": ";REP(__i,(v).size())cerr<<((v)[__i])<<", ";cerr<<endl

const ll MOD = 1000000007ll;

int main(){
    string ss[7] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin>>s;
    int i = find(ss, ss+7, s) - ss;
    cout << (7-i) << endl;
    return 0;
}


Measured memory_bytes: 256
n =int(input())
a = list(map(int,input().split()))
c = [0 for _ in range(n+1)]
ans = 0
for i in range(n):
  if a[i] <= n:
    c[a[i]] += 1
  else:
    ans += 1
for i in range(n+1):
  if c[i] >= i:
    ans += c[i] - i
  else:
    ans += c[i]
print(ans)



Measured memory_bytes: 90704
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int s = sc.nextInt();
		
		Set<Integer> set = new HashSet<>();
		set.add(s);
		
		int i = 1;
		while (true) {
			i++;
			s = f(s);
			if (!set.add(s)) break;
		}
		
		System.out.println(i);
		
		sc.close();
	}
	
	static int f(int n) {
		if (n % 2 == 0) return n / 2;
		return 3 * n + 1;
	}
}




Measured memory_bytes: 27104
import math
def prime(n):
    for i in range(2, int(math.sqrt(n))+1):
        if  n % i == 0:
            return False
    return True
num_prime = []
k = 0
while True:
    try:
        n = input()
    except:
        break
    if prime(int(n)):
        if not int(n) in num_prime:
            k += 1
            num_prime.append(int(n))
print(k)


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

int a[3][3];
int x[3], y[3];

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

  rep(i,3){
    rep(j,3) cin >> a[i][j];
  }
  
  x[0] = 0;
  rep(i,3) y[i] = a[0][i] - x[0];
  rep(i,3) x[i] = a[i][0] - y[0];

  bool good = true;
  rep(i,3){
    rep(j,3){
      if(x[i] + y[j] != a[i][j]) good = false; 
    }
  }

  if(good) cout << "Yes" << '\n';
  else cout << "No" << '\n';
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9) + 7;

    public static void main(String[] args) {
        try (Scanner in = new Scanner(System.in)) {
//            while (true)// MAKE SURE TO REMOVE THIS
                solve(in);
        }
    }

    private static final List<Integer> furui(int N) {
        boolean[] furui = new boolean[N + 1];
        for (int i = 2; i < N + 1; i++) {
            furui[i] = true;
        }
        List<Integer> ret = new ArrayList<>(N);
        for (int i = 2; i <= N; i++) {
            if (furui[i]) {
                ret.add(i);
                for (int j = i + i; j <= N; j += i) {
                    furui[j] = false;
                }
            }
        }
        return ret;
    }

    private static void solve(Scanner in) {
        int N = in.nextInt();
        List<Integer> ps = furui(N);
        long[] hist = new long[N + 1];
        for (int p : ps) {
            int h = 0;
            int n = N;
            while (n / p > 0) {
                n /= p;
                h += n;
            }
            hist[p] = h;
        }
        long count = 1;
        for (int i = 0; i < N + 1; i++) {
            count *= (hist[i] + 1);
            count %= MOD;
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 9044
package main

import (
	"fmt"
	"strconv"
	"strings"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	as := strings.Repeat(strconv.Itoa(a), b)
	bs := strings.Repeat(strconv.Itoa(b), a)

	if as < bs {
		fmt.Println(as)
	} else {
		fmt.Println(bs)
	}
}


Measured memory_bytes: 640
def main():
    # n = int(input())
    # n, m = map(int, input().split())
    # a = list(map(int, input().split()))
    # s = input()
    # h = [int(input()) for _ in rane(n)]
    a = int(input())
    b = int(input())
    c = int(input())
    d = int(input())
    e = int(input())
    k = int(input())
    if abs(a-b)>k or abs(a-c)>k or abs(a-d)>k or abs(a-e)>k or abs(b-c)>k or abs(b-d)>k or abs(b-e)>k or abs(c-d)>k or abs(c-e)>k or abs(d-e)>k:
        print(":(")
    else:
        print("Yay!")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61944
N = int(input())
H = list(map(int,input().split()))

for i in range(1, N)[::-1]:
  d = H[i] - H[i-1]
  if d >= 0:
    continue
  elif d == -1:
    H[i-1] -= 1
  else:
    print("No")
    exit()
print("Yes")

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

int main(void){
  int n;
  cin>>n;
  for(int i = 0 ; i < n ; i++){
    int c,a,n;
    int cnt = 0;
    cin>>c>>a>>n;
    while(a>=1&&c>=1&&n>=1){
      a--;c--;n--;
      cnt++;
    }
    while(a>=1&&c>=2){
      c-=2;
      a --;
      cnt ++;
    }
    while(c>=3){
      c-=3;
      cnt ++;
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define endl '\n'
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int m,n,ans[100050],pre[100050],suf[100050],dp[100050];
vector<int>ve[100050];
void dfs(int u,int fa){
	int lim=ve[u].size(),y;
	dp[u]=1;
	for(int i=0;i<lim;i++)if((y=ve[u][i])!=fa){
		dfs(y,u);
		pre[y]=dp[u];
		dp[u]=(dp[y]+1)*1ll*dp[u]%m;
	}
	int k=1;
	for(int i=lim-1;i>=0;i--)if((y=ve[u][i])!=fa){
		suf[y]=k;
		k=(dp[y]+1)*1ll*k%m;
	}
}
void get_ans(int u,int fa,int t){
	ans[u]=(t+1)*1ll*dp[u]%m;
	int lim=ve[u].size(),y;
	for(int i=0;i<lim;i++)
		if((y=ve[u][i])!=fa)
			get_ans(y,u,(t+1)*1ll*pre[y]%m*suf[y]%m);
}
int main(){
	int u,v;
	cin>>n>>m;
	for(int i=1;i<n;i++){
		cin>>u>>v;
		ve[u].pb(v);
		ve[v].pb(u);
	}
	dfs(1,0),get_ans(1,0,0);
	for(int i=1;i<=n;i++)cout<<ans[i]<<endl;
}


Measured memory_bytes: 13824
import sys
from collections import deque
import copy

from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

#class edge:
#    def __init__(x, y, cost):

class point_node:
    def __init__(self, point, cost):
        self.point = point
        self.cost = cost

def  BFS(con_list, start_point):
    cost_list = {}
    cost_list[start_point] = 0

    node_list = deque([point_node(start_point, 0)])
    while 1:
        #new_node_list = []
        #for i in range(len(node_list)):
        now_node = node_list.popleft()
        connects = con_list[now_node.point]
        for c in connects:
            if c[0] not in cost_list:
                cost_list[c[0]] = c[1] + now_node.cost
                node_list.append(point_node(c[0], c[1] + now_node.cost))
        if len(node_list) == 0:
            break
        #node_list = copy.deepcopy(new_node_list)

    return cost_list


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [int(input_raw[0])]
    pass_dict = {}
    for i in range(N - 1):
        input_raw = read_func().strip().split()
        [a, b, c] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        if a not in pass_dict:
            pass_dict[a] = []
        pass_dict[a].append((b, c))
        if b not in pass_dict:
            pass_dict[b] = []
        pass_dict[b].append((a, c))

    input_raw = read_func().strip().split()
    [Q, K] = [int(input_raw[0]), int(input_raw[1])]

    cost_list = BFS(pass_dict, K)

    for i in range(Q):
        input_raw = read_func().strip().split()
        [x, y] = [int(input_raw[0]), int(input_raw[1])]
        print cost_list[x] + cost_list[y]


if __name__ == '__main__':
    main()


Measured memory_bytes: 90516
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(auto &I:a){cin>>I; I--;}
    priority_queue<ll> Q;
    vector<ll> ans;
    for(int i=0;i<n;i++){
        if(a[i]==i){Q.push(i);}
    }
    while(!Q.empty()){
        ll w=Q.top(); Q.pop();
        ans.push_back(w);
        for(ll i=w;i+1<a.size();i++){
            a[i]=a[i+1];
            if(a[i]==i){Q.push(i);}
        }
        a.pop_back();
    }
    reverse(ans.begin(),ans.end());
    if(ans.size()!=n){cout<<-1<<endl;}
    else{
        for(auto &I:ans){cout<<I+1<<endl;}
    }
    
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <sstream>	// require stringstream 
//#include <fstream>	// require freopen

using namespace std;

bool do_lot (vector<string> path, vector <int> c, vector <int> e )
{
	int size = path.size();
	int n = c.size();

	for (int i = 0; i < size; ++i ){
		for (int j = 0; j < n - 1; ++j ){
			if (path[i][j] == '1' ){
				swap (c[j], c[j+1] );
			} // end if
		} // end for
	} // end for

	return (c == e );
}

bool isinsert_one (string str, int n )
{
	str = '0' + str + '0';
	
	return (str[n+1-1] == '0' && str[n+1+1] == '0' );
} 

string itos (int n )
{
	stringstream ss;
	ss << n;

	return ss.str();
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.dlII", "r", stdin );
	int n;

	while (cin >> n && n ){
		int m, h, d;
		cin >> m >> h >> d;
		vector <int> s(n, 0 ), e(n, 0 );
		string res = "";
	
		s[--m] = 1; e[--h] = 1;

		vector <string> path;

		for (int i = 0; i < d; ++i ) {
			string str = ""; 
			cin >> str;
			path.push_back (str );
		} // end for

		if (do_lot (path, s, e ) ){
			res += '0';
		}else{
			for (int i = 0; i < d; ++i ){
				for (int j = 0; j < n - 1; ++j ){
					if (path[i][j] == '0' 
					 && isinsert_one (path[i], j ) ){
						path[i][j] = '1';
						if (do_lot (path, s, e ) ){
							res += itos (i+1 );
							res += ' ';
							res += itos (j+1 );
							goto result;
						} // end if
						path[i][j] = '0';
					} // end if
				} // end for
			} // end for
		} // end if

result:
		if (res.empty() ){
			cout << '1' << endl;
		}else{
			cout << res << endl;
		} // end if
	} // end loop

	return 0;
}

Measured memory_bytes: 0
#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{
  static constexpr T mod = MOD;
  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;
  }

  static Mint add_identity(){return Mint(0);}
  static Mint mul_identity(){return Mint(1);}

  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-() const{return v?Mint(MOD-v):Mint(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;}

  // find x s.t. a^x = b
  static T log(T a,T b){
    const T sq=40000;
    unordered_map<T, T> dp;
    dp.reserve(sq);
    Mint res(1);
    for(Int r=0;r<sq;r++){
      if(!dp.count(res.v)) dp[res.v]=r;
      res*=a;
    }
    Mint p=Mint(a).inv().pow(sq);
    res=b;
    for(Int q=0;q<=MOD/sq+1;q++){
      if(dp.count(res.v)){
        T idx=q*sq+dp[res.v];
        if(idx>0) return idx;
      }
      res*=p;
    }
    assert(0);
    return T(-1);
  }

  static Mint comb(long long n,Int k){
    Mint num(1),dom(1);
    for(Int i=0;i<k;i++){
      num*=Mint(n-i);
      dom*=Mint(i+1);
    }
    return num/dom;
  }
};
template<typename T,T MOD> constexpr T Mint<T, MOD>::mod;
template<typename T,T MOD>
ostream& operator<<(ostream &os,Mint<T, MOD> m){os<<m.v;return os;}

//INSERT ABOVE HERE
using M = Mint<Int>;
const Int MAX = 2020;
M dp[MAX][MAX]={};
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> s(n),t(m);
  for(Int i=0;i<n;i++) cin>>s[i];
  for(Int i=0;i<m;i++) cin>>t[i];

  s.emplace_back(-1);
  t.emplace_back(-2);
  dp[0][0]=1;
  for(Int i=0;i<=n;i++){
    M res{0};
    for(Int j=0;j<=m;j++){
      dp[i+1][j]+=dp[i][j];
      dp[i][j+1]+=dp[i][j];
      dp[i+1][j+1]-=dp[i][j];
      if(s[i]==t[j]) dp[i+1][j+1]+=dp[i][j];
    }
  }
  cout<<dp[n][m]<<endl;
  return 0;
}


Measured memory_bytes: 32256
using System;
using System.Collections.Generic;

class MainClass
{
    public static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var p = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        var q = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

        var a = 0;
        var i = 0;
        perm(n, item =>
        {
            if (eq(p, item))
            {
                a = i;
                return true;
            }
            i++;
            return false;
        });


        var b = 0;
        i = 0;
        perm(n, item =>
        {
            if (eq(q, item))
            {
                b = i;
                return true;
            }
            i++;
            return false;
        });

        Console.WriteLine(Math.Abs(a - b));
    }

    static bool perm(int n, Func<int[], bool> func)
    {
        return _perm(0, new bool[n], new int[n], func);
    }

    static bool _perm(int i, bool[] v, int[] a, Func<int[], bool> pred)
    {
        if (v.Length <= i)
        {
            return pred(a);
        }

        for (int j = 0; j < v.Length; j++)
        {
            if (v[j]) continue;
            v[j] = true;
            a[i] = j + 1;

            if (_perm(i + 1, v, a, pred))
            {
                return true;
            }

            v[j] = false;
        }

        return false;
    }

    static bool eq(int[] x, int[] y)
    {
        for (int i = 0; i < x.Length; i++)
            if (x[i] != y[i])
                return false;

        return true;
    }
}


Measured memory_bytes: 11220
#include<iostream>
#include<math.h>
#include<algorithm>


using namespace std;
#define Int int64_t
#define dump(x) cout << (x) << endl
#define fi first
#define se second
Int mod = 1e9 + 7;
Int INF = 1e18;
double EPS = 0.00000001;
//Int mod = 1e6+3;


int main() {
	int n;
	cin >> n;
	int a[100001];
	if (n % 2 == 1) {
		cout << 0 << endl;
		return 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	cout << a[n / 2] - a[n / 2 - 1] << endl;
}


Measured memory_bytes: 640
#include <math.h>
#include <stdio.h>
int n, sqrtN;
long long ans, d;
char buf[8], out[20];
k;
i;
s;
X;
int main() {
    s = read(0, buf, 8);
    for(;;) {
        k = buf[i++];
        if(k < '0') break;
        n = n * 10 + k - '0';
    }
    const int sqrtN = sqrt(n);
    ans = -(long long)(sqrtN) * (sqrtN + 1) * (2 * sqrtN + 1) / 6;
    for(int i = 1; i <= sqrtN; ++i) {
        const int a = n / i;
        ans += ((long long)i * (i + a) * (a + 1 - i));
    }
    i = 20;
    do {
        out[--i] = ans % 10 + '0';
        ans /= 10;
    } while(ans);
    write(1, out + i, 20 - i);
}


Measured memory_bytes: 1780
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int solve(){
  ll n;std::cin >> n;
  vll a(n);re(i, n) std::cin >> a[i];
  string s;std::cin >> s;
  vvl dat = VV(61, 61, 0, ll);

  for(int i=n-1;i>=0;i--){
    if(s[i]=='1'){
      for(int j=0;j<61;j++){
        if(!dat[j][j]) continue;
        if(!((a[i]>>j)&1)) continue;
        for(ll k=0;k<61;k++)a[i] ^= (dat[j][k]<<k);
      }
      if(a[i]) return 1;
    }else{
      for(ll j=0;j<61;j++){
        if(((a[i]>>j)&1)==0) continue;
        if(!dat[j][j]){
          for(int k=0;k<61;k++) dat[j][k] = ((a[i] >> k)&1);
          break;
        }
        for(ll k=0;k<61;k++) a[i] ^= (dat[j][k]<<k);
      }
    }
  }
  return 0;
}
int main(int argc, char const *argv[]) {
  ll T;std::cin >> T;
  re(t, T) std::cout << solve() << '\n';
  return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
	int K, N;
	cin >> K >> N;
	
	int a0;
	cin >> a0;
	int a_last = a0;
	int d_max = 0;
	for(int i = 1; i < K; i++){
		int A;
		cin >> A;
		int d = A - a_last;
		if(d_max < d) d_max = d;
		a_last = A;
	}
	int d = a0 + K - a_last;
	if(d_max < d) d_max = d;
	
	cout << K - d_max << endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

n = INT()
a = LIST()
a.insert(0, 0)
a.append(0)
pre = 0
ans = 0
for i in range(n + 2):
    ans += abs(a[i] - pre)
    pre = a[i]
for i in range(1, n + 1):
    pans = ans - abs(a[i] - a[i - 1]) - abs(a[i] - a[i + 1]) + abs(a[i + 1] - a[i - 1])
    print(pans)

Measured memory_bytes: 85208
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<algorithm>
typedef long long int ll;
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define EFOR(i,a,b) for (int i=(a);i<=(b);i++)
const ll MOD = (10*10*10*10*10*10*10*10*10+7);

    int A,B,C;
    int N,M;
    int D[100];
    bool f=true;

int main(){
    REP(i,3){cin>>D[i];}
    sort(D,D+3);
    REP(i,3){
        if(i<=1){
            if(D[i]!=5){f=false;break;}
        }else{
            if(D[i]!=7){f=false;break;}
        }
    }
    f?cout<<"YES"<<endl:cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
 using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int>h(n+1,0);
  for(int i=1;i<n+1;i++)
  {
    cin>>h[i];  
  }
  vector<int>dp(n+1,0);
  {
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<n+1;i++)
    {
      dp[i]=fmin(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
      
    }
    cout<<dp[n]<<endl;
    
    
  }
  
  
  
  
  
  
}
  


Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
class Program
{	
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long L = long.Parse(str);
		long N = 20;
		long[,]A = new long[60,3];
		long ct = 0;
		while(ct < 19){
			A[ct,0] = ct + 1;
			A[ct,1] = ct + 2;
			A[ct,2] = 0;
			ct += 1;
		}
		long at = 1;
		long ai = 0;
		while(at * 2 <= L){
			A[ct,0] = ai + 1;
			A[ct,1] = ai + 2;
			A[ct,2] = at;
			at *= 2;
			ai += 1;
			ct += 1;
		}
		long la = L;
		la -= at;
		while(la > 0){
			if(la >= at / 2){
				A[ct,0] = ai;
				A[ct,1] = N;
				A[ct,2] = L-la;
				la -= at / 2;
				ct += 1;
			}
			ai -= 1;
			at /= 2;
		}
		Console.WriteLine(N+" "+ct);
		for(var i=0;i<ct;i++){
			Console.WriteLine(A[i,0]+" "+A[i,1]+" "+A[i,2]);
		}
	}
}

Measured memory_bytes: 11092
#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 ok = 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)){
                ok = false;
            }
        }
    }

    if(ok) cout << "APPROVED" << endl;
    if(!ok) cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define db(x){if(cond)cerr<<__LINE__<<" "<<#x<<" " <<x<<endl;}
#define rep(i,b)for(auto i=(0);i<(b);++i)
#define fo(i,a,b)for(auto i=(a);i<=(b);++i)
#define ford(i,a,b)for(auto i=(a);i>=(b);--i)
#define all(x) (x).begin(),(x).end()
#define vv vector
#define pb push_back
template<typename X>void MA(X&a,X b){a=max(a,b);}template<typename X>void MI(X&a,X b){a=min(a,b);}
template<typename X>void clr(X&x,int a){memset(x,a,sizeof(a));};typedef long long ll;typedef long double ld;
typedef array<int,2>i2;typedef vv<int>vi;int cond=0,multi=0,gcj=0;

struct solver_t;solver_t *solver;
struct solver_t{


  void solve(){
    string x;cin>>x;
    x[3]='8';
    cout<<x<<"\n";

  }
  void gen(){}
  void brute(){}
};

int main(int argc,char** argv){
  fo(i,1,argc-1)for(int j=0;argv[i][j];j++)if(argv[i][j]=='.')freopen(argv[i],"r",stdin);
  fo(i,1,argc-1)if(argv[i]==string("q"))cond=1<<30;
  fo(i,1,argc-1)if(argv[i]==string("gen")){(solver=new solver_t())->gen();exit(0);}
  fo(i,1,argc-1)if(argv[i]==string("brute")){(solver=new solver_t())->brute();exit(0);}
  ios::sync_with_stdio(false),cin.tie(0);
  cout.setf(ios::fixed),cout.precision(10);int t;if(multi||gcj)cin>>t;else t=1;
  fo(i,1,t){if(cond)cerr<<__LINE__<<" "<<i<<endl;if(gcj)cout<<"Case #"<<i<<": ";
    solver = new solver_t();
    solver->solve();
  }return 0;
}
template class std::vector<int>;
template class std::vector<ll>;


Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/

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

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    int a,b;
    cin>>a>>b;
    int t1=a+b;
    int t2=a-b;
    int t3=a*b;
    cout<<max(t1,max(t2,t3))<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[int(i) for i in input().split()]

one=[]
two=[]

for i in range(n):
    if i%2==0:
        one.append(a[i])
    else:
        two.append(a[i])

one_count=[0]*(10**5+1)
two_count=[0]*(10**5+1)

for i in one:
    one_count[i]+=1
for i in two:
    two_count[i]+=1

one_first_index=0
one_max_count=0
for i,value in enumerate(one_count):
    if one_max_count<value:
        one_max_count=value
        one_first_index=i
one_second_index=0
one_second_max_count=0
for i,value in enumerate(one_count):
    if one_second_max_count<value and i!=one_first_index:
        one_second_max_count=value
        one_second_index=i

two_first_index=0
two_max_count=0
for i,value in enumerate(two_count):
    if two_max_count<value:
        two_max_count=value
        two_first_index=i
two_second_index=0
two_second_max_count=0
for i,value in enumerate(two_count):
    if two_second_max_count<value and i!=two_first_index:
        two_second_max_count=value
        two_second_index=i



if one_first_index!=two_first_index:
    print(n-one_max_count-two_max_count)
elif one_max_count-one_second_max_count<=two_max_count-two_second_max_count:
    print(n - one_second_max_count - two_max_count)
else:
    print(n - two_second_max_count - one_max_count)





Measured memory_bytes: 20772
L,R = map(int, input().split(" "))
w = R-L


if w>2019:
    print(0)
else:
    List = [int(i) for i in range(L,R+1)]
    Min = 2018
    for i in range(len(List)-1):
        for j in range(i+1,len(List)):
            l = (List[j]*List[i])%2019
            if l<Min:
                Min = l
    print(Min)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char str[50];
int n;
int a,b;
int main()
{
	scanf("%s",&str);
	n=strlen(str);
	a=9*(n-1)+str[0]-'0'-1;
	for(int i=0;i<n;i++)
	b+=str[i]-'0';
	printf("%d",max(a,b));
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	while (1) {
		int n, i, j, a[5000], maxa = -100001, c;
		cin >> n;
		if (n == 0) {
			break;
		}
		for (i = 0; i < n; i++) {
			cin >> a[i];
		}
		for (i = 0; i < n; i++) {
			c = 0;
			for (j = i; j < n; j++) {
				c+= a[j];
				maxa = max(maxa, c);
			}
		}
		cout << maxa << endl;
	}
	return 0;
}

Measured memory_bytes: 1176
using System;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            if (x < 600) Console.WriteLine(8);
            else if (x < 800) Console.WriteLine(7);
            else if (x < 1000) Console.WriteLine(6);
            else if (x < 1200) Console.WriteLine(5);
            else if (x < 1400) Console.WriteLine(4);
            else if (x < 1600) Console.WriteLine(3);
            else if (x < 1800) Console.WriteLine(2);
            else Console.WriteLine(1);
        }
    }
}


Measured memory_bytes: 27396
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long H;
  cin >> H;
  
  long count = 0;
  for(long i=H; i>0; i/=2){
    count++;
  }

  long ans = (pow(2, count)-1);
  cout << ans << endl;
}

Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n,m;
int a[200005];
pair <int,int> in[100005];

bool cmp(pair <int,int> x,pair <int,int> y)
{
    return x.second > y.second;
}

int main()
{
    scanf("%d %d", &n, &m);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d", &a[i]);
    }

    for(int i = 1;i <= m;i++)
    {
        scanf("%d %d", &in[i].first, &in[i].second);
    }
    sort(a+1,a+n+1);
    sort(in+1,in+m+1,cmp);
    int ap = 1;
    for(int i = 1;i <= m;i++)
    {
        if(ap > n) continue;
        if(a[ap] >= in[i].second)
        {
            break;
        }
        for(int j = 1;j <= in[i].first;j++)
        {
            if(ap > n) break;
            if(a[ap] >= in[i].second)
            {
                break;
            }
            a[ap] = in[i].second;
            ap++;
        }
    }
    long long ans = 0;
    for(int i = 1;i <= n;i++)
    {
        ans += a[i];
    }
    printf("%lld",ans);
}

#endif // 1++


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,p[200010];
  cin >> n;
  int i;
  vector<int> x(200010);
  for(i=0;i<n;i++){
    cin >> p[i];
    x[p[i]]=i+1;
  }
  int ans=0,count=0,now=0;
  for(i=1;i<=n;i++){
    if(x[i]>now){
      count++;
      now=x[i];
    }
    else{
      ans=max(ans,count);
      now=x[i],count=1;
    }
  }
  ans=max(ans,count);
  cout << n-ans << endl;
}

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

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

    long long n, x;
    cin >> n >> x;

    long long p_total = 0;
    for (int i = 1; i <= n; ++i) {
        long long p_num = (long long) pow(2, n + 1 - i) - 1;
        long long b_num = (long long) pow(2, n + 1 - i) - 2;
        if (p_num + b_num + 2 < x) {
            p_total += p_num + 1;
            x -= p_num + b_num + 2;
            if (i == n) p_total++;
        } else if (p_num + b_num + 2 == x) {
            // center patty
            p_total += p_num + 1;
            break;
        } else  if (p_num + b_num + 1 == x) {
            p_total += p_num;
            break;
        } else {
            x -= 1;
        }
        if (x <= 0) break;
    }

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


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

int main(){
  int n;
  cin >> n;
  if(n%10 == 7 || (n%100)-(n%10) == 70 || n-(n%100) == 700){
    cout << "Yes" << endl;
  }else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3636