akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); i++ )
#define UREP( i, m, n ) for ( unsigned int i = (unsigned int)( m ); i < (unsigned int)( n ); i++ )
#define ITER( c ) __typeof( (c).begin() )
#define IREP( c, it ) for ( ITER(c) it = (c).begin(); it != (c).end(); ++it )
#define ALL( c ) (c).begin(), (c).end()
#define PB( n ) push_back( ( n ) )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define fst first
#define snd second

const string nums[] = {
	"*****     ",
	"     *****",
	"==========",
	" **** ****",
	"* **** ***",
	"** **** **",
	"*** **** *",
	"**** **** "
};

int main()
{
	string line;
	bool first = true;

	while ( cin >> line )
	{
		if ( first )
		{
			first = false;
		}
		else
		{
			cout << endl;
		}

		vector<string> res( 8 );

		while ( line.length() < 5 )
		{
			line = "0" + line;
		}

		UREP( i, 0, line.length() )
		{
			REP( j, 0, 8 )
			{
				res[j] += nums[j][ line[i] - '0' ];
			}
		}

		REP( i, 0, 8 )
		{
			cout << res[i] << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 900
#include <bits/stdc++.h>
using namespace std;
 
#define DEBUG if(1)
#define MAX INT_MAX
#define MAXLL INT_MAX
#define MAXU ULLONG_MAX
#define MIN -2000000
#define endl "\n"
#define INF INT_MAX
#define MOD 1000000007
#define s(n) scanf("%d", &n)
#define ss(a,b) scanf("%d %d",&a,&b)
#define pb push_back
#define mp make_pair
#define M_PI 3.14159265358979323846
#define sz(a) int(a.size())
#define lli long long int
#define rep(i,a,n) for (int i=a;i<n;i++)
#define ler(a,n,vec) for(int i=0;i<n;i++)s(a), vec.pb(a)
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> ii;
#define DEBUG if(1)
#define F first
#define S second
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
int ddx[] = {1, 0};
int ddy[] = {1, 1};
#define MAXN 100010
#define MAXL 20

int n;
vector<pair<int,ii>> vec;
lli pd[MAXN][4];

lli solve(int obj, int last){
	if(obj == sz(vec)) return 0;

	lli &ans = pd[obj][last];

	if(ans != -1) return ans;

	lli a = 0;
	if(!obj){
		a = max(a, solve(obj+1, 1) + vec[obj].F);
		a = max(a, solve(obj+1, 2) + vec[obj].S.F);
		a = max(a, solve(obj+1, 3) + vec[obj].S.S);
	} else {
		if(last == 1){
			a = max({a, solve(obj+1, 2) + vec[obj].S.F, solve(obj+1, 3) + vec[obj].S.S
			});
		} else if(last == 2){
			a = max({
				a, solve(obj+1, 1) + vec[obj].F, solve(obj+1, 3) + vec[obj].S.S
			});
		} else {
			a = max({
				a, solve(obj+1, 1) + vec[obj].F, solve(obj+1, 2) + vec[obj].S.F
			});
		}
	}

	return ans = a;
}

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

  cin >> n;
  for(int i=0;i<n;i++){
  	int a, b, c;
  	cin >> a >> b >> c;
  	vec.pb({a , { b, c}});
  }

  memset(pd, -1, sizeof pd);

  cout << solve(0, 0) << endl;


  return 0;
}

Measured memory_bytes: 10992
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef pair<int,int> P;
#define fi first
#define se second
#define all(v) (v).begin(),v.end()
set<string> c;
const ll inf=(1e18);
const ll mod=1000003;
const ll mod2=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
long long modpow(long long a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
const ll MAX = 2000010;//設定して
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;//＊１
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
//階乗
long long factor(ll n,ll k){
  if (n<k) return 0;
  if (n<0 || k<0) return 0;
  return (fac[n]*finv[k])%mod;
}
// 二項係数計算
long long COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
COMinit();
ll q;cin>>q;
while(q--){
    //x初項,d等差,n項数
    ll x,d,n;cin>>x>>d>>n;
    if(d==1){
        if(n>mod)cout<<0<<endl;
        else{
            cout<<factor(x+n-1,x-1)<<endl;
        }
    }
    else if(d==0){
        cout<<(modpow(x,n)%mod)<<endl;
    }
    else{
        if(n>mod)cout<<0<<endl;
        else{
        x=(x*modpow(d,mod-2))%mod;
        ll ans=(factor(x+n-1,x-1)*modpow(d,n))%mod;
        cout<<ans<<endl;
        }
    }
}
}


Measured memory_bytes: 47744
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
using namespace std;

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

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
ll myRand(ll B) {
	return (ull)rng() % B;
}

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second

clock_t startTime;
double getCurrentTime() {
	return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const int N = 222;
const int K = 62;
ll b[K];
char s[N];
ll a[N];
int n;

bool add(ll x) {
	for (int i = 0; i < K; i++) {
		if (((x >> i) & 1) == 0) continue;
		if (b[i] == -1) {
			b[i] = x;
			return true;
		}
		x ^= b[i];
	}
	return false;
}

void solve() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%lld", &a[i]);
	scanf("%s", s);
	for (int i = 0; i < K; i++)
		b[i] = -1;
	for (int i = n - 1; i >= 0; i--) {
		if (add(a[i]) && s[i] == '1') {
			printf("1\n");
			return;
		}
	}
	printf("0\n");
}

int main()
{
	startTime = clock();
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);

	int t;
	scanf("%d", &t);
	while(t--) solve();

	return 0;
}


Measured memory_bytes: 3168
import java.util.Scanner;




public class Main {

    public static void main(String[] args) {

    	Main main=new Main();

    	main.run();

    }

    void run() {
    	Scanner sc=new Scanner(System.in);

    	String[] Odd=sc.next().split("");
    	String[] Even=sc.next().split("");

    	int length=Odd.length+Even.length;

    	int indexO=0;
    	int indexE=0;

    	StringBuilder result=new StringBuilder();

    	while(true) {

    			if(indexO<=Odd.length-1) {
    				result.append(Odd[indexO]);
    			}

    			if(indexE<=Even.length-1) {
    				result.append(Even[indexE]);
    			}


    			if(indexO>=Odd.length-1 && indexE>=Even.length-1) {
        			break;
        		}else {
        			indexO++;
        			indexE++;
        		}

    	}

    	System.out.println(result.toString());
    }

}



Measured memory_bytes: 21844
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <numeric>
#include <vector>
#include <cassert>
#include <ctime>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)

using namespace std;
typedef vector<int> vi;
typedef  pair<int,int> pii;
typedef pair<ll, ll> pll;
const int mod = 10007;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
const int maxn = 1000001;


int main() {
    
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    int ans = 0;
    while(true) {
        if(a &1 || b & 1 || c & 1) break;
        int b1 = b / 2;
        int c1 = c / 2;
        int a1 = a / 2;
        a = c1 + b1;
        b = a1 + c1;
        c = a1 + b1;
        ans ++;
        if(ans > 1000000) break;
    }
    if(ans > 1000000) printf("-1\n");
    else printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int aheight = 0;
		for(int i = 1; i < b - a; i++) {
			aheight += i;
		}
		System.out.println(aheight - a);
	}
}

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

typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) (in).begin(),(in).end()
#define ALL(in,K) (in),(in)+(K)

#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a, b)*b; } //最小公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
  string s;
  cin >> s;
  s.at(3) = '8';
  cout << s << endl;
}

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

int main(int argc, char *argv[]){
    std::string L;
    std::cin >> L;
    int N = L.size();
    constexpr long int m = 1000000000 + 7;
    long int comb = 0,combTmp = 1;
    for(const auto &l : L){
        comb *= 3;
        comb %= m;
        if(l=='1'){
            //when (a+b)[i] = 0
            comb += combTmp;
            comb %= m;
            //when (a+b)[i] = 1
            combTmp *= 2;
            combTmp %= m;
        }
    }
    comb += combTmp;
    comb %= m;
    std::cout << comb << std::endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define INF 2e9
#define mod 1000000007
#define abs(x) ((x)>=0?(x):-(x))
#define y1 solai
#define fi first
#define se second
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void read(ll &x, ll &y)
{
	scanf("%lld%lld",&x,&y);
}
void read(ll &x, ll &y, ll &z)
{
	scanf("%lld%lld%lld",&x,&y,&z);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(ll x)
{
	printf("%lld\n",x);
}
const ll N=100000;
ll n,x[N+10],y[N+10],z[N+10];
int main()
{
	//freopen("c.cpp","r",stdin);
 
	cin>>n;
	for(ll i=1;i<=n;i++)
	{
		read(z[i],x[i],y[i]);
		if((abs(x[i]-x[i-1])+abs(y[i]-y[i-1]))%2!=(z[i]-z[i-1])%2||abs(x[i]-x[i-1])+abs(y[i]-y[i-1])>z[i]-z[i-1])
		{
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
int main(){
  char weather[6];
  for (int i=0;i<7;i++){
      scanf("%c",&weather[i]);
  }
  if (weather[0] == 'S'){
    printf("Cloudy");
  }
  else if (weather [0] == 'C'){
    printf("Rainy");
  }
  else
    printf("Sunny");
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define ll long long
int main(){
	ll a, b, c;
	scanf("%lld %lld %lld", &a, &b, &c);
	if (a + b >= c){
		printf("No\n");
		return 0;
	}
	unsigned ll t;
	if (c < a + b){
		t = a + b - c;
	}else{
		t = c - a - b;
	}
	t *= t;
	unsigned ll plz = 4 * a * b;
	if (plz < t){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
}

Measured memory_bytes: 128
arr = [0 for _ in range(1001)]
arr[1] = 1
for i in range(2,32):
    if arr[i]==1:
        continue
    tmp=i*i
    while tmp <=1000:
        arr[tmp]=1
        tmp*=i

for x in range(int(input()),0,-1):
    if arr[x]==1:
        print(x)
        break

Measured memory_bytes: 3060
n, k = list(map(int, input().split()))
h = list(map(int, input().split()))
inf = 10 ** 4 + 1
dp = [inf] * n
dp[0] = 0
for i in range(1,n):
    H = h[i]
    dp[i] = min([dp[j] + abs(h[j] - H) for j in range(max(0, i - k), i)])
print(dp[-1])


Measured memory_bytes: 13928
inp = input()
w = 0
list0 = []
list1 = []
for i in inp:
  if w == 0:
    list0.append(int(i))
    w = 1
  else:
    list1.append(int(i))
    w = 0

sum0 = sum(list0)
sum1 = sum(list1)
pat0 = sum(list0) + len(list1) - sum(list1)
pat1 = sum(list1) + len(list0) - sum(list0) 


print (min(pat0, pat1))

Measured memory_bytes: 4052
#include<stdio.h>
int main(void)
{
	int n,k,max=0,s,i,j,a[100001];
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0&&k==0) break;
		for(i=1;i<=n;i++) scanf("%d",&a[i]);
		for(i=1;i<=n;i++){
			s=0;
			if(i+k<=n){
				for(j=i;j<i+k;j++) s+=a[j];
				if(max<s) max=s;
			}
		}
		printf("%d\n",max);
	}
	return 0;
}	

Measured memory_bytes: 3056
n=int(input())
p=list(input().split())
p=[int(i) for i in p]
cnt=0
for i in range(1,n-1):
    if p[i]!=max(p[i-1],max(p[i],p[i+1])) and p[i]!=min(p[i-1],min(p[i],p[i+1])):
        cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1e3+5;
int n;
double ans,A[N];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i)scanf("%lf",&A[i]);
	sort(A+1,A+n+1);
	ans=A[1];
	for(int i=2;i<=n;++i)
		ans=(ans+A[i])/2;
	printf("%.6lf\n",ans);
}

Measured memory_bytes: 128
import math
from functools import reduce
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
K=int(input())
sum1=0
sum2=0
for i in range(1,K+1):
    c=i
    for j in range(c,K+1):
        b=j
        for k in range(b,K+1):
            a=k
            sum1 +=gcd_list([c,b,a])
def sigma(a):
    s=0
    for i in range(0,a+1):
        s+=i
    return(s)
for i in range(1,K+1):
    d=i
    for j in range(d,K+1):
        e=j
        sum2 +=gcd_list([d,e])
print(6*sum1+sigma(K)-6*sum2)

Measured memory_bytes: 9632
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    import copy


    m, d = map(int, input().split())

    if d < 22:
        print(0)
        exit()

    count = 0

    for month in range(1,m+1):
        for day in range(22,d+1):
            str_day = str(day)
            d_1 = int(str_day[0])
            d_2 = int(str_day[1])
            if d_1 > 1 and d_2 > 1 and d_1 * d_2 == month:
                count += 1
    print(count)


Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

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

void print(vector<int>& v) {
	for(int i : v) cout << i << ' ';
	cout << endl;
	exit(0);
}

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    vector<bool> have(30001, 0);
    int n;
    cin >> n;
    if(n == 3) {
    	cout << "2 5 63" << endl;
    	exit(0);
    } else if (n == 4) {
    	cout << "2 5 63 20" << endl;
    	exit(0);
    }
    have[2] = have[4] = have[3] = have[6] = have[9] = 1;
    vector<int> ans = {2, 4, 3, 6, 9};
    if(n == ans.size()) print(ans);
    for(int i = 12; i <= 30000; i += 6) {
    	have[i] = 1;
    	ans.push_back(i);
    	if(n == ans.size()) print(ans);
    }
    if((n-ans.size()) % 2 == 1) {
    	ans.pop_back();
    }
    for(int i = 6; i < 30000; i += 6) {
    	have[i+2] = have[i+4] = 1;
    	ans.push_back(i+2);
    	ans.push_back(i+4);
    	if(n == ans.size()) print(ans);
    }
    for(int i = 12; i < 30000; i += 12) {
    	have[i+3] = have[i+9] = 1;
    	ans.push_back(i+3);
    	ans.push_back(i+9);
    	if(n == ans.size()) print(ans);
    }

    return 0;
}

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

void chmax(long long &a, long long b){
    if(a < b)a = b;
    return;
}

template<typename T>
T GCD(T a, T b) {
	if(a % b == 0){
		return b;
	} else {
		return GCD(b, a % b);
	}
}

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    vector<long long> Ga(N);
    vector<long long> Gb(N);
    for(int i = 0; i < N; i++)cin >> A[i];
    Ga[0] = A[0], Gb[N - 1] = A[N - 1];
    
    for(int i = 1; i < N; i++){
        Ga[i] = GCD(Ga[i - 1], A[i]);
        Gb[N - 1 - i] = GCD(Gb[N - i], A[N - 1 - i]);
    }
    
    long long M = -1;
    for(int i = 0; i < N; i++){
        if(i == 0)chmax(M, Gb[i + 1]);
        else if(i == N - 1)chmax(M, Ga[i - 1]);
        else chmax(M, GCD(Ga[i - 1], Gb[i + 1]));
    }
    cout << M << endl;
    return 0;
}

Measured memory_bytes: 2688
import java.util.*;
import java.io.*;

class Main
{
    public static void main(String[] args)
    {
	    // Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		// Scanner in = new Scanner(Syste8
    	Scanner in = new Scanner(System.in);
    	Main s = new Main();
    	s.qa(in.nextLine());
	}

	void qa(String str)
	{
		String rev = new StringBuilder(str).reverse().toString();
		if(str.length() == 2) System.out.println(str);
		else System.out.println(rev);
	}
}

Measured memory_bytes: 21716
#include <cstdio>

int main() {
    int a, b, d, r;
    double f;
    scanf("%d %d", &a, &b);
    d = a / b;
    r = a % b;
    f = (double)a / b;
    printf("%d %d %f", d, r, f);
    return 0;
}


Measured memory_bytes: 2736
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);

impl<T: PartialEq> Eq for Total<T> {}

impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    let d:i32 = read();
    let n:i32 = read();

    if n == 100 {
        println!("{}", (n+1)*(100 as i32).pow(d as u32));
        return ();
    }

    println!("{}", n*(100 as i32).pow(d as u32));

}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
}



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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    ll n;
    cin >> n;

    for (ll i = sqrt(n) + 1; i >= 1; i--) {
        if (n % i == 0) {
            cout << i + n / i - 2 << endl;
            return 0;
        }
    }


    return 0;
}


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

typedef long long int LL;
typedef unsigned long long uLL;
typedef pair< int,int > ii;
typedef pair< int,ii > iii;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 100005;
const int MOD = 1e9+7;
const double EPS = 1e-6;
const double PI = acos(-1.0);

int main( int argc, char const *argv[] ) {
    string str;
    cin >> str;
    str[3] = '8';
    cout << str <<endl;
    return 0;
}



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

void dfs(int i, int p, vector<vector<int>>& nodes, vector<int>& num) {
    for (int j: nodes[i]) {
        if (j != p) {
            num[j] += num[i];
            dfs(j, i, nodes, num);
        }
    }
}

int main() {
    int N, Q;
    cin >> N >> Q;
    vector<vector<int>> nodes(N+1);
    for (int i = 0; i < N - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        nodes[a].push_back(b);
        nodes[b].push_back(a);
    }
    vector<int> num(N+1);
    for (int i = 0; i < Q; ++i) {
        int p, x;
        cin >> p >> x;
        --p;
        num[p] += x;
    }
    dfs(0, -1, nodes, num);
    for (int i = 0; i < N; ++i) {
        cout << num[i] << " ";
    }
}

Measured memory_bytes: 29696
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <unordered_map>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll N;
    scanf("%lld", &N);

    ll ans = 1000 - (N % 1000);
    ans %= 1000;
    printf("%lld\n", ans);
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  ll n, sum=0;
  cin >> n;
  
  vector<ll> a(n);
  rep(i, 0, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll mini = 1000000000;
  ll ans = 0;
  rep(i, 0, n) {
    if(abs(a[i]*n-sum) < mini) {
      mini = abs(a[i]*n-sum);
      ans = i;
    } 
  }
  cout << ans << "\n";
  
  //cout << (  ?"Yes" :"No") << "\n";

}

Measured memory_bytes: 256
#include<stdio.h>
int max(int x,int y){
  if(x>y)
    return x;
  return y;
}

int main(void){
  int a,b,s;

  scanf("%d%d",&a,&b);

  s=max(a+b,max(a-b,a*b));

  printf("%d",s);
  return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){

  int n;
  ll x;
  cin >> n >> x;
  vector<ll> v(n);
  REP(i,n){
    int xx;cin >> xx;
    v[i] = abs(x-xx);
  }
  ll gcd = v[0];
  for(int i = 1;i < n;i++){
    gcd = __gcd(gcd,v[i]);
  }
  cout << gcd << endl;




  

  return 0;
}


Measured memory_bytes: 1024
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]

s.sort()
S = []
S.append(s[0])
for i in range(len(s)-1):
    if s[i] != s[i+1]:
        S.append(s[i+1])

MAX = 0
for i in S:
    d = s.count(i) - t.count(i)
    MAX = max(MAX, d)

print(MAX)


Measured memory_bytes: 9068
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():

    X, N = in_nn()
    p = list(in_nn())

    ans = 1000
    for i in range(-5, 105):
        if i in p:
            continue
        else:
            if abs(X - i) < abs(X - ans):
                ans = i

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9248
#include <iostream> // cout, endl, cin
#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<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<int, int>
const ll  MOD = 1000000007;

int main() {
	ll k, n;
	cin >> k >> n;
	vector<ll> a(n);
	rep(i, n) cin >> a.at(i);
	sort(all(a));
	ll m = a.at(0) + k - a.at(n - 1);
	rep(i, n - 1) {
		if (a.at(i + 1) - a.at(i) > m) {
			m = a.at(i + 1) - a.at(i);
		}
	}
	cout << k - m;
	return 0;
}

Measured memory_bytes: 1792
D=int(input())
*c,=map(int,input().split())
s=[]
for i in range(D):
    *x,=map(int,input().split())
    s.append(x)

dt=[]
last=[-1]*26
v=0
for d in range(D):
    news=[s[d][i]-c[i]*((d+10)-last[i])*((d+10)-last[i]-1)//2 for i in range(26)]
    maxi=0
    tmp=-float('inf')
    for i in range(26):
        if tmp<news[i]:
            maxi=i
            tmp=news[i]
    last[maxi]=d
    v+=s[d][maxi]
    for i in range(26):
        v-=c[i]*(d-last[i])
    dt.append(maxi+1)

for i in dt:
    print(i)

Measured memory_bytes: 74360
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    int n = Integer.parseInt(in.readLine());
    System.out.println((n+1)/2);
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-10;
const vi emp;

class Graph{
	private:
	int V;
	vvi List;
	int bfs(int s1,int s2,int num){
		queue<P> que;
		vb used(V);
		int ans=0;
		if(s2==-1) que.push(P(s1,0));
		else{
			que.push(P(s1,0));
			que.push(P(s2,0));
			used[s2]=1;
		}
		while(!que.empty()){
			P p=que.front();
			que.pop();
			used[p.first]=1;
			ans++;
			if(p.second==num) continue;
			for(auto i=List[p.first].begin();i!=List[p.first].end();i++){
				if(!used[*i]) que.push(P(*i,p.second+1));
			}
		}
		return V-ans;
	}
	public:
	Graph(int v){
		V=v;
		List=vvi(v);
	}
	void add_edge(int s,int t){
		List[s].push_back(t);
		List[t].push_back(s);
	}
	int solve(int k){
		int ans=inf;
		if(k%2==0){
			for(int i=0;i<V;i++) ans=min(ans,bfs(i,-1,k/2));
		}
		else{
			for(int i=0;i<V;i++) for(auto j=List[i].begin();j!=List[i].end();j++){
				if(*j>i) ans=min(ans,bfs(i,*j,k/2));
			}
		}
		return ans;
	}
};

int n,k;

int main(){
	cin>>n>>k;
	Graph gra(n);
	int s,t;
	for(int i=0;i<n-1;i++){
		cin>>s>>t;
		gra.add_edge(s-1,t-1);
	}
	cout<<gra.solve(k)<<endl;
}

Measured memory_bytes: 384
x = int(input())
l = []
for i in range(130):
    l.append(i ** 5)
for i in l:
    a = int(i ** 0.2)
    b = i - x
    c = x - i
    if b in l or c in l:
        if b > 0:
            ans = int(b ** 0.2)
        else:
            ans = - int(c ** 0.2)
        print(a, ans)
        break
else:
    print("NO")

Measured memory_bytes: 9448
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, M;
  cin >> N >> M;
  
  priority_queue<ll> q;
  int a;
  REP(i, N){
    cin >> a;
    q.push(a);
  };
  
  REP(i, M){
    a = q.top(); q.pop();
    a /= 2;
    q.push(a);
  };
  
  ll sum = 0;
  while(!q.empty()){
    sum += q.top(); q.pop();
  };
  
  cout << sum << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	for(double i=b*10;;i++){
		int aa=i/100*8,bb=i/10;
		if(aa==a&&bb==b){
			cout<<i;
			return 0;
		}
		if(i>1000){cout<<-1<<endl;return 0;}
	}
}

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

int main(){
    int K,X;
    int total = 0;
    cin >> K >> X;
    
    total = 500 * K;
    
    if ( total >= X ){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 256
import itertools
a, b = [int(el) for el in input().split(' ')]

def f(n, x):
    if n == 0:
        return(1)
    else:
        return(n*x - (n-1))

for i in itertools.count(0):
    if f(i, a) >= b:
        print(i)
        break



Measured memory_bytes: 3060
#include<stdio.h>

int main()
{
	int n,i,a[100001],largest,smallest;
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	largest=a[0];
	for(i=0;i<n;i++)
	{
		if(largest<a[i]) largest=a[i];
	}
	smallest=a[0];
	for(i=0;i<n;i++)
	{
		if(smallest>a[i]) smallest=a[i];
	}
	
	printf("%d\n",largest-smallest);
	
	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n,m,ans=1;
	cin>>n>>m;
	for(int i=m/n;i>=2;i--){
		if(!(m%i)){
			ans=i;
			break;
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
  int a,b,c,ans;
  cin >> a >> b >> c;
  ans = b;
  if(a+b < c) ans += a+b+1;
  else ans += c;
  cout << ans << endl;
}

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

struct Node{
  int key;
  struct Node *next;
  struct Node *prev;
};

typedef struct Node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  struct Node *cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
}

void init(){
  nil = malloc(sizeof(struct Node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}

void deleteLast(){
  /* your code */
  NodePointer t = nil->prev;
  if(t == nil) return;
  deleteNode(t);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct Node));
  x->key = key;

  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      scanf("%d", &key);
      insert(key);
      np++;
      size++;
    }
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
	if ( com[6] == 'F' ) deleteFirst();
	else if ( com[6] == 'L' ) deleteLast();
      } else {
	scanf("%d", &key);
	delete(key);
	nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



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

int main()
{
    int n, i, j;
    cin >> n;
    int a[n][3];
    for(i = 0; i < n; ++i) {
        for(j = 0; j < 3; ++j) {
            cin >> a[i][j];
        }
    }
    int dp[3];
    dp[0] = a[0][0];
    dp[1] = a[0][1];
    dp[2] = a[0][2];

    for(i = 1; i < n; ++i) {
        int newdp[3];
        for(j = 0; j < 3; ++j) {
            if(j == 0)
                newdp[j] = max(a[i][j] + dp[1], a[i][j] + dp[2]);
            else if(j == 1)
                newdp[j] = max(a[i][j] + dp[0], a[i][j] + dp[2]);
            else
                newdp[j] = max(a[i][j] + dp[0], a[i][j] + dp[1]);
        }
        dp[0] = newdp[0];
        dp[1] = newdp[1];
        dp[2] = newdp[2];
        // wrong as if dp[0] is changed then for j=1, dp[1] will work with changed dp[0] val, hence we need new
        // cout << dp[0] << " " << dp[1] << " " << dp[2] << "\n";
    }
    cout << max({ dp[0], dp[1], dp[2] }) << "\n";

    return 0;
}


Measured memory_bytes: 1408
package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var N int
	fmt.Scan(&N)

	ans := func() string {
		for i := 1; i <= 50000; i++ {
			if float64(i)*1.08 >= float64(N) {
				check := math.Floor(float64(i) * 1.08)
				if check == float64(N) {
					return strconv.Itoa(i)
				}
				return ":("

			}
		}
		return ":("
	}()

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;

const int maxn = 5e5;
int n, x, a[maxn];

int main(void) {
  scanf("%d%d", &n, &x);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
  }
  sort(a, a + n);
  if (accumulate(a, a + n, 0LL) == x) {
    printf("%d\n", n);
    return 0;
  }
  int cnt = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (a[i] <= x) {
      x -= a[i];
      ++cnt;
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;
const int MOD = 1e9+7;

int main() {
    int n, m; cin >> n >> m;
    vector<pair<int, int>> key(m);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        int s = 0;
        for (int i = 0; i < b; i++)
        {
            int c; cin >> c;
            c--;
            s = s | (1<<c);
        }
        key[i] = make_pair(a, s);       
    }

    vector<int> dp(1<<n, INF);
    dp[0] = 0;

    for(int before = 0; before < (1<<n); before++) {
        for (int i = 0; i < m; i++) {
            int after = before | key[i].second;
            dp[after] = min(dp[after], dp[before]+key[i].first);   
        }
    }
    int ans = dp.back();
    if (ans == INF) ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::collections::VecDeque;

fn main() {
    let a: i64 = read();
    let b: i64 = read();

    if a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0 {
        println!("Possible")
    } else {
        println!("Impossible")
    }
}


Measured memory_bytes: 4352
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int cnt1[26], cnt2[26];
  CLR(cnt1);
  CLR(cnt2);
  FOR(i,0,n){
cnt1[s[i]-'a']++;
  }
  int ans = 0;
  FOR(i,0,n){
int tmp = 0;
    FOR(j,0,26){
if(cnt1[j]>0&&cnt2[j]>0) tmp++;
    }
    ans = max(ans, tmp);
    cnt1[s[i]-'a']--;
    cnt2[s[i]-'a']++;
  }
   cout<<ans<<endl; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int A, B; cin >> A >> B;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) cout << A * B << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
#N,Q = list(map(int,input().split()))
N,Q = [int(i) for i in sys.stdin.readline().split()]
G=[]
for i in range(N):
    G.append([])

for i in range(N-1):
    #a,b = list(map(int,input().split()))
    a,b = [int(j) for j in sys.stdin.readline().split()]
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N

for i in range(Q):
    #p,x = list(map(int,input().split()))
    p,x = [int(j) for j in sys.stdin.readline().split()]
    p-=1
    c[p] += x

stack=deque([0])
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.append(u)


ans = ' '.join([str(x) for x in c])

print(ans)

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

ll mul_mod(ll a, ll b) { return (a % MOD) * (b % MOD) % MOD; }

struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;

// 深さ優先探索
vector<bool> seen;  // 既に見たことがある頂点か記録
ll dfs(const Graph &G, int v, ll k, ll pre, bool isfirst = true) {
    seen[v] = true;
    ll ret = k;
    ll npre = (isfirst) ? 0 : 1;
    ll tmp = k - 1 + pre;
    // cout << v + 1 << " " << tmp << " " << npre << " " << ret << endl;

    for (auto e : G[v]) {
        if (!seen[e.to]) {  // 訪問済みでなければ探索
            ret = mul_mod(ret, dfs(G, e.to, tmp, npre, false));
            npre++;
            tmp--;
        }
    }
    // cout << v + 1 << " " << ret << endl;
    if (k == 0) return 0;
    return ret;
}

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

    int N;
    ll K;
    cin >> N >> K;

    Graph G(N);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }

    seen.assign(N, false);  // 初期化
    cout << dfs(G, 0, K, 0) << endl;

    return 0;
}


Measured memory_bytes: 11648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int K, A, B;
  	bool J = false;
  	cin >> K >> A >> B;
  
  if(K == 1){
    for(int i = K; i <= B; i ++){
      if(i >= A && i <= B){
        J = true;
      }
    }
  }else{
    int i = 0;
  	while(i <= B){
      i += K;
      if(i >= A && i <= B){
        J = true;
      }
    }
  }
  
  if(J){
    cout << "OK" << endl;
  }else{
    cout << "NG" << endl;
  }
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<map>
#include<queue>
#include<cstring>
#include<sstream>
using namespace std;

typedef long long ll;
int gcd(int a, int b) {
    if ( b == 0 ) return a;
    return gcd(b,a%b);
}

int main() {
  int N; cin >> N;
  int A[100010];
  int L[100010],R[100010];
  for ( int i = 0; i < N; i++ ) {
    cin >> A[i];
  }

  L[0] = A[0];
  for ( int i = 1; i < N; i++ ) {
    L[i] = gcd(A[i],L[i-1]);
  }
  R[N-1] = A[N-1];
  for (int i = N-2; i >= 0; i-- ) {
    R[i] = gcd(A[i],R[i+1]);
  }

  int ans = max(L[N-2],R[1]);
  for ( int i = 1; i < N-1; i++ ) {
    ans = max(ans,gcd(L[i-1],R[i+1]));
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1408
N,M=map(int,input().split())
E=[[] for i in range(N)]
for i in range(M):
  u,v=map(int,input().split())
  u,v=u-1,v-1
  E[u].append(v)
S,T=map(int,input().split())
S,T=S-1,T-1

from collections import deque
q=deque()
seen=[[False for i in range(3)] for j in range(N)]
q.append([S,0,1])
while q:
  node=q.popleft()
  v=node[0]
  step=node[1]
  turn=node[2]
  if step==3:
    if v==T:
      print(turn)
      break
    step=0
    turn+=1
  if seen[v][step]:
    continue
  seen[v][step]=True
  children=E[v]
  for child in children:
    q.append([child,step+1,turn])
else:
  print(-1)


Measured memory_bytes: 30096
#include <stdio.h>
 
#define PutChar(c) ; *p = (char)(c); ++p;
 
#define MAX_N (2000001)
#define MAX_Ai (10001)
#define STR_SIZE (10000010)
 
int getNum(void);
void putNum(int n);
void CountingSort(int A[], int B[], int k, int len);
 
int A[MAX_N];
int B[MAX_N];
char str[STR_SIZE];
char *p = str;
 
int main(void) {
    register int i;
    int n;
 
    fread(str, 1, STR_SIZE, stdin);
     
    n = getNum();
    for (i = 1; i <= n; ++i) {
        A[i] = getNum();
    }
     
    CountingSort(A, B, MAX_Ai, n);
     
    p = str;
    --n;
    for (i = 1; i <= n; ++i) {
        putNum(B[i]);
        PutChar(' ');
    }
    putNum(B[i]);
    PutChar('\0');
     
    puts(str);
     
    return 0;
}
 
int getNum(void) {
    int n = 0;
    while ((*p >= '0') && (*p <= '9')) {
        n = n * 10 + (int)(*p - '0');
        ++p;
    }
    ++p;
    return n;
}
 
void putNum(int n) {
    int d;
    if (n < 10) {
        PutChar('0' + n);
        return;
    }
    d = n / 10;
    if (d) putNum(d);
    PutChar('0' + (n - (d * 10)));
}
 
void CountingSort(int A[], int B[], int k, int len) {
    int C[MAX_Ai] = { 0 };
    int i, j;
    for (j = 1; j <= len; ++j) {
        ++C[A[j]];
    }
    for (i = 1; i <= k; ++i) {
        C[i] += C[i - 1];
    }
    for (j = len; j > 0; --j) {
        B[C[A[j]]] = A[j];
        --C[A[j]];
    }
}

Measured memory_bytes: 26736
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc165
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc165B();
            Console.Out.Flush();
        }

        public static void solve_abc165B()
        {
            BigInteger x = Convert.ToInt64(Console.ReadLine());
            BigInteger res = 100;
            long cnt = 0;
            while (BigInteger.Compare(res, x) < 0)
            {
                res = BigInteger.Add(res, BigInteger.Divide(res, 100));
                cnt++;
            }
            Console.WriteLine(cnt);
        }

        public static void solve_abc165A()
        {
            int k = Convert.ToInt32(Console.ReadLine());
            int[] ab = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
            bool ok = false;
            for (int i = ab[0]; i <= ab[1]; i++)
            {
                if (i % k == 0)
                {
                    ok = true;
                    break;
                }
            }
            Console.WriteLine(ok ? "OK" : "NG");
        }
    }
}


Measured memory_bytes: 28924
#include <bits/stdc++.h>
using namespace std;
struct Term
{
    using Ptr = shared_ptr<Term>;
    Term(const int rep, const vector<Ptr>& child, const int unit, const string& s) : rep{rep}, child{child}, unit{unit}, s{s} {}
    int rep;
    vector<Ptr> child;
    int unit;
    string s;
};
using Ptr = Term::Ptr;
string S;
string::iterator c;
Ptr parse()
{
    if (not isdigit(*c)) {
        string s;
        for (; 'A' <= *c and *c <= 'Z'; c++) { s.push_back(*c); }
        return make_shared<Term>(1, vector<Ptr>{}, (int)s.size(), s);
    }
    string d;
    for (; isdigit(*c); c++) { d.push_back(*c); }
    const int D = d == "" ? 1 : stoi(d);
    Ptr ans = make_shared<Term>(D, vector<Ptr>{}, 0, "");
    bool hasb = false;
    if (*c == '(') { hasb = true, c++; }
    if (not hasb) { return (ans->unit = 1, ans->s = string(1, *c), c++, ans); }
    for (; *c != ')';) {
        const auto p = parse();
        ans->child.push_back(p);
        ans->unit = min(ans->unit + (p->unit) * (p->rep), 1000001);
    }
    c++;
    return ans;
}
int main()
{
    while (true) {
        int N;
        cin >> S >> N;
        if (S == "0" and N == 0) { break; }
        S = "1(" + S + ")";
        c = S.begin();
        const Ptr root = parse();
        if (N >= root->unit * root->rep) {
            cout << 0 << endl;
            continue;
        }
        Ptr p = root;
        while (true) {
            if (p->child.empty()) {
                cout << p->s[N] << endl;
                break;
            } else {
                for (const auto& c : p->child) {
                    if (N >= c->rep * c->unit) {
                        N -= c->rep * c->unit;
                    } else {
                        N %= c->unit;
                        p = c;
                        break;
                    }
                }
            }
        }
    }
    return 0;
}



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

using namespace std;

int main(){
    int n,cnt=0,ma=0,x,y;
    scanf("%d%d",&n,&x);
    for(int i=0;i<n-1;i++){
        scanf("%d",&y);
        if(y<=x) cnt++;
        else cnt=0;
        ma=max(ma,cnt);
        x=y;
    }
    printf("%d",ma);
    return 0;
}


Measured memory_bytes: 256
import java.util.*; 
import java.io.*;

public class Main {
    static StringTokenizer st;
    static BufferedReader br;  
    static PrintWriter out;
 
    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));

        //ArrayList myList = new ArrayList<>();

        String S = next();
        int l = S.length();

        char[] myList = S.toCharArray();
        int[] mod = new int[l];

        int temp = myList[l-1]-'0';
        mod[l-1] = temp;
        int tenPower = 1;
        for(int i = l-2; i>=0; i--){
            tenPower *= 10;
            tenPower %=2019;
            temp = myList[i]-'0';
            mod[i] = (temp*tenPower + mod[i+1]) % 2019;
        }

        int[] fq = new int[2019];
         
        for(int i = 0; i<l; i++){
            fq[mod[i]] ++;
        }

        long count = fq[0];
        for(int i = 0; i<2019; i++){
            if(fq[i]>1){
                count += fq[i] * (fq[i]-1) /2;
            }
            
        }
        System.out.println(count);
    }
    
      
    public static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    public static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }

    static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
}

Measured memory_bytes: 37348
import sys
sys.setrecursionlimit(1000000000)
from fractions import gcd
from itertools import count
from functools import lru_cache
from collections import defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    A, B = mis()
    print(A*B//gcd(A,B))

main()


Measured memory_bytes: 5684