akhauriyash/Code-Regression huggingface dataset:
# coding=utf-8
import array


def sieve_of_eratosthenes(end: int) -> array:
    # noinspection PyUnusedLocal
    is_prime = array.array('B', (True for i in range(end+1)))
    is_prime[0] = False
    is_prime[1] = False

    primes = array.array("L")
    for i in range(2, end+1):
        if is_prime[i]:
            primes.append(i)
            for j in range(i * 2, end+1, i):
                is_prime[j] = False
    return primes


if __name__ == '__main__':
    prime_table = sieve_of_eratosthenes(1000000)
    while True:
        try:
            n = int(input())
        except EOFError:
            break
        prime_table_under_n = [x for x in prime_table if x <= n]
        print(len(prime_table_under_n))

Measured memory_bytes: 12352
-- ordinary-beauty.hs --- Ordinary Beauty

-- author: Seong Yong-ju <sei40kr@gmail.com>

solve :: Double -> Double -> Double -> Double
solve n m 0 = (m - 1) / n
solve n m d = 2 * (n - d) * (m - 1) / (n * n)

main :: IO ()
main = do
  [n,m,d] <- map (read ::String -> Double) . words <$> getLine
  print $ solve n m d


Measured memory_bytes: 508
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	int n, m;
	cin >> n >> m;

	vector<int> a(n);
	for (int i = 0; i < 2 * m; i++)
	{
		int x;
		cin >> x;

		a.at(x - 1)++;
	}

	for (int i = 0; i < n; i++)
	{
		cout << a.at(i) << endl;
	}
}

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

void print(int k)
{
    int bit = (1 << 3);
    while(bit > 0)
    {
        cout << (((bit & k) == bit) ? 1 : 0);
        bit >>= 1;
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    long long n, k;
    cin >> n >> k;

    vector<int> A(n, 0);
    vector<int> B(n, 0);

    long long ans = 0;
    for(int i = 0; i < n; ++i)
    {
        cin >> A[i] >> B[i];
        if((A[i] & k) == A[i]) ans += B[i];
    }

    for(int bit = (1 << 30); bit > 0; bit >>= 1)
    {
        if(!(bit & k)) continue;

        long long valid_bits = (bit - 1) | (k ^ bit);

        long long total = 0;
        for(int i = 0; i < n; ++i)
        {
            const long long a = A[i]; 
            const long long b = B[i];

            if((a & valid_bits) != a) continue;

            total += b;
        }
        ans = max(total, ans);
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		HashMap<String,String> map = new HashMap<String,String>();
		map.put("A", "T");
		map.put("T", "A");
		map.put("C", "G");
		map.put("G", "C");
		Scanner sc = new Scanner(System.in);
		System.out.println(map.get(sc.next()));
	}

}

Measured memory_bytes: 23892
def solve(n, a):
    v = [(i, a[i]) for i in range(n)]
    u = [p+1 for p, q in sorted(v, key=lambda _:_[1])]
    return " ".join(map(str, u))

n = int(input())
a = list(map(int, input().split()))
print(solve(n, a))

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest element(0-based)=> cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X => cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
vector<string> adj[100010];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,id;
	string s;
	cin>>n>>m;
	for(ll i=0;i<m;i++)
	{
		cin>>id>>s;
		adj[id].pb(s);
	}
	ll ac=0,pen=0;
	for(ll i=1;i<=n;i++)
	{
		bool flag=0;
		ll tpen=0;
		for(auto it:adj[i])
		{
			if(it=="AC")
			{
				ac++;
				flag=1;
				break;
			}
			else tpen++;
		}
		if(flag)pen+=tpen;
	}
	cout<<ac<<" "<<pen<<"\n";
	return 0;
}

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

int main(void){
  int H, W;

  cin >> H >> W;
  do{
    for( int i = 0; i < H; i++ ){
      if ( i == 0 || i == H-1 ){
	for( int j = 0; j < W; j++ ){
	  cout << '#';
	}
      }else{
	for( int j = 0; j < W; j++ ){
	  if( j == 0 || j == W-1 ){
	    cout << '#';
	  }else{
	    cout << '.';
	  }
	}
      }
      cout << endl;
    }
    cout << endl;
    
    cin >> H >> W;
  }while( H != 0 || W != 0);
  
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

ll dp[2][2020];

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif

    string S;
    cin >> S;
    ll N = (ll)S.size();

    ll ans = 0;

    for (ll i = 1; i <= N; i++) {
        int d = S[i - 1] - '0';
        int prev = (i - 1) % 2;
        int now = i % 2;
        for (ll r = 0; r < 2019; r++) {
            dp[now][r] = 0;
        }
        for (ll r = 0; r < 2019; r++) {
            ll nr = (r * 10 + d) % 2019;
            dp[now][nr] += dp[prev][r];
        }
        dp[now][d] += 1;
        ans += dp[now][0];
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3736
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで
// g++ hoge.cpp -std=c++17 -I . でコンパイルできる
// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#include <atcoder/all>
#define mod 1000000007
#define INF LLONG_MAX
#define ll int
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
using namespace atcoder;
typedef pair<ll,ll> P;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};
 
int op(int a, int b) { return max(a, b); }
 
int e() { return 0; }
 
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
 
    ll a,b,c,d,m,n,k,x,y,maxi=0,f=0,sum=0;
    string str;
    int hoge=0;
    cin>>n>>k;
    vector<ll> v(n);
    ll size=300020;
    segtree<int, op, e> seg(size);
    rep(i,size) seg.set(i,0);
    rep(i,n){
        cin>>v[i];
    }
    rep(i,n){
        ll left=v[i]-k;
        ll right=v[i]+k;
        if(left<0) left=0;
        if(size<=right) right=size-2;
        ll maxia=seg.prod(left,right+1);
        seg.set(v[i],maxia+1);
    }
    rep(i,size){
        hoge=max(seg.get(i),hoge);
    }
    cout<<hoge<<endl;
 
    return 0;
}

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

using namespace std;
int N;
int T[105];
int M;
int p,x;

int main(){
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> T[i];
    }
    cin >> M;
    for(int i = 1; i <= M; i++){
        cin >> p >> x;
        int sum = 0;    
        
        for(int j = 1; j <= N; j++){
            sum += (j==p)? x : T[j];
        }
        cout << sum << endl;
    }
}


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

#define N 10000

int main(void){
  int n, q, A[N], num;
  int cnt=0;
  
  scanf("%d", &n);
  for(int i=0; i<n; i++) scanf("%d", A+i);
  
  scanf("%d", &q);
  for(int i=0; i<q; i++){
    scanf("%d", &num);
    
    for(int j=0; j<n; j++){
      if(num == A[j]){
	cnt++;
	break;
      }
    }
    
  }

  printf("%d\n", cnt);
  
  return 0;
}



Measured memory_bytes: 3204
ABCD = input()
A, B, C, D = int(ABCD[0]), int(ABCD[1]), int(ABCD[2]), int(ABCD[3])
oper = ['+', '-']

for op1 in range(2):
    for op2 in range(2):
        for op3 in range(2):
            sum = A + (-1)**op1*B + (-1)**op2*C + (-1)**op3*D
            if sum == 7:
                ans = str(A)+oper[op1]+str(B)+oper[op2]+str(C)+oper[op3]+str(D)+'=7'
                break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
int main()
{
    int n,a[200005],inc[200005],sf[200005];
    cin >> n;
    for (int i=1;i<=n;i++)
    {
        cin >> a[i];
    }
    inc[n]=a[n];
    for (int i=n-1;i>=1;i--)
    {
        inc[i]=max(a[i],inc[i+1]);
    }
    sf[1]=a[1];
    for (int i=2;i<=n;i++)
    {
        sf[i]=max(a[i],sf[i-1]);
    }
    cout << inc[2] << '\n';
    for (int i=2;i<n;i++)
    {
        cout << max(sf[i-1],inc[i+1]) << '\n';
    }
    cout << sf[n-1];
}

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

int main()
{
	int a,b,s=0,t=0;
	for(int i=1; i<=4; i++){
		cin>>a;
		s+=a;
		}
	for(int i=1; i<=4; i++){
		cin>>b;
		t+=b;
		}
	if(s>=t)
		cout<<s<<endl;
	else
		cout<<t<<endl;
	return 0;
}

Measured memory_bytes: 1164
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;

		for (int i = 0; i < 2; i++) {

			if (a >= b) {
				ans += a;
				a--;

			} else {
				ans += b;
				b--;
			}
		}

		System.out.println(ans);

	}

}


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

ll f(ll n){
    if(n == 0) return 2;
    if(n == 1) return 1;
    else return f(n-1) + f(n-2);
}

int main(){
    ll n;
    cin >> n;

    if(n == 0){
        cout << "2" << endl;
        return 0;
    }
    if(n == 1){
        cout << "1" << endl;
        return 0;
    }

    ll tmp[n+1];
    tmp[0] = 2;
    tmp[1] = 1;
    for (int i=2;i<=n;i++){
        tmp[i] = tmp[i-1] + tmp[i-2];
    }
    cout << tmp[n] << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int N,a,s[200000],p;
main()
{
  int i,ret;
  scanf("%d",&N);
  ret=1;p=0;
  scanf("%d",&s[0]);
  for(i=1;i<N;i++)
    {
      scanf("%d",&a);
      if(a > s[p])
	s[++p]=a,ret++;
      if(a < s[p])
	{
	  while(p>=0 && a<s[p])
	    p--;
	  if(a > s[p])
	    s[++p]=a,ret++;
	}
    }
  printf("%d\n",ret);
  return(0);
}

Measured memory_bytes: 1376
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AOddsOfOddness solver = new AOddsOfOddness();
        solver.solve(1, in, out);
        out.close();
    }

    static class AOddsOfOddness {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int n = in.scanInt();
            int odd = (n + 1) / 2;
            out.printf("%.10f", (odd / (double) (n)));
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, x);
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;

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

int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void) {
  int a, b;
  cin >> a >> b;
  if (a == b) {
    cout << "Draw" << endl;
  } else if (a == 1) {
    cout << "Alice" << endl;
  } else if (b == 1) {
    cout << "Bob" << endl;
  } else if (a > b) {
    cout << "Alice" << endl;
  } else if (a < b) {
    cout << "Bob" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int i = a; i <= (b); ++i) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int n;
	cin >> n;
	int anscount = 0;
	int count = 0;
	rep1(i, n) {
		if (i % 2 != 0) {
			rep1(j, i) {
				if (i % j == 0) {
					count++;
				}
			}
		}
		if (count == 8) {
			count = 0;
			anscount++;
		}
		else
			count = 0;
	}
	cout << anscount<<endl;
	return 0;
}


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

const int divisor = 1000000007;

int main(){
	vector<int> ansvec;

	// 100000!までの数をdivisorで割った余りを格納しておく
	long long* factmodary = new long long[100001];
	long long fact = 1;
	for (int i = 1; i <= 100000; i++){
		fact *= i;
		fact %= divisor;
		factmodary[i] = fact;
	}

	int* word = new int[100000] {0};

	for (;;){
		int N, R;
		cin >> N;
		if (N == 0) break;
		cin >> R;
		
		//まず0番目の単語を入れておく
		for (int i = 0; i < N; i++) word[i] = i + 1;

		for (int i = 0; i < R; i++){
			int s, t;
			cin >> s >> t;
			/* swap */
			int tmp = word[s - 1]; word[s - 1] = word[t - 1]; word[t - 1] = tmp;
		}

		//word[i]をkey, word[i]より小さい数がそれ以前にいくつ使われていたかをvalueとして格納するmap
		map<int, int> bubblehist;
		bubblehist[word[0]] = 0;

		long long ans = factmodary[N-1] * (word[0] - 1);

		for (int i = 1; i < N; i++){
			int facttime = word[i] - 1;
			int bubblenum;
			map<int, int>::iterator it = bubblehist.lower_bound(word[i]);

			if (it != bubblehist.end()){
				bubblenum = (it--)->second;
				//--it;
			}
			else {
				bubblenum = (--it)->second + 1;
			}
			pair<int, int> p;
			p.first = word[i];
			p.second = bubblenum;
			map<int, int>::iterator it2 = bubblehist.insert(it, p);
			//word[i]より大きい数はすべてvalueが1増える
			for (++it2; it2 != bubblehist.end(); it2++) ++(it2->second);

			facttime -= bubblenum;
			ans += factmodary[N - (i + 1)] * facttime;
			ans %= divisor;
		}
		ansvec.push_back((int)ans);
	}

	for (vector<int>::iterator it = ansvec.begin(); it != ansvec.end(); it++) cout << *it << "\n";

	delete[] word;
	delete[] factmodary;
	return 0;
}

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

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

    int n, x;
    cin >> n >>  x;

    vector<int> v(n + 1);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    v[n] = x;

    sort(v.begin(), v.end());
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans = __gcd(ans, v[i] - v[i - 1]);
    cout << ans << endl;
}

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

public class Main {

    public static void main(String[] args)
    {
        int[] sides = getInput();
        int a = sides[0];
        int b = sides[1];
        int c = sides[2];
        System.out.println(a * b / 2);
    }

    private static int[] getInput()
    {
        int[] ret = new int[3];
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String[] digtes = br.readLine().split(" ");
            ret[0] = Integer.parseInt(digtes[0]);
            ret[1] = Integer.parseInt(digtes[1]);
            ret[2] = Integer.parseInt(digtes[2]);
        } catch (IOException e) {
            return null;
        }
        return ret;
    }

}


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

int main(int argc, char const *argv[]) {
  int i, j, same=0;
  string str;
  cin >> str;
  for (i=0; i < 4; i++) {
    for (j=i+1; j<4; j++) {
      if (str[i]==str[j]) {
        same++;
      }
    }
  }
  if (same==2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int N; cin >> N;
    string S; cin >> S;
    int res = 1;
    FOR(i, 1, N){
        if(S[i - 1] != S[i]) res++;
    }

    cout << res << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int f(int a)
{
   if(a % 2 == 0){return a/2;}
   else{return 3*a + 1;}
}

int main(){
   int s;
   cin >> s;
   vector<int> a;
   a.push_back(s);

   int i = 1;
   while(true){
      int a_i = f(a[i-1]);
      i++;
      for(int j=0; j < (int)a.size(); j++){
         if(a_i == a[j]){
            cout << i << endl;
            return 0;
         }
      }
      a.push_back(a_i);
   }

}

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

typedef long long ll;
int a[10];

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int x,y;
	cin>>x>>y;
	
	if(y%2 == 1 || y > 4*x || y < 2*x){
		cout<<"No";
	}else{
		cout<<"Yes";
	}
	
	return 0;
}


Measured memory_bytes: 3660
times = [int(input()) for i in range(5)]

queue = [(i,) for i in range(5)]
mintime = 1000
while(len(queue)):
    q = queue.pop(0)
    if(len(q)==5):
        time = 0
        for i in q:
            if(time%10 == 0):
                time += times[i]
            else:
                time += 10 - time%10 + times[i]
        mintime = min(mintime, time)
    for i in range(5):
        if not i in q:
            queue.append(q + (i,))

print(mintime)

Measured memory_bytes: 3064
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
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; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
// const ll mod = 1000000007;
const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

ll to_int(string s){
  ll ret=0;
  rep(i,s.size()){
    ret*=10;
    ret+=s[i]-'0';
  }
  return ret;
}

void f(int x,string s,set<ll>&set){
  set.insert(to_int(s));
  if(s.size()==10){
    return;
  }
  rep(i,10){
    if(abs(i-x)<=1){
      s.push_back('0'+i);
      f(i,s,set);
      s.pop_back();
    }
  }
  return;
}

bool solve(){
  set<ll>set;
  rep(i,10)f(i,"",set);
  ll k;cin>>k;
  auto itr=set.begin();
  rep(i,k)itr++;
  cout<<*itr<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


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

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> h(n+1),dp(n+1,1e9);
    for(int i=1;i<=n;i++) cin>>h[i];

    dp[1]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=k;j++){
            if(i+j<=n) dp[i+j]=min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
        }
    }
    cout<<dp[n]<<endl;
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<ll> v(4);
    cin>>v[0]>>v[1]>>v[2]>>v[3];
    sortAl(v);
    if(v[0]==1 && v[1]==4 && v[2]==7 && v[3]==9){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define lli long long int
#define rep(i,n,z) for(int i=z;i<n;i++)
#define rrep(i,z) for(int i=z;i>=0;i--)
#define nl cout<<endl
#define vi vector<int>
#define vlli vector<long long int>
#define umap unordered_map
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define ipair pair <int,int>
#define llipair pair <lli,lli>
#define pq priority_queue
#define displaymatrix(a,m,n) for(int i=0;i<m;i++){for(int j=0;j<n;j++)cout<<a[i][j]<<" ";cout<<endl;}
#define printarray(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}nl;
#define vinput(a,n) vlli a(n);rep(i,n,0)cin>>a[i]
#define ainput(a,n) rep(i,n,0)cin>>a[i]
#define SO(a) sort(a.begin(),a.end())
#define all(x) (x).begin(),(x).end()
#define SOP(a,comp) sort(a.begin(),a.end(),comp)
#define inf INT_MAX
#define endl '\n'


const lli mod = 998244353;
const int S = 2e5+5;
 
lli fact[S];
lli inv[S];

lli multi(lli x,lli n){
    if(n == 0)return 1;
    if(n==1)return x%mod;
    lli ans = multi((x*x)%mod,n/2);
    if(n%2)ans=(ans*x)%mod;
    return ans;
}

void precal()
{
  lli i;
  fact[0] = 1;
  inv[0] = multi(fact[0],mod-2);
  for(i=1;i<S;i++)
  {
    fact[i] = (i*fact[i-1])%mod;
    inv[i] = multi(fact[i],mod-2);
  }
}

lli ncr(lli x,lli y)
{
  if(x<y || x<0 || y<0)
    return 0;
  lli temp = fact[x];
  temp = (temp*inv[y])%mod;
  temp = (temp*inv[x-y])%mod;
  return temp;
}


int main()
{
    fastio;
    precal();
    lli n,m,k;
    cin>>n>>m>>k;

    lli pro = m;

    rep(i,n - (k + 1),0){
        pro= (pro*(m - 1))%mod;
    }

    lli ans = 0;

    for(int i = k;i >= 0;i--){

        // cout<<ncr(n - 1,i)<<" "<<pro<<" "<<ans<<endl;
        ans=(ans + (ncr(n - 1,i)*pro)%mod)%mod;
        pro = (pro*(m - 1))%mod;
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 6776
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int p=pow(10,9)+7,ans;
    int N;cin>>N;
    string S1,S2;cin>>S1>>S2;
    int i=0,front;
    if(S1[i]==S2[i]){
        ans=3;
        i++;
        front=0;
    }
    else{
        ans=6;
        i+=2;
        front=1;
    }
    while(i<N){
        if(S1[i]==S2[i]){
            if(front==0)ans=(2*ans)%p;
            front=0;
            i++;
        }
        else{
            if(front==0)ans=(2*ans)%p;
            else ans=(ans+(ans+ans)%p)%p;
            front=1;
            i+=2;
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
 ll N;
 cin >> N;
 vector<ll> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
  }
  ll a = A[0];
  for (int i = 1; i < N; ++i) {
    if(i%2==0)
      a+=A[i];
    else
      a-=A[i];
  }
  for (int i = 0; i < N; ++i) {
    cout << a << " ";
    a = (A[i]-a/2)*2;
  }
  cout << endl;
}


Measured memory_bytes: 2048
import java.util.Scanner;
//import java.util.Arrays;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//
		long a = sc.nextLong();
		long result = a % 1000;
		
		System.out.println(result == 0 ? 0 : 1000 - result);
	}
}


Measured memory_bytes: 35720
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars
    }
    let n = s.len();
    if s[0] != 'A' {
        println!("WA");
        return;
    }
    if s[2..n-1].iter().filter(|c| **c == 'C').count() != 1 {
        println!("WA");
        return;
    }
    if !s[1..].iter().filter(|c| **c != 'C').all(|c| c.is_lowercase()) {
        println!("WA");
        return;
    }
    println!("AC");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
                    
                    
int main(){
    int N;
    cin >> N;
    vector<int> A;
    int a;
    string ans = "YES";
    
    for(int i = 0;i < N;i++){
        cin >> a;
        A.push_back(a);
    }
    
    sort(A.begin(), A.end());
    
   
    for(int i = 1;i < N;i++){
        if(A.at(i-1) == A.at(i)){
            ans = "NO";
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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 (a > b) { a = b; return 1; } return 0; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int P, Q, R;
	cin >> P >> Q >> R;
	cout << P + Q + R - max({ P, Q, R }) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>                                                                   
                                                                                      
using namespace std;                                                                  
                                                                                      
int main(int argc, char*argv[]) {                                                     
  int H, W;                                                                           
  int h, w;                                                                           
  cin >> H >> W;                                                                      
  cin >> h >> w;                                                                      
  cout << (H-h) * (W-w) << endl;                                                      
  return 0;                                                                           
}                                                                                     
                                                                                      
                                                                                      
            

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func oneInt() int {
	var a int
	fmt.Scan(&a)
	return a
}
func oneStr() string {
	var a string
	fmt.Scan(&a)
	return a
}

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

func scanNums() (nums []int) {
	s := nextLine()
	numStr := strings.Split(s, " ")

	for _, n := range numStr {
		i, _ := strconv.Atoi(n)
		nums = append(nums, i)
	}
	return nums
}

func scanStrings() (strs []string) {
	s := nextLine()
	list := strings.Split(s, " ")
	strs = append(strs, list...)
	return strs
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func sortAsc(a []int) []int {
	sort.Ints(a)
	return a
}

func sortDesc(a []int) []int {
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	return a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	if a == 0 && b == 0 {
		return 0
	}
	return a * b / gcd(a, b)
}

func main() {
	S := oneStr()
	win := strings.Count(S, "o")

	sum := len(S)

	if sum < 8 {
		fmt.Print("YES")
		return
	}

	if sum-7 <= win {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}


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

S_ba = []
S_ab = []
for i in range(N):
    if A[i] < B[i]: S_ba.append(B[i] - A[i])
    # elif A[i] > B[i]: S_ab.append(A[i] - B[i])
    else: S_ab.append(A[i] - B[i])

if sum(S_ba) > sum(S_ab):
    print(-1)
    exit()
    
ans = len(S_ba)
now = 0
rem = sum(S_ba)
S_ab.sort(reverse=True)
for i in range(len(S_ab)):
    if rem <= now: break
    now += S_ab[i]
    ans += 1

print(ans)


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int n;
    cin >> n;
    int sum = 0;
    for (int i = 1; i <= n; i++) {
        sum += i;
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
using namespace std;
int main()
{
    int a, b, c = 0, p = 1;
    cin >> a >> b;

    while (b > p) {
        --p;
        p += a;
        ++c;
    }

    cout << c << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_a() {
	ll n, m;
	ll x, y;
	ll a, b, d;
	//ll c;
	//char c;
	//ll h, w;
	ll k;
	string s, t;
	ll l_ans = 0;
	string s_ans = "NG";
	ll l, r;

	cin >> x;

	if (x >= 400 && x <= 599) l_ans = 8;
	else if (x >= 600 && x <= 799) l_ans = 7;
	else if (x >= 800 && x <= 999) l_ans = 6;
	else if (x >= 1000 && x <= 1199) l_ans = 5;
	else if (x >= 1200 && x <= 1399) l_ans = 4;
	else if (x >= 1400 && x <= 1599) l_ans = 3;
	else if (x >= 1600 && x <= 1799) l_ans = 2;
	else if (x >= 1800 && x <= 1999) l_ans = 1;

	cout << l_ans << "\n";

	return;
}


int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(7);

	solve_abc_a();

	return 0;
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

namespace AtCoder {
    class Program {
        static void Main(string[] args) {

            var N = int.Parse(Console.ReadLine());
            var input = Console.ReadLine().Split(' ').Select(n => int.Parse(n)).ToArray();

            var max = input[0];
            var ans = 1;

            for(int i = 1; i < N; i++) {
                if (max <= input[i]) {
                    ans++;
                    max = input[i];
                }
            }

            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int N = 310, mod = 1e9 + 7;

int n, m;
vector<pair<int, int> > g[N];
ll f[N][N][N], ans;

void upd(ll &x, ll y) {
    x = (x + y) % mod;
    if(x < 0) x += mod;
}

int check(int x, int y, int z) {
    if(x && y && x == y) return 0;
    if(x && z && x == z) return 0;
    if(y && z && y == z) return 0;
    int mx = max(max(x, y), z);
    for(auto t: g[mx]) {
        int l = t.first, tmp = 0;
        tmp += x >= l;
        tmp += y >= l;
        tmp += z >= l;
        if(tmp != t.second) return 0;
    }
    return 1;
}

int main() {
    scanf("%d%d", &n, &m);
    for(int i = 1 ; i <= m ; ++ i) {
        int l, r, x; scanf("%d%d%d", &l, &r, &x);
        g[r].push_back(make_pair(l, x));
    }
    f[0][0][0] = 1;
    for(int i = 0 ; i <= n ; ++ i) {
        for(int j = 0 ; j <= n ; ++ j) {
            for(int k = 0 ; k <= n ; ++ k) {
                if(!check(i, j, k)) continue;
                ll s = f[i][j][k];
                ll mx = max(max(i, j), k);
                ll sum = f[i][j][k];
                upd(f[mx + 1][j][k], sum);
                upd(f[i][mx + 1][k], sum);
                upd(f[i][j][mx + 1], sum);
                if(mx == n) {
                    upd(ans, sum);
                }
            }
        }
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 227584
// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  N = parseInt(input[0].split(" "));
  var i=0;
  var result = "No";
  while(i<N-2) {
    var tmp = input[i+1].split(" ");
    var d_i1 = parseInt(tmp[0]);
    var d_i2 = parseInt(tmp[1]);
    if(d_i1 == d_i2) {
      var tmp2 = input[i+2].split(" ");
      if(parseInt(tmp2[0]) == parseInt(tmp2[1])) {
        var tmp3 = input[i+3].split(" ");
        if(parseInt(tmp3[0]) == parseInt(tmp3[1])) {
          result = "Yes";
          break;
        } else {
          i += 3;
        };
      } else {
        i += 2;
      }
    } else {
      i++;
    }
  }
  //出力
  console.log(result);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  double toRad = 180.0 / 3.1415926535;
  double a,b,x;
  cin >> a >> b >> x;
  x /= a;
  double ans;
  if(x <= a*b/2){
    double l = x*2/b;
    ans = atan(b/l);
  }else{
    double l = (a*b-x)*2/a;
    ans = atan(l/a);
  }
  ans *= toRad;
  cout << fixed << setprecision(10);
  cout << ans<< endl;
  return 0;
}


Measured memory_bytes: 512
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define ll_cin(X) scanf("%lld", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}
#pragma endregion

int main(void)
{
	int a, b, k,i,t;

	i_cin3(k,a, b);

	for (i = 1;; i++) {
		t = k * i;
	
		if (t > b) break;
		if (a <= t && t <= b) { s_cout("OK"); return 0; }
	}
	
	s_cout("NG");
	return 0;

}

//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    const ll INF = 1e16;

    int n;
    cin >> n;
    ll a[n];
    rep(i, n) {
        cin >> a[i];
    }
    
    ll dp[n+1][2];  /* dp[i][j] : a[0]からa[i-1]までを確定し、
                        j = 0 ならiを選ばず反転しない場合(a[i]はそのまま)
                        j = 1 ならiを選んで反転する場合(a[i]の符号が反転している状態)
                        のa[i-1]までの総和の最大値 */

    rep(i, n+1) {
        rep(j, 2) {
            dp[i][j] = -INF;
        }
    }

    dp[0][0] = 0;
    rep(i, n) {
        rep(j, 2) {
            if(j == 0) {
                dp[i+1][j] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
            }
            else if(j == 1) {
                dp[i+1][j] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
            }
        }
    }
    
    cout << dp[n][0] << endl;
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(obj) (obj).begin(),(obj).end()
typedef long long ll;
ll mod=ll(1e9)+7;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x;cin>>x;
  int cnt=0;
  cnt+=(x/500)*1000;
  x%=500;
  cnt+=(x/5)*5;
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		double max = Integer.MIN_VALUE,
			   min = Integer.MAX_VALUE,
			   tmp;
		
		while(sc.hasNext()) {
			tmp = sc.nextDouble();
			max = Math.max(max, tmp);
			min = Math.min(min, tmp);
		}
		
		System.out.println(max - min);

	}
}

Measured memory_bytes: 27648
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <iostream>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
typedef vector<long long> vll, vLL;

bool check(const string& s,const string& t){
	int n = s.size();
	int m = t.size();
	for(int i=0;i<=n-m;i++){
		bool ok = true;
		REP(j,m){
			if(s[i+j]!='?' && s[i+j]!=t[j])ok=false;
		}
		if(ok)return true;
	}
	return false;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n,t[1001],a[1001];
	ll dp[1001];
	scanf("%d",&n);
	REP(i,n){
		scanf("%d %d",&t[i+1],&a[i+1]);
	}

	dp[1] = 1;
	for(int i=2;i<=n;i++){
//		cout << "t率" << (double)t[i-1]/t[i] << endl;
//		cout << "a率" << (double)a[i-1]/a[i] << endl;
//		cout << "max" << (ll)(max((double)t[i-1]/t[i],(double)a[i-1]/a[i]) + 0.5) << endl;
		dp[i] = max((a[i-1]*dp[i-1] + a[i]-1) / a[i], (t[i-1]*dp[i-1] + t[i]-1) / t[i]);
//		dp[i] = ((ll)(max((double)t[i-1]/t[i],(double)a[i-1]/a[i]) + 0.5))*dp[i-1];
	}
	cout << dp[n]*(a[n]+t[n]) << endl;

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

	int n;
	ll dp[1001],t[1001],a[1001];
	scanf("%d",&n);
	REP(i,n){
		scanf("%lld %lld",&t[i+1],&a[i+1]);
	}

	dp[1] = 1;
	for(int i=2;i<=n;i++){
		dp[i] = max((a[i-1]*dp[i-1] + a[i]-1) / a[i], (t[i-1]*dp[i-1] + t[i]-1) / t[i]);
		//dp[i] = ((ll)(max(t[i-1]/t[i]+(t[i-1]%t[i]!=0),a[i-1]/a[i]+(a[i-1]%a[i]!=0))))*dp[i-1];
	}
	cout << dp[n]*(ll)(a[n]+t[n]) << endl;

	return 0;
}
*/

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

static const int INF = 1e+9;

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

    vector<int> W(N);
    for (int i = 0; i < N; ++i) {
        cin >> W[i];
    }

    int ans = INF;
    for (int T = 0; T < N; ++T) {
        int S1 = 0;
        int S2 = 0;

        for (int i = 0; i < N; ++i) {
            if (i <= T) {
                S1 += W[i];
            } else {
                S2 += W[i];
            }
        }

        ans = min(ans, abs(S1 - S2));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 888
package main

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

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	c, _ := strconv.Atoi(a + b)
	d := float64(c)
	e := math.Ceil(math.Sqrt(d))
	if e*e == d {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512