akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static PrintWriter out;
	static InputReader ir;

	static void solve() {
		int n=ir.nextInt();
		out.println(n%2==0?0.5:((n+1)/2)/(double)n);
	}

	public static void main(String[] args) {
		ir = new InputReader(System.in);
		out = new PrintWriter(System.out);
		solve();
		out.flush();
	}

	static class InputReader {

		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;

		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}

		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}

		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}

		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}

		public boolean hasNext() {
			skip();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}

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

		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}

		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}

		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}

	static void tr(Object... o) {
		out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 23124
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vec) vec.begin(), vec.end()
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y){
  return y == 0 ? x : gcd(y, x % y);
}
ll lcg(ll x, ll y){
  return x * y / gcd(x, y);
}
map<ll, ll> factor(ll n){
  map<ll, ll> ans;
  ll a = 2;
  while (n >= a * a){
    if (n % a == 0){
      ans[a]++;
      n /= a;
    }
    else a++;
  }
  ans[n]++;
  return ans;
}

int main(){
  int n; cin >> n;
  int nums[n];
  ll ans = 0;
  int m = 2e9;
  int ms;
  bool z = true;
  rep(i, n){
  	int x;
  	cin >> x;
  	ans += abs(x);
    if (x < 0) ms++;
    if (abs(x) < m) m = abs(x);
    if (x == 0) z = false;
  }
  if (ms % 2 == 1 && z) ans -= 2 * m;
  cout << ans << endl;
}

Measured memory_bytes: 256
import math

a,b,x = map(int, input().split())

base_s = x/a

if base_s <= a*b/2:
  limit_h = 2*base_s/b
  ans = math.degrees(math.atan2(b, limit_h))
  
elif base_s > a*b/2:
  base_s = a*b-base_s
  limit_h = 2*base_s/a
  ans = math.degrees(math.atan2(limit_h, a))

print(ans)

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

#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

#define int long long
using namespace std;
const int INF = 2e16;
const int MOD = 1e9 + 7;
const int MB = 20;
const int K = 500;
const int maxN = 2e4 + 1;

void solve() {
	string s;
	int d;
	cin >> s >> d;
	int len = s.size();
	vector<int> a(len);
	for (int i = 0; i < len; i++) a[i] = s[i] - '0';
	vector<vector<int>> dp(2, vector<int>(d));
	
	for (int i = 0; i < a[0]; i++) dp[0][i % d]++;
	dp[1][a[0] % d] = 1;

	for (int i = 1; i < len; i++) {
		vector<vector<int>> dp1(2, vector<int>(d));
		for (int j = 0; j < d; j++) {
			for (int c = 0; c < 10; c++) {
				dp1[0][j] = (dp1[0][j] + dp[0][(j - c % d + d) % d] + (c < a[i] ? dp[1][(j - c % d + d) % d] : 0)) % MOD;
				if (c == a[i]) dp1[1][j] = dp[1][(j - c % d + d) % d];
			}
		}
		swap(dp, dp1);
	}
	cout << ((dp[0][0] + dp[1][0]) % MOD - 1 + MOD) % MOD;
}

signed main() {
	/*
	freopen("search.in", "r", stdin);
	freopen("search.out", "w", stdout);
	*/
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cout << fixed;
	cout.precision(12);
	solve();
}

Measured memory_bytes: 384
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

namespace mod {
ll power(ll x, ll e) {
  ll v = 1;
  for (; e > 0; e >>= 1) {
    if (e & 1) {
      v = v * x % MOD;
    }
    x = x * x % MOD;
  }
  return v;
}

ll inverse(ll x) { return power(x, MOD - 2); }

vector<ll> fact, factInv;
void initFact(int N) {
  fact.resize(N + 1);
  factInv.resize(N + 1);
  fact[0] = 1;
  for (int i = 1; i <= N; i++) {
    fact[i] = fact[i - 1] * i % MOD;
  }
  factInv[N] = inverse(fact[N]);
  for (int i = N - 1; i >= 0; i--) {
    factInv[i] = factInv[i + 1] * (i + 1) % MOD;
  }
}

ll choose(int n, int k) {
  if (k > n) {
    return 0;
  } else {
    return fact[n] * factInv[k] % MOD * factInv[n - k] % MOD;
  }
}

ll multiChoose(int n, int k) {
  if (n == 0 && k == 0) {
    return 1;
  } else {
    return choose(n + k - 1, k);
  }
}
}  // namespace mod

int main() {
  mod::initFact(200000 + 10);
  int H, W, A, B;
  while (cin >> H >> W >> A >> B) {
    ll ans = 0;
    for (int i = B + 1; i <= W; i++) {
      ll ways = mod::choose(H - A - 1 + i - 1, i - 1) *
                mod::choose(A - 1 + W - i, W - i) % MOD;
      ans = (ans + ways) % MOD;
    }
    cout << ans << endl;
  }
  return 0;
}


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

int bin_search(const int a[], int n, int key){
	int pl = 0;
	int pr = n-1;

	do{
		int pc = (pl + pr) / 2;
		if (a[pc] == key){
			return 1;
		}else if (a[pc] < key){
			pl = pc + 1;
		}else{
			pr = pc - 1;
		}
	}while(pl <= pr);

	return -1;
}

int main(void)
{
	int i, j, nx, ny, k;
	int count = 0;
	int *x, *y;

	//S???????´???°??\???
	scanf("%d", &nx);
	x = calloc(nx, sizeof(int));

	//S?????´??°??????
	for (i = 0; i < nx; i++)
	{
		scanf("%d", &x[i]);
	}

	//T???????´???°??\???
	scanf("%d", &ny);
	y = calloc(ny, sizeof(int));

	//T?????´??°??????
	for (j = 0; j < ny; j++)
	{
		scanf("%d", &y[j]);
	}

	//??????C??????
	for (k = 0; k < ny; k++)
	{
		if (bin_search(x , nx, y[k]) == 1){
			count += 1;
		}
	}
	printf("%d\n", count);

	free(x);
	free(y);

	return 0;
}

Measured memory_bytes: 1152
read n
read ps
arr=($ps)
ans=0


for ((i=1; i<n-1; i++)); do
    count=0
    if [ ${arr[$((i - 1))]} -lt ${arr[$i]} ]; then
        count=$((count+1))
    fi
    if [ ${arr[$((i + 1))]} -lt ${arr[$i]} ]; then
        count=$((count+1))
    fi
    if [ $count -eq 1 ]; then
        ans=$((ans+1))
    fi
done

echo $ans

Measured memory_bytes: 376
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int n = sc.nextInt();
		int[] values = new int[w];
		for(int i = 0;i < values.length;i++){
			values[i] = i + 1;
		}
		for(int i = 0;i < n;i++){
			String str = sc.next();
			String[] ab = str.split(",");
			int a = Integer.parseInt(ab[0]) - 1;
			int b = Integer.parseInt(ab[1]) - 1;
			int tmp = values[a];
			values[a] = values[b];
			values[b] = tmp;
		}
		for(int i = 0;i < values.length;i++){
			System.out.println(values[i]);
		}
	}
}

Measured memory_bytes: 17272
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,t,m,a,ma=-1e9;
    cin>>n>>t;
    set<ll> s;
    set<ll> ans;
    for(int i=0;i<n;i++){
        cin>>a;
        if(i){
            m=a-(*(s.begin()));
            if(m>ma){
                ans.clear();
                ans.insert(*(s.begin()));
                ma=m;
            }else if(m==ma)ans.insert(*(s.begin()));
        }
        s.insert(a);
    }
    cout << (ans.size())<<endl;
    return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
long long f[200100];
int mod = 1e9 + 7;

int main()
{
    f[0] = 1;
    for(int i = 1 ; i<= 200000; i++)
        f[i] = (i * f[i-1])%mod;
    long long n,m;
    cin>>n>>m;
    long long ans = f[n] * f[m];
    ans%=mod;
    if(n==m) ans*=2;
    if(abs(n-m) > 1) ans = 0;
    cout<<ans%mod<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b) {if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b) {if(a<b) a=b;}

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

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int x,y;
	
	scanf("%d %d",&x,&y);
	
	if((x == 1 || x == 3 || x == 5 || x == 7 || x == 8 || x == 10 || x == 12) && (y == 1 || y == 3 || y == 5 || y == 7 || y == 8 || y == 10 || y == 12)){
		printf("Yes\n");
	}
	else if((x == 4 || x == 6 || x == 9 || x == 11) && (y == 4 || y == 6 || y == 9 || y == 11)){
		printf("Yes\n");
	}
	else if(x == 2 && y == 2){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return(0);
}


Measured memory_bytes: 128
N, M = map(int, input().split())
P = 10 ** 9 + 7
if abs(N - M) > 1:
    print(0)
else:
    S = 1
    if N > M:
        for i in range(1, M+1):
            S = (S * i * i) % P
        S = (S * N) % P
    elif N < M:
        for i in range(1, N+1):
            S = (S * i * i) % P
        S = (S * M) % P
    else:
        for i in range(1, N+1):
            S = (S * i * i) % P 
        S = (S * 2) % P
    print(S)


Measured memory_bytes: 3064
#if 0
斜めではなく\の場合は下に窪む。/の場合は上に窪むと考えて、.5が生じないようにする。
#endif

#include <iostream>
#include <stack>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

stack<int> y;       // 水位を入れる => 最初の水位を0とする
stack<int> leftMax; // 自分よりも左側の最大の水位
stack<int> result;
int allsum = 0;

int deleteRight()
{
    int rightTop = 0;
    // 右端より高い部分は捨てる
    while (y.size() > 1)
    {
        int right = y.top();
        y.pop();
        int leftMaximum = leftMax.top();
        leftMax.pop();
        if (leftMaximum < right)
        {
            // 水位より高い場合
            continue;
        }
        int left = y.top();
        if (left >= right)
        {
            // 左以下の場合
            continue;
        }
        else
        {
            rightTop = right;
            break;
        }
    }
    return rightTop;
}

int main()
{
    y.push(0);
    leftMax.push(0);
    string word;
    cin >> word;
    for (char a : word)
    {
        leftMax.push(leftMax.top() >= y.top() ? leftMax.top() : y.top());
        if (a == '\\')
        {
            y.push(y.top() - 1);
        }
        else if (a == '_')
        {
            y.push(y.top());
        }
        else if (a == '/')
        {
            y.push(y.top() + 1);
        }
    }
    while (y.size() > 1)
    {
        int righttop = deleteRight();
        int sum = 0;
        while ((righttop - y.top()) > 0)
        {
            sum += righttop - y.top();
            y.pop();
            leftMax.pop();
        }
        if (sum > 0)
        {
            allsum += sum;
            result.push(sum);
        }
    }
    cout << allsum << endl;
    cout << result.size();
    while (result.size() > 0)
    {
        cout << ' ' << result.top();
        result.pop();
    }
    cout << endl;
}



Measured memory_bytes: 3352
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//素因数分解 O(√n)
map<ll,ll>prime_factor(ll n){
    map<ll,ll> res;
    for(ll i = 2;i * i <= n;i++){
        while(n % i == 0){
            ++res[i];
            n /= i;
        }
    }
    if(n != 1) res[n] = 1LL;
    return res;
}

int main(void){
   ll a,b;cin >> a >> b;
   if(a == 1 or b == 1){
      cout << 1 << endl;
      return 0;
   }
   ll c = gcd(a,b);
   auto res = prime_factor(c);
   vector<ll> lst;
   for(auto i : res){
     // cout << i.second << endl;
      lst.pb(i.second);
   }
   int m = lst.size();
   cout << m + 1 << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int x, mx=1;
bool b;

int main(){
    scanf("%d", &x);
    for(int i=2; i<=x; i++){
        b=false;
        int j= i;
        while(j*i <= x){j*=i; b=true;}

        if(j <= x && j > mx && b)
            mx = j;
    }
    printf("%d\n", mx);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)(j);i <= (int)(k);i ++)
#define debug(x) cerr<<#x<<":"<<(x)<<endl
#define fix cout<<fixed<<setprecision(20);
#define int long long
const int maxn=(int)1e6+5;
typedef pair<int,int> pii;

#define X first
#define Y second
typedef long long ll;
int MOD = (ll)1e9+7;
inline ll qpow(ll a, ll b) {return b? ((b&1)? a*qpow(a*a%MOD,b>>1)%MOD: qpow(a*a%MOD,b>>1))%MOD: 1;}
inline ll gcd(ll a, ll b) {return b? gcd(b, a%b): a;}
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    map<pii,int> mp;
    int flag=0;
    rep(i,1,n){
        int a,b;cin>>a>>b;
        if(a==0&&b==0){flag++;continue;}
        int g=gcd(a,b);debug(g);
        a/=g,b/=g;
        if(a<0)a=-a,b=-b;
        mp[{a,b}]++;
    }
    int ans=1;
    for(auto p:mp){
        auto cur=p.X;
        int cnt1=p.Y;
        int cnt2=mp.count({cur.Y,-cur.X})?mp[{cur.Y,-cur.X}]:0;
        if(cur.Y<=0){
            //debug(cnt1);
            if(!mp.count({-cur.Y,cur.X}))ans*=(qpow(2,cnt1))%MOD;
        }
        else 
        ans*=(qpow(2,cnt1)+qpow(2,cnt2)-1+MOD)%MOD;
        ans%=MOD;
        //debug(cur.X),debug(cur.Y),debug(ans);
    }
    ans+=flag-1;ans+=MOD,ans%=MOD;
    cout<<ans<<endl;
}
/* 
ai*aj+bi*bj = 0
按照向量垂直分组，
每组只能取同一方向的，所有组的取法相乘即为答案
special case:
0 只能选一个
考虑和两个向量都垂直的情况，分成两组会重算，将向量都放到一四象限即可。

wr
1.p.Y cur.Y
2. 枚举p时处理算重
3. 都不取算两次
 */


Measured memory_bytes: 16012
s = int(input())

a = ['#']
i = 0
while i < 1000001:
  i += 1
  if i == 1:
    a.append(s)
  else:    
    if a[i-1]%2 == 0:
      ai = a[i-1] / 2
    else:
      ai = 3 * a[i-1] + 1
   
    if ai in a:
      print(i)
      exit()
    
    a.append(ai)

Measured memory_bytes: 3188
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        System.out.print(S);
        if (S.charAt(S.length()-1)=='s') {
            System.out.println("es");
        }else {
            System.out.println("s");
        }
    }
}

Measured memory_bytes: 35664
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int n = Integer.parseInt(in.next());
            int a[] = new int[n];
            int b[] = new int[n];
            int c[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < n; i++) {
                b[i] = Integer.parseInt(in.next());
            }
            for (int i = 0; i < n - 1; i++) {
                c[i] = Integer.parseInt(in.next());
            }
            int ans = 0;
            for (int i = 0; i < n; i++) {
                ans += b[a[i] - 1];
                if (i > 0 && (a[i] - a[i - 1]) == 1) ans += c[a[i - 1] - 1];
            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;int k;
  cin>>s>>k;
  set<string> v;
  for(int i=1;i<=k;i++)
  {
    for(int j=0;j+i-1<s.length();j++)
      v.insert(s.substr(j,i));
  }
  vector<string> vv;
  for(auto i:v) vv.push_back(i);
  cout<<vv[k-1];
 
  
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
const int N = 3e3 + 5;
typedef long long LL;
int n, m, p;
int a[N][N];
LL F[N][N][4];
int main(){
	scanf ("%d%d%d", &n, &m, &p);
	for (int i = 1, x, y, z; i <= p; i++) {
		scanf ("%d%d%d", &x, &y, &z);
		a[x][y] = z;
	}
	
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= m; j++)
	{
		F[i][j][0] = F[i][j - 1][0];
		for (int k = 0; k <= 3; k++) F[i][j][0] = max(F[i][j][0], F[i - 1][j][k]);
		F[i][j][1] = F[i][j - 1][1];
		F[i][j][2] = F[i][j - 1][2];
		F[i][j][3] = F[i][j - 1][3];
		
		if (a[i][j]) {
			for (int k = 0; k <= 3; k++) F[i][j][1] = max(F[i][j][1], F[i - 1][j][k] + a[i][j]);
			F[i][j][2] = max(F[i][j][2], F[i][j - 1][1] + a[i][j]);
			F[i][j][3] = max(F[i][j][3], F[i][j - 1][2] + a[i][j]);
		}
	}
	
	LL ans = 0;
	for (int i = 0; i <= 3; i++) ans = max(ans, F[n][m][i]);
	printf ("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 320712
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
typedef pair<int, int> PII;
typedef long long ll;
template<typename T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;


string s, t, u;
int a, b;

int main() {

	cin >> s >> t >> a >> b >> u;

	if (u == s)cout << a - 1 << " " << b << endl;
	else cout << a << " " << b - 1 << endl;

	return 0;
}

Measured memory_bytes: 256
open System

let read()   = Console.ReadLine().Split()
               |> Array.map(int)

let l1 = read()
let l2 = read()
let l3 = read()

let isValid arr = arr
                    |> Array.map2 (-) l1
                    |> Array.distinct 
                    |> Array.length = 1

(isValid l2 && isValid l3)
|> (function | true -> "Yes" | false -> "No")
|> printfn "%s"


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

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

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


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

  int size=(int)s.size(),l;
  for(l=size/2-1;l>0;l--) {
    string s0 = s.substr(0,l), s1 = s.substr(l,l);
    if(s0 == s1) {
      cout << l*2 << endl;
      return 0;
    }
  }

  return 0;
}


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

typedef long long ll;

string n;
int k;
ll res;

ll C(int lft, int k)
{
    if (k < 0) return 0;
    if (k == 3) return ll(lft) * (lft - 1) * (lft - 2) / 6 * 9 * 9 * 9;
    else if (k == 2) return lft * (lft - 1) / 2 * 9 * 9;
    else if (k == 1) return lft * 9;
    else return 1;
}

int main()
{
    cin >> n;
    cin >> k;
    res += C(int(n.length()) - 1, k);
    for (int i = 0; i < n.length() && k >= 0; i++) {
        for (int j = i == 0? 1: 0; j < n[i] - '0'; j++)
            res += C(int(n.length()) - 1 - i, k - (j != 0));
        k -= n[i] - '0' != 0;
    }
    if (k == 0) res++;
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;


public class Main {
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		int N=sc.nextInt();
		int[] A=new int[N];
		for (int i = 0; i < A.length-1; i++) {
			int a=sc.nextInt()-1;
			A[a]++;
		}
		for (int i = 0; i < A.length; i++) {
			System.out.println(A[i]);
		}
	}
	
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 63004
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int h, w, k;

bool check(vector<string> c) {
  int cnt = 0;
  rep(i, h) rep(j, w) if (c[i][j] == '#') ++cnt;
  return cnt == k;
}

int main() {
  cin>>h>>w>>k;
  vector<string> c(h);
  rep(i, h) cin>>c[i];

  int ans = 0;

  rep(i, 1<<h) rep(j, 1<<w) {
    vector<string> ct(c.begin(), c.end());
    rep(k, h) if (i & (1<<k)) rep(l, w) ct[k][l] = '!';
    rep(k, w) if (j & (1<<k)) rep(l, h) ct[l][k] = '!';
    if (check(ct)) ++ans;
  }
  print(ans);

  return 0;
}

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

public class Main{
    public static void main(String[] args){
        HashSet<String> set = new HashSet<String>();
        Scanner sc = new Scanner(System.in);
        String str = "";    
        String text;
        String word;
        int count=0;
        int i;

        count = sc.nextInt();

        for(i=0;i<count;i++){
            str = sc.next();
            if(str.equals("insert")){
                word = sc.next();
                set.add(word);

            }else if(str.equals("find")){
                word = sc.next();
                if(set.contains(word)==true){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
            }
        }

        sc.close();
    }
}


Measured memory_bytes: 253692
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

set<int> s;
int t[100009];
int hol[100009];
int n;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll ans=0;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>t[i];
        hol[t[i]]=i;
    }
    s.insert(0);
    s.insert(n+1);
    for(int i=n; i>=1; i--)
    {
        auto it=s.lower_bound(hol[i]);
        int v1=*it;
        int v2=-1;
        if(v1!=n+1)
        {
            it++;
            v2=*it;
            it--;
        }
        it--;
        int k1=*it;
        int k2=-1;
        if(k1!=0)
        {
            it--;
            k2=*it;
            it++;
        }

        if(k1!=0)
        {
            ans+=((ll)(i)*(ll)(k1-k2)*(ll)(v1-hol[i]));
        }
        if(v1!=n+1)
        {
            ans+=((ll)(i)*(ll)(v2-v1)*(ll)(hol[i]-k1));
        }
        s.insert(hol[i]);
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 5760
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
cd=[list(map(int,input().split())) for i in range(m)]
def dist(list1,list2):
  return abs(list1[0]-list2[0])+abs(list1[1]-list2[1])
for human in ab:
  for i in range(m):
    if i==0:
      d=dist(human,cd[0])
      index=1
    else:
      d_new=dist(human,cd[i])
      if d>d_new:
        d=d_new
        index=i+1
  print(index)

Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()



int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; i++) cin >> S[i];
	sort(all(S));
	for (int i = 0; i < N; i++) cout << S[i];
	cout << endl;

	return 0;
}

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

int main() {
    int K , a ,b ,i;
    cin >> K;
    cin >> a >>b;
    for(i = a ; i <= b ; ++i){
        if(i % K == 0){
            cout << "OK" << endl;
            break;
        }
        else if(i == b){
            cout << "NG" << endl;
        }
        }
    return 0;
}

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

char c[3][3];

int main() {
    for (int i = 0 ; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> c[i][j];
        }
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<complex>
#include<map>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef complex<double> P;

int b[20][20] = {{0}};
int &pos(int y, int x){
  return b[y+5][x+5];
}

int main(){
  string str;
  while(cin>>str){
    int i = 0;
    do{
      REP(j,8)
	pos(i,j) = str[j] - '0';
    }while(++i<8 && cin>>str);

    char ans;
    REP(y,8) REP(x,8){
      if(pos(y,x) == 1){
	if(pos(y+3,x) == 1)
	  ans = 'B';
	else if(pos(y,x+3) == 1)
	  ans = 'C';
	else if(pos(y+2,x-1) == 1)
	  ans = 'D';
	else if(pos(y+1,x+2) == 1)
	  ans = 'E';
	else if(pos(y+2,x+1) == 1)
	  ans = 'F';
	else if(pos(y,x+1) == 1 && pos(y+1,x-1) == 1)
	  ans = 'G';
	else
	  ans = 'A';
	goto end;
      }
    }
  end:
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
#define ever ;;
#define pb push_back

using namespace std;

#define loop(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}





int main()
{

	int n; cin>>n;
	int arr[n];
	loop(i,0,n) cin>>arr[i];
	sort(arr,arr+n);
	cout<<arr[n/2]-arr[n/2-1]<<endl;	
	////------------------------------------------------------------------////

	return 0;
}

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

int main(){
  int n, m, f, r;
  char G[10000] = {};

  for( int i = 0; 1; i++) {
    cin >> m >> f >> r;
    if( m == -1 && f == -1 && r == -1) break;
    n = i + 1;

    if( m == -1 || f == -1) {
      G[i] = 'F';
    } else if( m + f >= 80) {
      G[i] = 'A';
    } else if( m + f >= 65) {
      G[i] = 'B';
    } else if( m + f >= 50) {
      G[i] = 'C';
    } else if( m + f >= 30) {
      if( r >= 50) G[i] = 'C';
      else G[i] = 'D';
    } else{
      G[i] = 'F';
    }
  }

  for( int j = 0; j < n; j++) {
    cout << G[j] << endl;
  }

  return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <vector>

using namespace std;

void dfs(int u, const vector<vector<int>>& g, vector<bool>& visited) {
    if (visited[u]) return;
    visited[u] = true;
    for (auto v : g[u]) {
        if (visited[v]) continue;
        dfs(v, g, visited);
    }
}

int main() {
    int n,m;
    cin >> n >> m;
    vector<vector<int>> g(n+1);
    for (int i=0; i<m; i++) {
        int x,y,z;
        cin >> x >> y >> z;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    int ans = 0;
    vector<bool> visited(n+1,false);
    for (int i=1; i<=n; i++) {
        if (visited[i]) continue;
        ans++;
        dfs(i,g,visited);
    }

    cout << ans << endl;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pi pair <ll,ll>
#define vi vector <ll>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define SQ(a) (a)*(a)
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>       //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/


 
int main() 
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    /*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll i,j,m,t,l=0,x,prev=0,max1=0,flag=0,cnt=0,y,min1,q,sum=0,r,n,k,p,flag2=0,ind=0,b;
    cin>>n;
    ll a[n][3];
    ll dp[n][3];
    for(i=0;i<n;i++){
        for(j=0;j<3;j++){
            cin>>a[i][j];
            dp[i][j]=INT_MIN;
            if(i==0){
                dp[i][j]=a[i][j];
            }
        }
    }
    for(i=0;i<n-1;i++){
        for(j=0;j<3;j++){
            if(j==0){
                dp[i+1][1]=max(dp[i+1][1],dp[i][0]+a[i+1][1]);
                dp[i+1][2]=max(dp[i+1][2],dp[i][0]+a[i+1][2]);
            }
            if(j==1){
                dp[i+1][0]=max(dp[i+1][0],dp[i][1]+a[i+1][0]);
                dp[i+1][2]=max(dp[i+1][2],dp[i][1]+a[i+1][2]);
            }
            if(j==2){
                dp[i+1][0]=max(dp[i+1][0],dp[i][2]+a[i+1][0]);
                dp[i+1][1]=max(dp[i+1][1],dp[i][2]+a[i+1][1]);
            }
        }
    }
    i=n-1;
    max1=0;
    for(j=0;j<3;j++){
        if(dp[i][j]>=max1){
            max1=dp[i][j];
        }
    }
    cout<<max1;
    
  
    
    
 
    return 0;
}

Measured memory_bytes: 4992
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int s[]=new int[a];
		int f[]=new int[a];
		int b[]=new int[a];
		for(int i=0;i<a;i++) {
			s[i]=scan.nextInt();
		}
		for(int i=0;i<a;i++) {
			f[i]=scan.nextInt();
		}
		for(int i=0;i<a;i++) {
			b[i]=s[i]-f[i];
		}
		Arrays.sort(b);
		int ans=0;
		for(int i=a-1;i>-1;i--) {
			if(b[i]<0) {
				break;
			}
			ans+=b[i];
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <cmath>
#include <iomanip>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;

int main()
{
    // 整数の入力
    ll A,B,K;
    cin >> K;
    cin >> A >> B;
    if( ( (A + K - 1)/K)* K <= B ){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
   return 0;
}

Measured memory_bytes: 3632
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        //MyDebugger.MakeTestCase("../TextFile2.txt");
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }
    

    static object process(TextReader input) {
        int n = int.Parse(input.ReadLine());
        //int[] ll = ToIntArray(input.ReadLine(), n);
        
        int[] tb = new int[1001];

        var spl =input.ReadLine().Split(' ');
        for (int i = 0; i < n; i++) {
            var x = int.Parse(spl[i]);
            tb[x]++;
        }

        long count = 0;

        for(int i=1000; i>0; i--) {
            if (tb[i] == 0) continue;
            count += Combination(tb[i],3);

            for(int j=i-1; j>0; j--) {
                //if (i >= j * 2 && tb[i]<2) break;
                if (tb[j] == 0) continue;

                if (i < j*2) {
                    count += tb[i] * Combination(tb[j],2);
                }
                count += tb[j] * Combination(tb[i],2);

                for(int k=j-1; k>0; k--) {
                    if (i >= j + k) break;
                    if (tb[k] == 0) continue;

                    count += tb[i] * tb[j] * tb[k];
                }
            }
        }

        return count;
    }

    static long Combination(long m, long n) {
        if (m < n) return 0;
        if (m == n || n == 0) return 1;

        long ans = 1;
        for (long i = 1; i <= n; i++) {
            ans = ans * (m - i + 1) / i;
        }
        return ans;
    }
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;
ll dp[105][10005];
int main(void)
{
  int n,W;
  int v[105],w[105];
  cin >> n >> W;
  for(int i=0;i<=W;i++)
    {
      dp[0][i]=0;
    }
  for(int i=0;i<n;i++)
    {
      cin >> v[i] >> w[i];
    }
  for(int i=0;i<n;i++)
    {
      for(int j=0;j<=W;j++)
	{
	  if(j>=w[i])
	    {
	      dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
	    }
	  else
	    {
	      dp[i+1][j]=dp[i][j];
	    }
	}
    }
  cout << dp[n][W] << endl;
  return 0;
}



Measured memory_bytes: 10980
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll N=1e5+9;
ll n,dp[N],h[N];
int main(){
    cin>>n;
    for(ll i=0;i<n;i++)cin>>h[i];
    dp[1]=abs(h[1]-h[0]);
    for(ll i=2;i<n;i++){
        dp[i]=min(abs(h[i]-h[i-1])+dp[i-1],abs(h[i]-h[i-2])+dp[i-2]);
    }
    cout<<dp[n-1]<<"\n";
    return 0; 
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  rep(i,n+1){
    ans += i;
  }
  print(ans);
}

Measured memory_bytes: 256
using System;

namespace ARC067
{
    class C
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            int temp;
            int j;
            int[] Res = new int[N + 1];

            for (int i = N; i > 1; i--)
            {
                j = 2;
                temp = i;
                while (j <= N)
                {
                    while (temp % j == 0)
                    {
                        Res[j]++;
                        temp /= j;
                    }
                    j++;
                }
            }

            long count = 1;
            for (int i = 2; i <= N; i++)
            {
                count *= Res[i] + 1;
                count %= 1000000007;
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
from collections import Counter

N = int(input())
A = Counter(map(int, input().split()))
S = [None, A[3] + A[2] + A[1], A[3] + A[2], A[3]]

dp = [[[0] * (S[3] + 1) for _ in range(S[2] + 1)] for __ in range(S[1] + 1)]

for l in range(1, S[1] + 1):
    for m in range(S[2] + 1):
        if l < m:
            break
        for k in range(S[3] + 1):
            if m < k:
                break
            dp[l][m][k] = (dp[l - 1][m][k] * (l - m) + dp[l][m - 1][k] * (m - k) + dp[l][m][k - 1] * k + N) / l
print(dp[S[1]][S[2]][S[3]])


Measured memory_bytes: 494984
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for(ll i = a; i < (ll)(b); i++)

#define ALL(x) (x).begin(), (x).end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

using namespace std;
using ll = long long;
using vel = vector<ll>;
using ves = vector<string>;
using veb = vector<bool>;

using qul = queue<ll>;

int main() {
    ll A,B;
    cin >> A >> B;
    cout << A * B << endl;
}

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

typedef long long  ll;

ll MOD = 1000000007;
ll INF = 100000000000000;
double PI = 3.1415926535;

template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

int main(){
    int A,B,C;cin >> A >>  B >> C;
    if(A+B+C > 21){
        cout <<"bust" << endl;
    }else{
        cout << "win" << endl;
    }
}


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

#define ll long long
#define ld long double
#define xx first
#define yy second
#define vi vector<int>
#define pii pair<int,int>
#define all(v) v.begin(),v.end()

#define MAX 400005

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    ll x;
    cin >> x;

    ll five = x/500;
    x= x%500;

    ll fv = x/5;
    x= x%5;

    cout << five*1000 + fv*5 << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())

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

if 1 not in A:
  print(-1)
else:
  index = []
  current = 1
  cnt = 0
  for a in A:
    if a == current:
      index.append(cnt)
      current += 1
    cnt += 1
  print(n-len(index))

Measured memory_bytes: 24744