akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define REP(i,n) for(long long i = 0; i < (n); i++)
#define FOR(i, m, n) for(long long i = (m);i < (n); ++i)
#define ALL(obj) (obj).begin(),(obj).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template <class T> void corner(bool flg, T hoge) { if (flg) { cout << hoge << endl; exit(0); } }
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) { o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o; }
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) { o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o; }
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) { o << "{" << obj.first << ", " << obj.second << "}"; return o; }
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) { o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o; }
void print(void) { cout << endl; }
template <class Head> void print(Head&& head) { cout << head; print(); }
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) { cout << head << " "; print(forward<Tail>(tail)...); }
void YN(bool flg) { cout << ((flg) ? "YES" : "NO") << endl; }
void Yn(bool flg) { cout << ((flg) ? "Yes" : "No") << endl; }
void yn(bool flg) { cout << ((flg) ? "yes" : "no") << endl; }

//Repeat Square Method x^n MOD 
long long RSM(long long x, long long n, long long MOD) {
	long long y = 1;
	for (; n > 0; n >>= 1, (x *= x) %= MOD) if (n & 1) (y *= x) %= MOD;
	return y;
}

int main() {
	ll N; cin >> N;
	V<ll> A(N + 1,0);
	FOR(i, 1, N + 1) cin >> A[i];
	V<ll> P(N + 1,0);
	FOR(i, 1, N + 1) P[i] = RSM(i, MOD - 2, MOD);
	FOR(i, 1, N + 1) (P[i] += P[i - 1]) %= MOD;
	V<ll> C(N + 1);
	FOR(i, 1, N + 1) C[i] = (P[N - (i - 1)] + (P[i] - P[1]) + MOD)%MOD;
	ll ans = 0;
	FOR(i, 1, N + 1) (ans += (C[i] * A[i]) % MOD) %= MOD;
	FOR(i, 1, N + 1) (ans *= i) %= MOD;
	cout << ans << endl;
}

Measured memory_bytes: 2560
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
#define P pair<ll, ll>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl

class mint {
    long long x;
public:
    mint(long long x=0) : x((x%MOD+MOD)%MOD) {}
    mint operator-() const {
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }

    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

/* -- template -- */

int main() {
    double R; cin >> R;
    printf("%.5f", 2 * R * M_PI);
}


Measured memory_bytes: 3788
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[205];
int cnt;
bool check(int x[])
{
	for(int i=1;i<=n;i++)
		if(x[i]%2==1) return false;
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	while(check(a)==true)
	{
		for(int i=1;i<=n;i++)
			a[i]/=2;
		cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
using System;
using System.IO;
using System.Linq;

namespace Tree
{
    class Tree_Walk
    {
        struct Node
        {
            public int id;
            public int parent;
            public int left, right;
        }

        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            var nodes = new Node[size];

            for (int i = 0; i < size; i++)
                nodes[i].parent = -1;

            for (int i = 0; i < size; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var id = token[0];
                var l = token[1];
                var r = token[2];
                nodes[id].id = id;
                nodes[id].left = l;
                nodes[id].right = r;
                if (l != -1) nodes[l].parent = id;
                if (r != -1) nodes[r].parent = id;
            }

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            for (int i = 0; i < size; i++)
                if (nodes[i].parent == -1)
                {
                    Console.WriteLine("Preorder");
                    Preorder(nodes, i);
                    Console.WriteLine();
                    Console.WriteLine("Inorder");
                    Inorder(nodes, i);
                    Console.WriteLine();
                    Console.WriteLine("Postorder");
                    Postorder(nodes, i);
                    Console.WriteLine();
                    break;
                }

            Console.Out.Flush();
        }

        static void Preorder(Node[] nodes, int id)
        {
            if (id == -1) return;
            Console.Write(" " + nodes[id].id);
            Preorder(nodes, nodes[id].left);
            Preorder(nodes, nodes[id].right);
        }

        static void Inorder(Node[] nodes, int id)
        {
            if (id == -1) return;
            Inorder(nodes, nodes[id].left);
            Console.Write(" " + nodes[id].id);
            Inorder(nodes, nodes[id].right);
        }

        static void Postorder(Node[] nodes, int id)
        {
            if (id == -1) return;
            Postorder(nodes, nodes[id].left);
            Postorder(nodes, nodes[id].right);
            Console.Write(" " + nodes[id].id);
        }
    }
}

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

/**
 * バブルソート
 * 
 *
 */

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

		int n = s.nextInt();
		
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
			arr[i] = s.nextInt();
		}
		
		bubbleSort(arr, n);
		
	}
	
	public static void bubbleSort(int[] arr, int n) {
		boolean flag = true;
		int count = 0;
		while (flag) {
			flag = false;
			for (int j = n-1; j > 0; j--) {
				if (arr[j] < arr[j-1]) {
					int tmp = arr[j];
					arr[j] = arr[j-1];
					arr[j-1] = tmp;
					flag = true;
					count += 1;
				}
			}
		}
		printArray(arr);
		System.out.println(count);
	}
	
	public static void printArray(int[] arr) {
		String ans = "";
		for (int i = 0; i < arr.length; i++) {
			ans += arr[i] + " ";
		}
		System.out.println(ans.trim());
	}
}


Measured memory_bytes: 26440
import numpy as np

n = int(input())
a = input().split()
a = list(map(int,a))

#d = np.diff(np.array(a))
#print(d)
count =0
x = 0
#for i in d:
#  if i > 0:
#    count+=1
#print(count+1)    
for i in a:
  if x <= i:
    x = max(x,i)
    count +=1
    
print(count) 

Measured memory_bytes: 12504
import sys
input = sys.stdin.readline
S = input().strip()
mod = 10**9+7
a = 0
ab = 0
ans = 0
q = 1
for c in S:
    if c == 'A':
        a += q
    elif c == 'B':
        ab += a
    elif c == 'C':
        ans += ab
    elif c == '?':
        a, ab, ans, q = a*3+q, ab*3+a, ans*3+ab, q*3
    a %= mod
    ab %= mod
    ans %= mod
    q %= mod
print(ans % mod)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  string s;
  cin>>s;
  ll sum=0;
  int n=s.size();
  for(int bid=0;bid<(1<<n-1);bid++){
     ll cnt=s[0]-'0';
    for(int i=0;i<n-1;i++){
      if(bid&(1<<i)){
        sum+=cnt;
        cnt=s[i+1]-'0';
      }
      else{
        cnt*=10;
        cnt+=s[i+1]-'0';
      }
      
    }
    sum+=cnt;
  }
  cout<<sum<<endl;
}

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define push push
#define all(v) v.begin(),v.end()
#define rep(i,l,r) for(int i = (int)(l) ; i < (int)(r) ; i++)
#define clr(a,x) memset(a,x,sizeof(a));
#define rr(v) for(auto &val:v)
#define print(v) for(const auto itr:v){ cout << itr << ' ';} cout << endl;
#define init(v,x) for(auto &itr:v){ itr = x; }
#define minpq(x) x,vector<x>,greater<x>
#define ln length()
#define sz size()
#define infinity 1e18;
#define elif else if

signed main(){
    fastIO
    
    int k;
    cin >> k;
    
    string s = "ACL";
    string ans="";
    
    while(k--) {
		ans.append(s);
	}
	
	cout << ans;

    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int xx;
bool is_prime(ll x){
if(x<=1) return 0;
for(int i=2;i*i<=x;i++){
    if(x%i==0)return 0;
}
return 1;
}
int main(){
ll x;
cin>>x;
while(true){
    if(is_prime(x)){
        cout<< x << "\n";
        return 0;
    }
    x++;
}
return 0;

}



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

int main() {
    double r;
    double role;
    double sqrt;
    const double pi = M_PI;

    cin >> r;

    role = 2 * r * pi;
    sqrt = r * r * pi;

    cout << fixed << setprecision(6) << sqrt << " " << role << "\n";
}


Measured memory_bytes: 3292
/*
         Md.Fagun Molla
         18ICTCSE006
         BSMRSTU(SHIICT)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define End return 0

int main ()
{
    ll n;
    ll s=0;
    cin>>n;
    ll ans=0;
    ll i=0;
    while(n>0)
    {
        ans+=pow(2,i);
        i++;
        n/=2;
    }
    cout<<ans<<endl;

}
/* pray for me
All is well
*/


Measured memory_bytes: 256
main = do
  [n,m,x] <- fmap (map read . words) getLine
  as <- fmap (map read . words) getLine
  print (solve n m x as)


solve :: Int -> Int -> Int -> [Int] -> Int
solve n m x as =
  min (length ls) (length rs)
  where
    (ls,rs) = span (<x) as

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
        int n,q,r=0;
        cin>>n;
        int a[n];
        for(int i=0;i<n;i++) cin>>a[i];
        cin>>q;
        int b[q];
        for(int i=0;i<q;i++) cin>>b[i];
        for(int i=0;i<q;i++) {
                for(int j=0;j<n;j++){
                        if(a[j]==b[i]){
                                r++;
                                break;
                        }
                }
        }
        cout<<r<<endl;
        return 0;
}


Measured memory_bytes: 3092
def main():
    n = int(input())
    num_list = list(map(int, input().split()))

    for i in range(n):
        num_list[i] -= 1

    count = 0
    for i in range(n-1):
        if num_list[i] == i:
            num_list[i], num_list[i+1] = num_list[i+1], num_list[i]
            count += 1

    if num_list[n-1] == n-1:
        num_list[i], num_list[i-1] = num_list[i-1], num_list[i]
        count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 52332
#include <bits/stdc++.h>
 
using namespace std;
 
int main(void) {
  	string str;
  	cin >> str;
  	if (str.length()%2 != 0) {
    	cout << "No" << endl;
      	return 0;
    }
  	int flag = 1;
  	for (int i=0; str[i]; i+=2) {
    	if (str[i]!='h') flag = 0;
      	if (str[i+1]!='i') flag = 0;
    }
  	if (flag) cout << "Yes" << endl;
  	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
def sol(n):
    d = {}
    N = 1000
    for i in xrange(-N, N+1):
        d[i**5]=i
    for i in d:
        j = n+i
        if j in d:
            print d[j], d[i]
            return

def main():
    n = input()
    sol(n)
if __name__ == '__main__':
    main()

Measured memory_bytes: 66236
N,K = gets.split.map(&:to_i)
res = 0.to_f
(1..N).each do |i|
  tmp,cnt = i,0
  while( tmp < K )
    tmp *= 2
    cnt += 1
  end
  res += (1.to_f/N) * (1.to_f/2)**cnt.to_f
end
p res

Measured memory_bytes: 1788
use std::io::Read;
use std::cmp::max;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();
    let q: usize = iterator.next().unwrap().parse().unwrap();
    let mut a: Vec<usize> = Vec::new();
    let mut b: Vec<usize> = Vec::new();
    let mut c: Vec<usize> = Vec::new();
    let mut d: Vec<usize> = Vec::new();
    for _ in 0..q {
        a.push(iterator.next().unwrap().parse().unwrap());
        b.push(iterator.next().unwrap().parse().unwrap());
        c.push(iterator.next().unwrap().parse().unwrap());
        d.push(iterator.next().unwrap().parse().unwrap());
    }

    let mut array: Vec<usize> = vec![0; n];
    let mut arrays: Vec<Vec<usize>> = Vec::new();
    dfs(0, n, m, &mut array, &mut arrays);

    let mut ans: usize = 0;
    for array in arrays.iter() {
        let mut score: usize = 0;
        for i in 0..q {
            if array[b[i] - 1] - array[a[i] - 1] == c[i] {
                score += d[i];
            }
        }
        ans = max(ans, score);
    }

    return ans.to_string()
}

fn dfs(i: usize, n: usize, m: usize, array: &mut Vec<usize>, arrays: &mut Vec<Vec<usize>>) {
    if i == n {
        arrays.push(array.clone());
        return;
    }

    let mut last: usize = if i == 0 {
        1
    } else {
        array[i - 1]
    };
    while last <= m {
        array[i] = last;
        dfs(i + 1, n, m, array, arrays);
        last += 1;
    }
}


Measured memory_bytes: 12668
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
//#define int long long
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }

int main() {
    char c;
    cin >> c;
    cout << ++c << endl;
}

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

#define pb push_back
#define ll long long
#define fi first
#define se second
const int N = 1e8+7;
int dp[N];
#define MOD 1000000007
ll power(ll a, ll b) {ll ret=1;while(b) {if(b&1) ret*=a;a*=a;if(ret>=MOD) ret%=MOD;if(a>=MOD) a%=MOD;b>>=1;}return ret;}
int ncr(int n,int r){if(n<r)return 0;int p=1,k=1;if(n-r<r)r=n-r;if(r!=0){while(r){p*=n;k*=r;int g=__gcd(p, k);p/=g;k/=g;n--;r--;}}else p=1;return p;}

void solve()
{
    int n,k;
   // cout<<1;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
        cin>>a[i];
   // memset(dp,1e8+7,sizeof(dp));

    for(int i=1;i<=k;i++)
        dp[i]=abs(a[i]-a[1]);
    ll m;
    for(int i=k+1;i<=n;i++)
    {
        ll minn=999999999;
        for(int j=1;j<=k;j++)
        {
            m=dp[i-j]+abs(a[i]-a[i-j]);
            if(m<minn)
                minn=m;
        }
        dp[i]=minn;
       
    }
    cout<<dp[n];

}

int main()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
    }
}

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

bool is_pal(int a){
  stringstream ss;
  ss << a;
  string s = ss.str();
  for(int i=0;i<(int)s.size()/2;i++){
    if(s[i] != s[s.size()-1-i])return false;
  }
  return true;
}

int main(){
  int n;
  cin >> n;
  
  int ans = 1e9;
  for(int i=1;;i++){
    if(is_pal(i)){
      if(abs(n-ans) > abs(n-i)){
	ans = i;
      }
      if(i>=n)break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1220
#include <stdio.h>

#define MAX 100

//static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

int n, M[MAX][MAX];

void dijkstra(){
  int i, u, v, minv, d[MAX], color[MAX];
  for(i=0; i<n; i++){
    d[i] = INFTY;
    color[i] = WHITE;
  }
  d[0] = 0;
  color[0] = GRAY;
  while(1){
    minv = INFTY;
    u = -1;
    for(i=0; i<n; i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u = i;
	minv = d[i];
      }
    }
    if(u==-1) break;
    color[u] = BLACK;
    for(v=0; v<n; v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>d[u]+M[u][v]){
	  d[v] = d[u]+M[u][v];
	  color[v] = GRAY;
	}
      }
    }
  }
  for(i=0; i<n; i++){
    if(d[i]==INFTY) printf("%d -1\n", i);
    else printf("%d %d\n", i, d[i]);
  }
}

int main(){
  int i, j, k, c, u, v;
  
  scanf("%d", &n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++) M[i][j]=INFTY;
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    for(j=0; j<k; j++){
      scanf("%d%d", &v, &c);
      M[u][v] = c;
    }
  }

  dijkstra();

  return 0;
}



Measured memory_bytes: 2112
using System;

class Program
{
    static void Main(string[] args)
    {
        string[] input = Console.ReadLine().Split(' ');
        Console.WriteLine((long.Parse(input[2]) * 60 + long.Parse(input[3]))
        - (long.Parse(input[0]) * 60 + long.Parse(input[1]))
        - long.Parse(input[4]));
    }
}

Measured memory_bytes: 27556
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> a(N), b(N); rep(i, 0, N) {
		cin >> a[i] >> b[i];
	}
	using T = tuple<int, int, int>;
	vector<T> c(N);
	rep(i, 0, N)c[i] = T(a[i] + b[i], abs(a[i] - b[i]), i);
	sort(all(c));
	reverse(all(c));

	int ans = 0;
	rep(i, 0, N) {
		int x, y, z; tie(x, y, z) = c[i];
		if (i % 2 == 0) {
			ans += a[z];
		}
		else {
			ans -= b[z];
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4224
i=input
p=print
l=len
person=[i(),i(),i()]
f=0
t="a"
try:
  while True:
    t=person[f][0]
    person[f]=person[f][1:]
    if t=='a':
      f=0
    elif t=='b':
      f=1
    elif t=='c':
      f=2
except IndexError:
  p(['A','B','C'][f])

Measured memory_bytes: 3064
import math
n = int(input())
if n == 2:
	print(1)
else:
	rn = int(math.sqrt(n) // 1)
	li = []
	for i in range(2, rn+1):
		if n % i == 0:
			li.append(i)
	#print(li)
	ans = 0
	for i in range(len(li)):
		m = n
		while m % li[i] == 0:
			m //= li[i]
		if m % li[i] == 1:
			ans += 1
			#print(m, li[i])
	#print(ans)
	rm = int(math.sqrt(n-1)//1)
	cnt = 0
	irregu = 0
	for i in range(2, rm+1):
		if (n-1) % i == 0:
			#print('divisor', i)
			cnt += 1
		if (n-1) == i**2:
			irregu += 1
	#print(cnt)
	ans += (2*cnt+2-irregu)
	print(ans)

Measured memory_bytes: 40172
#include<bits/stdc++.h>
using namespace std;
inline int_fast64_t read(){int_fast64_t x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
void Main(){
    int N = read(), T = read(), c, t, ans = 1001;
    for(int i = 0; i<N; i++) {
        c = read();
        t = read();
        if (t <= T) ans = min(ans, c);
    }
    if (ans > 1000) {
        printf("TLE\n");
        return;
    }
    printf("%d\n", ans);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> P;

struct graph_t {
	int n;           // |V|, index begins with 0
	int m;           // |E|
	vector<P> edges; // E
	vector<ll> cost; // cost or distance
	vector<ll> cap;  // capacity
};

class Finding_Bridge {
private:
	struct node {
		int id; bool done; vi to_eid; vi to; int from_eid; int from; int pre; int low;
	};
	vector<node> nodes;
	int n;
	int ord;
	vector<P> bridges_idpair;
	vi bridges_eid;
	void lowlink_dfs(int a, int root) {
		nodes[a].done = 1;
		nodes[a].pre = nodes[a].low = ord;
		ord++;
		int cnt = 0;
		Loop(i, nodes[a].to.size()) {
			int b = nodes[a].to[i];
			if (b == nodes[a].from) continue;
			if (!nodes[b].done) {
				nodes[b].from = a;
				lowlink_dfs(b, root);
				nodes[a].low = min(nodes[a].low, nodes[b].low);
				if (nodes[a].pre <= nodes[b].low) cnt++;
				if (nodes[a].pre < nodes[b].low) {
					if (a < b) bridges_idpair.push_back({ a,b });
					else bridges_idpair.push_back({ b,a });
					bridges_eid.push_back(nodes[a].to_eid[i]);
				}
			}
			else {
				nodes[a].low = min(nodes[a].low, nodes[b].pre);
			}
		}
		return;
	}
public:
	Finding_Bridge(graph_t G) {
		n = G.n;
		nodes.resize(n);
		Loop(i, n) nodes[i] = { i, false,{},{}, -1, -1, -1, -1 };
		Loop(i, G.edges.size()) {
			nodes[G.edges[i].first].to_eid.push_back(i);
			nodes[G.edges[i].first].to.push_back(G.edges[i].second);
		}
		ord = 0;
		Loop(i, nodes.size()) {
			if (!nodes[i].done) lowlink_dfs(i, i);
		}
		sort(bridges_idpair.begin(), bridges_idpair.end());
		sort(bridges_eid.begin(), bridges_eid.end());
	}
	vector<P> get_bridges_idpair() {
		return bridges_idpair;
	}
	vi get_bridges_eid() {
		return bridges_eid;
	}
};

// prim sample
int main() {
	graph_t G;
	cin >> G.n >> G.m;
	Loop(i, G.m) {
		int s, t; cin >> s >> t;
		G.edges.push_back({ s, t });
		G.edges.push_back({ t, s });
	}
	Finding_Bridge finding_bridge(G);
	vector<P> bridges = finding_bridge.get_bridges_idpair();
	Loop(i, bridges.size()) {
		cout << bridges[i].first << " " << bridges[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 6620
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#define nmax_def 110000
#define Cmax_def 2200
#define mod 1000000007
#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;

int main() {
	int N, K;
	string S;
	cin >> N >> K;
	cin >> S;
	int ans = N - 1;
	rep(i, N - 1) {
		if (S[i] != S[i + 1])
			ans--;
	}
	ans += (K * 2);
	ans = min(ans, N - 1);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import javax.print.DocFlavor;
import java.awt.*;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.*;
import java.util.List;

public class Main {

    static String br = System.getProperty("line.separator");
    static Scanner sc = new Scanner(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        int A = nextInt();
        int B = nextInt();

        int an = A-B*2;
        println(an<0 ? 0 : an);
    }

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

    static Long nextLong() {
        return Long.parseLong(next());
    }

    static String next() {
        return sc.next();
    }

    static String nextLine(){
        return sc.nextLine();
    }

    static void println(Object o) {
        out.println(o);
        out.flush();
    }

    static void print(Object o) {
        PrintWriter out = new PrintWriter(System.out);
        out.print(o);
        out.flush();
    }
}


Measured memory_bytes: 21844
x, n = map(int, input().split())
try:
  lst = list(map(int, input().split()))
except:
  lst = []
  
flg = 0
if x not in lst or lst == []:
  print(x)
else:
  for _ in range(1, 101):
    mx = max(x - _, 0)    
    mn = min(x + _, 101)
    if mx not in lst:
      print(mx)
      break
    elif mn not in lst:
      print(mn)
      break
      


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

using namespace std;
string s;
int bac[500001],nn[500001],dem=0;
vector <int> ke[500001];
void dfs(int u)
{
    for(int i:ke[u])
    {
        bac[i]=max(bac[i],bac[u]+1);
        dfs(i);
    }
}
int main()
{
    cin >> s;
    for(int i=0;i<=s.length();i++)
    {
        if(s[i]=='>' && s[i+1]=='<')
        {
            dem++;
            nn[dem]=i+1;
            bac[i]=0;
        }
        if(s[i]=='<' && i==0)
        {
            dem++;
            nn[dem]=i;
            bac[i]=0;
        }
        if(s[i-1]=='>' && i==s.length())
        {
            dem++;
            nn[dem]=i;
            bac[i]=0;
        }
        if(s[i]=='>') ke[i+1].push_back(i);
            else ke[i].push_back(i+1);
    }
    for(int i=1;i<=dem;i++)
        dfs(nn[i]);
    long long sl=0;
    for(int i=0;i<=s.length();i++) sl+=bac[i];
    cout << sl << endl;
    return 0;
}


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

int main(){
	int n;
	int C[12];
	while(1){
		cin >> n;
		if(n == 0) break;
		for(int i=0;i<n;i++){
			cin >> C[i];
		}
		int ans = 0;
		int cou = 0;
		while(1){
			if(cou == n) break;
			cou = 0;
			int k[12]={0};
			for(int i=0;i<n;i++){
				int tmp = C[i];
				for(int j=0;j<n;j++){
					if(tmp == C[j]){
						k[i]++;
					}
				}
			}
			for(int i=0;i<n;i++){
				if(C[i] == k[i]){
					cou++;
				}
				C[i] = k[i];
			}
			ans++;
		}
		ans--;
		cout << ans << endl;
		for(int i=0;i<n;i++){
			cout << C[i];
			if(n != i+1) cout << " ";
		}
		cout << endl;
	}
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
map<string,int>mapp;
bool cmp(char a,char b){
	return a<b;
}
int sum[100005];
int main(){
	int n,cnt=0;
	long long ans=0;
	char s[12];
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%s",s);
		sort(s,s+10,cmp);
		if(mapp.count(s))ans+=sum[mapp[s]];
		else mapp[s]=++cnt;
		sum[mapp[s]]++;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 11520
k=int(input())
cur=1
ans=-1
cnt=0
while cnt<k:
    num=str(cur)
    n=len(num)
    flag=True
    pos=-1
  #  print(num,end=' num\n')
    for i in range(n-1):
        if abs(int(num[i])-int(num[i+1]))>1:
            pos=i+1
            flag=False
            break
 #   print(flag)
    if flag==True:
        ans=cur
        cur+=1
        cnt+=1
    else:
        if int(num[pos])!=9:
            ch=str(int(num[pos])+1)
#            print(ch)
            cur=int(num[:pos]+ch+num[pos+1:])
        else:
            ch=str(int(num[pos-1])+1)
            cur=int(num[:pos-1]+ch+'0'*len(num[pos:]))
print(ans)


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

using namespace std;

int main(){
	int n; string s;
	cin >> n >> s;
	int o = 0, c = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == '(') o++;
		if(s[i] == ')'){
			if(o == 0) c++;
			else o--;
		}
	}
	cout << string(c, '(') + s + string(o, ')') << endl;
	return 0;
}

Measured memory_bytes: 256
def d(u):
 global t
 C[u]=0;t+=1;D[u]=t
 for v in R:
  if M[u][v]and C[v]:d(v)
 t+=1;F[u]=t
N=int(input());R=range(N)
M=[[0]*N for _ in R]
for e in[input().split()for _ in R]:
 for v in e[2:]:M[int(e[0])-1][int(v)-1]=1
C,D,F=[1]*N,[0]*N,[0]*N
t=0
for i in R:
 if C[i]:d(i)
for i in R:print(i+1,D[i],F[i])


Measured memory_bytes: 5792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long n;
    cin>>n;
    
    vector<long long> A(n+1), B(n+1, 1e18);
    for(int i=0;i<n+1;i++) cin>>A[i];

    
    B[0]=1;
    
    if(A[0]>B[0]){
        cout<<-1<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        B[i+1] = (B[i]-A[i])*2;
        if(B[i]<0){
            cout<<-1<<endl;
            return 0;
        }
        if(B[i]>=1e18) break;
    }
    
    if(A[n]>B[n]){
        cout<<-1<<endl;
        return 0;
    }
    
    long long ans,now;
    
    B[n]=ans=now=A[n];
    
    for(int i=n-1;i>=0;i--){
        now = min(now, B[i]-A[i])+A[i];
        ans += now;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 4728
x = input().lower()

term_data = {}
for word in x.split():
  if term_data.get(word) is None:
    term_data[word] = [0, len(word)]
  term_data[word][0] += 1

term_data = [(term, data) for term, data in term_data.items() ]
print(max(term_data, key=lambda x:x[1][0])[0], max(term_data, key=lambda x:x[1][1])[0] )


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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 998244353
#define P pair<ll, ll>

ll n, acnt, bcnt, sz;
vector<string> s(1100000);
vector<P> fq, v;
int main() {
    cin >> n;
    REP(i, n){
        cin >> s[i];
        ll na = 0, mi = 0;
        REP(j, (ll)s[i].size()){
            if (s[i][j] == '(') {
                acnt++;
                na++;
            }
            else {
                bcnt++;
                na--;
            }
           // cout << na << endl;
            mi = min(mi, na);
        }
        if (na >= 0) fq.push_back(P(-mi, na));
        else v.push_back(P(na - mi, -na));
        //cout << mi << " " << na << endl;
    }
    sort(ALL(fq));
    sort(ALL(v));
    bool ok = true;
    REP(i, (ll)fq.size()){
        if (fq[i].first > sz) ok = false;
        sz += fq[i].second;
    }
    sz = 0;
    REP(i, (ll)v.size()){
        if (v[i].first > sz) ok = false;
        //cout << v[i].first << endl;
        sz += v[i].second;
    }
    if(acnt != bcnt or !ok){
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}


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

int main(){

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    int ans = 0;
    rep (i, K){
        if (A != 0){
            ans++;
            A--;
        } else if (B != 0){
            B--;
        } else if (C != 0){
            ans--;
            C--;
        }
    }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define int long long

const int INF = 1e18;

int get_last(multiset <int>& ms) {
    auto it = ms.end();
    --it;
    return *it;
}

int start(vector <pair <int, int> >& v, vector <pair <int, int> >& rv) {
    multiset <int> ms;
    int sum_v = 0;
    vector <int> del;
    for (auto it : rv) {
        sum_v += it.second;
        ms.insert(sum_v - it.first);
        del.push_back(sum_v - it.first);
    }
    reverse(del.begin(), del.end());
    int ans = get_last(ms);
    sum_v = 0;
    for (int i = 0; i < signed(v.size()) - 1; ++i) {
        sum_v += v[i].second;
        ms.erase(ms.find(del[i]));
        ans = max(ans, sum_v - 2 * v[i].first + get_last(ms));
    }
    return ans;
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, c;
    cin >> n >> c;
    vector <pair <int, int> > v(n), rv;
    for (auto& it : v) {
        cin >> it.first >> it.second;
    }
    for (int i = signed(v.size()) - 1; i >= 0; --i) {
        rv.push_back({c - v[i].first, v[i].second});
    }
    int ans = max(start(v, rv), start(rv, v));
    ans = max(ans, 0ll);
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 8884
h,w,k=map(int,input().split())
L=list()
for i in range(h):
    L.append(list(input()))
import itertools
import copy
v1=itertools.product([0,1],repeat=h)
v2=itertools.product([0,1],repeat=w)
V=list(itertools.product(v1,v2))
ans=0
for v in V:
    #print(v)
    #print(v[0][0])
    S=0
    Lcopy=copy.deepcopy(L)
    #print(Lcopy)
    for i in v[0]:
        for j in range(h):
            if v[0][j]==1:
                Lcopy[j]=['.']*w
    for i in v[1]:
        for j in range(w):
            if v[1][j]==1:
                for l in range(h):
                    Lcopy[l][j]='.'
    #print(Lcopy)
    for i in range(h):
        for j in range(w):
            if Lcopy[i][j]=='#':
                S+=1
    if S==k:
        ans+=1
        #print(Lcopy)
print(ans)        

Measured memory_bytes: 9488
def resolve():
    N, K = map(int, input().split())

    A = [0] * K
    # a % K を決め打つと b % K, c % K のとるべき値が一意に決まることを利用します
    for i in range(1, N + 1):
        A[i % K] += 1

    res = 0
    for a in range(K):
        b = (K - a) % K
        c = (K - a) % K
        if (b + c) % K != 0:
            continue
        res += A[a] * A[b] * A[c]

    print(res)


if __name__ == "__main__":
    resolve()

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

priority_queue<long long> q1;
priority_queue<long long,vector<long long>,greater<long long>> q2;
long long sum1=0,sum2=0;

void check(){
	while(true){
		if(q1.size()<q2.size()){
			sum2-=q2.top();
			sum1+=q2.top();
			q1.push(q2.top());
			q2.pop();
			continue;
		}
		if(q1.size()-q2.size()>1){
			sum1-=q1.top();
			sum2+=q1.top();
			q2.push(q1.top());
			q1.pop();
			continue;
		}
		if(q1.top()>q2.top()){
			sum1-=q1.top();
			sum2+=q1.top();
			q2.push(q1.top());
			q1.pop();
			continue;
		}
		break;
	}
}
			

int main(){
	int Q;
	cin>>Q;
	long long bb = 0;
	
	for(int i=0;i<Q;i++){
		int x;
		cin>>x;
		if(x==1){
			long long aq,bq;
			cin>>aq>>bq;
			bb+=bq;
			if(q1.size()==0){
				q1.push(aq);
				sum1+=aq;
			}
			else if(q2.size()==0){
				q2.push(aq);
				sum2+=aq;
				check();
			}
			else{
				sum1+=aq;
				q1.push(aq);
				check();
			}
		}
		else{
			long long ans = bb;
			ans+=sum2-sum1;
			ans+=q1.top()*q1.size()-q1.top()*q2.size();
			//cout<<q1.size()<<','<<q2.size()<<endl;
			cout<<q1.top()<<' '<<ans<<endl;
		}
	}
			
		
	
	
	
	return 0;
}

Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
char a[120000],b[120000];
int main(){
	cin>>a>>b;
	int n1=strlen(a),n2=strlen(b);
	for(int i=0;i<max(n1,n2);i++){
		cout<<a[i];
		if(i<=n2-1) cout<<b[i];	
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a, b;
int main()
{
    cin >> a >> b;
    if (a > 0 && b > 0)
        cout << "Positive" << endl;
    else if (max(a, b) >= 0 && min(a, b) <= 0 || a == 0 || b == 0)
        cout << "Zero" << endl;
    else
        if ((abs(min(a, b)) - abs(max(a, b))) % 2 == 0)
            cout << "Negative" << endl;
        else
            cout << "Positive" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
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)<(n);(i)++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
const int MOD = 1000000007;
const int INF = 1 << 29;
const long long LINF = 1LL << 60;



int main() {

	int n;
	cin >> n;
	rep(i, n+1) {
		int a = i * 1.08;
		if (a == n) {
			cout << i << endl;
			return 0;
		}


	}

	cout << ":(" << endl;
	return 0;
}


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

int n, k;
vector<int> di;
vector<vector<int>> Ai;

void input() {
    cin >> n >> k;
    di.resize(k);
    Ai.resize(k, vector<int>());

    for(int i = 0; i < k; i++) {
        cin >> di.at(i);
        Ai[i].resize(di.at(i));
        for(int j = 0; j < di.at(i); j++) {
            cin >> Ai[i][j];
            //cout << Ai[i][j];
        }
        //cout << endl;
    }
}

void solve() {
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        bool have = false;
        for(auto v : Ai) {
            for(auto p : v) {
                if(p == i) have = true;
            }
        }
        //if(!have)としても判定可能
        if (have == false) ans++;
    }
    cout << ans << endl;
}

int main() {
    input();
    solve();

    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#include<queue>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	int a[n];
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	double sum=0;
	for(int i=0;i<n;i++){
		sum+=1.0/a[i];
	}
	sum=1.0/sum;
	printf("%lf",sum);
	return 0;
}

Measured memory_bytes: 256
/*
  #問題：
  


  #分析：
  #オブジェクト：
  
  #条件：
  

  #要求：
  

  #解法：
  
*/

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
#include <initializer_list>
#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define fst first
#define snd second
#define PB push_back
#define MP make_pair
#define LL long long
#define uLL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;


const unsigned int bf0 = (1<<0);
const unsigned int bf1 = (1<<1);
const unsigned int bf2 = (1<<2);
const unsigned int bf3 = (1<<3);
const unsigned int bf4 = (1<<4);
const unsigned int bf5 = (1<<5);
const unsigned int bf6 = (1<<6);
const unsigned int bf7 = (1<<7);


//#include <boost/format.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;
using Bint = mp::cpp_int;
namespace bm = boost::math;

int GCD(int a,int b){ return b ? GCD(b,a%b) : a ;}
int LCM(int a,int b){ return a*b / GCD(a,b) ;}

int main(void){
  int n_finger; cin>>n_finger;
  n_finger = n_finger-1;
  int n_required; cin>>n_required;
  int m_hub_prepare = ( n_required - 1 ) / n_finger ;
  if (m_hub_prepare * n_finger + 1 < n_required) {
    m_hub_prepare += 1;
  }else{
    
  }
  
  cout << m_hub_prepare << endl;
  return 0;
}



Measured memory_bytes: 256
fs = require('fs');
input = fs.readFileSync('/dev/stdin', 'utf8');
tmp = input.split(' ');
x1 = parseInt(tmp[0],10);
x2 = parseInt(tmp[1],10);
x3 = parseInt(tmp[2],10);
x4 = parseInt(tmp[3],10);
x5 = parseInt(tmp[4],10);
if(x1 == 0) console.log(x2-(x3-x2));
if(x2 == 0) console.log(x3-(x4-x3));
if(x3 == 0) console.log(x4-(x5-x4));
if(x4 == 0) console.log(x3+(x2-x1));
if(x5 == 0) console.log(x4+(x2-x1));

Measured memory_bytes: 29528
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl;


//UnionFind群
class UnionFind {
protected:
    vector<int> par;
    vector<int> data;
    int cnt;
public:
    UnionFind() : par(1), data(1), cnt(1) {};

    UnionFind(int N);

    int root(int x);

    int marge(int x, int y);

    bool same(int x, int y);

    int add();

    int add(int x);

    inline int getSize(int x) { return data.at(root(x)); };

    int allroot() ;

    inline bool isroot(int x) {return (par.at(x) == -1) ; };
};

UnionFind::UnionFind(int N) : par(N), data(N), cnt(N) {
    for (int i = 0; i < N; i++) {
        par.at(i) = -1;
        data.at(i) = 1;
    }
}


int UnionFind::root(int x) {
    if (par.at(x) == -1) return x;
    return par.at(x) = root(par.at(x)); // 経路圧縮
}

int UnionFind::marge(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return rx;
    else { // ノード数の少ない方に接続
        if (data.at(rx) < data.at(ry)) swap(rx, ry);
        par.at(ry) = rx;
        data.at(rx) += data.at(ry);
        return rx;
    }
}

bool UnionFind::same(int x, int y) {
    return root(x) == root(y);
}

int UnionFind::add() {
    par.push_back(cnt);
    cnt++;
    return cnt - 1;
}

int UnionFind::add(int x) {
    par.push_back(cnt);
    cnt++;
    return marge(x, cnt);
}

int UnionFind::allroot() {
    int cnt = 0;
    for (const auto it : par) {
        if (it == -1) cnt++;
    }
    return cnt;
}

struct UF {
    vector<int> par;

    UF(int N) : par(N) {
        for (int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        else {
            return par[x] = root(par[x]);
        }
    }

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

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


int main() {
    int n, d,cnt = 0;
    cin >> n >> d;
    vector<vector<double>> a(n,vector<double>(d));
    for (int i  = 0 ; i < n ; i++) {
        for(int j = 0; j < d;j++){
            cin >> a.at(i).at(j);
        }
        for (int z = i - 1; z >= 0; z--){
            double sum = 0;
            for(int j = 0; j < d; j++){
                sum += pow(a.at(z).at(j) - a.at(i).at(j),2);
            }
            if (sqrt(sum) == (int)sqrt(sum)) {
                cnt++;
            }
        }

    }
    cout << cnt << endl;
}










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

const int MOD=1000000007;
const int INF=1000000009;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


struct Edge{
  int src;int dst;int wei;
  Edge(int s=0,int d=0,int w=0):src(s),dst(d),wei(w){}
};
using Graph = vector<vector<Edge>>;
vector<int> Dij(Graph&g,int s){
    using state = pair<int,int>;//???????????????????????????????????????????????????
    priority_queue<state,vector<state>,greater<state>> pq;
    vector<int> dis(g.size(),INF);
    dis[s]=0;
    pq.push(state(0,s));
    while(!pq.empty()){
      int d=pq.top().first;
      int v=pq.top().second;
      pq.pop();
      if(dis[v]<d)continue;
      rep(i,g[v].size()){
        Edge &e=g[v][i];
        if(dis[e.dst]>dis[v]+e.wei){
          dis[e.dst]=dis[v]+e.wei;
          pq.push(state(dis[e.dst],e.dst));
        }
      }
    }
    return dis;
}

signed main(){
  int v,e,r;
  cin>>v>>e>>r;
  Graph g(v);
  rep(i,e){
    int s,t,d;
    cin>>s>>t>>d;
    g[s].pb(Edge(s,t,d));
  }
  vector<int> dist=Dij(g,r);

  rep(i,v){
    if(dist[i]==INF)cout<<"INF"<<endl;
    else cout<<dist[i]<<endl;
  }

  return 0;
}

Measured memory_bytes: 24332
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
typedef long long       ll;
#define pb                emplace_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define F first
#define S second
#define fore(i, b, e)     for (int i = b; i < e; i++)
#define forr(i, b, e)     for (int i = b; i < e; i++)
int faster_in(){int r=0,c;for(c=getchar();c<=32;c=getchar());if(c=='-') return -faster_in();for(;c>32;r=(r<<1)+(r<<3)+c-'0',c=getchar());return r;}

using namespace std;
//using namespace __gnu_pbds;

typedef pair<int, int>  ii;
typedef vector<int>     vi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const int INF = int(1e9 + 7);
const double EPS = 1e-9;
const double PI = acos(-1);
const int tam =130000;
ll v[tam];
int main()
{
    std::ios::sync_with_stdio(false); cin.tie(0);
    ll  n,A,B;
    cin>>n>>A>>B;
    forr(i,0,n)
    {
        cin>>v[i];
    }
    sort(v,v+n);
    ll tot=0;
    forr(i,0,n-1)
    {
        if ((v[i+1]-v[i])*A>B)
            tot+=B;
        else
            tot+=(v[i+1]-v[i])*A;

    }
    cout<<tot<<endl;
}
// PLUS ULTRA!

Measured memory_bytes: 1024