akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>
#include <sstream>
typedef long long ll;

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

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}

int main() {
	ll p;
	cin >> n >> p;
	if (n == 1 || p == 1) {
		cout << p << endl;
		return 0;
	}
	ll res = 1;
	for (ll i = 2; i < sqrt(p) + 2; i++) {
		if (p % ((ll)pow(i,n))==0) {
			chmax(res, i);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 256
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val n = readint()
    val a = readlongs().sorted()
    var ans = a[n - 1]
    var k = n - 2
    for(i in 0 until n - 2){
        ans += a[k]
        if(i % 2 == 1) k--
    }
    println(ans)
}



fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}



Measured memory_bytes: 71208
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include<cstdio>
// #define MOD 1000000007
// #define MOD2 1000000014000000049LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
typedef long long ll;

const int n = 100000;
const int MOD = 1000000007;

class ModFact {
    int inv[n+1];
    int fact[n+1];
public:
    constexpr ModFact() : fact(), inv() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i <= n; i++) {
            f = f*(i+1)%MOD;
            fact[i+1] = f;
        }
        f = power(f, MOD-2);
        for (int i = n; i >= 0; i--) {
            inv[i] = fact[i] * f % MOD;
            f = f * (i+1) % MOD;
        }
    }
    inline constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%MOD;
            a = (a*a)%MOD;
            b >>= 1;
        }
        return r;
    }
	int operator[](int n) {
		return inv[n];
	}

	int getfact(int n) {
		return fact[n];
	}
    
} fact;

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
    ll ans = 0, d;
    int a, N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        now = getint();
        d = now - prev;
        prev = now;
        a = (a + fact[i]) % MOD;
        ans += a * d;
    }
    printf("%lld\n", ((ans%MOD)*fact.getfact(N-1))%MOD);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;i<(n);(i)++)
using namespace std;
 
int main(){
  long long int N;
  cin>>N;
 long long int M[N+10];
  M[0]=1;
  M[1]=1;
  for(int i=0;i<N-1;i++){
    M[i+2]=M[i]+M[i+1];
  }
  cout<< M[N]<<endl;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define sz(x) ((int)(x).size())
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b-1); i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

typedef long long ll;
typedef long double ld;

///----------------------------------------------
int dig[10];
int main() {

	///read
	rep(i,0,3) scanf("%d",&dig[i]);
	sort(dig,dig+3);
	if (dig[0]==5 && dig[1]==5 && dig[2]==7) puts("YES");
		else puts("NO");


}


Measured memory_bytes: 256
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n = ni()
s = str(n)
K = ni()

dp = [[[0] * 2 for _ in range(K + 2)] for _ in range(len(s) + 1)]
dp[0][0][0] = 1
for i in range(len(s)):
    for j in range(K + 1):
        for k in range(2):
            dmax = 9 if k else int(s[i])
            for d in range(dmax + 1):
                ni = i + 1
                nj = j + (d != 0)
                nk = k | (d < dmax)
                dp[ni][nj][nk] += dp[i][j][k]

print(dp[len(s)][K][0] + dp[len(s)][K][1])

Measured memory_bytes: 40560
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll n,q;

int main(){
	cin>>n>>q;
	ll res=(n-2)*(n-2);
	vp a(1,{0,n-2}),b(1,{0,n-2});
	for(int i=0;i<q;i++){
		int t,x;
		cin>>t>>x;
		x=n-x;
		if(t==1){
			if(a.back().first<x){
				int tmp=n-2-b.back().first;
				res-=tmp;
				a.push_back({x,tmp});
			}
			else{
				auto it=lower_bound(a.begin(),a.end(),make_pair(x,0));
				res-=it->second;
			}
		}
		else{
			if(b.back().first<x){
				int tmp=n-2-a.back().first;
				res-=tmp;
				b.push_back({x,tmp});
			}
			else{
				auto it=lower_bound(b.begin(),b.end(),make_pair(x,0));
				res-=it->second;
			}
		}
	}
	cout<<res<<endl;
}

Measured memory_bytes: 5264
n=int(input())
a=list(map(int,input().split()))

x=[0]*(10**6+1)
for i in a:
    x[i]+=1


for i in range(10**6+1):
    if x[i]>=1:
        j=2
        while i*j<=10**6:
            x[i*j]=0
            j+=1
print(x.count(1))


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

ll selfadd(ll a,ll b)
{
	if(a<b)
	return a;
	else return a%b;
}
void solve()
{

	ll	 n;
	
	cin>>n;
	
	ll a[n+1],b[n+1];
	for(int i=1;i<=n;i++){
	
		cin>>a[i];
		
		b[a[i]]=i;
	}
	
	for(int i=1;i<=n;i++)cout<<b[i]<<" ";
		

}
int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


Measured memory_bytes: 5116
var
 a,b:longint;
begin
 readln(a,b);
 if a>0 then write('Positive')
  else if (a=0)or((a<0)and(b>0)) then write('Zero')
   else if (abs(b)-abs(a)) mod 2<>0 then write('Positive')
    else write('Negative');
end.

Measured memory_bytes: 128
#ifdef LOCAL_EXEC
#include "include.h"
#else
#include <bits/stdc++.h>
using namespace std;
#define trace(...)
#endif

using LL = long long;

void NO() {
	cout << -1 << endl;
	exit(0);
}

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

	int n, k; cin >> n >> k;
	if (k > (n + 1) / 2) NO();

	int a = k + n / 2, b = k + 2 * n - 1, c = k + 3 * n - 1;
	vector<tuple<int, int, int>> ans;

	for (int i = 0; i < n; i++) {
		ans.emplace_back(a, b, c);
		if (a == k + n - 1) {
			a = k;
			b = k + 2 * n - 2;
		} else {
			a++;
			b -= 2;
		}
		c--;
	}

	// sort(ans.begin(), ans.end());
	// set<int> vals;
	for (const auto& e: ans) {
		int a, b, c; tie(a, b, c) = e;
		// assert(k <= min({a, b, c}));
		// assert(k + 3 * n - 1 >= max({a, b, c}));
		// assert(vals.insert(a).second);
		// assert(vals.insert(b).second);
		// assert(vals.insert(c).second);
		cout << a << ' ' << b << ' ' << c << '\n';
	}

	return 0;
}


Measured memory_bytes: 3572
//ループを展開して順序を入れ替える典型的な考察テク + お絵かきのセンス + 注意力
//↑黄色になったので、こういう「考察のとっかかり」的なものを意識してみる。
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;
typedef tuple<int, int, int> T;
 
int n;
int a[100000], b[100000];
T tup[200000];	//(cost, type, id)
 
bool check(bool used[]) {
	int i;
	bool exist[2][100000] = {false};
	
	rep(i, 2 * n) {
		if (used[i]) {
			exist[get<1>(tup[i])][get<2>(tup[i])] = true;
		}
	}
	
	rep(i, n) if (!exist[0][i]) break; if (i == n) return true;
	rep(i, n) if (!exist[1][i]) break; if (i == n) return true;
	rep(i, n) if (exist[0][i] && exist[1][i]) break; return i < n;
}
 
int toAns(bool used[]) {
	int i, ret = 0;
	rep(i, 2 * n) {
		if (used[i]) ret += get<0>(tup[i]);
	}
	return ret;
}
 
signed main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i] >> b[i];
	rep(i, n) { tup[2 * i] = T(a[i], 0, i); tup[2 * i + 1] = T(b[i], 1, i); }
	sort(tup, tup + 2 * n);
	
	static bool used[200000] = {false};
	int ans = 1e+15;
	
	rep(i, n) used[i] = true;
	if (check(used)) { ans = min(ans, toAns(used)); }
	
	used[n - 1] = false; used[n] = true;
	if (check(used)) { ans = min(ans, toAns(used)); }
	
	used[n] = false; used[n + 1] = true;
	if (check(used)) { ans = min(ans, toAns(used)); }
	
	rep(i, n) used[i] = true; used[n + 1] = false;
	used[n - 2] = false; used[n] = true;
	if (check(used)) { ans = min(ans, toAns(used)); }
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6784
N = int(input())
s = [input() for i in range(N)]
M = int(input())
t = [input() for i in range(M)]
dic = dict()
m = 0
for i in s:
    if i in dic:
        dic[i] = dic[i] + 1
    else:
        dic[i] = 1
for i in t:
    if i in dic:
        dic[i] = dic[i] - 1
    else:
        dic[i] = -1
for key in dic.keys():
    m = max(m,dic[key])
print(m)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, H, W;

  std::cin >> N >> H >> W;

  std::cout << (N - W + 1) * (N - H + 1) << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool prime(int a){
  for(int i=2;i*i<=a;i++)if(a%i==0)return 0;
  return 1;
}



signed main(){
  int n;cin>>n;
  int cnt=0;
  for(int i=11;cnt<n;i+=5){
    if(prime(i)){if(cnt)cout<<" ";cout<<i;cnt++;}
  }
  cout<<endl;
}


Measured memory_bytes: 256
#include <stdio.h> 
#include <stdlib.h> //atoiを使うため。

int main() {
 
  int  top = 0;
  int x,y,z;
  char s[100];
  int stack[1000];

  while(scanf("%s",s) != EOF) {
    if('\n' == s[0]) printf("%d\n",stack[top]);

    else  if(s[0] == '+') {
	x = stack[top];
	top--;
	if(top == 0) {
	  printf("アンダーフロ-\n");
	  continue;
	}
	y = stack[top];
	stack[top] = y + x;
      }

      else if(s[0] == '-') {
	x = stack[top];
	top--;
	if(top == 0) {
	  printf("アンダーフロ-\n");
	  continue;
	}
	y = stack[top];
	stack[top] = y - x;
      }

      else if(s[0] == '*') {
	x = stack[top];
	top--;
	if(top == 0) {
	  printf("アンダーフロ-\n");
	  continue;
	}
	y = stack[top];
	stack[top] = y * x;
      }

      else {
	stack[++top] = atoi(s);
       } 
  }
 printf("%d\n",stack[top]);
  return 0;
}

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

int main (){
	int n,m;
	cin >> n >> m;
	const int NMMAX=50;
	int A[NMMAX],B[NMMAX],C[NMMAX],D[NMMAX];
	for(int i=0;i<n;++i){
	cin >> A[i] >> B[i];
	}
	for(int i=0;i<m;++i){
	cin >> C[i] >> D[i];
	}

	for(int i=0;i<n;i++){
	int checkpoint = 1;
	int min_dist = abs(A[i]-C[0])+abs(B[i]-D[0]);

	for(int j=0;j<m;j++){
		const int cur_dist=abs(A[i]-C[j])+abs(B[i]-D[j]);
		if(min_dist>cur_dist){
			min_dist = cur_dist;
			checkpoint = j+1;
			}
		}
	cout << checkpoint << endl; 
	}
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<iostream>
#include<vector>
#define rep(a, n) for(int i = a; i < (int) n; i++)
#define rep(n) for(int i = 0; i < (int) n; i++)
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios::base::sync_with_stdio(false); cin.tie(NULL);
typedef long long int ll;
//typedef vector<int> vi;
//using ll = long long; //only for C++11 compiler and newer

using namespace std;

int main(){
    //fast()
    //freopen("input.txt","r",stdin);
    int n, r; cin >> n >> r;

    n = 100 * (10 - n);
    if(n < 0) cout << r << '\n';
    else cout << r + n << '\n';
    return 0;
}

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

/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
*/

using namespace std;

#if DEBUG && !ONLINE_JUDGE
    #include "debug.h"
#else
    #define debug(...)
#endif

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<ll,ll> iil;
typedef vector<vector<int> > vvi;
typedef vector<vector<ii> > vvii;

#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define ff first
#define ss second
#define trav(a, x) for(auto& a : x) 
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
const ll INF = 1e18;
const int mod = 1e9 + 7;
ll gcd(ll a,ll b){if (a==0) return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return a*(b/gcd(a,b));}
ll Abs(ll a){if(a>0)return a;return -a;}
ll Ceil(ll a,ll b){if(a%b==0)return a/b;else return a/b+1;}
double Abs(double a){if(a>0)return a;return -a;}

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

//#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_NOde_update> 

inline int pow_(ll x, ll y,ll p){
  int r = 1; while(y){if(y & 1) r = r * x % p; y >>= 1; x = x * x % p;} return r;
}
inline int inv_(int x){return pow_(x, mod - 2, mod);}
inline int add(int a, int b){a += b; if(a >= mod) a -= mod; return a;}
inline int mul(int a, int b){return a * 1LL * b % mod;}
inline int sub(int a, int b){a -= b; if(a < 0) a += mod; return a;}

int main()
{
	#ifdef LOCAL_TEST
	freopen("in.txt","r",stdin);
	//freopen("out.txt", "w", stdout);
	#else
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	#endif
	int n;
	cin>>n;
	vector<pair<ll,ll> > v;
	for(int i=1;i<=n;i++)
	{
		ll x,y;
		cin>>x>>y;
		v.pb(mp(x,y));
	}
	sort(all(v));
	if(n==1)
	{
		cout << "1\n";
		return 0;
	}

	map<pair<ll,ll>,ll> m;
	for(int i=0;i<v.size();i++)
	{
		for(int j=i+1;j<v.size();j++)
		{
			ll p = v[j].first-v[i].first;
			ll q = v[j].second-v[i].second;

			if(m.find(iil(p,q))!=m.end())m[iil(p,q)]++;
			else m[iil(p,q)] = 1;
		}
	}
	ll max = 1;
	for(auto it: m)
	{
		if(it.second > max)max = it.second;
	}

	ll ans = n - max;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
  int n, a[100];
  cin >> n;
  for(int i=0; i<n; i++){
   cin >> a[i];
  }
  for(int l=0; l<n; l++){
    cout << a[n-1-l];
  if(l == n-1) break;
  cout << ' ';  
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int e=sc.nextInt(),y=sc.nextInt();
        int[] f= {1868,1912,1926,1989,2017};
        char[] g= {'M','T','S','H'};
        if(e==0) {
            for(int i=0;i<4;i++) {
                if(y<=f[i+1]-1) {
                    System.out.println(g[i]+""+((y-f[i])+1));
                    break;
                }
            }
        }else {
            System.out.println(y+f[e-1]-1);
        }
    }
}


Measured memory_bytes: 26408
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int getNDigits(int x){
  int n_digits=1;
  while(x/10){
    x/=10;
    ++n_digits;
  }
  return n_digits;
}
int F(int A,int B){
  return max(getNDigits(A),getNDigits(B));
}
main(){
  int N;
  cin>>N;
  int root=sqrt(N);
  int minimum=numeric_limits<int>::max();
  for(int i=1;i<=root;++i){
    if(N%i==0){
      minimum=min(minimum,F(i,N/i));
    }
  }
  cout<<minimum<<endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

ans = 0

if h == 1 or w == 1:
    print(1)
    exit(0)

if h % 2 == 0 and w % 2 == 0:
    ans = (h // 2) * w
elif h % 2 == 0 or w % 2 == 0:
    ans = h * w // 2
else:
    ans = (h * w) // 2 + 1

print(ans)

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    int n; cin >> n;
    out((1000 - n % 1000) % 1000);
}

Measured memory_bytes: 3604
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define endl '\n';
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;



int main() {
    
    string s,t;
    cin>>s>>t;
    Sort(s);
    Rort(t);
    if(s<t)fin("Yes");
    else fin("No");
}


Measured memory_bytes: 256
A = [list(map(int,input().split())) for i in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
#print(A,N,b)
for i in range(3):
  for j in range(3):
    for k in b:
      if A[i][j]==k:
         A[i][j]=0
  
flag=0
for i in range(3):
  if A[i].count(0)==3:
    flag=1
    #print('yoko')
    break
  elif A[0][i]==0 and A[1][i]==0 and A[2][i]==0:
    flag=1
    #print('tate')
    break    
else:
  if A[0][0]==0 and A[1][1]==0 and A[2][2]==0:
    #print('naname1')
    flag=1
  elif A[0][2]==0 and A[1][1]==0 and A[2][0]==0:
    #print('naname2')
    flag=1
print('Yes' if flag==1 else 'No')

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <random>
#include <cassert>
#include <cstring>
#include <chrono>

using namespace std;

typedef long long ll;

const ll mod = 998244353;

ll Power(ll x, int n) {
  ll result = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      n--;
      result *= x;
      result %= mod;
    } else {
      n /= 2;
      x *= x;
      x %= mod;
    }
  }
  return result;
}

ll Inverse(ll x) {
  ll result = Power(x, mod - 2);
  assert(result * x % mod == 1);
  return result;
}

ll GetC(int n, int k, const vector<ll>& fact) {
  ll result = fact[n];
  result *= Inverse(fact[k]);
  result %= mod;
  result *= Inverse(fact[n - k]);
  result %= mod;
  return result;
}

int main()
{
  int n;
  cin >> n;
  ll result = 1;
  for (int i = 0; i < n; ++i) {
    result *= 3;
    result %= mod;
  }
  vector<ll> pow2(n);
  pow2[0] = 1;
  for (int i = 1; i < n; ++i) {
    pow2[i] = pow2[i - 1] * 2 % mod;
  }

  vector<ll> fact(n + 1);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = fact[i - 1] * i % mod;
  }

  for (int a = n / 2 + 1; a <= n; ++a) {
    ll cur = GetC(n, a, fact);
    cur *= pow2[n - a] * 2;
    cur %= mod;
    result -= cur;
    result %= mod;
    result += mod;
    result %= mod;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 156672
N, M = map(int, input().split())
root = [[] for _ in range(N)]
for _ in range(M):
    A, B = map(int, input().split())
    root[A-1].append(B-1)
    root[B-1].append(A-1)
ans = [[-1, -1] for _ in range(N)]

S = [[0, 0, 0]]

while len(S) > 0:
    S_ = []
    for s in S:
        if ans[s[0]][0] == -1 or s[2] < ans[s[0]][0]:
            ans[s[0]][0] = s[2]
            ans[s[0]][1] = s[1]
            for next in root[s[0]]:
                S_.append([next, s[0], s[2]+1])
    S = S_

print("Yes")
for a in ans[1:]:
    print(a[1]+1)


Measured memory_bytes: 79728
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

void Print(bool c)
{
    if (c)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    pii a[n];
    rep(i, 0, n)
    {
        cin >> a[i].fi;
        a[i].se = i + 1;
    }
    sort(a, a + n);
    rep(i, 0, n)
    {
        (i == n - 1) ? (cout << a[i].se << endl) : (cout << a[i].se << " ");
    }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
  int N;
  cin >>N;
  vector<int>vec(N);
  rep(i,N) {
cin >>vec.at(i);
  }
sort(all(vec));
  int sum=0;
  rep(i,N-1) {
sum +=vec.at(i);
  }
  cout <<sum+vec.at(N-1)/2<< endl;
}
  

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getMaxEffectiveBit(ull a)
{
	ll index = -1;
	for (; a != 0; a >>= 1)
	{
		++index;
	}
	return index;
}

inline ll getSpecifiedBit(ull a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

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

	ll N;
	cin >> N;

	vector<ll> As(N);
	ll firstX = 0LL, coef = 1LL;
	for (ll i = 0; i < N; ++i)
	{
		cin >> As[i];
		firstX += coef * As[i];
		coef *= -1LL;
	}
	firstX /= 2;
	cout << firstX * 2;

	ll nextX = firstX;
	for (ll i = 0; i + 1 < N; ++i)
	{
		nextX = As[i] - nextX;
		cout << " " << nextX * 2;
	}
	cout << endl;
	
	return 0;
}


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

ll gcd(ll a, ll b)
{
    if (a < b)
    {
        return gcd(b, a);
    }

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

int main (void){

    int n;
    cin >> n;

    ll a[n + 5], b[n + 5], c[n + 5];
    rep(i,n){

        cin >> a[i];
    }

    b[0] = a[0];

    for (int i = 1; i < n;i++){
        b[i] = gcd(a[i], b[i-1]);
    }
    c[n] = a[n-1];
    for (int i = n-1 ; i >=2;i--){
        c[i] = gcd(c[i+1], a[i-1]);
    }

    ll ans = max(b[n - 2],c[2]);

    for (int i = 0; i < n - 2; i++)
    {
        ans = max(gcd(b[i], c[i+3]), ans);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2560
local n=io.read("*n")
local a,b={},{}
for i=1,n do
    a[i],b[i]=io.read("*n","*n")
end

local push=0
for i=n,1,-1 do
    a[i]=a[i]+push
    if a[i]%b[i]~=0 then
        push=push+b[i]-a[i]%b[i]
    end
end
print(push)

Measured memory_bytes: 5076
n = gets.to_i
t = gets.split.map{|i| i.to_i}
sum_t = t.inject(:+)
m = gets.to_i

ans = []

m.times do
	p, x = gets.split.map{|i| i.to_i}
	ans << sum_t-t[p-1]+x
end

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define wh while
#define db double
#define pb .push_back
#define sz .size()
#define vc vector
#define vcd vector <double>
#define vcf vector <float>
#define vci vector <int>
#define vcs vector <string>
#define sti set <int>
#define fi .first
#define se .second
#define yes true
#define no false
#define bg .begin()
#define ed .end()
#define ad a,b,c,d
#define till n i<n.size();
set <int> A;
vector <int> B;
vector <int> C;
vector <int> D;
sti G;
bool t;
bool f;
int cnt=0;
int main(){
    int a;
    int b,k;
    cin>>a;
    int A[a+5];
    int B[a+5];
    for(int i=0;i<a;i++){
        cin>>b;
        A[i]=b;
        B[i]=b;
    }
    int x,y;
    cin>>k;
    for(int i=0;i<k;i++){
        for(int j=0;j<a;j++){
            A[j]=B[j];
        }
        cin>>y>>x;
        A[y-1]=x;
        int sum=0;
        for(int l=0;l<a;l++){
            sum+=A[l];
        }
        cout<<sum<<endl;
    }





}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7

N, W = MAP()

v, w = [0]*N, [0]*N
dp = [0]*(W+1)

for i in range(N):
	v[i], w[i] = MAP()

	for j in range(W, w[i]-1, -1):
		dp[j] = max(dp[j], dp[j-w[i]]+v[i])

print(dp[W])


Measured memory_bytes: 7408
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int h, a;
  cin >> h >> a;
  cout << (h+a-1) / a << endl;

}

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

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

fn main(){
    let line = read_as_vec::<usize>();
    let (a, b, c, d, e, f)  = (line[0], line[1], line[2], line[3], line[4], line[5]);


    let mut waters: Vec<bool> = vec![false;31];
    waters[0] = true;
    for i in 1..31{
        if i >= a && waters[i-a]{
            waters[i] = true;
        }

        if i >= b && waters[i-b]{
            waters[i] = true;
        }
    }

    let mut sugars: Vec<bool> = vec![false;f+1];
    sugars[0] = true;
    for i in 1..sugars.len(){
        if i >= c && sugars[i-c]{
            sugars[i] = true;
        }

        if i >= d && sugars[i-d]{
            sugars[i] = true;
        }
    }

    let mut ans = (100*a, 0);
    for i in 1..31{
        if waters[i] == false{
            continue;
        }

        for j in 1..sugars.len(){
            if sugars[j] == false{
                continue;
            }
            //too heavy
            if i*100 + j > f{
                break;
            }
            //println!("i = {}, j = {}", i, j);

            //sugar remains
            if j > i*e{
                break;
            }



            // ans.1/(ans.1+ans.0) VS j/(i*100+j)
            if ans.1*(i*100+j) < j*(ans.1+ans.0){
                ans = (i*100, j);
            }
        }
    }

    println!("{} {}", ans.0+ans.1, ans.1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int,int> P;
template <class T> void chmin(T & a, T const & b) { if (b < a) a = b; }
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
using ll = long long;
const ll mod = LLONG_MAX;

int N,sum;
int A[112345];
int B[112345];
int main(){
  cin>>N;

  int sum = 0;
  FOR(i,1,N+1){
    cin>>A[i];
    sum+=abs(A[i]-A[i-1]);
  }
  sum+=abs(A[N]);
  FOR(i,1,N+1){
    int a = abs(A[i-1]-A[i])+abs(A[i]-A[i+1]);
    int b = abs(A[i-1]-A[i+1]);
    cout<<sum- a+b<<endl;

  }


}


Measured memory_bytes: 1664
n = [int(_) for _ in str(input())]
if n[-1] == 2 or n[-1] == 4 or n[-1] == 5 or n[-1] == 7 or n[-1] == 9:
    print('hon')
elif n[-1] == 0 or n[-1] == 1 or n[-1] == 6 or n[-1] == 8:
    print('pon')
elif n[-1] == 3:
    print('bon')


Measured memory_bytes: 9172
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	if N == 3 {
		out("2 5 63")
		return
	}
	if N%2 == 0 {
		p := []int{2, 10, 3, 9, 4, 8, 6, 12}
		w := bufio.NewWriter(os.Stdout)
		defer w.Flush()
		for i := 0; i < N; i++ {
			fmt.Fprint(w, p[i%8]+12*(i/8), " ")
		}
		fmt.Fprintln(w)
	} else {
		p := []int{6, 2, 10, 3, 9, 4, 8, 12}
		w := bufio.NewWriter(os.Stdout)
		defer w.Flush()
		for i := 0; i < N; i++ {
			fmt.Fprint(w, p[i%8]+12*(i/8), " ")
		}
		fmt.Fprintln(w)
	}
}


Measured memory_bytes: 1152
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
#define tget(a,b) get<a>(b)
using namespace std;
typedef long long ll;
const ll INF = 1e17;
const int MOD = 1e9 + 7;

map<char, int> mp;
string a;
int main(void) {
	cin >> a;
	FOR(i, 0, a.size()) {
		mp[a[i]]++;
	}
	FOR(i, 'a', 'z') {
		if (mp[i] % 2 == 1) {
			ct("No");
			return 0;
		}
	}
	ct("Yes");
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long X = scan.nextLong();
        long A = scan.nextLong();
        long B = scan.nextLong();
        scan.close();
        if (B <= A) System.out.println("delicious");
        else if (B - A <= X) System.out.println("safe");
        else System.out.println("dangerous");
    }
}

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

int main() {
  int A, B, C=0, K;
  cin >> K >> A >> B;
  for(int i=A; i<=B; i++){
    if(i%K==0){
      C=1;
      break;
    }
  }
  if(C==1) cout << "OK" << endl;
  else cout << "NG" << endl;
}

Measured memory_bytes: 3636
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納。ノード番号は１から開始なのでn+1個。
        # par[x]<0の時そのノードは根で、par[x]の絶対値はグループのサイズ
        self.parents = [-1] * (n+1)

    # 親の親の...を辿って根を見つける
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            # 再度検索する時に手間がかからないよう根を繋ぎかえる
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # xの属するグループとyの属するグループを併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return False
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
        return True

    # 同じ集合に属するか判定
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xが属するグループのサイズを返す
    def size(self, x):
        x = self.find(x)
        return -self.parents[x]

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

UF = UnionFind(n)
for i in range(m):
    a, b = map(int, input().split())
    UF.union(a, b)

biggest = 0
for i in range(1, n+1):
    biggest = max(biggest, UF.size(i))

print(biggest)

Measured memory_bytes: 77372
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<string>
#include<numeric>

#define INF 100000001
using namespace std;
typedef long long ll;

int a[101];
int n;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	int i = 1;
	while (i < n) {
		if (a[i] == a[i - 1]) {
			ans++;
			i++;
		}
		i++;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        long c = long.Parse(input[2]);
//        long d = long.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string[] input = ReadLine().Split(' ');
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        long max = Max(a,Max(b,c));
        int temp = int.Parse(ReadLine());
        for(int i=0;i<temp;i++){
            max*=2;
        }
        if(a>=b && a>=c){
            WriteLine(max+b+c);
        }else if(b>=a && b>=c){
            WriteLine(max+a+c);
        }else{
            WriteLine(max+a+b);
        }
    }
}

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

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<typename T> void view(T cont) {std::cout << cont << std::endl;}
template<typename T> void view(T* cont, ll sz) {rep(i, sz) std::cout << cont[i] << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<T>& v) {for (const auto& f: v) std::cout << f << " "; std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv) { for (const auto& v: vv) {view(v);}}
const long long INF = 1LL<<60;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int factorial(int n) {
    if (n == 1) return 1;
    return n * factorial(n - 1);
}

int main(){
    int N; cin >> N;
    vector<int> P, Q;
    rep(i, N) {
        int temp_p; cin >> temp_p;
        P.push_back(temp_p);
    }
    rep(i, N) {
        int temp_q; cin >> temp_q;
        Q.push_back(temp_q);
    }
    vector<int> order;
    for (int i = 0; i < N; i++) order.push_back(i + 1);

    int cnt = 1;
    int a = -1;
    int b = -1;
    do {
        // rep(i, N) {
        //     cout << order[i] << " ";
        // }
        // cout << endl;

        bool p_same = true;
        bool q_same = true;
        rep(i, N) {
            if (P[i] != order[i]) p_same = false;
        }
        if (p_same) a = cnt;
        rep(i, N) {
            if (Q[i] != order[i]) q_same = false;
        }
        if (q_same) b = cnt;
        // bool vec_same = true;
        // if (a < 0) {
        //     rep(i, N) {
        //         if (P[i] != order[i]) vec_same = false;
        //     }
        //     if (vec_same) a = cnt;
        // } else if (b < 0) {
        //     rep(i, N) {
        //         if (Q[i] != order[i]) vec_same = false;
        //     }
        //     if (vec_same) b = cnt;
        // }
        
        cnt++;
    } while (next_permutation(order.begin(), order.end()));
    // cout << a << " " << b << endl;
    cout << abs(a - b) << endl;
}

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

using namespace std;

const int MX = 100005;

typedef long long ll;

int D[MX];

ll solve(ll a, ll b){
	if( b ) return solve(b, a%b) + (a/b) * 2 * b;
	else return -a;
}

int main()
{
	ll N, X;
	scanf("%lld%lld", &N, &X);
	printf("%lld\n", solve(X, N-X) + N);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
// long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

template <class T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}

const int mod = 1000000007;

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const { return mint(*this) += a; }
  mint operator-(const mint a) const { return mint(*this) -= a; }
  mint operator*(const mint a) const { return mint(*this) *= a; }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod - 2); }
  mint &operator/=(const mint a) { return *this *= a.inv(); }
  mint operator/(const mint a) const { return mint(*this) /= a; }
};

mint comb(int n, int a)
{
  mint x = 1, y = 1;
  rep(i, a)
  {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

int main()
{
  int x;
  cin >> x;
  struct mint m(x);
  ll n;
  cin >> n;
  cout << m.pow(n).x << endl;
  return 0;
}


Measured memory_bytes: 3136
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>
#include <stack>

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

using namespace std;

int main(){
  int n;
  int x[200005];
  int t[200005];

  x[0] = 0;
  t[0] = 0;

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

  sort(t, t + (n+1)); // インデックスがずれている

  int tem = (t[n/2] + t[(n/2) + 1]) / 2;
  for(int i = 1; i <= n; i++){
    if(x[i] > tem) cout << t[n / 2] << endl;
    else cout << t[(n/2) + 1] << endl;
  }

  return 0;
}


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

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

    bool b = false;
    while(s.empty() != true){
        b = true;
        s.erase(s.size() - 2); // 2文字ずつ消す
        for(int i=0; i<s.size()/2; i++){
            if(s.at(i) != s.at(s.size()/2 + i)){
                b = false;
                break;
            } 
        }
        if (b) {
            cout << s.size() << endl;
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

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

    map<char, int> chars;
    for (auto c : s) {
        chars[c] = chars[c] + 1;
    }
    for (std::map<char, int>::iterator iter = chars.begin(); iter != chars.end(); iter++) {
        if (iter->second % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int n, k;
	scanf("%d",&n);
	scanf("%d",&k);
	int val = 1;
	
	for (int i = 0; i < n; i++)
	{
		if (val < k)
		{
			val *= 2;
		}
		else
		{
			val += k;
		}
	}
	
	printf("%d",val);
	return 0;
}

Measured memory_bytes: 1696