akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main(){
  int n, k;
  cin >> n >> k;
  int x[n];
  for(int i=0; i<n; i++){
    cin >> x[i];
  }

  int d[n];
  int sum = 0;

  for(int i=0; i<n; i++){
    d[i] = min(x[i], k-x[i]);
    sum = sum + 2*d[i];
  }

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

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

int main() {
  int a, b;
  double x;
  int x_out;
  cin >> a;
  cin >> b;
  //↓で2.0にしないと丸められる
  //詳しくはhttps://atcoder.jp/contests/apg4b/tasks/APG4b_d
  x = ((a + b) / 2.0 + 0.5);
  x_out = x / 1;
  //cout << x << endl;
  cout << x_out << endl;
}

Measured memory_bytes: 256
n=int(input())
data=[int(x) for x in input().split()]
ans=[0]*n
ans[0]=0
ans[1]=abs(data[1]-data[0])
for q in range(2,n):
    temp2=abs(data[q]-data[q-2])+ans[q-2]
    temp1=abs(data[q]-data[q-1])+ans[q-1]
    if(temp2<temp1):
        ans[q]=temp2
    else:
        ans[q]=temp1
print(ans[-1])

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

int main(){
  int n, m;
  cin >> n >> m;
  int ans = (n*(n-1))/2 + (m*(m-1))/2;
  if(n = 0) ans = (m*(m-1))/2;
  else if(m = 0) ans = (n*(n-1))/2;
  cout << ans << endl;
}

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

pii operator+(pii a, pii b) {
    return {max(a.fi, b.fi), min(a.se, b.se)};
}

int len(pii a) {
    return max(0, a.se - a.fi + 1);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "rt", stdin);
#endif

    int n;
    cin >> n;
    vector<pii> a(n);
    forn(i, n) cin >> a[i].fi >> a[i].se;
    sort(all(a));
    vector<pii> pref(n + 1), suf(n + 1);
    pref[0] = {-1e9, 1e9};
    forn(i, n) pref[i + 1] = pref[i] + a[i];
    suf[0] = pref[0];
    forn(i, n) suf[i + 1] = suf[i] + a[n - i - 1];
    int ans = 0;
    for1(i, n - 1) uax(ans, len(pref[i]) + len(suf[n - i]));

    forn(i, n) uax(ans, len(a[i]) + len(pref[i] + suf[n - i - 1]));

    cout << ans << '\n';

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


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

using namespace std;

#define int long long

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test


constexpr int mod = 1e9 + 7;

struct M {
    unsigned v;
    M(long long a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    M& operator+=(M r) { if ((v += r.v) >= mod) v -= mod; return *this; }
    M& operator-=(M r) { if ((v += mod - r.v) >= mod) v -= mod; return *this; }
    M& operator*=(M r) { v = (uint64_t)v * r.v % mod; return *this; }
};

uint32_t add(M a, M b) { return (a += b).v; }
uint32_t mul(M a, M b) { return (a *= b).v; }
uint32_t sub(M a, M b) { return (a -= b).v; }

uint32_t po(M x, int n) {
    M res(1);
    while (n > 0) {
        res *= (n & 1 ? x : 1);
        x *= x; n /= 2;
    }
    return res.v;
}

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    int y = n / x + (n % x > 0);
    cout << y * t << '\n';
}

signed main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    for (int i = 1; i <= t; ++i) {
        // cout << "Case #" << i << ": ";
        solve();
    }

    return 0;
}


Measured memory_bytes: 3588
# -*- coding: utf-8 -*-
"""
A - 9x9
https://atcoder.jp/contests/abc144/tasks/abc144_a

"""
import sys


def solve(A, B):
    if 1 <= A <= 9 and 1 <= B <= 9:
        return A * B
    return -1


def main(args):
    A, B = map(int, input().split())
    ans = solve(A, B)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll (i) = 0; i < n; i++)
#define FORN(i, a, b) for (ll (i) = a; i < b; i++)
#define FORE(i, l) for (auto (i) : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) (n).begin(), (n).end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

bool pal(string s)
{
    string rev = string(s);
    reverse(all(rev));
    return s == rev;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    string s;
    cin >> s;    
    ll n = s.size();
    //cout << s.substr(0, (n - 1) / 2) << " " << s.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1) << '\n';
    cout << (pal(s.substr(0, (n - 1) / 2)) && pal(s.substr((n + 3) / 2 - 1, n - (n + 3) / 2 + 1)) && pal(s) ? "Yes\n" : "No\n");
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
const int INF = 1 << 20;

using namespace std;

int go[32][32], dict[32];
bool node[32];
char cn1, cn2, cn3;

int main()
{
	int num, total, wk, tk, kt, kr;

	//input start
	cin >> total >> num;

	for(int i = 0; i < total; i++)
	{
		dict[i] = INF;
		node[i] = false;
		for(int j = 0; j < total; j++)
		{
			go[i][j] = INF;
		}
	}

	for(int i = 0; i < num; i++)
	{
		cin >> wk >> cn1 >> tk >> cn2 >> kt >> cn3 >> kr;

		go[wk-1][tk-1] = kt;
		go[tk-1][wk-1] = kr;
	}

	int start, goal, exp, rew;
	cin >> start >> cn1>> goal >> cn2 >> rew >> cn3 >> exp;

	//input end
	
	//go dijkstra
	dict[start - 1] = 0;
	rew -= exp;
	
	while(1)
	{
		int v = -1;

		for(int i = 0; i < total; i++)
		{
			if(!node[i] && (v == -1 || dict[i] < dict[v])) v = i;
		}

		if(v == -1) break;

		node[v] = true;

		for(int i = 0; i < total; i++)
		{
			dict[i] = min(dict[i], dict[v] + go[v][i]);
		}
	
	}

	rew -= dict[goal -1];

	for(int i = 0; i < total; i++)
	{
		node[i] = false;
		dict[i] = INF;
	}

	//back dijkstra
	dict[goal - 1] = 0;
	while(1)
	{
		int v = -1;
		for(int i = 0; i < total; i++)
		{
			if(!node[i] && (v == -1 || dict[i] < dict[v]) ) v = i;
		}

		if(v == -1) break;

		node[v] = true;

		for(int i = 0; i < total; i++)
		{
			dict[i] = min(dict[i], dict[v] + go[v][i]);
		}
	}

	rew -= dict[start -1];

	cout << rew << endl;
}

Measured memory_bytes: 1160
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
using namespace std;
int main(){
	int n,i;
	scanf("%d",&n);
	vector<int>v(n);
	for(i=0;i<n;i++)scanf("%d",&v[i]);
	sort(v.begin(),v.end(),greater<int>());
	for(i=0;i<n&&v[i]>=i+1;i++);
	printf("%d\n",i);
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int N;
int M;
int ps[100100][2];

void solve() {
    cin >> N >> M;
    for (int i = 0; i < M; ++i) {
        int pi;
        string si;
        cin >> pi >> si;

        int ac = ps[pi][0];
        if (!ac) {
            if (si == "AC") {
                ps[pi][0] = 1;
            } else {
                ps[pi][1] += 1;
            }
        }
    }
    int ac = 0;
    int wa = 0;
    for (int i = 1; i <= N; ++i) {
        ac += ps[i][0];
        if (ps[i][0] == 1) wa += ps[i][1];
    }
    printf("%d %d\n", ac, wa);
}

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


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<sstream>
#include<climits>
#include<cstdio>
#include<cstdlib>
using namespace std;

vector<vector<char> > f;
vector<vector<int> > cost;
vector<pair<int,int> > M;
vector<pair<int,int> > hole;
pair<int,int> s,g;
struct S{
  pair<int,int> pos;
  int cost;
  int get;
};
bool operator<(S a,S b){
  return a.cost>b.cost;
}

const int vx[]={0,0,1,-1};
const int vy[]={1,-1,0,0};
bool all(int get){
  return get==(1<<M.size())-1;
}
vector<map<pair<int,int>,int>> dp;
int solve(){
  priority_queue<S> que;
  que.push(S{s,0,0});
  dp.clear();
  dp.resize(1<<M.size());
  while(!que.empty()){
    S now  = que.top();que.pop();
    if(now.pos.first<0 || now.pos.first>=cost.size() || now.pos.second <0 || now.pos.second>= cost[0].size())continue;
    if(dp[now.get][now.pos]==1)continue;
    dp[now.get][now.pos]=1;
    for(int i=0;i<M.size();i++){
      if(M[i]==now.pos){
        now.get = now.get | (1<<i);
      }
    }
    if(all(now.get)&&g==now.pos){
      return now.cost;
    }
    for(int i=0;i<4;i++){
      S tmp = now;
      tmp.pos.first += vx[i];
      tmp.pos.second += vy[i];
      tmp.cost += cost[now.pos.first][now.pos.second];
      que.push(tmp);
    }
  }
  return 0;
}
int main(){
  int n,m;
  while(cin>>n>>m){
    f.clear();cost.clear();M.clear();hole.clear();
    f.resize(m);
    for(int i=0;i<m;i++){
      for(int j=0;j<n;j++){
        char tmp;
        cin>>tmp;
        f[i].push_back(tmp);
      }
    }
    for(int i=0;i<f.size();i++){
      for(int j=0;j<f[i].size();j++){
        if(f[i][j]=='#'){
          hole.push_back(make_pair(i,j));
        }else if(f[i][j]=='M'){
          M.push_back(make_pair(i,j));
        }else if(f[i][j]=='S'){
          s = make_pair(i,j);
        }else if(f[i][j]=='G'){
          g = make_pair(i,j);
        }
      }
    }
    cost.resize(f.size());
    for(int i=0;i<f.size();i++){
      for(int j=0;j<f[i].size();j++){
        int tmp=1;
        for(int k=0;k<hole.size();k++){
          if(i==hole[k].first&&j==hole[k].second){
            tmp = INT_MAX/2;
          }else{
            tmp = max(tmp,max(0,min(4-abs(i-hole[k].first),4-abs(j-hole[k].second))));
          }
        }
        cost[i].push_back(tmp);
      }
    }

    cout<<solve()<<endl;
  }
}

Measured memory_bytes: 22884
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;

template <typename A, size_t N, typename T> void array_fill(A(&array)[N], const T &val){
    fill((T*)array, (T*)(array + N), val);
}

int main(){
    int N, M; long L; cin >> N >> M >> L;
    const long INF = 1e12;
    long d[301][301]; array_fill(d, INF);

    for (int i = 1; i <= N; i++) d[i][i] = 0;

    for (int i = 0; i < M; i++){
        int a, b; long c; cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }

    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    long p[301][301]; array_fill(p, INF);
    for (int i = 1; i <= N; i++) p[i][i] = 0;

    for(int i = 1; i <= N-1; i++){
        for(int j = i+1; j <= N; j++){
            if (d[i][j] <= L){
                p[i][j] = 1;
                p[j][i] = 1;
            }  
        }
    }


    for(int k = 1; k <= N; k++){
        for(int i = 1; i <= N; i++){
            for(int j = 1; j <= N; j++){
                p[i][j] = min(p[i][j], p[i][k] + p[k][j]);
            }
        }
    }

    int Q; cin >> Q;
    for(int i = 0; i < Q; i++){
        int s, t; cin >> s >> t;
        if (p[s][t] == INF) cout << -1 << endl;
        else cout << p[s][t]-1 << endl;
    }
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int k;
  cin>>k;
  string a,b,res="";
  cin>>a>>b;
  int i;
  for(i=0;i<k;i++)
  {
    res+=a[i];
    res+=b[i];
  }
  cout<<res;
}

Measured memory_bytes: 256
s = input()

if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s == 'THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)

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

template<typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}

signed main(){
  int x;cin>>x;
  for(int i=0;i<=100000;i++){
    if(i*100<=x&&i*105>=x)fin(1);
  }
  fin(0);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <vector>
#include <iostream>
#include <ctime>
#include <unistd.h>

using namespace std;

#define TRACE(x) cerr << #x <<  " = " << x << endl
#define _ << " " <<
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)

#define X first
#define Y second

typedef pair<int, int> P;
typedef long long ll;

int main()
{
  char s[1005];
  scanf("%[^\n]", s);
  
  REP(i, strlen(s) - 8) printf("%c", s[i]);
  printf("\n");

  return 0;
}


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

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

    for (int i = 0; i < S.size(); i++) {
        if (i % 2) {
            if (S.at(i) == 'R') {
                cout << "No" << endl;
                return 0;
            }
        } else {
            if (S.at(i) == 'L') {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
from itertools import product
T = [list(map(int, input().split())) for i in range(10)]

def calc(v):
    val = 0
    for e in v:
        val = T[val][e]
    return val

ans = 0
for code in product(range(10), repeat=4):
    e = calc(code)
    ok = 1
    code = list(code) + [e]
    for i in range(5):
        d = code[:]
        for j in range(10):
            if code[i] == j:
                continue
            d[i] = j
            if calc(d) == 0:
                ok = 0
    for i in range(4):
        d = code[:]
        if d[i] == d[i+1]:
            continue
        d[i], d[i+1] = d[i+1], d[i]
        if calc(d) == 0:
            ok = 0
    if ok == 0:
        ans += 1
print(ans)

Measured memory_bytes: 7856
#include<stdio.h>
int main()
{
  
	int A,B;
  	scanf("%d", &A);
  	scanf("%d", &B);
   
  if(B == 1){
	printf("0");
    return 0;
  }
  
  if(A >= B){
    printf("1");
    return 0;
  }
 
    
  	int n;
  int sum = A;
  int count = 1;
  	while(sum < B){
     sum = sum +A-1;  
      count++;
    }
    printf("%d ",count);

    return 0;
}

Measured memory_bytes: 128
package main

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

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

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	a := scanInt()
	b := scanInt()
	q := scanInt()
	s := scanInts(a)
	t := scanInts(b)

	for i := 0; i < q; i++ {
		x := scanInt()

		se := sort.Search(a, func(idx int) bool { return x < s[idx]})
		sw := se-1
		te := sort.Search(b, func(idx int) bool { return x < t[idx]})
		tw := te-1

		ans := 1 << 60
		if se != a {
			if te!=b {ans = min(ans, max(s[se],t[te])-x)}
			if tw!=-1 {ans = min(ans, s[se]-t[tw]+min(s[se]-x,x-t[tw]))}
		}
		if sw != -1 {
			if te!=b {ans = min(ans, t[te]-s[sw]+min(x-s[sw],t[te]-x))}
			if tw!=-1 {ans = min(ans, x-min(s[sw],t[tw]))}
		}

		fmt.Fprintln(wr, ans)
	}
}


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

void deleteIsland(int i, int j, int** island);

int main(void){
  while(1){
    int** island=(int**)malloc(sizeof(int*)*14);
    for(int i=0;i<14;i++){
      island[i]=(int*)malloc(sizeof(int)*14);
    }
    for(int i=0;i<14;i++){
      island[0][i]=0;
      island[13][i]=0;
      island[i][0]=0;
      island[i][13]=0;
    }

    string s;
    for(int i=1;i<13;i++){
      cin>>s;
      for(int j=1;j<13;j++){
        island[i][j]=s[j-1]-'0';
      }
    }
    if(cin.eof())break;

    int count=0;
    for(int i=1;i<13;i++){
      for(int j=1;j<13;j++){
        if(island[i][j]==1){
          count++;
          deleteIsland(i,j,island);
        }
      }
    }
    cout<<count<<endl;
  }
  return 0;
}

void deleteIsland(int i, int j, int** island){
  island[i][j]=0;
  bool l,r,u,d;
  l=false;
  r=false;
  u=false;
  d=false;
  if(island[i-1][j]==1)u=true;
  if(island[i+1][j]==1)d=true;
  if(island[i][j-1]==1)l=true;
  if(island[i][j+1]==1)r=true;
  if(u)deleteIsland(i-1,j,island);
  if(d)deleteIsland(i+1,j,island);
  if(l)deleteIsland(i,j-1,island);
  if(r)deleteIsland(i,j+1,island);
}



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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(bool _local){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    if (_local)
        freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    READ(0);
    int n;cin>>n;
    vi a(n);
    FOR(i,n) cin>>a[i];
    ll s=0;
    for(int i=0;i<n;i+=2) s += a[i];
    for(int i=1;i<n;i+=2) s -= a[i];
    vi b(n);
    b[0]=s/2;
    for(int i=1;i<n;++i){
        b[i]=a[i-1]-b[i-1];
    }
    FOR(i,n) cout << b[i]*2 << " ";
    return 0;
}



Measured memory_bytes: 2176
// And Then the GOD Entered..   
#include<bits/stdc++.h>
 using namespace std;
 
typedef long long int ll;
#define endl "\n"
#define fi first
#define sec second 
#define pb push_back
#define test cout<<"debuged\n";
#define INF ll(1e18)
#define MOD 998244353
#define debug(x) cout<<x<<"\n";
#define pll pair<ll,ll>
#define mp make_pair
#define Minato_Namikaze ios_base::sync_with_stdio(false) , cin.tie(NULL);
#define all(v) v.begin(),v.end()
#define MAX 200015

int main()
{
    Minato_Namikaze
    
    ll n;
    cin >> n;
    ll dp[10][10];
    memset(dp,0,sizeof(dp));
    for(ll i = 1; i <= n; ++i)
    {
        string s = to_string(i);
        ll a = s[0] - '0';
        ll b = s[s.size() - 1] - '0';
        dp[a][b]++; 
    }
    ll ans = 0;
    for(ll i = 1; i <= n; ++i)
    {
        string s = to_string(i);
        ll a = s[0] - '0';
        ll b = s[s.size() - 1] - '0';
        ans += dp[b][a]; 
    }
    cout << ans ;

    return 0;
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int K;
int d[100010];
vector<pi> G[100010];

void solve() {
	cin >> K;
	fill(d, d + K, inf);
	d[1] = 1;
	deque<int> que;
	que.push_front(1);
	while(!que.empty()) {
		int v = que.front(); que.pop_front();
		int to = (v + 1) % K;
		if(d[to] > d[v] + 1) {
			d[to] = d[v] + 1;
			que.push_front(to);
		}
		to = (v * 10) % K;
		if(d[to] > d[v]) {
			d[to] = d[v];
			que.push_back(to);
		}
	}
	cout << d[0] << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
#ifdef LOCAL
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



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

int main(){
    int n;
    cin >> n;
    set<string> ans;
    rep(i,n){
        string s;
        cin >> s;
        ans.insert(s);
    }
    cout << ans.size() << endl;
}

Measured memory_bytes: 19252
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<map>
#define MAX_N 100001
#define INF_INT 2147483647
#define INF_LL 9223372036854775807
#define REP(i,n) for(int i=0;i<(int)(n);i++)
void init(int n);
int find(int n);
void unite(int x,int y);
bool same(int x, int y);
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool cmp_P(const P &a,const P &b){
  return a.second < b.second;
}
int main()
{
  ll N,A[100001],m[100001],x,res=INF_LL,sum=INF_LL;
  cin >> N >> x;
  REP(i,N)cin >> A[i];
  REP(i,N)m[i] = A[i];
  REP(k,N){
    REP(i,N){
      m[i] = min(m[i],A[(i-k+N)%N]);
    }
    sum = 0;
    REP(i,N){
      sum += m[i];
    }
    sum += k*x;
    res = min(sum,res);
  }
  cout << res << endl;
  return 0;
}

int par[MAX_N];
int ranks[MAX_N];

//n要素で初期化
void init(int n){
  REP(i,n){
    par[i] = i;
    ranks[i] = 0;
  }

}

//木の根を求める
int find(int x){
  if(par[x] == x){
    return x;
  }else{
    return par[x] = find(par[x]);
  }
}

void unite(int x,int y){
  x = find(x);
  y = find(y);
  if(x == y) return ;
  if(ranks[x] < ranks[y]){
    par[x] = y;
  }else{
    par[y] = x;
    if(ranks[x] == ranks[y]) ranks[x]++;
  }
}

bool same(int x, int y){
  return find(x) == find(y);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MOD 1000000007
#define INF 1000000000000000
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
int kaijo(int n){
	int ans=1;
	for(int i=2;i<=n;i++){
		ans*=i;
		ans%=MOD;
	}
	return ans;
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	return modpow(a,b/2)*modpow(a,b/2)%MOD;
}
int comb(int a,int b){
	return kaijo(a)*modpow(kaijo(a-b),MOD-2)%MOD*modpow(kaijo(b),MOD-2)%MOD;
}
string s[111];
int a[111];
pair<string,pair<int,int>>p[111];
signed main(){
	int n;
	cin>>n;
	rep(i,n){
		cin>>p[i].first>>p[i].second.first;
		p[i].second.second=i+1;
		p[i].second.first*=-1;
	}
	sort(p,p+n);
	rep(i,n)cout<<p[i].second.second<<endl;
	return 0;
}


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

using namespace std;

#define MAX_N 100000

long long dp[MAX_N][3], a[MAX_N], b[MAX_N], c[MAX_N], N;

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

    cin >> N;

    for (int i = 0; i < N; i++)
        cin >> a[i] >> b[i] >> c[i];

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    for (int i = 1; i < N; i++) {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][1], dp[i - 1][0]) + c[i];
    }

    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << "\n";

    // --------------------
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }
template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

class Prime
{
public:
    static 
    bool is_prime(long long n) {
        if (n == 1) return false;
        for (ll a = 2; a * a <= n; ++a) if (n % a == 0) return false;
        return true;
    }
    static 
    std::vector<long long> listup(long long n) {
        std::vector<long long> ret;
        for (long long i = 1; i * i < n; ++i) {
            if (n % i == 0) ret.push_back(i);
            long long other = n / i;
            if (other != i) ret.push_back(other);
        }
        std::sort(ret.begin(), ret.end());
        return ret;
    }
    static 
    std::vector<std::pair<long long, long long>> factorize(long long n) {
       std::vector<pair<long long, long long>> res;
        for (long long a = 2; a * a <= n; ++a) {
            if (n % a != 0) continue;
            long long ex = 0;
            while (n % a == 0) {
                ++ex;
                n /= a;
            }
            res.push_back({a, ex});
        }
        if (n != 1) res.push_back({n, 1});
        return res;
    }
};

void solve() {
    ll n; cin >> n;
    vector<ll> ex(n+1, 0);
    for (ll i = 2; i <= n; ++i) {
        const auto& res = Prime::factorize(i);
        for (auto& p: res) ex[p.first] += p.second;
    }

    ll ret = 1;
    for (ll p = 2; p <= n; ++p) {
        ret *= ex[p] + 1;
        ret %= MOD;
    }
    cout << ret << endl;
}

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

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(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;
}

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

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0,k,x,r;
    cin >> k ;
    cin >> n >> m ;
    if(m-n>=k) 
    {
        cout << "OK" ;
        return 0;
    }
    else
    {
        f=0;
        for(i=n;i<=m;++i)
        {
            if(i%k==0) 
            {
                cout << "OK" ;
                return 0;
            }
        }
    }
     cout << "NG" ;
    
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <set>
using namespace std;
int main()
{
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n;
    while (cin >> n)
    {
        set<int> se;
        long long x, f = 0, s = 0;
        while (n--)
        {
            cin >> x;
            if (se.find(x) == se.end())
                se.insert(x);
            else
            {
                se.erase(x);
                if (x > f)
                {
                    s = f;
                    f = x;
                }
                else if (x > s)
                    s = x;
            }
        }
        cout << f * s << '\n';
    }
    return 0;
}

Measured memory_bytes: 4992
#include <algorithm>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int a, x;
  cin >> x >> a;
  if (x < a)
    cout << "0" << endl;
  else {
    cout << "10" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.array;
import std.conv;
import std.typecons;

int[][] F;
A[] ans;

struct P {
    int y, x;
}

struct A {
    int x, y, t;
}

int type(ulong len) {
    switch (len) {
        case 5: return 1;
        case 9: return 2;
        case 13: return 3;
        default: ;
    }
    throw new Error("?");
}

bool check() {
    foreach (i; 0 .. 10) 
        foreach (j; 0 .. 10) 
            if (F[i][j] > 0) return false;
    return true;
}

const Large = [
    P(0, 0),
    P(1, -1), P(1, 0), P(1, 1),
    P(2, -2), P(2, -1), P(2, 0), P(2, 1), P(2, 2),
    P(3, -1), P(3, 0), P(3, 1),
    P(4, 0)
];

const Medium = [
    P(0, 0), P(0, 1), P(0, 2),
    P(1, 0), P(1, 1), P(1, 2),
    P(2, 0), P(2, 1), P(2, 2)
];

const Small = [
    P(0, 0),
    P(1, -1), P(1, 0), P(1, 1),
    P(2, 0)
];
 
bool tryIt(int pos, const P[] D) {
    int y = pos / 10, x = pos % 10;
    foreach (d; D) {
        int ny = y + d.y, nx = x + d.x;
        if (! (0 <= ny && ny < 10 && 0 <= nx && nx < 10) ) return false;
        if (F[ny][nx] <= 0) return false;
    }
    foreach (d; D) {
        int ny = y + d.y, nx = x + d.x;
        F[ny][nx]--;
    }
    if (solve(pos)) {
        P med = D[$ / 2];
        ans ~= A(x + med.x, y + med.y, D.length.type);
        return true;
    }
    foreach (d; D) {
        int py = y + d.y, px = x + d.x;
        F[py][px]++;
    }
    return false;
}

bool solve(int pos = 0) {
    if (pos == 100) return check();
    int y = pos / 10, x = pos % 10;
    if (F[y][x] == 0) return solve(pos + 1);

    if (tryIt(pos, Large) || tryIt(pos, Medium) || tryIt(pos, Small)) {
        return true;
    }
    return false;
}

void main() {
    int N; readf("%d\n", &N);
    F = new int[][10];
    foreach (ref L; F) L = readln.chomp.split(" ").map!(to!int).array;
    solve;
    foreach (a; ans) {
        writeln(a.x, " ", a.y, " ", a.t);
    }
}

Measured memory_bytes: 1116
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ATheNumberOfEvenPairs {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, m; cin >> n >> m;
      int ans = n*(n-1)+m*(m-1);
      cout << ans/2 << endl;
    }
};

signed main() {
  ATheNumberOfEvenPairs solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

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

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

ll lcm(ll a, ll b){
    return a/gcd(a, b)*b;
}


int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    if(n==1) {
        cout<<v[0]<<endl;
        return 0;
    }
    ll ans=lcm(v[0], v[1]);
    for(int i=2;i<=n-1;i++){
        ans=lcm(ans, v[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val N, M = sc.nextInt()
  val pairs = Set.fill(M)(sc.nextInt() - 1 -> sc.next().toCharArray.head)
  val isMatched = (i: String) => pairs.forall { case (s, c) => i(s) == c }
  val range = if (N == 1) 0.to(9) else math.pow(10, N - 1).toInt.to(("9" * N).toInt)
  println(range.find(i => isMatched(i.toString)).getOrElse(-1))
}


Measured memory_bytes: 55428
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_map>
#include <map>
#include <time.h> //for clock
#define rep(i, a) for (int i = 0; i < (a); i++)
using namespace std;
using ll = long long;

int main(){
    char b;
    cin >> b;

    if(b == 'A'){
        cout << 'T' << endl;
    }else if(b == 'T'){
        cout << 'A' << endl;
    }else if(b == 'G'){
        cout << 'C' << endl;
    }else{
        cout << 'G' << endl;
    }
 }


Measured memory_bytes: 256
def main():
    n, ls = get_params()
    print(to_answer(is_drawable(ls)))


def get_params():
    n = int(input())
    ls = [int(s) for s in input().split()]
    return n, ls


def to_answer(b):
    return "Yes" if b else "No"


def is_drawable(ls):
    maximum = max(ls)
    return maximum < sum(ls) - maximum


if __name__ == "__main__":
    main()


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int d = b / a;
    if (c > d) {
        cout << d;
    }
    else{
        cout << c;
    }
    cout << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <ctime>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;

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

    long long sum = 0;
    long long three = 0;
    long long five = 0;
    long long fif = 0;

    for(int i = 0; i <= N; i++){
        sum = sum + i;
    
    }

    for(int i = 3; i <= N; i += 3){
        three = three + i;
    }

    for(int i = 5; i <= N; i += 5){
        five = five + i;
    }

    for(int i = 15; i <= N; i += 15){
        fif = fif + i;
    }


    cout << sum - three - five + fif << endl;


}

Measured memory_bytes: 3632
import std.algorithm;
import std.bigint;
import std.concurrency;
import std.container;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.meta;
import std.numeric;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;


auto solve(long N) {
    return N ^^ 3;
}


void main() {
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    static if (is(ReturnType!solve == void))
        solve(N);
    else
        solve(N).writeln;
}


Measured memory_bytes: 256
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;


void main() {
    int h, w; scan(h, w);

    if (h == 1 && w == 1) {
        writeln("No");
        return;
    }

    auto ban = new char[][](h, w);
    iota(h).each!(i => ban[i] = readln.chomp.dup);

    int[] di = [0, 1, 0, -1];
    int[] dj = [1, 0, -1, 0];

    foreach (i ; 0 .. h) {
        foreach (j ; 0 .. w) {
            if (ban[i][j] == '.') continue;
            int cnt;

            foreach (k ; 0 .. 4) {
                int ni = i + di[k];
                int nj = j + dj[k];
                if (ni < 0 || ni >= h) continue;
                if (nj < 0 || nj >= w) continue;
                if (ban[ni][nj] == '#') cnt++;
            }

            if (cnt == 0) {
                debug {
                    writefln("(%d, %d)", i, j);
                }
                writeln("No");
                return;
            }
        }
    }

    writeln("Yes");
}




void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
//C - Splitting Pile:  
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n;
    ll soma = 0, x = 0, y, ans = LINF;
    cin >> n;
    vector<int> cards(n);
    loop(i, 0, n) {
        cin >> cards[i];
        soma += cards[i];
    }
    loop(i, 0, n-1) {
        x += cards[i];
        y = soma - x;
        //cout << x << " " << y << "\n";
        //cout << abs(x - y) << "--\n";
        ans = min(ans, abs(x - y));
    }
    //x = cards[0];
    //loop(i, 1, n) {
      //  y = soma - cards
    //}
    cout << ans << "\n";
}

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

int main(void){

int a,b,c,buf;

cin >>a>>b>>c;

if(a > c){
   buf = a;
   a = c;
   c = buf;
}

if(a > b){
   buf = a;
   a = b;
   b = buf;
}

if(b > c){
   buf = b;
   b = c;
   c = buf;
}

cout <<a<< " "<<b<<" "<<c<<endl;

return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>
#include <stdlib.h>

int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return 1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return -1;
	}
	else
	{
		return 0;
	}
}

int main(void){

  long n;
  scanf("%ld", &n);
  long d[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &d[i]);
  }
  qsort(d, n, sizeof(long), cmpnum);

  long answer = 0;
  long abc_last;
  long arc_first;

  if (n%2 == 0) {
    abc_last = n/2-1;
    arc_first = n/2;
    if (d[abc_last] != d[arc_first]) {
      answer = d[arc_first] - d[abc_last];
    }
  }

  printf("%ld\n", answer);

  return 0;
}

Measured memory_bytes: 1788
#define DEB
#include<bits/stdc++.h>
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define ALL(t) (t).begin(),(t).end()
#define CLR(a) memset((a),0,sizeof(a))
#define pb push_back
#define mp make_pair
#define fr first
#define sc second

using namespace std;


#ifdef DEB
#define dump(x)  cerr << #x << " = " << (x) << endl
#define prl cerr<<"called:"<< __LINE__<<endl
#define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
#define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl
template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;}
#else
#define dump(x) ;
#define dumpR(x) ;
#define dumpY(x) ;
#define dumpG(x) ;
#define prl ;
template<class T> void debug(T a,T b){ ;}
#endif

template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; }
template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; }

typedef long long int lint;
typedef pair<int,int> pi;

namespace std{
  template<class S,class T>
  ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.fr<<','<<a.sc<<')';
    return out;
  }
}

//const int INF=5e8;
int n,K;
typedef vector<int> vi;

int mat[55][55];
int main(){
//  cin>>K;
  K=38;
  n=K*K-K+1;

  vector<vector<int> >res;
  int cnt=1;
  REP(i,K) REPN(j,K,1) mat[i][j]=cnt++;
  for(int i=0;i<K;++i){
    if(i==0){
      vi tmp;
      REP(j,K) tmp.pb(j);
      res.pb(tmp);
    }
    int cnt=(i==0?K:K-1);

    if(i+1<K){
      REP(j,cnt){
        vi tmp={i};
        for(int k=1;k<K;++k){
          tmp.pb(mat[1+(j+i*k)%cnt][k]);
        }
        if(j+1==K) ;
        else res.pb(tmp);
      }
    }else{
      REP(j,cnt){
        vi tmp={i};
        REPN(k,K,1) tmp.pb(mat[k][j+1]);
        res.pb(tmp);
      }
    }

/*
    set<int> cands;
    REPN(j,n,i+1) cands.insert(j);
    for(auto e:res){
      for(auto e2:e) if(e2==i){
        for(auto e3:e) if(cands.count(e3)) cands.erase(e3);
        break;
      }
    }
    debug(ALL(cands));
    vector<vi> cur(K-i);
    REP(j,K-i) cur[j].pb(i);
    int cnt=0;
    int loop=0;
    while(!cands.empty()){
      cur[(cnt+loop)%(K-i)].pb(*cands.begin());
      cands.erase(cands.begin());
      ++cnt;
      if(cnt==K-i){
        loop+=i;
      }
      cnt%=(K-i);
    }
      dump(loop);
    for(auto e:cur) res.pb(e);
    */
  }
  assert(n==res.size());
  n=res.size();

  printf("%d %d\n",(int)res.size(),K);
  for(auto e:res){
    for(auto e2:e) printf("%d ",e2+1);
    cout<<endl;
  }
  /*
  {
    int app[2005]={0};
    for(auto e:res) for(auto e2:e) ++app[e2];
    REP(i,n) assert(app[i]==K);
    REP(i,n){
      sort(ALL(res[i]));
      res[i].erase(unique(ALL(res[i])),res[i].end());
      assert(res[i].size()==K);
    }
    REP(i,n) REP(j,i){
      set<int> all;
      for(auto e:res[i]) all.insert(e);
      for(auto e:res[j]) all.insert(e);
      dump(i);dump(j);
      assert(all.size()==K+K-1);
    }
  }
*/

  return 0;
}





Measured memory_bytes: 768
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(false);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

int solve() {
  int N, X, Y, S = 0, t;
  cin >> N >> X >> Y;
  rep(i, 0, N - 2) cin >> t, S ^= t;

  int D = (X + Y - S) / 2;
  if ((X + Y - S) % 2 || D < 0 || D & S || D > X) return -1;

  int a = D;
  int b = D;
  rrep(i, 0, 50) {
    int p = 1LL << i;
    if ((D & p) != 0) continue;
    if ((S & p) == 0) continue;
    if ((a | p) <= X) {
      a |= p;
    } else {
      b |= p;
    }
  }
  if (!(1 <= a && a <= X && b >= Y)) return -1;
  return X - a;
}
signed main() {
  cout << solve() << endl;
  return (0 ^ _ ^ 0);
}



Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int x;
  cin >> x;
  int t = 100;
  int ans = 0;
  while(t < x){
    t += t / 100;
    ans++;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3612