akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	class data {
		boolean single;
		double rate;
		int fee;

		data(boolean single, double rate, int fee) {
			this.single = single;
			this.rate = rate;
			this.fee = fee;
		}

		int getCost(int a, int t) {
			if (this.single) {
				int A = a;
				int B = 0; // rishi
				for (int i = 0; i < t; i++) {
					int b2 = (int)(A * rate);
					B += b2;
					A -= fee;
				}
				return A+B;
			} else {
				int A = a;
				for(int i =0 ; i < t;i++){
					int b2 = (int) (A*rate);
					A += b2;
					A -= fee;
				}
				return A;
			}
		}

	}

	void run() {
		int m = sc.nextInt();
		for (int t = 0; t < m; t++) {
			int start = sc.nextInt();
			int year = sc.nextInt();
			int n = sc.nextInt();
			int max = 0;
			for (int u = 0; u < n; u++) {
				data d = new data(sc.nextInt() == 0,sc.nextDouble(),sc.nextInt());
				int cost = d.getCost(start, year);
//				System.out.println(cost);
				max = Math.max(max, cost);
			}
			System.out.println(max);
		}

	}

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 13000
import java.util.Scanner;

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

	int A[] = new int[3];
	for (int i = 0; i < A.length; i++)
	    A[i] = sc.nextInt();

	if (A[0] + A[1] + A[2] >= 22)
	    System.out.println("bust");
	else
	    System.out.println("win");

    }
}

Measured memory_bytes: 21844
function Main(input: string) {
  const lines: string[] = input.split('\n');
  const line = lines[0];
  if (line === 'AAA' || line === 'BBB') {
    console.log('No');
  } else {
    console.log('Yes');
  }
}

Main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

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

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

	int sum = 0;

	for (int i = 1; i < n - 1; i++) {
		if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
			sum++;
		}
		else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
			sum++;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 256
S = input()
K = int(input())
# DAY = 5000000000000000
if len(S) >= K:
    for i in range(K):
        if S[i] != '1':
            print(int(S[i]))
            break
    else:
        print(1)
else:
    for s in S:
        if s != '1':
            print(int(s))
            break

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

LL N, M, cost[10];
std::vector<LL>A;
std::vector<std::string>memo;

std::string str_max(std::string a, std::string b)
{
	if (a.length() > b.length()) return a;
	else if (a.length() < b.length()) return b;
	else
	{
		rep(i, a.length())
		{
			if (a[i] - '0' > b[i] - '0') return a;
			if (a[i] - '0' < b[i] - '0') return b;
		}
	}
	return a;
}

std::string dp(LL n)
{
	if (n == 0) return "";
	if (memo[n] != "-1") return memo[n];
	std::string res = "0";
	rep(i, M)
	{
		if (cost[A[i]] <= n)
		{
			auto temp = dp(n - cost[A[i]]);
			if (temp == "0") continue;
			res = str_max(res, std::to_string(A[i]) + temp);
		}
	}
	return memo[n] = res;
}

int main()
{
	in >> N >> M;
	A.resize(M);
	rep(i, M) in >> A[i];

	memo.resize(N + 1, "-1");
	cost[1] = 2;
	cost[2] = 5;
	cost[3] = 5;
	cost[4] = 4;
	cost[5] = 5;
	cost[6] = 6;
	cost[7] = 3;
	cost[8] = 7;
	cost[9] = 6;
	out << dp(N) << std::endl;
}


Measured memory_bytes: 33280
while true
    n = gets.to_i
    break if n == 0

    arr = []
    n.times{|i|
        line = gets.chomp.split
        name = line[0]
        height = line[1].to_f / 100
        weight = line[2].to_f
        bmi = weight / height / height
        diff = (22.0 - bmi).abs
        arr << [name, diff, i]
    }
    puts (arr.sort_by{|n, d, i| [d, i]}.first)[0]
end


Measured memory_bytes: 6932
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    string S;
    cin >> S;
    char a = S[S.length()-1];
    if (a == '2' || a == '4' || a == '5' || a == '7' || a == '9')cout << "hon" << endl;
    else if (a == '0' || a == '1' || a == '6' || a == '8')cout << "pon" << endl;
    else cout << "bon" << endl;

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long int
#define cases int t; cin >> t; while (t--)
#define pb push_back
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int k, x; cin >> k >> x;
    for (int i = x-(k-1); i <= x+(k-1); i++) cout << i << " ";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vl vector<ll>
typedef long long int ll;
typedef long double ld;
using namespace std;
#include <iomanip>

vvl G = vv(601, 0, 0, ll);
int main(int argc, char const *argv[]) {
  ld n, m, a, b;
  std::cin >> n >> m;
  vector<ld> num(n+1, 0);
  for(int i=0;i<m;i++){
    std::cin >> a >> b;
    G[a].push_back(b);
  }
  ll no_a=-1, no_b=-1;
  vector<ld> p(n+1);
  p[1] = 1.0;
  for(int i=1;i<n;i++){
    for(int j=0;j<G[i].size();j++){
      p[G[i][j]] += p[i]/G[i].size();
    }
  }

  ld cont=0.0, cont_i, cont_j;
  num[n] = 0;
  for(int i=n-1;i>0;i--){
    ld e = 0;
    ld k = G[i].size();
    for(int j=0;j<k;j++){
      e += num[G[i][j]];
    }
    num[i] = e/k + 1.0;
  }


  for(int i=n-1;i>0;i--){
    ld k = G[i].size();
    ld o = 0;
    for(int j=0;j<k;j++){
      o += num[G[i][j]];
    }
    ld s = o/G[i].size();
    if(k==1) continue;
    for(int j=0;j<k;j++){
      ld x = (o-num[G[i][j]])/(G[i].size()-1);
      if(cont<p[i]*(s-x)){
        cont = p[i]*(s-x), cont_i = i, cont_j = G[i][j];
      }
    }
  }
  if(cont>0) no_a = cont_i, no_b = cont_j;

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

  for(int i=n-1;i>0;i--){
    ld e = 0, k = G[i].size();
    if(i==no_a) k--;
    for(int j=0;j<G[i].size();j++){
      if(i==no_a&&G[i][j]==no_b) continue;
      e += num[G[i][j]];
    }
    num[i] = e/k + 1.0;
  }
  std::cout << fixed << setprecision(20) << num[1] << '\n';
  //for(int i=1;i<=n;i++) std::cout << fixed << setprecision(20) << num[i] << '\n';
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
ll max_3(ll a,ll b,ll c){
  return max(a,max(b,c));
}
int main() {
  int N;
  cin >> N;
  vector<ll> L(N);
  rep(i,N) cin >> L.at(i);
  ll ans = 0;
  for(int i = 0;i< N-2 ;++i){
    for(int j = i + 1;j < N-1 ;++j){
      for(int k = j + 1;k < N;++k){
        ll a = L.at(i);
        ll b = L.at(j);
        ll c = L.at(k);
        if(a == b || b == c || c == a){
          continue;
        }
        if(abs(a - b) < c && c < a + b){
          //cout << i+1 << "," << j+1 << "," << k+1 << endl;
          ans ++;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}



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

int main(){
  int k;
  string s;
  cin >> k >> s;
  if(s.size()>k){
    rep(i,k){
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  else cout << s << endl;

}


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

//priority_queue<int, vector<int>, greater<int>> min_heap;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
int main() { // E 
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n;
	string s; cin >> n >> s;
	if (n < 3200) {
		cout << "red" << '\n';
	}
	else {
		cout << s << '\n';
	}
	

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int N, M;
    cin >> N >> M;
    if (N == 0 && M == 0){
      break;
    }
    vector<tuple<int, int, int>> T(M);
    for (int i = 0; i < M; i++){
      int t, s, d;
      cin >> t >> s >> d;
      s--;
      d--;
      T[i] = make_tuple(t, s, d);
    }
    sort(T.begin(), T.end());
    vector<bool> I(N, false);
    I[0] = true;
    for (int i = 0; i < M; i++){
      int s = get<1>(T[i]);
      int d = get<2>(T[i]);
      if (I[s]){
        I[d] = true;
      }
    }
    int ans = 0;
    for (int i = 0; i < N; i++){
      if (I[i]){
        ans++;
      }
    }
    cout << ans << endl;
  }
}


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

int main ()
{
    int a,b;
    cin >> a >> b;
    for (int c=1;c<=3;++c)
    {
        if ((a*b*c)%2 == 1)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}



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

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i,n) cin >> h[i];
	vector<int> v(n,0);
	int count = 0;
	while(1){
		bool ok = true;
		rep(i,n){
			if(v[i] != h[i]) ok = false;
		}
		if(ok){
			break;
		}
		bool temp = false;
		rep(i,n){
			if(temp && v[i] >= h[i]){
				break;
			}
			if(v[i] < h[i]){
				v[i]++;
				temp = true;
			}
		}
		count++;
	}
	cout << count << endl;
    return 0;
}



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

int main() {
  int a, b;
  cin >> a >> b;
  
  int smaller = min(a, b);
  int larger = max(a, b);
  rep(i,larger) {
    cout << smaller;
  }
  cout << endl;
  
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: print('Yes' if b else 'No')
YESNO=lambda b: print('YES' if b else 'NO')

def main():
    Q=[]
    while True:
        N=int(input())
        if N==0:
            break
        Q.append(N)
    MAX_Q=max(Q)
    A=tuple((i+1)*(i+2)*(i+3)//6 for i in range(182))
    A_odd=tuple(i for i in A if i%2)
    A_even=tuple(i for i in A if i%2==0)
    dp=[INF]*(MAX_Q+1)
    dp[0]=0
    for x in A_odd:
        for k in range(x,MAX_Q+1):
            if dp[k]>dp[k-x]+1:
                dp[k]=dp[k-x]+1
    ans=[]
    for q in Q:
        ans.append(dp[q])
        
    for x in A_even:
        for k in range(x,MAX_Q+1):
            dp[k]=min(dp[k],dp[k-x]+1)
    for i,q in enumerate(Q):
        print(dp[q],ans[i])


if __name__ == '__main__':
    main()



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

int main() {
  int N, K;
  int cnt = 0;
  int x =1;
  cin >> N >> K;
  
  for(; cnt <N; cnt++ ){
    if(x < K) x *=2;
    else x += K;
  }
  cout << x << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include <string.h>
#include<limits.h>
int main(void){
	int x, y, z, i;
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	scanf("%d%d", &x, &y);
	while (x != 0 && y != 0) {
		for (i = 0; i < x; i++) {
			for (z = 0; z < y; z++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
		scanf("%d%d", &x, &y);
	}
	//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
 
using namespace std;
 
const int md = 998244353;
 
inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}
 
inline int mul(int a, int b) {
  return (long long) a * b % md;
}
 
inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}
 
inline int inv(int x) {
  return power(x, md - 2);
}
 
const int N = 12345;
 
int x[N], y[N];
 
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d %d", x + i, y + i);
  }
  int ans = power(2, n);
  add(ans, md - 1);
  add(ans, md - n);
  add(ans, md - n * (n - 1) / 2);
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      int a = y[j] - y[i];
      int b = x[i] - x[j];
      int c = -a * x[i] - b * y[i];
      int cnt = 2;
      for (int k = 0; k < n; k++) {
        if (k == i || k == j) {
          continue;
        }
        int z = a * x[k] + b * y[k] + c;
        if (z != 0) {
          continue;
        }
        if (k < j) {
          break;
        }
        cnt++;
      }
      add(ans, md - power(2, cnt));
      add(ans, 1);
      add(ans, cnt);
      add(ans, cnt * (cnt - 1) / 2);
    }
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
N, M, X = gets.chomp.split(' ').map(&:to_i)
C = Array.new
N.times do |i|
  C[i] = gets.chomp.split(' ').map(&:to_i)
end
min = Float::INFINITY

N.times do |i|
  combinations = (0..N-1).to_a.combination(i+1).to_a
  combinations.each do |combination|
    sum = Array.new(M+1, 0)
    (M+1).times do |k|
      (i+1).times do |j|
      	sum[k] += C[combination[j]][k]
      end
    end
    if sum.slice(1..-1).all?{ |value| value >= X }
      min = [min, sum[0]].min
    end
  end
end

p (min.infinite? ? -1 : min)

Measured memory_bytes: 14400
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#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 < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

int main() {
    int K, X;
    cin >> K >> X;
    cout << (K*500-X<0?"No":"Yes")<< endl;
}

Measured memory_bytes: 3596
import math

N = int(input())

ans = 0
for i in range(1, int(math.sqrt(N)) + 1):
  if i > N / 2:
    continue
  tmp = int((N - i) / i)
  if (N - i) % i == 0 and N % tmp != 0 and tmp >= math.sqrt(N):
    ans += tmp

print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,x,y;
  cin>>n>>x>>y;
  vector<vecint> g(n);
  REP(i,n-1) {
    g[i].push_back(i+1);
    g[i+1].push_back(i);
  }
  --x;--y;
  g[x].push_back(y);
  g[y].push_back(x);
  vecint cnt(n, 0);
  REP(i,n) {
    queue<int> q;
    constexpr int INF = 1e9;
    vecint dist(n, INF);
    dist[i] = 0;
    q.push(i);
    while (!q.empty()) {
      int j=q.front();
      q.pop();
      for(auto&& to:g[j]) {
        if (dist[to] > dist[j]+1) {
          dist[to] = dist[j]+1;
          q.push(to);
        }
      }
    }
    FOR(j,i,n) {
      ++cnt[dist[j]];
    }
  }
  FOR(i,1,n) {
    cout<<cnt[i]<<'\n';
  }
  cout<<flush;
  return 0;
}


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n;
	string s;
	cin>>n>>s;
	int ans=0;
	for(int i=0;i<s.size();++i){
		vector<bool>left(26,false),right(26,false);
		for(int j=0;j<i;++j){
			left.at(s.at(j)-'a')=true;
		}
		for(int j=i;j<s.size();++j){
			right.at(s.at(j)-'a')=true;
		}
		int tmp=0;
		for(int j=0;j<26;++j){
			if(left.at(j)&&right.at(j))++tmp;
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<"\n"s;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long L, R;
    cin >> L >> R;

    if( R-L >= 673 ){
        cout << 0 << endl;
    }else{
        long ans=2018;
        for(long i=L; i<R; i++){
            for(long j=L+1; j<=R; j++){
                ans=min(ans, (i*j)%2019 );
            }
        }
        cout << ans << endl;      
    }


    return 0;
}

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

int main(){
	int A, B, C;
	cin>>A>>B>>C;
	int kaisu=0;
	if(A*C<B){
		kaisu=C;
		cout<<C;
		return 0;
	}
	if(A>B){
		cout<<0;
		return 0;
	}
	int n=1;
	while((n+1)*A<=B){
		n += 1;
	}
	cout<<n;
	return 0;
}
		


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>

using namespace std;


int max_value = -1000007;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> v(n);
    for(int i = 0; i < n; i++) cin >> v[i];
    int ans = 0;

    for(int l = 0; l <= k; l++){
        if (l > n) break;
        vector<int> v1;
        int sum1 = 0;
        for(int i = 0; i < l; i++){
            sum1 += v[i];
            if(v[i] < 0) v1.push_back(v[i]);
        }
        for(int r = 0; r <= k; r++){
            if(l+r > k || r > n || n - l < r) break;
            vector<int> v2;
            int sum2 = sum1;
            for(int i = n-1; i >= n-r; i--){
                sum2 += v[i];
                if(v[i] < 0) v2.push_back(v[i]);
            }
            copy(v1.begin(), v1.end(), back_inserter(v2));
            sort(v2.begin(), v2.end());
            for(int i = 0; i < k - l - r && i < v2.size(); i++){
                sum2 -= v2[i];
            }
            ans = max(ans, sum2);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
# AOJ 0027 What day is today?

days_in_a_month = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
offset = []
days_in_a_month.each.with_index do |d, m|
  offset[m] = m.zero? ? 0 : days_in_a_month[0..(m - 1)].reduce(0, :+)
end

the_day = %w[Thursday Friday Saturday Sunday Monday Tuesday Wednesday]

loop do
  month, day = gets.split.map(&:to_i)
  break if month.zero? && day.zero?

  days = offset[month - 1] + (day - 1)
  puts the_day[days % 7]
end

Measured memory_bytes: 6120
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}


const long long MOD = 1000000007;
const long long INF = 1LL << 60;


const int MAX_N = 100010;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n; cin >> n;
	int l = 0; int r = 100000;
	while (r - l > 1) {
		int mid = (r + l) / 2;
		int tmp = mid * 108 / 100;
		if (mid * 108 / 100 == n) {
			cout << mid << endl; return 0;
		}
		else {
			if (tmp <= n)l = mid;
			else r = mid;
		}
	}
	cout << ":(" << endl;
	return 0;
}

Measured memory_bytes: 256
n,m,c=map(int,input().split())
b=list(map(int,input().split()))
a=[list(map(int,input().split())) for _ in range(n)]
count=0
for i in range(n):
    total=0
    for j in range(m):
        total+=b[j]*a[i][j]
    if total>-c:
        count+=1
print(count)

Measured memory_bytes: 3060
// このしゃくとり最強に難しくない？
// しゃくとりで解くのゲキムズなので別の方法でやる
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	N, K := nextInt(), nextInt()
	S := chars(next())
	boundary := []int{}
	j := 0
	for i := 1; i < N; i++ {
		if S[i-1] != S[i] {
			boundary = append(boundary, i-j)
			j = i
		}
	}
	boundary = append(boundary, N-j)
	// A[0]=0のとき
	//	00..11..00..11..00... -> 最初だけK*2, 次からはK*2+1の範囲
	// A[0]=1のとき最初は2K個、次からは2K+1個の範囲
	//	11..00..11..00..11.. -> K*2+1個の範囲
	ans := 0
	if S[0] == "0" {
		// 最初に長さ0として番兵をおいて帳尻合わせ
		boundary = append([]int{0}, boundary...)
	}
	r := 0
	tmp := 0
	for l := 0; l < len(boundary); {
		for r < len(boundary) && (r-l) < 2*K+1 {
			tmp += boundary[r]
			r++
		}
		ans = max(ans, tmp)
		if l+1 >= len(boundary) { // なんだよこれアホかアドホックすぎひん
			break
		}
		tmp -= (boundary[l] + boundary[l+1])
		l += 2
		if l >= r {
			r++
		}
	}
	fmt.Fprintln(out, ans)
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 8832
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;

public class Main{
  static int n, m;
  static int[] a, b;

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

    n = sc.nextInt();
    m = sc.nextInt();
    a = new int[m];
    b = new int[m];
    for(int i = 0; i < m; i++){
      a[i] = sc.nextInt() - 1;
      b[i] = sc.nextInt() - 1;
    }

    List< Set< Integer > > graph = new ArrayList< >(n);
    for(int i = 0; i < n; i++){
      graph.add(new HashSet< >());
    }

    for(int i = 0; i < m; i++){
      graph.get(a[i]).add(b[i]);
      graph.get(b[i]).add(a[i]);
    }

    boolean possible = false;
    for(int v : graph.get(n - 1)){
      if(graph.get(v).contains(0)){
        possible = true;
        break;
      }
    }

    if(possible){
      System.out.println("POSSIBLE");
    }
    else{
      System.out.println("IMPOSSIBLE");
    }
  }
}

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

using namespace std;

int main() {
    int x;
    cin >> x;
    
    int ans = 0;
    if (400 <= x && x < 600) {
        ans = 8;
    } else if (600 <= x && x < 800) {
        ans = 7;
    } else if (800 <= x && x < 1000) {
        ans = 6;
    } else if (1000 <= x && x < 1200) {
        ans = 5;
    } else if (1200 <= x && x < 1400) {
        ans = 4;
    } else if (1400 <= x && x < 1600) {
        ans = 3;
    } else if (1600 <= x && x < 1800) {
        ans = 2;
    } else if (1800 <= x && x < 2000) {
        ans = 1;
    }

    cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

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

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

  vector<ll> T(n);
  for (int i = 0; i < n; i++) {
    cin >> T[i];
  }

  ll LCM = 1;
  for (int i = 0; i < n; i++) {
    ll nGCD = gcd(LCM, T[i]);
    LCM = LCM / nGCD * T[i];
  }

  cout << LCM << endl;
  
  return 0;
}

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

int main()
{
	int n;
	while( std::cin >> n, n )
	{
		int cnt[10];
		memset( cnt, 0, sizeof( cnt ) );

		for( int i = 0; i != n; ++i )
		{
			int a;
			std::cin >> a;
			++cnt[a];
		}

		for( int i = 0; i <= 9; ++i )
			std::cout << ( cnt[i] ? std::string( cnt[i], '*' ) : "-" ) << std::endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
  int x,y;
  cin>>x>>y;

  string ans = "No";
  for(int a=0;a<x+1;a++)
  {
    int b = x-a;
    if(2*a+4*b==y)
      ans = "Yes";
  }
  cout<<ans<<"\n";
  return 0;
}


Measured memory_bytes: 3588
main(l,m,n,i){
	for(;scanf("%d",&l),l;){
		for(i=1;i<=12;i++){
			scanf("%d%d",&m,&n);
			l-=m-n;
			if(l<=0)	break;
		}
		printf(i<=12?"%d\n":"NA\n",i);
		for(;i<12;i++)	scanf("%*d%*d");
	}
	exit(0);
}

Measured memory_bytes: 0
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <fstream>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
typedef long long ll;

#define INF 1000000000
#define MAX 100000

bool isprime[MAX];
vector<int> primes;

void make_list(){
    fill(isprime, isprime+MAX, true);
    isprime[0]=isprime[1]=false;
    for(int i=2; i<=MAX/2; i++){
        if(isprime[i]){
            for(int j=i*2; j<=MAX; j+=i) isprime[j]=false;
            primes.pb(i);
        }
    }
}

int main(){
    make_list();
    int m,a,b;
    int n=primes.size();
    while(cin>>m>>a>>b, m|a|b){
        bool flg=true;
        int p,q;
        if(m%2==0) m--;
        while(flg){
            rep(i,n){
                if(m/2 < primes[i] || primes[i]>320) break;
                if( m%primes[i]==0 && isprime[m/primes[i]]==true ){
                    p = primes[i];
                    q = m/primes[i];
                    if(p>q) swap(p,q);
                    if(a*q>b*p) break;
                    flg=false;
                    break;
                }
            }
            m--;
            if(m>4)m--;
        }
        cout<<p<<" "<<q<<endl;
    }

    return 0;
}

Measured memory_bytes: 1368
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)

int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int main(void){
  map<int,int> mf,ms;
  string str;
  int cn,a,b;
  while(getline(cin,str),str.size()!=0){
    stringstream ss;
    rep(i,str.size()){
      if(str[i]==',') str[i] = ' ' ;
    }
    ss << str;
    ss >> a;
    mf[a]++;
    ss.str("");
    
  }
  while(scanf("%d,%d",&a,&b)!=EOF){
    if(mf[a]!=0){
      if(ms[a]==0)ms[a]+=mf[a];
      ms[a]++;
    }
  }
  map<int,int>::iterator it = ms.begin();
  while(it!=ms.end()){
    cout << it->first << ' ' << it->second << endl;
    it ++;
  }
}

Measured memory_bytes: 1284
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
  int N,M,C;
  cin >> N >> M >> C;
  int B[M];
  for(int i=0;i<M;i++){
    cin >> B[i];
  }
  int A[N][M];
  for(int i=0;i<N;i++){
    for(int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  int ans = 0;
  for(int i=0;i<N;i++){
    int cnt = 0;
    for(int j=0;j<M;j++){
      cnt += A[i][j] * B[j];
    }
    if(cnt + C > 0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
//RHYTHM_086_NS_01
//ALAN_IS_ON....

#include <bits/stdc++.h>

//define

#define                boost_                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define                iter_(i,n)                     for (int i = 0; i < int(n); i++)
#define                for_n(i, n)                    for (int i = 1; i <= int(n); i++)
#define                pb                             push_back
#define                mp                             make_pair
#define                itr                            ::iterator
#define                s_sort(s)                      sort(s.begin(),s.end())
#define                n_sort(a)                      sort(a,a+n)
#define                thank_you                      return 0
#define                thanks                         return
#define                pii                            pair<int,int>
#define                precise_impact                 cout<<setprecision(10)<<fixed;

using namespace std;

//data type
typedef long long int ll;
typedef unsigned long long int ulli;
typedef double db;


//constants
#define PI acos(-1.00)
#define MOD 1000000007

ll bigmod(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll tm=bigmod(a,b/2);
    tm=(tm*tm)%MOD;
    if(b%2==1)
        tm=(tm*a)%MOD;
    return tm;

}
int egcd(int a,int b,int &x,int &y){
    if(a==0){
        x=0;
        y=1;
        return b;
    }
    int x1,y1;
    int d=egcd(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
    return d;
}

void solve();


int main()
{
    boost_;
    precise_impact;
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Here we go...
    int t=1;
    //cin>>t;
    while(t--)
        solve();

    thank_you;
}


void solve()
{
    int a,b;
    cin>>a>>b;
    string s,p;
    iter_(i,b){
        s+=(char)(a+48);
    }
    iter_(i,a){
        p+=(char)(b+48);
    }
    if(p<s){
        cout<<p<<endl;
    }
    else
        cout<<s<<endl;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <regex>

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
int T[110];
int M;
int P[110];
int X[110];

int main() {
    cin >> N;
    rep(i, N) cin >> T[i];
    cin >> M;
    rep(i, M) cin >> P[i] >> X[i];

    for (int i = 0; i < M; i++) {
        int sec = 0;
        int problemIndex = P[i] - 1;
        for (int j = 0; j < N; j++) {
            if (j == problemIndex) {
                sec += X[i];
            } else {
                sec += T[j];
            }
        }
        cout << sec << endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
using iii = tuple<int, int, int>;
using mii = map<int, int>;
using vi = vector<int>;
using viii = vector<iii>;
 
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, q, a, b;
  cin >> n >> q;
  vi x(n);
  mii m;
  for (int i = 0; i < n; i++) {
    int y;
    cin >> y;
    if (m.count(y)) x[i] = m[y];
    else x[i] = m.size(), m[y] = x[i];
  }
  viii y(q);
  for (int i = 0; i < q; i++) {
    cin >> a >> b;
    y[i] = {a-1, b, i};
  }
  int k = sqrt(n);
  sort(y.begin(), y.end(), [&](iii x, iii y) -> bool {
    int a1, b1, i1, a2, b2, i2;
    tie(a1, b1, i1) = x;
    tie(a2, b2, i2) = y;
    int a1q = a1/k, a2q = a2/k;
    if (a1q < a2q) return true;
    if (a1q > a2q) return false;
    return b1 < b2;
  });
  vi res(q);
  vi count(m.size());
  int l = 0, r = 0, ans = 0;
  for (iii z : y) {
    int i;
    tie(a, b, i) = z;
    while (r < b) if (++count[x[r++]] == 1) ans++;
    while (r > b) if (--count[x[--r]] == 0) ans--;
    while (l < a) if (--count[x[l++]] == 0) ans--;
    while (l > a) if (++count[x[--l]] == 1) ans++;
    res[i] = ans;
  }
  for (int z : res) cout << z << '\n';
    return 0;
}

Measured memory_bytes: 38936
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ld long double
#define vi vector<vector<ll> >
using namespace std;
const int MOD=1000000007;
const int MOD2=15000007;
const ll MAX=9187201950435737471;
const int N=100005;
const ll INF=1e17;
const long double PI=acos(-1);



void solve(int T){
    int n;
    vector<pair<int,int> >v;
    cin>>n;
    for(int i=0;i<n;i++){
        int x,y;
        cin>>x>>y;
        v.pb({x,y});
    }
    for(int i=2;i<n;i++){
        bool x=1;
        for(int j=i;j>i-3;j--){
            if(v[j].fi!=v[j].se)x=0;
        }
        if(x==1){
                cout<<"Yes\n";
            return;
        }
    }
    cout<<"No\n";

}

int main() {
    fastio
    int T=1;
    //cin>>T;
    for(int i=1;i<=T;i++){
        solve(i);
        //if(i<T)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 3652
import java.util.*;

class UF{
	public int[] a;
	public UF(int size){
		Arrays.fill(a=new int[size],-1);
	}
	public int root(int t){
		return a[t]<0?t:(a[t]=root(a[t]));
	}
	public boolean connect(int p,int c){
		p=root(p);
		c=root(c);
		if(p==c)
			return false;
		if(a[p]>a[c]){
			int buf=c;
			c=p;
			p=buf;
		}
		a[p]+=a[c];
		a[c]=p;
		return true;
	}
	public boolean isConnected(int a,int b){
		return root(a)==root(b);
	}
	public int groupSize(int t){
		return -a[root(t)];
	}
}

public class Main{
	public static void main(String[] $){
		var s=new Scanner(System.in);

		var n=s.nextInt();
		var q=s.nextInt();

		var uf=new UF(n);

		for(int i=0;i<q;++i)
			if(s.nextInt()==0)
				uf.connect(s.nextInt(),s.nextInt());
			else
				System.out.println(uf.isConnected(s.nextInt(),s.nextInt())?1:0);
	}
}


Measured memory_bytes: 68272
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#define BLACK 0
#define RED 1
#define MAN 2

int count;
int tile[20][20];
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
int W,H;
int countdebug;

void hukasa(int width,int height);


int main(){

	int height,width;
	int i,j;
	char s;

	while(scanf("%d %d",&W,&H) && W && H){

		count = 0;


		for(j=0; j<H; j++){
			scanf("%*c");
			for(i=0; i<W; i++){

				scanf("%c",&s);

				if(s == '.'){
					tile[i][j] = BLACK;
				}
				else if(s == '#'){
					tile[i][j] = RED;
				}
				else if(s == '@'){
					tile[i][j] = RED;
					height = j;
					width = i;
				}

			}
		}

		hukasa(width,height);

		printf("%d\n",count+1);

	}
	return 0;
}



void hukasa(int width,int height){

	int i;


	for(i=0;i<4;i++){

		if(!(width + dx[i] < 0 || height + dy[i] < 0 || width + dx[i] > W - 1 || height + dy[i] > H - 1) ){
			if(tile[width + dx[i]][height + dy[i]] == BLACK){
				tile[width + dx[i]][height + dy[i]] = RED;
				count++;
				hukasa(width + dx[i],height + dy[i]);
			}
		}

	}
}

Measured memory_bytes: 1192
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int ans=0,J,O,I;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++){
    if(s[i]!='J')continue;

    for(J=0;s[i]=='J';i++)J++;
    for(O=0;s[i]=='O';i++)O++;
    if(s[i]=='J'){
      i--;
      continue;
    }
    for(I=0;s[i]=='I';i++)I++;
    if(J>=O&&I>=O)ans=max(ans,O);
    if(s[i]=='J'){
      i--;
      continue;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1964
while True:
    H, W = map(int, raw_input().split())
    if H == W == 0: break
    ls = [list(raw_input()) for i in range(H)]
    x, y = 0, 0
    while True:
    	tile = ls[y][x]
    	ls[y][x] = 0
        if tile == '.':
            print x,y
            break
        elif tile == '>':
            x += 1
        elif tile == '<':
            x -= 1
        elif tile == '^':
            y -= 1
        elif tile == 'v':
            y += 1
        else:
            print 'LOOP'
            break

Measured memory_bytes: 4400
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

const int N = 1e7 + 1;

int dp[N];
void testcase() {

    int n; cin >> n;

    for (int i=2; i<=(n/2); i++) {
        for (int j=i+i; j<=n; j+=i) {
            dp[j]++;
        }
    }

    ll res = 0;
    rep (i, 1, n) {
        res += ((ll)dp[i]+2LL)*i;
    }
    cout << res - 1;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 42704
#include<iostream>
#include<string>
using namespace std;
int main(){
    string W,T;
    cin>>W;
    
    for(int i=0;i<W.size();i++){
        if('A'<=W[i]&&W[i]<='Z')W[i]=tolower(W[i]);
    }
    
    int n=0;
    while(cin>>T&&T!="END_OF_TEXT"){
        for(int i=0;i<T.size();i++){
            if('A'<=T[i]&&T[i]<='Z')T[i]=tolower(T[i]);
        }
        if(T==W)n++;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 3184
def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
mod = 10**9+7 #出力の制限
N = 5*10**5 #Nの最大値
g1 = [0]*(N+1) #元テーブル
g1[0] = g1[1] = 1
g2 = [0]*(N+1) #逆元テーブル
g2[0] = g2[1] = 1
inverse = [0]*(N+1) #逆元テーブル計算用テーブル
inverse[0],inverse[1] = 0,1
for i in range(2,N+1):
    g1[i] = (g1[i-1] * i) % mod
    inverse[i] = (-inverse[mod % i] * (mod//i)) % mod
    g2[i] = (g2[i-1] * inverse[i]) % mod

N, M = map(int, input().split())
ans = 0
for i in range(N+1):
    ans += cmb(N,i,mod)*((-1)**i)*g1[M]*g2[M-i]*((g1[M-i]*g2[M-N])**2)
    ans %= mod
print(ans)

Measured memory_bytes: 99196
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <iomanip>
using namespace std;

int main(){
	int n;
  	float m;
	cin >> n;
	if(n%2 == 0){
		cout << 0.5 << endl;
	}else{
      	m = n;
      	m = (m+1)/2/m;
		cout << setprecision(10) << m << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,T,x;
int ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>N>>T>>x;
    while(--N){
        int y;
        cin>>y; 
        ans+=min(y-x,T);
        x=y;
    }
    cout<<ans+T<<endl;
    return 0;
}


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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

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

	double summ=v[0];
	for (int i = 1; i < n; i++) {
		summ = (summ + v[i]) / 2;
	}

	cout << summ << endl;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REV(v) reverse(v.begin(), v.end());
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, start, stop) for (int i = start; i < stop; i++)
#define FORR(i, start, stop) for (int i = start; i > stop; i--)
#define SORT(v, n) sort(v, v + n);
#define SORTR(v, n) sort(v, v + n,greater<int>());
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.begin(), v.end(),greater<int>());
#define REMOVE(v,n) remove(vector<int> v,v+v.size(),int n)
#define ll long long
#define ull unsigned long long
#define pb(a) push_back(a)
#define INF 999999999
#define V(v,i,j) vector(v.begin() + i, v.begin() + j)
#define INSERT(va,vb) va.insert(va.end(), vb.begin(), vb.end())
using namespace std;
typedef vector<int> vint;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
const int MOD = 1000000007;
void chmin(int &a, int b) { if (a > b) a = b; }

//vector< vector<int> > v (size1, vector<int>(size2) );

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin>>N;
    vector<ll> A(N);
    FOR(i,0,N){
        cin>>A[i];
        A[i]-=i+1;
    }
    VSORT(A);

    ll ans;

    FOR(i,0,N){
        ans+=abs(A[i]-A[N/2]);
    }

    cout<<ans<<endl;

}
//601

Measured memory_bytes: 1792
N = int(input())
p = input()
list1 = list(map(int,p.split()))

list2 = []
for i in range(1,N + 1):
    list2.append(i)

if list1 == list2:
    print("YES")
    exit()
for i in range(0,N):
    if list1[i] != i+1:
        if i+1 == list1[list1[i]-1]:
            list1[list1[i]-1] = list1[i]
            list1[i] = i+1
            

        if list1 == list2:
            print("YES")
            exit()
        else:
            print("NO")
            exit()

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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll n, l;
	cin >> n >> l;

	ll sum = (l - 1) * n + n * (n + 1) / 2;
	ll r = l + n - 1;

	ll ret;
	if(l * r <= 0) {
		ret = sum;
	} else if(absi(l) < absi(r)) {
		ret = sum - l;
	} else {
		ret = sum - r;
	}

	cout << ret << endl;


	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] arg) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int L = scanner.nextInt();

        int[][] E = new int[N][N];
        for (int u = 0; u < N; u++) {
            for (int v = 0; v < N; v++) {
                E[u][v] = (u == v ? 0 : L + 1);
            }
        }

        for (int i = 0; i < M; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            int c = scanner.nextInt();
            E[a - 1][b - 1] = c;
            E[b - 1][a - 1] = c;
        }

        allpairsShortestPaths(E);

        for (int u = 0; u < N; u++) {
            for (int v = 0; v < N; v++) {
                E[u][v] = (E[u][v] <= L ? 1 : N + 1);
            }
        }

        allpairsShortestPaths(E);

        int Q = scanner.nextInt();
        for (int i = 0; i < Q; i++) {
            int s = scanner.nextInt();
            int t = scanner.nextInt();
            int d = E[s - 1][t - 1];
            System.out.println(d < N ? d - 1 : -1);
        }
    }

    /** Floyd-Warshall algorithm */
    static void allpairsShortestPaths(int[][] D) {
        int N = D.length;
        for (int v = 0; v < N; v++) {
            for (int a = 0; a < N; a++) {
                for (int b = 0; b < N; b++) {
                    D[a][b] = Math.min(D[a][b], D[a][v] + D[v][b]);
                }
            }
        }
    }
}


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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define INF (1LL<<60)
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define rep1(i,n) for(ll i = 1; i <= (n); i++)

template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}


// 最大公約数
ll gcd(ll a, ll b)
{
  if(b == 0) return a;
  return gcd(b, a % b);
}

// mod m におけるa の逆元
ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b; swap(a, b);
    u -= t * v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

// 素因数分解
vector<pair<ll, ll>> prim;
void pf(ll n)
{
  ll s = sqrt(n);
  ll r = 0;
  for(ll i = 2; i <= s; i++) {
    if((n % i) == 0) {
      r = 0;
      do {
	r++;
	n = n / i;
      } while((n % i) == 0);
      prim.push_back({i, r});
    }
  }
  if(n > s) {
    prim.push_back({n, 1});
  }
}

void solve()
{
  ll N; cin >> N;
  vector<ll> a(N); rep(i, N) cin >> a[i];
  
  ll ans = 0;

  sort(a.begin(), a.end());
  ll t = 0;
  ll s = 0;
  rep(i, N - 1) {
    s += a[i];
    if(s * 2 < a[i + 1]) {
      t = i + 1;
    }
  }
  ans = N - t;
  
  cout << ans << endl;
}


int main(void)
{
  // ll t; cin >> t; rep(i, t)
  solve();
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define PI (acos(-1))

class UnionFind{
  public:
  //親の番号を格納する 親だった場合-1*集合のサイズ
  vector<int> Parent;

  //コンストラクタ 初めはバラバラの状態
  UnionFind(int N){
    Parent = vector<int>(N,-1);//要素数N,要素の値-1で初期化
  }

  //Ａがどのグループに属しているか調べる
  int root(int A){
    if(Parent[A] < 0)return A;//Aが親だったらA自身を返す
    return Parent[A] = root(Parent[A]);//親に繋ぎなおす
  }

  //頂点数を調べる
  int size(int A){
    return -Parent[root(A)];//Aの根×-1=集合のサイズ
  }

  //AとBをくっつける
  bool connect(int A, int B){
    //Aの根とBの根をくっつける
    A = root(A);
    B = root(B);
    if(A==B)return false;//既に同じグループならそのままでfalseを返す

    //Aのサイズ>=Bのサイズとする  
    if(size(A)<size(B))swap(A,B);

    Parent[A] += Parent[B];//AのサイズにBのサイズを足す
    Parent[B] = A;//Bの親をAに変更する
    return true;
  }

  //AとBが同じグループかどうか調べる
  bool same(int A,int B){
    if(root(A)==root(B))return true;
    else return false;
  }

};

int main(){
  int N,M;
  cin >> N >> M;
  int p[100010];
  rep(i,N){
    cin >> p[i];
    p[i]--;
  }

  UnionFind Uni(N);

  rep(i,M){
    int x,y;
    cin >> x >> y;
    x--;y--;
    Uni.connect(x,y);
  }

  int cnt=0;
  rep(i,N){
    if(Uni.same(i,p[i]))cnt++;
  }

  cout << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;
int sum[4];
double dp[301][301][301];

int main() {
    int N;
    scanf("%d", &N);
    for (int i=0;i<N;i++) {
        int a;
        scanf("%d", &a);
        sum[a]++;
    }
    double fail;
    for (int k=0;k<=sum[3];k++)
        for (int j=0;j<=sum[3] + sum[2] - k;j++)
            for (int i=0;i<=N - j - k;i++) {
                fail = 1.0 / (1 - (double)(N - i - j - k)/N); 
                double divis = (i + j + k);
                if (i) {
                   
                    dp[i][j][k] += i / divis * (dp[i - 1][j][k]);
                }
                if (j)
                    dp[i][j][k] += j / divis * (dp[i + 1][j - 1][k]);
                if (k)
                    dp[i][j][k] += k / divis * (dp[i][j + 1][k - 1]);
                if (i + j + k) 
                    dp[i][j][k] += fail;
            }
    printf("%.9lf\n", dp[sum[1]][sum[2]][sum[3]] );
}

Measured memory_bytes: 111160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1000000000
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repM(i, n) for (int i = n; i > 0; i--)

int main() {
    int N;
    cin >> N;
    string S,T;
    cin >> S >> T;
    string ans="";
    rep(i,N){
        ans = ans + S[i];
        ans = ans + T[i];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256