akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
string a[3];
int b[3];
signed main() {
	cin>>a[0]>>a[1]>>a[2];
	int t=0;
	while(1){
		if(b[t]==a[t].size()) break;
		int k=b[t]+1,r=t;
		t=(int)(a[t][b[t]]-'a');
		b[r]=k;
	}
	cout<<(char)(('a'+t)+('A'-'a'))<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<list>
#include<string>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<ctime>
using namespace std;

typedef long long ll;

bool debug = false;
const int NIL = -1;
const int INF = 1000000000;
const int NUM = 100010;
clock_t START, END;

int V, E, r;

struct HeapNode {
	int d, u;
	bool operator < (const HeapNode& rhs) const {
		return d > rhs.d;
	}
};

struct Edge {
	int from, to, dist;
	Edge(int u, int v, int d) :from(u), to(v), dist(d) {}
};

struct Dijkstra {
	int n, m;
	vector<Edge> edges;
	vector<int> G[NUM];
	bool done[NUM];
	int d[NUM];
	int p[NUM];

	void init(int n) {
		this->n = n;
		for (int i = 0; i < n; i++)
			G[i].clear();
		edges.clear();
	}

	void AddEdge(int from, int to, int dist) {
		edges.push_back(Edge(from, to, dist));
		m = edges.size();
		G[from].push_back(m - 1);
	}

	void dijkstra(int s) {
		priority_queue<HeapNode> Q;
		for (int i = 0; i < V; i++)
			d[i] = INF;
		d[s] = 0;
		memset(done, 0, sizeof(done));
		Q.push({ 0, s });
		while (!Q.empty()) {
			HeapNode x = Q.top();
			Q.pop();
			int u = x.u;
			if (done[u])
				continue;
			done[u] = true;
			for (int i = 0; i < G[u].size(); i++) {
				Edge& e = edges[G[u][i]];
				if (d[e.to] > d[u] + e.dist) {
					d[e.to] = d[u] + e.dist;
					p[e.to] = G[u][i];
					Q.push({ d[e.to],e.to });
				}
			}
		}
	}
};

Dijkstra solve;

int main(void)
{
	if (debug) {
		START = clock();
		freopen("in29.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	}
	int s, t, d;
	cin >> V >> E >> r;
	solve.init(V);
	for (int i = 0; i < E; i++) {
		scanf("%d%d%d", &s, &t, &d);
		solve.AddEdge(s, t, d);
	}
	solve.dijkstra(r);
	for (int i = 0; i < V; i++) {
		if (solve.d[i] == INF)
			cout << "INF" << endl;
		else
			cout << solve.d[i] << endl;
	}
	if (debug) {
		END = clock();
		double endtime = (double)(END - START) / 1000;
		printf("total time = %lf s", endtime);
	}
	return 0;
}


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

#define ll long long

using namespace std;

const float eps = 0.001;
ll a, b, c;
char ch;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    cin >> a >> b >> ch >> c;
    ll temp = a * (b * 100 + c);
   // cerr << a << ' ' << b << ' ' << c << endl;
    temp /= 100;
    cout << temp << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    int nc = n;
    int sum = 0;
    while(n > 0){
        sum += n%10;
        n /= 10;
    }
    //cout << sum << endl;
    if(nc % sum == 0){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#coding: UTF-8
import math

p = list(map(float, input().split()))
# dis = math.sqrt(pow((abs(p[2]) - abs(p[0])), 2) + pow((abs(p[3]) - abs(p[1])), 2))
dis = math.sqrt(pow((p[2] - p[0]), 2) + pow((p[3]) - (p[1]), 2))

print(round(dis, 8))


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

int main(void){
	string s;
	cin >> s;
	bool f = true;
	for(int i = 0; i < s.size(); ++i){
		if((i%2==0&&s[i]=='L') || (i%2==1&&s[i]=='R')){
			f = false;
		}
	}
	if(f){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

const long long MOD = 1000000007;

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

void normalize(long long& A, long long &B) {
    long long g = gcd(A, B);

    if (g != 0) {
        A /= g;
        B /= g;
    }

    if (A < 0) {
        A = -A;
        B = -B;
    } else if (A == 0) {
        if (B < 0) {
            B = -B;
        }
    }
}

long long twoPowMod(long long n) {
    if (n == 0) {
        return 1;
    }

    if (n == 1) {
        return 2;
    }

    long long half = twoPowMod(n/2);
    long long ret = half*half % MOD;

    if (n%2) {
        ret *= 2;
        ret %= MOD;
    }

    return ret;
}

int main() {
    int N;
    cin >> N;
    map < pair<long long, long long>, long long> cnt;
    long long spec = 0;

    for (int i = 0; i < N; ++i) {
        long long A;
        long long B;
        cin >> A >> B;
        normalize(A, B);

        if (A != 0 || B != 0) {
            ++cnt[make_pair(A, B)];
        } else {
            ++spec;
        }
    }

    auto iter = cnt.begin();
    long long ans = 1;

    while (iter != cnt.end()) {
        long long A = iter->first.first;
        long long B = iter->first.second;
        long long OB = -A;
        long long OA = B;
        normalize(OA, OB);

        long long res = 0;

        if (OA != A || OB != B) { // avoid mirror
            res += twoPowMod(cnt[make_pair(A, B)]);
            res += twoPowMod(cnt[make_pair(OA, OB)]);
            --res; // empty set
        } else {
            res = cnt[make_pair(A, B)]+1;
        }

        res = (res + MOD)%MOD;
        cnt[make_pair(A, B)] = cnt[make_pair(OA, OB)] = 0;

        ans *= res;
        ans %= MOD;

        ++iter;
    }

    cout << ((ans+MOD-1) + spec)%MOD << endl;
    return 0;
}

Measured memory_bytes: 28380
#include <iostream>
#include <vector>
#include <string>
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <deque>
#include <tuple>
#include <unordered_set>
#include <array>
#include <string>

using namespace std;
#define ll long long
#define ar array
const int mxN=3000;
int r, c, k;
ll grid[mxN][mxN];
ll dp[mxN+1][mxN+1][4];
ll h[mxN+1][mxN+1];

int main() {
	cin >> r >> c >> k;
	memset(grid, 0, sizeof(grid));
	memset(h, 0, sizeof(h));
	for (int i=0; i<k; i++) {
		int y,x;
		ll v;
		cin >> y >> x >> v, y--, x--;
		grid[y][x]=v;
	}
	for (int i=1; i<=r; i++) {
		for (int j=1; j<=c; j++) {
			for (int k=0; k<4; k++) {
				dp[i][j][k]=max(h[i-1][j], dp[i][j-1][k]);
				if (k<3) dp[i][j][k]=max(dp[i][j][k], max(h[i-1][j], dp[i][j-1][k+1])+grid[i-1][j-1]);
				h[i][j]=max(dp[i][j][k], h[i][j]);
			}
		}
	}
	cout << h[r][c];
    return 0;
}

Measured memory_bytes: 425512
//動的計画法

#include <cstdio>
#include <algorithm>
using namespace std;

int dp(int, int);

int N,W;
int w[1001];
int v[1001];

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

    for(int i = 0; i < N; i++){
        scanf("%d %d",&v[i],&w[i]);
    }

    int dp[N + 1][W + 1];
    for(int i = 0; i < W + 1; i++){
        dp[0][i] = 0;
    }

    for(int i = 1;i <= N;i++){
        for(int j = 0;j <= W;j++){
            if(j - w[i - 1] < 0){
                dp[i][j] = dp[i - 1][j];
            }else{
                dp[i][j] = max(dp[i - 1][j],dp[i][j - w[i - 1]] + v[i - 1]);
            }
        }
    }

    printf("%d\n",dp[N][W]);

    return 0;
}


Measured memory_bytes: 6676
import java.util.Scanner;

public class Main {

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

	    while (sc.hasNextLine()){

		    String i  = sc.nextLine();

		    if (i.equals("0")){
		    	break;
		    } else {

		    	String[] array = new String[i.length()];

			    int num = 0;

		    	for (int k = 0; k < i.length(); k++){
		    		array[k] = i.substring(k, k+1);
		    		num += Integer.valueOf(array[k]);
		    	}

		    	System.out.println(num);
		    }

	    }


	}

}




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

const int MAX = 100000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main(){
  COMinit();
  int n,k;
  cin>>n>>k;
  int a[100005];
  rep(i,n) cin>>a[i];
  sort(a,a+n);
  ll ans=0;
  rep(i,n){
    if(i>=k-1){
      ans=(ans+a[i]*COM(i,k-1))%MOD;
    }
    if(n-i-1>=k-1){
      ans=(ans-a[i]*COM(n-i-1,k-1))%MOD;
    }
  }
  if(ans<0) ans+=MOD;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 2944
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int a,b;
		a=sc.nextInt();
		b=sc.nextInt();
		int s=a*b-a-b+1;
		System.out.println(s);
	}
}

Measured memory_bytes: 21332
#!usr/bin/env python3

def string_three_numbers_spliter():
    a, b, c = [int(i) for i in input().split()]
    return a, b, c


def main():
    a, b, c = string_three_numbers_spliter()
    lst = [a, b, c]
    lst.sort()
    print(' '.join(str(i) for i in lst))


if __name__ == '__main__':
    main()

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

ll MOD = 998244353;

int main()
{

    int N;
    cin >> N;
    string S;
    cin >> S;
    if(N % 2 != 0){
        cout << "No" << endl;
        return 0;
    }
    for (int i = 0; i < N / 2; i++)
    {
        if(S[i] != S[i + N / 2]){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline()[:-1]
n=int(input())
data=[tuple(map(int,input().split())) for i in range(n)]
data.sort(key=lambda tup:tup[1])
time=0
for offer in data:
	time+=offer[0]
	if time > offer[1]:
		print('No')
		break
else:print('Yes')


Measured memory_bytes: 76764
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i,m) for(long long i=0; i<m; ++i)
#define FOR(i,n,m) for(long long i=n; i<m; ++i)
#define DUMP(n,a) for(long long dump=0; dump<n; ++dump) { cout<<a[dump]; if(dump!=n-1) cout<<" "; else cout<<endl; }
#define ALL(v) v.begin(),v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	map<ll,ll> d;
	REP(i,n) {
		ll a;
		cin>>a;
		if(d.count(a)!=0) ++d[a];
		else d[a]=1;
	}
	ll m;
	cin>>m;
	vector<ll> t(m);
	bool f=true;
	REP(i,m) {
		ll a;
		cin>>a;
		if(d.count(a)==0) {
			f=false;
			break;
		}
		if(d[a]==0) {
			f=false;
			break;
		}
		else d[a]--;
	}
	if(f) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 7;
typedef long long ll;
int n, k;
int d[maxn];
int main()
{
    scanf("%d%d", &n, &k);
    for (int i = 1, x; i <= k; i++) {
        scanf("%d", &x);
        for (int j = 1, t; j <= x; j++) {
            scanf("%d", &t);
            d[t]++;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; i++)
        if(d[i] == 0) ans++;
    printf("%d\n", ans);
}


Measured memory_bytes: 3760
from collections import Counter
import sys
def input():
	return sys.stdin.readline()[:-1]
n = int(input())
c = Counter([input() for _ in range(n)])

print("AC x " + str(c["AC"]))
print("WA x " + str(c["WA"]))
print("TLE x " + str(c["TLE"]))
print("RE x " + str(c["RE"]))

Measured memory_bytes: 74504
h, w = (int(i) for i in input().split())
list = []

for i in range(h):
	list.append([])
	row = input()
	for j in range(w):
		element = row[j]
		list[i].append(element == '#')

def all_check(h, w, list):
	for i in range(h):
		for j in range(w):
			if not check(i, j, h, w, list):
				return False

	return True

def check(i, j, h, w,list):
	if list[i][j]:
		return subcheck(i, j, h, w, list)
	else:
		return True

def subcheck(i, j, h, w, list):
	if i > 0 and list[i-1][j]:
		return True
	if i < h-1 and list[i+1][j]:
		return True
	if j > 0 and list[i][j-1]:
		return True
	if j < w-1 and list[i][j+1]:
		return True

if all_check(h, w, list):
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    private static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {

        int n = sc.nextInt();
        int x = sc.nextInt();

        int[] l = new int[n];
        for (int i=0; i < n; i++) {
            l[i] = sc.nextInt();
        }

        int current = 0;
        int ans = 1;
        for (int al : l) {
            current += al;
            if (current <= x) {
                ans++;
            } else {
                break;
            }
        }

        System.out.println(ans);
    }

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (((a)%mod) * ((b)%mod)) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;
const int mod = 1e9+7;
// int sum = accumulate(a, a+n, 0LL);
// int mx = max_element(a, a+n);
// int mn = min_element(a, a+n);
// int cnt = count(a, a+n, k);

int c1,c5,c10,c50,c100,c500;

signed main()
{
    cin >> c1>>c5>>c10>>c50>>c100>>c500;

    if((c1+c5*5+c10*10+c50*50+c100*100+c500*500)>=1000)cout << 1 << endl;
    else cout << 0 << endl;

    return 0;
}


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

using namespace std;

int main() {
	int alp[26] = { 0 };
	int flag = 0;
	string output[2] = { "yes","no" };

	string S;
	cin >> S;

	for (int i = 0; i < (int)S.size(); i++) {
		if (alp[S[i] - 'a'] == 1) {
			flag = 1;
			break;
		}
		alp[S[i] - 'a']++;
	}
	cout << output[flag] << endl;
}

Measured memory_bytes: 256
from itertools import permutations

N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
ans = 0

# 全組み合わせの取得
set_ = set()
for n in range(1,N+1):
  set_.add(n)
perm = list(permutations(set_))

# 該当するインデックスを取得
idx_p = 0
idx_q = 0
idx = 0
for p in perm:
  if p == P:
    idx_p = idx
  if p == Q:
    idx_q = idx
  idx += 1
  
ans = abs(idx_p-idx_q)
print(ans)

Measured memory_bytes: 8052
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////

ll H, W, N, sr, sc;


bool ch(vector<ll> a, vector<ll> b , ll L, ll s) {

	
	vector<ll> c(2 * N + 1);

	repn(i, N) {
		c[2 * i - 1] = b[N + 1 - i];
		c[2 * i] = a[N + 1 - i];
	}

	ll le = 1;
	ll ri = L;

	for (ll i = 2; i <= 2 * N; i++) {
		if (i % 2 == 0) {
			if (c[i] == 1) { ri--; }
			if (c[i] == -1) { le++; }
		}

		if (i % 2 == 1) {
			if (c[i] == 1) { le = max(le - 1, 1); }
			if (c[i] == -1) { ri = min(ri + 1, L); }
		}


		if (le > ri) { return false; }
	}

	if (s<le || s>ri) { return false; }
	return true;

}

int main() {

	cin >> H >> W >> N >> sr >> sc;
	string S, T;
	cin >> S >> T;

	vector<ll> a(N + 1, 0), b(N + 1, 0), c(N + 1, 0), d(N + 1, 0);
	repn(i, N) {
		if (S[i - 1] == 'D') { a[i] = 1; }
		if (S[i - 1] == 'U') { a[i] = -1; }
		if (S[i - 1] == 'R') { c[i] = 1; }
		if (S[i - 1] == 'L') { c[i] = -1; }
		if (T[i - 1] == 'D') { b[i] = 1; }
		if (T[i - 1] == 'U') { b[i] = -1; }
		if (T[i - 1] == 'R') { d[i] = 1; }
		if (T[i - 1] == 'L') { d[i] = -1; }
	}

	if (ch(a, b, H, sr) && ch(c, d, W, sc)) { cout << "YES"; }
	else { cout << "NO"; }

	
	
	system("PAUSE");
}


Measured memory_bytes: 16208
#!/usr/bin/env python3

import sys

s = input()

a1 = "dream"
a2 = "dreamer"
a3 = "erase"
a4 = "eraser"

while True:
    if len(s) < 5:
        print("NO")
        sys.exit(0)
    elif len(s) == 5:
        if s in ["dream", "erase"]:
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    elif len(s) == 6:
        if s == "eraser":
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    elif len(s) == 7:
        if s == "dreamer":
            print("YES")
        else:
            print("NO")
        sys.exit(0)
    else:
        if s[:8] in ["dreamerd", "dreamere"]:
            s = s[7:]
        elif s[:6] in ["dreamd", "dreame", "erasee", "erased"]:
            s = s[5:]
        elif s[:7] in ["eraserd", "erasere"]:
            s = s[6:]
        else:
            print("NO")
            sys.exit(0)



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

string S;

signed main()
{
	cin >> S;
	if (S.find("N") != string::npos && S.find("S") == string::npos) {
		cout << "No" << endl;
	} else if (S.find("S") != string::npos && S.find("N") == string::npos) {
		cout << "No" << endl;
	} else if (S.find("W") != string::npos && S.find("E") == string::npos) {
		cout << "No" << endl;
	} else if (S.find("E") != string::npos && S.find("W") == string::npos) {
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cout << #x << " = " << x << '\n'

using ll = long long;
using namespace std;

const int N = 1e5 + 1;
int weight[101], value[101];
ll dp[2][N];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
#ifdef LOCAL_DEFINE
	freopen("in.txt", "r", stdin);
#endif

	int n, w;
	cin >> n >> w;

	int sum_value = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> weight[i] >> value[i];
		sum_value += value[i];
	}

	for (int i = 1; i <= sum_value; ++i)
		dp[1][i] = 1e17;

	for (int i = 0; i < n; ++i)
	{
		memcpy(dp[0], dp[1], sizeof(ll) * (sum_value + 1));
		
		for (int j = 1; j <= sum_value; ++j)
		{
			dp[1][j] = dp[0][j];
			if (j - value[i] >= 0) {
				dp[1][j] = min(dp[1][j], dp[0][j - value[i]] + weight[i]);
			}
		}
	}

	int ans = 0;
	for (int i = 0; i <= sum_value; ++i)
	{
		if (dp[1][i] <= w)
			ans = i;
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FF fflush(stdout)
#define debug printf("Hello\n")
//why is my rating plummeting
int n, m, k, x, y, sum, cnt, ans;
map<int, int>f;
int main () {
	scanf("%d", &n);
	vi v, s;
	for (int i=1; i<=n; i++) {
		scanf("%d", &x);
		f[x]++;
		if (f[x]==2) {
			v.pb(x);
		}
		if (f[x]==4) {
			s.pb(x);
		}
	}
	sort(all(v));
	reverse(all(v));
	sort(all(s));
	reverse(all(s));
	ll ans=0;
	if (s.size()>0) {
		ans=1LL*s[0]*s[0];
	}
	if (v.size()>1 ) {
		ans=max(ans, 1LL*v[0]*v[1]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
#define ll long long
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
using namespace std;

int main()
{
    fast_io
    ll r,d,x,i,j,t=10;
    cin>>r>>d>>x;
    while(t--)
    {
        x=r*x-d;

    cout<<x<<endl;
    }



    return 0;
}





Measured memory_bytes: 3540
#include <iostream>

int main()
{
	int a;
	float d, b, c, sum = 0;

	std::cin >> a;
	
	for (int i = 0; i < a; i++)
	{
		std::cin >> d;
		b = 1 / d;
		sum = sum + b;
	
	}
	c = 1 / sum;
	
	std::cout << c << std::endl;
	return 0;
}


Measured memory_bytes: 256
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

console.log(main());
function main(){
  var a = o.a();
  var b = o.a();
  var c = o.a();
  var d = Math.max(a,b,c);
  var e = Math.min(a,b,c);
  var f = a+b+c-d-e;
  return d*10+e+f;
}

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

int main() {
  string s;
  cin >> s;
  if(s.at(0)=='0'||s.at(0)=='1'){
    cout << "Heisei" <<endl;
  }
  else if(s.at(0)=='2'){
    if(s.at(2)=='0'){
      cout << "Heisei" <<endl;
    }
    else if(s.at(3)!='9'){
      cout << "Heisei" <<endl;
    }
    else if(s.at(5)=='0'){
      if(s.at(6)=='1'||s.at(6)=='2'||s.at(6)=='3'||s.at(6)=='4'){
        cout << "Heisei" <<endl;
      }
      else {
        cout << "TBD" <<endl;
      }
    }
    else {
      cout << "TBD" <<endl;
    }
  }
  else {
    cout << "TBD" <<endl;
  }
}
       

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000)
 
l,r = map(int,input().split())

mod = 673

if r-l >= mod-1:
    print(0)
    exit()

MOD = 2019

l_s = l % MOD
r_s = r % MOD


ans = 2019

if r_s > l_s:
    for i in range(abs(l_s - r_s)+1):
        for j in range(1,abs(l_s - r_s)+2):
            if l_s+i+j > r_s:
                break
            tmp = (l_s+i)*(l_s+i+j) % MOD
            if ans > tmp:
                #print(l_s+i,l_s+i+j)
                ans = tmp
    print(ans)
    exit()
else:
    print(0)
    exit()

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

using namespace std;
using ll = long long;

int main()
{
    ll k,sum=0,a; 
    cin>>k;
    for(ll i=1;i<=k;i++)
    {
      for(ll j=1;j<=k;j++)
      {
        for(ll l=1;l<=k;l++)
          {
            a=__gcd(i,j);
            sum+=__gcd(a,l);
          }
      }
    }
    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 3592
#include"bits/stdc++.h"
#include<atcoder/modint.hpp>
#include<atcoder/lazysegtree.hpp>
using namespace atcoder;
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pll = pair<ll, ll>;
using tp3 = tuple<ll, ll, ll>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============
using mint = modint998244353;

struct S {
    mint val;
    int size;
};

S op(S a, S b) {
    return S{ a.val + b.val, a.size + b.size };
}

S e() {
    return S{ 0,0 };
}

struct F {
    mint b, c;
};

S mapping(F f, S x) {
    return {
        f.b * x.val + f.c * x.size,
        x.size
    };
};

F composition(F f, F g) {
    return {
        f.b*g.b,
        g.c * f.b + f.c
    };
}

F id() {
    return { 1,0 };
}

int main()
{
    int N, Q;
    cin >> N >> Q;
    vector<S> a(N);
    rep(i, N) {
        int tmp;
        cin >> tmp;
        a[i] = { tmp,1 };
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> seg(a);

    rep(_, Q) {
        int com;
        cin >> com;
        if (com == 0) {
            int l, r, b, c;
            cin >> l >> r >> b >> c;
            seg.apply(l, r, { b,c });
        }
        else {
            int l, r;
            cin >> l >> r;
            cout << seg.prod(l, r).val.val() << endl;
        }
    }
    return 0;
}


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

int main() {
	double q;
	while (cin >> q, q != -1.) {
		double x = q / 2;
		while (abs(x*x*x - q) >= EPS*q) {
			x -= (x*x*x - q) / (3 * x*x);
		}
		printf("%6lf\n", x);
	}
}

Measured memory_bytes: 3124
// 2014/07/24 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int y;
		cin >> y;

		double g_max = 0.0;
		int b_max = 0;

		for(int i=0; i<n; i++){
			int b, r, t;
			cin >> b >> r >> t;

			double g;
			if(t==1){
				g = 1.0+(double)y*(double)r/100.0;
			}
			else{
				g = 1.0;
				for(int j=0; j<y; j++){
					g *= (1.0+(double)r/100.0);
				}
			}

			if(g>g_max){
				g_max = g;
				b_max = b;
			}
		}

		cout << b_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>

auto& in = std::cin;
auto& out = std::cout;

int32_t N;
int32_t ARR[300000];
int64_t MAX[112345];//[N-1,2N][0,N+1]
int64_t MIN[112345];//[N-1,2N]
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> N;
	if (!(1 <= N && N <= 1'000'000'000)) {
		throw 0;
	}
	for (size_t i = 0; i < 3 * N; i++)
	{
		in >> ARR[i];
	}
	if (std::any_of(ARR, ARR + 3 * N, [](int32_t v) {return !(1 <= v && v <= 1'000'000'000); })) {
		throw 0;
	}
	//std::sort(ARR, ARR + N);
	//std::sort(ARR+2*N-1, ARR + 3*N);

	//前を最大化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(-ARR[i]);
			sum += ARR[i];
		}
		MAX[0] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(-ARR[N + i]);
			sum += ARR[N + i];
			sum += que.top(); que.pop();
			MAX[i + 1] = sum;
		}
	}
	//後ろを最小化
	{
		int64_t sum = 0;
		std::priority_queue<int32_t> que;
		for (int32_t i = 0; i < N; i++)
		{
			que.push(ARR[3 * N - 1 - i]);
			sum += ARR[3 * N - 1 - i];
		}
		MIN[N + 1] = sum;
		//[N,2N]を処理
		for (int32_t i = 0; i <= N; i++)
		{
			que.push(ARR[2 * N - 1 - i]);
			sum += ARR[2 * N - 1 - i];
			sum -= que.top(); que.pop();
			MIN[N - i] = sum;
		}
	}
	//[N-1,2N]を処理
	int64_t max_value = (-9223372036854775807);
	for (int32_t i = 0; i <= N; i++)
	{
		max_value = std::max(max_value, MAX[i] - MIN[i + 1]);
	}
	std::cout << max_value << std::endl;
	return 0;
}
#endif

Measured memory_bytes: 3952
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <cstdio>
#include <cmath>

using namespace std;
using ll = long long;
const int INF = 1e9;

int n;
int ans = INF;
vector<int> abc, l;
vector<pair<int, int>> now(4, pair<int, int>(0, 0));

void dfs(int depth) {
    if (depth == n) {
        int tmp = 0;
        for (int i = 0; i < 3; ++i) {
            if (now[i].second == 0) return;
            tmp += abs(abc[i] - now[i].first) + 10 * (now[i].second - 1);
        }
        ans = min(ans, tmp);
    } else {
        for (int i = 0; i < 4; ++i) {
            now[i].first += l[depth];
            now[i].second += 1;
            dfs(depth + 1);
            now[i].first -= l[depth];
            now[i].second -= 1;
        }
    }
}

int main() {
    cin >> n;
    for (int i = 0; i < 3; ++i) {
        int inp;
        cin >> inp;
        abc.push_back(inp);
    }

    for (int i = 0; i < n; ++i) {
        int inp;
        cin >> inp;
        l.push_back(inp);
    }
    dfs(0);
    cout << ans << endl;
}


Measured memory_bytes: 256
s=input()
t=input()

n=len(s)
n2=len(t)
sum=0
if n2-n==1:
    for i in range(n):
        if s[i]==t[i]:
            sum+=1
    if sum==n:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 9116
n = int(input())
hlist = [int(x) for x in input().split()]

def bunkatsu(list):
    returnlists = [[]]
    i = 0
    for num in list:
        if num != 0:
            returnlists[i].append(num)
        else:
            i = i + 1
            returnlists.append([])
    return returnlists

def mizuyari(list):
    if list == []:
        return 0
    else:
        i = 0
        while (list.count(0) == 0):
            i = i + 1
            list = [x - 1 for x in list]
        retlists = bunkatsu(list)
        for l in retlists:
            i += mizuyari(l)
        return i
print(mizuyari(hlist))

Measured memory_bytes: 3188
class ShopInformation(val unitPrice: Long, val limit: Long)

fun main(args: Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val shops = Array(n) { readLine()!!.split(" ").map { it.toLong() }.let { ShopInformation(it.first(), it.last()) } }.sortedBy { it.unitPrice }
    var count = 0L
    var answer = 0L

    for (i in 0 until n) {
        answer += Math.min(shops[i].limit, m - count) * shops[i].unitPrice
        if (shops[i].limit >= m - count) break
        count += shops[i].limit
    }
    println(answer)
}


Measured memory_bytes: 77556
#include<bits/stdc++.h>
#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define per(i,n,j) for(int i=(n)-1;i>=(j);i--)
using ll=long long;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF=1LL<<60;

int n;
unordered_map<ll,int> dict;

int main(){
    cin>>n;
    vector<ll> a(n);
    rep(i,0,n){
        cin>>a[i];
        dict[a[i]]++;
    }
    int ans=0;
    rep(i,0,n){
        if(dict[a[i]]%2==1){
        ans++;
        dict[a[i]]=0;
        }
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 8016
using System;
using System.Collections.Generic;
using System.Linq;

public class Problem_D
{
  public static void Main()
  {
    var N = int.Parse(Console.ReadLine());
    var primes = new List<int>();

    for (var i = 2; i < 55555; i++)
      if (isPrime(i)) primes.Add(i);

    var ans = primes.FindAll(p => p % 5 == 1).Take(N).ToArray();
    Console.WriteLine($"{string.Join(" ", ans)}");
  }

  private static bool isPrime(int n)
  {
    for (var i = 2; i * i <= n; i++)
    {
      if (n % i == 0) return false;
    }
    return true;
  }
}


Measured memory_bytes: 13308
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 200003

int n, m, lb;
int used[N][4];
int t[4] = {'A', 'A', 'B', 'B'};
string s;

vector<int> g[N];

int dfs(int v, int k) {
  if(used[v][k]) {
    return used[v][k] == lb;
  }
  used[v][k] = lb;
  int k1 = (k + 1) % 4;
  repe(w, g[v]) {
    if(s[w] == t[k1] && dfs(w, k1)) {
      return 1;
    }
  }
  used[v][k] = -1;
  return 0;
}

int main() {
  cin >> n >> m >> s;
  rep(i, m) {
    int a, b; cin >> a >> b; --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  bool ok = false;
  rep(i, n) {
    lb = i+1;
    if(s[i] == 'A' ? dfs(i, 0) : dfs(i, 2)) {
      ok = true;
      break;
    }
  }
  cout << (ok ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 22660
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
		while (true) {
			String line = sc.readLine();
			String[] lineAry = line.split(" ");
			int n = Integer.parseInt(lineAry[0]);
			int m = Integer.parseInt(lineAry[1]);
			int a = Integer.parseInt(lineAry[2]);
			List<CrossBar> crbar = new ArrayList<>();
			if (n == 0 && m == 0 && a == 0) {
				return;
			}
			for (int i = 0; i < m; i++) {
				line = sc.readLine();
				lineAry = line.split(" ");
				crbar.add(new CrossBar(Integer.parseInt(lineAry[0]), Integer.parseInt(lineAry[1]),
						Integer.parseInt(lineAry[2])));
			}
			
			MyPoint mypoint = new MyPoint(a, 1002);

			while (mypoint.y > 0) {
				mypoint.y--;
				for (int k = 0; k < m; k++) {
					if (crbar.get(k).y == mypoint.y && crbar.get(k).x1 == mypoint.x) {
						mypoint.setPoint(crbar.get(k).x2, mypoint.y);
						break;
					}
					if (crbar.get(k).y == mypoint.y && crbar.get(k).x2 == mypoint.x) {
						mypoint.setPoint(crbar.get(k).x1, mypoint.y);
						break;
					}
				}
			}
			System.out.println(mypoint.x);
		}
	}

	static class MyPoint {

		private int x = 0;
		private int y = 0;

		public MyPoint(int x_val, int y_val) {
			x = x_val;
			y = y_val;
		}

		public void setPoint(int x_val, int y_val) {
			x = x_val;
			y = y_val;
		}

	}

	static class CrossBar implements Comparable<Object> {

		private int x1 = 0;
		private int x2 = 0;
		private int y = 0;

		public CrossBar(int h, int p, int q) {
			y = h;
			x1 = p;
			x2 = q;
		}

		public int compareTo(Object obj) {
			return Integer.toString(((CrossBar) obj).y).compareTo(Integer.toString(this.y));
		}
	}

}

Measured memory_bytes: 47540
N = int(input())
a = list(map(int,input().split()))
s,t = 0, 0
for e in a:
    if e%4 == 0:
        s += 1
    elif e%2 == 0:
        t += 1

if t == 0:
    if N//2 <= s:
        print("Yes")
    else:
        print("No")
else:
    if (1+N-t)//2 <= s:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 62576
from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
d = defaultdict(int)
for i in A:
    d[i] += 1
ans = 0
for i in range(10 ** 5):
    ans = max(ans, d[i-1] + d[i] + d[i+1])
print(ans)

Measured memory_bytes: 20044
#include<iostream>
using namespace std;
int h,w;
string a;
string s[100];
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++)cin>>s[i];
    for(int i=0;i<w+2;i++)a+='#';
    for(int i=0;i<h+2;i++){
        if(i==0 || i==h+1){
            cout<<a<<endl;
            continue;
        }
        cout<<'#'<<s[i-1]<<'#'<<endl;
    }

}

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

typedef long long ll;

using namespace std;

int main()
{
    ll n, k, x, y;
    cin >> n >> k >> x >> y;

    ll sum(0); 

    for (ll i=1; i<=n; i++)
    {
        sum += (i > k) ? y : x;
    }

    cout << sum << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

class TaskA
{
public:
	ll a, b, k;
	void process()
	{
		cin >> k >> a >>b;
		for(int i=a; i<=b; i++)
		{
			if(i%k == 0)
			{
				cout << "OK\n";
				return ;
			}
		}

		cout << "NG\n";
	}
};


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

	TaskA solver;
	solver.process();

	return 0;
}


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

int main() {
  string S;
  cin >> S;
  bool ans=true;
  if(S[0]!='A')ans=false;
  else{
    int c=0;
    for(int i=2;i<S.length()-1;i++){
      if(S[i]=='C')c+=1;
      else if((S[i]>= 'A') && (S[i]<='Z')){
        ans=false;
      }
    }
    if(c!=1)ans=false;
  }
  if((S[1]>= 'A') && (S[1]<='Z'))ans=false;
  if((S[S.length()-1]>= 'A') && (S[S.length()-1]<='Z'))ans=false;
  if(ans)cout << "AC";
  else cout << "WA";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <map>
#include <set>
#include <vector>

using namespace std;

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

	map<int, set<vector<int>>> precompute;

	for (int i = 1; i <= 100; i++)
	{
		for (int j = 1; j <= 100; j++)
		{
			for (int k = 1; k <= 100; k++)
			{
				int check_value = i * i + j * j + k * k + i * j + j * k + i * k;
				precompute[check_value].insert(vector<int>({ i, j, k }));
			}
		}
	}

	int N;
	cin >> N;

	for (int i = 1; i <= N; i++)
	{
		cout << precompute[i].size() << "\n";
	}

	return 0;
}


Measured memory_bytes: 101032
t = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for i in range(t):
    s = str(input())
    if s == 'AC':
        c0 += 1
    elif s == 'WA':
        c1 += 1
    elif s == 'TLE':
        c2 += 1
    elif s == 'RE':
        c3 += 1
print('AC x ' + str(c0))
print('WA x ' + str(c1))
print('TLE x ' + str(c2))
print('RE x ' + str(c3))

Measured memory_bytes: 9096
// Why am I so dumb? :c
#include<bits/stdc++.h>

#define pb push_back
#define mp make_pair

#define all(x) (x).begin(), (x).end()

#define fi first
#define se second

using namespace std;

typedef long long ll;

const int MAXN = (int)1e5 + 5;

vector<int> adj[MAXN];

bool u[MAXN];

int n, m;

void solve() {
    scanf("%d %d", &n, &m);

    for (int i = 1, u, v; i <= m; ++i) {
        scanf("%d %d", &u, &v);
        adj[u].pb(v);
        adj[v].pb(u);
    }

    deque<int> q;
    u[1] = 1;
    q.pb(1);

    for (int i = 1; i <= n; ++i) {
        {
            int v = q.front();

            for (int to : adj[v]) {
                if (!u[to]) {
                    q.push_front(to);
                    u[to] = 1;
                    break;
                }
            }
        }

        {
            int v = q.back();

            for (int to : adj[v]) {
                if (!u[to]) {
                    q.pb(to);
                    u[to] = 1;
                    break;
                }
            }
        }
    }

    printf("%d\n", q.size());

    while (!q.empty()) {
        printf("%d ", q.front());
        q.pop_front();
    }
}

int main() {
    int tt = 1;

    while (tt--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 6740
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int[] p = new int[n];
        for (int i=0; i<n; i++) {
            p[i] = sc.nextInt();
        }
        Arrays.sort(p);
        int sum = 0;
        for (int i=0; i<k; i++) {
            sum += p[i];
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 30296
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int H,W;
  cin>>H>>W;
  if(H%3 == 0 || W%3 == 0)
  {
    cout<<0<<endl;
    return;
  }
  int ANS = INF;
  for (int h = 1; h < H; h++)
  {
    int S1 = h*W;
    int S2 = (H-h)*(W/2);
    int S3 = (H-h)*(W/2 + W%2);
    chmin(ANS,max(S1,max(S2,S3)) - min(S1,min(S2,S3)));
  }

  swap(H,W);
  for (int h = 1; h < H; h++)
  {
    int S1 = h*W;
    int S2 = (H-h)*(W/2);
    int S3 = (H-h)*(W/2 + W%2);
    chmin(ANS,max(S1,max(S2,S3)) - min(S1,min(S2,S3)));
  }

  if(H > W) swap(W,H);

  {
    int S1 = W/3*H;
    int S2 = (W/3 + (int)(W%3 == 2))*H;
    int S3 = (W/3 + (int)(W%3 > 0))*H;
    chmin(ANS,max(S1,max(S2,S3)) - min(S1,min(S2,S3)));
  }
  cout<<ANS<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import math 

def main():
   n= int(input())
   str = input()
   ans = 0
   last =str[0]
   for i in range(n):
       if( str[i] != last):
           ans +=1
           if(i+1 >= n): break;
           i += 1
           last = str[i]
       else:
           last = str[i] 
   print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5860
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N] = [long(input_raw[0])]
    input_raw = read_func().strip().split()
    [A, B] = [long(input_raw[0]), long(input_raw[1])]
    input_raw = read_func().strip().split()
    P = []
    for i in range(N):
        P.append(int(input_raw[i]))

    P.sort()

    A_Count = 0
    B_Count = 0
    C_Count = 0
    for i in range(N):
        if P[i] <= A:
            A_Count += 1
        elif A < P[i] and P[i] <= B:
            B_Count += 1
        elif B < P[i]:
            C_Count += 1
    print min(A_Count, B_Count, C_Count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3056
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;

 
int main (){
    int n; cin>>n; int arr[n];
    for(int i=0;i<n;i++){
        cin>>arr[i];
    }

    int count =0; int i=1; 
     do{
        int temp=arr[i-1];
        i=temp;
        count+=1;

     }while(arr[i-1]!=2 && count <n);
 if (arr[0]==2) {cout<<1;}
else if(count+2>n){cout<<-1;}
  
    else {cout<<count+1;}
      

     return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  vi p(n);
  rep(i, n) cin >> p[i];

  vi a(n), b(n);
  rep(i, n){
    a[i] = b[n-i-1] = 40000*i+1;
  }

  rep(i, n) a[--p[i]] += i;

  rep(i, n){
    cout << a[i] << " \n"[i==n-1];
  }

  rep(i, n){
    cout << b[i] << " \n"[i==n-1];
  }

  return 0;
}


Measured memory_bytes: 896