akhauriyash/Code-Regression huggingface dataset:
// 2020-09-28 23:55:44
// clang-format off
#include <bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
// #include <atcoder/convolution>
// #include <atcoder/dsu>
// #include <atcoder/fenwicktree>
// #include <atcoder/lazysegtree>
// #include <atcoder/math>
// #include <atcoder/maxflow>
// #include <atcoder/mincostflow>
// #include <atcoder/modint>
// #include <atcoder/scc>
// #include <atcoder/segtree>
// #include <atcoder/string>
// #include <atcoder/twosat>
// #include <atcoder/all>
// using namespace atcoder;

// clang-format on
void answer() {
  int n, z, w;
  cin >> n >> z >> w;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int ans = abs(w - a[n - 1]);
  if (n >= 2) chmax(ans, abs(a[n - 2] - a[n - 1]));
  cout << ans << '\n';
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3668
n = gets.to_i()
a = gets.split().map!.with_index{|x,i| x.to_i()-i}.sort!()
h = (n/2).to_i()
b = a[h]
if n > 1
  s = b*h - a[0,h].inject(:+) + a[h,n-h].inject(:+) - b*(n-h)
else
  s = 0
end
puts s

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

int main() {
	string s1, s2, s3;
	cin >> s1 >> s2 >> s3;
	if (s1[s1.size() - 1] == s2[0] && s2[s2.size() - 1] == s3[0])
		cout << "YES" << endl;
	else
		cout << "NO" <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int h,w;
	cin >> h >> w;
	string s;
	for(int i=0;i<w+2;i++){
		cout << "#";
	}
	cout << endl;
	for(int i=0;i<h;i++){
		cin >> s;
		cout << "#" << s << "#" << endl;
	}
	for(int i=0;i<w+2;i++){
		cout << "#";
	}
	cout << endl;
    return 0;
}


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

int main() {
  int n;
  

  cin >> n;
  int L[n];
  for(int i=0; i<n; i++){
    cin >> L[i];
  }
  int ans = 0;
  for(int i=0;i<n-2;i++){
    for(int j=i+1; j<n-1; j++){
      for(int k=j+1;k<n;k++){
        if((L[i]+L[j])>L[k]){
          if((L[i]+L[k])>L[j]){
            if((L[k]+L[j])>L[i]){
              if((L[i]!=L[j]) && (L[i]!=L[k]) && (L[k] != L[j])) ans++;
            }
          }

        }
      }
    }
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 3668
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char const *argv[]) {
    double n,k;
    std::cin >> n >> k;
    // 2^mother2 >= k
    int mother2 = int(log2(k));
    if (log2(k) != double(int(log2(k)))) {
        mother2++;
    }

    double children = 0.0;
    for (int i = 1; i <= min(n, k-1); i++) {
        int child = int(log2(k/i));
        if (log2(k/i) != double(int(log2(k/i)))) {
            child++;
        }

        children += pow(2,mother2-child);
    }

    for (int i = min(n, k-1)+1; i <= n; i++) {
        children += pow(2,mother2);
    }

    double ans = children / pow(2,mother2) / n;

    std::cout << std::setprecision(12) << ans << '\n';

    return 0;
}



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

int main()
{
int i;
int j;
int N;

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

	cin >> N;

	i = 0;
	while( i * 4 <= N )
	{
		if( ( N - i * 4 ) % 7 == 0 )
		{
			cout << "Yes" << endl;

			return 0;
		}

		i++;
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
N, K = gets.split.map(&:to_i)
A    = gets.split.map(&:to_i)

x = 0
b = 1 << 39
half = (N + 1) / 2
while b > 0
  if (x | b) <= K && A.count{|a| a & b > 0} < half 
    x += b   
  end
  b >>= 1
end
puts A.inject(0) {|tot, a| tot + (x ^ a)}

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

using namespace std;

using ll = long long;

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

    int a, b, k;
    cin >> a >> b >> k;
    for (int i = min(a, b); 0 <= i; --i) {
        if ((a % i == 0) && (b % i == 0)) {
            --k;
            if (k == 0) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}


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

using namespace std;

int main() {
  long long a, b, c, k;
  cin >> a >> b >> c >> k;

  if (k % 2 == 0) {
    cout << a - b << endl;
  } else {
    cout << b - a << endl;
  }
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	static  char exchange(char c) {
		if(Character.isUpperCase(c)) {
			return Character.toLowerCase(c);
		}
		if(Character.isLowerCase(c)) {
			return Character.toUpperCase(c);
		}
		return c;
	}
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			String line = sc.nextLine();
			// 文字列を連結しながら生成するときは StringBuilderをつくる
			StringBuilder sb = new StringBuilder();
			for(int i = 0; i < line.length(); i++) {
				sb.append(exchange(line.charAt(i)));
			}
			line = sb.toString();  // 連結した文字列をえる
			System.out.println(line);
		}
	}
}



Measured memory_bytes: 26400
N = int(input())
Xs = list(map(int, input().split()))
s = sum(Xs)
s2 = sum([X*X for X in Xs])
rs = []
for P in range(1, 100+1):
  r = N*P*P-2*s*P+s2
  rs.append(r)
r = min(rs)
print(r)


Measured memory_bytes: 3060
def main():
    N = int(input())
    a = list(map(int, input().split()))
    l = [-1] * N
    s = []
    for i, v in enumerate(a):
        while s and  s[-1][0] > v:
            s.pop()
        if s:
            l[i] = s[-1][1]
        s.append((v, i))
    r = [N] * N
    s = []
    for i, v in (enumerate(reversed(a))):
        while s and s[-1][0] > v:
            s.pop()
        if s:
            r[N - i - 1] = s[-1][1]
        s.append((v, N - i - 1))
    ans = 0
    for i in range(N):
        rr = r[i] - 1
        ll = l[i] + 1
        ans += ((rr - i + 1) * (i - ll) + rr - i)*a[i] + a[i]
    return ans
print(main())


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

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

    long long ans = 0, under = 0, over = 0;
    for (int i = s.size() - 1; i >= 0; i--) {
        if (s[i] == '0') {
            over += 9;
        } else {
            under = max(s[i] - '0' - 1 + over, s[i] - '0' + under);
            over += 9;
        }
    }
    cout << under << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  rep(i,h) cin >> s[i];
  int ans = 0;
  rep(si,h)rep(sj,w) {
    if (s[si][sj] == '#') continue;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    queue<P> q;
    auto update = [&](int i, int j, int x) {
      if (dist[i][j] != INF) return;
      dist[i][j] = x;
      q.push(P(i,j)); // .emplace(i,j)
    };
    update(si,sj,0);
    while (!q.empty()) {
      int i = q.front().first;
      int j = q.front().second; q.pop();
      rep(dir,4) {
        int ni = i+di[dir], nj = j+dj[dir];
        if (ni<0||ni>=h||nj<0||nj>=w) continue;
        if (s[ni][nj] == '#') continue;
        update(ni, nj, dist[i][j]+1);
      }
    }
    rep(i,h)rep(j,w) {
      if (dist[i][j] == INF) continue;
      ans = max(ans, dist[i][j]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3528
<?php
fscanf(STDIN, "%d %d", $A, $B);

echo f($A-1) ^ f($B);

function f($n) {
	switch(fmod($n, 4)) {
	case 0:
		return $n;
	case 1:
		return 1;
	case 2:
		return $n+1;
	case 3:
		return 0;
	}

	return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;

ll n, a, b;
vector<ll> h(100010);

bool check(ll x) {
  ll cnt = 0;
  REP(i, n) {
    ll tmp = h[i] - x * b;
    if (tmp <= 0) continue;
    cnt += (tmp + a - b - 1) / (a - b);
  }
  return cnt <= x;
}

int main() {
  cin >> n >> a >> b;
  REP(i, n) cin >> h[i];

  ll lb = 0, ub = 1000000000;
  while (ub - lb > 1) {
    ll mid = (lb + ub) / 2;
    if (check(mid)) {
      ub = mid;
    } else {
      lb = mid;
    }
  }
  cout << ub << endl;
  return 0;
}

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

int const MAXSL = 1e5;
int const MAXQ = 2e5;
int Q, T, F;
char C;
bool reverse;
int main() {
  reverse = false;
  std::string s, pre, post;
  pre.reserve(Q+1); post.reserve(Q+1);
  std::cin >> s >> Q;
  for(int i = 0; i < Q; ++i) {
    std::cin >> T;
    if(T==1) reverse = !reverse;
    else {
      std::cin >> F >> C;
      if(reverse == (F==1)) post += C;
      else pre += C;
    }
  }
  if(reverse) {
    std::reverse(s.begin(), s.end());
    std::reverse(post.begin(), post.end());
    std::cout << post << s << pre << std::endl;
  } else {
    std::reverse(pre.begin(), pre.end());
    std::cout << pre << s << post << std::endl;
  }
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FOR(n) for(int i=0;i<n;i++)
#define For(i,n) for(int i=0;i<n;i++)
#define ll long long
ll mob=1000000007;
int main()
{map<string,int> m;
 m["SUN"]=0;
 m["MON"]=1;
 m["TUE"]=2;
 m["WED"]=3;
 m["THU"]=4;
 m["FRI"]=5;
 m["SAT"]=6;
 string h;
 getline(cin,h);
 cout<<7-m[h];
return 0;
}

Measured memory_bytes: 256
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

N, Q = map(int, input().split())
S = input()

# count[i] ... number of 'AC' in S[:i]
count = [0] * (N + 1)
for i in range(2, N + 1):
    if S[i - 2:i] == 'AC':
        count[i] = count[i - 1] + 1
    else:
        count[i] = count[i - 1]
for _ in range(Q):
    l, r = map(int, input().split())
    print(count[r] - count[l])



Measured memory_bytes: 78676
#include <iostream>
#include <cassert>
#include <vector>
#include <algorithm>
#include <climits>

#include <stack>
#include <queue>
// #include <deque>
#include <set>
#include <map>
// #include <string>
// #include <unordered_set>
// #include <unordered_map>

#include <tuple>
// #include <cmath>
// #include <numeric>

using namespace std;


typedef long long ll;
typedef pair<long,long> pll;
typedef pair<int,int> pii;
typedef pair<int,long> pil;
typedef pair<long,int> pli;
typedef pair<long long, long long> pllll;
typedef pair<long long, int> plli;
typedef pair<int,long long> pill;
typedef vector<vector<long long>> vvll;
typedef vector<vector<long>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<long long> vll;

#define emplace_back pb
const char el = '\n';

/*
Edge cases:


*/




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

    int n; cin>>n;
    string s; cin>>s;


    // num[i] is a vector {x,y,z} where x = # R's in s[0]...s[i], y = # G's, etc.
    vector< vector< int> > num(n, vector<int>(3,0) );

    vector<int> temp{0,0,0};

    map<char,int> m{};
    m['R']=0, m['G']=1, m['B']=2;

    for (int i = 0; i<n; ++i) {
        if (s[i]=='R') {
            ++temp[0];
        } else if (s[i]=='G') {
            ++temp[1];
        } else {
            ++temp[2];
        }

        num[i] = temp;
    }


    ll ret = 0;
    for (int i = 0; i<n; ++i) {
        for (int k = i+2; k<n; ++k) {

            if (s[i]==s[k]) continue;

            char thirdletter;
            //identify the letter that s[i], s[k] is NOT
            set<char> t{'R','G','B'};
            t.erase(s[i]), t.erase(s[k]);


            thirdletter = *t.begin();

            int thirdlettercode = m[thirdletter];

            int numbetween = num[k-1][thirdlettercode] - num[i][thirdlettercode];

            ret += (ll) numbetween;


            //remove the evenly spaced one;
            if ( (k-i)%2 == 0 && s[ (i+k)/2 ]==thirdletter) {
                --ret;
            }

            
        }
    }



    cout << ret << el;


}

Measured memory_bytes: 3832
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

typedef struct edge{ll s,c;}E;
int csort(const void*a,const void*b){
	ll p=(*(E*)a).c,q=(*(E*)b).c;
	return p<q?-1:p>q?1:0;
}

ll n,m;
E a[100010];
int main(){
	scanf("%lld%lld",&n,&m);
	rep(i,0,n){
		ll p,q;
		scanf("%lld%lld",&p,&q);
		a[i].s=q;
		a[i].c=p;
	}
	qsort(a,n,sizeof(E),csort);
	
	ll ans=0;
	for(int i=0;m>0;i++){
		ans+=min(m,a[i].s)*a[i].c;
		m-=min(m,a[i].s);
	}
	printf("%lld\n",ans);
}

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

int main(){
   int N;
   int min,max;
   long sum;
   int temp;
   
   cin >> N;
   cin >> temp;
   min = temp; max = temp; sum = temp; 
   for(int i = 1;i < N; i++){
       cin >> temp;
       if(min > temp) min = temp;
       if(max < temp) max = temp;
       sum += temp;    
   } 
   
   cout << min << " " << max << " " << sum << endl;
   return 0;
}

Measured memory_bytes: 1168
// Contest.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <set>

using namespace std;

int main()
{
	int x;
	cin >> x;
	if (x < 1200)puts("ABC");
	else puts("ARC");
	return 0;
}



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

typedef long long int ll;

int main(){
  int N;
  string s , t;
  cin >> N >> s >> t;
  int cnt = 0;
  for(int i = 0;i < N+1;i++){
     if(s.substr(N-i,i) == t.substr(0,i)){
        cnt = i;
     }
  }
  cout << 2 * N - cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
S = [0]*N
C = [0]*4
for i in range(N):
    S[i] = input()
    if S[i] =="AC":
        C[0] += 1
    elif S[i] =="WA":
        C[1] += 1
    elif S[i] =="TLE":
        C[2] += 1
    elif S[i] =="RE":
        C[3] += 1
        
print("AC x",str(C[0]))
print("WA x",str(C[1]))
print("TLE x",str(C[2]))
print("RE x",str(C[3]))

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

typedef long long ll;

int main(void)
{
    int MAX = 101000;
    vector<bool> is_prime(MAX, true);
    is_prime[0] = is_prime[1] = false;
    rep(i, MAX)
    {
        if(!is_prime[i]) continue;
        for(int j = i*2; j < MAX; j += i) is_prime[j] = false;
    }

    vector<bool> a(MAX, false);
    rep(i, MAX)
    {
        if(i%2 == 0) continue;
        if(is_prime[i] && is_prime[(i+1)/2]) a[i] = true;
    }

    vector<int> s(MAX+1, 0);
    rep(i, MAX)
    {
        s[i+1] = s[i];
        if(a[i]) s[i+1]++;
    }

    int q;
    cin >> q;
    rep(i, q)
    {
        int l, r;
        cin >> l >> r;
        cout << s[r+1] - s[l] << endl;
    }

    return 0;
}

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

using namespace std;

int main() {
  int N;
  cin >> N;
  
  string S;
  cin >> S;
  
  int count = 1;
  char cur_char = S.at(0);
  for (int i = 1; i < N; i++) {
    if (S.at(i) != cur_char) {
      count++;
      cur_char = S.at(i);
    }

  }
  cout << count << endl;
  
    
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

void trace(int a[], int n) {
    for (int i = 0; i < n; i++) {
        if (i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
}

// bubble sort
int main() {
    int n;
    cin >> n;
    int r[n];

    for (int i = 0; i < n; i++) cin >> r[i];
    bool flag = true;
    int t, counter = 0;
    while (flag) {
        flag = false;
        for (int i = n - 1; i >= 1; i--) {
            if (r[i] < r[i - 1]) {
                t = r[i];
                r[i] = r[i - 1];
                r[i - 1] = t;
                counter++;
                flag = true;
            }
        }
    }

    trace(r, n);
    cout << counter << endl;
    return 0;
}



Measured memory_bytes: 3096
fn build_loop(n: usize, ps: &mut Vec<usize>) -> Vec<Vec<usize>> {
    let mut ret = Vec::new();
    let mut idx = 0;
    while idx < n {
        if ps[idx] == 0 {
            idx += 1;
            continue;
        }
        let mut tmp = vec![];
        let mut tmp_idx = idx;
        while ps[tmp_idx] != 0 {
            let next = ps[tmp_idx] - 1;
            tmp.push(next);
            ps[tmp_idx] = 0;
            tmp_idx = next;
        }
        ret.push(tmp);
    }

    ret
}

#[test]
fn test_build_loop() {
    let mut tmp = vec![3, 1, 2];
    let ls = build_loop(3, &mut tmp);
    assert_eq!(ls, vec![vec![2, 1, 0]]);
    let mut tmp = vec![3, 4, 1, 2];
    let ls = build_loop(4, &mut tmp);
    assert_eq!(ls, vec![vec![2, 0], vec![3, 1]]);
}

fn solve(k: usize, l: Vec<i64>) -> i64 {
    // println!("{:?}", l);
    let len = l.len();
    let li64 = len as i64;
    let mut max = None;

    let mut acc = vec![0; len + 1];
    for idx in 0..len {
        acc[idx + 1] = acc[idx] + l[idx];
    }
    let sum = acc[len];

    for a in 0..len {
        for b in 0..len {
            // println!("from {} to {}", a, b);
            let (mut ans, dist) = if a < b {
                (acc[b + 1] - acc[a + 1], b - a)
            } else if a == b {
                (sum, len)
            } else {
                (acc[len] - acc[a + 1] + acc[b + 1], len + b - a)
            };
            if dist > k {
                continue;
            }

            if sum > 0 {
                let rest = (k - dist) as i64;
                let loop_cnt = rest / li64;
                ans += loop_cnt * sum
            }
            // println!("max = {:?}: ans = {}", max, ans);
            match max {
                Some(a) => {
                    if a < ans {
                        max = Some(ans)
                    }
                }
                None => max = Some(ans),
            }
        }
    }
    max.unwrap()
}

fn main() {
    use proconio::input;
    input!(n: usize, k: usize);
    input!(mut ps: [usize; n]);
    input!(cs: [i64; n]);
    let ls = build_loop(n, &mut ps);

    let mut max = None;
    for l in ls {
        let arr = l.iter().map(|&idx| cs[idx]).collect();
        let a = solve(k, arr);
        match max {
            Some(b) => {
                if b < a {
                    max = Some(a);
                }
            }
            None => max = Some(a),
        }
    }

    println!("{}", max.unwrap());
}


Measured memory_bytes: 2436
// #include <bits/stdc++.h>
// #include <vecot>
// using namespace std;
//
// int main() {
//   int H, W;
//   cin >> H >> W;
//   vector<vector<int>> array(H, vector<int> (W));
//
//   for(int i = 0; i < H; i++){
//     for(int j = 0; j < W; j++) {
//       cin >> array[i][j];
//     }
//   }
//
//
//   for(int i = 0; i < H; i++){
//     for(int j = 0; j < W; j++) {
//       if(array[i][j] == "")
//     }
//   }

  // ここからプログラム写経　　

#include  <iostream>
#include <string>
#include <vector>
using namespace std;

int main() {
  int h;
  cin >> h;
  int w;
  cin >> w;
  vector<string> a(h);
  for(int i = 0; i < h; i++){
    cin >> a[i];
  }

  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for(int i = 0; i  < h; i++){
    for(int j = 0; j < w; j++){
      if(a[i][j] =='#'){
        row[i] = true;
        col[j] = true;
      }
    }
  }

  for(int i =0; i <  h; i++){
    if(row[i]){
      for(int  j = 0; j < w; j++){
        if(col[j]){
          cout << a[i][j];
        }
      }
      cout << endl;
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,i,k,q,d,m;
    map<long long,long long>a;
    cin>>n>>k>>q;
    for(i=0;i<q;i++)
    {
        cin>>m;
        a[m]++;
    }
    for(i=1;i<=n;i++)
    {
        d=k-(q-a[i]);
        if(d<=0)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define endl "\n"
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);

    string s;
    cin >> s;

    if ((s[0]=='7')||(s[1]=='7')||(s[2]=='7'))
    {
        cout << "Yes" << endl;
    }    
    else
    {
        cout << "No" << endl;
    }

    return 0;    
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
inline int read(){
	char c=getchar();while (c!='-'&&(c<'0'||c>'9'))c=getchar();
	int k=1,kk=0;if (c=='-')c=getchar(),k=-1;
	while (c>='0'&&c<='9')kk=kk*10+c-'0',c=getchar();return kk*k;
}using namespace std;
void write(int x){if (x<0)putchar('-'),x=-x;if (x/10)write(x/10);putchar(x%10+'0');}
void writeln(int x){write(x);puts("");}
int n,t,x,y,tt,xx,yy;
signed main(){
	n=read();for (int i=1;i<=n;i++){
		tt=read();xx=read();yy=read();
		if (abs(xx-x)+abs(yy-y)>tt-t||((abs(xx-x)+abs(yy-y))&1)!=((tt-t)&1)){
			puts("No");return 0;
		}t=tt;x=xx;y=yy;
	} puts("Yes");
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <list>
#include <cmath>
using namespace std;
using ll = long long;
const int INF = 1e9;


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

    vector<ll> v(K, 0);
    for(ll i=1; i<=N; ++i) {
        v[i%K]++;
    }

    ll res=0;
    res += (v[0]*v[0]*v[0]);

    if(K%2==0) {
        res += (v[K/2]*v[K/2]*v[K/2]);
    }

    cout << res << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
    // N+1マス左右　0,1.....N
    //自分の位置X
    //0またはNでゴール
    
    
    int N,M,X;
    scanf("%d %d %d",&N,&M,&X);
    int Ai[M];
    int costN = 0;
    int cost0 = 0;
    for(int i = 0;i<M;i++){
        scanf("%d",&Ai[i]);
        if(Ai[i]<X){
            //0へ向かう時のコスと
            cost0++;
        }else{
            costN++;
        }
        
    }
    if(cost0 < costN){
        printf("%d",cost0);
    }else{
        printf("%d",costN);
    }
    return 0;
    
}


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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    int n;
    cin >> n;
    int m;
    cin >> m;
    int fir[n+1]={},sec[n+1]={};
    for(int i=0;i<m;i++){
        int x,y;
        cin >> x >> y;
        if(x==1)fir[y]=1;
        if(y==n)sec[x]=1;
    }
    for(int i=2;i<n;i++){
        if(fir[i]&&sec[i]){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    if(s == "ABC") puts("ARC");
    else puts("ABC");
    return 0;
}

Measured memory_bytes: 3624
//S.G.N.//
#include <bits/stdc++.h>
using namespace std;
typedef vector< long long > vi;
typedef long long ll;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define fr(n) for(ll i=0;i<n;i++)
#define tr(a) for(auto it=a.begin();it!=a.end();it++)
#define N 998244353445 
#define PI 3.1415926535897932384
#define F first
#define S second
#define mp make_pair
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod 1000000007
void solve()
{
 ll n,d;
 cin>>n>>d;
 ll ans=0;
 fr(n)
 {
  ll a,b;
  cin>>a>>b;
  if((a*a+b*b)<=(d*d))
    ans++;
 }
 cout<<ans;
}
int main()
{
  
  #ifndef ONLINE_JUDGE
     * freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
  FAST
  ll test;
test=1;
  //cin>>test;
  while(test--)
  {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3640
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

int a,b,c;

int main(){
    cin>>a>>b>>c;
    if(a==b)cout<<c<<endl;
    if(c==b)cout<<a<<endl;
    if(a==c)cout<<b<<endl;
}


Measured memory_bytes: 256
import heapq
from collections import defaultdict
h, w = map(int, input().split())
cnt = defaultdict(int)
for _ in range(h):
    for a in input():
        cnt[a] -= 1
blocks = list(cnt.values())
heapq.heapify(blocks)

tasks = []
tasks.extend([4]*((h//2)*(w//2)))
tasks.extend([2]*((h % 2)*(w//2)+(w % 2)*(h//2)))
if h & 1 and w & 1:
    tasks.append(1)


for k in tasks:
    v = -heapq.heappop(blocks)
    if v < k:
        break
    x = -(v-k)
    if x == 0:
        continue
    heapq.heappush(blocks, x)
print('Yes' if not blocks else 'No')

Measured memory_bytes: 3316
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int X;
    cin >> X;
    if (X == 7 || X == 5 || X == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let l: Vec<i64> = s.take(n).map(|a| a.parse().unwrap()).collect();
	let mut ans = 0;
	for i in 0..n {
		for j in i + 1..n {
			for k in j + 1..n {
				let mut a = vec![l[i], l[j], l[k]];
				a.sort();
				if a[2] < a[0] + a[1] && a[0] != a[1] && a[1] != a[2] {
					ans += 1;
				}
			}
		}
	}
	println!("{}", ans);
}


Measured memory_bytes: 2152
#include <stdio.h>

#if 1
    #define gc() getchar_unlocked()
#else
    #define gc() getchar()
#endif

int n, k;
int w[100001];

int in() {
    int n = 0, c = gc();
    do n *= 10, n += (c & 0xf), c = gc(); while (c >= '0');
    return n;
}


int check(int capacity) {
    int curLoad = 0, numTrucks = 0, i;
    for (i=0; i<n; i++) {
        curLoad += w[i];
        if (curLoad > capacity) {
            curLoad=w[i], numTrucks++;
            if (numTrucks == k) break;
        }
    }

    return numTrucks < k;
}

int main(void){
    int p, lo, hi, mi, i;
    
    n = in(), k = in();
    
    lo = hi = 0;
    for (i=0; i<n; i++) {
        w[i] = in();
        if (w[i] > lo) lo = w[i];
        hi += w[i];
    }
    
    if (k == 1) { printf("%d\n", hi); return 0; }
    else if (check(lo)) { printf("%d\n", lo); return 0; }
    
    while (lo+1 < hi) {
        mi = (lo+hi) >> 1;
        if (check(mi)) hi = mi;
        else lo = mi;
    }
    
    printf("%d\n", hi); return 0;
}



Measured memory_bytes: 2256
#include <iostream>
#include <map>
#include <string>
using namespace std;

int main(){
  int n;
  cin >> n;
  map<string, int>m;
  string sb;
  cin >> sb;
  m[sb]++;
  char nc = sb[sb.length()-1];
  for(int i=1; i<n; i++){
    string s;
    cin >> s;
    if(s[0]!=nc || m[s]!=0){
      cout << "No";
      return 0;
    }
	m[s]++;
    nc=s[s.length()-1];
  }
  cout << "Yes";
  return 0;
}

Measured memory_bytes: 256
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
from collections import deque
import itertools
import heapq
#import bisect
from fractions import Fraction
import copy
from functools import lru_cache
from collections import defaultdict
import pprint

#oo=list("ABCDEFGHIJKLMNOPQRSTUVWXYZ")
# ko=list("abcdefghijklmnopqrstuvwxyz")

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]

def ret(a):
    c=[None]*(len(a)-1)
    if len(a)==1:
        return a[0]
    elif len(a)==0:
        return 0
    for i in range(1,len(a)):
        c[i-1]=abs(a[i]-a[i-1])
    return ret(c)

def soinsubunkai(n):
    a = []
    i = 1
    while i*i <= n:
        if n % i == 0 and i!=1:
            a.append(i)
            n=n//i

        if n% i !=0 or i==1:
            i += 1
    nokori=[n]
    return a + nokori

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def main():
    n=int(input())
    if n%1000!=0:
        print(1000-n%1000)
    else:
        print(0)



if __name__ == "__main__":

    main()

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

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

    multiset<int> st;
    int n;
    cin>>n;

    for (int i=1; i<=n; i++) {
        int x;
        cin>>x;
        st.insert(x);
    }

    int d = *st.rbegin();

    for (int i=0; i<=d; i++) {
        int dis = max(i, d-i);
        auto it = st.find(dis);
        if (it == st.end()) {
            cout<<"Impossible\n";
            return 0;
        }
        st.erase(it);
    }

    if (st.size() && *st.begin() <= (d+1)/2) cout<<"Impossible\n";
    else                                cout<<"Possible\n";

}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;

vector<vector<int> > g;
vector<int> ids;

void rec(int v, int id)
{
  //fprintf(stderr, "DEBUG: v=%d, id=%d\n", v, id);
  int n = g[v].size();
  ids[v] = id;
  for (int i = 0; i < n; ++i) {
    if (ids[g[v][i]] == -1) {
      rec(g[v][i], id);
    }
  }
}

int main()
{
  int n, m;
  fscanf(stdin, "%d %d", &n, &m);
  g = vector<vector<int> >(n);
  ids = vector<int>(n, -1);
  for (int i = 0; i < m; ++i) {
    int s, t;
    fscanf(stdin, "%d %d", &s, &t);
    g[s].push_back(t);
    g[t].push_back(s);
  }
  int id = 0;
  for (int i = 0; i < n; ++i) {
    if (ids[i] == -1) {
      rec(i, id);
      ++id;
    }
  }
  int q;
  fscanf(stdin, "%d", &q);
  // fprintf(stderr, "DEBUG: ");
  // copy(ids.begin(), ids.end(), ostream_iterator<int>(cerr, ", "));
  // fprintf(stderr, "\n");
  for (int i = 0; i < q; ++i) {
    int s, t;
    fscanf(stdin, "%d %d", &s, &t);
    fprintf(stdout, "%s\n", ids[s] == ids[t] ? "yes" : "no");
  }
  return 0;
}

Measured memory_bytes: 11656
#include <iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;


int main() {
	
	int n,l;
	cin>>n>>l;
		
  	std::vector <std::string> final;
  
	string str;
		
	for(int i=0;i<n;i++){
	    str.clear();
      	cin>>str;
      	final.push_back(str);
	    }
	
	 
	std::sort(final.begin(),final.end());
	
	for(int i=0;i<n;i++){
	    cout<<final[i];
	    }
	
	
	// your code goes here
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  int n,m;
  cin>>n>>m;
  vector<int>a(m),b(m);
  vector<int>c(n);
  rep(i,m){
    cin>>a[i]>>b[i];
  }
  rep(i,m){
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  rep(i,n){
  cout<<c[i]<<endl;
  }
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main(){
	int n;
	cin>>n;
	int k,s=0;
	for(int i=0;i!=n;++i){
		cin>>k;
		if(!(k&1))
			++s;
	}
	cout<<pow(3,n)-pow(2,s);
}

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

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>istream &operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
//template <typename T, typename S>ostream &operator<<(ostream &os, pair<T, S> &p) {os << p.first << " " << p.second;return os;}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T, class U>bool chmin(T& a, U b) { if (a > b) { a = b; return true; }return false; }
template <class T, class U>bool chmax(T& a, U b) { if (a < b) { a = b; return true; }return false; }

void check(string s, string t) {
	set<char>ss(s.begin(), s.end()), tt(all(t));

	for (auto c : tt) {
		if (not ss.count(c)) {
			cout << -1 << endl;
			exit(0);
		}
	}
}


signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	string s, t;
	cin >> s >> t;

	check(s, t);

	map<char, vector<int>>mp;
	rep(i, 0, s.size()) {
		mp[s[i]].eb(i);
	}

	int x = 0;
	int y = 0;

	for (auto c : t) {
		auto lb = lower_bound(all(mp[c]), y);
		if (lb == mp[c].end()) {
			x++;
			y = mp[c].front() + 1;
		}
		else {
			y = (*lb) + 1;
		}
	}

	cout << x * s.size() + y << endl;

	return 0;
}


Measured memory_bytes: 1736
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;



int main(void)
{
	int N;
	cin >> N;
	long long A, B;
	cin >> A >> B;

	vector<long long> h(N);
	for(int i=0; i<N; i++)
		cin >> h[i];

	long long left, right;
	left = 0;
	right = 1E9;
	const long long dif = A - B;
	while(right-left>1)
	{
		long long mid = (left + right)/2;

		long long cnt = 0;
		long long dmg = B * mid;
		for(int i=0; i<N; i++)
		{
			if(h[i] <= dmg)
				continue;

			cnt += (h[i] - dmg + dif - 1)/dif;
		}
		
		if(cnt <= mid)
			right = mid;
		else
			left = mid;
	}

	cout << right << endl;

	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>
int main() {
	char s[201], t[201], u[201];
	int i, j, k, m, h;
	while(1) {
		scanf("%s", s);
		if (s[0] == '-') break;
		scanf("%d", &m);
		for (i=0; i<m; i++) {
			scanf("%d", &h);
			for (j=0; j<h; j++) {
				t[j] = s[j];
			}
			t[h] = '\0';
			for (k=0; k<strlen(s)-h; k++) {
				u[k] = s[h+k];
			}
			u[strlen(s)-h] = '\0';
			strcat(u, t);
			strcpy(s, u);
		}
		printf("%s\n", s);
	}
	return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define RFOR(i, s, n) for (int i = (n) - 1; i >= (int)(s); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(a) a.begin(), a.end()
constexpr long long INF = 1e18;
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;}



signed main(){
	int N,K;
	cin>>N>>K;
	vector<int>h(N);
	REP(i,N)cin>>h[i];
	int ans = 0;
	REP(i,N){
		if(h[i]>=K)ans++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
from itertools import accumulate

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())))
q = sorted(list(map(int, input().split())))
r = sorted(list(map(int, input().split())))

num_red = 0
num_green = 0


def top_pop(*lst):
    # print(lst)
    if len(lst[-1]) == 0:
        lst = lst[:-1]
    top = max(map(lambda x: x[-1], lst))
    for i in range(len(lst)):
        if lst[i][-1] == top:
            return (lst[i].pop(), i)

def func(i):
    global num_red, num_green
    if i == 0:
        num_red += 1
    elif i == 1:
        num_green += 1
    else:
        pass

ans = 0
for i in range(x+y):
    if num_red < x and num_green < y:
        popped, i = top_pop(p, q, r)
    elif num_red < x:
        popped, i = top_pop(p, r)
    elif num_green < y:
        popped, i = top_pop(q, r)
    else:
        raise RuntimeError
    func(i)
    ans += popped

print(ans)

Measured memory_bytes: 22720
def Split(a):
    no = []
    for i, x in a:
        if no:
            is_ok = i == x
            la_ok = no[-1][0] == no[-1][1]
            if is_ok == la_ok:
                yield no
                no = []
        no.append((i, x))
    yield no

n = int(input())
p = list(enumerate((int(input()) for i in range(n)), 1))
for sq in Split(p):
    tl = tr = 0
    for np, goal in sq:
        if goal > np:
            if goal < tr or goal > sq[-1][0]:
                print("No")
                exit(0)
            tr = goal
        elif goal < np:
            if goal < tl or goal < sq[0][0]:
                print("No")
                exit(0)
            tl = goal
print("Yes")

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int K, A, B;

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

  std::cin >> K >> A >> B;

  bool ok = false;

  for(int i=A;i<=B;++i){
      if(i % K == 0){
          ok = true;
      }
  }

  if(ok){
      std::cout << "OK" << std::endl;
  }else{
      std::cout << "NG" << std::endl;
  }
}


Measured memory_bytes: 3620
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

void warshall_floyd(vector<vector<long long>>& d, int n) {
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

//--------------------------- Solve ---------------------------//

const long long INF = 1LL << 60;

long long N, M, L;
vector<vector<long long>> d, cost;

void solve() {
    int s, t; cin >> s >> t;
    s--; t--;
    int ans;
    if (cost[s][t] == INF) ans = -1;
    else ans = cost[s][t] - 1;
    cout << ans << '\n';
}

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

    cin >> N >> M >> L;
    d.resize(N, vector<long long>(N, INF));

    for (int i = 0; i < M; i++) {
        long long a, b, c; cin >> a >> b >> c;
        a--; b--;
        d[a][b] = c;
        d[b][a] = c;
    }
    for (int i = 0; i < N; i++) d[i][i] = 0;

    warshall_floyd(d, N);

    cost = d;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) cost[i][j] = 0;
            else if (d[i][j] <= L) cost[i][j] = 1;
            else cost[i][j] = INF;
        }
    }

    warshall_floyd(cost, N);

    int Q; cin >> Q;
    while(Q--) solve();

    return 0;
}

Measured memory_bytes: 4848
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	vector<pair<long,long>> A(N);
	rep(i,0,N){
		cin>>A[i].first>>A[i].second;
	}
	pair<long,long> ans=A[0];
	rep(i,1,N){
		long a=A[i].first,b=A[i].second;
        long c=(ans.first+a-1)/a;
        long d=(ans.second+b-1)/b;
        ans.first=max(c,d)*a;
        ans.second=max(c,d)*b;
	}cout<<ans.first+ans.second<<endl;
}

Measured memory_bytes: 256
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import numpy as np

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

N = int(input())
sp = [[] for i in range(N)]
for i in range(N):
    s,p = input().split()
    sp[i] = [str(s),int(p)]

sp_sorted = sorted(sp)
city = sp_sorted[0][0]
group = [sp_sorted[0]]
first = 0
# print(sp_sorted)
for i in range(1,N):
    if city == sp_sorted[i][0]:
        group.append(sp_sorted[i])
    else:
        # print(group)
        group = sorted(group,key = lambda x:x[1],reverse=True)
        if len(group) == 1:
            pass
        else:
            sp_sorted[first:i] = group
        group = [sp_sorted[i]]
        city = sp_sorted[i][0]
        first = i
    if i == N-1 and len(group) != 1:
        group = sorted(group,key = lambda x:x[1],reverse=True)
        sp_sorted[first:] = group


# print(sp_sorted)


ans = [-1 for i in range(N)]
for i in range(N):
    ans[i] = sp.index(sp_sorted[i])

for i in range(N):
    print(ans[i]+1)


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int M;
	cin >> M;
	cout << 24 + (24 - M) << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
	HashSet<Integer> set;
	int a,b,c;
	public void solve() {
		a = nextInt();
		b = nextInt();
		c = nextInt();
		set = new HashSet<Integer>();
		set.add(a);
		set.add(b);
		set.add(c);
		out.println(set.size());
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 8144