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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

lli dp[110][110];

void func(long long N, long long M, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c){

    REP(k,0,N)REP(i,0,N)REP(j,0,N)chmin(dp[i][j],dp[i][k]+dp[k][j]);

    lli cnt = 0;
    REP(i,0,M){
        if(dp[a[i]][b[i]]!=c[i])cnt++;
    }

    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    REP(i,0,110)REP(j,0,110)dp[i][j]=INF;
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> a(M);
    std::vector<long long> b(M);
    std::vector<long long> c(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&a[i]);
        scanf("%lld",&b[i]);
        scanf("%lld",&c[i]);
        a[i]--,b[i]--;
        dp[a[i]][b[i]]=c[i];
        dp[b[i]][a[i]]=c[i];
    }
    func(N, M, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=s;i<n;i++)
typedef long long ll;
ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}
int main(){
    int n; cin >> n;
    int ans; cin >> ans;
    rep(i,n-1){
        int a; cin >> a;
        ans = gcd(ans, a);
    }
    cout << ans << endl;
    return 0;
}

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

int Nijo(int x,int y,int a,int b)
{
  return (x-a)*(x-a)+(y-b)*(y-b);
}

int main()
{
  int n;
  cin>>n;
  vector<vector<int>> xy(n,vector<int>(2));
  
  for(int i=0;i<n;i++)
    cin>>xy.at(i).at(0)>>xy.at(i).at(1);
  
  vector<int> a;
  for(int i=0;i<n;i++)
    a.push_back(i);
  double sum=0;
  do
  {
    for(int i=0;i<n-1;i++)
    {
      sum+=sqrt(Nijo(xy.at(a.at(i)).at(0),xy.at(a.at(i)).at(1),xy.at(a.at(i+1)).at(0),xy.at(a.at(i+1)).at(1)));
    }
  }while(next_permutation(a.begin(),a.end()));
  
  for(int i=1;i<n+1;i++)
    sum=sum/i;
  cout.precision(10);
  cout<<sum<<endl;
}

Measured memory_bytes: 256
n,x = map(int,input().split())
l = list(map(int,input().split()))
#print(len(l))
a = len(l)
d = 0
i = 0
while(i<=a):
    if d <= x:
        if i == a:
            i += 1
            break
        d += l[i]
        i += 1
    else:
        break
print(i)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,M,X; cin >> N >> M >> X;
    vector<ll> A(M); for(auto& in:A) cin >> in;
    ll I = lower_bound(A.begin(),A.end(),X) - A.begin();
    cout << min(I,M-I) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
using namespace std;
int input(){
  int x;
  cin>>x;
  return x;
}
int abs(int x){
  if(x>=0){
    return x;
  }else{
    return -x;
  }
}
int gcd(int x, int y){
	if(x<y){
    return gcd(y,x);
  }
  if(y==0){
    return x;
  }
  return gcd(y,x%y);
}
int moji(char in)
{
    int ans = (int)in-(int)'a'+1;
    if((in < 1) || (in > 26)){
        ans = 100;
    }
    return ans;
}





int main() {
  int n=input();
  int guu[100010];
  int kis[100010];
  for(int i=0;i<100010;i++){
    guu[i]=0;
    kis[i]=0;
  }
  for(int i=0;i<n;i++){
    if(i%2==1){
      int x=input();
      kis[x]++;
    }else{
      int x=input();
      guu[x]++;
    }
  }
  int guuu=0;
  int kisu=0;
  int guunosuu=0;
  int kisuunosuu=0;
  for(int i=0;i<100010;i++){
    if(kis[i]>kisu){
      kisu=kis[i];
      kisuunosuu=i;
    }
    if(guu[i]>guuu){
      guuu=guu[i];
      guunosuu=i;
    }
  }
  
  
  int guuuni=0;
  int kisuni=0;
  for(int i=0;i<100010;i++){
    if(kis[i]>kisuni&&i!=kisuunosuu){
      kisuni=kis[i];
    }
    if(guu[i]>guuuni&&i!=guunosuu){
      guuuni=guu[i];
    }}
  if(kisuunosuu!=guunosuu){
    cout<<(n/2-kisu)+(n/2-guuu)<<endl;
  }else{
    if(guuuni>kisuni){
      cout<<(n/2-kisu)+(n/2-guuuni)<<endl;
    }else{
      cout<<(n/2-kisu)+(n/2-kisuni)<<endl;
    }
  }

  





  

  
  
  


  
  


  

  




  
  
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}

int main()
{
	lli n,m;
	set<lli> mp;
  map<lli,lli> mpa;
	cin>>n>>m;
	lli anse=0;
	for(int i=0;i<m;i++)
	{
		lli x;
		string y;
		cin>>x>>y;
      	if(mp.find(x)!=mp.end())
          continue;
		if(y=="AC")
        {mp.insert(x);if(mp.find(x)!=mp.end())anse+=mpa[x];}
		else if(mp.find(x)==mp.end())
			mpa[x]++;
	}
	cout<<mp.size()<<" "<<anse;

}



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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        System.out.println((fsc.nextInt()-1)*(fsc.nextInt()-1));
        fsc.close();
        
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 21076
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}



fn solve(a: i64, b: i64, c: i64, num_of_used: usize, bambs: &[i64], counts: &mut [i64]) -> i64{
    if num_of_used == bambs.len(){
        if counts.iter().any(|count| *count == 0){
            return i64::max_value();
        }else{
            return a.abs() + b.abs() + c.abs() + counts.iter().filter(|count| **count > 1)
                .map(|count| *count-1).sum::<i64>() * 10;
        }
    }

    
    let mut results: Vec<i64> = Vec::new();
    results.push(solve(a, b, c, num_of_used+1, bambs, counts));
    for i in 0..3{
        counts[i] += 1;
        let (a, b, c) = match i{
            0 => (a-bambs[num_of_used], b, c),
            1 => (a, b-bambs[num_of_used], c),
            _ => (a, b, c-bambs[num_of_used])
        };

        results.push(solve(a, b, c, num_of_used+1, bambs, counts));
        counts[i] -= 1;
    }
    results.into_iter().min().unwrap()
}


fn main(){
    let line = read_as_vec::<i64>();
    let (n, a, b, c) = (line[0], line[1], line[2], line[3]);
    let mut bambs: Vec<i64> = Vec::new();
    for _ in 0..n{
        bambs.push(read_as_vec::<i64>()[0])
    }
    let mut counts: Vec<i64> = vec![0;3];
    let mut num_of_used: usize = 0;
    let ans = solve(a, b, c, num_of_used, &bambs, &mut counts);

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


Measured memory_bytes: 4352
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder.ABC091.B
{
    class Program
    {
        static void Main ()
        {
            var sc = new Scanner ();
            int n = sc.nextInt ();
            var s = new string[n];
            for (int i = 0; i < n; i++)
            {
                s[i] = sc.next ();
            }
            int m = sc.nextInt ();
            var t = new string[m];
            for (int i = 0; i < m; i++)
            {
                t[i] = sc.next ();
            }

            var count = new Dictionary<string, int> ();
            foreach (var item in s)
            {
                if (count.ContainsKey (item)) count[item] += 1;
                else count.Add (item, 1);
            }
            foreach (var item in t)
            {
                if (count.ContainsKey (item)) count[item] -= 1;
            }
            Console.WriteLine (Math.Max (count.Values.Max (), 0));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner ()
        {
            s = new string[0];
            i = 0;
        }

        public string next ()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine ();
            while (st == "") st = Console.ReadLine ();
            s = st.Split (cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next ();
            i = 0;
            return s[i++];
        }

        public int nextInt ()
        {
            return int.Parse (next ());
        }
        public int[] ArrayInt (int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt () + add;
            }
            return Array;
        }

        public long nextLong ()
        {
            return long.Parse (next ());
        }

        public long[] ArrayLong (int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong () + add;
            }
            return Array;
        }

        public double nextDouble ()
        {
            return double.Parse (next ());
        }

        public double[] ArrayDouble (int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble () + add;
            }
            return Array;
        }

        public decimal nextDecimal ()
        {
            return decimal.Parse (next ());
        }

        public decimal[] ArrayDecimal (int N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDecimal ();
            }
            return Array;
        }
    }
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;
int par[MAX] , sz[MAX] ;
int n ;

void init()
{
	for(int i = 0 ; i < MAX ; ++i)
		par[i] = i , sz[i] = 1; 
}

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

void Union(int x , int y)
{
	int a = root(x) ; 
	int b = root(y) ;
	par[a] = b ;
	sz[b] += sz[a] ;
}

bool cmp(pair<int , pair<int , int> >&a , pair<int , pair<int , int> >&b)
{
	return a.second.first < b.second.first;
}

int main()
{
	init() ;
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	vector< pair<int , pair<int , int> > >vp ;
	for(int i = 0 ; i < n ; ++i)
	{
		int x , y ;
		cin>>x>>y ;
		vp.push_back({x , {y , i}}) ;
	}
	sort(vp.begin() , vp.end()) ;
	vector< pair<int , pair<int , int> > >edges ;
	for(int i = 0 ; i < n-1 ; ++i)
		edges.push_back({vp[i+1].first - vp[i].first , {vp[i].second.second , vp[i+1].second.second}}) ;
	sort(vp.begin() , vp.end() , cmp) ;
	for(int i = 0 ; i < n-1 ; ++i)
		edges.push_back({vp[i+1].second.first - vp[i].second.first , {vp[i].second.second , vp[i+1].second.second}}) ;
	sort(edges.begin() , edges.end()) ;
	long long ans = 0ll ;
	for(auto &i : edges)
	{
		if(root(i.second.first) == root(i.second.second))
			continue ;
		Union(i.second.first , i.second.second) ;
		ans += (i.first * 1ll) ;
	}
	return cout<<ans<<"\n" , 0 ;
}


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

int main() {
  char a, b;
  int c, i;
  cin >> a >> b;
  if (a > b) {
    c = a - '0';
    for (i = 0; i < c; i++) {
      cout << b;
    }
  } else {
    c = b - '0';
    for (i = 0; i < c; i++) {
      cout << a;
    }
  }
  cout << endl;
  return 0;
}
    

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

int main() {
    int n, x;
    cin >> n >> x;
    int a[n];
    rep(i,n) {
        cin >> a[i];
    }
    int64_t ans = 0;
    rep(i,n) {
        if (i + (n % 2 == 0) > 0) {
            int cnt = min(max(a[i] + a[i-1] - x, 0), a[i]);
            a[i] -= cnt;
            ans += cnt;
        }
    }
    if (a[0] + a[1] > x) {
        ans += min(max(a[1] + a[0] - x, 0), a[0]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
N, M = map(int, input().split())
if N == 1:
  if M == 1:
    print(1)
  elif M == 2:
    print(0)
  else:
    print(M - 2)
elif N == 2:
  print(0)
else:
  if M == 1:
    print(N - 2)
  elif M == 2:
    print(0)
  else:
    print((N - 2) * (M - 2))

Measured memory_bytes: 61592
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<string>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<climits>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; i++)
#define FOR(i, j, k) for(int i = j; i < k; i++)
#define P pair<int, int>
const int INF = INT_MAX / 2;

int main(){
    map<char, string> f;
    f[' '] = "101";
    f['\''] = "000000";
    f[','] = "000011";
    f['-'] = "10010001";
    f['.'] = "010001";
    f['?'] = "000001";
    f['A'] = "100101";
    f['B'] = "10011010";
    f['C'] = "0101";
    f['D'] = "0001";
    f['E'] = "110";
    f['F'] = "01001";
    f['G'] = "10011011";
    f['H'] = "010000";
    f['I'] = "0111";
    f['J'] = "10011000";
    f['K'] = "0110";
    f['L'] = "00100";
    f['M'] = "10011001";
    f['N'] = "10011110";
    f['O'] = "00101";
    f['P'] = "111";
    f['Q'] = "10011111";
    f['R'] = "1000";
    f['S'] = "00110";
    f['T'] = "00111";
    f['U'] = "10011100";
    f['V'] = "10011101";
    f['W'] = "000010";
    f['X'] = "10010010";
    f['Y'] = "10010011";
    f['Z'] = "10010000";

    map<string, char> s;
    s["00000"] = 'A';
    s["00001"] = 'B';
    s["00010"] = 'C';
    s["00011"] = 'D';
    s["00100"] = 'E';
    s["00101"] = 'F';
    s["00110"] = 'G';
    s["00111"] = 'H';
    s["01000"] = 'I';
    s["01001"] = 'J';
    s["01010"] = 'K';
    s["01011"] = 'L';
    s["01100"] = 'M';
    s["01101"] = 'N';
    s["01110"] = 'O';
    s["01111"] = 'P';
    s["10000"] = 'Q';
    s["10001"] = 'R';
    s["10010"] = 'S';
    s["10011"] = 'T';
    s["10100"] = 'U';
    s["10101"] = 'V';
    s["10110"] = 'W';
    s["10111"] = 'X';
    s["11000"] = 'Y';
    s["11001"] = 'Z';
    s["11010"] = ' ';
    s["11011"] = '.';
    s["11100"] = ',';
    s["11101"] = '-';
    s["11110"] = '\'';
    s["11111"] = '?';

    string inp;
    while(getline(cin, inp)){
        string tmp = "";
        REP(i, inp.length()) tmp += f[inp[i]];
        while(tmp.size() % 5 != 0) tmp += '0';
        string ans = "";
        for(int i = 0; i < tmp.size(); i += 5) ans += s[tmp.substr(i, 5)];
        cout <<ans <<endl;
    }
    return 0;
}

Measured memory_bytes: 1204
#include <cmath>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

#include <numeric>

using namespace std;

using ll = long long;
using ld = long double;
using vi = vector<int>;

int n;

void input() {
  cin >> n;
}

void solve() {
  ll ans = 0;

  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      for (int k = 1; k <= n; ++k)
        ans += gcd(i, gcd(j, k));
    }
  }

  cout << ans << '\n';
}

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

  cout.precision(16);
  cout << fixed;

  int _times = 1;

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);

  _times = 2;
#endif

  // cin >> _times;

  while (_times--) {
    input();
    solve();
  }
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

typedef long long int ll;

int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }

  vector<int> e(n);
  int m = 0;
  int k = 0;
  rep(i, n)
  {
      if (v[i] % 2 == 0)
      {
          m++;
          if (v[i] % 3 == 0 || v[i] % 5 == 0)
          {
              k++;
          }
      }
  }
  if (m == k) {
    cout << "APPROVED" << endl;
  } else {
    cout << "DENIED" << endl;
  }
}

Measured memory_bytes: 256
using System;

public class AtCoder
{
    public static void Main()
    {
        int n;
        n = int.Parse(Console.ReadLine().Trim());
        int[] p = new int[n];
        for (int i = 0; i < n; i++)
        {
            p[i] = int.Parse(Console.ReadLine().Trim());
        }
        Array.Sort(p);
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            ans += p[i];
        }
        ans -= p[n - 1] / 2;
        
        Console.WriteLine(ans);
    }
}


Measured memory_bytes: 11092
def main():
    import sys
    N=int(input())
    MOD=1000000007
    
    a=list(map(int,input().split()))
    c=[3]+[0]*N
    ans=1
    for i in range(N):
        p=a[i]
        ans=ans*c[p]%MOD
        c[p]-=1
        c[p+1]+=1

    print(ans)


 
if __name__ == '__main__':
    main()


Measured memory_bytes: 13964
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <map>
using namespace std;
using P = pair<int,int>;
typedef long long ll;


#define rep(i,n) for (int i=0; i<(n); i++)
const int INF =1001001001;
const ll BIG = 1000000007;
const double PI = 3.141592653589793;

int main(){
    int n;
    string si;
    cin >> n;
    map<string, int> s;
    rep(i, n){
        cin >> si;
        s[si] += 1;
    }
    int max_num  = 0;
    for(auto x: s){
        int v = x.second;
        max_num = max(max_num, v);
    }
    for(auto x: s){
        if(x.second==max_num){
            cout << x.first << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 25216
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

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

int main() {
	int n;
	string str[20];
	int alpha[30];
	int al[30];
	int top[30];
	for(;;){
		memset(alpha,0,sizeof(alpha));
		memset(al,0,sizeof(alpha));
		memset(top,0,sizeof(alpha));
		n=in();
		if(n==0)break;
		rep(i,n)cin>>str[i];
		rep(i,n){
			int ten=1;
			for(int j=str[i].size()-1;j>=0;j--,ten*=10){
				al[str[i][j]-'A']=1;
				if(i<n-1)alpha[str[i][j]-'A']+=ten;
				else alpha[str[i][j]-'A']-=ten;
			}
			if(str[i].size()>1)top[str[i][0]-'A']=1;
		}
		int used[30];
		int m=0;
		rep(i,30){
			if(al[i]>0)used[m++]=i;
		}
		int res=0;
		do{
			int bit=(1<<m)-1;
			int q;
			for(;bit<1<<10;q=bit+(bit&-bit),bit=q|((bit&~q)/(bit&-bit))>>1){
				if((bit&1)>0&&top[used[0]]>0)continue;
				int c=0,sum=0;
				rep(i,10){
					if((bit&1<<i)!=0){
						sum+=alpha[used[c++]]*i;
					}
				}
				if(sum==0)res++;
			}
		}while(next_permutation(used,used+m));
		cout<<res<<endl;
	}
	return 0;
}

Measured memory_bytes: 956
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    while(scanf("%d",&n)==1){
        set<int> se;
        multiset<int> re;
        int e;
        for(int i=0;i<n;i++){
            scanf("%d",&e);
            if(se.find(e)!=se.end()){
                re.insert(e);
                se.erase(e);
                //printf("%d\n",e);
            }
            else{
                se.insert(e);
            }
        }
        if(re.size()<2){
            printf("0\n");
            continue;
        }
        ll ans=*re.rbegin();
        auto it=re.end();
        it--;
        re.erase(it);
        ans*=*re.rbegin();
        printf("%lld\n",ans);
    }
}


Measured memory_bytes: 4992
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

int main() {
	ll n;
	cin >> n;
	vector<ll> h(n), x(n, 0);
	rep(i, n) cin >> h.at(i);
	ll ans = 0;
	bool ok = true;
	bool fin = true;
	while (fin) {
		ok = false;
		fin = false;
		rep(i, n) {
			if (h.at(i) > 0) {
				h.at(i)--;
				if (ok) continue;
				else {
					ok = true;
					ans++;
				}
			}
			else {
				ok = false;
			}
		}
		rep(i, n) if (h.at(i) > 0) fin = true;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<queue>
#include <cstdio>
using namespace std;
int money[]={500,100,50,10,5,1};
int diem[]={1000,100,50,10,5,0};
int main()
{
  long long int x;
  cin>>x;
  if(x%10>=5)
  {
    x-=(x%10-5);
  }
  else
  {
    x-=x%10;
  }
  long long int tong=0;
    for(int i=0;i<=5;i++)
    {
      while(x/money[i]>0)
      {
        tong+=diem[i];
        x-=money[i];
      }
    }
    cout<<tong;
}


Measured memory_bytes: 256
N = parse(Int,readline())
A = map(x->parse(Int,x), split(readline()))
#A = parse.(Int, split(readline()))

count = Dict()

for a in A
    count[a] = get(count,a,0) + 1
end

count = sort([x for x in count if x.second >= 2],by = x->x.first,rev = true)

ans = 0

if length(count) >= 2
    ans = max(count[1].first * count[2].first)
end

i = 0
for (x,y) in count
    if i == 3
        break
    end
    if y >= 4
       global ans = max(ans, x * x)
    end
    global i+=1
end

println(ans)

Measured memory_bytes: 151924
S = input()
S = S + "s"
s = [0] * len(S)

rl = "R"
stock = 0
lidx = 0
for i in range(len(S)):
    #print(S[i])
    if S[i] == rl:
        stock += 1
    else:
        if rl == "R":
            s[i-1] += stock // 2 + stock % 2
            s[i] += stock // 2
            lidx = i
        elif rl == "L":
            s[lidx] += stock // 2 + stock % 2
            s[lidx-1] += stock // 2
        rl = S[i]
        stock = 1

    #print(s)

print(" ".join(map(str, s))[:-1])


Measured memory_bytes: 10484
S = input()
C = [S.count('a'), S.count('b'), S.count('c')]
if (len(set(list(S))) == 3 and max(C) - min(C) < 2) or len(S) == 1 or (len(S) == len(set(list(S))) == 2):
    print('YES')
else:
    print('NO')

Measured memory_bytes: 71752
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        ArrayDeque<Long> deq = new ArrayDeque<>();
        for (long i = 1; i <= 9; i++) {
            deq.add(i);
        }
        for (int i = 1; i < n; i++) {
            long x = deq.poll();
            if (x % 10 != 0) {
                deq.add(x * 10 + x % 10 - 1);
            }
            deq.add(x * 10 + x % 10);
            if (x % 10 != 9) {
                deq.add(x * 10 + x % 10 + 1);
            }
        }
        System.out.println(deq.poll());
    }
}


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

int main() {
  ll n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) cout << 1 << endl;
  else if (n == 1 || m == 1) cout << max(n, m)-2 << endl;
  else cout << n*m - (n+m)*2 + 4 << endl;
  return 0;
}

Measured memory_bytes: 256
#入力値の取得
_in =input().split()
num_ab = [ int(i) for i in _in]

#積の計算
prod = num_ab[0] * num_ab[1]

#奇数偶数の判定
if prod % 2 == 0:
    print('Even')
else:
    print('Odd')

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
ll power(ll a,int n){
	if(n==0)
	  return 1;
	if((n%2)==0)
	  return power(a*a,n/2);
	else
	  return a*power(a*a,n/2);    
}
int main(){
FASTIO
ll n,k;
cin>>n>>k;
n=n%k;
cout<<min(n,k-n);
return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        if ((1 <= i && i <= 9)
            || (100 <= i && i <= 999)
            || (10000 <= i && i <= 99999)) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool ans = false;
string str;
int main(void){
    // Your code here!
    cin >> str;
    if (str == "AKIHABARA") ans = true;
    if (str == "AKIHABAR") ans = true;
    if (str == "AKIHBARA") ans = true;
    if (str == "AKIHBAR") ans = true;
    if (str == "AKIHABRA") ans = true;
    if (str == "AKIHABR") ans = true;
    if (str == "AKIHBRA") ans = true;
    if (str == "AKIHBR") ans = true;
    if (str == "KIHABARA") ans = true;
    if (str == "KIHABAR") ans = true;
    if (str == "KIHBARA") ans = true;
    if (str == "KIHBAR") ans = true;
    if (str == "KIHABRA") ans = true;
    if (str == "KIHABR") ans = true;
    if (str == "KIHBRA") ans = true;
    if (str == "KIHBR") ans = true;
    if (ans) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;

    bool ok = true;
    rep(i, a + b + 1) {
        if (i == a && s[i] != '-') ok = false;
        else if (i != a && s[i] == '-') ok = false;
    }

    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
unsigned long long n,d,x,y,s;
int main(){
	cin>>n>>d;
	while(n--){
		cin>>x>>y;
		if(sqrt(x*x+y*y)<=d)s++;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 3612
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

typedef long long ll;
const int MAXN = 2e5 + 10;
int N;
int A[MAXN], B[MAXN];
ll D[MAXN], ta, tb, ans;

int main() {
	register int i, t = 0;
	scanf("%d", &N);
	for(i = 1; i <= N; ++i)
		scanf("%d%d", A + i, B + i),
		ta += A[i], tb += B[i],
		D[++t] = A[i], D[++t] = B[i];
	sort(D + 1, D + (N << 1) + 1);
	ans = min(ta, tb);
	for(i = 1; i <= N << 1; ++i)
		D[i] += D[i - 1];
	for(i = 1; i <= N; ++i) {
		int pos = N; ll res = 0;
		if(A[i] <= D[pos - 1] - D[pos - 2]) ++pos; else res += A[i];
		if(B[i] <= D[pos - 1] - D[pos - 2]) ++pos; else res += B[i];
		ans = min(ans, res + D[pos - 2]);
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#define llint long long
#define inf 1e18
#define mod 998244353
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)

using namespace std;

llint n, s;
llint a[3005];
llint dp[3005][3005];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	dp[0][0] = 1;
	llint ans = 0;
	for(int i = 0; i < n; i++){
		for(int j = 0; j <= s; j++){
			(dp[i+1][j] += dp[i][j]) %= mod;
			if(j+a[i+1] <= s){
				llint add = dp[i][j];
				if(j == 0) add *= (i+1), add %= mod;
				(dp[i+1][j+a[i+1]] += add) %= mod;
				if(j+a[i+1] == s) ans += add * (n-i) % mod, ans %= mod;
			}
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 70784
use std::io::stdin;
use std::str::FromStr;

struct Input {
    line: Vec<String>,
    position: usize,
}

// 型にメソッドを実装する
impl Input {
    fn new() -> Input {
        Input {
            line: vec![],
            position: 0,
        }
    }

    fn read_word(&mut self) -> &String {
        let mut _line = String::new();
        stdin().read_line(&mut _line);
        {
            // let mut iter = "A few words".split_whitespace();
            // assert_eq!(Some("A"), iter.next());
            // assert_eq!(Some("few"), iter.next());
            // assert_eq!(Some("words"), iter.next());
            // assert_eq!(None, iter.next());
        }
        self.line = _line.split_whitespace().map(|x| x.to_string()).collect();
        let result = &self.line[self.position];
        result
    }

    fn get<T: FromStr>(&mut self) -> Result<T, T::Err> {
        // parse can parse any type that implements the FromStr trait.
        self.read_word().parse()
    }
}

fn main() {
    // let a = [1, 2, 3, 4, 5];
    let mut input = Input::new();
    let x: i32 = input.get().unwrap(); // vector の 値全ての 参照を受け取った後に unwrap() を使って実値を受け取る
    println!("{}", x * x * x);
}



Measured memory_bytes: 5032
#include<iostream>
#include<algorithm>
#include<vector>

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

    std::vector<int> b(n);

    for(int i = 0; i < n; i++){
        int a;
        std::cin >> a;
        b[i] = a - i - 1;
    }

    std::sort(b.begin(), b.end());

    int median_b = b[n / 2];

    long long ans = 0;

    for(int i = 0; i < n; i++){
        ans += std::abs(b[i] - median_b);
    }

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

Measured memory_bytes: 1024
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = 0;
  int d = 0;
  int e = 0;
  for(int i = 0;i < n;i++){
    int p = sc.nextInt();
    if(p <= a)c++;
    else if(p <= b)d++;
    else e++;
  }
  if(c<=d && c<=e)System.out.println(c);
  else System.out.println(d <= e ? d:e);
}}

Measured memory_bytes: 22356
import java.util.Scanner; 

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int D = in.nextInt();
      int range = 2 * D + 1;
      int ans = N / range + (N % range != 0 ? 1 : 0);

      System.out.println(ans);
    }
  }
}

Measured memory_bytes: 20560
#include <bits/stdc++.h>
#define int long long
#define bp __builtin_popcountll
#define pb push_back
#define in(s) freopen(s, "r", stdin);
#define out(s) freopen(s, "w", stdout);
#define inout(s, end1, end2) freopen((string(s) + "." + end1).c_str(), "r", stdin),\
		freopen((string(s) + "." + end2).c_str(), "w", stdout);
#define fi first
#define se second
#define bw(i, r, l) for (int i = r - 1; i >= l; i--)
#define fw(i, l, r) for (int i = l; i < r; i++)
#define fa(i, x) for (auto i: x)
using namespace std;
const int mod = 1e9 + 7, inf = 1061109567;
const long long infll = 4557430888798830399;
const int N = 5005;
int n, a[N], sz[N], dp[N][N][2];
vector<int> g[N];
int solve(int u, int p) {
	if (a[u] > 0) dp[u][0][0] = a[u];
	else dp[u][0][1] = a[u];
	
	sz[u] = 1;
	
	fa (v, g[u]) if (v != p) {
		solve(v, u);
		sz[u] += sz[v];
		
		bw (j, sz[u], 0) {
			int og0 = dp[u][j][0], og1 = dp[u][j][1];
			dp[u][j][0] = infll, dp[u][j][1] = infll;
			fw (k, max(0ll, sz[v] - sz[u] + j), min(j + 1, sz[v])) {
				//Cut edge i - v
				if (j - k >= 1) {
					if (dp[v][k][0] != infll || dp[v][k][1] < 0) {
						dp[u][j][0] = min(dp[u][j][0], dp[u][j - 1 - k][0]);
						dp[u][j][1] = min(dp[u][j][1], dp[u][j - 1 - k][1]);
					}
				}
				//Keep edge i - v
				if (k > 0) {
					dp[u][j][0] = min(dp[u][j][0], dp[u][j - k][0] + dp[v][k][0]);
				
					dp[u][j][1] = min(dp[u][j][1], dp[u][j - k][1] + dp[v][k][1]);
					dp[u][j][1] = min(dp[u][j][1], dp[u][j - k][0] + dp[v][k][1]);
					dp[u][j][1] = min(dp[u][j][1], dp[u][j - k][1] + dp[v][k][0]);
				} else {
					dp[u][j][0] = min(dp[u][j][0], og0 + dp[v][k][0]);
				
					dp[u][j][1] = min(dp[u][j][1], og1 + dp[v][k][1]);
					dp[u][j][1] = min(dp[u][j][1], og0 + dp[v][k][1]);
					dp[u][j][1] = min(dp[u][j][1], og1 + dp[v][k][0]);
				}
			}
		}
	}
//	fw (j, 0, sz[u]) fw (k, 0, 2) cout << "dp[" << u + 1 << "][" << j << "][" << k << "] = " << dp[u][j][k] << "\n";
}
signed main() {
	#ifdef BLU
	in("blu.inp");
	#endif
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	fw (i, 0, n) cin >> a[i];
	fw (i, 1, n) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		g[u].pb(v), g[v].pb(u);
	}
	memset(dp, 63, sizeof dp);
	solve(0, -1);
	fw (k, 0, n) {
		if (dp[0][k][0] != infll || dp[0][k][1] < 0) {
			cout << k << "\n";
			return 0;
		}
	}
	return 0;
}

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

public class Main{

	public static void main(String[] args) throws NumberFormatException, IOException{
		// インプットデータ取得
		Scanner sc = new Scanner(System.in);

        while(true) {

        int n_tatesen = sc.nextInt();//2
        int m_yokosen = sc.nextInt();//1
        int a_selected = sc.nextInt();//2

        if(n_tatesen==0&&m_yokosen==0&&a_selected==0) {
        	break;}

        int height, p_tatesen, q_tatesen;
        int[][] map = new int[1001][n_tatesen+1];
        for(int i=0;i<m_yokosen;i++) {
        	//横線がわたる高さと縦線番号を取得
        	height=sc.nextInt();//1
        	p_tatesen=sc.nextInt();//1
        	q_tatesen=sc.nextInt();//2
        	//高さが決まるとき、小さい側の縦線が3番だったら
        	//3から4か4から3のどちらかになるが、それは自分の現在地次第
        	map[height][p_tatesen]=q_tatesen;//2
        	map[height][q_tatesen]=p_tatesen;//1
        }

        //現在地がaなので、3番にいるときの行先がmapの値に入っている
        //高い順でループを回す
        for(int i=1000;i>0;i--) {
        	if(map[i][a_selected]!=0) {
        		a_selected=map[i][a_selected];
        	}
        }
        System.out.println(a_selected);

	}
}
	 public static void ScanYokosen(){
		 //横線のデータを取得する

	 }

	 public static void SelectYokosen(){
		 //選んだ縦線から必要な線だけ抜き出して、高さ順に並べる
	 }

}



Measured memory_bytes: 71128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define mp make_pair
#define PI pair<ll,ll>
#define poly vector<ll>
#define mem(a) memset((a),0,sizeof(a))
#define For(i,l,r) for(int i=(int)(l);i<=(int)(r);i++)
#define Rep(i,r,l) for(int i=(int)(r);i>=(int)(l);i--)
#define pb push_back
#define fi first
#define se second
#define SZ(x) ((int)(x.size()))
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
ll rnd(){
	ull ans=0;
	For(i,0,4)ans=ans<<15^rand();
	return ans%((ull)1<<63);
}
const int N=100005;
ll solve(int w,int h,int k){
	ll ans=0;
	For(h2,1,h-1){
		int h1=h-h2;
		For(de,0,w-2){
			int l=1,r=w-1-de,gg=__gcd(h,de),sum=0;
			while(l<r){
				ll b=((l+r)>>1)+1,a=b+de;
				if((a+b)*h-a*h1-b*h2-gg+2<=2*k)l=b; else r=b-1;
			}
			int L=l;
			l=0,r=w-1-de;
			while(l<r){
				ll b=((l+r)>>1)+1,a=b+de;
				if((a+b)*h-a*h1-b*h2-(h+gg)+2<=2*k)l=b; else r=b-1;
			}
			int R=l;
			//R=min(R+1,w-1-de);
			//L=1; R=w-1-de;
			if(L>R)break;
			sum+=L-1;
			For(b,L,R){
				int a=b+de;
				if((a+b)*h-a*h1-b*h2-(__gcd(a,h1)+__gcd(b,h2)+gg)+2<=2*k){
					//assert(((a+b)*h-a*h1-b*h2-2*(h+gg)+2<=k));
					sum++;
				}
			}
			if(de)ans+=sum*2; else ans+=sum;
		}
	}
	return ans*2;
}
int main(){
	#ifdef Brollan
		freopen("1.in","r",stdin);
	#endif
	int w=read(),h=read(),k=read();
	cout<<solve(w,h,k)+solve(h,w,k)<<endl;
}


Measured memory_bytes: 3620
n=int(input())
a=list(map(int,input().split()))
a.sort()
ans=[]
R=a.pop()
L=a.pop(0)
s=L
if a:
    while a[-1]>0:
        r=a.pop()
        ans.append([s,r])
        s=s-r
        if not a:break
ans.append([R,s])
s=R-s
while a:
    L=a.pop()
    ans.append([s,L])
    s=s-L
print(s)
for x in ans:
    print(*x)


Measured memory_bytes: 21544
import java.math.BigInteger;
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    BigInteger point = BigInteger.ONE;
    List<BigInteger> aList = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      BigInteger a = new BigInteger(sc.next());
      aList.add(a);
      if (i < k) {
        continue;
      }
      System.out.println(a.compareTo(aList.get(i - k)) > 0 ? "Yes" : "No");
    }
  }
}


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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll n,k;
	cin>>n>>k;
	ll ans = 0;
	while(n)
	{
		ans++;
		n/=k;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int k;
	cin >> k;
	long long int m[k]; 
	for(int i=0;i<k;i++){
	cin >> m[i];
}
	long long int a,b,c;
	a=2;
	b=2;
	for(int j=k-1;j >= 0;j--){
	c=b%(m[j]);
	if(a-1 < (b-c)){
	a=(((a-1)/(m[j]))+1)*(m[j]);
	b=b-c+(m[j])-1;
}
	if(a > (b-c)){
	a=1;
	b=1;
}
}
	if((a == 1) && (b == 1)){
	cout << -1 << endl;
    }else{
		cout << a << ' ' << b << endl;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    ll h;
    cin >> h;
    int index = 0;
    int ans = 0;
    while (1)
    {
        if(pow(2,index) <= h &&  h<pow(2,index+1LL) ){
            break;
        }
        index++;
    }
   // cerr << index << endl;
    for (int i = 0; i <= index; i++)
    {
        ans += pow(2, i);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
/* ex 6-2
    kas056 */

#include <stdio.h>
#include <string.h>

#define SIZE 1000

int main(void){
    int mid; //間の数は入力した文字の長さ－2
    char omission[SIZE];

    scanf("%s", omission);
    int length = strlen(omission);//入力の読込後、長さ測定

    mid = length - 2;//midの大きさは(長さ-2)

    if(mid < 1){//midが0以下ならエラー
        fprintf(stderr, "unexpected characters: %s", omission);
    }

    else{//ヌル文字でない最後の文字は、omission[length - 1]に入っている。
        printf("%c%d%c\n",omission[0], mid, omission[length - 1]);
        
    }

    return 0;

}

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

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

    ll count = 0;
    if ((N&1) == 0) {
        for (ll i = 10; i <= N; i*=5) count += N / i;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
4 5
3 2 4 1
'''

def solve(l,k):
	n = len(l)
	curr = 0
	zz = 1
	done = defaultdict(int)
	last = 1
	prev = 0
	done[curr+1] = zz
	f = 0
	while(zz <= k):
		last = curr + 1
		curr = l[curr]-1
		zz += 1
		if(done[curr+1] != 0):
			f = 1
			last = curr+1
			break
		else:
			done[curr+1] = zz
	if(len(done) == 1):
		return l[0]
	zz -= 1
	if(zz == 1):
		return l[0]
	mod = k%zz
	k = k - done[last] + 1
	cycle = zz - done[last] + 1
	mod = k%cycle
	find = mod+done[last]
	if(not f):
		return curr + 1
	for i in done:
		if(done[i] == find):
			return i
	return curr+1
	

N,K = list(map(int, stdin.readline().rstrip().split()))
l = list(map(int, stdin.readline().rstrip().split()))
ans = solve(l,K)
print(ans)



Measured memory_bytes: 115136
// #include <bits/stdc++.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;

#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0; i<n; i++)

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

    ll a;
    ll ans = 1;
    ll MAX = 1e18;
    bool flag = 0;
    bool zero = 0;

    rep(i, n) {
        cin >> a;
        if (a==0) zero = 1;
        else if (ans > MAX/a) flag = 1;
        ans *= a;
    }

    if (zero) cout << 0 << endl;
    else if (flag) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3616