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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	map<int,int> ind;
	map<int,int> cnt;
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
		ind[v[i]] = -1;
		//ind[v[i]].push_back(i);
		//cnt[v[i]]++;
	}
	vector<int> a = v;
	sort(a.begin(),a.end());
	for (int i = 0; i < n; ++i) {
		if (ind[a[i]] == -1) {
			ind[a[i]] = i;
		}
	}
	vector<int> ans(n);
	for (int i = 0;i < n; ++i) {
		int index = ind[v[i]] + cnt[v[i]];
		cnt[v[i]]++;
		if (index >= n / 2) {
			ans[i] = a[(n / 2) - 1];
		}else {
			ans[i] = a[n / 2];
		}
		//. . . . . . // (n/2) 
	}
	for (int i = 0; i < n; ++i) {
		cout << ans[i] << endl;
	} 
}




Measured memory_bytes: 23864
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readFloat64() float64 {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return float64(i)
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b, n := readFloat64(), readFloat64(), readInt()

	x := b - 1.0
	if int(x) > n {
		x = float64(n)
	}
	y := floor((a*x)/b) - int(a)*floor(x/b)

	fmt.Println(y)
}

func floor(a float64) int {
	return int(a)
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define endl '\n'

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;

const ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
// head

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

    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }

    ll cash = 1000;
    for(int i = 0; i < n; i++) {
        ll low = a[i];
        while(i + 1 < n && a[i + 1] > a[i]) i++;
        ll stonks = cash / low;
        cash += stonks * (a[i] - low);
    }
    cout << cash << endl;
    return 0;
}


Measured memory_bytes: 3556
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        // 入力
        long n = long.Parse(Console.ReadLine());
        long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();

        var dic = new Dictionary<long, long>() { };
        for (long i = 0; i < n; i++)
        {
            if (!dic.ContainsKey(a[i]))
            {
                dic.Add(a[i], 1);
            }
            else
            {
                dic[a[i]]++;
            }
        }

        for (long i = 0; i < n; i++)
        {
            if (dic[a[i]] < 2)
            {
                dic[a[i]] = 0;
            }
        }

        var tmp1 = new Dictionary<long, long>() { };
        foreach (var item in dic)
        {
            if (item.Value > 1)
            {
                tmp1.Add(item.Key, (item.Value * (item.Value - 1)) / 2);
            }
        }

        var tmp2 = new Dictionary<long, long>() { };
        foreach (var item in dic)
        {
            if (item.Value > 2)
            {
                tmp2.Add(item.Key, ((item.Value-1) * (item.Value - 2)) / 2);
            }
            else if (item.Value == 2)
            {
                tmp2.Add(item.Key, 0);
            }
        }

        long[] ans = new long[n];
        var sum = tmp1.Values.Sum();
        for (long i = 0; i < n; i++)
        {
            if (dic[a[i]] == 0)
            {
                ans[i] = sum;
            }
            else
            {
                ans[i] = sum - tmp1[a[i]] + tmp2[a[i]];
            }
        }

        for (long i = 0; i < n; i++)
        {
            Console.WriteLine(ans[i]);
        }

    }
}

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

using namespace std;

int main()

{
    long long int ans=0,i;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++){
        ans+=s[i]-'0';
    }
    if(ans%9){
        printf("No\n");
    }
    else{
         printf("Yes\n");
    }

    return 0;
}


Measured memory_bytes: 3748
#include <iostream>
#include <string>

using namespace std;

int main() {
	string str;
	while (true) {
		cin >> str;
		if (str.size() == 1 && str.at(0) == '0')
			break;
		int sum = 0;
		for (int i = 0; i < str.size(); i++)
			sum += str.at(i) - '0';
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define lp(n) for(int i = 0; i < n; i++)
using namespace std;
int main(){
  int n;
  unsigned long long A[45];
  A[0] = 1;
  A[1] = 1;
  for(int i = 2; i <= 44; i++) A[i] = A[i-1] + A[i-2];
  cin >> n;
  cout << A[n] << endl;
  return 0;
}



Measured memory_bytes: 3092
n = int(input())
s = [input() for _ in range(n)]
a = 0
b = 0
ab = 0
ans = 0
for i in range(n):
    ans += s[i].count('AB')
    if s[i][-1]=='A' and s[i][0]=='B':
        ab += 1
        continue
    if s[i][-1]=='A':
        a += 1
    if s[i][0]=='B':
        b += 1
if ab==0:
    ans += min(a,b)
elif a+b>0:
    ans += ab+min(a,b)
else:
    ans += ab-1
print(ans)

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, M;
    while (cin >> N >> M, N) {
        int D, P, res = 0;
        int Ps[11] = {0};
        for (int i=0; i<N; ++i) {
            cin >> D >> P;
            res += D * P;
            Ps[P] += D;
        }
        for (int i=10; i>=0; --i) {
            if (M <= Ps[i]) {
                res -= M * i;
                M = 0;
            } else {
                res -= Ps[i] * i;
                M -= Ps[i];
            }
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1196
it = lambda: list(map(int, input().strip().split()))

def solve():
    N = int(input())
    L = it()
    ans = 0
    for i in range(N):
        for j in range(i + 1, N):
            for k in range(j + 1, N):
                if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and L[i] + L[j] > L[k] and L[i] + L[k] > L[j] and L[k] + L[j] > L[i]:
                    ans += 1
    return ans


if __name__ == '__main__':
    ans = solve()
    print(ans)

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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	ll N, k, now = 0, step = 1;
	cin >> N >> k;
	REP(_, N - 1) {
		while (true) {
			ll next = now + step;
			ll nstep = next / k + 1;
			if (step == nstep)break;
			step = nstep;
		}
		now += step;
		//cerr << "test " << now << endl;
	}
	cout << now << endl;

	return 0;
}



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

using namespace std;

int main()
{
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);

	// ios_base::sync_with_stdio(false);
	// cin.tie(0);

	int n,x;
	cin >> n >> x;

	int m[n];
	int i,answer=0,min=99999;
	for (i=0;i<n;i++)
	{
		cin >> m[i];
		if (m[i]<min)
		{
			min = m[i];
		}
		if (m[i]<=x)
		{
			answer++;
			x -= m[i];
		}
	}
	answer += x/min;
	cout << answer;


	return 0;
}

Measured memory_bytes: 256
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
DP2 = lambda d1, d2: [[INIT_VAL]*d2 for _ in range(d1)]
DP3 = lambda d1, d2, d3: [[[INIT_VAL]*d3 for _ in range(d2)] for _ in range(d1)]

def main():
    n, k = MII()
    cnt = (n//k)**3
    if k%2==0:
        cnt += ((n+(k//2))//k)**3
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    int N, sum = 0, f = 0;
    cin >> N;
    vector<int> d(N);
    for(int i = 0; i < N; i++)
    {
        cin >> d.at(i);
    }
    for(int i = 0; i < N; i++)
    {
        for(int j = i + 1; j < N; j++)
        {
            sum += d.at(i)*d.at(j);
        }
    }
    cout << sum << endl;
    return 0;
}
 

Measured memory_bytes: 256
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  vector<int> a(3);
  rep(i, 3) cin >> a[i];

  sort(a.begin(), a.end());
  int ans = 0;
  if (a[2] % 2 != (a[0] + a[1] + a[2]) % 2) {
    ans++;
    a[2]++;
    rep(i, 2) {
      if (a[i] % 2 != a[2] % 2) {
        a[i]++;
      }
    }
  }
  else {
    if (a[0] % 2 != a[2] % 2) {
      ans++;
      rep(i, 2) a[i]++;
    }
  }

  rep(i, 2) ans += (a[2] - a[i]) / 2;
  cout << ans << endl;






  
  return 0;
}

Measured memory_bytes: 256
package main

import (
        "fmt"
)

func solution(n int, a []int) int {
        var out int = 1

        for _, num := range a {
                if num == 0 {
                        return 0
                }
        }
        for _, num := range a {
                if num <= 1e18/out {
                        out *= num
                } else {
                        return -1
                }
        }
        return out
}

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, 0, n)
        for i := 0; i < n; i++ {
                var t int
                fmt.Scan(&t)
                a = append(a, t)
        }
        fmt.Println(solution(n, a))
}

Measured memory_bytes: 6336
terms = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(terms[K-1])


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<=n;i++)
#define rep2(i,k,n) for(int i=k;i>=n;i--)
using namespace std;
const int N=1005;
const int M=1e6+7;
typedef unsigned long long ll;
ll a[N],stk[M];
int n,vis[M],K,top=0;
int main(){
	scanf("%d%d",&n,&K);
	rep(i,1,n)cin>>a[i];
	rep(i,1,n){
		ll S=0;
		rep(j,i,n){
			S+=a[j];
			stk[++top]=S;
		}
	}
	ll ans=0;
	rep2(i,63,0){
		int cnt=0;
		rep(j,1,top)if(!vis[j]){
			if((stk[j] >> i)&1){
				cnt++;
			}
		}
		if(cnt>=K){
			rep(j,1,top)if(!vis[j]){
				if(!((stk[j] >> i)&1)){
					vis[j]=1;
				}
			}
			ans|=(1ull<<i);
		}
	}
	cout<<ans;
}

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

using namespace std;

int i,j,k;

int main(){
    int k;
    long ans;
    ans=0;
    cin>>k;
    
    queue<long> que;
    for(i=1;i<=9;i++)que.push(i);
    REP(i,k){
        long x=que.front();
        que.pop();
        int t=x%10;
        if(t!=0){
            que.push(10*x+t-1);
        }
        que.push(10*x+t);
        if(t!=9){
            que.push(10*x+t+1);
        }
        ans=x;
    }
    
    

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


Measured memory_bytes: 1792
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

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

ll f(ll n, ll b)
{
  ll ret = 0;
  while (n) {
    ret += n % b;
    n /= b;
  }
  return ret;
}

int main()
{
  ll n, s;
  cin >> n >> s;

  if (n == s) {
    cout << (n + 1) << endl;
    return 0;
  }

  for (ll b = 2; b*b <= n; b++) {
    if (s == f(n, b)) {
      cout << b << endl;
      return 0;
    }
  }

  ll ans = LLINF;
  for (ll u = 1; u*u <= n; u++) {
    ll b = (n - s)/u + 1;
    if (b <= 1) continue;
    if (s == f(n, b)) ans = min(ans, b);
  }
  if (ans == LLINF) cout << -1 << endl;
  else cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

N = int(input())
yaku = set()
for x in range(1,int(math.sqrt(N))+1):
    if N % x == 0:
        yaku.add(x)
        yaku.add(N//x)

yaku = sorted(list(yaku))
L = len(yaku)
ans = 0
for i in range(1,L):
    if yaku[i] - yaku[i-1] !=1:
        tmp = yaku[i]-1
        if N//tmp == N%tmp:
            ans += tmp

print(ans)


Measured memory_bytes: 5012
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 1e6 + 7;
const ll inf = 1e9 + 7;

int main()
{
    //ios::sync_with_stdio(0); cin.tie(0); //C++关同步
    string s;
    cin >> s;
    cout << s.substr(0, 3) << '\n';
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#include<set>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;
long long  gcd(long long  a,long long  b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

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

set<long long >s;
vector<long long>v(N);

bool exist=false;
//bool possible=false;
bool odd_exist=false;
bool even_exist=false;
rep(i,N){
    cin>>v[i];
    s.insert(v[i]);
    if(v[i]==K){
        cout<<"POSSIBLE"<<endl;
        exist=true;
        return 0;
    }
    if(v[i%2==0])even_exist=true;
    else odd_exist=true;
}
//if(N==1 && !exist)possible=false;

//if(K%2!=0 && !odd_exist)possible=false;
//else possible=true;

sort(v.begin(),v.end());

if(K>v[N-1]){
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}
long long g=v[N-1];


rep(i,N){
    g=gcd(g,v[i]);
}
if(K%g==0){
    cout<<"POSSIBLE"<<endl;
    return 0;
}
else{
    cout<<"IMPOSSIBLE"<<endl;
    return 0;
}


 return 0;
}
/*
3 7
9 3 4

POSSIBLE


3 5
6 9 3

IMPOSSIBLE


4 11
11 3 7 15

POSSIBLE


5 12
10 2 8 6 4

IMPOSSIBLE
*/

Measured memory_bytes: 5760
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        
        int a=N/1000%10;
        int b=N/100%10;
        int c=N/10%10;
        int d=N/1%10;
        
        if((a==b&&b==c)||(b==c&&c==d)){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true){
        int n=114514;
        double stu[n];
        double ave=0,bun=0;
        cin>>n;
        if(n==0)break;
        for (int i = 0; i < n; i++){
            cin>>stu[i];
            ave+=stu[i];
        }
        ave=ave/n;
        for (int i = 0; i < n; i++){
            bun+=pow((ave-stu[i]),2);
        }
        printf("%.5f\n",sqrt(bun/n));
    }
}


Measured memory_bytes: 3244
#include <iostream>
using namespace std;
int n,a[100010],arr[5],x,y;
int main() {
	cin>>n;
	for(int i=1;i<=n;i++) {
		cin>>a[i];
		if(a[i]%4==0) {
			arr[4]++;
		}
		else if(a[i]%2==0) {
			arr[2]++;
		} else {
			arr[0]++;
		}
	}
	if(arr[2])arr[0]++;
	if(arr[0]-1>arr[4]) {
		cout<<"No"<<endl;
	} else {
		cout<<"Yes"<<endl;
	}
}
	

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i, n) {
        int x;
        cin >> x;
        ans += min(x, abs(x - k));
    }
    cout << ans * 2 << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
 class Main
{
public static void main(String arg[])
{
Scanner s=new Scanner(System.in);
long n=s.nextLong();
long count=0,min=Long.MAX_VALUE;
for(int i=1;i<=(int)Math.sqrt(n);i++)
{if(n%i==0)
{count=(i-1)+(n/i)-1;
if(count<min)
min=count;}}
System.out.println(min);}}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;
 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define pii pair<int, int>
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define tiii tuple<ll, ll, ll>
#define INF 1e18
#define MOD 1000000007


int main(){
	fast;

	int N;
	cin >> N;
	vector<ll> divisors(N + 1, 2);
	divisors[1] = 1;

	for (int i = 2; i <= (N / 2); i++) {
		for (int j = 2 * i; j <= N; j += i) {
			divisors[j] += 1;
		}
	}

	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		// cout << divisors[i] << " ";
		ans += i * divisors[i];
	}
	// cout << "\n";

	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 81336
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<map>
using  namespace std;
typedef long long ll;
const int maxn=1e4+50;
int main()
{
	double ans1,w,h;
	ll x,y,ans2;
	scanf("%lf%lf%lld%lld",&w,&h,&x,&y);
	ans1=w*h/2;
	if(x==w/2&&y==h/2)ans2=1;
	else ans2=0;
	printf("%.6lf %d\n",ans1,ans2);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func absInt(a int) int {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var A, B int
var S string

const MAX = 100000 * 2

func main() {
	sc.Split(bufio.ScanWords)

	A, B = nextInt(), nextInt()
	S = nextStr()

	ans := "Yes"
	if string(S[A]) == "-" {
		for i := 0; i < len(S); i++ {
			if i == A {
				continue
			}
			_, err := strconv.Atoi(string(S[i]))
			if err != nil {
				ans = "No"
				break
			}
		}
	} else {
		ans = "No"
	}
	fmt.Println(ans)

}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n = sc.nextInt();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long[] h = new long[n];
		for(int i = 0; i<n; i++){
			h[i] = sc.nextLong();
		}
		long tmax=1000000000;
		long tmin=0;
		while(tmax-tmin>1){
			int k = 0;
			long t =(tmax+tmin)/2;
			for(int i = 0; i<n; i++){
				if(h[i]>b*t){
					k+=Math.ceil((double)(h[i]-b*t)/(double)(a-b));
				}
			}
			if(k>t){
				tmin=t;
			}else{
				tmax=t;
			}
		}
		System.out.println(tmax);
	}
}


Measured memory_bytes: 50232
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://arc060.contest.atcoder.jp/tasks/arc060_c>
 問題文============================================================
 N 軒のホテルが一直線上に並んでいます。i (1≤i≤N) 番目のホテルは、座標 xi に位置しています。
 
 旅行者である高橋君には、次の 2 つの信念があります。
 
 高橋君の 1 日の移動距離は L を超えない。
 高橋君は野宿をしない。すなわち、1 日の終わりには必ずいずれかのホテルにいなければならない。
 
 Q 個のクエリが与えられます。j (1≤j≤Q) 番目のクエリとして、異なる 2 つの整数 aj, bj が与えられます。
 各クエリについて、前述の信念をともに守った上で、
 高橋君が aj 番目のホテルから bj 番目のホテルに移動するために必要な最小日数を求めてください。
 なお、高橋君が aj 番目のホテルから bj 番目のホテルに移動できることは保証されます。
 =================================================================
 解説=============================================================
 ================================================================
 */

ll check(ll i,ll d,vector<vector<ll>>& next){
    if(d == 0) return i;
    ll k = 0;
    while(d >= (1<<k)) k++;
    return check(next[k-1][i],d - (1<<(k-1)),next);
}
void solve(){
    ll N; cin >> N;
    vector<ll> x(N); for(auto& in:x) cin >> in;
    ll L; cin >> L;
    ll Q; cin >> Q;
    vector<ll> a(Q),b(Q);
    for(int i = 0; i < Q;i++){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        if(a[i] > b[i]) swap(a[i],b[i]);
    }
    
    ll LOG_N = 0;
    while(N >= (1<<LOG_N)) LOG_N++;
    vector<vector<ll>> next(LOG_N,vector<ll>(N));
    for(int i = 0; i < N;i++){
        next[0][i] = upper_bound(x.begin(), x.end(), x[i]+L) - x.begin() - 1;
    }
    for(int k = 0; k < LOG_N-1; k++){
        for(int i = 0; i < N;i++){
            next[k+1][i] = next[k][next[k][i]];
        }
    }
    for(int i = 0; i < Q;i++){
        ll _a = a[i], _b = b[i];
        ll l = 0, r = N;
        while(r-l>1){
            ll m = (l+r)/2;
            
            // a番目の要素のm個次の要素を求める
            ll p = _a;
            for(ll k = LOG_N-1; k>=0; k--){
                if((m>>k)&1){
                    p = next[k][p];
                }
            }
            if(p >= _b){
                r = m;
            }else{
                l = m;
            }
        }
        cout << r << endl;
    }
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 16768
using System;

namespace ITP1_10_D
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string[] inputx = Console.ReadLine().Split(' ');
            string[] inputy = Console.ReadLine().Split(' ');

            double D1 = 0;
            double D2 = 0;
            double D3 = 0;
            double D8 = 0;
            double dis1 = 0;
            double dis2 = 0;
            double dis3 = 0;
            double dis8 = 0;

            for (int i = 0; i < num; i++)
            {
                dis1 = Math.Abs(double.Parse(inputx[i]) - double.Parse(inputy[i]));
                D1 += dis1;
                dis2 += Math.Pow(dis1, 2);
                dis3 += Math.Pow(dis1, 3); 

                if (dis8 < dis1)
                {
                    dis8 = dis1;
                }
            }

            D2 = Math.Sqrt(dis2);
            D3 = Math.Pow(dis3, 1.0 / 3.0);
            D8 = dis8;

            Console.WriteLine("{0:f6}", D1);
            Console.WriteLine("{0:f6}", D2);
            Console.WriteLine("{0:f6}", D3);
            Console.WriteLine("{0:f6}", D8);
        }
    }
}

Measured memory_bytes: 9504
n = int(input())
a = list(map(int, input().split()))

org = [[i, a[i]] for i in range(n)]

lis = sorted(org, key=lambda x: x[1], reverse=True)

dp = [[0 for i in range(n+1)] for j in range(n+1)]


for i in range(0, n, 1):
    for j in range(0, n-i, 1):
        if i + j == n:
            break
            
        dp[i+1][j] = max(dp[i+1][j], dp[i][j] + lis[i+j][1]*abs(lis[i+j][0] - i))
        dp[i][j+1] = max(dp[i][j+1], dp[i][j] + lis[i+j][1]*abs(lis[i+j][0] - (n-j-1)))

ans = 0
for i in range(n):
    for j in range(n):
        ans = max(ans, dp[i][j])
        
print(ans)

Measured memory_bytes: 102192
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for i in range(N)]
Answer = 0
count = 0

for i in range(N):
  for j in range(M):
    Answer += A[i][j]*B[j]
  Answer += C
  if Answer > 0:
    count += 1
    Answer = 0
  else:
    Answer = 0

print(count)


Measured memory_bytes: 3316
var
	s:array[1..100]of String[10];
	n,i,j:Longint;
begin
	readln(n);
	readln(s[1]);
	for i:=2 to n do begin
		readln(s[i]);
		if s[i-1][length(s[i-1])]<>s[i][1] then begin
			writeln('No');
			exit;
		end;
		for j:=1 to i-1 do begin
			if s[i]=s[j] then begin
				writeln('No');
				exit;
			end;
		end;
	end;
	writeln('Yes');
end.


Measured memory_bytes: 128
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
p = [0]*M
S = [""]*M
for i in range(M):
	p[i], S[i] = input().split()
	p[i] = int(p[i])

ac = 0
wa = 0
dic = defaultdict(int)
for i in range(M):
	if S[i] == "AC":
		if dic[p[i]] == -1:
			continue
		ac += 1
		wa += dic[p[i]]
		dic[p[i]] = -1
	else:
		if dic[p[i]] == -1:
			continue
		dic[p[i]] += 1
print(ac, wa)


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

int main()
{
  string S;
  int min = 1000000;
  
  cin >> S;
  
  for (int i = 0; i < 2; i++) {
    int count = 0;
    for (int j = 0; j < S.length(); j++) {
      if (j % 2 == 0 && S[j] == (i + '0')) count++;
      if (j % 2 == 1 && S[j] != (i + '0')) count++;
    }
    if (min > count) {
      min = count;
    }
  }
  
  cout << min << endl;
  
  return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int a,b,c;
	std::cin >> a >> b >> c;
	
	if(a+b>=c){
	    std::cout << "Yes" << std::endl;
	}else{
	    std::cout << "No" << std::endl;
	}
	return 0;
}

Measured memory_bytes: 256
n,y = map(int,input().split())
a,b,c = -1,-1,-1
for i in range(n+1):
    for j in range(n-i+1):
        k = n - i -j
        if 10000*i + 5000*j + 1000*k == y:
            a,b,c = i,j,k
            break
print(a,b,c)

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

int main(){
  int n,k,count=0;
  cin >> n >> k;
  vector<int> h(n);
  rep(i,n)
    cin >> h[i];
  rep(i,n){
    if(h[i]>=k)
      count++;
  }
  cout << count;
}

Measured memory_bytes: 640
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let m: i32 = read();
    println!("{}", 48 - m);
}

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
IDENTIFICATION DIVISION.
PROGRAM-ID. B-Bishop.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP PIC X(22).
01 H   PIC 9(10).
01 W   PIC 9(10).
01 S1  PIC 9(10).
01 S2  PIC 9(10).
01 OUT PIC Z(19)9.
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ' ' 
      INTO H W. 
*>
  IF (H = 1 OR W = 1)
    MOVE 1 TO OUT
  ELSE
    COMPUTE S1 = H / 2
    COMPUTE S2 = W / 2
    IF (H = S1 * 2) OR (W = S2 * 2)
      COMPUTE OUT = H * W / 2 
    ELSE
      COMPUTE OUT = H * W / 2 + 1
    END-IF
  END-IF.
  DISPLAY FUNCTION TRIM(OUT).
*>
  STOP RUN.


Measured memory_bytes: 764
n = int(input())
p_list = list(map(int, input().split()))
count = 0
for i in range(1,n-1):
    if p_list[i-1] < p_list[i] < p_list[i+1] or p_list[i+1] < p_list[i] < p_list[i-1]:
        count += 1
print(count)

Measured memory_bytes: 3060
// C++ program to find 3 elements such that max(abs(A[i]-B[j]), abs(B[j]- 
// C[k]), abs(C[k]-A[i])) is minimized. 
  
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back  
#define MOD 998244353 
// Driver program 


int main() 
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int j=1;
  while(1){
    if(j%2) c-=b;
    else a-=d;
    if(c<=0 || a<=0) break;
    else j++;
  }
  if(j%2){
    cout<<"Yes";

  }
  else cout<<"No";
} 

Measured memory_bytes: 3632
while True :
	D, E = map(int, input().split())
	if(D == 0) :
		break
	else :
		ans = 100
		for i in range((D // 2) + 1) :
			A = (i ** 2 + (D - i) ** 2) ** (1/2)
			a = abs(A - E)
			if(a < ans) :
				ans = a
			else :
				pass
		print(ans)


Measured memory_bytes: 5652
#include<iostream>
#include<cstring>
using namespace std;
int a,b,c,x;
int sum=0;
int main()
{
	cin>>a>>b>>c>>x;
	int i,j,k;
	for( i=0;i<=a;i++)
	{
		for( j=0;j<=b;j++)
		{
			for( k=0;k<=c;k++)
			{
				if(500*i+100*j+50*k==x)
				{
					sum++;
				}
				if(500*i+100*j+50*k>x)
				{
					break;
				}
			}
		
		}
	
	}
	cout<<sum<<endl;
	return 0;
 } 

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define pai 3.1415926535


int main(void) {

	int N;
	scanf("%d", &N);
	char S[101], T[101];
	scanf("%s %s", S, T);
	char X[201];
	int count = 0;
	for (int i = 0; i < N; i++) {
		X[count] = S[i];
		count += 2;
	}
	count = 1;
	for (int j = 0; j < N; j++) {
		X[count] = T[j];
		count += 2;
	}
	X[strlen(S) + strlen(T)] = '\0';
	printf("%s", X);
	return 0;


}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<cstdio>
using namespace std;
#define MAX 10001
int main(){
    int A[MAX];
    int a;
    int now =0;
    for (int i=0;i<MAX;i++){
        scanf("%d",&A[i]);
        if(A[i] == 0){
            break;
        }else
        {
            now++;
        }
        
    }
    for (int j=0;j<now;j++){
        printf("Case %d: %d\n",j+1,A[j]);
    }
    return 0;
}


Measured memory_bytes: 3172
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <list>
#include <set>
using namespace  std;

constexpr int INF = std::numeric_limits<int>::max();

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;

    double ans = 0;
    for (int i = 1; i <= N; i++) {
        double p = 1.0 / N;
        int score = i;

        while (score < K) {
            score *= 2;
            p /= 2;
        }
        ans += p;
    }

    printf("%.9lf\n", ans);
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AizuOnLine_Lesson
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] line = System.Console.ReadLine().Split(' ');
            int num1 = Convert.ToInt32(line[0]);
            int num2 = Convert.ToInt32(line[1]);

            int area = num1 * num2;
            int nagasa = (num1 + num2) * 2;
        
            Console.WriteLine(string.Format("{0} {1}", area, nagasa));
        }
    }
}

Measured memory_bytes: 5680
#include <iostream>
#include <cmath>
#define SIZE 1010
using namespace std;
int main(){
    int N;
    cin >> N;
    int list[SIZE] = {0};
    for(int i=2; i<=N; i++){
        int x = i;
        int y = 2;
        while(y<=x){
            if(x%y == 0){
                list[y]++;
                x /= y;
            }else{
                y++;
            }
        }
    }
    long long x = 1;
    for(int i=0; i<SIZE; i++){
        x %= (1000000000+7);
        x *= (list[i]+1)%(1000000000+7);
    }
    cout << x;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
import java.util.Arrays;

public class Main {
	public static void main(final String[] args){
    
    final Scanner sc = new Scanner(System.in);
    final List<Integer> list = new ArrayList<>();
    String result = "abcdefghijklmnopqrstuvwxyz";
    int num = 0;
    char c = sc.next().charAt(0);

    for(int i = 0 ; i < result.length() ; i++){
        if(c == result.charAt(i)){
            num = i + 1;
        }
    }

    System.out.println(result.charAt(num));












    
    






    

    



    
  

    


    


    

    
    
    



    





}
}

Measured memory_bytes: 35448
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <tuple>
#include <queue>
#include <deque>
using namespace std;
using ll=long long;
#define INF 2100000000

ll gcd(ll A,ll B){
  while(A%B!=0){
    ll tmp=A%B;
    A=B;
    B=tmp;
  }
  return B;
}

int main(){
  int T;
  cin>>T;
  vector<ll> a(T),b(T),c(T),d(T);
  for(int i=0;i<T;i++){
    cin>>a.at(i)>>b.at(i)>>c.at(i)>>d.at(i);
  }

  for(int i=0;i<T;i++){
    ll A=a.at(i);
    ll B=b.at(i);
    ll C=c.at(i);
    ll D=d.at(i);
    if(B>D){
      cout<<"No"<<endl;
    }else if(B==D){
      if(A<B){
        cout<<"No"<<endl;
        continue;
      }
      ll x=A%B;
      ll y=C/B;
      ll A=(y+2)*B+x;
      while(A>C){
        A-=B;
      }
      if(A<0){
        cout<<"No"<<endl;
      }else{
        cout<<"Yes"<<endl;
      }
    }else{
      if(A<B){
        cout<<"No"<<endl;
        continue;
      }else if(A<=D){
        ll x=D-B;
        ll y=(D-A)/x;
        A+=x*(y+1);
      }
      ll x=A%B;
      ll y=C/B;
      ll A=y*B+x;
      if(A>C){
        A-=B;
      }
      ll g=gcd(B,D);
      A+=((C-A)/g+1)*g;
      if(A-B>=0){
        cout<<"Yes"<<endl;
      }else{
        cout<<"No"<<endl;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}  
bool isPowerOfTwo(ll x)
{
    // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
    return (x && !(x & (x - 1)));
} 

void solve()
{
	ll n;
	cin>>n;
	ll x=n/1000;
	if(n%1000!=0) x+=1;
	cout<<x*1000-n<<"\n";
}


int main()       
{
  fastio
  ll t=1;
  while(t--)
    solve();
  return 0;
}

Measured memory_bytes: 3664
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e18;
const int mod=1e9+7;
const int M=100005;

 main()

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

}





































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

// #define ONLINE_JUDGE

#define V vector
#define P pair

using LL = long long;
#define FOR(i, x, y) \
    for (decay<decltype(y)>::type i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) \
    for (decay<decltype(x)>::type i = (x), _##i = (y); i > _##i; --i)
#ifndef ONLINE_JUDGE
#define dbg(x...)                             \
    do {                                      \
        cerr << "\033[32;1m" << #x << " -> "; \
        err(x);                               \
    } while (0)
void err() { cerr << "\033[39;0m" << endl; }
template <template <typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) {
    for (auto v : a) cerr << v << ' ';
    err(x...);
}
template <typename T, typename... A>
void err(T a, A... x) {
    cerr << a << ' ';
    err(x...);
}
#else
#define dbg(...)
#endif
#define sz(x) (int)x.size()

LL bin(LL a, LL b, LL p) {
    LL res = 1;
    a = (a % p + p) % p;
    for (; b; b >>= 1, a = a * a % p)
        if (b & 1) res = res * a % p;

    return res;
}

const int N = 1e5+50;


void solve() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i=a; i<=b; ++i) {
        if (i % k == 0) {
            puts("OK");
            return;
        }
    }
    puts("NG");
}

int main() {

    // int t;
    // cin >> t;
    // while (t--) solve();

    solve();

    return 0;
}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String numbers = sc.next();
		int A = Integer.valueOf(numbers.substring(0,1));
		int B = Integer.valueOf(numbers.substring(1,2));
		int C = Integer.valueOf(numbers.substring(2,3));
		int D = Integer.valueOf(numbers.substring(3,4));
		sc.close();
		int[] ticket = {B,C,D};
		String[] op = {"000",
		"001",
		"010",
		"011",
		"100",
		"101",
		"110",
		"111"
		};
		for(int i = 0; i < op.length; i++){
          	int ans = A;
			for(int j = 0; j < ticket.length; j++){
				if(op[i].charAt(j) == "0".charAt(0)) { ans -= ticket[j]; }
				if(op[i].charAt(j) == "1".charAt(0)){ ans += ticket[j]; }
				if(j == 2 && ans == 7){
					String out = String.valueOf(A) + printOp(op[i].substring(0, 1)) + String.valueOf(B)
			+ printOp(op[i].substring(1, 2)) + String.valueOf(C) + printOp(op[i].substring(2, 3)) + String.valueOf(D) + "=7";
					System.out.println(out);
					return;
				}
			}
			// System.out.println(ans);
		}
	}

	static String printOp(String op){
		if(op.equals("0")) return "-";
		return "+";
	}

}


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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<LL> PQ_DESC;
typedef priority_queue<LL, VL, greater<LL>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
typedef priority_queue<VL> PQ_DESC_VL;
typedef priority_queue<VL, vector<VL>, greater<VL>> PQ_ASC_VL;
typedef priority_queue<PLL> PQ_DESC_PLL;
typedef priority_queue<PLL, vector<PLL>, greater<PLL>> PQ_ASC_PLL;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF*(LL)INF;
const int MOD = 1e9+7;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

void Main()
{
    int n;cin>>n;
    int top = 0;
    int result = 0;
    REP(i,n){
        int h;cin>>h;
        if(h>=top){
            result++;
        }
        top = max(top,h);
    }
    cout<<result<<endl;
    
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
    return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {

	int n;
	int kaisu;
	int team[100][3] = {0};
	int teamn[100];
	int a,b,c,d;
	int kari;
	int juni = 1;
	int counter = 1;
	
	cin >> n;
	kaisu = n * (n - 1) / 2;

	for (int i = 0; i < n; i++) {
		team[i][0] = i;
	}

	for (int i = 0; i < kaisu; i++) {
		cin >> a >> b >> c >> d;
		if (c > d) {
			team[a-1][1] += 3;
		} else if ( c < d) {
			team[b-1][1] += 3;
		} else {
			team[a-1][1] += 1;
			team[b-1][1] += 1;
		}
	}

	for (int i = n-1; i > 0; i--) {
		for (int j = 0; j < i; j++) {
			if (team[j][1] < team[j+1][1]) {
				for (int k = 0; k < 2; k++) {
					kari = team[j][k];
					team[j][k] = team[j+1][k];
					team[j+1][k] = kari;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		team[i][2] = juni;
		if (team[i][1] > team[i+1][1]) {
			juni += counter;
			counter = 1;
		} else {
			counter++;
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (team[j][0] == i) {
				cout << team[j][2] << endl;
				break;
			}
		}
	}
	return 0;
}

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

int main() {
  int N, M;
  cin >> N;
  
  map<string, int> m;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    
    if (m.count(s)) {
      m.at(s)++;
    } else {
      m[s] = 1;
    }
  }
  
  cin >> M;
  for (int i = 0; i < M; i++) {
    string s;
    cin >> s;
    
    if (m.count(s)) {
      m.at(s)--;
    } else {
      m[s] = -1;
    }
  }
  
  int ans = 0;
  for (auto x : m) {
    if (x.second > ans) {
      ans = x.second;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define OUT(a) cout << (a) << "\n"

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;

const ll MOD = 10e9 + 7;

int main() {
    int a;
  	string s;
  	cin >> a >> s;
  	if (a < 3200) s = "red";
  	cout << s << endl;
    return 0;
}


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

#define F first
#define S second
#define pb push_back

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int a[MAXN];

int ptr = 1;

int H, W;

int c[111][111];

void go(int i, int how) {
	if (how) {
		for (int j = 1; j <= W; j++) {
			c[i][j] = ptr;
			a[ptr]--; 
			if (a[ptr] == 0) {
				ptr++;
			}			
		}
	} else {
	    for (int j = W; j >= 1; j--) {
			c[i][j] = ptr;
			a[ptr]--; 
			if (a[ptr] == 0) {
				ptr++;
			}			
		}
	}
}

int main() {
	
    H = readInt(), W= readInt();
    int n = readInt();
    for (int i = 1; i <= n; i++) {
    	a[i] = readInt();
    }
	for (int i = 1; i <= H; i++) {
		go(i, i % 2);
	}
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cout << c[i][j] << ' ';
		}
		cout << endl;
	}
    return 0;
}

Measured memory_bytes: 764