akhauriyash/Code-Regression huggingface dataset:
N,Ma,Mb=map(int,input().split())
a=[0 for k in range(N)]
b=[0 for k in range(N)]
c=[0 for k in range(N)]
import copy
for k in range(N):
    a[k],b[k],c[k]=map(int,input().split())
Sa=sum(a)
Sb=sum(b)
dp =[[[5000 for k in range(Sb+1)]for k in range(Sa+1)]for k in range(N+1)]
dp[0][0][0]=0
for k in range(N):
    listj=[]
    listl=[]
    for j in range(Sa-a[k]+1):
        for l in range(Sb-b[k]+1):
            if dp[k][j][l]!=5000:
                listj.append(j)
                listl.append(l)
    for m in range(len(listl)):
        dp[k+1][listj[m]+a[k]][listl[m]+b[k]]=min(dp[k][listj[m]][listl[m]]+c[k], dp[k][listj[m]+a[k]][listl[m]+b[k]])
        dp[k+1][listj[m]][listl[m]]=min(dp[k][listj[m]][listl[m]], dp[k+1][listj[m]][listl[m]])
ans=[5000]
for k in range(1, min(Sa//Ma,Sb//Mb)+1):
    ans.append(dp[-1][Ma*k][Mb*k])
if min(ans)==5000:
    print(-1)
else:
    print(min(ans))

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


int main() {
    int A, B;
    cin >> A >> B;

    for (int i = 1; i <= 20000; i++) {
        double eight = (double)i * 0.08;
        double ten = (double)i * 0.10;
        if (floor(eight) == A && floor(ten) == B) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <time.h>
#include <complex>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define pi pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int N;
string s;
int main(){
    cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'o') ans++;
    }
    if(15-s.size() + ans >= 8){
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}



Measured memory_bytes: 256
local function ston(x,i)
    return tonumber(x:sub(i,i))
end
local function eo(i)
    if i%2==0 then
        return 1
    else
        return -1
    end
end
local function pm(i)
    if i%2==0 then
        return "+"
    else
        return "-"
    end
end

x=io.read()
a=ston(x,1)
b=ston(x,2)
c=ston(x,3)
d=ston(x,4)

for i=1,2 do
    for j=1,2 do
        for k=1,2 do
            if a+b*eo(i)+c*eo(j)+d*eo(k)==7 then
                print(a..pm(i)..b..pm(j)..c..pm(k)..d.."=7")
                return
            end
        end
    end
end

Measured memory_bytes: 888
#include <cstdio>
#include <iostream>
#include <string.h>
#include <string> 
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stack>
#include <iomanip>
#define mem0(a) memset(a,0,sizeof(a))
#define meminf(a) memset(a,0x3f,sizeof(a))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
const int maxn=200005,inf=0x3f3f3f3f;  
const ll llinf=0x3f3f3f3f3f3f3f3f;   
const ld pi=acos(-1.0L);
vector<int> v[maxn];

int main() {
	int n,m,i,j,l,r;
	scanf("%d%d",&n,&m);
	priority_queue<int,vector<int>,greater<int> > pq;
	for (i=1;i<=n;i++) {
		scanf("%d%d",&l,&r);
		if (l==0) pq.push(r); else v[l].push_back(r);
	}
	for (i=1;i<=m+1;i++) {
		sort(v[i].begin(),v[i].end());
	}
	int pos=-1;
	for (i=1;i<=m;i++) {     //枚举左界 
		if (v[i].size()>1) {     //当前左界有多个人，则只坐右界最大的那个人 
			for (j=0;j<v[i].size()-1;j++) pq.push(v[i][j]);
		} else if (v[i].size()==0) {   //当前左界无人
			if (!pq.empty()) {        //安排之前没坐的人坐到现在位置 
				if (pq.top()<=i) pq.pop(); else {
					pos=max(pos,i);
					while (!v[pos].size()&&pos<=m) pos++;
					if (v[pos].size()) v[pos].pop_back();
				}  
			} else {                  //安排后面的人坐到现在的位置 
				pos=max(pos,i);
				while (!v[pos].size()&&pos<=m) pos++;
				if (v[pos].size()) v[pos].pop_back();
			}
		}
	}
	int ans=pq.size();
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793238462
typedef long long ll;
typedef double db;
//ll qpow(ll a,ll b){ll res=1;while(b){if(b&1) res=res*a%mod;a=a*a%mod;b/=2;}return res%mod;}
map<ll,ll> p;
vector<ll> c;
int main(){
    ll n,ans=0;
    cin>>n;
    for(ll i=2;i*i<=n;i++){
        if(n%i==0){
            c.push_back(i);
            while(n%i==0) n/=i,p[i]++;
        }
    }
    if(n>1) c.push_back(n),p[n]++;
    for(auto x:c){
        ll j=1;
        while(true){
            if((j*(j+1))/2>p[x]) break;
            j++;
        }
        ans+=j-1;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3636
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld long double
#define   pb push_back
#define  sz(x)  (int)x.size()
#define  ff first
#define  ss second
#define  pii  pair<int,int>
using namespace std; 

vector<int> allPrimes; 
 
void sieve(int n) 
{ 
    vector<bool> prime(n+1, true); 
    for (int p=2; p*p<=n; p++) { 
        if (prime[p] == true) { 
            for (int i=p*2; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++) 
        if (prime[p]) 
            allPrimes.push_back(p); 
} 
int solve(int n) 
{ 
    sieve(n); 
    int result = 1;
    for (int  i=0; i < allPrimes.size(); i++) 
    { 
        int p = allPrimes[i]; 
        int x = 0; 
        while (p <= n) 
        { 
            x = x + (n/p); 
            p = p*allPrimes[i]; 
        } 
        result = (result*(x+1))%1000000007; 
    } 
    return result; 
}
 


signed main()
{
    int n=1; cin>>n;
    cout << solve(n) << endl ;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

#define NODE_MAX 1002
#define INF 100000000

typedef struct edge_t_tag {
	int max;
	int next;
	struct edge_t_tag* pair;
} edge_t;

int edge_num[NODE_MAX];
edge_t edges[NODE_MAX][NODE_MAX];
char visited[NODE_MAX];


int get_one_flow(int now,int goal,int limit) {
	int i;
	if(now==goal)return limit;
	if(visited[now])return 0;
	visited[now]=1;
	for(i=0;i<edge_num[now];i++) {
		int now_flow;
		if(edges[now][i].max<=0)continue;
		now_flow=get_one_flow(edges[now][i].next,goal,
			edges[now][i].max<limit?edges[now][i].max:limit);
		if(now_flow>0) {
			edges[now][i].max-=now_flow;
			edges[now][i].pair->max+=now_flow;
			return now_flow;
		}
	}
	return 0;
}

int get_max_flow(int s,int g) {
	int result=0;
	while(1) {
		int now;
		memset(visited,0,sizeof(visited));
		now=get_one_flow(s,g,INF);
		if(now==0)break;
		result+=now;
	}
	return result;
}

void flow_init(void) {
	memset(edge_num,0,sizeof(edge_num));
}

void flow_add_edge(int s,int t,int max) {
	edges[s][edge_num[s]].max=max;
	edges[s][edge_num[s]].next=t;
	edges[s][edge_num[s]].pair=&edges[t][edge_num[t]];
	edge_num[s]++;
	edges[t][edge_num[t]].max=0;
	edges[t][edge_num[t]].next=s;
	edges[t][edge_num[t]].pair=&edges[s][edge_num[s]];
	edge_num[t]++;
}

int gcd(int a,int b) {
	return b==0?a:gcd(b,a%b);
}

int main(void) {
	int m,n;
	int b[500];
	int r[500];
	while(scanf("%d%d",&m,&n)==2 && (m|n)!=0) {
		int i,j;
		for(i=0;i<m;i++)scanf("%d",&b[i]);
		for(i=0;i<n;i++)scanf("%d",&r[i]);
		/*
			0 : s
			1 : t
			2, ... ,m+1 : b
			m+2, ... , m+n+1 : r
		*/
		flow_init();
		for(i=0;i<m;i++)flow_add_edge(0,i+2,1);
		for(i=0;i<n;i++)flow_add_edge(m+2+i,1,1);
		for(i=0;i<m;i++) {
			for(j=0;j<n;j++) {
				if(gcd(b[i],r[j])>1)flow_add_edge(i+2,m+2+j,1);
			}
		}
		printf("%d\n",get_max_flow(0,1));
	}
	return 0;
}

Measured memory_bytes: 15072
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp70 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int K = st[0];
            int S = st[1];

            int ans = 0;

            for (int i = 0; i <= K; i++) {
                for (int j = 0; j <= K; j++) {
                    if (i + j <= S && i + j >= S - K) {
                        //Console.WriteLine("(i, j, k) = " + i + " " + j + " " + (S - (i + j)));

                        ans++;
                    }

                }

            }

            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11348
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;


public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			long N = in.nextInt();
			long M = in.nextInt();
			long ans = 0;
			if(N == 1 && M == 1) {
				ans = 1;
			} else if(N == 1 || M == 1) {
				ans = N * M - 2;
			} else {
				ans = N * M - ((2 * N + 2 * M) - 4);
			}
			out.println(ans);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;

vec dp(1e5+10,-1);
vector<set<ll>> E(1e5+10);
ll res(ll n) {
  if(dp[n]!=-1) return dp[n];
  ll out=0;
  for(ll t:E[n]) {
    out=max(out,res(t));
  }
  return dp[n]=out+1;
}

int main() {
  ll n,m;
  cin >> n >> m;
  for(ll i=0;i<m;i++) {
    ll x,y;
    cin >> x >> y;
    x--,y--;
    E[x].insert(y);
  }
  ll ans=0;
  for(ll i=0;i<n;i++) {
    ans=max(ans,res(i));
  }
  cout << ans-1 << endl;
}

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

using ll = long long;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	ll n, x, d;
	cin >> n >> x >> d;

	if(d == 0) {
		if(x == 0) {
			cout << 1 << endl;	
		} else {
			cout << n+1 << endl;
		}	

		return 0;
	}

	map<ll, vector<pair<ll, ll>>> mp;
	for(ll s = 0; s <= n; s++) {
		ll L_sum = s*(s-1)/2;
		ll R_sum = (n - s) * s + L_sum;
		assert(L_sum <= R_sum);
		mp[s*x % d].emplace_back(s*x/d + L_sum, s*x/d + R_sum);
	}

	ll ans = 0;

	for(auto& p : mp) {
		auto& v = p.second;
		int sz = v.size();
		sort(v.begin(), v.end());
		for(int i = 0; i < sz; ) {
			int j = i;
			ll L = v[i].first, R = v[i].second;
			while(j < sz && v[j].first <= R) {
				R = max(R, v[j++].second);	
			}
			ans += R - L + 1;
			i = j;
		}
	}

	cout << ans << endl;


}


Measured memory_bytes: 22144
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		if(d == 25) {
			System.out.println("Christmas");
		}else if(d == 24) {
			System.out.println("Christmas Eve");
		}else if(d == 23) {
			System.out.println("Christmas Eve Eve");
		}else {
			System.out.println("Christmas Eve Eve Eve");
		}
	}
}

Measured memory_bytes: 21844
using System;

namespace ABC046C
{
  class Program
  {
    static void Main(string[] args)
    {
      int N = int.Parse(Console.ReadLine());

      long tak = 0;
      long aok = 0;

      string[] bufs = Console.ReadLine().Split(' ');
      tak = long.Parse(bufs[0]);
      aok = long.Parse(bufs[1]);
      double ratio = (double)tak / aok;

      for (int i = 1; i < N; i++) {
        bufs = Console.ReadLine().Split(' ');
        int rt = int.Parse(bufs[0]);
        int ra = int.Parse(bufs[1]);

        double ratioNew = (double)rt / ra;
        long power;

        // if Tak ratio is greater
        if (ratio > ratioNew) {
          power = (tak + rt - 1) / rt;
        } else {
          power = (aok + ra - 1) / ra;
        }
        tak = rt * power;
        aok = ra * power;

        ratio = ratioNew;
      }

      Console.WriteLine(tak + aok);
    }
  }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int max1=2e5+5;
int a[max1]={0};
int main(){
	int n,k;
	double maxn=0,sum=0;
	cin>>n>>k;
	for(int i=0;i<n;i++)scanf("%d",&a[i]);
	for(int i=0;i<k;i++)sum+=(a[i]+1)/2.0;
	maxn=sum; 
	for(int i=0;i<n-k;i++){
		sum-=(a[i]+1)/2.0;
		sum+=(a[i+k]+1)/2.0;
		maxn=maxn>sum?maxn:sum;
	}
	printf("%.12f",maxn);
	return 0; 
} 

Measured memory_bytes: 1024
from collections import deque
n = int(input())

lis = set()
def dfs():
    d = ['3','5','7']
    que = deque(['3','5','7'])
    while len(que) != 0:
        val = que.pop()
        #print(val)
        if len(val) < 11:
            #print(len(str(val)))
            for i in range(3):
                val2 = val + d[i]
                #print(val3[-1])
                l = list(val2)
                if '3' in l and '5' in l and '7' in l:
                    lis.add(int(val2))
                que.append(val2)

    return lis
lis = dfs()
ans = 0
for i in lis:
    if int(i) <= n:
        ans += 1
print(ans)


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

using namespace std;

int main() {
    int N;
    cin >> N;
    long long A[N];
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    long long left = 0;
    long long right = sum;
    long long min_diff = sum;
    for (int i = 0; i < N; i++) {
        left += A[i];
        right -= A[i];
        long long diff = abs(left - right);
        if (diff < min_diff) {
            min_diff = diff;
        }
    }
    cout << min_diff << "\n";

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    ll bad = 0;
    rep(i, n) {
        if (s[i] == 'L') {
            if ((i == 0) || (s[i - 1] == 'R')) {
                bad++;
            }
        }
        else {
            if ((i == (n - 1)) || (s[i + 1] == 'L')) {
                bad++;
            }
        }
    }
    bad = max(1LL, bad - k * 2);
    cout << (n - bad) << endl;
    return 0;
}


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

int main(){
    int64_t X;
    cin >> X;
    int64_t a, b = 0;
    bool flag = false;
    vector<int64_t> A(160);
    rep(i, 160){
        A.at(i) = pow(i, 5);
    }
    rep(i, 160){
        rep2(j, i, 160){
            if(A.at(j) - A.at(i) == X){
                a = j;
                b = i;
                flag = true;
            } else if(A.at(j) + A.at(i) == X){
                a = j;
                b = -i;
                flag = true;
            }
            if(flag) break;
        }
        if(flag) break;
    }
    cout << a << endl;
    cout << b << endl;

    return 0;
}


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

using namespace std;

int main(){
	while(true){
		string str;
		cin >> str;
		if(str=="-")break;
		int n;
		cin >> n;
		for(int i=0;i<n;i++){
			int s;
			cin >> s;
			string temp = str.substr(0,s);
			str.erase(str.begin() , str.begin()+s);
			str += temp;
		}
		cout << str << endl;
	}
	return 0;
}

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

int main(){
  int x, a, b;
  
  cin >> x >> a >> b;
  
  if(b - a <= 0){
    cout << "delicious" << endl;
  } else if(b - a < x + 1){
    cout << "safe" << endl;
  } else {
    cout << "dangerous" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
N,M = list(map(int,input().split()))
A = ['a']*N
for i in range(M):
  s,c = list(map(int,input().split()))
  if A[s-1] != 'a' and A[s-1] != str(c):
    print('-1')
    exit()
  else:
    A[s-1] = str(c)
if A[0] == '0' and len(A) != 1:
  print('-1')
  exit()
elif A[0] == 'a' and len(A) != 1:
  A[0] = '1'
for i in range(N):
      if A[i] == 'a':
        A[i] = '0'
print(''.join(A))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  vector<char>vec(4);
  for(ll i=0;i<4;i++){
    cin>>vec.at(i);
  }
  vector<ll>veco(2,0);
  if(vec.at(0)=='0'){
    if(vec.at(1)!='0'){
      veco.at(1)=1;
    }
  }
  if(vec.at(0)=='1'){
    if(vec.at(1)=='0'||vec.at(1)=='1'||vec.at(1)=='2'){
      veco.at(1)=1;
    }
  }
  if(vec.at(2)=='0'){
    if(vec.at(3)!='0'){
      veco.at(0)=1;
    }
  }
  if(vec.at(2)=='1'){
    if(vec.at(3)=='0'||vec.at(3)=='1'||vec.at(3)=='2'){
      veco.at(0)=1;
    }
  }
  vector<ll>yymm={1,0};
  vector<ll>mmyy={0,1};
  if(veco==yymm){
    cout<<"YYMM"<<endl;
  }
  else if(veco==mmyy){
    cout<<"MMYY"<<endl;
  }
  else if(veco.at(0)+veco.at(1)==2){
    cout<<"AMBIGUOUS"<<endl;
  }
  else{
    cout<<"NA"<<endl;
  }
  return 0;
  
}


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

using namespace std;

int n, m;
vector <int> tree[100001];
vector <int> emp[100001];
int dp[100001];
int gmx = 0;

int dfs(int ind)
{
    int mx = 0;
    if(dp[ind] != 0) return dp[ind];
    
    for(auto e : tree[ind])
    {
        mx = max(mx, dfs(e));
    }
    dp[ind] = mx+1;
    return mx + 1;
}

int main()
{
    cin >> n >> m;
    for(int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        tree[a].push_back(b);
        emp[b].push_back(a);
    }

    queue <int> q;
    for(int i = 1; i <= n; i++)
    {
        if(emp[i].empty()) q.push(i);
    }

    while(!q.empty())
    {
        gmx = max(gmx, dfs(q.front()));
        q.pop();
    }

    cout << gmx - 1 << endl;
}

Measured memory_bytes: 16256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
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;
}
///////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    vector<char> A(9);
    rep(i,9) cin >> A[i];

    cout << A[0] << A[4] << A[8] << endl;
}

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

using namespace std;

int solve(const int stones_height[], int memo[], const int &n, const int &k){
    int ans;
    if(memo[n] != -1) ans = memo[n];
    else if(n == 1) return 0;
    else{
        ans = abs(stones_height[n] - stones_height[n - 1]) + solve(stones_height, memo, n - 1, k);
        for(int i = 2; n - i >= 1 && i <= k; i++){
            ans = min(ans, abs(stones_height[n] - stones_height[n - i]) + solve(stones_height, memo, n - i, k));
        }
    }
    return memo[n] = ans;
}

int main(){
    int n, k;
    while(scanf("%d %d", &n, &k) != EOF){
        int stones_height[n + 1], memo[n + 1];
        for(int i = 0; i < n; i++){
            scanf("%d", &stones_height[i + 1]);
            memo[i + 1] = -1;
        }
        printf("%d\n", solve(stones_height, memo, n, k));
    }
    return 0;
}

Measured memory_bytes: 13928
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
 
using namespace std;
#define ll long long int
#define N 300000
int main(){
    ll n, a[N], d[N], sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        sum+=a[i];
        d[a[i]]++;
    }
    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        sum+=(c-b)*d[b];
        d[c]+=d[b];
        d[b]=0;
        cout<<sum<<endl;
    }
    return 0;
}

Measured memory_bytes: 5132
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7 #998244353
dir = [(-1,0),(1,0),(0,-1),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"


def main():
    n = int(ipt())
    x = [int(i) for i in ipt().split()]
    d = [x[i+1]-x[i] for i in range(n-1)]
    k = [1]
    for i in range(1,n):
        k.append(k[-1]*i%mod)

    #n!の逆元を求める
    g2 = [1,1]
    inverse = [0,1] #逆元テーブル計算用テーブル
    for i in range(2,n+1):
        inverse.append((-inverse[mod%i]*(mod//i))%mod)
        g2.append((g2[-1]*inverse[-1])%mod)

    ans = 0
    na = 0
    for i in range(1,n):
        na = na*i+k[i-1]
        na %= mod
        ans += na*d[i-1]*k[-1]*g2[i]
        ans %= mod

    print(ans)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 108400
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<algorithm>
#include<queue>
#include<functional>
#include<numeric>
#include<sstream>
#include<math.h>
#include <iomanip>
#define ll long long
#define PLL pair<ll,ll>
#define VS vector<string>
#define VL vector<ll>
#define VB vector<bool>
#define VPLL vector<pair<ll,ll> >
#define VVL vector<vector<ll> >
#define VVVL vector<vector<vector<ll> > >
#define VVB vector<vector<bool> >
#define rep(i,a) for (ll i=0;i<a;i++)
#define nrep(i,n,a) for (ll i=n;i<a;i++)
#define mrep(i,a) for(ll i=a;i>=0;i--)
#define INF 1145141919810
#define PI 3.141592653589793238
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VMIN(vec) *std::max_element(vec.begin(),vec.end())
#define VSUM(vec) std::accumulate(vec.begin(),vec.end(),0LL)
#define LTS(n) to_string(n)
#define STL(str) stoll(str)

using namespace std;

int main() {
	ll n, ma, mb;
	cin >> n >> ma >> mb;
	VL a(n), b(n), c(n);
	rep(i, n) cin >> a[i] >> b[i] >> c[i];
	VVVL dp(n+1, VVL(10*n+1, VL(10*n+1,INF)));
	dp[0][0][0] = 0;
	rep(i, n) rep(j, 10 * n+1) rep(k, 10 * n+1){
		if (dp[i][j][k] == INF) continue;
		dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
		dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);
		
	}ll ans = INF;
	nrep(i, 1, n * 10 + 1) nrep(j, 1, n * 10 + 1) if (i*mb == j*ma) ans = min(ans, dp[n][i][j]);
	cout << (ans==INF ? -1:ans) << endl;
	return 0;
}

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

//#include "atcoder/all"
//using namespace atcoder;

const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll k;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) cin >> a[i];
	sort(a.begin(), a.end());
	ll ok = -INF, ng = INF;
	while(ng - ok > 1){
		ll mid = (ok + ng) / 2;
		ll cnt = 0;
		rep(i,n){
			if(a[i] < 0){
				int l = -1, r = n;
				while(r - l > 1){
					int m = (l + r) / 2;
					if(a[m] * a[i] < mid) r = m;
					else l = m;
				}
				cnt += n - r;
			}
			else{
				int l = -1, r = n;
				while(r - l > 1){
					int m = (l + r) / 2;
					if(a[m] * a[i] < mid) l = m;
					else r = m;
				}
				cnt += r;
			}
			if(a[i] * a[i] < mid) --cnt;
		}
		if(cnt/2 < k) ok = mid;
		else ng = mid;
	}
	cout << ok << endl;
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	if (N < 105) cout << 0 << endl;
	else if (N < 135) cout << 1 << endl;
	else if (N < 165) cout << 2 << endl;
	else if (N < 189) cout << 3 << endl;
	else if (N < 195) cout << 4 << endl;
	else cout << 5 << endl;
}

Measured memory_bytes: 256
#
# abc095 b
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3 1000
120
100
140"""
        output = """9"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4 360
90
90
90
90"""
        output = """4"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 3000
150
130
150
130
110"""
        output = """26"""
        self.assertIO(input, output)


def resolve():
    N, X = map(int, input().split())
    m = []
    for _ in range(N):
        m.append(int(input()))
    print((X - sum(m)) // min(m) + N)


if __name__ == "__main__":
     # unittest.main()
     resolve()


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

ll max(ll a, ll b)
{
  if (a>b) return a;
  return b;
}

int main()
{
  ll a,b,k;
  cin >> a >> b >> k;
  ll x,y;
  if (a < k)
  {
    x = 0;
    y = max(a+b-k,0);
  } else {
    x = a-k;
    y = b;
  }
  cout << x << " "  << y << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, N, a, b) for(int i = a; i < N; i += b)

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

	vector<string> pic(H);
	rep(i, H) cin >> pic.at(i);
	rep(i, W + 2) cout << '#';
	cout << endl;
	rep(i, H){
		cout << '#';
		cout << pic.at(i);
		cout << '#' << endl;
	}
	rep(i, W + 2) cout << '#';
	cout << endl;
}

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

using namespace std;

int const N = 1e5 + 10;

char s[N];

int main ()
{
		scanf (" %s", s);

		int n = strlen (s);

		if (n <= 1)
		{
			printf ("-1 -1\n");
			return 0;
		}

		else if (n == 2)
		{
			if (s[0] == s[1])
				printf ("1 2\n");
			else
				printf ("-1 -1\n");
			return 0;
		}

		for (int i = 0; i + 2 < n; i++)
			if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2])
			{
				printf ("%d %d\n", i + 1, i + 3);
				return 0;
			}
		
		printf ("-1 -1\n");
		return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int gcd(int n, int m)
{
	int r;
	if (n > m) {
		int t = m;
		m = n;
		n = t;
	}
	while ((r = m % n) != 0) {
		m = n;
		n = r;
	}
	return n;
}

int main()
{
	int K,a,b,c,sum=0;
	cin >> K;
	for (a = 1;a <= K;++a)
		for (b = 1;b <= K;++b)
			for (c = 1;c <= K;++c)
			{
				sum += gcd(gcd(a, b), c);
			}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int T;
typedef long long LL;
const int MAX_N = 2e4+100;
int N,V; // N:个物品 V:容量
int v[MAX_N], w[MAX_N]; // v:价值, w:重量
LL f[MAX_N];

int main(){
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> V >> N;
    int mx = 0;
    for(int i = 0; i < N; ++i){
        cin >> w[i] >> v[i];
        mx = max(mx, w[i]);
    }
    V += mx;
    for(int i = 0; i <= V; ++i) f[i] = 1e18;
    f[0] = 0;
    for(int i = 0; i < N; ++i){
        for(int j = w[i]; j <= V; ++j){
            f[j] = min(f[j], f[j-w[i]]+v[i]);
        }
    }
    LL mn = 1e18;
    for(int j = V-mx; j <= V; ++j){
        mn = min(mn, f[j]);
    }
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>
#include<cmath>





using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;


vector<int> step(const vector<int>& a) {
    int n = a.size();
    vector<int> res(n + 1, 0);

    for (int i = 0; i < n; ++i) {
        int l = max(0, i - a[i]);
        ++res[l];
        int r = min(n, i + a[i] + 1);
        --res[r];
    }
    for (int i = 1; i < n; ++i)
        res[i] += res[i - 1];
    res.resize(n);
    return res;
}


void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < k; ++i) {
        int ok = 0;
        vector<int> b = step(a);
        for (int i = 0; i < n; ++i) {
            if (a[i] != b[i]) {
                ok = 1;
                break;
            }
        }
        if (!ok)
            break;
        swap(a, b);
    }
    for (int i = 0; i < n; ++i) {
        cout << a[i] << " ";
    }
    cout << "\n";

}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 4740
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = false;
bool f = false;
bool used[210];
bool graph[100][100];
bool visited[8];
int abc[26] = { 0 };
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

int main() {
	ll n, s;
	std::cin >> n >> s;
	if (n == s)std::cout << n + 1 << std::endl;
	else if (s > n)std::cout << -1 << std::endl;
	else if (n == 1) {
		if (s == 1)std::cout << 2 << std::endl;
		else std::cout << -1 << std::endl;
	}
	else {
		for (int i = 2;i <=sqrt(n);i++) {
			ll a = n, b = 0;
			while (true) {
				b += a%i;
				a /= i;
				if (a == 0)break;
			}
			if (b == s) {
				std::cout << i << std::endl;
				flag = false;
				break;
			}
		}
		if (flag) {
			for (int i = sqrt(n);i >= 1;i--) {
				ll c = (n - s) / i + 1, b = 0, a = n;
				if (c == 1)continue;
				while (true) {
					b += a%c;
					a /= c;
					if (a == 0)break;
				}
				if (b == s) {
					std::cout << c << std::endl;
					fl = true;
					break;
				}
			}
			if (fl == false)std::cout << -1 << std::endl;
		}
	}
	}

Measured memory_bytes: 256
N, *rest = $stdin.read.split.map(&:to_i)
TRAINS = rest.each_slice(3).to_a
def solve(i)
  t = 0
  TRAINS[i...(N-1)].each do |c, s, f|
    #p t: t, c: c, s: s, f: f
    if t <= s
      #p "#{s}まで待つ"
      t = s
    else
      diff = t%f==0 ? 0 : f - (t % f)
      #p "#{diff}だけ待つ"
      t += diff
    end
    #p "#{c}かかる"
    t += c
  end
  t
end
for i in 0...N
  p solve(i)
end


Measured memory_bytes: 1916
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
 
using namespace std;
typedef long long ll;
 
int main(){
  ll result = 0;
  int n, k;
  scanf("%d %d", &n, &k);
  result = k; 
  for(int i = 0; i < n-1; i++){
    result *= k-1; 
  }
  printf("%lld\n", result);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    int n,m;cin >> n >> m;
    vector<LL> h(n);
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    vector<bool> f(n,true);
    for (int i = 0; i < m; i++) {
        int a,b;cin >> a >> b;
        a--,b--;
        if(h[a] == h[b]){
            f[a] = false;
            f[b] = false;
        }
        else if(h[a] < h[b]){
            f[a] = false;
        }
        else{
            f[b] = false;
        }
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if(f[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4052
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<string>
#include<map>
#include<list>
 
using namespace std;
 
using ll = long long int ;

#define POW2(x) ((x)*(x))
 
 
int main(void){
	cin.tie(0);ios::sync_with_stdio(false);
 
    int n;
    double avg;
 
    cin >> n;

    vector<double> px(n);
    vector<double> py(n);

    vector<int> perm_idx(n);

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

    double sum = 0;
    int cnt = 0;
    do{
        for(int i = 1; i < n; i++){
            int p = perm_idx[i-1];
            int j = perm_idx[i];
            sum += sqrt(POW2(px[j]-px[p]) + POW2(py[j]-py[p]));
        }
        cnt++;
    }while(next_permutation(perm_idx.begin(), perm_idx.end()));

    avg = sum / (double)cnt;

    printf("%.10lf\n", avg);
 
    return 0;
}

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

int main(int qtd, char* nome[])
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = n/(a+b)*a;
	cout << ans + min(n%(a+b), a) << endl;
	
	return 0;
}

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

using namespace std;

const int N = 2e5 + 5;

int n;
int a[N];
long long dpl[N][3], dpr[N][3];

int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  for (int i = 0; i < n; ++i) {
    dpl[i+1][0] = dpl[i][0] + a[i];
    int cost = a[i] == 0 ? 2 : (a[i] & 1);
    dpl[i+1][1] = cost + min(dpl[i][0], dpl[i][1]);
    cost = (a[i] & 1) ? 0 : 1;
    dpl[i+1][2] = cost + min(dpl[i][0], min(dpl[i][1], dpl[i][2]));
    for (int j = 0; j < 2; ++j)
      dpl[i+1][j+1] = min(dpl[i+1][j], dpl[i+1][j+1]);
  }
  for (int i = n-1; i >= 0; --i) {
    dpr[i][0] = dpr[i+1][0] + a[i];
    int cost = a[i] == 0 ? 2 : (a[i] & 1);
    dpr[i][1] = cost + dpr[i+1][1];
    cost = (a[i] & 1) ? 0 : 1;
    dpr[i][2] = cost + dpr[i+1][2];
    for (int j = 0; j < 2; ++j)
      dpr[i][j+1] = min(dpr[i][j], dpr[i][j+1]);
  }
  long long ans = 1e18;
  for (int i = 0; i <= n; ++i) {
    // cerr << i << " " << dpl[i][2] << " " << dpr[i][2] << endl;
    ans = min(ans, dpl[i][2] + dpr[i][2]);
  }
  printf("%lld\n", ans);
  return 0;
}

Measured memory_bytes: 10368
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define all(a) (a).begin(), (a).end()

int main() {
	int m, f, r, s;
	char c;
	while (cin >> m >> f >> r) {
		s = m + f;
		if (m < 0 && f < 0)
			break;
		else if (m < 0 || f < 0)
			c = 'F';
		else if (s >= 80)
			c = 'A';
		else if (s >= 65)
			c = 'B';
		else if (s >= 50 || (s >= 30 && r >= 50))
			c = 'C';
		else if (s >= 30)
			c = 'D';
		else
			c = 'F';
		cout << c << endl;
	}

	return 0;
}


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

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

  int n;cin >> n;
  vector<ll> nums(n + 1);
  vector<ll> log(n);
  int tmp;
  rep_i(i, n){
    cin >> tmp;
    nums[tmp] += 1;
    log[i] = ll(tmp);
  }

  vector<ll> nums2(n + 1);
  rep_i(i, n + 1){
    if(nums[i] == 0){
      continue;
    }
    nums2[i] = nums[i]*(nums[i] - 1)/2;
  }
  ll sum = accumulate(nums2.begin(), nums2.end(), 0LL);
  rep_i(i, n){
    if(nums[log[i]] == 1){
      cout << sum << endl;
    }else{
      cout << sum - ll(nums[log[i]]*(nums[log[i]] - 1)/2) + ll((nums[log[i]] - 1)*(nums[log[i]] - 2)/2) << endl;
    }
  }

}


Measured memory_bytes: 7296
#include <stdio.h>

int main(void){

  long w,h,x,y;
  scanf("%ld %ld %ld %ld", &w, &h, &x, &y);
  double answer = w*h/2.0;
  printf("%lf ", answer);
  if (x*2 == w && y*2 == h) {
    printf("1\n");
  } else {
    printf("0\n");
  }

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include<vector>
#include<queue>
#include<string>
#include<list>
#include<algorithm>
using namespace std;
int main()
{
	vector<long long int> v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	cout << v[0] << " " << v[2] << endl;
}


Measured memory_bytes: 3164
use proconio::input;

fn main() {
    input! {
        _: usize,
        m: usize,
        ab: [(i64, i64); m],
    };
    let mut map = std::collections::BTreeMap::new();
    for &(a_i, b_i) in ab.iter() {
        *map.entry(a_i).or_insert(0) += 1;
        *map.entry(b_i).or_insert(0) += 1;
    }
    let ans = map.values().all(|count| count % 2 == 0);
    println!("{}", if ans { "YES" } else { "NO" });
}


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

int main() {
    long long R, G, B, N;
    cin >> R >> G >> B >> N;

    int ans = 0;

    for (int r = 0; r <= 3000; ++r) {
        for (int g = 0; g <= 3000; ++g) {
            int bB = N - r*R - g*G;
            if (N >= r*R + g*G && bB % B == 0) ans++;
        }
    }

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

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 998244353
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, k;
vector<int> vec, vec2;
int cnt0;

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		int a; cin >> a;
		if (a > 0)vec.push_back(a);
		if (a < 0)vec2.push_back(a);
		if (a == 0)cnt0++;
	}
	sort(all(vec));
	sort(all(vec2));
	int mi = -INF, ma = INF;
	while (ma - mi > 1) {
		int md = (mi + ma) / 2;
		int cnt = 0;
		for (int i = 0; i < (int)vec.size(); i++) {
			if (!vec2.empty()) {
				if (vec2[(int)vec2.size() - 1] * vec[i] < md)cnt += (int)vec2.size();
				else cnt += lower_bound(all(vec2), md / vec[i]) - vec2.begin();
			}
			if (vec[(int)vec.size() - 1] * vec[i] < md)cnt += (int)vec.size() - 1;
			else {
				if (vec[i] <= (md - 1) / vec[i])cnt += upper_bound(all(vec), (md - 1) / vec[i]) - vec.begin() - 1;
				else cnt += upper_bound(all(vec), (md - 1) / vec[i]) - vec.begin();
			}
		}
		for (int i = 0; i < (int)vec2.size(); i++) {
			if (!vec.empty()) {
				if (vec[0] * vec2[i] < md)cnt += (int)vec.size();
				else {
					int x = upper_bound(all(vec), md / vec2[i]) - vec.begin();
					cnt += (int)vec.size() - x;
				}
			}
			if (vec2[0] * vec2[i] < md)cnt += (int)vec2.size() - 1;
			else {
				if ((md - 1) / vec2[i] <= vec2[i]) {
					int x = lower_bound(all(vec2), (md - 1) / vec2[i]) - vec2.begin();
					cnt += (int)vec2.size() - x - 1;
				}
				else {
					int x = lower_bound(all(vec2), (md - 1) / vec2[i]) - vec2.begin();
					cnt += (int)vec2.size() - x;
				}
			}
		}
		cnt /= 2;
		if (0 < md) {
			cnt += cnt0 * (n - cnt0);
			cnt += cnt0 * (cnt0 - 1) / 2;
		}
		if (cnt < k)mi = md;
		else ma = md;
	}
	cout << ma - 1 << endl;
}

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

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

    vector<int> h(N);
    rep(i, N){cin >> h.at(i);}

    vector<int> dp(N);
    dp.at(0) = 0;
    dp.at(1) = dp.at(0) + abs(h.at(0) - h.at(1));
    for (size_t i = 2; i < N; i++)
    {

        dp.at(i) = min((dp.at(i-2) + abs(h.at(i) - h.at(i-2))), (dp.at(i-1) + abs(h.at(i) - h.at(i-1))));

    }
    
    cout << dp.at(N-1) << endl;

}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll n; cin>>n;
	printf("%lf\n",2*n*M_PI);
	return 0;
}

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef pair<lli, pii> ppi;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    static uint64_t splitmix64(uint64_t x) {
    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
    }
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const{
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        uint64_t x = hash1 ^ hash2;
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M ;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
lli solve(){
    lli n, r;
    cin>>n>>r;
    if(n >= 10)
        cout<<r<<"\n";
    else
        cout<<r + 100*(10-n)<<"\n";
    return 0;
 }
int main(){
    fastio;
    lli t;
    // cin>>t;
    t = 1;
    while(t>0){
        t--;
        solve();
    }
    return 0;
}


Measured memory_bytes: 256