akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int[] d = new int[n];
        for(int i = 0; i < n; i++){
            d[i] = Integer.parseInt(sc.next());
        }
        
        Arrays.sort(d);
        System.out.println(d[n/2] - d[n/2-1]);
    }
}

Measured memory_bytes: 49240
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int r = sc.nextInt();
    os.println(3 * r * r);
  }
}

Measured memory_bytes: 23252
#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 n, l, r;
  cin >> n;
  int sum = 0;
  rep(i,n){
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
  return 0;
}

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

using namespace std;

int main(){
    vector<int> hoge(3);
    for(int i=0;i<3;i++) cin>>hoge.at(i);
    sort(hoge.begin(),hoge.end());
    
    int ans=hoge.at(2)-hoge.at(1);
    hoge.at(0)+=ans;
    hoge.at(1)=hoge.at(2);
    
    if((hoge.at(2)-hoge.at(0))%2==0){
        ans+=(hoge.at(2)-hoge.at(0))/2;
    }else{
        ans+=(hoge.at(2)-hoge.at(0))/2+2;
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#include <map>


#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;


int main(void){

double a;
	while(cin >> a){
		if( cin.eof()) break;
		double s = a;
		rep2(i,2,11){
			if(i%2) a /= 3;
			else    a *= 2;
			s += a;
		}
		printf("%.10f\n", s);
	}
	return 0;
	
	
}

Measured memory_bytes: 1236
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//CODE

void solve(void)
{
  int N;
  cin>>N;
  map<string,int> mp;
  for (int i = 0; i < N; i++)
  {
    string str;
    cin>>str;
    auto itr = mp.find(str);
    if(itr == mp.end())
    {
      mp[str] = 1;
    }
    else
    {
      itr->second++;
    }
  }

  int MAX =0;
  for (int i = 0; i < mp.size(); i++)
  {
    static auto itr = mp.begin();
    chmax(MAX,itr->second);
    itr++;
  }
  for (int i = 0; i < mp.size(); i++)
  {
    static auto itr = mp.begin();
    if(itr->second == MAX)
    {
      cout<<itr->first<<endl;
    }
    itr++;
  }
  
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 23808
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; i++ )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4]={1,0,-1,0} , dy[4]={0,1,0,-1} ;

int main(){
   int x,y,h;
   cin>>x>>y>>h;
   cout<<(x+y)*h/2<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			String st[]=in.next().split("\\+");
			String st2[]=st[1].split("=");
			String a=st[0];
			String b=st2[0];
			String c=st2[1];
			int ans=-1;
			for(int i=0;i<10;i++)
			{
				String x=a;
				String y=b;
				String z=c;
				if(i==0)
				{
					if(x.length()>1)
						if(x.charAt(0)=='X')
							continue;
					if(y.length()>1)
						if(y.charAt(0)=='X')
							continue;
					if(z.length()>1)
						if(z.charAt(0)=='X')
							continue;
				}
				x=x.replaceAll("X",String.valueOf(i));
				y=y.replaceAll("X",String.valueOf(i));
				z=z.replaceAll("X",String.valueOf(i));
				
				BigInteger x2=new BigInteger(x);
				BigInteger y2=new BigInteger(y);
				BigInteger z2=new BigInteger(z);
				
				if((x2.add(y2)).equals(z2))
				{
					ans=i;
					break;
				}
			}
			System.out.println(ans==-1 ? "NA":ans);
		}
	}
	
	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 23352
n = gets.to_i
a = []
a << 1
1.upto(7) do |i|
  a << 6 ** i
end
1.upto(6) do |i|
  a << 9 ** i
end
a.sort!
dp = Array.new(n + 1, Float::INFINITY)
dp[0] = 0
n.times do |i|
  a.each do |x|
    break if i + x > n
    if dp[i + x] > dp[i] + 1
      dp[i + x] = dp[i] + 1
    end
  end
end
puts dp[-1]

Measured memory_bytes: 4220
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
	for (int i = 0; i < 10000; i++) {
		int x = 0;
		cin >> x;
		if (x == 0) break;
		else cout << "Case " << i + 1 << ": " << x << endl;
	}
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
#include<set>

using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;

#define MOD 1000000007

int N,M;
vector<vector<int> > e;
vector<bool> used;
vector<int> ans;

void dfs(int s){
  ans.push_back(s+1);
  used[s] = true;
  REP(i,0,e[s].size()){
    int v = e[s][i];
    if(!used[v])
      return dfs(v);
  }
  return;
}

int main()
{
  cin >> N >> M;
  used.resize(N);
  e.resize(N);
  REP(i, 0, M)
  {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  REP(i,0,N){
    used[i] = false;
  }

  dfs(0);
  reverse(ans.begin(),ans.end());
 ans.pop_back();
 dfs(0);
  cout << ans.size()<<endl;
  REP(i,0,ans.size()){
    cout << ans[i] << " ";
  }
}


Measured memory_bytes: 11128
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long ll;

int main(){
  string S;
  cin >> S;
  vector<int> que(S.size()-1,0);
  ll sum=0,INF=pow(2,S.size()-1);
  for(int i=0;i<INF;i++){
    int j=i,count=0;
    ll x=S[0]-'0';
    while(j>0){
      que.at(count)=j%2;
      count++;
      j/=2;
    }
    for(int k=0;k<S.size()-1;k++){
      if(que.at(k)==0)x=x*10+(S[k+1]-'0');
      else{
        sum+=x;
        x=S[k+1]-'0';
      }
    }
    sum+=x;
    }
  cout << sum << endl;
}


Measured memory_bytes: 256
from collections import deque 
H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
moves = ((1, 0), (0, 1), (0, -1), (-1, 0))
dist = [[-1]*W for _ in range(H)] 

def bfs():
    q = deque([[0, 0]])
    visited = [[0]*W for _ in range(H)]
    visited[0][0] = 1
    dist[0][0] = 0

    while q:
        y, x = q.popleft()
        for dy, dx in moves:
            ny = y + dy 
            nx = x + dx 
            if 0 <= ny < H and 0 <= nx < W and visited[ny][nx] == 0 and s[ny][nx] == '.':
                visited[ny][nx] = 1 
                dist[ny][nx] = dist[y][x] + 1 
                q += [[ny, nx]]

bfs()
ans = H * W
if dist[H-1][W-1] == -1:
    print(-1)
    exit()
for i in range(H):
    for j in range(W):
        if s[i][j] =='#':
            ans -= 1 

print(ans-dist[H-1][W-1]-1)

Measured memory_bytes: 40304
n=int(input())
a=list(map(int,input().split()))
mod=1000000007
ans=0
s=0
for i in range (n-1):
    if i ==0:
        for j in range(i+1,n):
            s=(s+a[j])%mod
    else:
        s-=a[i]
    ans=(ans+(a[i]*(s))%mod)%mod

print(ans)


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

int N;

int main(){
    cin >> N;
    // a1 ~ aNの全ての積から1を引いた数を作る。
    // その数をどの数で割っても、あまりが-1(割った数-1)になる。 

    int ans = 0;
    int n;
    REP(i,N){
        cin >> n;
        ans += n - 1;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let k: i64 = sc.cin();
    let xs: Vec<usize> = (0..n).map(|_| sc.cin()).collect();

    let kk = (k * (k - 1) / 2) % M;

    let mut acc = vec![vec![0; n + 1]; 2003];
    for c in 1..2001 {
        for i in 0..n {
            acc[c][i + 1] = acc[c][i] + if xs[i] == c { 1 } else { 0 };
        }
    }
    let mut ans = 0;
    for i in 0..n {
        for c in xs[i] + 1..2001 {
            if acc[c][n] == 0 { continue }
            ans += acc[c][i] * k;
            ans %= M;
            ans += acc[c][n] * kk;
            ans %= M;
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 45308
#include <bits/stdc++.h>
using namespace std;
// 如果是可能有红，数量超过1，目标可能
// 如果可能有红， 数量1， 目标可能， 自身不可能
// 自身不可能， 不变
int main(){
    int n,m;
    scanf("%d %d", &n, &m);
    vector<int> num(n, 1);
    vector<bool> f(n, false);
    f[0] = true;
    int x,y;
    for(int i = 0; i < m; i++){
        scanf("%d %d", &x, &y);
        x--;
        y--;
        if(num[x] > 1 && f[x] == true){
            f[y] = true;
        }else if(num[x] == 1 && f[x] == true){
            f[y] = true;
            f[x] = false;
        }
        num[x]--;
        num[y]++;
    }
    int ens = 0;
    for(int i = 0; i <n; i++){
        if(f[i] == true) ens++;
    }
    cout << ens << endl;
    return 0;
}


Measured memory_bytes: 768
#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 n,m;
    cin>>n>>m;
    int nn=(n*(n-1))/2;
    int mm=(m*(m-1))/2;
    cout<<nn+mm<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <set>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <sstream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <fstream>
#include <iomanip>
//#include <unordered_map>
using namespace std;
#define dbg(x) cerr << #x " = " << x << endl;
typedef pair<int, int> P;
typedef long long ll;

int main()
{
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int s, w;
    cin >> s >>w;
    if(s <= w)
    {
        cout << "unsafe" << endl;
    }
    else
    cout << "safe" << endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int N; cin >> N;
    vector<pair<int, int>> X(N);
    for(int i = 0; i < N; i++){
        int x, l; cin >> x >> l;
        X[i] = make_pair(x+l, x-l);
    }
    sort(X.begin(), X.end());
    int ledge;
    int redge;
    int cnt = 0;
    for(int i = 0; i < N; i++){
        int r = X[i].first;
        int l = X[i].second;
        if(i == 0){
            redge = r;
            ledge = l;
        }
        else{
            if(l < redge) cnt++;
            else{
                redge = r;
            }
        }
    }
    cout << N-cnt << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
 ll x,y;
 cin>>x>>y;
 bool flag = false;
 for(ll i=0;i<=x;i++){
  if( y == i*2 + (x-i)*4 ) flag = true;
 }
 if(flag)cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) {
        par.assign(n, -1);
    }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    bool is_same(int x, int y) {
        return root(x) == root(y);
    }
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    int size(int x) {
        return -par[root(x)];
    }
};
int main() {
    int n; cin >> n;
    vector<vector<pair<int, int>>> persons(n);
    rep(i, n) {
        int a; cin >> a;
        rep(j, a) {
            int x, y; cin >> x >> y;
            --x;
            persons[i].push_back({x, y});
        }
    }
    int ans = 0;
    for (int bit = 0; bit < (1 << n); bit++) {
        UnionFind uf(n);
        vector<int> oks, ngs;
        rep(i, n) {
            if (bit & (1 << i)) oks.push_back(i);
            else ngs.push_back(i);

        }

        int index = 0;
        while (index + 1 < oks.size()) {
            uf.merge(oks[index], oks[index + 1]);
            index++;
        }
        index = 0;
        while (index + 1 < ngs.size()) {
            uf.merge(ngs[index], ngs[index + 1]);
            index++;
        }
        bool ok = true;
        rep(i, n) {
            for (auto p: persons[i]) {
                if (p.second == 1
                    && (bit & (1 << i))) {
                    if (!uf.is_same(i, p.first)) {
                        ok = false;
                        break;
                    }
                } else if (p.second == 0
                           && (bit & (1 << i))) {
                    if (uf.is_same(i, p.first)) {
                        ok = false;
                        break;
                    }
                }
            }
            if (!ok) break;
        }
        if (ok) {
            ans = max(ans, (int)oks.size());
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cctype>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<list>
#include<map>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

void bubbleSort(int A[], int N) {
	int flag = 1,
		cnt = 0;
	while (flag) {
		flag = 0;
		for (int j = N - 1; j >= 1; j--) {
			if (A[j] < A[j - 1]) {
				swap(A[j], A[j - 1]);
				flag = 1;
				cnt++;
			}
		}
	}

	for (int i = 0; i < N; i++)	{
		cout << A[i];
		if (i != N - 1)cout << " ";
	}
	cout << endl;
	cout << cnt << endl;
}

int main() {
	int N; cin >> N;
	int A[100];
	for (int i = 0; i < N; i++)	{
		cin >> A[i];
	}
	bubbleSort(A, N);
	
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

 
int main() {
  int n;
  cin >> n;
  int cnt = 0;
  for (int i = 0; i < n; i++){
    int a, b;
    cin >> a >> b;
    if (a == b) {
      cnt++;
      if (3 <= cnt ){
        cout << "Yes" << endl;
        return 0;
      }
    } else {
      cnt = 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <deque>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int q; cin >> q;
    int a=0,b=0;
    while(q--){
        string s,t; cin >> s >> t;
        if(s>t){
            a+=3;
        }
        else if(s<t){
            b+=3;
        }
        else{
            a++;
            b++;
        }
    }
    cout << a << " " << b << endl;
}


Measured memory_bytes: 3196
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <cctype>  // std::islower(), std::isupper(), std::tolower, std::toupper
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {
  int X, t; std::cin >> X >> t;
  std::cout << std::max(0, X - t) << std::endl;
  return 0;
}


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

int main()
{
    int n, m, X, Y;
    cin >> n >> m >> X >> Y;
    vector<int> x(n), y(m);
    rep (i, n)
        cin >> x[i];
    rep (i, m)
        cin >> y[i];
    sort(x.rbegin(), x.rend());
    sort(y.begin(), y.end());

    bool ok = false;
    for (int i = X + 1; i <= Y; i++)
        if (x[0] < i && y[0] >= i)
            ok = true;

    cout << (ok ? "No War" : "War") << endl;
    return 0;
}

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

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            string[] ABCD = Console.ReadLine().Split(' ');
            int A = int.Parse(ABCD[0]);
            int B = int.Parse(ABCD[1]);
            int C = int.Parse(ABCD[2]);
            int D = int.Parse(ABCD[3]);

            while(true)
            {
                C -= B;
                
                if(C <= 0)
                {
                    Console.WriteLine("Yes");
                    break;
                }

                A -= D;

                if (A <= 0)
                {
                    Console.WriteLine("No");
                    break;
                }
            }
        }
    }
}

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

int main() {
	int X, A, B;
	cin >> X >> A >> B;
	if (A >= B) cout << "delicious";
	else if (A + X >= B) cout << "safe";
	else cout << "dangerous";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

特に解説することもなく、if文通り
ただ、皆さんはXを普通分からないので、間違ってもこんな食品のとり方はせずdeliciousのみを食べようね！
ちなみに、アイスなどは劣化しないので賞味期限はないです4 3 64 3 6
*/

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


public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);

		String toi = scanner.nextLine();
		int cflag = 0;
		int joken1 = 0;
		int joken2 = 0;
		int joken3 = 0;


		for(int i = 0; i < toi.length(); i++) {

			if(toi.charAt(0) == 'A') {
				joken1 = 1;
			}else {
				break;
			}

			if(2 <= i && i <= toi.length() - 2 && toi.charAt(i) == 'C' && joken2 == 0) {
				joken2++;
			}else if(0 < i  && Character.isUpperCase(toi.charAt(i))){
				joken3 ++;
				break;
			}
		}



		if(joken1 == 1 && joken2 == 1 && joken3 == 0) {
			System.out.println("AC");
		}else {
			System.out.println("WA");
		}
	}
}


Measured memory_bytes: 25044
import java.util.*;
public class Main{
	static long[] aa;
  static long maxx(int[] arr,int ind){
  	if(ind>=arr.length){
      return Integer.MAX_VALUE;
    }
    if(ind==arr.length-1){ return 0; } 
    if(aa[ind]!=-1){return aa[ind];}
    if(ind+2<arr.length){
      return aa[ind]=Math.min(maxx(arr,ind+1)+Math.abs(arr[ind]-arr[ind+1]),
                              maxx(arr,ind+2)+Math.abs(arr[ind]-arr[ind+2]) );
    } else{
    	return aa[ind]=maxx(arr,ind+1)+Math.abs(arr[ind]-arr[ind+1]);
    }
    
    
  }
  
  public static void main(String[] args){
  	Scanner s=new Scanner(System.in);
    //int t=s.nextInt();
   // for(int j=0;j<t;j++){
    	int n=s.nextInt();
        int arr[]=new int[n];
      for(int i=0;i<n;i++){
      		arr[i]=s.nextInt();
      }
      aa=new long[n];
      Arrays.fill(aa,-1);
      System.out.println( maxx(arr,0)); 
   // }
    
    
  }

}

Measured memory_bytes: 66876
import java.io.*;
import java.util.*;
import java.awt.Point;
public class Main {
	static Scanner sc;
	static PrintWriter out;
	static final int uncal = -1;
	public static void main(String[] args) throws Exception{
		// TODO Auto-generated method stub
		sc = new Scanner(System.in); 
		out = new PrintWriter(System.out);
		long n = sc.nextLong();
		HashSet<Long> divisors = new HashSet<Long>();
		for (int i = 2; 1l*i*i <= n; i++) {
			if(n%i == 0) {
				divisors.add(1l*i);
				divisors.add(n/i);
			}else if((n-1)%i == 0) {
				divisors.add(1l*i);
				divisors.add((n-1)/i);				
			}
		}
		int cnt = 0;
		if(n == 2)
			cnt++;
		else
			cnt+=2;
		for(long k:divisors) {
			long tmp = n;
			while(tmp%k == 0) {
				tmp /= k;
			}
			if(tmp%k == 1) {
				cnt++;
			}
		}
		out.println(cnt);
		out.close();
	}
	static class Point extends java.awt.Point implements Comparable<Point>{
		public Point(int x,int y) {
			// TODO Auto-generated constructor stub
			super(x,y);
		}
		public String toString() {
			return x+" "+y;
		}
		@Override
		public int compareTo(Point p) {
			// TODO Auto-generated method stub
			if(x == p.x)
				return y - p.y;
			return x - p.x;
		}
		
	}
	static class Scanner{
		private BufferedReader br;
		private StringTokenizer st;
		public Scanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}
		public Scanner(String filename) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(filename));
		}
		public String next() throws IOException{
			while(st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
		public int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		public long nextLong() throws IOException{
			return Long.parseLong(next());
		}
		public double nextDouble() throws IOException{
			return Double.parseDouble(next());
		}
		public int[] inArr(int n) throws Exception{
			int a [] = new int[n];
			st = new StringTokenizer(br.readLine());
			for(int i=0;i<n;i++) {
				a[i] = Integer.parseInt(st.nextToken());
			}
			return a;
		}
	}

}

Measured memory_bytes: 22224
#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

#include<bits/stdc++.h>
#include<boost/dynamic_bitset.hpp>
using namespace std;
using u64 = uint64_t;
using s64 = int64_t;

template <class T> class fenwick_tree {
	private: vector<T> val;

	public:
	fenwick_tree(const u64 size) {
		val.resize(size);
	}

	void add(const u64 i, const T v) {
        u64 index = i + 1;

		while (index <= val.size()) {
			val[index - 1] += v;
			index += index & (-index);
		}
	}

	T sum(u64 b, u64 e) {
		// [b. e)
        if(b == e) {
            return 0;
        } else {
            return sum(e) - sum(b);
	    }
    }

	T sum(const u64 i) {
        // [0 i)
        T s = 0;

        for(u64 k=i; k>0; k-=(k & -k)) 
            s += val[k-1];
        
        return s;
	}
};


int main(void) {
    u64 N, Q;
    cin >> N >> Q;

    vector<s64> c_last(N, -1);
    priority_queue<pair<u64, u64>> c_range;
    u64 r_max = 0;

    for(u64 i=0; i<N; i++) {
        u64 c;
        cin >> c;
        c--;
        
        if(c_last[c] >= 0) {
            c_range.push(make_pair((u64)c_last[c], i));
            r_max = max(r_max, i);
        }

        c_last[c] = (s64)i;
    }

    priority_queue<pair<pair<u64, u64>, u64>> queries;

    for(u64 i=0; i<Q; i++) {
        u64 l, r;
        cin >> l >> r;
        l--; r--;
        queries.push(make_pair(make_pair(l, r), i));
        r_max = max(r_max, r);
    }

    fenwick_tree<u64> fenwick(r_max + 1); 
    vector<u64> answers(Q);

    while(!queries.empty()) {
        if(!c_range.empty() && c_range.top().first >= queries.top().first.first) {
            auto c_r = c_range.top().second;
            c_range.pop();

            fenwick.add(c_r, 1);

        } else {
            auto q_l = queries.top().first.first;
            auto q_r = queries.top().first.second;
            auto q_i = queries.top().second;
            queries.pop();

            auto f_r = fenwick.sum(q_r + 1);
            auto f_l = fenwick.sum(q_l);

            answers[q_i] = q_r - q_l + 1 - f_r + f_l;

        }
    }

    for(const auto ans : answers) {
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int dp[1001];

int main() {
  int D, G;
  cin>>D>>G;
  vector<int> p(D),c(D);
  int p_sum=0;
  for (int i=0;i<D;++i) {
    cin>>p[i]>>c[i];
    p_sum += p[i];
  }

  for (int i=1;i<=D;++i) {
    for (int j=p_sum;j>=0;--j) {
      for (int k=0;k<=p[i-1]&&k<=j;++k) {
        int pts = (k==p[i-1])?(100*i*k+c[i-1]):100*i*k;
        dp[j] = max(dp[j], dp[j-k]+pts);
      }
    }
  }

  int ans=0;
  while(dp[ans]<G)ans++;
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define repd(i,a,b) for (int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template
struct edge{
    int to, cost;
};

struct query{
    int p, q, c;
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N, M;
    cin >> N >> M;

    vector<query> Q(M);
    vector<pair<int, int>> A; // to, line
    
    rep(i, M){
        int p, q, c;
        cin >> p >> q >> c;
        p--, q--;
        Q[i] = {p, q, c};
        A.pb(mp(p, c));
        A.pb(mp(q, c));
    }
    rep(i, N) A.pb(mp(i, -1)); // 各頂点の改札
    
    sort(all(A));
    
    vector<vector<edge>> G(A.size()); // to, cost
    
    rep(i, M){
        int pi = (int)(lower_bound(all(A), mp(Q[i].p, Q[i].c)) - A.begin());
        int qi = (int)(lower_bound(all(A), mp(Q[i].q, Q[i].c)) - A.begin());
        G[pi].pb({qi, 0});
        G[qi].pb({pi, 0});
    }

    vector<int> dist(A.size(), inf);
    int si = 0;
    rep(i, A.size()){
        if(A[i].second == -1){
            si = i;
        }
        else{
            G[i].pb({si, 0});
            G[si].pb({i, 1});
        }
    }
    
    // 0-1 BFS
    deque<int> q;
    q.push_back(0);
    dist[0] = 0;
    while(!q.empty()){
        int t = q.front();
        q.pop_front();
        for(edge e: G[t]){
            if(dist[e.to] > dist[t] + e.cost){
                dist[e.to] = dist[t] + e.cost;
                if(e.cost == 0) q.push_front(e.to);
                else q.push_back(e.to);
            }
        }
    }
    
    int ans = inf;
    rep(i, A.size()){
        if(A[i].first == N - 1) ans = min(ans, dist[i]);
    }
    
    if(ans == inf) output(-1, 0);
    else output(ans, 0);
    
    return 0;
}

Measured memory_bytes: 42604
#include <bits/stdc++.h>
#include <array>
#define int long long
using namespace std;
signed main() {
  ios::sync_with_stdio(0); cin.tie(0);
  bool yes = false;
  int n;
  cin >> n;
  vector<array<int, 2>> d(n);
  for (int i = 0; i < n; ++i)
    cin >> d[i][0] >> d[i][1];
  for (int i = 0; i < n; ++i) {
    if (i + 2 < n && d[i][0] == d[i][1] &&
      d[i + 1][0] == d[i + 1][1] &&
      d[i + 2][0] == d[i + 2][1])
      yes = true;
  }
  cout << (yes ? "Yes\n" : "No\n");
  return 0;
}

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

bool dfs(ll n, ll A, ll B, ll C, ll K) {
    if (n == K) {
        if (A < B && B < C) {
            return true;
        } else {
            return false;
        }
    }
    if (dfs(n + 1, A * 2, B, C, K)) {
        return true;
    }
    if (dfs(n + 1, A, B * 2, C, K)) {
        return true;
    }
    if (dfs(n + 1, A, B, C * 2, K)) {
        return true;
    }
    return false;
}

int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;
    if (dfs(0, A, B, C, K)) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(ll i = (ll)(n)-1;i >= 0;--i)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define eb(val) emplace_back(val)
const double PI = acos(-1);
const double EPS = 1e-10;
const ll MOD = 1e9+7;
//#define int ll
void cioacc(){//accelerate cin/cout
  cin.tie(0);
  ios::sync_with_stdio(false);
}
signed main(){
  int n;
  cin >> n;
  vb s;
  int minor = 1;
  if(n==0){
    cout << 0 << endl;
    return 0;
  }
  for(;n!=0;minor*=-1,n>>=1){
    if(n&1) {
      s.eb(1);
      n -= minor;
    }
    else s.eb(0);
  }
  RREP(i,s.size()) cout << s.at(i);
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=1<<18,INF=1<<30;

int main(){
vector<int> A(5);
int ans=0;
for(int i=0;i<5;i++){
cin>>A[i];
A[i]=max(A[i],40);
ans+=A[i];
}
cout<<ans/5<<endl;

}



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

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int[] a = new int[n];
		for(int i=0;i<n;i++){
			a[i] = Integer.parseInt(scan.next());
		}
		Arrays.sort(a);
		System.out.println(a[n-1]-a[0]);
	}

}


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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)

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

    int N,A,B; cin >> N >> A >> B;
    int counter[3] = {0, 0, 0};

    int P;
    rep(i, N) {
        cin >> P;
        if (P <= A)      counter[0]++;
        else if (P <= B) counter[1]++;
        else             counter[2]++;
    }

    cout << min(counter[0], min(counter[1], counter[2])) << endl;
}


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

using namespace std;

int snack[101];

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    
    int n, k;
    cin >> n >> k;
    
    for (int i = 0; i < k; ++i)
    {
        int cnt;
        cin >> cnt;
        
        for (int j = 0; j < cnt; ++j)
        {
            int x; cin >> x;
            snack[x] = 1;
        }
    }
    
    int res = 0;
    
    for (int a = 1; a <= n; ++a)
        if (!snack[a])
            ++res;
    
    cout << res;
}

Measured memory_bytes: 3612
import sys
input = sys.stdin.readline

N, A = [int(x) for x in input().split()]
x = [int(x) - A for x in input().split()]

dp = [[0] * 5001 for _ in range(N + 1)]
dp[0][0 + 2500] = 1

for i in range(1, N + 1):
    for j in range(-2500, 2501):
        if 5000 >= j + 2500 - x[i - 1] >= 0:
            dp[i][j + 2500] = dp[i - 1][j + 2500 - x[i - 1]] + dp[i - 1][j + 2500]
        else:
            dp[i][j + 2500] = dp[i - 1][j + 2500]

print(dp[N][0 + 2500] - 1) # 何も選ばないものを引く

Measured memory_bytes: 41328
def solve(string):
  diff = 0
  for k, v in enumerate(string):
    if (k % 2 == 1 and v == '1') or (k % 2 == 0 and v == '0'):
      diff += 1
  return min(diff, len(string) - diff)

def main():
  string = input()
  ans = solve(string)
  print(ans)
  
main()

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int A = sc.nextInt();
		// スペース区切りの整数の入力
		int B = sc.nextInt();
      int sum=0;
      // 出力
      for(int cnt=0;cnt<2;cnt++){
      if(A<=B){
          sum+=B;
        B--;
        }else{
        sum+=A;
        A--;
      	}    
      }
		System.out.println(sum);
	}
}

Measured memory_bytes: 23124
#include <algorithm>
#include <iostream>
#define ll long long;
using namespace std;

int cnt_digits(long long N) {
  int digits = 0;

  while (N > 0) {
    N /= 10;
    digits++;
  }
  return digits;
}

int main(){
  long long N;
  cin >> N;

  int ans = cnt_digits(N);

  for(long long A = 1LL; A * A <= N; ++A) {
    if(N % A != 0) continue;

    const long long B = N / A;

    const int cur=max(cnt_digits(A), cnt_digits(B));
    if(ans > cur){
      ans = cur;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

c = 0
sum = 0
for b in a:
    if sum + b <= x:
        c += 1
        sum += b
    else:
        break
if c == N and sum != x:
    c -= 1
print(c)

Measured memory_bytes: 3060
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

        }

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            if (a % 2 == 0 || b % 2 == 0) WriteLine("Even");
            else WriteLine("Odd");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <stack>
#include <map>
#include <queue>
#include <functional>
using namespace std;
typedef long long ll;
int main(){
    string s;
    cin >> s;
    int k;
    cin >> k;

    int digit = (int)s.size();
    vector<vector<vector<ll>>> dp(digit+1,vector<vector<ll>>(k+2,vector<ll>(2,0)));

    dp[0][0][1] = 1;

    for(int i = 0;i <= digit - 1;i++){
        for(int j = 0;j <= k;j++){
           dp[i+1][min(k+1,j+1)][0] += (dp[i][j][0] * 9);
           dp[i+1][j][0] += dp[i][j][0];
           if(s[i] != '0'){
               dp[i+1][min(k+1,j+1)][0] += dp[i][j][1] * (s[i] - '0' - 1);
               dp[i+1][min(k+1,j+1)][1] += dp[i][j][1];
               dp[i+1][j][0] += dp[i][j][1];
           }
           else dp[i+1][j][1] = dp[i][j][1];
        }
    }
    cout << dp[digit][k][0] + dp[digit][k][1] << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
// by piano
template<typename tp> inline void read(tp &x) {
    x = 0;char c = getchar();bool f = 0;
    for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
    for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
    if(f) x = -x;
}
const int N = 3e5 + 10;
int n, K, tr[N], ans = 0, x[N], tp = 0, a[N], b[N];
inline void A(int u) {for(; u <= tp; u += u & -u) tr[u] ++;}
inline int Q(int u, int ans = 0) {for(; u >= 1; u -= u & -u) ans += tr[u]; return ans;}

main() {
	read(n), read(K);
	for(int i = 1; i <= n; i ++) {
		read(a[i]); a[i] -= K;
	}
	for(int i = 1; i <= n; i ++) a[i] += a[i - 1];
	for(int i = 1; i <= n; i ++) {
		x[i] = a[i]; ans += (a[i] >= 0);
	}
	sort(x + 1, x + n + 1); tp= unique(x + 1, x + n + 1) - x - 1;
	for(int  i = 1; i <= n; i ++) {
		b[i] = lower_bound(x + 1, x + tp + 1, a[i]) - x;
	}
	for(int i = 1; i <= n; i ++) {
		ans += Q(b[i]);
		A(b[i]);
	}
	cout << ans << "\n";
}

Measured memory_bytes: 8320
APPROVE_NUM_THREE = 3
APPROVE_NUM_FIVE = 5


def approve_entry(entry_judge_number_list):
    for n in entry_judge_number_list:
        if n % 2 == 0:
            if n % APPROVE_NUM_THREE != 0 and n % APPROVE_NUM_FIVE != 0:
                return 'DENIED'

    return 'APPROVED'


if __name__ == '__main__':
    input_numbers = input()
    entry_judge_number_list = map(int, input().split())
    print(approve_entry(entry_judge_number_list))


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

signed main()
{
  int A, B, K;
  cin >> K;
  cin >> A >> B;
  FOR(a,A,B+1) {
    if (a%K == 0) {
      cout << "OK" << endl;
      return 0;
    }
  }

  cout << "NG" << endl;
  
  return 0;
}


Measured memory_bytes: 3448
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	z = zeros(Int,10^5+1)
	for i in 1:n
		z[a[i]+1]+=1
	end
	ans = 0
	for i in 1:10^5-1
		ans = max(ans,z[i]+z[i+1]+z[i+2])
	end
	println(ans)
end

main()

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

long long int ans(long long int pos, int k, int step){
  if(step==1) return pos;
  else{
    long long int tmp = pos/(k-1);
    long long int prevpos = tmp*k + pos+1-tmp*(k-1);
    return ans(prevpos, k, step-1);
  }
}

int main(){
  int n,k;
  cin >> n >> k;
  cout << ans(0,k,n) << endl;
  return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n,sum=0;
  cin >> n;
  vector<int> v(n);
  r(i,n) cin >> v.at(i);
  sort(v.begin(),v.end());
  r(i,n) {
    if(i==n-1) sum+=v.at(i)/2;
    else sum+=v.at(i);
  }
  cout << sum << endl;
}


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

string A, B;

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

    if(A.size() > B.size()){
        cout << "GREATER";
    }else if(A.size() < B.size()){
        cout << "LESS";
    }else{
        if(A==B) cout << "EQUAL";
        else{
            cout << (A > B ? "GREATER" : "LESS");
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>

#define MAX_N 200000

int main() {
    bool sieve[MAX_N];
    for (int i = 2; i < MAX_N; i++) {
        sieve[i] = true;
    }
    
    for (int i = 2; i < MAX_N; i++) {
        if (!sieve[i]) {
            continue;
        }
        for (int j = i + i; j < MAX_N; j += i) {
            sieve[j] = false;
        }
    }

    int X;
    std::cin >> X;

    for (int i = X; i < MAX_N; i++) {
        if (sieve[i]) {
            std::cout << i << std::endl;
            break;
        }
    }
    
    return 0;
}

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

int search_up(const vector<int>& d,int k){

}

int search_low(const vector<int>& d,int k){
	
}



int N;
int main(){
	while(cin >> N && N>0){
		vector<int> A(N,0),B(N,0),C(N,0);
		long long ans = 0;
		for(int i=0;i<N;i++){
			cin >> A[i];
		}
		sort(A.begin(),A.end());
		for(int i=0;i<N;i++){
			cin >> B[i];
		}
		for(int i=0;i<N;i++){
			cin >> C[i];
		}
		sort(C.begin(),C.end());
		//reverse(C.begin(),C.end());
		for(int j=0;j<N;j++){
			decltype(A)::iterator it = lower_bound(A.begin(), A.end(), B[j]);
			decltype(C)::iterator it2 = upper_bound(C.begin(), C.end(), B[j]);
			ans += (it-A.begin())*(C.end()-it2);
		}
		cout << ans << endl;
	}
}

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

void fnInput(int& rnBasTmpr, int& rnTrgTmpr, vector<int>& rvnPosHeight)
{
  int nPosSiz;
  cin >> nPosSiz;
  cin >> rnBasTmpr >> rnTrgTmpr;

  rvnPosHeight.resize(nPosSiz);
  for (int& rnPosHeight : rvnPosHeight)
    cin >> rnPosHeight;
}

int fnTmprCheck(int nBasTmpr, int nTrgTmpr, const vector<int>& cnrvnPosHeight)
{
  double nMinDiff = (double)DBL_MAX;
  int nMinPos;

  for (int n = 0; n < cnrvnPosHeight.size(); n++)
  {
    double nPosDiff = abs((double)nBasTmpr - (double)cnrvnPosHeight[n] * 0.006 - (double)nTrgTmpr);
    if (nPosDiff < nMinDiff)
    {
      nMinDiff = nPosDiff;
      nMinPos  = n;
    }
  }
  return nMinPos + 1;
}

int main()
{
  int nBasTmpr, nTrgTmpr;
  vector<int> vnPosHeight;

  fnInput(nBasTmpr, nTrgTmpr, vnPosHeight);
  cout << fnTmprCheck(nBasTmpr, nTrgTmpr, vnPosHeight) << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
long a[444],sum[444],dp[444][444];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i],sum[i+1]=sum[i]+a[i];
	for(int i=n;i--;)
	{
		for(int j=i+2;j<=n;j++)
		{
			dp[i][j]=9e18;
			for(int k=i;k++<j;)
			{
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]+sum[j]-sum[i]);
			}
		}
	}
	cout<<dp[0][n]<<endl;
}

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author wnqmw
 */
public class Main {
    public static void main(String args[]){
        Scanner kb = new Scanner(System.in);
        int nums = kb.nextInt(), sel = kb.nextInt();

        int[] num = new int[nums];

        int total = 0, totalvotes = 0;
        for(int i = 0; i < nums; i++){
            num[i] = kb.nextInt();
            totalvotes += num[i];
        }

        Arrays.sort(num);
        float req = (float)(totalvotes)/(4*sel);
        for(int i = nums-1; i >= 0; i--){
            if(num[i] >= req){
                total++;
             //   if(total == sel){
             //       break;
             //   }
            }
        }

        if(total < sel){
            System.out.println("No");
        }else{
            System.out.println("Yes");
        }


    }
}


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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

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

int field[50][50] = {};

int w, h;

void dfs( int x, int y );

int main() {

	while( cin >> w >> h, w ) {
		REP( i, h ) {
			REP( j, w ) {
				cin >> field[j][i];
			}
		}

		int cnt = 0;
		REP( i, h ) {
			REP( j, w ) {
				if( field[j][i] == 1 ) {
					cnt++;
					dfs( j, i );
				}
			}
		}

		cout << cnt << endl;

	}

}

void dfs( int x, int y ) {
	field[x][y] = 0;
	REP( i, 8 ) {
		if( x + dx[i] >= 0 && x + dx[i] < w &&
			y + dy[i] >= 0 && y + dy[i] < h &&
			field[x + dx[i]][y + dy[i]] == 1 ) {

			dfs( x + dx[i], y + dy[i] );

		}

	}
}


Measured memory_bytes: 3168