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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

using i64=int64_t;

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

    set<int> s;
    rep(i,0,N){
        int A;
        cin >> A;
        if(s.find(A)!=s.end()) s.erase(A);
        else s.insert(A);
    }

    cout << s.size() << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 4992
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

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

int main() {
	int n, m;
	cin >> n;
	VI d(n); rep(i, n)cin >> d[i];
	cin >> m;
	VI t(m); rep(i, m)cin >> t[i];
	SORT(d); SORT(t);
	VI re;
	set_intersection(all(d), all(t), inserter(re, re.end()));
	puts(t == re ? "YES" : "NO");
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
ll a[300000];
int n;
int main()
{
ios_base::sync_with_stdio(false);
cin>>n;
for(int i=0;i<n;++i)
{
    cin>>a[i];
    a[i]-=i+1;
}
sort(a,a+n);
ll ans=0;
ll l=a[n/2];
ll r=a[(n+1)/2];
if(r==n)
--r;
for(int i=0;i<n;++i)
{
    ans+=abs(l-a[i]);
}
ll ans2=0;
for(int i=0;i<n;++i)
{
    ans2+=abs(l-a[i]);
}
cout<<min(ans,ans2);
}

Measured memory_bytes: 1792
import java.util.*

fun main(args: Array<String>) {
   val sc = Scanner(System.`in`)

   var bingo = IntArray(9)
   var bingoOpen = BooleanArray(9)

   for(i in 0 until 9){
       bingo[i] = sc.nextInt()
      bingoOpen[i] = false
   }

   val n = sc.nextInt()
   val nums = IntArray(n)
   for(i in 0 until n) {
      nums[i] = sc.nextInt()
      val index = bingo.indexOf(nums[i])
      if(index >= 0){
         bingoOpen[index] = true
      }
   }

   val ans = bingoOpen[0] && bingoOpen[1] && bingoOpen[2] ||
   bingoOpen[3] && bingoOpen[4] && bingoOpen[5] ||
           bingoOpen[6] && bingoOpen[7] && bingoOpen[8] ||
           bingoOpen[0] && bingoOpen[3] && bingoOpen[6] ||
           bingoOpen[1] && bingoOpen[4] && bingoOpen[7] ||
           bingoOpen[2] && bingoOpen[5] && bingoOpen[8] ||
           bingoOpen[0] && bingoOpen[4] && bingoOpen[8] ||
           bingoOpen[2] && bingoOpen[4] && bingoOpen[6]

   println(if(ans) "Yes" else "No")







}

Measured memory_bytes: 36044
#include<bits/stdc++.h>
#define ll long long int
#define M 998244353;
using namespace std;
int arr[100006];
int max(int a,int b)
{
	if(a>b)return a;
	return b;
}
ll qsm(ll a,ll x)
{
	ll ans=1;
	while(x)
	{
		if(x%2==1)ans=ans*a%M;
		a=a*a%M;
		x/=2;
	}
	return ans;
}
int main(){
 	int n,mx=0;
 	cin>>n;
 	int l;
 	cin>>l;
 	if(l!=0)
 	{
 		cout<<0;
	 	return 0;	
	 }
	 arr[l]++;
 	for(int i=1;i<n;++i)
 	{
 		int d;
 		cin>>d;
 		arr[d]++;
 		mx=max(mx,d);
	 }
	 if(arr[0]!=1){
	 	cout<<0;
	 	return 0;
	 }
	 for(int i=1;i<=mx;++i)
	 {
	 	if(arr[i]==0)
	 	{
	 		cout<<0;
	 		return 0;
		 }
	 }
	 ll sum=1;
	 for(int i=1;i<=mx;++i)
	 {
	 	ll d=arr[i-1];
	 	sum=sum*qsm(d,arr[i])%M;
	 }
	 cout<<sum;
}

Measured memory_bytes: 640
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
//#pragma GCC target("avx,avx2")
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

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

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
	// cin.exceptions(cin.failbit); 
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

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

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
 
int rnd (int l, int r) {
	return uniform_int_distribution<int> (l, r)(gen);
}
 
int n, m, k;
ld pw[N];



int main () {
	SpeedForce;
	setIO();
	ll n;
	cin >> n;
	int len = 1;
	ld cur = 26;

	while(n > cur) {
		n -= cur;
		++len;
		cur *= 26;
	}
//	cout << len << '\n';
//	exit(0);

	pw[0] = 1;
	for (int i = 1; i <= 13; ++i) pw[i] = pw[i-1] * 26;

	int pos = 0;
	string s = "";
	while(pos < len) {	
		char c = 'a';
		for (char ch = 'a'; ch <= 'z'; ++ch) {
			ld cnt = (ch-'a' + 1) * pw[len-pos-1];
			if (cnt >= n) {
				c = ch;
				break;
			}
		}
		n -= pw[len-pos-1] * (c-'a');
		s += c;
		++pos;
	}

	cout << s << '\n';

	return Accepted;
}

// B...a

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
using namespace std;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a,b;
    cin>>a>>b;
    long long n;
    n=a*b;
    if(a<b) swap(a,b);
    long long r=a%b;
    while(r!=0){
      a=b;
      b=r;
      r=a%b;
    }
    
    
    cout<<n/b<<'\n';
    
    return 0;
}


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

int main() {
    int n, k, x, y;
    cin >> n;
    cin >> k;
    cin >> x;
    cin >> y;
    
    int cost = min(n, k) * x + max(0, (n - k)) * y;
    
    cout << cost << endl;
    
    return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(1000000) 
ans = 0
def main():
    N, M, Q = map(int, readline().split())
    query = []
    for _ in range(Q):
        a, b, c, d = map(int, readline().split())
        a -= 1
        b -= 1
        query.append((a, b, c, d))

    def slv(A):    
        s = 0
        for a, b, c, d in query:
            if A[b]-A[a] == c:
                s += d
        return s
    #数列Aを構築
    #数列Aを構築できたら計算処理
    from collections import deque 
    A = deque()
    def dfs(p):
        global ans
        if p == N:
            s = 0
            for a, b, c, d in query:
                if A[b]-A[a] == c:
                    s += d
            ans = max(s, ans)
            return
        if len(A) == 0:
            k = 1
        else:
            k = A[p-1]
        for i in range(k, M+1):
            A.append(i)
            dfs(p+1)
            A.pop()
    dfs(0)
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 75788
#include <bits/stdc++.h>
#define IO                       \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define mem(a, x) memset(a, x, sizeof(a))
#define per(x, a, b) for (int x = a; x <= b; x++)
#define rep(x, a, b) for (int x = a; x >= b; x--)

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int maxn = 1e5 + 10;
const int mod = 1e9 + 7;
const double eps = 1e-8;

LL l, r;

LL solve(LL x) {
    if (x % 4 == 0)
        return x;
    else if (x % 4 == 1)
        return 1;
    else if (x % 4 == 2)
        return x + 1;
    else
        return 0;
}
int main() {
#ifdef LOCAL_IM0QIANQIAN
    freopen("test.in", "r", stdin);
//    freopen("test.out", "w", stdout);
#else
    IO;
#endif // LOCAL_IM0QIANQIAN

    while (cin >> l >> r) {
        cout << (solve(r) ^ solve(l - 1)) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(){
 
int a, b;
 
scanf("%d",&a);
scanf("%d",&b);

 
if(a > b){
 
printf("a > b\n");
 
}
 
 
else if(a < b){
 
printf("a < b\n");
 
}
 
 
else {
 
printf("a == b\n");
 
}
 
return 0;
 
}

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

#define int long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 200010;
struct Edge {
	int u, v, w;
	bool operator < (const Edge &z) const {
		return w < z.w;
	}
}e[N << 1];
int n, q, c, w[N], fa[N];
int find(int x) {
	return x == fa[x] ? x : fa[x] = find(fa[x]);
}
 main() {
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	read(n), read(q);
	int tot = 0;
	memset(w, 127, sizeof(w));
	for (int i = 1, x, y, z; i <= q; i++) {
		read(x), read(y), read(z);
		e[++tot] = (Edge) {x, y, z};
		w[x] = min(w[x], z + 1); w[y] = min(w[y], z + 2);
	}
	for (int i = 0; i < n; i++) w[(i + 1) % n] = min(w[(i + 1) % n], w[i] + 2);
	for (int i = 0; i < n; i++) w[i] = min(w[i], w[(i - 1 + n) % n] + 2);
	for (int i = 0; i < n; i++) e[++tot] = (Edge) {i, (i + 1) % n, w[i]};
	sort(e + 1, e + 1 + tot);
	for (int i = 0; i < n; i++) fa[i] = i;
	int ans = 0;
	for (int i = 1; i <= tot; i++) {
		int u = find(e[i].u), v = find(e[i].v);
		if (u == v) continue;
		ans += e[i].w;
		fa[v] = u;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 12800
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int k = in.nextInt();
        String s = in.next();
        LinkedList<Integer> l = new LinkedList<>();
        char prev = s.charAt(0);
        int current = 1;
        for(int i=1; i<n; i++) {
            char c = s.charAt(i);
            if(prev == c) {
                current++;
            }
            else {
                l.add(current);
                current = 1;
                prev = c;
            }
        }
        l.add(current);

        while(k > 0) {
            if(l.size() <= 1) {
                break;
            }
            k--;
            int first = l.pollFirst();
            int second = l.pollFirst();
            int third = 0;
            if(l.size() >= 1) {
                third = l.pollFirst();
            }
            l.offerFirst(first + second + third);
        }
        int result = 0;
        while(!l.isEmpty()) {
            int i = l.pollFirst();
            result += Math.max(0, i-1);
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 30708
#include <iostream>
#include <algorithm>
#include <cmath>
#include <fstream>
#include <string.h>
using namespace std;

typedef unsigned long long ll;

ll kombin[110][110];

ll C(ll x,ll y)
{
	ll ans;
	if (y<=x/2){
	ans=1;
	ll ans1=1;
	ll pengali=x;
	for (ll loop=x;loop>=(x-y)+1;loop--)
	{
		ans1*=loop;
		//cout<<loop<<" loop\n";
	}
	//cout<<ans1<<"\n";
	ll ans2=1;
	for (ll loop=1;loop<=y;loop++)
	{
		ans2*=loop;
	}
	//cout<<ans1<<" "<<ans2<<"\n";
	ans=ans1/ans2;}
	else
	 {
	 	if (kombin[x][x-y]!=-1)
	 	 ans=kombin[x][x-y];
	 	else
	 	 {
	 	 	//cout<<x<<" "<<y<<"\n";
	 	 	//cout<<"yo\n";
	 		ans=C(x,x-y);
		 }
	 }
	kombin[x][y]=ans;
	return ans;
}

int main()
{
	
	//freopen("input.txt","r",stdin);
	//cout<<C(50,30)<<"\n";
	ll i,j,k,n,tab[110],mod;
	memset(kombin,-1,sizeof(kombin));
	cin>>n>>mod;
	//cout<<n<<" n\n";
	ll genap=0,ganjil=0;
	for (i=1;i<=n;i++)
	{
		cin>>tab[i];
		if (tab[i]%2==0)
		 genap++;
		else
		 ganjil++;
	}
	//cout<<ganjil<<" ganjil "<<genap<<" genap\n";
	//cout<<ganjil<<" ganjil\n";
	if (mod==1)
	{
		if (n==1)
		{
			if (ganjil==1)
			{
				cout<<1<<"\n";
				return 0;
			}
			else
			{
				cout<<0<<"\n";
				return 0;
			}
		}
		ll hitung=1;
		ll sum=0;
		ll kali=1;
		for (i=1;i<=genap;i++)
		{
			kali*=2;
		}
		//kali-=1;
		//cout<<kali<<"\n";
		while (hitung<=ganjil)
		{
			ll kombinasi=C(ganjil,hitung);
			sum+=(kombinasi*kali);
			//cout<<ganjil<<" "<<hitung<<"\n";
			//cout<<C(ganjil,hitung)<<"\n";
			hitung+=2;
		}
		//sum+=ganjil*genap;
		cout<<sum<<"\n";
		return 0;
	}
	else
	 {
	 	ll sum=1;
	 	for (i=1;i<=genap;i++)
	 	{
	 		sum*=2;
		}
		sum-=1;
		ll kali=sum;
		ll hitung=2;
		while (hitung<=ganjil)
		{
			sum+=C(ganjil,hitung)*kali+C(ganjil,hitung);
			//cout<<ganjil<<" "<<hitung<<"\n";
			//cout<<C(ganjil,hitung)<<"\n";
			hitung+=2;
		}
		sum+=1;
		cout<<sum<<"\n";
	 }
}

Measured memory_bytes: 384
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;


int main()
{
	char s[1010], t[1010];
	int ndif[1010] = {};

	cin >> s;
	cin >> t;

	int len = strlen(s) - strlen(t);

	for (int i = 0; i <= len; i++) {
		for (int j = 0; j < strlen(t); j++) {
			if (t[j] != s[j + i]) ndif[i]++;
		}
	}

	cout << *min_element(ndif, ndif + len) << endl;
	return 0;
}


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

int n;
int m;
int par[114514];
int grp[114514];
int myws[114514];
int height[114514];
vector<int> belong[114514];

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

bool same(int v, int u) {
  return find(v) == find(u);
}

void unite(int u, int v) {
  u = find(u);
  v = find(v);
  if (u == v) return;

  if (height[u] > height[v]) par[v] = u;
  else if (height[u] < height[v]) par[u] = v;
  else {
    par[v] = u;
    height[v]++;
  }
}

int main() {
  while (1) {
    scanf("%d%d", &n, &m);
    if (n == 0 && m == 0) return 0;

    for (int i=0; i<=n; i++) {
      myws[i] = 0;
      par[i] = i;
      height[i] = 0;
      belong[i].clear();
      belong[i].push_back(i);
      grp[i] = i;
    }

    for (int i=0; i<m; i++) {
      char cmd;
      int a, b;
      scanf(" %c%d%d", &cmd, &a, &b);
      if (cmd == '!') {
        int w;
        scanf("%d", &w);
        if (!same(a, b)) {
          if (belong[grp[a]].size() < belong[grp[b]].size()) {
            swap(a, b);
            w = -w;
          }

          int d = myws[b]-(myws[a]+w);
          for (int v : belong[grp[b]]) {
            belong[grp[a]].push_back(v);
            grp[v] = grp[a];
            myws[v] -= d;
          }
          unite(a, b);
        }
      } else {
        if (!same(a, b)) puts("UNKNOWN");
        else {
          printf("%d\n", myws[b]-myws[a]);
        }
      }
    } 
  }
}

Measured memory_bytes: 11424
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n; cin >> n;
    VL x(n); cin >> x;

    ll ans = LLINF;
    eFOR(i, 0, 100) {
        ll sum = 0;
        FOR(j, 0, n) {
            sum += (x[j] - ll(i)) * (x[j] - ll(i));
        }
        chmin(ans, sum);
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma G++ optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define mst(a, b) memset((a), (b), sizeof(a))
#define mp(a, b) make_pair(a, b)
#define pi acos(-1)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pdd pair<double, double>
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define lson l, mid, rt << 1
#define rson mid + 1, r, rt << 1 | 1
const ll INF = 0x3f3f3f3f3f3f3f;
const double eps = 1e-8;
const int maxn = 4e3 + 7;
const int maxm = 1e5 + 7;
const int mod = 192600817;
#define IO ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int main()
{
    IO;
    int k,a,b;
    cin>>k>>a>>b;
    for (int i=a;i<=b;++i)
    {
        if (i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}

Measured memory_bytes: 3644
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;


const int N=105;
const ll mod=1e9+7;
ll dp[N*N];
ll pc[N*N][N];
ll d;
string s;
ll ans;

inline void precal(){
	pc[0][0]=1;
	FER(tam,1,sz(s)+1)FER(j,0,d)FER(c,0,10){
		int id=((j-c)%d+d)%d;
		//pc[tam][j]=(pc[tam][j]+pc[tam-1][(j-c+d)%d])%mod;
		//if(tam<sz(s)&&c!=0&&j==0)ans=(ans+pc[tam-1][(j-c+d)%d])%mod;
		pc[tam][j]=(pc[tam][j]+pc[tam-1][id])%mod;
		if(tam<sz(s)&&c!=0&&j==0)ans=(ans+pc[tam-1][id])%mod;
	}
}

inline void solve(){
	ll acum=0;
	//trace(ans);
	IFR(tam,sz(s),1){
		ll id=sz(s)-tam;
		ll cur=s[id]-'0';
		FER(dig,tam==sz(s),cur){
			ll idd=(d-(acum+dig)%d)%d;
			dp[tam]=(dp[tam]+pc[tam-1][idd])%mod;
		}
		ans=(ans+dp[tam])%mod;
		acum=(acum+cur)%d;
	}
	ll sum=0;
	FER(i,0,sz(s))sum=(sum+(s[i]-'0'))%d;
	if(sum==0)ans=(ans+1)%mod;
	cout<<ans<<endl;
}


int main(){	
	fastio;
	cin>>s>>d;
	ans=0;
	precal();
	solve();

	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std ;
#define ll long long
inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}


//#########################################



int main() {

    long long n=LLD(),h=LLD();
    long long a[n];
    long long b[n];
    long long mx=-1;
    long long cnt=0;
    for(int i=0;i<n;i++){

        scanf("%lld%lld",&a[i],&b[i]);
        if(a[i]>mx)
            mx=a[i];
    }
    sort(b,b+n);
    for(int i=n-1;i>=0;i--) {

        if(b[i]>=mx) {
            h -= b[i];
            cnt++;
        }
        if(h<=0){
            cout<<cnt;
            return  0;

        }



    }
    if(h%mx==0){
        cnt+=h/mx;

    } else {
        cnt += h / mx;
        cnt++;
    }

    cout<<cnt;

}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <stack>
#include <deque>
#include <ctime>
#include <random>
#include <cassert>
#include <cmath>
#include <climits>
#include <queue>
#include <cstring>
#include <bitset>
#include <iomanip>
#include <chrono>

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2")
*/


#ifdef LOCAL
	#define dbg(x) cout << #x << " : " << x << endl;
#else 
	#define dbg(x)
#endif

#define int long long
#define pb push_back
#define ppb pop_back()
#define mp make_pair
#define fi(a,b) for (int i=a;i<b;i++)
#define fj(a,b) for (int j=a;j<b;j++)
#define fk(a,b) for (int k=a;k<b;k++)
#define fi1(a,b) for (int i=a-1;i>=b;i--)
#define fj1(a,b) for (int j=a-1;j>=b;j--)
#define fk1(a,b) for (int k=a-1;k>=b;k--)
#define fx(x,a) for (auto& x : a)
#define rep(i, a, b) for (int i = a; i < b; ++i)
#define rep1(i, a, b) for (int i = a - 1; i >= b; --i)
#define siz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;

template<typename T1, typename T2>inline void mine(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void maxe(T1 &x, T2 y) { if (x < y) x = y; }

ostream& operator << (ostream &a, const vector<int> &b) {
    for (auto k : b) cout << k << ' ';
    return a;
}


typedef long long ll;
typedef unsigned long long ull;
typedef char ch;
typedef string str;
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<ch> vch;
typedef vector<vch> vvch;
typedef vector<str> vs;



const int MOD = 1000000007;
const int INF = 1000000050;
const long long BIG = (long long)2e18 + 50;
const int MX = 200010;
const double EPS = 1e-9;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
   
   	int x;
   	cin >> x;
   	cout << x + x * x  + x * x * x << '\n';
   	
}

Measured memory_bytes: 3608
// 挿入ソート
#include<iostream>
#include<algorithm>
using namespace std;

//static const int MAX_N = 100;
static const int MAX_ELE = 1000;

int main(void)
{
    int v, j;
    int N;
    int ary_sequence[MAX_ELE];

    cin >> N;

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

    for(int i = 0; i < N - 1; i++)
    {
        cout << ary_sequence[i] << ' ';
    }

    cout << ary_sequence[N - 1] << endl;

    // -----▼▼▼ 挿入ソート ▼▼▼-----

    for(int i = 1; i < N; i++)
    {
        v = ary_sequence[i];
        j = i - 1;

        while( j >= 0 && ary_sequence[j] > v )
        {
            ary_sequence[j + 1] = ary_sequence[j];
            j--;
        }

        ary_sequence[j + 1] = v;

        for(int k = 0; k < N - 1; k++)
        {
        		cout << ary_sequence[k] << ' ';
        }

        cout << ary_sequence[N - 1] << endl;
    }

    // -----▲▲▲ 挿入ソート ▲▲▲-----

    return 0;
}



Measured memory_bytes: 3096
#include <cstdio>

using namespace std;

int main(){
  int a, b, r, d;
  double f;
  scanf("%d %d", &a, &b);
  d = a / b;
  r = a % b;
  f = static_cast<double>(a) / static_cast<double>(b);

  printf("%d %d %.5f\n", d, r, f);
  
  return 0;
}



Measured memory_bytes: 2728
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

int main() {
  cout << fixed << setprecision(15);

  ll N;
  string s;
  cin >> N;
  cin >> s;

  ll ans = 0;
  for (ll i = 0; i <= 9; i++) {
    for (ll j = 0; j <= 9; j++) {
      for (ll k = 0; k <= 9; k++) {
        string::size_type pos = s.find(i + '0');
        if (pos == string::npos) {
          continue;
        }
        pos = s.find(j + '0', pos + 1);
        if (pos == string::npos) {
          continue;
        }
        pos = s.find(k + '0', pos + 1);
        if (pos == string::npos) {
          continue;
        }
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        String s = scan.next();
        String t = scan.next();
        int a = scan.nextInt();
        int b = scan.nextInt();
        String u = scan.next();
        if(s.equals(u)){
            a--;
        }
        if(t.equals(u)){
            b--;
        }
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 23124
fun main(args: Array<String>) {
    val s = readLine().orEmpty()
    val t = readLine().orEmpty()
    val sLen = s.length
    val tLen = t.length
    val lenDiff = sLen - tLen
    (0 .. lenDiff)
        .map { i ->
            val sub = s.substring(i, i + tLen)
            sub.zip(t) { sc, tc -> sc == tc }.count { it }
        }
        .max()!!
        .let { println(tLen - it) }
}


Measured memory_bytes: 39220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define P pair<ll, ll>
#define Graph vector<vector<ll>>
#define fi first
#define se second
constexpr ll mod = 1000000007;
constexpr ll INF = (1ll << 60);
constexpr double pi = 3.14159265358979323846;
template <typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    string S;
    cin >> S;
    if (S.size() < 7) {
        cout << "NO\n";
        return 0;
    }

    bool ans = false;
    string key = "keyence";
    // if (S.substr(0, 7) == key) ans = true;
    // if (S.substr(S.size() - 7) == key) ans = true;

    rep(i, 7 + 1) {
        // if (i == 0 || i == 7) continue;
        string sp = key.substr(0, i), ano = key.substr(i);

        // cout << sp << " " << ano << "\n";

        if (S.substr(0, i) == sp && S.substr(S.size() - 7 + i) == ano) {
            ans = true;
        }
    }

    if (ans)
        cout << "YES\n";
    else
        cout << "NO\n";
    return 0;
}

Measured memory_bytes: 3596
n,m = map(int, input().split())

flag = [False]*n
wa = [0]*n
for _ in range(m):
  p,s = input().split()
  p = int(p)-1
  if not flag[p]:
    if s == "WA":
      wa[p] += 1
    else: flag[p] = True

count = 0
for i in range(n):
  if flag[i]: count += wa[i]

print(flag.count(True), count)

Measured memory_bytes: 10284
import java.lang.Math

fun main(args: Array<String>)
{
    val MOD: Long = 1000000007L // (1e+9)+7

    val n = readLine()!!.toInt()
    val s = readLine()!!.toCharArray()

    for (i in 0 until s.size) {
        var tmp = s[i].toInt()
        tmp += n
        if (tmp > 'Z'.toInt()) tmp = tmp % 'Z'.toInt() + 'A'.toInt() - 1
        s[i] = tmp.toChar()
    }

    println(s.joinToString(separator=""))
}


Measured memory_bytes: 34024
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> son[1010];
int x[1010];
int z[1010];
int dp1[10010],dp2[10010];
void dp(int &x, int y)
{
	if(x == -1 || x > y) x = y;
}
int main()
{
	scanf("%d", &n);
	for (int i = 2; i <= n; ++i)
	{
		int y;
		scanf("%d", &y);
		son[y].push_back(i);
	}
	for(int i = 1; i <= n; ++i)
		scanf("%d",&x[i]);
	for(int i = n; i >= 1; --i)
	{
		memset(dp1, -1, sizeof(dp1));
		dp1[0] = 0;
		vector<int>::iterator it;
		for( it = son[i].begin(); it != son[i].end(); ++it)
		{
			int hei = x[*it], bai = z[*it];
			memset(dp2,-1,sizeof(dp2));
			for(int j = 0; j <= x[i]; ++j)
				if(dp1[j] != -1)
				{
					if(j + hei <= x[i])
						dp(dp2[j + hei], dp1[j] + bai);
					if(j + bai <= x[i])
						dp(dp2[j + bai], dp1[j] + hei);
				}
			memcpy(dp1, dp2, sizeof(dp2));
		}
		int res = -1;
		for(int j = x[i]; j >= 0; --j)
			if(dp1[j] != -1)
				dp(res, dp1[j]);
		if(res == -1)
		{
			puts("IMPOSSIBLE");
			return 0;
		}
		z[i] = res;
	}
	puts("POSSIBLE");
	return 0;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner std = new Scanner(System.in);
        int x = std.nextInt();
        int ans = solution(x);
        System.out.println(ans);
    }

    static int solution(int x) {
        boolean[] dp = new boolean[x+10];
        dp[0] = true;
        int[] elements = {100,101,102,103,104,105};
        for (int i = 100; i <= x; i++) {
            for (int j = 0; j < elements.length; j++) {
                int yen = elements[j];
                int diff = i - yen;
                if (diff < 0) {
                    continue;
                }
                if (dp[diff]) {
                    dp[i] = true;
                    break;
                }
            }
        }
        if (dp[x]) {
            return 1;
        } else {
            return 0;
        }
    }

}


Measured memory_bytes: 22996
n = int(input())
l = list(map(int, input().split()))

l.sort(reverse=True)
kmax = len(format(l[0], 'b'))

l0 = [0]*kmax
l1 = [0]*kmax

for i in range(n):
  a = format(l[i], 'b')
  a = ''.join(list(reversed(a)))
  for j in range(kmax):
    if j > len(a)-1:
      l0[j] += 1
    elif a[j] == '0':
      l0[j] += 1
    else:
      l1[j] += 1

ans = 0
for k in range(kmax):
  ans += l0[k]*l1[k]*(2**k)
  ans %= 10**9+7
print(ans)

Measured memory_bytes: 125624
from fractions import gcd
from math import factorial, ceil, sqrt, atan2, log, pi, e, asin,acos, cos, sin, floor, atan
from itertools import *
from fractions import Fraction
import string
import copy
import random
import bisect
from decimal import *
from collections import deque
from sys import *
digs = string.digits + string.ascii_letters

def id_generator(size=20, chars=string.digits):
    return ''.join(random.choice(chars) for _ in range(size))
 
def mp():
    return map(int,str(raw_input()).strip().split())

clear=stdout.flush()

t,x=mp()
print t/float(x)

Measured memory_bytes: 4760
import io.{StdIn => in}
import scala.collection.mutable.HashSet

object Main extends App {
  val Array(n, k) = in.readLine.split(" ").map(_.toLong)
  val ans = k * (2L to n)./:(1L)((acc,_) => acc * (k-1))
  println(ans)
}

Measured memory_bytes: 27580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    ll cnt = 0;
    for (int a = 1; a <= N; a++) {
        for (int b = 1; b <= N; b++) {
            if (a * b >= N) break;
            cnt++;
        }
    }
    cout << cnt << "\n";
    return 0;
}

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

using namespace std;


int main(){
	int n, odd=0;
	double ans;
	cin>>n;
	for(int i=1; i<=n; i++){
		if(i%2!=0){
			odd++;
		}
	}
	printf("%.10f\n", (double)odd/(double)n);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# IMPORT ###############################################################################################################
import sys                                                      # システム
sys.setrecursionlimit(10**6)                                    # 再帰処理の上限変更
from collections import deque, Counter                          # キュー・個数カウント
from itertools   import accumulate, permutations, combinations  # 累積和・順列・組み合わせ
from operator    import itemgetter                              # ソート補助
from bisect      import bisect_left, bisect_right, bisect       # 二分探索
from heapq       import heappop, heappush                       # プライオリティキュー
from fractions   import gcd                                     # 最大公約数
from math        import ceil, floor, sqrt, cos, sin, tan, pi    # 数学処理
from copy        import deepcopy                                # オブジェクトコピー
import numpy         as np                                      # 数値計算

# MAIN #################################################################################################################
def main():
    # Init #############################################################################################################
    im = InputManager()
    # Input ############################################################################################################
    r, d, x_2000 = im.inputMultiple()
    # Logic ############################################################################################################
    x_next = x_2000
    for _ in range(10):
        x_next = r * x_next - d
        print(x_next)
    # Output ###########################################################################################################

    # Return ###########################################################################################################
    return

# INPUT MANAGER ########################################################################################################
class InputManager(object):
    def __init__(self):
        pass

    @staticmethod
    def inputSingle(dtype=int):
        return dtype(input())
    
    @staticmethod
    def inputMultiple(dtype=int, aslist=False):
        if aslist:
            return list(map(dtype, input().split()))
        else:
            return map(dtype, input().split())

    @staticmethod
    def input2D(h, dtype=int):
        return [list(map(dtype, input().split())) for i in range(h)]

# CALL MAIN ############################################################################################################
main()

Measured memory_bytes: 22912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int n = scanner.nextInt();
			if (n == 0)
				break;
			int[][] kasi = new int[n][5];
			for (int i = 0; i < n; i++) {
				int id = scanner.nextInt();
				int p = scanner.nextInt();
				int q = scanner.nextInt();
				int r = scanner.nextInt();
				kasi[i][0] = id;
				kasi[i][1] = p;
				kasi[i][2] = q;
				kasi[i][3] = r;
				kasi[i][4] = p * 4 + q * 9 + r * 4;
			}
			int P = scanner.nextInt();
			int Q = scanner.nextInt();
			int R = scanner.nextInt();
			int C = scanner.nextInt();
			boolean flag = true;
			for (int i = 0; i < n; i++) {
				if (kasi[i][1] <= P && kasi[i][2] <= Q && kasi[i][3] <= R
						&& kasi[i][4] <= C) {
					System.out.println(kasi[i][0]);
					flag = false;
				}
			}
			if (flag)
				System.out.println("NA");
		}
	}
}

Measured memory_bytes: 64140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  string s;cin>>s;
  bool ans=(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi");
  cout<<btos(ans)<<endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<VVLL> VVVLL;

#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define FORL(i,a,b) for(LL i=(a);i<(b);++i)
#define REPL(i,n)  FORL(i,0,n)
#define SIZE(a) int((a).size())
#define ALL(a) (a).begin(),(a).end()
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
template <typename Iterator>
inline bool next_combination(const Iterator first, Iterator k, const Iterator last)
{
   /* Credits: Thomas Draper */
   if ((first == last) || (first == k) || (last == k))
      return false;
   Iterator itr1 = first;
   Iterator itr2 = last;
   ++itr1;
   if (last == itr1)
      return false;
   itr1 = last;
   --itr1;
   itr1 = k;
   --itr2;
   while (first != itr1)
   {
      if (*--itr1 < *itr2)
      {
         Iterator j = k;
         while (!(*itr1 < *j)) ++j;
         iter_swap(itr1,j);
         ++itr1;
         ++j;
         itr2 = k;
         rotate(itr1,j,last);
         while (last != j)
         {
            ++j;
            ++itr2;
         }
         rotate(k,itr2,last);
         return true;
      }
   }
   rotate(first,k,last);
   return false;
}

inline double get_time_sec(void){
    return static_cast<double>(chrono::duration_cast<chrono::nanoseconds>(chrono::steady_clock::now().time_since_epoch()).count())/1000000000;
}

template<typename T>
T gcd(T a, T b) {
    if(a > b) swap(a, b);
    if(a == 0) return b;
    else return gcd(b%a, a);
}

template<typename T>
map<T, T> prime_list(T n) {
    map<T, T> ret;
    for(T i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            ret[i] = 0;
            while(n % i == 0) {
                n /= i;
                ret[i]++;
            }
        }
    }
    if(n != 1) ret[n]++;
    return ret;
}

#define MOD 1000000007

LL mypow(LL a, LL n) {
    if(n == 1) return a % MOD;
    if(n % 2 == 1) return (a * mypow(a, n-1)) % MOD;
    LL t = mypow(a, n/2);
    return (t * t) % MOD; 
}

int main(void) {
    string s, t;
    cin >> s >> t;
    VS v;
    REP(i, s.size() - t.size() + 1) {
        bool flg = true;
        string u(s);
        REP(j, t.size()) {
            if(s[i + j] != '?' && s[i + j] != t[j]) {
                flg = false;
                break;
            }
            u[i + j] = t[j];
        }
        if(flg) {
            REP(j, s.size()) {
                if(u[j] == '?') u[j] = 'a';
            }
            v.push_back(u);
        }
    }
    if(v.size() == 0) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    sort(ALL(v));
    cout << v[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;
int dis(str a, str b){
    int n = a.size();
    int r = 0;
    for(int i = 0; i < n; i++) if(a[i] != b[i])r++;
    return r;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    str s, t;
    cin >> s >> t;
    int ans = 1e9;
    for(int i = 0; i <= s.size() - t.size(); i++){
        ans = min(ans, dis(s.substr(i, t.size()), t));
    }
    cout << ans << "\n";
}


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

const long long mod=998244353;
int n, s;
long long a[3003], dp[3003][3003], mi2;

long long modpow(long long x, int y){
	long long ret=1;
	while (y>0){
		if (y&1){
			ret*=x;
			ret%=mod;
		}
		x*=x;
		x%=mod;
		y>>=1;
	}
	return ret;
}

long long modinv(long long x){
	return modpow(x,mod-2);
}

int main(){
	cin >> n >> s;
	for (int i=0;i<n;i++) cin >> a[i];
	memset(dp,0,sizeof dp);
	dp[0][0]=modpow(2,n);
	mi2=modinv(2);
	for (int i=0;i<n;i++){
		for (int j=0;j<=s;j++){
			// include a[i]
			if (j+a[i]<=s){
				dp[i+1][j+a[i]]+=(dp[i][j]*mi2)%mod;
				dp[i+1][j+a[i]]%=mod;
			}
			// exclude a[i]
			dp[i+1][j]+=dp[i][j];
			dp[i+1][j]%=mod;
		}
	}
	cout << dp[n][s] << "\n";
}

Measured memory_bytes: 74084
#include<stdio.h>
int main(){
	long long int a,b,bai[1000]={},yaku[1000]={},e,f=0,g,bosu,j=0,m,n;
	while(scanf("%lld %lld",&a,&b)!=EOF){
		if(a>b){
		m=a;
		n=b;}else{m=b;n=a;}
		while(m%n!=0){
			g=n;
			n=m%n;
			m=g;

		}
		yaku[j]=n;
		bosu=a*b;
		bai[j]=bosu/yaku[j];
		j++;
	}
	for(e=0;e<j;e++){
		printf("%lld %lld\n",yaku[e],bai[e]);
	}
	return 0;
}

Measured memory_bytes: 612
N,K = map(int,input().split())
import sys
sys.setrecursionlimit(10000000)

a, p = [1], [1]
for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)
def dfs(N,X):
    #print(N,X)
    if N == 0:
        return 0 if X != 1 else 1
    elif X <= 1 + a[N-1]:
        return dfs(N-1, X-1)
    elif X == 2 + a[N-1]:
        return p[N-1] + 1
    elif X <= 2 + 2*a[N-1]:
        return p[N-1] + 1 + dfs(N-1, X-2-a[N-1])
    else:
        return 2*p[N-1]+1
    
print(dfs(N,K))

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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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

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

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

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


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char l[501];
char h[501][501];
int main()
{
  int n,m,i,j,k;
  for(;;){
    scanf("%d",&n);
    scanf("%d",&m);
    if(n == 0 && m == 0) break;
    memset(l,0,sizeof(l));
    memset(h,0,sizeof(h));
    for(i=0;i<m;i++){
      scanf("%d%d",&j,&k);
      h[j][k] = 1;
      h[k][j] = 1;
    }
    for(i=2;i<=n;i++){
      if(h[1][i] == 1){
	l[i] = 1;
	for(j=1;j<=n;j++){
	  if(h[i][j] == 1) l[j] = 1;
	}
      }
    }
    j = 0;
    for(i=2;i<=n;i++){
      if(l[i] == 1) j++;
    }
    printf("%d\n",j);
  }
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())

using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
int modpow(int a,int n,int p){if (n==0)return 1%p; if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位


class unionfind{
public:
	vector<int> table;
	void init(int size){
		table.resize(size);
		rep(i,size)table[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};


int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(19);
	int n;
	in(n);
	vint a(n);
	in(a);
	vlint table(n+3);
	vlint kab(n+3);
	vlint gold(n+3);
	table[0]=1000;
	gold[0]=1000;
	arep(i,1,n+1){
		rep(j,n){
			chmax(table[i],gold[j]+kab[j]*a[j]);
		}
		lint count=table[i]/a[i-1];
		gold[i]=table[i]-count*a[i-1];
		kab[i]=count;
	}
	out(table[n]);
	return 0;
}


Measured memory_bytes: 3644