akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>  
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define forn(i,a,b)        for( i = a ; i < b  ; i++ )
#define debug(x)           cout << #x << " " << x << " -- "
#define I__O               ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ll                 long long  
#define p(x)               cout << x << "\n" ; 
#define MOD                100000007
#define pi                 pair<int,int>
#define vi                 vector <int>
#define pb                 push_back
#define vp                 vector <pair<ll,ll>>
#define endl               cout << "\n"
#define mi                 map <int,int> 
#define f1                 first 
#define s1                 second    
#define in                 insert
#define all(x)             (x).begin(),(x).end() 
/* 
  date | time : 3/22/2020 9:57:02 AM 
*/    
using namespace std ; 
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set ; 
const int N = 2e5+7;  
int tests(){ 
	int n,m ;
	cin >> n >> m ;
	cout << n*(n-1)/2 + m*(m-1)/2  << '\n' ; 
	return 0; 
} 
int main(){
    I__O ;          
    int cases = 1 ; 
    // cin >> cases ; 
    for(int i = 1 ; i <= cases ; i++ ){
      // cout << "Case #" << i << ": " ;  	
      tests(); 
    }
    return 0 ; 
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		
		Scanner sc = new Scanner(System.in);
		
		int num = sc.nextInt();
		int []a = new int[num];
		
		long min, max, sum;
		
		for(int i=0; i<num; i++){
			a[i] = sc.nextInt();
		}
		min = a[0];
		for(int i=0; i<num; i++){
			if(a[i] < min){
				min = a[i];
			}
		}
		max = a[0];
		for(int i=0; i<num; i++){
			if(a[i] > max){
				max = a[i];
			}
		}
		sum = 0;
		for(int i=0; i<num; i++){
			sum += a[i];
		}
		System.out.println(min + " " + max + " " + sum);
		sc.close();
	}
}



Measured memory_bytes: 41296
#include<iostream>
#include<string>
using namespace std;
int main(){
	int n,a,b[10];
	while(true){
	cin>>n;
	if(n==0)
		break;
	for(int i=0;i<10;i++)
		b[i]=0;
	for(int i=0;i<n;i++){
		cin>>a;
		b[a]++;
	}
	for(int i=0;i<10;i++){
		if(b[i]==0)
			cout<<"-"<<endl;
		else{
		for(int j=0;j<b[i];j++)
			cout<<"*";
		cout<<endl;
		}
	}
	}
    return 0;
}
 

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    int a;cin>>a;
    cout<<a+a*a+a*a*a<<endl;
}

Measured memory_bytes: 3588
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    t = LI()
    a = LI()
    b = LI()
    a[0] -= b[0]
    a[1] -= b[1]
    if t[0]*a[0] == -t[1]*a[1]:
        print("infinity")
        return
    if a[0] < 0:
        a[0] *= -1
        a[1] *= -1
    if t[0]*a[0]+t[1]*a[1] > 0:
        print(0)
        return
    A = t[0]*a[0]+t[1]*a[1]
    k = t[0]*a[0]
    x = k//(-A)
    ans = 2*x+1
    if A*x+k == 0:
        ans -= 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 39760
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    vector<pair<int,int>> p(5);

    rep(i,5){
        cin >> p[i].second;
        p[i].first = p[i].second %10;
        if(p[i].first == 0) p[i].first = 10;
        p[i].second += 10 - p[i].first;
    }

    sort(all(p));
    reverse(all(p));

    int ans = 0;

    rep(i,4) ans += p[i].second;
    if(p[4].first != 10){
        ans += p[4].second + p[4].first - 10;
    }
    else{
        ans += p[4].second + p[4].first - 10;
    }

    dunk(ans);
}
    


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

using namespace std;

int main(){

    int N;
    cin >> N;

    double money = 0;

    for(int i = 0; i < N; i++){
        double x;
        string u;

        cin >> x >> u;

        if (u == "JPY") {
            money += x;
        }else{
            money += x * 380000.0;
        }
    }

    cout << money << endl;
    
    return 0;
}

Measured memory_bytes: 256
//you**can**do**anything 
#include <bits/stdc++.h> 
#define ll long long
#define read(i) scanf("%lli" , &i)
const ll maxn=1e6;
using namespace std; 

int main() 
{ 


ll n ;

read(n) ;
 vector<ll> fac(n+1 ,0); 
 
 int i =1 ;
 while(i<=n)
 {
 
 ll vv =  i ;
 while(vv<=n)
 {
 	fac[vv]++;
 	vv+=i;
 }
 i++;
 
 }

ll ans  =0 ;
for(int j =1 ;j<= n ;j++) ans+= j * fac[j];
cout<<ans;
 
}

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

#define ll long long

inline ll read() {
    ll x = 0, f = 1; char ch = getchar();
    for(; ch < '0' || ch>'9'; ch = getchar())
        if(ch == '-') f = -f;
    for(; ch >= '0' && ch <= '9'; ch = getchar())
        x = x * 10 + ch - '0';
    return x * f;
}

inline void chkmin( int &a, int b ) { if(a > b) a = b; }

inline void chkmax( int &a, int b ) { if(a < b) a = b; }

#define _ read()

#define ln endl

int main()
{
	int x = _, y = _;
	int tmp = 0;
	if(x == 1) 
		tmp += 300000;
	if(y == 1) 
		tmp += 300000;
	if(x == 2)
		tmp += 200000;
	if(y == 2)
		tmp += 200000;
	if(x == 3)
		tmp += 100000;
	if(y == 3)
		tmp += 100000;
	if(x == y && x == 1)
		tmp += 400000;
	cout << tmp << ln;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int count = 1;
        int length[] = new int[10];

        while(true){
        String str = sc.next();
        if(str.equals("-")) break;
        int m = sc.nextInt();
        int h[] = new int[str.length()];
        char har[] = new char[1000];

        for(int i=0; i<m; i++) h[i] = sc.nextInt();

        for(int i=0; i<str.length(); i++){
            har[i] = str.charAt(i);
        
        }

        //int t = str.length();

        for(int i=0; i<m; i++){
            for(int j=0; j<h[i]; j++){
                har[j+str.length()] = har[j];
            }
            for(int j=0; j<=str.length(); j++){
                har[j] = har[j+h[i]];
            }
        }
        //length[count] = str.length(); 
        //count++; 
        for(int i=0; i<str.length(); i++) System.out.print(har[i]);
        System.out.println("");
        
    }
       
    }
}


Measured memory_bytes: 26240
N=int(input())
C=[ list(map(int,input().split(' '))) for i in range(N)]
dp=[]
for i in range(N):
	if i==0:
		dp.append(C[0]) #[a0,b0,c0]
	else:
		dp.append([ C[i][j]+max(dp[i-1][(j+1)%3], dp[i-1][(j+2)%3]) for j in range(3) ])
print(max(dp[N-1]))

Measured memory_bytes: 47384
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
/*int 2 <= A;
int A <= 20;
int 1 <= B;
int B <= 20;*/
int main(void){
  int A;
int B;
int kuti = 1;
int c = 0;

  //scanf("%d"),&A;
  scanf("%2d %2d",&A,&B);
  //scanf("%d",&B);
  while(kuti < B){
    //if(c == 0){
   kuti = kuti + A-1;
   c = c + 1;
    //}
    /*else if(c >=1){
    int kuti = kuti + A;
         int c = c + 1;
  	}*/
  }
  printf("%2d",c);
  //return = 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int a,m;
   cin>>a>>m;
   vector<string>s(a);
   for(int i=0;i<a;i++)
   {
       cin>>s[i];
   }
   sort(s.begin(),s.end());
   for(int i=0;i<a;i++)
   {
       cout<<s[i];
   }
   cout<<endl;
    return 0;
}


Measured memory_bytes: 384
n = gets.to_s.to_i
c = gets.to_s.chars

l = 0
r = n - 1
ans = 0
while l < r
  if c[l] == 'W' && c[r] == 'R'
    ans += 1
    l += 1
    r -= 1
  elsif c[l] == 'W'
    r -= 1
  elsif c[r] == 'R'
    l += 1
  else
    l += 1
    r -= 1
  end
end

puts ans


Measured memory_bytes: 30380
#include<stdio.h> 
int main(){
    int a=0,b=0,c=0;
    scanf("%d %d %d",&a,&b,&c);
 
    if(a+b==c||a+c==b||b+c==a)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 128
// ABC 126 D: Even Relation
// https://atcoder.jp/contests/abc126/tasks/abc126_d

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#define INF 1000000000+7
using intpair = std::pair<int,int>;

std::vector<std::vector<intpair>> adjacency_list;
std::vector<bool> node_stat;
std::vector<int> isEven;

void paint(int vertex) {
    node_stat.at(vertex) = false;
    for (int i=0; i<adjacency_list.at(vertex).size(); i++) {
        int next_vertex = adjacency_list.at(vertex).at(i).first;
        int edge_weight = (adjacency_list.at(vertex).at(i).second + isEven.at(vertex)) % 2;
        isEven.at(next_vertex) = edge_weight;
        if (node_stat.at(next_vertex)) {
            paint(next_vertex);
        } else {}
    }
}

int main() {
    int total_node_num; std::cin >> total_node_num;
    adjacency_list.resize(total_node_num+1);
    node_stat.assign(total_node_num+1, true);
    isEven.assign(total_node_num+1, INF);
    int vertex, next_vertex, edge_weight;
    while (std::cin >> vertex >> next_vertex >> edge_weight) {
        edge_weight = edge_weight % 2;
        adjacency_list.at(vertex).push_back(std::make_pair(next_vertex, edge_weight));
        adjacency_list.at(next_vertex).push_back(std::make_pair(vertex, edge_weight));
    }

    for (int i=1; i<node_stat.size(); i++) {
        if (node_stat.at(i)) {
            isEven.at(i) = 0;
            paint(i);
        }
    }

    for (int i=1; i<isEven.size(); i++) {
        std::cout << isEven.at(i) << "\n";
    }
}

Measured memory_bytes: 8192
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	while(true){
		int n;
		cin >> n;
		if(n == 0){break;}
		
		int mini=-1e9-10,maxi=1e9+10;
		int a[1100] = {};
		for(int i = 0;i < n;i++){
			string s;
			cin >> s;
			if(s[0] == 'x'){
				a[i] = 1e9 + 2;
			}else{
				int num;
				sscanf(s.c_str(),"%d",&num);
				a[i] = num;
			}
		}
		
		bool flag = true;
		for(int i = 1;i<n;i++){
			if((i+1) % 2 == 0){
				if(a[i] == 1e9+2){
					if(a[i-1] == 1e9+2){
						flag = false;
						break;
					}else{
						mini = max(mini,a[i-1]+1);
					}
				}else{
					if(a[i-1] == 1e9+2){
						maxi = min(maxi,a[i]-1);
					}else{
						if(a[i] < a[i-1]){
							flag = false;
							break;
						}
					}
				}
			}else{
				if(a[i] == 1e9+2){
					if(a[i-1] == 1e9+2){
						flag = false;
						break;
					}else{
						maxi = min(maxi,a[i-1]-1);
					}
				}else{
					if(a[i-1] == 1e9+2){
						mini = max(mini,a[i]+1);
					}else{
						if(a[i] > a[i-1]){
							flag = false;
							break;
						}
					}
				}
			}
		}
		
		//cout << maxi << " " << mini << endl;
		if(flag){
			if(maxi == mini){
				cout << maxi << endl;
			}else{
				if(maxi < mini){
					cout << "none" << endl;
				}else{
					cout << "ambiguous" << endl;
				}
			}
		}else{
			cout << "none" << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll a, b, n;
	cin >> n >> a >> b;
	if ((b - a) % 2 == 0)
		cout << (b - a) / 2;
	else {
		ll ans = 0;
		if (a - 1 <= n - b) {
			ans += a - 1;
			ans += 1 + (b - a - 1) / 2;
		} else {
			ans += n - b;
			ans += 1 + (b - a - 1) / 2;
		}
		cout << ans;
	}
	return 0;
}

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

typedef pair<int,int > Pi;
struct edge{
  int to,cost;
};
typedef vector< vector< edge > > Graph;

int Dijkstr(Graph& info,int s,int g){

  //if(info.size() <= 0) return -1;

  vector<int> min_cost; // その場の最小値
  priority_queue<Pi,vector<Pi>,greater<Pi> >que;
  min_cost.resize(info.size(),-1);
  que.push( Pi(0,s) );
  min_cost[s]=0;

  while(!que.empty()){
    Pi p = que.top();
    que.pop();
    if(p.second == g) return p.first;
    if(p.first > min_cost[p.second]) continue;
    for(int i=0;i<info[p.second].size();i++){
      edge& e = info[p.second][i];
      if(min_cost[e.to] == -1 || e.cost + p.first < min_cost[e.to]){
	min_cost[e.to] = p.first + e.cost;
	que.push( Pi(min_cost[e.to],e.to) );
      }
    }
  }
  return -1;
}


int main(){

  int n,k,sele,a,b,c,d,e;
  while(cin >> n >> k, n){ //nが0以外の間
    Graph info;
    info.resize(k);
    for(int i=0;i<k;i++){
      cin >> sele;
      if(sele==0){
	cin >> a >> b;
	//aからbへの経路探索
	
	cout << Dijkstr(info,a,b) << endl;
      }
      else if(sele==1){
	cin >> c >> d >> e;
	info[c].push_back( (edge){d,e} );
	info[d].push_back( (edge){c,e} );
	//cout << "ehehe" << endl;
      }

    }
  }
}

      

Measured memory_bytes: 1380
#include <iostream>
using namespace std;
int main(){
int a,b,c,buf;
cin >> a >> b >> c ;
if(a>b){
buf = a;
a = b;
b = buf;
}
if(b>c){
buf = b;
b = c;
c = buf;
}
if(a>b){
buf = a;
a = b;
b = buf;
}
cout << a << " " << b << " " << c << endl;
return 0;
}



Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll; typedef long double ld;
const int INF32 = 1e9+10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N; cin >> N;
  string A, B, C; cin >> A >> B >> C;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    char a = A[i], b = B[i], c = C[i];
    set<char> S;
    S.insert(a); S.insert(b); S.insert(c);
    ans += (S.size() - 1);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <climits>

using namespace std;

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

    vector<int> p(n);
    for (int i = 0; i < n; i++) cin >> p[i];

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

    int sum = 0;
    for (int i = 0; i < k; i++) sum += p[i];

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b,c,d;
 cin >> a>> b>> c >>d;
 int e = a+b;
 int f = c+d;
 if(e>f){
     cout << "Left" << endl;
 }else if(e<f){
     cout << "Right" << endl;
 }else{
     cout << "Balanced" << endl;
 }
 return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    write(a + b + c > 21 ? "bust" : "win");
}

Measured memory_bytes: 256
q, h, s, d = map(int, input().split())
n = int(input())

ans = 0
if n >= 2:
  ans += ((n // 2) * min(8*q, 4*h, 2*s, d))
if n % 2 == 1:
  ans += min(4*q, 2*h, s)
print(int(ans))


Measured memory_bytes: 2940
(defun split (str delim)
  (let ((res (make-array 1 :element-type 'string
                           :fill-pointer 0
                           :adjustable t)))
    (loop for i from 0 below (length str)
          with start = 0
          when (eq (char str i) delim)
          do (vector-push-extend (subseq str start i) res)
             (setf start (1+ i))
          finally (let ((tail (subseq str start)))
                    (when tail
                      (vector-push-extend tail res))))
    res))

(let* ((line (map 'vector #'parse-integer (split (read-line) #\Space)))
       (n (aref line 0))
       (m (truncate (aref line 1) 2))
       (res 0)
       (nmin (min n m)))
  (incf res nmin)
  (decf n nmin)
  (decf m nmin)
  (incf res (truncate m 2))
  (format t "~A~%" res))

Measured memory_bytes: 17128
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
Ls = Is()
m = max(Ls)
if sum(Ls) - m > m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define LONGMAX 1e18
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define endl "\n"
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first	
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define INF 1e9
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
ll powe(ll x,ll y){ll res=1;while(y>0){if(y&1)res=res*x;y=y>>1;x=x*x;}return res;}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}
void ceilsearch(ll ar[],ll low,ll high,ll x,ll &y){ll mid=(low+high)/2;if(low>high)return;if(ar[mid]>=x){y=mid;ceilsearch(ar,low,mid-1,x,y);}else{ceilsearch(ar,mid+1,high,x,y);}}
int main()
{
	fastio();
	ll N,M;
	cin>>N>>M;
	ll X;
	cin>>X;
	cout<<min((X+N-1)/N,(X+M-1)/M)<<endl;
}

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

using namespace std;

#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()

const int MX = (int)5e5 + 10;
const int mod = 998244353;

int main(int argc, char* argv[]){

    cin.tie(0); cout.tie(0);
    ios_base::sync_with_stdio(0);

    // registerGen(argc, argv, 1);

    int n;
    cin >> n;

    int dam[n];
    for(int i = 0; i < n; ++i){
        cin >> dam[i];
        dam[i] <<= 1;
    }

    ll lhs = dam[0];
    for(int i = 1; i < n; ++i){
        lhs *= -1;
        lhs += dam[i];
    }

    int mountain[n];

    mountain[0] = lhs / 2;

    cout << mountain[0] << " ";

    for(int i = 1; i < n; ++i){
        mountain[i] = (dam[i - 1] / 2 - mountain[i - 1] / 2) * 2;
        cout << mountain[i] << " \n"[i == n - 1];
    }

    return 0;
}

Measured memory_bytes: 2176
n=int(input())
v=list(map(int,input().split()))
w=sorted(a for a in v[0::2])
x=sorted(a for a in v[1::2])
a=[[0,i]for i in range(10**5+1)]
b=[[0,i]for i in range(10**5+1)]
for t in w:
    a[t][0]+=1
for t in x:
    b[t][0]+=1
c=sorted(a)[::-1]
d=sorted(b)[::-1]
if c[0][1]==d[0][1]:
    t=max(c[1][0],d[1][0])
    print(n-c[0][0]-t)
else:
    print(n-c[0][0]-d[0][0])

Measured memory_bytes: 37032
#include <bits/stdc++.h>
#include <set>
#include <numeric>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;
 
// ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }


// const double PI = acos(-1);
// int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
// int a[12][12];



void solve() {
  int n; cin >> n;

  string n_str = to_string(n);
  // if (n_str[0]=='1') n_str[0]='9'

  int n_size = n_str.size();
  for (int i =0; i< n_size; i++) {
    if (n_str[i] == '9') n_str[i] = '1';
    else  n_str[i] = '9';
    if (i==2) break;
  }
  cout << n_str << endl;

}

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


Measured memory_bytes: 256
N = int(input())
counter = 0
for i in range(1,N):
    if (i**0.5).is_integer():
        #print(i,"here",N-1//i)
        counter += (N-1)//i
    else:
        #print(i,(N-1)//i-1)
        counter += (N-1)//i
print(counter)

Measured memory_bytes: 9616
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<iostream>
#include<set>
#include<map>
#define re register
#define ll long long
using namespace std;
inline int gi(){
	int f=1,sum=0;char ch=getchar();
	while(ch>'9'|| ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9'){sum=(sum<<3)+(sum<<1)+ch-'0';ch=getchar();}
	return sum*f;
}
const double eps=1e-10,Pi=acos(-1.0);
struct node{
	double x,y;
	node operator+(node b){return (node){x+b.x,y+b.y};}
	node operator-(node b){return (node){x-b.x,y-b.y};}
	node operator*(double b){return (node){x*b,y*b};}
	double len(){return sqrt(x*x+y*y);}
};
int fh(double a){return fabs(a)<eps?0:a>eps?1:-1;}
double cross(node a,node b){return a.x*b.y-a.y*b.x;}
double dot(node a,node b){return a.x*b.x+a.y*b.y;}
node projection(node p1,node p2,node p){node v=p2-p1;return p1+v*(dot(v,p-p1)/dot(v,v));}
node reflection(node p1,node p2,node p){node P=projection(p1,p2,p);P=P*2-p;return P;}
void Counter_Clockwise(node p1,node p2,node p){
	if(cross(p2-p1,p-p1)>eps){puts("COUNTER_CLOCKWISE");return;}
	if(cross(p2-p1,p-p1)<-eps){puts("CLOCKWISE");return;}
	if(dot(p2-p1,p-p1)<-eps){puts("ONLINE_BACK");return;}
	if(dot(p2-p1,p2-p1)>=dot(p-p1,p2-p1)){puts("ON_SEGMENT");return;}
	puts("ONLINE_FRONT");
}
bool insegment(node A,node B,node p){
	if(fh(cross(B-A,p-A)))return false;
	return ((fh(p.x-A.x)>=0 && fh(B.x-p.x)>=0) || (fh(p.x-A.x)<=0 && fh(B.x-p.x)<=0)) && ((fh(p.y-A.y)>=0 && fh(B.y-p.y)>=0) || (fh(p.y-A.y)<=0 && fh(B.y-p.y)<=0));
}
bool intersection(node A1,node A2,node B1,node B2){
	if(!fh(cross(B2-B1,A2-A1))){
		if(insegment(A1,A2,B1) || insegment(A1,A2,B2) || insegment(B1,B2,A1) || insegment(B1,B2,A2))return true;
		return false;
	}
	return fh(cross(A1-B1,B2-B1)*cross(A2-B1,B2-B1))<=0 && (fh(cross(B1-A1,A2-A1)*cross(B2-A1,A2-A1))<=0);
}
int main(){
	node p1,p2,p3,p4;
	int Q=gi();
	while(Q--){
		p1.x=gi();p1.y=gi();p2.x=gi();p2.y=gi();
		p3.x=gi();p3.y=gi();p4.x=gi();p4.y=gi();
		if(intersection(p1,p2,p3,p4))puts("1");
		else puts("0");
	}
	return 0;
}


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

int main() {
    int n,t;
    cin >> n >> t;
    int c[n],s[n];
    int cost = 2000;
    for(int i=0;i<n;i++){
        cin >> c[i] >> s[i];
    }
    for(int i=0;i<n;i++){
        if(t >= s[i]){
            cost = min(cost, c[i]);
        }
    }
    if(cost == 2000){
        cout << "TLE" << endl;
    }else{
        cout << cost << endl;
    }
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 

int main(){
    stack<char> act;
    string S;
    cin >> S;
    for(int i=0;i<S.length();++i){
        if(S[i]=='B'){
            if(act.empty()==false){
            act.pop();
        }
    }
        else{
            act.push(S[i]);
        }
    }
    string W;
    while(act.empty()==false){
        W+=act.top();
        act.pop();
    }
    reverse(W.begin(),W.end());
    cout << W;
    cout << endl;
}

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

#include <atcoder/all>
#define FASTIO
using namespace std;

using ll = long long;
using Vi = std::vector<int>;
using Vl = std::vector<ll>;
using Pii = std::pair<int, int>;
using Pll = std::pair<ll, ll>;

constexpr int I_INF = std::numeric_limits<int>::max();
constexpr ll L_INF = std::numeric_limits<ll>::max();

template <typename T1, typename T2>
inline bool chmin(T1& a, const T2& b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, const T2& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Prints {
private:
    class __Prints {
    public:
        __Prints(const char* sep, const char* term) : sep(sep), term(term) {}
        template <class... Args>
        void operator()(const Args&... args) const { print(args...); }
        template <typename T>
        void pvec(const T& vec, size_t sz) const {
            for (size_t i = 0; i < sz; i++)
                std::cout << vec[i] << (i == sz - 1 ? term : sep);
        }
        template <typename T>
        void pmat(const T& mat, size_t h, size_t w) {
            for (size_t i = 0; i < h; i++)
                for (size_t j = 0; j < w; j++)
                    std::cout << mat[i][j] << (j == w - 1 ? term : sep);
        }

    private:
        const char *sep, *term;
        void print() const { std::cout << term; }
        void print_rest() const { std::cout << term; }
        template <class T, class... Tail>
        void print(const T& head, const Tail&... tail) const { std::cout << head, print_rest(tail...); }
        template <class T, class... Tail>
        void print_rest(const T& head, const Tail&... tail) const { std::cout << sep << head, print_rest(tail...); }
    };

public:
    Prints() {}
    __Prints operator()(const char* sep = " ", const char* term = "\n") const { return __Prints(sep, term); }
};

Prints prints;

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    int N, M;
    cin >> N >> M;
    atcoder::scc_graph scc(N);
    for (ll i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        scc.add_edge(a, b);
    }
    auto res = scc.scc();
    prints()(res.size());
    for (const auto& vec : res) {
        prints("", " ")(vec.size());
        prints().pvec(vec, vec.size());
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    std::cin.tie(nullptr), std::cout.tie(nullptr);
    std::ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    std::ifstream ifs("./in_out/input.txt");
    std::cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    std::ofstream ofs("./in_out/output.txt");
    std::cout.rdbuf(ofs.rdbuf());
#endif
    std::cout << std::setprecision(18) << std::fixed;
    solve();
    std::cout << std::flush;
    return 0;
}

Measured memory_bytes: 40096
require "bigdecimal"
require "bigdecimal/util"
def GCD(m, n)
	return 0 if m == 0 || n == 0
	while m != 0 && n != 0
		if m > n then
			m %= n
		else
			n %= m
		end
	end
	return [m, n].max
end

def LCM(m, n)
	return 0 if m == 0 || n == 0
	return m * n / GCD(m, n)
end



a, b, c, d = gets.chomp.split.map(&:to_d)
e = LCM(c, d)

ac = (a / c).ceil * c
bc = (b / c).floor * c
ad = (a / d).ceil * d
bd = (b / d).floor * d
ae = (a / e).ceil * e 
be = (b / e).floor * e

#puts "ac:#{ac} bc:#{bc} ad:#{ad} bd:#{bd} ae:#{ae} be:#{be}"

cc = (bc - ac) / c + 1
dd = (bd - ad) / d + 1
ee = (be - ae) / e + 1

cc = 0 if ac > bc 
dd = 0 if ad > bd
ee = 0 if ae > be 

#puts "cc:#{cc} dd:#{dd} ee:#{ee}"
puts ((b - a + 1) - (cc + dd - ee)).to_i


Measured memory_bytes: 14408
n = STDIN.gets.chomp.to_i
ary = STDIN.gets.chomp.split(' ').map(&:to_i)

count = 0
n.times do |i|
  (n-1).downto(i+1) do |j|
    if ary[j] < ary[j-1]
      ary[j], ary[j-1] = ary[j-1], ary[j]
      count += 1
    end
  end
end

puts ary.join(' ')
puts count

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

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

  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  double lim = (double)sum / (4 * m);

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

  if (cnt >= m)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
    //Enter your code here Tanmay:)
    int n,sum=0;
    cin>>n;
    if(n%2==0)
        sum=n/2;
    else
        sum=n/2+1;
    float prop=(sum*1.0)/n;
    cout<<prop;

}
signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

int main(){
  int x;
  cin>>x;
  int tf,tff,ft,ans;
  tf=x/500;
  tff=(x%500)/5;
  ft=x/5;
  ans=max(tf*1000+tff*5,ft*5);
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
s,t = 2.times.map{gets.chomp}
a,b = 2.times.map{Hash.new{|h,k|h[k] = []}}
s.size.times do |i|
  a[s[i]] << i
  b[t[i]] << i
end
puts a.values.sort == b.values.sort ? "Yes" : "No"

Measured memory_bytes: 7104
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define se second
#define fi first
#define rep(i, l, r) for (ll i = (ll)(l); i < (ll)(r); i++)
#define print(v) for (const auto itr : v){cout << itr << ' ';} cout << endl;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define inf 1e18
using namespace std;
const ll INF = 1e18L + 5;
const ll maxn = 1e5+5, maxn1=202;
ll ceel(ll a, ll b)
{
   if (a % b == 0)
       return a / b;
   return a / b + 1;
}
ll modneg(ll a,ll m)
{
    a = a % m;
    if(a<0)
        a=a+m;
    return a;
}
ll powermod(ll x, unsigned ll y, ll p){ll res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
ll lcm(ll a, ll b) { return (a * b) / __gcd(a, b); };
ll csb(ll n){ ll count = 0;while (n){ count += n & 1; n >>= 1; } return count;}
vector <ll> v[2005];
ll lvl[2005];
bool vis[2005];
void bfs(ll a)
{
    queue<ll> q;
    q.push(a);
    lvl[a]=0;
    vis[a]=1;
    while(!q.empty())
    {
        ll b=q.front();
        q.pop();
        for(auto it:v[b])
        {
            if(!vis[it])
            {
                q.push(it);
                vis[it]=1;
                lvl[it]=lvl[b]+1;
            }
        }
    }

}

int main()
{

ll test,n,k,i,j,a,b,m,x,y;
cin>>n>>x>>y;
for(i=1;i<n;i++)
{
    v[i].pb(i+1);
    v[i+1].pb(i);
}

v[x].pb(y);
v[y].pb(x);
// for (i = 1; i < n; i++)
// {
//     cout << i << "--";
//     for (auto it : v[i])
//         cout << it << " ";
//     cout << endl;
// }
map <ll,ll> mp;
for(i=1;i<n;i++)
{
    memset(vis,0,sizeof(vis));
    memset(lvl,0,sizeof(lvl));
    bfs(i);    
    for(j=i+1;j<=n;j++)
    {
        mp[lvl[j]]++;
        // cout<<j<<" "<<lvl[j]<<endl;
    }
}
for(i=1;i<n;i++)
    cout<<mp[i]<<" ";
// for(auto it:mp)
//     cout<<it.se<<" ";
return 0;
}

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

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

Measured memory_bytes: 256
d[11][10];main(i,j,k,n){for(;scanf("%d",&n)*n;printf("%d %d\n",i,*d[i]%*d[10])){for(memset(d,8,500);n--;d[i][j]=d[j][i]=k)scanf("%d%d%d",&i,&j,&k);for(k=10;i=k--;d[k][k]=0)for(i=10;i--;)for(j=10;j--;)d[i][j]=fmin(d[i][j],d[i][k]+d[k][j]);for(;k++<9;*d[i]>*d[k]?i=k:0)for(j=9;j;)*d[k]+=d[k][j--];}}

Measured memory_bytes: 0
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 1000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
using namespace std;

int n,m,ans;
int a[111111],b[111111];
int dp[111111];
signed main(){
    cin>>m>>n;
    rep(i,n){
    	cin>>a[i]>>b[i];
    }
    fill(dp,dp+m,INF);
    for(int i=m;i>=0;i--){
    	for(int j=0;j<n;j++){
    		if(i-a[j]<0){
    			dp[0]=min(dp[0],dp[i]+b[j]);
    		}
    		else{
    			dp[i-a[j]]=min(dp[i-a[j]],dp[i]+b[j]);
    		}
    	}
    }
    cout<<dp[0]<<endl;
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;



int main(){
    int n,W;
    cin >> n >> W;
    vector<ll> w(n);
    vector<int> v(n);
    rep(i,n) cin >> w[i] >> v[i];
    int vMax = 1e6;
    ll wMAX = 1e12*1LL;
    vector<vector<ll>> dp(n,vector<ll>(vMax,wMAX));
    
    rep(i,v[0]+1){
        dp[0][i] = w[0];
    }
    dp[0][0] = 0LL;
    rep(i,n-1){
        rep(oldV,1e5+1){
            int newV = oldV + v[i+1];
            dp[i+1][oldV] = min(dp[i+1][oldV],dp[i][oldV]);
            dp[i+1][newV] = min(dp[i+1][newV],dp[i][oldV] + w[i+1]);
        }
    }
    int ans = 0;
    rep(i,1e5+1){
        if (dp[n-1][i] <= W) ans = i;
    }
    cout << ans;
    
}


Measured memory_bytes: 789632
#include<stdio.h>
#include<string.h>
#define MAX 100000

typedef struct{
  char name[10];
  int time;
}Process;

void enqueue(Process );
Process dequeue(void);
void calc(int n); //計算する関数

int n=0,j=0;//ループ回数を記録する外部変数
int head=0, tail=0;
int sum=0;//時間の合計を記録する外部変数

Process pro[MAX];

int main(){
  int i;
  int ms;
  
  scanf("%d%d", &n, &ms);
  
  for( i=0 ; i<n ; i++){
    scanf("%s%d", pro[i].name, &pro[i].time);
    tail++;
  }

  calc(ms);//計算開始
    
  return 0;
}

void calc(int ms){
  int i, dif;
  Process x;
  
  for( i=0; head!=tail ; i++){
    dif = pro[head].time - ms;
    if(dif  > 0){
      x = dequeue();
      x.time = dif;
      enqueue(x);
      sum += ms;
    }else{
      sum += pro[head].time;
      x = dequeue();
      printf("%s %d\n",x.name,sum);
    }
  }
}

void enqueue(Process x){
  pro[tail] = x;
  
  if(tail+1 == MAX){
    tail = 0;
  }else{
    tail++;
  }
}

Process dequeue(){
  Process x;

  x = pro[head];
  
  if(head+1 == MAX){
    head = 0;
  }else{
    head++;
  }

  return x;
}



Measured memory_bytes: 3244
#include<stdio.h>

#define MAX_N 200001

int main(void){

    int N,A[MAX_N],i,ans[MAX_N] = {0};

    scanf("%d",&N);
    for(i = 2;i <= N;i++) scanf("%d",&A[i]);
    for(i = 2;i <= N;i++) ans[A[i]]++;
    for(i = 1;i <= N;i++) printf("%d\n",ans[i]);
    return 0;
}

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

const int Nmax=200010;

int main() {
	string S,T;
	cin >> S >> T;
	bool flag=false;
	int cnt=0,k=0;
	for(int i=S.length()-T.length();i >= 0;i--){
		if(!flag){
          	flag = true;
			for(int j=0;j < T.length();j++){
				if(S[i+j] != '?' && S[i+j] !=  T[j]) flag = false;
			}
      		if(flag){
		  		for(int j=0;j < T.length();j++) S[i+j] = T[j];
		  	}
		}
	}
	for(int i=0;i < S.length();i++){
		if(S[i] == '?') S[i] = 'a';
	}
	if(flag) cout << S << endl;
	else cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,child,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  double a, b;
  cin >> a >> b;
  cout << (a / b) << endl;
  return 0;
}


Measured memory_bytes: 256
//Solution By SlavicG
#include "bits/stdc++.h"
using namespace std;
 
#define        ll                   long long
 
#define  forn(i,n)                  for(int i=0;i<n;i++)
#define     all(v)                  v.begin(), v.end()
#define    rall(v)                  v.rbegin(),v.rend()
 
#define        pb                    push_back
#define     sz(a)                    (int)a.size()
 
#define     fastio                  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define       endl                  "\n"

const int N = 2e5;
vector<int> adj[N];
bool vis[N];
vector<int> component;
void dfs(int i) {
    component.push_back(i);
    vis[i] = true;
    for(auto u:adj[i]) {
        if(!vis[u]) {
            dfs(u);
        }
    }
}
int main()
{
	int n,m;
	cin >> n >> m;
	while(m--)
	{
		int x,y;
		cin >> x >> y;
		x,y;
		adj[x].pb(y);
		adj[y].pb(x);
	}
	vector<vector<int>> ans;
	for(int i = 1;i <= n;i++)
	{
		if(!vis[i])dfs(i);
		if(sz(component))ans.pb(component);
		component.clear();
	}
	cout << sz(ans) - 1 <<"\n";
}

Measured memory_bytes: 13588
#include <bits/stdc++.h>
#define MOD (ll)(998244353)
#define MAX (ll)(1e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;


int main () {
	int n;
	cin >> n;
	int ar[n], mi = n + 1;
	int cc = 0;
	for (int i = 0; i < n;i++) {
		cin >> ar[i];
		if (mi > ar[i]) {
			cc++;
		}
		mi = min (mi, ar[i]);
	}
	cout << cc << "\n";
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String source=br.readLine();
		char s1=source.charAt(0);
		char s2=source.charAt(1);
		char s3=source.charAt(2);

		int price=700;

		if(s1!='x'){
			price+=100;
		}
		if(s2!='x'){
			price+=100;
		}

		if(s3!='x'){
			price+=100;
		}

		System.out.println(price);
	}
}


Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> PA;
typedef priority_queue<int, vector<int>, greater<int> > PQG;
#define REP(i, a, n) for(ll i = (ll) a;i < (ll) n;i++)
#define fi first
#define se second
#define pb push_back
#define INF 1000000009
#define MOD 1000000007
#define MAXN 102
#define MAXM 100005
#define MAXV 1000000009

ull n, t[MAXN], ans = 1;

ull gcd(ull a, ull b){
    if(b == 0){
        return a;
    }
    else{
        return gcd(b, a % b);
    }
}

ull lcm(ull a, ull b){
    ull g = gcd(a, b);
    return (a / g) * b;
}

int main()
{
    cin >> n;
    REP(i, 0, n){
        cin >> t[i];
        ans = lcm(ans, t[i]);
    }
    cout << ans << endl;



    return 0;
}
/*
*/





Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
		static Scanner sc = new Scanner(System.in);
		public static void main(String[] args) {
			int n = sc.nextInt();
			
			int t,x,y,dis;
			String ans = "Yes";
			for (int i=0; i<n; i++) {
				t = sc.nextInt();
				x = sc.nextInt();
				y = sc.nextInt();
				dis = x+y;
				if (dis > t) {
					ans = "No";
					break;
				}
				else {
					if ((t-dis)%2 == 1) {
						ans = "No";
						break;
					}
				}
			}
			
			System.out.println(ans);
		}
	}

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

int main(int argc, const char * argv[]) {
    // insert code here...
    int N;
    bool flag = false;
    cin >> N;
    for (int i = 0; i < 26; i++) {
        int four = i;
        for (int i = 0; i < 15; i++) {
            int seven = i;
            if (4 * four + 7 * seven == N) {
                flag = true;
                break;
            }
        }
    }
    if (flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()

const ll MOD = 1000000007;

int N;
ll A[200010];

bool f(ll md) {
	map<ll, ll> M;
	M.insert({ 1,0 });
	ll a, b;
	for (int i = 1;i < N;i++) {
		if (A[i - 1] < A[i])continue;
		else {
			if (M.count(A[i])) M[A[i]]++;
			else M.insert({ A[i],1 });
			while (1) {
				auto it = M.end();
				it--;
				tie(a, b) = *it;
				if (a == A[i])break;
				while (1) {
					b /= md;
					a--;
					if (b == 0)break;
					if (M.count(a)) {
						M[a] += b;
						break;
					}
				}
				M.erase(it);
			}
		}
	}

	while (1) {
		auto it = M.end();
		it--;
		tie(a, b) = *it;
		if (a == 1)break;
		while (1) {
			b /= md;
			a--;
			if (b == 0)break;
			if (M.count(a)) {
				M[a] += b;
				break;
			}
		}
		M.erase(it);
	}
	return M[1] < md;
}

ll binary(ll ng, ll ok) {
	if (ng + 1 == ok)return ok;
	ll mid = (ng + ok) / 2;
	if (f(mid)) {
		return binary(ng, mid);
	}
	else {
		return binary(mid, ok);
	}
}

int main() {
	/*
	random_device rnd;
	mt19937 mt(rnd());
	uniform_int_distribution<> randA(1, 1000000000);
	*/

	cin.tie(0); ios::sync_with_stdio(false);

	cin >> N;
	
	for (int i = 0;i < N;i++)cin >> A[i];
	//for (int i = 0;i < N;i++)A[i] = randA(mt);

	//単調増加なら1、そうでなければ2以上
	for (int i = 1;i < N;i++) {
		if (A[i - 1] >= A[i]) {
			cout << binary(1, 200000) << endl;
			return 0;
		}
	}
	cout << 1 << endl;
	return 0;
}

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

int main(){
	int n, a;
	int max = 0;
	unordered_map<int, int> m;
	cin >> n;
	for(int i=0; i<n; i++){
		cin >> a;
		m[a-1]++;
		m[a]++;
		m[a+1]++;
		if(m[a-1] > max) max = m[a-1];
		if(m[a] > max) max = m[a];
		if(m[a+1] > max) max = m[a+1];
	}
	cout << max;
}


Measured memory_bytes: 4260
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

//マクロ
#define REP(i,n) for(int i=0; i<(int)(n); ++i)
#define REPS(i,n) for(int i=1; i<=(int)(n); ++i)
#define RREP(i,n) for(int i=(int)(n)-1; i>=0; --i)
#define RREPS(i,n) for(int i=(int)(n); i>0; --i)
#define FOR(i,s,e) for(int i=(int)(s); i<(int)(e); ++i)
#define RFOR(i,s,e) for(int i=(int)(e)-1; i>=(int)(s); --i)

#define All(a) (a).begin(),(a).end()

//定数
#define INF 1e9
#define MOD (int)(1e9+7)

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

//とりあえず書いておく変数
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

//今回の変数
vector<vector<int>> v(200001);
vector<ll> score(200001,0);
vector<bool> f(200001, false);

//使用する関数
void dfs(int a, ll s) {
	//cout << a << endl;
	if (f[a])return;
	//cout << "done" << endl;
	f[a] = true;
	score[a] += s;
	REP(i, v[a].size()) {
		dfs(v[a][i], score[a]);
	}
}

int main()
{
	string s,t;
	cin >> s >> t;

	vector<vector<int>> a(26);
	REP(i, s.length()) {
		a[s[i] - 'a'].push_back(i);
	}

	int now = -1;
	int cnt = 0;
	REP(i, t.length()) {
		//cout << "i:" << i << " now ="<<now<< endl;
		int tar = t[i] - 'a';
		int idx = upper_bound(All(a[tar]), now) - a[tar].begin();
		//cout << "tar=" << tar << " a[tar].size()="<<a[tar].size()<<" idx=" << idx<<endl;
		if (idx == a[tar].size()) {
			if (now == -1) {
				cout << -1 << endl;
				return 0;
			}
			now = -1;
			i--;
			cnt++;
			continue;
		}
		now = a[tar][idx];
	}
	ll ans = (ll)s.length()*cnt + now + 1;
	cout << ans << endl;
}

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

int N,M;
int edge[51][51];
int VF[51];

bool dfs(int s,int goal){
  int result = false;

  if(s==goal)
    return true;

  for(int next=1;!result&&next<=N;next++){
    if(edge[s][next]==1&&VF[next]==0){
      VF[next]=1;
      result=dfs(next,goal);
      VF[next]=0;
    }
  }
  return result;
}

bool findPath(int a,int b){
  bool result=false;
  VF[a]=1;
  for(int next=1;!result&&next<=N;next++)
    if(next!=a&&next!=b&&edge[a][next]==1){
      VF[next]=1;
      result = dfs(next,b);
      VF[next]=0;
    }
  VF[a]=0;

  return result;
}


int main(){


  cin>>N>>M;

  for(int i=1;i<=N;i++){
    for(int j=1;j<=N;j++)
      edge[i][j]=0;
    VF[i]=0;
  }
  for(int i=0;i<M;i++){
    int ai,bi;
    cin>>ai>>bi;
    edge[ai][bi]=edge[bi][ai]=1;
  }
  int result=0;
  for(int i=1;i<=N;i++)
    for(int j=i+1;j<=N;j++)
      if(edge[i][j]==1&&!findPath(i,j)){
        result++;
      }

  cout<<result<<endl;

  return 0;
}


Measured memory_bytes: 256
import math
N = int(input())
max = 0
max2 = 0
for i in range(2, int(math.sqrt(N)+ 2)):
    if N % i == 0:
        max = i
        max2 = N // i
if max != 0:
    print(max + max2 - 2)
else:
    print(N -1)
#print(max, max2)


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




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

    string s;
    cin>>s;
    if(s[s.size()-1]=='s') {
        s+="es";
    } else {
        s+="s";
    }
    cout<<s;

}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <algorithm>
#include<string>
using namespace std;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int X, A, B;
    cin >> X >> A >> B;

    if (B - A <= 0) {
        cout << "delicious" << endl;
    } else {
        if (B - A <= X) {
            cout << "safe" << endl;
        } else {
            cout << "dangerous" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N;
vector<ll> par;
void initialize(){
 for(ll i = 1; i < 10000000; i++){
par[i] = i;} //始めは任意のノードの親が自分自身
}
ll root(ll x){
if(par[x] == x){ return x;}
else{ return par[x] = root(par[x]);}}

void unite(ll x, ll y){
if( root(x) == root(y)){ return;}
else{
 par[root(x)] = root(y);}}

bool issame(ll x, ll y){
return root(x) == root(y);}



int main(){
ll M; cin >> N >> M; par.resize(10000000); initialize(); 
  
  
  for(ll i = 1; i <= N; i++){ ll p; cin >> p; unite(p,i+100000);}
  
  for(ll i = 0; i < M; i++){ 
    ll x,y; cin >> x >> y; unite(x,y);}
  
  ll cnt = 0;
  
  for(ll i = 1; i <= N; i++){
    if(issame(i,i+100000)){ cnt++;}}
  
  cout << cnt << endl; return 0;}
                            
  

Measured memory_bytes: 78336