akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) int((x).size())
#define OUT(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;
typedef vector<vector<int>> VV;
typedef pair<int, int> P;
typedef map<string, int> M;
typedef unordered_map<int, int> HM;
typedef set<int> S;
typedef multiset<int> MS;
typedef queue<int> Q;

int main(){
    int n,k; cin>>n>>k;
    if(k==1) OUT(0);
    else OUT(n-k);
}



Measured memory_bytes: 256
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;//namespace

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl;
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl;

#define SANKOU(n,a,b) cout << ((n) ? (a) : (b) ) << endl;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define WFA(d,v) REP(k,v)REP(i,v)REP(j,v)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);// warshall-floyd

#define CIN(x) int x;cin>>x;
#define CIN2(x,y) int x,y;cin>>x>>y;
#define CIN3(x,y,z) int x,y,z;cin>>x>>y>>z;
#define SCIN(x) string x;cin>>x;
#define SCIN2(x,y) string x,y;cin>>x>>y;
#define COUT(x) cout<<(x)<<endl;
#define SCOUT(x) cout<<(x)<<" ";
#define ENDL cout<<endl;

#define VECCIN(x) for(auto&youso_: (x) )cin>>youso_;
#define VECIN2(x,y) REP(i,x.size())cin>>x[i]>>y[i];
#define VECCOUT(x) for(auto&youso_: (x) )cout<<youso_<<" ";cout<<endl;

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define EXIST(n,x) (find(ALL(n),x)!=n.end())
#define UNIQUE(obj) sort(ALL( obj )); obj.erase(unique(ALL(obj)),obj.end())


#define P pair<int,int>
#define V vector<int>
#define M map<int,int>
#define S set<int>
#define L list<int>

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    CIN(n);V a(3*n);VECCIN(a);
    sort(ALL(a),greater<int>());
    REP(i,n)a.erase(a.end()-1);
    ll ans=0;

    REP(i,a.size())if(i%2)ans+=a[i];
    COUT(ans);
    return 0;
}


Measured memory_bytes: 1408
N = int(input())
S = input()
w = [0]
s = [0]
for v in S:
    if v == 'W':
        w.append(w[-1] + 1)
        s.append(s[-1])
    else:
        w.append(w[-1])
        s.append(s[-1] + 1)
ans = 10 ** 9
for i in range(N):
    ans = min(ans, w[i] + s[-1] - s[i + 1])
print(ans)

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

def calculate(n):
    result = 0
    for i in range(1, n + 1):
        num = n // i
        if num == 1:
            result += i
        else:
            start = i
            end = num * i
            total = ((start + end) * num) // 2
            result += total

    print(result)


calculate(N)


Measured memory_bytes: 9116
#include <algorithm>
#include <iostream>
#include <vector>
#define mod 1000000007
using namespace std;
typedef long long LL;
typedef vector<int> vi;
typedef vector<vi> vvi;

const int K = 60;

LL m;
int n,tot;
vvi ans;
vvi mat[K];

vvi getEmptyMat() {
	vvi emptyMat = vvi( n , vi( n , 0 ) );
	return emptyMat;
}

vvi getUnitMat() {
	vvi unitMat = getEmptyMat();
	for( int i = 0 ; i < n ; i++ )
		unitMat[i][i] = 1;
	return unitMat;
}

vvi multMats( vvi a , vvi b ) {
	vvi res = getEmptyMat();
	for( int i = 0 ; i < n ; i++ )
		for( int j = 0 ; j < n ; j++ )
			for( int k = 0 ; k < n ; k++ )
				res[i][k] = ( res[i][k] + (LL) a[i][j] * b[j][k] ) % (LL) mod;
	return res;
}

int main() {
	cin >> n >> m;
	mat[0] = getEmptyMat();
	for( int i = 0 ; i < n ; i++ )
		for( int j = 0 ; j < n ; j++ )
			cin >> mat[0][i][j];
	for( int k = 1 ; k < K ; k++ )
		mat[k] = multMats( mat[k-1] , mat[k-1] );
	ans = getUnitMat();
	for( int k = 0 ; k < K ; k++ )
		if( m & (1LL << k) )
			ans = multMats( ans , mat[k] );
	for( int i = 0 ; i < n ; i++ )
		for( int j = 0 ; j < n ; j++ )
			tot = ( tot + ans[i][j] ) % mod;
	cout << tot << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

signed main(){
	int t;
	cin>>t;
	rep(j,0,t){
		int x,y,w,h;
		cin>>x>>y>>w>>h;
		int n,nx,ny,ans=0;
		cin>>n;
		rep(i,0,n){
			cin>>nx>>ny;
			if(x<=nx && nx<=x+w && y<=ny && ny<=y+h) ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll INFL = 1e18+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

vector<int> sieve(int n) {
	vector<int> res;
	vector<bool> is_prime(n + 1, true);
	
	is_prime[0] = is_prime[1] = false;
	
	for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
		res.push_back(i);
		is_prime[i] = false;
		for (int j = 2; i * j <= n; j++) if (is_prime[i * j]) {
			is_prime[i * j] = false;
		}
	}
	
	REP(i, n + 1) if (is_prime[i]) res.push_back(i);
	sort(res.begin(), res.end());
	return res;
}

int main() {
	vector<int> prime = sieve(55555);
	int n;
	cin >> n;
	vector<int> ans;
	REP(i, prime.size()) {
		if (prime[i] % 10 == 3 && n) ans.push_back(prime[i]), n--;
	}
	REP(i, ans.size()) printf("%d%c", ans[i], i == ans.size() - 1 ? ' ' : '\n');
	return 0;
}

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



int main(){
    ll N;cin>>N;
    ll a[100010],rui[100010],ans=1;
    rep(i,0,N)cin>>a[i];
    sort(a,a+N);
    rui[0]=a[0];
    rep(i,1,N)rui[i]=rui[i-1]+a[i];
    for(int i=N-2;i>=0;i--){
        if(2*rui[i]>=a[i+1])ans++;
        else break;
    }
    cout<<ans<<endl;
}







Measured memory_bytes: 1792
def main():
    N = int(input())
    dp = [[[[0 for _ in range(4)] for _ in range(4)]
           for _ in range(4)] for _ in range(101)]
    dp[0][3][3][3] = 1
    mod = 10 ** 9 + 7
    for n in range(100):
        for i in range(4):
            for j in range(4):
                for k in range(4):
                    if dp[n][i][j][k] == 0:
                        continue
                    for a in range(4):
                        if (j == 0 and i == 1 and a == 2) or \
                            (j == 0 and i == 2 and a == 1) or \
                            (j == 1 and i == 0 and a == 2) or \
                            (k == 0 and j == 1 and a == 2) or \
                                (k == 0 and i == 1 and a == 2):
                            continue
                        dp[n + 1][a][i][j] += dp[n][i][j][k]
                        dp[n + 1][a][i][j] %= mod
    ans = 0
    for i in range(4):
        for j in range(4):
            for k in range(4):
                ans += dp[N][i][j][k]
                ans %= mod
    print(ans)


main()


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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


t = I()
for _ in range(t):
    n, a, b, c, d = LI()
    memo = {0: 0, 1: d}
    def dfs(x):
        if x in memo:
            return memo[x]
        ret = x * d
        ret = min(ret, min(dfs(x // 2), dfs((x - 1) // 2 + 1)) + a + d * (x % 2))
        if (x % 3) < (-x % 3):
            ret = min(ret, b + dfs(x // 3) + d * (x % 3))
        else:
            ret = min(ret, b + dfs((x - 1) // 3 + 1) + d * (-x % 3))
        if (x % 5) < (-x % 5):
            ret = min(ret, c + dfs(x // 5) + d * (x % 5))
        else:
            ret = min(ret, c + dfs((x - 1) // 5 + 1) + d * (-x % 5))

        memo[x] = ret
        return ret

    print(dfs(n))
    

Measured memory_bytes: 92728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int x, ans;
  cin >> x;
  if(x < 600){
   ans = 8;
  }else if( x < 800){
   ans = 7;
  }else if( x < 1000){
   ans = 6;
  }else if( x < 1200){
   ans = 5;
  }else if( x < 1400){
   ans = 4;
  }else if( x < 1600){
   ans = 3;
  }else if( x < 1800){
   ans = 2;
  }else if( x < 2000){
   ans = 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
int C[111][111]; // nCr の 事前計算.
int p9[5] = {1, 9, 81, 729, 6561};

// 0でない数字が, ちょうどK個あるようなものの個数を計算.
// @param N: 与えられた整数.
// @param c: 現在見ている桁.
// @param k: 0でない数字が使える残りの桁数.
// @return : 計算結果.
int recursive(string N, int c, int k){
    int ret = 0, d = N.size();
    // ex.
    // 1
    // 1
    // -> 1 が 正解だが, 3 と 出力されたため, ロジック修正.
    // if(c >= d) return 1;
    if(c >= d - 1) return N[d - 1] - '0';
    if(k == 0) return 1;
    // hand_03 ～ hand_05 で, WA版.
    // ex.
    // 10
    //  2
    // -> 0 が 正解だが, 1 と 出力された.
    // -> 以下の桁数チェックのロジックを追加.
    if(d - c < k) return 0;
    
    if(N[c] > '0'){
        // c桁目が, 0 だった場合, (c + 1)桁目 ～ d桁目 の中で, 1 ～ 9 を k回選択できる.
        ret += C[d - 1 - c][k] * p9[k];
        
        // c桁目が, 1 ～ (N[c] - 1) だった場合, (c + 1)桁目 ～ d桁目 の中で, 1 ～ 9 を (k - 1)回選択できる.
        ret += (N[c] - '1') * C[d - 1 - c][k - 1] * p9[k - 1];
        
        // c桁目が, N[c] だった場合, (c + 1)桁目 ～ d桁目 の中で, 1 ～ 9 を (k - 1)回選択できる.
        ret += recursive(N, c + 1, k - 1);
    }else{
        ret += recursive(N, c + 1, k);
    }
    return ret;
}

int main(){
    
    // 1. 入力情報.
    int K;
    char c[111];
    scanf("%s %d", c, &K);
    string N(c);
    int d = N.size();
    
    // 2. nCr の 事前計算.
    C[0][0] = 1;
    rep(n, 111) C[n][0] = C[n][n] = 1;
    rep(n, 110) repx(k, 1, 111) C[n + 1][k] = C[n][k - 1] + C[n][k];
    assert(C[1][1] == 1);
    assert(C[1][3] == 0);
    assert(C[3][2] == 3);
    assert(C[5][3] == 10);
    assert(C[10][3] == 120);
    assert(C[55][2] == 1485);
    assert(C[100][3] == 161700);
    
    // 3. d < K の 場合.
    if(d < K){
        puts("0");
        return 0;
    }
    
    // 4. d >= K の 場合.
    // ex.
    // 1111
    // 3
    // 
    // 1011 ～ 1099: 81通り
    // 1101 ～ 1109: 9通り
    // 1110 ～ 1110: 1通り
    // 0111 ～ 0999: 729通り
    // => 合計 820通り
    int ans = recursive(N, 0, K);
    
    // 5. 出力.
    printf("%d\n", ans);
    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<int>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
const int MAX = 510000;
const ll 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;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//a^n%mod
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main(){
  int n;
  cin >> n;
  int ans=0;
  int a=-2000000000;
  int b=2000000000;
  int x[n];
  int y[n];
  rep(i,n)cin >> x[i] >> y[i];
  rep(i,n)a=max(a,x[i]-y[i]);
  rep(i,n)b=min(b,x[i]-y[i]);
  ans=a-b;
  int c=-2000000000;
  int d=2000000000;
  rep(i,n)c=max(c,x[i]+y[i]);
  rep(i,n)d=min(d,x[i]+y[i]);
  cout << max(ans,c-d) << endl;
}


Measured memory_bytes: 5184
#include <map>
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <sstream>
#include <vector>
using namespace std;
typedef long long ll;

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

	if (K >= (A - 1) + 2 && B - A > 2)
	{
		ans = A + ((K - (A - 1)) / 2) * (B - A) + (K - (A - 1)) % 2;
	}
	else
	{
		ans = K + 1;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int solve(int n, int h[]){
    int res = 0;
    int tmp = 0;
    rep(i,n-1){
        if(h[i] >= h[i+1]){
            tmp++;
        }else{
            res = max(res, tmp);
            tmp =  0;
        }
    }
    res = max(res, tmp);
    return res;
}

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i,n)cin >> h[i];

    int ans = solve(n, h);

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


Measured memory_bytes: 640
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
#define mod 1000000007
using namespace std;

char c[3][100];
int n,f[110];
long long ans;

int main()
{
	scanf("%d\n",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%c",&c[1][i]);
	}
	scanf("\n");
	for(int i=1;i<=n;i++)
	{
		scanf("%c",&c[2][i]);
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(c[1][i]==c[1][i+1])
		{
			f[++cnt]=2;
			i++;
		}
		else
		{
			f[++cnt]=1;
		}
	}
	if(f[1]==2) ans=6;
	else ans=3;
	for(int i=1;i<cnt;i++)
	{
		if(f[i]==1)
		{
			if(f[i+1]==1)
			{
				ans=ans*2%mod;
			}
			if(f[i+1]==2)
			{
				ans=ans*2%mod;
			}
		}
		else
		{
			if(f[i+1]==1)
			{
				ans=ans%mod;
			}
			else
			{
				ans=ans*3%mod;
			}
		}
	}
	printf("%lld\n",ans);
}

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

// 色の塗り方と移動経路を決める順番は答えに影響しない。そこで、移動しながら塗り方を決める ことで、bool 値のテーブルを持つことを考える。
// DP[i][j][k] = "マス(i, j) までの経路の偏りが k になることがあるか？"
// マス(i, j) で偏りが k であるとき、マス(i + 1, j) での偏りは、マス(i + 1, j) の数の色の塗り方により
//  k + | Ai + 1, j −Bi + 1, j | か | k − | Ai + 1, j −Bi + 1, j || となる。
// マス(i, j + 1) についても同様です。 したがって、i, j が小さい方から順にテーブルを埋めていくことができます。
// M = max{ | A11 −B11 | ,..., | AHW −BHW | }として、偏りは最大で O((H + W)M) 程度まで考慮 する必要があるので、
// 全体で O(HW(H + W)M) で解くことができた。　bitset を用いた高速化をすることもできる。


int table[80][80];
bool DP[80][80][15000] = {};

int main() {
	int H, W;
	scanf("%d", &H);
	scanf("%d", &W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			scanf("%d",&table[i][j]);
		}
	}
	int M = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			int b; 
			scanf("%d",&b);
			table[i][j] = abs(table[i][j] - b); // table[][] 格納するのは A[][] とB[][] の差で良い
			M = max(M, table[i][j]); // 偏りの最大
		}
	}
	DP[0][0][table[0][0]] = true;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			for (int k = 0; k <= (H + W) * M; k++) {
				if (DP[i][j][k]) { // 偏り k がある

					// マス(i, j) で偏りが k であるとき、マス(i + 1, j) での偏りは、マス(i + 1, j) の数の色の塗り方により
						//  k + | Ai + 1, j −Bi + 1, j | か | k − | Ai + 1, j −Bi + 1, j || となる。
						// ます(i,j + 1)でも同様
					if (j < W - 1) { // グリッド内にいる
						DP[i][j + 1][k + table[i][j + 1]] = true;
						DP[i][j + 1][abs(k - table[i][j + 1])] = true;
					}
					if (i < H - 1) { // グリッド内にいる
						DP[i + 1][j][k + table[i + 1][j]] = true;
						DP[i + 1][j][abs(k - table[i + 1][j])] = true;
					}
				}
			}
		}
	}
	for (int k = 0; k <= (H + W) * M; k++) {
		if (DP[H - 1][W - 1][k]) {
			cout << k << endl;
			break;  //最小の k を出力することができる。
		}
	}
	return 0;
}

Measured memory_bytes: 92800
#include<iostream>
#include<cstring>
#include<cstdio>

int main(){
    char str1[201]={},str2[101]={},str3[101]={};
    scanf("%s %s",str1,str2);
    strcpy(str3,str1);
    strcat(str1,str3);
    if(strstr(str1,str2)==NULL) printf("No\n");
    else printf("Yes\n");
    return 0;
}


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


int main() {
    int N,K;
    cin>>N>>K;
    int a[N];
    rep(i,N)cin>>a[i];
    int cnt=1;
    if(N-K>0){
        if((N-K)%(K-1)==0)cnt+=(N-K)/(K-1);
        else cnt+=(N-K)/(K-1)+1;
    }
    cout<<cnt<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });


void solve(string S){
	ll res = 0;
	REP(i, S.size()-1) {
		if (i<0) i = 0;
		if (S[i] != S[i+1]) {
			S = S.substr(0, i) + S.substr(i+2, S.size());
			res += 2;
			i -= 2;
		}
	}
	cout << res << "\n";
}

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


Measured memory_bytes: 848
#include<iostream>

using namespace std;

const int MAXN = 200005;

int n, m, a, b;
int x[MAXN], y[MAXN];

int main () {
	cin >> n >> m;
	for (int i=0; i<m; i++) {
		cin >> a >> b;
		if (a==1) x[b]++;
		if (b==1) x[a]++;
		if (a==n) y[b]++;
		if (b==n) y[a]++;
	}
	bool naso=0;
	for (int i=2; i<=n-1; i++) {
		if (x[i] && y[i]) naso=1;
	}
	if (naso) cout << "POSSIBLE"; else cout << "IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 1792
#include<algorithm>

template<class T>
int partition(T &A, int first, int last){
    const int pivot = A[last-1];
    int bound = first-1;
    for(int i=first;i<last;++i)
        if(A[i]<=pivot) std::swap(A[++bound], A[i]);
    return bound;
}

#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
    int N;
    cin>>N;
    vector<int> P(N);
    for(int i=0;i<N;++i) cin>>P[i];
    int bound = partition(P,0,N);
    string s;
    for(int i=0;i<N;++i){
        if(i==bound) s+='['+to_string(P[i])+"] ";
        else s+=to_string(P[i])+' ';
    }
    s.pop_back();
    cout<<s<<endl;
}

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

int main()
{
 int h[10];
 for(int i=0; i<10; i++) cin >> h[i];

 for(int i=0; i<3; i++){
  int n = h[0];
  int m = 0;
  for(int j=1; j<10; j++)
   if(n < h[j]){
    n = h[j];
    m = j;
   }
  cout << n << '\n';
  h[m] = -1;
 }

 return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    int n = s.size();
    vector<int> a(n+1,0);
    for(int i=0;i<n;i++){
        if(s[i] == '<'){
            a[i+1] = a[i]+1;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(s[i] == '>'){
            a[i] = max(a[i], a[i+1]+1);
        }
    }
    ll ans = 0;
    for(int i=0;i<n+1;i++){
        ans += a[i];
    }    
    cout << ans << endl;
}

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

using namespace std;

typedef vector< vector<int> > Mat;

#define EPS 1e-12

int N;
Mat operator *(const Mat& A, const Mat& B) {
	Mat res(N, vector<int>(N, 0));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			for (int k = 0; k < N; ++k) {
				res[i][j] = (res[i][j] + A[i][k] * B[k][j]) % 2;
			}
		}
	}
	return res;
}

Mat pow(Mat A, int n) {
	Mat res = A;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			res[i][j] = i == j ? 1 : 0;
		}
	}

	for (int k = 1; k <= n; k <<= 1) {
		if (n & k) {
			res = res * A;
		}
		A = A * A;
	}

	return res;
}

int main() {
	cin >> N;

	Mat A(N, vector<int>(N));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			cin >> A[i][j];
		}
	}
	vector<int> v(N);
	for (int i = 0; i < N; ++i) cin >> v[i];
	int T; cin >> T;

	A = pow(A, T);

	vector< vector<int> > B(N, vector<int>(N+1));
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			B[i][j] = A[i][j];
		}
		B[i][N] = v[i];
	}

	for (int i = 0; i < N; ++i) {
		int pos = -1;
		for (int j = i; j < N; ++j) {
			if ( B[j][i] == 1 ) {
				pos = j;
				break;
			}
		}
		if (pos > -1) {
			swap(B[i], B[pos]);

			for (int j = 0; j < N; ++j) {
				if (j != i && B[j][i] == 1) {
					for (int k = 0; k < N+1; ++k) {
						B[j][k] = (B[j][k] + B[i][k]) % 2;
					}
				}
			}
		}
	}

	int ans = 0;
	for (int i = 0; i < N; ++i) {
		bool f = true;
		for (int j = 0; j < N; ++j) {
			if ( B[i][j] == 1 ) {
				f = false;
				break;
			}
		}
		if (f) {
			if (B[i][N] == 1) {
				ans = -2;
				break;
			}
			else {
				ans = -1;
			}
		}
	}
/*
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N+1; ++j) {
			cout << B[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
*/
	if (ans == -1) {
		cout << "ambiguous" << endl;
	}
	else if (ans == -2) {
		cout << "none" << endl;
	}
	else {
		for (int i = 0; i < N; ++i) {
			if (i) cout << " ";
			cout << B[i][N];
		}
		cout << endl;
	}
}

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

struct item
{
	int wt;
	int val;
};

ll solve(vector<item> ar, int n, int W)
{
	int maxVal = n * 1000;
	ll dp[n + 1][maxVal + 1];

	//base case
	for (int val = 0; val <= maxVal; val++)
		dp[1][val] = INT_MAX;
	dp[1][0] = 0;
	dp[1][ar[1].val] = ar[1].wt;

	for (int i = 2; i <= n; i++)
	{
		for (int v = 0; v <= maxVal; v++)
		{
			dp[i][v] = dp[i - 1][v];
			if (ar[i].val > v)
				continue;
			dp[i][v] = min(dp[i][v], ar[i].wt + dp[i - 1][v - ar[i].val]);
		}
	}
	ll ans = 0;
	for (int x = 0; x <= maxVal; x++)
	{
		if (dp[n][x] <= W)
			ans = x;
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, w;
	cin >> n >> w;
	vector<item> ar(n + 1);
	for (int i = 1; i <= n; i++)
		cin >> ar[i].wt >> ar[i].val;
	cout << solve(ar, n, w);
}

Measured memory_bytes: 81784
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N, ans=0;
    cin >> N;
    for(int i=1; i<=N; i++){
        int I=i, keta=0;
        while(I!=0){
            I /= 10;
            keta++;
        }
        if(keta%2!=0){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

/**
 * https://abc074.contest.atcoder.jp/tasks/abc074_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		sc.close();
		
		System.out.println(N*N-A);

	}

}

Measured memory_bytes: 22868
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
using namespace std;
vector<int> list;
int restore(int rate_pre, int price) {
	if ((price * 100) % (100 + rate_pre) == 0) return price * 100 / (100 + rate_pre);
	int i = price * 100 / (100 + rate_pre) + 1;
	if (i*(rate_pre + 100) / 100 != price) return 0;
	return i;
}

int main() {
	int rate_pre, rate_next, sum_pre;

	while (1) {
		scanf("%d %d %d", &rate_pre, &rate_next, &sum_pre);
		if (rate_pre == 0) break;
		for (int price_a = 1; price_a <= sum_pre / 2; price_a = price_a + 1) {
			int price_b = sum_pre - price_a;
			int a = (100 + rate_next) * restore(rate_pre, price_a) / 100;
			int b = (100 + rate_next) * restore(rate_pre, price_b) / 100;
			if (a == 0 || b == 0) continue;
			list.push_back(a + b);
		}
		int p = 0;
		for (unsigned int i = 0; i < list.size(); i++) {
			if (list[i] > p) p = list[i];
		}
		printf("%d\n",p);
		list.clear();
	}
	return 0;
}


Measured memory_bytes: 3268
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <utility>
#include <queue>

using namespace std;
typedef long long signed int ll;

constexpr int inf = INT32_MAX / 2;
constexpr int mod = 1000000007;
constexpr int maxn = 100000;

namespace arithmetic {
	class utils {
	private:
	public:
		template<typename T>
		static multiset<T> factor(T n) {
			T m = n;
			multiset<T> ret;
			for (T i = 2; i <= m && i*i <= n;i++) {
				while (m % i == 0) {
					ret.insert(i);
					m = m / i;
				}
			}
			if (m != 1) ret.insert(m);
			return ret;
		}

		template<typename T>
		static long long gcd(T a, T b) {
			if (b == 0) return a;
			return gcd(b, a % b);
		}

		template<typename T>
		static pair<T, T> extgcd(pair<T, T> a) {
			if (a.second == 0) return make_pair(a.first, 0);
			auto t = extgcd(make_pair(a.second, a.first % a.second));
			return make_pair(t.second, t.first - t.second * (a.first / a.second));
		}

		template<class T>
		class combination {
		private:
			map<pair<T,T>,T> dp;
		public:
			T compute(T n, T k) {
				if (k == 0) return T(1);
				if (dp.find(make_pair(n, k)) == dp.end()) {
					dp[make_pair(n, k)] = (compute(n - 1, k - 1) * n) / k;
				}
				return dp[make_pair(n, k)];
			}
		};

	};

	template <typename T>
	class modulo {
	private:
		T n = 0;
	public:
		T mod = 1000000007;
		modulo(T n_,T mod_) {
			mod = mod_;
			n = ((n_ % mod) + mod) % mod;
		}
		modulo(T n_) {
			n = ((n_ % mod) + mod) % mod;
		}
		modulo() {
			n = 0;
		}
		explicit operator T() const {
			return n % mod;
		}
		modulo operator+(modulo e) {
			return modulo((n + (T)e) % mod, mod);
		}
		modulo operator-(modulo e) {
			return modulo((n - (T)e) % mod, mod);
		}
		modulo operator*(modulo e) {
			return modulo((n * (T)e) % mod, mod);
		}
		modulo operator/(modulo e) {
			return modulo(((n * utils::extgcd(make_pair((T)e, -mod)).first)) % mod, mod);
		}
		bool operator==(modulo e) const{
			return n == (T)e && mod == e.mod;
		}
		bool operator<(modulo e) const{
			return n == (T)e ? mod < e.mod : n < (T)e;
		}
	};
};

int main() {
	int n, m;
	cin >> n >> m;
	map<ll, ll> q;
	for (auto e : arithmetic::utils::factor(m)) q[e]++;
	arithmetic::utils::combination<arithmetic::modulo<ll>> c;
	arithmetic::modulo<ll> ret(1);
	for (auto e : q) {
		ret = ret * c.compute(e.second + n - 1, e.second);
	}
	cout << (ll)ret << endl;
}


Measured memory_bytes: 256
import core.stdc.stdlib;
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.numeric;
import std.stdio;
import std.string;

// void toBaseMinus2(in long rest, in long digit, in string result)
// {
//     // stderr.writeln(rest, ",  ", digit, ", ", result.dup.reverse);
//     if (rest == 0)
//     {
//         if (result == "")
//         {
//             writeln("0");
//         }
//         else
//         {
//             writeln(result.dup.reverse);
//         }
//         exit(0);
//     }
//     else
//     {
//         long d = pow(-2, digit);
//         if (abs(d) < abs(n))
//         {
//             toBaseMinus2(rest, digit + 1, result ~ '0');
//             toBaseMinus2(rest - d, digit + 1, result ~ '1');
//         }
//     }
// }

// long n;

void main()
{
    // n = readln.chomp.to!long;
    // toBaseMinus2(n, 0, "");
    // string s;
    // long digit = 0;
    // while(true) {
    //     pow(-2, digit);
    // }
    // for (long k = 30; 0 <= k; --k)
    // {
    //     auto d = pow(-2, k);
    //     if (d <= n)
    //     {
    //         n -= d;
    //         s ~= '1';
    //     }
    //     else
    //     {
    //         s ~= '0';
    //     }
    // }
    // writeln(s.dup.reverse);
    long n = readln.chomp.to!long;
    long digit = 0;
    string result;
    while (n != 0)
    {
        if (n % pow(2, digit + 1) == 0)
        {
            result ~= '0';
            ++digit;
        }
        else
        {
            n -= pow(-2, digit);
            result ~= '1';
            ++digit;
        }
    }
    if (result == "")
    {
        writeln("0");
    }
    else
    {
        auto dup = result.dup;
        reverse(dup);
        writeln(dup);
    }
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

long long mod_inverse(long long a) {
	/*a^{10^9+5}を計算すればよい*/
	int p = 1000000005;
	long long ret = 1;

	while (p > 0) {
		if (p % 2 == 1) {
			ret = (ret * a) % 1000000007;
		}
		a = (a * a) % 1000000007;

		p = p / 2;
	}

	return ret;

}


int main() {

	long long n, k;
	cin >> n >> k;

	long long ans = 0;

	long long binomA = 1; /*C(n,i)*/
	long long binomB = 1; /*C(n-1,i)*/

	for (int i = 0; (i < n) && (i <= k); i++) {
		ans += (binomA * binomB) % 1000000007;
		ans = ans % 1000000007;

		binomA = (binomA * (n - i)) % 1000000007;
		binomA = (binomA * mod_inverse(i + 1)) % 1000000007;

		binomB = (binomB * (n - 1 - i)) % 1000000007;
		binomB = (binomB * mod_inverse(i + 1)) % 1000000007;
	}

	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int h,w;
	scanf("%d%d\n",&h,&w);
	char s[h][w],i,j,r[105]={0},c[105]={0};
	for(i=0;i<h;i++) {
		for(j=0;j<w;j++) {
			scanf("%c",&s[i][j]);
			if(s[i][j]=='#'){
				r[i]++;
				c[j]++;
			} 
		}
		scanf("\n");
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(r[i]>0&&c[j]>0){
				printf("%c",s[i][j]);
			}
		}
		if(r[i]>0)
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 128
N,M,X = map(int,input().split())
CA = []
ans = 12*(10**5)+1
for n in range(N):
    CA.append(list(map(int,input().split())))

for bit in range(2**N):
    power = [0]*(M+1)
    for n in range(N):
        if bit>>n & 1:
            for i in range(M+1):
                power[i] += CA[n][i]
    rikai = True
    for m in range(M):
        if power[m+1]<X:
            rikai = False
    if rikai:
        ans=min(ans,power[0])
if ans == 12*(10**5)+1:
    ans = -1
print(ans)


Measured memory_bytes: 9216
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, X = il()
    L = il()
    now, ret = 0, 1
    for l in L:
        now += l
        if now <= X:
            ret += 1
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14544
#include<stdio.h>

int main(void)
{
	char class[20];
	int i, am, pm;
	
	for(i=0;i<9;i++)
	{
		scanf("%s %d %d",class,&am,&pm);
		printf("%s %d %d\n",class,am+pm,(200*am)+(300*pm));
	}
	return 0;
}

Measured memory_bytes: 596
#include<iostream>
     
    using namespace std;
    #define int long long int
     
    signed main()
    {
    	int n,k;
    	cin>>n>>k;
     
    	int ans=(n/k),tmp=0;
    	
    	if(!(k&1))
    	{
    		tmp=(n/(k/2))-ans;
    	}
     
    	cout<<ans*ans*ans+tmp*tmp*tmp;
    	return 0;
    }

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

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

//int a[1010][1010];

int main()
{
    int n;
    cin>>n;
    vector<int> h;
    for(int i=0;i<n;i++){
        ll val;
        cin>>val;
        h.push_back(val);
    }
    ll mx = -1,ans=0;
    for(int i=1;i<n;i++){
        if(h[i]<=h[i-1])
            ans++;
        else{
            mx = max(mx,ans);
            ans=0;
        }
    }
    mx = max(mx,ans);
    cout<<mx<<'\n';
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;

int		main(void)
{
	int n;
	cin >> n;
	vector<int> a(n - 1);
	for (int i = 0; i < n - 1; i++)
		cin >> a.at(i);
	sort(a.begin(), a.end());
	vector<int> b(n);

	int j = a.at(0);
	int c = 0;

	for (int i = 0; i < n - 1; i++)
	{
		if (a.at(i) == j)
			c++;
		else
		{
			b.at(j - 1) = c;
			j  =a.at(i);
			c = 1;
		}
	}
	b.at(j - 1) = c;
	for (int j = 0; j < n; j++)
		cout << b.at(j) << endl;
}


Measured memory_bytes: 4844
#include<iostream>
using namespace std;
bool prime[5000005];
int main(){
	for(int i=0;i<5000005;i++)prime[i]=true;
	for(int i=3;i*i<10000000;i+=2)for(int j=i/2+i;j<5000005;j+=i)prime[j]=false;
	int n;
	while(true){
		cin>>n;
		if(n==0)break;
		if(n%2==0)n=n/2-1;
		else n/=2;
		while(true){
			if(prime[n]&&prime[n-1]&&prime[n-3]&&prime[n-4])break;
			n--;
		}
		cout<<n*2+1<<endl;
	}
	return 0;
}

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

int main() {

	int x, y, z;
	cin >> x >> y >> z;

	if (x > y) {
		if (x > z && z > y) {
			cout << "Yes\n";
		}
		else cout << "No\n";
	}
	if (y > x) {
		if (y > z && z > x) {
			cout << "Yes\n";
		}
		else cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int x;
    int y;
    int ans=0;
    
    cin >> x >> y;
    
    if(x==1){
        
        ans += 300000;
        
    } else if(x==2){
        
        ans += 200000;
        
    } else if(x==3){
        
        ans += 100000;
        
    }
    
    if(y==1){
        
        ans += 300000;
        
    } else if(y==2){
        
        ans += 200000;
        
    } else if(y==3){
        
        ans += 100000;
        
    }
    
    if(ans==600000){
        
        ans += 400000;
        
    }
    
    cout << ans << endl;

    return 0;
    
}

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

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

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

void solve() {
    int n;
    cin >> n;
    int maxv = -2*INF;// その時刻までの解答
    int minv = 2*INF;// その時刻までの最小値
    REP(_,n) {
        int r;
        cin >> r;
        chmax(maxv,r-minv);
        chmin(minv,r);
    }
    cout << maxv << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3112
#include <stdio.h>
 
int main(void) {
 
	// ??°????????\?????????????????????
	int input[3];
 
	// ??\??????????????°?????????????????\??????
	for (int cnt = 0; cnt < 3; cnt++) {
 
		scanf("%d", &input[cnt]);
 
	}

	// ??????????????°????????\???????????°
	int temporary = 0;

	// ????????????????????????
	for (int cnt2 = 0; cnt2 < 3; cnt2++) {
 
		for (int cnt3 = cnt2+1; cnt3 < 3; cnt3++) {
 
			if (input[cnt2] > input[cnt3]) {

				temporary =  input[cnt2];
				
				input[cnt2] = input[cnt3];

				input[cnt3] = temporary;
				
			}
		}
	}

	for(int cnt4 = 0; cnt4 < 3; cnt4++) {
		
		if(cnt4 < 2) {

			printf("%d ", input[cnt4]);

		} else {
			
			printf("%d\n", input[cnt4]);
		}
	}
	return 0;
}

Measured memory_bytes: 1784
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  ll k;
  cin >> k;
  ll a, b;
  cin >> a >> b;
  ll tmp = k;
  while(tmp <= b){
    if(a <= tmp && tmp <= b){
      cout << "OK" << endl;
      return 0;
    }
    tmp += k;
  }
  cout << "NG" << endl;
  return 0;
}


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

#define int long long int
#define ff first
#define ss second
#define pb push_back
#define print(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int bexp(int a, int b, int mod)
{
    int res = 1;

    while (b)
    {
        if (b & 1) res = (res * a) % mod;

        a = (a * a) % mod; 
        b >>= 1;
    }
    return res;
}

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

#define N 100010
#define MOD 1000000007

struct comp {
    bool operator() (const pair<int, int> a, const pair<int, int> b) const
    {
        return a.ss > b.ss;
    }
};


int32_t main() 
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(10);
    
    int n, a, b;
    cin >> n;

    int cnt = 0;
    for (int i = 0; i < n; ++i)
    {
        cin >> a >> b;

        if (a == b) {
            cnt++;
        }
        else {
            cnt = 0;
        }
            if (cnt > 2) {
                cout << "Yes\n";
                return 0;
            }
    }

    cout << "No\n";

    return 0;
}

Measured memory_bytes: 3652
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
using namespace std;
using ll = int64_t;
using vi = vector<int>;
using vvi = vector<vi>;

int main() {
    string s, t;
    cin >> s >> t;
    int num = s.size();
    vi si(num), ti(num);
    rep(i, num) {
        si[i] = s[i] - 'a';
        ti[i] = t[i] - 'a';
    }

    vi sc(26), tc(26);
    
    rep(i, num) {
        ++sc[si[i]];
        ++tc[ti[i]];
    }

    sort(sc.begin(), sc.end());
    sort(tc.begin(), tc.end());

    rep(i, 26) {
        if(sc[i]-tc[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 2312
s = input()
o = ['R','U','D']
e = ['L','U','D']
ans = 'Yes'
for i in range(len(s)):
    if i % 2 == 0:
        if s[i] not in o:
            ans = 'No'
    else:
        if s[i] not in e:
            ans = 'No'
print(ans)

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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

struct UnionFind {
    UnionFind(int n) {
        rank.assign(n, 0);
        parent.resize(n);
        for (int i = 0; i < n; ++i) {
            parent[i] = i;
        }
    }

    int find(int x) {
        if (x == parent[x])
            return x;
        return parent[x] = find(parent[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    void unit(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;

        if (rank[x] < rank[y]) {
            parent[x] = y;
        }
        else {
            parent[y] = x;
            if (rank[x] == rank[y])
                rank[x]++;
        }
    }

    vector<int> rank;
    vector<int> parent;
};

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

    ll N;
    cin >> N;
    priority_queue<tuple<pll, ll>, vector<tuple<pll, ll>>, function<bool(tuple<pll, ll>, tuple<pll, ll>)>> q(
            [](tuple<pll, ll> a, tuple<pll, ll> b) {
                return get<1>(a) > get<1>(b);
            });
    REP(i, N) {
        REP(j, N) {
            ll a;
            cin >> a;
            if (a < 0)
                continue;
            q.push(make_tuple(pll(i, j), a));
        }
    }
    UnionFind uf(N);
    ll ans = 0;
    while (!q.empty()) {
        auto t = q.top();
        q.pop();
        pll p = get<0>(t);
        if (uf.same(p.first, p.second))
            continue;
        uf.unit(p.first, p.second);
        ans += get<1>(t);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3256
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
    int n;
    cin >> n;
    int pans[n + 1];
    for(int i = 0; i < n; i++){
        cin >> pans[i];
    }
    int result = 20000;
    for(int i = 0; i <= pans[0]; i++){
        int tempPans[n];
        for(int j = 0; j < n; j++){
            tempPans[j] = pans[j];
        }
        int tempResult = 0;
        tempResult += i;
        tempPans[0] -= i;
        for(int j = 0; j < n - 1; j++){
            if(tempPans[j] > 0){
                tempResult += tempPans[j] * 2;
                tempPans[j + 1] -= tempPans[j];
                tempPans[j] = 0;
            }
        }
        if(tempPans[n - 1] > 0){
            tempResult += tempPans[n - 1];
        }
        result = min(result, tempResult);
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 3112
if __name__ == "__main__":
    n = int(input())
    cur_x = 0
    cur_y = 0
    cur_t = 0
    can_travel = True
    for _ in range(n):
        next_t, next_x, next_y = list(map(int, input().split(" ")))
        time_diff = abs(next_t - cur_t)
        x_diff = abs(next_x - cur_x)
        y_diff = abs(next_y - cur_y)

        if time_diff < (x_diff + y_diff):
            can_travel = False
        elif time_diff > (x_diff + y_diff):
            can_travel = ((time_diff - (x_diff + y_diff)) % 2 == 0)

        cur_t, cur_x, cur_y = next_t, next_x, next_y
        if not can_travel:
            break

    print("Yes" if can_travel else "No")



Measured memory_bytes: 3064
n=int(input())
s=list(map(int,input().split()))
q=int(input())
t=list(map(int,input().split()))
count=0
for i in t:
	left,right=0,n
	while left<right:
		mid=(left+right)//2
		if s[mid] ==i:
			count+=1
			break
		elif s[mid]<i:
			left =mid+1
		else:
			right=mid
print(count)




Measured memory_bytes: 16708
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    n=int(input())
    *a,=map(int,input().split())
    b=[a[0]]*2
    for i in a[1:]:
        b[-1]=min(i,b[-1])
        b.append(i)
    print(sum(b))
if __name__ == '__main__':
    main()


Measured memory_bytes: 5056
#include<bits/stdc++.h>
using namespace std;
#define I inline int
#define V inline void
#define ll long long int
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define REP(u) for(int i=h[u],v;v=e[i].t,i;i=e[i].n)
const int N=2e5+1,INF=0x3f3f3f3f;
ll ans,now,dis[N];
int n,m,tot,sum,minn,rt,p;
int siz[N],vis[N],h[N],w[N],fa[N];
struct edge{int t,n,w;}e[N<<1];
struct node{
	int x,y;ll w;
	I operator<(const node&u)const{return w<u.w;}
}a[N<<5];
V add_edge(int x,int y,int w){
	e[++tot]=(edge){y,h[x],w},h[x]=tot;
	e[++tot]=(edge){x,h[y],w},h[y]=tot;
}
V cmax(int&x,int y){if(x-y>>31)x=y;}
V getrt(int u,int fa=0){
	int maxn=0;siz[u]=1;
	REP(u)if(!vis[v]&&v!=fa)
		getrt(v,u),cmax(maxn,siz[v]),siz[u]+=siz[v];
	cmax(maxn,sum-siz[u]);
	if(maxn<minn)minn=maxn,rt=u;
}
V getdp(int u,int fa=0){
	siz[u]=1;
	if(dis[u]+w[u]<now)p=u,now=dis[u]+w[u];
	REP(u)if(!vis[v]&&v!=fa)
		dis[v]=dis[u]+e[i].w,getdp(v,u),siz[u]+=siz[v];
}
V dfs(int u,int fa=0){
	if(u!=p)a[++m]=(node){u,p,now+dis[u]+w[u]};
	REP(u)if(!vis[v]&&v!=fa)dfs(v,u);
}
V solve(int u){
	vis[u]=1,dis[u]=0,now=1ll<<62,getdp(u),dfs(u);
	REP(u)if(!vis[v])sum=siz[v],minn=INF,getrt(v),solve(rt);
}
I find(int x){return x==fa[x]?x:fa[x]=find(fa[x]);}
I merge(int x,int y){return(x=find(x))!=(y=find(y))&&(fa[x]=y);}
int main(){
	scanf("%d",&n),sum=n,minn=INF;
	FOR(i,1,n)scanf("%d",w+i),fa[i]=i;
	for(int x,y,w;--n;add_edge(x,y,w))scanf("%d%d%d",&x,&y,&w);
	getrt(1),solve(rt),sort(a+1,a+1+m);
	FOR(i,1,m)if(merge(a[i].x,a[i].y))ans+=a[i].w;
	return cout<<ans,0;
}

Measured memory_bytes: 66816
import java.util.*;
import java.io.*;
import java.lang.*;

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

        String s = sc.next();
        int len = s.length();

        String ans = "Yes";

        for (int i = 0; i<len; i++){
            if (i%2 == 0 && s.charAt(i) == 'L') {
                ans = "No";
                break;
            }
            else if (i%2 == 1 && s.charAt(i) == 'R'){
                ans = "No";
                break;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35712
#include<stdio.h>

int main(){
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(W >= x+r && H >= y+r && x >= r && y >= r){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
return 0;
}


Measured memory_bytes: 2148