akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <ctype.h>
 
using namespace std;
 
int main(void) {
  string S;
  cin >> S;
  if(S[0] == 'A'){
    int N = S.size();
    int T = 0;
    int X = 0;
    for(int i = 1; i < N; i++){
      if(S[i] == 'C' && i > 1 && N - i > 1){
        T++;
      }else if(isupper(S[i])){
        X++;
      }else if(S[i] == 'C'){
        X++;
      }
    }
    if(T == 1 && X == 0){
      printf("AC");
    }else{
      printf("WA");
    }
  }else{
    printf("WA");
  }
  return 0;
}

Measured memory_bytes: 256
'use strict';
const main = input => {
  let s = input[0], ans = '';
  for(let i=0; i<s.length; i++) {
    ans += String.fromCharCode(s.charCodeAt(i)+1);
  }
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
#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 rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define mp(a,b) make_pair(a,b)
#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())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

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

#define INF INT_MAX/3
#define MAX_N 1000
ll n,x;
std::vector<ll> a,p;

ll rec(ll n,ll x){
  if(n==0) if(x<=0) return 0;
  if(n==0) if(x>0) return 1;
  if(x<=1+a[n-1]) return rec(n-1,x-1);
  else return p[n-1] + 1 + rec(n-1,x-2-a[n-1]);
}
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>x;
  // a.resize(n);p.resize(n);
  rep(i,n+1){
    if(i==0) {
      a.pb(1);
      p.pb(1);
    } else {
      a.pb(2*a[i-1]+3);
      p.pb(2*p[i-1]+1);
    }
  }
  cout<<rec(n,x)<<endl;

}
int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	a := make([]int, 3)
	fmt.Scan(&a[0], &a[1], &a[2])
	sort.Sort(sort.Reverse(sort.IntSlice(a)))
	fmt.Println((a[0]*10 + a[1]) + a[2])
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <string>
#include <algorithm>
#include <set>
using namespace std;
#define ll long long
const int maxn = 1e5 + 10;
int b[maxn] = {0}, l[maxn] = {0}, u[maxn] = {0};
long long pre[maxn] = {0}, sum[maxn] = {0};

int mult(int who, int k){
    if(k >= b[who]){return u[who];}
    return l[who];
}

pair <long long, int> a[maxn];

bool check(int n, int m, int k){
    for(int i = 1; i <= m; i++){
        int p = a[i].second;
        //int p = G[i - 1].second;
        int multi = mult(p, k);
        long long a1 = sum[m + 1] - sum[i] + sum[i - 1] + (long long)(k - b[p]) * multi;
        long long a2 = pre[n] - pre[m + 1];
        if(a1 >= a2){
            return true;
        }
    }
    for(int i = m + 1; i <= n; i++){
        int p = a[i].second;
        //int p = G[i - 1].second;
        int multi = mult(p, k);
        long long a1 = sum[m] + (long long)(k - b[p]) * multi;
        long long a2 = pre[n] - pre[i] + pre[i - 1] - pre[m];
        if(a1 >= a2){return true;}
    }
    return false;
}

int main(){
    int n, x;
    scanf("%d%d", &n, &x);
    for(int i = 1; i <= n; i++){
        scanf("%d%d%d", &b[i], &l[i], &u[i]);
        long long anw = (long long)b[i] * l[i] + (long long)(x - b[i]) * u[i];
        a[i] = make_pair(anw, i);
    }
    sort(a + 1, a + 1 + n);
    reverse(a + 1, a + 1 + n);
    for(int i = 1; i <= n; i++){
        int j = a[i].second;
        pre[i] = pre[i - 1] + (long long)b[j] * l[j];
        sum[i] = sum[i - 1] + (long long)(x - b[j]) * u[j];
    }
    long long L1 = 0, R = (long long)n * x;
    while(L1 < R){
        long long mid = (L1 + R) >> 1;
        if(check(n, mid / x, mid % x)){
            R = mid;
        }
        else{
            L1 = mid + 1;
        }
    }
    printf("%lld", L1);
    return 0;
}


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

int ans=0;
int main(){
  int A,B;
  cin>>A>>B;
  for (A;A<=B;A++){
    int AA=A;
    if(AA%10==AA/10000){
      AA-=(AA/10000)*10000;
      AA/=10;
      if(AA%10==AA/100){
        ans++;
      }
    }
  }
  cout<<ans<<endl;
}

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

// 

public class Procon2019_A // ←Class名変更！！
{
    public static void Main()
    {
        var n = Ria();

        var min = (n[1] + n[2]) - n[0];
        if (min<0)
        {
            min = 0;
        }

        var max = n[1] < n[2] ? n[1] : n[2];

        WriteLine($"{max} {min}");

    } // Main

    public static string Rs() { return ReadLine(); }
    public static char Rc() { var c = ReadLine(); return c[0]; }    //最初の1文字だけ返す
    public static int Ri() { return int.Parse(ReadLine()); }
    public static long Rl() { return long.Parse(ReadLine()); }
    public static char[] Rca() { return ReadLine().ToCharArray(); }
    public static int[] Ria() { return Array.ConvertAll(ReadLine().Split(' '), int.Parse); }
    public static long[] Rla() { return Array.ConvertAll(ReadLine().Split(' '), long.Parse); }
} // Class


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;

#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////////////////

ll b[10]={0,2,5,5,4,5,6,3,7,6};

int main(){fastio;
    ll n,m;cin>>n>>m;
    ll a[m];
    rep(i,0,m-1){
        cin>>a[i];
    }
    sort(a,a+m);
    ll dp[m+1][n+1];rep(i,0,m)rep(j,0,n)dp[i][j]=-100;
    dp[0][0]=0;
    rep(i,0,m-1){
        rep(j,0,n){
            dp[i+1][j]=dp[i][j];
            if(j-b[a[i]]>=0)Max(dp[i+1][j],1+dp[i+1][j-b[a[i]]]);
        }
    }
    /*rep(i,0,m){
        rep(j,0,n){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll res=n,pos=m;
    while(res>0){
        while(res-b[a[pos-1]]>=0&&dp[pos][res-b[a[pos-1]]]+1==dp[pos][res]){
            cout<<a[pos-1];
            res-=b[a[pos-1]];
        }
        pos--;
    }

    
    return 0;
}





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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

ll dp[101][101010] = {0};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> v;
  v.push_back(1);
  for (ll i = 6; i <= n; i *= 6) v.push_back(i);
  for (ll i = 9; i <= n; i *= 9) v.push_back(i);
  int m = v.size();

  ll INF = 10000000000;
  for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) dp[j][i] = INF;
  dp[0][0] = 0;
  for (int i = 0; i < m; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
      if (j + v[i] <= n) {
        dp[i][j + v[i]] = min(dp[i][j + v[i]], dp[i][j] + 1);
      }
    }
  }
  cout << dp[m][n] << endl;
  return 0;
}


Measured memory_bytes: 12672
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	a := nextString()
	b := nextString()
	ab := ""
	ba := ""
	int_a, err := strconv.Atoi(a)
	if err != nil {
		log.Println(err)
	}
	int_b, err := strconv.Atoi(b)
	for i := 0; i < int_b; i++ {
		ab += a
	}
	for i := 0; i < int_a; i++ {
		ba += b
	}
	if strings.Compare(ab, ba) < 0 {
		fmt.Println(ab)
	} else {
		fmt.Println(ba)
	}
}

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

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

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;

#define debug(x) cerr<<#x<<'='<<x<<'\n'
unsigned long long N, n, w, h;
int main(void) {
	cin>>N;
	bool flag=false;
	for (n=1; n<=3500; n++) {
		for (h=1; h<=3500; h++) {
		//	if (n==3498 && h==3498) flag=true;
			if (flag) {
				debug(-N*n*h*1.0/(N*n+N*h-4*n*h));
			}
			int tmp=4*h*n-N*n-N*h;
			if (flag) debug(tmp);
			long double f=(long double)N*h*n/(long double)tmp;
			if (flag) {
				debug(N*h*n);
				debug(f);
			}
			if (f-(int)f==0 && f<=3500 && f>0) {
				w=f;
				cout<<h<<' '<<n<<' '<<w<<'\n';
				return 0;
			}
			flag=false;
		}
	}
}

Measured memory_bytes: 256
m,d = map(int,input().split())
cnt = 0
for i in range(1,d+1):
    s = str(i)
    if len(s) ==2:
        num = int(s[0]) * int(s[1])
        if int(s[0]) >=2 and int(s[1]) >=2:
            if num <=m:
                cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <stack>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> G[N], cost[N];
    for (int i = 0; i < N - 1; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        G[u].push_back(v); G[v].push_back(u);
        cost[u].push_back(w); cost[v].push_back(w);
    }

    vector<int> res(N, -1);
    res[0] = 0;
    stack<int> s;
    s.push(0);
    while (!s.empty()) {
        int v = s.top(); s.pop();
        for (int i = 0; i < G[v].size(); i++) {
            int u = G[v][i];
            int w = cost[v][i];

            if (res[u] != -1) continue;
            res[u] = (res[v] + w) % 2;
            s.push(u);
        }
    }

    for (int i = 0; i < N; i++)
        cout << res[i] << endl;
    return 0;
}


Measured memory_bytes: 11904
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//*********************************************************
// 最大公約数（Greatest Common Divisor）を返す。
//*********************************************************
ll gcd(ll a, ll b)
{
	ll tmp, r;
	if (a < b) {
		tmp = a;
		a = b;
		b = tmp;
	}

	/* ユークリッドの互除法 */
	r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}
int main(int argc, char* argv[]) {
	ll n, r = 0, g = 0, b = 0, answer = 0;
	string s;
	cin >> n;
	cin >> s;
	for (int i = 0; i < s.length(); i++)
	{
		if (s[i] == 'R')
		{
			r++;
		}
		else if (s[i] == 'G')
		{
			g++;
		}
		else if (s[i] == 'B')
		{
			b++;
		}
	}
	answer = r * b * g;
	for (int i = 0; i < s.length(); i++)
	{
		for (int j = i + 1; j < s.length(); j++)
		{
			int k = j + (j - i);
			if (k < s.length() && s[i] != s[j] && s[i] != s[k] && s[k] != s[j])
			{
				answer--;
			}
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<map>
#include<vector>
using namespace std;

int main(){
    int N,M;
    cin >> N >> M;
    int a,b;
    map<int,int> m;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        if(a==1){
            m[b]++;
        }
        if(b==N){
            m[a]++;
        }
    }
    for(auto it=m.begin();it!=m.end();it++){
        if(it->second>=2){
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 9600
from math import gcd
from functools import reduce

N = int(input())
A = [int(i) for i in input().split()]
mod = 10**9 + 7

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

num = lcm_list(A)%mod
ans = 0
for a in A:
    ans += (num * pow(a, mod-2, mod))%mod
ans %= mod

print(ans)


Measured memory_bytes: 10704
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MX = 100005;
int n, k, a;
ll p[MX], al[MX],ans;

int main(){
	scanf("%d%d", &n, &k);
	rep(i,n){
		scanf("%d", &a);
		p[i+1] = p[i] + (a>0?a:0);
		al[i+1] = al[i] + a;
	}
	rep(i,n-k+1) ans = max(ans,p[i]+p[n]-p[i+k]+max(0ll,al[i+k]-al[i]));
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			char[] d = sc.nextLine().toCharArray();
			
			//配列のindexとカードの番号を一致させた．datacount[0]は空けておく．
			int[] datacount = new int[9 + 1];
			datacount[0] = 0;
			
			//カードの枚数を調べる
			for(int i = 0; i < d.length; i++){
				datacount[new Integer(d[i] - '0')] ++;
			}
			
			StringBuffer output = new StringBuffer();
			for(int i = 1; i <= 9; i++){
				//カードiをつけ加えて，整うかどうか調べる．
				
				//カードiが既に4枚以上あるなら飛ばす
				if(datacount[i] == 4){continue;}
				
				//データを複製し，カードiを1枚つけ加える．
				int[] s = datacount.clone();
				s[i] ++;
				
				boolean res = search(s, false, 4);
				if(res){
					output.append(" ");
					output.append(i);
				}
			}
			
			if(output.length() == 0){output.append(" 0");}
			output.delete(0, 1);
			System.out.println(output);
		}
	}
	
	static boolean search(int[] data, boolean is2searched, int paircount){
		boolean res = false;
		if(!is2searched){
			//はじめは2枚ペアを探す
			
			for(int i = 1; i <= 9; i++){
				if(data[i] >= 2){
					int[] d = data.clone();
					d[i] = d[i] - 2;
					
					//残りのグループを探す
					boolean r = search(d, true, paircount);
					if(r){
						//成功例が1つでも存在すればOK．それ以上は調べない．
						res = true;
						break;
					}
				}
			}
		}else{
			//2枚ペアを探したあと，グループを探す
			
			if(paircount == 0){
				//グループを探し尽くしたあと
				
				//カードが1枚も残っていないか確認する
				for(int i : data){
					boolean flag = true;
					if (i != 0){
						flag = false;
						break;
					}
					
					//1枚も残ってないなら，flagはtrueなのでOK．
					//1枚でも残っていると，flagはfalseにされる．
					res = flag;
				}
			}else{
				//グループ探し中
				
				for(int i = 1; i <= 9; i++){
					boolean res1 = false;
					boolean res2 = false;
					
					//いま対象にしているカードiについて，3枚同一グループがあるか
					if(data[i] >= 3){
						int[] d = data.clone();
						
						d[i] = d[i] - 3;
						res1 = search(d, true, paircount - 1);
					}
					
					//カードiについて，そこから起点とする連続グループがあるか
					//i = 8, 9 はしらべなくてもいい
					if(i < 8 && data[i] >= 1 && data[i + 1] >= 1 && data[i + 2] >= 1){
						int[] d = data.clone();
						
						d[i] --;
						d[i + 1] --;
						d[i + 2] --;
						
						res2 = search(d, true, paircount -1);
					}
					
					//成功例が1つでもあればOK．それ以上は調べない．
					if(res1 || res2){
						res = true;
						break;
					}
				}
			}
		}
		
		return res;
	}
}

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

using namespace std;

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

using ll = long long;
using ld = long double;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template <typename T1, typename T2>
void chmax(T1 &a, const T2 &b) {
  if(a < b) a = b;
}

template <typename T1, typename T2>
void chmin(T1 &a, const T2 &b) {
  if(a > b) a = b;
}

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

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

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

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

  ll tmp1 = 0, tmp2 = 0;
  for(int i=0;i<k-1;++i) {
    tmp1 += i;
    tmp2 += n-i;
  }

  ll cnt = 0;
  for(int i=k-1;i<=n;++i) {
    tmp1 += i;
    tmp2 += n-i;
    //cout << tmp1 << " " << tmp2 << endl;
    cnt += (tmp2 - tmp1 + 1);
    cnt %= MOD;
  }
  cout << cnt << endl;

}


Measured memory_bytes: 3652
//g++ -std=gnu++14 a.cpp
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

ll gen(ll x, ll y){
  if(y == 1)return x;
  if(y%2)return (x*gen(x,y-1))%MOD;
  ll res = (gen(x,y/2))%MOD;
  return (res*res)%MOD;
}

ll nijou(ll x){
  if(x==1)return 2;
  if(x%2)return (2*nijou(x-1))%MOD;
  ll res = nijou(x/2)%MOD;
  return (res*res)%MOD;
}

ll kaijou(ll x){
  ll res = 1;
  while(x>0){
    res *= x;
    x--;
    res %= MOD;
  }
  return res%MOD;
}

int main() {
  int n,a,b;
  cin >> n >> a >> b;

  ll resa,resb;
  resa = 1;
  resb = 1;
  ll nn;
  nn = n;
  while(nn>=n-a+1){
    resa = (resa*nn)%MOD;
    nn--;
  }
  resa *= gen(kaijou(a),MOD-2);
  resa %= MOD;
  nn = n;
  while(nn>=n-b+1){
    resb = (resb*nn)%MOD;
    nn--;
  }
  resb *= gen(kaijou(b),MOD-2);
  resb %= MOD;

  ll all = nijou(n);
  //cout << all << endl;
  ll ans = all-resa-resb-1;
  ans %= MOD;
  if(ans < 0)ans += MOD;
  //if(ans < 0) ans += MOD;
  //cout <<  resa << " " << resb << endl;
  //cout  << nijou << endl;
  cout << ans << endl;
}


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

int main() {
  int n;
  cin >> n;
  
  string s;
  int num = 0;
  map<string, int> m;
  for(int i=0; i<n; i++) {
    cin >> s;
    m[s]++;
    num = max(num, m[s]);
  }
  
  for(auto p : m) if(p.second==num) cout << p.first << endl;
  return 0;
}

Measured memory_bytes: 19220
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int a, b, k;
  cin >> k >> a >> b;
  for (int i = a; i <= b; i++) {
    if (i % k == 0) {
      cout << "OK";
      exit(0);
    }
  }
  cout << "NG";
}
  

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

using namespace std;
using ll = long long;

int main()
{
  ll N, A, B; cin >> N >> A >> B;
  cout << max(0LL, (N-2)*B-(N-2)*A+1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main()
{
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= 50000; ++i)
  {
    if (i * 108 / 100 == n)
    {
      printf("%d\n", i);
      return 0;
    }
  }
  puts(":(");
  return 0;
}

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

int main(){
    
    int N;
    cin >> N;
    
    int s[N];
    for(int i = 0; i <N;i++)cin >> s[i];
    
    sort(s,s+N);
    int sum = 0;
    for(int i = 0; i <N;i++)sum +=s[i];
    
    for(int i = 0; i <N;i++){
        if(sum%10!=0){
            cout << sum <<endl;
            return 0;
        }else{
            if(s[i]%10!=0)sum -= s[i];
        }
        
    }
    cout << 0 <<endl;
}
    
    



Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define FF first
#define SS second
#define pb push_back
#define mp make_pair

typedef long long int LL;
typedef pair<int, int > pii;
typedef vector<int > vi;

const int N = 200005;

int A[N], P[N];

int main() {
  int n;
  S(n);
  LL ans = 0;
  rep(i,0,n) {
    S(A[i]);
    if(i) {
      if(A[i - 1]) P[i] = i - 1;
      else P[i] = P[i - 1];
    } else {
      P[0] = -1;
    }
    int x = 0;
    int sm = 0;
    int idx = i;
    while(sm == x && idx >= 0) {
      x ^= A[idx];
      sm += A[idx];
      ans += (sm == x) * (idx - P[idx]);
      idx = P[idx];
    }
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 1792
//
// Created on 2020/08/22.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;



int main() {
    string n;
    cin>>n;
    int sum = 0;
    for (int i = 0; i < n.size(); ++i) {
        sum += n[i] - '0';
        sum %= 9;
    }
    if(sum == 0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3720
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
i64 H;

vector<i64> a,b;

int main(){
    cin >> N >> H;
    a.resize(N);
    b.resize(N);
    rep(i,0,N - 1) cin >> a[i] >> b[i];
    sort(b.rbegin(),b.rend());
    i64 MAX = *max_element(a.begin(),a.end());
    int i = 0;
    i64 ans = 0;
    while(i < N && H > 0 && b[i] >= MAX){
        H -= b[i];
        ans++;
        i++;
    }

    if(H > 0){
        ans += H / MAX + min(1LL,H % MAX);
    }

    cout << ans << endl;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,d[50],ans;

signed main() {
    cin >> n;
    rep(i,n) cin >> d[i];
    rep(i,n) repo(j,i+1,n) ans += d[i]*d[j];
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <stdio.h>

long long  A[2000001];
long long min,max,d;
int a;

long long make_min(long long x,long long y){
  if(x>=y) min=y;
  else min=x;
  return min;
}
long long make_max(long long x,long long y){
  if(x<=y) max=y;
  else max=x;
  return max;
}

int main(void) {
  scanf("%d",&a);
  for(int i=0;i<a;i++){
      scanf("%d",&A[i]);
  }

  max=A[1]-A[0];
  min = make_min(A[0],A[1]);

    if(a==2){
      max = A[1]-A[0];
    }
      else{
        for(int i=1;i<a;i++){
            d=A[i+1]-min;
            max= make_max(max,d);
            min = make_min(A[i+1],min);
    }
  }

  printf("%d\n",max);

}



Measured memory_bytes: 3420
// {{{
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long int i32;
typedef unsigned long int u32;
typedef long long int i64;
typedef unsigned long long int  u64;
typedef pair<i32, i32> PII;
#define IN(x) cin >> x;
#define MEM(a, b) memset(a, (b), sizeof(a))
#define ZERO(a) memset(a, 0, sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j-1, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define MP make_pair
#define PB push_back
#define PF push_front
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define DEBUG(x) cout << #x << ": " << x << endl;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
// }}}

const int MAX_N = 2 * 1e5 + 2;
int ss[MAX_N];
u64 bit[MAX_N];
int cnt[26];
void add(int index, u64 n, int size) {
    for(; index <= size; index+=index&(-index)) {
        bit[index] += n;
    }
}
u64 get(int n) {
    u64 ret = 0;
    for(;n;n -= n&(-n)) {
        ret += bit[n];
    }
    return ret;
}
int main() {
    string s;
    cin >> s;
    int n = s.length();
    for(char c : s) {
        cnt[c-'a']++;
    }
    int r = 0;
    for(int i=0; i<26; i++) {
        r += cnt[i] % 2;
    }
    if(r > 1) {
        cout << -1 << endl;
        return 0;
    }
    int p = 0;
    vector<int> num[26];
    fill(num, num+26, vector<int>(0));
    for(int i=0; i<n; i++) {
        char c = s[i];
        int cn = c - 'a';
        int t = num[cn].size() + 1;
        if(2*t <= cnt[cn]) {
            ss[p] = i;
            num[cn].PB(p);
            p++;
        } else if(2*t - 1 == cnt[cn]) {
            ss[n/2] = i;
            num[cn].PB(n/2);
        } else {
            int index = n - 1 - num[cn][cnt[cn] - t];
            ss[index] = i;
            num[cn].PB(index);
        }
    }
    u64 ans = 0;
    for(int i=0; i<n; i++) {
        u64 x = ss[i] + 1;
        ans += get(n) - get(x);
        add(x, 1, n);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3836
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
const int MOD = 1000000007;

typedef long long int ll; 
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;

void floatOutPutSetup(){
    cout << fixed;
    cout << setprecision(10);
}

vector<int> par;
vector<int> ranks;
vector<int> nums;

int find(int x){
    if(par[x] == x){
        return x;
    } else {
        return par[x] = find(par[x]);
    }
}

void unite(int x,int y){
    x = find(x); y = find(y);
    if(x==y)return;
    if(ranks[x]<ranks[y]){
        par[x] = y;
        nums[y]+=nums[x];
    } else {
        par[y] = x;
        nums[x]+=nums[y];
        if(ranks[x]==ranks[y]){
            ranks[x]++;
        }
    }
}

bool same(int x,int y){
    return find(x)==find(y);
}

int main(){
    int n,m,k,tmp1,tmp2;
    cin>>n>>m>>k;
    int ans[n];
    int tmpA[n];
    rep(i,n){
        ans[i]=0;
        par.push_back(i);
        ranks.push_back(0);
        nums.push_back(1);
    }
    rep(i,m){
        cin>>tmp1>>tmp2;
        ans[tmp1-1]--;
        ans[tmp2-1]--;
        unite(tmp1-1,tmp2-1);
        
    }

    rep(i,k){
        cin>>tmp1>>tmp2;
        if(same(tmp1-1,tmp2-1)){
            ans[tmp1-1]--;
            ans[tmp2-1]--;
        }
        
    }

    for (int  i = 0; i < n; i++)
    {
        cout<<ans[i]+nums[find(i)]-1<< " ";
    }
    return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int n, k;
    while(cin >> n >> k, n) {
        ll t = 9;
        ll digit = 1;
        ll sum = 0;
        while(sum + digit * t < n) {
            sum += digit * t;
            digit++;
            t *= 10;
        }
        ll now = (ll)pow(10, digit - 1) - 1;
        now += (n - sum) / digit;
        ll rest = n - sum - (n - sum) / digit * digit;
        if((n - sum) % digit == 0) {
            rest = digit - 1;
        } else {
            rest -= 1;
            now += 1;
        }
        string res;
        while(true) {
            string s = to_string(now);
            if(k == 0) {
                break;
            }
            for(int i=0; i<s.size() && k > 0; ++i) {
                if(rest > 0) {
                    --rest;
                    continue;
                } else {
                    res += s[i];
                    --k;
                }
            }
            now++;
        }
        cout << res << endl;
    }
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)

int main() {
  int k,x;
  cin>>k>>x;

  for(int i=x-k+1;i<x+k;i++){
    cout<<i<<" ";
  }
  
  return 0;
}


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

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    string ans = "";

    int x = sx, y = sy;
    while(x < tx){
        x++;
        ans.push_back('R');
    }
    while(y < ty){
        y++;
        ans.push_back('U');
    }
    while(x > sx){
        x--;
        ans.push_back('L');
    }
    while(y >= sy){
        y--;
        ans.push_back('D');
    }
    while(x <= tx){
        x++;
        ans.push_back('R');
    }
    while(y < ty){
        y++;
        ans.push_back('U');
    }
    x--;
    ans.push_back('L');
    y++;
    ans.push_back('U');
    while(x >= sx){
        x--;
        ans.push_back('L');
    }
    while(y > sy){
        y--;
        ans.push_back('D');
    }
    x++;
    ans.push_back('R');

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;


/**
 * AIZU ONLINE JUDGE
 * 0404
 *  2020/5/6
 */
public class Main {



    boolean main() throws IOException {

        Scanner sc = new Scanner(systemin);

        result.printf("%d\n", sc.nextInt() + sc.nextInt() + sc.nextInt() + sc.nextInt());

        sc.close();
        return false;
    }



    PrintStream log;
    PrintStream result = System.out;
    BufferedReader systemin;

    static Main instance = new Main();

    Main() {
        systemin = new BufferedReader(new InputStreamReader(System.in));
        log = new PrintStream(new OutputStream() { public void write(int b) {} } );
    }

    public static void main(String[] args) throws IOException {

        instance.main();
        instance.systemin.close();
    }


}




Measured memory_bytes: 26412
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;
typedef long long ll;
const ll MOD = 1'000'000'007;
ll mod_powe(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int main(void)
{
    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    ll comb[200100];
    ll combr[200100];

    comb[0] = combr[0] = 1;

    rep(i, 1, 200100)
    {
        comb[i] = comb[i - 1] * i % MOD;
        combr[i] = combr[i - 1] * mod_powe(i, MOD - 2, MOD) % MOD;
    }
    long long ans = 0;
    for (int i = 1; i <= w - b; i++)
    {
        ll path1, path2;
        path1 = comb[h - a + b + i - 2] * combr[b + i - 1] % MOD;
        path1 = path1 * combr[h - a - 1] % MOD;
        path2 = comb[w + a - 1 - b - i] * combr[w - b - i] % MOD;
        path2 = path2 * combr[a - 1] % MOD;
        ans = (ans + (path1 * path2) % MOD) % MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;

priority_queue<int> pq;
pair<int, int> a[111111];

int main(void)
{
	int n, m, i, ans = 0;

	scanf("%d %d" ,&n, &m);
	for (i = 1; i <= n; i++)
		scanf("%d %d" ,&a[i].first, &a[i].second);

	sort(a + 1, a + n + 1);

	int take = 1;
	for (i = 0; i < m; i++)
	{
		while (a[take].first == i + 1)
		{
			pq.push(a[take].second);
			++take;
			if (take > n)
				break;
		}

		if (!pq.empty())
		{
			ans += pq.top();
			pq.pop();
		}
	}

	printf("%d" ,ans);
	return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define MAX_N 1000

int H, N, A[MAX_N + 1], B[MAX_N + 1];

void solve(){
    int C[N + 1][H], over = INT_MAX;
    fill(C[0], C[0] + H, (1<<30));
    for(int i = 0; i <= N; i++) C[i][0] = 0;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j < H; j++){
            if(j < A[i]) C[i][j] = C[i - 1][j];
            else C[i][j] = min(C[i - 1][j], C[i][j - A[i]] + B[i]);
            if(j + A[i] >= H) over = min(over, C[i][j] + B[i]);
        }
    }
    cout << over << endl;
}

int main(){
    cin >> H >> N;
    for(int i = 1; i <= N; i++)
        cin >> A[i] >> B[i];
    solve();
    return 0;
}

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

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

  cout << max( max( A+B, A-B ), A*B ) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 1000;
  for (int i = 1; i < n; ++i) {
    ll stocks = 0;
    if (a[i] > a[i - 1]) {
      stocks = ans / a[i - 1];
      ans %= a[i - 1];
      ans += a[i] * stocks; 
    }

  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
read a b c
read k
ans=No
for i in $(seq $((k+1)))
do
  if [ $b -le $a ]
  then
    b=$((b*2))
  elif [ $c -le $b ]
  then
    c=$((c*2))
  else
    ans=Yes
    break
  fi
done
echo $ans


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

stack<int> s;

int num[110];
int n;

void chg(int st,int ed)
{
	for(int i=st;i<ed;i++)
	{
		num[i]=num[i+1];
	}
}

main()
{
	
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		scanf("%d",&num[i]);
	}
	for(int i=0;i<n;i++)
	{
		int dd=0;
		for(int j=n-1-i;j>=0;j--)
		{
			if(num[j]==j+1)
			{
				dd=1;
				s.push(j+1);
				chg(j,n-i-1);
				break;
			}
		}
		if(dd==0)
		{
			printf("-1");
			return 0;
		}
	}
	while(!s.empty())
	{
		printf("%d\n",s.top());
		s.pop();
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            Main main = new Main();

            // main.solveA(sc);
            // main.solveB(sc);
            main.solveC(sc);
            // main.solveD(sc);
            // main.solveE(sc);

        }

    }

    private void solveD(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {} catch (IOException e) {

        }
    }

    private void solveE(Scanner sc) {
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out)) {

        } catch (IOException e) {

        }
    }

    private void solveC(Scanner sc) {
        int N = sc.nextInt();
        int[] arr = new int[N];
        for (int i = 0; i < N; i++) {
            arr[i] = sc.nextInt();
        }

        for (int i = N - 1; i > 0; i--) {
            if (arr[i] >= arr[i - 1]) {
                continue;
            }
            arr[i - 1] -= 1;
            if (arr[i] >= arr[i - 1]) {
                continue;
            }

            System.out.println("No");
            return;
        }

        System.out.println("Yes");

    }

    void solveB(Scanner sc) {
        int N = sc.nextInt();

        int sum = 0;

        if (N >= 10) {
            sum += 9;
        } else {
            System.out.println(N);
            return;
        }

        if (N >= 1000) {
            sum += 900;
        } else {
            System.out.println(sum + Math.max(N - 99, 0));
            return;
        }

        if (N >= 100000) {
            System.out.println(90909);
        } else {
            System.out.println(sum + Math.max(N - 9999, 0));
            return;
        }

    }

    class SolveB {
    }

    class Edge {
    }

    void solveA(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        System.out.println(Math.max(c - (a - b), 0));

    }
}


Measured memory_bytes: 50448
#pragma GCC optimize(3,"Ofast","inline")
#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

const int N=2e5+5,mod=1e9+7;
int a[N],sum[N],ans,n;

signed main(){
	read(n);
	for(int i=1;i<=n;i++) read(a[i]),sum[i]=(sum[i-1]+a[i])%mod;
	for(int i=1;i<=n;i++) ans=(ans+a[i]*((sum[n]-sum[i]+mod)%mod)%mod)%mod;
	write(ans);
}

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

int main() {
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    vector<unsigned long> factor;
    {
        unsigned long S(accumulate(A.begin(), A.end(), 0UL));
        for(unsigned long i = 1; i * i <= S; ++i)if(!(S % i)){
            factor.push_back(i);
            if(i * i != S)factor.push_back(S / i);
        }
        sort(factor.rbegin(), factor.rend());
    }
    for(const auto& i : factor){
        vector<unsigned long> r(N);
        transform(A.cbegin(), A.cend(), r.begin(), [&i](auto a){return a % i;});
        sort(r.rbegin(), r.rend());
        unsigned long S(accumulate(r.begin(), r.end(), 0UL) / i);
        unsigned long ans{0};
        for(unsigned long j = 0; j < N; ++j)ans += j < S ? i - r[j] : r[j];
        if(ans <= K * 2){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    agc015a()
}

fun agc015a() {
    val (n, a, b) = readLine()!!.split(' ').map { it.toLong() }

    if (a > b) return println(0)
    if (n == 1L) return if (a != b) println(0) else println(1)
    if (n == 2L) return println(1)

    val answer = (a + b * (n - 1)) - (a * (n - 1) + b) + 1

    println(answer)
}


Measured memory_bytes: 38184
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
using namespace std;

/*
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long  ll;

#define fi first
#define se second

using Graph = vector<vector<int>>;


int main() {
    int n,m;
    cin>>n>>m;
    int ans=0;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        ans+=a[i];
    }
    sort(a.begin(),a.end(),greater< int >());
    if(a[m-1]*4*m<ans){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }



    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#define ll long long
#define ld long double
#define fi first
//#define endl "\n"
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define initialize(array,size,value) for(ll i=0;i<size;i++) array[i]=value
#define couta(array,size) for(ll i=0;i<size;i++) cout<<array[i]<<" "
#define debug(x) cout<<"x: "<<x<<endl
#define dbug(x,y) cout<<"x: "<<x<<"    "<<"y: "<<y<<endl
#define inf (long long int) 1e18
#define eps 0.000001
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
#define mod 1000000007
#define MAXN 100001
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
ll spf[MAXN]; 
ll gcd(ll a,ll b);
ll palindrome(string s);
ll modexp(ll a,ll b,ll m);
void sieve();
ll ceil(ll a, ll b);
vl getFactorization(ll x);
void getZarr(string str, ll Z[]);
vector<ll> prefix_function(string s);


int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/
        
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll r=0, b=0;
    loop(i,0,n){
        if(s[i]=='R') r++;
        else if(s[i]=='B') b++;
    }
    if(r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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

ll palindrome(string s){
    ll l = 0;
    ll h = s.length() - 1;
    while (h > l){
        if (s[l++] != s[h--]){
            return 0;
        }
    }
    return 1;
}

ll modexp(ll a, ll b, ll m){
    if (b==0)
        return 1;
    ll temp = modexp(a,b/2,m);
    temp = (temp*temp)%m;
    if (b&1)
        return (temp*(a%m))%m; // if b is odd a^b = a^(b/2)*a^(b/2)*a
    return temp;
}

void sieve() { 
    spf[1] = 1; 
    for (ll i=2; i<MAXN; i++) 
        spf[i] = i; 
    for (ll i=4; i<MAXN; i+=2) 
        spf[i] = 2; 
  
    for (ll i=3; i*i<MAXN; i++) { 
        if (spf[i] == i) { 
            for (ll j=i*i; j<MAXN; j+=i) 
                if (spf[j]==j) 
                    spf[j] = i; 
        } 
    } 
} 


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        int k = sc.nextInt();
        for(int i = 0; i < k; i++){
            if(i % 2 == 0){
                if(a%2 == 0){
                    b += a/2;
                    a = a/2;
                }else{
                    a -= 1;
                    b += a/2;
                    a = a/2;
                }
            }else{
                if(b%2 == 0){
                    
                    a += b/2;
                    b = b/2;
                }else{
                    b -= 1;
                    a += b/2;
                    b = b/2;
                }
            }
        }
        System.out.println(a + " " + b);
    }
}


Measured memory_bytes: 22736
N = int(input())
A = [int(s) for s in input().split()]

def main():
    a = A
    even = [n for i, n in enumerate(a) if i % 2 == 0]
    odd = [n for i, n in enumerate(a) if i % 2 != 0]

    l = len(a)
    if l % 2 != 0:
        even.reverse()
        ans = even + odd
    else:
        odd.reverse()
        ans = odd + even
    print(*ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 26176
n, k = map(int, input().split())
mod = 10**9+7

R = 200010
f = [1]*R
p = 1
for i in range(1, R):
    p = f[i] = p*i%mod

finv = [1]*R
p = finv[-1] = pow(f[-1], mod-2, mod)
for i in range(R-2, 0, -1):
    p = finv[i] = p*(i+1)%mod

def comb(n, k):
    return f[n]*finv[n-k]*finv[k]%mod

ans = 0
for m in range(min(k, n-1)+1):
    x = comb(n, m)
    y = comb(n-1, m)
    ans += x*y%mod

print(ans%mod)

Measured memory_bytes: 18932
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF = 0x3f3f3f3f;
const ll mod  = 1e9 + 7;
const ll N = 1e6 + 5;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;cin>>s;
    int cnt=0,ans=0;
    for(int i=0;i<3;i++){
    	if(s[i]=='R') cnt++;
    	else cnt=0;
    	ans=max(cnt,ans);
    }
    cout<<ans;
    return 0;
}

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

using namespace std;

const int N = 100050;

int vr[N];
int dp[N];
vector<int> a;
vector<int> topo;
vector<int> vec[N];
int main()
{
    int n,m,u,v;
    cin>>n>>m;
    for(int i=0 ; i<m; i++)
    {
        cin>>u>>v;
        v--;
        u--;
        vec[u].push_back(v);
        vr[v]++;
    }
    for (int i=0; i<n; i++)
    {
        if(vr[i]==0)
        {
            a.push_back(i);
        }
    }
    while( a.size() )
    {
        int x = a.back();
        a.pop_back();
        topo.push_back(x);
        for(int y:vec[x])
        {
            dp[y]=max(dp[y],dp[x]+1);
            vr[y]--;
            if(vr[y]==0)
            {
                a.push_back(y);
            }
        }
    }
    int mx=0;
    for(int i=0; i<N; i++)
    {
        mx=max(mx,dp[i]);
    }
cout<<mx;
}


Measured memory_bytes: 7164
#include <cstdio>
#include <climits>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <cstdio>
#include <climits>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cstring>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
long long MOD = 1000000007;
long long INF = 1000000000000000;

typedef long long ll;
typedef unsigned long long ull;

ull powMod(ull x, ull n) {
  if (n == 0) return 1;
  if (n == 1) return x;
  ull tmp = powMod(x, n / 2);
  if (n % 2 == 0) return (tmp * tmp) % MOD;
  return x * (tmp * tmp) % MOD;
}

int main(void) {
  int m; cin >> m;
  ll c, d, D = 0, S = 0;
  rep(i, m) {
    cin >> d >> c;
    D += c;
    S += d * c;
  }
  if (S % 9 == 0) cout << (S / 9 - 1) + (D - 1) << endl;
  else cout << S / 9 + D - 1 << endl;

  return 0;
}
  


Measured memory_bytes: 256
using System;

namespace _2610
{
	class Program
	{
		static void Main(string[] args)
		{
			string s = Console.ReadLine();
			switch (s)
			{
				case "0":
				{
					Console.WriteLine(1);
					break;
				}
				case "1":
				{
					Console.WriteLine(2);
					break;
				}
				case "2":
				{
					Console.WriteLine(1);
					break;
				}
				default:
				{
					Console.WriteLine(0);
					break;
				}
			}
		}
	}
}


Measured memory_bytes: 17928