akhauriyash/Code-Regression huggingface dataset:
/*
    ThunderClap and Flash
    Raunaq Singh
*/
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod) + (b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod) * (b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod) - (b%mod) + mod)%mod;}

void Flash(){
	ll n;
	cin>>n;
	ll a[n];
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		cin>>a[i];
		if (!(i & 1)) {
			ans += (a[i] & 1);
		}
	}
	cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){ 
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
    #endif
    ThunderClap;
    ll t = 1;
    //cin>>t;
    for(ll i = 1; i <= t; i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

#define st first
#define nd second

const int MAXN = 1e6 + 5, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18, MOD = 1e15 + 37;
const ld PI = acos(-1);

int a[MAXN], b[MAXN];
ll sum[MAXN];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout << setprecision(13) << fixed;

    //////////////////////////////////////////
    //////////////////////////////////////////

    ll n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }

    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }

    int ctr_a = 0;
    ll suma_a = 0;
    while (ctr_a + 1 <= n && suma_a + a[ctr_a + 1] <= k) {
        suma_a += a[++ctr_a];
    }

    ll suma_b = 0;
    int res = ctr_a;
    for (int i = 0; i <= m; ++i) {
        suma_b += b[i];
        if (suma_b > k) {
            break;
        }
        while (suma_a + suma_b > k) {
            suma_a -= a[ctr_a--];
        }
        res = max(res, ctr_a + i);
    }
    cout << res << "\n";
}


Measured memory_bytes: 5212
// https://atcoder.jp/contests/abc048/tasks/arc064_a

fun main() {
    abc048c()
}

fun abc048c() {
    val (ns, xs) = readLine()!!.split(" ")
    val n = ns.toInt()
    val x = xs.toLong()
    val a = readLine()!!.split(" ").map { it.toLong() }.toTypedArray()
    var count = 0L
    for (i in 1 until n) {
        val sum = a[i] + a[i - 1]
        if (sum > x) {
            val eat = sum - x
            count += eat
            a[i] = (a[i] - eat).coerceAtLeast(0)
        }
    }
    println(count)
}

Measured memory_bytes: 57964
#include<iostream>
#include<tuple>
#include<algorithm>

using namespace std;

bool mycompare( const tuple<string,int,int> &lhs, const tuple<string,int,int> &rhs )
{
    if (get<0>(lhs) != get<0>(rhs)) return get<0>(lhs) < get<0>(rhs);
    if (get<1>(lhs) != get<1>(rhs)) return get<1>(lhs) > get<1>(rhs);
    return get<2>(lhs) < get<2>(rhs);
}

int main(){
    int n,i; cin >> n;
    string s[n];int p[n];
    tuple<string,int,int> t[n];
    for(i = 0; i < n; i++){
        cin >> s[i] >> p[i];
        t[i] = make_tuple(s[i],p[i],i+1);
    }
    sort(t,t+n,mycompare);
    for(i = 0;i < n; i++){
        cout << get<2>(t[i]) << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 200005;
const int MOD = 1000000007;
const double pi = 3.141592653589;
/* global variables */
int D = 60;
/* function */
/* main */
int main(){
    int n; ll k;
    cin >> n >> k;
    // Doublingでの解法
    // to[k][i]: start i -> 2^k進んだ時の場所
    vector<vector<int>> to(D, vector<int>(MAX));
    for (int i = 0; i < n; i++) {
        cin >> to[0][i];
        to[0][i]--;
    }

    // i -> 2^{k + 1}進む
    // <=>   i  -> 1. 2^{k} 進む   -> 2. 2^{k}進む
    // 1. to[k][i]
    // 2. to[k][to[k][i]]
    // -> to[k + 1][i] = to[k][to[k][i]]
    for (int k = 0; k < D - 1; k++) {
        for (int i = 0; i < n; i++) {
            to[k + 1][i] = to[k][to[k][i]];
        }
    }

    // 2進数で進めていく
    int v = 0;
    for (int i = D - 1; i >= 0; --i) {
        ll b = 1LL << i;
        if (k & b) {
            v = to[i][v];
        }
    }
    cout << v + 1 << '\n';
}


Measured memory_bytes: 51028
#include <iostream>
using namespace std;
int main()
{
    int k, a, b;
    cin >> k >> a >> b;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) {
            cout << "OK" << endl;
            return 0;
        }
    }
    cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoder.Tool;

namespace AtCoder
{
    class AC
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;

        
        
        
        

        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var p = cin.SplitRead();
            Console.WriteLine(p[0] % p[1] == 0 ? -1 : p[0]);




            //Console.Out.Flush();
        }

        

        


    }
    public class Scanner
    {
        public int[] SplitRead()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReadL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for (var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value, long mod)
        {
            long r = value % mod;

            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }

    }

   struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
   {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
   }

    


}






Measured memory_bytes: 13268
while 1:
  n = input()
  if n==0: break
  D = [0]*n
  for j in range(n):
    a,b,c,d,e,f,g,h,i = map(int, raw_input().split())
    D[j] = [(b+d+f+h)*60 + c+e+g+i, a]
  D = sorted(D)
  print D[0][1]
  print D[1][1]
  print D[-2][1]

Measured memory_bytes: 4984
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define mapa map<char,int>
#define repa(p,A) for(auto p:A)
#define pb push_back
/*#define sort(a) sort(a.begin(),a.end())*/
#define reverse(a) reverse(a.begin(),a.end())
const double PI=acos(-1);
using namespace std;

int main( ) {
    vec A,B;
    ll N;
    cin>>N;
    rep(i,0,N) {
        ll a;
        cin>>a;
        if(i%2==0) {
            A.push_back(a);   
        }
        else {
            B.push_back(a);
        }
        }
        map<ll,ll> C,D;
        rep(i,0,A.size()) {
            C[A[i]]++;
        }
        rep(i,0,B.size()) {
            D[B[i]]++;
        }
        vector<pair<ll,ll>> E,F;
        for(auto p:C) {
            E.push_back(pair<ll,ll>(p.first,p.second));
            }
        for(auto p:D) {
            F.push_back(pair<ll,ll>(p.first,p.second));
            }
        auto comp = [](pair<int, int> a, pair<int, int> b) {
        return a.second>b.second;
    };   
        ll count=0;
        sort(E.begin(),E.end(),comp);
        sort(F.begin(),F.end(),comp);
        if(E[0].first==F[0].first) {
            if(E.size()>=2) {
                count+=E[0].second+max(E[1].second,F[1].second);
                }
            else count+=E[0].second;    
        }

        else count+=E[0].second+F[0].second;

        cout<<N-count<<endl;















        }
        



Measured memory_bytes: 9584
#include<iostream>
#include<iomanip>
unsigned int gcd(unsigned int a, unsigned int b)
{
	unsigned int a_p = b, b_p = a % b;
	return b_p == 0 ? a_p : gcd(a_p, b_p);
}
int main()
{
	unsigned int result[50][2];
	int num;
	for(int i = 0;; i++)
	{
		int a, b;
		std::cin >> a >> b;
		if(std::cin.eof())
		{
			num = i;
			break;
		}
		result[i][0] = gcd(a, b);
		result[i][1] = a / result[i][0] * b;
	}
	for(int i = 0; i < num; i++)
	{
		std::cout << result[i][0] << ' ' << result[i][1] << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3028
package main

import "fmt"

func SelectionSort(a []int) ([]int, int) {
	var minj, count int
	n := len(a)
	for i := 0; i < n; i++ {
		minj = i
		for j := i; j < n; j++ {
			if a[j] < a[minj] {
				minj = j
			}
		}
		if a[i] > a[minj] {
			a[i], a[minj] = a[minj], a[i]
			count++
		}
	}
	return a, count
}

func printArray(b []int) {
	for i, v := range b {
		fmt.Print(v)
		if i < len(b)-1 {
			fmt.Print(" ")
		} else {
			fmt.Println()
		}
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	b, count := SelectionSort(a)
	printArray(b)
	fmt.Println(count)
}



Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

long long int INF = 1e18;
int const TREE_SIZE = 1 << 21;
long long int seg_tree[TREE_SIZE] = {};
long long int c_diff[TREE_SIZE] = {}; // 子との差

// [a, b) の最小値を求める
// find(a, b + 1, 1, 0, 0, TREE_SIZE / 2)
long long int find(int a, int b, int index, long long int diff, int l, int r){
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		return INF;
	}
	if(a <= l && r <= b){
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, find(a, b, index * 2, c_diff[index], l, (l + r) / 2));
	ret = min(ret, find(a, b, index * 2 + 1, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	return ret;
}

// [a, b) に num を足す
// add(a, b + 1, 1, num, 0, 0, TREE_SIZE / 2);
long long int add(int a, int b, int index, long long int num, long long int diff, int l, int r){
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		return seg_tree[index];
	}
	if(a <= l && r <= b){
		seg_tree[index] += num;
		c_diff[index] += num;
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, add(a, b, index * 2, num, c_diff[index], l, (l + r) / 2));
	ret = min(ret, add(a, b, index * 2 + 1, num, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	return seg_tree[index] = ret;
}

int main(){
	
	int n, q;
	cin >> n >> q;
	
	for(int loop = 0; loop < q; loop++){
		long long int num, s, t, x;
		cin >> num;
		if(num == 0){
			cin >> s >> t >> x;
			add(s, t + 1, 1, x, 0, 0, TREE_SIZE / 2);
		}else{
			cin >> s >> t;
			cout << find(s, t + 1, 1, 0, 0, TREE_SIZE / 2) << endl;
		}
	}
	
	return 0;
}



Measured memory_bytes: 6268
# a,bが小さい
# 合計のa,bでdp

import numpy as np

N,MA,MB = map(int,input().split())
U = N*10

dp = np.zeros((U+1,U+1),dtype=np.int64)
temp = np.zeros_like(dp)

INF = 10**18
dp += INF
dp[0,0] = 0

for _ in range(N):
  a,b,c = map(int,input().split())
  temp[:] = dp.copy()
  temp[a:,b:] = np.minimum(temp[a:,b:], dp[:-a,:-b]+c)
  dp = temp
  
answer = INF
for t in range(1,401):
  a = MA*t
  b = MB*t
  if max(a,b) >= U:
    break
  answer = min(answer,dp[a,b])

if answer == INF:
  answer = -1
  
print(answer)


Measured memory_bytes: 17496
fn main() {
    let s = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    };

    let t = {
        let mut t = String::new();
        std::io::stdin().read_line(&mut t).unwrap();
        t.trim_right().to_owned()
    };

    let n = {
        let mut ws = s.split_whitespace();
        let n: i64 = ws.next().unwrap().parse().unwrap();
        n
    };

    let mut a = {
        let mut ws = t.split_whitespace();

        let mut a : Vec<i64> = Vec::new();
        for i in ws {
            a.push(i.parse().unwrap());
        }
        a
    };

    let mut sum : i64 = 0;

    for i in 0..(n - 1) as usize  {
        if a[i + 1] < a[i] {
            sum += a[i] - a[i + 1];
            a[i + 1] = a[i];
        }
    }

    //println!("{:?}", a);

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


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

int main () {
  long N, M;
  cin >> N >> M;
  long ans;
  if (N >= 2 && M >= 2) ans = (N-2)*(M-2);
  else if (N == 1 && M >= 2) ans = M-2;
  else if (N >= 2 && M == 1) ans = N-2;
  else ans = 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int,input().split()))
count = 0
for i in range(N):
    if i != N-1 and P[i] == i+1:
        P[i],P[i+1]=P[i+1],P[i]
        count += 1
if P[N-1] == N:
    count += 1
print(count)

Measured memory_bytes: 13880
s = input()
ss = []

tmp = ''
for i in range(len(s)-1):
    tmp += s[i]
    if s[i] == 'L' and s[i+1] == 'R':
        ss.append(tmp)
        tmp = ''
ss.append(tmp+'L')

ans = []
for sss in ss:
    l = len(sss)
    for i in range(l):
        if sss[i] == 'R' and sss[i+1] == 'L':
            ri = i
            break
    rn = ri//2 + 1 + (l-ri-1)//2
    ln = l-rn
    for i in range(l):
        if i == ri:
            ans.append(rn)
        elif i == (ri+1):
            ans.append(ln)
        else:
            ans.append(0)
print(*ans)


Measured memory_bytes: 9456
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string S, T; cin >> S >> T;
    int A, B; cin >> A >> B;
    string U; cin >> U;

    if (S == U) --A;
    else if (T == U) --B;

    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	long long n ,sum =0, max= -20000000, min =20000000;
	cin >>n;
	int test[n];
	for (int i =1; i<n+1;i++){
		cin >>test[i];
		sum +=test[i];
		if(max < test[i]){
			max =test[i];
		}
		if(min >test[i]){
			min = test[i];
		}

	} 
	cout <<min <<" "<<max<<" " <<sum<<"\n";
	return 0;

}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
#define ll                long long int
#define ld                long double
#define pb                push_back
#define pf                push_front
#define ppb               pop_back
#define ppf               pop_front
#define sz                size()
#define pi                acos(-1.0)
#define mod               1000000007
#define F                 first
#define S                 second
#define C                 continue
#define G                 goto done
#define maxe              max_element
#define mine              min_element
#define min3(a,b,c)       min(a,min(b,c))
#define max3(a,b,c)       max(a,max(b,c))
#define min4(a,b,c,d)     min(a,min(b,min(c,d)))
#define max4(a,b,c,d)     max(a,max(b,max(c,d)))
#define mem(a,b)          memset(a,b,sizeof(a))
#define all(a)            (a).begin(),(a).end()
#define gcd(a,b)          __gcd(a,b)
#define lcm(a,b)          ((a)*((b)/gcd(a,b)))
#define case(a)           cout<<"Case "<<(a)<<": "
#define point(a)          fixed<<setprecision(a)
#define get(a)            for(auto &x:a) cin>>x
#define print(a)          for(auto x:a) cout<<x<<" "; cout<<endl
#define see(x)            cout<<#x<<" = "<<x<<endl
#define uniq(a)           sort(all(a)); (a).erase(unique((a).begin(),(a).end()),(a).end())
#define big(a)            transform((a).begin(),(a).end(),(a).begin(),::toupper)
#define small(a)          transform((a).begin(),(a).end(),(a).begin(),::tolower)
#define ischar(a)         (('a'<=a&&a<='z')('A'<=a&&a<='Z'))
#define isvowel(a)        (a=='a'||a=='e'||a=='i'||a=='o'||a=='u'||a=='A'||a=='E'||a=='I'||a=='O'||a=='U')
#define fast              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define tc                int test; cin>>test; while(test--)
using namespace std;
int main()
{
    ll a,b,c,d; cin>>a>>b>>c>>d;
    ll m1=a*c;
    ll m2=a*d;
    ll m3=b*c;
    ll m4=b*d;
    cout<<max({m1,m2,m3,m4});
}




















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

public class Main {
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

	public static void main(String[] args) throws IOException {
		String[] hw = br.readLine().split(" ");
		int h = Integer.parseInt(hw[0]);
		int w = Integer.parseInt(hw[1]);

		int[][] c = new int[10][10];
		for(int i = 0; i < 10; i++) {
			String[] currLine = br.readLine().split(" ");
			for(int j = 0; j < 10; j++) {
				c[i][j] = Integer.parseInt(currLine[j]);
			}
		}

		int[][] a = new int[h][w];
		for(int i = 0; i < h; i++) {
			String[] currLine = br.readLine().split(" ");
			for(int j = 0; j < w; j++) {
				a[i][j] = Integer.parseInt(currLine[j]);
			}
		}

		// int[][] dist = new int[10][10];
		for (int k = 0; k < 10; k++)   {  
	        for (int i = 0; i < 10; i++)  {  
	            for (int j = 0; j < 10; j++) {  
	                if (c[i][k] + c[k][j] < c[i][j])  
	                    c[i][j] = c[i][k] + c[k][j];  
	            }  
	        }  
	    }

	    int ans = 0;

	    for(int i = 0; i < h; i++) {
	    	for(int j = 0; j < w; j++) {
	    		if(a[i][j] != -1 && a[i][j] != 1) {
	    			ans += c[a[i][j]][1];
	    		}
	    	}
	    }

	    System.out.println(ans);
	}
}

Measured memory_bytes: 26196
#include <stdio.h>
 
int main() {
  long long int N;
  long long int i;
  long long int ans = 1;
  
  scanf("%d", &N);
  for(i = 1; i <= N; i++) {
    ans *= i;
    ans %= 1000000007;
  }
  
  printf("%d\n", ans);
  
  return 0;
}

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

using namespace std;

int n;
long long A, B;

const int maxn = 100010;
const int mod = 1e9 + 7;
long long S[maxn];

struct arr {
	int a[maxn];
	int s[maxn];
	int cur;
	int last;
	void ins(int val) {
		int i = cur++;
		s[i] = a[i] = val;
		if(i) (s[i] += s[i-1]) %= mod;
	}
	void clear() {
		for(int i = last; i < cur; ++i)
			a[i] = s[i] = 0;
		last = cur;
	}
} ax, ay;

int main() {
	scanf("%d", &n); scanf("%lld", &A); scanf("%lld", &B);
	for(int i = 1; i <= n; ++i) scanf("%lld", &S[i]);

	int lx = 0, ly = 0;
	ax.ins(1); ay.ins(1);

	for(int i = 2; i <= n; ++i) {
		while(S[i] - S[lx + 1] >= A) ++lx;
		while(S[i] - S[ly + 1] >= B) ++ly;
		int fx = ay.s[min(i-2, lx)];
		int fy = ax.s[min(i-2, ly)];
		if(lx != i-1) ax.clear();
		if(ly != i-1) ay.clear();
		ax.ins(fx);
		ay.ins(fy);
	}

	long long ans = ax.s[n-1] + ay.s[n-1];
	cout << ans % mod << endl;
	return 0;
}


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

int main()
{    int n; cin>>n; int arrx[n]; int arry[n]; int temp; 
    for (int i = 0; i < n; ++i)
     {
      cin>>arrx[i]>>arry[i];
     } 
   int min=arry[0];
     int index=arrx[0];
 for (int i = 0; i < n; ++i)
 {
  if(arry[i]<min){min=arry[i]; index=arrx[i];}

 }
cout<<min+index;
    return 0;
}  



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

int main(){
  int e;
  while(cin >> e, e){
    int num;
    int ans = 1e9;
    for(int i = 0; i < e; i++){
      if(i * i * i > e)break;
      for(int j = 0; j < e; j++){
        num = e - i * i * i - j * j;
        if(num < 0)break;
        ans = min(ans, num + i + j);
      }
    }
    cout << ans << endl;


  }
}

Measured memory_bytes: 3048
#include<stdio.h>

int main(void)
{
	int i,j,N, a[100],A,B,max,M;

	scanf("%d", &N);

	for (i = 0; i < N; i++)
		scanf("%d", &a[i]);

	A = 0;
	B = 0;

	for (i = 0; i < N; i++)
	{
		max = 0;

		for (j = 0; j < N; j++)
		{
			if (a[j]>max)
			{
				max = a[j];
				M = j;
			}
		}
		a[M] = 0;
		if (i % 2 == 0)
			A += max;
		else
			B += max;
	}

	printf("%d\n", A-B);

	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String args[]) {

		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();

		int T = Integer.parseInt(s.split(" ")[0]);
		int X = Integer.parseInt(s.split(" ")[1]);

		Double ans = (double)T/(double)X;

		System.out.println(ans);
	}

}

Measured memory_bytes: 25172
import sys

L = sys.stdin.readline().strip()
mod = 10**9 + 7
ls = len(L)

# 左からi桁目で、L以下が確定しているかどうかTrue/ 一致している False の場合の(a, b)の組み合わせの総数
dp = [[0 for i in (True, False)] for _ in range(ls)]
# 1からしか始まらない
dp[0][False] = 2
dp[0][True] = 1

for i in range(ls-1):
    for j in (True, False):
        if L[i+1] == "1":
            dp[i+1][True] = 3 * dp[i][True] + 1 * dp[i][False]
            dp[i+1][False] = 2 * dp[i][False]
        else:
            dp[i+1][True] = 3 * dp[i][True]
            # dp[i+1][False] = 1 * dp[i][False]
            dp[i+1][False] = 1 * dp[i][False]
        dp[i+1][True] %= mod
        dp[i+1][False] %= mod

# print(dp)
print(sum(dp[ls-1]) % mod)

Measured memory_bytes: 86176
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <stdio.h>
using namespace std;

// GCD and LCM(0005)
int GCD(int a, int b)
{
	if (b == 0)
		return a;
	return GCD(b, a%b);
}

int main()
{
	int a, b;
	while (cin >> a >> b) {
		int g = GCD(a, b);
		cout << g << " " << a / g * b << endl;
	}
	return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
#define ALL(a)  (a).begin(),(a).end()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N; cin >> N;
    vector<int> L(N);
    REP(i, N) {
        cin >> L[i];
    };
    SORT(L);
    int a, b, c;
    int ans = 0;
    for(int i = N - 1; i >= 2; i--) {
        a = L[i];
        for(int j = i - 1; j >= 1; j--) {
            b = L[j];
            for(int k = j - 1; k >= 0; k--) {
                c = L[k];
                if (a < b + c) {
                    ans++;
                } else {
                    break;
                }
            }
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<string.h>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int f[600][600],sum[600][600];
int main()
{
    memset(sum,0,sizeof(sum));
    memset(f,0,sizeof(f));
    int n,m,q,i,j;
    scanf("%d%d%d",&n,&m,&q);
    for (i=1;i<=m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        f[a][b]++;
    }
    for (i=1;i<=n;i++)
    {
        for (j=1;j<=n;j++)
           sum[i][j]=sum[i][j-1]+sum[i-1][j]-sum[i-1][j-1]+f[i][j];
    } 

    for (i=1;i<=q;i++)
    {
        int a,b,ans;
        scanf("%d%d",&a,&b);
        ans=sum[b][b]+sum[a-1][a-1]-sum[a-1][b]-sum[b][a-1];
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 3712
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>

using namespace std;



string sum(string& a, string& b){
	int i = a.length() - 1;
	int j = b.length() - 1;
	int carry = 0;
	string temp;

	while(i >= 0 && j >= 0){
		temp.push_back((a[i] + b[j] + carry - 2*'0') % 10 + '0');
		carry = (a[i] + b[j] - 2*'0') / 10;
		--i, --j;
	}

	string& longer = i > j ? a : b;
	int& index = i > j ? i : j;
	while(index >= 0){
		temp.push_back((longer[index] + carry - '0') % 10 + '0');
		carry = (longer[index] + carry - '0') / 10;
		--index;
	}

	if(carry){
		temp.push_back('1');
	}

	reverse(begin(temp), end(temp));

	return temp;
}

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

	vector<string> input(n*2);

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

	for(int i = 0; i < n; i++){
		string t = sum(input[2*i], input[2*i+1]);
		if(t.size() <= 80)
			cout << t << endl;
		else
			cout << "overflow" << endl;
	}


	return 0;
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
using p = pair<int,int>;
using pp = pair<p,int>;
using ll = long long;
const auto INF =(ll)1e5;
int main(){
  int n;
  cin >> n;
  auto a = vector<int>(INF,0);
  for (int i = 0; i < n; i++)
  {
    int t;
    cin >> t;
    a[t-1]=i+1;
  }
  
  for (int i = 0; i < n; i++)
  {
    cout << a[i]<<" ";
  }
  

  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main(){
    cin>>N>>S;
    bool yes = (N+1)%2;
    rep(i,N/2){
        if(S[i] != S[i + N/2]) yes = false;
    }
    cout<<(yes ? "Yes" : "No")<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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 n, k;

int main(void){
    cin >> n >> k;
    vector<lli> a(n);
    rep(i, n){
        cin >> a[i];
        a[i]--;
    }
    lli now = 0;
    lli c;
    lli d;

    if(k < 1e6){
        while(k > 0){
            now = a[now];
            k--;
        }
        cout << now+1 << endl;
        return 0;
    }
    vector<lli> seen(n, -1);
    seen[now] = 0;
    while(1){
        lli nx = a[now];
        if(seen[nx] != -1){
            c = seen[now]-seen[nx]+1;
            d = seen[nx];
            break;
        }
        seen[nx] = seen[now]+1;
        now = nx;
    }
    lli t = d + (k-d)%c;
    now = 0;
    while(t--){
        now = a[now];
    }
    cout << now + 1 << endl;
    return 0;
}


Measured memory_bytes: 6308
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}

ll dp[210000][13];

void add(long long &a, long long b) {
  a += b;
  if (a >= MOD) a -= MOD;
}

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

  string S;
  cin >> S;
  memset(dp, 0, sizeof(dp));
  dp[0][0] = 1;
  REP(i, S.size()) {
    int c;
    if(S[i] == '?') c = -1;
    else c = S[i] - '0';

    REP(j, 10) {
      if(c != -1 && c != j) continue;
      REP(k, 13) {
        dp[i+1][(k*10+j)%13] += dp[i][k];
      }
    }
    REP(j, 13) dp[i+1][j] %= MOD;
  }  

  cout << dp[S.size()][5] << endl;

  return 0;
}


Measured memory_bytes: 21840
#include<bits/stdc++.h>
#define p 3.14159265358979323846L

using namespace std;

vector<int>adj[100001];
bool visited[100001];
int elevation[100001];
int res[100001];

void bfs(int ind)
{
    if(adj[ind].size()==0)
    {
        res[ind]++;
        return;
    }
    for(auto to:adj[ind])
    {
        if(elevation[ind]>elevation[to])
            res[ind]++;
        else
        {
            res[ind]=0;
            return;
        }
    }
}

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

    int n,m;
    cin>>n>>m;

    for(int i=1;i<=n;i++)
        cin>>elevation[i];

    while(m--)
    {
        int u,v;
        cin>>u>>v;

        adj[u].push_back(v);
        adj[v].push_back(u);
    }


    for(int i=1;i<=n;i++)
        bfs(i);
        int r=0;
    for(auto x:res)
        if(x)
        r++;

    cout<<r<<endl;
    return 0;
}


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

int main(){
    string S, T, U;
    int A, B;
    cin >> S >> T >> A >> B >> U;
    if (S==U) {
        cout << A-1 << " " << B << endl;
    }else{
        cout << A << " " << B-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    vector<int> arr(len);
    bool ok = false;
    for(int i = 0; i < len; i++) {
        cin >> arr[i];
        if(arr[i] == 2)
            ok = true;
    }
    if(!ok) {
        cout << -1;
        return 0;
    }
    int ans = 0, i = 0;
    set<int> seen;
    while(i != 1) {
        i = arr[i] - 1;
        if(seen.count(i)) {
            cout << -1;
            return 0;
        }
        seen.insert(i);
        ans += 1;
    }
    cout << ans;
}

Measured memory_bytes: 8200
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#define ll long long
#define rep(i, a, b) for(int i = a; i <= b; i++)
void read(int &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
void read(ll &x) {
    x = 0; int flag = 1; char ch = ' ';
    while(ch < '0' || ch > '9') { if(ch == '-') flag = -1; ch = getchar(); }
    while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
    x *= flag;
}
using namespace std;
const int maxn = 110;
int n, w, weight[maxn], value[maxn];
ll dp[100010];
int main()
{
    read(n), read(w);
    rep(i, 1, n) read(weight[i]), read(value[i]);
    rep(i, 1, n)
        for(int j = w; j >= weight[i]; j --)
            dp[j] = max(dp[j], dp[j - weight[i]] + value[i]);
    printf("%lld\n", dp[w]);
    return 0;
}

Measured memory_bytes: 1024
use std::io;

/// 一行を読み込んで、空白で区切ったベクタにして返す
#[allow(dead_code)]
fn read<T>() -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim()
        .split_whitespace()
        .map(|s| s.parse().unwrap())
        .collect()
}

/// n行を読み込んで、数字を空白で区切って二次元のベクタにして返す
#[allow(dead_code)]
fn read_table<T>(n: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut ret: Vec<Vec<T>> = Vec::new();
    for _ in 0..n {
        ret.push(read::<T>());
    }
    ret
}

/// n行を読み込んで、1文字ずつを二次元のベクタにして返す
#[allow(dead_code)]
fn read_char_table(n: usize) -> Vec<Vec<char>> {
    let mut ret: Vec<Vec<char>> = Vec::new();
    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        let chr = buf.trim().chars().collect();
        ret.push(chr);
    }
    ret
}

/// n行を読み込んで、一次元のベクタにして返す
#[allow(dead_code)]
fn read_array<T>(n: usize) -> Vec<T>
where
    T: std::str::FromStr,
    T::Err: std::fmt::Debug,
{
    let mut array = Vec::new();

    for _ in 0..n {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        array.push(buf.trim().parse().unwrap());
    }
    array
}

fn main() {
    // 数値
    let (d, n) = {
        let i = read::<u32>();
        (i[0], i[1])
    };

    let mut ns = n;
    if ns == 100 {
        ns += 1;
    }

    let ans = ns * 100_u32.pow(d);

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
        {
            for (int k = 1; k <= n; k++)
            {
                sum += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << sum;
}

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

#define all(v)   v.begin(), v.end()
#define endl "\n";
#define pb push_back
#define F first
#define S second
#define JULEE_DO_THE_THING fast()
#define to_str to_string
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMIN INT_MIN
#define IMAX INT_MAX
#define pow POW

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double dd;
typedef string str;
typedef vector<int> vecint;
typedef vector<ll> vecll;
typedef pair<int, int> pii;

void fast() {
	cin.tie(0);
	cout.tie(0);
	cin.sync_with_stdio(0);
}

bool compare(int &a, int &b) {
	return a > b;
}

ll numOfDigits(ll n) {
	if (!n)
		return 1;
	return (ll) (log10(n)) + 1;
}

ull POW(ll a, ll b);

/*

 */

ll BN();

int main() {
	JULEE_DO_THE_THING;
	//freopen("test cases\\.txt", "r", stdin) ;
    int n; cin>>n;
    map<str, int> mp;
    ll sum = 0;
    for(int i =0; i<n; i++){
        str s; cin>>s;
        sort(all(s));
        mp[s]++;
    }
    for(auto &it: mp){
        ll x = it.S;
        sum += x*(x-1)/2;
    }
    cout<<sum;
	return 0;
}

ll BN() {
	ll low = 0;
	ll up = 0;
	ll ans = 0;
	while (low <= up) {
		ll mid = ((low + up) / 2);
		if (mid) {
			ans = mid;
			low = mid + 1;
		} else
			up = mid - 1;
	}
	return ans;
}

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


Measured memory_bytes: 11264
n=int(input())
l=list(map(int,input().split()))
d=[l[0]]
for i in range(n-1):
    if(l[i]>=l[i-1]):
        d.append(l[i])
    else:
        d[i]=l[i]
        d.append(l[i])
print(sum(d))


Measured memory_bytes: 61844
#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef int64_t  ll;
typedef uint64_t ull;

int n, m;
int lights[10][11];
int sw[10];
int conds[10];
int ans;

void count() {
    int i, j, sum;
    for (i = 0; i < m; i++) {
        sum = 0;
        j = 0;
        while (lights[i][j] != 0) {
            if (sw[lights[i][j]-1] == 1) sum++;
            j++;
        }
        if (sum%2 != conds[i]) return;
    }
    ans++; return;
}

void solve(int i) {
    if (i == n-1) count();
    else {
        i++;
        sw[i] = 0;
        solve(i);
        sw[i] = 1;
        solve(i);
    }
}

int main(void) {
    int i, j, k;
    cin >> n >> m;
    for (i = 0; i < m; i++) {
        cin >> k;
        for (j = 0; j < k; j++) {
            cin >> lights[i][j];
        }
    }
    for (i = 0; i < m; i++) {
        cin >> conds[i];
    }
    sw[0] = 0;
    solve(0);
    sw[0] = 1;
    solve(0);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from functools import lru_cache

def almost_everywhere_zero():
    N=int(input())
    K=int(input())
    print(f(N,K))
    
@lru_cache(None)
def f(n,k):
    if n<=10:
        if k==0:
            return 1
        if k==1:
            return n
        return 0
    div_n=n//10
    mod_n=n%10
    ans=f(div_n,k-1)*mod_n + f(div_n-1,k-1)*(9-mod_n) + f(div_n,k)
    return ans


almost_everywhere_zero()


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

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String input = scan.nextLine();
		char[] board = input.toCharArray();
		int totalPlacements = 0;
		char current = board[0];
		for (int i = 1; i < board.length; i++) {
			if (board[i] != current) {
				totalPlacements++;
				current = board[i];
			}
		}
		System.out.println(totalPlacements);
		
	}
	
	
}

Measured memory_bytes: 26308
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;



int main(int argc, const char* argv[]){
    int N;

    cin >> N;
    bool flag = false;
    int sameCount = 0;
    for(int i = 0; i < N; i++){
        int d1 = 0;
        int d2 = 0;
        cin >> d1 >> d2;
        if(d1 == d2){
            sameCount++;
        } else{
            sameCount = 0;
        }
        if(sameCount >= 3){
            flag = true;
        }
    }
    
    if(flag){
        cout << "Yes" << endl;
    } else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
n,m=map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for j in range(m)]

for x in range(n):
    e = []
    for y in range(m):
        e.append(abs(ab[x][0]-cd[y][0]) + abs(ab[x][1]-cd[y][1]))

    print(e.index(min(e))+1)

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


int main(){
    int n, ans = 0;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        ans += a-1;
    }
    cout << ans << endl;
}


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

static const int MAX = 200000;

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a + b + c < 22) {
    cout << "win" << endl;
  } else {
    cout << "bust" << endl;
  }
}


Measured memory_bytes: 3648
k=int(input())
n=0
a=0
ss=0
if k==7:
  print(1)
elif k%2==0:
  print(-1)
elif k%5==0:
  print(-1)
else:
  while a==0:
    n+=1
    ss=10*(ss%k)+7
    if ss%k==0:
      a=1
  if a==1:
    print(n)
  else:
    print(-1)
   


Measured memory_bytes: 63164
"use strict";
    
const main = arg => {
    arg = arg.split("\n");
    const N = parseInt(arg[0]);
    const S = arg[1].split("");
    
    const R = S.filter(n=>n==="R").length;
    const B = S.filter(n=>n==="B").length;

    console.log(R > B ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include<iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout<< "YES"<<endl;
#define No cout<< "No"<<endl;
#define Yes cout<< "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<int,int>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main(){
    
    double num[1000];
    int n;
    double sum;
    
    cin >> n;
    rep(i,n){
        cin >> num[i];
        if(i==0){
            sum=num[i];
        }else{
            sum=sum*num[i];
        }
    }
    
    double b;
    b=sum/num[0];
    for(int i=1;i<n;i++){
        b+=sum/num[i];
    }
    
    cout << sum/b<<endl;
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int i = 1;
    while (i <= 5)
    {
        int a;
        cin >> a;
        if (a == i)
        {
            i++;
            continue;
        }
        else if (a == 0)
        {
            cout << i << endl;
            break;
        }
        else
        {
            i++;
            continue;
        }
    }
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;
typedef pair<int, int> pii;

int main(){
        ios_base::sync_with_stdio(false);
        int N;
        while(cin >> N){
                vector<pii> p(N);
                bool found[10] = { false };
                for(int i = 0; i < N; ++i){
                        int x;
                        cin >> x;
                        p[i] = pii(x / 10, x % 10);
                        found[p[i].first] = found[p[i].second] = true;
                }
                bool answer = false;
                vector<int> dp(1 << N);
                for(int begin = 0; !answer && begin < 10; ++begin){
                        if(!found[begin]){ continue; }
                        fill(dp.begin(), dp.end(), 0);
                        dp[0] |= (1 << begin);
                        for(int i = 0; i < (1 << N); ++i){
                                for(int j = 0; j < 10; ++j){
                                        if(!(dp[i] & (1 << j))){ continue; }
                                        for(int k = 0; k < N; ++k){
                                                if(i & (1 << k)){ continue; }
                                                int m = i | (1 << k);
                                                if(p[k].first == j){ dp[m] |= (1 << p[k].second); }
                                                if(p[k].second == j){ dp[m] |= (1 << p[k].first); }
                                        }
                                }
                        }
                        if(dp[(1 << N) - 1]){ answer = true; }
                }
                cout << (answer ? "Yes" : "No") << endl;
        }
        return 0;
}

Measured memory_bytes: 2300
def gcd(x, y):
    if y == 0:
        return x
    while y != 0:
        x, y = y, x % y
    return x

def lcm(x, y):
    return x * y // gcd(x, y)


def examC():
    N = I()
    T = [I() for _ in range(N)]
    ans = 1
    for t in T:
        ans = lcm(ans, t)
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 3444
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int main() {
	long long int n;
	cin >> n;
	cout << n * (n - 1) / 2 << endl;
}


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

// g++ -std=c++17 -O2 -Wall template.cpp -o template
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int tot = 0;
    for (auto &i : x) {
        tot += 2 * min(i, abs(i - k));
    }
    cout << tot << endl;

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n,m;
    n=2,m=3;
    vector<vector<char>>v(n,vector<char>(m));
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>v[i][j];
        }
    }
    bool no=false;
    for(int i=0;i<m;i++)
    {
            if(v[0][i]!=v[n-1][m-i-1])
        {
            no=true;
            break;
        }
    }
    if(no)
    {
        cout<<"NO"<<endl;
    }
    else
    {
        cout<<"YES"<<endl;
    }
}

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

int main(void){

    string S; cin>>S;
    int czero=0;
    int cichi = 0;
    for(int i:S){
        if(i == '0')czero++;
        else cichi++;
    }
    cout<<min(cichi, czero)*2
    <<endl;
    return 0;
}

Measured memory_bytes: 512