akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
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; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n, x;
void in(){
    cin >> n >> x;
}

int dfs(int a, int b){

    
    if(b > a) swap(a, b);
    if(a % b == 0) return (a / b) * b * 2 - b;

    int ret = (a / b) * b * 2;
    return ret + dfs(b, a % b);

}

void solve(){

    print(n + dfs(n - x, x));

}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

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

int main(){
    int n;
    while(cin >> n && n){
        vector<string> s(n);
        rep(i,n){
            string t;
            cin >> t;
            string u = "";
            u += t[0];
            rep(j,t.size()-1){
                if((int)string("aiueo").find(t[j]) != -1){
                    u += t[j+1];
                }
            }
            s[i] = u;
        }
        int ans = -1;
        rep(i,60){
            set<string> t;
            rep(j,n) t.insert(s[j].substr(0,i));
            if((int)t.size() == n){
                ans = i;
                break;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3116
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	Scanner sc = new Scanner(System.in);

	int w;
	int h;
	int[][] s;
	int[][][] dis;

	int cs[];
	int[] dx = { 1, 0, -1, 0 };
	int[] dy = { 0, 1, 0, -1 };
	final int INF = 1 << 29;

	boolean init() {
		w = sc.nextInt();
		h = sc.nextInt();
		if ((h | w) == 0)
			return false;
		s = new int[w][h];
		dis = new int[w][h][4];
		for (int i = 0; i < w; i++) {
			for (int j = 0; j < h; j++) {
				Arrays.fill(dis[i][j], INF);
			}
		}
		cs = new int[5];
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				s[j][i] = sc.nextInt();
			}
		}
		for (int i = 0; i < 4; i++) {
			cs[i] = sc.nextInt();
		}
		cs[4] = 0;
		return true;
	}

	void run() {
		while (init()) {
			dis[0][0][0] = 0;
			while (true) {
				boolean update = false;
				for (int x = 0; x < w; x++) {
					for (int y = 0; y < h; y++) {
						for (int d = 0; d < 4; d++) {
							// コマンド0,1,2,3orパネルの命令
							for (int i = 0; i < 5; i++) {
								if (s[x][y] == 4 && i == 4)
									continue;
								int nd = ((i != 4 ? i : s[x][y]) + d) % 4;
								int nx = x + dx[nd];
								int ny = y + dy[nd];
								if (nx < 0 || ny < 0 || nx >= w || ny >= h)
									continue;
								if (dis[x][y][d] != INF
										&& dis[nx][ny][nd] > dis[x][y][d]
												+ cs[i]) {
									dis[nx][ny][nd] = dis[x][y][d] + cs[i];
									update = true;
								}
							}
						}
					}
				}
				if (!update)
					break;
			}
			System.out.println(Math.min(dis[w - 1][h - 1][1],
					dis[w - 1][h - 1][0]));
		}
	}

	public static void main(String[] args) {
		new Main().run();

	}
}

Measured memory_bytes: 46096
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    n--;
    int c[n],s[n],f[n];
    for(int i=0;i<n;i++)cin>>c[i]>>s[i]>>f[i];
    for(int i=0;i<n;i++){
        int t=c[i]+s[i];
        for(int j=i+1;j<n;j++)t=max(s[j],((t-1)/f[j]+1)*f[j])+c[j];
        cout<<t<<endl;
    }
    cout<<"0"<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  int ret = 0;
  int t;
  REP(i,5){
    cin >> t;
    ret += max(40,t);
  }
  ret /= 5;

  cout << ret << endl;
  return 0;
}

Measured memory_bytes: 1160
// template version 1.15
using namespace std;
#include <bits/stdc++.h>

// varibable settings
#define int long long
const int INF=1e18;

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(a, b, c) make_tuple(a, b, c)
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

#define divceil(a,b) ((a)+(b)-1)/(b)
#define is_in(x, a, b) ((a)<=(x) && (x)<(b))
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define slice(l, r) substr(l, r-l)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
    #include "lib/dump.hpp"
#else
    #define dump(...) 42
    #define dump_1d(...) 42
    #define dump_2d(...) 42
    #define cerrendl 42
#endif
//}}}

signed main() {
    vi x = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;cin>>k;
    k--;
    cout << x[k] << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define cs const 
#define int long long
#define low(i) (i&(-i))
#define mid ((l+r)>>1)
#define ls (now<<1)
#define rs (now<<1|1)
#define par pair<int,int>
#define mp make_pair
#define fr first 
#define se second
#define rep(i, x, y) for(int i=x; i<=y; ++i)
#define drep(i, x, y) for(int i=x; i>=y; --i)
#define fore(i, x) for(int i=fir[x]; i; i=nex[i])
cs int base = 233;
cs int ff = 3e6+1;
cs int mod = 998244353;
cs int inf = 1e9+1;
int n, a[ff], cnt[ff], ans, sum;
int gp(int y) {return max(0LL, y * (y-1) / 2 );}
void init()
{
	cin >> n;
	rep(i, 1, n) scanf("%lld", &a[i]), cnt[a[i]]++;
	rep(i, 1, n) ans += max( 0LL, cnt[i] * ( cnt[i] - 1 ) / 2 );
	rep(i, 1, n) printf("%lld\n", ans - ( gp(cnt[a[i]]) - gp(cnt[a[i]]-1 ) ) ) ;
}
signed main()
{
	int T = 1;
	while(T--) 
		init();
} 


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    string s;
    cin>>s;
    lli t=0;

    for(lli i=0;i<3;i++)
    if(s[i]=='R')t++;
    
    if(t==2)
    {
        if(s[1]!='R')
        t=1;
    }

    cout<<t;
    cout<< endl;
    // cout<< fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(10);
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int n,x,d;
int main()
{
    while (1>0)
    {
        n=x=d=0;
        scanf("%d%d",&n,&x);
        if (n==0 && x==0) return 0;
        for(int i=1;i<=n;i++)
            for(int j=i+1;j<=n;j++)
                for(int k=j+1;k<=n;k++)
                    if(i+j+k==x) d++;
        printf("%d\n",d);
    }
}



Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int a = stoi(s.substr(0, 2));
    int b = stoi(s.substr(2, 2));
    if(1<=a && a<=12){
        if(1<=b && b<=12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(1<=b && b<=12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a;
  cin >>a;
  int t=0;
  for(int i= 0;i <a.size();i++){
    if(a.at(i)=='+'){
      t++;
    }
    else{
      t--;
    }
  }
    cout << t <<endl;
}

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

int main()
{
  string S, T;
  int A, B;
  cin >> S >> T;
  cin >> A >> B;
  string U;
  cin >> U;
  if(S == U) A--;
  else B--;
  cout << A << " " << B << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int dp[1<<20][2];
int list[100001][20];
int n,m,r,w;
int find(int a,int b,int t){
	//a~b?????????t??§???????????°????????°?????????
	return b-a-(list[b][t]-list[a][t]);
}
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++)list[0][i]=0;
	for(int i=0;i<n;i++){
		cin>>r;
		for(int j=0;j<m;j++)list[i+1][j]=list[i][j];
		list[i+1][r-1]++;
	}
	w=1;
	for(int i=0;i<m;i++)w*=2;
	for(int i=0;i<w;i++)dp[i][0]=1145141919;
	dp[0][0]=0,dp[0][1]=0;

	for(int i=0;i<w;i++){
		bool will[20]={false};//????????§???????????????
		int e=1;
		for(int j=0;j<m;j++){
			if(i%(e*2)<e)will[j]=true;
			e*=2;
		}

		e=1;
		for(int j=0;j<m;j++){
			if(will[j]){
				dp[i+e][1]=dp[i][1]+list[n][j];
				dp[i+e][0]=min(dp[i+e][0],dp[i][0]+find(dp[i][1],dp[i+e][1],j));
			}
			e*=2;
		}
	}
	cout<<dp[w-1][0]<<endl;
	return 0;
}

Measured memory_bytes: 19084
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = 0
e = 0
for i in c:
    if i % 2 == 0:
        d += 1
    else:
        e += 1
if e == 0:
    if b == 0:
        print(2 ** a)
    else:
        print(0)
else:
    print(2 ** (a - 1))


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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt(x) __builtin_popcount(x)
#define lbit(x) __builtin_ffsll(x)
#define rbit(x) __builtin_clzll(x)
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()

template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}

template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 5e18;
// const double PI = atan(1.0) * 4.0;
const ll dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
#define PI 3.141592653589793238

signed main() {
    LCIN(K);
    cout << (K / 2) * ((K + 1) / 2) << "\n";
}


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

using namespace std;
#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
   	SpeedForce;
   	int n, k;
   	cin >> n >> k;
   	map < int, int > cnt;
   	for (int i = 1, x; i <= n; i ++) {
   		cin >> x;
   		cnt[x]++;

   	}
   	vector < int > v;
   	for (auto it : cnt) {
   		v.pb(it.S);
   	}
   	sort(v.rbegin(), v.rend());

   	int cur = n;
   	for (int i = 0; i < min(k, sz(v)); i ++) {
   		cur -= v[i];
   	}
   	cout << cur << '\n';

   	return Accepted;
}

// B...a

Measured memory_bytes: 29176
#include<iostream>
using namespace std;
int main()
{
  int A1;
  int A2;
  int A3;
  cin >> A1 >> A2 >> A3;
  
  if(A1+A2+A3>=22){
    cout << "bust";
  }else{cout << "win";
       }
    return 0;
}

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

#define INF 0x3f3f3f3f
#define MAXN 100010
#define endl "\n"
#define abs(a, b) ((a > b) ? a-b : b-a)

typedef long long int ll;

/* End */

int n;
ll a[MAXN];
ll pd[3];

int main() {
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];

	int m = 0;
	pd[2] = 0;
	pd[1] = abs(a[n-2], a[n-1]);
	for (int i = n-3; i >= 0; i--) {
		pd[m] = min(pd[(m+1)%3] + abs(a[i], a[i+1]),
              	            pd[(m+2)%3] + abs(a[i], a[i+2]));
		m--;
		if(m < 0) m += 3;
	}

	cout << pd[(m+1)%3] << endl;

	return 0;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
               int count = 0;
               for ( int i = 0; i < 6; i++ ) {
                   char c = s.charAt(i);
                   if ( c == '1' ) count++;
               }
               System.out.println(count);
	}
}

Measured memory_bytes: 22356
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;

#define BIG_NUM 2000000000

using namespace std;

int table_4[24][4],table_5[120][5],index_9,m_data[9] = {0,1,2,3,4,5,6,7,8};
int** table_9;

void calc9(){
	int select_num = 5,num,loc_left[5],loc_right[4],left_index,right_index,left_calc[5],right_calc[4];

	index_9 = 0;

	for(int i = 0; i < 512;i++){
		num = 0;
		for(int k = 0; k < 9; k++){
			if(i & (1 << k))num++;
		}
		if(num != select_num)continue;

		left_index = right_index = 0;

		for(int k = 0; k < 9; k++){
			if(i & (1 << k)){
				loc_left[left_index++] = k;
			}else{
				loc_right[right_index++] = k;
			}
		}

		left_index = right_index = 0;

		left_calc[0] = m_data[loc_left[0]],left_calc[1] = m_data[loc_left[1]],left_calc[2] = m_data[loc_left[2]],left_calc[3] = m_data[loc_left[3]],left_calc[4] = m_data[loc_left[4]];
		right_calc[0] = m_data[loc_right[0]],right_calc[1] = m_data[loc_right[1]],right_calc[2] = m_data[loc_right[2]],right_calc[3] = m_data[loc_right[3]];

		for(int k = 0; k < 120; k++){
			for(int p = 0; p < 24; p++){
				for(int a = 0; a < 4; a++){
					table_9[index_9][a] = left_calc[table_5[k][a]];
					table_9[index_9][5+a] = right_calc[table_4[p][a]];
				}
				table_9[index_9][4] = left_calc[table_5[k][4]];
				index_9++;
			}
		}
	}
}


int main(){

	int index_4 = 0;

	for(int a = 0; a < 4; a++){
		for(int b = 0; b < 4; b++){
			for(int c = 0; c < 4; c++){
				for(int d = 0; d < 4; d++){
					if(a != b && a != c && a != d && b != c && b != d && c != d){
						table_4[index_4][0] = a,table_4[index_4][1] = b,table_4[index_4][2] = c,table_4[index_4][3] = d;
						index_4++;
					}
				}
			}
		}
	}

	int index_5 = 0;

	for(int a = 0; a < 5; a++){
		for(int b = 0; b < 5; b++){
			for(int c = 0; c < 5; c++){
				for(int d = 0; d < 5; d++){
					for(int e = 0; e < 5; e++){
						if(a != b && a != c && a != d && a != e && b != c && b != d && b != e && c != d && c != e && d != e){
							table_5[index_5][0] = a,table_5[index_5][1] = b,table_5[index_5][2] = c,table_5[index_5][3] = d,table_5[index_5][4] = e;
							index_5++;
						}
					}
				}
			}
		}
	}



	table_9 = new int*[362880];
	for(int i = 0; i < 362880; i++){
		table_9[i] = new int[9];
	}

	calc9();

	int K,gates[9],jenny[9],count,score_G,score_J;
	double ans_J,ans_G;
	scanf("%d",&K);

	for(int loop = 0; loop < K; loop++){
		for(int i = 0; i < 9; i++)scanf("%d",&gates[i]);
		for(int i = 0; i < 9; i++)scanf("%d",&jenny[i]);

		count = 0;
		for(int i = 0; i < 362880; i++){
			score_G = 0,score_J = 0;
			for(int k = 0; k < 9; k++){
			if(jenny[table_9[i][k]] > gates[k]){
					score_J += jenny[table_9[i][k]] + gates[k];
				}else{
					score_G += gates[k] + jenny[table_9[i][k]];
				}
			}
			if(score_J > score_G)count++;
		}

		ans_J = (double)count/(double)362880;
		ans_G = 1 - ans_J;

		printf("%.5lf %.5lf\n",ans_G,ans_J);
	}

    return 0;
}

Measured memory_bytes: 22464
import java.io.IOException;

public class Main {

	public static void main(String[] args) {
		while (true) {
			int n = nextInt();
			if (n == 0) {
				break;
			}

			int[][] cir = new int[n][4];
			int[] above = new int[n];// テ、ツクツ甘」ツ?ォテゥツ?催」ツ?ェテ」ツ?」テ」ツ?ヲテ」ツつ凝・ツ??ァツ崢、

			int[] bitDP = new int[1 << n];

			for (int i = 0; i < n; i++) {
				int x = nextInt();
				int y = nextInt();
				int r = nextInt();
				int c = nextInt();
				cir[i][0] = x;
				cir[i][1] = y;
				cir[i][2] = r;
				cir[i][3] = c;

				for (int j = 0; j < i; j++) {
					// テゥツ?催」ツ?ェテ」ツ?」テ」ツ?ヲテ」ツ??」ツつ凝・ツ??ァツ崢、テ」ツ?古」ツ?づ」ツつ凝」ツ?凝」ツ?ョテ・ツ按、テ・ツョツ?
					int jx = cir[j][0] - x;
					int jy = cir[j][1] - y;
					int jr = cir[j][2];
					double dist = Math.sqrt(jx * jx + jy * jy);
					if (dist < r + jr) {
						above[i] += (1 << j);
					}
				}
			}

			int max = 0;
			for (int bit = 0; bit < bitDP.length; bit++) {
				// テ・ツ按ーテゥツ?氾」ツ?療」ツ??」ツつ凝ゥツ?キテァツァツサテ」ツ??
				if (bit != 0 && bitDP[bit] == 0) {
					continue;
				}
				for (int i = 0; i < n; i++) {
					// テ・ツ??テ」ツ?ィjテ」ツ?古・ツ渉姪」ツつ甘ゥツ卍、テ」ツ?凝」ツつ古」ツ?ヲテ」ツ??」ツ?ェテ」ツ??」ツ?凝」ツδ?」ツつァテ」ツδε」ツつッ
					if ((bit & (1 << i)) != 0) {
						continue;
					}
					for (int j = i + 1; j < n; j++) {
						// テ・ツ??テ」ツ?ィjテ」ツ?古・ツ渉姪」ツつ甘ゥツ卍、テ」ツ?凝」ツつ古」ツ?ヲテ」ツ??」ツ?ェテ」ツ??」ツ?凝」ツδ?」ツつァテ」ツδε」ツつッ
						if ((bit & ((1 << i) + (1 << j))) != 0) {
							continue;
						}
						// iテ」ツ?ィjテ」ツ?ョテ、ツクツ甘」ツ?ォティツシツ嘉」ツ?」テ」ツ?ヲテ」ツ??」ツつ凝・ツ??」ツ?古・ツ?ィテゥツδィテ・ツ渉姪」ツつ甘ゥツ卍、テ」ツ?凝」ツつ古」ツ?ヲテ」ツ??」ツつ?
						if ((above[i] & bit) != above[i] || (above[j] & bit) != above[j]) {
							continue;
						}
						// ティツ可イテ」ツ?古、ツクツ?ァツキツ津」ツ?凝」ツ?ゥテ」ツ??」ツ??
						if (cir[i][3] == cir[j][3]) {
							int newbit = bit + (1 << i) + (1 << j);
							bitDP[newbit] = Math.max(bitDP[newbit], bitDP[bit] + 2);
							max = Math.max(max, bitDP[newbit]);
						}
					}
				}
			}

			System.out.println(max);
			System.gc();
		}
	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

Measured memory_bytes: 162824
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  vector<ll> av,vm;
  priority_queue<ll> pque;
  for(int i=0;i<n;i++){
    ll a;
    cin>>a;
    av.push_back(a);
  }
  ll cnt=0,mcnt=0,one=0;
  for(int i=0;i<n;i++){
    ll b;
    cin>>b;
    if(b-av[i]>1) pque.push(b-av[i]);
    else if(b-av[i]==1) one++;
    else mcnt+=av[i]-b;
    cnt+=b-av[i];
  }
  if(cnt<mcnt){
    cout<<"No"<<endl;
    return 0;
  }
  while(mcnt>0){
    if(pque.empty()){
      cout<<"No"<<endl;
      return 0;
    }
    ll an=pque.top();
    pque.pop();
    mcnt-=min(mcnt,an/2);
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include<iostream>
#define inf 1e9
using namespace std;
int cp(vector<int>v,int n){
    vector<int>dp(n+1);
    dp[1]=0;
    
    for(int i=2;i<=n;i++){
        int op1=abs(v[i]-v[i-1])+dp[i-1];
        int op2=(i==2)?inf:abs(v[i]-v[i-2])+dp[i-2];
        dp[i]=min(op1,op2);
    }
    return dp[n];
}

int main()
{
    int n;
    cin>>n;
    vector<int>v(n+1);
    for(int i=1;i<=n;i++)
    cin>>v[i];
    cout<<cp(v,n);

    return 0;
}


Measured memory_bytes: 4544
#include <stdio.h>
#include <string.h>

int nm;
char dic[1000000][14];

/*long long conbert(char wd[]){
    int i;
    long long data = 0;

    for(i = 1; i <= strlen(wd); i++){                              // 1:A 2:C 3:G 4:T
        if(wd[i] == 'A') data += i*5;
        else if(wd[i] == 'C') data += i*10;
        else if(wd[i] == 'G') data += i*15;
        else if(wd[i] == 'T') data += i*20;
    }

    return data;
}*/
int getChar(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'C') return 2;
    else if(ch == 'G') return 3;
    else if(ch == 'T')return 4;
    else return 0;
}

long long getkey(char wd[]){
    long long sum = 0, p = 1, i;
    for(i = 0; i < strlen(wd); i++){
        sum += p*(getChar(wd[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){
    return (key % 1000000);
}

int h2(int key){
    return (1 + (key % 999999));
}

int insert(char wd[]){
    long long i = 0, h, key;

    key = getkey(wd);

    for(i = 0; ; i++){
        h = (h1(key)+i*h2(key)) % 1000000;
        if(strcmp(dic[h], wd) == 0) return 1;
        else if(strlen(dic[h]) == 0){
            strcpy(dic[h], wd);
            return 0;
        }
    }
    return 0;
}

void find(char wd[]){
    long long key, i = 0, h;

    key = getkey(wd);

    for(i = 0; ; i++){
        h = (h1(key)+i*h2(key)) % 1000000;
        if(strcmp(dic[h], wd) == 0){
            printf("yes\n");
            return;
        }
        else if(strlen(dic[h]) == 0){
            printf("no\n");
            return;
        }
    }
}

int main(){
    int i, j;
    char op[7];
    char wd[14];
    
    for(i = 0; i < 14; i++) wd[i] = '\0';

    scanf("%d", &nm);

    for(i = 0; i < nm; i++){
        scanf("%s %s", op, wd);
        if(op[0] == 'i'){
            insert(wd);
        }
        else{
            find(wd);
        }
    }


    return 0;
}


Measured memory_bytes: 15364
#include <stdio.h>
#define N 100

int main(){
  int n, a, max, min;
  scanf("%d", &n);
  int i;
  for(i=1;i<=n;i++){
    scanf("%d", &a);
    if(i==1){
      max = a; min = a;
    } else {
      if(max < a) max = a;
      if(min > a) min = a;
    }
  }
  printf("%d\n", max-min);
  return 0;
}

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

using namespace std;

typedef long long ll;

int main()
{
    char s[3];
    int f1=0,f2=0,f3=0;
    cin>>s;
    for(int i=0;i<3;i++)
    {
        if(s[i]=='a') f1=1;
        if(s[i]=='b') f2=1;
        if(s[i]=='c') f3=1;
    }
    if(f1 && f2 && f3 )
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
// STLを使う　p.105

#include <iostream>
#include <cstdlib>
#include <stack>
using namespace std;

int main() {
    stack<int> S;
    int a, b, x;
    string s;

    while (cin >> s) {
        if (s[0] == '+') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        } else if (s[0] == '-') {
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a-b);
        } else if (s[0] == '*') {
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        } else {
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;
    return 0;
}


Measured memory_bytes: 3208
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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

	if (a >= 13) {
		cout << b << endl;
	}
	else if (a <= 12 && a >= 6) {
		cout << b / 2 << endl;
	}
	else if (a <= 5) {
		cout << 0 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <cfloat>
#include <complex>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

vector<vector<ll> > table;
vector<P> roads;
vector<P> qs;

int main() {
  ll N, X;
  cin >> N >> X;

  ll ans = 0;
  ll min = 1000000000;
  for (int i = 0; i < N; i++) {
    ll tmp;
    cin >> tmp;
    X -= tmp;
    ans++;
    if (tmp < min) min = tmp;
  }

  ans += X / min;

  cout << ans << endl;

  return 0;
}


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

int func (int x){
  if (x % 2 == 1) return 0;
  return func(x / 2) + 1;
}


int main(){
  int N;
  cin >> N;
  
  int ans = 1;
  
  for (int i = 1; i <= N; i++) {
    if (func(i) >= func(ans)) {
      ans = i;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=998244353;

#define pb push_back
#define mp make_pair


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

    ll t,n,k;
    string s;
    cin>>n;
    cout<<(n/500)*1000+((n%500)/5)*5;


    return 0;
}




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

// 素数5つの和が合成数になっているかを真面目に確かめる方針で実装して、初めの4項を試行錯誤した結果、
// 5n+k 型の素数について考えれば楽だということにあとから気付いて実装を流用したver.
int main(){ 
  const int Nbits= 55555;
  int N;
  cin >> N;

  bitset<Nbits> primes; // primes.test(i): iが素数かどうか
  primes.set(); primes.reset(0); primes.reset(1);
  int div= 2;
  while(div*div < Nbits){
    if(primes.test(div)){
      for(int i=2*div; i< Nbits; i+= div){
        primes.reset(i);
      }
    }
    div++;
  }

  bitset<Nbits> mask; // 5n+k型のビットマスク
  for(int i=1; i<Nbits; i+=5){ mask.set(i); }

  bitset<Nbits> ans;
  ans.set(2);
  while(true){
    bitset<Nbits> buf= primes & mask;
    if(buf.count() >= N-1){
      ans |= buf;
      break;
    }

    mask << 1;
  }

  cout << 2;
  int p= 3; int cnt_out= 1;
  while(cnt_out < N){
    if(ans.test(p)){
      cout <<" "<< p;
      cnt_out++;
    }
    p+= 2;
  }
  cout << endl;
}

Measured memory_bytes: 256
S = input()
T = [S[i] for i in range(4)]
A = ''.join(T[:2])
B = ''.join(T[2:])
Month = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12']

if A in Month and B in Month:
    print('AMBIGUOUS')
elif A in Month and B not in Month:
    print('MMYY')
elif A not in Month and B in Month:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int max = int.MaxValue;
            for (int i = -100; i <= 100; i++)
            {
                int tmp = 0;
                for (int j = 0; j < n; j++)
                {
                    tmp += (int)Math.Pow((i - a[j]), 2);
                }
                if (tmp < max)
                {
                    max = tmp;
                }
            }
            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 3032
#include <stdio.h>

#define R_MAX 10    // 最大行サイズ
#define C_MAX 10000 // 最大列サイズ

#define MAX(a,b) ((a)>(b)?(a):(b))

int main( void );
void solve( int input_row, int input_col, int input_ary[R_MAX][C_MAX]);

// 型定義
typedef unsigned char  uint8;
typedef unsigned short uint16;
typedef unsigned long  uint32;
typedef signed   char  sint8;
typedef signed   short sint16;
typedef signed   long  sint32;

int main( void )
{
    int input_row;               // [入力]行数(scanf用なのでint型)
    int input_col;               // [入力]列数(scanf用なのでint型)
    uint16 u2col;                // 列走査用一時変数
    uint8  u1row;                // 行走査用一時変数
    int input_ary[R_MAX][C_MAX]; // [入力]input_ary[行][列] : 煎餅の裏表(0:裏,1:表)が格納された2重配列(scanf用なのでint型) 
    //入力
    while(1)
    {
        scanf("%d %d",&input_row,&input_col);

        if( (input_row == 0) && (input_col == 0 ) )
        {
            break;
        }
        for( u1row = (uint8)0U; u1row < (uint8)input_row; u1row++ ){
            for( u2col = (uint16)0U; u2col < (uint16)input_col; u2col++ ){
                scanf("%d",&(input_ary[u1row][u2col]));
            }
        }
        
        // 問題解答
        solve( input_row, input_col, input_ary );
    }

    return 0;
}

// 問題解答用関数
void solve( int input_row, int input_col, int input_ary[R_MAX][C_MAX]){
    uint32 u4sellable_max;       // [出力]出荷できる最大値
    uint32 u4sellable_cnt;       // ある列の出荷できる総数
    uint16 u2row_pattern;        // 行反転パターン番号
    uint16 u2row_pattern_num;    // 行反転パターンの数
    uint16 u2col;                // 列走査用一時変数
    uint8  u1row;                // 行走査用一時変数
    uint8  u1row_reverse[R_MAX]; // 各行の反転要否(0：反転しない、1：反転する)
    uint8  u1front_cnt;          // 表の数
    uint8  u1back_cnt;           // 裏の数

    // 行ごとに反転させるかどうかを全パターン試す。
    // 2^row(==1<<row)パターンあり、
    // 2進数表現x桁目とx行を対応させ
    //  0：反転しない、1：反転する と考える。
    u4sellable_max = 0UL;
    u2row_pattern_num = (uint16)(1U << (uint8)input_row); // input_rowは最大10なのでuint16のサイズを超えない
    for( u2row_pattern = (uint16)0U; u2row_pattern < u2row_pattern_num; u2row_pattern++ ){
        // 各行の反転要否を扱いやすくするため配列に格納しておく
        for( u1row = (uint8)0U; u1row < (uint8)input_row; u1row++ ){
            u1row_reverse[u1row] = (uint8)( (u2row_pattern>>u1row) & (uint16)0x0001U );
        }

        // 列ごとに出荷できる数を求め、合計する
        u4sellable_cnt = 0UL;
        for( u2col = (uint16)0U; u2col < (uint16)input_col; u2col++ ){
            // 裏の数を数える
            u1back_cnt = (uint8)0U;
            for( u1row = (uint8)0U; u1row < (uint8)input_row; u1row++ ){
                // [0(裏),0(反転しない)] または [1(表),1(反転する)] のとき裏
                if( ((uint8)input_ary[u1row][u2col] ^ u1row_reverse[u1row]) == (uint8)0U ){
                    u1back_cnt++;
                }
            }

            // 表の数の方が多ければ裏返せばよいので、表と裏の大きいほうの数が出荷できる
            u1front_cnt     = (uint8)input_row - u1back_cnt;
            u4sellable_cnt += MAX( u1front_cnt, u1back_cnt );
        }

        // 最大値を更新する
        if( u4sellable_max < u4sellable_cnt ){
            u4sellable_max = u4sellable_cnt;
        }
    }

    //出力
    printf("%d\n",u4sellable_max);
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 100000 + 10;
const LL MOD = 1e9 + 7;
vector<int> g[N];
int n,dp[N][2];
void dfs(int u,int p){
	dp[u][0]=dp[u][1]=1;
	for(auto v:g[u]){
		if(v==p)continue;
		dfs(v,u);
		dp[u][0]=1LL*dp[u][0]*(dp[v][1]+dp[v][0])%MOD;
		dp[u][1]=1LL*dp[u][1]*dp[v][0]%MOD;
	}
}
int main() {
	scanf("%d", &n);
	for(int i=1;i<n;i++){
		int u,v; scanf("%d%d",&u,&v);
		g[u].push_back(v); g[v].push_back(u);
	}
	dfs(1,1);
	cout<<(dp[1][0]+dp[1][1])%MOD<<endl;
}

Measured memory_bytes: 13440
def chmin(a, b):
  if a > b:
    return b
  else:
    return a
N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float("inf")]*N
dp[0] = 0
for i in range(N - 1): #ジャンプ地点
	for j in range(1, min(K + 1, N - i)): #ジャンプ距離
		dp[i+j] = chmin(dp[i + j], dp[i] + abs(h[i + j] - h[i]))
print(dp[N - 1])


Measured memory_bytes: 55264
#define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

int main()
{
	int n;
	for (; cin >> n;)
	{
		vector<int> v;

		for (int i = 1; i <= n; i<<=1)
		{
			if (i & n)
			{
				v.push_back(i);
			}
		}

		for (int i = 0; i < v.size(); i++)
		{
			cout << v.at(i) << (i == v.size() - 1 ? "" : " ");
		}
		cout << endl;
	}
}


Measured memory_bytes: 3148
import heapq
n, m = map(int,input().split())
ip = list(map(int,input().split()))
a = []
for i in range(n):
    heapq.heappush(a, -ip[i])
for i in range(m):
    new = -heapq.heappop(a)//2
    heapq.heappush(a, -new)
print(-sum(a))

Measured memory_bytes: 14180
#include<stdio.h>
#include<string.h>
int main(){
    char moji[1001] = {}, str[8] = {}, tmpstr[1001] = {}, x[1001] = {};
    int a, b, n, tmp, r, i, tmp2;
    scanf("%s", moji);
    scanf("%d", &n);
    for( i = 0; i < n; i++ ){
        scanf("%s %d %d", str, &a, &b);
        if( strcmp( str, "print" ) == 0 ){
            for( tmp = a; tmp <= b; tmp++ ){
                printf("%c", moji[tmp]);
                }
            printf("\n");
            }else if( strcmp( str, "reverse" ) == 0 ){
              strcpy( tmpstr, moji );
                for( tmp = a; tmp <= b; tmp++ ){
                    moji[ tmp ] = tmpstr[ b - ( tmp - a ) ];
                }
        }else{
            scanf("%s", x);
            for( tmp = a; tmp <= b; tmp++ ){
                moji[tmp] = x[ tmp - a ];
            }
        }
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,a,n) for(int i=a;i<=n;i++)
#define repb(i,a,n) for(int i=a;i>=n;i--)
#define trav(a,x) for(auto a=x.begin();a!=x.end();a++)
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long double ld;
typedef vector <int> vi;
typedef long long ll;

void solve()
{
  int k; cin>>k;

  int a,b; cin>>a>>b;

  if(a%k==0 || b%k==0 || b/k!=a/k) cout<<"OK"<<"\n";
  else cout<<"NG"<<"\n";
}

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

  int t;
  t=1;

  rep(i,t) solve();

return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;

int gcd(int a, int b){
    if(b == 0){
        return a;
    } else {
        b = gcd(b, a%b);
        return b;
    }
}
int vgcd(vector<int> a){
    int ans = a[0];

    for(int i = 1; i < a.size(); i++){
        ans = gcd(ans, a[i]);
    }

    return ans;

}
int main(){
    int n;
    cin >> n;
    vector<int> a(n);

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

    sort(a.begin(), a.end());

    int ans = vgcd(a);

    cout << ans << endl;

}


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

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

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

	bool flag = true;
	rep(i, S.size())
	{
		char c = S[i];

		if (i % 2 == 0)
		{
			if (c == 'L')
			{
				flag = false;
				break;
			}
		}
		else
		{
			if (c == 'R')
			{
				flag = false;
				break;
			}
		}
	}

	if (flag)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
   long long a,b,c[100000],sum=0,i,sum1=0;
   scanf("%lld %lld",&a,&b);
   for(i=0;i<b;i++)
   {
       scanf("%d",&c[i]);
   }
   for(i=0;i<b;i++)
   {
       sum=sum+c[i];
   }
   sum1=a-sum;
   if(sum1>=0)
    printf("%lld\n",sum1);
   else if(sum1<0)
    printf("-1\n");

    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  deque<int> d;
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int j, k, l;
    cin >> j >> k;
    switch (j) {
      case 0:
        cin >> l;
        if (k == 0) {
          d.push_front(l);
        } else {
          d.push_back(l);
        }
        break;
      case 1:
        cout << d[k] << endl;
        break;
      case 2:
        if (k == 0) {
          d.pop_front();
        } else {
          d.pop_back();
        }
        break;
    }
  }
  return 0;
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
 
string rotation(vector<char> &x){
  int N=x.size();
  x.insert(x.begin(), x.at(N-1));
  x.pop_back();
  return string(x.begin(), x.end());
}
  
  
int main(){
  string S,T; cin >> S >> T;
  int k=S.size();
  vector<char> MY(k);
  for(int i=0;i<k;i++){
    MY.at(i)=S.at(i);
  }
  for(int i=0;i<k;i++){
    if(rotation(MY)==T){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        cin >> a[i];
    }
    map<int,int> mp;
    int ans = 0;
    int tmp = 0;
    rep(i, n)
    {
        int x = a[i] / 400;
        if(x <= 7 && !mp[x]){
            mp[x]++;
            ans++;
        }else if(x > 7){
            tmp++;
        }
    }
    cout << max(1, ans) << " " << ans + tmp << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<climits>

using namespace std;

int vals[100005];
int dp[100005];

int f(int n, int k){
    if(n == 0){
        return 0;
    }

    if(dp[n] != 1e9){
        return dp[n];
    }

    for(int i = 1;i<=k;i++){
        if(n-i >= 0){
            dp[n] = min(f(n-i, k) + abs((vals[n]-vals[n-i])) , dp[n]);
        }
    }

    return dp[n];
}

int main(){
    int n,k;

    cin >> n;
    cin >> k;

    for(int i = 0;i<n;i++){
        cin >> vals[i];
        dp[i] = 1e9;
    }

    cout << f(n-1, k) << endl;
}

Measured memory_bytes: 12188
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cctype>
using namespace std;
int main(){
    double n,x,y,p,p2,p3,p4,sum1,sum2,sum3;
    double xi[1000];
    double yi[1000];
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>x;
        xi[i]=x;
    }
    for(int i=0;i<n;i++){
        cin>>y;
        yi[i]=y;
    }

    p=xi[0]-yi[0];
    for(int i=0;i<n;i++){
        if(xi[i]>yi[i]){
            if(p<xi[i]-yi[i]){
                p=xi[i]-yi[i];
            }
            sum1+=xi[i]-yi[i];
        }
        else if(xi[i]<yi[i]){
            if(p<yi[i]-xi[i]){
                p=yi[i]-xi[i];
            }
            sum1+=yi[i]-xi[i];
        }
        
    }
    cout<<fixed<<sum1<<endl;
    for (int i=0;i<n;i++){
        if(xi[i]-yi[i]!=0){
            p2=pow(xi[i]-yi[i],2.0);
            sum2+=p2;
        }
        
    }
    cout<<fixed<<sqrt(sum2)<<endl;
    for (int i=0;i<n;i++){
        if(xi[i]>yi[i]){
            p3=pow(xi[i]-yi[i],3.0);
            sum3+=p3;
        }
        else if(xi[i]<yi[i]){
            p3=pow(yi[i]-xi[i],3.0);
            sum3+=p3;
        }
        
    }
    cout<<fixed<<pow(sum3,1.0/3.0)<<endl;
    cout<<fixed<<p<<endl;
    return 0;
}


Measured memory_bytes: 3484
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
ll ceil(ll x,ll y)
{
	return x/y+(x%y!=0);
}
int main()
{
    IOS
 	// freopen("input.txt","r",stdin);
 	// freopen("output.txt","w",stdout);
 	// freopen("error.txt","w",stderr);
 	ll w,h,n;
 	cin>>w>>h>>n;
 	cout<<min(ceil(n,w),ceil(n,h))<<endl;	
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define N_MAX 5000

int dp[N_MAX + 1][N_MAX + 1];

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  int N;
  string s;

  cin >> N;
  cin >> s;

  int men = 0;
  int mlen = 0;
  
  //  for(int k=0; k<N-1; k++) {
  for(int k=0; k<1; k++) {
    string s1 = s.substr(k, N-k);
    string s2 = s1;

    Fill(dp, 0);

    int maxlen = 0;
    int endIdx = 0;
    for(int i=0; i<N-k; i++) {
      for(int j=i+1; j<N-k; j++) {
	if(s1[i]==s2[j]) {
	  dp[i+1][j+1] = dp[i][j] + 1;
	  if(dp[i+1][j+1] > j-i) {
	    dp[i+1][j+1] = j-i;
	  }
	  if(dp[i+1][j+1] > maxlen) {
	    maxlen = dp[i+1][j+1];
	    endIdx = i+1;
	  }
	}
      }
    }

    if(mlen <= maxlen) {
      mlen = maxlen;
      men = endIdx + k;
    }
  }
  
  string com = s.substr(men - mlen, mlen);
  //  cout <<men << "," << mlen << endl;
  
  //  cout << com << endl;
  cout << mlen << endl;
  
  return 0;
}


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

using namespace std;

int c[20];

int main()
{
	int n,ma = 0,mi = 0x3fffffff;
	scanf("%d%d%d",&n,&ma,&mi);
	if((ma * 10 + mi) % 4)printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 128
#include <iostream>

struct Dice{
    int top, S, E, W, N, bottom;    
    void Set(int *Input);
    void Roll_N();
    void Roll_W();
    void Roll_S();
    void Roll_E();
};
void Dice::Set(int *Input)
{
    top = Input[0];
    S = Input[1];
    E = Input[2];
    W = Input[3];
    N = Input[4];
    bottom = Input[5];
}

void Dice::Roll_S()
{
    int temp;
    temp = top;
    top = N;
    N = bottom;
    bottom = S;
    S = temp;
}

void Dice::Roll_E()
{
    int temp;
    temp = top;
    top = W;
    W = bottom;
    bottom = E;
    E = temp;
}

void Dice::Roll_N()
{
    int temp;
    temp = top;
    top = S;
    S = bottom;
    bottom = N;
    N = temp;
}

void Dice::Roll_W()
{
    int temp;
    temp = top;
    top = E;
    E = bottom;
    bottom = W;
    W = temp;
}

int main(){
    int Input[6];
    Dice Dice1;
    char command[100];
    //std::string command;
    for (int i = 0; i < 6; i++)
        std::cin >> Input[i];
    for (int i = 0; i < 100; i++){
        std::cin >> command[i];
        if(std::cin.eof()){
            command[i] = '\0';
            break;
        }           
    }        

    Dice1.Set(Input);
    for (int i = 0; command[i] != '\0'; i++){
        if(command[i] == 'S'){
            Dice1.Roll_S();
        }
        else if(command[i] == 'E'){
            Dice1.Roll_E();
        }
        else if (command[i] == 'W')
        {
            Dice1.Roll_W();
        }
        else if (command[i] == 'N')
        {
            Dice1.Roll_N();
        }
    }
    std::cout << Dice1.top << std::endl;
}


Measured memory_bytes: 3104