akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <random>
#include <cmath>
#include <iomanip>
#include <climits>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#include <new>
#include <typeinfo>

typedef  long long ll;
#define mop 1000000007
#define mop2 998244353
using namespace std;

int main() {
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll i=1;i<=n;i++){
        if(i%3 != 0 and i%5 != 0){
            ans += i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3620
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashSet;
import java.util.Set;

public class Main {

	public static void main(String[] args) throws Exception {
		long start = System.currentTimeMillis();
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = br.readLine();
		String[] flds = line.split(" ");
		int a = Integer.parseInt(flds[0]);
		int b = Integer.parseInt(flds[1]);
		int c = Integer.parseInt(flds[2]);
		Set<Integer> set = new HashSet<Integer>();
		set.add(a);
		set.add(b);
		set.add(c);
		System.out.println(set.size());
		long end = System.currentTimeMillis();
		//System.out.println((end-start) + "ms");
	}

}


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

int main() {
  int n;
  cin >>n;
  int t[100100],x[1000100],y[100100];
  for(int i = 1; i<n+1; i++){
    cin >> t[i] >> x[i] >> y[i];
  }
  t[0]=x[0]=y[0] = 0;
  
  bool ok= true;
  rep(i,n){
    int dt = t[i+1] - t[i];
    int dis = abs(x[i+1] - x[i]) + abs(y[i+1] - y[i]);
    if (dis > dt){
      ok = false;
    }
    if (dt%2 != dis%2){
      ok = false;
    }
  }
  if (ok){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
	int w[10],k[10];
	for(int i=0;i<10;i++) scanf("%d",&w[i]);
	for(int i=0;i<10;i++) scanf("%d",&k[i]);
	sort(w,w+10);
	sort(k,k+10);
	printf("%d ",w[7]+w[8]+w[9]);
	printf("%d\n",k[7]+k[8]+k[9]);
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator

#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second

#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));

#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2

#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;

const int N=505;
const int LIM=8000;
int fl[LIM],pri[LIM],n;
void initprime(){
	For(i,2,LIM-1) For(j,2,(LIM-1)/i) fl[i*j]=1;
	For(i,1,LIM-1) if (!fl[i]) pri[++*pri]=i;
}
map<int,int> mp1,mp2;
map<ll,int> mp3;
ll ans[N][N];
ll gcd(ll x,ll y){
	return y?gcd(y,x%y):x;
}
void work(){
	int l=4;
	For(i,1,n) For(j,1,n) if ((i+j)&1){
		if (!mp1[i+j]) mp1[i+j]=pri[l++];
		if (l>333) l=4;
		ans[i][j]=mp1[i+j];
	}
	l=4;
	Rep(i,n,1) For(j,1,n) if ((i+j)&1){
		if (!mp2[i-j]) mp2[i-j]=pri[l++];
		if (l>333) l=4;
		ans[i][j]*=mp2[i-j];
	}
	For(i,1,n) For(j,1,n) if ((i+j)&1){
		int v=mp1[i+j]*mp2[i-j];
		for (;mp3[ans[i][j]];ans[i][j]+=v);
		mp3[ans[i][j]]++;
	}
	ll mx=0;
	For(i,1,n) For(j,1,n) if (!ans[i][j]){
		ll lcm=1;
		if (i!=1) lcm*=ans[i-1][j]/gcd(ans[i-1][j],lcm);
		if (i!=n) lcm*=ans[i+1][j]/gcd(ans[i+1][j],lcm);
		if (j!=1) lcm*=ans[i][j-1]/gcd(ans[i][j-1],lcm);
		if (j!=n) lcm*=ans[i][j+1]/gcd(ans[i][j+1],lcm);
		ans[i][j]=lcm+1;
		for (;mp3[ans[i][j]];ans[i][j]+=lcm);
		mp3[ans[i][j]]=1;
		mx=max(mx,ans[i][j]);
	}
	For(i,1,n){
		For(j,1,n) printf("%lld ",ans[i][j]);
		puts("");
	}
}

int main(){
	scanf("%d",&n);
	initprime();
	work();
}

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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
#define MOD 1000000007
using namespace std;


ll solve1(int n , int m){
	int p = 0;
	ll ans = 1;
	if(m > n)return 0;
	int l = n + m;
	rep(i , l){
		if(p == 0 && n > 0){
			ans = (ans * n) % MOD;
			p ^= 1;
			--n;
		}else if(p == 1 && m > 0){
			ans = (ans * m) % MOD;
			p ^= 1;
			--m;
		}else{
			return 0;
		}
	}
	return ans;
}

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

	int n , m;
	cin >> n >> m;
	
	ll ans = 0;
	
	ans += solve1(n , m) % MOD;
	ans += solve1(m , n) % MOD;
	ans %= MOD;
	while(ans < 0)ans += MOD;
	cout << ans;
	
	
	

	return 0;
}

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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  int n,m;
  cin >> n >> m;
  ll cnt[n+1] = {0LL};
  bool ng[n+1] = {false};
  
  int tmp;
  REP(i,m) {
    cin >> tmp;
    ng[tmp] = true;
  }
  cnt[0] = 1;
  FOR(i,0,n){
    if(ng[i])continue;
    if(i+1 <= n && !ng[i+1]){
      cnt[i+1] += cnt[i];
      cnt[i+1] %= MOD;
    }
    if(i+2 <= n && !ng[i+2]){
      cnt[i+2] += cnt[i];
      cnt[i+2] %= MOD;
    }
  }
  cout << cnt[n] << endl;
  return 0;
}

Measured memory_bytes: 4460
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <limits.h>
int numbers[100005];
char cards[100005];
int numbersM[100005];
char cardsM[100005];
void merge(int *array, char *cards, int p, int q, int r){
	int n1 = q-p+1;
	int n2 = r-q;
	int left[n1 + 1];
	int right[n2 + 1];
	char leftcard[n1];
	char rightcard[n2];

	for(int i = 0; i < n1; ++i){
		left[i] = array[p + i];
		leftcard[i] = cards[p + i];
	}
	left[n1] = INT_MAX;
	for(int i = 0; i < n2; ++i){
		right[i] = array[q + 1 + i];
		rightcard[i] = cards[q + 1 + i];
	}
	right[n2] = INT_MAX;
	int i=0, j=0;
	for(int k = p; k <= r; ++k){
		if(left[i] <= right[j]){
			array[k] = left[i];
			cards[k] = leftcard[i];
			++i;
		}else{
			array[k] = right[j];
			cards[k] = rightcard[j];
			++j;
		}
	}
}
void mergeSort(int *array, char *cards, int p, int r){
	if(p < r){
		int q = (p+r)/2;
		mergeSort(array, cards, p, q);
		mergeSort(array, cards, q+1, r);
		merge(array, cards, p, q, r);
	}
}
void swap(int p, int r){
	int tmpnum = numbers[p];
	char tmpcard = cards[p];

	numbers[p] = numbers[r];
	cards[p] = cards[r];

	numbers[r] = tmpnum;
	cards[r] = tmpcard;
}
int partition(int p, int r){
	int x = numbers[r];
	int i = p - 1;
	for(int j = p; j < r; ++j){
		if(numbers[j] <= x){
			++i;
			swap(i, j);			
		}
	}
	swap(i+1, r);
	return i + 1;
}

void quickSort(int p, int r){
	if(p < r){
		int q = partition(p, r);
		quickSort(p, q - 1);
		quickSort(q + 1, r);
	}
}
void printCard(int n){
	for(int i = 0; i < n; ++i){
		printf("%c %d\n", cards[i], numbers[i]);
	}
}
void printCardM(int n){
	for(int i = 0; i < n; ++i){
		printf("%c %d\n", cardsM[i], numbersM[i]);
	}
}
void check(int n){
	for(int i = 0; i < n; ++i){
		if((cards[i] == cardsM[i]) && (numbers[i] == numbersM[i])){
			
		}else{
			printf("Not stable\n");
			return;
		}
	}
	printf("Stable\n");
}
int main(){
	int n;
	char line[100];
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%d", &n);
	char *str_ptr;
	for(int i = 0; i < n; ++i){
		fgets(line, sizeof(line), stdin);
		cards[i] = line[0];
		cardsM[i] = line[0];
		str_ptr = strtok(line, " ");
		str_ptr = strtok(NULL, " ");
		numbers[i] = atoi(str_ptr);
		numbersM[i] = atoi(str_ptr);
	}
	
	quickSort(0, n - 1);
	mergeSort(numbersM, cardsM, 0, n - 1);
	check(n);
	printCard(n);
	
	return 0;
}


Measured memory_bytes: 3204
H, W = map(int, input().split())
N = int(input())
a = list(map(int, input().split()))
ans = [[0]*W for _ in range(H)]

now = a.pop()
now_i = N
for i in range(H):
    if i % 2 == 0:
        for j in range(W):
            if now == 0:
                now = a.pop()
                now_i -= 1
            ans[i][j] = str(now_i)
            now -= 1
    else:
        for j in range(W-1, -1, -1):
            if now == 0:
                now = a.pop()
                now_i -= 1
            ans[i][j] = str(now_i)
            now -= 1
for i in range(H):
    print(" ".join(ans[i]))


Measured memory_bytes: 9440
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int,int>;
#define rep(i,n) for(int i=0; i<n; i++)
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてから使う
#define INF 2147483647
#define LLINF 9223372036854775807LL

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

Measured memory_bytes: 3548
#include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <set>

#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, x, n) for (int i = x; i < n; ++i)

typedef std::vector<int> v;
typedef std::vector<std::vector<int>> vv;
typedef unsigned long long ull;

int main(void)
{
    int n;
    scanf("%d", &n);
    std::set<std::string> ss;
    REP(i, n)
    {
        char *s = new char[10];
        scanf("%s", s);
        ss.insert(s);
    }
    printf("%lu", ss.size());
}

Measured memory_bytes: 21900
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>


using namespace std;
int main()
{/*二日目*/
	long long n;cin >> n;
	int a = n / 500;
	int b = n % 500;
	int c = b / 5;
	int sum = a * 1000 + c * 5;
	cout << sum;
}

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

int main()
{
  string s;
  cin>>s;
 
  for(int i=0;i<4;i++)
  {
    if(s[i] == s[i+1])
    {
      cout<<"Bad";
    return 0;
    }
  }
    
   cout<<"Good";
   return 0;
}


Measured memory_bytes: 3552
#include <stdio.h>
#include <string.h>

typedef struct {
  char name[10];
  int t;
} P;

P Q[100000], _Q;
int head = 0, tail = 0, n,q,i,c=0,t=0,s;

void enqueue(P x){
  if(tail == n){
    tail = 0;
  }
  Q[tail++]=x;
}

P dequeue(void){
  if(head == n){
    head = 0;
  }
  return Q[head++];
}

int main(){

  scanf("%d %d",&n,&q);
  for(i=0;i<n;i++){
    scanf("%s%d",Q[i].name,&Q[i].t);
  }

  while(c!=n){
    _Q=dequeue();
    if(_Q.t<=q){
      t += _Q.t;
      c++;
      printf("%s %d\n",_Q.name,t);
    }else{
      t+=q;
      _Q.t-=q;
      enqueue(_Q);
    }
  }
  return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

  int cnt = 0;
  sort(l.begin(), l.end());
  for (int x = 0; x < n - 2; x++) {
    for (int y = x + 1; y < n - 1; y++) {
      auto iter = upper_bound(l.begin() + y + 1, l.end(), l[x] + l[y] - 1);
      cnt += (int)distance(l.begin() + y + 1, iter);
    }
  }

  cout << cnt << '\n';
  return 0;
}


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

map<string, int>M;

int main(){
    int n;
    cin>>n;
    long ans = 0;
    
    for(int i=0; i<n; i++){
        string s;
        cin>>s;
        sort(s.begin(), s.end());

        //アナグラムが一個見つかるとそれまでの分だけ増える
        ans+=M[s]++;
    }

    cout<<ans<<endl;
}

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

int main (){
  int n;
  vector< pair<int,int> > tm;
  while(cin>>n && n){
    tm.clear();
    char ch1,ch2;
    int h,m,s;
    for(int i=0;i<n;i++){
      cin>>h>>ch1>>m>>ch2>>s;
      tm.push_back(make_pair(h*3600+m*60+s,1));
      cin>>h>>ch1>>m>>ch2>>s;
      tm.push_back(make_pair(h*3600+m*60+s,-1));
    }
    sort(tm.begin(),tm.end());
    int ans=0;
    int co=0;
    for(int i=0;i<(int)tm.size();i++){
      co+=tm[i].second;
      ans = max(co,ans);
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1532
fun main(args: Array<String>){
  val S = readLine()!!
  for( i in S.indices ){
    if( S[i] == 'U' || S[i] == 'D' || i%2 == 1 && S[i] == 'L' || i%2 == 0 && S[i] == 'R')
      continue
    println("No")
    return
  }
  println("Yes")
}


Measured memory_bytes: 33852
#include <iostream>
using namespace std;
const string kai[11] = {"light fly","fly","bantam","feather","light","light welter"
			,"welter","light middle","middle","light heavy","heavy"};

  int main(){
    double w;
      while( cin >> w ){
	if(w <= 48.00)cout << kai[0];
	else if(w <= 51.00)cout << kai[1];
	else if(w <= 54.00)cout << kai[2];
	else if(w <= 57.00)cout << kai[3];
	else if(w <= 60.00)cout << kai[4];
	else if(w <= 64.00)cout << kai[5];
	else if(w <= 69.00)cout << kai[6];
	else if(w <= 75.00)cout << kai[7];
	else if(w <= 81.00)cout << kai[8];
	else if(w <= 91.00)cout << kai[9];
	else cout << kai[10];
	cout << endl;
      }
    return 0;
  }

Measured memory_bytes: 1232
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  string s;
  cin >> s;
  string a;
  rep(i,s.size()){
    if(i%2==0) a += s.at(i);   
  }
  cout << a << endl;
}

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

bool isprime(int a){
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
		}
		return a!=1;
	}

int main(){
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=1;i<=n;i++){
			int b=n+1-i;
			if(isprime(b)&&isprime(i))ans++;
			}
			cout<<ans<<endl;
		}
		return 0;
	}

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=998244353;
vin dx={-2,-1,0,1,2};
vin dy={-2,-1,0,1,2};

int MAX_N=1000050;

vector<vector<pair<ll,ll>>> edge(MAX_N);
vll d(MAX_N);

void dijkstra(ll s){
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> q;
    fill(all(d),INF);
    d[s]=(ll)0;
    q.push(mp(0,s));
    while(q.size()){
        auto p=q.top();q.pop();
        auto v=p.second;
        if(d[v]<p.first)continue;
        for(auto e:edge[v]){
            if(d[e.first]>d[v]+e.second){
                d[e.first]=d[v]+e.second;
                q.push(mp(d[e.first],e.first));
            }
        }
    }
}

int main(){
    //(i,j)=i*w+J
    int h,w;cin>>h>>w;
    int ch,cw,dh,dw;cin>>ch>>cw>>dh>>dw;
    vvch s(h,vch(w));rep(i,h)rep(j,w)cin>>s[i][j];
    int ni,nj;
    rep(i,h)rep(j,w){
        if(s[i][j]=='.'){
            rep(k,5)rep(l,5){
                if(dy[k]==0&&dx[l]==0)continue;
                ni=i+dy[k];
                nj=j+dx[l];
                if(0<=ni&&ni<h&&0<=nj&&nj<w&&s[ni][nj]=='.'){
                    if(abs(dy[k])+abs(dx[l])<=1)edge[i*w+j].push_back(mp(ni*w+nj,0));
                    else edge[i*w+j].push_back(mp(ni*w+nj,1));
                }
            }
        }
    }
    ch--;cw--;dh--;dw--;
    dijkstra(ch*w+cw);
    ll ans=d[dh*w+dw];
    if(ans==INF)cout<<-1<<endl;
    else cout<<ans<<endl;
}

Measured memory_bytes: 167600
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(12);
  std::cerr << std::fixed << std::setprecision(12);

  int N;

  std::cin >> N;

  std::cout << static_cast<long double>((N + 1) / 2) / N << std::endl;
  
  return 0;
}


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

public class Main {
	public static void main(String[] arg) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		String[] param = new String[10];
		do {
			for (int i = 0; i < n; i++) {
				String name = in.next();
				int point = in.nextInt() * 3;
				in.next();
				point += in.nextInt();
				param[i] = String.format("%1$02d%2$02d%3$s,%4$d", 30-point, i,
						name, point);
			}
			Arrays.sort(param, 0, n);
			for (int i = 0; i < n; i++) {
				System.out.println(param[i].substring(4));
			}
			if ((n = in.nextInt()) == 0) {
				break;
			} else {
				System.out.println();
			}
		} while (true);
	}
}

Measured memory_bytes: 20772
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

char flip(char c){
	if(c == 'A') return 'B';
	else return 'A';
}

signed main(){
	int n,k,head = 0,cnt = 0;
	string s;
	cin >> n >> k >> s;
	for(int i = 0;i < min(k,n * 4);i++){
		char c = s[head];
		if(cnt % 2) c = flip(c);
		if(c == 'A') s[head] = flip(s[head]);
		else{
			head = (head + 1) % n;
			cnt++;
		}
	}
	if(cnt % 2){
		for(int i = 0;i < n;i++) s[i] = flip(s[i]);
	}
	if(k > n * 4 && n % 2 && (k - n * 4) % 2) s[head] = flip(s[head]);
	for(int i = 0;i < n;i++) cout << s[(head + i) % n];
	cout << endl;
	return 0;
}

Measured memory_bytes: 900
#include <cstdio>
#define k 1024
#define r(a) for(int i=0;i<a;i++)
#define s(a) scanf("%d",&a);
#define m(a,b) a<b?a:b
int w,n,m,c[k],d[k],p[k];
int main(){
	s(n)s(m)
	r(n)s(d[i])
	r(m)s(c[i])
	r(n+1)p[i]=1<<29;
	p[0]=0;
	r(m*n)w=n-i%n,p[w]=m(p[w],p[w-1]+c[i/n]*d[w-1]);
	printf("%d\n",p[n]);
}

Measured memory_bytes: 1036
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
 
 
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
 
ll modPow(ll x, ll n, ll mod = MOD){
    ll res = 1;
    while(n){
        if(n&1) res = (res * x)%mod;
 
        res %= mod;
        x = x * x %mod;
        n >>= 1;
    }
    return res;
}
 
ll arr[100010];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  ll N, K; cin >> N >> K;

  ll ans = 0;
  for(int i=K; i>=1; i--){

    arr[i] = modPow(K/i, N, MOD);
    for(int j=2; j*i<=K; j++){
      arr[i] -= arr[j*i];
      arr[i] += MOD;
      arr[i] %= MOD;
    }

    ans += arr[i] * i;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}

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

public class Main {
	public static void main(String [] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int min = 2000000000;
		int h = 0;
		for(int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
		}

		Arrays.sort(x);
		if(x[0] == x[x.length - 1]) {
			System.out.println(0);
			System.exit(0);
		}

		for(int i = x[0]; i < x[x.length - 1]; i++) {
			h = 0;
			for(int value : x) {
				h += cost(value, i);
				if(h > min) {
					break;
				}
			}
			if(h < min) min = h;
		}

		System.out.println(min);
		sc.close();
	}

	public static int cost(int x, int p) {
		return (x - p) * (x - p);
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <set>
#include <map>

#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

constexpr int inf = (int)1e9;
constexpr double INF = 1e12, EPS = 1e-9;
constexpr int MX = 2010;
constexpr int mod = inf + 7;

int n, m, q, a[MX];
int L[MX][MX], R[MX][MX];
int memo[MX][MX];

int main() {
  int N, K;

  ll c[3][3];

  rep(i,3) {
    rep(j, 3) {
      cin >> c[i][j];
    }
  }

  int a[3];
  int b[3];

  a[0] = 0;
  rep(i, 3) {
    b[i] = c[0][i] - a[0];
  }

  a[1] = c[1][0] - b[0];
  a[2] = c[2][0] - b[0];

  bool re{true};
  rep(i,3) {
    rep(j, 3) {
      if (c[i][j] != a[i] + b[j]) {
        re = false;
        goto end;
      }
    }
  }

  end:

  cout << (re ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <numeric>
#include <iomanip>
#include <cmath>
#include <cstring>
using namespace std;
int a[50];
int b[50];
int c[50];
int d[50];
int f(int depth, int N, int M, int Q, vector <int> A){
  if(depth == N){
    int ret = 0;
    for(int i = 0; i < Q; i++){
      if(A[b[i]] - A[a[i]] == c[i]){
        ret += d[i];
      }
    }
    return ret;
  }

  int prev = 1;
  if(A.size() > 0){
    prev = A[A.size() - 1];
  }

  int ret = 0;
  for(int i = prev; i <= M; i++){
    vector <int> new_A = A;
    new_A.push_back(i);
    ret = max(ret, f(depth + 1, N, M, Q, new_A));
  }
  return ret;
}
int main(){
  int N;
  int M;
  int Q;
  cin >> N >> M >> Q;

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

  vector <int> A;
  cout << f(0, N, M, Q, A) << endl;

  return 0;
}


Measured memory_bytes: 3584
#include<stdio.h>
     
int main()
{
  int i,j,v,A[100],N,s;

  scanf("%d",&N);
  for(i=0;i<N;i++)
    {
      scanf("%d",&A[i]);
    }
        for(s=0;s<N;s++)
	{
	  if(s>0) printf(" ");
	  printf("%d",A[s]);
	}
      printf("\n");

  
  for(i=1;i<=N-1;i++)
    {
      v=A[i];//ittan
      j=i-1;
      while(j>=0 && A[j]>v)
	{
	  A[j+1] = A[j];
	  j--;
	}
      A[j+1]=v;
      for(s=0;s<N;s++)
	{
	  if(s>0) printf(" ");
	  printf("%d",A[s]);
	}
      printf("\n");
    }


  return 0;
}
  




Measured memory_bytes: 2064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

ll solve() {
    ll N, M;
    cin >> N >> M;
    if ( N == 1 && M == 1 ) return 1;
    if ( N == 1 ) return M-2;
    if ( M == 1 ) return N-2;
    return (N-2)*(M-2);
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        List<Integer> l = new ArrayList<>();
        
        for (int i = 0; i < n; i++){
            l.add(sc.nextInt());
        }
        Collections.sort(l);
        
        int res = 0;

        for (int i= n-1; i>=n-k; i--){
            res = res + l.get(i);
        }

        System.out.println(res);
    }
}

Measured memory_bytes: 35692
n,h = map(int, input().split())
A = 0
B = []
for _ in range(n):
    a,b = map(int, input().split())
    if A < a: A = a
    B.append(b)
B.sort(reverse=True)
cnt = 0
for i in B:
    if A < i: 
        h -= i
        cnt += 1
    if h <= 0:
        print(cnt)
        exit()
print(cnt+(h+A-1)//A)

Measured memory_bytes: 7388
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    int n,m,i;
    cin>>n>>m;
    vector<pair<int ,int> > sc(n);
    vector<int> keta(n,0);
    int aa=0;

    if(n==1){
        if(m==0){
            cout<<0;
            return 0;
        }else{
            rep(i,m){
                cin>>sc[i].first>>sc[i].second;
                if(aa==0){
                    aa=sc[i].second;
                }else if(aa==sc[i].second){
                    continue;
                }else{
                    cout<<-1;
                    return 0;
                }
            }
            cout<<aa;
            return 0;
        }
    }

    rep(i,m){
        cin>>sc[i].first>>sc[i].second;
        if(sc[i].first==1 && sc[i].second==0){
            cout<<-1;
            return 0;
        }else if(keta[sc[i].first-1]==0 || keta[sc[i].first-1]==sc[i].second){
            keta[sc[i].first-1]=sc[i].second;
        }else{
            cout<<-1;
            return 0;
        }
    }
    int ans=0;
    if(keta[0]!=0){
        rep(i,n){
            ans+=pow(10,n-i-1)*keta[i];
        }
        cout<<ans;
    }else{
        ans+=pow(10,n-1);
        rep(i,n-1){
            ans+=pow(10,n-i-2)*keta[i+1];
        }
        cout<<ans;
    }
    return 0;

}

Measured memory_bytes: 256
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input1 = Console.ReadLine().Split(' ');
            int N = int.Parse(input1[0]);
            int K = int.Parse(input1[1]);
            string S = Console.ReadLine();
            char[] str = S.ToCharArray();
            str[K-1] = Char.ToLower(str[K-1]);
            string s_out = new string(str);
            Console.WriteLine(s_out);
        }
    }
}


Measured memory_bytes: 11092
w=input()
list=[]
for i in range(len(w)):
    if w[i]=='C':
        list.append('Z')
        
    elif w[i]=='B':
        list.append('Y')
        
    elif w[i]=='A':
        list.append('X')
    else:
        c=ord(w[i])-3
        list.append(chr(c))
l=''.join(list)
print(l)
    


Measured memory_bytes: 5564
n = int(input())
s = input()
ans = [0]*n
for i in range(n-1):
    cnt = 0
    x = list(set(s[0:i+1]))
    y = list(set(s[i+1:]))
    for j in range(len(x)):
        if x[j] in y:
            cnt += 1
    ans.append(cnt)
print(max(ans))

Measured memory_bytes: 39280
#include <bits/stdc++.h>
using namespace std;
int main () {
	int A,B,C,X,Y;
	long long money = 0;
	cin >> A>>B>>C>>X>>Y;
	int minKind = min(X,Y);
	money += minKind * min(A+B,2*C);
	if(X>Y){
		int left = X - Y;
		if(A > 2 * C){
			money += 2 * C * left;
		}else{
			money += A * left;
		}
	}else{
		int left = Y - X;
		if(B > 2 * C){
			money += 2 * C * left;
		}else{
			money += B * left;
		}
	}
	cout << money << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//using ProCon.Util;

namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            AC135B();
        }

        static void AC135B()
        {
            //https://atcoder.jp/contests/abc135/tasks

            var n = int.Parse(Console.ReadLine()); //勇者の数
            var listA = Console.ReadLine().Split().Select(long.Parse).ToArray(); //街にいるモンスターの数
            var listB = Console.ReadLine().Split().Select(long.Parse).ToArray(); //勇者が倒せる数

            var sum = listA.Sum();

            for (int i = 0; i < n; i++ )
            {
                //まずはiの街を倒す
                if(listB[i] - listA[i] >= 0)
                {
                    listB[i] = listB[i] - listA[i];
                    listA[i] = 0;
                }
                else
                {
                    listA[i] = listA[i] - listB[i];
                    listB[i] = 0;
                }

                //まだ余力があればi +1の街を倒す
                if(listB[i] > 0)
                {
                    if (listB[i] - listA[i + 1] >= 0)
                    {
                        listB[i] = listB[i] - listA[i + 1];
                        listA[i + 1] = 0;
                    }
                    else
                    {
                        listA[i+ 1] = listA[i + 1] - listB[i];
                        listB[i] = 0;
                    }
                }
            }

            Console.WriteLine(sum - listA.Sum());
            Console.ReadKey();

        }

    }
}


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

public class Main {
	
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int r = in.readInt(); 
		int g = in.readInt();
		System.out.println(2*g - r);	
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 23124
from collections import Counter

def input_func():
    N = int(input())
    lis = []
    for i in range(N):
        x, y = map(int, input().split())
        lis.append([x,y])
        sort_lis = sorted(lis)
    return N,sort_lis


def evaluate(N, sort_lis):
    diff = []
    if N == 1:
        answer = 1
        
    else:
        for i in range(N-1):
            for j in range(i+1,N):
                diff.append((sort_lis[i][0] -sort_lis[j][0],sort_lis[i][1]-sort_lis[j][1]))
        count = Counter(diff).most_common()
        answer = len(sort_lis)-count[0][1]
    return answer 

if __name__ == '__main__':
    N, sort_lis = input_func()
    answer = evaluate(N,sort_lis)
    print(answer)

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ulint = unsigned long long;
using lint = long long ;
using ldouble = long double;

void err(istream_iterator<string> _it) {}
template<typename T,typename... Args>
void err(istream_iterator<string> _it, T a,Args... args) {cerr<<"\e[91m"<<*_it<<" is "<<a<<"\e[39m"<<endl;err(++_it,args...);}

//#define __debug true; // c++17
const bool _debug = true;
#define cerr if(_debug)cerr
#define eb emplace_back
#define watch(args...) if(_debug){string _s = #args; replace(_s.begin(),_s.end(),',',' ');stringstream _ss(_s);cerr<<"\n";istream_iterator<string> _itt(_ss);err(_itt,args);} 

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    
    int d, t, s;
    cin >> d >> t >> s;
    double ans = (double)d / s;
    int ans1 = d / s;
    if (ans == ans1) cout << (ans1 <= t ? "Yes" : "No") << endl;
    else cout << (ans1 + 1 <= t ? "Yes" : "No") << endl;
    return 0;
}





Measured memory_bytes: 3700
# 55:33
import numpy as np

N, K, *XY = map(int, open(0).read().split())

X = XY[::2]
comp_X = {}
decomp_X = {}
for i, x in enumerate(sorted(set(X))):
    comp_X[x] = i
    decomp_X[i] = x

Y = XY[1::2]
comp_Y = {}
decomp_Y = {}
for i, y in enumerate(sorted(set(Y))):
    comp_Y[y] = i
    decomp_Y[i] = y

I = len(comp_X)
J = len(comp_Y)
comp_XY = [(comp_X[x], comp_Y[y]) for x, y in zip(X, Y)]
acc = np.zeros((I + 1, J + 1), np.int32)
for c_x, c_y in comp_XY:
    acc[c_x + 1][c_y + 1] += 1
acc = np.add.accumulate(acc, axis=0)
acc = np.add.accumulate(acc, axis=1)

ans = float("inf")
for i in range(1, I + 1):
    for j in range(1, J + 1):
        cur = acc[i:, j:] + acc[:-i, :-j] - acc[:-i, j:] - acc[i:, :-j]
        for k, row in enumerate(cur):
            for l, val in enumerate(row):
                if val >= K:
                    ans = min(
                        ans,
                        (decomp_X[k + i - 1] - decomp_X[k])
                        * (decomp_Y[l + j - 1] - decomp_Y[l]),
                    )
print(ans)


Measured memory_bytes: 27404
#include <iostream>

int main()
{
    int A, B;
    int K;

    std::cin >> K;
    std::cin >> A >> B;
    bool succeed = false;
    if (A % K == 0)
    {
        succeed = true;
    }
    else if (B % K == 0)
    {
        succeed = true;
    }
    else
    {
        int min = A / K;
        int max = B / K;
        if (min != max)
            succeed = true;
    }
    if (succeed)
        std::cout << "OK";
    else
        std::cout << "NG";
}

Measured memory_bytes: 3580
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use std::cmp::*;
use std::collections::*;
use std::mem::*;

fn main() {
    let (r, w, e) = (std::io::stdin(), std::io::stdout(), std::io::stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    let n = io.read::<usize>();
    let mut a = io.readn::<i64>(n);

    // let mut a1 = vec![26, 5, 7, 22];
    // let conv = |a: Vec<i64>| -> Vec<i64> {
    //     let mut c = Vec::new();
    //     for i in 0..a.len() {
    //         let mut ret = 0;
    //         for j in 0..a.len() {
    //             if i == j {
    //                 continue;
    //             }
    //             ret ^= a[j];
    //         }
    //         c.push(ret);
    //     }
    //     c
    // };

    // let a2 = a1.clone();
    // io.debug(conv(a1));
    // io.debug(conv(conv(a2)));

    let mut allxor = 0;
    for &x in a.iter() {
        allxor ^= x;
    }

    for &x in a.iter() {
        io.writeln(allxor ^ x);
    }
}

static MX: usize = 1010101;
static MOD: i64 = 1000000007;
static INF: i64 = std::i64::MAX >> 1;
// IO
use std::io::*;
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn chari(&mut self) -> Vec<i64> {
        self.chars()
            .iter()
            .map(|&c| (c as u8 - b'0') as i64)
            .collect::<Vec<i64>>()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug, T: std::fmt::Debug>(&mut self, val1: S, val2: T) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
    fn debug3<S: std::fmt::Debug, T: std::fmt::Debug, U: std::fmt::Debug>(
        &mut self,
        val1: S,
        val2: T,
        val3: U,
    ) {
        writeln!(
            self.Error,
            "(debug3) {:?} -> {:?} -> {:?}",
            val1, val2, val3
        );
    }
}


Measured memory_bytes: 4052
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
bool possible(vector<ll> &a,int k,ll can)
{

 ll count=0;
 int n=a.size();

 for(int i=0;i<n;i++)
 {	
 	if(a[i]<=can)
 		continue;

 	count+=(a[i]/can);
 }



 return (count<=k);

}


int main()
{
	int n,k;
	cin>>n>>k;
	vector<ll> a(n);
	ll mx=INT_MIN;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		mx=max(mx,a[i]);
	}

	ll l=1,h=mx+1;


	ll opt=1e18;

	while(l<=h)
	{
		ll mid=(l+h)/2;

		if(possible(a,k,mid))
		{
			opt=min(opt,mid);
			h=mid-1;
		}
		else
		{
			l=mid+1;
		}

		//cout<<mid<<endl;


	}

	cout<<opt<<endl;


	return 0;
}

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

vector<pair<int, int>> points;
vector<vector<double>> dists;
double totalDists;
int N;

void dfs(int prev, int current, int visited, double distance)
{
    distance += dists.at(prev).at(current);
    visited |= 1 << current;
    if(visited == (1 << N) - 1){
        totalDists += distance;
        return;
    };
    for(int i = 0; i < N; i++)
    {
        if((visited & 1 << i) == 0){
            dfs(current, i, visited, distance);
        }
    }
}

int main()
{
    cin >> N;
    points = vector<pair<int, int>>(N);
    dists = vector<vector<double>>(N, vector<double>(N));
    for(int i = 0; i < N; i++)
    {
        int x, y;
        cin >> x >> y;
        points.at(i) = pair<int, int>(x, y);
    }
    for(int i = 0; i < N; i++)
    {
        pair<int, int> point1 = points.at(i);
        for(int j = 0; j < N; j++)
        {
            pair<int, int> point2 = points.at(j);
            dists.at(i).at(j) = sqrt(pow(abs(point1.first - point2.first), 2.0)
            + pow(abs(point1.second - point2.second), 2.0));
        }
    }
    for(int i = 0; i < N; i++)
    {
        dfs(i, i, 0, 0.0);
    }
    for(int i = 2; i <= N; i++){
        totalDists /= i;
    }
    cout << std::setprecision(11) << totalDists << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define ld long double
int const M=2e5+10,M2=1e7+10,mod=1e9+7,inf=1e18+10;
int a[M];
int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];	
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		int tmp;
		cin>>tmp;
		a[i]=a[i]-tmp;
		if(a[i]>0)cnt+=a[i];
		else cnt-=(abs(a[i])/2);
	}
	if(cnt>0)cout<<"No";
	else cout<<"Yes";
}

Measured memory_bytes: 384
use std::collections::HashMap;
fn read<T: std::str::FromStr>() -> T {
	let mut s = String::new();
	std::io::stdin().read_line(&mut s).ok();
	s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
	read::<String>().split_whitespace()
		.map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
	(0..n).map(|_| read_vec()).collect()
}

pub trait LexicalPermutation {
	/// Return `true` if the slice was permuted, `false` if it is already
	/// at the last ordered permutation.
	fn next_permutation(&mut self) -> bool;
}
impl<T> LexicalPermutation for [T] where T: Ord {
	/// Original author in Rust: Thomas Backman <serenity@exscape.org>
	fn next_permutation(&mut self) -> bool {
		// These cases only have 1 permutation each, so we can't do anything.
		if self.len() < 2 { return false; }

		// Step 1: Identify the longest, rightmost weakly decreasing part of the vector
		let mut i = self.len() - 1;
		while i > 0 && self[i-1] >= self[i] {
			i -= 1;
		}

		// If that is the entire vector, this is the last-ordered permutation.
		if i == 0 {
			return false;
		}

		// Step 2: Find the rightmost element larger than the pivot (i-1)
		let mut j = self.len() - 1;
		while j >= i && self[j] <= self[i-1]  {
			j -= 1;
		}

		// Step 3: Swap that element with the pivot
		self.swap(j, i-1);

		// Step 4: Reverse the (previously) weakly decreasing part
		self[i..].reverse();

		true
	}
}

fn main() {
	let (n, m) = {
		let tmp: Vec<usize> = read_vec();
		(tmp[0], tmp[1])
	};

	let mut sc: Vec<(usize, usize)> = Vec::new();

	for _ in 0..m {
		let tmp: Vec<usize> = read_vec();
		sc.push((tmp[0], tmp[1]));
	}

	for x in 0..1000 {
		let mut digit = vec![x%10; 1];
		let mut nx = x/10;
		while nx > 0 {
			digit.push(nx%10);
			nx /= 10;
		}
		if n != digit.len() { continue; }
		digit.reverse();
		let mut flag = true;
		for i in 0..m {
			if digit[sc[i].0 - 1] != sc[i].1 { flag = false }
		}
		if flag {
			println!("{}", x);
			return;
		}
	}
	println!("-1");
}


Measured memory_bytes: 4476
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void)
{
  string s1, s2;
  int cnt = 0;
  while(cin >> s1) {
    s2 = s1;
    reverse(s2.begin(), s2.end());
    if(s1 == s2) cnt++;
    //cnt += s1 == s2;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	string s;
	cin>>n>>s;
	for(int i=0;i<s.length();i++){
		s[i]+=n;
		if(s[i]>'Z')
			s[i]-=26;
	}
	cout<<s;
}


Measured memory_bytes: 256
#include <stdlib.h>
int main() {
    int x, y;
    int t; 
    
    for (;;) {
        scanf("%d%d", &x, &y);
        
        if (x == 0 && y == 0) break;
        if (x > y){ 
            t = x; 
            x = y;
            y = t;
        }
        
        printf("%d %d\n", x, y);
        
        
    }
        return 0;
        
} 


Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
vector<string> s(210);
int dis[210][210];

int main(){
  int n;
  cin >> n;
  for(int i=0;i<n;i++) cin >> s[i];
  int ans=0;
  queue<int> q;
  vector<int> flag(n);
  for(int i=0;i<n;i++){
    q.push(i);
    flag[i]++;
    while(q.size()){
      int t=q.front(); q.pop();
      for(int j=0;j<n;j++){
        if(s[t][j]=='1'&&flag[j]==i){
          dis[i][j]=dis[i][t]+1;
          q.push(j);
          flag[j]++;
        }
      }
    }
  }
  vector<int> a(n,-1);
  a[0]=0;
  for(int i=1;i<n;i++){
    a[i]=dis[0][i]%2;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      ans=max(ans,dis[i][j]);
      if(dis[i][j]%2!=(a[i]+a[j])%2){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans+1 << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

ll N,ans,tmp,till;
bool chk=false;

int main(){
    cin>>N;
    for(long long i=1;i<=1000000;i++){
        if(i*i==N)chk=true;
    }
    till = sqrt(N)+1;
    // out(till);
    repi(i,1,till){
        // out(i);
        if((N-i)%i==0){
            if((N-i)/i>i)ans+=(N-i)/i;
        }
    }
    out(ans);
}


Measured memory_bytes: 256
// B - 105

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int count_divisor(int k) {
	int result = 0;;
	for (int i=1; i<=k; i++) {
		if (k % i == 0) {
			result++;
		}
	}

	return result;
}

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

	int ans = 0;
	for (int i=1; i<=N; i+=2) {
		if (count_divisor(i) == 8) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/agc027_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll N, x;
  cin >> N >> x;
  
  vector<ll> c(N);
  rep(i, N) { cin >> c[i]; }
  sort(c.begin(), c.end());

  ll ans = 0;
  rep(i, N) {
    if (x >= c[i]) {
      ans += 1;
      x -= c[i];
    }
  }
  if (x > 0 && ans == c.size()) ans--;

  cout << ans << endl;
}

Measured memory_bytes: 256