akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << "["<< *it << " = " << a << "]"<< endl;
    err(++it, args...);
}
using ll = long long;



int main() {
    ios::sync_with_stdio(false);

    ll a,b;
    cin >> a >> b;

    int cnt = 1;

    ll x = 2;

    while (a>1 && b > 1 && x * x <= max(a,b)) {
        //~ debug(x,max(a,b));
        if ( a % x == 0 && b % x == 0) {
            //~ debug(x);
            cnt++;
            while (a % x == 0)
                a /=x;
            while (b % x == 0)
                b /=x;
        }
        x++;
    }
    if (a > 1 && b > 1 ) {
        if (__gcd(a,b) >1) {
            cnt++;
        }
    }
    cout << cnt;

}


Measured memory_bytes: 256
/*I wanna be the very best, like no one ever was...*/

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma=strchr(names+1,',');cerr.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1, args...);
}
#else
#endif



int main() {
    io;
    // freopen("in","r",stdin); 
    // freopen("out","w",stdout);
  

 
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<k){
        cout<<x*n;
    }
    else {
        cout<<k*x+ (n-k)*y;
    }
    
 
    return 0;
}

Measured memory_bytes: 256
from collections import deque
#input
N,M=map(int,input().strip().split())
A=list(map(int,input().strip().split()))

#M回全て、その時点で一番高価な商品に割引を
#適用した時、支払金額が最小となる。

#安い順にソート
A.sort()

#割引券を一回でも使った商品を格納
dp=deque([])
#割引未適用品(A)と、適用済み品(dp)の最高値を比較し、大きい方に割引を適用
for m in range(M):
    if len(dp)==0:
        tmp=A.pop()
    elif len(A)==0:
        tmp=dp.popleft()
    else:
        if A[-1]>=dp[0]:
            tmp=A.pop()
        else:
            tmp=dp.popleft()
    dp.append(tmp//2)
print(sum(A)+sum(dp))

Measured memory_bytes: 20372
round=lambda x:(x*2+1)//2
s = 0
i = 0
n_sum = 0
while True:
    try:
        v, n = map(int, input().split(","))
        s += v*n
        n_sum += n
        i += 1
    except:
        break
print(s)
print(int(round(n_sum/i)))



Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

#define int long long

void ins(multiset<int> &a, int x, int &s) {
	s += x;
	a.insert(x);
}

void ers(multiset<int> &a, int x, int &s) {
	s -= x;
	a.erase(a.find(x));
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);

	int q;
	cin >> q;
	multiset<int> lp;
	multiset<int> rp;
	int sb = 0;
	int ls = 0;
	int rs = 0;
	while (q--) {
		int tp;
		cin >> tp;
		if (tp == 1) {
			int a, b;
			cin >> a >> b;
			sb += b;
			if (lp.empty() || a <= *lp.rbegin()) {
				// cerr << "lol " << endl;
				ins(lp, a, ls);
				// cerr << "iok" << endl;
				if (lp.size() >= rp.size() + 2) {
					ins(rp, *lp.rbegin(), rs);
					ers(lp, *lp.rbegin(), ls);
				}
			} else {
				ins(rp, a, rs);
				if (rp.size() > lp.size()) {
					ins(lp, *rp.begin(), ls);
					ers(rp, *rp.begin(), rs);
				}
			}
		} else {
			int v = *lp.rbegin();
			int ans = 0;
			ans += v * ((int)lp.size()) - ls;
			ans += rs - v * ((int)rp.size());
			ans += sb;
			cout << v << ' ' << ans << endl;	
		}
	}
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;

vector <vector<ll>> graph;
vector <bool> visited;
vector <ll> depth;
vector <ll> out;

void dfs(ll v,ll p,ll d){
	visited[v] = true;
	depth[v] = d;
	for (int z=0;z<graph[v].size();z++){
		if (graph[v][z] == p) continue;
		if (!visited[graph[v][z]]){
			dfs(graph[v][z],v,d+1);
		} else {
			if (depth[v] > depth[graph[v][z]]){
				cout << v << " " << graph[v][z] << endl;
				out[v]++;
			}
		}
	}
	if (p != 0){
		if (out[v] & 1){
			cout << v << " " << p << endl;
			out[v]++;
		} else {
			cout << p << " " << v << endl;
			out[p]++;
		}
	}
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,m;
	cin >> n >> m;
	graph.resize(n+1);
	visited.resize(n+1,false);
	depth.resize(n+1);
	out.resize(n+1,0);
	for (int z=0;z<m;z++){
		ll a,b;
		cin >> a >> b;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}
	if (m & 1) {
		cout << -1 << endl;
		return 0;
	}
	dfs(1,0,1);
}

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

int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);

  int sum=0;


  rep(i,n) cin>>a[i];
  rep(i,n) {
      cin>>b[i];
      sum+=b[i];
  }
  rep(i,n) cin>>c[i];

  rep(i,n-1){
      if(a[i]+1==a[i+1]) sum+=c[a[i]-1];
  }

  cout<<sum;

}

Measured memory_bytes: 3604
from collections import defaultdict
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
blue_dic = defaultdict(int)
red_dic = defaultdict(int)
res = 0
for i in range(n):
    blue_dic[s[i]] += 1
for i in range(m):
    red_dic[t[i]] += 1
for i in range(n):
    res = max(res, blue_dic[s[i]] - red_dic[s[i]])
print(res)


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

int main() {
    long long X,Y;
    cin >> X >> Y;

    int res = 1;
    while(X * 2 > 0 && X * 2 <= Y) {
        X *= 2;
        ++res;
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s;
int a[200005],d[200005],b[200005];
ll ans;
int main(void){
    cin>>s;
    d[s.size()-1]=1;
    for(int i=s.size()-1;i>=0;i--){
        a[i]=s[i]-48;
        if(i!=s.size()-1){
            d[i]=d[i+1]*10%2019;
            d[i+1]=d[i+1]*a[i+1]%2019;
        }
    }
    d[0]=d[0]*a[0];
    /*for(int i=0;i<s.size();i++){
        cout<<d[i]<<endl;
    }*/
    for(int i=0;i<s.size();i++){
        b[i+1]=(b[i]+d[i])%2019;
    }
    sort(b,b+s.size()+1);
    int t=1;
    for(int i=1;i<s.size()+1;i++){
        if(b[i]==b[i-1]){
            t++;
        }else{
            ans+=(t-1)*t/2;
            t=1;
        }
    }
    ans+=(t-1)*t/2;
    cout<<ans<<endl;
    
}


Measured memory_bytes: 6056
import java.util.Scanner;

public class Main {
	static int max = 0;
	static int h, w, c;
	static int n;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (true) {
			h = sc.nextInt();
			w = sc.nextInt();
			c = sc.nextInt();
			max = 0;
			if (h == 0)
				break;
			int panel[][] = new int[h][w];
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					panel[i][j] = sc.nextInt();
				}
			}
			color(panel, 1);
			System.out.println(max);
		}
	}

	private static void color(int[][] panel, int num) {
		if (num == 6) {
			int[][] copypanel = new int[h][];
			for (int i = 0; i < h; i++)
				copypanel[i] = panel[i].clone();
			copypanel[0][0] = 0;
			n = 1;
			countpanel(copypanel, 0, 0);
			if (n > max) {
				max = n;
			}
			return;
		}
		for (int col = 1; col <= 6; col++) {
			// System.err.println(num + ":" + col);
			if (panel[0][0] == col)
				continue;

			int[][] copypanel = new int[h][];
			for (int i = 0; i < h; i++)
				copypanel[i] = panel[i].clone();

			copypanel[0][0] = col;
			connect(copypanel, 0, 0, col, panel[0][0]);
			color(copypanel, num + 1);
		}

	}

	private static void countpanel(int[][] panel, int i, int j) {
//		debugp(panel);
		if (j + 1 < w) {
			if (panel[i][j + 1] == c) {
				panel[i][j + 1] = 0;
				n++;
				countpanel(panel, i, j + 1);
			}
		}
		if (j - 1 >= 0) {
			if (panel[i][j - 1] == c) {
				panel[i][j - 1] = 0;
				n++;
				countpanel(panel, i, j - 1);
			}
		}
		if (i + 1 < h) {
			if (panel[i + 1][j] == c) {
				panel[i + 1][j] = 0;
				n++;
				countpanel(panel, i + 1, j);
			}
		}
		if (i - 1 >= 0) {
			if (panel[i - 1][j] == c) {
				panel[i - 1][j] = 0;
				n++;
				countpanel(panel, i - 1, j);
			}
		}
	}

	private static void debugp(int[][] panel) {
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				System.err.print(panel[i][j] + " ");
			}
			System.err.println();
		}
	}

	private static int countcolor(int[][] panel) {
		int n = 0;
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (panel[i][j] == c) {
					n++;
				}
			}
		}
		return n;
	}

	private static void connect(int[][] panel, int i, int j, int newcol,
			int oldcol) {
		if (j + 1 < w && panel[i][j + 1] == oldcol) {
			panel[i][j + 1] = newcol;
			connect(panel, i, j + 1, newcol, oldcol);
		}
		if (j - 1 >= 0 && panel[i][j - 1] == oldcol) {
			panel[i][j - 1] = newcol;
			connect(panel, i, j - 1, newcol, oldcol);
		}
		if (i + 1 < h && panel[i + 1][j] == oldcol) {
			panel[i + 1][j] = newcol;
			connect(panel, i + 1, j, newcol, oldcol);
		}
		if (i - 1 >= 0 && panel[i - 1][j] == oldcol) {
			panel[i - 1][j] = newcol;
			connect(panel, i - 1, j, newcol, oldcol);
		}
	}

}

Measured memory_bytes: 290560
N,M = [int(x) for x in input().split()]
count = [0]*N
ac = 0
wa = 0
ireta = []
for i in range(M):
    a,b = input().split()
    a = int(a)
    if b == "AC" and count[a-1] == 0:
        count[a-1] = 1
        ac += 1
    elif count[a-1] == 0:
        ireta.append(a)
        wa += 1
for i in range(len(ireta)):
    if count[ireta[i]-1] == 0:
        wa -= 1
print(ac,wa)


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

using namespace std;

typedef long long ll;

using V = vector<int>;
using Q = queue<int>;
using Graph = vector<vector<int>>;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define inn(x, y) int x,y;cin>>x>>y
#define innn(x, y, z) int x,y,z;cin>>x>>y>>z
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl
#define outt(x,y) cout<<(x)<<" "<<(y)<<endl
#define err(x) cerr<<(x)<<endl
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl
#define errrr(x,y,z) cerr<<(x)<<" "<<(y)<<" "<<(z)<<endl

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)
#define reppp(j, i, n) for (int j=i+1; j<n; j++)

#define lim5 200010
#define lim9 1000000010

#define deg(_rad) (((_rad)/2/M_PI)*360)
#define rad(_deg) (((_deg)/360)*2*M_PI)
#define mid(min, max) ((min + max) / 2)

int main() {
	string s;
	cin >> s;
	out(s.substr(0, 3));
    return 0;
}


Measured memory_bytes: 3592
dayall=input().split("/")
if int(dayall[0])>2019:#2019/4/30
    print("TBD")
elif int(dayall[0])==2019:
  if int(dayall[1])>4:
    print("TBD")
  else:
    print("Heisei")
else:
  print("Heisei")
      
  

Measured memory_bytes: 38384
import sys
sys.setrecursionlimit(10 ** 9)
# input = sys.stdin.readline    ####
def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')
# from math import ceil, floor, log2
# from collections import deque
# from itertools import combinations as comb, combinations_with_replacement as comb_w, accumulate, product, permutations
# from heapq import heapify, heappop, heappush
# import numpy as np    # cumsum
# from bisect import bisect_left, bisect_right

def solve():
    S = LS()
    T = LS()

    ans = 0
    for s, t in zip(S, T):
        if s != t:
            ans += 1

    print(ans)
if __name__ == '__main__':
    solve()


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

int		main(void)
{
	string s;

	cin >> s;
	int num = stoi(s);
	int div = 0;

	for (int i = 0; s[i]; i++)
	{
		div += s[i] - '0';
	}
	if (num % div == 0)
		puts("Yes");
	else
		puts("No");
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
long n,x,y,z,w,x2,y2,z2,w2,i;
while(cin>>n,n){
for(i=0;i<n;i++){
cin>>x>>y>>z>>w>>x2>>y2>>z2>>w2;
cout
<<x*x2-y*y2-z*z2-w*w2<<" "
<<x*y2+y*x2+z*w2-w*z2<<" "
<<x*z2-y*w2+z*x2+w*y2<<" "
<<x*w2+y*z2-z*y2+w*x2<<endl;
}
}
return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);
typedef long long LL;

LL a[500002] = {0};
int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	LL N = S.size() + 1;
	for(int i=0; i<N; i++){
		a[i] = -1;
	}

	vector<LL> V;
	V.push_back(0);
	for(int i=0; i<N-1; i++){
		if(i+1 < N-1 && S[i] == '>' && S[i+1] == '<'){
			a[i+1] = 0;
			V.push_back((-1)*(i+1));
		}
		if(i+1 < N-1 && S[i] == '<' && S[i+1] == '>'){
			a[i+1] = INF;
			V.push_back(i+1);
		}
	}

	LL ans = 0;
	if(V.size() == 1){
		ans = (N*(N-1))/2 ;
		printf("%lld\n", ans);
		return 0;
	}

	V.push_back(N);
	for(int i=1; i<V.size(); i++){
		LL p = V[i-1];
		LL q = V[i];
		if(q < 0){
			for(int i=p+1; i<(-1)*q; i++){
				a[i] = abs(q) - i;
			}
		}
		else if(q > 0 && q != N){
			for(int i=(-1)*p+1; i<q; i++){
				a[i] = i - abs(p);
			}
		}
		else if(q == N){
			if(p < 0){
				for(int i=(-1)*p+1; i<q; i++){
					a[i] = i - abs(p);
				}
			}
			else if(p > 0){
				for(int i=p+1; i<q; i++){
					a[i] = abs(q) - i - 1;
				}
			}
		}
	}
	//a[0]を決定する
	LL c = V[1];
	for(int i=0; i<abs(c); i++){
		if(c < 0){
			a[i] = abs(c) - i;
		}
		else{
			a[i] = i;
		}
	}

	for(int i=0; i<N; i++){
		if(a[i] == INF){
			a[i] = max(a[i-1], a[i+1]) + 1;
		}
	}

	ans = 0;
	for(int i=0; i<N; i++){
		ans += a[i];
	}
	printf("%lld\n", ans);
	return 0;
}

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

#define rep(i,n) for (int i = 0; i < (n); ++i)

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main() {
  string S, T;
  cin >> S >> T;

  bool found = false;

  for (int i = S.size() - T.size(); i >= 0; i--) {
    rep(j, T.size()) {
      if (S[i + j] != '?' && S[i + j] != T[j]) break;
      else if (j == T.size() - 1) {
        rep(k, T.size()) {
          S[i + k] = T[k];
        }
        rep(k, S.size()) {
          if (S[k] == '?') S[k] = 'a';
        }
        found = true;
      }
    }
  }

  if (found) {
    cout << S << endl;
  } else {
    cout << "UNRESTORABLE" << endl;
  }

  return 0;
}


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

int main()
{
  int N, K;
  std::cin >> N >> K;
  std::multiset<int> ps;

  for(int i=0; i<N; i++) {
    int p;
    std::cin >> p;
    ps.insert(p);
  }

  int sum = 0;
  int i = 0;
  for(auto p: ps) {
    sum += p;
    i++;
    if(i == K) {
      break;
    }
  }

  std::cout << sum << std::endl;
  return 0;
}


Measured memory_bytes: 3632
from sys import exit, stdin

input = stdin.readline
import copy

# from collections import deque,Counter
# import numpy as np

(N,) = list(map(int, input().split()))
mod = 10 ** 9 + 7
ans = (pow(10, N, mod) + pow(8, N, mod) - 2 * pow(9, N, mod)) % mod

print(ans)


Measured memory_bytes: 9280
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n;

//文字列strとstr.substr(i,str.length()-1)の先頭何文字が一致するかメモ
long long int prefix_length[5500];
void Z_Algo(string str){
	prefix_length[0]=str.length();
	int L=0,R=0;
	for(int i=1;i<str.length();i++){
		if(R<=i){
			L=i;
			R=i;
			while(R<str.length()&&str[R]==str[R-L])R++;
			prefix_length[i]=R-L;
			
		}else{
			int k=i-L;
			if(prefix_length[k]<R-i){
				prefix_length[i]=prefix_length[k];
			}else{
				L=i;
				while(R<str.length()&&str[R]==str[R-L])R++;
				prefix_length[i]=R-L;
				
			}
		}
	}
}
long long int res=0;
int main() {
	cout << fixed << setprecision(10);
	cin>>n>>str;
	for(int j=0;j<n;j++){
		Z_Algo(str.substr(j,n-j));
		for(int i=0;i<n-j;i++){
			if(prefix_length[i]<=i)
			res=max(res,prefix_length[i]);
		}
	}
	cout<<res<<endl;
} 


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;

pii A[100009];

int main() {
    long long ans = 0;
    int N; scanf("%d",&N);
    for(int i=0; i<N; i++) scanf("%d%d", &A[i].first, &A[i].second);
    sort(A, A+N, [&](pii P, pii Q) { return P.first + P.second > Q.first + Q.second; });
    for(int i=0; i<N; i++) ans += (i%2 ? -A[i].second : A[i].first);
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    
	public static void main(String[] args) {
		
        Scanner s = new Scanner (System.in);
        double n = s.nextInt();
        double d = s.nextInt();
        
        System.out.println((int) Math.ceil(n / (2 * d + 1)));
	}
}

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

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N; cin >> N;
  VI rs(N); REP(i,N) cin >> rs[i];
  vector<double> xs(N);
  double ans = 0.;
  REP(i,N){
	xs[i] = rs[i];
	REP(j,i)
	  xs[i] = max(xs[i], xs[j]+2*sqrt(rs[i]*rs[j]));
	ans = max(ans, xs[i]+rs[i]);
  }
  cout << fixed << setprecision(9) << ans << endl;
  
  
  return 0;
}

Measured memory_bytes: 3292
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

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

			int h = sc.nextInt();
			int w = sc.nextInt();

			int ch = sc.nextInt();
			int cw = sc.nextInt();

			int dh = sc.nextInt();
			int dw = sc.nextInt();

			int[][] maze = new int[h+4][w+4];

			for(int i = 0 ; i < h+4 ; i++ ) {
				maze[i][0] = -1;
				maze[i][1] = -1;
				maze[i][w+2] = -1;
				maze[i][w+3] = -1;
			}
			for(int j = 0 ; j < w+4 ; j++ ) {
				maze[0][j] = -1;
				maze[1][j] = -1;
				maze[h+2][j] = -1;
				maze[h+3][j] = -1;
			}

			for(int i = 0 ; i < h ; i++ ) {
				String s = sc.next();
				for(int j = 0 ; j < w ; j++ ) {

					int val = 0;
					if ( s.charAt(j) == '#' ) {
						val = -1;
					}

					maze[i+2][j+2] = val;
				}
			}
			
//			dispMaze(maze, h, w);

			paint(maze, ch+1, cw+1, 1, h, w);

//			dispMaze(maze, h, w);
			
			if ( maze[dh+1][dw+1] == 0 ) {
				System.out.println(-1);
			}
			else {
				System.out.println(maze[dh+1][dw+1] - 1);
			}


		}
	}

	public static void paint(int[][] maze, int y, int x, int areaNo, int h, int w) {		
		Queue<Position> walkqueue = new LinkedList<>();
		Queue<Position> warpqueue = new LinkedList<>();

		walkqueue.add(new Position(x, y, areaNo));

		while( walkqueue.size() > 0 || warpqueue.size() > 0) {

			while (walkqueue.size() > 0 ) {
				Position pos = walkqueue.remove();

				int px = pos.x;
				int py = pos.y;

				if ( maze[py][px] != 0 ) {
					continue;
				}

				maze[py][px] = pos.areaNo;
				//			dispMaze(maze, h, w);

				if (maze[py-1][px] == 0 ) {
					walkqueue.add(new Position(px, py-1, pos.areaNo));
				}
				if (maze[py+1][px] == 0 ) {
					walkqueue.add(new Position(px, py+1, pos.areaNo));
				}
				if (maze[py][px-1] == 0 ) {
					walkqueue.add(new Position(px-1, py, pos.areaNo));
				}
				if (maze[py][px+1] == 0 ) {
					walkqueue.add(new Position(px+1, py, pos.areaNo));
				}		
				for(int i = -2 ; i < 3 ; i++ ) {
					for(int j = -2 ; j < 3 ; j++ ) {
//						System.out.println(String.format("px: %d, py:%d, i:%d,j:%d", px,py,i,j));
						if ( maze[py+i][px+j] == 0  ) {
							
							warpqueue.add(new Position(px+j, py+i, pos.areaNo + 1));
						}
					}
				}
			}
			
			while( warpqueue.size() > 0 ) {
				Position pos = warpqueue.remove();
				if ( maze[pos.y][pos.x] == 0) {
					walkqueue.add(pos);
					break;
				}
			}

		}
	}

	public static void dispMaze(int[][] maze, int h, int w) {
		for(int i = 0 ; i < h + 4 ; i++ ) {
			for(int j = 0 ; j < w + 4 ; j++ ) {
				System.out.print(maze[i][j]);
			}
			System.out.println();
		}
	}

	public static class Position {

		public Position(int x, int y, int areaNo) {
			this.x = x;
			this.y = y;
			this.areaNo = areaNo;
		}
		public int x;
		public int y;
		public int areaNo;
	}

}

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

using namespace std;

#define ll  long long
#define ld  double

#define sz(x)   (int)x.size()
#define all(x)  x.begin(),x.end()

#define pb  emplace_back
#define X   first
#define Y   second

const int   N   = 2e5 + 5;
const int   mod = 1e9 + 7;

void add(int &a,int b)  {
    a += b;
    if (a >= mod)
        a -= mod;
}
void sub(int &a,int b)  {
    a -= b;
    if (a <  0)
        a += mod;
}
int mul(int a,int b)    {   return  1ll * a * b % mod;  }
int inv(int a,int p)    {   return  a == 1 ? 1 : p - 1ll * p * inv(p % a,a) / a;    }
int Pow(int a,int b)    {
    int ans = 1;

    while  (b)  {
        if (b & 1)  ans = mul(ans,a);
        a = mul(a,a);   b >>= 1;
    }
    return  ans;
}
struct DSU  {
    int p[N];
    int s[N];

    int init(int n) {
        iota(p + 1,p + 1 + n,1);
        fill(s + 1,s + 1 + n,1);
    }
    int lead(int x) {   return  p[x] == x ? x : p[x] = lead(p[x]);  }
    int join(int x,int y)   {
        x = lead(x);
        y = lead(y);

        if (x == y) return  0;
        if (s[x] < s[y])
            swap(x,y);

        p[y] = x;
        s[x] += s[y];

        return  1;
    }
}   Combi;

typedef pair<int,int>   ii;
typedef pair<int,ii>    pii;

vector<ii>  g[N];

int p[N];
int M[N];
int h[N];

void dfs(int u) {
    for(ii  e : g[u])   if (e.X != p[u])    {
        p[e.X] = u;
        h[e.X] = h[u] + 1;
        M[e.X] = e.Y;

        dfs(e.X);
    }
}

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

    int n;  cin >> n;
    int m;  cin >> m;
    ll  X;  cin >> X;

    vector<pii> Edges;

    for(int i = 0 ; i < m ; ++i)    {
        int x;  cin >> x;
        int y;  cin >> y;
        int c;  cin >> c;

        Edges.pb(c,ii(x,y));
    }
    sort(all(Edges));

    Combi.init(n);

    ll  mst_cost = 0;

    for(pii e : Edges)  {
        int u = e.Y.X;
        int v = e.Y.Y;

        if (Combi.join(u,v))    {
            g[u].pb(v,e.X);
            g[v].pb(u,e.X);
        
            mst_cost += e.X;
        }
    }
    if (X < mst_cost)   {
        cout << 0;
        return  0;
    }
    dfs(1);
    Combi.init(n);

    int lower = 0;
    int equal = 0;
    int upper = 0;

    for(pii e : Edges)  {
        int u = e.Y.X;
        int v = e.Y.Y;

        if(!Combi.join(u,v))    {
            int val = 0;

            for(; h[u] > h[v] ; val = max(val,M[u]), u = p[u]);
            for(; h[v] > h[u] ; val = max(val,M[v]), v = p[v]);

            for(; u != v ;)
                val = max(val,M[u]),    u = p[u],
                val = max(val,M[v]),    v = p[v];
            
            if (e.X - val <  X - mst_cost)  lower++;
            if (e.X - val >  X - mst_cost)  upper++;
            if (e.X - val == X - mst_cost)  equal++;
        }
    }
    if (X == mst_cost)  {
        int ans = 0;
        add(ans,Pow(2,m));
        sub(ans,Pow(2,m - n + 2));

        add(ans,Pow(2,equal + upper + 1));
        sub(ans,Pow(2,upper + 1));

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

    add(ans,Pow(2,equal + upper + 1));
    sub(ans,Pow(2,upper + 1));

    cout << ans << endl;
}

Measured memory_bytes: 6528
#include<iostream>

using namespace std;

int main(void) {
	int a=0, b=0;
	cin >> a ;
	cin >> b;


	if (a >= 13) {
		cout << b;
	}
	else if(a>5){
		cout << b / 2;
	}
	else {
		cout << 0;
	}
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
dic = {}
for i in range(1, n+1):
  dic[i] = []
for i in range(m):
  a1, a2 = map(int, input().split())
  dic[a1] += [a2]
  dic[a2] += [a1]

Places_from1 = dic[1]
for place in Places_from1:
  if n in dic[place]:
    print("POSSIBLE")
    break
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 87264
#include<iostream>
using namespace std;
#define MAX 100005
#define NIL -1

struct Node{int p, l, r;};

Node T[MAX];
int n,D[MAX];

void print(int u)
{
	int i,c;
	cout << "node " << u <<": ";
	cout << "parent = " << T[u].p << ", ";
	cout << "depth = " << D[u] << ", ";

	if (T[u].p == NIL) cout << "root, ";
	else if (T[u].l == NIL) cout << "leaf, ";
	else cout << "internal node, ";

	cout << "[";

	for (i = 0,c = T[u].l;c != NIL;i++, c =T[c].r){
		if(i) cout << ", ";
		cout << c;
	}
	cout << "]" << endl;
}

int rec(int u,int p){
	D[u]=p;
	if(T[u].r !=NIL) rec(T[u].r,p);
	if(T[u].l !=NIL) rec(T[u].l,p+1);
}

int main(){
	int i,j,d,v,c,l,r;
	cin >> n;
	for (i = 0; i < n; i++){
		T[i].p= T[i].l=T[i].r=NIL;
	}
	for (i = 0; i < n; i++){
		cin >> v >> d;
		for (j = 0; j < d; j++){
			cin >> c;
			if (j==0) T[v].l=c;
			else T[l].r=c;
			l=c;
			T[c].p=v;
		}
	}
	for (i = 0; i < n; i++){
		if(T[i].p == NIL) r=i;
	}

	rec(r,0);

	for(i=0;i<n;i++) print(i);
	return 0;
}

Measured memory_bytes: 7760
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define f(i,a,b,c) for(ll i=a;i<b;i+=c)
#define r(i,a,b,c) for(ll i=a;i>=b;i-=c)
int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    float a,b,c; cin >> a >> b >> c;
    if((a/b)<=c)
    	cout << "Yes";
    else
    	cout << "No";
    return 0;
}

Measured memory_bytes: 3736
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ld;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes(x) cout<<(x?"Yes":"No")<<endl;
#define YES(x) cout<<(x?"YES":"NO")<<endl;
#define out(s) cout<<s<<endl;
#define Reverse(x) reverse(all(x));
#define Sort(x) sort(all(x));
#define pb(s) push_back(s);
#define sp " " 
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(lli i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    cout << std::fixed << std::setprecision(10);
    lli n;
    cin >> n;
    if(n==1)
    {
    out("Hello World")
        }
    else
    {
        lli a,b;
        cin >> a >> b;
        out(a + b);
    }
}

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

using namespace std;
typedef long long ll;

ll N;
ll m[310][310];
bool f[310][310];

int main(){
    cin >> N;
    ll sum = 0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> m[i][j];
            sum += m[i][j];
            f[i][j] = true;
        }
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                if(i == j || j == k || k == i) continue;
                if(m[j][k] > m[j][i] + m[i][k]){
                    cout << -1 << endl;
                    return 0;
                }
                if(m[j][k] == m[j][i] + m[i][k] && f[j][k]){
                    sum -= m[j][k];
                    f[j][k] = false;
                }
            }
        }
    }
    cout << sum / 2 << endl;
    return 0;
}

Measured memory_bytes: 1024
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
using namespace std;
int main(){

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	bool f = false;
	int n;
	cin >> n;

	while(n) {
		f |= ((n % 10) == 7);
		n /= 10;
	}

	cout << (f ? "Yes\n" : "No\n");
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  const int INF=1001001001;
  vector<int> to[1000010];
int main() {
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  queue<int> q;
  vector<int> dist(n,INF);
  vector<int> pre(n,-1);
  dist[0]=0;
  q.push(0);
  while(!q.empty()){
    int v = q.front(); q.pop();
    for(int u : to[v]){
      if(dist[u]!=INF)continue;
      dist[u]=dist[v]+1;
      pre[u]=v;
      q.push(u);
    }
  }
  cout<<"Yes"<<endl;
  rep(i,n){
    if(i==0)continue;
    int ans=pre[i];
    ans++;
    cout<<ans<<endl;;
  }   
}

Measured memory_bytes: 31728
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    sys.setrecursionlimit(10**7)
    INF = 10**4
    LI = lambda : [int(x) for x in sys.stdin.readline().split()]
    NI = lambda : int(sys.stdin.readline())

    N,A,B,C = LI()
    l = [NI() for _ in range(N)]
    x = [0] * 3
    ans = INF
    for p in itertools.combinations(range(N),3):
        q = []
        for i in range(N):
            if not i in p: q.append(i)
        for i in range(4**(N-3)):
            for j in range(3): x[j] = l[p[j]]
            mp = 0
            r = i
            for j in range(N-3):
                k = r % 4
                if k > 0:
                    x[k-1] += l[q[j]]
                    mp += 10
                r //= 4
            for a,b,c in itertools.permutations(x):
                ans = min(ans,mp+abs(A-a)+abs(B-b)+abs(C-c))

    print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 45672
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
      
      int a[] =new int[N+1];
      
      for(int i=1; i<=N; i++){
        int b =sc.nextInt();
        a[b] = i;
      }
      for(int i=1; i<=N; i++){
      System.out.print(a[i]+" ");
      }
    }
}


Measured memory_bytes: 60396
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,k;
    cin>>n>>k;
    vector<ll> v(n);
    for(int i=0;i<n;i++)
        cin>>v[i];
    vector< vector<ll> > v1(n,vector<ll>(k+1));
    for(int i=0;i<n;i++)
    for(int j=0;j<=k;j++)
        v1[i][j]=0;
    for(int i=0;i<=v[n-1];i++)
    {
        v1[n-1][i]=1;
    }
    for(int i=n-2;i>=0;i--)
    {
        vector<int> s(k+1);
        s[0]=v1[i+1][0];
        for(int j=1;j<=k;j++)
            s[j]=(s[j-1]+v1[i+1][j])%1000000007;
        for(int j=0;j<=k;j++)
        {
            int t=s[j];
            if(j>v[i])
            {
                t=(t-s[j-v[i]-1]+1000000007)%1000000007;
            }
            v1[i][j]=t%1000000007;
        }
    }
    cout<<v1[0][k]%1000000007<<endl;
  return 0;
}


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

int main()
{
    int N;
    vector<int> p;
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        int temp;
        cin >> temp;
        p.push_back(temp);
    }
    int maxim, ans;
    maxim = *max_element(p.begin(), p.end());
    ans = accumulate(p.begin(), p.end(), 0) - maxim / 2;
    cout << ans;
}

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

const long long int INF = 1000000007;

int main(void)
{
    long long now, k, d;
    cin >> now >> k >> d;

    int mod = k % 2;
    now = abs(now);
    long long how_many = now / d;
    // how_many回で行ける地点
    long long most = now - how_many * d;
    // how_many+1回で行ける
    long long more_point = abs(now % d - d);

    long long ans;

    if (how_many >= k)
    {
        ans = now - k * d;
    }
    else
    {
        if (most < more_point)
        {
            if ((k - how_many) % 2 == 0)
            {
                ans = most;
            }
            else
            {
                ans = more_point;
            }
        }
        else
        {
            if ((k - how_many - 1) % 2 == 0)
            {
                ans = more_point;
            }
            else
            {
                ans = most;
            }
        }
        
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3628
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

# N, Q <= 10^5
N, K, Q = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(stdin.readline().rstrip()) for _ in range(Q)] 

point = [K] * (N+1)

for Ai in A:
    point[Ai] += 1

res = list(map(lambda x: x - Q, point))

for r in res[1:]:
    if r <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 78424
import java.io.IOException;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		double d = (double)a / b;
		String str = String.format("%.5f", d);
		System.out.println((a / b) + " " + (a % b) + " " + str);
	}
}

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

int main(){
string s;
string t;
cin >> s;
cin >> t;
bool ans1 = true;
bool ans2 = true;
for(int i=0;i < s.size();++i){
if(s.at(i) != t.at(i) )
ans1 =false;
}
if( s.size()+1!=t.size())
ans2 = false;
if(ans1 == true&& ans2 == true)
cout << "Yes" << endl;
else
{
    cout << "No" << endl;
}



}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n,k;
	cin>>n>>k;
	long long int l=0;
	long long int r=n;
	long long int ans=0;
	while (l<=r){
		int mid=(l+r)/2;
		if ((k-1)*mid+1>=n){
			ans=mid;
			r=mid-1;
		}
		else{
			l=mid+1;
		}
	}
	printf ("%lld\n",ans);
}

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

int main(){
    int N,Q; cin >> N >> Q;
    string S; cin >> S;
    vector<pair<int,int>> pairs(Q);
    for(int i=0; i<Q; i++) cin >> pairs[i].first >> pairs[i].second;

    /*  累積和で考える
        i文字目までにあるACの個数を求める。
    */

   vector<int> cnt(N+1);
   for(int i=2; i<=N; i++){
       if(S[i-2] == 'A' && S[i-1] == 'C'){
           cnt[i] = cnt[i-1] + 1;
       }else{
           cnt[i] = cnt[i-1];
       }
   }

   //表示
   for(int i=0; i<Q; i++){
       cout << cnt[pairs[i].second] - cnt[pairs[i].first] << endl;
   }
}

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

ll X;

bool calc(ll a, ll b){
  if (pow(a, 5) - pow (b, 5) == X) return true;
  if (pow(b, 5) - pow (a, 5) == X) return true;
  if (pow(-a, 5) - pow (b, 5) == X) return true;
  if (pow(b, 5) - pow (-a, 5) == X) return true;  
  return false;
}

int main() {
  cin >> X;
  
  if(X == 0){
    cout << 0 << " " << 0 << endl;
    return 0;
  }
  
  bool found = false;
  ll a = 0;
  ll b = 0;
  while(!found){
	a++;
    b = 0;
    while(a != b){
      if (calc(a, b)){
        found = true;
        break;
      }
      b++;
    }
  }
  
  if (pow(b, 5) - pow (a, 5) == X) {
    swap(a, b);
  } else if (pow(-a, 5) - pow (b, 5) == X) {
    a = -a;    
  } else if (pow(b, 5) - pow (-a, 5) == X) {
    a = -a;
    swap(a, b);
  }
  
  cout << a << " " << b << endl;
}


Measured memory_bytes: 4064
#include<algorithm>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
const int MAXN=1e5+5;
int read()
{
    int s=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
    return s*f;
}
int main()
{
    int a,b,c;cin>>a>>b>>c;
    swap(a,b);swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

void solve() {
    ll N;
    cin >> N;
    ll ans = INF;
    FOR(i,1,1e6+1) {
        if (N%i == 0) {
            ll p = N/i;
            chmin(ans,(p-1)+(i-1));
        }
    }
    cout << ans << endl;
}

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


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{

	cin.tie(0); ios_base::sync_with_stdio(false);
	ll n; 
	cin >>n;
	
	ll ans = n*(n-1) /2;
	cout <<ans <<"\n";
	return 0;
	/*
	VI w(n);
	rep(i,n) w[i]=i+1;
	ll ans = 0;
	do {
		ll sm=0;
		rep(i,n) sm += w[i]%(i+1);
		ans = max(ans, sm);
	} while ( next_permutation(all(w)) );

	cout << ans <<"\n";
	return 0;
	*/
	
}


Measured memory_bytes: 384
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var ans = 0

    for (i in 1..n step 2){
        var c = 0
        for(j in 1..i){
            if(i % j == 0) c++
        }
        if(c == 8) ans++
    }

    println(ans)
}

Measured memory_bytes: 33812
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(){
	int a;
	while(scanf("%d",&a),a){
		int H=0;
		int L=500;
		for(int i=0;i<a;i++){	
			int now=0;
			int val;
			for(int j=0;j<5;j++){
				scanf("%d",&val);
				now+=val;
			}
			H=max(H,now);
			L=min(L,now);
		}
		printf("%d %d\n",H,L);
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
int n,r,i,j,a[100];
main(){
scanf("%d",&n);
for(;i<n;)scanf("%d",a+i++);
for(i=0;i<n;i++){
for(j=0;j<i;){
if(a[i]<a[j++])r++;
}
}
std::sort(a,a+n);
for(i=0;i<n;printf("%d",a[i++]))if(i)printf(" ");
printf("\n%d\n",r);
}

Measured memory_bytes: 3252
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


void solve(string s){
    set<int> st{0,1,2,3,4,5,6,16,17,18,19,21,22,23,25};
    int ans=0;
    int n=s.size();
    rep(i,n-1){
        if(st.count(s[i]-'a')^st.count(s[i+1]-'a'))++ans;
    }
    cout<<ans<<endl;
}
int main(){
    string s;
    while(cin>>s,s!="#")solve(s);
    return 0;
}


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

int main() {
  int n, m;
  cin>>n>>m;
  map<int, int> b_num;
  for (int i=0; i<n; i++) {
    b_num[i+1] = 1;
  }
  set<int> red;
  red.insert(1);
  for (int i=0; i<m; i++) {
    int x, y;
    cin>>x>>y;
    if (red.find(x) != red.end()) {
      if (b_num[x] == 1) {
        red.erase(x);
        red.insert(y);
      } else {
        red.insert(y);
      }
    }
    --b_num[x];
    ++b_num[y];
  }
  cout<<red.size()<<endl;
}

Measured memory_bytes: 9600
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int N = getint();
	int A[100000];
	ll kotae = 0;
	rep(i, N) {
		int a = getint(), b = getint();
		A[i] = a + b;
		kotae -= b;
	}

	pakuri_sort(N, A);

	for (int i = N - 1; i >= 0; i -= 2) kotae += A[i];

	printf("%lld", kotae);

	Would you please return 0;
}

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

int D = 60;
vector<vector<int>> t;

int main() {
	int n;	ll k;	cin >> n >> k;
	t = vector<vector<int>>(D,vector<int>(n));
  	rep(i,n){cin >> t[0][i];	t[0][i]--;}
  	rep(i,D-1)rep(j,n) t[i+1][j] = t[i][t[i][j]];
  	
  	int v = 0;
  	for(int i = D-1; i >= 0; i--){
    	ll dg = 1ll<<i;
      	if(dg <= k){
        	v = t[i][v];
          	k -= dg;
        }
    }
  	cout << v+1 << endl;
}

Measured memory_bytes: 50952
#include<bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;

int main()
{
	int a, b, c = 0;

	cin >> a;

	for (int i = 1; i <= a; i++)
	{
		cin >> b;
		if (i % 2 == 1 && b % 2 == 1)
			c++;
	}

	cout << c;

	return 0;
}

Measured memory_bytes: 3624
(N, M, R), Rs, *ABCs = readlines.map{|l| l.split.map(&:to_i)}

d = ABCs.each_with_object(Array.new(N + 1){Array.new(N + 1, 100000000)}){|(a, b, c), d| d[a][b] = d[b][a] = c}
[*1 .. N].repeated_permutation(3){|i, j, k| d[j][k] = d[j][i] + d[i][k] if d[j][k] > d[j][i] + d[i][k]}
puts Rs.permutation(R).map{|rs| rs.each_cons(2).inject(0){|s, (a, b)| s + d[a][b]}}.min

Measured memory_bytes: 7136
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
m=float('inf')
ans=1
for i in range(n):
  if m>abs(a-t+h[i]*0.006):
    ans=i+1
  m=min(m,abs(a-t+h[i]*0.006))
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int N; cin>>N;
    vector<int> d(N);
    for(int i=0;i<N;i++){
      cin>>d.at(i);
    }

    int sum = 0;
    for(int i=0;i<N-1;i++){
      for(int j=i+1;j<N;j++){
        sum += d.at(i)*d.at(j);
      }
    }

    cout<<sum<<endl;
}


Measured memory_bytes: 256
// finish date: 2018/01/22
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <map>
#include <climits>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define bigmod 1000000007
#define INF 500000000


int main() {
    int N;
    cin >> N;
    vl a(N);
    rep(i, N) cin >> a[i];
    FOR(i, 1, N) a[i] += a[i - 1];
    ll mi = LONG_LONG_MAX;
    rep(i,N-1) mi = min(mi,abs(a[N-1]-2*a[i]));
    cout<<mi<<endl;

    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#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, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];
    ll x = 0;
    REP(i, n){
        if(i % 2) x -= a[i];
        else x += a[i];
    }
    REP(i, n){
        cout << x << " ";
        x = 2 * a[i] - x;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
#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 pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	int m;
	cin >> m;
	cout << 24 + 24 - m << endl;

	return 0;
}

Measured memory_bytes: 256