akhauriyash/Code-Regression huggingface dataset:
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *NOIP 2019 RP++                                           *
 ***********************************************************/
//#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
    char *pp = (char*)malloc(size) + size;  \
    __asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) ((x>y)?x:y)
#define Min(x,y) ((x<y)?x:y)
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
    ll x=0,f=1;char c;
    for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
    for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}
template<typename T>
inline void write(T a){
    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//

signed main(){
	#ifdef _WIN32
        freopen("0.in","r",stdin);
//        freopen("0.out","w",stdout);
//        ADD_STACK;
        long double be=clock();
    #endif
	ll n=read(),d=0,m=read(),x,ans=1;
	FOR(i,1,n){
		x=read();
		d+=x;
		if(d>m)return writeln(ans),0;
		++ans;
	}
	writeln(ans);
	#ifdef _WIN32
        long double en=clock();
        printf("Time: %.0Lfms\n",en-be);
        fclose(stdin);fclose(stdout);
    #endif
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>

using namespace std;

typedef long long ll;

const ll M = 1e9 + 7;
ll n;
vector<ll> ve;
ll a[10005];
ll c[10005];
ll b[1000005];
bool v[1000005];
ll lcm = 1;
ll ans;

ll f(ll p)
{
    ll re = 1;
    for(ll i = 1; i <= M - 2; i*=2)
    {
        if(i & (M - 2)) re *= p;
        p *= p;
        re %= M;
        p %= M;
    }
    return re;
}

int main()
{
    scanf("%lld", &n);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        c[i] = a[i];
        for(ll j = 2; j * j <= a[i]; j++)
        {
            ll cnt = 0;
            while(a[i] % j == 0) cnt++, b[j] = max(b[j], cnt), a[i] /= j;
        }
        if(a[i] > 1) b[a[i]] = max(b[a[i]], 1LL);
    }
    for(ll i = 2; i <= 1000000; i++) while(b[i]--) lcm *= i, lcm %= M;
    for(ll i = 0; i < n; i++)
    {
        ans += lcm * f(c[i]) % M;
        ans %= M;
    }
    printf("%lld", ans);
    return 0;
}


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

using namespace std;

int main()
{
    int N, K, result = 0, x;
    cin >> N >> K;
    for(int i = 0; i < N; ++i) {
        cin >> x;
        result += min(abs(0-x), abs(K-x)) * 2;
    }
    cout << result << endl;
}


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

using namespace std;

#define MAX_N (1<<17)

class BIT{
public:
  int bit[MAX_N+1],n;
  
  BIT(){
    for(int i = 0 ; i < MAX_N ; i++){
      bit[i] = 0;
    }
  }

  int sum(int i){
    int s = 0;
    while(i > 0){
      s += bit[i];
      i -= i & -i;
    }
    return s;
  }
  
  void add(int i,int x){
    while(i <= n){
      bit[i] += x;
      i += i & -i;
    }
  }
};

int main(){
  int q,com,x,y;
  BIT b;
  cin >> b.n >> q;
  while(q--){
    cin >> com >> x >> y;
    if(com){
      cout << b.sum(y)-b.sum(x-1) << endl;
    }else{
      b.add(x,y);
    }
  }
  return 0;
}

Measured memory_bytes: 1672
#include <iostream>
#include <cstring>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void){
    int N, K;
    int V[50] = {};
    int takenV[50] = {};
    cin >> N >> K;
    for(int i=0; i<N; i++)cin >> V[i];

    int res=0;

    for(int i=0; i<=min(N,K); i++){
        for(int j=0; j<=min(N,K)-i; j++){
            fill(takenV, takenV+49, 0);
            memcpy(takenV, V, i*sizeof(int));
            memcpy(takenV+i, V+N-j, j*sizeof(int));
            sort(takenV, takenV+i+j);
            int neg=0;
            for(int l=0; l<min(i+j, K-i-j); l++){
                if(takenV[l]<0)neg+=takenV[l];
            }
            res=max(res, accumulate(takenV, takenV+i+j, 0)-neg);
        }
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;

int main() {
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> a(n);

    int y;
    for (int i = 0; i < q; i++) {
        cin >> y;
        a[y - 1]++;
    }

    for (int i = 0; i < n; i++) {
        if (k  > q - a[i]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
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;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" <<endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

string str(int n) {
    string tmp = to_string(n);
    while (tmp.length() != 3)
    {
        tmp = "0"+tmp;
    }
    return tmp;
}

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

    ll ans = 0;

    REP(o, 9+1) REP(t, 9+1) REP(h, 9+1) {
        string tmp = str(o + t*10 + h*100);
        int itr = 0;
        for (char ch : s) {
            if (itr == 3) break;
            if (ch == tmp[itr]) {
                // debug(ch)
                // debug(tmp + " : " + to_string(itr))
                itr++;
            }
        }

        if (itr == 3) {
            ans++;
            //debug(tmp)
        }
    }

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


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), m = scanner.nextInt();
			Path[] paths = new Path[m];
			@SuppressWarnings("unchecked")
			List<Path>[] pathLists = new List[n];
			IntStream.range(0, n).forEach(i -> pathLists[i] = new ArrayList<>());
			IntStream.range(0, m).forEach(i -> {
				paths[i] = new Path(scanner.nextInt() - 1, scanner.nextInt() - 1, scanner.nextInt());
				pathLists[paths[i].from].add(paths[i]);
				pathLists[paths[i].to].add(new Path(paths[i].to, paths[i].from, paths[i].cost));
			});
			int[][] dist = new int[n][];
			IntStream.range(0, n).forEach(i -> dist[i] = dijkstra(pathLists, i, n));
			int answer = m;
			for (Path path : paths) {
				boolean shortest = false;
				for (int j = 0; j < n; j++) {
					if (dist[j][path.from] + path.cost == dist[j][path.to]) {
						shortest = true;
						break;
					}
				}
				if (shortest) {
					answer--;
				}
			}
			System.out.println(answer);
		}
	}

	/**
	 * @param pathLists ノード間の連結パス一覧の配列
	 * @param src       開始ノード
	 * @param n         ノードの数
	 * @return 開始ノードからの距離の配列
	 */
	private static int[] dijkstra(List<Path>[] pathLists, int src, int n) {
		int[] distances = new int[n];
		Arrays.fill(distances, Integer.MAX_VALUE);
		// 最短距離が確定したかどうか
		boolean[] fixed = new boolean[n];
		Arrays.fill(fixed, false);
		// 出発地点までの距離を0とする
		distances[src] = 0;
		Queue<Path> queue = new PriorityQueue<>();
		queue.add(new Path(src, src, 0));
		while (!queue.isEmpty()) {
			int now = queue.poll().to;
			if (!fixed[now]) {
				fixed[now] = true;
				for (Path path : pathLists[now]) {
					if (!fixed[path.to] && distances[path.to] > distances[now] + path.cost) {
						distances[path.to] = distances[now] + path.cost;
						queue.add(new Path(path.to, path.to, distances[path.to]));
					}
				}
			}
		}
		return distances;
	}

	/**
	 * ノード間の一つのパスを表すクラス
	 */
	private static class Path implements Comparable<Path> {
		/** 開始ノード */
		int from;
		/** 終了ノード */
		int to;
		/** 移動コスト */
		int cost;

		Path(int from, int to, int cost) {
			super();
			this.from = from;
			this.to = to;
			this.cost = cost;
		}

		@Override
		public int compareTo(Path path) {
			return this.cost - path.cost;
		}
	}
}


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


#(2)二分探索を使った実装 O(NlogM)

# 下の配列を累積和にしとく
for i in range(1,N):
    A[i] += A[i - 1]
for i in range(1, M):
    B[i] += B[i - 1]

# O(N),O(M)かかるからあんま良くないが複数の実装をする都合でinsert()使用.
A.insert(0, 0)
B.insert(0,0)
ans = 0

#　各A[i]について考える.
for i in range(N+1):
    if K - A[i] < 0:
        break
    # 二分探索
    ok = -1
    ng = M+1
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if B[mid] <= K - A[i]: ok = mid
        else: ng = mid
        
    ans = max(ans, i + ok)
    
print(ans)

Measured memory_bytes: 40168
import sys

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

if N==1:
    print("First")
    exit()

depth=[-1 for i in range(N)]
depth[0]=0
q=set([0])
sub=set([])
while q:
    while q:
        x=q.pop()
        for i in edge[x]:
            if depth[i]==-1:
                depth[i]=1+depth[x]
                sub.add(i)
        if not q:
            q=sub
            sub=set([])
            break

root=depth.index(max(depth))
depth=[-1 for i in range(N)]
depth[root]=0
q=set([root])
sub=set([])
while q:
    while q:
        x=q.pop()
        for i in edge[x]:
            if depth[i]==-1:
                depth[i]=1+depth[x]
                sub.add(i)
        if not q:
            q=sub
            sub=set([])
            break

dia=max(depth)
dp=[["" for i in range(0,2)] for i in range(0,dia+1)]
dp[0][0]="First"
dp[0][1]="Second"
dp[1][0]="Second"
dp[1][1]="First"
for i in range(2,dia+1):
    if dp[i-1][1]=="First" or dp[i-2][1]=="First":
        dp[i][0]="First"
    else:
        dp[i][0]="Second"

    if dp[i][0]=="First":
        dp[i][1]="Second"
    else:
        dp[i][1]="First"

print(dp[dia][0])

Measured memory_bytes: 107724
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
		String s;
		while ((s = stdIn.readLine()) != null) {
			int pcs = Integer.valueOf(s);
			Card[] mine = new Card[pcs];
			for (int i = 0; i < pcs; i++) {
				mine[i] = new Card(stdIn.readLine());
			}
			for (int m = 0; m < 4; m++)
				for (int r = 1; r <= 13; r++)
					doMain(m, r, mine);
		}
		System.exit(0);
	}

	private static void doMain(int mark, int rank, Card[] mine) {
		for (int i = 0; i < mine.length; i++)
			if (mine[i].isEqual(mark, rank))
				return;
		switch (mark) {
		case (0):
			System.out.println("S " + rank);
			break;
		case (1):
			System.out.println("H " + rank);
			break;
		case (2):
			System.out.println("C " + rank);
			break;
		case (3):
			System.out.println("D " + rank);
			break;
		}
	}
}

class Card {
	public Card(String s) {
		String[] se = s.split(" ");
		switch (se[0]) {
		case ("S"):
			mark = 0;
			break;
		case ("H"):
			mark = 1;
			break;
		case ("C"):
			mark = 2;
			break;
		case ("D"):
			mark = 3;
			break;
		}
		rank = Integer.valueOf(se[1]);
	}

	public boolean isEqual(int mark2, int rank2) {
		if (mark == mark2 && rank == rank2)
			return true;
		else
			return false;
	}

	private int mark;
	private int rank;
}

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

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

void solve(int W, int H) {
    int wall[N][N][N][N];
    for(int i = 0; i < H; ++i) {
        for(int j = 0; j < W - 1; ++j) {
            cin >> wall[i][j][i][j + 1];
            wall[i][j + 1][i][j] = wall[i][j][i][j + 1];
        }
        if(i != H - 1) {
            for(int j = 0; j < W; ++j) {
                cin >> wall[i][j][i + 1][j];
                wall[i + 1][j][i][j] = wall[i][j][i + 1][j];
            }
        }
    }
    queue<pair<int, int>> que;
    vector<vector<int>> dist(H, vector<int>(W));
    que.emplace(0, 0);
    dist[0][0] = 1;
    while(!que.empty()) {
        auto cur = que.front(); que.pop();
        int y = cur.first, x = cur.second;
        for(int i = 0; i < 4; ++i) {
            int ny = y + dy[i], nx = x + dx[i];
            if(ny < 0 || nx < 0 || ny >= H || nx >= W) continue;
            if(dist[ny][nx]) continue;
            if(!wall[y][x][ny][nx]) {
                que.emplace(ny, nx);
                dist[ny][nx] = dist[y][x] + 1;
            }
        }
    }
    if(dist[H - 1][W - 1] == -1) cout << 0 << '\n';
    else cout << dist[H - 1][W - 1] << '\n';
}

int main() {
    int w, h;
    while(cin >> w >> h) {
        if(!w) break;
        solve(w, h);
    }
    return 0;
}



Measured memory_bytes: 6984
#include"bits/stdc++.h"
using namespace std;
int MOD = 1000000007;
int main() {
	int N; cin >> N;
	vector<int> A(N);
	long long ans = 0, m = 0;
	for (int i = 0; i < N; i++)
	{
		cin >> A.at(i);
		m += A.at(i);
		m %= MOD;
	}
	for (int i = 0; i < N; i++)
	{
		m -= A.at(i);
		if (m < 0) m += MOD;
		ans += A.at(i) * m;
		ans %= MOD;
	}
	cout << ans << endl;
}

Measured memory_bytes: 4032
n=int(input())
c=list(map(int,input().split()))

c.sort()

a=b=0
d=len(c)
for i in range(d):
    if i%2==0:
        a+=c[d-i-1]
    else:
        b+=c[d-i-1]

print(abs(a-b))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front

string s;
int sum[200200][100];
int ans = 1;

signed main()
{
    cin >> s;
    int N = s.size();
    for(int i = 0; i < N; i++){
        if(i > 0){
            for(int j = 0; j < 26; j++){
                sum[i][j] = sum[i - 1][j];
            }
        }
        ans += i - sum[i][s[i] - 'a'];
        sum[i][s[i] - 'a']++;
        //printf("%d\n", sum[i][s[i] - 'a']);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 156804
import java.util.Scanner;

 class Main {
	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x;
		int y;
		
		while(true){
			x = scan.nextInt();
			y = scan.nextInt();
			if(x == 0 && y == 0)break;
			if(x > y){
				System.out.println(y + " " + x);
			}
			else if(x < y){
				System.out.println(x + " " + y);
			}
			if(x == y ){
				System.out.println(x + " " + y);
			}
		}
	}	
}

Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int MOD = pow(10, 9) + 7;
//const int MOD = 998244353;
//const int MOD = ;
int mod(int A, int M) {return (A % M + M) % M;}
const int INF = 1LL << 60;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
int myctoi(char C) {return C - 48;}
char myitoc(int N) {return '0' + N;}

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

  int ans = max((int)0, C - A + B);
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;
 
template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}
 
template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};
 
struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int n; scan(n);
      std::vector<Int> ts(n+2), vs(n+2);
      ts[0] = 0, vs[0] = 0;
      ts[n+1] = 0, vs[n+1] = 0;
      for(Int i = 1; i <= n; ++i) scan(ts[i]);
      for(Int i = 1; i <= n; ++i) scan(vs[i]);
      std::vector<Int> as, bs;
      std::vector<Int> ls, rs;
      Int st = 0;
      for(Int i = 0; i < n + 2; ++i) {
         //
         as.push_back(-1);
         bs.push_back(vs[i]+st);
         ls.push_back(-1e10);
         rs.push_back(st);
         //
         as.push_back(0);
         bs.push_back(vs[i]);
         ls.push_back(st);
         rs.push_back(st+ts[i]);
         //
         as.push_back(1);
         bs.push_back(vs[i]-(st+ts[i]));
         ls.push_back(st+ts[i]);
         rs.push_back(1e10);
         st += ts[i];
      }
      double res = 0.0;
      for(Int i = 0; i <= 2 * st; ++i) {
         double t = (double)i / 2;
         double z = 1e10;
         for(Int k = 0; k < (Int)as.size(); ++k) {
            if( ls[k] <= t and t <= rs[k] ) {
               z = std::min(z, as[k] * t + bs[k]);
            }
         }
         res += z;
      }
      printf("%.20lf\n", res / 2);
   }
};
 
int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}
 
 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define MOD 1000000007
typedef long long ll;
using namespace std;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int k,a,b; cin >> k >> a >> b;
    bool flag = false;
    for(int i=a;i<=b;i++){
        if(i % k == 0){
            flag = true;
        }
    }
    if(flag){
        cout << "OK" << endl;
    }else{
        cout << "NG" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
def main():
    n, k = map(int, input().split())
    h = tuple(map(int, input().split()))
    cost = [0 for _ in range(n)]
    cost[0] = 0
    cost[1] = abs(h[1] - h[0])
    for i in range(2, n):
        cost[i] = min((cost[i-1-j] + abs(h[i]-h[i-1-j]) for j in range(min(i, k))))
    print(cost[-1])
main()


Measured memory_bytes: 59488
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N; cin >> N;

    vector<int> v(N);
    vector<vector<int> > p(N, vector<int>(11));
    int a;
    for (int i = 0; i < N; i++) {
        int tmp = 0;
        for (int j = 0; j < 10; j++) {
            cin >> a; tmp += a * (1 << j);
        }
        v[i] = tmp;
    }
    for (int i = 0; i < N; i++) for (int j = 0; j < 11; j++) cin >> p[i][j];

    int ans = -INF;
    for (int b = 1; b < (1 << 10); b++) {
        int tmp = 0;
        for (int i = 0; i < N; i++) {
            int cnt = 0, c = b & v[i];
            for (int j = 0; j < 10; j++) { if (c & (1 << j)) cnt++; }
            tmp += p[i][cnt];
        }
        ans = max(tmp, ans);
    }
    cout << ans << '\n';
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


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

    int k = 0;
    while(k!=K) {

        // takahashi tern
        if (A%2==1) A--;
        B+=(A/(ll)2);
        A/=(ll)2;
        k++;
        if (k==K) break;

        // aoki tern
        if (B%2==1) B--;
        A+=(B/(ll)2);
        B/=(ll)2;
        k++;

    }

    cout << A << " " << B << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
using namespace std;
#define int long long
main()
{
    int m,n,k,a,b,c,d;
    vector< int> v;
    string s;
    cin >> s;
    set< char > st;
    for( int i = 0; i < s.size() ;i++ )st.insert( s[i] );
    if( st.size() == 2 ) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
import itertools

N,M=map(int,input().split())
x=[[0,0,0] for _ in range(N)]

for i in range(N):
    x[i][0],x[i][1],x[i][2]=map(int,input().split())
    
#+++,++-など8パターン
a=[]
for i in itertools.product([1,-1], repeat=3):
    a.append(i)
dp=[[[0]*(M+1) for _ in range(N+1)] for k in range(8)]#i番目まで，j個使うとき,kパターンの合計の最大

def msum(L,xx):
    ans=0
    for i in range(len(xx)):
        ans+=xx[i]*L[i]
    return ans


for k in range(8):
    for i in range(N):
        for j in range(min(M,i+1)):
            if j==i:
                dp[k][i+1][j+1]=dp[k][i][j]+msum(a[k],x[i])
            else:
                dp[k][i+1][j+1]=max(dp[k][i][j+1],dp[k][i][j]+msum(a[k],x[i]))
            
        
ans=0
for k in range(8):
    ans=max(ans,dp[k][-1][-1])
print(ans)




Measured memory_bytes: 108252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();

		int res = 0;

		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			int y = sc.nextInt();

			double dist = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

//			System.out.println(x + " " + y);

			if ((double) d >= dist) {
				res++;
			}

		}

		System.out.println(res);

	}

}

Measured memory_bytes: 59172
#include<iostream>
#include<vector>
typedef long long int ll;
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<ll> arr(n+1, 2);
    arr[1] = 1;
    for(int i = 2; i <= n/2; i++) {
        for(int j = 2 * i; j <= n; j+=i) {
                arr[j]++;
        }
    }
    ll sum = 0;
    for(int i = 1; i <= n; i++) {
        sum += arr[i] * i;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 81276
#include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <deque>
#include <stack>
#include <iomanip>
#include <cmath>


using namespace std;


typedef long long ll;
typedef long double ld;


const ll MOD = 1000000007ll;


ll modSum(ll a, ll b) {
  return ((a % MOD) + (b % MOD)) % MOD;
}


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


ll getPowMod(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPowMod(x, e/2);
    return modProd(tmp, tmp);
  } else {
    ll tmp = getPowMod(x, e-1);
    return modProd(tmp, x);
  }
}


ll getPow(ll x, ll e) {
  if (e == 0) return 1;
  if (e % 2 == 0) {
    ll tmp = getPow(x, e/2);
    return tmp * tmp;
  } else {
    ll tmp = getPow(x, e-1);
    return tmp * x;
  }
}


bool isEven(ll x) {
  ll tmp = ((x % 2) + 2) % 2;
  return tmp == 0;
}


ll getSumOfDigitsInBase(ll n, ll b) {
  ll ret = 0;
  while (n > 0) {
    ret += n % b;
    n /= b;
  }
  return ret;
}


vector<int> getKMP(string &s) {
  int len = (int)s.size();
  vector<int> ret (len, 0);
  for (int i = 1 ; i < len ; i++) {
    int at = ret[i-1];
    while (at > 0 && s[i] != s[at]) {
      at = ret[at-1];
    }
    if (s[i] == s[at]) {
      at++;
    }
    ret[i] = at;
  }
  return ret;
}


string getSubstring(string &s, int from, int to) {
  int l = to-from+1;
  if (l <= 0) {
    return "";
  }
  return s.substr(from, l);
}

















const int MAXN = 11;


int N;
string s;
pair<ll, ll> memo[MAXN];


void input() {
  cin >> s;
  N = (int)s.size();
}

void preprocess() {
}


pair<ll, ll> getAns(int pos) {
  if (pos == N) return {0, 1};
  if (memo[pos].second != 0) return memo[pos];
  ll ret1 = 0;
  ll ret2 = 0;
  for (int i = pos ; i < N ; i++) {
    auto p = getAns(i+1);
    ret1 += (stoll(getSubstring(s, pos, i)) * p.second) + p.first;
    ret2 += p.second;
  }
  return memo[pos] = {ret1, ret2};
}


void solve() {
  cout << (getAns(0)).first;
}


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

  int T;
//  cin >> T;
  T = 1;

  for (int i = 0 ; i < T ; i++) {
    input();
    preprocess();
    solve();
  }

  return 0;
}


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

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

    t.erase(t.size()-1);
    if(s == t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a),end(a)
#define MS(m,v) memset(m,v,sizeof(m))
#define D10  fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef complex<double> Point;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;
const double PI = acos(-1.0);
struct edge
{
	int from, to, cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int m, n;
		cin >> m >> n;
		int t = m*m + n*n;
		int cnt = 0;
		for (int p = 0; p*p <= t; p++)
		{
			for (int q = 0; q*q <= t; q++)
			{
				if ((p*p + q*q) < 1) continue;
				if ((m*p + n*q) % (p*p + q*q) == 0 && (p*n - q*m) % (p*p + q*q) == 0) cnt++;
			}
		}
		puts(cnt <= 4 ? "P" : "C");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int,int>P;

#define INF 1<<30
#define F first
#define S second
#define MOD 1000000007

int main(){
  int n;
  int max_a=0,max_pos;
  int sec_a=0;
  int a[200005];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    if(a[i]>max_a){
      sec_a=max_a;
      max_a=a[i];
      max_pos=i;
    }else if(a[i]>sec_a){
      sec_a=a[i];
    }
  }

  for(int i=0;i<n;i++){
    if(i==max_pos){
      printf("%d\n",sec_a);
    }else{
      printf("%d\n",max_a);
    }
  }
  
  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ar[n];
    for(int i=0;i<n;i++){
        cin>>ar[i];
    }
    int ans=1,ma=ar[0];
    for(int i=1;i<n;i++){
        if(ar[i]>=ma){
            ma=ar[i];
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
(n, m, l) = [int(i) for i in input().split()]
a = []
b = []

for i in range(n):
    a.append([int(i) for i in input().split()])
for j in range(m):
    b.append([int(j) for j in input().split()])

for x in range(n):
    c = []
    for y in range(l):
        d = 0
        for z in range(m):
            d += a[x][z] * b[z][y]
        c.append(str(d))
    print(' '.join(c))

Measured memory_bytes: 8396
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int n , k; cin >> n >> k;
    vector<bool> treat(n + 1, true);
    for (int i = 0; i < k; i++) {
        int d; cin >> d;
        for (int i = 0; i < d; i++) {
            int a; cin >> a;
            treat[a] = false;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++) {
        if (treat[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main()
{
    int n;
    ll ans=0;
    cin>>n;
    vector<ll> a(n),b(n);
    
    for(int i = 0; i < n; i++)
    {
        cin>>a[i]>>b[i];
    }
    
    for(int i = n - 1; i >= 0; i--)
    {
        a[i]+=ans;
        if(a[i]%b[i]>0)
        {
            ans+=b[i]-(a[i]%b[i]);
        }
    }

    cout<<ans<<endl;

    return 0;
}

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

int main() {
  int X;
  cin >> X;
  if(X>=400 && X<=599){
    cout << 8 <<endl;
  }
  if(X>=600 && X<=799){
    cout << 7 <<endl;
  }
  if(X>=800 && X<=999){
    cout << 6 <<endl;
  }
  if(X>=1000 && X<=1199){
    cout << 5 <<endl;
  }
  if(X>=1200 && X<=1399){
    cout << 4 <<endl;
  }
  if(X>=1400 && X<=1599){
    cout << 3 <<endl;
  }
  if(X>=1600 && X<=1799){
    cout << 2 <<endl;
  }
  if(X>=1800 && X<=1999){
    cout << 1 <<endl;
  }
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin>>a;
    cin>>b;
    if(a>=13)
        cout<<b;
    if(a>5&&a<13)
        cout<<b/2;
    if(a<=5)
        cout<<0;

    return 0;
}


Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s,t,x;
    string ans = "No";
    cin >> s >> t;
    for(int i=0;i<s.length();i++){
        if(i==0){
            x = s;
        }
        x = x.substr(x.length()-1,1) + x.substr(0,x.length()-1);
        if(x == t){
            ans = "Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
s = input()
ans = 1
prev = s[0]
i = 1
new = True
while i < len(s):
    if new:
        now = s[i]
        if now == prev: 
            new = False
        else: 
            prev = now
            ans += 1
    else:
        now += s[i]
        if now != prev:
            prev = now
            ans += 1
            new = True
    i += 1
print(ans)
        


Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define int int64_t
int a[404],dp[404][404],s[404];
signed main()
{
	int n,i,j,l;
	cin>>n;
	for(i=1;i<=n;i++)
	{
	cin>>a[i];
	s[i]=s[i-1]+a[i];
}
	for(l=1;l<=n;l++)
	{
		for(i=1;i<=n-l+1;i++)
		{
			j=i+l-1;
			if(l==1)
			dp[i][j]=0;
			else if(l==2)
			dp[i][j]=a[i]+a[j];
			else
			{
			dp[i][j]=10000000000000000;
			for(int k=i;k<=j-1;k++)
			{
			dp[i][j]=min(dp[k+1][j]+dp[i][k]+s[j]-s[i-1],dp[i][j]);
		}
	}
		}
	}
	cout<<dp[1][n]<<"\n";
}

Measured memory_bytes: 1536
n,m = map(int,input().split())
s = []
for i in range(n):
    s.append(list(map(int,input().split())))
cnt = 0
for j in range(1,m+1):
    check = True
    for i in range(n):
        if not j in s[i][1::]:
            check = False
    if check:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const char s[2]={'A','B'};
int a,b,c,d,q,k,nb;ll lim;
inline int calc(R int x){return (a-(b-x+k-1)/k)/k;}
inline int find(){
    R int l=0,r=b,mid,ans=0;
    while(l<=r){
        mid=(l+r)>>1;
        mid<=calc(mid)?(ans=mid,l=mid+1):r=mid-1;
    }
    return ans;
}
int main(){
//  freopen("testdata.in","r",stdin);
    for(scanf("%d",&q);q;--q){
        scanf("%d%d%d%d",&a,&b,&c,&d),--c;
        k=(a+b)/(a<b?a+1:b+1);
        if(k==1){
			for(int i=c;i<d;i++) putchar(s[(i+(b>a))&1]);
        }
        else{
            nb=find();
//          printf("qwq %d %d %d %d\n",a,b,k,nb);
            lim=nb+a-(b-nb+k-1)/k+1;
            fp(i,c,d-1)putchar(i<lim?s[i%(k+1)==k]:s[(a+b-i)%(k+1)>0]);
        }
        putchar('\n');
    }
    return 0;
}    

Measured memory_bytes: 384
#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 <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int N, Y;
    cin >> N >> Y;
    int yd = Y / 1000;
    int x, y, z;
    rep(i, 0, 2001) {
        rep(j, 0, 2001) {
            if (10 * N - yd == 5 * i + 9 * j) {
                x = N - i - j;
                y = i;
                z = j;
                if (x >= 0) {
                    cout << x << " " << y << " " << z << endl;
                    return 0;
                }
            }
        }
    }
    x = -1;
    y = -1;
    z = -1;
    cout << x << " " << y << " " << z << endl;
    return 0;
}


Measured memory_bytes: 888
N=int(input())
xyh=list(sorted([list(map(int, input().split())) for _ in range(N)], key=lambda x: -x[2]))

for cx in range(101):
    for cy in range(101):
        flag=1
        tmp=abs(xyh[0][0]-cx)+abs(xyh[0][1]-cy)+xyh[0][2]
        for i in range(1,N):
            if xyh[i][2]==0 and abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)<tmp:
                flag=0
                break
            if tmp!=abs(xyh[i][0]-cx)+abs(xyh[i][1]-cy)+xyh[i][2] and xyh[i][2]!=0:
                flag=0
                break
        if flag:
            print(cx, cy, tmp)
            exit(0)


Measured memory_bytes: 3188
N = int(input())

A = [[0]*N for i in range(N)]

for i in range(N):
    A[i] = list(map(int,input().split()))
B = [[A[i][j] for j in range(i+1,N)] for i in range(N-1)]
#print(A)
#print(B)

det = 0

for i in range(N-1):
    for j in range(i+1,N):
        for k in range(N):
            if A[i][j] > A[i][k] + A[k][j]:
                det = -1
                break
            elif i != k and j != k and A[i][j] == A[i][k] + A[k][j]:
                B[i][j-(i+1)] = 0
                #print(i,j,k,B)
        
        if det == -1:
            break

    if det == -1:
        break

if det == 0:
    ans = 0
    for i in range(N-1):
        for j in range(i+1,N):
            ans += B[i][j-(i+1)]
else:
    ans = -1

print(ans)


Measured memory_bytes: 45404
import java.util.Scanner;

public class Main {

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int N = scanner.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = scanner.nextInt() - 1;
        }

        int index = 0;
        int count = 1;
        while (count < N) {
            index = a[index];
            if (index == 1) {
                System.out.println(count);
                return;
            }
            count++;
        }

        System.out.println(-1);
    }

}


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

#define ll long long
#define P pair<int,int>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define asort(x) sort(x.begin(),x.end())

int main() {
    int x,y;
    cin >> x >> y;
    rep(i,x+1) {
        int j = x - i;
        if(y == i * 2 + j * 4 || y == i * 4 + j * 2) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3588
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

vector<int> temp(4);

void sos(int l, int r, vector<int> arr[]) {

	if(l+1 == r) return;

	int mid = (l + r) >> 1;
	sos(l, mid, arr);
	sos(mid, r, arr);
	int len = (r - l) >> 1;

	for(int i=l; i<mid; i++) {
		merge(arr[i+len].begin(), arr[i+len].end(), arr[i].begin(), arr[i].end(), temp.begin());
		arr[i+len][0] = temp[0];
		arr[i+len][1] = temp[1];
	}
}

vector<int> F[N];

int main() {

	boost;
	int n; cin>>n;
	for(int i=0; i<(1<<n); i++) {
		int a; cin>>a;
		F[i].push_back(-a);
		F[i].push_back(0);
	}
	sos(0, 1<<n, F);

	int ans = F[0][0] + F[0][1];
	for(int i=1; i<(1<<n); i++) {
		ans = min(ans, F[i][0] + F[i][1]);
		cout<<-ans<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 34688
u[6]={1,5,10,50,100,500};
main(p){
	int n[6],i,b,c,m,r,t;
	for(;scanf("%d",&p)*p;){
		for(i=0;i<6;i++)
			scanf("%d",n+i);
		m=1e9;
		for(b=0;b<500;b++){//0`499~½­x¥¤
			c=0;
			r=p+b;//x¥¤àz
			//è¿ÌdÝÅx¥¦é©`FbN
			for(i=6;i--;){
				t=r/u[i];
				if(t>n[i])
					t=n[i];
				c+=t;
				r-=t*u[i];
			}
			if(r==0){//x¥¦é
				c+=b%5+b/5%2+b/10%5+b/50%2+b/100%5;
				if(c<m)
					m=c;
			}
		}
		printf("%d\n",m);
	}
}

Measured memory_bytes: 0
#include<stdio.h>

int main()
{
        int N;
        int x[2];

        scanf("%d", &N);

        x[0] = N%10;
        x[1] = N/10;

        if(x[0]==9 || x[1]==9)
        {
                printf("Yes\n");
        }
        else
        {
                printf("No\n");
        }

        return 0;
}




Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
 
#define rep(i, n) for(int i = 0; i < (n); ++i)
 
using namespace std;

typedef long long ll;

ll x, y;

int main(){
    cin >> x >> y;
    cout << (abs(x - y) <= 1 ? "Brown" : "Alice") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
int N,M;
int P[100000],Y[100000];
vector <int> yd[100001];
int main() {
  scanf("%d%d",&N,&M);
  rep(i,M)scanf("%d%d",&P[i],&Y[i]),yd[P[i]].push_back(Y[i]);
  rep(i,N)sort(yd[i+1].begin(),yd[i+1].end());
  rep(i,M)printf("%012lld\n",ll(P[i])*1000000+int(lower_bound(yd[P[i]]. begin(),yd[P[i]].end(),Y[i])-yd[P[i]].begin())+1);
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define forall(it, v) for(auto it = v.begin(); it != v.end(); ++it)
#define dforn(i, n) for(int i = ((int) n) - 1; i >= 0; i--)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define ff first
#define ss second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = -1;

ll gcd(ll a, ll b){ return !a ? b : gcd(b%a, a);}

ll a, b, c, d;

int main(){
//	freopen("input.txt", "r", stdin);
	int t;
	while(scanf("%d", &t) >= 1){
	forn(cs, t){
	    scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	    if(b > a)goto LOSE;
	    if(d < b)goto LOSE;
	    if(c >= b)goto WIN;
//	    cout << "dd" << endl;
	    if(b-gcd(b, d)+a%gcd(b, d) <= c)goto WIN;
	    else goto LOSE;

	    WIN: cout << "Yes" << endl; continue;
	    LOSE: cout << "No" << endl; continue;
    }
    }puts("");
	return 0;
}


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


using namespace std;

typedef long long ll;

const ll MAX_N = 1e5+10, MAX_M = 2e5+10;

ll x[MAX_N];
vector<pair<ll, ll> > G[MAX_N];
vector<ll> vec;

bool used[MAX_N];

bool dfs(ll v){
  used[v] = true;
  for (auto u : G[v]){
    if (used[u.first]) {
      if (x[u.first] != x[v] + u.second) return false;
      continue;
    }
    else {
      x[u.first] = x[v] + u.second;
      if (!dfs(u.first)) return false;
    }
  }
  return true;
}

bool solve(){
  vec.erase(unique(vec.begin(), vec.end()), vec.end());
  for (int i = 0; i < vec.size(); ++i) {
    ll v = vec[i];
    if (used[v]) continue;
    if (!dfs(v)) return false;
  }
  return true;
}


int main(int argc, char const *argv[]) {
  ll n, m;
  fill(used,used+MAX_N, false);

  cin >> n >> m;
  for (ll i = 0; i < m; i++) {
    ll l, r, d;
    scanf("%lld %lld %lld", &l, &r, &d);
    l--;
    r--;
    G[l].push_back(make_pair(r, d));
    G[r].push_back(make_pair(l, -d));
    vec.push_back(l);
    vec.push_back(r);
  }  

  if (solve()) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 18796
#include <stdio.h>
#define N 44
int fib(int);
int F[N];
int main(){
int n,i;
for( i=0;i<N;i++){
F[i] = 0;
}
scanf("%d",&n);
printf("%d\n",fib(n));
}

int fib(int n){
if(n == 0 || n ==1){
return F[n] =1;
}
if(F[n] != 0){
return F[n];
}
return F[n] = fib(n-2) +fib(n-1);
}



Measured memory_bytes: 2104
//code by 27.
#include<stdio.h>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
int a[11];
int n;
set<string>seet;
int ypa(int k)
{
	if(k>n)
	{
		string st;
		bool shit=false;
		for(int i=1;i<=n;i++)
		{
			st+=(char)(a[i]);
			if(a[i]%2==0)shit=true;
		}
		//sort(st.begin(),st.end());
		if(shit)
		{
			/*
			for(int i=1;i<=n;i++)
			{
				printf("%d ",a[i]);
			}
			cout<<endl;
			*/
			seet.insert(st);
		}
	}
	else
	{
		a[k]++;
		ypa(k+1);
		a[k]--;
		ypa(k+1);
		a[k]--;
		ypa(k+1);
		a[k]++;
	}
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	ypa(1);
	cout<<seet.size();
	return 0;
}

Measured memory_bytes: 6656
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define MOD 1000000007

int main(){
  int n,k;
  cin >> n >> k;
  int ans = 1;
  rep(i,n){
    ans = min(ans*2,ans+k);
  }
  cout << ans << endl;
}


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

namespace ABC124_A_Buttons
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			int coin = 0;

			for(int i = 0; i < 2; i++)
			{
				if(a >= b)
				{
					coin += a;
					a--;
				}
				else
				{
					coin += b;
					b--;
				}
			}

			Console.WriteLine(coin);
		}
	}
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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; }
 

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

ll ans=0;
    rep(i, K)
    {
        rep(j, K)
        {
            rep(h, K)
            {
                ans+=__gcd(h+1, __gcd(i+1, j+1));
            }
        }
    }
    

    cout << ans << endl;
 

 

 

    return 0;
}
 

//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define forr(i, a, b) for(int i = (a); i < (int) (b); i++)
#define forn(i, n) forr(i, 0, n)
#define dforr(i, a, b) for(int i = (int)(b-1); i >= (a); i--)
#define dforn(i, n) dforr(i, 0, n)
#define db(v) cerr << #v << " = " << v << endl
#define pb push_back
#define sz(x) ((int)x.size())
#define fst first
#define snd second
typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
const int MAXN = -1;

int n, w, h;

int main(){
//	freopen("input.txt", "r", stdin);
	while(scanf("%d %d %d", &n, &w, &h) >= 1){
        int ans = max(n-w+1, 0) * max(n-h+1, 0);
        printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256