akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
    #define nikal ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    using namespace std;
    int main()
    {
        nikal;
        unsigned long long n,k;
        cin>>n>>k;
        cout<<min(n%k,k-(n%k));
    }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<int> abc(3);

void input(){
    for(int i=0;i<3;i++) cin >> abc[i];
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    sort(abc.begin(), abc.end());
    int ans = abc[2] - abc[1];
    abc[0] += abc[2] - abc[1];
    if((abc[2]-abc[0])%2==0){
        ans += (abc[2]-abc[0])/2;
    }
    else{
        ans += 1 + (abc[2]+1-abc[0])/2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin>>S;
  
  int n=S.size();
  bool O=true;
  bool E=true;
  for(int i=0;i<n;i+=2){
	if(S.at(i)=='L'){
	O=false;
      break;
    }
  }
  for(int i=1;i<n;i+=2){
	if(S.at(i)=='R'){
	E=false;
      break;
    }
  }
  if(O==true&&E==true) cout<<"Yes"<<endl;
  else  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,l,r)for(int i=(int)l;i<(int)r;i++)
#define rep(i,n)Rep(i,0,n)
typedef long long lld;
typedef long double Lf;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))
#define N 100001

int main() {
	lld a[N],n,flag0=0,ans=1;
	Lf dig = 0;
	scanf("%lld", &n);
	rep(i, n) { scanf("%lld", &a[i]); if (!a[i])flag0++; }
	if (flag0)ans=0;
	else {
		rep(i,n)dig+=log10l((Lf)a[i]);
		if (dig > 18.5)ans = -1;
		else rep(i, n)ans *= a[i];
	}
	printf("%lld", (ans > (lld)1e18 ? -1 : ans));
}

Measured memory_bytes: 2996
#include<bits/stdc++.h>
#define endl '\n'
#define mod (int)(1e9+7)
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
using namespace std;
int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res *= (n - i);
        res /= (i + 1);
    }
    return res;
}
int fibonacci(int n){
    double phi = (1 + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}
int inv_mod(int a){
    int res = 1;
    int mod_temp = mod-2;
    while(mod_temp){
        if(mod_temp&1){
            res = ((res%mod)*(a%mod))%mod;
        }
        a = ((a%mod)*(a%mod))%mod;
        mod_temp >>= 1;
    }
    return res%mod;
}
signed main(){

#ifndef ONLINE_JUDGE
  //  freopen("input.txt","r", stdin);
#endif
    fastIO

    int n, k;
    cin >> n >> k;
    int arr[n];
    for(int i =0;i< n;i++){
        cin >> arr[i];
    }
    sort(arr, arr+n);
    int count = 0;
    if(k>=n) cout << "0";
    else {
        for (int i = 0; i < n - k;i++){
            count += arr[i];
        }
        cout << count << endl;
    }


    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,s=0;
    cin >> n >> m;
    if(n>1)
    {
    	for (int i=1; i<n; ++i)
            s+=i;
            
    }
    if(m>1)
	{
		for (int i=1; i<m; ++i)
            s+=i;
            
	}
	
    cout << s << endl;
    return 0;
}

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


int main(){
  int H,W;
  cin >> H >> W;
  
  queue<pair<int,int> > q;
  vector<vector<int> > dist(H+2,vector<int>(W+2,-1));
  
  vector<vector<char>> g(H+2,vector<char>(W+2,'#'));
  for(int i=1;i<H+1;i++){
    for (int j=1;j<W+1;j++){
      cin >> g[i][j];
    }
  }
  
  q.push(pair<int,int>(1,1));
  dist[1][1]=0;
  const int dy[4]={0,1,0,-1};
  const int dx[4]={1,0,-1,0};
  
  
  while(!q.empty()){
    int y,x;
    pair<int,int> qf=q.front();
    tie(y,x)=qf;
    q.pop();
    for (int dir=0;dir<4;dir++){
      int ny=y+dy[dir];
      int nx=x+dx[dir];
      if(dist[ny][nx]==-1 && g[ny][nx]=='.' && 1<=ny && ny<=H && 1<=nx && nx<=W){
        dist[ny][nx]=dist[y][x]+1;
        q.push(pair<int,int>(ny,nx));
      }
    }
  }  
  
  int count=0;
  for (int i=1;i<=H;i++){
    for (int j=1;j<=W;j++){
      if (g[i][j]=='.')
        count++;
    }
  }
  
  int ans=count-(1+dist[H][W]);
  if (dist[H][W]==-1)
    cout << -1 << endl;
  else
    cout << ans << endl;
  
  
}

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

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("2");
            WillReturn.Add("2");
            WillReturn.Add("2");
            WillReturn.Add("100");
            //2
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("5");
            WillReturn.Add("1");
            WillReturn.Add("0");
            WillReturn.Add("150");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("30");
            WillReturn.Add("40");
            WillReturn.Add("50");
            WillReturn.Add("6000");
            //213
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        int A = int.Parse(InputList[0]);
        int B = int.Parse(InputList[1]);
        int C = int.Parse(InputList[2]);
        int X = int.Parse(InputList[3]);

        int Answer = 0;
        for (int I = 0; I <= A; I++) {
            for (int J = 0; J <= B; J++) {
                for (int K = 0; K <= C; K++) {
                    if (500 * I + 100 * J + 50 * K == X)
                        Answer++;
                }
            }
        }
        Console.WriteLine(Answer);
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <stdbool.h>
typedef struct {
  char gara;
  int value;
}Huda;

void bubbleSort(Huda [],int);
void selectionSort(Huda [],int);
void printArray(Huda [],int);
bool isStable(Huda [],Huda[],int N);

int main(){
 Huda H1[50];
 Huda H2[50];
 int n;
 char ch;
 int i;

 scanf("%d",&n);
 for(i=0;i<n;i++){
   scanf(" %c%d",&H1[i].gara,&H1[i].value);
 }

for(i=0;i<n;i++){
  H2[i]=H1[i];
}

 bubbleSort(H1,n);
 selectionSort(H2,n);

printArray(H1,n);
printf("Stable\n");
printArray(H2,n);
if(isStable(H1,H2,n)){
  printf("Stable\n");
}else printf("Not stable\n");

return 0;
}

void bubbleSort(Huda H1[],int N){
  int i,j;
  int h;
  i=0;
  Huda t;

for(h=0;h<=N-1;h++){
    for(j=N-1;j>=i+1;j--){
      if(H1[j].value<H1[j-1].value){
        t=H1[j];
        H1[j]=H1[j-1];
        H1[j-1]=t;
}
    }
  i++;
  }
 }

 void selectionSort(Huda H2[],int N){
   int i,minj,j;
   Huda t;
   for(i=0;i<N;i++){
     minj=i;
     for(j=i;j<N;j++){
       if(H2[j].value<H2[minj].value){
         minj=j;
       }
     }
   if(i!=minj){
     t=H2[i];
     H2[i]=H2[minj];
     H2[minj]=t;
   }
  }
  }

bool isStable(Huda H1[],Huda H2[],int N){
  int i;
  for(i=0;i<N;i++){
    if(H1[i].gara!=H2[i].gara)return false;
  }
return true;
}

void printArray(Huda A[],int N){
  int i;
  for(i=0;i<N;i++){
    if(i)printf(" ");
    printf("%c%d",A[i].gara,A[i].value);
  }
printf("\n");
}

Measured memory_bytes: 612
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
    int i,j,m,sum;
    char s[1500];
    while(~scanf("%s",s))
    {
        m=strlen(s);
        sum=0;
        for(i=m-1,j=0; j<m; j++,i--)
        {
            if(s[i]=='I'&&s[i+1]!='V'&&s[i+1]!='X')
                sum+=1;
            if(s[i]=='I'&&(s[i+1]=='V'||s[i+1]=='X'))
                sum-=1;
            if(s[i]=='V')
                sum+=5;
            if(s[i]=='X'&&s[i+1]!='L'&&s[i+1]!='C')
                sum+=10;
            if(s[i]=='X'&&(s[i+1]=='L'||s[i+1]=='C'))
                sum-=10;
            if(s[i]=='L')
                sum+=50;
            if(s[i]=='C'&&s[i+1]!='D'&&s[i+1]!='M')
                sum+=100;
            if(s[i]=='C'&&(s[i+1]=='D'||s[i+1]=='M'))
                sum-=100;
            if(s[i]=='D')
                sum+=500;
            if(s[i]=='M')
                sum+=1000;
        }
        printf("%d\n",sum);
    }
    return 0;
}



Measured memory_bytes: 1984
#include<iostream>
#include<vector>
#include<algorithm>
#include<iterator>
#include<string>
#include<queue>
#include<set>
#include<stack>
#include<map>

using namespace std;

typedef long long ll;
struct edge {
    int to;
    ll cost;
};
typedef pair<ll,ll> P;
typedef pair<ll,P> T;
const int MAX_V=200000;
const int MAX_N=100000;
vector<edge> G[MAX_N];
vector<edge> F[MAX_V];//利用した辺を収納
class uft {//union-find tree
public:
    int parent[MAX_N];
    int size[MAX_N];
    void initialize(int N);//N頂点利用するということ。
    int root(int x);
    int sz(int x);//頂点xが属するグループに含まれている要素数を返す
    bool same(int x,int y);
    void unite(int x,int y);
};
void uft::initialize(int N){
    for(int i=0;i<N;i++){
        parent[i]=i;
    }
}
int uft::root(int x){
    if(parent[x]==x){
        return x;
    }
    return parent[x] = root(parent[x]);
}
int uft::sz(int x){
    return size[root(x)];
}
bool uft::same(int x,int y){
    if(root(x)==root(y)){
        return true;
    }else{
        return false;
    }
}
void uft::unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x == y) return;
    parent[x] = y;
    size[y] = size[y]+size[x];
}
ll Kruskal(int N){//頂点数NのグラフGの最小全域木を求める。そして、利用した辺の重みの和を返す。
    uft u;
    u.initialize(N);
    ll ret=0;
    priority_queue<T, vector<T>, greater<T> > q;
    for(int i=0;i<N;i++){
        for(int j=0;j<G[i].size();j++){
            edge e=G[i][j];
            q.push(T(e.cost,P(i,e.to)));
        }
    }
    while(u.sz(0) != N && !q.empty()){
        T t=q.top(); q.pop();
        int x=(t.second).first;
        int y=(t.second).second;
        ll co=t.first;
        if(!u.same(x,y)){
            u.unite(x,y);
            ret+=co;
            edge e;
            e.cost=co;
            e.to=y; F[x].push_back(e);
            e.to=x; F[y].push_back(e);
        }
    }
    return ret;
}

int main(){
    int N;
    P xy[100000],yx[100000];
    cin>>N;
    for(int i=0;i<N;i++){
        ll x,y;
        cin>>x>>y;
        xy[i]=P(x,i);
        yx[i]=P(y,i);
    }
    sort(xy,xy+N);
    sort(yx,yx+N);
    for(int i=0;i<N-1;i++){
        ll x=xy[i+1].first-xy[i].first;
        ll xi=xy[i].second;
        ll xii=xy[i+1].second;
        edge e;
        e.to=xii;
        e.cost=x;
        G[xi].push_back(e);
        e.to=xi;
        G[xii].push_back(e);
        
        ll y=yx[i+1].first-yx[i].first;
        ll yi=yx[i].second;
        ll yii=yx[i+1].second;
        e.to=yii;
        e.cost=y;
        G[yi].push_back(e);
        e.to=yii;
        G[yii].push_back(e);
    }
    ll ans = Kruskal(N);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 35948
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
using namespace std;

int main(void)
{
    int a,b,x;
    cin >> a >> b >> x;
    if(a <= x && a + b >= x){cout << "YES" << endl;}
    else{cout << "NO" << endl;}
    return 0;
}

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

cnt = 0
while True:
    flag = False
    for i in range(N):
      if A[i]%2 != 0:
          flag = True
    if flag:
      break
    else:
      A = list(map(lambda x: x/2, A))
      cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define TASK "task"

using namespace std;

void rwFile() {
    freopen(TASK ".in", "r", stdin);
    freopen(TASK ".out", "w", stdout);
}

void solveA() {
    int arr[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k; cin >> k;
    cout << arr[k - 1];
}

void solveB() {
    long long h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1;
        return;
    }
    long long res = 0;
    if (h % 2 == 0 || w % 2 == 0) res = 1LL * h * w / 2;
    else res = (1LL * h * w + 1) / 2;
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    solveB();
}


Measured memory_bytes: 256
#include <cstdio>

#define INFONUM 4
#define HOUSENUM 4
#define FLOORNUM 3
#define ROOMNUM 10

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

	int info[n][INFONUM];
	int buff[HOUSENUM][FLOORNUM][ROOMNUM];

	/*CLEAR ARRAY "buff"*/
	for(int j = 0; j < HOUSENUM; j++){
		for(int k = 0; k < FLOORNUM; k++){
			for(int l = 0; l < ROOMNUM; l++)
				buff[j][k][l] = 0;
		}
	}	

	for(int i = 0; i < n; i++){
		for(int j = 0; j < INFONUM; j++){
			scanf("%d", &info[i][j]);
		}
	}

	for(int i = 0; i < n; i++){

		for(int j = 0; j < HOUSENUM; j++){
			for(int k = 0; k < FLOORNUM; k++){
				for(int l = 0; l < ROOMNUM; l++){

					if(j == info[i][0] - 1 && k == info[i][1] - 1 && l == info[i][2] - 1)
						buff[j][k][l] += info[i][3];
				}
			}
		}
	}

	for(int i = 0; i < HOUSENUM; i++){

		for(int j = 0; j < FLOORNUM; j++){
			for(int k = 0; k < ROOMNUM; k++){
				printf(" %d", buff[i][j][k]);
			}
			printf("\n");
		}

		if(i != HOUSENUM - 1){
			for(int j = 0; j < 20; j++)
				printf("#");
			printf("\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;

int par[N];
bool vis[N];
int val[N];
priority_queue<int, vector<int>, greater<int>> nodes[N];
void init(int n)
{
	for (int i = 0; i <= n; ++i)
		par[i] = i;
}

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

void merge(int a, int b)
{
	if (getpar(a) == getpar(b))
		return;
	par[par[a]] = par[b];
}

int main()
{
	//freopen("in.txt", "rt", stdin);
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 0; i < n; ++i)
		scanf("%d", val + i);
	init(n + 1);
	int x, y;
	for (int i = 0; i < m; ++i)
	{
		scanf("%d %d", &x, &y);
		merge(x, y);
	}

	for (int i = 0; i < n; ++i)
	{
		nodes[getpar(i)].push(val[i]);
		//printf("%d %d\n", i, getpar(i));
	}
	long long ans = 0;
	priority_queue<int, vector<int>, greater<int>> pq;
	vector<pair<int, int>> cc;
	for (int i = 0; i < n; ++i)
	{
		if (nodes[i].size())
			cc.push_back(make_pair(nodes[i].size(), i));
	}
	sort(cc.begin(), cc.end());
	int i = cc.back().second;
	while (nodes[i].size())
	{
		pq.push(nodes[i].top());
		nodes[i].pop();
	}
	cc.pop_back();
	while (cc.size())
	{
		i = cc.back().second;
		cc.pop_back();
		if (nodes[i].size() == 0)
			continue;
		if (pq.size() == 0)
		{
			puts("Impossible");
			return 0;
		}
		ans += (pq.top() + nodes[i].top());
		pq.pop();
		nodes[i].pop();
		while (nodes[i].size())
		{
			pq.push(nodes[i].top());
			nodes[i].pop();
		}
	}
	printf("%lld\n", ans);
	return 0;
}


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

using namespace std;

int main()
{
    int k;
    string s;
    cin>>k>>s;
    if(s.length()<=k){
        cout<<s<<endl;
    }
    if(s.length()>k){
        cout<<s.substr(0,k)+"..."<<endl;
    }
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#define ll long long
using namespace std;
int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> pr, pg, pb;
	int hashb[n] = {0};
	for(int i = 0; i < n; i++){
		if(s[i] == 'R') pr.push_back(i);
		if(s[i] == 'G') pg.push_back(i);
		if(s[i] == 'B') {
			pb.push_back(i);
			hashb[i] = 1;
		}
	}
	ll cnt = 0;
	for(auto i : pr){
		for(auto j : pg){
			int diff = abs(j - i);
			if((int)max(i, j) + diff < n){
				if(hashb[(int)max(i, j) + diff]) cnt++;
			}
			if((int)min(i, j) - diff >= 0){
				if(hashb[(int)min(i, j) - diff]) cnt++;
			}
			if(diff % 2 == 0){
				if(hashb[ (int)min(i, j) + (diff / 2) ]) cnt++;
			}
			
		}
	}
	// cout << cnt;
	ll tot = (int)pr.size() * (int)pg.size();
	tot *= (int)pb.size();
	
	cout << tot - cnt;
}

Measured memory_bytes: 3656
# -*- coding: utf-8 -*-
# input
d, g = map(int, input().split())
p = []
c = []
for i in range(d):
    p_sub, c_sub = map(int, input().split())
    p.append(p_sub)
    c.append(c_sub)
# calc
select_bin = []
for i in range(2 ** d):
    select_bin.append(format(i, "0" + str(d) + "b"))
complete_score = []
for i in range(d):
    complete_score.append(100 * (i + 1) * p[i] + c[i])
ans = 0
for i in range(d):
    ans += p[i]
for i in range(2 ** d):
    ans_sub = 0
    sum_score = 0
    for j in range(d):
        if select_bin[i][j] == "1":
            ans_sub += p[j]
            sum_score += complete_score[j]
        else:
            not_complete_idx = j
    ans_sub_sub = ans_sub
    sum_score_sub = sum_score
    for j in range(p[not_complete_idx]):
        ans_sub = ans_sub_sub + j
        sum_score = sum_score_sub + 100 * (not_complete_idx + 1) * j
        if sum_score >= g:
            if ans_sub < ans:
                ans = ans_sub
            break
# output
print(ans)

Measured memory_bytes: 3064
b[5<<17],S[2<<17],q;char*p=S;main(t){for(scanf("%*d%s%*d ",S);*p;)b[++q]=1<<*p++-97;for(;~scanf(~getchar()&1?t=0,"%d%d ":"%d%s ",&q,S);)if(t)b[q]=1<<*S-97;else{for(int i=q;i<=*S;)t|=b[i++];printf("%d ",__builtin_popcount(t));}}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<ll> points(M);
    for(int i = 0; i < M; i++)
    {
        cin >> points.at(i);
    }
    sort(points.begin(), points.end());
    vector<ll> distances(M - 1);
    for(int i = 0; i < M - 1; i++)
    {
        distances.at(i) = points.at(i + 1) - points.at(i);
    }
    sort(distances.begin(), distances.end());
    int needMoveDistance = max((ll)0, (M - 1) - (N - 1));
    ll answer = 0;
    for(int i = 0; i < needMoveDistance; i++)
    {
        answer += distances.at(i);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 1792
"use strict";

main(require("fs").readFileSync("/dev/stdin", "utf8"));

function main(input) {
  const [
    [n],
    ...infos
  ] = input.trim().split("\n").map(e => e.split(" ").map(Number));

  const last = infos.reduce((p, c) => p[0] - c[0] > 0 ? p : c, [0, 0]);
  const ans = last[0] + last[1];
  console.log(ans);
}

Measured memory_bytes: 51968
//============================================================================
// My word     : hakuna matata
// My wisdom   : وتحسب انك جرم صغير وفيك انطوى العالم الأكبر
//============================================================================
#include <bits/stdc++.h>
using namespace std;
void file()
{

    freopen("divisors.in", "r", stdin);
    //  freopen("out.txt", "w", stdout);

}
#define Star ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define mem(x,y)    memset(x,y,sizeof(x))
typedef long long ll;
const int maxsize=2e5+5,oo=0X3f3f3f3f;
int  n,c,ans,tot,arr[maxsize];





int main()
{
    Star;
    cin>>n>>c;
    while(n>0)
    {
        n-=c;
        tot++;

    }
    cout<<tot<<endl;
    














    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	int x=(a+d-1)/d;
	int y=(c+b-1)/b;
	if(x>=y)printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		long k = in.nextLong();
		if(k==1) System.out.println(s.charAt(0));
		else {
			int idx = 0;
			while(s.charAt(idx)=='1' && idx<k-1) idx++;
			System.out.println(s.charAt(idx));
		}
		in.close();
	}

}

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

struct edge {
  int to, cost;
};
typedef pair<int, int> P;

vector<edge> G1[114514], G2[114514];
long long d1[114514], d2[114514];
int n, m, s, t;

void dijkstra1(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d1, d1 + n, 100100100100100100);
  d1[s] = 0;
  que.push(P(0, s));
  
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d1[v] < p.first) continue;
    for (int i = 0; i < G1[v].size(); i++) {
      edge e = G1[v][i];
      if (d1[e.to] > d1[v] + e.cost) {
        d1[e.to] = d1[v] + e.cost;
        que.push(P(d1[e.to], e.to));
      }
    }
  }
}


void dijkstra2(int s) {
  priority_queue<P, vector<P>, greater<P> > que;
  fill(d2, d2 + n, 100100100100100100);
  d2[s] = 0;
  que.push(P(0, s));
  
  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d2[v] < p.first) continue;
    for (int i = 0; i < G2[v].size(); i++) {
      edge e = G2[v][i];
      if (d2[e.to] > d2[v] + e.cost) {
        d2[e.to] = d2[v] + e.cost;
        que.push(P(d2[e.to], e.to));
      }
    }
  }
}

int main(void) {
  vector<pair<long long, int> > ans;
  
  cin >> n >> m >> s >> t;
  s--; t--;
  
  for (int i = 0; i < m; i++) {
    int u, v, a, b;
    
    cin >> u >> v >> a >> b;
    u--;
    v--;
    G1[u].push_back({v, a});
    G1[v].push_back({u, a});
    G2[u].push_back({v, b});
    G2[v].push_back({u, b});
  }
  
  dijkstra1(s);
  dijkstra2(t);
  
  for (int i = 0; i < n; i++) {
    
    ans.push_back({d1[i] + d2[i], i});
  }
  
  sort(ans.begin(), ans.end());
  
  int now = 0;
  
  for (int i = 0; i < n; i++) {
    while (i > ans[now].second)
      now++;
    cout << 1000000000000000 - ans[now].first << endl;
  }
}


Measured memory_bytes: 17716
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, count_p = 0, count_q = 0;
	cin >> n;
	vector <int> p(8);
	vector <int> q(8);
	for (int i = 0; i < n; i++){
		cin >> p[i];
	}
	for (int i = 0; i < n; i++){
		cin >> q[i];
	}

	while(next_permutation(p.begin(), p.begin() + n)){
		count_p++;
	}
	while(next_permutation(q.begin(), q.begin() + n)){
		count_q++;
	}

	cout << abs(count_p - count_q) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define MIN(x,y) ((x)<(y)?(x):(y))

typedef long long int ll;

int a[2000];

int dp[2000];
ll dp2[2];

int main(){
  int n, x, i, j;
  scanf("%d%d", &n, &x);
  for(i=0;i<n;i++){
    scanf("%d", a+i);
    dp2[0] += dp[i] = a[i];
  }

  for(j=1;j<n;j++){
    int b = j&1;
    dp2[b] = (ll) j*x;
    for(i=0;i<n;i++){
      dp2[b] += dp[i] = MIN(dp[i], a[(i+n-j)%n]);
    }
    dp2[b] = MIN(dp2[b^1], dp2[b]);
  }

  printf("%lld\n", dp2[~n&1]);
  return 0;
}


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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
struct edge{int u,v,w;}vs[N<<1];
int n,q,tA[N],tB[N],ee,st[N],cnt,F1[N],F2[N],fa[N],m;
inline bool cmp(const edge &a,const edge &b){return a.w<b.w;/*not a.w<=b.w or you'll get a TLE result*/} //stdsort's compelxity depends on its operator ?
inline int getfa(int x){return fa[x]==x? x:fa[x]=getfa(fa[x]);}
int main()
{
	// freopen("read.in","r",stdin);
	n=read(); m=q=read();
	memset(tA,0x3f,sizeof tA);
	memset(F1,0x3f,sizeof F1);
	while(q--)
	{
		int u=read(), v=read(), w=read();
		vs[++cnt]=(edge){u+1,v+1,w};
		tA[u]=min(tA[u],w+1); tA[v]=min(tA[v],w+2);
	}
	for(int i=0;i<n;i++) F1[i]=min(F1[((i-1)+n)%n]+2,tA[i]);
	for(int i=0;i<n;i++) F1[i]=min(F1[((i-1)+n)%n]+2,tA[i]);
	for(int i=0;i<n;i++) vs[++cnt]=(edge){i+1,(i+1)%n+1,F1[i]};
	// cout << cnt << endl;
	sort(vs+1,vs+1+cnt,cmp);
	// assert(0); 
	for(int i=1;i<=n;i++) fa[i]=i;
	long long Ans=0;
	for(int i=1;i<=cnt;i++)
	{
		int f1=getfa(vs[i].u),f2=getfa(vs[i].v);
		if(f1!=f2) 
		{
			Ans+=vs[i].w;
			fa[f1]=f2; n--;
		}
		if(n==1) break;
	}
	cout << Ans << endl;  return 0;
}

Measured memory_bytes: 11392
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;

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

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

const long long INF = 1LL << 60;


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

	vector<int> h;
	vector<long long> dp;

	int tmp;
	REP(i, N) {
		cin >> tmp;
		h.push_back(tmp);
	}

	REP(i, N) dp.push_back(INF);

	dp[0] = 0;

	FOR(i,1,N) {
		chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[N - 1] << endl;


	return 0;
}

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

public class Main {
    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = in.nextInt();
            int M = in.nextInt();
            int likeAll = ((1 << M) - 1);
            for (int i = 0; i < N; i++) {
                int K = in.nextInt();
                int like = 0;
                for (int j = 0; j < K; j++) {
                    int A = in.nextInt() - 1;
                    like |= (1 << A);
                }
                likeAll &= like;
            }

            System.out.println(Integer.bitCount(likeAll));
        }
    }
}


Measured memory_bytes: 21972
import scala.io.StdIn.readLine
import scala.math.{max,min}

object Main extends App {

  var (n,x) = (0,0)
  while({val Array(n2,x2) = readLine.split(" ").map(_.toInt);n=n2;x=x2;(n,x)} != (0,0) ) {
    println(
      ( 1 until min(n-1,x/3) ).foldLeft(0) { (sum,i) =>
        sum + (max(i+1,x-i-n) until min(n,(x-i+1)/2)).length
      }
    )
  }
}

Measured memory_bytes: 44208
N=int(raw_input())
AN=map(int, raw_input().split())

BN=[0 for i in xrange(N)]
for i in AN:
    BN[i-1] += 1
BN.sort()

LN = [0 for i in xrange(N)]
s = 0
j = 0
try:
    for X in xrange(1, N+1):
        while j<N and  BN[j] < X:
            s += BN[j]
            j += 1
        LN[X-1] = (s + X*(N - j)) / X
except IndexError:
    pass

KN = [0 for i in xrange(N)]
for i in xrange(len(LN)):
    KN[LN[i]-1] = i+1

for i in xrange(len(KN)-2, -1, -1):
    if KN[i] == 0:
        KN[i] = KN[i+1]

for i in KN:
    print (str(i))

Measured memory_bytes: 28664
#include <bits/stdc++.h>
using namespace std;
using lli  = long long;
using ulli = unsigned long long;

int main() {
    // sort : R < W
    int N;
    cin >> N;
    string c;
    cin >> c;

    int w = 0;
    for (auto ci : c)
        if (ci == 'W') ++w;
    int r = N - w;

    if (w == 0 || r == 0) {
        cout << "0\n";
        return 0;
    }

    int ans = 0;
    for (int i = 0ul; i < r; ++i) {
        if (c.at(i) == 'W') {
            ans++;
        }
    }

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


Measured memory_bytes: 3736
#include <iostream>

using namespace std;

int main() {
    int N;
    cin >> N;
    auto      result = "No";
    for (auto i      = std::size_t(1); i < 10; ++i) {
        if (N % i == 0) {
            const auto A = N / i;
            if (1 <= A && A <= 9) result = "Yes";
        }
    }
    cout << result << endl;

    return 0;
}


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

bool prime(int n) {
  bool pr = true;
  for (int i = 2; i < sqrt(n) + 1; i++) {
    if (n % i == 0) pr = false;
  }
  if (pr || n == 2) return true;
  else return false;
}


int main() {
  int X;
  cin >> X;
  int ans = 0;
  for (int i = X; i < 1000000; i++) {
    if (prime(i)) {
      ans = i;
      
      break;
    }
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;


#define PI 3.14159265
#define int long long




main(){

	int n; cin >> n;


	vector <int> p(n);

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

	int ans = 0;

	for(int i = 1; i < n - 1; i++){
		if(p[i] > p[i - 1] and p[i] < p[i + 1]){
			ans++;
		}
		if(p[i] < p[i - 1] and p[i] > p[i + 1]){
			ans++;
		}
	}

	cout << ans << endl;

	
	
	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
#AGC024A
import sys
#import collections

#n= int(input())
#s= input()
tmp = input().split()
a,b,c,k = list(map(lambda a: int(a), tmp))

if(k%2==1):
	print(b-a)
else:
	print(a-b)


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

using namespace std;

#define ll long long int
typedef pair<int,int>PII;
int arr[105];
int main() {
      int n,m;
      cin>>n>>m;
      for (int i = 0; i < m; i++) {
            int a,b;
            cin>>a>>b;
            arr[a]++;
            arr[b]++;
      }
      for (int i = 1; i <= n; i++) {
            cout<<arr[i]<<endl;
      }
      return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
//BSMRSTU,Gopalganj
#include<bits/stdc++.h>
using namespace std;int tc = 1;
#define happy ios::sync_with_stdio(false);
#define coding  cin.tie(0);
#define F first
#define S second
#define mp make_pair
#define ll long long
#define Pi atan(1)*4
#define pb  push_back
#define vpr vector<pr> 
#define pr pair<int, int> 
#define vi std::vector<int>
#define vll std::vector<ll>
#define YES printf("YES\n");
#define NO printf("NO\n");
#define Yes printf("Yes\n");
#define No printf("No\n");
#define all(n) n.begin(),n.end()
#define point(x) setprecision(x)
#define Test printf("Case %d: ",tc++);
#define Unique(c) (c).resize(unique(all(c))-(c).begin())
#define vout(v) for (auto z: v) cout << z << " "; cout << endl;

#define error(args...) {vector<string>_v=split(#args,',');err(_v.begin(),args);cout<<endl;}
vector<string> split(const string &s, char c) {vector<string>v; stringstream ss(s); string x;
while (getline(ss, x, c))v.emplace_back(x); return move(v);} void err(vector<string>::iterator it) {}
template<typename T, typename... Args>void err(vector<string>::iterator it, T a, Args...args) {
cout << it->substr((*it)[0] == ' ', it->length()) << " = " << a << " "; err(++it, args...);}

const int M = 1e9 + 7;
const ll  Inf = (ll)2e18 + 5;
const int N   = 2e5 + 5;
ll vis[N],res[N];

int solve() 
{
	//happy coding


	ll n;
	cin>>n;
	ll a[n],b[n];

	for(ll i=0;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<n;i++){
		cin>>b[i];
	}
	ll sum = 0LL;
	for(ll i=1;i<=n;i++){
		ll x = min(b[i-1],a[i-1]);
		ll y  = min(a[i],b[i-1] - x);
		a[i] = max(0LL,a[i] - y);
		//error(x,y,a[i]);
		sum +=(x+y);
	}

	cout<<sum<<endl;
	return 0;
}
int main(){
	int test = 1;
  	//scanf("%d", &test);
  	while (test--)solve();return 0;
}

Measured memory_bytes: 1792
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <iostream> 
#include <iomanip>  
#include <string>
#include <sstream>  
#include <algorithm>
#include <numeric>
#include <complex>
#include <functional>
#include <cstring>
#include <cmath>
#include <cassert>


#define INF              (int)1000000007
#define EPS              1e-9
#define pb               push_back
#define mp               make_pair
#define all(c)           c.begin(), c.end()
#define forall(i,a,b)    for(int i=a;i<(b);++i)
#define trav(a,x)        for(auto & a: x)
#define in(a,b)          ((b).find(a) != (b).end())
#define sz(c)            (int)(c).size()
#define input(a)         for(auto & x : a) cin >> x;

using namespace std;

typedef vector<int>      vi;
typedef pair<int,int>    ii;
typedef vector<vi>       vvi;
typedef vector<ii>       vii;
typedef long long        ll;

#ifdef DEBUG
#define trace(...)       __f(#__VA_ARGS__, __VA_ARGS__)
#define debug(args...)   {dbg,args; clog<<endl;}
#define print_( a )      for( auto & x : a ) clog << x << ' '; clog << '\n';
#define printPair_( a )  for( auto & x : a ) clog << '(' << x.first << ',' << x.second << ')' << ' '; clog << '\n';
#else
#define trace(...)       
#define debug(args...)            
#define print_( a )               
#define printPair_( a )           
#endif

struct debugger {
  template<typename T> debugger& operator , (const T& x) {    
    clog << x << " ";    return *this;    
  }
}dbg;

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " | ";
    __f(comma + 1, args...);
}

auto ____ =[]() { std::ios::sync_with_stdio(0); cin.tie(0); return nullptr; }();

int main( int argc, char * argv[] ){
  int n; cin >> n; 
  vvi mtx(n, vi(n));
  for(auto & v : mtx) input(v);

  vi dp(1<<n, 0);
  dp[0] = 1;
  auto mod_add = [](int & x, int y){
    x += y;
    x %= INF;
  };
  for(int mask = 0; mask < (1<<n)-1; ++mask){
    int a = __builtin_popcount(mask);
    forall(b,0,n){
      if( mtx[a][b] and !(mask & (1<<b)) ){
        int m2 = mask | (1<<b);
        mod_add(dp[m2], dp[mask]);
      }
    }
  }
  cout << dp.back() << endl;
  return 0;
}


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

#define int long long
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; }

int tmp[1010];

signed main(){
	int n;
	cin >> n;
	string s;
	cin >> s;

	int r[5010] = {};
	int g[5010] = {}; 
	int b[5010] = {};

	for(int i = 0;i < n;i++){
		if(s[i] == 'R') r[i+1]++;
		if(s[i] == 'G') g[i+1]++;
		if(s[i] == 'B') b[i+1]++;
		r[i+1] += r[i];
		g[i+1] += g[i];
		b[i+1] += b[i];
	}

	int ans = 0;
	for(int i = 0;i < n;i++){
		for(int j = i+1;j < n;j++){
			if(s[i] != s[j]){
				string tmp;
				tmp.push_back(s[i]);
				tmp.push_back(s[j]);
				if(tmp.find('R') == string::npos){
					ans += r[n]-r[j+1];
					int tt = j + (j-i);
					if(tt < n && s[tt] == 'R') ans--;
				}
				if(tmp.find('G') == string::npos){
					ans += g[n]-g[j+1];
					int tt = j + (j-i);
					if(tt < n && s[tt] == 'G') ans--;
				}
				if(tmp.find('B') == string::npos){
					ans += b[n]-b[j+1];
					int tt = j + (j-i);
					if(tt < n && s[tt] == 'B') ans--;
				}
			}
		}
	}
	
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3760
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

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

const int INF = 10000000;
using namespace std;
typedef long long  ll;
const int MAX = 10000;
/** Problem0150 : Twin Prime **/
int main()
{
	int n;
	bool prime[MAX];
	int before=0, ans1=0, ans2, max;
	
	for (int i=0; i<MAX; i++)
		prime[i] = true;
	
	prime[0] = false; prime[1] = false;
	
	for (int i=2; i<MAX; i++) {
		if (prime[i]) {
			for (int j=2; i*j<MAX; j++) {
				prime[i*j] = false;
			}
		}
	}
	
	while (cin>>n, n!=0) {
		before = 1; max=0;
		REP(i, 3, n+1) {
			if (prime[i]) {
				if (i-before==2) {
					if (i>max) {
						max = i;
						ans1 = before;
						ans2 = i;
					}
				}
				before = i;
			}
		}
		cout << ans1 << " " << ans2 << endl;
	}
	return 0;
}

Measured memory_bytes: 1168
<?php
  
	list($num, $road) = explode(' ', trim(fgets(STDIN)));
	$high = explode(' ', trim(fgets(STDIN)));
	$result = $high;
 
	for ($i = 1; $i <= $road; $i++) {
	  list($from, $to) = explode(' ', trim(fgets(STDIN)));
      $from--;
      $to--;
      if ($high[$from] === $high[$to]) {
        unset($result[$from]);
        unset($result[$to]);     
      } elseif ($high[$from] < $high[$to]) {
        unset($result[$from]);
      } else {
        unset($result[$to]);        
      }
    }
echo count($result);

Measured memory_bytes: 27276
#include <stdio.h>

int NumberOfEvenPairs(int num) {
	int qtdPairs = 0;

	if ( num >= 2 ) {
		// Fórmula para contar subconjuntos: N! / (N- K)! K!
		qtdPairs = (num * (num - 1)) / 2;
	}

	return qtdPairs;
}

int main () {
	int N, M, answer = 0;

	scanf("%d %d", &N, &M);

	// Para que a soma de dois números resulte par,
	// ambos os números devem ser par OU ambos os números devem ser ímpar.

	answer = NumberOfEvenPairs(N) + NumberOfEvenPairs(M);

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

	return 0;
}


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

typedef long long ll;
using namespace std;
int main()
{
  ll n,m;
  cin>>n>>m;
  cout<<(n-1)*(m-1)<<endl;
  return 0;
}


Measured memory_bytes: 3636
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	switch s {
	case "Sunny":
		fmt.Println("Cloudy")
	case "Cloudy":
		fmt.Println("Rainy")
	case "Rainy":
		fmt.Println("Sunny")
	}
}


Measured memory_bytes: 512
class Array
    def accum
        inject([0]){|a, x| a + [a[-1] + x]}[1..-1]
    end
end

n, m = gets.split.map &:to_i
s = (1..n-1).map{ gets.to_i }
d = [0] + s.accum
k = 0
total = 0
m.times {
    a = gets.to_i
    total += (d[k + a] - d[k]).abs
    k += a
}
p total % 100000

Measured memory_bytes: 19092
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def count(hp, attack):
    return hp // attack + (0 if hp % attack == 0 else 1)

def solve(A: int, B: int, C: int, D: int):
    print( "Yes" if count(C, B) <= count(A, D) else "No")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    D = int(next(tokens))  # type: int
    solve(A, B, C, D)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9212
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    
    Scanner cin;
    
    void calc()
    {
        cin = new Scanner();
        int N, M, Q;
        N = cin.nextInt();
        M = cin.nextInt();
        Q = cin.nextInt();
        int[] L, R;
        L = new int[M];
        R = new int[M];
        for (int i = 0; i < M; i++)
        {
            L[i] = cin.nextInt();
            R[i] = cin.nextInt();
        }
        int[] p, q;
        p = new int[Q];
        q = new int[Q];
        for (int i = 0; i < Q; i++)
        {
            p[i] = cin.nextInt();
            q[i] = cin.nextInt();
        }

        int[,] sum = new int[N + 1, N + 1];
        for (int i = 0; i < M; i++)
        {
            sum[L[i], R[i]]++;
        }
        for (int i = 1; i < N + 1; i++)
        {
            for (int j = 1; j < N + 1; j++)
            {
                sum[i, j] += sum[i-1, j];
                sum[i, j] += sum[i, j-1];
                sum[i, j] -= sum[i-1, j-1];
            }
        }

        for (int i = 0; i < Q; i++)
        {
            Console.WriteLine(sum[q[i], q[i]] - sum[p[i] - 1, q[i]]);
        }


    }
}






class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

typedef long long ll;
static const int MOD=1e9+7;

int main(){
    string L;
    cin >> L;
    int N=L.size();
    ll dp[N+1][2];
    memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    for(int i=0;i<N;i++){
        int l=L[i]-'0';
        for(int j=0;j<2;j++){
            if(l==1) dp[i+1][1]+=dp[i][j]%MOD;
            else dp[i+1][j]+=dp[i][j]%MOD;

            if(!(l==0&&j==0)) dp[i+1][j]+=dp[i][j]*2%MOD;
        }
    }
    long long ans=dp[N][0]+dp[N][1];
    cout << ans%MOD << endl;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
long long int MOD = 1000000007;
using namespace std;
//g++ -std=c++14
//setprecision(10)
int main(){
	string s;	cin >> s;
	int ans = 0;
	s.erase( s.end() - 1);
	s.erase( s.end() - 1);
	while( !s.empty() ){
		string a = "", b = "";
		for(int j = 0; j < s.size() / 2; j++)
			a += s[j];
		for(int j = s.size() / 2; j < s.size(); j++)
			b += s[j];
		if(a == b){
			cout << a.size() * 2 << endl;
			break;
		}
		s.erase( s.end() - 1);
		s.erase( s.end() - 1);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin >> n;
    string s;
    cin >> s;
    s = " " + s;

    int left[n + 1], right[n + 2];
    left[0] = right[n + 1] = 0;


    for (int i = 1; i <= n; i++) {
        left[i] = left[i - 1];
        if (s[i] == '#') {
            left[i]++;
        }
    }

    for (int i = n; i >= 1; i--) {
        right[i] = right[i + 1];
        if (s[i] == '.') {
            right[i]++;
        }
    }

    int fir = count(s.begin(), s.end(), '.');
    int sec = count(s.begin(), s.end(), '#');
    int ans = min(fir, sec);
    for (int i = 1; i <= n; i++) {
        ans = min(ans, left[i] + right[i + 1]);
    }

    cout << ans;


}

Measured memory_bytes: 2128
n =  int(input())
l =  list(map(int,input().split()))
l1 = []
for i in range(n):
  for j in range(n-1-i,-1,-1):
    if l[j]==j+1:
      l1.append(l[j])
      del l[j]
      break
    else:
      continue
if len(l)==0:
  for j in l1[::-1]:
    print(j)
else:
  print(-1)

Measured memory_bytes: 3064
import collections
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N = int(input())

a = []
for i in range(N):
  s = "".join(sorted(list(input())))
  a.append(s)

c = collections.Counter(a)
r = 2
total = 0
for k in c.keys():
  n = int(c[k])
  if n != 1:
    total += cmb(n, r)

print(total)

Measured memory_bytes: 20004
// Sは2019年の実在する日付
#include <bits/stdc++.h>
using namespace std;
int main(void) {
    int y, m, d;
    char c1, c2;
    cin >> y >> c1 >> m >> c2 >> d;
    cout << (m <= 4 ? "Heisei" : "TBD") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

int main()
{
    int n; cin >> n;
    vint c(n-1), s(n-1), f(n-1);
    rep(i, n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    vint ans(n);
    ans[n-1] = 0;
    rep(i, n-1){
        int t = 0;
        FOR(j, i, n-1){
            if(s[j] > t){
                t = s[j];
            }else if(t%f[j]!=0){
                t += (f[j] - t%f[j]);
            }

            t += c[j];
            // pr(t);
        }

        ans[i] = t;
        // pr("");
    }
    rep(i, n) pr(ans[i]);
    return 0;}

Measured memory_bytes: 3636
#include <math.h>
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define EPS (1.0e-8)
#define LINF (LLONG_MAX / 2)
const int MGN = 10;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using psi = pair<string, int>;

void warshall(vvl& d, vvi& es, map<pii, ll>& cost) {
    int N = es.size();
    d = vvl(N, vl(N, LINF));
    // d[i][j] : the shortest distance from i to j

    REP(i, N) d[i][i] = 0;
    if (cost.size() > 0) {

      REP(i, N) {
          for (int t : es[i]) {
              d[i][t] = cost[pii(i, t)];
              d[t][i] = cost[pii(t, i)];
          }
      }
    } else {
      REP(i, N) {
          for (int t : es[i]) {
              d[i][t] = 1;
              d[t][i] = 1;
          }
      }
    }
    REP(k, N) {
        REP(i, N) {
            if (d[i][k] == LINF) continue;
            REP(j, N) {
                if (d[k][j] == LINF) continue;

                if (d[i][j] > d[i][k] + d[k][j]) {
                    d[i][j] = d[i][k] + d[k][j];
                }
            }
        }
    }
}

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

  int N, M, L; cin >> N >> M >> L;
  if (M == 0) {
    int Q; cin >> Q;
    REP(i,Q) cout << -1 << endl;
    return 0;
  }
  vi A(M), B(M), C(M); 
  REP(i,M) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--; B[i]--;
  }
  int Q; cin >> Q;
  vi S(Q), T(Q); 
  REP(i,Q) {
    cin >> S[i] >> T[i];
    S[i]--; T[i]--;
  }

  vvi es(N);
  map<pii, ll> cost;
  REP(i,M) {
    if (C[i] > L) continue;
    es[A[i]].push_back(B[i]);
    es[B[i]].push_back(A[i]);
    cost[pii(A[i],B[i])] = C[i];
    cost[pii(B[i],A[i])] = C[i];
  }

  vvl dist;
  warshall(dist, es, cost);
  
  vvi es2 = es;
  REP(s,N-1) {
    FOR(t,s+1,N) {
      if (dist[s][t] > L) continue;
      es2[s].push_back(t);
      es2[t].push_back(s);
    }
  }

  vvl dist2;
  map<pii, ll> cost2;
  warshall(dist2, es2, cost2);

  REP(i,Q) {
    ll d = dist2[S[i]][T[i]];
    ll ans = d==LINF ? -1 : d - 1;
    cout << ans << endl;
  }

  return 0;
}


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

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;

typedef long long ll;
int main() {
	ll n;
	cin >> n;
	string s = "";
	while (n > 0) {
		n--;
		s.push_back('a' + (n%26));
		n /= 26;
	}
	reverse(s.begin(),s.end());
	cout << s << '\n';

	return 0;
}


Measured memory_bytes: 3636