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

using namespace std;

int main() {
	int cnt = 1;
	int a, b;
	while (cnt <= 3000) {
		cin >> a >> b;
		if (a == 0 && b == 0) {
			break;
		}
		int first = a;
		int second = b;
		if (a > b) {
			first = b;
			second = a;
		}
		printf("%d %d\n", first, second);
	cnt++;
	}
}


Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int Max = 1, Min = 1000000000;

		for (int n = 0; n < N; n++) {
			int A = scanner.nextInt();
			Max = Math.max(Max, A);
			Min = Math.min(Min, A);
		}
		scanner.close();
		int A = Max - Min;
		System.out.println(A);

	}
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
/* #pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/
typedef long long ll;
const ll MAXN = 2e5 + 2;
const ll MAXK = 10 + 2;
const ll MOD = 1e9 + 9;
const ll MODH = 1e9 + 9;
const long double PI = acos(-1);
const ll p = 41;
const long double EPS = 1e-4;
#define x first
#define y second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll rand(ll a, ll b) {ll c = rng(); return a+((ll)abs(c))%(b-a+1);}
ll binpow(ll a, ll b, ll m) {a %= m;ll res = 1;while (b > 0) {if (b & 1){res = res * a % m;}a = a * a % m;b >>= 1;
}return res;}


long double pre[MAXN];
long double a[MAXN];
int main(){

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

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

pre[1] = log10(a[1]);
for(int i = 2 ; i <= n ; i++)
     pre[i] = log10(a[i]) + pre[i - 1];


for(int i = k + 1;  i <= n ; i++)
      {
         
         long double me = pre[i] - pre[i - k];
         long double him = pre[i - 1] - pre[i - k - 1];
         if(me > him)
             cout << "Yes\n";
        else
             cout << "No\n";
      }




} 

Measured memory_bytes: 10060
#include "iostream"
#include "fstream"
#include "algorithm"
#include "iomanip"
#include "stack"
#include "queue"
#include "string"
#include "vector"
#include "map"
#include "set"
#include "list"
#include "deque"
#include "complex"
#include "bitset"
#include "cmath"
#include "unordered_set"
#include "unordered_map"
#include "iterator"
#include <ctime>
#include <cassert>
#include "numeric"
#include <cstdio>

using namespace std;

//#define f(i,n) for(int i=0; i<n;i++) 
//#define rf(i, n) for(int i=n-1;i>=0;i--)
//#define forn(i, j, n) for(int i=j; i<n; i++)
//#define ff(i, j, n) f(i, n)f(j, n)
#define pb push_back
#define maxi(a,b) a = max(a, b);
#define mini(a,b) a = min(a, b);
#define endl '\n'
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define sqr(x) ((x) * (x))
#define SZ(a) ((int)(a.size()))
#define watch(x) cout << (#x) << " = " << x << endl;
//typedef long long ll;
typedef long double ld;
#define int long long
#define double ld
typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<pii> vpii;
typedef vector<char> vc;

template<class T>
void show(const vector<T> &a)
{
	for (T x : a)
		cout << x << " ";
	cout << endl;
}

const int sze = 3e5 + 50, oo = 1e18 + 500, mod = 1e9 + 7;
const double eps = 1e-9, PI = 2 * acos(0.0);
const int N = 1e6 + 10;
vi vertices[sze];
vi visit(sze, 0);
vc used(sze, false);
vi arr(sze, 0);
int n, m, k;
int cnt = 0;

int gcd(int a, int b)
{
	while (b)
	{
		a %= b;
		swap(a, b);
	}

	return a;
}


signed main()
{
	ios::sync_with_stdio(0);
	cout.tie(0); cin.tie(0);
	/*freopen("stars.in", "r", stdin);
	freopen("stars.out", "w", stdout);*/

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	cnt = c / gcd(c, d)*d;

	a--;
	cout << b - a - (b / c - a / c + b / d - a / d) + b / cnt - a / cnt;
	return 0;
}

Measured memory_bytes: 12920
def getlist():
	return list(map(int, input().split()))

con = 10 ** 9 + 7

#処理内容
def main():
	L = list(input())
	L = L[::-1]
	N = len(L)
	#前処理
	DP1 = [0] * (N + 1)
	DP2 = [0] * (N + 1)
	DP2[0] = 3
	for i in range(1, N + 1):
		DP2[i] = (3 * DP2[i - 1]) % con
	if L[0] == "1":
		DP1[0] = 3
	else:
		DP1[0] = 1

	#DP
	for i in range(1, N):
		if L[i] == "1":
			DP1[i] = (DP1[i - 1] * 2 + DP2[i - 1]) % con
		else:
			DP1[i] = DP1[i - 1]
	print(DP1[N - 1])


if __name__ == '__main__':
	main()

Measured memory_bytes: 11628
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <tuple>
#include <vector>
using ll = long long;
using namespace std;
#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__)
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

class DICE {
  public:
    int T, S, E, W, N, B;
    DICE(vector<int> tmp) {
        if(tmp.size() != 6)
            exit(1);
        T = tmp[0];
        S = tmp[1];
        E = tmp[2];
        W = tmp[3];
        N = tmp[4];
        B = tmp[5];
    }
    DICE(int T0, int S0, int E0, int W0, int N0, int B0) {
        tie(T, S, E, W, N, B) = make_tuple(T0, S0, E0, W0, N0, B0);
    }

    void turn(char dir) {
        if(dir == 'S')
            tie(T, B, S, N) = make_tuple(N, S, T, B);
        else if(dir == 'N')
            tie(T, B, N, S) = make_tuple(S, N, T, B);
        else if(dir == 'E')
            tie(T, B, E, W) = make_tuple(W, E, T, B);
        else if(dir == 'W')
            tie(T, B, W, E) = make_tuple(E, W, T, B);
        else
            cout << "err" << endl;
    }
};

int main() {
    vector<int> di(6);
    rep(i, 6) cin >> di[i];
    DICE d = di;
    string S;
    cin >> S;
    rep(i, S.length()) d.turn(S[i]);
    cout << d.T << endl;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}

signed main() {
    int N, x;
    cin >> N >> x;

    int res=0, prev=0;
    rep(i, N) {
        int a;
        cin >> a;

        int temp = max(prev+a-x, 0);
        res += temp;
        prev = a-temp;
    }

    cout << res << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>

using namespace std;

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

int dx[] = { 1, -1, 0, 0 };
int dy[] = { 0, 0, 1, -1 };

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> triple;

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

bool prime(int n) {
  for (int i = 2; i <= sqrt(n); ++i) {
    if (n % i == 0) { return false; }
  }
  return n != 1;
}

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

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

ll powmod(ll x, ll y) {
  ll r = 1;
  while (y) {
    if (y & 1) {
      r = r * x % MOD;
    }
    x = x * x % MOD;
    y >>= 1;
  }
  return r;
}

const int COM_MAX = 500010;
ll fac[COM_MAX], facinv[COM_MAX], inv[COM_MAX];
void COMinit() {
  fac[0] = fac[1] = 1;
  facinv[0] = facinv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < COM_MAX; ++i) {
    fac[i] = fac[i-1] * i % MOD;
    inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
    facinv[i] = facinv[i-1] * inv[i] % MOD;
  }
}

ll COM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD) * facinv[n-k] % MOD;
}

ll PERM(ll n, ll k) {
  return (fac[n] * facinv[k] % MOD);
}

int main(int argc, char** argv) {
  int N;
  cin >> N;
  vector<ull> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  ull allxor = 0;
  rep(i, N) {
    allxor ^= A[i];
  }
  // NOTE: leave only significant bits.
  rep(i, N) {
    A[i] &= ~allxor;
  }

  ull rank = 0;
  for (int i = 59; i >= 0; --i) {
    int j;
    for (j = rank; j < N; ++j) {
      if (A[j] & (1LL << i)) { break; }
    }
    if (j == N) { // No match
      continue;
    }
    if (j > rank) {
      A[rank] ^= A[j];  // Set 1 to i-bit of A[rank]
    }

    for (int k = rank + 1; k < N; ++k) {
      A[k] = min(A[k], A[k] ^ A[rank]);  // Set 0 to i-bit of A[k].
    }

    ++rank;
  }

  ull x = 0;
  rep(i, N) {
    x = max(x, x ^ A[i]);
  }

  cout << (x * 2) + allxor << endl;
}


Measured memory_bytes: 1024
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def gcd(a,b):
    while b:a,b=b,a%b
    return a

def main():
    a,b,c=MI()
    g=gcd(a,b)
    if c%g:print("NO")
    else:print("YES")

main()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define fcout cout << fixed << setprecision(10)
#define rep(i,n)    for(int i=0; i<(int)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define all(x) x.begin(), x.end()
#define F first
#define S second
const ll inf = 1e18;
const ll mod = 1e9 + 7;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

// mod. m での a の逆元 a^(-1) を計算する。
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll modpow(ll a, ll n){
    ll res = 1;
    while(n>0){
        if(n&1){
            res = res * a % mod;
        }
        a = a * a % mod;
        n >>=1;
    }
    return res;
}



int main(){
    char s;
    cin >> s;
    if(65 <=  s && s <= 90){
        cout << 'A' << endl;
    }else{
        cout << 'a' << endl;
    }
}



Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair<int, int> pii;  // pair<int, int> に pii という別名を付ける
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	int a = N*(N-1)/2;
	int b = M*(M-1)/2;
	cout << ceil(a) + ceil(b) << endl;
}

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

long long INF = 1e18;

struct SegmentTree {
private:
    int n;
    vector<long long> node;

public:
    // 元配列 v をセグメント木で表現する
    SegmentTree(vector<long long> v) {
        // 最下段のノード数は元配列のサイズ以上になる最小の 2 冪 -> これを n とおく
        // セグメント木全体で必要なノード数は 2n-1 個である
        int sz = v.size();
        n = 1; while(n < sz) n *= 2;
        node.resize(2*n-1, INF);

        // 最下段に値を入れたあとに、下の段から順番に値を入れる
        // 値を入れるには、自分の子の 2 値を参照すれば良い
        for(int i=0; i<sz; i++) node[i+n-1] = v[i];
        //ここでminを使うことで区間の最小値となる、最大にすれば最大値
        for(int i=n-2; i>=0; i--) node[i] = min(node[2*i+1], node[2*i+2]);
    }

//x番目(0-indexed)の要素をvalにする
void update(int x, long long val) {
    // 最下段のノードにアクセスする
    x += (n - 1);

    // 最下段のノードを更新したら、あとは親に上って更新していく
    node[x] = min(node[x], val);
    while(x > 0) {
        x = (x - 1) / 2;
        //ここでminを使うことで区間の最小値となる、最大にすれば最大値
        node[x] = min(node[2*x+1], node[2*x+2]);
    }
}

// 要求区間 [a, b) 中の要素の最小値を答える(つまりbは含まれない)
// k := 自分がいるノードのインデックス
// 対象区間は [l, r) にあたる

long long getmin(int a, int b, int k = 0, int l = 0, int r = - 1) {
    // 最初に呼び出されたときの対象区間は [0, n)
    if(r < 0) r = n;

    // 要求区間と対象区間が交わらない -> 適当に返す(今回は最小値なので、結果に影響しないような大きい値を返しておく)
    if(r <= a || b <= l) return INF;

    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    if(a <= l && r <= b) return node[k];

    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    long long vl = getmin(a, b, 2*k+1, l, (l+r)/2);
    long long vr = getmin(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
}

};

int main(){
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> edge(m);
    int a, b, c;
    for (int i = 0; i < m; i++) {
        cin >> a >> b >> c; a--; b--;
        edge[i] = tie(a, b, c);
    }
    sort(edge.begin(), edge.end());
    vector<long long> d(n, INF);
    d[0] = 0;
    SegmentTree seg(d);
    for (int i = 0; i < m; i++){
        tie(a, b, c) = edge[i];
        long long x = seg.getmin(a, n);
        if (x == INF) continue;
        seg.update(b, x + c);
    }
    long long ans = seg.getmin(n - 1, n);
    if (ans == INF) cout << - 1 << endl;
    else cout << ans << endl;
}

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

using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
 
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
#define MAX_N 1000100
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
 
ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

int main(){
    ll a,b,hcf,temp,lcm;
    cin>>a>>b;
    
    hcf = a;
    temp = b;
    
    while(hcf != temp){
        if (hcf > temp)
            hcf -= temp;
        else
            temp -= hcf;
    }
    
    lcm = (a*b)/hcf;
    
    cout << lcm << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll dist[333][333];
ll dist2[333][333];
ll n,m,l;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>m>>l;
 for(int i=0;i<n;i++)
   for(int j=0;j<n;j++)
     dist[i][j]=dist2[i][j]=llINF;
  for(int i=0;i<m;i++){
    ll f,t,c;
    cin>>f>>t>>c;
    f--;t--;
    dist[f][t]=c;
    dist[t][f]=c;
  }
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      if(dist[i][j]<=l)
	dist2[i][j]=1;
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	dist2[i][j]=min(dist2[i][j],dist2[i][k]+dist2[k][j]);
  ll q;cin>>q;
  for(int i=0;i<q;i++){
    ll from,to;cin>>from>>to;
    from--;to--;
    if(dist2[from][to] == llINF)cout<<-1<<endl;
    else cout<<dist2[from][to]-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#[macro_use]
mod utils {
    macro_rules! input {
        ($($r:tt)*) => {
            let stdin = std::io::stdin();
            let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
            let mut next = move || -> String{
                bytes
                    .by_ref()
                    .map(|r|r.unwrap() as char)
                    .skip_while(|c|c.is_whitespace())
                    .take_while(|c|!c.is_whitespace())
                    .collect()
            };
            input_inner!{next, $($r)*}
        };
    }
    macro_rules! input_inner {
        ($next:expr) => {};
        ($iter:expr, ) => {};
 
        ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
            let $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
    macro_rules! read_value {
        ($next:expr, ( $($t:tt),* )) => {
            ( $(read_value!($next, $t)),* )
        };
        ($next:expr, [ $t:tt ; $len:expr ]) => {
            (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        };
        ($next:expr, chars) => {
            read_value!($next, String).chars().collect::<Vec<char>>()
        };
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
}
 

fn main() {
    input!{
        k: u64,
        n: usize,
        mut a: [u64; n]
    }
    let mut kyori = Vec::new();
    a.sort();
    for i in 0..n-1{
        kyori.push(a[i+1] - a[i]);
    }
    kyori.push(k - a[n-1] + a[0]);
    kyori.sort();
    let mut sum = 0;
    for i in 0..n-1{
        sum += kyori[i];
    }
    println!("{}",sum);
}

Measured memory_bytes: 10492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int a, b, c; cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
from itertools import accumulate

mod = 10 ** 9 + 7

N, *A = map(int, open(0).read().split())

S = list(accumulate(pow(i, mod - 2, mod) for i in range(1, N + 1)))

ans = 0
for i in range(N):
    ans += A[i] * (S[i] + S[N - 1 - i] - S[0])
    ans %= mod

F = 1
for i in range(1, N + 1):
    F *= i
    F %= mod

print(F * ans % mod)

Measured memory_bytes: 14436
/*
 * ??\?????????????????¨?¨???§????????????????????????????????????????????°?????????????????????????????????
 * ??????¨?????????£?????????????°?????????? x ????????¨???????????¨???
 */
public class Main{
	
	public static void main(String[] args){
		qq(9);
	}
	
	static void qq(int n) {
		for(int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++) {
				int result = i * j;
				System.out.println(i + "x" + j + "=" + result);
			}
		}
	}
}

Measured memory_bytes: 15016
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int data[110];
    for(int i=0; i<n; i++){
        cin >> data[i];
    }
    sort(data, data+n, greater<>());
    int a=0, b=0;
    if(n%2==0){
        for(int i=0; i<n; i+=2){
            a += data[i];
            b += data[i+1];
        }
    }else{
        for(int i=0; i<n-2; i+=2){
            a += data[i];
            b += data[i+1];
        }
        a += data[n-1];
    }
    
    cout << a-b << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

// 入力
string s, t;

// DPテーブル
int dp[3100][3100] = {0}; // 初期値も初期条件も 0

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

    // DPループ
    for (int i = 0; i < s.size(); ++i) {
        for (int j = 0; j < t.size(); ++j) {
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // 復元
    string res = "";
    int i = (int)s.size(), j = (int)t.size();
    while (i > 0 && j > 0)
    {
        // (i-1, j) -> (i, j) と更新されていた場合
        if (dp[i][j] == dp[i-1][j]) {
            --i; // DP の遷移を遡る
        }

        // (i, j-1) -> (i, j) と更新されていた場合
        else if (dp[i][j] == dp[i][j-1]) {
            --j; // DP の遷移を遡る
        }

        // (i-1, j-1) -> (i, j) と更新されていた場合
        else {
            res = s[i-1] + res; // このとき s[i-1] == t[j-1] なので、t[j-1] + res でも OK
            --i, --j; // DP の遷移を遡る
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 37120
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(int)(n); ++i)
 
template<class T> inline bool chmin(T &a, T b) { if(a>b){ a=b; return true; }  return false;}
template<class T> inline bool chmax(T &a, T b) { if(a<b){ a=b; return true; }  return false;}

vector<pair<double, double>> v;
vector<int> perm;

double dist(pair<double, double> p1, pair<double, double> p2){
  return sqrt(pow(p2.first-p1.first, 2.0) + pow(p2.second-p1.second, 2.0));
}

double calc(){
  double ans=0.0;
  rep(i, perm.size()-1){
    pair<double, double> x = v[perm[i]];
    pair<double, double> y = v[perm[i+1]];
    ans+=dist(x, y);
  }
  return ans;
}

double f(double r){
  if(r==1.0) return r;
  return r*f(r-1.0);
}

int main() {
  double n; cin >> n;
  rep(i, n) {
    double x,y;cin>>x>>y;
    v.push_back(make_pair(x,y));
  }
  rep(i, n) perm.push_back(i);
  double ans=0.0;
  do{
    ans += calc();
  }while(next_permutation(perm.begin(), perm.end()));
  double div = f(n);
  cout << setprecision(11) << ans/div << endl;
}


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

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll t;
ll ret = 0;

void input() {
  IN(N);
}

void solve() {
  FOR(i, 1, 50001) {
    double X = (double)i;
    int val = (int)X*1.08f;
    if (val == N) {
      PRINT(i);
      return;
    }
  }
  PRINT(":(");
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 256
(n,m,x)=gets.split.map(&:to_i)
ca=(0...n).map{gets.split.map(&:to_i)}

memo = []
(1..n).each{|t|
    ca.combination(t).each {|v|
        sum = v.reduce{|lhs,rhs| 
            lhs.zip(rhs).map{|a,b|a+b}
        }
        if sum[1...sum.size].all?{|e| e >= x }
            memo << sum[0]
        end
    }
}


if memo == []
    print -1
else
    print memo.min
end

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

typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main() {
  int n,m;
  cin >> n;
  map<int,int> st;
  rep(i,n){
    cin >> m;
    st[m]=i+1;
  }
  rep(i,n){
    cout << st[i+1] << ' ';
  }
  
  
  return 0;
  
}

Measured memory_bytes: 5504
import Data.List
import Data.Ord

solve :: Int -> [Int] -> Int
solve _ [] = 0
solve k (n:ns)
    | k > 0 = solve (k-1) ns
    | otherwise = sum (n:ns)

main = do
    [n,k] <- map read . words <$> getLine :: IO [Int]
    ns <- sortBy (comparing Down) . map read . words <$> getLine :: IO [Int]
    print $ solve k ns

Measured memory_bytes: 100732
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
const int INF=1e9+7;
int mp[202][202];
int a[10];
int p[10];
int main()
{
    int n,m,r;
    scanf("%d%d%d",&n,&m,&r);
    for(int i=1;i<=r;i++)
        scanf("%d",&a[i]);
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
        {
            if(i==j) mp[i][j]=0;
            else mp[i][j]=INF;
        }
    int u,v,w;
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d%d",&u,&v,&w);
        if(w<mp[u][v])
            mp[u][v]=mp[v][u]=w;
    }
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                if(mp[i][k]+mp[k][j]<mp[i][j])
                    mp[i][j]=mp[i][k]+mp[k][j];
    for(int i=1;i<=r;i++)
        p[i]=i;
    int ans=INF;
    do
    {
        int sum=0;
        for(int i=2;i<=r;i++)
            sum+=mp[a[p[i]]][a[p[i-1]]];
        ans=min(ans,sum);
    }while(next_permutation(p+1,p+1+r));
    printf("%d\n",ans);
    return 0;
}



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

using namespace std;

long long w,h,x,y,t;

int main(){
	scanf("%lld%lld%lld%lld",&w,&h,&x,&y);
	if( (h%2==0 && y==h/2) && (w%2==0 && x==w/2) ) t = 1;
	else t = 0;
	double ans = (double)(w*h)/2;
	printf("%.10lf %lld\n",ans,t);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
#include<cmath>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<int,P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
#define mp1(a,b,c) P1(a,P(b,c))

const int INF=1000000000;
const int dir_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dir_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

vector<P> prime_factory(int n){
	vector<P> ret;
	
	for(int i=2;i*i<=n;i++){
		if(n%i==0){
			P p=P(i,0);
			while(n%i==0){
				p.sc++;
				n/=i;
			}
			ret.pb(p);
		}
	}
	if(n!=1)ret.pb(P(n,1));
	
	return ret;
}

int main(){
	int n;
	cin >> n;
	rep1(i,(1<<13)){
		vector<P> vec = prime_factory(i);
		int ret = 1;
		rep(j,vec.size())ret *= vec[j].sc+1;
		if(ret == n){
			cout << i << endl;
			return 0;
		}
	}
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	int ans = 0;
	int r = 0;
	int cnt = 0;
	if (S[r]=='0'){
		cnt++;
	}
	for (int l = 0; l < N; ++l){
		//cntがKより大きくなるまで右端を動かす
		while( (cnt <= K) && (r < N-1) ) {
			if ( (S[r]=='1') && (S[r+1]=='0') ){
				cnt++;
			}
			if (cnt > K) break;
			r++;
			if (r==N-1) break;
		}
		int tmp = r - l + 1;
		ans = max(ans, tmp);

		// printf("tmp=%i, ans=%i at (l,r)=(%i,%i)\n", tmp, ans, l, r);

		if (l < N-1){
			if ( (S[l]=='0') && (S[l+1]=='1') ){
				// printf("cnt %i -> ", cnt);
				cnt--;
				if (r < N-1){
					r++;
				}
				// printf("%i\n", cnt);
			}
		}
	}

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>
#include <queue>
#include <bits/stdc++.h>
#include <stack>
#include <vector>
#include <list>
#define NUMBER 100000

using namespace std;

int main()
{
  int N;
  cin >> N;
  int a[NUMBER];
  for(int i = 1; i <= N; i++)
    cin >> a[i];

  int ans = 0;
  for(int i = 1; i <= N; i++){
    int tmp = a[i];
    if(i == a[tmp]){
      ans++;
      a[tmp]=0;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 768
import Data.List

splitRec _ [] = []
splitRec n xs = let (h, t) = splitAt n xs in h : splitRec n t

counting = (++[(0, 0)]) . sortBy (flip compare) . map (\es -> (length es, head es)) . group . sort 

calc n os es
  | ov /= ev || length (takeWhile ((==oc) . fst) os) > 1 || length (takeWhile ((==ec) . fst) es) > 1 = n - oc - ec
  | otherwise = min (n - oc - secondc es) (n - ec - secondc os)
  where
    (oc, ov) = head os
    (ec, ev) = head es
    secondc = fst . head . tail

main = do
    n <- readLn :: IO Int
    [os, es] <- map counting . transpose . splitRec 2 . map (read :: String -> Int) . words <$> getLine
    print $ calc n os es

Measured memory_bytes: 52604
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
already = []
ans = 0
while len(a) != 1:
    comp = a.pop(0)
    if  comp <= x:
        ans += 1
        x -= comp
    else:
        print(ans)
        exit()

if a[0] == x:
    print(ans+1)
else:
    print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main()
{
  	int n, a;
  cin >> n;
  for(int i = 1; i <= n; i++)
  {
    	cin >> a;
    if(a % 2 == 0) 
    {
      if(a % 3 == 0 || a % 5 == 0);
      else cout << "DENIED", exit(0);
   	}
  }
  cout << "APPROVED";
}

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;

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

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

    int N, W;
    cin >> N >> W;

    vector<int> w(N);
    vector<int> v(N);
    REP(i, N) cin >> w[i] >> v[i];

    vector<vector<ll> > dp(N + 1, vector<ll>(W + 1, 0));

    REP(i, N) REP(j, W + 1) {
        if (j - w[i] >= 0)
            chmax(dp[i + 1][j], dp[i][j - w[i]] + v[i]);
        chmax(dp[i + 1][j], dp[i][j]);
    }

    cout << dp[N][W] << '\n';
    return 0;
}

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

int main()
{
    int w,h,x,y,r;
    string ans = "Yes";
  
    cin >> w >> h >> x >> y >> r;
  
	if(r > x || w - r < x || r > y || h - r < y)
      ans = "No";
    
    cout << ans << endl;
}


Measured memory_bytes: 3208
x = io.read("*n")

not_prime = {true}

for i = 2, 10 ^ 6 do
  if not_prime[i] == nil then
    if i >= x then
      print(i)
      break
    end
    cur = i * 2
    while cur < 10 ^ 6 do
      not_prime[cur] = true
      cur = cur + i
    end
  end
end


Measured memory_bytes: 10868
s = input()
a = []


def suuretu(sa, hairetu):
    hairetu.append(float(sa))

    for i in range(len(hairetu)):
        for j in range(len(hairetu)):
            if hairetu[i] == hairetu[j] and i != j:
                print(max(i, j)+1)
                return 

    if sa % 2 == 0:
        suuretu(float(sa)/2, hairetu)
    else:
        suuretu(3*float(sa)+1, hairetu)


suuretu(float(s), a)


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

using namespace std;

int main(void)
{
  int h,w; cin>>h>>w;
  vector< vector<char> > a(h+2,vector<char>(w+2,'#'));
  char moji;

  for(int i=0;i<h+2;i++){
    for(int j=0;j<w+2;j++){
      if(((i==0)||(i==h+1))||((j==0)||(j==w+1))){
        cout<<a[i][j];
      }else{
        cin>>moji;
        cout<<moji;
      }
    }
    cout<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    ll A,B,N;
    cin >> A >> B >> N;
    
    ll x = min(B-1,N);
    //cout << x << endl;
    cout << (A*(ll)x)/B - A * (((ll)x)/B) << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define rloop(i,a,b) for(ll i=a;i>b;i--)
const int inf=1e9+7;



int main()
{

ll n,m;
cin>>n>>m;
string s;
ll dp[n][m];
loop(i,0,n)
{	
	cin>>s;
	loop(j,0,m){
		
		
		dp[i][j]=-1;
			if(s[j]=='#')
	{
		dp[i][j]=0;
	}
	}


	
}

dp[0][0]=1;
loop(i,0,n)
{
loop(j,0,m)
{	
	if(dp[i][j]==0||(i==0&&j==0))continue;

dp[i][j]=0;
if(i-1<0)
{
	dp[i][j]=dp[i][j-1];
	continue;
}
if(j-1<0)
{
	dp[i][j]=dp[i-1][j];
	continue;
}


dp[i][j]=(dp[i-1][j]%inf+dp[i][j-1]%inf)%inf;


	
}


}



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

Measured memory_bytes: 8064
#include <iostream>
#include <vector>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> arg(n);
  int alice = 0;
  int bob = 0;
  for(int i=0; i<n; i++){
    cin >> arg.at(i);
  }
  for(int i=0; i<n; i++){
    int max = 0;
    int maxIndex;
    for(int j=0; j<arg.size(); j++){
      if(max < arg.at(j)){
        max = arg.at(j);
        maxIndex = j;
      }
    }
    if(i % 2 == 0){ //アリスのターン
      alice += max;
    }else{ //ボブのターン
      bob += max;
    }
    arg.erase(arg.begin() + maxIndex);
  }
  cout << alice-bob;
  return 0;
}

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

# N = int(input())
# S = input()
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
import numpy as np

def main():
    a = np.array(A)
    print(min(sum(a < X), sum(a > X)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 21112
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    ll x[N], y[N], z[N];
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i] >> z[i];
    }
    
    ll s[8][N];
    for (int i = 0; i < N; i++) {
        s[0][i] = x[i] + y[i] + z[i];
        s[1][i] = -x[i] + y[i] + z[i];
        s[2][i] = x[i] - y[i] + z[i];
        s[3][i] = -x[i] - y[i] + z[i];
        s[4][i] = x[i] + y[i] - z[i];
        s[5][i] = -x[i] + y[i] - z[i];
        s[6][i] = x[i] - y[i] - z[i];
        s[7][i] = -x[i] - y[i] - z[i];
    }
    sort(s[0], s[0]+N, greater<ll>());
    sort(s[1], s[1]+N, greater<ll>());
    sort(s[2], s[2]+N, greater<ll>());
    sort(s[3], s[3]+N, greater<ll>());
    sort(s[4], s[4]+N, greater<ll>());
    sort(s[5], s[5]+N, greater<ll>());
    sort(s[6], s[6]+N, greater<ll>());
    sort(s[7], s[7]+N, greater<ll>());
    
    ll sum[8];
    for (int i = 0; i < M; i++) {
        for (int j = 0; j < 8; j++) {
            if ( i == 0) sum[j] = 0;
            sum[j] += s[j][i];
        }
    }
    
    ll res = 0;
    for (int i = 0; i < 8; i++) {
        res = max(res, sum[i]);
    }
    if (M == 0) res = 0;
    cout << res << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>

using namespace std;

int inf = 1000000000;
int main(){
    int N;
    cin >> N;
    vector<int> H(N),ans(N);
    for(int i=0;i<N;i++){
        cin >>H[i];
    }
    ans[N-1]=0;
    for(int i=N-2;i>=0;i--){
        if(H[i]>=H[i+1])ans[i]=ans[i+1]+1;
        else ans[i] = 0;
    }
    sort(ans.begin(),ans.end());
    cout << ans[N-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>

using namespace std;

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

Measured memory_bytes: 1188
#include<bits/stdc++.h>
#define ll long long
#define ajaychutiya ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll k;
ll frog(ll arr[],ll i,ll n,ll dp[])
{
    if(i>=n-1)
    {
        dp[i]=0;
        return dp[i];
    }
    
    if(dp[i]!=-1)
    return dp[i];
    
    ll y=INT_MAX;
    for(ll j=1;j<=k;j++)
    {
        ll x=INT_MAX;
        if(i+j<=n-1)
         x=abs(arr[i+j]-arr[i])+frog(arr,i+j,n,dp);
        y=min(y,x);
    }
    
    dp[i]=y;
    return dp[i];
}

int main()
{
    ajaychutiya
    
     ll n;
     cin>>n;
     cin>>k;
     ll arr[n];
     ll dp[n];
     
     memset(dp,-1,sizeof(dp));

     for(ll i=0;i<n;i++)
     cin>>arr[i];
     
     ll ans=frog(arr,0,n,dp);
     cout<<ans;
}

Measured memory_bytes: 11264
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 #define int long long
#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define fi first
#define se second

 
 
using namespace __gnu_pbds;
using namespace std;
 const int mod=1e9+7;
 // const int mod=998244353;
const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i; 
int multiply(int a, int b, int in_mod){return (a*b)%in_mod;} 
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);
        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

// const int MAXN=5e5+10;
// vector<int> fac(MAXN);
// vector<int> infac(MAXN);
// void build_factorial()
// {
//     fac[0]=1;
//     infac[0]=1;
//     for(int i=1;i<MAXN;i++)
//     {
//         fac[i]=(fac[i-1]*i)%mod;
//         infac[i]=mod_inv(fac[i], mod);
//     }
// }



// void solve()
// {
//     int h, w, n;
//     cin>>h>>w>>n;
//     vector<pair<int, int> > bad;
//     for(int i=0;i<n;i++)
//     {
//         int r, c;
//         cin>>r>>c;
//         bad.pb({r,c});
//     } 
//     sort(all(bad));
//     bad.pb({h, w});



//     int ways[n+1];
//     for(int i=0;i<=n;i++)
//     {

//         ways[i] = (fac[bad[i].fi+bad[i].se-2]*infac[bad[i].fi-1])%mod * infac[bad[i].se-1]%mod;
//         for(int j=0;j<=i;j++)
//         {
//             if(bad[j].fi<=bad[i].fi && bad[j].se<=bad[i].se)
//             {
//                 ways -= 
//             }
//         }
//     }
// }


void solve()
{
    int k;
    cin>>k;
    int a, b;
    cin>>a>>b;
   if((a-1)/k  !=(b)/k)
   {
    cout<<"OK"<<endl;
   } 
   else
    cout<<"NG"<<endl;
}

 
 
signed main()
 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);  
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        if(fopen("INPUT.txt","r"))
        {
            freopen ("INPUT.txt" , "r" , stdin);
            freopen ("OUTPUT.txt" , "w" , stdout);
        }
    #endif
    auto clk=clock(); 
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------     
 
    int t=1;
    // cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        solve();
        // cout<<endl;
 
    }
 
    // -------------------------------------Code ends here------------------------------------------------------------------
 
 
    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
 }


Measured memory_bytes: 3768
#include <bits/stdc++.h>
#define x first
#define y second
#define gcd(x, y) __gcd((x), (y))
using namespace std;

using i64 = long long;
using pii = pair<int, int>;

int n, k, ant;

map<int, int> mp;
vector<int> v;

int main() {
#ifdef HOME
	freopen("atc.in", "r", stdin);
	freopen("atc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);

	cin >> n >> k;
	for (int t, i = 0; i < n; ++i) {
		cin >> t;
		mp[t]+= 1; }

	for (auto i: mp)
		v.push_back(i.second);

	sort(begin(v), end(v));
	for (int i = 0; i < int(v.size()) - k; ++i)
		ant+= v[i];

	cout << ant << endl;


	return 0; }


Measured memory_bytes: 10744
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define repa(X,A,Y) for (int (X) = A;(X) <= (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

ll N;

int main() {

  cin >> N;
  ll n = 0, k = 1;
  while (true) {
    if (n == N) break;
    if (n > N) {
      cout << "No" << endl;
      return 0;
    }
    n += k;
    ++k;
  }

  vector<vector<int> > S(k);
  int count = k;
  for (int j = 1; j <= k-1; ++j)  S[0].push_back(j);
  for (int i = 1; i < k; ++i) {
    for (int j = 0; j < k-1; ++j) {
      if (i > j) {
        S[i].push_back(S[j][i-1]);
      } else {
        S[i].push_back(count++);
      }
    }
  }

  cout << "Yes" << endl;
  cout << k << endl;
  rep(i, k) {
    cout << k-1 << ' ';
    rep(j, k-1) printf("%d%c", S[i][j], j+1 == k-1 ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std;
int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c,d,e=0;
    string s;
    cin>>n>>a>>b>>c>>d>>s;
    b--;
    a--;
    int a1=a,b1=b;
    for(int i=b;i<d;i++){
        if(b<d-1){
            if(s[b+1]=='.' && b+1!=a)
                b++;
            else if(s[b+2]=='.' && b+2!=a)
                b+=2;
        }
        if(s[b-1]=='.' && s[b+1]=='.'){
            e=1;
        }
    }
    for(int i=a;i<c;i++){
        if(a<c-1){
            if(e==0){
                if(s[a+1]=='.' && a+1!=b)
                    a++;
                else if(s[a+2]=='.' && a+2!=b)
                    a+=2;
            } 
            else{
                if(s[a+1]=='.')
                    a++;
                else if(s[a+2]=='.')
                    a+=2;
            } 
        }
    }
    if(a==c-1 && b==d-1){
        cout<<"Yes"<<endl;
        return(0);
    }
    e=0;
    for(int i=a1;i<c;i++){
        if(a1<c-1){
            if(s[a1+1]=='.'&& a1+1!=b1)
                a1++;
            else if(s[a1+2]=='.'&& a1+2!=b1)
                a1+=2;
        }
        if(s[a1-1]=='.' && s[a1+1]=='.'){
            e=1;
        }
    }
    for(int i=b1;i<d;i++){
        if(b1<d-1){
            if(e==0){
                if(s[b1+1]=='.' && b1+1!=a1)
                    b1++;
                else if(s[b1+2]=='.' && b1+2!=a1)
                    b1+=2;
            }
            else{
                if(s[b1+1]=='.')
                    b1++;
                else if(s[b1+2]=='.')
                    b1+=2;
            } 
        }
    }
    if(a1==c-1 && b1==d-1){
        cout<<"Yes"<<endl;
        return(0);
    }
    cout<<"No"<<endl;
    return(0);
}

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

int main() {
    int n; long long k; cin >> n >> k;
    vector<long long> a(n), f(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> f[i];
    sort(a.begin(), a.end());
    sort(f.rbegin(), f.rend());
    long long left = -1; long long right = 1e12;
    while (right - left > 1) {
        long long mid = (right + left) / 2;
        long long remain = k;
        for (int i = 0; i < n; i++) {
            remain -= max(a[i] - mid / f[i], 0LL);
        }
        if (remain >= 0) right = mid;
        else left = mid;
    }
    cout << right << endl;
    return 0;
}

Measured memory_bytes: 3328