akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main()
{
	int y, x, n;
	char map[100 + 10][100 + 10];

	int i, j;

	int spn=0;

	int sum=0;

	cin >> y >> x >> n;

	for (i = 0; i < y; i++)
	{
		for (j = 0; j < x; j++)
		{
			cin >> map[i][j];

			if (map[i][j] == '.')
			{
				spn++;
			}
			else
			{
				if (spn - n + 1 > 0)
				{
					sum += spn - n + 1;
				}
				spn = 0;
			}
		}

		if (spn - n + 1 > 0)
		{
			sum += spn - n + 1;
		}

		spn = 0;
	}

	for (i = 0; i < x; i++)
	{
		for (j = 0; j < y; j++)
		{
			if (map[j][i] == '.')
			{
				spn++;
			}
			else
			{
				if (spn - n + 1 > 0)
				{
					sum += spn - n + 1;
				}
				spn = 0;
			}
		}

		if (spn - n + 1 > 0)
		{
			sum += spn - n + 1;
		}

		spn = 0;
	}

	cout << sum << endl;

	return 0;

}

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

int main()
{
  // 入力受け取り
  long N,M;
  long totalB=0;
  cin >> N >> M;
  vector<long long> AList(N);
  for (int i = 0; i < N; ++i) cin >> AList[i];
  // sort
  sort(AList.begin(), AList.end());
  
  vector<vector<long long>> CBList = vector<vector<long long>>(M, vector<long long>(2, 0));
  for (int i = 0; i < M; ++i) cin >> CBList.at(i).at(1) >> CBList.at(i).at(0), totalB+=CBList[i][1];
  sort(CBList.begin(), CBList.end());
  reverse(CBList.begin(), CBList.end());
    
  int CBpoint=0;
  long long total=0;
  for (int i=0; i < N; i++) {
    if (i < totalB && AList[i] < CBList[CBpoint][0]) {
      AList[i] = CBList[CBpoint][0];
      CBList[CBpoint][1]--;
      if (CBList[CBpoint][1] == 0) {
        CBpoint++;
      }
    } 
    total+=AList[i];
  }

  cout << total << endl;   
  return 0;
}


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

int main() {
    int N;
    long long sum=0;
    cin >> N;
    vector<int> a(N);

    vector<long long> count(N+1, 0);
    for(int i=0; i<N; i++){
	cin >> a[i];
	count[a[i]]++;
    }

    for(int i=0; i<N+1; i++){
	sum += count[i]*(count[i]-1)/2;
    }

    for(int i=0; i<N; i++){
	int num = a[i];
	long long ans = sum - count[num]*(count[num]-1)/2 +(count[num]-1)*(count[num]-2)/2;
	cout << ans  << endl;
    }

}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long int a[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i];
    }
    sort(a,a + n);
    vector<long long int> v;
    for(int i = n - 2;i >= 0;i--)
    {
        if(a[i] == a[i + 1])
        {
            v.push_back(a[i]);
            if(v.size() >= 2)
            {
                break;
            }
            i--;
        }
    }
    if(v.size() < 2)
    {
        cout << "0";
    }
    else
    {
        cout << v.at(0) * v.at(1);
    }
    
    return 0;
}

Measured memory_bytes: 1024
import java.util.*;
class Main{
public static void main(String[] args) {
  Scanner reader =new Scanner (System.in);
  int a=reader.nextInt();
  int b=reader.nextInt();
  int c=reader.nextInt();
  int d=reader.nextInt();
  while(true)
  {
    c-=b;
    
    if(c<=0)
    {
      System.out.println("Yes");
      return;
    }
    a-=d;
    if(a<=0)
    {
      System.out.println("No");
      return;
    }

  }
}
}

Measured memory_bytes: 35708
import java.util.Scanner;
 
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    
    if(C>=A && C<=B){
    	System.out.println("Yes");
    }else{
    	System.out.println("No");
    }
  }
}

Measured memory_bytes: 23764
import bisect
 
 
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for _ in range(N)]
AB.sort(key=lambda x: x[1], reverse=True)
memo = [x for x in range(N)]
ans = 0
for a, b in AB:
    if M < a:
        continue
    Ma = M - a
    i = bisect.bisect_right(memo, Ma)
    if i > 0:
        del memo[i - 1]
        ans += b
print(ans)

Measured memory_bytes: 31884
import java.util.Scanner;

public class Main {

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

		int X = sc.nextInt();
		String ans = "";

		if (X == 7 ||X == 5 || X == 3) {
			ans = "YES";
		} else {
			ans = "NO";
		}
		System.out.println( ans );
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
#define LL long long
using namespace std;
const int maxn=200005,K=998244353;
int n,m,p,ans,fac[maxn],inv[maxn];
int C(int A,int B) { return (LL)fac[A]*inv[B]%K*inv[A-B]%K; }
int Pow(int A,int B)
{
	int res=1;
	while (B)
	{
		if (B&1) res=(LL)res*A%K;
		A=(LL)A*A%K;
		B>>=1;
	}
	return res;
}
int main()
{
	scanf("%d%d%d",&n,&p,&m);
	fac[0]=1;
	for (int i=1;i<=n;i++) fac[i]=(LL)fac[i-1]*i%K;
	inv[n]=Pow(fac[n],K-2);
	for (int i=n-1;i>=0;i--) inv[i]=(LL)inv[i+1]*(i+1)%K;
	for (int i=m,now=(LL)p*Pow(p-1,n-m-1)%K;i>=0;i--)
	{
		//cerr<<">>>>>>"<<now<<endl;
		ans=(ans+(LL)now*C(n-1,i))%K;
		now=(LL)now*(p-1)%K;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 5320
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author HARSHAD
 */

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

class TaskD {
public:
	void solve(std::istream& in, std::ostream& out) {
		int n; in>>n;
		int arr[n];
		for(int i = 0; i<n; ++i) in>>arr[i];
		sort(arr, arr+n);
		vector<int> ans(2);
		ans[1] = ans[0] = arr[n-1];
		int low = 0, high = n-1, res = n;
		while(low<=high) {
			int mid = (low + high) >> 1;
			if (2 * arr[mid] >= arr[n-1]) res = mid, high = mid - 1;
			else low = mid + 1;
		}
		if(res<n-1){
			ans[1]=arr[res];
		}
		--res;
		if(res>=0){
			if(min(ans[0]-arr[res], arr[res])>=min(ans[0]-ans[1], ans[1])){
				ans[1] = arr[res];
			}
		}
		out<<ans[0]<<" "<<ans[1];
	}
};


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	TaskD solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
n=int(input())
x=list(map(int,input().split()))
tmp1=sum(x)//n
tmp2=-(-sum(x)//n)
ans1=0
ans2=0
for i in range(n):
    ans1+=(tmp1-x[i])**2
for i in range(n):
    ans2+=(tmp2-x[i])**2
print(min(ans1,ans2))

Measured memory_bytes: 3064
import sys
from collections import deque
from collections import  Counter
import statistics
import math
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
a_li = na()
for i in range(n):
    a_li[i] = a_li[i] - (i + 1)
m1 = statistics.median_low(a_li)
m2 = statistics.median_high(a_li)
ans1 = 0
ans2 = 0
for i in range(n):
    ans1 += abs(a_li[i] - m1)
    ans2 += abs(a_li[i] - m2)
print(min(ans1, ans2))


Measured memory_bytes: 27264
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[]srgs) {
	Scanner scan=new Scanner(System.in);
	int a=scan.nextInt();
	int b=scan.nextInt();
	int c[]=new int[a];
	for(int i=0;i!=a;i++) {
		c[i]=scan.nextInt();
	}
	Arrays.sort(c);
	int ans=0;
	for(int i=c.length-1,n=0;n!=b;i--,n++) {
		ans+=c[i];
	}
	System.out.println(ans);
}
}

Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(i=0;i<n;i++)
#define Fo(i,k,n) for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef pair<int, int>  pii;
typedef pair<ll, ll>  pl;
typedef vector<int>   vi;
typedef vector<ll>    vl;
typedef vector<pii>   vpii;
typedef vector<pl>    vpl;
typedef vector<vi>    vvi;
typedef vector<vl>    vvl;
void myInit();
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int MOD = 1000000007;
const int N = 3e5, M = N;
//=========TQR==============
vi g[N];
int a[N];

int main() {
	myInit();
	FIO;
	long double a, b, h, m;
	cin >> a >> b >> h >> m;
	h = h * 30;
	m = m * 6;
	h += m / 12;
	long double angle = abs(h - m);
	long double ans = a * a + b * b - 2 * a * b * cos(angle * PI / 180);
	ans = sqrt(ans);
	cout << setprecision(21) << ans << endl;

	return 0;
}

void myInit() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int mpow(int base, int exp) {
	base %= MOD;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = ((ll)result * base) % MOD;
		base = ((ll)base * base) % MOD;
		exp >>= 1;
	}
	return result;
}

void ipgraph(int n, int m) {
	int i, u, v;
	while (m--) {
		cin >> u >> v;
		g[u - 1].pb(v - 1);
		g[v - 1].pb(u - 1);
	}
}

void dfs(int u, int par) {
	for (int v : g[u]) {
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 11240
<?php
  list($h, $w) = explode(" ", trim(fgets(STDIN)));

  $s = [];
  $black=0;
  $white=0;
  for ($i=0; $i<$h; $i++) {
    list($c) = explode(" ", trim(fgets(STDIN)));
    for($j=0;$j<strlen($c);$j++){
      if($c[$j]=='.') $white++;
      else $black++;
    }
    $s[] = str_split($c);
  }

  $dist=[];
  for($i=0;$i<$h;$i++){
    $dist[] = array_fill(0, $w, PHP_INT_MAX);
  }

  $q = new SplQueue();
  $q->enqueue([0,0,0]);
  while($q->count() > 0){
    list($i,$j,$d) = $q->dequeue();
    if($dist[$i][$j] > $d){
      $dist[$i][$j]=$d;
      // 上
      if(isset($dist[$i-1][$j]) && $s[$i-1][$j]=="."){
        $q->enqueue([$i-1, $j, $d+1]);
      }
      // 下
      if(isset($dist[$i+1][$j]) && $s[$i+1][$j]=="."){
        $q->enqueue([$i+1, $j, $d+1]);
      }
      // 左
      if(isset($dist[$i][$j-1]) && $s[$i][$j-1]=="."){
        $q->enqueue([$i, $j-1, $d+1]);
      }
      // 右
      if(isset($dist[$i][$j+1]) && $s[$i][$j+1]=="."){
        $q->enqueue([$i, $j+1, $d+1]);
      }
    }
  }

  if($dist[$h-1][$w-1] == PHP_INT_MAX){
    echo "-1";
  }else{
    echo $white-$dist[$h-1][$w-1]-1;
  }

Measured memory_bytes: 16656
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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; }

#include <bits/stdc++.h>
using namespace std;

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

  int x;
  rep(i,n){
    bool bo=true;
    stack<int> a,b;
    rep(j,10){
      cin>>x;
      if(a.empty()) a.push(x);
      else if(x>a.top()) a.push(x);
      else if(b.empty()) b.push(x);
      else if(x>b.top()) b.push(x);
      else bo=false;
    }
    if(bo) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
      
  return 0;
}


Measured memory_bytes: 3016
#include<bits/stdc++.h>
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;

typedef long long       ll;
typedef long double     ld;

typedef vector<int>     vi;
typedef vector<bool>    vb;
typedef vector<ll>      vll;
typedef vector<vi>      vvi;
typedef vector<vll>     vvll;
typedef vector<string>  vs;

typedef pair<int, int>  pii;
typedef pair<ll, int>   pli;
typedef pair<ll, ll>    pll;
typedef vector< pii >   vpi;
typedef vector< pll >   vpll;

// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;

#define pb           push_back
#define mod          1000000007
#define INF          1e17
#define mini         INT_MIN
#define maxo         INT_MAX
#define eb           emplace_back
#define ff           first
#define ss           second
#define re           return 
#define endl         "\n" 

#define all(c)       c.begin(),c.end()
#define be           begin()
#define en           end()
#define sz(x)        (ll)x.size()
#define mem(a,val)   memset(a,val,sizeof(a))
#define mk(x,y)      make_pair(x,y)
#define mid(s,e)     ((s)+((e)-(s))/2) 

#define fo(i,a,b)     for(ll i = (ll)(a); i <= (ll)(b); i++)
#define rf(i,a,b)    for(ll i = (ll)(a); i >= (ll)(b); i--)
#define read(a,n)    for(int i=0;i<n;i++)cin>>a[i];
#define show(a,n)    for(int i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;
#define p2(n)        (1LL << (n))
#define deb(x) cout <<#x << " = " << x << " | " << "LINE: "<<__LINE__<< endl;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }

void add(ll &x, ll y){ x += y; if(x>=mod) x %= mod; if(x<0) x = x%mod + mod; }

//============== *** START OF CODE ***




void solve()
{
    int n;rd(n);
    bool p = 0;
    while(n){
        if(n%10==7)p=1;
        n/=10;
    }   
    if(p)pp("Yes");
    else pp("No");
    
}


void prep(){}

//=============== *** END OF CODE ***

int main(){
    speedio; cout<<fixed<<setprecision(12);

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

    prep();
    int t = 1;
    // cin >> t;
    while(t--)
        solve();

    return 0;
}

Measured memory_bytes: 3636
s = input()
l = int(s[:2])
r = int(s[2:])
ans = "NA"
if (1 <= l and l <= 12) and (1 <= r and r <= 12):
    ans = "AMBIGUOUS"
elif (1 <= l and l <= 12) and (r == 0 or r > 12):
    ans = "MMYY"
elif (1 <= r and r <= 12) and (l == 0 or l > 12):
    ans = "YYMM"
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;
int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll reverse(ll num)
{
     ll n, reversedNumber = 0, remainder;
     n=num;
    while(n != 0)
    {
        remainder = n%10;
        reversedNumber = reversedNumber*10 + remainder;
        n /= 10;
    }
    return reversedNumber;
}
bool divisor(ll n)
{
    for(ll i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return 0;
    }
    return 1;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   ll n,m,k;
   cin>>n>>m>>k;
   ll a[n],b[m];
   rep(i,0,n) cin>>a[i];
   rep(i,0,m) cin>>b[i];
   ll sum[n+1]={0};
   ll s2[m+1]={0};
   sum[0]=a[0];
   s2[0]=b[0];
   for(ll i=1;i<n;i++)
   {
       sum[i]=sum[i-1]+a[i];
   }
   for(ll i=1;i<m;i++)
   {
       s2[i]=s2[i-1]+b[i];
   }
   ll ans=0;
   for(ll i=0;i<m;i++)
   {
       if(s2[i]<=k)
            ans=i+1;
   }
   for(ll i=0;i<n;i++)
   {
       if(k-sum[i]<0) continue;
       ll idx=ub(s2,s2+m,k-sum[i])-s2;
       if(idx==m){ans=max(ans,i+1+m);}
       else{ans=max(ans,i+1+idx);}
   }
   cout<<ans;
	return 0;
}


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

int prime[100007]={1,1},sum[100007],T;
void Prime(int n)
{
	int m=sqrt(n);
	for(int i=2;i<=m;i++)
		if(!prime[i])
			for(int j=i*i;j<=n;j+=i)
				prime[j]=1;
}
int main()
{
	cin>>T;Prime(100000);
	for(int i=1;i<=100000;++i)
		if(!prime[i] && !prime[(i+1)/2])sum[i]=sum[i-1]+1;
		else sum[i]=sum[i-1];
	while(T--)
	{
		int l,r,ans=0;
		cin>>l>>r;
		cout<<sum[r]-sum[l-1]<<endl;
	}
	return 0;
} 

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
	long long n;
	cin >> n;
	long long count = n / 1000000000 + n % 1000000000 / 100000000 + n % 100000000 / 10000000 + n % 10000000 / 1000000 + n % 1000000 / 100000 + n % 100000 / 10000 + n % 10000 / 1000 + n % 1000 / 100 + n % 100/10+n%10;
	if (n%count == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
	getchar();
	getchar();
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0 
for i in range(0, A + 1):
  numi = i * 500
  if numi == X:
    ans += 1
  elif numi < X:
    for j in range(0, B + 1):
      numj = j * 100 + numi
      if numj == X:
        ans += 1
      elif numj < X:
        for k in range(0, C + 1):
          numk = k * 50 + numj
          if numk == X:
            ans += 1
          elif numk < X:
            continue
          else:
            break
      else:
        break
  else:
    continue
print(ans)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n,h; cin>>n>>h;
	vector<int>b(n);
	int amx=0;
	for(int i=0;i<n;++i){
		int a; cin>>a>>b.at(i);
		amx=max(amx,a);
	}
	sort(b.begin(),b.end(),[](auto a,auto b){return a>b;});
	int ans=0;
	for(int i=0;i<n;++i){
		if(b.at(i)<=amx||h<=0)break;
		h-=b.at(i),++ans;
	}
	if(h>0)ans+=h/amx;
	if(h>0&&h%amx)++ans;
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 640
inputs = input().split()
w = int(inputs[0])
h = int(inputs[1])
x = int(inputs[2])
y = int(inputs[3])
r = int(inputs[4])

if x+r > w or x-r < 0:
    print("No")
elif y+r > h or y-r < 0:
    print("No")
else:
    print("Yes")



Measured memory_bytes: 5596
function Main(input){
  var inp = input.split(' ');
  var A = parseInt(inp[0]);
  var B = parseInt(inp[1]);
  var C = parseInt(inp[2]);
  var D = parseInt(inp[3]);

  var L = A + B;
  var R = C + D;

  if(L > R){
    console.log('Left');
  } else if(L < R){
    console.log('Right');
  } else {
    console.log('Balanced');
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(ll i=0;i<(n);++i)
#define OREP(i,n) for(ll i=1;i<=(n);++i)
#define RREP(i,n) for(ll i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false


int main(void){
    ll N;
    string S[114514];
    cin >> N;
    REP(i,N){
        cin >>  S[i];
    }
    
    ll a=0,w=0,t=0,r=0;
    REP(i,N){
        if(S[i]=="AC"){
            a++;
        }else if(S[i]=="WA"){
            w++;
        }else if(S[i]=="TLE"){
            t++;
        }else{
            r++;
        }
    }
    
    cout << "AC x " << a << endl;
    cout << "WA x " << w << endl;
    cout << "TLE x " << t << endl;
    cout << "RE x " << r << endl;
    return 0;
}



Measured memory_bytes: 7208
#include <bits/stdc++.h>
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define loop(i, start, end) for(int i=start; i<=end; ++i)
#define MOD 1e9+7
using namespace std;

int readInt () {
	bool minus = false;
	int result = 0;
	char ch;
	ch = getchar();
	while (true) {
		if (ch == '-') break;
		if (ch >= '0' && ch <= '9') break;
		ch = getchar();
	}
	if (ch == '-') minus = true; else result = ch-'0';
	while (true) {
		ch = getchar();
		if (ch < '0' || ch > '9') break;
		result = result*10 + (ch - '0');
	}
	if (minus)
		return -result;
	else
		return result;
}

template <typename T>
void cloneArray(T *a, T *b, int start, int end) {
    loop(i, start, end) {
        *(b+i)=*(a+i);
    }
}

template <typename T>
void inputArray(T *a, int start, int end) {
    loop(i, start, end) cin >> a[i];
}

template <typename T>
void printArray(T *a, int start, int end) {
    loop(i, start, end) cout << *(a+i) << ' ';
}

void ruffleSort(int *a, int n) {
    unsigned seed=0;
    shuffle(a, a+n, default_random_engine(seed));
    sort(a, a+n);
}

int main(int argc, char const *argv[])
{   
    IOS;
    int n, x, t;
    cin >> n >> x >> t;
    if(n%x==0) {
        cout << (n/x)*t;
    } else {
        cout << ((n/x)+1)*t;
    }
    //cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
    return 0;
}

Measured memory_bytes: 3656
import collections
h,w = map(int, raw_input().split())
mat = [map(int, raw_input().split(' ')) for _ in range(h)]
elems = [(i,j) for i in range(len(mat)) for j in range(len(mat[0]))]
elems.sort(key = lambda x: x[0] + x[1])
q = collections.deque(elems)
moves = []
while(q):
	i,j = q.popleft()
	if mat[i][j] % 2:
		if j + 1 < len(mat[0]):
			mat[i][j] -= 1
			mat[i][j+1] += 1
			moves.append([(i+1,j+1), (i+1, j + 2)])
			#q.append((i,j + 1))
		elif i + 1 < len(mat):
			mat[i][j] -=1
			mat[i+1][j] += 1
			moves.append([(i+1,j+1), (i+2, j+1)])
			#q.append((i + 1,j ))
print len(moves)
for u,v in moves: print u[0],u[1],v[0],v[1]

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

    //入力高速化
    struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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

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

signed main() {
  int Q;
  cin >> Q;
  vector<P> input(Q);
  rep(i, Q) {
    cin >> input[i].F >> input[i].S;
  }
  vector<bool> d(1e5 + 5, false);
  vector<int> ans;
  ans.pb(2);
  rep(i,1e5/2+2){
    d[i*2] = true;
  }
  for (int i = 3; i <= (int)(1e5 + 1); i += 2) {
    if (d[i] == false) {
      ans.pb(i);
    }
    else{
      continue;
    }
    for(int j = 1; j * i <= 1e5; j++) {
      d[i*j] = true;
    }
  }

  vector<int> ans2;

  for(auto val : ans){
    if(find(all(ans), (val + 1)/2) != ans.end()){
      ans2.pb(val);
    }
  }

  vector<int> ans3(1e5+5,0);

  for(auto val : ans2){
    ans3[val] ++;
  }

  rep(i, 1e5-1){
    ans3[i+1] = ans3[i]+ans3[i+1];
  }

  rep(i, Q) {
    cout << ans3[input[i].S] - ans3[input[i].F-1] << endl;
  }


}


Measured memory_bytes: 1920
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

def query(index):
    q = [item % (2*n) + 1 for item in range(index, index+n)]
    s_q = "? " + " ".join([str(item) for item in q])
    print(s_q, flush=True)
    ret = input().rstrip()
    return ret

n = int(input())
init_color = query(0)
l = 0; r = n
while r - l > 1:
    mid = (l + r) // 2
    ret = query(mid)
    if ret == init_color:
        l = mid
    else:
        r = mid

ans = [""] * (2*n)

# Check outside
equal_set = [item % (2 * n) for item in range(r, r+n-1)]
for i in range(r + n - 1, l + 1 + 2*n):
    index = i % (2*n)
    s_q = "? " + " ".join([str(item + 1) for item in equal_set + [index]])
    print(s_q, flush=True)
    ret = input().rstrip()
    ans[index] = ret[0]

# Check inside
equal_set = [item % (2 * n) for item in range(r+n, r+n+n-1)]
for i in range(r, r+n-1):
    index = i % (2*n)
    s_q = "? " + " ".join([str(item + 1) for item in equal_set + [index]])
    print(s_q, flush=True)
    ret = input().rstrip()
    ans[index] = ret[0]

print("! " + "".join([item for item in ans]), flush=True)

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

#define MAXN 200005

int mod1[MAXN], mod2[MAXN];

int num(int a){
    int res = 0;
    while(a){
        if(a&1) ++res;
        a >>= 1;
    }
    return res;
}

int main(void)
{
    int n; cin>>n;
    string s; cin>>s;
    int cnt = 0;
    for(int i=0;i<n;++i)
        if(s[i]=='1') ++cnt;
    int cnt1 = cnt-1, cnt2 = cnt+1;
    if(cnt1) mod1[n-1] = 1%cnt1;
    else mod1[n-1] = 0;
    mod2[n-1] = 1%cnt2;
    for(int i=n-2;i>=0;--i){
        if(cnt1) mod1[i] = mod1[i+1]*2 % cnt1;
        else mod1[i] = 0;
        mod2[i] = mod2[i+1]*2 % cnt2;
    }
    long long sum1 = 0, sum2 = 0;
    for(int i=0;i<n;++i){
        if(s[i]=='1'){
            sum1 += mod1[i]; //sum1 %= cnt1;
            sum2 += mod2[i]; //sum2 %= cnt2;
        }
    }
    for(int i=0;i<n;++i){
        int sum;
        if(s[i]=='1'){
            if(cnt1==0){
                cout<<0<<'\n';
                continue;
            }
            sum = (sum1 - mod1[i]) % cnt1;
        }
        else sum = (sum2 + mod2[i]) % cnt2;
        int ans = 1;
        while(sum){
            sum = sum % num(sum);
            ++ans;
        }
        cout<<ans<<'\n';
    }
    return 0;
}

Measured memory_bytes: 5296
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
using namespace std;
const int N=5005;
char s[N],t[N];
int q1[N],q2[N];
int n,ans;
void check(int p1,int p2){
	int S=0;
	For(i,1,p1-1) S+=q1[i];
	For(i,1,p2-1) S+=q2[i];
	for (;p1<=*q1&&p2<=*q2;++p1,++p2)
		S+=abs(q1[p1]-q2[p2]);
	For(i,p1,*q1) S+=n-q1[i];
	For(i,p2,*q2) S+=n-q2[i];
	ans=min(ans,S);
}
void getop(char *s,int *q,int *tp){
	For(i,0,n) if (s[i]!=s[i+1])
		q[++*q]=i,tp[i]=s[i]&1;
}
int main(){
	ans=1<<30;
	scanf("%d%s%s",&n,s+1,t+1);
	s[0]=97-s[1]; s[n+1]=97-s[n];
	t[0]=97-t[1]; t[n+1]=97-t[n];
	For(i,0,n) if (s[i]!=s[i+1]) q1[++*q1]=i;
	For(i,0,n) if (t[i]!=t[i+1]) q2[++*q2]=i;
	For(i,1,*q1) if (s[q1[i]]==t[q2[1]]) check(i,1);
	For(i,1,*q2) if (s[q1[1]]==t[q2[i]]) check(1,i);
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;

int main(){
    int n;
    cin >> n;
    long long a[n];
    long long ans=1;
    long long temp;

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

    if(ans==0){
        cout << 0 << endl;
        return 0;
    }

    long long A = pow(10,18);
    for(int i=0;i<n;i++){
        temp = ans;
        ans *= a[i];
        if(ans>A || ans<temp){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4420
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    ll m, rd, rr, cd, cr;
    cin >> m >> rd >> rr >> cd >> cr;
    ll x = (cd*100+rd-1)/rd;
    ll y = (cr*100+rr-1)/rr;
    m -= x+y;
    if(m >= 0)  cout << m << endl;
    else        cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3100
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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


// 長い文字列を読み込む時に使う //
var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
    buf := make([]byte, 0, 1000000)
    for {
        l, p, e := rdr.ReadLine()
        if e != nil {
            panic(e)
        }
        buf = append(buf, l...)
        if !p {
            break
        }
    }
    return string(buf)
}
/////////////////////////////


func main() {
	sc.Split(bufio.ScanWords)

	readLine()
	xs := readLine()

	dic := make(map[rune]int)

	for _, char := range xs {
		val, ok := dic[char]
		if !ok {
			val = 0
		}
		dic[char] = val + 1
	}
	prod := 1
	div := 1000000007
	for _, val := range dic {
		prod = (prod * (val + 1)) % div
	}
	fmt.Println(prod - 1)
}


Measured memory_bytes: 2816
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int H, W, h, w;
  cin>>H>>W>>h>>w;

  cout<<(H-h)*(W-w)<<endl;

  return 0;
}


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            price = 500 * i + 100 * j + 50 * k
            if price == x:
                ans += 1

print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

int main(){
	string s; cin>>s;
	vector<ll> N(s.sz);
	ll sum=0;
	rep(i,s.sz){
		N[i]=s[i]-'0';
		sum+=N[i];	
	}
	cout<<max(sum,(ll)(9*(s.sz-1)+N[0]-1));
}

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

int main() {
  int A , B;
  char op;
  cin >> A >> op >> B;
  if(op == '+'){
    cout << A + B << endl;
  }
   else if(op == '-'){
      cout << A - B << endl;
   }
    
    

  // ここにプログラムを追記
  
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{ 
  int A;
  int B;
  cin >> A >> B;
  if(B<=0&&(A-B)>=A*B){
    cout <<A-B;
  }else if(B>=0&&A*B<=(A+B)){
    cout <<A+B;
    }else{
      cout << A*B;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long  ll;
const ll inf = 1e18 + 10;
const ll N = 1e5 + 10;
ll n , x , y , z , pr , mx ;
vector<ll> v[N];
ll dp[N][3];
ll func(ll ind , ll pr)
{
    ll sum = 0;
    if(ind == n)    return 0;
    if(dp[ind][pr] != -1)   return dp[ind][pr];
    if(pr == 0)
    {
        sum += max(v[ind][1] + func(ind + 1 , 1) , v[ind][2] + func(ind + 1 , 2));
    }else if (pr == 1)
    {
        sum += max(v[ind][0] + func(ind + 1 , 0) , v[ind][2] + func(ind + 1 , 2));
    }else
    {
        sum += max(v[ind][0] + func(ind + 1 , 0) , v[ind][1] + func(ind + 1 , 1));
    }
    dp[ind][pr] = sum;
    return sum;
}
void solve()
{
    cin >> n;
    memset(dp , - 1 , sizeof dp);
    for(ll i = 0 ; i < n ; i ++)
    {
        cin >> x >> y >> z;
        //cout << x << " " << y << " " << z << endl;
        v[i].push_back(x);
        v[i].push_back(y);
        v[i].push_back(z);
    }
    for(ll i = 0 ; i < 3 ; i ++)
    {
        mx = max(mx , func(1 , i) + v[0][i]);
    }
    cout << mx << endl;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll t;
    t = 1;
    //cin >> t ;
    while(t --)
        solve();
    return 0;
}

Measured memory_bytes: 17640
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

typedef long long ll;

ll N;
vector<ll> v;

int main(){
    cin >> N;
    ll n;
    for(int i=0;i<N;i++){
        cin >> n;
        v.push_back(n);
    }
    N = v.size();
    sort(v.begin(),v.end());
    ll ans = 0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            ll l = v[i] + v[j];
            n = (lower_bound(v.begin(),v.end(),l) - v.begin()) - (j+1);
            ans += (ll)n;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
n,m = map(int, input().split())

l = [0] * m
r = [0] * m
for i in range(m):
    l[i], r[i], = map(int, input().split())

l_max = max(l)
r_min = min(r)

if l_max > r_min:
    print(0)
else:
    if n < l_max:
        print(0)
    elif n < r_min:
        print(r_min - n + 1)
    else:
        print(r_min - l_max + 1)



Measured memory_bytes: 10868
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let n: usize = sc.read();
    let k: u32 = sc.read();
    let mut p: Vec<i32> = sc.vec(n);

    p.sort();

    let mut res = 0;
    for (i, v) in p.iter().enumerate() {
        if i == k as usize {
            break;
        }
        res = res + v;
    }

    println!("{}", res);

}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2084
from itertools import permutations
import sys
input = sys.stdin.readline

N = int(input())
xy = []
for _ in range(N):
    x, y = map(int, input().split())
    xy.append((x, y))

avg = 0.0
count = 0
for perm in permutations(range(N)):
    count += 1
    # print(perm)
    cost =  0
    for i in range(N - 1):
        pi, pj = perm[i], perm[i + 1]
        dij = ((xy[pi][0] - xy[pj][0]) ** 2 + (xy[pi][1] - xy[pj][1]) ** 2) ** 0.5
        cost += dij
    avg += cost
print(avg / count)

Measured memory_bytes: 40812
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#if defined(DAIJOBU)
#include "/home/ichigo/includes.hpp"
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long lint;
typedef vector<lint> vlint;
typedef vector<vlint> vvlint;
typedef pair<lint, lint> plint;
typedef double ld;

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



int main() {
    ios::sync_with_stdio(false);
	cin.tie(0);
	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if((abs(a - b) <= d && abs(b - c) <= d) || abs(a - c) <= d)puts("Yes");
	else puts("No");
	return 0;
}



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

// int/long:		-2,147,483,648 - 2,147,483,648 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<29)
//536,870,912

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

/*
int	gcd(int A, int B) {
	while (0!=B) {
		A %=B;
		swap(A, B);
	}
	return A;
}
*/

#define	MOD 1000000007

int	main() {
	int N, M;
	cin >>N >>M;
	vector<int> A(N+1, 0);
	vector<bool> AC(N+1, false);
	for (int i=0; i<M; i++) {
		int p;
		string S;
		cin >>p >>S;
		if ("AC"==S)
			AC.at(p)=true;
		else {
			if (!AC.at(p)) {
				A.at(p)++;
			}
		}
	}
	int S=0;
	int WA=0;
	for (int i=1; i<=N; i++) {
		if (AC.at(i)) {
			S++;
			WA +=A.at(i);
		}
	}
	cout <<S <<' ' <<WA <<endl;
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);

int main(){
    int n;
    ll k;
    cin >> n >> k;
    map<int,ll> m;
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        m[a] += b;
    }
    ll cnt = 0;
    for(auto x:m){
        cnt += x.second;
        if(cnt >= k){
            cout << x.first << endl;
            return 0;
        }
    }
}

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

int selectionsort(int a[], int n)
{
	int sw = 0;
	
	for(int i=0; i<n; i++)
	{
		int minj = i;
		
		for(int j= i; j < n; j++)
		{
			if(a[j] < a[minj])
			{
				minj = j;
			}
		}
		
		if(i != minj)
		{
			int temp = a[i];
			a[i] = a[minj];
			a[minj] = temp;
			sw++;
		}
	}
	return sw;
}

int main()
{
	int n;
	int sw = 0;
	cin >> n;
	int a[n] = {0};
	for(int i=0; i<n; i++)cin >> a[i];
	
	sw = selectionsort(a,n);
	
	for(int i=0; i<n; i++)
	{
		if(i != 0)cout << " ";
		cout << a[i];
	}
	cout << endl;
	
	cout << sw << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  int a[N];
  for (int i=0;i<N;i++) cin >> a[i];
  sort(a,a+N);
  reverse(a,a+N);
  int count = 1;
  int radius = a[0];
  for (int i=1;i<N;i++) {
    if (radius > a[i]){
      count += 1;
      radius = a[i];
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 256
def main():
	n, x = map(int, input().split())
	a = list(map(int, input().split()))
	ans = 0
	for i in range(1, n):
		temp = x - a[i] - a[i-1]
		if temp < 0:
			ans += min(-1*temp, a[i])
			a[i] -= min(-1*temp, a[i])
		temp = x - a[i] - a[i-1]
		if temp < 0:
			ans += min(-1*temp, a[i-1])
			a[i-1] -= min(-1*temp, a[i-1])
	# print(a)
	print(ans)

main()

Measured memory_bytes: 14548
n = int(input())
x = []
y = []
for _ in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
ans = 0
for i in range(n):
    for j in range(n):
        ans += ((x[i]-x[j])**2 + (y[i]-y[j])**2)**0.5
print(ans/n)

Measured memory_bytes: 9400
import java.util.*;


public class Main {
    static Scanner s = new Scanner(System.in);
    static class Load implements Comparable<Load> {
        int D;
        int P;

        Load(int d, int p) {
            D = d;
            P = p;
        }
        public int compareTo(Load a){
            int Pa = a.P;
            int Pb = this.P;

            return Pa-Pb;
        }
    }

    public static void main(String[] args) {
        while (true) {
            int N = s.nextInt();
            int M = s.nextInt();
            if(N==0 && M==0) break;

            Load[] load = new Load[N];
            for(int i=0;i<N;i++){
                int d = s.nextInt();
                int p = s.nextInt();
                load[i] = new Load(d,p);
            }
            Arrays.sort(load);

            int totalP =0;
            for(int i=0;i<N;i++){
                if(M>=load[i].D){
                    M-=load[i].D;
                    continue;
                } else{
                    totalP+=(load[i].D-M)*load[i].P;
                    M=0;
                }
            }
            System.out.println(totalP);
        }
    }
}

Measured memory_bytes: 78024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
int a[105];
int main() {
    memset(a, 0, sizeof(a));
    int n; cin >> n;
    for(int i = 0; i < n; ++i){
        int x; cin >> x;
        if(i == 0){
            a[i] = x;
            continue;
        }
        a[i] = x + a[i - 1];
    }
    vector<int> m;
    int r = a[n - 1];
    for(int i = 0; i < n; ++ i){
        int y = abs(a[i] - (r - a[i]));
        m.push_back(y);
    }
    sort(m.begin(), m.end());
    cout << m[0] << endl;
	return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

res = 0
while a % 2 == 0 and b % 2 == 0 and c % 2 == 0:
	if a == b and b == c:
		print('-1')
		exit()
	a, b, c = (b + c) // 2, (c + a) // 2, (a + b) // 2 
	res += 1

print(res)

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

#define ll long long int
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define all(A) A.begin(), A.end()
#define sz(A) (int)A.size()
typedef vector <int> vi;
typedef vector <ll> vl;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tii;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;
const int inf = 1e9;
//const ll inf = 1e18;
const int N = 1e6;
int cnt[N + 1], cp[N + 1];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	int a[n];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
	}
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		if (cnt[i] > 0) {
			for (int j = 2; j <= N / i; j++) {
				cp[i * j]++;
			}
		}
	}
	for (int i = 0; i < n; i++) {
		if (cnt[a[i]] == 1 && cp[a[i]] == 0) {
			ans++;
		}
	}
	cout << ans << "\n";
 	return 0;
}

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

int main() {
  char c;
  cin >> c;
  
  if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u'){
    cout << "vowel" << endl;
  }else{
    cout << "consonant" << endl;
  }


}


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

#define rep(i,l,r) for(int i=(l);i<(r);i++)
#define pb push_back
#define fi first
#define se second

using ll = long long;
using G = vector<vector<int>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const ll MOD = 1000000007;

ll GCD(ll x, ll y){
	return y ? GCD(y, x%y) : x;	
}

int main() {
	ll n, k; cin >> n >> k;
	map<ll, ll> m;
	rep(i, 0, n){
		ll a, b; cin >> a >> b;
		m[a] += b;
	}
	ll cnt = 0;
	ll ans = 0;
	for(auto kv: m){
		cnt += kv.se;
		if(cnt>=k){
			ans = kv.fi;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 7540
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let x: i32 = input();
    let a: i32 = input();
    println!("{}", if x < a { 0 } else { 10 });
}


Measured memory_bytes: 4352
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	li n;
	cin>>n;
	li res=1;
	repp(i,1,n+1)res*=i;
	cout<<res<<endl;
	
	return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
#define max(a,b) ((a)>(b) ? (a):(b))
int dp[101][20000];
int main(void){
    int n,w;
    int V[101],W[101];
    int i,j;

    scanf("%d%d",&n,&w);
    for(i=1;i<=n;i++){
	scanf("%d%d",&V[i],&W[i]);
    }

    for(i=1;i<=n;i++){
	for(j=0;j<=w;j++){
	    dp[i][j]=max(dp[i][j],dp[i-1][j]);
	    dp[i][j+W[i]]=max(dp[i-1][j]+V[i],dp[i-1][j+W[i]]);
//	    printf("dp[%d][%d]=%d\n",i,j+W[i],dp[i][j+W[i]]);
	}
    }

    printf("%d\n",dp[n][w]);
//   printf("dp[3][3]=%d\n",dp[3][3]);

    return 0;
}

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

//int nail[5004][5004]={};

int main(){
	int N,M;
	cin >> N >> M;
	vector<int> nail[N+5];
	for(int i=0; i<N+5; ++i) nail[i].resize(i+5);
	for(int i=0; i<M; ++i){
		int a,b,x;
		cin >> a >> b >> x;
		++a;
		++b;
		--nail[a+x-1][b-1];
		++nail[a+x][b];
		--nail[a+x][b+x+1];
		++nail[a+x-1][b+x+1];
		++nail[a-2][b-1]; 
		--nail[a-2][b]; 
	}
	for(int x=N+2; x>=0; --x ){
		for(int y=nail[x].size()-1; y>=0; --y){
			nail[x][y]+=nail[x+1][y+1];
		}
	}
	for(int x=N+2; x>=0; --x){
		for(int y=0; y<=nail[x].size()-1; ++y){
			nail[x][y]+=nail[x+1][y];
		}
	}
	long long int ans=0;
	for(int x=0; x<=N+2; ++x){
		for(int y=1; y<=nail[x].size()-1; ++y){
			nail[x][y]+=nail[x][y-1];
			if(nail[x][y]>=1) ++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 50384
#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; }
 
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
using Graph = vector<vector<int>>;

int main(){
    ll N,C; cin>>N>>C;
    vector<vector<int>> imos(31,vector<int>(100010,0));
    rep(i,N){
        ll s,t,c; cin>>s>>t>>c;
        imos[c][s]++;
        imos[c][t]--;
    }
    rep1(i,C){
        rep1(t,100001)imos[i][t] += imos[i][t-1];
    }
    vector<int> dp(100010,0);
    rep1(i,C){
        rep1(t,100001){
            if(imos[i][t-1]==0&&imos[i][t]==1)dp[t-1]++;
            if(imos[i][t-1]==1&&imos[i][t]==0)dp[t]--;
        }
    }
    int res = 0;
    rep1(t,100001)dp[t] += dp[t-1], res = max(res,dp[t]);
    cout<<res<<endl;
}

Measured memory_bytes: 15892