akhauriyash/Code-Regression huggingface dataset:
// IDE used VSCode with gcc plug-in
/*
Event: Codeforces Global Round 7
Author: miitbh1
*/
#include <map>
#include <set>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstdlib>
#include <climits>
#include <iomanip>
#include <iostream>
#include <algorithm>


#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)
#define trav(it, ctr) for(auto it=ctr.begin(); it!=ctr.end(); it++)
#define p(x) cout<<x<<"\n"
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pp(x, y) cout<<x<<" "<<y<<"\n"
#define btc __builtin_popcount
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef priority_queue<int> pq;
typedef pair<int, int> ii;
typedef map<int, int> mii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;
using ll=long long int;
int N=100001, M=1e9+7;

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b;
    cin>>a>>b;
    a*=a-1;
    a/=2;
    b*=b-1;
    b/=2;
    a+=b;
    p(a);
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

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


    ll n = b - a;

    cout << n * (n + 1) / 2 - b << endl;

    return 0;

}



Measured memory_bytes: 888
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n)
	max1, max2 := 0, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
		if as[i] > max1 {
			max1, max2 = as[i], max1
			continue
		}
		if as[i] > max2 {
			max2 = as[i]
		}
	}

	for _, a := range as {
		if a == max1 {
			fmt.Println(max2)
			continue
		}
		fmt.Println(max1)
	}
}


Measured memory_bytes: 6400
def check(h,w):
    if (h+w) % 2 == 0: return '#'
    return '.' 

while True:
    H,W=map(int,input().split())
    if H==0 and W==0:
        break

    for h in range(H):
        for w in range(W):
            print(check(h,w), end="")
        print()
    print()


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

using namespace std;

#define N 1200000

const int mod=998244353;
int n;
long long a,b,c,ab,ac,bc,ans;
char s[N];

void upd(long long &x,long long y){x=(x+y)%mod;}

int main(){
	scanf("%d%s",&n,s+1);
	ans=1;
	for (int i=1;i<=n;++i) ans=ans*i%mod;
	for (int i=1;i<=n*3;++i){
		a+=s[i]=='R';
		b+=s[i]=='G';
		c+=s[i]=='B';
		if (ab&&c){
			ans=ans*ab*c%mod;
			--ab; --c;
		}
		if (ac&&b){
			ans=ans*ac*b%mod;
			--ac; --b;
		}
		if (bc&&a){
			ans=ans*bc*a%mod;
			--bc; --a;
		}
		if (a&&b){
			ans=ans*a*b%mod;
			++ab; --a; --b;
		}
		if (a&&c){
			ans=ans*a*c%mod;
			++ac; --a; --c;
		}
		if (b&&c){
			ans=ans*b*c%mod;
			++bc; --b; --c;
		}
	}
	printf("%lld\n",ans);
	
	return 0;
}
			

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

int bubble_sort(std::vector<int>& ary) {
    int n = ary.size();
    int flag = 1;
    int replace_counter = 0;
    while (flag) {
        flag = 0;
        for (int j = n-1; j > 0; j--) {
            if (ary[j] <  ary[j - 1]) {
                std::swap(ary[j], ary[j - 1]);
                replace_counter++;
                flag = 1;
            }
        }
    }
    return replace_counter;
}

int main(int argc, char const* argv[])
{
    int N = 0;
    std::vector<int> ary;
    std::cin >> N;
    ary.resize(N);
    for(auto& i: ary) {
        std::cin >> i;
    }
    int c = bubble_sort(ary);
    for(int i = 0; i < N-1; i++) {
        std::cout << ary[i] << " ";
    }
    std::cout << ary[N - 1] << std::endl;
    std::cout << c << std::endl;
    return 0;
}

Measured memory_bytes: 3112
n = int(input())
up = int("1"+"0"*18)

a = list(map(int, input().split()))
ans = a[0]

def calc(a):
    x = ans
    for i in range(1, len(a)):
        x = x * a[i]

        if (x > up):
            x = -1
            return x

    return x

if (0 in a):
    ans = 0
else:
    ans = calc(a)

print(ans)


Measured memory_bytes: 21596
#include <cstdio>
char s[100][100];
int c[100][100],a,b,ans,cnt;
int d[2][2]={1,0,0,1};
void bfs(int x,int y)
{
   if((x==a-1)&&(y==b-1)) {ans=1;return ;}
   for(int i=0;i<2;i++)
    {
        int dx=x+d[i][0];
        int dy=y+d[i][1];
        if(s[dx][dy]=='#'&&dx>=0&&dx<a&&dy>=0&&dy<=b)
        bfs(dx,dy);
    }
}
int main()
{
    while(scanf("%d %d",&a,&b)!=EOF)
    {
        for(int i=0;i<a;i++)
         {
             scanf("%s",s[i]);
             for(int j=0;j<b;j++)
                if(s[i][j]=='#') cnt++;
         }
         ans=0;
         bfs(0,0);
         if(ans==1 && cnt==a+b-1) printf("Possible\n");
         else printf("Impossible\n");

    }
    return 0;
}


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

const int N = 432;

int n, H, V;
int p[N], in[N], out[N];
bool dicyc[N];

int ancestor(int x) {return p[x] == x ? x : (p[x] = ancestor(p[x]));}

int main() {
	int i, Lu, Ld, Ru, Rd, L, R;
	scanf("%d%d", &n, &H), V = 2 * H;
	std::iota(p, p + V, 0);
	for (i = 1; i <= n; ++i)
		scanf("%d%d%d%d", &Lu, &Ru, &Ld, &Rd),
		++out[L = (Ld ? Ld + H : Lu) - 1], ++in[R = (Rd ? Rd : Ru + H) - 1],
		p[ancestor(L)] = ancestor(R);
	for (i = 0; i < H && in[i] <= out[i] && in[i + H] >= out[i + H]; ++i);
	if (i != H) return puts("NO"), 0;
	for (i = 0; i < V; ++i) dicyc[ancestor(i)] |= in[i] != out[i] || !in[i];
	for (i = 0; i < V && (p[i] != i || dicyc[i]); ++i);
	return puts(i == V ? "YES" : "NO"), 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;
#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[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////


struct tower{
    ll w,s,v;
};
bool comp(tower t1,tower t2){
    if(t1.w+t1.s<t2.w+t2.s)return true;
    else return false;
}

int main(){
    ll n;cin>>n;
    tower t[n];
    rep(i,0,n-1){
        cin>>t[i].w>>t[i].s>>t[i].v;
    }
    sort(t,t+n,comp);
    ll N=(ll)2E4+1;
    ll dp[n+1][N];
    memset(dp,0,sizeof(dp));
    rep(i,0,n-1){
        rep(j,0,N-1){
            dp[i+1][j]=dp[i][j];
            if(0<=j-t[i].w&&j-t[i].w<=t[i].s)Max(&dp[i+1][j],dp[i][j-t[i].w]+t[i].v);
        }
    }
    /*rep(i,0,n){
        rep(j,0,20){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    ll ans=0;rep(i,0,N-1)Max(&ans,dp[n][i]);
    cout<<ans<<endl;
    return 0;
}






Measured memory_bytes: 156672
var
	s:array[0..50] of longint;
	i,j,n,m,t,ans,x:longint;
begin
	readln(n,m);
	fillchar(s,sizeof(s),0);
	for i:=1 to n do
	begin	
		read(t);
		for j:=1 to t do
		begin
			read(x);
			inc(s[x]);
		end;
	end;
	ans:=0;
	for i:=1 to m do
		if s[i]=n then inc(ans);
	writeln(ans);
end.

Measured memory_bytes: 128
N, A, B, C, D = map(int, input().split())
Ss = input()

A, B, C, D = A-1, B-1, C-1, D-1

if '##' in Ss[A:max(C, D)+1]:
    print('No')
else:
    if C < D:
        print('Yes')
    else:
        if '...' in Ss[B-1:D+2]:
            print('Yes')
        else:
            print('No')


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define long long long
using namespace std;
const int X = 3005;
const long MD = 998244353;
int N, K, in[X];
long mm[X][X][2];
bool base;
int main(){
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> N >> K;
	for(int i = 0; i < N; ++i) cin >> in[i];
	for(int i = 0; i < N; ++i) for(int j = 0; j <= K; ++j, ++in[i]){
		base = !j; 
		(mm[i + 1][j][0] += base + mm[i][j][0]) %= MD;
		(mm[i + 1][j][1] += base + mm[i][j][0] + mm[i][j][1]) %= MD;
		if(in[i] <= K){ 
			(mm[i + 1][in[i]][0] += base + mm[i][j][0]) %= MD;
			(mm[i + 1][in[i]][1] += base + mm[i][j][0]) %= MD;
		}
	}
	cout << mm[N][K][1];
}

Measured memory_bytes: 141184
#include <stdio.h>

#define LENGTH 256

int main() {
  char input[LENGTH];
  int n;
  fgets(input, LENGTH,stdin);
  sscanf(input, "%d", &n);
  int rem = n % 10;
  if(rem == 2 || rem == 4 || rem == 5 || rem == 7 || rem == 9) {
    printf("hon \n");
  } else if(rem == 0 || rem == 1 || rem == 6 || rem == 8) {
    printf("pon \n");
  } else if(rem == 3) {
    printf("bon \n");
  }
}


Measured memory_bytes: 1668
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int N;
unordered_set<string> ng3 = {"AGC", "GAC", "ACG"};
unordered_set<string> ng4 = {"ACGC", "AGGC", "AGTC", "ATGC" };
#define MOD 1000000007

string ACGT = "ACGT";

vector<map<string, int>> memo;

int solve(int p, string history)
{
    if (p == N) {
        return 1;
    }

    int res = 0;
    if (memo[p].count(history) == 1) {
        return memo[p][history];
    }


    for (auto const& c : ACGT) {
        string s3 = history.substr(2, 2) + c;
        string s4 = history.substr(1, 3) + c;
        if (ng3.count(s3) == 0 && ng4.count(s4) == 0) {
            res = (int)(((ll)res + solve(p+1, s4)) % MOD);
        }
    }

    memo[p][history] = res;

    return res;
}

int main()
{
    cin >>N;
    memo.resize(N);

    int ans;

    ans = solve(0, "XXXX");

    cout << ans << endl;
}


Measured memory_bytes: 2688
package main

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

func main() {
	sc := NewScanner()

	n := sc.ReadInt()
	m := sc.ReadInt()

	a := make([]int, n)
	total := 0
	for i := 0; i < n; i++ {
		ai := sc.ReadInt()
		a[i] = ai
		total += ai
	}
	sort.Ints(a)

	text := ""
	if a[n-m] < CeilInt(total, 4*m) {
		text = "No"
	} else {
		text = "Yes"
	}

	fmt.Println(text)
}

func CeilInt(numerator int, denominator int) int {
	answer := numerator / denominator
	if numerator%denominator > 0 {
		answer++
	}
	return answer
}

// util
// * math

func AbsInt(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func MinInt(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

// * io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
#define MOD (int)1e9+7
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;

int main(){
    int N;cin>>N;
    vector<int> A(N,0);
    REP(i,N) cin>>A[i];
    ll summation = A[0];
    ll right = 1;
    ll ans = 0;
    REP(left,N){
        while(right < N and (summation + A[right]) == (summation xor A[right])){
            summation += A[right];
            right++;
        }
            ans+= right - left;
            //cout<<left<<"LLLLL"<<right<<endl;
            if(left==right) right++;
            else {
                summation -= A[left];
            }
    }
    cout<<ans<<endl;;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int x[] = new int[N];
		int y[] = new int[N];

		for(int i=0; i<N; i++) {
			sc.nextLine();
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
//			System.out.println(x[i] + ":" + y[i]);
		}

		double sumDist = 0;

		for (int i=0; i<N; i++) {
			for(int j=i+1; j<N; j++)
				sumDist += calcDistance(x[i],y[i],x[j],y[j]);
		}

		int C = Factrial(N) / Combi(N,2) ;

		double sumDist2 = (sumDist * C * (N-1))/Factrial(N);

		System.out.println(sumDist2);

	}


	public static double calcDistance(int x1, int y1, int x2, int y2) {

		return Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)) ;
	}

	public static int Factrial(int n) {
		int Sum = 1;
		for (int i=1; i<=n; i++) {
			Sum *= i;
		}
		return Sum;
	}

	public static int Combi(int a, int b) {
		int C=1;
		for(int i=a; i>(a-b); i--)
			C *= i;
		return C / Factrial(b);
	}

}

Measured memory_bytes: 21844
#include <stdio.h>
#include <stdlib.h>
#define MAX 1000000

typedef struct{
char name[10];
int time;
}element;

void enqueue(element);
element dequeue(void);

element queue[MAX];
int head,tail;

int main(){
    int i,n,q,ac=0,t;
    element e[n];
    element s;
    scanf("%d %d",&n,&q);
    for(i=0;i<n;i++){
        scanf("%s",queue[i].name);
        scanf("%d",&queue[i].time);
    }
    head=0;
    tail=n;
    while(head!=tail){
        s=dequeue();
        t=s.time-q;
        if(t>0){
            s.time=t;
            enqueue(s);
            ac=ac+q;
        }
        else {
            ac=ac+s.time;
            printf("%s %d\n",s.name,ac);

        }
    }
    return 0;

}
//データ挿入
 void enqueue(element x){
     int next=(tail+1)%MAX;
     queue[tail] = x;
    tail=next;
   
 }
 
//データ取り出し
 element dequeue(void){
    element x;
   x = queue[head];
   head=(head+1)%MAX;
  return x;
 }


Measured memory_bytes: 4692
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;

int main(void){

    int n, k;
    cin >> n >> k;

    ll X[55], Y[55], sX[55], sY[55];

    for (int i = 0; i < n; i++){
        cin >> X[i] >> Y[i];
        sX[i] = X[i]; sY[i] = Y[i];
    }

    sort(sX, sX + n); sort(sY, sY + n);

    ll ans = 5000000000000000000;

    for (int x = 0; x < n; x++){
        for (int nx = x + 1; nx < n; nx++){
            for (int y = 0; y < n; y++){
                for (int ny = y + 1; ny < n; ny++){
                    int count = 0;
                    for (int i = 0; i < n; i++){
                        if (sX[x] <= X[i] && X[i] <= sX[nx] && sY[y] <= Y[i] && Y[i] <= sY[ny]){
                            count++;
                        }
                    }
                    if (k <= count){
                        ans = min(ans, (sX[nx] - sX[x])*(sY[ny] - sY[y]));
                    }

                }
            }
        }
    }

    cout << ans << endl;


}

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

#define INF INT_MAX/2;
#define MOD 1000000007

using namespace std;

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

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

   ll N,M;
   cin>>N>>M;

   double par = 1/pow(2,M);
   ll ok = (N-M)*100;
   ll ng = M*1900; 
   double b=par*(ok+ng);
   for(ll i=2;i<1000000;i++){
      b+= 1.*i*(ok+ng)*par*pow(1.-par,i-1);
   }
   cout<<b<<endl;
   return 0; 
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int P = 31 , MOD = 1e9 + 9; // Hashing parameters

void compute_hash(string const& s , vector<int> &preH) {
   int n = (int)s.size();
   preH.resize(n);
   long long hash_value = 0;
   long long p_pow = 1;
   for(int i = 0 ; i < n ; ++i){
      hash_value = (hash_value + (s[i] - 'a' + 1) * p_pow) % MOD;
      p_pow = (p_pow * P) % MOD;
      preH[i] = hash_value;
   }
}

int power(int b, int p) {
   if (p == 0) return 1;
   int res = power(b, p / 2);
   res = 1LL * res * res % MOD;
   if (p & 1) {
      res = 1LL * b * res % MOD;
   }
   return res;
}

int modInv(int x) {
   return power(x, MOD - 2);
}

int mul(int a , int b , int m){
   return (1LL * (a % m) * (b % m)) % m;
}

int add(int a , int b , int m){
   return (1LL * (a % m) + (b % m)) % m;
}

long long get_hash(int l , int r , vector<int> &preH){
   long long ret = (preH[r] - (l ? preH[l - 1] : 0) + MOD) % MOD;
   return mul(ret , modInv(power(P , l)) , MOD);
}

int n;
string s;
bool valid(int sz , vector<int> &preH){
   unordered_map<int , bool> mp;
   for(int i = n - sz; i >= 0 ; --i){
      int cur = get_hash(i , i + sz - 1 , preH);
      mp[cur] = true;
      int j = i - sz;
      if(j < 0)return false;
      int nxt = get_hash(j , j + sz - 1 , preH);
      if(mp.count(nxt)){
         return true;
      }
   }
   return false;
}

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> n;
   cin >> s;
   vector<int> preH(n);
   compute_hash(s , preH);
   int l = 1 , r = n , ans = 0;
   while (l <= r){
      int mid = (l + r) / 2;
      if(valid(mid , preH)){
         ans = mid , l = mid + 1;
      }
      else{
         r = mid - 1;
      }
   }
   cout << ans << "\n";
}

Measured memory_bytes: 608
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

ll modpow(ll a,ll b){
	ll res = 1 ;
	while(b>0){
		if(b&1) res = res*a%mod ;
		b >>= 1 ;
		a = a*a%mod ;
	}
	return res ;
}

ll sum(ll a){
	ll res = 0 ;
	while(a>0){
		res += a%10 ;
		a /= 10 ;
	}
	return res ;
}

int main(){
	ll a,n,m ;
	cin >> a >> n >> m ;
	ll ans = 0 ;
	for(ll i=1;modpow(i,n)<=m;i++){
		ll x = modpow(i,n) ;
		if(i==sum(x)+a) ans++ ;
	}
	cout << ans << endl ;
}




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


int main(){
    int K,A,B;
    cin>>K>>A>>B;
    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout <<"OK"<<endl;
            return 0;
        }
    }
    cout <<"NG"<<endl;
    return 0;
}


Measured memory_bytes: 3548
import java.util.Scanner;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Arrays;
import java.util.Stack;

public class Main {
	static Scanner scn = new Scanner(System.in);
	static long count=0,max=0;
	public static void main(String[] args) {
		// TODO Auto-generated method stub
			long n=scn.nextLong();
			long min=Long.MAX_VALUE,a,b;
			for(long i=1;i*i<=n;i++)
			{
				if(n%i==0)
				{
					a=i;b=n/i;
					if((a+b-2)<min)
						min=a+b-2;
				}
			}
			System.out.println(min);
		
		}
			
	
	
		
	public static void coin(int[] arr,int sum,int n,int prev)
	{	if(sum==n)
		{
			count++;
			return;
		}
	if(sum>n)	return;
		for(int i=prev;i<arr.length;i++)
		{
			coin(arr, sum+arr[i], n,i);
		}
	}
	
}



Measured memory_bytes: 23764
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;
using u64=std::uint_fast64_t;

u64 popcount(u64 x){
  x = (x & 0x5555555555555555ULL) + ((x & 0xAAAAAAAAAAAAAAAAULL)>>1);
  x = (x & 0x3333333333333333ULL) + ((x & 0xCCCCCCCCCCCCCCCCULL)>>2);
  x = (x & 0x0F0F0F0F0F0F0F0FULL) + ((x & 0xF0F0F0F0F0F0F0F0ULL)>>4);
  x *= 0x0101010101010101ULL;
  return x >> 56;
}

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

  ll n;
  std::cin>>n;

  std::string x;
  std::cin>>x;

  auto calc=[](auto f,u64 num)->u64{
    if(num==0)return 0;
    u64 cnt=popcount(num);
    return 1+f(f,num%cnt);
  };

  ll cnt=0;

  rep(i,0,n)if(x[i]=='1')cnt++;

  if(cnt==0){
    rep(i,0,n)std::cout<<1<<"\n";
    return 0;
  }

  std::vector<ll> on(n,1),off(n,1);

  if(cnt!=1){
    rep(i,1,n)off[i]=(off[i-1]*2)%(cnt-1);
  }
  rep(i,1,n)on[i]=(on[i-1]*2)%(cnt+1);

  ll on_val=0,off_val=0;

  rep(i,0,n){
    if(x[i]=='1'){
      on_val=(on_val+on[n-1-i])%(cnt+1);
    }
    if(cnt!=1){
      if(x[i]=='1'){
        off_val=(off_val+off[n-1-i])%(cnt-1);
      }
    }
  }

  rep(i,0,n){
    if(x[i]=='1'){
      if(cnt==1){
        std::cout<<0<<"\n";
        continue;
      }
      std::cout<<1+calc(calc,(off_val+cnt-1-off[n-1-i])%(cnt-1))<<"\n";
    }else{
      std::cout<<1+calc(calc,(on_val+on[n-1-i])%(cnt+1))<<"\n";
    }
  }

  return 0;
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt();
        fsc.close();
        if(n%2==0) System.out.println(n/2-1);
        else System.out.println((n-1)/2);
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}

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

int main() {
  string s; cin >> s;
  int a = s.size();
  int h, o;
  for(int i; i<a; i++){
    if(s.at(i)=='A'){
      h = i;
      break;
    }
  }
  for(int i=a-1; i>0; i--){
    if(s.at(i)=='Z'){
      o = i;
      break;
    }
  }
  
  cout << o-h+1 << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

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

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(int x, int y){
  if(x % y == 1) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(int x, int y){
  return x * y / gcd(x, y);
}
// n個の最大公約数
ll ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i=1; i<a.size() && res!=1; i++){
    res = gcd(res, a[i]);
  }
  return res;
}
// n個の最小公倍数
ll nlcm(vector<int> a){
  int res;
  res = a[0];
  REP(i, a.size()){
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  string s;
  cin >> s;
  rep(i,3){
    if(s[i] == '1') cout << 9;
    else cout << 1;
  }
  cout << endl;
}






Measured memory_bytes: 384
import itertools
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for _ in range(M)] 

t=[i for i in range(N-1)]
premu=list(itertools.permutations(t))

cnt=0
for elem in premu:
    eb=1
    for e in elem:
        ec=e+2
        flag=False
        for ab in AB:
            if (ec in ab) and (eb in ab):
                flag=True    
        if flag:
            eb=ec
        else:
            break
    if flag:
        cnt+=1

print(cnt)


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n,m;
int ix[5000],iy[5000];
int sum[5005][5005];
main()
{
	cin>>n>>m;
	vector<int>x,y;
	for(int i=0;i<n;i++)
	{
		cin>>ix[i]>>iy[i];
		x.push_back(ix[i]);
		y.push_back(iy[i]);
	}
	sort(x.begin(),x.end());x.erase(unique(x.begin(),x.end()),x.end());
	sort(y.begin(),y.end());y.erase(unique(y.begin(),y.end()),y.end());
	for(int i=0;i<n;i++)
	{
		int X=lower_bound(x.begin(),x.end(),ix[i])-x.begin();
		int Y=lower_bound(y.begin(),y.end(),iy[i])-y.begin();
		sum[X+1][Y+1]++;
	}
	for(int i=0;i<=x.size();i++)
	{
		for(int j=0;j<y.size();j++)sum[i][j+1]+=sum[i][j];
	}
	for(int j=0;j<=y.size();j++)
	{
		for(int i=0;i<x.size();i++)sum[i+1][j]+=sum[i][j];
	}
	for(int i=0;i<m;i++)
	{
		int xl,yl,xr,yr;
		cin>>xl>>yl>>xr>>yr;
		xl=lower_bound(x.begin(),x.end(),xl)-x.begin();
		yl=lower_bound(y.begin(),y.end(),yl)-y.begin();
		xr=upper_bound(x.begin(),x.end(),xr)-x.begin();
		yr=upper_bound(y.begin(),y.end(),yr)-y.begin();
		cout<<sum[xr][yr]-sum[xr][yl]-sum[xl][yr]+sum[xl][yl]<<endl;
	}
}



Measured memory_bytes: 101008
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
    public static void main(String[] args) {
        FastScanner fsc = new FastScanner();
        int n = fsc.nextInt();
        int[] q = new int[n];
        for (int i = 0; i < n; i++) {
            q[fsc.nextInt() - 1] = i;
        }
        int maxlen = 1;
        int len = 1;
        for (int i = 0 ; i < n - 1; i++) {
            if (q[i] < q[i + 1]) {
                len++;
            } else {
                maxlen = Math.max(maxlen, len);
                len = 1;
            }
        }
        maxlen = Math.max(maxlen, len);
        System.out.println(n - maxlen);
    }
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

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

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

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

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

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

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


Measured memory_bytes: 22540
#include<stdio.h>
int main(void){
    int a[4][13]={0};
    int i,j,k,n,x;
    char m;
    scanf("%d", &n);
    for(k=0;k<n;k++){
        scanf(" %c%d", &m, &x);
        if(m == 'S'){
            a[0][x-1] = 1;
        }else if(m == 'H'){
            a[1][x-1] = 1;
        }else if(m == 'C'){
            a[2][x-1] = 1;
        }else if(m == 'D'){
            a[3][x-1] = 1;
        }
    }
    //printf("\n");
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(a[i][j] == 0){
                if(i == 0){
                    printf("S %d\n", j+1);
                }else if(i == 1){
                    printf("H %d\n", j+1);
                }else if(i == 2){
                    printf("C %d\n", j+1);
                }else if(i == 3){
                    printf("D %d\n", j+1);
                }
            }
            //printf("a[%d][%d] = %d\n", i, j, a[i][j]);
        }
        //printf("\n");
    }
    return 0;
}



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

int main()
{
    int N, d[50], sum = 0;

    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> d[i];
    }

    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            sum += d[i]*d[j];
        }
    }

    cout << sum << endl;
 
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args)throws Exception {
		Scanner scan = new Scanner(System.in);
		int money = scan.nextInt();
		int yen500 = 0;
		int yen5 = 0;

		for(;;) {
			if(money >= 500) {
				money -= 500;
				yen500 += 1;
			}else {
				break;
			}
		}
		for(;;) {
			if(money >= 5) {
				money -= 5;
				yen5 += 1;
			}else {
				break;
			}
		}
		System.out.println(yen500 * 1000 + yen5 * 5);

		scan.close();
	}
}

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

int main(void)
{
  char b;
  cin>>b;

  switch (b)
  {
  case 'A':
    cout<<'T'<<endl;
    break;
    
  case 'T':
    cout<<'A'<<endl;
    break;

  case 'G':
    cout<<'C'<<endl;
    break;

  case 'C':
    cout<<'G'<<endl;
    break;
  
  default:
    break;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;



int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	long long n, i, j, k, sa, sb, c;
	bool valid = true;
	cin >> n;
	sa = 0; sb = 0; c = 0;
	vector<long long>a(n), b(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
		sa += a[i];
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
		sb += b[i];
		if (a[i] < b[i]) c += (b[i] - a[i] + 1) / 2;
	}
	if (c <= sb - sa) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>

using namespace std;

#define sz(a) static_cast<int>((a).size())
#define f first
#define s second
#define els(v) for (auto &el : (v))


#ifdef KIRYA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) {
    cerr << _s << " = " << _h << "\n";
}

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;


#include <cstdio>

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> vec(10, vector<int>(10, 0));
    for (int i = 0; i <= n; ++i) {
        string s = to_string(i);
        int l = s.size();
        vec[s[0] - '0'][s[l - 1] - '0']++;
    }
    int64_t ans = 0;
    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            ans += vec[i][j] * vec[j][i];
        }
    }
    cout << ans << '\n';
}

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

    int q = 1;

    for (int i = 0; i < q; ++i) {
        solve();
    }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=2019;
const int inf=1<<30;

ll rui(ll a,ll n){
  ll ans=1;
  while(n>0){
    if(n&1) ans=ans*a%mod;
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

ll dp[200010];

int main(){
  string s; cin >> s;
  reverse(all(s));
  int n=s.size();
  rep(i,n){
    dp[i+1]=dp[i];
    dp[i+1]+=(s[i]-'0')*rui(10,i)%2019;
    dp[i+1]%=2019;
  }
  map<ll,ll> mp;
  rep(i,n+1){
    mp[dp[i]]++;
  }
  ll ans=0;
  for(auto c:mp){
    ans+=c.second*(c.second-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5324
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REP2(i,x,n) for(ll i=x; i<(n); i++)
#define REP3(i,x,n) for(ll i=x; i>(n); i--)
#define zero_pad(num) setfill('0') << std::right << setw(num)
#define space_pad(num) setfill(' ') << std::right << setw(num)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main(){
    ll N;
    cin >> N;
    vector<ll> L(N);
    for (ll i = 0; i < N; i++)
    {
        cin>>L[i];
    }
    int count = 0;
    for (ll i = 0; i < N; i++)
    {
        for (ll j = i+1; j < N; j++)
        {
            for (ll k = j+1; k < N; k++)
            {
                if(L[i]==L[j]||L[j]==L[k]||L[k]==L[i]){
                    continue;
                }else{
                    if(L[i]+L[j]>L[k]&&L[j]+L[k]>L[i]&&L[k]+L[i]>L[j]){
                        count++;
                    }
                }
            }
            
        }
        
    }
    
    cout << count << endl;
    return 0;
}


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

#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define repp(i,a,b) for(int i=a;i<b;i++)
#define repm(i,a,b) for(int i=a;i>b;i--)
#define debug_interval endl
#define dump_interval ' '
#define debug_toggle 0

typedef long long ll;

inline ll toInt(string s){ll v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
inline ll gcd(ll a,ll b){return a?gcd(b%a,a):b;} //Don't use C++17
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cout<<endl;}
template<class...A> inline void debug_rest() {cout<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cout<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cout<<first,debug_rest(rest...);}

int n,a,b,ans,dispo,p,q;
double d;
vector<int>nl;

int main(){
  ios::sync_with_stdio(false);
  cin>>n;
  repp(i,0,n)cin>>dispo,nl.pub(dispo);
  sort(rall(nl));
  a=nl.front();
  d=(double)a/2;
  nl.erase(nl.begin());
  reverse(all(nl));
  vector<int>::iterator ite1 = lower_bound(all(nl),d);
  p=*ite1;
  repp(i,0,n-1)debug("! "),nl[i]*=-1;
  sort(all(nl));
  vector<int>::iterator ite2 = lower_bound(all(nl),-d);
  q=*ite2;
  q*=-1;
  debug (p,q);
  if(abs(q-d)>=abs(p-d))dump(a,p);
  else dump(a,q);
}

Measured memory_bytes: 892
#include <stdio.h>
#include <string.h>
int main()
{
    char s[201], top[201], bottom[201];
    int m, h;
    do
    {
        scanf("%s", s);
        if (strcmp(s, "-") == 0)
        {
            break;
        }
        scanf("%d", &m);
        for (int i = 0; i < m; i++)
        {
            scanf("%d", &h);
            for (int j = 0; j < h; j++)
            {
                bottom[j] = s[j];
                bottom[h] = '\0';
            }
            int j = 0;
            while (s[h + j] != '\0')
            {
                top[j] = s[h + j];
                j++;
            }
            top[j] = '\0';
            strcpy(s, top);
            strcat(s, bottom);
        }
        printf("%s\n", s);
    } while (strcmp(s, "-") != 0);
    return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
int read()
{
	char s;
	int k=0,base=1;
	while((s=getchar())!='-'&&s!=EOF&&!(s>='0'&&s<='9'));
	if(s==EOF)exit(0);
	if(s=='-')base=-1,s=getchar();
	while(s>='0'&&s<='9')
	{
		k=k*10+(s^'0');
		s=getchar();
	}
	return k*base;
}
const int maxn=2e4+100;
const int maxm=6e5+100;
int n,X,Y,m,l,r,ans;
struct node
{
	int id,p,oth;
} a[maxn];
int Map[maxn];
int dfs_time,low[maxn],dfn[maxn],scc[maxn];
int to[maxm],ne[maxm],id,po[maxn],sccid;
stack<int> S;
bool cmp(node aa,node bb)
{
	if (aa.p==bb.p) return aa.id<bb.id;
	return aa.p<bb.p;
}
inline int qmax(int x,int y)
{
	return x>y?x:y;
}
bool flag;
void tarjan(int x)
{
	S.push(x);
//	printf(" *%d* ",x);
	dfn[x]=low[x]=++dfs_time;
	for (int i=po[x];i;i=ne[i])
	{
		if (dfn[to[i]]==0) 
		{
			tarjan(to[i]);
			if (!flag) return;
			low[x]=min(low[x],low[to[i]]);
		} else
		if (scc[to[i]]==0)
		{
			low[x]=min(low[x],dfn[to[i]]);
		}
	}
	if (dfn[x]==low[x])
	{
		++sccid;
		while (!S.empty())
		{
			scc[S.top()]=sccid;
			if (scc[a[S.top()].oth]==sccid)
			{
				flag=false;
				return;
			}
			if (S.top()==x) {S.pop();break;}
			S.pop();
		}
	}
}
inline void add(int x,int y)
{
//	printf("(%d->%d)\n",x,y);
	id++;to[id]=y;ne[id]=po[x];po[x]=id;
}
bool check(int x)
{
	id=0;sccid=0;
	dfs_time=0;
	memset(po,0,sizeof(po));
	memset(low,0,sizeof(low));
	memset(scc,0,sizeof(scc));
	memset(dfn,0,sizeof(dfn));
	for (int i=1;i<m;i++)
	{
		int last=min(m,i+9);
		for (int j=i+1;j<=last;j++)
		{
			if (a[j].p-a[i].p<x)
			{
				//printf("==(%d,%d)",i,j);
				add(i,a[j].oth);
				add(j,a[i].oth);
			} else break;
		}
	}
	flag=true;
	tarjan(1);
	for (int i=1;i<=m;i++) 
	{
		if (!dfn[i]) tarjan(i);
		if (flag==false) return false;
	}
	return true;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++)
	{
		X=read();Y=read();
		if (X>Y) swap(X,Y);
		a[i].id=i,    a[i].p=X,  a[i].oth=i+n;
		a[i+n].id=i+n,a[i+n].p=Y,a[i+n].oth=i;
	}
	m=n+n;
	r=qmax(abs(a[n+1].p-a[2].p),abs(a[n+2].p-a[1].p));
	r=qmax(r,qmax(abs(a[2].p-a[1].p),abs(a[n+2].p-a[n+1].p)));
	sort(a+1,a+n+1,cmp);
	l=a[2].p-a[1].p;
	for (int i=3;i<=n;i++) l=min(l,a[i].p-a[i-1].p);

	sort(a+1,a+m+1,cmp);
	for (int i=1;i<=m;i++) Map[a[i].id]=i;
	for (int i=1;i<=m;i++) a[i].oth=Map[a[i].oth];
	while (l<=r)
	{
	//	cout<<l<<" "<<r<<" "<<ans<<" \n";
		int mid=(l+r)>>1;
		if (check(mid)) {ans=max(ans,mid);l=mid+1;} else r=mid-1;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

string s;
int dp[MAXN], opt[(1 << 26) + 250], msk;

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> s;
	memset(dp, 0x3f, sizeof dp);
	memset(opt, 0x3f, sizeof opt);
	dp[0] = 0;
	opt[0] = 0;
	rep(i, 0, sz(s) - 1) {
		msk ^= (1 << (s[i] - 'a'));
		dp[i] =  opt[msk] + 1;
		rep(j, 0, 25) {
			updmin(dp[i], opt[msk ^ (1 << j)] + 1);
		}
		updmin(opt[msk], dp[i]);
	}
	cout << dp[sz(s) - 1];

	return 0;
}

Measured memory_bytes: 264724
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#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                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}

bool chk(string s)
{
    string yo=s;
    reverse(s.begin(),s.end());
    if(yo==s)return  true;
    else return false;
}

 main()

{
    fast
    string s;
    cin>>s;
    int n=s.size();
    int lft=1;
    int rgt=(n-1)/2;
    int len=rgt-lft+1;
    string x=s.substr(lft-1,len);
    lft=(n+3)/2;
    rgt=n;
    len=rgt-lft+1;
    string y=s.substr(lft-1,len);
    if(chk(x) && chk(y) && chk(s))
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;


















    return 0;

}













Measured memory_bytes: 256
#include <bits/stdc++.h>
#define io ios_base::sync_with_stdio(0);cin.tie(0);
#define mod 1000000007
#define pi 2*acos(0)
#define ll long long
#define ii pair<int,int>
#define vi vector<int>
using namespace std;



int main()
{

	io;
	
	string s, t; cin >> s >> t;
	int del = 0;
	int ans = INT_MAX;

	for (int i = 0; i <= s.size() - t.size(); i++) {
		int k = i;



		for (int j = 0; j < t.size(); j++) {
			
			if (t[j] != s[k]) del++;
			k++;
		}
		ans = min(ans, del);
		del = 0;

	}
	


	cout << ans;

}



Measured memory_bytes: 3564
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	vals := make([]int, n)
	for i := range vals {
		var x int
		fmt.Scanf("%d", &x)

		vals[i] = x
	}

	sort.Ints(vals)

	sum := float64(vals[0])
	for i := 1; i < len(vals); i++ {
		sum += float64(vals[i])
		sum /= 2
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512