akhauriyash/Code-Regression huggingface dataset:
/*its_Rashid*/
#include <bits/stdc++.h>
using namespace std ;

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

int main ()
{
    fastio

    lli num1 , num2 , a[] = {1 , 2 , 3} ;
    bool t = 0 ;
    cin >> num1 >> num2 ;

    for (lli i = 0 ; i < 3 ; i ++)
    {
        if ((num1 * num2 * i) % 2 == 1)
            t = 1 ;
    }
    (t ? Yes : No) ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
vll fa(100005, 1), fare(100005, 1);
long long comb(long long n, long long r){
	if(n<r) return 0;

	return (((fa[n]*fare[n-r])%MOD)*fare[r])%MOD;
}
long long repeat_pow(long long x, int n){
	long long ans=1;

	while(n>0) {
		if((n&1)==1){
			ans=ans*x;
			if(ans>=MOD) ans%=MOD;
		}
		x=(x*x)%MOD; //一周する度にx, x^2, x^4, x^8となる
		n>>=1; //桁をずらす n = n >> 1
	}
	return ans;
}
int main(void)
{
	int n, len[3], db;

	cin>>n;

	vi a(n+1), cnt(n+1, 0);

	rep(i, n+1){
		cin>>a[i];
		cnt[a[i]]++;
		if(cnt[a[i]]==2){
			db=a[i];
		}
	}

	int count=0, ptr=0;
	rep(i, n+1){
		if(a[i]==db){
			len[ptr++]=count;
			count=0;
		}else{
			count++;
		}
	}
	len[2]=count;



	ll temp=1;
	repr(i, 1, n+5){
		temp*=i;
		if(temp>=MOD) temp%=MOD;
		fa[i]=temp;
	}
	fare[n+4]=repeat_pow(fa[n+4], (int)MOD-2);
	reprrev(i, 1, n+5){
		fare[i-1]=(fare[i]*i)%MOD;
	}

	repr(i, 1, n+2){
		if(i==1){
			cout<<n<<endl;
		}else{
			cout<<(comb(n+1, i)-comb(len[0]+len[2], i-1)+MOD)%MOD<<endl;
		}
	}
}

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

/*
#include <boost/functional/hash.hpp>
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int mlint;
*/

#define debug 0
#define fcout(d) cout << fixed << setprecision(d)
#define urep(i,s,t) for(int i = (int)(s); i <= (int)(t); ++i)
#define drep(i,s,t) for(int i = (int)(s); i >= (int)(t); --i)
#define rep(i,n) urep(i,0,(n) - 1)
#define rep1(i,n) urep(i,1,(n))
#define rrep(i,n) drep(i,(n) - 1,0)
#define all(v) begin(v),end(v)
#define rall(v) rbegin(v),rend(v)
#define vct vector
#define prique priority_queue
#define l_bnd lower_bound
#define u_bnd upper_bound
#define rsz resize
#define era erase
#define emp emplace
#define emf emplace_front
#define emb emplace_back
#define pof pop_front
#define pob pop_back
#define mkp make_pair
#define mkt make_tuple
#define fir first
#define sec second
#define odd(x) ((x) & 1)
#define even(x) (~(x) & 1)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef vct<vct<ll>> mat;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tiii;
typedef map<int,int> mpii;
typedef unordered_map<int,int> umpii;

const int dir[8][2] = { {1,0},{0,1},{-1,0},{0,-1},{1,1},{-1,1},{-1,-1},{1,-1} };
const ll inf32 = (1 << 30) - 1;
const ll inf64 = (1LL << 62) - 1;
const ll mod = 1e9 + 7;
const db eps = 1e-9;

template <class T, class U> T qceil(T x, U y) { return x > 0 ? (x - 1) / y + 1 : x / y; }
template <class T, class U> bool parity(T x, U y) { return odd(x) ^ even(y); }
template <class T, class U> bool chmax(T &m, U x) { if(m < x) { m = x; return 1; } return 0; }
template <class T, class U> bool chmin(T &m, U x) { if(m > x) { m = x; return 1; } return 0; }
template <class T> bool cmprs(T &v) {
    T tmp = v;
    sort(all(tmp));
    tmp.erase(unique(all(tmp)),end(tmp));
    for(auto it = begin(v); it != end(v); ++it) *it = l_bnd(all(tmp),*it) - begin(tmp) + 1;
    return v.size() > tmp.size();
}

template <class T> void esc(T ret) {
    cout << ret << endl;
    exit(0);
}

int n,x[101],y[101],h[101];

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

    cin>>n;
    rep(i,n) cin>>x[i]>>y[i]>>h[i];
    rep(X,101)rep(Y,101){
        ll H = 0,ub = inf64;
        bool f=1;
        rep(i,n){
            if(f){
                if(h[i]){
                    int dx=abs(x[i]-X);
                    int dy=abs(y[i]-Y);
                    if(H && H != dx+dy+h[i]){ f=0;break; }
                    H = dx+dy+h[i];
                }else{
                    int dx=abs(x[i]-X);
                    int dy=abs(y[i]-Y);
                    chmin(ub,dx+dy);
                }
            }
        }
        if(f&&ub>=H&&H){
            cout<<X<<' '<<Y<<' ';
            esc(H);
        }else{
            if(f&&ub==1&&!H) cout<<X<<' '<<Y<<' ',esc(1);
        }
    }
}


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

#define x first
#define y second
#define all(x) begin(x), end(x)
typedef long long ll;

const int MAX_N = 1024;

char ans[MAX_N][MAX_N];

char for4[][5] = {
	"aacd",
	"bbcd",
	"efgg",
	"efhh"
};
char for5[][6] = {
	"aabbc",
	"hii.c",
	"h..jd",
	"g..jd",
	"gffee"
};

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	if (n == 2) {
		cout << "-1\n";
	} else if (n == 3) {
		cout << "aa.\n..b\n..b\n";
	} else if (n == 6) {
		cout << "aabb..\nb..zz.\nba....\n.a..aa\n..a..b\n..a..b\n";
	} else if (n == 7) {
		cout << "\
.aabaa.\n\
a..b..a\n\
a.cc..a\n\
bb..dbb\n\
a...d.a\n\
a..b..a\n\
.aabaa.\n";
	} else if (n == 11) {
		cout << "\
.aabaa.....\n\
a..b..a....\n\
a.cc..a....\n\
bb..dbb....\n\
a...d.a....\n\
a..b..a....\n\
.aabaa.....\n\
.......aacd\n\
.......bbcd\n\
.......efaa\n\
.......efbb\n\
";
	} else {
		int offset = 0;
		int oldn = n;
		while (n % 4 != 0) {
			for (int i = 0; i < 5; ++i)
				for (int j = 0; j < 5; ++j)
					ans[i + offset][j + offset] = for5[i][j];
			offset += 5;
			n -= 5;
		}
		while (n) {
			for (int i = 0; i < 4; ++i)
				for (int j = 0; j < 4; ++j)
					ans[i + offset][j + offset] = for4[i][j];
			offset += 4;
			n -= 4;
		}
		n = oldn;
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < n; ++j) {
				if (ans[i][j])
					cout << ans[i][j];
				else
					cout << ".";
			}
			cout << "\n";
		}
	}
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int A, B, C, D;

    scanf("%d%d%d%d", &A, &B, &C, &D);

    if(A * B > C * D){
        printf("%d\n", A * B);
    }else{
        printf("%d\n", C * D);
    }

    return 0;
}

Measured memory_bytes: 1724
// review
#include <iostream>

using namespace std;
typedef long long ll;
const int MAXN = 100010;
const int MOD = 1e9 + 7;

int n, m;
ll x[MAXN], y[MAXN];

void solve() {
  ll xsum = 0;
  ll ysum = 0;
  for (int i=0;i<n;i++) {
    xsum = (xsum + x[i] * (-n + 2 * i + 1)) % MOD;
  }
  for (int i=0;i<m;i++) {
    ysum = (ysum + y[i] * (-m + 2 * i + 1)) % MOD;
  }
  ll ans = xsum * ysum % MOD;
  cout << ans << endl;
}

int main() {
  cin >> n >> m;
  for (int i=0;i<n;i++) {
    cin >> x[i];
  }
  for (int i=0;i<m;i++) {
    cin >> y[i];
  }
  solve();
}


Measured memory_bytes: 1792
#-*-coding:utf-8-*-

def main():
    n, m = map(int, input().split())

    arry = []
    cnt = 0
    for i in range(m):
        a, b = map(int, input().split())
        if a == 1:
            cnt += 1
            arry.append(b)
        elif b == n:
            cnt += 1
            arry.append(a)
    if len(set(arry)) < cnt:
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')

if __name__ == '__main__':
    main()

Measured memory_bytes: 23280
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>
#include <list>
#include <stdio.h>
#include <sstream>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const ll mod = 1e9 + 7;
const ll inf = 1LL << 60;
const long double pi = 3.14159265358979323846;

// ****************************************CODE***************************************//

ll n, k, h[100100];
ll dp[100100];

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

    for(int i = 0; i < 100100; i++) dp[i] = inf;

    dp[0] = 0;
    for(int i = 0; i < n; i++){
        for(int j = 1; j <= k; j++){
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }

    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int mod = 1e9 + 7;

const int m = 2019;

int main()
{

    vector<int> a(3);
    for (int i = 0; i < 3; i++)
    {
        cin >> a.at(i);
    }

    string x = "Yes";
    for (int i = 0; i < 2; i++)
    {
        if (a.at(i) >= a.at(i + 1))
        {
            x = "No";
            break;
        }
    }

    cout << x << endl;

    return 0;
}


Measured memory_bytes: 3228
def e_payment_greedy():
    N = [int(i) for i in list(input())]
    s = N[::-1] + [0]  # [-d-1]: 最終的に 10**d 円札を何枚受渡ししたかが格納される

    for i in range(len(N)):
        if s[i] >= 6 or (s[i] == 5 and s[i + 1] >= 5):
            s[i] = 10 - s[i]
            s[i + 1] += 1
    return sum(s)

print(e_payment_greedy())

Measured memory_bytes: 26472
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

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

int main() {
    int A, B; cin >> A >> B;
    cout << lcm(A, B) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<int,int>mp;
int main(void){
int x,n;
cin>>x>>n;
for(int i=0;i<n;i++){
    int j;
    cin>>j;
    mp[j]++;
}
pair<int,int>p;
p={102,0};
for(int i=0;i<=102;i++){
    if(!mp.count(i) && abs(x-i)<p.first){
        p={abs(x-i),i};
    }
}
cout<<p.second<<"\n";

return 0;}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())

char getSig(int i){
  if(i==0) return '+';
  else return '-';
}

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

  string ans;
  rep(i,2) rep(j,2) rep(k, 2){
    if(ans!="") break;
    int val=s.at(0)-'0';

    if(i==0) val+=s.at(1)-'0';
    else val-=s.at(1)-'0';

    if(j==0) val+=s.at(2)-'0';
    else val-=s.at(2)-'0';

    if(k==0) val+=s.at(3)-'0';
    else val-=s.at(3)-'0';

    if(val==7){
      ans+=s.at(0);
      ans+=getSig(i);
      ans+=s.at(1);
      ans+=getSig(j);
      ans+=s.at(2);
      ans+=getSig(k);
      ans+=s.at(3);
      break;
    }
  } 
  ans+="=7";

  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(x) x.begin(),x.end()
#define ceil(n, m) ((n / m) + ( n % m ? 1 : 0))
#define fast_IO  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define file_in freopen("input.txt","r",stdin);
#define file_out freopen("output.txt","w",stdout);
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);

int main(){
    //fast_IO;
    
    int n;
    cin >> n;
    cout << n*(n+1)/2;
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <bitset>
#include <utility>
#include <vector>
#include <algorithm>

using namespace std;

int n;
bitset<15> bits;
vector<vector<pair<int, int>>> a;

int main(){
    int n;
    cin >> n;
    a.resize(n);
    for(int i = 0; i < n; i++){
        int sz;
        cin >> sz;
        a[i].resize(sz);
        for(auto&& j : a[i]){
            cin >> j.first >> j.second;
            j.first--;
        }
    }
    int ans = 0;
    for(int i = 0; i < (1 << n); i++){
        bitset<15> info(i);
        bool check = true;
        for(int j = 0; j < n; j++){
            if(!info[j]) continue;
            for(auto&& k : a[j]){
                if(info[k.first] != k.second){
                    check = false;
                    break;
                }
            }
            if(!check){
                break;
            }
        }
        if(check){
            ans = max<int>(ans, info.count());
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


N = I()


print(sum((N-1)//i for i in range(1,N)))


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

typedef long long ll;

const int N = 200005;

ll a[N], f[N], k;
int n;
int main()
{
    ios_base::sync_with_stdio(false);

    cin >> n >> k;
    for(int i=0; i<n; i++) 
        cin >> a[i];
    for(int i=0; i<n; i++) 
        cin >> f[i];

    sort(a, a+n, greater<ll>());   
    sort(f, f+n);   

    ll lo=0, hi=1e13, ans;


    while(lo<=hi) {
        ll mid = (lo+hi)>>1;
        ll maxi = 0;
        ll x = k;
        ll flag = false;

        for(int i=0; i<n; i++){
            if(a[i]*f[i] > mid) {
                ll aux = ceil((a[i]*f[i] - mid) / (double)f[i]);
                if(aux > x){
                    flag = true;
                    break;
                }
                a[i]-=aux;
                maxi = max(maxi, a[i]*f[i]);
                a[i]+=aux;
                x-=aux;
            }
            else maxi = max(maxi, a[i]*f[i]);
        }

        if(flag) lo = mid+1;
        else {
            ans = maxi;
            hi = mid-1;
        }

    }

    cout << ans << endl;
}





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

int main(void){
  int N,K;
  cin>>N>>K;
  vector<long long> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  long long count=0;
  sort(A.begin(),A.end());
  for(int i=0;i<N-K;i++){
    count+=A[i];
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<vector>
#include<stack> 
#include<queue>
#include<cmath>
#include<map>
#include<bitset>
#include<set>
#define LL long long
#define ULL unsigned long long
#define N 300100
#define M 5010
#define MOD 1000000007
#define FOR(i,l,r) for (int i = (l); i <= (r); i ++)
#define CLR(a,x) memset(a,x,sizeof(a))
#define INF 0x3f3f3f3f
#define ALL(x) x.begin(),x.end()
#define pb push_back
#define X first
#define Y second
using namespace std;
char st[N];
int dp[(1 << 26) + 10];
int pre[N];
int main(){
	scanf("%s",st + 1);
	int len = strlen(st + 1),ans = INF;
	memset(dp,0x3f,sizeof(dp));
	dp[0] = 0;
	for (int i = 1; i <= len; i ++){
		pre[i] = pre[i - 1] ^ (1 << (st[i] - 'a'));
		//printf("%d\n",pre[i]);
		for (int j = 0; j < 26; j ++){
			int sta = pre[i] ^ (1 << j);
			dp[pre[i]] = min(dp[pre[i]],dp[sta] + 1);
			//printf("(%d %d) ",sta,dp[sta]);
		}
		//printf("%d ",dp[pre[i]]);
		//printf("\n");
	}
	printf("%d\n",max(dp[pre[len]],1));
}

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

const int MAX=100005;

vector<int> par(MAX);

int root(int u){
    if(par[u]==u) return u;
    else return par[u]=root(par[u]);
}
void unite(int a,int b){
    int x=root(a);
    int y=root(b);
    if(x!=y) par[y]=x;
}
bool check(int a,int b){
    if(root(a)==root(b)) return 1;
    else return 0;
}

int main(){
    
    int N,M;cin>>N>>M;
    for(int i=0;i<N;i++){
        par[i]=i;
    }
    
    for(int i=0;i<M;i++){
        int a,b,c;cin>>a>>b>>c;
        a--;b--;
        unite(a,b);
    }
    
    set<int> S;
    
    for(int i=0;i<N;i++){
        S.insert(root(i));
    }
    cout<<S.size()<<endl;
}


Measured memory_bytes: 5376
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int p, q, r;
   cin >> p >> q >> r;
   cout << min({p + q, q + r, r + p}) << endl;
   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 repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define repr(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod = 1e9 + 7;
const ll INF = 1e9;
const ll LINF = 1LL << 60;

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u)
    cout << a - 1 << " " << b << endl;
  else
    cout << a << " " << b - 1 << 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 ss[]=s.split("");
    int n[]=new int[ss.length];
    for(int i=0;i<ss.length;i++){
      n[i]=Integer.parseInt(ss[i]);
    }

    int count1=0;
    int count2=0;

    for(int i=0;i<n.length;i++){
      if(i%2==0){
        if(n[i]==0){
          count1++;
        }
      }else{
        if(n[i]==1){
          count1++;
        }
      }
      if(i%2==0){
        if(n[i]==1){
          count2++;
        }
      }else{
        if(n[i]==0){
          count2++;
        }
      }
    }
    

    if(count1<count2){
      System.out.println(count1);
    }else{
      System.out.println(count2);
    }


	}
}


Measured memory_bytes: 33180
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c;
    scanf("%lld%lld%lld",&a,&b,&c);
    if(c>a+b&&(c-a-b)*(c-a-b)>a*b*4) printf("Yes");
    else printf("No");
    return 0;
}

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

int main() {
 int W,a,b;
 cin>>W>>a>>b;
 if(a+W<b){cout<<b-a-W<<endl;}
 else if(b+W>a){cout<<0<<endl;}
 else{cout<<a-b-W<<endl;}

 return 0;}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long int n,w,i,j,k,v;
  cin>>n>>w;
  long int kati[n+1][w+1];
  for(i=0;i<w+1;i++){
    for(j=0;j<n+1;j++){
      kati[j][i]=0;
    }
  }
  for(i=0;i<n;i++){
    cin>>k>>v;
    for(j=0;j<k;j++){
      kati[i+1][j]=kati[i][j];
    }
    for(j=k;j<w+1;j++){
      kati[i+1][j]=max(kati[i][j-k]+v,kati[i][j]);
    }
  }
  cout<<kati[n][w];
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, 0, n) cin >> a[i];
    ll ans = 1e18;
    for(int bit = 0; bit < (1<<n); bit++) {
        vector<ll> tmp;
        for(int i = 0; i < n; i++) {
            if(bit & (1<<i)) tmp.push_back(i);
        }
        if(tmp.size() < k) continue;
        ll pay = 0;
        ll itr = 0, i = 0, tmx = -100;
        rep(i, 0, n) {
            if(i == tmp[itr]) {
                pay += max(0LL, tmx - a[i] + 1);
                itr++;
                tmx = max(tmx+1, a[i]);
                if(itr == tmp.size()) break;
            } else {
                tmx = max(tmx, a[i]);
            }
        }
        ans = min(ans, pay);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;

int main() {
    while (1) {
        int n;
        cin >> n;
        if (n == 0)break;
        int* x = new int[n];
        double av = 0;
        double s = 0;
        for (int i = 0; i < n; i++) {
            cin >> x[i];
            av += (double)x[i];
        }
        av /= (double)n;
        for (int i = 0; i < n; i++) {
            s += ((double)x[i] - av) * ((double)x[i] - av);
        }
        double result = sqrt((double)((double)s / (double)n));
        printf("%lf\n", result);
    }
    return 0;
}


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

using ll = long long;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> h(n);
	for (auto& x : h)
		cin >> x;

	for (int i = n - 2; i >= 0; i--) {
		if (h[i] > h[i + 1])
			h[i]--;
	}

	bool ok = true;
	for (int i = n - 2; i >= 0; i--) {
		if (h[i] > h[i + 1])
			ok = false;
	}

	if (ok) cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define repr(i,k,n) for(int i = (k); i < (n); i++)
#define rep(i,n) repr(i,0,n)
#define ALL(a) begin(a),end(a)
const int INF = 114514810;
const int MOD = 1000000007;
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
int ctoi(const char c){
    switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
  }
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B,C,an;
	cin >> A >> B >> C;
    if (A>=B&&A>=C){
        an=A*10+B+C;
    }else if (B>=A&&B>=C)
    {
        an=B*10+A+C;
    }else{
        an=C*10+B+A;
    }
    cout << an << endl;
}

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

#define for1(i, n) for (ll i = 1; i <= n; ++i)
#define for0(i, n) for (ll i = 0; i < n; ++i)
#define vll vector<ll>
#define fast std::ios_base::sync_with_stdio(false);
#define ll long long int
#define etc \
  ll t;     \
  cin >> t; \
  while (t--) solve();
#define ntc solve();
#define pb push_back
#define mp make_pair

void solve() {
  ll n, k;
  cin >> n >> k;

  ll arr[n];

  for0(i, n) cin >> arr[i];

  ll dp[n] = {0};
  dp[0] = 0;

  for1(i, n - 1) dp[i] = INT_MAX;

  for (ll i = 1; i < n; i++) {
    for (ll j = 1; j <= k && i - j >= 0; j++)
      dp[i] = min(dp[i], dp[i - j] + abs(arr[i] - arr[i - j]));
  }

  cout << dp[n - 1];
}

int main() { fast ntc return 0; }

Measured memory_bytes: 5124
o=list(input())
e=list(input())
ans=["e" for _ in range(len(o)+len(e))]
for i in range(len(o)+len(e)):
    if i%2==0:
        ans[i]=o[i//2]
    else:
        ans[i]=e[i//2]
print("".join(ans))

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

ll monster(ll h) {
  if (h == 1)
    return 1;
  else
    return 2 * monster(h / 2) + 1;
}

int main() {
  ll H;
  cin >> H;
  cout << monster(H) << endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Created on Sun May  3 20:56:48 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

X = int(input())

for i in range(-2000,2001):
    for j in range(-2000,2001):
        if pow(i,5) - pow(j,5) == X:
            print(i,j)
            sys.exit()



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

using namespace std;

const int MAXN=1e6+7;

int n;
int a[MAXN];

int cnt[MAXN],cnt2;

int ans,maxx1,maxx2,K1,K2;
int maxx3,maxx4;

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	
	cnt2=0;
	maxx1=0;
	for(int i=1;i<=n;i+=2)
		cnt[a[i]]++,cnt2++;
	for(int i=1;i<=100000;i++)
		if(cnt[i]>maxx1)
			maxx1=cnt[i],K1=i;
	
	memset(cnt,0,sizeof(cnt));
	cnt2=0;
	maxx2=0;
	for(int i=2;i<=n;i+=2)
		cnt[a[i]]++,cnt2++;
	for(int i=1;i<=100000;i++)
		if(cnt[i]>maxx2)
			maxx2=cnt[i],K2=i;

	if(K1==K2) {
		memset(cnt,0,sizeof(cnt));
		cnt2=0;
		maxx3=0;
		for(int i=1;i<=n;i+=2)
			cnt[a[i]]++;
		cnt[K1]=0;
		for(int i=1;i<=100000;i++)
			if(cnt[i]>maxx3)
				maxx3=cnt[i];
		
		memset(cnt,0,sizeof(cnt));
		cnt2=0;
		maxx4=0;
		for(int i=2;i<=n;i+=2)
			cnt[a[i]]++;
		cnt[K2]=0;
		for(int i=1;i<=100000;i++)
			if(cnt[i]>maxx4)
				maxx4=cnt[i];
		cout<<min(n-maxx1-maxx4,n-maxx2-maxx3)<<endl;
	}
	else {
		cout<<n-maxx1-maxx2<<endl;
	}
}

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

ok_count = 0
for i in range(1, N + 1, 2):
    # 約数を8個もつものの数
    count = 0
    for j in range(1, i + 1):
        # print("{}".format(j))
        if i % j == 0:
            count += 1
    if count == 8:
        ok_count += 1
print(ok_count)


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int H, W;
  while(cin>>H>>W,H){
	VVI xs(H, VI(W));
	REP(y,H) REP(x,W) cin >> xs[y][x];

	int ans = 0;
	for(int b=0;b<1<<H;++b){
	  int sum = 0;
	  REP(x,W){
		int z = 0;
		REP(y,H){
		  if(xs[y][x]^((b>>y)&1))
			++z;
		}
		sum += max(z, H-z);
	  }
	  maxi(ans, sum);
	}
	cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define req(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define qer(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=10000000000000000;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    cout<<max(max(a*c,a*d),max(b*c,b*d));
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()



int main() {
    ll s;
    cin>>s;
    const int v=1000000000;

    int x=(v-s%v)%v;
    int y=(s+x)/v;
    cout<<"0 0 1000000000 1 "<<x<<" "<<y<<endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cstdint>
#include <cstddef>
#include <cinttypes>
#include <memory>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <array>
#include <valarray>
#include <string>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <queue>
#include <complex>
#include <tuple>
#include <utility>
#include <functional>
#include <algorithm>
#include <numeric>

using namespace std;

const double EPS = 1e-10;
const int64_t INF = 1e9;

typedef long long ll;

const ll MOD = 1000000007;

int main()
{
	ll ans[2010];

	ans[0] = ans[1] = ans[2] = 0;

	int N;
	scanf("%d", &N);

	for (int i = 3; i <= N; ++i) {
		ans[i] = 1;
		for (int j = 3; j <= i-3; ++j) {
			ans[i] = (ans[i] + ans[i-j]) % MOD;
		}
	}

	printf("%lld\n", ans[N]);

	return 0;
}



Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define pll pair<ll,ll>
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define mx 1000002
mt19937 myrand(time(0));

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(),cout.tie();
    char ch;
    cin>>ch;
    if(ch>='a' && ch<='z') cout<<"a"<<endl;
    else cout<<"A"<<endl;
    return 0;
}


Measured memory_bytes: 3612
#include <iostream>

#define MAX 2000

char map[MAX][MAX];
using namespace std;
typedef pair<int,int> p;

int horizon(int,int);
int vertical(int,int);
p num[MAX][MAX];

int H,W;

int main(void){
  cin >> H >> W;
  for(int i=i;i<H;i++){
    for(int j=0;j<W;j++){
      cin >> map[i][j];
    }
  }
  // 横からやる
  for(int i=0;i<H;i++){
    int n=0;
    while(n<W){
      n = horizon(i,n);
    }
  }
  for(int i=0;i<W;i++){
    int n=0;
    while(n<H){
      n = vertical(i,n);
    }
  }
  // first + start - 1が最大値
  int max = 0;
  int cordX,cordY;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(max < num[i][j].first + num[i][j].second - 1){
	max = num[i][j].first + num[i][j].second - 1;
      }
      //cout << "(" << num[i][j].first << "," << num[i][j].second << ")"; 
    }
    //cout << endl;
  }
  cout << max << endl;
  return 0;
}

int horizon(int row, int start){
  //"."を探す
  while(start < W){
    if(map[row][start] == '.')
      break;
    //そうじゃなきゃ0にしておく
    num[row][start] = make_pair(0,0);
    start++;
  }
  if(start == W)
    return W;
  //横にどれだけいけるかみる
  int loc;
  for(loc=start;loc<W;loc++){
    if(loc >= W || map[row][loc] == '#')
      break;
  }
  // loc - startが横のぶん
  for(int i = start;i < loc;i++){
    num[row][i].first = loc - start;
  }
  return loc;
}

int vertical(int col, int start){
  //"."を探す
  while(start < H){
    if(map[start][col] == '.')
      break;
    //そうじゃなきゃ0にしておく
    num[start][col] = make_pair(0,0);
    start++;
  }
  if(start == H)
    return H;
  //横にどれだけいけるかみる
  int loc;
  for(loc=start;loc<H;loc++){
    if(loc >= H || map[loc][col] == '#')
      break;
  }
  // loc - startが横のぶん
  for(int i = start;i < loc;i++){
    num[i][col].second = loc - start;
  }
  return loc;
}


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

#define SZ(x) (((int)x.size()))
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;

using namespace std;

ll n;

int main()
{
	cin >> n;
	cout << n * (n + 1) / 2 - 3 * (n / 3) * (n / 3 + 1) / 2 - 5 * (n / 5) * (n / 5 + 1) / 2 + 15 * (n / 15) * (n / 15 + 1) / 2;
	return 0;
}


Measured memory_bytes: 3632
#include<cstdio>
#include<algorithm>
using namespace std;
int main()
{
	int x1,y1,x2,y2;
	while(scanf("%d %d %d %d",&x1,&y1,&x2,&y2)!=EOF){
		int b = x2-x1,a = y2-y1;
		
		for(int i = 0; i < a; i++)		printf("U");
		for(int i = 0; i < b; i++)		printf("R");
		
		for(int i = 0; i < a; i++)		printf("D");
		for(int i = 0; i < b; i++)		printf("L");
		
		printf("L");
		for(int i = 0; i < a+1; i++)		printf("U");
		for(int i = 0; i < b+1; i++)		printf("R");
		printf("D");
		
		printf("R");
		for(int i = 0; i < a+1; i++)		printf("D");
		for(int i = 0; i < b+1; i++)		printf("L");
		printf("U\n");
	}
	return 0;
}

Measured memory_bytes: 128
N, M = map(int, input().split())
H = list(map(int, input().split()))
P = [list(map(int,input().split())) for i in range(M)]

Tallest = [1]*N

for i in range (0,M):
	if H[int(P[i][0])-1] > H[int(P[i][1])-1]:
		Tallest[P[i][1]-1]=0	
	elif H[int(P[i][0])-1] == H[int(P[i][1])-1]:
		Tallest[P[i][0]-1]=0
		Tallest[P[i][1]-1]=0
	else:
		Tallest[P[i][0]-1]=0

print(sum(Tallest))

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

int state[100005];

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int n; string s;

    cin >> n >> s;

    for(int i = 0; i < 2; ++i){
        for(int yikes = 0; yikes < 2; ++yikes){
            for(int j = 0; j < n; ++j)
                state[j] = -1;
            state[0] = i;
            if((s[0] == 'o') ^ i){
                state[1] = state[n - 1] = yikes;
            } else {
                state[1] = yikes; state[n - 1] = 1 - yikes;
            }
            bool bad = false;
            for(int pos = 1; pos < n; ++pos){
                if((s[pos] == 'o') ^ (state[pos] == 1)){
                    if(state[(pos + 1) % n] != -1 && state[pos - 1] != state[(pos + 1) % n])
                        bad = true;
                    state[(pos + 1) % n] = state[pos - 1];
                } else {
                    if(state[(pos + 1) % n] != -1 && state[pos - 1] == state[(pos + 1) % n])
                        bad = true;
                    state[(pos + 1) % n] = 1 - state[pos - 1];
                }
            }
            if(bad) continue;
            for(int pos = 0; pos < n; ++pos)
                cout << (state[pos] == 0 ? "S" : "W");
            cout << "\n";
            return 0;
        }
    }

    cout << "-1\n";

    return 0;

}


Measured memory_bytes: 976
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define siz(v) (ll)(v).size()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, x, n) for (ll i = x; i < (ll)(n); i++)
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
vector<ll> dx = {-1, 1, 0, 0}, dy = {0, 0, -1, 1};

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

    ll n, ans = 0;
    cin >> n;

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i];

    rep(i, n) cin >> b[i];

    queue<ll> q;
    for(int i=0;i < n;i++)
    {
        if (b[(i + 1) % n] < b[i] && b[i] > b[(i - 1 + n) % n])
        {
            q.push(i);
        }
    }
    

    while(!q.empty())
    {
        ll ind=q.front();
        q.pop();

        if (b[ind] <= a[ind])
            continue;

        ll ng = 0, ok = INF,fr=b[(ind + 1) % n],ba=b[(ind - 1 + n) % n];
        while (abs(ng - ok) > 1)
        {
            ll mid = (ok + ng) / 2, B = b.at(ind) - (mid) * (fr + ba);

            if (B>a[ind] && (fr < B && B > ba))
            {
                ng = mid;
            }
            else
            {
                ok = mid;
            }
        }

        b.at(ind) -= ok * (fr+ba);

        if (b[ind] < a[ind])
            break;

        ans += ok;

        ind+=n-1;
        ind%=n;
        if (b[(ind + 1) % n] < b[ind] && b[ind] > b[(ind - 1 + n) % n])
        {
            q.push(ind);
        }

        ind+=2;
        ind%=n;
        if (b[(ind + 1) % n] < b[ind] && b[ind] > b[(ind - 1 + n) % n])
        {
            q.push(ind);
        }
        
    }

    for (int i = 0; i < n; i++)
    {
        if (a[i] != b[i])
        {
            cout << -1 << endl;
            return 0;
        }

    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <math.h>

#include <algorithm>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;

int main() {
  int k, a, b;
  cin >> k >> a >> b;

  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK";
      goto end;
    }
  }
  cout << "NG";
end:
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int P, Q;
string master[10], sample[10];

void solve() {
    set<int> solutions[10];

    for (int r = 1; r <= 20; ++r) {
        for (int c = 1; c <= 20; ++c) {
            for (int s = 1; s <= 20; ++s) {
                // check it is consistenw with master
                int nr = 0, nc = 0, ns = 0;
                bool ok = true;
                for (int j = 0; j < P; ++j) {
                    int idt = 0;
                    for (int k = 0; k < (int)(master[j].size()); ++k) {
                        char ch = master[j][k];
                        if (ch != '.') {
                            idt = k; break;
                        }
                    }
                    if (nr * r + nc * c + ns * s != idt) {
                        ok = false; break;
                    }
                    for (char& ch : master[j]) {
                        if (ch == '(') nr++;
                        if (ch == ')') nr--;
                        if (ch == '{') nc++;
                        if (ch == '}') nc--;
                        if (ch == '[') ns++; 
                        if (ch == ']') ns--; 
                    }
                }
                if (!ok) continue;

                // apply the rule (r, c, s) to the sample
                int idt = 0;
                for (int j = 0; j < Q; ++j) {
                    solutions[j].insert(idt);
                    for (char& ch : sample[j]) {
                        if (ch == '(') idt += r;
                        if (ch == ')') idt -= r;
                        if (ch == '{') idt += c;
                        if (ch == '}') idt -= c;
                        if (ch == '[') idt += s;
                        if (ch == ']') idt -= s;
                    }
                }
            }
        }
    }

    for (int j = 0; j < Q; ++j) {
        if (j > 0) cout << " ";
        cout << (solutions[j].size() == 1 ? *begin(solutions[j]) : -1);
    }
    cout << endl;
}

int main() {
    while (true) {
        cin >> P >> Q;
        if (P == 0 && Q == 0) break;
        for (int j = 0; j < P; ++j) {
            cin >> master[j];
        }
        for (int j = 0; j < Q; ++j) {
            cin >> sample[j];
        }
        solve();
    }
    return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>
long long N, ans;
int num(long long a, long long b3, long long b5, long long b7) {
	if (a > N) { return; }
	if (b3 + b5 + b7 == 3) { ans++; }
	num(a * 10 + 3, 1, b5, b7);
	num(a * 10 + 5, b3, 1, b7);
	num(a * 10 + 7, b3, b5, 1);
}

int main() {
	scanf("%lld", &N);
	num(0, 0, 0, 0);
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 128
n = int(input())
w = []
for i in range(n):
    s = input()
    if s in w:
        print("No")
        break
    else:
        if i != 0:
            if w[-1][-1] != s[0]:
                print("No")
                break
        w.append(s)
else:
    print("Yes")


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

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  int ans = 0;
  for (int i = 1; i < n; i++) {
    set<char> x;
    for (int j = 0; j < i; j++) {
      x.insert(s[j]);
    }

    set<char> y;
    for (int j = i; j < n; j++) {
      y.insert(s[j]);
    }

    int count = 0;
    for (char ch : x) {
      if (y.find(ch) != y.end()) {
        count++;
      }
    }
    ans = max(ans, count);
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 256
#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)
int main(){
    int n;cin>>n;
    int a[3][n];
    REP(i,3)REP(j,n)cin>>a[i][j];
    REP(i,3)sort(a[i],a[i]+n);
    long int s=0;
    REP(i,n)s+=(lower_bound(a[0],a[0]+n,a[1][i])-a[0])*(a[2]+n-upper_bound(a[2],a[2]+n,a[1][i]));
    cout<<s<<endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <stdio.h>
#include <string>
#include <utility>
#include <set>

using llint = long long int;
using namespace std;

namespace CsF {
#define MIN_INT -2147483648
#define MAX_INT 2147483647

#define nfor(I,J,K) for(int I = 0;I < J;I+=K)


	string ConvertBit(int N, int e) {
		string s = "";
		int r = 0;
		while (N != 0) {
			r = N % e;
			s = to_string(r) + s;
			N -= r;
			N /= e;
		}
		return s;
	}

	int GCD(int a, int b) {
		if (a < b)swap(a, b);
		int r = a % b;
		while (r != 0) {
			a = b;
			b = r;
			r = a % b;
		}
		return b;
	}

	int LCM(int a, int b) {
		int n = a * b;
		return (n / GCD(a, b));
	}

	int Count(string s, char c) {
		int cou = 0;
		nfor(i, s.length(), 1) {
			if (s[i] == c)cou++;
		}
		return cou;
	}

	vector<int> SieveOfEratosthenes(int N) {
		vector<bool> memo(N + 1);
		vector<int> ret;
		memo[0] = true;
		memo[1] = true;
		for (int i = 2; i < N; i++) {
			if (memo[i])continue;
			ret.push_back(i);
			for (int b = 2; true; b++) {
				if (i*b <= N) {
					memo[i*b] = true;
				}
				else break;
			}
		}
		return ret;
	}
}

using namespace CsF;


int main() {
	int N;
	cin >> N;
	N %= 28;
	for (int i = 0; i <= 4; i++) {
		for (int j = 0; j <= 7;j++) {
			if (i == 0 && j == 0)continue;
			if (N % (7 * i + 4 * j) == 0) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		String b = saori.nextHayami();
		if(b.equals("A")){
			System.out.println("T");
		} else if(b.equals("C")){
			System.out.println("G");
		} else if(b.equals("G")){
			System.out.println("C");
		} else if(b.equals("T")){
			System.out.println("A");
		}
		
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21076
open Printf
open Scanf

let id x = x

let solve n =
  let al = Array.init n @@ fun _ -> scanf "%d " id in
  let ans = ref 0 in
  Array.sort compare al;
  for i = 0 to n-3 do
    for j = i+1 to n-2 do
      for k = j+1 to n-1 do
        if al.(i) < al.(j) && al.(j) < al.(k) && al.(i) + al.(j) > al.(k) then incr ans
      done
    done
  done;
  !ans
  
let () =
  scanf "%d " solve |> printf "%d\n"


Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1e6+10;

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#define fo(x,a,b) for(int x=(a),_e=(b);x<=_e;x++)
#define fd(x,a,b) for(int x=(a),_e=(b);x>=_e;x--)
typedef long long ll;
char c[200001];
int lei;
int main(){
	scanf("%s",c+1);
	lei=0;
	fo(i,1,strlen(c+1)) lei=(lei+c[i]-'0')%9;
	lei==0 ? puts("Yes") : puts("No");
	return 0;
}


Measured memory_bytes: 1812