akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n; i>0; i--)
#define rep1(i, n) for(int i=1; i<n; i++)
#define all(v) v.begin(), v.end()
using pint = pair<int, int>;
using tint = tuple<int, int, int>;
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; }
constexpr double PI=3.14159265358979323846;
constexpr int INF = INT_MAX/2;

int type = 26;

int main() {
	int D;
	cin >> D;
	// 不開催により低下する満足度
	int dec = 0;
	vector<int64_t> c(type);
	vector<vector<int64_t>> l(type, vector<int64_t>(1, -1));
	rep(i, type) {
		cin >> c.at(i);
		dec += c.at(i);
	}
	// 開催により増加する満足度
	vector<vector<int64_t>> s(D, vector<int64_t>(type));
	rep(i, D) {
		rep(j, type) {
			cin >> s.at(i).at(j);
		}
	}

	// 仮の日程
	vector<int64_t> t(D);
	rep(i, D) {
		cin >> t.at(i);
		t.at(i)--;
	}

	// 日程変更クエリ
	int M;
	cin >> M;
	vector<pint> dq(M);
	rep(i, M) {
		cin >> dq.at(i).first >> dq.at(i).second;
		dq.at(i).first--;
		dq.at(i).second--;
	}

	// 初期解の満足度計算
	int a=0, b=0, x, y, z;
	rep(i, D) {
		// i日目に開催するtype
		x = t.at(i);
		// 開催による増加
		a += s.at(i).at(x);
		// 不開催による減少
		b += (dec - c.at(x)*(i-l.at(x).at(l.at(x).size()-1)));
		l.at(x).push_back(i);
		a -= b;
		// 暫定満足度
		// cout << a << endl;
	}
	rep(i, type) {
		l.at(i).push_back(D);
	}

	// 変更処理
	rep(i, M) {
		x = dq.at(i).first;
		y = t.at(x);
		z = dq.at(i).second;
		t.at(x) = z;
		// 開催による増加差分
		a -= s.at(x).at(y);
		a += s.at(x).at(z);
		// 不開催による減少差分 減少
		int f = 0;
		rep1(j, l.at(y).size()) {
			if (l.at(y).at(j-1) == x) {
				l.at(y).at(j-1) = l.at(y).at(j);
				l.at(y).at(j) = x;
			} else {
				f = j;
			}
		}
		l.at(y).pop_back();
		a -= (l.at(y).at(f) - x) * (x - l.at(y).at(f-1)) * c.at(y);
		// 不開催による減少差分 増加
		f = 0;
		l.at(z).push_back(x);
		rrep(j, l.at(z).size()-1) {
			if (l.at(z).at(j-1) > x) {
				l.at(z).at(j) = l.at(z).at(j-1);
				l.at(z).at(j-1) = x;
			} else {
				f = j;
				break;
			}
		}
		a += (l.at(z).at(f+1) - x) * (x - l.at(z).at(f-1)) * c.at(z);
		// 暫定満足度
		cout << a << endl;
	}
}


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

int main(){
  string s;
  cin >> s;
  
  int sum;
  if(s[0]== '1')sum++;
  if(s[1]== '1')sum++;
  if(s[2]== '1')sum++;
  
  cout << sum << endl;
}


Measured memory_bytes: 3620
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	var N, M, X, Y int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &M)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &X)
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &Y)

	xs := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &xs[i])
	}

	ys := make([]int, M)
	for i := 0; i < M; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &ys[i])
	}

	maxx := max(X, max(xs...))
	miny := min(Y, min(ys...))

	if maxx < miny {
		fmt.Println("No War")
	} else {
		fmt.Println("War")
	}
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}

func min(ns ...int) int {
	ret := math.MaxInt64
	for _, n := range ns {
		if n < ret {
			ret = n
		}
	}
	return ret
}


Measured memory_bytes: 640
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define ld long double
#define pb push_back
#define debug cout << "here!"
#define pii pair<int , int>
#define pdd pair<double , double>
#define F first
#define S second
const int maxn = 1e5 * 5 + 10 , inf = 1e9 , pi = 3.14159265;
int a , b , c , d;
void solve(){
    
}
void in(){
    cin >> a >> b >> c >> d;
    if (abs (a - c) <= d){
        cout << "Yes"; return ;
    }
    if (abs (a - b) <= d && abs (b - c) <= d){
        cout << "Yes"; return ;
    }
    cout << "No";
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    in();
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
int T;
ll gcd(ll a, ll b){
    return b ? gcd(b, a % b) : a;
}
int main(){
    cin >> T;
    for(int qw = 0; qw < T; ++qw){
        ll a, b, c, d;
        cin >> a >> b >> c >> d;
        if(d < b || a < b){
            cout << "No" << endl;
            continue;
        }
        // d >= b && a >= b
        if(c + 1 > b - 1){
            cout << "Yes" << endl;
            continue;
        }
        // we need some stuff to be in [c + 1, b - 1]
        // c <= b - 2 && a >= b && d >= b
        ll gc = gcd(b, d);
        // if exist k such as a + k * gc in [c + 1, b - 1] then no
        // it means k * gc in [c + 1 - a, b - 1 - a]
        
        ll k = (c + 1 - a) / gc;
        while(k * gc >= c + 1 - a) --k;
        while(k * gc < c + 1 - a) ++k;
        if(k * gc <= b - 1 - a){
            cout << "No" << endl;
            continue;
        }
        cout << "Yes" << endl;
    }
}
/*
 1
 9 7 5 9
 */


Measured memory_bytes: 256
//sucannerクラス使うためにインポート
import java.util.*;

class Main{
	//プログラムのエントリポイント
	public static void main(String[] args){
		//入力ストリームの生成
		Scanner sc = new Scanner(System.in);
		//case の回数の変数i
		int i = 0;
		//breakされるまで処理を繰り返す
		while (true) {
			//数字を受け取る
			int x = sc.nextInt();
			//変数にｘが入力されたときbreakする
			if( x == 0 ){
				break;
				
			} else {
			//繰り返すたびcase回数に＋１
			i = i+1;
			//表示
			System.out.println("Case " + i + ": " + x);
			}
		}
	}
}

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

int main(){
  int h, n;
  cin >> h >> n;
  vector<int> a(n), b(n);
  for(int i = 0; i < n; i += 1){
    cin >> a[i] >> b[i];
  }
  
  vector<int> dp(h + 1, 1000000000);
  dp[0] = 0;
  for(int i = 1; i <= h; i += 1){
    for(int j = 0; j < n; j += 1){
      dp[i] = min(dp[i], dp[max(i - a[j], 0)] + b[j]);
    }
  }
  
  cout << dp[h] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,v,n,i;
    cin>>a>>b>>c;
    v=a+b;
    if(b>=c){
        cout<<"delicious"<<endl;
        return 0;
    }
    else if(v>=c){
            cout<<"safe"<<endl;
    }
    else{
        cout<<"dangerous"<<endl;
    }


    return 0;
}


Measured memory_bytes: 256
from itertools import groupby
import copy

def equalfind(A):
    A.sort()
    s=1
    count=0
    if len(A)==1:
        return count
    else:
        for i in range(0,len(A)-1):
            if A[i]==A[i+1]:
                s+=1
            else:
                count+=s*(s-1)//2
                s=1
        return count+s*(s-1)//2


N=int(input())
A=list(map(int,input().split()))

B=copy.copy(A)
s=equalfind(B)
data=groupby(B)
ans=[0 for i in range(0,N+1)]
for key,group in data:
    g=len(list(group))
    ans[key]=g

for i in range(0,N):
    minus=ans[A[i]]-1
    print(s-minus)


Measured memory_bytes: 27028
#include <bits/stdc++.h>
#include <sstream>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;

int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  int max = a[0];
  ll ans = 0;
  rep(i,n){
    if(a[i] > max){
      max = a[i];
    }
    if(a[i] < max){
      ans += (max - a[i]);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 4372
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
signed main(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(a+b>c+d)cout<<"Left"<<endl;
    else if(a+b==c+d)cout<<"Balanced"<<endl;
    else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from collections import deque

def resolve():
    N, = iim()
    *A, = iim()

    m = 1000

    m1 = A[0]
    i = 1
    k1 = 0
    while i < N:
        for i in range(i, N):
            ai = A[i]
            diff = ai - m1
            if diff > 0:
                k1, m = divmod(m, m1)
                break
            elif diff < 0:
                m1 = ai

        m1 = A[i]
        for i in range(i, N):
            ai = A[i]
            diff = ai - m1
            if diff > 0:
                m1 = ai
            else:
                k1, m = 0, m + m1 * k1
                i += 1
                break
        else:
            break
        m1 = ai

    print(max(1000, m))



if __name__ == "__main__":
    resolve()


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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long  ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n; cin >> n;
    vvl g(n);
    rep(i,n-1){
        int a,b; cin >> a >> b;
        a--;b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    vl c(n);
    rep(i,n)cin>>c[i];
    sort(rall(c));
    
    vb visited(n);
    vl res(n);
    queue<int> que;
    que.push(0);
    visited[0] = true;
    int idx = 0;
    res[0] = c[idx++];
    while(!que.empty()){
        int node = que.front();
        que.pop();
        for(auto nv:g[node]){
            if(visited[nv] == false){
                res[nv] = c[idx++];
                visited[nv] = true;
                que.push(nv);
            }
        }
    }
    ll ttl = accumulate(all(c),0LL) - c[0];
    out(ttl);
    rep(i,n){
        if(i) cout << " ";
        cout << res[i];
    }
    cout << endl;
}


Measured memory_bytes: 1152
#include <iostream>

#include <deque>

using namespace std;

int main(){
  int q,func,flag;
  long x,p;
  deque <long> A;
  cin >> q;
  for(int i = 0; i < q; i++){
    cin >> func;
    switch (func ) {
      case 0:
        cin >> flag >> x;
        if(flag) A.push_back(x);
        else A.push_front(x);
        break;
      case 1:
        cin >> p;
        cout << A[p] << endl;
        break;
      case 2:
        cin >> flag ;
        if(flag)A.pop_back();
        else A.pop_front();
        break;
    }
  }
  return 0;
}



Measured memory_bytes: 6200
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll p(N);
        rep(i, 0, N) cin >> p[i];

        ll ans = 0;
        rep(i, 0, N) {
                if (p[i] == i+1) {
                        ++ans;
                        ++i;
                }
        }

        cout << ans << endl;

        // ll cnt1 = 0;
        // rep(i, 0, N) {
        //         if (p[i] == i+1) ++cnt1;
        // }

        // ll cnt2 = 0;
        // rep(i, 1, N) {
        //         if (p[i-1] == i and p[i] == i+1) ++cnt2;
        // }

        // ll ans = cnt1 - cnt2;

        // cout << ans << endl;

        // ll cnt = 0;
        // rep(i, 0, N) {
        //         if (p[i] == i+1 or p[i+1] == i+2) ++cnt;
        //         ++i;
        // }

        // if (odd(N) and p.back() == N) ++cnt;

        // ll ans = inf;
        // chmin(ans, cnt);

        // cnt = 0;
        // rep(i, 1, N-1) {
        //         if (p[i] == i+1 or p[i+1] == i+2) ++cnt;
        //         ++i;
        // }

        // if (p[0] == 1 or p.back() == N) ++cnt;
        // chmin(ans, cnt);

        // cout << ans << endl;
}

Measured memory_bytes: 4056
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<cstdlib>
#define cmax(a,b) (a<(b)?a=(b),1:0)
#define cmin(a,b) (a>(b)?a=(b),1:0)
#define dmin(a,b) ((a)<(b)?(a):(b))
#define dmax(a,b) ((a)>(b)?(a):(b))
#define CL fclose(stdin),fclose(stdout)
namespace io
{
	int F()
	{
		int n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
	long long G()
	{
		long long n=0,F=1;
		char ch;
		while((ch=getchar())!='-'&&(ch<'0'||ch>'9'));
		ch=='-'?F=0:n=ch-'0';
		while((ch=getchar())>='0'&&ch<='9')n=(n<<1)+(n<<3)+ch-'0';
		return F?n:-n;
	}
}
char s[11];
int main()
{
	int n=io::F();
	puts("0");
	fflush(stdout);
	scanf("%s",s);
	if(s[0]=='V')return 0;
	char a[2]={s[0],'M'+'F'-s[0]};
	register int l,r,mid;
	for(l=1,r=n-1,mid=l+r>>1;l<=r;mid=l+r>>1)
	{
		printf("%d\n",mid);
		fflush(stdout);
		scanf("%s",s);
		if(s[0]=='V')return 0;
		if(s[0]==a[mid&1])l=mid+1;
			else r=mid-1;
	}
	//printf("%d\n",r);
	//fflush(stdout);
	return 0;
}



Measured memory_bytes: 848
#include <stdio.h>
#include <inttypes.h>

int main(void) {
	uint64_t horieyui = 100;
	uint64_t X;
	uint64_t tamurayukari = 0;
	if (scanf("%" SCNu64, &X) != 1) return 1;
	while (horieyui < X) {
		horieyui += horieyui / 100;
		tamurayukari++;
	}
	printf("%" PRIu64 "\n", tamurayukari);
	return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
using namespace std;

int main() {

	int ans = 0;
	int N; cin >> N;

	if (N >= 105) ans++;
	if (N >= 135) ans++;
	if (N >= 165) ans++;
	if (N >= 189) ans++;
	if (N >= 195) ans++;

	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
A = list(map(int, input().split()))

#最初の所持金
money = 1000
#株の所持数
kabu_c = 0

l = []
#予言で翌日上がるかどうかのリスト
for i in range(n-1):
    if A[i+1] - A[i] > 0:
         l.append(1)
    else:
         l.append(0)

#株の購入
#enumerateを使うと便利、変に勘違いすることもなさそう。
for idx, i in enumerate(l):
    if i == 1 and money - A[idx] >= 0:
        kabu_c = money // A[idx]
        money = money - kabu_c * A[idx]
    if i == 0:
        money = money + kabu_c * A[idx]
        kabu_c = 0

if kabu_c > 0:
    money = money + kabu_c * A[n-1]
print(money)

Measured memory_bytes: 9088
#include<iostream>
using namespace std;
int N,A,B,C,D;
string s;
main()
{
	cin>>N>>A>>B>>C>>D>>s;
	A--,B--,C--,D--;
	for(int i=A;i+1<=C;i++)
	{
		if(s[i]=='#'&&s[i+1]=='#')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	for(int i=B;i+1<=D;i++)
	{
		if(s[i]=='#'&&s[i+1]=='#')
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(D<C)
	{
		s[A]='#';
		s[C]='#';
		int id=-1;
		for(int i=B;i<=D;i++)
		{
			if(s[i-1]=='.'&&s[i]=='.'&&s[i+1]=='.')
			{
				id=i;
				break;
			}
		}
		cout<<(id<0?"No":"Yes")<<endl;
	}
	else
	{
		cout<<"Yes"<<endl;
	}
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep2(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
const ll INF = 100100100100;
const int MOD = 1000000007;
const ld EPS = 1e-10;

int main(){
  ll A, B, K; cin >> A >> B >> K;
  if (A >= K) {
    cout << A - K << " " << B << endl;
  }
  else if (A + B >= K) {
    cout << 0 << " " << B - (K - A) << endl;;
  }
  else {
    cout << 0 << " " << 0 << endl;
  }
  return 0;
}

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

int main()
{
  string s;

  for(;cin>>s;)
    {
      bool flag=true;
      string ans="";
      if(s.size()%2!=0)
	  flag=false;
      for(int i=0;i<s.size()&&flag;i+=2)
	{
	  if(s[i]>'6' ||s[i+1]>'5'||s[i]<'1'||s[i+1]<'1')
	    flag=false;

	  if(s[i]=='6')
	    {
	      if(s[i+1]=='1')
		ans+="z";
	      if(s[i+1]=='2')
		ans+=".";
	      if(s[i+1]=='3')
		ans+="?";
	      if(s[i+1]=='4')
		ans+="!";
	      if(s[i+1]=='5')
		ans+=" ";
	    }
	  else
	    {
	      int a=s[i]-'0';
	      int b=s[i+1]-'0';
	      char tmp='a'+(5*(a-1))+(b-1);
	      ans+=tmp;
	    }
	}
      
      if(flag)
	cout<<ans<<endl;
      else
	cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define endl '\n'
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define line cout<<"----------------------------------"<<endl
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define filein freopen("input.txt","r",stdin)
#define fileout freopen("output.txt","w",stdout)
using namespace std;
const ll mx=200009;
ll nn; 
ll dp[109][5][5][5]; 
ll call(ll n, ll a, ll b,ll c)
{
    if(n==nn) return 1; 
    ll &ans=dp[n][a][b][c]; 
    if(ans!=-1) return ans; 
    ans=0; 
    if(n==0)
    for(ll i=1;i<=4;i++) ans+=call(n+1,i,b,c);
    else if(n==1)
    for(ll i=1;i<=4;i++) ans+=call(n+1,a,i,c);
    else if(n==2)
    {
        for(ll i=1;i<=4;i++)
        {
            if(a==1 and b==3 and i==2) continue; 
            if(a==1 and b==2 and i==3) continue; 
            if(a==3 and b==1 and i==2) continue; 
            ans+=call(n+1,a,b,i);
            ans%=mod; 
        }
    }
    else 
    {
        for(ll i=1;i<=4;i++)
        {
            if(b==1 and c==3 and i==2) continue; 
            if(b==1 and c==2 and i==3) continue; 
            if(b==3 and c==1 and i==2) continue; 
            if(a==1 and b==4 and c==3 and i==2) continue; 
            if(a==1 and b==3 and c==4 and i==2) continue; 
            if(a==1 and b==3 and c==3 and i==2) continue; 
            ans+=call(n+1,b,c,i);
            ans%=mod; 
        }
    }
    return ans%mod; 
}
int  main()
{
    fast;    
    memset(dp,-1,sizeof dp);
    cin>>nn; 
    string str; 
    cout<<call(0,0,0,0)<<endl; 
    
}


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

main()
{
    long int A,B,s,k1,k2;
    int c=0;
    scanf("%ld %ld",&A,&B);

    s= ((A + B)/2) ;

    k1= abs(A-s);
    k2= abs(B-s);

    if(k1 == k2)
        printf("%ld\n",s);
    else
        printf("IMPOSSIBLE\n");


    return 0;
}






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

using namespace std;

int main(void){
    char s[200010] = {'\0'};
    scanf("%s", s);
    int pos = 0;
    long long ans = 0;
    int len = strlen(s);
    long long cnt = 0;
    while(pos < len){
        if(s[pos] == 'A'){
            cnt++;
            pos++;
        }else if(s[pos] == 'B' && s[pos + 1] == 'C'){
            ans += cnt;
            pos += 2;
        }else{
            cnt = 0;
            pos++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

int main(){
   int N;
   std::cin >> N;
   std::vector<int> a(N);
   for (int i=0; i<N; i++){
      std::cin >> a.at(i);
   }
   int cnt = 0;
   for (int i=0; i<N; i++){
      if (a.at(i) % 2 == 0){
         int temp = a.at(i);
         while (temp % 2 == 0){
            temp = temp / 2;
            cnt++;
         }
         std::cerr << a.at(i) << " " << cnt << std::endl;
      }
   }
   std::cout << cnt << std::endl;
}



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

const int MOD = (int)1e9+7;

int main(){
	int A,B;
	cin >> A >> B;

	int ans=0;
	int now=1;
	while(1){
		if(now<B){
			now+=A-1;
			ans++;
		}
		else	break;
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define NIL NULL
typedef struct node* Node;
struct node{
  Node right;
  Node left;
  Node parent;
  int key;
};
Node root;

Node treeMinimum(Node x){
  while(x->left != NIL) x = x->left;
  return x;
}
Node treeSearch(Node x,int k) {
  while(x != NIL && k != x->key) {
    if(k < x->key) x = x->left;
    else x = x->right;
  }
  return x;
}

Node treeSuccessor(Node x) {
  Node y;
  if(x->right != NIL) return treeMinimum(x->right);
  y = x->parent;
  while(y != NIL && x->key == y->right->key) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node z){
  Node y;
  Node x;
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);
  if(y->left != NIL) x = y->left;
  else x = y->right;

  if(x != NIL) x->parent = y->parent;
  if(y->parent == NIL) root = x;
  else if(y == y->parent->left) y->parent->left = x;
  else y->parent->right = x;
  if(y != z) z->key = y->key;
}

void insert(int k) {
  Node y = NIL;
  Node x = root;
  Node z;

  z = (Node)malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL) {
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;

  if(y == NIL) root = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void inorder(Node u) {
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node u) {
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main()
{
  int n,i,x;
  char c[10];
  Node t;
  scanf("%d",&n);

  for(i=0; i<n; i++) {
    scanf("%s",c);
    if(!strcmp(c,"find")) {
      scanf("%d",&x);
      t = treeSearch(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(!strcmp(c,"insert")) {
      scanf("%d",&x);
      insert(x);
    }
    else if(!strcmp(c,"print")){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if(!strcmp(c,"delete")) {
      scanf("%d",&x);
      treeDelete(treeSearch(root,x));
    }
  }
  return 0;
}

Measured memory_bytes: 19364
import java.io.*;

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

        String str = br.readLine();
        String[] data = str.split(" ");
        int[] numdata = new int[4];
        for (int i = 0; i < 4; i++) {
            numdata[i] = Integer.parseInt(data[i]);
        }

        int a = 0, b = 0, c = 0, d = 0, e = 0;
        for (int i = 0; i < 4; i++) {
            if (!(e == 0)) {
                e = 1;
                break;
            }
            switch (numdata[i]) {
            case 1:
                if (a == 0) {
                    a = 1;
                } else {
                    e = 1;
                }
                break;
            case 9:
                if (b == 0) {
                    b = 1;
                } else {
                    e = 1;
                }
                break;
            case 7:
                if (c == 0) {
                    c = 1;
                } else {
                    e = 1;
                }
                break;
            case 4:
                if (d == 0) {
                    d = 1;
                } else {
                    e = 1;
                }
                break;
            default:
                e = 1;
                break;
            }
        }

        if (e == 0)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}

Measured memory_bytes: 22612
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, insort, insort_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
from decimal import *

N = INT()
a = LIST()
b = LIST()

a_cnt = 0
b_cnt = 0

for i in range(N):
	if a[i] < b[i]:
		a_cnt += -(a[i]-b[i])//2
	elif a[i] > b[i]:
		b_cnt += a[i]-b[i]


if b_cnt <= a_cnt:
	print("Yes")
else:
	print("No")
	

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

int main()
{
  int64_t N, A, B, q;
  cin >> N >> A >> B;
  int64_t C[3] = {0, 0, 0};
  for (int i = 0; i < N; i++)
  {
    cin >> q;
    if (q <= A)
      C[0]++;
    else if (q >= B + 1)
      C[2]++;
    else
      C[1]++;
  }
  cout << min(C[0], min(C[1], C[2])) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ct;
    int maxct = 0;

    REP(i, n){
        ct = 0;
        map<char, int> ct1;
        map<char, int> ct2;
        
        FOR(j, i, n) ct1[s[j]]++;
        FOR(j, 0, i) ct2[s[j]]++;

        for(char c = 'a'; c <= 'z'; c++){
            if (ct1[c] > 0 && ct2[c] > 0) ct++;
        }
        
        if (ct > maxct) maxct = ct;
                                                                                                                                                             
    }

    cout << maxct << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int main()
{
    IO;

    ll N, K, P; cin >> N >> K;
    vl a(N);
    rep(i, N) cin >> a[i];
    rep(j, N) {
        if (a[j] == 1) {
            P = j + 1;
        }
    }
    
    if (N == K) {
        cout << 1 << endl;
    }
    else if (P == 1 || P == N) {
        if ((N - 1) % (K - 1) == 0) {
            cout << (N - 1) / (K - 1) << endl;
        }
        else {
            cout << (N - 1) / (K - 1) + 1 << endl;
        }
    }
    else if ((N - K) % (K - 1) == 0) {
        cout << (N - K) / (K - 1) + 1 << endl;
    }
    else if ((P - 1) / (K - 1) == 0 || (N - P) / (K - 1) == 0) {
        if ((N - K) % (K - 1) == 0) {
            cout << (N - K) / (K - 1) + 1<< endl;
        }
        else {
            cout << (N - K) / (K - 1) + 2 << endl;
        }
    }
    else {
        if ((P - 1) % (K - 1) == 0 && (N - P) % (K - 1) == 0) {
            cout << (P - 1) / (K - 1) + (N - P) / (K - 1) << endl;
        }
        else if ((P - 1) % (K - 1) != 0 && (N - P) % (K - 1) == 0) {
            cout << (P - 1) / (K - 1) + (N - P) / (K - 1) + 1 << endl;
        }
        else if ((P - 1) % (K - 1) == 0 && (N - P) % (K - 1) != 0) {
            cout << (P - 1) / (K - 1) + (N - P) / (K - 1) + 1 << endl;
        }
        else {
            cout << (P - 1) / (K - 1) + (N - P) / (K - 1) + 2 << endl;
        }
    }
}

Measured memory_bytes: 3680
//Solution by Tima
#include <bits/stdc++.h>
 
#define f first
#define s second
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define vi vector <int>
#define ld long double
#define pii pair<int, int>
#define y1 sda
 
using namespace std;    
const int N = int(3e5) + 12, mod = int(1e9)  + 7; 

int n;

pair <int,int> p[N];

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

	for(int i = 1,x,l; i <= n; i++){
		scanf("%d%d", &x, &l);
		p[i] = mp(x + l,x - l);
	}
	sort(p + 1, p + n + 1);

	int ans = 0, last = -2 * mod;
	for(int i = 1; i <= n; i++){
	    if(p[i].s >= last){
	    	last = p[i].f;
	    	ans++;
	    }
	}
	cout << ans;

 
return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(void)
{
   int i,n,t,w[13],x[13],y[13],z[13];
   char a;
   for(i=0;i<13;i++){
      w[i]=0;
      x[i]=0;
      y[i]=0;
      z[i]=0;
   }
   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%s %d",&a,&t);
      if(a=='S'){
         w[t-1]=1;
      }
      else if(a=='H'){
         x[t-1]=1;
      }
      else if(a=='C'){
         y[t-1]=1;
      }
      else if(a=='D'){
         z[t-1]=1;
      }
   }
   for(i=0;i<13;i++){
      if(w[i]==0){
         printf("S %d\n",i+1);
      }
   }
   for(i=0;i<13;i++){
      if(x[i]==0){
         printf("H %d\n",i+1);
      }
   }
   for(i=0;i<13;i++){
      if(y[i]==0){
         printf("C %d\n",i+1);
      }
   }
   for(i=0;i<13;i++){
      if(z[i]==0){
         printf("D %d\n",i+1);
      }
   }
   return 0;
}

Measured memory_bytes: 596
N,M = map(int,input().split()) 
H = list(map(int,input().split()))
lst = [[] for _ in range(N)]
for i in range(M):
    A,B = map(int,input().split())
    lst[A-1].append(B-1)
    lst[B-1].append(A-1)
cnt = 0
for i in range(N):
    if len(lst[i]) == 0:
        cnt += 1
    else:
        flg = True
        for j in lst[i]:
            if H[i] <= H[j]:
                flg = False
        if flg:
            cnt += 1
print(cnt)            


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

using namespace std;

typedef long long ll;

int main() {
    ll n;   cin >> n;
    ll *a = new ll[n], *b = new ll[n], *c = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int i = 0; i < n; i++)
        cin >> b[i];
    for (int i = 0; i < n; i++) 
        cin >> c[i];

    sort(a, a+n);
    sort(b, b+n);
    sort(c, c+n);

    ll sum = 0;
    for (int i = 0; i < n; i++) {
        ll cnt_a = upper_bound(a, a+n, b[i]-1) - a;
        ll cnt_c = c+n - lower_bound(c, c+n, b[i]+1);
        sum += cnt_a*cnt_c;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 2560
# C Colon

import math

a, b, h, m = map(int, input().split())

theta = abs((1/30 - 1/360)*(60*h+m)*math.pi)
if theta > math.pi:
  theta = 2*math.pi - theta
  
ans = (a**2 + b**2 - 2*a*b*math.cos(theta))**(1/2)

print(ans)

Measured memory_bytes: 9504
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const int mod = 1000000007;
const int inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int, P>PP;
int f[100006];

struct segtree {
	int n = 1;
	vector<int>node, lazy;
	void init(int N) {
		while (n < N)n *= 2;
		node.resize(2 * n - 1);
		lazy.resize(2 * n - 1);
	}
	void eval(int k, int l, int r) {
		if (!lazy[k])return;
		node[k] += lazy[k]*(r-l);
		if (k < n - 1) {
			rep(i, 2) {
				lazy[2 * k + i + 1] += lazy[k];
			}
		}
		lazy[k] = 0;
	}
	void update(int a, int b, int x, int k, int l, int r) {
		eval(k, l, r);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] += x;
			eval(k, l, r);
			return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		node[k] = node[k * 2 + 1] + node[k * 2 + 2];
	}
	int calc(int a, int b, int k, int l, int r) {
		eval(k, l, r);
		if (r <= a || b <= l)return 0;
		if (a <= l&&r <= b)return node[k];
		int vl = calc(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = calc(a, b, k * 2 + 2, (l + r) / 2, r);
		return vl + vr;
	}
	void add(int a, int b, int x) {
		update(a, b, x, 0, 0, n);
	}
	int getsum(int a, int b) {
		return calc(a, b, 0, 0, n);
	}
};
segtree seg;
signed main() {
	int n, q; cin >> n >> q;
	seg.init(n);
	rep(i, q) {
		int Q; cin >> Q;
		if (Q) {
			int s, t; cin >> s >> t;
			cout << seg.getsum(s - 1, t)<<endl;
		}
		else {
			int s, t, u; cin >> s >> t >> u;
			seg.add(s - 1, t, u);
		}
	}
}



Measured memory_bytes: 7052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,u,v;
  cin >> N >> u >> v;
  vector<set<int>> E(N);
  for (int i = 0; i < N - 1; i++){
    int A,B;
    cin >> A >> B;
    E[A-1].insert(B-1);
    E[B-1].insert(A-1);
  }
  int T = u-1;
  int A = v-1;
  //T,Aのそれぞれの頂点までの距離
  vector<int> TD(N,-1),AD(N,-1);
  queue<int> Q;
  Q.push(T);
  TD[T]=0;
  while (!Q.empty()){
    int V = Q.front();
    Q.pop();
    for (int i : E[V]){
      if (TD[i] == -1){
        TD[i] = TD[V] + 1;
        Q.push(i);
      }
    }
  }
  Q.push(A);
  AD[A]=0;
  while (!Q.empty()){
    int V = Q.front();
    Q.pop();
    for (int i : E[V]){
      if (AD[i] == -1){
        AD[i] = AD[V] + 1;
        Q.push(i);
      }
    }
  }
  set<int> S;
  for (int i = 0; i < N; i++){
    if (AD[i] > TD[i]) S.insert(i);
  }
  int res=0;
  for (int i : S){
    res = max(res,AD[i]-1);
  }
  cout << res;
}

Measured memory_bytes: 19712
from collections import Counter
n = int(input())
def gcd(x, y): 
    while(y): 
        x, y = y, x % y 
  
    return x 
s = 0
c = []
c1 = []
for i in range(1,n+1):
	for j in range(i,n+1):
		for k in range(j,n+1):
			if i == j ==k:
				s+=i
			elif i!=j!=k:
				s+=6*gcd(i,gcd(j,k))
			else:
				kk = sorted([i,j,k])
				s+=3*gcd(kk[0],kk[-1])
			c.append(tuple(sorted([i,j,k])))
print(s)


Measured memory_bytes: 105784
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <cmath>
#include <cstdio>
#include <map>
using namespace std;

#define PI 4*atan(1);

int main(){
  int n;
  while(cin >> n && n){
    map<char, char> table;
    char a, b;
    for(int i = 0; i < n; i++){
      cin >> a >> b;
      table[a] = b;
    }
    int m;
    cin >> m;
    string s;
    for(int i = 0; i < m; i++){
      char tmp;
      cin >> tmp;

      if(table.count(tmp)){
        s += table[tmp];
      }else{
        s += tmp;
      }
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 1332
import * as fs from 'fs';

namespace AtCoder {
    export interface Paramable {
        readonly args: string[][];
    }

    export interface Task {
        main(this: Task): void;
    }
}

namespace AtCoder.abc001 {
    export class TaskA implements AtCoder.Task, AtCoder.Paramable {
        public constructor(public readonly args: string[][]) {
        }

        public main(this: TaskA): void {
            const abc: number[] = this.args[0].map(Number);

            abc.sort();

            if (abc[0]===abc[1]) {
                console.log(abc[2]);
            } else{
                console.log(abc[0]);
            }
        }
    }

    const args: string[][] = fs.readFileSync('/dev/stdin', 'utf8').trim().split('\n').map(r => r.split(' '));
    const task: AtCoder.Task = new TaskA(args);
    task.main();
}



Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();

		int A = sc.nextInt();
		int B = sc.nextInt();

		String U = sc.next();

		if (U.equals(S)){
			A--;
		} else {
			B--;
		}
		System.out.println(A + " " + B);

	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W ;
    while(1){
        cin >> H >> W;
        if(H==0 && W==0){
            break;
        }
        for(int i=0;i<H;i++){
          for(int j=0;j<W;j++){
            if((i+j)%2==0){
                cout << "#";
            } else {
                cout << ".";
            }
          }
          cout << endl;
        }
      cout << endl;
     }
}


Measured memory_bytes: 3100
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main implements Runnable {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        // Run with 32MB stack
        Thread thread = new Thread(null, new Main(), "", 32 * 1024 * 1024);
        thread.start();
    }

    @Override
    public void run() {
        final Scanner scanner = new Scanner(System.in);
        solve(scanner);
    }

    static void solve(Scanner scanner) {
        int N = Integer.parseInt(scanner.next());
        long K = Long.parseLong(scanner.next());
        Long[] A = new Long[N];
        for (int i = 0; i < N; i++) {
            A[i] = Long.parseLong(scanner.next());
        }
        Arrays.sort(A);
        Long[] F = new Long[N];
        for (int i = 0; i < N; i++) {
            F[i] = Long.parseLong(scanner.next());
        }
        Arrays.sort(F, Comparator.reverseOrder());

        long l = -1, r = (long) 1e12;
        while (r - l > 1) {
            long mid = (l + r) >>> 1;
            long sum = 0;
            for (int i = 0; i < N; i++) {
                sum += Math.max(0, A[i] - mid / F[i]);
            }
            if (sum <= K) {
                r = mid;
            } else {
                l = mid;
            }
        }

        System.out.println(r);
    }
}


Measured memory_bytes: 82412
#include <bits/stdc++.h>
using namespace std;
long long dp[100099];
int n,k,a[100099];
int main()
{
    cin>>n>>k;
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    dp[0]=0;
    for (int i=1;i<100099;i++) dp[i]=999999999999999999;
    for (int i=0;i<n;i++)
    {
        for (int j=1;j<=k && i-j>=0;j++)
        {
            dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
        }
    }
    cout<<dp[n-1];
}


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

using namespace std;

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

Measured memory_bytes: 3596
#include <iostream>




using namespace std;
int N;
int A;
int B;
int tr_total;


int main () {
    cin >> N;
    cin >> A; // train (each)
    cin >> B; // taxi (total)

    tr_total = A* N;
    

    if (tr_total<B){
        cout << tr_total;
    }else{
        cout << B;
    }
    
}

    

    
    


     

    

    





Measured memory_bytes: 256
# coding: utf-8
import sys
from heapq import heapify, heappop, heappush

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 同じ地点で銀貨の枚数によって別の状態として扱う（最大max(A)*(N-1))
N, M, S = lr()
UVAB = [lr() for _ in range(M)]
CD = [lr() for _ in range(N)]  # 0-indexed
Amax = 0
for i in range(M):
    a = UVAB[i][2]
    if a > Amax:
        Amax = a

limit = Amax*(N-1)
S = min(S, limit)
graph = [[] for _ in range(N+1)] # 1-indexed
for u, v, a, b in UVAB:
    graph[u].append((v, a, b))
    graph[v].append((u, a, b))

def dijkstra(start):
    # 時間、銀貨の枚数、現在地をqueへ
    INF = 10 ** 15
    dist = [[INF for _ in range(limit+1)] for _ in range(N+1)]
    dist[1][S] = 0
    que = [(0, S, 1)]
    while que:
        time, silver, prev = heappop(que)
        if dist[prev][silver] < time:
            continue
        for next, a, b in graph[prev]:
            t = time + b
            si = silver - a
            if si < 0:
                continue
            if dist[next][si] > t:
                dist[next][si] = t
                heappush(que, (t, si, next))
        c, d = CD[prev-1]
        si = min(limit, silver+c)
        while dist[prev][si] > time + d:
            dist[prev][si] = time + d
            heappush(que, (time+d, si, prev))
            si += c; si = min(limit, si)
            time += d
            
    return dist

dist = dijkstra(1)
for i in range(2, N+1):
    d = dist[i]
    answer = min(d)
    print(answer)

# 52

Measured memory_bytes: 52724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll x=0;ll y=0;ll z=0;
    for(int i=0;i<n;i++){
        ll a;
        cin>>a;
        if(a%4==0)x++;
        else if(a%4!=0 && a%2==0)y++;
        else z++;
    }
    if(y==0){
        if(z<=x+1)puts("Yes");
        else puts("No");
    }
    if(y>0){
        if(z<=x)puts("Yes");
        else puts("No");
    }
}


Measured memory_bytes: 3672
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")

const int mod = 998244353;

int pow_mod(int a, int b) {
  if (b == 0) return 1;
  int nesf = pow_mod(a, b / 2);
  if (b % 2 == 0) return nesf * nesf % mod;
  else return ((nesf * nesf % mod) * a) % mod;
}

int inv(int a) {
  return pow_mod(a, mod - 2);
}

const int N = 2e5 + 100;
int fuc[N];

int ent(int n, int k) {
  return fuc[n] * inv(fuc[k]) % mod * inv(fuc[n - k]) % mod;
}
signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m, k;
  cin >> n >> m >> k;
  fuc[0] = 1;
  for (int i = 1; i < N; i++) {
    fuc[i] = fuc[i - 1] * i % mod;
  }
  int ans = 0;
  for (int i = 0; i <= k; i++) {
    ans += m * pow_mod(m - 1, n - i - 1) % mod * ent(n - 1, i) % mod;
    ans %= mod;
  }
  cout << ans << "\n";
}



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

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

    int N;
    cin >> N;
    vector<ll> A(N);
    int cntNeg = 0;
    for (auto &x : A) {
        cin >> x;
        if (x < 0) {
            cntNeg++;
            x *= -1;
        }
    }
    sort(A.begin(), A.end());
    ll sum = 0;
    for (int i = 0; i < N; ++i) {
        if (i < cntNeg % 2) {
            sum -= A.at(i);
        } else {
            sum += A.at(i);
        }
    }
    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int ans = 0;
  if(s.length() <= 1){
    cout << 0;
    return 0;
  }
  for(int i = 0; i<= s.length()-2;i++){
    char a = s[i];
    char b = s[i+1];
    if(a != b){
      ans++;
    }
  }
  cout << ans;
}


Measured memory_bytes: 512
n = int(input())
W = list(map(int, input().split()))

W_org = W[:]
W_org_idx = {w:i for i, w in enumerate(W_org)}
W_srt = list(sorted(W[:]))
W_srt_idx = {w:i for i, w in enumerate(W_srt)}

#print(W_org)
#print(W_org_idx)
#print(W_srt)
#print(W_srt_idx)


def rec(idx, ret):
    if W_org[idx] in ret:
        return ret
    
    ret.append(W_org[idx])
    idx = W_srt_idx[W_org[idx]]
    return rec(idx, ret)

ans = 0
searched = set()
all_min_r = min(W_org)
for i in range(n):    
    if W_org[i] in searched:
        continue
    ret = rec(i, [])
    for r in ret:
        searched.add(r)
    
    if len(ret) == 1:
        continue
    elif len(ret) == 2:
        ans += sum(ret)
    else:
        #print(ret)
        min_r = min(ret)
        ans_a = sum(ret) + len(ret)*min_r - 2*min_r
        
        ans_b = 2*(all_min_r+min_r) + (sum(ret)-min_r+all_min_r) + len(ret)*all_min_r - 2*all_min_r
        ans += min(ans_a, ans_b)

print(ans)
        
    
    



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

#define ff first
#define ss second
#define pb push_back
#define ll long long
#define ull unsigned long long
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define mst(ss,b) memset(ss,b,sizeof(ss));
#define dbg(x) cout << #x << "= " << x << endl;
typedef pair <int, int> pii;
const int inf = 0x3f3f3f3f;
const ll INF = (1LL<<62)-1;
const ll mod = 1e9+7;
const int N = 2e5+5;

int a[N];
vector<int>ans;
int n;

int  main(){
    scanf("%d", &n);
    for(int i=1; i<=n; i++)scanf("%d", &a[i]);
    if(n&1){
        int sz = n;
        while(sz > 0){
            ans.pb(a[sz]);
            sz -= 2;
        }
        sz = 2;
        while(sz < n){
            ans.pb(a[sz]);
            sz += 2;
        }
    }
    else{
        int sz = n;
        while(sz > 0){
            ans.pb(a[sz]);
            sz -= 2;
        }
        sz = 1;
        while(sz < n){
            ans.pb(a[sz]);
            sz += 2;
        }
    }
    for(auto x : ans)printf("%d ", x);
    puts("");
    return 0;
}


//    lower_bound()
//    __builtin_popcount()
//    ios::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
//    freopen("out.txt","w",stdout);
//    const double eps=1e-12;
//    #pragma comment(linker,"/STACK:102400000,102400000")



Measured memory_bytes: 3828