akhauriyash/Code-Regression huggingface dataset:
import sys
from math import ceil, floor
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    a,b = map(int, input().split())
    
    def check(k):
        if floor(k*0.08) == a and floor(k*0.1) == b:
            return True
        else:
            return False
    # [k*0.08] = A
    # [k*0.1] = B
    # B <= k*0.1 <= B+1
    # A <= k*0.08 <= A+1

    m,n = a / 0.08, b/0.1
    
    for i in range(1300):
        if check(i):
            print(i)
            return
    print('-1')
    return

if __name__ == '__main__':
    main()

Measured memory_bytes: 64876
#include "bits/stdc++.h"
using namespace std;
#define pb push_back
#define fi first
#define se second
#define FF first
#define SS second
#define mp make_pair
#define ll long long
#define pii pair<int,int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define endl '\n'
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define sz(x) (int)x.size()
typedef long double f80;

const int N = 1e5 + 5;
multiset<f80> m;

signed main()
{
    #ifdef LOCAL
        freopen("inp.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    fr(i, 1, n) {
        int x;
        cin >> x;
        m.insert(x);
    }
    while(sz(m) > 1) {
        f80 val = *m.begin();
        m.erase(m.begin());
        f80 val1 = *m.begin();
        m.erase(m.begin());
        val += val1;
        val /= 2;
        m.insert(val);
    }
    cout << *m.begin();
    return 0;
}

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

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



Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <map>
#include <set>

using namespace std;

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

    int n;  cin >> n;
    int *b = new int[n];
    for (int i = 0; i < n; i++)
        cin >> b[i];

    sort(b, b+n);


    bool c[3][3] = {false};

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            if (binary_search(b, b+n, A[i][j]))
                c[i][j] = true;
        }
    }

    bool can = false;
    for (int i = 0; i < 3; i++) {
        if (c[i][1] && c[i][0] && c[i][2])
            can = true;
    }

    for (int i = 0; i < 3; i++) {
        if (c[0][i] && c[1][i] && c[2][i])
            can = true;
    }

    if (c[0][0] && c[1][1] && c[2][2])
        can = true;

    if (c[0][2] && c[1][1] && c[2][0])
        can = true;

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

    return 0;

}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
const double pi = acos(-1.0);
int n;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	printf("%.10f",pi*2*n);
	return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
//#pragma GCC optimize(2)

using namespace std;

#define LL long long
#define Re register
#define U unsigned
#define forn(i,a,b) for(int i = a;i <= b;++i)
#define nfor(i,a,b) for(int i = a;i >= b;--i)
#define CLR(i,a) memset(i,a,sizeof(i))
#define BR printf("--------------------\n")
#define pb push_back
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl
const double PI=atan(1.)*4.;
const int maxn=1e6+5;
const int inf = 0x3f3f3f3f;
const int mod=1e9+7;
const double e=2.71828182845904523536;
int dir[4][2]={1,0,0,1,-1,0,0,-1};

int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
   	cout.tie(0);
    int n;
    cin>>n;
    int ans=0;
    bool f=true;
    for(int i=1;i<=n;i++)
    {
        if(i==10||i==100||i==1000||i==10000||i==100000)
            f=!f;
        if(f)
            ans++;
    }
    cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import math
N, A, B = map(int, input().split())
all_attack = 0
enemy = [int(input()) for i in range(N)]


def possible_kill_all(attack):
    tmp_enemy = [v-B*attack for v in enemy]
    tmp_needed_attack = 0
    for v in tmp_enemy:
        if v>0:
            tmp_needed_attack += math.ceil(v/(A-B))
    if tmp_needed_attack <= attack:
        return True
    else:
        return False



possible = 10**14
impossible = 0

while possible - impossible > 1:
    M = (possible+impossible)//2
    if possible_kill_all(M):
        possible = M
    else:
        impossible = M

print(possible)



Measured memory_bytes: 18440
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int l,r,d;
   cin >> l >> r >> d;
   int ans=r/d-(l-1)/d;
   cout << ans << endl;
}

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
typedef long long ll;
ll d[51][51][2500];
int main(void){
    int n,a;
    cin>>n>>a;
    d[0][0][0]=1;
    for(int i=0,x;i<n;i++){
        cin>>x;
        for(int j=0;j<=i;j++){
            for(int k=0;k<2500;k++){
                if(d[i][j][k]){
                    d[i+1][j][k]+=d[i][j][k];
                    d[i+1][j+1][k+x]+=d[i][j][k];
                }
            }
        }
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        ans+=d[n][i][i*a];
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 48128
#include<cstdio>
#include<cstring>
using namespace std;

#define ll long long

#define file_io 0

ll i,j,md=1e9+7;
ll k,n,a[10005],lens,dp[10005][105];
char s[10005];

ll dfs(int pos,int sum,bool limit) {
	if(pos==lens+1) return dp[pos][sum] = (sum==0);

	if(limit==0 && dp[pos][sum] != -1) return dp[pos][sum];

	//12345, tried 123AB, A must <=4, limited
	//otherwise, A<=9
	int up=limit ? a[pos] : 9;
	ll newsum = 0;

	int t;
	for(t=0; t<=up; ++t) {
		newsum+=dfs(pos+1,(sum+t)%k,limit&&t==up);
		if(newsum>=md) newsum-=md;
	}

	if(limit==0) dp[pos][sum] = newsum;
	return newsum;
}

int main() {
	if (file_io) {
		freopen(".in","r",stdin);
		freopen(".out","w",stdout);
	}

	scanf("%s%lld",s+1,&k);

	memset(dp,-1,sizeof(dp));

	lens=strlen(s+1);
	for (i=1; i<=lens; ++i) {
		a[i]=(int)s[i]-48;
	}

	printf("%lld\n",(dfs(1,0,1)-1+md)%md);

	return 0;
}

Measured memory_bytes: 9216
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9

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

  vector<int> A(N);
  rep(i,N) cin >> A[i];

  ll count = 0;
  int right = 0;
  int sum = 0;

  for(int left = 0; left < N; ++left){
    while(right<N && ((sum+A[right]) == (sum^A[right]))){
      sum+=A[right];
      right += 1;
    }
    count += (right-left);
    if(left==right) right+=1;
    else{
      sum -= A[left];
    }
  }

  cout << count << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(){
  int k,s;
  int ans=0;
  cin >> k >> s;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      int z = s-i-j;
      if((z>=0) && (z<=k)){
        ans++;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
red, blue = [], []
ans = 0
for _ in range(n):
    a, b = map(int, input().split())
    red.append((max(a, b), a, b))
for _ in range(n):
    c, d = map(int, input().split())
    blue.append((min(c, d), c, d))
red.sort(key=lambda x: x[0], reverse=True)
blue.sort(key=lambda x: x[0])
for i in range(n):
    _, xb, yb = blue[i]
    for j in range(n):
        if red[j]:
            _, xr, yr = red[j]
            if xb > xr and yb > yr:
                red[j] = False
                ans += 1
                break
print(ans)


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

using namespace std;

const int e = 2e5 + 69;

vector<ll>adj[e];
ll par[e];
bool vs[e];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int u, v;
        cin >> u >> v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    for(int i=1; i<=n; i++){
        vs[i] = true;
    }
    queue<ll>q;
    q.push(1);
    vs[1] = false;
    while(q.size() != 0){
        ll cur = q.front();
        q.pop();
        for(auto j : adj[cur]){
            if(vs[j] == true){
                /*if(par[j] != 0 && par[j] != cur){
                    cout << "No";
                    return 0;
                }*/
                par[j] = cur;
                vs[j] = false;
                q.push(j);
            }
        }
    }
    for(int i=2; i<=n; i++){
        if(par[i] == 0){
            cout <<"No";
            return 0;
        }
    }
    cout << "Yes" <<"\n";
    for(int i=2; i<=n; i++){
        cout << par[i] <<"\n";
    }

}


Measured memory_bytes: 15460
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import defaultdict

def main():
  n = int(input())
  la = list(map(int, input().split()))
  cs_la = [0] * n
  for i in range(n):
    cs_la[i] += (cs_la[i-1] + la[i])
  
  cnts = defaultdict(int)
  for i in range(n):
    cnts[cs_la[i]] += 1
    
  cnt = 0
  for k, v in cnts.items():
    if k == 0:
      cnt += v
    cnt += ( v * (v-1) ) // 2
  print(cnt)
  
if __name__=='__main__':
  main()



Measured memory_bytes: 40960
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int H, W; cin >> H >> W;
	int K; cin >> K;
	VS S(H);
	REP(i, H)cin >> S[i];
	int ans = 0;
	int X = (1 << (H + W));
	//cout << X << endl;
	REP(i, X) {
		int cnt = 0;
		REP(a, H) {
			REP(b, W) {
				if (i&(1 << b) || i & (1 << (a + W)))continue;
				if(S[a][b]=='#')cnt++;


			}
		}
		//cout << i << " " << cnt << endl;
		if(cnt==K)ans++;

	}




	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main ()
{
 int x;
     cin>>x;
 int sum=0;
 string s;
      cin>>s;
 for(int i=0;i<=x;i++)
    {
        if (s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
            sum++;
    }
    cout<<sum<<endl;

    return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, A; scanf("%d %d", &N, &A);
  vector<int> X(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d", &X[i]);
    X[i] -= A;
  }

  int upper = N * A;
  int T = 2 * upper;
  vector<vector<ll>> dp(N + 5, vector<ll>(T + 5, 0));
  dp[0][upper] = 1;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j <= T; ++j) {
      dp[i + 1][j] += dp[i][j];
      if (0 <= j - X[i] and j - X[i] <= T) {
        dp[i + 1][j] += dp[i][j - X[i]];
      }
    }
  }
  ll ans = dp[N][upper] - 1;
  printf("%lld\n", ans);
  return 0;
}


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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  char c;
  cin >> c;

  cout << (char) (c + 1) << endl;
  return 0;
}


Measured memory_bytes: 256
Option Infer On
Imports System.Collections.Generic
Imports System.Console
Imports System.Math

Module Program
    Sub Main()
        Dim N As Integer = NextInt()
        Dim a As Integer() = New Integer(N - 1) {}

        For i = 0 To N - 1
            a(i) = NextInt()
        Next

        Dim j = 1
        For i = 1 To N
            j = a(j - 1)
            If j = 2 Then
                WriteLine(i)
                Exit Sub
            End If
        Next

        WriteLine(-1)
    End Sub

    Function NextInt() As Integer
        Return CInt(NextString())
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 26856
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, i, count = 0, start, end;
  cin >> N;
  
 for ( i = 0; i < N; i++) { 
   cin >> start >> end ;
	count += end - start + 1;
 }
  cout << count << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    vector<int> v(3);
    for (int i = 0; i < 3; ++i) cin >> v[i];
    cout << accumulate(v.begin(), v.end(), 0) - *std::max_element(v.begin(), v.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <functional>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <iomanip>

using namespace std;

inline int solution(istream &cin, ostream &cout) {
  int a, b;
  cin >> a >> b;
  cout << a + b / 2 << endl;
  return 0;
}

#if defined(LOCAL_TEST_RUN)

#include "gtest/gtest.h"
#include "gmock/gmock-matchers.h"
#include "gmock/gmock-more-matchers.h"
#include <sstream>

typedef pair<string, string> TestParam;
class ATest : public ::testing::TestWithParam<TestParam> {};

TEST_P(ATest, ExampleTest) {
  string input, expected_output;
  tie(input, expected_output) = GetParam();

  stringstream ss(input);
  stringstream out;
  solution(ss, out);
  EXPECT_THAT(out.str(), ::testing::StartsWith(expected_output));
}

INSTANTIATE_TEST_CASE_P(Case1, ATest, ::testing::Values(
  make_pair(
      /*input=*/R"(81 58)",
      /*output=*/R"(110)")
));

INSTANTIATE_TEST_CASE_P(Case2, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"(4 54)",
        /*output=*/R"(31)")
));

INSTANTIATE_TEST_CASE_P(Case3, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

INSTANTIATE_TEST_CASE_P(Case4, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

INSTANTIATE_TEST_CASE_P(Case5, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

INSTANTIATE_TEST_CASE_P(Case6, ATest, ::testing::Values(
    make_pair(
        /*input=*/R"()",
        /*output=*/R"()")
));

#else

int main() {
  return solution(cin, cout);
}

#endif

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m;
    cin>>n>>m;
    set<int> se;
    se.insert(0);
    vi vec(n,1);
    REP(i,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        if(se.count(x)){
            se.insert(y);
            if(vec[x]==1){
                se.erase(x);
            }
        }
        vec[x]--;
        vec[y]++;
    }
    cout<<se.size()<<endl;
    return 0;
}

Measured memory_bytes: 5376
#import collections
N,M = map(int,input().split())
l = []

for i in range(N):
    ab = tuple(map(int,input().split()))
    l.append(ab)
l.sort(key=lambda x:x[0])

res = 0
for t in l:
    if t[1] < M:
        res += t[0]*t[1]
        M -= t[1]
    elif t[1] >= M:
        res += t[0]*M
        break
print(res)

Measured memory_bytes: 18120
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define endl "\n"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

const long long MOD = 998244353;
const long long ALTMOD = 100000007;

const int INF = 0x3F3F3F3F;
const long long INFLL = 0x3F3F3F3F3F3F3F3F;

void set_IO(string s) {
    freopen((s + ".in").c_str(), "r", stdin);
    freopen((s + ".out").c_str(), "w", stdout);
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int N; cin >> N;
    int X = (N % 2 == 0) ? N / 2 : (N / 2) + 1;
    cout << X << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();

        if (u.equals(s)) {
            a -= 1;
        } else {
            b -= 1;
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const int MAX_N = 100010;
vector<int> tree[MAX_N];

void dfs(int v, vector<int>& d)
{
    queue<int> q;
    q.push(v);
    while (!q.empty()) {
        int t = q.front();
        q.pop();
        for (auto c : tree[t]) {
            if (d[c] == 0 && c != v) {
                d[c] = d[t] + 1;
                q.push(c);
            }
        }
    }
}

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

    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }

    vector<int> d0(N, 0), dN(N, 0);

    dfs(0, d0);
    dfs(N - 1, dN);

    int sum = 0;
    rep(i, N) {
        if (d0[i] <= dN[i]) sum += 1;
        else sum -= 1;
    }

    if (sum > 0) {
        cout << "Fennec" << endl;
    }
    else {
        cout << "Snuke" << endl;
    }
    return 0;
}

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

double DP[3005][3005][2];
bool vis[3005][3005][2];
int N,K;
double arr[3005],arrD[3005];

double dp(int pos, int tail, int st){
//	printf("%d %d %d\n",pos, tail, st);
	
	if(tail>K) return 0;
	if(pos>=N-1){
		if(st == 1)return arr[N-1];
		return arrD[N-1];
	}
	if(vis[pos][tail][st]) return DP[pos][tail][st];
	
	vis[pos][tail][st] = 1;
	if(st==1){
		
		return DP[pos][tail][st] = arr[pos]*(dp(pos+1,tail+1,0) + dp(pos+1,tail,1));
	} else {
		return DP[pos][tail][st] = (arrD[pos])* (dp(pos+1,tail+1,0) + dp(pos+1,tail,1));
	}
}

int main(){
	memset(vis,0,sizeof vis);
	scanf("%d",&N);
	for (int i =0; i<N;i++){
		scanf("%lf",&arr[i]);
		arrD[i] = 1.000-arr[i];
	}
	K = N/2;
	double ans = dp(0,1,0) + dp(0,0,1);
	printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 158592
#include <iostream>
#include<map>
#define REPD(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) REPD(i, 0, n)

using namespace std;
#define fin(ans) cout << (ans) << '\n'
int main()
{
    string S;
    bool flag = true;
    cin >> S;
    map<char,int> m;
    REP(i,S.length()){
        m[S[i]]++;
    }
    REP(i,S.length()){
        if(m[S[i]] == 2){
            continue;
        }else{
            flag = false;break;
        }
    }
    if(flag)fin("Yes");
    else fin("No");
    return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
typedef pair<int,int> iP;
int power(int x,int y){
    int res=1;
    x=x%mod;
    while(y>0){
        if(y&1)res=(res*x)%mod;
        x=(x*x)%mod;
        y/=2;
    }
    return res;
}
int mulmod(int a,int b){ 
    int res=0;
    a=a%mod; 
    while(b>0){
        if(b%2==1) 
        res=(res+a)%mod; 
        a=(a*2)%mod; 
        b/=2;
    } 
    return res%mod; 
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);cout<<fixed;
    int n,a,b;
    cin>>n>>a>>b;
    if((a-b)%2==0)
    cout<<(abs(a-b))/2;
    else{
        int x=min(a,b),y=max(a,b);
        x=n-max(a,b);y=min(a,b)-1;
        x++;y++;
       // cout<<x<<" "<<y<<" ";
        cout<<min(x+(n-(min(a,b)+x))/2,y+(max(a,b)-y-1)/2);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long pow_mod(long long n,long long k,long long m){
    if (k == 0){
        return 1;
    } else if (k % 2 == 1){
        return pow_mod(n,k-1,m)*n % m;
    } else {
        long long t = pow_mod(n,k/2,m);
        return t*t % m;
    }
}

const int COM_MAX = 500500;
long long fac[COM_MAX],finv[COM_MAX],inv[COM_MAX];
void init(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < COM_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 || n < 0 || k < 0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int par[100010],dep[100010];
void init(int N){
    for(int i = 0; i < N; i++){
        par[i] = i;
        dep[i] = 0;
    }
}

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

void merge(int a,int b){
    a = find(a);
    b = find(b);
    if (dep[a] > dep[b]){
        par[b] = a;
        dep[a] += b;
    } else {
        par[a] = b;
        dep[b] += a;
    }
}

int main(){
    long long N,a[100010],b[100010],ans = 0;
    cin >> N;
    for(int i = 0; i < N+1; i++){
        cin >> a[i];
    }
    for(int i = 0; i < N; i++){
        cin >> b[i];
        if (a[i] >= b[i]){
            a[i] -= b[i];
            ans += b[i];
        } else if (a[i] + a[i+1] > b[i]){
            ans += b[i];
            b[i] -= a[i];
            a[i+1] -= b[i];
        } else {
            ans += a[i]+a[i+1];
            a[i] = 0;
            a[i+1] = 0;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner sc = null;
		Map<String, Integer> map = new HashMap<String, Integer>();
		try {
			sc = new Scanner(System.in);
			String maxFrequencyWord = "";
			String maxLengthWord = "";

			String[] sentence = sc.nextLine().split(" ");

			for (String s : sentence) {
				map.put(s, map.containsKey(s) ? map.get(s) + 1 : 1);
			}

			int maxFrequency = Collections.max(map.values());

			for (Map.Entry<String, Integer> entry : map.entrySet()) {
				if (maxFrequency == entry.getValue()) {
					maxFrequencyWord = entry.getKey();
				}
			}
			maxLengthWord = Collections.max(map.keySet(), new Comparator<String>() {
				@Override
				public int compare(String o1, String o2) {
					return o1.length() - o2.length();
				}
			});

			System.out.println(maxFrequencyWord + " " + maxLengthWord);

		} finally {
			sc.close();
		}
	}
}

Measured memory_bytes: 25892
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#include <cstring>
#include <cstdio>
#include <stack>
#define INF 1000000000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

int main(){
    for (;;) {
        int n,q;
        cin >> n>> q;
        if (!n and !q) {
            break;
        }
        map<string, int> cal;
        vector<string> re(1002);
        int ans[1002][2];
        memset(ans, 0, sizeof(ans));
        int pa=1;
        for (int i=0; i<n; i++) {
            string s;
            int a,b;
            cin >> s >> b >> a;
            if (cal[s]==0){
                re[pa]=s;
                cal[s]=pa;
                ans[cal[s]][0]=a-b+1;
                ans[cal[s]][1]=a;
                pa++;
            }else{
                ans[cal[s]][0]=min(a-b+1,ans[cal[s]][0]);
                ans[cal[s]][1]=max(a,ans[cal[s]][1]);
            }
        }
        for (int i=0; i<q; i++) {
            int y;
            cin >> y;
            int ch = 0;
            for (int i=1; i<=n;i++) {
                int a = ans[i][0], b = ans[i][1];
                if (a<= y and y <= b) {
                    cout << re[i] <<" "<< y-ans[i][0]+1<< endl;
                    ch++;
                    break;
                }
            }
            if(ch == 0) cout <<"Unknown"<<endl;
            
        }
    }
}

Measured memory_bytes: 1356
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B, C, D, l, r;
  cin >> A >> B >> C >> D;
  l = A + B;
  r = C + D;
  if (l > r) {
    cout << "Left" <<endl;
  }
  else if (l < r) {
    cout <<"Right" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
struct S
{
    //double a;
    int x,y;
};
vector<int> v[33110];

int a,b,c,i,k,d,n,m,e,dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};
int l[218111];
int o[212000];
//int dx[10]={1,0,1,-1,-1,0},dy[10]={0,1,1,1,-1,-1};

long long x,y,z[555];
P u[1222];
int j[2];
//priority_queue<int,vector<int>,greater<int> > q,q1;
stack<int> s,s1;
queue<int> q;

//deque<int> de;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
string r,r1;
//char r[10010];

bool as(P a,P b)
{

    return a.x<b.x;
}



int main()
{
    cin>>r;
    i=1;
    o[1]=1;
    for(int t=1;t<r.size();t++)
        if(r[t-1]==r[t]) o[i]++;
        else i++,o[i]=1;
    if(i<=2)
    {
        printf("%d",max(o[1],o[2]));
        return 0;
    }
    k=0;

    for(int t=i;t>=1;t--)
        o[t]+=o[t+1];
    //for(int t=1;t<=i;t++)
    //    printf("%d ",o[t]);
    for(int t=1;t<=i;t++)
    {
        int n=t,m=i;
        for(;n<m;)
        {
            //printf("%d %d\n",n,m);
            int h=(n+m)/2;
            k=max(k,min(-o[h+1]+o[t],-o[i+1]+o[h]));
            if(-o[h+1]+o[t]>=-o[i+1]+o[h]) m=h;
            else n=h+1;

        }
    }
    printf("%d",k);
}


Measured memory_bytes: 1408
def g;gets.split.map &:to_i;end
while(n,m=g)[0]>0
d=(0..n).map{[]}
m.times{s,t=g;d[s]<<t;d[t]<<s}
l=[0]+g
r=[0]+(1..n).map{g[1..-1].sort}
h={l<<1=>[]}
q=l[1]<1?[]:[l]
q.map{|w|*t,a=w
d[a].map{|i|t[i]>0&&h[v=t+[i]]||=(q<<v;["Move to room #{i}.",w])}
r[a].map{|i|u=w.dup;v=u[i]^=1;a!=i &&h[u]||=(q<<u;["Switch o#{v>0??n:"ff"} room #{i}.",w])}}
puts (h[c=[0]*n+[1,n]])?(s=[]
s=[l]+s while(l,c=h[c])[1]
["You can go home in #{s.size} steps."]+s):h.all?{|k,v|k[n+1]<n}?"Help me!":"You can not switch off all lights."
end

Measured memory_bytes: 36264
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const int INF=1e17;
const long double PI=acos(-1);



void solve(int T){
    int n,m;
    cin>>n>>m;
    int x=n/m;
    x+=(n%m>0);
    cout<<x<<"\n";
}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}




Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define S 500005
#define M 100000000
#define nl cout<<"\n";
#define er  cout<<"\n***********\n";
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test lli t;  cin>>t; while(t--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (lli)(x.size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define Y cout<<"YES\n";
#define N cout<<"NO\n";
#define print(x)                 cout<<#x<<": "<<x<<endl;
#define print2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl;
#define print3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define print4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define print5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl;
#define print6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl;

void solve()
{
    lli n,ans=(lli)1e16;cin>>n;
    for(lli i=1;i*i<=n;i++)
    {
        if(n%i==0)
        {
            ans=min(ans,i+n/i-2);
        }
    }

    cout<<ans;




}


int main()
{
    fast
    #ifndef ONLINE_JUDGE
     freopen("inputa.txt", "r", stdin);
     freopen("outputa.txt", "w", stdout);
    #endif    
     
     // test
     {
          solve();
          nl
     }
}
//a+b=a?b+2?(a&b)
//__builtin_popcnt(number)
//cout<<fixed<<setprecision(8)<<output<<"\n";

Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
const int INF=1000000000;
const int MOD_2=998244353;


int main()
{
	LL n,ans=0;
	string s;
	cin>>n>>s;
	
	LL r=0,g=0,b=0;
	for(int i=0;i<n;i++)
	{
		if(s[i]=='R')r++;
		if(s[i]=='G')g++;
		if(s[i]=='B')b++;
	}	
	ans=r*g*b;
	
	for(int i=0;i<n;i++)
	{
		for(int dist=1; i-dist>=0 && i+dist<n; dist++)
		{
			if(s[i-dist]!=s[i] && s[i]!=s[i+dist]
			 && s[i-dist]!=s[i+dist])ans--;
		}
	}
	cout<<ans<<"\n";
	return 0;
}
	

Measured memory_bytes: 3644
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    map<char, LLONG> char2NumMap;
    for (int i = 0; i < N; ++i)
    {
        string Si; cin >> Si;
        switch (Si[0])
        {
        case 'M':
            ++char2NumMap[Si[0]];
            break;
        case 'A':
            ++char2NumMap[Si[0]];
            break;
        case 'R':
            ++char2NumMap[Si[0]];
            break;
        case 'C':
            ++char2NumMap[Si[0]];
            break;
        case 'H':
            ++char2NumMap[Si[0]];
            break;
        }
    }
    // ３文字種以上ない場合は０通り
    if (char2NumMap.size() < 3)
    {
        cout << 0 << endl;
    }
    // ３文字種以上ある場合，全ての組み合わせを計算。高々5C3=10通り
    else
    {
        vector<LLONG> nums;
        for (const auto &kvp : char2NumMap)
        {
            nums.push_back(kvp.second);
        }
        int N = static_cast<int>(nums.size());
        LLONG ans = 0;
        for (int i = 0; i < N; ++i)
        {
            for (int j = i + 1; j < N; ++j)
            {
                for (int k = j + 1; k < N; ++k)
                {
                    ans += nums[i] * nums[j] * nums[k];
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    string s; cin >> s;
    int a = (s[0] - '0') * 10 + (s[1] - '0');
    int b = (s[2] - '0') * 10 + (s[3] - '0');
    if(a > 12 || a == 0) {
        if(b > 12 || b == 0) {
            cout << "NA" << endl;
        } else {
            cout << "YYMM" << endl;
        }
    } else {
        if(b > 12 || b == 0) {
            cout << "MMYY" << endl;
        } else {
            cout << "AMBIGUOUS" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
def d_prediction_and_restriction():
    from itertools import groupby
    N, K = [int(i) for i in input().split()]
    R, S, P = [int(i) for i in input().split()]
    T = input()

    ans = 0
    for i in range(K):
        tmp = groupby(T[i:N:K])
        for k, lst in tmp:
            v = len(list(lst))
            if v == 1:
                t = 1
            elif v % 2 == 0:
                t = v // 2
            else:
                t = v // 2 + 1
            if k == 'r':
                ans += P * t
            elif k == 's':
                ans += R * t
            elif k == 'p':
                ans += S * t
    return ans

print(d_prediction_and_restriction())

Measured memory_bytes: 4212
#[allow(unused_imports)]
use {
   proconio::{fastout, input, marker::*},
   std::cmp::*,
   std::collections::*,
};

#[fastout]
fn main() {
   input! {
      s: Bytes
   }
   let n = s.len();
   for i in 0..n-1 {
      if s[i] == s[i+1] {
         println!("{} {}", i+1, i+2);
         return;
      }
   }
   for i in 0..n-2 {
      if s[i] == s[i+2] {
         println!("{} {}", i+1, i+3);
         return;
      }
   }
   println!("-1 -1");
}



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

int I[256];
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n)scanf("%d", &I[i]);
		int S, A, C;
		double Min = INFINITY;
		rep(s, 16)rep(a, 16)rep(c, 16) {
			int r = s;
			int mp[256]{};
			rep(i, n) {
				r = (a*r + c) % MOD;
				mp[(I[i] + r) % MOD]++;
			}
			double sum = 0;
			rep(i, 256) {
				if (!mp[i])continue;
				double d = mp[i] / double(n);
				sum -= d*log10(d);
			}
			if (Min > sum + 1e-10) {
				Min = sum; S = s; A = a; C = c;
			}
		}
		printf("%d %d %d\n", S, A, C);
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m; cin>>n>>m;
    vi p(n);
    rep(i,n) cin>>p[i];
    vector<vi> adj(n);
    rep(i,m){
        int x,y; cin>>x>>y; x--; y--;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    vector<bool> visit(n,false);
    int ans=0;
    rep(i,n){
        if (visit[i]) continue;
        set<int> s1,s2;
        queue<int> que;
        que.push(i);
        while(que.size()){
            int v=que.front(); que.pop();
            visit[v] = true;
            s1.ins(v);
            s2.ins(p[v]);
            for(auto u:adj[v]){
                if (visit[u]) continue;
                que.push(u);
            }
        }
        for(auto e:s1){
            if (s2.count(e+1)) ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 15488
#include <iostream>
#include <cmath>

#define Yes(condition) cout << (condition ? "Yes" : "No") << endl

using namespace std;

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    Yes(abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d));
    return 0;
}


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

int main(){
    int k,a,b;
    cin >> k >> a >> b;
    if(a%k==0 || b%k==0){
        cout << "OK" << endl;
    }
    else if((b/k)-(a/k) > 0){
        cout << "OK" << endl;
    }
    else cout << "NG" << endl;
    return 0;
}


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

int main() {
  int hh, w, t, p;
  while (cin >> w >> hh >> t >> p, w) {
    int res[40][40];
    for (int i = 0; i < 40; i++) for (int j = 0; j < 40; j++) res[i][j] = 0;
    for (int i = 0; i < hh; i++) for (int j = 0; j < w; j++) res[i][j] = 1;
    for (int ii = 0; ii < t; ii++) {
      int d, c; cin >> d >> c;
      int tmp[40][40];
      for (int i = 0; i < 40; i++) for (int j = 0; j < 40; j++) tmp[i][j] = 0;
      if (d == 1) {
        for (int i = 0; i < 40; i++) {
          for (int j = c; j < 40; j++) {
            tmp[i][j - c] += res[i][j];
          }
        }
        for (int i = 0; i < 40; i++) {
          for (int j = c - 1; j >= 0; j--) {
            tmp[i][c - 1 - j] += res[i][j];
          }
        }
      } else {
        int h = 0;
        for (int i = 0; i < 40; i++) {
          if (res[i][0] != 0) h++;
        }
        if (c >= h - c) {
          for (int i = h - 1; i >= h - c; i--) {
            for (int j = 0; j < 40; j++) {
              tmp[h - 1 - i][j] += res[i][j];
            }
          }
          for (int i = 0; i < h - c; i++) {
            for (int j = 0; j < 40; j++) {
              tmp[i + 2 * c - h][j] += res[i][j];
            }
          }
        } else {
          for (int i = 0; i < h - c; i++) {
            for (int j = 0; j < 40; j++) {
              tmp[i][j] += res[i][j];
            }
          }
          int now = c;
          for (int i = h - 1; i >= h - c; i--) {
            for (int j = 0; j < 40; j++) {
              tmp[i - 2 * now + 1][j] += res[i][j];
            }
            now--;
          }
        }
      }
      for (int i = 0; i < 40; i++) {
        for (int j = 0; j < 40; j++) {
          res[i][j] = tmp[i][j];
        }
      }
    }
    int hlen = 0;
    for (int i = 0; i < 40; i++) {
      if (res[i][0] != 0) hlen++;
    }
    for (int i = 0; i < p; i++) {
      int x, y; cin >> x >> y;
      cout << res[hlen - 1 - y][x] << endl;
    }
  }
}


Measured memory_bytes: 3104
#include <bits/stdc++.h> 
#define M 1000000007
#define forz(i,s,n) for(lli i=s;i<n;i++)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
typedef long long int lli; 
 
using namespace std;
 
bool sortbysec(const pair<string, lli> &a,const pair<string, lli> &b){
    return (a.second < b.second);
}
lli highest2(lli n){
    lli x=n;
    while(n){
        x=n;
        n=n&(n-1);
    }
    return x;
}
int main(){
    fast_io;
    lli m,k,t,row,col,n,i,b,p,j,p0,p1,mno,R,r,br,x,count=0;
    string s,y;
    cin>>n;
    lli h[n+1];
    forz(i,1,n+1)cin>>h[i];
    lli dp[n+1];
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    forz(i,3,n+1){
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    } 
    //cout<<dp[n-1]<<endl;
    cout<<dp[n];
    cout<<endl;      
    return 0;
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<long long> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());

    long long ans1 = 0;
    for(int i = 0; i < n/2-1; i++){
        ans1 += v[i] * 2;
    }
    ans1 += v[n/2-1];
    if(n%2 == 0) ans1 -= v[n/2];
    else ans1 += v[n/2];
    for(int i = n/2+1; i < n; i++){
        ans1 -= v[i] * 2;
    }

    long long ans2 = 0;
    for(int i = 0; i < (n-1)/2; i++){
        ans2 += v[i]*2;
    }
    if(n%2 == 0) ans2 += v[(n-1)/2];
    else ans2 -= v[(n-1)/2];
    ans2 -= v[(n-1)/2+1];
    for(int i = (n-1)/2+2; i < n; i++){
        ans2 -= v[i] * 2;
    }

    cout << max(ans1, ans2) << endl;
    return 0;
}

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

using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

signed main(){

	lli n;
	cin>>n;

	lli x=0;
	lli ans = 0;
	REP(i,0,n){
		char s;
		cin>>s;
		x += (s=='I'?1:-1);
		ans = max(ans,x);
	}
	cout<<ans<<endl;


	return 0;
}

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

const int inf = 1e9;
const ll linf = 1e18;

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

    int n, m; cin >> n >> m;
    cout << (1 << m) * (1900 * m + 100 * (n - m)) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

char s[51];
int a[26];
int b[26];

int main() {
    int n, i, j;
    
    for (i = 0; i < 26; i++) a[i] = 100;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int m;
        
        scanf("%s", s);
        
        m = strlen(s);
        
        for (j = 0; j < 26; j++) b[j] = 0;
        
        for (j = 0; j < m; j++) b[s[j] - 'a']++;
        
        for (j = 0; j < 26; j++) a[j] = min(a[j], b[j]);
    }
    
    for (i = 0; i < 26; i++) {
        for (j = 0; j < a[i]; j++) putchar('a' + i);
    }
    
    puts("");
    
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll n , a, b;
    cin >> n >> a >> b;
    ll cnt = n / (a + b);
    n %= (a + b);
    ll ans = cnt * a;
    ans += min(n, a);
    cout << ans << endl;
}


Measured memory_bytes: 256
//
/*
//*/
//#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define MAX(x,y) (((x)>(y))?(x):(y))
#define MIN(x,y) (((x)<(y))?(x):(y))
#define lowbit(x) ((x)&-(x))
struct IO{
	inline char gc() {static char buf[10000000],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,10000000,stdin),p1==p2)?EOF:*p1++;}
    #ifdef ONLINE_JUDGE
    #else
    	#define gc getchar
    #endif
	template<typename T>inline IO operator>>(T &n){n=0; bool s=0; char c=gc();while(c<'0'||c>'9') s|=c=='-',c=gc();while(c>='0'&&c<='9') n=(n<<3)+(n<<1)+(c^48),c=gc();if(s) n=-n;return *this;}
	template<typename T>inline IO operator<<(T x){if (x<0) x=-x,putchar('-');static T sta[35];T top = 0;do{sta[top++] = x % 10, x /= 10;}while (x);while (top) putchar(sta[--top] + '0');return *this;}
}cin,cout;
int n;
int main ()
{
	#ifdef ONLINE_JUDGE
	#else
	//freopen("E:\\testdata.in","r",stdin);
	//freopen("E:\\testdata1.out","w",stdout);
	#endif
	cin>>n;
	cout<<(n-1)/2;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
int A[5], T, M;

int main(void){
	//IO("test.in", "test.out");
	M = INT_MAX;
	scanf("%d%d%d%d%d", &A[0], &A[1], &A[2], &A[3], &A[4]);
	for(int i = 0; i < 5; i++)
		if(A[i] % 10 != 0) T += A[i] + (10 - A[i] % 10);
		else T += A[i];
	for(int i = 0; i < 5; i++)
		if(A[i] % 10 != 0 && T - (10 - A[i] % 10) < M) M = T - (10 - A[i] % 10);
		else if(A[i] % 10 == 0 && T < M) M = T;
	printf("%d\n", M); 
}

Measured memory_bytes: 256