akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

//#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL N,K; cin>>N>>K;
    if(K == 0)
    {
        cout << N*N << endl;
        return 0;
    }


    LL ans = 0;
    for(int b = K+1; b <= N; b++)
    {
        dump(b)
        LL tmp = (N / b) * (b-K) + max((N%b-K+1),0LL);
        dump(tmp)
        dump(N/b*(b-K))
        ans += tmp;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int a,b,x=0;
    cin>>a>>b;
    for(int i=1; i<=b-a; i++)
    {
        x+=i;
    }
    cout<<x-b<<endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll n,k;cin>>n>>k;

    cout<<min(n%k,k-n%k)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MAX 1000000007
#define ll long long 
ll power(ll x, ll y) 
{ 
    ll res = 1;      // Initialize result 
  
    x = x % MAX;  // Update x if it is more than or  
                // equal to p 
  
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % MAX; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % MAX;   
    } 
    return res; 
} 
ll finv(ll n){
  return(power(n,MAX-2));
}
long long int ncr(long long int A,long long int B){
 	if(B==0) return(1);
  	long long int fac[A+1];
  	fac[0]=fac[1]=1;
  	for(long long int i=2;i<=A;i++){
      fac[i]=(i*fac[i-1])%MAX;
       
    }
  	return (fac[A]* finv(fac[B]) % MAX *finv(fac[A-B]) % MAX) % MAX; 
}
int main(){
  long long int x,y;
  cin>>x>>y;
  long long int A=(2*y-x)/3,B=(2*x-y)/3;
  if((2*y-x)%3!=0 || (2*x-y)%3!=0) cout<<0;
  else if(A<0 || B<0) cout<<0;
  else cout<<ncr(A+B,A);
}

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

int main() {
    int s, n=0;
    scanf("%d",&s);
    for (int i=100; i >= 1; i /= 10) {
        if (s / i == 1) {
            n += 1;
        }
        s = s%i;
    }
    cout << n << "\n";
}

Measured memory_bytes: 256
n = gets.to_i
count = 0
n.times do |i|
  x,y = gets.split(' ').map(&:to_i)
  if x == y then
    count += 1
  else
    count = 0
  end

  if count == 3
    puts 'Yes'
    exit
  end
end

puts 'No'


Measured memory_bytes: 14360
#include <stdio.h>

int H[2000005],n=0;

void max(int x)
{
    int l,r,largest,d;
    l=2*x;
    r=l+1;

    if( l <= n && H[l] > H[x] ) 
        largest = l;
    else
        largest = x;
    if( r <= n && H[r] > H[largest] )
        largest = r;
   
    if( largest != x ) {
        d=H[largest];
        H[largest]=H[x];
        H[x]=d;
        max(largest);   
    }
}

int extract(void)
{
    int m;
    m=H[1];
    H[1]=H[n];
    n--;
    max(1);

    return m;
}

void increse(int x,int key)
{
    int d;
    if (key<H[x])
        return;
    H[x]=key;
    while(x>1&&H[x]>H[x/2])
    {
        d=H[x];
        H[x]=H[x/2];
        H[x/2]=d;
        x= x/2;
    }
}

void insert(int key)
{
    n++;
    H[n]=-2000005;
    increse(n,key);
}

int main()
{
    int key;
    char comand[10];

    while(1)
    {
        scanf("%s",comand);

        if (comand[0]=='e'&&comand[1]=='n') break;
        else if (comand[0]=='i')
        {
            scanf("%d",&key);
            insert(key);
        }
        else
        {
            printf("%d\n",extract());
        }

    }

    return 0;
}  


Measured memory_bytes: 5600
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
#define rep(i, n)for(int i=0; i<n; i++)

int main(){
  int X, N;
  cin >> X >> N;
  int p[N];
  rep(i, N)
    cin >> p[i];
  //

  sort(p, p+N);

  int l = 0;
  int r = 0;

  while(1){
    if(binary_search(p, p+N, X-l) == 0){
      cout << X-l << endl;
      return 0;
    }
    l++;
    if(binary_search(p, p+N, X+r) == 0){
      cout << X+r << endl;
      return 0;
    }
    r++;
  }
    

  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>

int main(){
  	int S[4];
  	int a, b = 0;
  	for(int i = 0; i < 4; i++){
    	scanf("%1d",&S[i]);
      	//printf("%d\n",S[i] );
    }
  
  	a = S[0] * 10 + S[1];
  	b = S[2] * 10 + S[3];
  	//printf("%d, %d\n",a, b );
  	if(  (1 <= a && a <= 12) && (1 <= b && b <= 12)){
    	printf("AMBIGUOUS\n");
    }else if(a > 12 &&  b > 12){
    	printf("NA\n");
    }else if(1 <= a && a <= 12){
      	printf("MMYY\n");
    }else if(1 <= b && b <= 12){
    	printf("YYMM\n");
    }else if((a == 0 && b > 12) || (b == 0 && a > 12)){
    	printf("NA\n");
    }else if(a == 0 && b == 0){
    	printf("NA\n");
    }
	return 0;
}

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

const int64_t mod = 1000000007;
vector<int64_t> fact, inv;

int64_t power(int64_t n, int64_t k) {
  if (k == 0) return 1;
  int64_t half = power(n, k / 2), ans = half * half % mod;
  if (k % 2) ans = ans * n % mod;
  return ans;
}

void init(int64_t n) {
  fact.push_back(1);
  inv.push_back(1);
  for (int64_t i = 1; i <= n; i++) {
    fact.push_back(i * fact.at(i - 1) % mod);
    inv.push_back(power(fact.at(i), mod - 2));
  }
}

int64_t comb(int64_t n, int64_t r) {
  if (n < 0 || r < 0 || n - r < 0) return 0;
  return fact.at(n) * inv.at(r) % mod * inv.at(n - r) % mod;
}

int main() {
  int64_t n, k;
  cin >> n >> k;
  vector<int64_t> a(n);
  for (int64_t i = 0; i < n; i++) cin >> a.at(i);
  sort(a.begin(), a.end());
  init(n);
  int64_t smax = 0, smin = 0;
  for (int64_t i = 0; i < n; i++) {
    smax += a.at(i) * comb(i, k - 1) % mod;
    smax %= mod;
    smin += a.at(i) * comb(n - 1 - i, k - 1) % mod;
    smin %= mod;
  }
  cout << (smax - smin + mod) % mod << endl;
}


Measured memory_bytes: 2804
N,*B = map(int, open(0).read().split())
ans = [0]*N
for i in range(N):
  for j in range(len(B)-1,-1,-1):
    if B[j]==j+1:
      ans[N-1-i] = j+1
      B = B[:j]+B[j+1:]
      break
if B==[]:
  print('\n'.join(map(str,ans)))
else:
  print(-1)

Measured memory_bytes: 38512
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

const int MAX = 1e5 + 10;
LL N, K;
map<int, LL> mp;

int main(void) {
    scanf("%lld%lld", &N, &K);
    REP(i, N) {
        int a, b;
        scanf("%d%d", &a, &b);
        mp[a] += b;
    }
    LL now = 0;
    FORE(e, mp) {
        if (now + e.second >= K) {
            cout << e.first << endl;
            return 0;
        } else {
            now += e.second;
        }
    }
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long ll;
typedef long double ld;
const long double pi = 3.14159265358979323846264338327950288;
int main() {
	ll n, t, s = 0, sum = 0, r = 0;
	cin >> n >> t;
	for (ll i = 0; i < n; i++) {
		cin >> s;
		if (r < s) {
			sum += t;
		}
		else {
			sum -= (r - s);
			sum += t;
		}
		r = s + t;
	}
	cout << sum << endl;
	cin >> n;
}

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

using namespace std;
int main(void){
    long long q,h,s,d;
    cin >> q >> h >> s >> d;
    long long n;
    cin >> n;
    
    long long ans = min(q * 8,min(4 * h,min(s * 2,d))) * (n / 2);
    ans += (n % 2 == 1) ? min(q * 4,min(h * 2,s)) : 0;
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3572
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(long[]);

    auto DP = new long[][](N+5, 3);
    foreach (ref dp; DP) dp[] = long.min/3;
    DP[0][0] = 0;
    foreach (i; 0..N) {
        foreach (j; 0..3) {
            DP[i+2][j] = max(DP[i+2][j], DP[i][j] + AS[i]);
            if (j < 2) DP[i+1][j+1] = max(DP[i+1][j+1], DP[i][j]);
        }
    }
    if (N%2 == 0) {
        writeln(max(DP[N-2][0] + AS[N-2], DP[N-1][1] + AS[N-1]));
    } else {
        writeln(max(DP[N-1][2] + AS[N-1], DP[N-2][1] + AS[N-2], DP[N-3][0] + AS[N-3]));
    }
}

Measured memory_bytes: 21288
#include<bits/stdc++.h>
using namespace std;
string s,t;
bool use[30];
set<string>st;
int main()
{
	ios::sync_with_stdio(false);
	cin>>s;
	if(s=="zyxwvutsrqponmlkjihgfedcba")
	{
		cout<<-1;
		return 0;
	}
	if(s.size()==26)
	{
		string ans="zz";
		for(int i=0;i<26;i++)
		{
			for(int j=i+1;j<26;j++)
			{
				if(s[i]<s[j])
				{
					string t=s;
					swap(t[i],t[j]);
					t.erase(i+1,t.size()-i-1);
					ans=min(ans,t);
				}
			}
		}
		cout<<ans<<endl;
	}
	else
	{
		for(int i=0;i<s.size();i++)use[s[i]-'a']=1;
		for(int i=0;i<26;i++)
		{
			if(!use[i])
			{
				cout<<s<<char(i+'a')<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
class UnionFind {
private:
    int sz;
    vector<int> par, size_;
public:
    UnionFind(){}
    UnionFind(int node_size) : sz(node_size), par(sz), size_(sz, 1){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(par[x] == x) return x;
        else return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(size_[x] < size_[y]) swap(x,y);
        par[y] = x;
        size_[x] += size_[y];
    }
    int size(int x){
        x = find(x);
        return size_[x];
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    if(m == n - 1){
        cout << 0 << endl;
        return 0;
    }
    if(n / 2 < n - m - 1){
        cout << "Impossible" << endl;
        return 0;
    }
    rep(i,m){
        int c, d;
        cin >> c >> d;
        uf.unite(c, d);
    }
    vector<vector<int>> g(n);
    rep(i,n){
        g[uf.find(i)].push_back(a[i]);
    }
    ll ans = 0;
    vector<int>b;
    rep(i,n){
        if(g[i].size()){
            sort(g[i].begin(), g[i].end());
            ans += g[i][0];
            for(int j = 1; j < g[i].size(); j++){
                b.push_back(g[i][j]);
            }
        }
    }
    sort(b.begin(), b.end());
    rep(i,n-m-2){
        ans += b[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define ll long long

using namespace std;



int main()
{ 
int n;
  cin>>n;
  ll a[n],pref[n];
  for(int i=0;i<n;i++) cin>>a[i];
  pref[n-1]=a[n-1];
  for(int i=n-2;i>=0;i--)
    pref[i]=a[i]+pref[i+1];
  
  ll ans=0;
  for(int i=0;i<n-1;i++)
  {    ans=(ans+(a[i]%1000000007)*(pref[i+1]%1000000007)%1000000007)%1000000007;
  }
  cout<<ans;
 
 
}

Measured memory_bytes: 6680
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int line = in.nextInt();
		int line_column = in.nextInt();
		int column = in.nextInt();

		int[][] matrixA = new int[line][line_column];
		int[][] matrixB = new int[line_column][column];

		for(int l = 0; l < line; l++){

			for(int l_c = 0; l_c < line_column; l_c++){

				matrixA[l][l_c] = in.nextInt();

			}
		}

		for(int l_c = 0; l_c < line_column; l_c++){

			for(int c = 0; c < column; c++){

				matrixB[l_c][c] = in.nextInt();

			}
		}

		long[][] ans = new long[line][column];

		for(int l = 0; l < line; l++){

			for(int l_c = 0; l_c < line_column; l_c++){

				for(int c = 0; c < column; c++){

					ans[l][c] += matrixA[l][l_c] * matrixB[l_c][c];

				}
			}
		}

		for(int l = 0; l < line; l++){

			for(int c = 0; c < column - 1; c++){

				System.out.print(ans[l][c] + " ");

			}

			System.out.println(ans[l][column - 1]);

		}
	}
}

Measured memory_bytes: 52448
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 area = a*b;
        int length = a+a+b+b;
        System.out.println(area + " "+ length);
        sc.close();
    }
}


Measured memory_bytes: 25972
#include<stdio.h>
#include<stdlib.h>

int cnt1 = 0, cnt2 = 0;
void make_seq(int flag[], int num[], int seq1[], int seq2[], int n, int k){
    int f, judge = 1;
    for(int i = 0; i < n; i++){
        f = flag[i];
        if(f == 0){
            flag[i] = 1;
            num[n - k] = i + 1;
            if(k == 1){
                cnt2 ++;
                for(int j = n - 1; j >= 0; j--){
                    if(seq1[j] != num[j]){
                        judge = 0;
                        break;
                    }
                }
                if(judge == 0){
                    judge = 1;
                    for(int j = n - 1; j >= 0; j--){
                        if(seq2[j] != num[j]){
                            judge = 0;
                            break;
                        }
                    }
                }
                if(judge == 1){
                    if(cnt1 == 0){
                        cnt1 = cnt2;
                    }else{
                        printf("%d\n", abs(cnt1 - cnt2));
                        exit(0);
                    }
                }
            }else{
                make_seq(flag, num, seq1, seq2, n, k - 1);
            }
            flag[i] = 0;
        }
    }
}

void set_seq(int seq[], int n){
    for(int i = 0; i < n; i++){
        scanf("%d", &seq[i]);
    }
}

int main(void){
    int i, n, judge = 1;
    scanf("%d", &n);
    int flag[n], num[n], seq1[n], seq2[n];
    set_seq(seq1, n);
    set_seq(seq2, n);

    for(int i = 0; i < n; i++){
        num[i] = flag[i] = 0;
    }

    for(int i = 0; i < n; i++){
        if(seq1[i] != seq2[i]){
            judge = 0;
            break;
        }
    }
    if(judge){
        printf("%d\n", 0);
    }
    make_seq(flag, num, seq1, seq2, n, n);
    return 0;

}

Measured memory_bytes: 128
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main(void){
    double r;
    cin >>r;
    printf("%.4Lf\n",r*2*PI);
    return 0;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
using namespace std;
int dp[100001];

int solve(vector<int>&height,int n,int start,int k)
{
	if(start>=n)
	{
		return 0;
	}
	if(dp[start]!=-1)
	return dp[start];
		int res=INT_MAX;
	for(long i=1;i<=k;i++)
	{
	
		if(start+i<=n)
		{
			res=min(abs(height[start+i]-height[start])+solve(height,n,start+i,k),res);
		}
		else
		break;
	 
	}
	return dp[start]=res;
	

}
int main()
{

	memset(dp,-1,sizeof(dp));
	long n,k;
	cin>>n>>k;
	vector<int> height(n+1);
	height[0]=0;
	for(long i=1;i<=n;i++)
	{
		cin>>height[i];
	 } 
	 int start=1;
	cout<<solve(height,n,start,k)<<endl;
		
}

Measured memory_bytes: 14892
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;
use std::ops::Bound::*;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut points = vec![];
    for i in 0..n {
        let v = read_vec::<i64>();
        points.push((v[0], v[1]));
    }

    let plus_max = points.iter().map(|&(x, y)| x + y).max().unwrap();
    let plus_min = points.iter().map(|&(x, y)| x + y).min().unwrap();
    let minus_max = points.iter().map(|&(x, y)| x - y).max().unwrap();
    let minus_min = points.iter().map(|&(x, y)| x - y).min().unwrap();
    let ans = max(plus_max - plus_min, minus_max - minus_min);
    println!("{}", ans);
}

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

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


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

const int LEN = 100000;

class pp {
public:
	char name[100];
	int t;
};

pp Q[LEN];
int head, tail, n;

void enqueue(pp x) {
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

pp dequeue() {
	pp x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int min(int a, int b) {
	return (a < b) ? a : b;
}

int main() {
	int elaps = 0, c;
	int q;
	pp u;
	
	cin >> n >> q;
	
	for(int i = 1; i <= n; i++) {
		cin >> Q[i].name;
		cin >> Q[i].t;
	}

	head = 1; tail = n + 1;

	while(head != tail) {
		u = dequeue();
		c = min(q, u.t);
		u.t -= c;
		elaps += c;
		if(u.t > 0) {
			enqueue(u);
		} else {
			cout << u.name << " " << elaps << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 13276
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;
const int INF = 1e9;
#define ll long long

class TaskA {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int a;
		cin >> a;
		cout << a + a*a + a*a*a << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};

int main(){
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
int mbk(long long a,int n,int m){return n?(mbk((a*a)%m,n/2,m)*(n%2?a:1))%m:1;}
//mを法としたaの逆元!
int inv(int a,int m){return mbk((long long)a,m-2,m);}
//mを法としたaCb!
long long D[100010]={1};
int aCb(int a,int b,int m){return a<b?0:D[a]*inv(D[b],m)%m*inv(D[a-b],m)%m;}
/*int aCb(int a,int b,int m){
  long long s=1,i;
  if(a<b)return 0;
  if(b>a-b)b=a-b;
  for(i=0;i<b;i++)s=(((s*(a-i))%m)*inv(i+1,m))%m;  
  return (int)s;
  }//*/
int main(){
  int n,M=1e9+7,d[100010],w,a,i,j,c[100010]={};
  for(i=1;i<=100005;i++)D[i]=(D[i-1]*i)%M;
  //for(i=0;i<100;i++)printf("%lld\n",D[i]);
  scanf("%d",&n);
  for(i=0;i<=n;i++){
    scanf("%d",&d[i]);
    if(c[d[i]])w=d[i];
    c[d[i]]++;
  }
  for(i=0  ;d[i]-w;i++);
  for(j=i+1;d[j]-w;j++);
  a=n-(j-i);
  for(i=1;i<=n;i++)printf("%d\n",(aCb(n+1,i,M)-aCb(a,i-1,M)+M)%M);
  printf("1\n");
  return 0;
}
    


Measured memory_bytes: 2688
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;

#[derive(Clone, Debug, Default)]
struct Struct;


fn gcd( a:usize, b:usize ) -> usize {
    if a < b {
        gcd(b,a)
    } else {
        let k = a/b;
        if a - k*b == 0 {
            b
        } else {
            gcd( b, a-k*b)
        }
    }
}


//#[proconio::fastout]
fn main() {
    input! {
        k:usize,
    }

    let mut ans = 0;
    for a in 1..=k {
        for b in 1..=k {
            let ab = gcd(a,b);
            for c in 1..=k {
                ans += gcd(ab,c);
            }
        }
    }

    println!("{}", ans);
}


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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

LL a[110];

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n;
    cin >> n;

    LL S = 0;
    for(LL i = 1; i <= n; i++)
        cin >> a[i], S += a[i];

    LL m;
    cin >> m;

    for(LL i = 1; i <= m; i++){
        LL p, x;

        cin >> p >> x;

        cout << S - a[p] + x << '\n';
    }
    return 0;
}




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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;


int main() {
    int a, n, m, c, cnt = 0, ans = 0;
    cin >> n >> m >> c;
    vector<int>b(m);
    rep(i, m)cin >> b[i];
    rep(i, n) {
        cnt = c;
        rep(j, m) {
            cin >> a;
            cnt += a * b[j];
        }
        if (cnt > 0)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <array>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
using namespace std;


typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(v) (v).rbegin(),(v).rend()
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define PB push


#define MOD 1000000007LL
#define EPS 1e-10

int dr[] = {0, 0, 1, -1};
int dc[] = {1, -1, 0, 0};

int main()
{
    int N;
    string S;
    cin >> N >> S;
    int E[N];
    int W[N];
    REP(i, N)
    {
        E[i] = ((i > 0) ? E[i - 1] : 0) + ((S[i] == 'E') ? 1 : 0);
        W[i] = ((i > 0) ? W[i - 1] : 0) + ((S[i] == 'W') ? 1 : 0);
    }
    int ans = 1000000000;
    REP(i, N)
    {
        int num = ((i > 0) ? W[i - 1] : 0) + ((i < N - 1) ? E[N - 1] - E[i] : 0);
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2948
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;

ll gcd(ll a, ll b) {
	if (a == 0 || b == 0)return 0;
	if (a%b == 0)return b;
	gcd(b, a%b);
}



int main() {
	ll n, k;
	cin >> n >> k;

	ll ans = 0;
	ans += (n / k)*(n / k)*(n / k);

	if (k % 2 == 0 && k / 2 <= n) {
		ans += ((n - k / 2) / k + 1)*((n - k / 2) / k + 1)*((n - k / 2) / k + 1);
	}


	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define LINF 1000000000000000000
#define MOD 1000000007
#define mod 1000007
#define INF63 1061109567
#define INF127 9187201950435737471
#define F first
#define S second
#define ll long long
using namespace std;
ll n,k,ans=0;
vector<ll> h;
int main(){
	ll i,x;
	cin>>n>>k;
	for(i=0;i<n;i++)
	{
		cin>>x;
		h.push_back(x);
	}
	sort(h.begin(),h.end());
	reverse(h.begin(),h.end());
	for(i=min(k,n);i<n;i++)
	{
		ans+=h[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 2420
N = int(input())
X = list(map(int, input().split()))
Y = X.copy()
Y.sort()
for i in range(len(Y)):
	if X[i] < Y[int(N / 2)]:
		print(Y[int(N / 2)] )
	else:
		print(Y[int(N / 2) - 1])

Measured memory_bytes: 25224
N = int(input())
AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(1,N+1):
  S = input()
  if S == "AC":
    AC += 1
  elif S == "WA":
    WA += 1
  elif S == "TLE":
    TLE += 1
  else:
    RE += 1
print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 9068
#include <iostream>
#include <stdio.h>
#include <algorithm>
using namespace std;

const int M=105;
char s[M];

int main()
{
	int n; 
	scanf("%d%s",&n,s);
	int l=0,r=n/2;
	int f=1;
	for(;l<n/2;l++,r++)
		if(s[l]!=s[r])
		{
			f=0;
			break;
		}
	if((n&1)||!f)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int H,W,i,j;
    while(1){
        cin >> H >> W ;
        if(H==0 && W==0) break;
        else{
            for(i=0;i<H;i++){
                for(j=0;j<W;j++){
                    if(i==0 || j==0 || i==H-1 || j==W-1) cout <<"#";
                    else cout <<".";
                }
                cout <<endl;
            }
        }
        cout <<endl;
    }
}



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

int main(void){
    int a,b,c,x,y,costA,costB,costAB,buyA,buyB;
    cin >> a >> b >> c >> x >> y;

    if(a + b < 2 * c){
        costA = a * x;
        costB = b * y;
        cout << costA + costB << endl;
    }else{
        if(x < y){
            costA = 2 * c * x;
            costB = (y - x) * b;
            costAB = 2 * c * y;
            cout << min(costA+costB,costAB) << endl;
        }else{
            costB = 2 * c * y;
            costA = (x - y) * a;
            costAB = 2 * c * x;
            cout << min(costA+costB,costAB) << endl;
            }
        }


    return 0;
}

Measured memory_bytes: 256
import Control.Monad
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as B

main=do
    n<-readLn
    print=<<sum.take n.unfoldr f.sortBy(flip compare).unfoldr(B.readInt.B.dropWhile(==' '))<$>B.getLine
f (a:b:r) = Just(b,r)

Measured memory_bytes: 51580
#strange bank
n=int(input())
dp=[10**10 for i in range(200000)]
dp[0]=0
for i in range(1,100001):
    for j in range(9):
        num=3**j
        if i>=6**j and dp[i-6**j]+1<dp[i]:
            dp[i]=dp[i-6**j]+1
        if i>=9**j and dp[i-9**j]+1<dp[i]:
            dp[i]=dp[i-9**j]+1
print(dp[n])

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

class Main {

	void solve() {

		int[] a = inintar(3);
		Arrays.sort(a);
		out.println(a[2]*10 + a[1] + a[0]);
		
	}
	
	public static Scanner in = new Scanner(System.in);
	public static PrintWriter out = new PrintWriter(System.out);
	
	public static void main(String[] args) {
		new Main().solve();
		out.flush();
	}
	
	public int inint() {
		return in.nextInt();
	}
	
	public String instr() {
		return in.next();
	}

	public int[] inintar(int num) {
		int[] a = new int[num];
		for (int i=0; i<num; i++) {
			a[i] = in.nextInt();
		}
		return a;
	}
	
	public char[] incharar() {
		return in.next().toCharArray();
	}
	
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
using namespace std;
typedef long long ll;

int main(){
int a,b;cin>>a>>b;
if(a%b==0)cout<<a/b;
else cout<<a/b+1;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    l = {}
    o = list(map(int, input().split()))
    if o[0] != 0:
        print(0)
        exit()
    for i in o:
        if i in l:
            l[i] += 1
        else:
            l[i] = 1
    
    count = 1
    m = max(l)
    if 0 not in l:
        print(0)
        exit()
    if l[0] >= 2:
        print(0)
        exit()
    
    for i in range(1,m+1):
        if i in l:
            count *= l[i-1] ** l[i] % 998244353
        else:
            print(0)
            exit()
    
    print(count%998244353)


if __name__ == '__main__':
    main()

Measured memory_bytes: 19552
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define FOR(i) for(cin>>i;i>0;i--)
#define elif else if
#define pb push_back
#define ll long long
#define mp make_pair
#define all(x) x.begin(),x.end()
#define re(x) {cout<<x<<endl;return 0;}
//#define x first
//#define y second

using namespace std;
int n,k,d,e,ans=0;
bool ok[105]={0};
int main()
{
	cin>>n>>k;
	rep(i,k)
	{
		cin>>d;
		rep(i,d)
		{
			cin>>e;
			ok[e]=1;
		}
	}
	rep2(i,1,1+n)
	if(!ok[i]) ans++;
	re(ans)
	return 0;}

Measured memory_bytes: 3636
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int mod = 1e+9 + 7;

//マクロ
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n)
  {
    cin >> a[i];
  }

  ll ans = 0;
  // 桁を全部試す
  // AiとAjのk桁目を試す
  // ２進数で表した時の桁ごとの総和
  // 1から60桁目までのk桁目までについて、0の個数*1の個数*2^k
  rep(i, 60)
  {
    // i桁目が1である個数をx
    ll x = 0;
    rep(j, n) if (a[j] >> i & 1) x++;
    ll y = n - x;
    ll now = x * y % mod;
    // x*y*2^k
    rep(j, i) now = now * 2 % mod;
    ans += now;
    ans %= mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());
    int A=0,b=0;
    
    for(int i=0;i<n;i++){
        if(i%2==0)A+=a[i];
        else b+=a[i];
    }
    cout << A -b << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
#define lb lower_bound
#define pb push_back
#define all(v) v.begin(),v.end()
#define fio ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
using ll = long long;
using lf = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
const ll mod = 1e9 + 7;

int n;
ll k;

inline void add(ll &x, ll y){
    x = (x + y) % mod;
}

struct mat{
    ll a[50][50];
    mat operator* (mat x){
        mat c;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                c.a[i][j] = 0;
                for(int k = 0; k < n; k++){
                    add(c.a[i][j], a[i][k] * x.a[k][j] % mod);
                }
            }
        }
        return c;
    }
    void show(string S = "Mat"){
        cout << S << '\n';
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++) cout << a[i][j] << ' ';
            cout << '\n';
        }
    }
};
mat A, T;
int main(){
    fio;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        T.a[i][i] = 1;
        for(int j = 0; j < n; j++){
            cin >> A.a[i][j];
        }
    }
    for(;k;k>>=1){
        if(k & 1) T = T * A;
        A = A * A;
        //T.show("T"); A.show("A");
    }
    ll ans = 0;
    for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) add(ans, T.a[i][j]);
    //T.show();
    cout << ans << '\n';
}


Measured memory_bytes: 384
n=int(input())
town=[]
for i in range(n):
  x,y=map(int,input().split())
  town.append([x,y,i])

  
X=sorted(town,key=lambda x:x[0])

Y=sorted(town,key=lambda x:x[1])
es=[]
for i in range(1,n):
  es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i][2],X[i-1][2]))
  es.append((min(abs(X[i][0]-X[i-1][0]),abs(X[i][1]-X[i-1][1])),X[i-1][2],X[i][2]))
  es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i][2],Y[i-1][2]))
  es.append((min(abs(Y[i][0]-Y[i-1][0]),abs(Y[i][1]-Y[i-1][1])),Y[i-1][2],Y[i][2]))
es.sort(key=lambda x:x[0])


#Union-Find木
#par[i]:iの親　deep[i]:iの深さ　size[i]:iの大きさ
par=[i for i in range(n)]
deep=[1]*n
size=[1]*n

#親を見つける
def find(x):
  if par[x]==x:
    return x
  else:
    return find(par[x])

#二つのグループを統合する
def unite(x,y):
  x=find(x)
  y=find(y)
  if x==y:
    return
  if deep[x]<deep[y]:
    par[x]=y
    size[y]+=size[x]
  else:
    par[y]=x
    size[x]+=size[y]
    if deep[x]==deep[y]:
      deep[x]+=1

#xとyが同じグループに属するかどうか
def same(x,y):
  return find(x)==find(y)

#xが属するグループの要素数を返す
def group_count(x):
  return size[find(x)]
  
#クラスカル法
#esは重みで小さい順にsort済み
#es[i]:[重み、始点、終点]
def kruskal(n,es):
  ans=0
  for to in es:
    if not same(to[1],to[2]):
      ans+=to[0]
      unite(to[1],to[2])
  return ans

      
  
print(kruskal(n,es))


Measured memory_bytes: 175416
import java.util.*

data class Data(val s: String, val p: Int, val i: Int) : Comparable<Data> {
    override fun compareTo(other: Data): Int {
        val r = s.compareTo(other.s)
        if (r != 0) return r
        return other.p - p
    }
}

fun main(args: Array<String?>) {
    val scanner = Scanner(System.`in`)

    val n = scanner.nextInt()
    val array = ArrayList<Data>(n)
    for (i in 1..n) {
        val s = scanner.next()
        val p = scanner.nextInt()
        array.add(Data(s, p, i))
    }
    array.sort()
    array.forEach {
        println(it.i)
    }
}


Measured memory_bytes: 31380
input()
nums = input().split(" ")
# print(nums)
sett = set(nums)
dicto = {}
for a in range(len(sett)):
    dicto[str(sett.pop())] = 0
for a in nums:
    dicto[a] += 1
# print(dicto)
ans = 0
for k,v in dicto.items():
    k = int(k)
    if v>k:
        ans += v-k
    elif v<k:
        ans += v
print(ans)

Measured memory_bytes: 26232
#include<stdio.h>
#include<math.h>
#define MAX 100
#define inf 1000000000
double cal(int x,int y){
    return sqrt(x*x+y*y);
}
int main(void){
    int D,E;
    while(1){
        scanf("%d%d",&D,&E);
        if(D+E==0) break;
        double min=inf;
        for(int i=0;i<=MAX;i++){
            for(int j=i;j<=MAX;j++){
                if(i+j==D&&min>fabs(cal(i,j)-E)){
                    min=fabs(cal(i,j)-E);
                }
            }
        }
        printf("%f\n",min);
    }
}



Measured memory_bytes: 2032
#include <iostream>                                     
using namespace std;                                    
                                                        
int main() {                                            
  int a, b, c;                                          
  cin >> a >> b >> c;                                   
  if (a<b && b<c) {                                     
    cout << "Yes" << endl;                              
  } else {                                              
    cout << "No" << endl;                               
  }                                                     
  return 0;                                             
}                                                       
                                                        
          

Measured memory_bytes: 3088
#include<stdio.h>
int main() {
  int L[10];
  int i, l, v1, v2;
  double ll;
  while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d", &L[0], &L[1], &L[2], &L[3], &L[4], &L[5], &L[6], &L[7], &L[8], &L[9], &v1, &v2) != EOF) {
    l = 0;
    for (i = 0; i < 10; i ++) l += L[i];
    ll = (double) l / (v1 + v2) * v1; l = 0;
    for (i = 0; i < 10; i ++) {
      l += L[i];
      if (ll <= l) {
	printf("%d\n", i + 1);
	break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 596
#include <cstdio>

const int MaxN = 400 + 5, MaxM = 100000 + 5;

int N, M;
int X[MaxM], Y[MaxM];
bool S[MaxN][MaxN], O[MaxN];

void init() {
  scanf("%d %d", &N, &M);
  for (int i = 1; i <= M; ++i)
    scanf("%d %d", &X[i], &Y[i]);
}

void solve() {
  for (int i = 1; i <= N; ++i) {
    S[i][i] = true; O[i] = true;
    for (int j = M; j >= 1; --j) {
      int x = X[j], y = Y[j];
      if (S[i][x] == true && S[i][y] == true) {
        O[i] = false;
        break;
      } else if (S[i][x] == true) S[i][y] = true;
      else if (S[i][y] == true) S[i][x] = true;
    }
  }

  int Ans = 0;
  for (int i = 1; i < N; ++i) for (int j = i + 1; j <= N; ++j) {
    if (O[i] == false || O[j] == false) continue;
    int add = 1;
    for (int k = 1; k <= N; ++k)
      if (S[i][k] == true && S[j][k] == true) add = 0;
    Ans += add;
  }
  printf("%d\n", Ans);
}

int main() {
  init();
  solve();
  return 0;
}

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

const int N = (int) 1e5 + 5;
int a[N];
int dp[N];

int main()
{
    ios :: sync_with_stdio(0);
    cin.tie(0);
    int n,k;
    cin >> n >> k;
    for(int i = 0;i < n;++i)
        cin >> a[i];
    dp[1] = abs(a[1] - a[0]);
    for(int i = 2;i < n;++i)
    {
        dp[i] = INT_MAX;
        for(int j = 1;j <= k;++j)
        {
            if(i - j < 0)
                break;
            dp[i] = min(dp[i],dp[i-j] + abs(a[i]-a[i-j]));
        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
   using namespace std;
   using pii = pair<int, int>;
   using ll = long long;
   #define rep(i, j, n) for(int i = j; i < (int)(n); i++)
   const ll MOD = 1000000007;
   const ll INFL = (1LL << 60);
   const int INFI = (1 << 30);

   int ans = 0, Q, N, M;
   vector<int> a(100), b(100), c(100), d(100), A(11);

   void dfs(int n) {
     if (n == N) {
       //和を求めてansを更新
       int ans_tmp = 0;
       rep(i, 0, Q) {
         if (A.at(b.at(i)) - A.at(a.at(i)) == c.at(i)) ans_tmp += d.at(i);
       }
       ans = max(ans, ans_tmp);
     }
     else {
       rep(i, A.at(n), M + 1) {
         A.at(n + 1) = i;
         dfs(n + 1);
       }
     }
   }

   int main() {
     cin >> N >> M >> Q;
     A.at(0) = 1;

     rep(i, 0, Q) cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);

     dfs(0);

     cout << ans << endl;
   }


Measured memory_bytes: 3632
n = int(input())
station = [tuple(map(int, input().split())) for _ in range(n-1)]

for i in range(n):
    res = 0
    for j in range(i, n-1):
        c, s, f = station[j]
        res += max(s-res, ((res+(f-1))//f)*f - res) + c
    print(res)


Measured memory_bytes: 3188
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string S;
	LL ans = 0;
	cin >> S;
	FOR(i, 0, S.length()) {
		if (S[i] == '1')ans++;
	}
	O(ans);
	return 0;
}

Measured memory_bytes: 256