akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int r = rei();
	int D = rei();
	long ans = rei();
	for(int i=0;i<10;i++){
		ans = ans * r - D;
		cout << ans << "\n";
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func main() {
    n := nextInt()
    x := math.Pow(float64(n), 3)
    fmt.Println(x)
}

Measured memory_bytes: 640
from itertools import product
import sys
read = sys.stdin.read
def main():
    h, w, k = map(int, input().split())
    c = []
    for _ in range(h):
        row = [c == '#' for c in list(input())]
        c.append(row)
    r = 0
    p1 = tuple(product((0, 1), repeat=w))
    p2 = tuple(product((0, 1), repeat=h))
    pat = tuple(product(p1, p2))
    for pe in pat:
        t = 0
        for x, col in enumerate(pe[0]):
            for y, row in enumerate(pe[1]):
                t += col * row * c[y][x]
        if t == k:
            r += 1
    print(r)
if __name__ == '__main__':
    main()

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

using namespace std;

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

    map<int, int> mp;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        mp[a]++;
    }

    int even = 0;
    for (auto &x:mp) {
        if (x.second % 2 == 0) even++;
    }

    int ans = mp.size();
    if (even % 2 == 1) ans--;
    cout << ans << endl;
    return 0;
}



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

int main(){
    int a,b,c;
    int count=0;
    cin >> a >> b >> c;
    for(int i=a; i<=b; i++){
        if(c%i == 0){
            count++;
        }
    }
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <random>

using namespace std;
using ll = long long;

ll solve(vector<ll> a){
	const int n = a.size() - 1;
	ll answer = accumulate(a.begin(), a.end(), 0ll);
	for(int i = n; i > 0; --i){
		vector<ll> b = a;
		for(int j = i; j <= n; j += i){ b[j] = 0; }
		bool modified = true;
		while(modified){
			modified = false;
			for(int j = n; j > i; --j){
				ll acc = 0;
				for(int k = j; k <= n; k += j){ acc += b[k]; }
				if(acc < 0){
					for(int k = j; k <= n; k += j){ b[k] = 0; }
					modified = true;
				}
			}
		}
		const ll sum = accumulate(b.begin(), b.end(), 0ll);
		if(sum > answer){
			answer = sum;
			a = move(b);
		}
	}
	return answer;
}

int main(){
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n + 1);
	for(int i = 1; i <= n; ++i){ cin >> a[i]; }
	cout << solve(a) << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
 
// 隣接リストで使う辺を表す型
struct Edge {
  int to, cost; // 辺の接続先頂点、辺の重み
  Edge(int to, int cost) : to(to), cost(cost) {}  // コンストラクタ
};
typedef long long ll;
const ll INF = 1e18;
typedef vector<vector<Edge> > AdjList;  // 隣接リストの型
AdjList graph; // グラフの辺を格納した構造体
               // graph[v][i]は頂点vから出るi番目の辺Edge
vector<ll> dist; // 最短距離
vector<bool> negative; // 負の閉路があるかどうか
 
void bellman_ford(int n, int s) { // nは頂点数、sは開始頂点
  dist = vector<ll>(n, INF);
  negative = vector<bool>(n, false);
  dist[s] = 0; // 開始点の距離は0
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        if (dist[v] == INF) continue;
        Edge e = graph[v][k];
        if (dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
        }
      }
    }
  }
  for (int i = 0; i < n; i++) {
    for (int v = 0; v < n; v++) {
      for (int k = 0; k < graph[v].size(); k++) {
        if (dist[v] == INF) continue;
        Edge e = graph[v][k];
        if (dist[e.to] > dist[v] + e.cost) {
          dist[e.to] = dist[v] + e.cost;
          negative[e.to] = true;
        }
        if (negative[v]) negative[e.to] = true;
      }
    }
  }
}
 
int main() {
  int n, m;
  cin >> n >> m;
  graph = AdjList(n);
  for (int i = 0; i < m; i++) {
    int from, to, cost;
    cin >> from >> to >> cost;
    from--; to--;
    graph[from].push_back(Edge(to, -cost));
  }
  bellman_ford(n, 0);
  // 解答
  if (negative[n-1]) cout << "inf" << endl;
  else cout << -dist[n-1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

const int N = 2e5+1;
const int INT32 = 2147483647;

int dp[N];
int h[N];

int main(){
  int n,k;
  cin >> n >> k;
  for(int i = 1; i <= n; i++){
    cin >> h[i];
  }
  for(int i = 2; i <= n; i++)
    dp[i] = INT32;
  dp[1] = 0;
  for(int i = 1; i < n; i++){
    for(int j = 1; j <= min(k,n-i); j++){
      if(dp[i+j]>dp[i]+abs(h[i+j]-h[i]))
        dp[i+j] = dp[i]+abs(h[i+j]-h[i]);
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 1024
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
const int N = 1000005;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 1e9+7;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(12);
}

//3. Structure or classes
//3. Ends here

//1. Data structures declaration here
//1. Ends here


//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

void solve()
{
    
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld theta = abs(((h*30)+((0.5)*m))-(6*m));
    theta = min(theta,360-theta);
    theta = (PI*theta)/180.0;
    //cout<<theta<<" "<<cos(theta)<<"\n";
    ld ans =sqrt( (a*a) + (b*b) - (2*a*b*cos(theta)) );
    cout<<ans;
    return;
}

Measured memory_bytes: 4120
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,s[100500];
ll solve(ll p) {
    vector<ll> k(2*n+1);
    ll sum=n;
    k[sum]=1;
    ll add=1;
    ll res=0;
    for(int i=1;i<=n;i++) {
        if(s[i]<p) {
            add-=k[sum];
            sum--;
        }
        else {
            
            sum++;
            add+=k[sum];

        }
        res+=add;
        k[sum]++;
        add++;    
    }
    return res;
}


int main() {
     ll l=INT_MAX,r=INT_MIN,res=INT_MIN;
     cin>>n;
     for(int i=1;i<=n;i++) {
         cin>>s[i];
         l=min(l,s[i]);
         r=max(r,s[i]);
     }
     if(l==r)
     {
        cout<<l<<endl;
        return 0;
     }
    ll tot=n*(n+1)/2-(n*(n+1)/4+1);
     while(l<=r) {
        ll mid=(l+r)>>1;
        ll ans=solve(mid);
        if(ans<tot) {
            r=mid-1;

        }
        else {
            res=max(mid,res);
            l=mid+1;

        }
     } 
     cout<<res<<endl;  
}

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

bool f;

int expr(string, int&);
int term(string, int&);
int factor(string, int&);
int number(string, int&);


int expr(string s, int& p) {
  int res = term(s, p);
  while ( p < (int)s.size() ) {
    if ( s[p] == '+' ) {
      p++;
      res += term(s, p);
      continue;
    }
    break;
  }
  return res;
}

int term(string s, int& p) {
  int res = factor(s, p);
  while ( p < (int)s.size() ) {
    if ( s[p] == '*' ) {
      p++;
      res *= factor(s, p);
      continue;
    }
    break;
  }
  return res;
}

int factor(string s, int& p) {
  int res;
  if ( s[p] == '(' ) {
    p++;
    res = expr(s, p);
    p++;
  } else {
    res = number(s, p);
  }
  return res;
}

int number(string s, int& p) {
  int res = 0;
  while ( p < (int)s.size() && isdigit(s[p]) ) {
    res = res*10+s[p++]-'0';    
  }
  return res;  
}

int main() {
  map<string, int> wei;
  {
    string s;
    while ( cin >> s, s != "END_OF_FIRST_PART" ) {
      int a;
      cin >> a;
      wei[s] = a;      
    }
  }

  string s;
  while ( cin >> s, s != "0" ) {
    // cout << s << endl;
    string t = "";
    int l = s.size();
    bool flag = true;
    for ( int i = 0; i < l; i++ ) {
      if ( s[i] == '(' || s[i] == ')' ) {
	t.push_back(s[i]);
	if ( s[i] == ')' && i < l-1 ) {	  
	  if ( isdigit(s[i+1]) ) t.push_back('*');
	  else if ( s[i+1] != ')' ) {
	    t.push_back('+');
	  }
	}
      }
      else if ( isdigit(s[i]) ) {
	string add = "";	
	while ( 1 ) {
	  if ( i == l || !isdigit(s[i]) ) {	    
	    i--;
	    break;
	  }
	  add += s[i];
	  i++;
	}
	t += add;	
	if ( i < l-1 ) {	  
	  if ( isdigit(s[i+1]) ) t.push_back('*');
	  else if ( s[i+1] != ')' ) {
	    t.push_back('+');
	  }
	}
      } else {
	string a = ""; a += s[i];	
	if ( i < l-1 && 'a' <= s[i+1] && s[i+1] <= 'z' ) {
	  a += s[i+1];
	  i++;	  
	}
	if ( wei.count(a) == 0 ) {
	  flag = false;	  
	  break;	  
	} else {
	  t += to_string(wei[a]);	  
	}
	if ( i < l-1 ) {	  
	  if ( isdigit(s[i+1]) ) t.push_back('*');
	  else if ( s[i+1] != ')' ) {
	    t.push_back('+');
	  }
	}
      }
    }
    if ( !flag ) {
      cout << "UNKNOWN" << endl;
    }
    else {
      int p = 0;
      cout << expr(t, p) << endl;
    }
  }
}



Measured memory_bytes: 3300
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;
// const int N = 1e5 + 5;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	vector<int> v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int k; cin >> k;
	cout << v[k-1];
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

	bool inRect = false;

	if (x >= r && y >= r)
	{
		if (x <= W - r && y <= H - r)
		{
			inRect = true;
		}
	}

	printf(inRect ? "Yes\n" : "No\n");
	return 0;
}


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

int main (void) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if(a + b < c + d){
        cout << "Right" << endl;
    }else if(a + b == c + d){
        cout << "Balanced" << endl;
    }else{
        cout << "Left" << endl;
    }
    return 0;
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>
#include<set>
#include<cstdio>

using namespace std;

#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define P pair<int, int>

typedef vector<int> vec;
typedef vector<vec> mat;

const ll mod = 1000000007;

mat mul(mat &A, mat &B){
    mat C(A.size(), vec(B[0].size()));
    for (int i = 0; i < A.size(); i++){
        for (int k = 0; k < B.size(); k++){
            for (int j = 0; j < B[0].size(); j++){
                C[i][j] = (C[i][j] + A[i][k] * B[k][j]) % mod;
            }
        }
    }
    return C;
}

mat pow(mat A, ll n){
    mat B(A.size(), vec(A.size()));
    for (int i = 0; i < A.size(); i++){
        B[i][i] = 1;
    }
    while(n > 0){
        if(n & 1) B = mul(B, A);
        A = mul(A, A);
        n >>= 1;
    }
    return B;
}

ll gcd(ll x, ll y){
    if(y == 0) return x;
    return gcd(y, x % y);
}

ll lcm(ll x, ll y){
    return x * (y / gcd(x, y));
}

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll numa, numb;
    // cout << gcd(2, 3) << endl;
    // cout << lcm(2, 3) << endl;
    numa = (a - 1) / c + (a - 1) / d - (a - 1) / lcm(c, d);
    numb = b / c + b / d - b / lcm(c, d);
    ll sm = numb - numa;
    ll ans = b - a + 1 - sm;
    // cout << numa << " " << numb << endl;
    cout << ans << endl;
}

Measured memory_bytes: 3580
#include<stdio.h>
int main(){
int a,b,i,N,K[1000],P[1000];
	scanf("%d",&N);
	
	for(i=0;i<N;i++){
		scanf("%d %d",&K[i],&P[i]);
	}
	
	for(a=0;a<N;a++){
		b=K[a]%P[a];
		if(b==0){
			b=P[a];
		}
		printf("%d\n",b);
	}
	
return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

ll dp[100020];
ll mm[100020];

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long count(int num, int n){
    long long sum = 1;
    if(mm[num] != -1){
        return mm[num];
    }
    for(int i = 0; i < n; i++){
        sum = (sum*num)%MOD;
    }

    mm[num] = sum%MOD;

    return sum%MOD;
}

long long sub(int i, ll sum, int k){
    for(int j = 2; j*i <= k; j++){
        sum -= dp[j*i];
        if(sum <= 0){
            sum += MOD;
        }
    }
    return sum;
}

int main(){
    std::ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    ll ans = 0;
    vector<ll> prime;

    for(int i = 0; i < 100020; i++){
        dp[i] = 0;
        mm[i] = -1;
    }

    dp[k] = 1;
    for(int i = k-1; i >= 1; i--){
        ll tmp = count(k/i,n);
        dp[i] = sub(i,tmp,k);
    }

    for(int i = 1; i <= k; i++){
        ans += dp[i]*i%MOD;
    }

    cout << ans%MOD << endl;

    return 0;
}

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


void solve(){

}

int main(){
    int R,G,B,N;
    cin >> R >> G >> B >> N;
    int ans = 0;
    for(int i = 0; i * R <= N; i++){
        for(int j = 0; i * R + j * G <= N; j++){
            if ((N - i*R - j*G) % B == 0 ){
                ans++;
            }
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
    int n, q, t, time=0; cin >> n >> q; string name;
    queue<pair<string,int> >Q;
    for(int i=0;i<n;i++){
        cin >> name >> t;
        Q.push(make_pair(name,t));
    }
    while(!Q.empty()){
        pair<string,int> x=Q.front(); Q.pop();
        int c=min(x.second,q); x.second-=c; time+=c;
        if(x.second>0) Q.push(x);
        else cout << x.first << " " << time << endl;
    }
    return 0;
}

Measured memory_bytes: 6208
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String[] params = sc.nextLine().split(" ");
        int h = Integer.parseInt( params[0]);
        int a = Integer.parseInt( params[1]);

        System.out.println( h / a + ( h % a == 0  ? 0 : 1 ) );

    }

}


Measured memory_bytes: 21972
using System;
using static System.Console;

namespace abc179
{
    class Program
    {
        static void Main()
        {
            var s = ReadLine();
            if (s[s.Length - 1] == 's')
            {
                WriteLine(s + "es");
            }
            else
            {
                WriteLine(s + "s");
            }
        }
    }
}


Measured memory_bytes: 25796
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <stack>
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;

char s[105];
int num[35], p[35], n;

int main() 
{
	while(~scanf("%d", &n)) {
		for(int i = 0; i < 26; i++) num[i] = 1000; 
		for(int i = 1; i <= n; i++) {
			scanf("%s", s);
			memset(p, 0, sizeof(p));
			int len = strlen(s);
			for(int i = 0; i < len; i++) p[s[i] - 'a']++;
			for(int i = 0; i < 26; i++) num[i] = min(num[i], p[i]);
		}
		for(int i = 0; i < 26; i++)
			for(int j = 1; j <= num[i]; j++) printf("%c", 'a' + i);
		printf("\n");
	}
}

Measured memory_bytes: 256
n=int(input())


# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])
    if arr==[]:
        arr.append([n, 1])
    return arr
#factorization(24) 
## [[2, 3], [3, 1]] 
##  24 = 2^3 * 3^1
from collections import defaultdict
d=defaultdict(int)

for i in range(1,n+1):
  x=factorization(i)
  for xi in x:
    d[xi[0]]+=xi[1]
di=defaultdict(int)
for k in d:
  if d[k]>=74:
    di[74]+=1
    di[24]+=1
    di[14]+=1
    di[4]+=1
    di[2]+=1
  elif d[k]>=24:
    di[24]+=1
    di[14]+=1
    di[4]+=1
    di[2]+=1
  elif d[k]>=14:
    di[14]+=1
    di[4]+=1
    di[2]+=1
  elif d[k]>=4:
    di[4]+=1
    di[2]+=1
  elif d[k]>=2:
    di[2]+=1
ans=di[74]
ans+=max(0,di[24]*(di[2]-1))
ans+=max(0,di[14]*(di[4]-1))
ans+=max(0,(di[4]*(di[4]-1))//2*(di[2]-2))
print(max(ans,0))


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

int a[10010];
int main() {
  for (int N; scanf("%d", &N), N; ) {
      for (int i = 0; i < N; i++) {
          scanf("%d", &a[i]);
      }
      sort(a, a + N);
      long long ans = 0;
      long long acc = 0;
      for (int i = 0; i < N; i++) {
          ans += acc;
          acc += a[i];
      }
      cout << ans << endl;
  }

}

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

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

    int N;
    cin >> N;
    int m = (int)pow(2 * N, 0.5);
    if (2 * N != m * (m + 1)) {
        printf("No\n");
        return 0;
    }
    printf("Yes\n");
    printf("%d\n", m + 1);

    int t[m + 1][m];
    int h = 1;
    int v = 1;
    for (int i = 0; i < m; ++i) {
        for (int j = i; j < m; ++j) {
            t[i][j] = h++;
        }
        for (int k = i + 1; k < m + 1; ++k) {
            t[k][i] = v++;
        }
    }

    for (int i = 0; i < m + 1; ++i) {
        printf("%d", m);
        for (int j = 0; j < m; ++j) {
            printf(" %d", t[i][j]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2176
#include <cstdio>
#include <list>
#include <algorithm>
using namespace std;

int main() {
  int q, x;
  char com[20];

  list<int> v;
  scanf("%d", &q);
  for ( int i = 0; i < q; i++ ) {
    scanf("%s", com);
    if ( com[0] == 'i' ) {
      scanf("%d", &x);
      v.push_front(x);
    } else if ( com[6] == 'L' ) {
      v.pop_back();
    } else if ( com[6] == 'F' ) {
      v.pop_front();
    } else if ( com[0] == 'd' ) {
      scanf("%d", &x);
      for ( list<int>::iterator it = v.begin(); it != v.end(); it++ ) {
        if ( *it == x ) {
          v.erase(it);
          break;
        }
      }
    }
  }

  int i = 0;
  for ( list<int>::iterator it = v.begin(); it != v.end(); it++ ) {
    if ( i++ ) printf(" ");
    printf("%d", *it);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 34024
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;


int main(){
  int N,M,Q;cin>>N>>M>>Q;
  vector<vint> sum(N,vint(N,0));
  repeat(i,M){
    int L,R;cin>>L>>R;
    L--;R--;
    sum[L][R]++;
  }
  repeat(i,N){
    repeat(j,N-1){
      sum[i][j+1] += sum[i][j];
    }
  }
  repeat(j,N){
    for(int i=N-1;i>0;i--){
      sum[i-1][j] += sum[i][j];
    }
  }
  repeat(i,Q){
    int p,q;cin>>p>>q;p--;q--;
    cout << sum[p][q] << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include <stdio.h>
#include <vector>
using namespace std;
int main(){
    int cases;
    scanf("%d",&cases);
    for(int i=0;i<cases;i++){
        int times;
        scanf("%*d%d",&times);
        vector<int>table;
        for(int k=0;k<times;k++){
            int num;
            scanf("%d",&num);
            table.push_back(num);
        }
        int tmp=0;
        for(int k=0;k<cases;k++){
            if(k!=0){
                printf(" ");
            }
            if(tmp<table.size() && table[tmp]==k+1){
                printf("1");
                tmp++;
            }else{
                printf("0");
            }
        }
        printf("\n");
    }
}



Measured memory_bytes: 2620
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define srt(i) sort(i.begin(), i.end())
#define rvt(i) sort(i.begin(), i.end(), greater<int>())
 
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    while(a>0 && c>0){
      c-=b;
      a-=d;
    }

    if(c<=0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3636
#pragma region head
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << endl
#define test(s) \
  if (!(s))     \
    cout << "Line " << __LINE__ << ": [" << #s << "] is false" << endl;
#define int long long
typedef long long ll;
#define double long double
typedef double ld;
const int INF = 1001001001001001001ll;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;
const double PI = acos(-1.0);

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      s << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
#pragma endregion

signed main() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }

  chmin(K, 50ll);

  while (K-- > 0) {
    vector<int> imos(N + 1);
    rep(i, N) {
      int l = max(0ll, i - A[i]);
      int r = min(i + A[i] + 1, N);
      imos[l]++, imos[r]--;
    }

    int temp = 0;
    rep(i, N) {
      temp += imos[i];
      A[i] = temp;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 6392
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

A, B, C, K = MAP()

print((A-B)*(-1)**(K%2))


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

int main()
{
    /* ------- 宣言と入力 ------- */

    int N, M;

    cin >> N >> M;

    /* ------- 計算 ------- */

    if (N == M)
    {

        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int MX = 1000005;

int main(){
    int h,w,k,ans;
    char input;
    cin>>h>>w>>k;
    ans=0;
    vector<vector<bool>>hw(h,vector<bool>(w,false));
    rep(i,h){
        rep(j,w){
            cin>>input;
            if(input=='#'){
                hw[i][j]=true;
            }
        }
    }
    rep(is,1<<h)rep(js,1<<w){
        int cnt=0;
        rep(i,h)rep(j,w){
            if(is>>i&1)continue;
            if(js>>j&1)continue;
            if(hw[i][j])cnt++;   
        }
        if(cnt==k)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3616
#include <iostream>
using namespace std;
int main(){
    int h, m, s;
    cin >> s;
    h = s/(60*60);
    s %= 60*60;
    m = s/60;
    s %= 60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3108
class Vertex
  def initialize(id, others)
    @id = id
    @others = others.sort
    @d = -1
    @f = -1
  end

  def visit(time)
    @d = time
    @others.each do |v1|
      vertex = $vertices.find{|v2| v2.id == v1}
      if vertex.d < 0 then
        time += 1
        time = vertex.visit(time)
      end
    end
    time += 1
    @f = time
    return time
  end

  attr_accessor :id, :others, :d, :f
end

def dfs
  time = 1
  loop do
    index = $vertices.index{|v| v.d < 0}
    break if index == nil
    time = $vertices[index].visit(time)
    time += 1
  end
end

n = gets.chomp.to_i
$vertices = []
(n).times do
  inputs = gets.chomp.split.map(&:to_i)
  others = []
  inputs[1].times do |i|
    others << inputs[2 + i]
  end
  $vertices << Vertex.new(inputs[0], others)
end

$vertices.sort_by!{|v| v.id}
dfs
$vertices.each do |v|
  puts "#{v.id} #{v.d} #{v.f}"
end

Measured memory_bytes: 8992
#include "bits/stdc++.h"
using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> boal(N);
  for(int i = 0; i < N; i++){
    int num;
    cin >> num;
    num--;
    boal[num] += 1;
  }
  sort(boal.begin(), boal.end());
  int sum = 0;
  int i = 0;
  int cnt = 0;
  for(int i = 0; i < N - K; i++){
    sum += boal[i];
  }
  cout << sum << endl;
}

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

long minOperations(long candies[], int num_boxes, long max_sum) {
	long min_count = 0;
	long ZERO = 0;
	for (int i = 0; i < num_boxes - 1; i++) {
		if (candies[i] + candies[i + 1] > max_sum) {
			min_count += candies[i + 1] + candies[i] -  max_sum;
			candies[i + 1] = max_sum - candies[i];
		}
	}
	if (candies[num_boxes - 1] > max_sum)
		min_count += candies[num_boxes - 1] - max_sum;
	return min_count;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int num_boxes;
	cin >> num_boxes;
	long max_sum;
	cin >> max_sum;
	long candies[num_boxes];
	for (int i = 0; i < num_boxes; i++) {
		cin >> candies[i];
	}
	cout << minOperations(candies, num_boxes, max_sum);
}

Measured memory_bytes: 1024
N,K = map(int,input().split())
def Base_10_to_n(X, n):
    if (int(X/n)):
        return Base_10_to_n(int(X/n), n)+str(X%n)
    return str(X%n)

x2 = Base_10_to_n(N, K)
print(len(str(x2)))

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<vector>
using namespace std;

int main(){
    int n, c, t, ans = 0;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        cin >> t;
        v.push_back(t);
    }
    for(int i = 0; i < n; i++){
        cin >> c;
        if(c < v[i]) ans += v[i] - c;
    }

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

Measured memory_bytes: 256
#include <stdio.h>

int a, b, c, temp;

int main(){
  scanf("%d %d %d", &a, &b, &c);
  if (a > b){
    temp = a;
    a = b;
    b = temp;
  }
  if (b > c){
    temp = b;
    b = c;
    c = temp;
  }
  if (a > b){
    temp = a;
    a = b;
    b = temp;
  }
  printf("%d %d %d\n", a, b, c);

  return 0;
}



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

int main()
{ 
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++){
        if(s[i]==t[i]){ans++;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int flag=0,i;
int main()
{
    char we[100086];
    gets(we);
    for(i=0;i<strlen(we);i++)
    {
        if(we[i]=='C')
    {
            flag=1;
        }
        if(we[i]=='F'&&flag==1)
    {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int , int > P;




int main()
{
    LL t, n;
    cin >> t >> n;
    LL cnt=0;
    while(t--)
    {
        LL a, b;
        cin >> a >> b;
        if(a*a+b*b<=n*n)
        {
           // cout << a << "  " << b <<endl;
            cnt++;
        }

    }
    cout << cnt ;

}


Measured memory_bytes: 3620
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st s;
  ci(s);
  int A, Z;
  rep(i, sz(s) - 1){
    if(s.at(i) == 'A'){
      A = i;
      br;
    }
  }
  rev(i, sz(s) - 1){
    if(s.at(i) == 'Z'){
      Z = i;
      br;
    }
  }
  co(Z - A + 1);
}

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

int main(){
	const int MOD = 1e9+7;
	int N,K;
	cin >> N >> K;
	vector<vector<ll>> C(N+1,vector<ll>(N+1,1));
	for(int i=0; i<=N; i++) for(int j=i+1; j<=N; j++) C[i][j] = 0;
	
	for(int i=1; i<=N; i++){
	  for(int j=1; j<=i; j++){
	  	C[i][j] = (C[i-1][j] + C[i-1][j-1]) % MOD;
	  }
	}

	for(int i=1; i<=K; i++){
		cout << C[N-K+1][i] * C[K-1][i-1] % MOD << endl;
	}
	
}


Measured memory_bytes: 31744
#include<stdio.h>
int main(void){
	int i,j,h,w;
	for(;;){
		scanf("%d %d",&h,&w);
		for(i=0;i<h;i++){
			
			for(j=0;j<w;j++){
				
				if((i+j)%2==0){
					printf("#");
				}
				else{
					printf(".");
				}
			
			}
			printf("\n");
		}
		if(h==0&&w==0){
			break;
		}
	else printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define REP(i,a,b) for(int(i)=(a);(i)<(b);++(i))
#define RREP(i,a,b) for(int(i)=(a)-1;(i)>=(b);--(i))
#define ALL(x) (x).begin(),(x).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int D,G;
vector<int> p,c;

int main()
{
  cin >> D >> G;
  p.resize(D);
  c.resize(D);
  REP(i,0,D) cin >> p[i] >> c[i];

  int min_count = INF;  // 最小の問題数(ans)

  REP(bit,0,1<<D) {
    int score = 0;
    int count = 0;  // 問題数
    int rest_max = -1; // 完全には解かない問題のうちで，最高配点
    REP(i,0,D) {
      if (bit & (1<<i)) {
        // 100(i+1)点の問題を全て解く
        score += 100*(i+1)*p[i] + c[i];
        count += p[i];
      } else {
        rest_max = i;  // ビット0が立っている最大の場所
      }
    }
    if (rest_max == -1) chmin(min_count, count);

    // 完全には解かなかった問題のうちで
    // いちばん配点の高い問題(rest_max)を解く
    // 0問以上・p[rest_max]-1問以下を解く
    REP(k,0,p[rest_max]) { //k個解く
      if (score + 100*(rest_max + 1)*k >= G) {
        chmin(min_count, count + k);
        break;
      }
    }
  }

  cout << min_count << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
******************* Author:Bisnu sarkar ****************************
**/
/*
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/
#define fRead(x)       freopen(x,"r",stdin)
#define fWrite(x)      freopen (x,"w",stdout)
#define ull            unsigned long long
#define ll             long long
#define pii            pair<int,int>
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define sz(s)          (int)s.size()
#define all(s)         s.begin(),s.end()
#define IO             ios_base::sync_with_stdio(false),cin.tie(NULL);  
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*///
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl;}
template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << ", ";
  err(++it, args...);
}
///*....Input....*///
template <typename T> inline void Int(T &n) {
  n = 0; int f = 1; register int ch = getchar();
  for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
  for (; isdigit(ch); ch = getchar()) n = (n << 3) + (n << 1) + ch - '0';
  n = n * f;
}
 
template <typename T, typename TT> inline void Int(T &n, TT &m) { Int(n); Int(m); }
template <typename T, typename TT, typename TTT> inline void Int(T &n, TT &m, TTT &l) { Int(n, m); Int(l);}
double ind(){double x; scanf("%lf",&x);return x;}

///*....Bitmask....*///
int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

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

///*....Constraints....*///
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;


int main()
{
    int t=1,te=0;
    //Int(t);
    while(t--){
        int x,y;
        Int(x,y);

        printf("%d\n", x*y);     

        //printf("Case %d: ",++te);
    }
    return 0;
}






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

int main() {
  int N, Nw, d, Nf;
  cin >> N;
  
  Nw = N;
  while (Nw != 0) {
    Nw /= 10;
    d++;
  }
  
  int sum = 0;
  Nf = N;
  for (int i = 0; i < d; i++) {
    int num;
    num = Nf % 10;
    sum += num;
    Nf /= 10;
  }
  
  if (N % sum == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;


int main()
{
  ll n, m;
  cin >> n >> m;
  vector<vector<int>> jobs(m, vector<int>());
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    int day = m - a;
    if (day < 0) continue;
    jobs[day].push_back(b);
  }

  priority_queue<int> q;

  ll ans = 0;
  for (int i = m-1; i >= 0; i--) {
    for (auto& b : jobs[i]) {
      q.push(b);
    }
    if (q.empty()) continue;
    ans += q.top();
    q.pop();
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;

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



Measured memory_bytes: 3212
N, M = map(int, input().split())
number = list()
for i in range(M):
    number.append(list(map(int, input().split())))
   
answer_dict = dict()
check = 0
for i in range(M):
    keta = number[i][0]
    num = number[i][1]
    if keta not in answer_dict.keys():
        answer_dict[keta] = num
    
    elif keta in answer_dict.keys() and answer_dict[keta] != num:
        check = -1
        break


answer_list = list()
for i in range(1, N+1):
    if i == 1:
        if i not in answer_dict.keys() and N >= 2:
            answer_list.append('1')
        elif i not in answer_dict.keys() and N == 1:
            answer_list.append('0')
        elif answer_dict[i] == 0 and N >= 2:
            check = -1
        else:
            answer_list.append(str(answer_dict[i]))
    else:
        if i not in answer_dict.keys():
            answer_list.append('0')
        else:
            answer_list.append(str(answer_dict[i]))

if check == -1:
    print(-1)
else:
    print(''.join(answer_list))

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

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

    int n; cin >> n;
    vector<int> a(n);
    bool flag = true;
    cin >> a[0];
    for (int i = 1; i < n; i++) {
        cin >> a[i];
        if (a[i] != a[i-1]) flag = false;
    }

    int ans;
    if (!flag) {
        ans = (1 << 29);
        for (int i = -100; i <= 100; i++) {
            int cost = 0;
            for (int j = 0; j < n; j++) {
                cost += (a[j]-i)*(a[j]-i);
            }
            ans = min(ans, cost);
        }
    } else {
        ans = 0;
    }
    cout << ans << endl;

    return 0;
}

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

//create arrays outside of main()

int a[100];

int main(){

    int a;
    int b;
    cin >> a >> b;

    int add = a+b;
    int subtract = a-b;
    int multiply = a*b;

    int biggestNum = 0;

    for(int i=0; i<3; i++){
        if (add>=subtract){
            biggestNum = add;
        } else {
            biggestNum = subtract;
        }

        if(multiply>=biggestNum){
            biggestNum = multiply;
        } 
    }
    
    cout << biggestNum;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MOD2 998244353
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")

void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{ ll a , b;}fr;
int cmp1( const void *p, const void *q ) { return ((fr*)p) ->a - ((fr*)q)->a;}
int cmp2( const void *p, const void *q ) { return ((fr*)q) ->a - ((fr*)p)->a;}
void strsortup(fr*a,int n){qsort(a,n,sizeof(fr),cmp1);}
void strsortdown(fr*a,int n){qsort(a,n,sizeof(fr),cmp2);}

/*階乗 a!*/
ll factorial(ll a){return a==0?1:a*factorial(a-1);}


int main(void){
    // char ;
    ll n;
    double ans=0;
    scanf("%lld",&n);
    ll x[n],y[n];
    rep(i,0,n){
        scanf("%lld%lld",&x[i],&y[i]);
    }
    rep(i,0,n){
        rep(j,0,n){
            ans+=sqrt(POW(x[i]-x[j],2) + POW(y[i]-y[j],2) )*factorial(n-1) ;
            // printf("%f ",ans);
        }
    }
    ans/=factorial(n);
    
    printf("%.8f\n",ans);
    return 0;
}


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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint n,p; cin >> n >> p;
  vector<lint> a(n); for(lint i=0;i<n;i++) { cin >> a[i]; }

  vector<lint> odd(n,0), evn(n,0);
  for(lint i=0;i<n;i++) {
    if(i == 0) {
      if(a[i]%2 == 0) { evn[i] = 2; odd[i] = 0; }
      else { evn[i] = 1; odd[i] = 1; }
    } else {
      if(a[i]%2 == 0) { evn[i] = evn[i-1]*2; odd[i] = odd[i-1]*2; }
      else { evn[i] = evn[i-1]+odd[i-1]; odd[i] = evn[i-1]+odd[i-1]; }
    }
  }

  if(p == 0) { cout << evn[n-1];}
  else { cout << odd[n-1]; }
  cout << endl;
  return 0;
}


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

int main(){
ll N,M; cin >> N >> M;
  vector<ll> x(N),y(N),z(N);
  for(ll i = 0; i < N; i++){ cin >> x[i] >> y[i] >> z[i];}
  ll ans = -1LL<< 60;
  for(int i = 0; i <(1<<3); i++){
    vector<ll> vec;
    for(ll j = 0; j < N; j++){
      ll res = 0;
      if( (i>>2) & 1){ res += x[j];} else{ res -= x[j];}
      if( (i>>1) & 1){ res += y[j];} else{ res -= y[j];}
      if( (i>>0) & 1){ res += z[j];} else{ res -= z[j];}
      vec.push_back(res);}
  sort(vec.rbegin(),vec.rend());
    ll sum = 0;
    for(ll k = 0; k < M; k++){ sum += vec[k];}
    ans = max( ans, sum );}
  
  cout << ans << endl; return 0;}

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

const long long MAX = 200010;
const long long MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

    // 前処理
    COMinit();

    long long n, m, k;
    cin >> n >> m >> k;
    
    long long ans = 0;
    for(int d = 1; d < n; d++){
        long long t = d * (n - d) * m;
        t %= MOD;
        t *= m;
        t %= MOD;
        t *= COM(n * m - 2, k - 2);
        t %= MOD;
        
        ans += t;
        ans %= MOD;
    }

    for(int d = 1; d < m; d++){
        long long t = d * (m - d) * n;
        t %= MOD;
        t *= n;
        t %= MOD;
        t *= COM(n * m - 2, k - 2);
        t %= MOD;

        ans += t;
        ans %= MOD;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+20;
int a[N],b[N],n;
int main()
{
	while(cin>>n)
	{
		ll sum=0,ans=0;//
		for(int i=0;i<n;i++)
		{
			cin>>a[i]>>b[i];
		}
		int r;
		for(int i=n-1;i>=0;i--)
		{
			//cout<<a[i]+sum<<endl; 
			r=(a[i]+sum)%b[i];//还差b[i]-r
			if(r==0)
			continue;
			sum+=b[i]-r;//更新前面累加和 
			ans+=b[i]-r; 
		}
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

vpl dd = {PL(-1,0), PL(1,0), PL(0,1),PL(0,-1)};

int main(){
    ll N; cin >> N;
    vl hs(N, 0); REP(i, N) cin >> hs[i];
    ll ans = hs[0];
    REP(i, N-1){
        if(hs[i+1] - hs[i] >= 0) ans += hs[i+1] - hs[i];
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
while True:
    a,op,b = input().split()
    a = int(a)
    b = int(b)
    if op == "+":
        print(a+b)
    elif op == "-":
        print(a-b)
    elif op == "*":
        print(a*b)
    elif op == "/":
        print(a//b)
    elif op == "?":
        break


Measured memory_bytes: 5592