akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	//Inspiration@99
	long long n;
	cin>>n;
	vector<long long> v;
	for(long long i=0;i<n;i++)
	{
		long long x;
		cin>>x;
		v.push_back(x);
	}
	vector<long long> ans;
	ans.push_back(0);
	ans.push_back(abs(v[1]-v[0]));
	for(long long i=2;i<n;i++)
	{
		if(abs(v[i]-v[i-1])+ans[i-1]<abs(v[i]-v[i-2])+ans[i-2])
		{
			ans.push_back(abs(v[i]-v[i-1])+ans[i-1]);
		}
		else
		{
			ans.push_back(abs(v[i]-v[i-2])+ans[i-2]);
		}
	}
	cout<<endl;
	cout<<ans[n-1]<<endl;
}

Measured memory_bytes: 2548
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args) {
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
      String S = in.readLine();
      int len = S.length();
      boolean[] exist = new boolean[26];
      char a = 'a';
      boolean result = true;
      for(int i=0;i<len;i++){
        if(exist[S.charAt(i)-a]){
          result = false;
          break;
        }else{
          exist[S.charAt(i)-a] = true;
        }
      }
      if(result){
        System.out.println("yes");
      }else{
        System.out.println("no");
      }
    }catch(IOException e){
      e.printStackTrace();
    }
  }
}


Measured memory_bytes: 21076
#include <stdio.h>


int main() {
	int N;
	int p[50];
	int i, j;
	int temp = 0;
	int countclear, countj=0;
	int k = 0;

	scanf("%d", &N);

	for (i = 1; i <=N; i++) {
		scanf("%d", &p[i]);
	}

	for (i = 1; i <= N; i++) {
		if (i != p[i]) {
			k++;
		}
	}

	if (k <= 2) {
		printf("YES\n");
	}
	else {
		printf("NO\n");
	}
	
	return 0;
}


Measured memory_bytes: 128
// inputに入力データ全体が入る
function Main(input) {
    // 1行目がinput[0], 2行目がinput[1], …に入る
    input = input.split("\n");
    tmp0 = input[0].split(" ");
    X = Number(tmp0[0]);
    Y = Number(tmp0[1]);
    x=X+Y/2;
    console.log(x);
 
  }
  //*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
  Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//   

Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  string s;
  cin >> s;
  int q;
  cin >> q;
  int r = 0;
  string mae = "", ato = "";
  rep(i, q){
    int t;
    cin >> t;
    if (t == 1) r++;
    else {
      int f;
      char c;
      cin >> f >> c;
      int res = r%2;
      if (res) {
        if (f == 2) mae = c + mae;
        else ato += c; 
      } else {
        if (f == 1) mae = c + mae;
        else ato += c; 
      }
    }
  }
  string ans = mae + s + ato;
  if (r%2) reverse(ALL(ans));
  cout << ans << endl;
} 

Measured memory_bytes: 1360
# 入力の取得
k, n = map(int, input().split())
a = list(map(int, input().split()))

min_distance = k + 1
for index, x in enumerate(a):
    start = a[index]
    goal = a[(n - 1 + index) % n]
    if goal == 0:
        goal = k

    if start < goal:
        work_distance = goal - start
    else:
        work_distance = k + goal - start

    if work_distance < min_distance:
        min_distance = work_distance

print(min_distance)

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

int main() {
  int N;
  cin >> N;
  double ans = 0;
  for (int i = 0; i < N; i++) {
    double a;
    cin >> a;
    ans += double(1.0) / a;
  }
  ans = double(1.0) / ans;
  cout << ans << endl;
  return 0;
}

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

using namespace std;

class Node
{
public:
    int key;
    Node *parent, *left, *right;

    Node(int key)
    {
        this->key = key;
        parent = left = right = NULL;
    }
};

class BinarySearchTree
{
    Node *root;

public:
    BinarySearchTree()
    {
        root = NULL;
    }

    void insert(int key)
    {
        Node *node = new Node(key);

        if (root == NULL)
        {
            root = node;
            return;
        }

        Node *target = root;
        
        while (target != NULL)
        {
            if (target->key > node->key)
            { 
                if(target->left != NULL)
                {
                    target = target->left;
                }
                else
                {
                    target->left = node;
                    node->parent = target;
                    target = NULL;
                }
            }
            else
            {
                if(target->right != NULL)
                {
                    target = target->right;
                }
                else
                {
                    target->right = node;
                    node->parent = target;
                    target = NULL;
                }
            }
        }
    }

    void printPreOrder(Node *n)
    {
        if (n == NULL)
        {
            return;
        }

        cout << " " << n->key;

        if (n->left != NULL)
        {
            printPreOrder(n->left);
        }

        if (n->right != NULL)
        {
            printPreOrder(n->right);
        }
    }

    void printInOrder(Node *n)
    {
        if (n == NULL)
        {
            return;
        }

        if (n->left != NULL)
        {
            printInOrder(n->left);
        }

        cout << " " << n->key;

        if (n->right != NULL)
        {
            printInOrder(n->right);
        }
    }

    void print()
    {
        if (root == NULL)
        {
            return;
        }

        printInOrder(root);
        cout << endl;
        printPreOrder(root);
        cout << endl;
    }
};

int main()
{
    BinarySearchTree *tree = new BinarySearchTree;

    int m;
    cin >> m;

    for (int i = 0; i < m; i++)
    {
        string message;
        cin >> message;

        if (message == "insert")
        {
            int key;
            cin >> key;
            tree->insert(key);
        }
        else if (message == "print")
        {
            tree->print();
        }

        //cout << message << endl;
    }

    return 0;
}


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

int frog_jump_1(int arr[], int n) {
    int dp[n];
    dp[0] = 0;
    dp[1] = abs(arr[0] - arr[1]);

    for (int i = 2; i < n; i++) {
        dp[i] = min((dp[i - 1] + abs(arr[i] - arr[i - 1])), (dp[i - 2] + abs(arr[i] - arr[i - 2])));
    }
    return dp[n - 1];
}

int main() {
    int n; cin>>n;
    int arr[n];
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    cout << frog_jump_1(arr, n) << endl;
    return 0;
}

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

int main() {
	long long A, B;
	cin >> A >> B;
	if (A == B) {
		cout << 1 << endl;
		return 0;
	}
	int X;
	for (int i = 59; i >= 0; i--) {
		if (((A >> i) & 1) != ((B >> i) & 1)) {
			X = i;
			break;
		}
		A &= ~(1LL << i), B &= ~(1LL << i);
	}
	pair<long long, long long> Range1, Range2, Range3;
	Range1 = { A, (1LL << X) - 1 };
	Range2 = { A | (1LL << X), (1LL << (X + 1)) - 1 };
	B &= ~(1LL << X);
	Range3 = { (1LL << X), (1LL << X) };
	for (int i = X - 1; i >= 0; i--) {
		if ((1LL << i) <= B) Range3.second |= (1LL << i);
	}
	if (Range3.second < Range2.first) cout << Range1.second - Range1.first + 1 + Range2.second - Range2.first + 1 + Range3.second - Range3.first + 1 << endl;
	else cout << Range1.second - Range1.first + 1 + Range2.second - Range3.first + 1 << endl;
}

Measured memory_bytes: 3536
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> l_l;
typedef pair<int,int> i_i;
const ll MOD=1e9+7;
const int INF=1<<30;

ll inv[10];


int main(){
  char x; cin >> x;
  char y=x+1;
  cout << y << endl;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
const int MOD=998244353;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
/*
	Swamy Saranam

	Date	: 28/01/2018 18:02:54
	Author	: Krishna Mohan A M
	Problem	:
	Status	:
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef pair<int,int>	pii;
typedef pair<ld,ld>	pdd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef pair<ll,ll> pll;

#define FASTIO                ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FOR(i,a,b)            for(int i=(a);i<(b);i++)
#define REP(i,n)              FOR(i,0,n)
#define SORT(v)               sort((v).begin(),(v).end())
#define UN(v)                 SORT(v),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define CL(a,b)               memset(a,b,sizeof a)
#define PB                    push_back
#define F                     first
#define S                     second

const int MOD = 1000000007;
const int N = 2e5+5;

ll n, m, dist[N], l, r, d;
vector<pll> graph[N];
bool isPos;
queue<ll> q;

int main()
{
      FASTIO
      CL(dist, -1);
      cin>>n>>m;
      FOR(i, 1, n+1)
            dist[i] = MOD;
      REP(i, m){
            cin>>l>>r>>d;
            graph[l].PB({r, d});
            graph[r].PB({l, -d});
      }
      isPos = true;
      FOR(i, 1, n+1){
            if(dist[i]==MOD){
                  // cout<<"CC: "<<i<<"\n";
                  dist[i] = 0;
                  q.push(i);
                  while(!q.empty()){
                        ll cur = q.front();
                        q.pop();
                        for(pll v : graph[cur]){
                              if(dist[v.F]==MOD){
                                    dist[v.F] = dist[cur]+v.S;
                                    q.push(v.F);
                              }
                              else if(dist[v.F]!=dist[cur]+v.S){
                                    cout<<"No\n";
                                    return 0;
                              }
                        }
                  }
            }
      }
      cout<<"Yes\n";
      return 0;
}


Measured memory_bytes: 17152
from collections import deque
from sys import stdin


def main():
    lines = stdin.readlines()
    A = deque(map(int, lines[1].split()))
    B = deque(map(int, lines[2].split()))
    cnt = 0
    ans = 0
    while B:
        a = A.pop()
        b = B.pop()
        tmp = a if a < b else b
        ans += tmp
        if cnt % 2:
            A.append(a - tmp)
        else:
            B.append(b - tmp)
        cnt += 1
    print(ans)
    return


main()


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


int main(void){
	
	int square[2][200];
	int in_a=0;
	int in_b=0;
	int num=-1;
	int max_r,max_l,max_u,max_t;
	int ans_p[100];
	int ans_v[100];
	int i;
	int j;
	int k=0;
	
	
	while(1){
		
		for(i=0;i<2;i++){
			for(j=0;j<200;j++){
				square[i][j]=0;
			}
		
		}
		
		scanf("%d",&num);
		
		if(num==0){
				break;
		}
		
		if(num==1){
			ans_p[k]=1;
			ans_v[k]=1;
		}
			
		
		max_r=0;
		max_l=0;
		max_u=0;
		max_t=0;
		square[0][0]=0;
		square[1][0]=0;
		
		if(num!=1){
			for(i=1;i<num;i++){
				
				scanf("%d %d",&in_a,&in_b);
				
				switch(in_b){
					
					case 0: square[0][i]=square[0][in_a]-1;
					    	square[1][i]=square[1][in_a];
							break;
					case 1: square[0][i]=square[0][in_a];
					    	square[1][i]=square[1][in_a]-1;
							break;
					case 2: square[0][i]=square[0][in_a]+1;
					    	square[1][i]=square[1][in_a];
							break;
					case 3: square[0][i]=square[0][in_a];
					    	square[1][i]=square[1][in_a]+1;
							break;
				
				}
				
				if(max_l>square[0][i])max_l=square[0][i];
				if(max_r<square[0][i])max_r=square[0][i];
				if(max_t<square[1][i])max_t=square[1][i];
				if(max_u>square[1][i])max_u=square[1][i];
		
				
			}
			
			ans_p[k]=max_r-max_l+1;
			ans_v[k]=max_t-max_u+1;
		
			
		}
	
		k++;
		
	}
	ans_p[k]=-1;
	
	for(i=0;ans_p[i]!=-1;i++){
		printf("%d %d\n",ans_p[i],ans_v[i]);
	}
			
	
	

	return 0;
		
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll A, B, C, X;
        cin >> A >> B >> C >> X;
        ll ans = 0;
        rep(a, 0, A+1) {
                rep(b, 0, B+1) {
                        rep(c, 0, C+1) {
                                if (500*a + 100*b + 50*c == X) ++ans;
                        }
                }
        }
        cout << ans << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int h, w;
  cin >> h >> w;
  vector<vector<char>> s(h, vector<char>(w));
  for(int i = 0; i < h; i++){
    string tmp;
    cin >> tmp;
    for(int j = 0; j < w; j++) {
      s[i][j] = tmp[j];
    }
  }
  int dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
  int dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#'){
        cout << "#";
        continue;
      }
      int cnt = 0;
      for(int k = 0; k < 8; k++) {
        int nx = i + dx[k];
        int ny = j + dy[k];
        if(nx < 0 || nx >= h || ny < 0 || ny >= w){
          continue;
        }
        if(s[nx][ny] == '#'){
          cnt++;
        }
      }
      cout << cnt;
    }
    cout << '\n';
  }
    return 0;
}

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

#define PrintLn(X) cout << X << endl
#define Rep(i, n) for(int i = 0; i < (int)(n); ++i)

int T[100];
int main(void)
{
	int N, M;
	cin >> N;
	int ans = 0;
	Rep(i, N){
		cin >> T[i];
		ans += T[i];
	}
	cin >> M;
	Rep(i, M){
		int p, x;
		cin >> p >> x;
		p--;
		PrintLn(ans + x - T[p]);
	}
}


Measured memory_bytes: 256
import heapq as hq
n, k = map(int, input().split())
v = list(map(int, input().split()))*2
ans = -10**9
for i in range(1, n + 1):
    if i > k:
        continue
    tmp = -10**9
    for j in range(i + 1):
        value = 0
        stack = v[n+j-i:n+j].copy()
        hq.heapify(stack)
        value = sum(stack)
        for rep in range(k - i):
            if len(stack) == 0:
                break
            pick = hq.heappop(stack)
            if pick < 0:
                value -= pick
            else:
                break
        tmp = max(tmp, value)
    ans = max(ans, tmp)
print(ans)

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

int main() {
  int n;
  cin >> n;
  int ans = 0;
  int tmp = 0;
  for(int i = 0; i < n; i++) {
    int h;
    cin >> h;
    if(tmp <= h) {
      tmp = h;
      ans++;
    }
  }

  cout << ans << endl;
  
}


Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if (500 * i + 100 * j + 50 * k) == X:
        counter += 1

print(counter)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long A, B, V, W, T;
    cin >> A >> V;
    cin >> B >> W;
    cin >> T;
    if (A <= B){
        if (T*V + A >= T*W + B) cout << "YES" << endl;
        else cout << "NO" << endl;
    }else{
        if (B - W*T >= A - V*T) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <stack>
#include <unordered_map>
#define lld long long int
#define dbg1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define dbg2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define dbg3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string a,b;
	cin >> a >> b;
	cout << b << a;
}

Measured memory_bytes: 256
# B - 1 Dimensional World's Tale
N, M, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

ans = "War"

for Z in range(-100,101):
    if max(x) < Z <= min(y):
        if X < Z <= Y:
            ans = "No War"
            break

print(ans)

Measured memory_bytes: 9184
N = int(input())
A = list(map(int, input().split()))    

count, end =-1,0
while end==0:
    for i in range(N):
        if A[i]% 2 == 1:
            end=1
            break
    A= list(map(lambda x: x/2, A))
    count +=1
print(count)



Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define rf(i,n) for(int i=n-1;i>=0;i--)
#define rf1(i,n) for(int i=n-1;i>=1;--i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)
#define PI 3.1415926535897932384626433832795
#define fi first
#define se second
#define mp(x,y) make_pair(x,y)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define BIN(n,x) bitset<n>(x)  //bitshift works on 32 bit integers only
#define mod (ll)1000000007
#define mod1 (ll)998242353
using namespace std;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;

//nC2
ll C2(ll n){
    ll ans= max(((n*(n-1))/2),(ll)0);
    return ans;
}
//square
ll sq(ll n){
    return n*n;
}

//GCD
ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    if(b==0){
        return a;
    }    
    else{
        return gcd(b,a%b);
    }
}

//LCM
ll lcm(ll a,ll b){
    if(a==0 || b==0){
        return 0;
    }
    else{
        return((ll)((a*b)/gcd(a,b)));
    }
}

//sort pair by second values
bool sortsec(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.second < b.second); 
}
//sort pair by first vals in descending
bool sortinrev(const pair<ll,ll> &a, const pair<ll,ll> &b){ 
    return (a.first > b.first); 
} 

//Binary Exponentiation
ll BinExp(ll a, ll b, ll m){
    a%=m;
    ll res =1;
    while(b>0){
        if(b&1){
            res = (res * a)%m;
        }
        a=(a*a)%m;
        b>>=1;
    }
    return res;
}

//All Non-Empty SubSequences(O(2*n))
vvi SubSeq;
void allSub(vector<int> arr, int index,vector<int> subarr){
    if (index == arr.size()){ 
        int l = subarr.size(); 
        if (l != 0){
            SubSeq.pb(subarr); 
        }
    } 
    else{ 
        allSub(arr, index + 1, subarr); 
        subarr.push_back(arr[index]); 
        allSub(arr, index + 1, subarr); 
    } 
    return; 
} 

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

    ll n;
    cin>>n;
    double x=((double)25/26)*(double)n+1;
    double k=(double)log(x)/(double)log(26);
    //cout<<x<<endl<<k<<endl;
    int y=k;
    if(k==(double)y){
        f(i,y){
            cout<<'z';
        }
        cout<<endl;
    }
    else{
        ll z=((ll)pow(26,y)-1)*26/25;
        ll a=n-z;
        string ans;
        for(int i=0;i<=y;++i){
            ll b=(ll)(pow(26,y-i));
            ll m=((a-1)/b);
            char an=(char)(97+m);
           //cout<<an<<endl;
            a-=m*b;
            ans+=an;
        }
        cout<<ans<<endl;
    }

    


    return 0;
}



Measured memory_bytes: 4064
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double[] vArr = new double[n];

        for (int i = 0; i < n; i++) {
            vArr[i] = (double) sc.nextInt();
        }

        Arrays.sort(vArr);

        for (int i = 0; i < n; i++) {
            if (i+1 >= n) break;
            double tmpNew = (vArr[i] + vArr[i+1])/2;
            vArr[i+1] = tmpNew;
        }

        System.out.println(vArr[n-1]);
    }
}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;

const ll MOD=1000000007ll;
const int MAX=5100000;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

void inputArray(int * p, int a){
    for(int i=0;i<a;i++){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    for(int i=0;i<a;i++){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

// nCr
ll comb(ll n, ll r){
	ll t=1000000;
	fact[0]=1;
	    for(int i=0;i<t;i++){ fact[i+1]=fact[i]*(i+1)%MOD;}
	fact_inv[t]=power(fact[t], MOD-2);
	for(int i=0;i<t;i++){ fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;}
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int i,j,k,tmp;
ll ans = 0;

int main()
{
	cin.tie(0);	ios::sync_with_stdio(false);
    cin >> tmp;
	if(tmp >= 30){cout << "Yes" << endl;}
	else{cout << "No" << endl;}

  return 0;
}


Measured memory_bytes: 3648
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll N;
    cin >> N;
    for (ll i = 0; ; i++) {
        if ((i + 1) * i / 2 >= N) {
            for (ll j = i; j >= 1; j--) {
                if (N >= j) {
                    N -= j;
                    cout << j << endl;
                }
            }
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <hash_map>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define ll long long
using namespace std;

inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, k;
int a[60];
int main()
{
	n = read();
	int mxid = 1, mx = 0;
	rep(i, 1, n)
	{
		a[i] = read();
		if(abs(a[i]) > mx) mx = abs(a[i]), mxid = i;
	}
	cout << 2 * n - 1 << endl;
	if(a[mxid] >= 0)
	{
		rep(i, 1, n)
		{
			printf("%d %d\n", mxid, i);
			a[i] += mx;
		}
		rep(i, 1, n - 1)
			printf("%d %d\n", i, i + 1);
		//printf("%d %d\n", n, 1);
	}
	else
	{
		rep(i, 1, n)
		{
			printf("%d %d\n", mxid, i);
			a[i] -= mx;
		}
		rrep(i, n, 2)
			printf("%d %d\n", i, i - 1);
		//printf("1 %d\n", n);
	}


	return 0;
}


Measured memory_bytes: 256
//
// Created by nhatminh2947 on 7/3/19.
//

#include <bits/stdc++.h>

using namespace std;

int main() {
    int n;
    int p[25];

    cin >> n;

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

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

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
x=0
for i in range(1,a+1):
  for j in range(11,b+1):
    lst = []
    while j > 0:
      lst.append(j%10)
      j //= 10
    lst.reverse()
    if lst[0] >= 2 and lst[1] >= 2:
      if i == lst[0]*lst[1]:
        x+=1
print(x)
      

Measured memory_bytes: 3060
typedef long long ll;

#include <algorithm>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <iostream>
#include <queue>
#include <set>
using namespace std;

struct edge{
  int a;
  int b;
  int c;
  edge(int aa, int bb, int cc) :
    a(aa), b(bb), c(cc){}
};

bool operator < (const edge &lhs, const edge &rhs){
  return lhs.c < rhs.c;
}

class UnionFind{
private:
  vector<int> id;
  vector<int> cnt;

  int getId(int i){
    if(i == id[i]) return i;
    return id[i] = getId(id[i]);
  }
public:
  UnionFind(int size = 0){ init(size); }
  ~UnionFind(){}
  void init(int size){
    id = vector<int>(size);
    cnt = vector<int>(size);
    for(int i = 0; i < size; i++){
      id[i] = i;
      cnt[i] = 1;
    }
  }
  void unite(int i, int j){
    int next = min( getId(i), getId(j) );
    if(getId(i) != next || getId(j) != next){
      if(getId(i) == next){
	cnt[getId(i)] += cnt[getId(j)];
      }else{
	cnt[getId(j)] += cnt[getId(i)];
      }
    }
    id[getId(i)] = id[getId(j)] = next;
  }
  int getCnt(int i){ return cnt[getId(i)]; }
  int operator [](int i){ return getId(i); }
};

int main(){
  const int n = getInt();
  vector<edge> v; v.reserve(n);
  UnionFind uf(n);
  REP(i,n - 1){
    const int a = getInt();
    const int b = getInt();
    const int c = getInt();

    v.push_back(edge(a, b, c));
  }

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

  ll ans = 0;
  REP(i,n - 1){
    const int a = v[i].a;
    const int b = v[i].b;
    const int c = v[i].c;

    const ll aa = uf.getCnt(a);
    const ll bb = uf.getCnt(b);

    ans += aa * bb * c;

    uf.unite(a, b);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 5892
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cassert>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

typedef long long ll;

constexpr int INF = 1e8;
constexpr int MOD = 1e9+7;
constexpr int ESP = 1e-9;
constexpr double PI = acos(-1);

int main(void) {
    int i, n;
    int l[200];
    cin >> n;
    REP (i,2*n) cin >> l[i];
    sort(l,l+2*n);
    int ans = 0;
    REP (i,n) ans += l[i*2];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define dup(x,y) (((x)+(y)-1)/(y))
#define v(T) vector<T>
#define vv(T) v(v(T))
using ll = int64_t;
using ull = uint64_t;
using uint = uint32_t;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using pil = pair<int,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,v.size())i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,v.size())s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(v.size())o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const double eps = 1e-6;
const ll LINF = 100200300400500600ll;
const int INF = 1001001001;
//--------------------------------------------------------
#define fastio cin.tie(nullptr); std::ios::sync_with_stdio(false);
#define myio ifstream iofi; if(argc>1){iofi.open(argv[1]); std::cin.rdbuf(iofi.rdbuf());}
#define myloopset int loop = 1; if(argc>2) loop =stoi(argv[2]); rep(i,loop)
//--------------------------------------------------------------
template <class T> T chmin(T &a,T b){if(a>b){a=b; return 1;}else return 0;}
template <class T> T chmax(T &a,T b){if(a<b){a=b; return 1;}else return 0;}
const int dx[4] = {0,1,0,-1};
const int dy[4] = {-1,0,1,0};
#define MOD 1000000007

ll binomial(int N, int K) {
  if(K < 0 || N < K) return 0;
  ll ret = 1;
  for(ll i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
void Main(){
  string s;
  cin>>s;
  int k;
  cin>>k;
  if(s.length()>=k){
    ll ans = binomial(s.length(),k);
    rep(i,k) ans*=9;
    if(k==1){
      string t(s.length(),'0');
      srep(i,1,10){
        t[0] = i+'0';
        if(s<t) ans--;
      }
    }else if(k==2){
      srep(i,1,10){
        srep(j,1,10){
          rep(k,s.length()-1){
            string t(s.length(),'0');
            t[0] = i+'0';
            t[k+1] = j+'0'; 
            if(s<t) ans--;
          }
        }
      }
    } else {
      srep(i,1,10){
        srep(j,1,10){
          srep(k,1,10){
            srep(p1,1,s.length()){
              srep(p2,p1+1,s.length()){
                string t(s.length(),'0');
                t[0] = i+'0';
                t[p1] = j+'0'; 
                t[p2] = k+'0'; 
                if(s<t) ans--;
              }
            }
          }
        }
      }
    }

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


} signed main(int argc,char** argv)
{fastio; myio; myloopset Main();}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{

	public static void main(String[] args) {




		Scanner scan = new Scanner(System.in);
		String[] aStrings = new String[3];
		for(int i= 0; i < 3;i++){
			aStrings[i] = scan.next();
		}
		for(int i = 0;i < 3;i++){
			System.out.print(aStrings[i].charAt(i));
		}



	}


}


Measured memory_bytes: 21076
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;

int arr[101] = {0};

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if(b*c >= a)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
}



Measured memory_bytes: 3644
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		sc.nextLine();
		String[] str =  new String[N+1];
		int[] t = new int[N+1];
		int[] x = new int[N+1];
		int[] y = new int[N+1];
		t [0] = 0;
		x [0] = 0;
		y [0] = 0;
		
		for(int i = 1; i <= N; i++ ) {
			str[i]= sc.nextLine(); 
		}
		sc.close();
		
		for(int i = 1; i <= N; i++) {
			String[] s = str[i].split(" ");
			t[i] = Integer.parseInt(s[0]);
			x[i] = Integer.parseInt(s[1]);
			y[i] = Integer.parseInt(s[2]);
		}
		
		for(int j = 0; j < N; j++) {
			int absT = t[j+1] - t[j];
			int absX = Math.abs(x[j+1] - x[j]);
			int absY = Math.abs(y[j+1] - y[j]);
	
            if(absT < absX + absY || absT % 2 != (absX + absY) % 2 ) {
                System.out.println("No");
                System.exit(0);
            } 
		}
		System.out.println("Yes");
	}
}

Measured memory_bytes: 132700
n = int(input())
ary = list(map(int, input().split()))
#print(n,ary)

ary_2 = [ary[0]]
for i in range(1, n):
    ary_2.append(ary[i] + ary_2[i-1])
ary_2 = [0] + ary_2
#print(ary_2)

from collections import Counter
c = Counter(ary_2)
v = (c.values())
#print(v)

ans = 0
for j in v:
    if j > 1:
        ans += j * (j-1) // 2 # 'J'個から'2'個選ぶ場合の数_combination, 重複無し

print(ans)


Measured memory_bytes: 44416
#include<bits/stdc++.h>
using namespace std;
long long n,k;
long long ans=1;
long long l_neg=-1,l_pos=-1,r_neg=-1,r_pos=-1;
const long long M=1000000007;
bool cmp(long long a,long long b)
{
    return abs(a)<abs(b);
}
long long calc(vector<long long> a)
{
    long long temp=1;
    for(long long i=n-k;i<n;i++)
        temp=(temp*a[i])%M;
    return (temp+M)%M;
}
int main()
{
    cin>>n>>k;
    vector<long long> a(n, 0);
    for(long long i=0;i<n;i++)
        cin>>a[i];
    sort(a.begin(),a.end(),cmp);
    for(long long i=n-k;i<n;i++)
    {
        ans=(ans*a[i])%M;
        if(r_pos==-1&&a[i]>0)
            r_pos=i;
        if(r_neg==-1&&a[i]<0)
            r_neg=i;
    }
    for(long long i=n-k-1;i>=0;i--)
    {
        if(l_pos==-1&&a[i]>0)
            l_pos=i;
        if(l_neg==-1&&a[i]<0)
            l_neg=i;
    }
    if(ans<0&&n!=k)
    {
        if(r_pos==-1)
        {
            if(l_pos==-1)
            {
                ans=1;
                for(long long i=0;i<k;i++)
                    ans=(ans*a[i])%M;
            }
            else
            {
                swap(a[l_pos],a[r_neg]);
                ans=calc(a);
            }
        }
        else
        {
            if(l_neg==-1)
            {
                swap(a[l_pos],a[r_neg]);
                ans=calc(a);
            }
            else if(l_pos==-1)
            {
                swap(a[l_neg],a[r_pos]);
                ans=calc(a);
            }
            else
            {
                vector<long long> c1=a;
                vector<long long> c2=a;
                swap(c1[l_neg],c1[r_pos]);
                swap(c2[l_pos],c2[r_neg]);
                ans=(abs(a[l_neg]*a[r_neg])>abs(a[l_pos]*a[r_pos]))?calc(c1):calc(c2);
            }
        }
    }
    cout<<(ans+M)%M<<endl;
    return 0;
}

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

using namespace std;

const int max_n = 200222, inf = 1000111222;

struct point {
    int x, y, id;

    bool operator < (const point &p) const {
        return x < p.x;
    }
};

template<typename T>
struct segment_tree {
    pair<T, int> mn[4 * max_n];

    void build(int v, int l, int r, T a[]) {
        if (l == r) {
            mn[v] = {a[l], l};
            return;
        }
        int mid = (l + r) / 2;
        build(2 * v, l, mid, a);
        build(2 * v + 1, mid + 1, r, a);
        mn[v] = min(mn[2 * v], mn[2 * v + 1]);
    }

    void update(int v, int l, int r, int x, T value) {
        if (l == r) {
            mn[v] = {value, l};
            return;
        }
        int mid = (l + r) / 2;
        if (x <= mid) {
            update(2 * v, l, mid, x, value);
        } else {
            update(2 * v + 1, mid + 1, r, x, value);
        }
        mn[v] = min(mn[2 * v], mn[2 * v + 1]);
    }

    pair<T, int> get_min(int v, int tl, int tr, int l, int r) {
        if (tl == l && tr == r) {
            return mn[v];
        }
        int mid = (tl + tr) / 2;
        if (r <= mid) {
            return get_min(2 * v, tl, mid, l, r);
        } else if (l > mid) {
            return get_min(2 * v + 1, mid + 1, tr, l, r);
        }
        return min(get_min(2 * v, tl, mid, l, mid), get_min(2 * v + 1, mid + 1, tr, mid + 1, r));
    }
};

#define y1 qwe
#define y2 qwer

int n, ans[max_n], used[max_n], sz[max_n], comps;
int y1[max_n], y2[max_n];
point p[max_n];
segment_tree<int> t1, t2;

void dfs(int v) {
    //cout << v << endl;
    ++sz[comps];
    used[v] = comps;
    y1[v] = inf;
    y2[v] = inf;
    t1.update(1, 0, n - 1, v, y1[v]);
    t2.update(1, 0, n - 1, v, y2[v]);
    while (true) {
        pair<int, int> mn = t1.get_min(1, 0, n - 1, 0, v);
        if (mn.first >= p[v].y) {
            break;
        }
        dfs(mn.second);
    }
    while (true) {
        pair<int, int> mn = t2.get_min(1, 0, n - 1, v, n - 1);
        if (mn.first >= -p[v].y) {
            break;
        }
        //cout << "@" << mn.first << " " << mn.second << " " << p[v].y << endl;
        dfs(mn.second);
    }
}

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d%d", &p[i].x, &p[i].y);
        --p[i].x;
        --p[i].y;
        p[i].id = i;
    }
    sort(p, p + n);
    for (int i = 0; i < n; ++i) {
        y1[i] = p[i].y;
        y2[i] = -p[i].y;
    }
    t1.build(1, 0, n - 1, y1);
    t2.build(1, 0, n - 1, y2);
    memset(used, -1, sizeof(used));
    for (int i = 0; i < n; ++i) {
        if (used[i] == -1) {
            dfs(i);
            ++comps;
        }
    }
    for (int i = 0; i < n; ++i) {
        ans[p[i].id] = sz[used[i]];
    }
    for (int i = 0; i < n; ++i) {
        printf("%d\n", ans[i]);
    }
    return 0;
}


Measured memory_bytes: 54808
#include <queue>
#include <vector>
#include <iostream>
using namespace std;
const int bits = 20;
struct edge {
	int to, cost;
};
struct state {
	int pos, cost, dist, pop, par;
};
bool operator<(const state& s1, const state& s2) {
	if (s1.cost != s2.cost) return s1.cost > s2.cost;
	if (s1.dist != s2.dist) return s1.dist > s2.dist;
	return s1.pop > s2.pop;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	int N, M;
	cin >> N >> M;
	vector<int> t(N);
	for (int i = 0; i < N; ++i) cin >> t[i];
	vector<vector<edge> > G(N);
	for (int i = 0; i < M; ++i) {
		int a, b, c;
		cin >> a >> b >> c; --a, --b;
		G[a].push_back(edge{ b, c });
		G[b].push_back(edge{ a, c });
	}
	priority_queue<state> que;
	que.push(state{ 0, 0, 0, t[0], -1 });
	vector<int> p(N, -2), pc(N), days(N), costs(N);
	while (!que.empty()) {
		state u = que.top(); que.pop();
		if (p[u.pos] == -2) {
			p[u.pos] = u.par;
			days[u.pos] = u.dist;
			costs[u.pos] = u.cost;
			for (edge e : G[u.pos]) {
				if (p[e.to] == -2) {
					que.push(state{ e.to, u.cost + e.cost, u.dist + 1, t[u.pos], u.pos });
				}
			}
		}
	}
	vector<vector<int> > xp(bits, vector<int>(N));
	xp[0] = p; xp[0][0] = 0;
	for (int i = 1; i < bits; ++i) {
		for (int j = 0; j < N; ++j) {
			xp[i][j] = xp[i - 1][xp[i - 1][j]];
		}
	}
	int Q;
	cin >> Q;
	for (int i = 0; i < Q; ++i) {
		int pos, day, money;
		cin >> pos >> day >> money; --pos;
		int forward = max(days[pos] - day, 0);
		int fpos = pos;
		for (int j = bits - 1; j >= 0; --j) {
			if ((forward >> j) & 1) fpos = xp[j][fpos];
		}
		int least = costs[pos] - costs[fpos];
		int ans = least + max(costs[fpos] - money, 0);
		cout << ans << '\n';
	}
	return 0;
}


Measured memory_bytes: 35716
#include<bits/stdc++.h>
using namespace std;
bool x[210][210];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<210;i++)
	for(int j=0;j<210;j++)
	x[i][j]=true;
	for(int i=1;i<=210;i++)
	for(int j=1;j<=m*2;j+=2)
	x[i][j]=false;
	for(int i=1;i<=210;i++)
	for(int j=1;j<=n*2;j+=2)
	x[j][i]=false;
	int num=0;
	for(int i=0;i<210;i++)
	for(int j=0;j<210;j++)
	if(x[i][j]==true&&x[i][j-1]==false&&x[i][j+1]==false&&x[i+1][j]==false&&x[i-1][j]==false)num++;	
	cout<<num<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,N;
    int C[51],V[51];
    int sub[51]={};
    int max=0;
    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&V[i]);
    for(i=0;i<N;i++) scanf("%d",&C[i]);
    for(i=0;i<N;i++){
        sub[i] = V[i]-C[i];
        if(sub[i]>0) max += sub[i];
    }
    printf("%d\n",max);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstdio>
using namespace std;
const int M = 1e5 + 10;
int f[M];
int find(int x) {
    if(x == f[x]) return f[x];
    int tmp = find(f[x]);
    return f[x] = tmp;
}
struct TnT {
    int x , y , pos , num;
}T[M] , GT[M << 1];
bool cmp1(TnT a , TnT b) {
    return a.x < b.x;
}
bool cmp2(TnT a , TnT b) {
    return a.y < b.y;
}
bool cmp3(TnT a , TnT b) {
    return a.num < b.num;
}
int main() {
    int n;
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; i++) {
        scanf("%d%d" , &T[i].x , &T[i].y);
        T[i].pos = i;
    }
    for(int i = 1 ; i <= n ; i++) f[i] = i;
    sort(T + 1 , T + 1 + n , cmp1);
    int cnt = 0;
    for(int i = 1 ; i < n ; i++) {
        GT[++cnt].x = T[i].pos , GT[cnt].y = T[i + 1].pos , GT[cnt].num = T[i + 1].x - T[i].x;
    }
    sort(T + 1 , T + 1 + n , cmp2);
    for(int i = 1 ; i < n ; i++) {
        GT[++cnt].x = T[i].pos , GT[cnt].y = T[i + 1].pos , GT[cnt].num = T[i + 1].y - T[i].y;
    }
    int sum = 0;
    sort(GT + 1 , GT + 1 + cnt , cmp3);
    for(int i = 1 ; i <= cnt ; i++) {
        GT[i].x = find(GT[i].x) , GT[i].y = find(GT[i].y);
        if(GT[i].x != GT[i].y) {
            f[GT[i].x] = GT[i].y;
            sum += GT[i].num;
        }
    }
    printf("%d\n" , sum);
    return 0;
}

Measured memory_bytes: 5376
#最大公約数を求めたあとに
#素因数分解？して、素因数の種類？
p,q=map(int,input().split())

def gcd(a,b):
    if b>a:
        return(gcd(b,a))
    else:
        if a%b==0:
            return(b)
        else:
            return(gcd(b,a%b))

def soin(n):
    ans={1:1}
    for i in range(2,int(pow(n,1/2))+1):
        while n%i==0:
            ans[i]=ans.get(i,0)+1
            n//=i
    if n>1:
        ans[n]=1
    return(ans)
  
r=gcd(p,q)
print(len(soin(r)))

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

pair<int,int> v[100001];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>v[i].first>>v[i].second;
	sort(v+1,v+n+1);
	int idx = 1;
	for(int i=1;i<=n;i++)
		if(v[i].second<v[idx].second)
			idx = i;
	int Lmax = v[1].first, Rmin = v[1].second;
	for(int i=1;i<=n;i++)
		Lmax = max(Lmax,v[i].first), Rmin = min(Rmin,v[i].second);
	int ans = 0;
	int x = v[n].second;
	for(int i=n-1;i>=idx;i--){
		ans = max(ans,max(Rmin-v[i].first+1,0) + max(x-Lmax+1,0));
		x = min(x, v[i].second);
	}
	for(int i=1;i<=n;i++)
		ans = max(ans,max(Rmin-Lmax+1,0)+v[i].second-v[i].first+1);
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
/**
 * Title: D - Powerful Discount Tickets
 * Url: https://atcoder.jp/contests/abc141/tasks/abc141_d
 */
#include<bits/stdc++.h>

using namespace std;

#define ll long long

int main() {

    int n, m; cin >> n >> m;
    vector<ll> a(n);
    for(int i=0; i<n; i++) cin >> a[i];
    vector<pair<ll, int>> ca(n);
    for(int i=0; i<n; i++) {
        ca[i] = make_pair(a[i], i);
    }

    // 前処理
    int max_h = 0;
    for(int i=0; i<n; i++) {
        int x = (int)log2(a[i]);
        max_h = max(max_h, x);
    }

    vector<int> cnt(n);

    sort(ca.begin(), ca.end(), greater<pair<ll, int>>());

    // 1
    for(int i=max_h; i>=0; i--) {
        // N
        for(int j=0; j<n; j++) {
            if((int)log2(ca[j].first)==i) {
                ca[j].first /= 2;
                cnt[ca[j].second]++;
                m--;
            }
            if(m==0) break;
        }
        // NlogN
        sort(ca.begin(), ca.end(), greater<pair<ll, int>>());
        if(m==0) break;
    }

    if(m>0) {
        cout << 0 << endl;
    } else {
        ll ans = 0;
        for(int i=0; i<n; i++) {
            ans += a[i] / pow(2, cnt[i]);
        }
        cout << ans << endl;
    }


    return 0;
}

Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()
#define pb push_back

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

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

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

	ll N, X;
	cin >> N >> X;
	vector<ll> x(N);
	rep(i, N) cin >> x[i];

	x.push_back(X);

	sort(allof(x));

	ll ans = x[1] - x[0];

	Rep(i, 2, N + 1) {
		ll d = x[i] - x[i - 1];
		ans = gcd(ans, d);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
a,b = map(int,input().split(" "))
ar = [0 for i in range(a)]
for i in range(b):
    c,d = map(int,input().split(" "))
    ar[c-1] += 1
    ar[d-1] += 1
for r in ar:
    if r % 2 == 1:
        print("NO")
        exit()
print("YES")

Measured memory_bytes: 3888
def one_out_of_three(A: int, B: int, C: int)->int:
    if A == B:
        return C
    if A == C:
        return B
    return A


if __name__ == "__main__":
    A, B, C = map(int, input().split())
    ans = one_out_of_three(A, B, C)
    print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

int main(){
	int awal = 1;
	int n, k;
	scanf("%d", &n);
	scanf("%d", &k);
	for (int i = 0; i<n; i++){
		awal*2 > awal+k ? awal+=k : awal*=2;
	}
	printf("%d", awal);
	return 0;
}

Measured memory_bytes: 1688
use std::cmp::min;
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let nt: Vec<i64> = read_vec();
    let tn: Vec<i64> = read_vec();
    let ans = (0..nt[0] - 1).fold(nt[1], |x, y| {
        let sub = (tn[(y + 1) as usize] - tn[y as usize]).abs();
        x + min(nt[1], sub)
    });
    println!("{}", ans);
}

Measured memory_bytes: 8444
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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 main(){
    int n;
    cin >> n;
    set<ll> a;
    REP(i,n){
        ll input;
        cin >> input;
        a.insert(input);
    }
    if(a.size()==n){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 9600
n = gets.to_i

a = (n / 100) <= 12 && (n / 100)  != 0
b = (n % 100) <= 12 && (n % 100)  != 0

if a && b
  puts 'AMBIGUOUS'
elsif a && !b
  puts 'MMYY'
elsif !a && b
  puts 'YYMM'
else
  puts 'NA'
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
using Graph = vector<vector<int> >;
using GraphC = vector<vector<char> >;
typedef pair<int, int> P;
const int MAX_N = 10000;
const int MAX_L = 100000000;
const int MAX_SQRT_B = 10000;
const int INF = 1000000000;
typedef int64_t ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll a, b, c;

int main() {
	cin >> a >> b >> c;
	
	ll ans = min((a % 2) * b * c, min((b % 2) * a * c, (c % 2) * a * b));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3568