akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static void Main(string[] args)
        {
            var V = ReadInts();
            Console.WriteLine((V[0] == V[1]) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,a[55],i,j,max=0,count=0;
    bool c=true;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a[i];
    }
    max=a[0];
    for(j=0;j<n;j++){
c=true;
for(int k=0;k<j;k++){

        if(a[k]>a[j]){
                c=false;break;
        }
      //  if(c!=false&&j!=0&&a[j]==max){count++;}

    }
    if(c){count++;}
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 222222
using namespace std;
int n,m,i,x,y,S,T,fir[N],ne[N],la[N],q[N],tot,t,cnt,vis[N],pre1[N],pre2[N],ta,tb,a[N],b[N];
void ins(int x,int y){la[++tot]=y;ne[tot]=fir[x];fir[x]=tot;}
void dfs1(int x){
	vis[x]=1;
	for(int i=fir[x],y;i;i=ne[i])if(!vis[y=la[i]]){
		dfs1(y),pre1[y]=x;
		return;
	}
	S=x;
}
void dfs2(int x){
	vis[x]=1;
	for(int i=fir[x],y;i;i=ne[i])if(!vis[y=la[i]]){
		dfs2(y),pre2[y]=x;
		return;
	}
	T=x;
}
int main(){
	scanf("%d%d",&n,&m);
	for(i=1;i<=m;i++)scanf("%d%d",&x,&y),ins(x,y),ins(y,x);
	dfs1(1);dfs2(1);
	for(i=S;i!=1;i=pre1[i])a[++ta]=i;
	for(i=T;i!=1;i=pre2[i])b[++tb]=i;
	printf("%d\n",ta+tb+1);
	for(i=1;i<=tb;i++)printf("%d ",b[i]);
	printf("%d",1);
	for(i=ta;i;i--)printf(" %d",a[i]);
}

Measured memory_bytes: 9344
from bisect import bisect_left
n = int(input())
s = input()
idxs = [[] for _ in range(10)]
for i, j in enumerate(s):
    idxs[int(j)].append(i)
ans = 0
for i in range(10):
    if len(idxs[i])==0:
        continue
    b = idxs[i][0]+1
    for j in range(10):
        if len(idxs[j])==0:
            continue
        m = bisect_left(idxs[j], b)
        if len(idxs[j])==m:
            continue
        m = idxs[j][m]+1
        for k in range(10):
            if bisect_left(idxs[k], m)<len(idxs[k]):
                ans += 1
print(ans)

Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    bool flag = true;
    for(ll i=0; i<s.size(); i+=2) {
        if(s[i]=='h' && i+1 < (ll)s.size() && s[i+1]=='i') {

        } else {
            flag = false;
        }
    }

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

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double k = (a + b) / 2;
		if ((a + b) % 2 == 0) {
			System.out.println((int)k);
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c,d,n,m,p,q,x,y,k,h,w,sum,mi,ma,ans,l,r,res;
string s;
typedef vector<int> VI;
typedef vector<pair<int,int> > VP;

//全ての10000円札と5000円札の組を試し、1000円札で帳尻が合うか調べる。

int main(){
    cin>>n>>y;
    rep(i,n+1)rep(j,n+1){
        if(i+j>n)continue;
        if(y==10000*i+5000*j+(n-i-j)*1000){ps(i);ps(" ");ps(j);ps(" ");p(n-i-j);return 0;}
    }
    ps(-1);ps(" ");ps(-1);ps(" ");p(-1);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  bool found = false;
  for (int i = 1; i <= B; ++i) {
    if (A * i % B == C) {
      found = true;
      break;
    }
  }
  if (found)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	long long x=0,ans=0,n=100;
    cin >> x;
	while (true) {
		ans++;
		n += n/100;
		if (n >= x) {
			cout << ans << endl;
            return 0;
		}
	}
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<cfloat>
using namespace std;
int mod = 1e9+7;

int main() {
  int n, p;
  cin >> n >> p;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
    a[i] %= 2;
  }
  sort(a.begin(), a.end());
  if( a[n-1] == 0 ){
    if( p == 1 ){
      cout << 0 << endl;
      return 0;
    }
    long long int ans = 1;
    for(int i=0; i<n; i++) ans *= 2;
    cout << ans << endl;
  } else {
    long long int ans = 1;
    for(int i=0; i<n-1; i++) ans *= 2;
    cout << ans << endl;
  }

  return 0;
}

//


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <cassert>
using namespace std;
#define rep(i,n) for((i)=0;(i)<(n);(i)++)
#define max(a,b) ((a)>(b) ? (a) : (b))
#define min(a,b) ((a)<(b) ? (a) : (b))
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main(){
  ll n,m,k,i,j,result=0,u,v,w;
  queue<pair<ll,ll> > que;
  vector<pair<ll,ll> > tree[100010];
  cin >> n;
  vector<ll> dist(n,-1);
  rep(i,n-1){
    cin >> u >> v >> w;
    u--;
    v--;
    tree[u].push_back(make_pair(v,w));
    tree[v].push_back(make_pair(u,w));
  }
  que.push(make_pair(0,0));
  dist[0] = 0;
  while(!que.empty()){
    auto p = que.front();
    que.pop();
    for(auto q : tree[p.first]){
      if(dist[q.first]!=-1) continue;
      que.push(make_pair(q.first,p.second+q.second));
      dist[q.first] = p.second+q.second;
    }
  }
  rep(i,n){
    cout << (dist[i]%2==0 ? 0 : 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 11356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main(){
    string S; cin >> S;
    deque<char> dS;
    for(int i=0; i<S.size(); i++){
        dS.push_back(S[i]);
    }
    int Q; cin >> Q;
    int T, F;
    char C;
    int rev = 0;
    for(int i=0; i<Q; i++){
        cin >> T;
        if(T == 1){
            rev = 1-rev;
        }else{ // T == 2
            cin >> F >> C;
            if(rev == 1){
                F = 3-F;
            }
            if(F == 1){
                dS.push_front(C);
            }else{ // F == 2
                dS.push_back(C);
            }
        }
    }

    if(rev == 1){
        reverse(dS.begin(), dS.end());
    }
    
    for(auto s : dS){
        cout << s;
    }
    cout << endl;

    return 0;
}

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

int main() {
  int N, A, B, C, D, x, y, z;
  cin >> N;
  A = N/1000;
  B = (N - N/1000*1000)/100;
  C = (N - N/100*100)/10;
  D = N - N/10*10;
  x = A - B;
  y = B - C;
  z = C - D;
  if (x == 0 && y == 0 || y == 0 && z == 0 || x == 0 && y == 0 && z == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int main () {
    int N, K, s;
    cin >> N >> K;
    int sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> s;
        if (s < K - s) {
            sum += 2 * s;
        }
        else {
            sum += 2 * (K - s);
        }
    }    
    cout << sum << endl;
}

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

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

    vector<int> p;
    for(int i = 0;i < N;i++)
    {
        int P;
        cin>>P;
        p.push_back(P);
    }

    if(N == 0)
    {
        cout<<X<<endl;
        //_getch();
        return 0;
    }

    auto result = find(p.begin(),p.end(),X);
    if(result == p.end())
    {
        cout<<X<<endl;
        return 0;
    }

    int up = X + 1, down = X - 1;
    while(1)
    {
        result = find(p.begin(),p.end(),down);
        if(result != p.end())
        {
            down--;
        }
        else
        {
            cout<<down<<endl;
            //_getch();
            return 0;
        }

        result = find(p.begin(),p.end(),up);
        if(result != p.end())
        {
            up++;
        }
        else
        {
            cout<<up<<endl;
            //_getch();
            return 0;
        }
        
        
    }
   
   //_getch();
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>

using namespace std;


int main(){

	int a, b, c;

	cin >> a >> b >> c;

	    if (a<=b && b<=c){
		cout << a << " " << b << " " << c << endl;
	}
	else if(b<=c && c<=a){
		cout << b << " " << c << " " << a << endl;
	}
	else if(c<=a && a<=b){
		cout << c << " " << a << " " << b << endl;
	}
	else if(c<=b && b<=a){
		cout << c << " " << b << " " << a << endl;
	}
	else if(a<=c && c<=b){
		cout << a << " " << c << " " << b << endl;
	}
	else if(b<=a && a<=c){
		cout << b << " " << a << " " << c << endl;
	}

}


Measured memory_bytes: 3100
//---------- Begin IO utilities ----------
// Thanks to https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:tt : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! p {
    ($v:ident) => {
        println!("{}", $v);
    };
    ($v:ident, $($t:ident),*) => {
        print!("{}", $v);
        ($(print!(" {}", $t)),*);
        println!();
    }
}
#[allow(unused_macros)]
macro_rules! ps {
    ($v:ident) => {
        println!("{}", $v.iter().collect::<String>());
    };
    ($v:ident, $($t:ident),*) => {
        print!("{}", $v.iter().collect::<String>());
        ($(print!(" {}", $t.iter().collect::<String>())),*);
        println!();
    }
}
#[allow(dead_code)]
fn pv<T: std::string::ToString>(v: &[T], sep: &str) {
    let s = v.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep);
    println!("{}", s);
}
#[allow(dead_code)]
fn pvs(v: &[Vec<char>], sep:&str) {
    let s = v.iter().map(|e| e.iter().collect::<String>()).collect::<Vec<String>>().join(sep);
    println!("{}", s);
}
//---------- End IO utilities ----------

fn main() {
    input!{
        s: usize,
        w: usize,
    }
    if s <= w {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


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

typedef long long ll;

const int N = 1e6 + 10;

vector <int> adj[N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll a, b;
	cin >> a >> b;
	cout << max(0ll, a - b * 2) << "\n";
}

Measured memory_bytes: 23680
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
  ll N;
  cin>>N;
  vector<ll> A(N),B(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i]=A[i]-i;
  }
  sort(B.begin(), B.end());
  ll b=B[N/2];
  ll tmp=0;
  for(int i=0;i<N;i++){
    tmp+=abs(-b+B[i]);
  }
  cout<<tmp<<endl;
}

Measured memory_bytes: 3328
{-# LANGUAGE BangPatterns #-}
import Data.Char (isSpace)
import Data.Int (Int64)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.ByteString.Char8 as BS
import Control.Monad (replicateM)

main = do
  [n,maxW] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  items <- replicateM n $ do
    [w,v] <- unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
    return (w, fromIntegral v :: Int64)
  print $ solve maxW items U.! maxW

solve :: Int -> [(Int, Int64)] -> U.Vector Int64
solve !maxW [] = U.replicate (maxW + 1) 0
solve !maxW ((w,v):xs)
  = let !a = solve maxW xs
    in U.generate (maxW + 1)
       $ \i -> if w <= i
               then max (a U.! i) (a U.! (i - w) + v)
               else a U.! i


Measured memory_bytes: 3836
n,l = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)

max = 0
idx = 0
(n-1).times{|i|
  tmp = a[i]+a[i+1]
  if max<tmp
    max = tmp
    idx = i
  end
}

if max<l
  puts "Impossible"
  exit
end

puts "Possible"
1.upto(idx){|i| p i}
(n-1).downto(idx+1){|i| p i}


Measured memory_bytes: 16772
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	var N int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d", &N)

	as := make([]int, N)
	for i := 0; i < N; i++ {
		scanner.Scan()
		fmt.Sscanf(scanner.Text(), "%d", &as[i])
	}

	ans := 0
	var mp map[int]int
	for i := 0; i < N; i++ {
		nextmp := make(map[int]int)
		for k, cnt := range mp {
			if as[i]+k == as[i]^k {
				nextmp[as[i]+k] = cnt
				ans = ans + cnt
			}
		}
		nextmp[as[i]]++
		ans++
		mp = nextmp
		//fmt.Println(mp)
	}
	fmt.Println(ans)

	/*
		foo := 0
		for i := 0; i < N; i++ {
			for j := i; j < N; j++ {
				sum := 0
				xor := 0
				for k := i; k <= j; k++ {
					sum = sum + as[k]
					xor = xor ^ as[k]
				}
				if sum == xor {
					foo++
				}
			}
		}
		fmt.Println(foo)
	*/
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
int a[100000];
int main()
{
    int ans=0;
    for(int i=10000;i<=99999;i++)
    {
        int x=i%10,y=i/10000;
        int m=i/10%10,n=i/1000%10;
        if(x==y&&m==n)
            ans++;
        a[i]=ans;
    }
    int A,B;
    scanf("%d%d",&A,&B);
    printf("%d\n",a[B]-a[A-1]);
    return 0;
}


Measured memory_bytes: 640
N = 1
data = []
for i in range(N):
    data_input = list(map(int,input().split()))
    data.append(data_input)
M = 1
if data[0][0]%2 == 0:
    print('Even')
else:
    if data[0][1]%2 ==0:
        print('Even')
    else:
        print('Odd')

Measured memory_bytes: 3060
#include<stdio.h>
int main() {
int N,K,i;
int array[100];
scanf("%d",&N);
scanf("%d",&K);
for (i=0;i<=N-1;i++) {
scanf("%d",&array[i]);
}
int sum;
sum=0;
for (i=0;i<=N-1;i++){
if (array[i]<=K/2)
 sum = sum + 2*array[i];
else
 sum = sum + 2*(K-array[i]);
}
printf("%d\n",sum);
return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <iomanip>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <complex>
#include <ctime>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e9;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(ll i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用
#define ret return 0

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

using Graph = vector<vector<ll>>;

#define ketasitei setprecision(15) //15桁表示

const ll MOD = 1000000007;
const double PI = 3.1415926535897932;



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

	ll n, k;
	cin >> n >> k;

	vector<ll> a(n);
	priority_queue<pair<double,bool>> pq;
	rep(i, n)
	{
		cin >> a[i];

		if (a[i] % 2 == 0)
		{
			pq.emplace(a[i], false);
		}
		else
		{
			pq.emplace(a[i], true);
		}
	}

	ll left = 0, right = 1000000000;
	ll mid ;
	while (right - left > 1)
	{
		mid = (left + right) / 2;
		ll tmpk = k;
		for (int i = 0; i < n; i++)
		{
			tmpk -= (a[i] + mid - 1) / mid - 1;
			if (tmpk < 0)
				break;
		}

		if (tmpk < 0)
		{
			left = mid;
		}
		else
		{
			right = mid;
		}

	}

	cout << right << endl;

	return 0;
}

Measured memory_bytes: 8952
import itertools
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
l = [i + 1 for i in range(n)]
itt = sorted(list(itertools.permutations(l, n)))
counter = 0
for list_ in itt:
    list_ = list(list_)
    if list_ == p:
        a = counter
    if list_ == q:
        b = counter
    counter += 1
print(abs(b - a))


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

int main() {
	// your code goes here
	char c;
	cin>>c;
	int d = c- 'A';
	if(0<=d && d<=25) cout<<"A"<<endl;
	else if(32<=d && d<=57) cout<<"a"<<endl;
	return 0;
}


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

using namespace std;

int main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    
    for(int i=1;i<n;i++){
        string left=s.substr(0,i);
        string right=s.substr(i,n-i);
        map<char,int> leftmap;
        map<char,int> rightmap;
        for(auto a:s) leftmap[a]=-2;
        for(auto a:s) rightmap[a]=-1;
        
        for(auto a:left) leftmap[a]=1;
        for(auto a:right) rightmap[a]=1;
        
        int cnt=0;
        
        for(auto a:s){
            if(rightmap[a]==leftmap[a] && rightmap[a]!=2 && leftmap[a]!=2){
                cnt++;
                rightmap[a]=2;
                leftmap[a]=2;
            }
        }
        
        ans=max(ans,cnt);
    }
    
    cout<<ans<<endl;
    
    return 0;
}

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

int main() {
  int N, M;
  cin >> N >> M;
  vector<int> switches(N);
  for (int i = 0; i < M; i++) {
    int switch_size;
    cin >> switch_size;
    for (int j = 0; j < switch_size; j++) {
      int switch_number;
      cin >> switch_number;
      switch_number--;  // インデックスを0から始める。
      switches[switch_number] |= 1 << i;    // 1 << i でシフト演算。1 << 2なら 100を表す。 
                                            // |はビット演算のor 1000 | 100 = 1100
                                            // 下からi番目の桁に1を入れる
                                            // 最終的に各スイッチの電球の対応状況が1,0で入る
    }
  }
  int remainder = 0;
  for (int i = 0; i < M; i++) {
    int x;
    cin >> x;
    remainder |= x << i;       // 下からi番目の桁に1, 0を入れる。
  }

  int ans = 0;
  for (int pattern = 0; pattern < (1 << N); pattern++) { // 1 << Nで2のN乗に等しい
    int switch_status = 0;
    for (int i = 0; i < N; i++) {
      if (pattern >> i & 1) {
        switch_status ^= switches[i];  // ^はビット演算のXOR i番目のスイッチをonにした時のスイッチ全体の状態
      }
    }
    if (switch_status == remainder) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printVec(v) printf("{"); for (const auto& i : v) { std::cout << i << ", "; } printf("}\n");
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; }
//get the biggest element.
template<typename KeyType, typename ValueType>
std::pair<KeyType,ValueType> get_max( const std::map<KeyType,ValueType>& x ) {
  using pairtype=std::pair<KeyType,ValueType>;
  return *std::max_element(x.begin(), x.end(), [] (const pairtype & p1, const pairtype & p2) {
        return p1.second < p2.second;
  });
}
using namespace std;
using P = pair<int,int>;
using ll = long long;
const ll INF = 1LL<<60;

int main() {
  ll n, a, b, c, d, e;
  cin >> n;
  vector<ll> vi(5);
  rep (i, 5) cin >> vi[i];

  ll tmp = n;
  rep (i, 5) {
    if (tmp > vi[i]) tmp = vi[i];
  }

  ll ans = 5;
  ans += (n - tmp) / tmp;
  if ( (n - tmp) % tmp != 0) ++ans;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>

using namespace std;

const long long kInf = (long long) 1e13;													

int main() {
	int n, W;
	cin >> n >> W;
	vector<long long> w(n), v(n);
	long long sum = 0;
	for (int i = 0; i < n; ++i) {
		cin >> w[i] >> v[i];
		sum += v[i];
	}
	
	vector<vector<long long>> dp(n + 1, vector<long long>(sum + 1, kInf));
	for (int i = 0; i <= n; ++i) {
		dp[i][0] = 0;
	}

	for (int val = 1; val <= sum; ++val) {
		for (int i = 1; i <= n; ++i) {
			dp[i][val] = dp[i - 1][val];
			if (val - v[i - 1] >= 0) {
				dp[i][val] = min(dp[i][val], dp[i - 1][val - v[i - 1]] + w[i - 1]);
			}
		}
	}
	
	for (int val = sum; val >= 0; --val) {
		if (dp[n][val] <= W) {
			cout << val << endl;
			break;
		}	
	}
}


Measured memory_bytes: 80632
N, M = map(int, input().split())
left = []
right = []
for i in range(M):
  a, b = map(int, input().split())
  if a == 1:
    left.append(b)
  elif b == N:
    right.append(a)
    
flag = False
left = set(left)
for r in right:
  if r in left:
    flag = True
    break
    
if flag:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 101440
import sys
import queue
sys.setrecursionlimit(10 ** 6)


class UnionFind:
    def __init__(self, n):
        self.parents = [-1] * n  # 各ノードの親を保存する。 idx 番号がノードに相当する
        self.rank = [0] * n  # 各ノードのrank　を保存する。 idx 番号がノードに相当する

    def root(self, x):  # ノードの一番上の親を返す。
        if self.parents[x] == -1:  # self.parents が変化していないならば根である。
            return x
        self.parents[x] = self.root(self.parents[x])
        return self.parents[x]

    def unite(self, x, y):
        x_root = self.root(x)
        y_root = self.root(y)

        if x_root == y_root:  # すでに同一の木に属している場合
            return

        if self.rank[x_root] < self.rank[y_root]:
            self.parents[x_root] = y_root  # 大きい木に小さい木を接続する。　self.root の処理が軽くなるから。
        elif self.rank[x_root] == self.rank[y_root]:
            self.parents[x_root] = y_root
            self.rank[y_root] += 1
        else:
            self.parents[y_root] = x_root
        return

    def is_in_same(self, x, y):  # 同じ木に属しているか確認する。
        if self.root(x) == self.root(y):
            return True
        else:
            return False


def main():
    v, e = map(int, sys.stdin.readline().strip().split())

    edges = []
    for _ in range(e):
        s, t, w = map(int, sys.stdin.readline().strip().split())
        edges.append((s, t, w))

    edges = sorted(edges, key=lambda x: x[2])  # 辺の重みで昇順ソート

    ans = 0  # 最小全域木の辺の重みの総和

    unionfind = UnionFind(v)
    for s, t, w in edges:
        if unionfind.is_in_same(s, t):
            continue
        else:
            unionfind.unite(s, t)
            ans += w

    print(ans)


if __name__ == '__main__':
    main()



Measured memory_bytes: 26392
n=int(input())
count=0
l=[]
for _ in range(n):
    d1,d2=map(int,input().split())
    if d1==d2:
        count+=1
    else:
        count=0
    l.append(count)
if l.count(3)!=0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 62292
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
const ll mod=1e+9;
typedef pair<int,int> P;
#define fi first
#define se second
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin>>n;
vector<int>a(n),b(n);
for(int i=0;i<n;i++){cin>>a.at(i);b.at(i)=a.at(i);}
sort(b.begin(),b.end(),greater<int>());
for(int i=0;i<n;i++){
    if(a.at(i)==b.at(0))cout<<b.at(1)<<endl;
    else cout<<b.at(0)<<endl;
}
}


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

int main(){
    int h,w,ch,cw,dh,dw;cin>>h>>w>>ch>>cw>>dh>>dw;
    ch--;cw--;dh--;dw--;
    vector<vector<char> > adj(h,vector<char>(w));
    rep(i,h)rep(j,w){
        cin>>adj[i][j];
    }
    auto valid=[&](int x,int y)->bool{
        return (x<h&&y<w&&x>=0&&y>=0);
    };
    
    queue<pair<int,int> > Q;
    int memo[h][w],warcost=0;
    rep(i,h)rep(j,w)memo[i][j]=-1;
    Q.push(make_pair(ch,cw));
    memo[ch][cw]=warcost;
    int dou=0;
    while(!Q.empty()){
        vector<pair<int,int> > now;
        while(!Q.empty()){
            pair<int,int> p=Q.front();Q.pop();
            now.emplace_back(make_pair(p.first,p.second));
            if(p.first==dh&&p.second==dw){dou=1;break;}
            for(int i=-1;i<=1;i++){
                int x=p.first+i,y=p.second;
                if(valid(x,y)&&memo[x][y]==-1&&adj[x][y]=='.'){
                    Q.push(make_pair(x,y));
                    memo[x][y]=warcost;
                }
            }
            for(int i=-1;i<=1;i++){
                int x=p.first,y=p.second+i;
                if(valid(x,y)&&memo[x][y]==-1&&adj[x][y]=='.'){
                    Q.push(make_pair(x,y));
                    memo[x][y]=warcost;
                }
            }
        }
        if(dou==1)break;
        warcost++;
            //warpでたどり着けるもののうち、前のcostまでで訪問しきっていないところをQに格納
        rep(i,now.size()){
            pair<int,int> p=now[i];
            for(int j=p.first-2;j<=p.first+2;j++)for(int k=p.second-2;k<=p.second+2;k++){
                if(valid(j,k)&&memo[j][k]==-1&&adj[j][k]=='.'){
                    Q.push(make_pair(j,k));
                    memo[j][k]=warcost;
                }
            }
        }
    }
    cout<<memo[dh][dw]<<endl;
    return 0;
}

Measured memory_bytes: 8536
mod=10**9+7
s=input()
dp1=[1]+[0]*12
for i in range(len(s)):
    dp2=[0]*13
    if s[i]!='?':
        p=int(s[i])
        for j in range(13):
            dp2[(j*10+p)%13]+=dp1[j]
    else:
        for p in range(10):
            for j in range(13):
                dp2[(j*10+p)%13]+=dp1[j]
    dp1=[dp2[j]%mod for j in range(13)]
print(dp1[5])


Measured memory_bytes: 43372
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

S = input()
T = input()
if T[:-1] == S:
    print("Yes")
else:
    print("No")


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

using namespace std;

int main(void) {
    string s;
    cin >> s;
    long k;
    cin >> k;

    set<string> t;
    for(char c='a'; c<='z'; c++) {
        for(long i=0; i<s.size(); i++) {
            if(s[i] == c) {
                string u;
                for(long j=0; j<k && i+j<s.size(); j++) {
                    u += s[i+j];
                    t.insert(u);
                }
            }
        }

        if(t.size() >= k)
            break;
    }

    auto it = t.begin();
    for(long i=0; i<k-1; i++)
        it++;
    cout << *it << endl;
}


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

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

const int INF = 1e9;
const ll lINF = 1e18;
const int MOD = 1e9+7;
const int SIZE = 100;


int main() {
	string s;
	cin >> s;
	char s1[] = "YAKI";
	if (s.length() < 4) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < 4; i++) {
		if (s[i] != s1[i]) {
			cout << "No" << endl;
			return 0;
		};
	}
	cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s1,s2;
  int n,m,ct,i;
  cin>>s1>>s2;
  n=s1.size();
  m=s2.size();
  for(i=0;i<n;i++)
  {
    if(s1[i]!=s2[i])
      break;
  }
  if(i==n)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define f first
#define s second
#define si(x)   scanf("%d",&x)
#define sl(x)   scanf("%I64d",&x)
#define CLR(x)  memset(x,0,sizeof(x))
#define RESET(x,a) memset(x,a,sizeof(x))
#define pi pair<int,int>
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<">value ("<<#x<<") : "<<x<<endl;

const int N=100005;
int a[N],b[N];

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(NULL);
    int t,n,m,i,j=0;
    si(n);
    for(i=0;i<n;i++)
    {
        si(a[i]);
        b[i]=a[i];
    }
    sort(b,b+n);
    for(i=0;i<n;i+=2)
    {
        int pos=lower_bound(b, b+n, a[i]) - b ;
        if(pos&1)
            j++;
    }
    printf("%d\n",j);
    return 0;
}



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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  string s; cin >> s;
  if(s[2] == s[3] && s[5] == s[4]) cout << "Yes" << endl;
  else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define si set<int>
#define stk stack<int>
#define que queue<int>
#define pb push_back
#define ff first
#define ss second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const ll mod=1e9+7;
 
using namespace std;


int main(){
	int q=1;
	//cin>>q;

	while(q--){
		ll n;
		cin>>n;

		ll ans=1000*(n/500);
		n%=500;
		ans+=5*(n/5);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MOD 1000000007
#define mp make_pair
#define ll long long
#define pb push_back
#define faster ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define debug cout<<"Debugging.."<<endl
using namespace std;
int main()
{
	faster;

	ll int tc=1;

	while(tc--)
	{
		ll int n,k;
		cin>>n>>k;
		vector<ll int> v;
		//map<long int,long int> m;
		ll int x;
		//ll int s=0;
		//ll int flag=0;
		for(ll int i=0;i<n;i++)
		{
			cin>>x;
			//m[x]++;
			v.push_back(x);

		}
		sort(v.begin(),v.end());
		int i=0,sum=0;
		while(k--)
		{
			sum+=v[i++];
		}
		cout<<sum<<endl;

	}
}




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

typedef long long ll;
typedef pair<int,int> P;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> h(n),comph(n),rmph(n+1);
    for (int i = 0;i < n;++i) cin >> h[i];
    map<int,int> mp;
    for (int i = 0;i < n;++i) mp[h[i]] = 0;
    mp[0] = 0;
    {
        int i = 0;
        for (auto& p : mp) {
            p.second = i;
            rmph[i] = p.first;
            i++;
        }
    }
    for (int i = 0;i < n;++i) comph[i] = mp[h[i]];
    int s = mp.size();
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(k+1,vector<ll>(s,1LL<<60)));
    dp[0][0][0] = 0;
    for (int i = 0;i < n;++i) {
        for (int j = 0;j < k+1;++j) {
            int t = comph[i];
            for (int l = t;l < s;++l) dp[i+1][j][t] = min(dp[i+1][j][t],dp[i][j][l]);
            for (int l = 0;l < comph[i];++l) dp[i+1][j][t] = min(dp[i+1][j][t],dp[i][j][l]+h[i]-rmph[l]);
        }
        for (int j = 0;j < k;++j) for (int l = 0;l < s;++l) dp[i+1][j+1][l] = min(dp[i+1][j+1][l],dp[i][j][l]);
    }
    ll ans = 1LL<<60;
    for (int i = 0;i < k+1;++i) for (int j = 0;j < s;++j) ans = min(ans,dp[n][i][j]);
    cout << ans << endl;
}

Measured memory_bytes: 216832
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

const int INF = 1001001001;

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    for(int i = 0; i < N; ++i){
        cin >> V[i];
    }
    
    int limit = min(N, K);
    
    int ans = 0;
    for(int i = 0; i <= limit; ++i){
        for(int j = 0; j <= limit - i; ++j){
            
            priority_queue<int, vector<int>, greater<int>> que;
            for(int k = 0; k < i; ++k){
                que.push(V[k]);
            }
            for(int k = N - 1; k > N - 1 - j; --k){
                que.push(V[k]);
            }
            int delete_cnt = K - (i + j);
            
            int sum = 0;
            while(!que.empty()){
                int temp = que.top();
                que.pop();
                
                if(temp < 0 && delete_cnt > 0){
                    delete_cnt--;
                    continue;
                }
                
                sum += temp;
            }
            
            ans = max(ans, sum);
        }
    }
    
    cout << ans << endl;
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int A, B, C, K;
	cin >> A >> B >> C >> K;
	int mx = max({ A, B, C });
	int ans = A + B + C;
	ans -= mx;
	mx *= pow(2, K);
	cout << ans + mx;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string>
#include<stdexcept>
#include<stdio.h>
#include<queue>
#include<stack>
#include <cmath>
#include<bits/stdc++.h>
#include<math.h>
#define cinf(n,x) for(int i=0;i<n;i++) cin >> x[i];
#define pi pair<int,int> 
using namespace std;
using ll = long long;
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 int MAX = 3000;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];
void COMint(){ //前処理
    fac[0]=fac[1]=1; //階乗
    finv[0]=finv[1]=1; //階乗の逆元
    inv[1]=1; //逆元

    for(int i=2;i<MAX;i++){
        fac[i] = fac[i-1]*i % MOD;
        inv[i] = MOD - inv[MOD % i]*(MOD/i) % MOD;
        finv[i] = finv[i-1]*inv[i] % MOD;
    }
}
ll COM(int n, int k){ //二項係数の計算
        if(n<k) return 0;
        if(n<0 || k<0) return 0;
        return fac[n]*(finv[k]*finv[n-k] % MOD) % MOD; // n! * (k!)^-1 * ((n-k)!)^-1
}
int main(){
    int n; cin >> n;
    string s[n];
    ll ans = 0;
    map<string,int> T;
    for(int i=0;i<n;i++){
      cin >> s[i];
      sort(s[i].begin(),s[i].end());
      ans += T[s[i]];
      T[s[i]]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 18176
#include <stdio.h>

int main(){
    int group[12] = {1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y;
    scanf("%d %d", &x, &y);
    if(group[x - 1] == group[y - 1]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;

bool hantei(vector<vector<int>> &ten, int i){

  int x = max (ten.at(i+1).at(1) - ten.at(i).at(1), -ten.at(i+1).at(1) + ten.at(i).at(1));
  int y = max (ten.at(i+1).at(2) - ten.at(i).at(2), -ten.at(i+1).at(2) + ten.at(i).at(2));
  int t = ten.at(i+1).at(0) - ten.at(i).at(0);
  if ( (max(x,y) <= t) && ( (x+y+t) % 2 == 0) ) 
    return 1;
  else 
    return 0;
}



int main()
{
  int N;
  cin >> N;
  vector<vector<int>> ten (N+1,vector<int>(3));
  
  ten.at(0).at(0)=0, ten.at(0).at(1)=0, ten.at(0).at(2)=0;

  for (int i=1; i<N+1; i++)
    cin >> ten.at(i).at(0) >> ten.at(i).at(1) >> ten.at(i).at(2);
  
  bool flag = 1;
  for (int i=0; i<N; i++){
    if( hantei(ten,i) == 0 ){
      flag = 0;
      break;
    }
  }
  if (flag)
    cout << "Yes";
  else
    cout << "No";
  
  
  return 0;
}

Measured memory_bytes: 5760
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
const int inf=0x3f3f3f3f;
int n,m,t;
struct node{
	int c,s,f;
}edge[550];
int main(){
	int i,j;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d%d",&edge[i].c,&edge[i].s,&edge[i].f);
	}
	for(j=1;j<n;j++){
		long long sum=0;
		for(i=j;i<n;i++){
			if(edge[i].s>sum)
				sum=edge[i].s;
			while(sum%edge[i].f!=0)
				sum++;
			sum+=edge[i].c;
		}
		printf("%lld\n",sum);
	}
	printf("0\n");
	return 0;
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N =100011;
int vis[N];
int main()
{
    int k;
    scanf("%d",&k);
    memset(vis,0,sizeof(vis));
    queue<int>q;
    q.push(1);
    vis[1]=1;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        for(int i=0;i<=9;i++)
        {
            int p=(x*10+i)%k;
            if(vis[p]==0||vis[x]+i<vis[p])
            {
                vis[p]=vis[x]+i;
                q.push(p);
            }
        }
    }
    printf("%d\n",vis[0]);
    return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <boost/optional.hpp>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0, i##_MACRO = (n); i < i##_MACRO; i++)
#define RANGE(i, a, b) for(int i = (a), i##_MACRO = (b); i < i##_MACRO; i++)
#define EACH(e, a) for(auto&& e : a)
#define ALL(a) std::begin(a), std::end(a)
#define RALL(a) std::rbegin(a), std::rend(a)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)
#define INT(x) (static_cast<int>(x))

using namespace std;

using ll = long long;
using VI = vector<int>;
using VI2D = vector<vector<int>>;

constexpr int INF = 2e9;
constexpr double EPS = 1e-10;
constexpr double PI = acos(-1.0);

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

template <typename T>
constexpr int sign(T x) {
	return x < 0 ? -1 : x > 0 ? 1 : 0;
}

template <>
constexpr int sign(double x) {
	return x < -EPS ? -1 : x > EPS ? 1 : 0;
}

template <typename T, typename U>
constexpr void chmax(T& m, U x) {
	m = max(m, x);
}

template <typename T, typename U>
constexpr void chmin(T& m, U x) {
	m = min(m, x);
}

template <typename T>
constexpr T square(T x) {
	return x * x;
}

int main() {
	int k, a, b;
	cin >> k;
	cin >> a >> b;
	RANGE(i, a, b + 1) {
		if(i % k == 0) {
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
	return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>

using namespace std;

int main() {
    
    int a, b, q;
    cin >> a >> b >> q;
    
    vector<long long> sa(a);
    vector<long long> tb(b);
    
    for (int i = 0; i < a; ++i)
    {
        cin >> sa[i];
    }
    
    for (int i = 0; i < b; ++i)
    {
        cin >> tb[i];
    }
    
    sort(sa.begin(), sa.end());
    sort(tb.begin(), tb.end());
    
    for (int i = 0; i < q; ++i)
    {
        long long x;
        cin >> x;
        
        long long dist = 1e12;
        
        auto itrs = lower_bound(sa.begin(), sa.end(), x);
        long long s;
        if (itrs == sa.end())
        {
            s = *(itrs - 1);
        }
        else
        {
            s = *itrs;
        }
        
        auto itrt = lower_bound(tb.begin(), tb.end(), s);
        long long t;
        
        if (itrt == tb.end())
        {
            t = *(itrt - 1);
        }
        else
        {
            t = *itrt;
        }
        
        dist = min(dist, (abs(x - s) + abs(s - t)));
        
        if (itrt != tb.begin())
        {
            t = *(itrt - 1);
            dist = min(dist, (abs(x - s) + abs(s - t)));
        }
        
        if (itrs != sa.begin())
        {
            s = *(itrs - 1);
            
            itrt = lower_bound(tb.begin(), tb.end(), s);
            if (itrt == tb.end())
            {
                t = *(itrt - 1);
            }
            else
            {
                t = *itrt;
            }
            
            dist = min(dist, (abs(x - s) + abs(s - t)));
            
            if (itrt != tb.begin())
            {
                t = *(itrt - 1);
                dist = min(dist, (abs(x - s) + abs(s - t)));
            }
            
        }
        
        itrt = lower_bound(tb.begin(), tb.end(), x);
        if (itrt == tb.end())
        {
            t = *(itrt - 1);
        }
        else
        {
            t = *itrt;
        }
        
        itrs = lower_bound(sa.begin(), sa.end(), t);
        if (itrs == sa.end())
        {
            s = *(itrs - 1);
        }
        else
        {
            s = *itrs;
        }
        
        dist = min(dist, (abs(x - t) + abs(s - t)));
        
        if (itrs != sa.begin())
        {
            s = *(itrs - 1);
            dist = min(dist, (abs(x - t) + abs(s - t)));
        }
        
        if (itrt != tb.begin())
        {
            t = *(itrt - 1);
            
            itrs = lower_bound(sa.begin(), sa.end(), t);
            if (itrs == sa.end())
            {
                s = *(itrs - 1);
            }
            else
            {
                s = *itrs;
            }
            
            dist = min(dist, (abs(x - t) + abs(s - t)));
            
            if (itrs != sa.begin())
            {
                s = *(itrs - 1);
                dist = min(dist, (abs(x - t) + abs(s - t)));
            }
        }
        
        cout << dist << endl;
        
    }
    
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < int(n); i++)

lint gcd(lint a, lint b){
    if(b){
        return gcd(b, a % b);
    }else{
        return a;
    }
}

int main(){
    int N;
    cin >> N;
    lint p[N];
    rep(i, N){
        cin >> p[i];
    }
    set<lint> lcms;
    rep(i, (1 << N)){
        if(!i){
            continue;
        }
        lint lcm = 1;
        rep(j, N){
            if((i >> j) & 1){
                lcm = lcm / gcd(lcm, p[j]) * p[j];
            }
        }
        lcms.insert(lcm);
    }
    cout << lcms.size() << endl;
}





Measured memory_bytes: 4088
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define Max(a,b) a=max(a,b);
#define Min(a,b) a=min(a,b);
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 100010
ll x[N],y[N],n;
bool F(ll m){
    ll mx=-mod,my=-mod,sx=mod,sy=mod;
    lol(i,n){
	Max(mx,x[i]);Max(my,y[i]);
	Min(sx,x[i]);Min(sy,y[i]);
    }
    if(mx-sx<=m){
	lol(i,n)if(sy+m<y[i]&&y[i]<my-m)return 0;
	return 1;
    }
    if(my-sy<=m){
	lol(i,n)if(sx+m<x[i]&&x[i]<mx-m)return 0;
	return 1;
    }
    ll mw=-mod,mh=-mod,sw=mod,sh=mod;
    lol(i,n){
	if(x[i]>sx+m||y[i]>sy+m){
	    Max(mw,x[i]);Max(mh,y[i]);
	    Min(sw,x[i]);Min(sh,y[i]);
	}
    }
    return (mw-sw<=m&&mh-sh<=m);
}
ll Solve(){
    ll l=0,r=mod,m;
    while(l<r-1){
	m=(l+r)/2;
	if(F(m))r=m;
	else l=m;
    }
    return r;
}
void Flipx(){lol(i,n)x[i]=-x[i];}
void Flipy(){lol(i,n)y[i]=-y[i];}
int main(){
    cin>>n;
    lol(i,n){
	ll a,b;cin>>a>>b;
	x[i]=a+b,y[i]=a-b;
    }
    ll ans=mod;
    Min(ans,Solve());
    Flipx();
    Min(ans,Solve());
    Flipy();
    Min(ans,Solve());
    Flipx();
    Min(ans,Solve());
    cout<<ans<<endl;
    return 0;
}



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

int main(){
  int x;
  cin >> x;
  for(int i = 1; i <= x; i++){
    if(100 * i <= x && 105 * i >= x){
      cout << 1 << endl;
      return 0;
    }
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int x,a;
	scanf("%d%d", &x, &a);
	PRINTD(x < a ? 0 : 10);
}


Measured memory_bytes: 128
/**
 * @file A-StillTBD.cpp
 * @author murnana
 * @brief A - Still TBD
 * @date 2019-02-24
 * 
 * @copyright Copyright (c) 2019
 * 
 */

#include <iostream>
#include <array>
#include <string>
#include <stdio.h>
using namespace std;

/**
 * @brief Entry point
 * 
 * @return int 
 */
int main()
{
    // 文字列Sを取得
    string S;
    cin >> S;

    // 文字列Sをスラッシュ「/」で区切る
    array<string, 3> date;
    const string separator("/");
    const auto separatorLength = separator.length();
    auto offset = string::size_type(0);
    for (auto i = 0; i < 3; ++i)
    {
        auto pos = S.find(separator, offset);
        if (pos == string::npos)
        {
            date[i] = S.substr(offset);
        }
        else
        {
            date[i] = S.substr(offset, pos - offset);
            offset = pos + separatorLength;
        }
        // cerr << "date[" << i << "]: " << date[i] << endl;
    }

    // 西暦から比較
    if (2019 < atoi(date[0].c_str()))
    {
        cout << "TBD" << endl;
    }
    else if (4 < atoi(date[1].c_str()))
    {
        cout << "TBD" << endl;
    }
    else if (30 < atoi(date[2].c_str()))
    {
        cout << "TBD" << endl;
    }
    else
    {
        cout << "Heisei" << endl;
    }

    return 0;
}


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

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

  int N, x;
  cin >> N >> x;

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

  int ans = max(0LL, a[0]-x);
  a[0] = min(a[0], x);
  for ( int i = 1; i < N; i++ ) {
    ans += max(0LL, a[i]-(x-a[i-1]));
    a[i] = min(a[i], x-a[i-1]);
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3972