akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include<vector>
class Card {
	public:
	//private????????????
	int check;
	char DesignCard;
	int ValueCard;
	//public
	void SetCheck(int InputValueCard, char InputDesignCard, int num);
	int ReturnValue();
};
void Card::SetCheck(int InputValueCard, char InputDesignCard, int num) {
	check = num;
	ValueCard = InputValueCard;
	DesignCard = InputDesignCard;
}
int Card::ReturnValue() {
	return ValueCard;
}
void BubbleSort(std::vector<Card> &InputCard) {
	bool flag = true;
	while (flag) {
		flag = false;
		for (unsigned int i = 0; i < InputCard.size() - 1; ++i) {
			if (InputCard[i].ReturnValue() > InputCard[i+1].ReturnValue()) {
				std::swap(InputCard[i].check, InputCard[i + 1].check);
				std::swap(InputCard[i].DesignCard, InputCard[i + 1].DesignCard);
				std::swap(InputCard[i].ValueCard, InputCard[i + 1].ValueCard);
				flag = true;
			}
		}
	}
}
void SelectSort(std::vector<Card> &InputCard) {
	for (unsigned int i = 0; i < InputCard.size(); ++i) {
		int minj = i;
		for (unsigned int j = i; j < InputCard.size(); ++j) {
			if (InputCard[minj].ReturnValue() > InputCard[j].ReturnValue()) {
				minj = j;
			}
		}
		std::swap(InputCard[i].check, InputCard[minj].check);
		std::swap(InputCard[i].DesignCard, InputCard[minj].DesignCard);
		std::swap(InputCard[i].ValueCard, InputCard[minj].ValueCard);
	}
}
bool stable(std::vector<Card> InputCard) {
	for (unsigned int i = 0; i < InputCard.size() - 1; ++i) {
		if (InputCard[i].ReturnValue() == InputCard[i + 1].ReturnValue()) {
			if (InputCard[i].check > InputCard[i + 1].check) {
				return false;
			}
		}
	}
	return true;
}
void print_stable(bool stable) {
	if (stable == true) {
		std::cout << "Stable" << std::endl;
	}
	else {
		std::cout << "Not stable" << std::endl;
	}
}
void print_array(std::vector<Card> InputCard) {
	for (unsigned int i = 0; i < InputCard.size(); ++i) {
		std::cout << InputCard[i].DesignCard << InputCard[i].ValueCard;
		if (i < InputCard.size() - 1) {
			std::cout << " ";
		}
	}
	std::cout << std::endl;
}
int main(void) {
	int N;
	std::cin >> N;
	std::vector<int>InputValueCard(N);
	std::vector<char>InputDesignCard(N);
	for (int i = 0; i < N; ++i) {
		std::cin >> InputDesignCard[i] >> InputValueCard[i];
	}
		std::vector<Card> BubbleCARD(N);
	std::vector<Card> SelectCARD(N);
	for (int i = 0; i < N; ++i) {
		BubbleCARD[i].SetCheck(InputValueCard[i], InputDesignCard[i], i);
		SelectCARD[i].SetCheck(InputValueCard[i], InputDesignCard[i], i);
	}
	BubbleSort(BubbleCARD);
	print_array(BubbleCARD);
	print_stable(stable(BubbleCARD));
	SelectSort(SelectCARD);
	print_array(SelectCARD);
	print_stable(stable(SelectCARD));
//	system("pause");
	return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define sim template<class n
sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
sim> auto operator << (ostream &p, n y) ->
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define I(x) #x " =", (x), " "
#define A(a, i) #a "[" #i " =", i, "] =", a[i], " "


int main()
  {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  __int128 res = 1;
  LD resd = 0;
  REP(i, n)
    {
    LL a;
    cin >> a;
    if(a == 0)
      {
      cout << 0 << endl;
      return 0;
      }
    res *= a;
    if(res > 1e20)res=1e20;
    }
  LL prog = 1;
  REP(i, 18)prog *= 10;


  if(res > prog)
    {
    cout << -1 << endl;
    }
  else
    {
    cout << (long long)res << endl;
    }
  }


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s, t;
    cin >> s >> t;
    string g = s;
    for(int i = 0; i < 100; i++)
    {
        if(t.compare(g) == 0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        char end = g[0];
        for(int j = 0; j < s.size()-1; j++)
        {
            g[j] = g[j+1];
        }
        g[g.size()-1] = end;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var n = next(), k = next();
  var p = nexts(n);
  p.sort((a,b)=>a-b);
  var ans = 0;
  for(var i = 0; i < k; i++)ans += p[i];
  return ans;
}

Measured memory_bytes: 29708
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL unsigned long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head

int a[3];
int main() {
	for (int i = 0; i < 3; i++) scanf("%d", &a[i]);
	sort(a, a+3);
	printf("%d\n", (a[2]*10+a[1]) + a[0]);
	return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;

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

  vector<P> ans;
  if(n%2){
    for(int i=1;i<n;i++){
	 for(int j=i+1;j<n;j++){
	   if(i+j==n)continue;
	   ans.pb(P(i,j));
	 }
    }
    for(int i=1;i<n;i++)ans.pb(P(n,i));
  }else{
    for(int i=1;i<=n;i++){
	 for(int j=i+1;j<=n;j++){
	   if(i+j==n+1)continue;
	   ans.pb(P(i,j));
	 }
    }
  }
  cout<<ans.size()<<endl;
  for(int i=0;i<ans.size();i++){
    cout<<ans[i].fi<<" "<<ans[i].se<<endl;
  }
  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
 string s;
 cin>>s;
 int a[10];
 a[0]=s[0]-'0';
 a[1]=s[1]-'0';
 a[2]=s[2]-'0';
 a[3]=s[3]-'0';
 if(a[0]+a[1]+a[2]+a[3]==7)
 {
 	cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"+"<<a[3];
 }
 else if(a[0]+a[1]+a[2]-a[3]==7)
 {
 	cout<<a[0]<<"+"<<a[1]<<"+"<<a[2]<<"-"<<a[3];
 }
 else if(a[0]+a[1]-a[2]+a[3]==7)
 {
 	cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"+"<<a[3];
 }
 else if(a[0]+a[1]-a[2]-a[3]==7)
 {
 	cout<<a[0]<<"+"<<a[1]<<"-"<<a[2]<<"-"<<a[3];
 }
 else if(a[0]-a[1]+a[2]+a[3]==7)
 {
 	cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"+"<<a[3];
 }
 else if(a[0]-a[1]+a[2]-a[3]==7)
 {
 	cout<<a[0]<<"-"<<a[1]<<"+"<<a[2]<<"-"<<a[3];
 }
 else if(a[0]-a[1]-a[2]+a[3]==7)
 {
 	cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"+"<<a[3];
 }
 else if(a[0]-a[1]-a[2]-a[3]==7)
 {
 	cout<<a[0]<<"-"<<a[1]<<"-"<<a[2]<<"-"<<a[3];
 }
 cout<<"=7"<<endl;
return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

string s;
ll n,m;

int main () {
  cin >> s;
  if(s == "Rainy") s = "Sunny";
  else if(s == "Cloudy") s = "Rainy";
  else s = "Cloudy";
  cout << s << endl;
}


Measured memory_bytes: 256
S = input()
N = len(S)
X = set(['A', 'G', 'C', 'T'])

ans = 0
for i in range(N + 1):
    for j in range(i, N + 1):
        substr = S[i:j]
        if X.issuperset(set(list(substr))):
            ans = max(ans, j - i)

print(ans)


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main()
{
    int S;
    cin >> S;
    
    int min = S / 60;
    
    int h = min / 60;
    int m = min % 60;
    int s = S % 60;
    
    cout << h << ":" << m << ":" << s << endl;
}

Measured memory_bytes: 3088
N, K = map(int, input().split())
A = list()
B = list()
for i in range(K):
  d = int(input())
  A = A + list(map(int, input().split()))

for j in range(1, N+1):
  if j in A:
    pass
  else:
    B.append(j)
print(len(B))

Measured memory_bytes: 9188
#include <iostream>
#include <string>
using namespace std;
void f(int a,int b,int k)
{
    for(int i=a;i<a+k;i++)
        cout<<i<<endl;
    for(int i=b-k+1;i<=b;i++)
        cout<<i<<endl;
}
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    if(k>(b-a)/2)
        for(int i=a; i<=b; i++)
            cout<<i<<endl;
    else if(k==(b-a))
        if((b-a)%2==0)
        {
            for(int i=a; i<=b; i++)
                cout<<i<<endl;
        }
        else
            f(a,b,k);
    else
        f(a,b,k);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int co=0,flag=0;
    string str;
    while(cin>>str){
        for(int i=0;i<3&&flag!=1;i++){
            for(int j=0;j<3;j++){
                if(str[i*3+j]==str[i*3])co++;
            }
            if(co==3&&str[i*3]!='s'){
                    cout<<str[i*3]<<endl;
                    flag=1;
            }
            co=0;
        }
        if(flag==0){
            for(int i=0;i<3&&flag!=1;i++){
                for(int j=0;j<3;j++){
                if(str[i+j*3]==str[i])co++;
                }
                if(co==3&&str[i]!='s'){
                        cout<<str[i]<<endl;
                        flag=1;
                }
                co=0;
            }
            if(flag==0){
                for(int i=0;i<3;i++)if(str[i*4]==str[0])co++;
                if(co==3&&str[0]!='s')cout<<str[0]<<endl;
                else {
                    co=0;
                    for(int i=0;i<3;i++)if(str[i*2+2]==str[2])co++;
                    if(co==3&&str[2]!='s')cout<<str[2]<<endl;
                    else cout<<"d"<<endl;
                }
            }
        }
        co=0;flag=0;
    }
}

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

ll n;
ll qpow(ll b, ll x){
	ll ans = 1LL;
	while(x){
		if(x & 1) ans = (ans * b) % Mod;
		b = (b * b) % Mod;
		x >>= 1;
	}
	return ans;
}

int main(){
	cin >> n;
	cout << (qpow(10, n) - qpow(9, n) - qpow(9, n) + qpow(8, n) + Mod + Mod) % Mod;
	return 0;
} 

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <array>
#include <cmath>
#include <string>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {
  int N; std::cin >> N;

  struct res {
    std::string name;
    int p;
    int ind;
  };
  std::vector<res> L(N);
  for(int i=0; i<N; i++){
    std::cin >> L[i].name >> L[i].p;
    L[i].ind = i+1;
  }

  std::sort(L.begin(), L.end(), [](res &a, res &b) { if ( a.name != b.name ) return a.name < b.name; else return a.p > b.p;} );

  for(int i=0; i<N; i++) std::cout << L[i].ind << std::endl;

  return 0;
}

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

int main()
{
	std::set<long> s1, s;
	long n, m;

	cin >> n;

	for (long i = 0; i < n; i++) {
		long t;
		cin >> t;
		s1.insert(t);
	}

	cin >> m;

	for (long i = 0; i < m; i++) {
		long t;
		cin >> t;
		if (s1.find(t) != s1.end())
			s.insert(t);
	}

	for (std::set<long>::iterator itr = s.begin(); itr != s.end(); itr++)
		cout << *itr << endl;

	return 0;
}


Measured memory_bytes: 14364
scores =[]
while True:
    score = list(map(int,input().split()))
    if all([i == -1 for i in score]):
        break
    scores.append(score)

def judge(score):
    if score[0] == -1 or score[1] == -1:
        print('F')
    elif score[0] + score[1] >= 80:
        print('A')
    elif score[0] + score[1] >= 65:
        print('B')
    elif score[0] + score[1] >= 50:
        print('C')
    elif score[0] + score[1] >= 30:
        if score[2] >= 50:
            print('C')
        else:
            print('D')
    else:
        print('F')

for i in scores:
    judge(i)


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

class MainClass
{
	public static void Main (string[] args)
	{
		string str;
		List<int> digit = new List<int> ();
		while (!string.IsNullOrEmpty(str = Console.ReadLine())) {
			string[] input = str.Split(' ');
			int a = int.Parse(input[0]);
			int b = int.Parse(input[1]);
			int c = a + b;
			digit.Add ((int)Math.Floor(Math.Log10(c)+1));
		}
	
	        for (int i = 0; i < digit.Count; i++) {
			Console.WriteLine (digit[i]);
		}
		Console.Read ();
	}
}

Measured memory_bytes: 9384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>

constexpr int INFI = 1145141919;

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

    std::string S;
    std::cin >> S;

    //AGCT以外で切って長さ判定すればできる気がする
    std::string s = "";
    int ans=0;
    for(int i=0; i<S.size(); i++){
        if(S[i]=='A' || S[i]=='G' || S[i]=='C' || S[i]=='T'){
            s = s + S[i];
        }else{
            ans = std::max(ans, (int)s.size());
            s = "";
        }
    }
    ans = std::max(ans, (int)s.size());

    std::cout << ans;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
void push(int);
int pop(void);
int top,S[1000];

int main(void){
  int a,b;
  char s[100];

  top=0;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      a=pop();
      b=pop();
      push(a+b);
    }
    else if(s[0]=='-'){
      a=pop();
      b=pop();
      push(b-a);
    }
    else if(s[0]=='*'){
      a=pop();
      b=pop();
      push(a*b);
    }
    else {
      push(atoi(s));
    }
  }
  printf("%d\n",pop());
  return 0;
}
void push(int x){
  S[++top]=x;
}
int pop(void){
  top--;
  return S[top+1];
}


Measured memory_bytes: 2088
import std.stdio, std.algorithm, std.array, std.range, std.string, std.conv, std.uni;

void main() {
    long n, k;
    readf("%d %d\n", &n, &k);
    k--;
    auto s = readln.strip;

    writeln(s[0..k] ~ s[k..k+1].toLower ~ s[k+1..$]);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mset(a,b) memset(a,b,sizeof(a))
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
typedef long long ll;
const ll maxn=1e4+200;
const int inf=0x3f3f3f3f;
const double EPS=1e-10;
//typedef pair<int,int> PA;
double add(double a,double b){//考虑误差的加法运算
    if(abs(a+b)<EPS*(abs(a)+abs(b))) return  0;
    return a+b;
}
class Point{
public:

    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){
    }
    Point operator+ (Point p){
        return Point(add(x,p.x),add(y,p.y));
    }
    Point operator -(Point p){
        return Point(add(x,-p.x),add(y,-p.y));
    }
    Point operator *(double d){
        return Point(x*d,y*d);
    }
    double dot(Point p){//外积 p1.p2  outside
        return add(x*p.x,y*p.y);
    }
    double det(Point p){//内积 p1*p2    inner
        return add(x*p.y,-y*p.x);
    }
    double len(){
        return sqrt(add(x*x,y*y));
    }
};
Point operator *(double d,Point p){
    return Point(p.x*d,p.y*d);
}
Point getProjection(Point p1,Point p2,Point p){//p 在线段p1,p2上的投影坐标
    double d1=1.0/(p2-p1).len();
    Point ans=(p-p1).dot((p2-p1))*(p2-p1)*d1*d1;
    return ans+p1;
}
Point getReflection(Point p1,Point p2,Point p){//p 关于线段p1 p2的 反射坐标
    return 2.0*getProjection(p1,p2,p)-p;
}
double getDistance(Point a,Point b){//两点之间距离
    return (b-a).len();
}
int seg(double x){
    if(abs(x)<EPS)  return 0;
    if(x<0) return -1;
    else return 1;
}
class Line{
public:
    Point s,e;
    Line(){}
    Line(Point s,Point e):s(s),e(e){}
};
int getLineState(Line la,Line lb){
    if(seg((la.e-la.s).det(lb.e-lb.s))==0){
        return 2;//平行
    }//两向量平行 内积为0
    else if(seg((la.e-la.s).dot(lb.e-lb.s))==0){
        return 1;//垂直
    }
    else return 0;
}
int getDir(Point p,Point p1,Point p2){//返回 p2 关于p 在p1的什么方向
        int a=seg((p1-p).det(p2-p));
        int b=seg((p1-p).dot(p2-p));
        if(a>0){
            puts("COUNTER_CLOCKWISE");
        }
        else if(a<0){
            puts("CLOCKWISE");
        }
        else if(b<0){
            puts("ONLINE_BACK");
        }
        else if(b>0&&seg((p1-p).dot(p2-p1))>0){
            puts("ONLINE_FRONT");
        }
        else{
            puts("ON_SEGMENT");
        }
        return 0;

}
typedef Point P;
int main(){
    int q;
    P p0,p1,p2,p3;
    scanf("%d",&q);
    while(q--){
        scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&p0.x,&p0.y,&p1.x,&p1.y,&p2.x,&p2.y,&p3.x,&p3.y);
        int state=getLineState(Line(p0,p1),Line(p2,p3));
        printf("%d\n",state);
    }
    return 0;
}



Measured memory_bytes: 3252
#include<bits/stdc++.h>
using namespace std;
long long m[10000005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;

    long long ans=0;

    for(int i=1; i<=n; i++){
        m[i]++;
    }

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

        for(int j=i; j<=n; j+=i){
            m[j]++;
        }
    }

    for(int i=1; i<=n; i++){
        ans+=(i*m[i]);
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 81736
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n); i++)
#define sz(x) int(x.size())
using namespace std;
typedef unsigned long long ll;

vector<pair<int, int>> xy;

double getDistance(int a, int b){
    return hypot((double)(xy[a].first - xy[b].first), (double)(xy[a].second - xy[b].second));
}

double dfs(vector<int> nodes, int next){

    int nextNode = nodes[next];

    nodes.erase(nodes.begin()+next);

    double temp = 0;

    rep(i, sz(nodes)){
        temp += getDistance(nodes[i], nextNode);
        temp+=dfs(nodes, i);
    }

    if(sz(nodes)==0)return 0;

    temp = temp / (double)sz(nodes);
    return temp;
}

int main(){
    int n;
    cin >> n;
    vector<pair<int, int>> xytemp(n);
    rep(i, n){
        int x,y;
        cin >> x >> y;
        xytemp[i]=make_pair(x,y);
    }
    xy=xytemp;

    double temp = 0;
    vector<int> nds(n);
    rep(i,n){
        nds[i]=i;
    }
    rep(i, n){
        temp += dfs(nds, i);
    }

    cout << printf("%.7f", temp/(double)n) << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

int n, k;
vector <int> a;

ll calc(int mid){
    ll ret = 0;
    for(auto &i : a){
        ret += (i + mid - 1) / mid - 1;
    }
    return ret;
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    a.resize(n);
    for(auto &i : a) cin >> i;
    int l = 1, r = 1e9;
    while(l <= r){
        int mid = (l + r) / 2;
        if(calc(mid) <= k) r = mid - 1;
        else l = mid + 1;
    }
    cout << l << endl;
}


Measured memory_bytes: 3988
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n, m;
    cin>>n>>m;
    vec(pii) rec(n);
    rep(i,n){
        lli a, b;
        cin>>a>>b;
        rec[i]=pii(a, b);
    }
    sort(all(rec));
    lli ans=0, cnt=0;
    rep(i,n){
        if(rec[i].second+cnt<m){
            cnt+=rec[i].second;
            ans+=rec[i].first*rec[i].second;
        }
        else{ 
            ans+=(m-cnt)*rec[i].first;
            break;
        }
    }
    out(ans);
} 

Measured memory_bytes: 4796
import sys
from itertools import accumulate
from collections import deque

def solve():
    N, K = map(int, input().split())
    S = input()

    '''
    if N == 1:
        if K % 2 == 0:
            print(S)
        else:
            print('A' if S == 'B' else 'B')

        return
    '''

    q = deque([1 if c == 'A' else 0 for c in S])
    cb = 0

    for i in range(min(K, 2 * N + K % 2)):
        if q[0] == (cb ^ 1):
            q[0] ^= 1
        else:
            q.popleft()
            q.append(cb)
            cb ^= 1

    # print(q)

    ans = ['A' if (c ^ cb) else 'B' for c in q]
    print(''.join(ans))


def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

if __name__ == '__main__':
    solve()

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
long long mod(long long a){
  if(a<0)
    a=-a;
  return a;
}
int main(){
  long long n;
  cin>>n;
  long long h[n];
  for(long long i=0;i<n;i++){
    cin>>h[i];
  }
  long long b[n];
  b[0]=0;b[1]=mod(h[1]-h[0]);
  for(long long j=2;j<n;j++){
    b[j]=min(mod(h[j]-h[j-1])+b[j-1],mod(h[j]-h[j-2])+b[j-2]);
  }
  cout<<b[n-1];
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    if (S.length() == 2) {
        cout << S << endl;
    } else {
        cout << S[2] << S[1] << S[0] << endl;
    }

    return 0;
}


Measured memory_bytes: 256
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <queue>
#include <limits.h>

using namespace std;
static const int NMAX = 100;
int N, D[NMAX] = {};
bool G[NMAX][NMAX] = { { false } };

void breadthFirstSearch(int base) {
	int ix;
	for (int i = 0; i < N; i++) {
		D[i] = INT_MAX;
	}

	D[base] = 0;
	queue<int> q;
	q.push(base);
	while (!q.empty()) {
		ix = q.front(); q.pop();
		for (int i = 0; i < N; i++) {
			if (!G[ix][i]) continue;
			if (D[i] != INT_MAX) continue;
			D[i] = D[ix] + 1;
			q.push(i);
		}
	}

	for (int i = 0; i < N; i++) {
		cout << i + 1 << " " << ((D[i] == INT_MAX) ? (-1) : D[i]) << endl;
	}
}

int main() {
	int ix, deg, cache;
	cin >> N;

	for (int i = 0; i < N; i++) {
		cin >> ix >> deg;
		for (int j = 0; j < deg; j++) {
			cin >> cache;
			G[ix-1][cache-1] = true;
		}
	}

	breadthFirstSearch(0);

	return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1<<29;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

Pi d[100001]={};
int main() {

	int n;

	cin>>n;

	int a[100001];
	rep(i,n){
		cin>>a[i];
		d[i].first=a[i];
		d[i].second=i+1;
	}
	sort(d,d+n);
	rep(i,n-1){
		cout<<d[i].second<<" ";
	}
	cout<<d[n-1].second<<endl;
	return 0;
}


Measured memory_bytes: 2048
fun main(args: Array<String>) {

    val N = readLine()!!.toInt()
    val aList = readLine()!!.split(" ").map { it.toInt() }

    val isApproved = aList.filter { it % 2 == 0 }.all { it % 3 == 0 || it % 5 == 0 }

    if (isApproved) println("APPROVED") else println("DENIED")
}

Measured memory_bytes: 37892
/**
   <Linear Search>
   
   http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_4_A
   
   Shunji Lin
   06/01/2016
**/

#include <cstdio>
#include <set>
#include <vector>

int main()
{
  int s, t; //number of integers for S and T

  int count = 0; // number of integers of T in S
  
  std::set<int> S; // set S to be checked against

  scanf("%d", &s);
  
  for (int i = 0; i < s; ++i) {
    int input;
    scanf("%d", &input);
    S.insert(input);
  }

  scanf("%d", &t);

  std::vector<int> T;

  for (int i = 0; i < t; ++i) {
    int input;
    scanf("%d", &input);
    T.push_back(input);
  }

  for (int i = 0; i < t; ++i) {
    if ( S.find(T[i]) != S.end() ) ++count; // increment count if found in S
  }

  printf("%d\n", count);
}
    

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

vector<long long> primefact(long long n) {
  long long a = 1;
  vector<long long> pf;
  while(n >= a*a) {
    if (n % a == 0) {
      pf.push_back(n/a);
      pf.push_back(a);
    }
    a++;
  }
  return pf;
}

int main(void) {
  long long n, m;
  cin >> n >> m;
  vector<long long> pf = primefact(m);

  // for(int i = 0; i < pf.size(); i++)
  // {
  //   cout << pf[i] << endl;
  // }
  
  long long maxt = 0;
  for (int i = 0; i < pf.size(); i++) {
    if ((m / pf[i]) >= n)
      maxt = max(pf[i], maxt); 
  }

  cout << maxt << endl;

  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int a,b,c;

  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);

  if(b/a>=c){
    printf("%d",c);
  }else if(b/a<c){
    printf("%d",b/a);
  }

  return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()
N=len(S)

T1=''
for i in range(N):
    if i%2==0:
        T1+='0'
    else:
        T1+='1'
T2=''
for i in range(N):
    if i%2==0:
        T2+='1'
    else:
        T2+='0'

cnt1=0
for i in range(N):
    if S[i]!=T1[i]:
        cnt1+=1
cnt2=0
for i in range(N):
    if S[i]!=T2[i]:
        cnt2+=1
print(min(cnt1, cnt2))


Measured memory_bytes: 3316
char s[1<<20];m[1<<20]={1},n;main(t){for(gets(s);s[n];m[++n]=--t)for(;t<1&&s[-t]-s[n];t=m[-t]);t+=n;n=!printf(t*2<n?"Love %.*s!\n":"mitomerarenaiWA\n",t*=n/3/t+1,s);}

Measured memory_bytes: 5432
import math
import sys
input = sys.stdin.readline


def main():
    sc = Scan()
    n = sc.intarr()[0]
    d = sc.intarr()
    d.sort()
    ans = d[n//2] - d[n//2 - 1]
    print(ans)


class Scan():

    def intarr(self):
        line = input()
        array = line.split(' ')
        num_array = [int(n) for n in array]
        return num_array

    def strarr(self):
        line = input()
        array = line.split(' ')
        array[-1] = array[-1].strip('\n')
        return array


main()


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

string toString(int x, int k){
  stringstream ss;
  ss << x;
  string res = ss.str();
  while((int)res.size()<k)res = "0" + res;
  return res;
}

int main(){
  int n,m;
  int c[10];

  cin >> n >> m;
  for(int i=0;i<10;i++)cin >> c[i];

  int lim = 1;
  for(int i=0;i<n;i++)lim*=10;

  string ans = "NA";
  for(int x=0;x<lim;x++){
    string s = toString(x,n);
    int sum = 0;
    for(int i=0;i<n;i++){
      sum += c[s[i]-'0'];
    }
    if(sum<=m){
      ans = s; break;
    }
  }

  cout << ans << endl;
}


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

class Disjoint_Set
{
    struct data {
        int parent;
        int rankk;
    } Node[100005];

public:
    void MakeSet(int x)
    {
        Node[x].parent = x; //Points parent to itself
        Node[x].rankk = 0;  //Rank is initialize as zero
    }

    int FindSet(int x)
    {
        if(Node[x].parent == x) //If representative is found
            return x;
        else
            Node[x].parent = FindSet(Node[x].parent); //Path compression

        return Node[x].parent; //Return the parent of the desired node
    }

    void UnionSet(int x, int y)
    {
        int i = FindSet(x); //Representative of set of x
        int j = FindSet(y); //Representative of set of y

        if(i == j) //If they are in the same set
            return ; //Do nothing

        if(Node[i].rankk == Node[j].rankk) { //If they have the same depth
            Node[i].rankk++; //Increase depth of i
            Node[j].parent = i; //Point j to i
        } else if (Node[i].rankk > Node[j].rankk) { //If depth of i is greater than j
            Node[j].parent = i; //Point j to i
        } else {
            Node[i].parent = j; //If depth of j is greater than i than point i to j
        }
    }

    bool SameSet(int x, int y)
    {
        return FindSet(x)==FindSet(y);
    }
};

Disjoint_Set DS;
int n, m, p[100005], x, y, ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    for(int i=1; i<=n; i++) {
        cin >> p[i];
        DS.MakeSet(i);
    }
    for(int i=1; i<=m; i++) {
        cin >> x >> y;
        DS.UnionSet(x, y);
    }

    for(int i=1; i<=n; i++) {
        if(!DS.SameSet(i, p[i])) ans++;
    }
    cout << n-ans << endl;

    return 0;
}


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

int main(){
    string S;
    cin >> S;
    bool ok = true;
    for(int i = 1; i <= S.size(); i++) {
        if(i%2 == 0 && S[i-1] == 'R') {
            ok = false;
            break;
        }
        else if(i%2 == 1 && S[i-1] == 'L') {
            ok = false;
            break;
        }
    }
    if(ok) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i = 0; i < n;i++)
#define ll long long
#include <bits/stdc++.h>
using namespace std;
#define mo 1000000007
#define ull unsigned long long 

int main(){
  int a,b;cin>>a>>b;
  if(a>b)
    cout<<a-1;
  else
    cout<<a;
}
  


Measured memory_bytes: 256
Module Module1

    Sub main()
        Dim user2 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
        Dim toudaiMax As Long = user2(0)
        Dim michiMax As Long = user2(1)

        ' 展望台の高さを取得
        Dim user3 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))

        Dim toudaiHeight As New List(Of Long)(Array.ConvertAll(user3.ToArray, Function(i As String) CLng(i)))

        Dim goodTenboFlg(toudaiMax - 1) As Boolean

        For i = 0 To goodTenboFlg.Count - 1
            goodTenboFlg(i) = True
        Next


        For i = 0 To michiMax - 1
            Dim user4 As List(Of String) = New List(Of String)(Split(Console.ReadLine(), " "))
            Dim michiA As Long = user4(0) - 1
            Dim michiB As Long = user4(1) - 1

            If toudaiHeight(michiA) >= toudaiHeight(michiB) Then
                goodTenboFlg(michiB) = False
            End If
            If toudaiHeight(michiA) <= toudaiHeight(michiB) Then
                goodTenboFlg(michiA) = False
            End If
        Next
        Dim sss As New List(Of Boolean)(goodTenboFlg)
        Console.WriteLine(sss.FindAll(Function(n) n).Count)
    End Sub
end module

Measured memory_bytes: 163020
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    string s;
    vector<bool> v(26, false);
    cin >> s;
    for (auto &&i: s){
        if (v.at(i-'a')){
            cout << "no";
            return 0;
        }
        v.at(i-'a') = true;
    }
    cout << "yes";
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  int n = a * 100 + b * 10 + c;
  puts(n % 4 == 0 ? "YES" : "NO");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define INF 2e9
#define MOD (1000000007)
#define EPS 1e-9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long long int lli;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int val = (N * (N - 1) / 2 - (N - 1)) - K;
    if (val < 0)
    {
        cout << -1 << "\n";
    }
    else
    {
        cout << N - 1 + val << "\n";
        REPS(i, N - 1)
        {
            cout << i << " " << N << "\n";
        }
        int count = 0;
        REPS(i, N - 1)
        {
            FORS(j, i + 1, N - 1)
            {
                if (count == val)
                    break;
                cout << i << " " << j << "\n";
                count++;
            }
            if (count == val)
                break;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
int result[100][100];
int map[101][101];
int h, w;

int kousin(int turn){
	int r = 0;
	for (int i = 0; h > i; i++){
		for (int j = 0; w > j; j++){
			if (map[i][j+1] == 1){
				if (result[i][j] == -1){
					result[i][j] = turn;
				}
				r = 1;
			}
		}
	}
	return r;
}

int main() {
	for (int i = 0; 100 > i; i++){
		for (int j = 0; 100 > j; j++){
			result[i][j] = -1;
		}
	}
	scanf("%d %d%*c", &h, &w);
	for (int i = 0; h > i; i++){
		for (int j = 1; w + 1 > j; j++){
			char c;
			scanf("%c", &c);
			map[i][j] = (c == 'c');
		}
		scanf("%*c");
	}
	for (int turn = 0; kousin(turn); turn++){
		for (int i = h - 1; i >= 0; i--){
			for (int j = w; j >= 1; j--){
				map[i][j] = map[i][j - 1];
			}
		}
	}
	for (int i = 0; h > i; i++){
		for (int j = 0; w > j; j++){
			printf("%d", result[i][j]);
			if (j < w - 1)printf(" ");
		}
		printf("\n");
	}
	return 0;
}

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

ll MOD = 1e9 + 7;

int d[1001];

int main() {
  int N;
  cin >> N;
  ll ans = 1;
  for (int i = 2; i <= N; i++) {
    int M = i;
    for (int j = 2; j <= N; j++) {
      while (M % j == 0) {
        M /= j;
        d[j]++;
      }
    }
  }
  for (int i = 2; i <= N; i++) {
    ans = ans * (d[i] + 1) % MOD;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as C
import Data.Maybe ( fromJust )
import Data.List

import qualified Data.Vector.Unboxed as U

cReadLn :: IO Int
cReadLn = fst . fromJust . C.readInt <$> C.getLine

getParms :: IO [Int]
getParms = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

main :: IO ()
main = do
  [n,k] <- getParms
  as    <- getParms
  print $ f k as

f :: Int -> [Int] -> Int
f k as 
  | k >= l = 0 -- There are enough, no need to rewrite.
  | k <  l = g ns (l-k) 0
  where
    as' = group . sort $ as
    l   = length as' -- # of kinds.
    ns  = U.fromList . sort . map (U.length . U.fromList) $ as' -- A list of # of kinds.

    g :: U.Vector Int -> Int -> Int -> Int
    g _ 0 x = x -- Assuming k<=n.
    g v k x = g (U.tail v) (k-1) (x + U.head v)

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

namespace TYC
{
	const int N = 605;

	int n, vis[N][N], cnt[5];

	void solve(int D, const int type)
	{
		int tim = 0;
		while (!(D & 3))
			D /= 4, tim++;
		if (D & 1)
		{
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					if (((i >> tim) + (j >> tim)) & 1)
						vis[i][j] += type;
		}
		else
		{
			for (int i = 0; i < n; i++)
				for (int j = 0; j < n; j++)
					if ((i >> tim) & 1)
						vis[i][j] += type;
		}
	}

	void work()
	{
		int d1, d2;
		scanf("%d%d%d", &n, &d1, &d2);
		n <<= 1;
		solve(d1, 1);
		solve(d2, 2);
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				cnt[vis[i][j]]++;
		int mx = 0, id = -1;
		for (int i = 0; i < 4; i++)
			if (cnt[i] > mx)
				mx = cnt[i], id = i;
		for (int i = 0, res = (n >> 1) * (n >> 1); i < n; i++)
			for (int j = 0; j < n && res; j++)
				if (vis[i][j] == id)
				{
					printf("%d %d\n", i, j);
					res--;
				}
	}
}

int main()
{
	TYC::work();
	return 0;
}

Measured memory_bytes: 2304
using System;
using System.Text;

namespace ALDS1_6_A {
    class Program {
        static void Main(string[] args) {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');

            int[] A = new int[n + 1];
            int[] B = new int[n + 1];
            int[] C = new int[10001];

            for (int i = 1, j = 0; i <= n; i++, j++) {
                int temp = int.Parse(input[j]);
                A[i] = temp;
                C[temp]++;
            }

            for (int i = 1; i < 10001; i++) {
                C[i] += C[i - 1];
            }

            for (int i = n; i > 0; i--) {
                B[C[A[i]]] = A[i];
                C[A[i]]--;
            }

            StringBuilder sb = new StringBuilder();
            sb.Append(B[1]);
            for (int i = 2; i <= n; i++)
                sb.Append(" " + B[i]);
            Console.WriteLine(sb.ToString());
        }
    }
}

Measured memory_bytes: 257832
d, g = map(int, input().split())
point = [[int(x) for x in input().split()] for i in range(d)]

ans = 100000000
for i in range(2**d):
  sub = 0
  count = 0
  complete = [False]*d
  for j in range(d):
    if (i>>j)&1:
      complete[j] = True
      sub += 100*(j+1)*point[j][0]+point[j][1]
      count += point[j][0]
  for j in range(d-1, -1, -1):
    if sub >= g:
      break
    if complete[j]:
      continue
    c = min((g-sub-1)//(100*(j+1))+1, point[j][0])
    count += c
    sub += c*100*(j+1)
    if c == point[j][0]:
      sub += point[j][1]
  if ans > count:
    ans = count

print(ans)

Measured memory_bytes: 9260
#include<bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define pb push_back
#define S second
#define F first

void solve(){

	ll a, b, x;
	cin >> a >> b >> x;

	ll q1 = a/x , q2 = b/x;

	if(a%x == 0)
		cout << q2 - q1 + 1 << endl;
	else
		cout << q2 - q1 << endl;
 
}
 
 
int main(){
	    
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
 
	solve();
	 
	return 0;
 
}




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

using namespace std;
#define ll long long int
int const mod=1000000007;
int main()
{
    ll t;
    cin>>t;
    ll a=0,b=0,c=0,d=0;
    while(t--)
    {
        string s;

        cin>>s;
        if(s=="AC")
            a++;
        if(s=="WA")
            b++;
        if(s=="TLE")
            c++;
        if(s=="RE")
            d++;

    }
        cout<<"AC x "<<a<<endl;
        cout<<"WA x "<<b<<endl;
        cout<<"TLE x "<<c<<endl;
        cout<<"RE x "<<d<<endl;
}


Measured memory_bytes: 3624
K = int(input())
A, B = map(int, input().split())
count = 0
s = 0

while s <= B:
    count += 1
    s = K * count
    if(A <= s and s <= B):
        print('OK')
        break
    elif(s >= B):
        print('NG')
        break
    else:
        pass

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

int main() {
    // insert code here...
    
    int i,j,k,N,V;
    int A[1000];
    
    cin >> N;
    
    for (i=0; i<N; i++){
        cin >> A[i];
    }

    for (k=0; k<N; k++){
        if (k==N-1)
        {
            cout << A[k] << endl;
        }
        else
        {
            cout << A[k] << flush;
            cout << " " << flush;
        }
    }
    
    for (i=1; i<N; i++){
        V=A[i];
        j=i-1;
        while (j>=0 and A[j]>V){
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=V;
        for (k=0; k<N; k++){
            if (k==N-1)
            {
               cout << A[k] << endl;
            }
            else
            {
            cout << A[k] << flush;
            cout << " " << flush;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3092
import java.io.*;
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
    	Scanner s = new Scanner(System.in);
        try {
            int A_size;
            
            while(true){
                boolean nosol = true;
                long res = 0;
                /* input from here */
                A_size = s.nextInt();
                if(A_size==0){
                    break;
                } else if(A_size==1){
                    System.out.println(s.nextInt());
                    continue;
                } else {
                	HashMap<Long,Integer> A = new HashMap<Long,Integer>();
                    for(int i=0;i<A_size;i++){
                        long t = s.nextLong();
                        if(A.containsKey(t)){
                        	int v = A.get(t);
                        	if(v+1>A_size/2){
                        		res = t;
                        		nosol = false;
                        	}
                        	A.put(t, v+1);                        	
                        } else {
                        	A.put(t,1);
                        }
                        if(i % 100000 == 0) System.gc();
                    }
                }
                /* input till here */
                if(nosol){
                    System.out.println("NO COLOR");
                } else {
                	System.out.println(res);
                }
                 
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
        	s.close();
        }
    }
}

Measured memory_bytes: 119296
N, M = map(int, input().split())
side = [list(map(int, input().split())) for i in range(M)]
maze = [[0] * N for i in range(N)]


for i, j in side:
    maze[i-1][j-1] = 1
    maze[j-1][i-1] = 1


visited = [0] * N

def search_side(maze, v):
    ans = []
    for i in range(len(maze[v])):
        if maze[v][i] == 1:
            ans.append(i)
    return ans

def dfs(v, visited, maze):
    visited[v] = 1
    for i in search_side(maze, v):
        if visited[i] == 1:
            continue
        else:
            visited = dfs(i, visited, maze)
    return visited

ans = 0
for i, j in side:
    maze[i-1][j-1] = 0
    maze[j-1][i-1] = 0
    if sum(dfs(0, visited, maze)) != N:
        ans += 1
    maze[i-1][j-1] = 1
    maze[j-1][i-1] = 1
    visited = [0] * N
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
//A is array and N is count
int selection_sort(int array[],int size){
  int count=0,min,min_index,tmp,i,j;
  for(i=0;i<size;i++){
    min_index=i;
    for(j=i;j<size;j++){
      if(array[j]<array[min_index]){
        min=array[j];
        min_index=j;
      }
    }
    if(i!=min_index) count++;
    tmp=array[i];
    array[i]=min;
    array[min_index]=tmp;
  }
  return count;
}

int main(void){
  int i,size,array[100000],count;
  scanf("%d",&size);
  for(i=0;i<size;i++){
    scanf("%d",&array[i]);
  }
  count = selection_sort(array,size);
  for(i=0;i<size;i++){
    if(i>0) printf(" ");
    printf("%d",array[i]);
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}

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

bool is_prime(int x){
    for(int i = 2; i * i <= x; i++)
        if (x % i == 0)
            return false;
    return true;
}
int main(){
    int x;
    cin >> x;
    while (!is_prime(x))
        x++;
    cout << x << endl;
}

Measured memory_bytes: 3552
module Main where
import qualified Control.Monad as C
import qualified Data.Char as C
import qualified Data.List as L
import qualified Data.Map as M
import qualified Data.Array as A

int = read :: String -> Int
getWord :: IO String
getWord = do
  c <- getChar
  if C.isSpace c
  then
    return []
  else do
    ws <- getWord
    return (c:ws)
getInt = fmap int getWord
replace pred a = map (\x -> if pred x then a else x)

main = interact $ printer . solver . parser
parser = map int . words
printer = (++"\n") . show

solver [x,y] = let z = x - 2 * y in if z < 0 then 0 else z

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    int n,l; cin >> n >> l;
    int Allsum = (n + 2*l - 1)*n/2;
    
    std::vector<pair<int,int>> ABS;

    for (int i = 0; i < n; ++i)
    {
    	ABS.push_back(make_pair(abs(l + i),i));
    }

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

    cout << Allsum - (l + ABS[0].second) << endl;

}

Measured memory_bytes: 256