akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
    int n;
    scanf("%d", &n);

    int A[1000];
    int i;
    for (i = 0; i < n; i++) scanf("%d", A + i);

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

    int b, m, e, k, mod;
    int T[1000];
    while (q--) {
        scanf("%d %d %d", &b, &m, &e);
        mod = e - b;
        for (k = 0; k < mod; k++) {
            T[b + ((k + e - m) % mod)] = A[b + k];
        }
        for (i = b; i < e; i++) {
            A[i] = T[i];
        }
    }

    n--;
    for (i = 0; i < n; i++) printf("%d ", A[i]);
    printf("%d\n", A[n]);

    return 0;
}


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

int main(){
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	
	int count = 0;
	for(int i = 0; i <= a; i++)
		for(int j = 0; j <= b; j++)
			for(int k = 0; k <= c; k++){
				if(500*i + 100*j + 50*k == x)
					count++;
			}

	cout << count << endl;
}

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

public class Main {

    int a, b, c, n;
    int[] ls;
    int[] ts;

    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = sc.nextInt(); b = sc.nextInt(); c = sc.nextInt();
        ts = new int[]{a, b, c};
        ls = new int[n];
        for (int i = 0; i < n; i++) {
            ls[i] = sc.nextInt();
        }

        int max = 1 << (n * 3);
        int mask = (1 << n) - 1;
        int ans = 1 << 30;
        for (int i = 0; i < max; i++) {
            int ab = i & mask;
            int bb = (i >> n) & mask;
            int cb = (i >> (n * 2)) & mask;
            ans = Math.min(ans, calc(ab, bb, cb));
        }
        System.out.println(ans);
    }

    int calc(int ab, int bb, int cb) {
//        debug(Integer.toBinaryString(ab), Integer.toBinaryString(ab), Integer.toBinaryString(ab));
        if (ab == 0 || bb == 0 || cb == 0) {
            return 1 << 30;
        }
        if ((ab & bb) > 0 || (bb & cb) > 0 || (cb & ab) > 0) {
            return 1 << 30;
        }
        int[] bs = {ab, bb, cb};
        int cost = 0;
        for (int j = 0; j < 3; j++) {
            int len = 0;
            cost += (Integer.bitCount(bs[j]) - 1) * 10;
            for (int i = 0; i < n; i++) if (((bs[j] >> i) & 1) == 1) {
                len += ls[i];
            }
            cost += Math.abs(ts[j] - len);
        }
        return cost;
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 24404
#include<bits/stdc++.h>
using namespace std;
typedef long l;
typedef long long ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    const l mod = 1000000007;
    l t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        l n;
        cin>>n;
        vector<l> v(n);
        for(l i = 0 ; i<n ; i++)
        cin>>v[i];
       /* stack<l> s;
        vector<l> u(n,-1);
        for(l i = 0 ; i<n ;i++)
        {
            if(s.empty())
            {
                s.push(i);
                continue;
            }
            if(v[i]<=v[s.top()])
            {
                s.push(i);
            }
            else
            {
                while(!s.empty() && v[i]>v[s.top()])
                {
                    u[s.top()] = i;
                    s.pop();
                }
                s.push(i);
            }
        }//for  */
        l ans = 0;
        vector<l> md(n,0);
        for(l i = n-1 ; i>=0 ;i--)
        {
                        l tt; 
            if(i == n-1)
            {
                tt = 0;
                md[i] = 0;
                continue;
            }
            if(v[i+1]<=v[i])
            {
                md[i] = md[i+1]+1;
            }
            else
            md[i]=0;
            ans = max(ans , md[i]);
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>

using namespace std;

int main(){
	char ans[5],a[5];
	int hit,blow;
	while(true){
		cin >> ans >> a;
		if(ans[0] == '0' && a[0] == '0')
			return 0;
		hit = 0;
		blow = 0;
		for(int i=0; i<4; i++){
			for(int j=0; j<4; j++){
				if(ans[i] == a[j]){
					if(i == j)
						hit++;
					else
						blow++;
					break;
				}
			}
		}
		cout << hit << ' ' << blow << endl;
	}
}

Measured memory_bytes: 0
#!/usr/bin/env python3
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def solve():
    return


def main():
    A, B = map(int, input().split())
    print(max([A + B, A + A - 1, B + B - 1]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pi=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vll=vector<ll>;
using vstr=vector<string>;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
void Yes(bool c) { if (c)print("Yes"); else print("No"); };
void YES(bool c) { if (c)print("YES"); else print("NO"); };

vll runrun;


ll func(int n){
    int ofset = 0;
    int count = 9;
    while(count<n){
        int c = 0;
        for(int i=ofset;i<count;i++){
            ll a = runrun[i]%10;
            ll b = 10*runrun[i]+a;
            if(a!=0){
                runrun.pb(b-1);
                c++;
            }
            runrun.pb(b);
            c++;
            if(a!=9){
                runrun.pb(b+1);
                c++;
            }
        }
        ofset = count;
        count += c;
    }
    return runrun[n-1];
}

void solve() {
    int K;
    cin >> K;
    rng(i,1,10){
        runrun.pb(i);
    }
    print(func(K));
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 5252
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

const int Inf = 1e9;

int main(int argc, char const *argv[]) {
  int n;  cin >> n;
  int ans = 0;
  int mini = Inf;
  vector<int> w, b, t(10001);
  vector<bool> visit(n, false);
  for (int i = 0; i < n; ++i) {
    int a;  cin >> a;
    mini = min(mini, a);
    w.push_back(a);
    b.push_back(a);
  }
  sort(b.begin(), b.end());
  for (int i = 0; i < n; ++i) {
    t[b[i]] = i;
  }
  for (int i = 0; i < n; ++i) {
    if (visit[i]) continue;
    int current = i;
    int sum = 0;
    int e = 0;
    int m = Inf;
    while (1) {
      visit[current] = true;
      e++;
      int value = w[current];
      sum += value;
      m = min(m, value);
      current = t[value];
      if (visit[current]) break;
    }
    ans += min(sum + m + (e + 1) * mini, sum + (e - 2) * m);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 3216
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int dp[100110];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K; cin >> N >> K;
    int h[100110];
    rep(i, N) cin >> h[i];
    rep(i, 100110) dp[i] = INF;
    dp[0] = 0;
    rep(i, N) {
        rep(j, K) {
            int cost = dp[i] + abs(h[i + j + 1] - h[i]);
            dp[i + j + 1] = min(dp[i + j + 1], cost);
        } 
    }
    // rep(i, N) cout << dp[i] << " ";
    // cout << endl;
    cout << dp[N - 1] << endl;

    return 0;
}


Measured memory_bytes: 4424
#define M 2000000000
#include <stdio.h>

int min(int,int);
int abs(int);

int main(){
    int n,k;
    int h[100000];
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++) scanf("%d",&h[i]);
    int dp[100000]={};
    for(int i=0;i<n;i++) dp[i]=M;

    for(int i=0;i<n;i++){
        if(i==0){
            dp[i]=0;
        }
        else {
            int j;
            if(i-k<0) j=0;
            else j=i-k;
            for(;j<i;j++){
                dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
            }
        }
        // for(int k=0;k<n;k++){
            // printf("dp[%d]=%d\n",k,dp[k]);
        // }
        // printf("\n");
    }
    printf("%d\n",dp[n-1]);

}

int min(int a,int b){
    if(a<=b) return a;
    else return b; 
}

int abs(int n){
    if(n>=0) return n;
    else return -n;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int k;cin>>k;
string s;cin>>s;

if(s.size()<=k){
  cout<<(s)<<endl;
}else{
  cout<<(s.substr(0, k));
  cout<<"..."<<endl;
}
  
  return 0;
}


Measured memory_bytes: 3632
N,M = map(int,input().split())
AB = []
count = 0
sum = 0

for i in range(N):
  a,b = map(int,input().split())
  s = [a,b]
  AB.append(s)
  
AB.sort()
i = 0
while(1):
  if(count >= M):
    break  
  if((count + AB[i][1]) <= M):
   sum += AB[i][0]*AB[i][1]
   count += AB[i][1]
  else:
    rest = M - count
    sum += AB[i][0]*rest
    break
  i += 1

print(sum)

Measured memory_bytes: 20072
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = (int)(n-1); i >= 0; i--)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll m;cin>>m;
  ll num=0;
  ll su=0;
  rep(i,m){
    ll a,b;cin>>a>>b;
    num+=b;
    su+=a*b;
  }
  ll res=num-1;
  if(su%9==0){
    res+=su/9-1;
  }
  else res+=su/9;
  cout<<res<<endl;

  return 0;

}


Measured memory_bytes: 256
#pragma GCC optimize(2)

#include<bits/stdc++.h>
#define mp make_pair
#define rep(i,n) for(int i=0;i<n;i++)
#define BINF 0x7fffffff
#define INF 0x3f3f3f3f
#define LINF 9223372036854775807
#define END(s) {cout<<s;return 0;}
#define CON(s) {cout<<s;continue;}
#define BRE(s) {cout<<s;break;}
#define pb push_back
#define All(a) a.begin(),a.end()  //with A in CAPITAL!!!
#define sz(a) (int)a.size()
#define F first
#define S second
using namespace std;

int p[]={1,4,8,9,16,25,27,32,36,49,64,81,100,121,125,128,144,169,196,216,225,243,256,289,324,343,361,400,441,484,512,529,576,625,625,676,729,784,841,900,961,1000};

int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int i=0;
	while(p[i]<n) i++;
	if(p[i]==n) cout<<p[i]<<endl;
	else cout<<p[i-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

bool isPrime(int n){
  if(n==2)return true;
  if(n%2==0)return false;
  for(int i=3;i<=n/i;i+=2){
    if(n%i==0)return false;
  }
  return true;
}

vector<int> p;
ll n;
ll s[1001]={};

ll solve(){
  FOR(i,2,1001)if(isPrime(i))p.pb(i);
  if(n==1)return 1;
  FOR(i,2,n+1){
    int tmp=i,index=0;
    while(tmp!=1 && index!=p.size()){
      if(tmp%p[index]==0){
        s[p[index]]++;
        tmp/=p[index];
      }
      else index++;
    }
  }
  ll res=1;
  FOR(i,2,n+1){
    if(0<s[i]){
      res*=(s[i]+1);
      res%=mod;
    }
  }
  return res;
}

int main()
{
  cin>>n;
  cout<<solve()<<endl;
  return 0;
}



Measured memory_bytes: 256
def inputstdin():
    n, y = map(int, input().split(" "))
    return n, y


def calc(n, y):
    for a in range(n + 1):
        for b in range(n - a + 1):
            c = n - b - a
            if 10 * a + 5 * b + c == y:
                return a, b, c
    return -1, -1, -1


def main():
    n, y = inputstdin()
    print(" ".join(map(str, calc(n, y // 1000))))


main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>

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

using namespace std;
using ll = long long;
using ull = unsigned long long;


int main() {

	vector<int> v(3);
	int ans = 0;

	cin >> v[0] >> v[1] >> v[2];


	while (!(v[0] == v[1] && v[1] == v[2])) {
		sort(v.begin(), v.end(), [](int x, int y) { return x < y; });
		if (v[2] - v[1] >= 1) {
			v[0]++;
			v[1]++;
		} else {
			v[0] += 2;
		}
		ans++;
	}

	cout << ans NL;


	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define MOD_Q 998244353
#define PI 3.14159265358979
#define ll long long
using namespace std;

int main()
{
	int x;
	cin >> x;
	printf("%d", x ? 0 : 1);

	return 0;
}

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

int main(void){
    // Your code here!
    long long N;cin>>N;
    long long X[N],Y[N];for(long long i=0;i<N;i++)cin>>X[i]>>Y[i];
    double length=0;
    for(long long i=0;i<N;i++){
        for(long long j=i+1;j<N;j++){
            length+=sqrt((X[i]-X[j])*(X[i]-X[j])+(Y[i]-Y[j])*(Y[i]-Y[j]));
        }
    }
    length/=(N*(N-1)/2);
    cout<<setprecision(15)<<length*(N-1)<<endl;
    return 0;
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define F first
#define S second
#define fast_io ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
const int N=1e2+10,LN=30,SQ=550;
const ll INF=1e16;
const int MOD=1000000007 /*998244353*/;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using pll=pair<ll,ll>;
using pii=pair<int,int>;
#define ordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
ll pow(ll x, ll y, ll mod){
    ll ans=1;
    while (y != 0) {
        if (y & 1) ans = ans * x % mod;
        y >>= 1;
        x = x * x % mod;
    }
    return ans;
}
ll n,ans;
int main(){
    fast_io;
    cin >> n;
    for(ll i=1; i<n; i++){
        if(n%i==0) ans--;
        ans+=(n-n%i)/i;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let a: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let b: Vec<usize> = (0..n).map(|_| iterator.next().unwrap().parse().unwrap()).collect();
    let c: Vec<usize> = (0..(n - 1)).map(|_| iterator.next().unwrap().parse().unwrap()).collect();

    let mut ans: usize = 0;
    for i in 0..n {
        ans += b[a[i] - 1];
        if i >= 1 && a[i - 1] + 1 == a[i] {
            ans += c[a[i - 1] - 1];
        }
    }
    return ans.to_string();
}


Measured memory_bytes: 2164
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n, m;
	cin >> n >> m;
	cout << (n - 1) *(m - 1) << endl;

	return 0;
}

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

using namespace std;

#define int long long
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

signed main() {
	int h1, h2, k1, k2, a, b, c, d;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	int h = h1 * a + h2 * b + h1 / 10 * c + h2 / 20 * d;
	int k = k1 * a + k2 * b + k1 / 10 * c + k2 / 20 * d;
	if(h > k) cout << "hiroshi";
	else if(h < k) cout << "kenjiro";
	else cout << "even";
	cout << "\n";
	return 0;
}



Measured memory_bytes: 3076
#include <iostream>
using namespace std;
#define ll long long int
ll a, sign, arr[3001], dp[3001][3001];
ll eval (ll l, ll r){
    if (l==r) dp[l][r]=sign*arr[l];
    if (dp[l][r]!=0) return dp[l][r];
    if ((l+((a-1)-r))%2==0){ //Taro's turn
        dp[l][r]=max(eval(l+1, r)+arr[l], eval(l, r-1)+arr[r]);
        return dp[l][r];
    }
    else { //Jiro's turn
        dp[l][r]=min(eval(l+1, r)-arr[l], eval(l, r-1)-arr[r]);
        return dp[l][r];
    }
}
int main(){
    cin>>a;
    if (a%2==0) sign=-1;
    else sign=1;
    for (ll i=0; i<a; i++) cin>>arr[i];
    cout<<eval(0, a-1)<<endl;
}

Measured memory_bytes: 70144
#include <stdio.h>

int main() {
	int x, a, b;

	scanf("%d", &x);
	scanf("%d", &a);
	scanf("%d", &b);

	int judge = b - a;

	if (judge <= 0)
		printf("delicious\n");
	else if (judge > 0  && judge <= x)
		printf("safe\n");
	else if (judge > x)
		printf("dangerous\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
using namespace std;
struct node
{
	string s;
	int t;
}w[200005];
bool cmp(node a,node b)
{
	if(a.t==b.t){
		return a.s<b.s;
	}
	return a.t>b.t;
}
string a[200005];
map<string,int> m;
int main()
{
	int n;
	cin>>n;
	int p=0;
	for(int i=0;i<n;i++){
		string ss;
		cin>>ss;
		if(!m[ss]){
			a[p++]=ss;
		}
		m[ss]=m[ss]+1;
	}
	for(int i=0;i<p;i++){
		w[i].s=a[i];
		w[i].t=m[a[i]];
	}
	sort(w,w+p,cmp);
	cout<<w[0].s<<endl;
	for(int i=1;i<p;i++){
		if(w[i].t==w[i-1].t){
			cout<<w[i].s<<endl;
		}else{
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   int N;
   cin >> N;
   int A[N],B[N],C[N];
   for (int i=0; i<N; i++) {
      cin >> A[i];
   }
   for (int i=0; i<N; i++) {
      cin >> B[i];
   }
   for (int i=0; i<N; i++) {
      cin >> C[i];
   }
   sort(A,A+N);
   sort(B,B+N);
   sort(C,C+N);
   long long total=0;
   for (int i=0; i<N; i++) {
      long long counta=0,countc=0;
      counta=lower_bound(A,A+N,B[i])-A;
      if (B[i]<C[N-1]) countc=N-(upper_bound(C,C+N,B[i])-C);
      total+=counta*countc;
   }
   cout << total << endl;
}

Measured memory_bytes: 1408
n = int(input())
s = [int(input()) for _ in range(n)]
s.sort()
sum_s = sum(s)
not_ten_multipe_s = [i for i in s if i%10 != 0]
not_ten_multipe_s.sort()

if sum_s % 10 == 0:
    if not_ten_multipe_s:
        print(sum_s - not_ten_multipe_s[0])
    else:
        print(0)
else:
    print(sum_s)

Measured memory_bytes: 3060
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())

priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }


void solve(){
    int n;
    cin >> n;
    if(n%1000==0)cout << 0 << endl;
    else cout << 1000-(n%1000) << endl;
}

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




Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,n) FOR(i,0,n){ll buf; scanf("%lld",&buf); a.pb(buf); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


int main(void) {
  ll a, b, mid;
  vll h;
  cin >> n >> a >> b;
  PB(h, n);

  ll up = 10e9, low = 0;

  while (up != low) {
	mid = (up + low) >> 1;
	cnt = mid;
	FOR(i, 0, n) {
	  if (h[i] > b*mid) cnt -= (h[i] - b * mid + (a - b - 1)) / (a - b);
	}
	if (cnt >= 0) {
	  up = mid;
	}
	else {
	  low = mid + 1;
	}
  }
  cout << low << endl;

  return 0;
}

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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

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

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

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

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

    string add1;
    string add2;
    bool omote = true;
    for (int i = 0; i < Q; ++i) {
        ll T;
        cin >> T;
        if (T == 1) {
            omote = !omote;
        } else {
            ll F;
            string C;
            cin >> F >> C;
            if (F == 1) {
                if (omote) {
                    add1 += C;
                } else {
                    add2 += C;
                }
            } else {
                if (omote) {
                    add2 += C;
                } else {
                    add1 += C;
                }
            }
        }
    }

    reverse(all(add1));
    if (omote) {
        cout << add1 << S << add2 << endl;
    } else {
        reverse(all(add1));
        reverse(all(add2));
        reverse(all(S));
        cout << add2 << S << add1 << endl;
    }
}

Measured memory_bytes: 3912
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	lint a[300010]={};
	priority_queue<int,vector<int>,greater<int>> ql;
	priority_queue<int> qr;
	lint qsum;
	lint lsum[100010]={};
	lint rsum[100010]={};
	lint ans=-1e18;
	
	cin >> N;
	for(int i=0;i<3*N;i++)
		cin >> a[i];
	
	qsum=0;
	for(int i=0;i<N;i++)
	{
		ql.push(a[i]);
		qsum+=a[i];
	}
	lsum[0]=qsum;
	for(int i=0;i<N;i++)
	{
		ql.push(a[N+i]);
		qsum+=a[N+i];
		
		qsum-=ql.top();
		ql.pop();
		lsum[i+1]=qsum;
	}
	
	qsum=0;
	for(int i=0;i<N;i++)
	{
		qr.push(a[3*N-i-1]);
		qsum+=a[3*N-i-1];
	}
	rsum[N]=qsum;
	for(int i=0;i<N;i++)
	{
		qr.push(a[2*N-i-1]);
		qsum+=a[2*N-i-1];
		
		qsum-=qr.top();
		qr.pop();
		rsum[N-i-1]=qsum;
	}
	
	for(int i=0;i<=N;i++)
		ans=max(ans,lsum[i]-rsum[i]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5368
import java.util.*;

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

    while(true){
      int n = sc.nextInt();
      if(n == 0) break;

      int m = sc.nextInt();
      char[] s = sc.next().toCharArray();
      int[] IOIlength = new int[m];
      int[] lengthCount = new int[m + 1];
      int previousLength = -1;

      for(int i = 2; i < m; i++){
        if(s[i] == 'I' && s[i - 1] == 'O' && s[i - 2] == 'I'){
          IOIlength[i] = IOIlength[i - 2] + 1;
          if(IOIlength[i] <= previousLength){
            lengthCount[previousLength]++;
          }
          previousLength = IOIlength[i];
        }
      }
      if(0 < previousLength){
        lengthCount[previousLength]++;
      }

      int answer = 0;

      for(int i = n; i <= m; i++){
        if(lengthCount[i] > 0){
          answer += (i - n + 1) * lengthCount[i];
        }
      }

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

Measured memory_bytes: 24000
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
            long L = x[0] + x[1];
            long R = x[2] + x[3];
            if (L > R) Console.WriteLine("Left");
            else if (L < R) Console.WriteLine("Right");
            else Console.WriteLine("Balanced");
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<string>
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) std::memset(arg,n,sizeof(arg))
using std::cin;
typedef long long ll;
typedef std::pair<int,int> pi;
typedef std::vector<int> vi;
const int INF=1e+9;
const ll INFLL=1e+17;
int N;
int solve(){
  int x=800*N;
  int y=N/15*200;
  return x-y;
}
int main(){
  cin>>N;
  prin(solve());
  return 0;
}


Measured memory_bytes: 256
n = int(input())
lis = [1]
i = 1
while 6 ** i <= n:
    lis.append(6 ** i)
    i += 1
i = 1
while 9 ** i <= n:
    lis.append(9 ** i)
    i += 1

dp = [[0] * (n+1) for i in range(len(lis))]
for i in range(n+1):
    dp[0][i] = i
#print(lis)
for i in range(1,len(lis)):
    for j in range(1, n+1):
        if j < lis[i]:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = min(dp[i-1][j], dp[i][j-lis[i]] + 1)
print(dp[len(lis)-1][n])


Measured memory_bytes: 49008
#include <iostream>
#include <vector>

#define MAX 3

using namespace std;

int main(void){
  int num;
  
  cin >> num;
  
  for(int i = 0;i < MAX;i++){
   if(num % 10 == 7){
   	cout << "Yes";
    return 0;
   } 
   num = num / 10;
  }
  
  cout << "No";
  
  return 0;
}

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

namespace AtCoder.Heuristics
{
    class Introduction
    {
        private static int GeneN = 50;

        private static int DayN;

        private static int ContestN = 26;

        private static int[] c;

        private static int[][] s;

        private static int sumC;

        class Gene
        {
            public int[] Program;
            public int[] Score;
            public Gene()
            {
                Program = new int[DayN + 1];
                Score = new int[DayN + 1];
            }

            public Gene(int[] program)
            {
                Program = program;
                Score = new int[program.Length];
            }
        }

        private static void Evaluate(List<Gene> generation)
        {
            var last = new int[ContestN + 1];
            var dec = 0;
            foreach (var gene in generation)
            {
                gene.Score[0] = 0;
                for (int i = 1; i <= DayN; i++)
                {
                    dec += sumC - (c[gene.Program[i]] * (i - last[gene.Program[i]]));
                    last[gene.Program[i]] = i;
                    gene.Score[i] = gene.Score[i - 1] - dec + s[i][gene.Program[i]];
                }
            }
        }

        public static void Main()
        {
            DayN = int.Parse(Console.ReadLine());
            c = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            sumC = c.Sum();


            s = new int[DayN + 1][];
            for (int i = 1; i <= DayN; i++)
                s[i] = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var generation = CreateFirstGeneration();
            Gene best = generation.First();

            Evaluate(generation);
            generation.Sort((a, b) => b.Score.Last() - a.Score.Last());
            if (best.Score.Last() < generation[0].Score.Last())
                best = generation[0];

            // update

            for (int i = 1; i <= DayN; i++)
                Console.WriteLine(best.Program[i] + 1);
        }

        private static List<Gene> CreateFirstGeneration()
        {
            var gene = new List<Gene>();
            var item = Enumerable.Range(0, DayN + 1).Select(x => x % ContestN).ToArray();
            gene.Add(new Gene(item));

            var random = new Random();
            var index = Enumerable.Range(0, ContestN).ToArray();
            for (int i = 0; i < GeneN; i++)
            {
                Shuffle(index, random);
                gene.Add(new Gene(item.Select(x => index[x]).ToArray()));
            }
            return gene;
        }

        private static void Shuffle(int[] srcdst, Random rand)
        {
            int n = srcdst.Length;
            while (n > 1)
            {
                int k = rand.Next(n--);
                int temp = srcdst[k];
                srcdst[k] = srcdst[n];
                srcdst[n] = temp;
            }
        }
    }
}

Measured memory_bytes: 29068
import math
import bisect


def primelist(N):
    prime = [2]
    for i in range(3, N+1):
        flag = 1
        for j in prime:
            if i % j == 0:
                flag = 0
                break
        if flag == 1:
            prime.append(i)
    return prime


X = int(input())
primes = primelist(110000)

print(primes[bisect.bisect_left(primes, X)])


Measured memory_bytes: 39044
N,P = map(int,input().split())
A = [int(x) for x in input().split()]

odd = sum(x&1 for x in A)

if odd:
  # どちらも半分ずつ
  answer = 2**(N-1)
else:
  answer = (2 ** N) * (1-P)

print(answer)

Measured memory_bytes: 3060
#include <iostream>
using namespace  std;
int main()
{
    int a,b,c;
    cin >> a >> b;
    c = a - b;
    if(c == 0){
        cout << "a == b"<< endl;
    } else if(c > 0){
        cout << "a > b" << endl;
    } else if(c < 0){
        cout << "a < b" << endl;
    }
    return 0;
}



Measured memory_bytes: 3088
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, sum, a, b;
    String s;

    for(;sc.hasNext();){
      s = sc.nextLine();

      a = resrf(s.charAt(0)); b = a; sum = 0;
      for(i = 1;i < s.length();i++){
        b = resrf(s.charAt(i));
        if(a < b)sum -= a;
        else sum += a;
        a = b;
      }
      sum += b;
      out.println(sum);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int resrf(char c){
    if(c == 'I')return 1;
    else if(c == 'V')return 5;
    else if(c == 'X')return 10;
    else if(c == 'L')return 50;
    else if(c == 'C')return 100;
    else if(c == 'D')return 500;
    else return 1000;
  }
}

Measured memory_bytes: 17192
#include <iostream>
using namespace std;
#define rep(i,s,n)for(int i = s;i<n;i++)

int main() {
	int N; cin >> N;
	char s[101];
	rep(i, 0, N) {
		cin >> s[i];
		if (s[i] == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;

	return 0;
}

Measured memory_bytes: 256
def AGCT(x):
    if x=='A':
        return True
    elif x=='G':
         return True
    elif x =='C':
        return True 
    elif x=='T':
        return True
    else:
        return False

S = list(input())
Ans = [0]
flag = 0
i_new =0
ans = 0
for i in range(len(S)):
    ans = 0
    flag = 0
    if AGCT(S[i])==True:
        ans += 1
        i_new = i
        while flag ==0:
            i_new += 1
            if i_new >len(S)-1:
                Ans.append(ans)
                flag = 1
            elif AGCT(S[i_new])!=True:
                Ans.append(ans)
                flag = 1
            else:ans += 1

print(max(Ans))
            
            

Measured memory_bytes: 3064
w,h,x,y = map(int, input().split())
if x==(w/2) and y==(h/2):
    print((w*h)/2,1)
elif x==(w/2) or y==(h/2) or y==(h/w)*x or y==(-1*(h/w)*x+h):
    print((w*h)/2,0)
else:
    print((w*h)/2,0)

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

int main() {
  
  int N;
  cin >> N;
  
  string res="No";
  for(int i=0; i<=25; i++){
    for(int j=0; j<=14; j++){
      if(i*4+j*7==N){ res="Yes"; break;}
    }
  }
  
  cout << res << endl;

}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int X,Y,K,S,result=0;
    scanf("%d %d",&K,&S);
    for (X=0;X<=K;X++){
        for (Y=0;Y<=K;Y++){
            if (0<=S-Y-X&&S-Y-X<=K){
                result+=1;
            }
        }
    }
    printf("%d",result);
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>
 
using namespace std;
using experimental::any;
 
#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);
 
#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)
#define BitFOR(N) REP(Bit,1<<(N))
 
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) (f)? cout<<"true ":cout<<"false ";
#define FORDEB(n,X) for(int i=0;i<(n);i++)ARDEB(i,X)
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define ARDEB(i,X) {}
#define TFDEB(f) {}
#define FORDEB(n,X) {}
#define END {}
#endif
 
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
//struct edge{int from,cost,to;};
struct P2{int x,y;};
#define BIT(Bit,n) bitset<n>(Bit)
#define Endl endl
 
const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000;
 
int main(){
	string s,t;
	cin>>s>>t;
	int n=stoi(s+t);
	DEB(n)END
	for(int i=1;i<=n;i++){
		if(i*i==n){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

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

int main()
{
    long long a, b, c, d, ans;
    cin >> a >> b >> c >> d;
    ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * d);
    ans = max(ans, b * c);

    cout << ans << endl;
}

Measured memory_bytes: 3644
N,K,Q = map(int,input().split())
A = [int(input()) for _ in range(Q)]
X = [0] * N
Y = K - Q 
for i in range(Q):
  X[A[i]-1] += 1
for j in range(N):
  if Y + X[j] > 0:
    print("Yes")
  else:
    print("No")


Measured memory_bytes: 8632
n=gets.chomp.to_i
a=gets.chomp.split(" ").map{|s| s.to_i}
b=gets.chomp.split(" ").map{|s| s.to_i}
c=Array.new
ans=0
for i in 0..n-1
  if a[i]>=b[i]
    ans+=b[i]
  else
    if a[i+1]-(b[i]-a[i])>0
      a[i+1]-=b[i]-a[i]
      ans+=b[i]
    else
      ans+=a[i]+a[i+1]
      a[i+1]=0
    end
  end
end
puts ans

Measured memory_bytes: 17556
#include<bits/stdc++.h>
//macros
using namespace std;
typedef long long ll;
typedef pair<int, int > Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize 
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define repll(i, a, b) for(ll i=(a); i<(b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(),(a).end()
const long long int mod = 1e9 + 7;

Vi b;
Vi res(0);
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false); 
    int N;
    cin >> N;
    b.rs(N);
    rep(i,0,N) cin >> b[i];
    N--;
    int l=N;
    bool flag=true;
    while(b.size()>0){
        if(l==-1){
            flag = false;
            break;
        }
        if(b[l] == l+1){
            res.insert(res.begin(), l+1);
            //cout << b[l]<< "will be erased"<<endl;
            b.erase(b.begin()+l);
            N--;
            l=N;
        }else{
            l--;
        }
    }
    if(flag){
        rep(i,0,res.size()) COUT(res[i]);
    }else{
        COUT(-1);
    }

}

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

int main() {
    int A, B, C, X, cnt;
    cin >> A >> B >> C >> X;
    cnt = 0;

    for (int i_A = A; i_A >= 0; i_A--) {
        int sum_a = 500 * i_A;
        if (sum_a > X)
            continue;
        for (int i_B = B; i_B >= 0; i_B--)
        {
            int sum_b = sum_a + 100 * i_B;
            if (sum_b > X)
                continue;
            for (int i_C = C; i_C >= 0; i_C--)
            {
                int sum_c = sum_b + 50 * i_C;
                if (sum_c == X)
                    cnt++;
                else
                    continue;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int p[] = new int[N];
    int A;
    
    for(int i=0; i<N; i++) {
      p[i] = K - Q;
    }
    
    for(int j=0; j<Q; j++) {
      A = sc.nextInt();
      p[A-1]++;
    }
    
    for(int k=0; k<N; k++) {
      if(p[k]>0) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
      
    }   
  }
}

Measured memory_bytes: 70220
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		int a,b,k;
		cin >> k >> a >> b;
		bool ok = false;
		for (int i=a ; i<=b ; i++)
		{
			if(i%k==0)
			{
				ok=true;
				break;
			}
		}
		if (ok==true) cout << "OK" << endl;
		else cout << "NG" << endl;
		return 0;  
}  

/*
               
 

*/


Measured memory_bytes: 3608
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

vector< int> conn[N];
int du[N], dv[N];

void dfsU(int a, int d) {
    du[a] = d, d++;
    for (int b : conn[a]) {
        if (du[b] != -1) continue;
        dfsU(b, d);
    }
}

void dfsV(int a, int d) {
    dv[a] = d, d++;
    for (int b : conn[a]) {
        if (dv[b] != -1) continue;
        dfsV(b, d);
    }
}

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

    int n, u, v;
    cin >> n >> u >> v;

    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        conn[a].emplace_back(b);
        conn[b].emplace_back(a);
    }
    memset(du, -1, sizeof du);
    memset(dv, -1, sizeof dv);

    dfsU(u, 0);
    dfsV(v, 0);

    int ans = 0;
    for (int i = 1; i <= n; i++) if (ans < dv[i] && du[i] < dv[i]) ans = max(ans, dv[i]);
    cout << ans - 1 << endl;
}

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

long long fact(int N)
{
  long long ans=1;
  for(int i=1;i<=N;i++)ans=((ans%mod)*i)%mod;
  return ans%mod;
}

long long fast_exp(ll a,int b)
{
  long long x=a;
  long long y=(b%2)? x : 1;
  b>>=1;
  while(b>0)
  {
    x=((x%mod)*(x%mod))%mod;
    if(b%2==1)
    {
      y=(y==1)? x:(((y%mod)*(x%mod))%mod);
    }
    b>>=1;
  }
  return y;
}
struct mint {
  ll x;
  mint(ll x=0):x(x%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
};
int M;
mint nCr(int n,int r)
{
  	r=min(n-r,r);
	mint up=1;
  	mint down=1;
  	for(int i=0;i<r;i++)
    {
      up*=(n-i);
      down*=(i+1);
    }
  	mint ans=fast_exp(down.x,mod-2);
  	ans*=up;
  return ans;
}
  
int main()
{
  int n,m,k;
  cin>>n>>m>>k;
  mint ans1=0;
  
  vector<mint>co(k+1);
  co[k]=fast_exp(m-1,n-1-k);
  for(int i=k-1;i>=0;i--)
  {
	co[i]=co[i+1]*(m-1);
  }
  if(m==1 && k==n-1)
  {
    cout<<1<<endl;
    return 0;
  }
  
  vector<mint>inv(n);
  inv[n-1]=fast_exp(fact(n-1),mod-2);
  for(int i=n-2;i>=1;i--)inv[i]=inv[i+1]*(i+1);
  inv[0]=1;
  mint u1=fact(n-1);
  for(int i=0;i<=k;i++)
  {
    mint t=co[i]*u1*inv[n-1-i]*inv[i];
    ans1+=t;    
  }
  ans1*=m;
  cout<<ans1.x<<endl;
  
  return 0;
}

Measured memory_bytes: 6304
a,b=map(int,input().split())

if a==1:
    if b==1:
        print("Draw")
    elif b>=2:
        print("Alice")
elif a>=2:
    if b==1:
        print("Bob")
    if b>=2:
        if a==b:
            print("Draw")
        if a>b:
            print("Alice")
        if a<b:
            print("Bob")

Measured memory_bytes: 3060
import scala.io.Source.stdin

object Main extends App {
  var b = new StringBuilder

  def integral(i:Int,s:Int,d:Int):Unit = if(i*d >= 600-d) b.append((s + i*i*d*d*d)+"\n") else integral (i+1, s + i*i*d*d*d, d)

  for(i<-stdin.getLines)
    integral(0,0,i.toInt)

  print(b.result)
}

Measured memory_bytes: 43740
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  int n;
  set<string> set1;
  string s;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    set1.insert(s);
  }
  
  bool isOpen = 0;
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> s;
    if(set1.count(s)) {
      cout << (isOpen ? "Closed" : "Opened") << " by " << s << endl;
      isOpen = !isOpen;
    }
    else {
      cout << "Unknown " << s << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1232