akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
const int maxn =2e5+10;
const int mod=1e9+7;

ll power(ll base,ll n,ll p)
{
    ll r=1;
    while(n)
    {
        if(n%2) r=r*base%p;
        base=base*base%p;
        n/=2;
    }
    return r;
}

int cal(ll x)
{
    int cnt=0;
    for(int i=0;i<=60;i++)
        if((x>>i)&1)
        cnt++;
    return cnt;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    string s;
    cin>>s;
    int k=0;
    int cnt=0;
    for(auto &v:s)
    {
        int x=v-'0';
        if(x)
            cnt++;
    }
    ll sum1=0;
    ll sum22=0;
    for(int i=n-1;i>=0;i--)
    {
        int x=s[i]-'0';
        if(x)
        sum1+=power(2,k,cnt+1);
        k++;
    }
    if(cnt-1!=0)
    {
        k=0;
        for(int i=n-1;i>=0;i--)
        {
            int x=s[i]-'0';
            if(x)
            sum22+=power(2,k,cnt-1);
            k++;
        }
    }
    k=0;
    vector<int>ans;
    for(int i=n-1;i>=0;i--)
    {
        int x=s[i]-'0';
        if(x)
        {
            if(cnt==1)
            {
                ans.pb(0);
            }
            else
            {
                ll temp=sum22;
                temp-=power(2,k,cnt-1);
                temp=(temp+cnt-1)%(cnt-1);
                int num=1;
                while(temp)
                {
                    temp%=cal(temp);
                    num++;
                }
                ans.pb(num);
            }
        }
        else
        {
            ll temp=sum1+power(2,k,cnt+1);
            temp%=cnt+1;
            int num=1;
            while(temp)
            {
                temp%=cal(temp);
                num++;
            }
            ans.pb(num);
        }
        k++;
    }
    reverse(ans.begin(),ans.end());
    for(auto &v:ans)
        cout<<v<<'\n';





}


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

using namespace std;

#define MOD 1000000007
#define N 1003
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

int grid[N][N];
ll dp[N][N];

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int n, m, i, j;
    cin>>n>>m;
    char ch;
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            cin>>ch;
            if(ch == '#') grid[i][j] = 1;
        }
    }
    dp[1][1] = (grid[1][1] == 0);
    for(i=1; i<=n; i++){
        for(j=1; j<=m; j++){
            if(grid[i-1][j] == 0){
                dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD;
            }
            if(grid[i][j-1] == 0){
                dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
            }
        }
    }
    cout<<dp[n][m];
    return 0;
}

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

int main() {
  int h1, h2, m1, m2, time;
  cin >> h1 >> m1 >> h2 >> m2 >> time;
  cout << (h2 * 60 + m2 - h1 * 60 - m1 - time) << endl;
  
}

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

int main(){
	int N;
	do {
		cin >> N;
	} while (N < 0 || N > 1000000);

	long m = 0;

	for (int i = 1; i <= N; i++) {
		if (i % 3 != 0 && i % 5 != 0) {
			m += i;
		}
	}
	
	cout << m << endl;
}

Measured memory_bytes: 3652
import math
import itertools

n = int(input())
x = [0]*n
y = [0]*n
for i in range(n):
    x[i], y[i] = map(int, input().split())

N = math.factorial(n)
Sum = 0
for ls in itertools.permutations(range(n)):
    x_tmp = x[ls[0]]
    y_tmp = y[ls[0]]
    for j in range(1,n):
        dist = (x_tmp - x[ls[j]])**2 + (y_tmp - y[ls[j]])**2
        x_tmp = x[ls[j]]
        y_tmp = y[ls[j]]
        Sum += math.sqrt(dist)
print(Sum/N)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String A = scan.next();
        String B = scan.next();
        String C = scan.next();
        char a_l = A.toCharArray()[A.length()-1];
        char b_f = B.toCharArray()[0];
        char b_l = B.toCharArray()[B.length()-1];
        char c_f = C.toCharArray()[0];
        boolean answer = false;
        if (a_l == b_f && b_l == c_f) {
            answer = true;
        }
        System.out.println(answer ? "YES" : "NO");
    }
}


Measured memory_bytes: 23252
import java.util.*;

public class Main {
    static int INF = 1001001009;
    
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] array = new int[n];
        for (int i = 0; i < n; i++) {
            array[i] = sc.nextInt();
        }
        
        // ans: 最長増加部分列(広義) O(NlogN)
        // process:
        // 0.配列について次の1.2.の操作をN個分左から行う O(N)
        // 1.次の場所を二分探索で探す (O(logN))
        //  - 左からi番目の値(val)以上の初めての場所
        // 2.その場所をvalに書き換える
        // ex. 
        // {1,4,7}である時、3が来たら{1,3,7}とする
        // 何故か？ <- i番目の値はできるだけ小さい方がi+1番目以降で取れる値が増えるから。
        
        // 今回は"減少"なので符号を反転させる
        for (int i = 0; i < n; i++) {
            array[i] *= -1;
        }
        
        int[] lis = new int[n];
        Arrays.fill(lis, INF);
        
        for (int i = 0; i < n; i++) {
            int val = array[i];
            
            int index = upperBound(lis, val);
            lis[index] = val;
            // System.out.println(Arrays.toString(lis));
        }
        
        int length = lowerBound(lis, INF);
        System.out.println(length);
    }
    
    public static int lowerBound(int[] array, int target) {
        // target"以上の"初めての場所を返す
        // {1, 3, 3, 7} target: 3 -> 1
        
        int left = 0;
        int right = array.length;
        
        while (left < right) {
            int center = (left + right) / 2;
            if (array[center] < target) {
                left = center + 1;
            } else {
                right = center;
            }
        }
        
        return left;
    }
    
    public static int upperBound(int[] array, int target) {
        // target"より大きい"初めての場所を返す
        // {1, 3, 3, 7} target: 3 -> 3
        
        int left = 0;
        int right = array.length;
        
        while (left < right) {
            int center = (left + right) / 2;
            if (array[center] <= target) {
                left = center + 1;
            } else {
                right = center;
            }
        }
        
        return left;
    }
}


Measured memory_bytes: 59932
n = int(input())
seat = [0] * (10 ** 5 + 1)
for i in range(n):
    l, r = map(int, input().split())
    seat[l - 1] += 1
    seat[r] -= 1

for i in range(1, 10 ** 5):
    seat[i] += seat[i - 1]

res = 0
for i in range(10 ** 5):
    if seat[i] == 1:
        res += 1
print(res)


Measured memory_bytes: 9500
#include <iostream>
#include <algorithm>
#include <iterator>
#include <iomanip>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

int main()
{

    vector<int> sequence;

    int n, e;
    cin >> n;
    while (n--)
    {
        cin >> e;
        sequence.push_back(e);
    }

    long long sum = 0; 
    vector<int>::iterator it = sequence.begin(), max, min;
    min = max = it;
    while (it != sequence.end())
    {
        if (*max < *it)
            max = it;
        if (*min > *it)
            min = it;
        sum += *it;
        it++;
    }

    cout << *min << ' ' << *max << ' ' << sum << endl;

}


Measured memory_bytes: 3240
/*
ID: espr1t
TASK: 
KEYWORDS: 
*/

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
FILE* in = stdin; FILE* out = stdout;

const int MOD = 1000003;

int fact[MOD * 2];

int fastPow(int num, int pwr) {
    int ret = 1;
    while (pwr) {
        if (pwr & 1)
            ret = ((long long)ret * num) % MOD;
        num = ((long long)num * num) % MOD;
        pwr >>= 1;
    }
    return ret;
}

int solve(int x, int d, int n) {
    // x * (x + d) * (x + 2d) * (x + 3d) * (x + 4d) * (x + 5d) * ... * (x + (n-1)d) =
    // d(x/d) * d(x/d + 1) * d(x/d + 2) * ... * d(x/d + n - 1) = 
    // d^n * (x/d)^nr! (https://en.wikipedia.org/wiki/Arithmetic_progression)
    
    if (d == 0)
        return fastPow(x, n);
    if (n >= MOD)
        return 0;
    if (x == 0)
        return 0;
    
    int xd = ((long long)x * fastPow(d, MOD - 2)) % MOD;
    int rf = ((long long)fact[xd + n - 1] * fastPow(fact[(xd - 1 + MOD) % MOD], MOD - 2)) % MOD;
    return ((long long)fastPow(d, n) * rf) % MOD;
}

int dummy(int x, int d, int n) {
    int ans = 1;
    for (int i = 0; i < n; i++) {
        ans = ((long long)ans * x) % MOD;
        x = (x + d) % MOD;
    }
    return ans;
}

int main(void) {
//	in = fopen("E.in", "rt");
	
	fact[0] = 1;
	for (int i = 1; i < MOD * 2; i++) {
	    fact[i] = ((long long)fact[i - 1] * i) % MOD;
    }
	
	int numQueries;
	fscanf(in, "%d", &numQueries);
	for (int i = 0; i < numQueries; i++) {
	    int x, d, n;
	    fscanf(in, "%d %d %d", &x, &d, &n);
	    fprintf(out, "%d\n", solve(x, d, n));
    }
	
	return 0;
}

Measured memory_bytes: 8576
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <list>
#define debug(x) cout << #x << ": " << (x) << endl
using namespace std;

const double PI  = 3.141592653589793238463;
const int INF = 1000000007;

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

using Int = int;
using Double = double;

using P = pair<Int, Int>;
using V = vector<Int>;
using M = vector<V>;

/* 
  00 -> 1
  01 -> 0
  10 -> 0
  11 -> 1
*/
char solve(char a, char b){
    if(a == 'H' ^ b == 'H'){
        return 'D';
    }else{
        return 'H';
    }
}

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

    char a, b;
    cin >> a >> b;
    cout << solve(a, b) << endl;

    return 0;
}


Measured memory_bytes: 256
#include<fstream>
#include<vector>
#include<deque>
#include<iostream>
#include<algorithm>
#include<cmath>
#define x first
#define y second
#define pb push_back
using namespace std;
const int DN=2e5+5;
long long n,dp[DN],a[DN],C;
typedef pair<long long,long long> pll;
deque<pll >d;
pll fc;
int inter(pll a,pll b,long long t)
{
	return (b.y-a.y)<=t*(a.x-b.x);
}
void del(long long t)
{
	while(1)
	{
		if(d.size()<2)
			break;
		if(!inter(d[0],d[1],t))
			break;
		d.pop_front();
	}
}
int vf(pll a,pll b,pll c)
{
	return (b.y-a.y)*(c.x-b.x)<(b.y-c.y)*(a.x-b.x);
}
void ins()
{
	while(1)
	{
		if(d.size()<2)
			break;
		if(!vf(d[d.size()-2],d[d.size()-1],fc))
			break;
		d.pop_back();
	}
	d.pb(fc);
}
int main()
{
	cin>>n>>C;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	d.pb({-2*a[1],C+a[1]*a[1]});
	for(int i=2;i<=n;i++)
	{
		del(a[i]);
		dp[i]=d[0].x*a[i]+d[0].y+a[i]*a[i];
		fc.x=a[i];
		fc.x*=-2;
		fc.y=C+dp[i]+a[i]*a[i];
		ins();
	}
	cout<<dp[n];
}

Measured memory_bytes: 5632
#include <iostream>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <algorithm>
#include <functional>
#include <cstring>
#include <limits.h>
#include <bitset>
#include <complex>
#include <cassert>
#define FOR(i,k,n)  for (int i=(k); i<(int)(n); ++i)
#define REP(i,n)    FOR(i,0,n)
#define FORIT(i,c)	for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define SZ(i) ((int)i.size())
#define GI(i) (scanf("%d",&i))
#define GLL(i) (scanf("%lld",&i))
#define GD(i)  (scanf("%lf",&i))
#define PB          push_back
#define MP          make_pair
#define MT          make_tuple
#define GET0(x)     (get<0>(x))
#define GET1(x)     (get<1>(x))
#define GET2(x)     (get<2>(x))
#define ALL(X)      (X).begin(),(X).end()
#define LLMAX       (1LL<<60)
#define LLMIN       -(1LL<<60)
#define IMAX        (1<<30)
#define IMIN        -(1<<30)
typedef long long LL;
using namespace std;

int main(void){
    string S;
    cin>>S;
    vector<LL> nB(SZ(S), 0);
    nB[0] = (S[0]=='B')?1:0;
    FOR(i,1,SZ(S)){
        nB[i] = nB[i-1];
        if(S[i]=='B')
            nB[i]++;
    }
    LL ans=0;
    for(int i=SZ(S)-1;0<=i;i--)
        if(S[i]=='W')
            ans += nB[i];
    printf("%lld\n",ans);
    return 0;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int ans = 0;
    int able = 2 * d + 1;
    for(int i = 1; i < 20; i++){
      if (i * able >= n) {
        ans = i;
        break;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1000000007;


int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> s(m);
  for (int i=0; i<m; i++){
    int k; cin >> k;
    for(int j = 0; j<k; j++){
      int t; cin >> t; t--; 
      s[i].push_back(t);
    }
  }
  vector<int> p(m);
  for(int i=0; i<m; i++){
    cin >> p[i];
  }

  int ans = 0;
  for(int bit = 0; bit < (1 << n); bit++){
    bool flag = true;
    for (int i=0; i<m; i++){
      int tmp = 0;
      for (int j=0; j<s[i].size(); j++){
        if(bit & (1 << s[i][j])){
          tmp++;
        }
      }
      if(tmp % 2 != p[i]){
        flag = false;
        break;
      }
    }
    if(flag){
      ans++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
PROGRAM ATCODER

implicit none
integer(16) :: n,k,i,j
integer(16),allocatable :: c(:),ans(:)
character(len=10**5) :: s

read*, n,k,s
allocate(c(n+2*k+1),ans(n))
c = n + 1
c(1) = 1
ans = 1

!! c(:)は0か1が連続する区間の始点
j = 2
do i = 1, n-1, 1
  if ( s(i:i+1) == '01' .or. s(i:i+1) == '10' ) then
    c(j) = i+1
    j = j + 1
  end if
end do

do i = 1, n-1, 1
  if ( s(c(i):c(i)) == '0' ) then
    ans(i) = c(i+2*k) - c(i)
  else
    ans(i) = c(i+2*k+1) - c(i)
  end if
end do

print'(i0)', maxval(ans)

END PROGRAM ATCODER

Measured memory_bytes: 6820
/****************### With The name of ALLAH, most Gracious, most Compassionate ###****************/

/**============================================================================**\
|   Author      : Md Jubayer Hossen Jame
|   Study       : CSE, BRUR
|   Today       : Monday, 14 September, 2020
|   Source      : AtCoder Online Judge
|   Problem link: https://atcoder.jp/contests/abc150/tasks/abc150_b
|   Algorithm   :
|
\**============================================================================**/

#include "bits/stdc++.h"
using namespace std;

#define FI                    freopen("input.txt", "r", stdin)
#define FO                    freopen("output.txt", "w", stdout)
#define FasterIO              ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

typedef long long             ll;
typedef unsigned long long    ull;
typedef unsigned int          ui;

#define mem(x,y)              memset(x,y,sizeof(x));
#define pii                   pair<int,int>
#define mk                    make_pair
#define ff                    first
#define ss                    second
#define pb                    push_back
#define ppb                   pop_back
#define all(x)                (x).begin(), (x).end()
#define rall(x)               (x).rbegin(), (x).rend()
#define for0(i, n)            for (int i = 0; i < (int)(n); ++i)
#define endl                  '\n'

const double PI = acos(-1.0);

#define gcd(a,b)              __gcd(a,b)
#define lcm(a,b)              (a*(b/gcd(a,b)))

///Direction Array
// 4 Direction - DOWN, UP, RIGHT, LEFT
int dx4[]= {+1, -1, +0, +0};
int dy4[]= {+0, +0, +1, -1};
#define isValid(a, b, R, C)   (0 <= a && a < R) && (0 <= b && b < C)
int dx8[]= {+0, +0, +1, -1, -1, +1, -1, +1};
int dy8[]= {-1, +1, +0, +0, +1, +1, -1, -1};

///Knight Moves
int dr[] = {-1, 1, -2, -2, -1, 1, 2, 2};
int dc[] = {-2, -2, -1, 1, 2, 2, 1, -1};
/**************************************************************************************************/

void test_case()
{
    int n;
    cin >> n;

    string s;
    cin >> s;
    s += "###";

    int cnt = 0;
    for0(i, n)
    {
        if(s[i] == 'A' and s[i+1] == 'B' and s[i+2] == 'C')cnt++;
    }
    cout << cnt << endl;
}

int main()
{
#ifndef ONLINE_JUDGE
    //FI;
    //FO;
#endif // ONLINE_JUDGE
    //FasterIO

    int T = 1;
    //cin >> T;
    for(int tc = 1; tc <= T; ++tc)
    {
        //cout << "Case #" << tc << ":" << endl;
        test_case();
    }
    return 0;
}


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

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

    int A[N], B[N];
    rep(i, N) cin >> A[i] >> B[i];
    sort(A, A+N);
    sort(B, B+N);

    int ans;
    if (N % 2 == 1) {
        int midA = A[(N+1)/2-1];
        int midB = B[(N+1)/2-1];
        ans = midB - midA + 1;
    } else {
        int midAS = A[N/2-1], midAL = A[N/2];
        int midBS = B[N/2-1], midBL = B[N/2];
        ans = (midBL + midBS) - (midAL + midAS) + 1;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5172
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
#include <queue>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007




signed main(){

	string s;
	deque<char> d;

	cin >> s;
	for (int i = 0; i < s.length(); i++)
		d.push_back(s[i]);

	int ans = 0;
	while (!d.empty()){
		if (d.size() == 1){
			break;
		}
		if (d.front() == d.back()){
			d.pop_back();
			d.pop_front();
		}
		else if (d.front() == 'x'){
			ans++;
			d.pop_front();
		}
		else if (d.back() == 'x'){
			ans++;
			d.pop_back();
		}
		else{
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    vector<int> ans(0);
    while(1){
        cin>>n>>k;
        if(n==0&&k==0){
            break;
        }
        vector<int> vec(n);
        for(int i=0;i<n;i++){
            cin>>vec.at(i);
        }
        vector<int> rsw(n+1);
        rsw.at(0)=0;
        for(int i=1;i<n+1;i++){
            rsw.at(i) = rsw.at(i-1) + vec.at(i-1);
        }
        int ans =0;
        for(int i=k;i<n+1;i++){
            if(ans < rsw.at(i) - rsw.at(i-k)){
                ans = rsw.at(i) - rsw.at(i-k);
            }
        }
        cout << ans << endl;
    }
    
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int q; cin >> q;
  ll su = 0;
  REP(i, q) {
    ll p, n; char c; cin >> p >> c >> n;
    int now = (c == '(') ? 1 : -1;
    su += now * n;
    cout << ((su == 0) ? "Yes" : "No") << endl;
  }
}



Measured memory_bytes: 3100
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    int n = 0;
    cin >> n;
    vector<pair<ll, ll>> a(n);
    for (int i=0; i<n; i++) {
        cin >> a.at(i).first >> a.at(i).second;
    }
    reverse(a.begin(), a.end());
    ll bufa = 0, bufb = 0;
    ll cnt = 0, ans = 0;
    for (int i=0; i<n; i++) {
        bufa = a.at(i).first, bufb = a.at(i).second;
        bufa += cnt;
        cnt += (bufb - bufa%bufb)%bufb;
        ans += (bufb - bufa%bufb)%bufb;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N, M; cin >> N >> M;
    string S; cin >> S;
    int masu = N;
    vector<int> ans;
    bool canDone = true;
    while (true) {
        for(int i = M; i >= 0; i--) {
            if(masu - i < 0) {
                ans.push_back(masu);
                masu = 0;
                break;
            } else if (i != 0 && S[masu - i] == '0') {
                ans.push_back(i);
                masu = masu - i;
                break;
            } else if (i == 0) {
                canDone = false;
                masu = 0;
                break;
            }
        }
        if (masu == 0) break;
    }
    if (!canDone) {
        cout << -1 << endl;
    } else {
        for(int i = ans.size() - 1; i >= 0; i--) {
            cout << ans[i] << ' ' << flush;
        }
    }
}

Measured memory_bytes: 1144
import java.util.*;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int a, d, n;
	
	static boolean read() {
		a = sc.nextInt();
		d = sc.nextInt();
		n = sc.nextInt();
		
		return (a != 0 && d != 0 && n != 0);
	}
	
	static boolean isPrime(int n) {
		if(n == 1) 
			return false;
		boolean ret = true;
		for(int i = 2; i * i <= n; i++) {
			if(n % i == 0) {
				ret = false;
				break;
			}
		}
		return ret;
	}
	
	static int solve() {
		int ret = 0, cnt = 0;
		for(int i = 0; ; i++) {
			ret = a + d * i;
			if(isPrime(ret))
				cnt++;
			
			if(cnt == n)
				return ret;
		}
	}
	
	public static void main(String[] args) {
		while(read()) {
			System.out.println(solve());
		}
	}
}

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

#define int long long
#define endl '\n'
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define DESYNC ios::sync_with_stdio(0); cin.tie(0);
#define deb(x) cerr << ">> " << #x << " : " << x << "\n";
#define print(a) for(auto x : a) cout << x << " "; cout << "\n";

const int inf = 1e18 + 5;

// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

void solve()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if(sum >= h) cout << "Yes\n";
    else cout << "No\n";
}

int32_t main()
{
    DESYNC
    int t = 1;
    // cin >> t;
    while(t--)
        solve();
    return 0;
}

Measured memory_bytes: 3964
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		int W, H, x, y, r;
		W = sc.nextInt();
		H = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		r = sc.nextInt();
		if (x + r > W) {
			System.out.println("No");
		}
		else if(y+r>H) {
			System.out.println("No");


		}

		else if(x-r<0) {
			System.out.println("No");
		}
		else if(y-r<0) {
			System.out.println("No");

		}
		else  {
			System.out.println("Yes");
		}

	}
}




Measured memory_bytes: 26372
#include<bits/stdc++.h>
using namespace std;
 
#define ll             long long 
#define vi             vector<int>
#define mod            1000000007
#define MAX            INT_MIN
#define MIN            INT_MAX
#define ff             first
#define ss             second
#define pb             push_back
#define bs             binary_search    // binary_search(a,a+n,x);
#define mp             make_pair
#define pii            pair<int,int>
#define pqb            priority_queue<int>
#define lower(x)         transform(x.begin(), x.end(), x.begin(), ::tolower);           
#define upper(x)          transform(x.begin(), x.end(), x.begin(), ::toupper);
#define lb             lower_bound      // lower_bound(a,a+n,x) - a; => For Index
#define up             upper_bound      // upper_bound(a,a+n,x) - a; => For Index       
#define floop(x,n)       for(int i=x;i<n;i++)
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define ps(x,y)        fixed<<setprecision(y)<<x         
#define FIO            ios_base::sync_with_stdio(false); cin.tie(NULL);
                  
void c_p_c()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif   
}    

void solution()
{
    int x;
    cin>>x;

    if(x==1)
        cout<<"0"<<endl;
    else
        cout<<"1"<<endl;
}

int32_t main()
{
    c_p_c();
    FIO;
 
    // int t;
    // cin>>t;
 
    // while(t--)
    // {
         solution();
    //}
 
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;

const string YES = "Yes";
const string NO = "No";

void solve(std::string S){
    if(S[2]==S[3]&&S[4]==S[5]) cout<<YES<<endl;
    else cout<<NO<<endl;
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> as(n), bs(n), cs(n - 1);
  for (int& a: as)
    cin >> a;
  for (int& b: bs)
    cin >> b;
  for (int& c: cs)
    cin >> c;

  int ret = 0;
  int pre = -2;
  for (int i = 0; i < n; ++i) {
    int j = as[i] - 1;
    ret += bs[j];
    if (pre + 1 == j) {
      ret += cs[pre];
    }
    pre = j;
  }
  cout << ret << "\n";
  
  return 0;
}


Measured memory_bytes: 256
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_dedges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_wedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define in_dwedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;
 
int main() //PointBlank's code ¯\_(ツ)_/¯
{
    quickio
    ld d, t, s;
    cin >> d >> t >> s;

    if(d/s <= t) cout << "Yes";
    else cout  << "No";

}

ll power(ll x, ll y)
{ 
    ll res = 1; x %= MOD;
    while(y > 0){if(y & 1) res = (res*x) % MOD; y = y>>1, x = (x*x) % MOD;} 
    return res; 
}

Measured memory_bytes: 3732
#include "bits/stdc++.h"
using namespace std;

#define input_from_file freopen("input.txt","r",stdin)
#define output_to_file freopen("output.txt" , "w",stdout)
#define fastio ios_base::sync_with_stdio(0)
#define endl '\n'

const int N = 1e5+1;
vector < int > adj[N];
bitset < N >  vis;
int dp[N] ; 
int compute(int cur)
{
	if(vis[cur]) return dp[cur];

	int x = adj[cur].size() ,  l = 0;
	for(int i = 0 ; i < x ; ++i)
	{
		l = max(l , compute(adj[cur][i]));
	}
	
	vis[cur] = 1;
	if(x == 0) dp[cur] = 0;
	else dp[cur] = max(1 + l , dp[cur]);
	return dp[cur];

}

int main()
{
	 #ifdef LOCAL
        input_from_file;
        output_to_file;
    #endif
	fastio;cin.tie(0);cout.tie(0);
	int n , m , x , y; cin >> n >> m ;
	for(int i = 1 ; i <= m ; ++i)
	{
		cin >> x >> y ;
		adj[x].emplace_back(y);
	}
	vis.reset();
	for(int i = 1 ; i <= n ; ++i)
	{
		if(!vis[i]) x= compute(i);
	}
	x = INT_MIN ; 
	for(int i = 1 ; i <= n ; ++i)
		x = max(x , dp[i]);
	cout << x ; 

	return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;

const int N = 10;
int G[N+1][N];

int main() {
  string line;
  while(cin >> line) {
    stringstream ss;
    ss << line;
    for(int i = 0; i < N; ++i) {
      char c;
      ss >> c;
      G[N][i] = c-'0';
    }
    for(int i = N-1; i >= 1; --i) {
      for(int j = 0; j < i; ++j) {
	G[i][j] = (G[i+1][j] + G[i+1][j+1])%10;
      }
    }
    cout << G[1][0] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
using namespace std;
#define int long long

int n;
string s;
int32_t main() {
	string a, b;
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n >> s;
	if (n % 2 == 1) cout << "No";
	else {
		for(int i = 0; i < s.length()/2; ++i) a += s[i];
		for(int i = s.length()/2; i < s.length(); ++i) b += s[i];
		if (a == b) cout << "Yes";
		else cout << "No";
	}	
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 1; i < int(n); i++)
ll mod=998244353;

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

    return 0;
}



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

using namespace std;

int n, m, a[1005], sum;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		sum += a[i];
	}
	sort(a, a + n);
	sum =(int) ceil((double)(sum*1.0 / (4 * m)));
	if (a[n - m] >= sum)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll c[100000005],p,ans;
map<ll,ll> a;
int check(ll x)
{
	for(ll i=2;i*i<=x;i++)
	if(x%i==0)
	return 0;
	return 1;
}
int main()
{
	ll x,y;
	cin>>x>>y;
	for(ll i=1;i*i<=x;i++)
	if(x%i==0)
	{
		a[i]++;
		if(i!=x/i)
		a[x/i]++;
	}
	for(ll i=1;i*i<=y;i++)
	if(y%i==0)
	{
		a[i]++;
		if(i!=y/i)
		a[y/i]++;
		if(a[i]==2)
		c[++p]=i;
		if(a[y/i]==2)
		c[++p]=y/i;
	}
	sort(c+1,c+1+p);
	for(ll i=2;i<=p;i++)
	if(check(c[i])&&c[i]>1)
	ans++;
	cout<<(ans+1);
}

Measured memory_bytes: 768
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        Scanner scanner = new Scanner(System.in);
        long N = 0;
        int ans = (int) 1e9;
        N = scanner.nextLong();
        long A = 1;
        long B = 1;
        for (A = 1; A <= Math.sqrt(N); A++) {
            B = N / A;
            if (A * B == N) {
                ans = Math.min(ans, String.valueOf(Math.max(A, B)).length());
            }

        }
        System.out.println(ans);
    }
}


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

int main() {
int A,B;
  string S,T;
  T="Yes";
  cin >> S;
  A=S.size();
  for(int i=0;i<(A-1);i=i+2){
    if(S.at(i)=='L'){
      T="No";
      break;
    }
    if(S.at(i+1)=='R'){
      T="No";
      break;
    }
  }
  if((S.at(A-1)=='L')&&((A%2)==1)){
    T="No";
  }
cout << T << endl;

}








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

const int INF = 0x3f3f3f3f;
const int MAXN = 112345;

int n, k;
int h[MAXN];
int pd[MAXN];


int rec(int cur)
{
	if(cur==(n-1))
		return 0;

	if(cur>=n)
		return INF;

	if(pd[cur]!=-1)
		return pd[cur];

	int rtnMin = INF;
	for(int i=1; (i<=k) && ((cur+i)<n); i++)
		rtnMin = min(rtnMin, abs(h[cur+i]-h[cur])+rec(cur+i));

	return pd[cur] = rtnMin;
}

int main(){
	memset(pd, -1 , sizeof(pd));

	cin >> n >> k;

	for(int i=0; i<n; i++)
		cin >> h[i];

	cout << rec(0) << endl;

	return 0;
}

Measured memory_bytes: 5760
import math

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

div = (x/(a*a))/b
wide = div * a
bottom = wide * 2.0
if bottom <= a:
    print(math.degrees(math.atan2(b,bottom)))
else :
    high = (b - (x/(a*a)))*2
    print(math.degrees(math.atan2(high,a)))


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

int main() {
	int n; cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	int ans = 0;
	vector<int> k(n,0);
	rep(i, n) {
		if (i > 0) {
			if (h[i] > h[i - 1]) {
				k[i] = 0;
			}
			else {
				k[i] = k[i - 1] + 1;
			}
		}
	}
	rep(i, n) {
		ans = max(ans, k[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  int n,x,d=0,c=1;
  cin>>n>>x;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
    for(int i=0;i<n;i++){
      d+=a[i];
      if(d<=x)
        c++;
    }
  cout<<c<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

ll N;
vector<ll> A(200010, 0), B(200010, 0);
ll ans;

int main() {
    cin >> N;
    rep(i, N) {
        cin >> A[i];
        if (i == 0) {
            B[i] = 0;
        }
        else {
            B[i] += B[i - 1] + A[i - 1];
        }
        B[i] %= MOD;
    }

    rep(i, N) {
        ans += A[i] * B[i];
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6272
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>

using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define NA -1
typedef long long ll;


void dfs(vector<int>* to, vector<int>& ans, int v, int p = -1)
{
  for(int u : to[v])
  {
    if(u == p) continue;
    ans[u] += ans[v];
    dfs(to, ans, u, v);
  }
}
int main()
{
  int n, q;
  cin >> n >> q;
  int a, b;
  vector<int> to[n];
  vector<int> ans(n);
  rep(i, n-1)
  {
    cin >> a >> b;
    --a;--b;
    to[a].emplace_back(b);
    to[b].emplace_back(a);
  }
  rep(i, q)
  {
    cin >> a >> b;
    --a;
    ans[a] += b;
  }

  dfs(to, ans, 0);

  rep(i, n)
    cout << ans[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 29696
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,j,n) for (int i = n; j<=i;i--)
#define print(out) cout<< out  << "\n";
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N,Q,ans,l,r;cin>>N>>Q;
  string S,s;cin>>S;
  vector<ll> vec(N,0);
  REP(i,0,N-1){
    vec[i+1]=vec[i]+(S.substr(i,2)=="AC"?1:0);
  }
  REP(q,0,Q){
    cin>>l>>r;
    l--;r--;
    print(vec[r]-vec[l]);
  }

}


Measured memory_bytes: 1920
# ALDS1_7_B: Binary Tree

class Node
  class << self
    def bind(parent, left, right)
      parent.set_children(left, right)
      left.set_parent(parent, :left)
      right.set_parent(parent, :right)
    end
  end

  attr_accessor :id, :left, :right

  def initialize(id)
    @id = id
  end

  def depth
    root? ? 0 : 1 + @parent.depth
  end

  def height
    return -1 if nil_node?
    lh = @left.height
    rh = @right.height
    (lh < rh ? rh : lh) + 1
  end

  def parent
    root? ? NIL : @parent
  end

  def sibling
    return NIL if root?
    on_left? ? @parent.right : @parent.left
  end

  def children
    [@left, @right].select { |n| not n.nil_node? }
  end

  def degree
    children.size
  end

  def type
    case
    when root? then 'root'
    when degree == 0 then 'leaf'
    else 'internal node'
    end
  end

  def root?
    @parent.nil?
  end

  def nil_node?
    self == NIL
  end

  def on_left?
    @position == :left
  end

  def set_children(left, right)
    @left  = left
    @right = right
  end

  def set_parent(parent, position)
    @parent   = parent
    @position = position
  end

  protected
    attr_writer :depth, :height
end

Node.const_set :NIL, Node.new(-1)

n_nodes = gets.to_i
tree = Array.new(n_nodes).map.with_index do |_, i|
  Node.new(i)
end

n_nodes.times do
  id, left_id, right_id = gets.split.map &:to_i
  left  = left_id  == -1 ? Node::NIL : tree[left_id]
  right = right_id == -1 ? Node::NIL : tree[right_id]
  Node.bind tree[id], left, right
end

tree.each do |n|
  puts "node #{n.id}: parent = #{n.parent.id}, " <<
       "sibling = #{n.sibling.id}, " <<
       "degree = #{n.degree}, depth = #{n.depth}, " <<
       "height = #{n.height}, #{n.type}"
end

Measured memory_bytes: 8636
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int x=sc.nextInt();
		System.out.println(x<1200?"ABC":"ARC");
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


Measured memory_bytes: 21716
macro_rules! get_one {
    ($t:ty) => {{
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse::<$t>().unwrap()
    }};

    ($t:ty; $n:expr) => {
        (0..$n).map(|_| get_one!($t)).collect::<Vec<_>>()
    };
}

fn main() {
    let k = get_one!(usize);
    let mut gcds: Vec<Vec<usize>> = vec![vec![0; k]; k];

    for i in 0..k {
        for j in i..k {
            let g = gcd(i + 1, j + 1);
            gcds[i][j] = g;
            gcds[j][i] = g;
        }
    }

    let sum_gcd1 : Vec<usize> = gcds.iter().map(|x| x.iter().sum()).collect();

    let mut sum_gcd2 = vec![0; k];

    gcds.iter().for_each(
        |v| v.iter().for_each(
            |&i| sum_gcd2[i - 1] = sum_gcd2[i - 1] + 1));

    let ans : usize = sum_gcd1.iter().zip(sum_gcd2.iter()).map(|(&a, &b)| a * b).sum();
    println!("{}", ans);

}


fn gcd(min: usize, max: usize) -> usize {
    match min {
        0 => max,
        1 => 1,
        min => {
            let m = max - (max / min) * min;
            gcd(m, min)
        }
    }
}


Measured memory_bytes: 2404
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

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

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ll mod2 = 998244353;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  ll ans = 1;
  rep(i, n) (ans *= (i+1)) %= mod;
  cout << ans << endk;
  return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
template <typename T> 
using lim = numeric_limits<T>;
template <typename T>
using indexed_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using indexed_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll n, d; cin >> n >> d;
    ll cnt = 0;
    for (int i = 0; i < n; i++){
        ll x, y;
        cin >> x >> y;
        cnt += (x*x+y*y <= d*d);
    }
    cout << cnt << "\n";
}

Measured memory_bytes: 3640
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using static System.Console;

namespace B_D2019
{
    class MainClass
    {

        static int[] s;


        public static void Main(string[] args)
        {

            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            int n = s[3];           
            int rmax = n/s[0] +1;
            int gmax = n/s[1] +1;
            int bmax = n/s[2]+1;


            int ans = 0;

            for(int i= 0;i<=rmax;i++){
                if(i*s[0]==n){
                    ans++;
                   // WriteLine("only i:  {0}",i);
                    continue;
                }
                for(int j= 0;j<=gmax;j++){
                    int diff = n-i*s[0]-j*s[1];
                    if(diff>=0){
                        if(diff==0){
                            ans++;
                         //   WriteLine("only i,j:  {0} {1}",i,j);
                        }else if(diff%s[2]==0){
                            ans++;
                          //  WriteLine("only i,j,k:  {0} {1}",i,j);
                        }
                    }
                    else break;
                }
            }
        
            


            WriteLine(ans);


        }
    }
}


Measured memory_bytes: 13268
using System;

namespace HelloWorld
{
    class Program
    {
        static void Main(string[] args)
        {
            int S = int.Parse(Console.ReadLine());

            int h = S / 3600;
            int m = (S - h * 3600) / 60;
            int s = S - h * 3600 - m * 60;   
            
            Console.WriteLine(h + ":" + m +":" + s);
        }
    }
}



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

const int MOD =  1e9 + 7;
#define int long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

bool gap;
int dp[3001][3001];

// Method 1 - Player1 tries to maximise X-Y while player2 tries toh minimise X-Y
int solve(vector<int>&v,int l,int r)
{
    if(l > r) return 0;

    if(dp[l][r] != -1) return dp[l][r];

    if(((r-l)&1) != gap)
    {
        return dp[l][r] = max(v[l] + solve(v,l+1,r),v[r] + solve(v,l,r-1));
    }

    // cout<<l<<" "<<r<<endl;

    return dp[l][r] = min(-v[l] + solve(v,l+1,r),-v[r] + solve(v,l,r-1));
}

// Method 2 - Player1 tries to maximise X while player2 tries toh minimise X
int solve02(vector<int>&v,int l,int r)
{
    if(l > r) return 0;

    if(dp[l][r] != -1) return dp[l][r];

    if(((r-l)&1) != gap)
    {
        return dp[l][r] = max(v[l] + solve02(v,l+1,r),v[r] + solve02(v,l,r-1));
    }

    // cout<<l<<" "<<r<<endl;

    return dp[l][r] = min(solve02(v,l+1,r),solve02(v,l,r-1));
}

int32_t main()
{
	FASTIO;

	int n;
    cin>>n;

    memset(dp,-1,sizeof dp);

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

    if(n&1) gap = true;
    else gap = false;

    // Method 1 - Player1 tries to maximise X-Y while player2 tries toh minimise X-Y
    // cout<<solve(v,0,n-1);

    // Method 2 - Player1 tries to maximise X while player2 tries toh minimise X
    int sumX = solve02(v,0,n-1);
    int sumY = sum - sumX;
    
    cout<<sumX - sumY;


}

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

int ctoi(char c) {
    int n = c - '0';
    return n;
}

int pow_int(int x, int n) {
    if (n == 0) {
        return 1;
    }else {
        int y = x;
        for (int i = 0; i < n-1; i++) {
            x *= y;
        }
        return x;
    }
}


int main() {
    long long x;
    cin >> x;
    int year = 0;
    long long money = 100;
    while(true) {
        year++;
        money = floor(money * 1.01);
        if(money >= x) {
            break;
        }
    }
    cout << year << endl;
}


Measured memory_bytes: 3712
# coding: utf-8
# Your code here!
a=input()
s=list(a)
a=s
cnt=[]
#print(a)
aa=0
for i in range(2**(len(s)-1)):
    su=a[0]
    cnt=[]
    for j in range(len(s)-1):
        if (i>>j)&1==1:
            aa+=int(su)
            su=a[j+1]
            #cnt.append('+')
        elif (i>>j)&1==0:
            su+=a[j+1]
    aa+=int(su)
    #print(aa,su)
            #cnt.append('-')
        #print(su,cnt)
    #if su==7:
     #   print(str(a[0])+cnt[0]+str(a[1])+cnt[1]+str(a[2])+cnt[2]+str(a[3])+'='+'7')
      #  exit()
print(aa)        

Measured memory_bytes: 39280