akhauriyash/Code-Regression huggingface dataset:
module WeightedDirectedGraph
  (Weight : sig
    type t
    val inf : t (* オーバーフローの恐れはないので，max_intとか突っ込んでも良い *)
    val zero : t
    val neg_inf : t (* オーバーフローの恐れはないので，min_intとか突っ込んでも良い *)
    val ( + ) : t -> t -> t
    val compare : t -> t -> int
  end) :
sig
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  val warshall_floyd :
    (* 頂点の数n *)
    int ->
    (* 辺のリスト *)
    (* 頂点は0からn-1までの整数でなくてはならない *)
    (int * int * Weight.t) church_list ->
    (* 辿り着けなければinf，負閉路を含む経路があればneg_infを返す関数 *)
    (int -> int -> Weight.t)
end =
struct
  type 'a church_list = { fold : 'b. ('a -> 'b -> 'b) -> 'b -> 'b }

  let warshall_floyd n es =
    let d = Array.make_matrix n n Weight.inf in
    for v = 0 to n - 1 do
      d.(v).(v) <- Weight.zero
    done;
    es.fold (fun (u, v, c) () ->
      (* c < d.(u).(v) *)
      if 0 < Weight.compare d.(u).(v) c
      then d.(u).(v) <- c) ();
    for i = 0 to n - 1 do
      for j = 0 to n - 1 do
        for k = 0 to n - 1 do
          let open Weight in
          if 
            (* 経路がない場合は更新しない *)
            0 < Weight.compare inf d.(j).(i)
            && 0 < Weight.compare inf d.(i).(k)
            (* d.(j).(i) + d.(i).(k) < d.(j).(k) *)
            && 0 < Weight.compare d.(j).(k) (d.(j).(i) + d.(i).(k))
          then d.(j).(k) <- d.(j).(i) + d.(i).(k)
        done
      done
    done;
    for i = 0 to n - 1 do
      (* 頂点iを通る負閉路がある *)
      if 0 < Weight.compare Weight.zero d.(i).(i) then
        for j = 0 to n - 1 do
          for k = 0 to n - 1 do
            (* 負閉路を通る経路があれば，最短距離を負の無限大で更新 *)
            let open Weight in
            if 0 < Weight.compare inf d.(j).(i) && 0 < Weight.compare inf d.(i).(k)
            then d.(j).(k) <- Weight.neg_inf
          done
        done
    done;
    fun u v -> try d.(u).(v) with _ -> Weight.inf
end

module G = WeightedDirectedGraph (struct
  type t = int
  let zero = 0
  let ( + ) = ( + )
  let inf = max_int
  let neg_inf = min_int
  let compare = compare
end)

let rec perm acc zs ys n xs =
  match n, xs with
  | 0, _ -> zs :: acc
  | _, [] -> acc
  | n, x :: xs -> perm (perm acc (x :: zs) [] (n - 1) (List.rev_append ys xs)) zs (x :: ys) n xs
let perm n = perm [] [] [] n
      
let () = Scanf.scanf "%d %d %d\n" @@ fun n m r ->
  let rs = Array.init r @@ fun _ -> Scanf.scanf "%d " pred in
  let abcs = Array.init m @@ fun _ -> Scanf.scanf "%d %d %d\n" @@ fun a b c -> a - 1, b - 1, c in
  let d = G.warshall_floyd n { G.fold = fun f -> Array.fold_right (fun ((a, b, c) as e) acc -> f (b, a, c) @@ f e acc) abcs } in
  Printf.printf "%d\n" @@
  List.fold_left (fun acc (r :: rs) ->
    min acc @@
    snd @@
    List.fold_left (fun (r, a) s -> (s, d r s + a)) (r, 0) rs) max_int @@
  perm r @@
  Array.to_list rs


Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin>>N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin>> S;
 
  
    if (S == "Y") {
     cout<< "Four"<<endl;
      break;
    }
   if(S!="Y" && i==N-1){
    cout << "Three" << endl;
   }
   }  
 
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {
//		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
//		String W	 = in.readLine();
//		int num = Integer.parseInt(W.split(" ")[0]);

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();




		System.out.println(A*B);

	}

	//	//二分探索
	//k <= num となる最小の配列要素kのインデックスを返す
	static private int binarySearch(long num, long[] orderedArray){
		int lowerBorder = -1;
		int upperBorder = orderedArray.length;
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedArray[mid]<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//二分探索
	//k <= num となる最小のList要素kのインデックスを返す
	static private int binarySearch(long num, ArrayList<Long> orderedList){
		int lowerBorder = -1;
		int upperBorder = orderedList.size();
		int mid;

		while(upperBorder - lowerBorder >1) {
			mid = (upperBorder + lowerBorder)/2;
			if(orderedList.get(mid)<=num) {
				lowerBorder = mid;
			}else {
				upperBorder = mid;
			}
		}
		return lowerBorder;
	}

	//aとbの最小公倍数を求める
	public static int gcd(int a, int b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}



}


Measured memory_bytes: 35664
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
typedef short int si;
typedef long long int ll;
typedef long int li;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<li,li> pli;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define linf LONG_MAX 
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define rb pop_back
#define rf pop_front
#define mkp make_pair
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define endl '\n'
const ll N=11;
ll mod=1e9+7;
signed main()
{
    fast;
    ll pro=1,temp,n,m,k,t,i,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=0,i1=-1,i2=-1;
    cin>>n;
    ll a[n+1],b[n+1];
    rep(i,1,n)
    {
        cin>>a[i];
    }
    rrep(i,n,1)
    {
        sum=0;
        for(j=i+i;j<=n;j+=i)
        {
            if(b[j])
            {
                sum++;
            }
        }
        sum%=2;
        b[i]=sum^a[i];
        if(b[i])
        {
            ans++;
        }
    }
    cout<<ans<<endl;
    for(i=1;i<=n;i++)
    {
        if(b[i])
        {
            cout<<i<<' ';
        }
    }
    return 0;
} 
 

Measured memory_bytes: 3968
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdbool.h>
#include<math.h>
#include<limits.h>
#define MAX 1000004
typedef long long ll;
int main(){
    ll N,prime_index=0,prime_seq[MAX]={0};
    bool prime_flag[MAX];    //素数ならtrue;
    for(ll i=2;i<MAX;i++) prime_flag[i]=true;
    scanf("%lld",&N);
    //素数列作るよ
    for(ll i=2;i<MAX;i++){
        if(!prime_flag[i]) continue;
        for(ll j=2;i*j<MAX;j++)
            prime_flag[i*j]=false;
    }
    for(ll i=2;i<MAX;i++)
        if(prime_flag[i]) prime_seq[prime_index++]=i;
    //素数列作り終わったよ
    prime_index--;
    //素因数分解始まるよ
    ll prime_fac[MAX]={0},ans=0;
    bool f=false;
    while(N!=1){
        ll i=0;
        while(N%prime_seq[i]!=0 && prime_index>i)i++;
        if(prime_index<=i){
            ans++;
            break;
        }
        N/=prime_seq[i];
        prime_fac[prime_seq[i]]++;
        f=true;
    }
    //素因数分解終わったよ
    //総和のテーブル作るよ
    ll table[100];
    table[1]=1;
    for(ll i=2;i<=100;i++)
        table[i]=table[i-1]+i;
    //総和のテーブル作り終わったよ
    for(ll i=0;i<prime_index;i++){
        if(!prime_fac[prime_seq[i]]) continue;
        ll j=1;
        while(table[j]<=prime_fac[prime_seq[i]]) j++;
        ans+=j-1;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 18304
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cstdio>
#include<cfloat>

using namespace std;

double EPS = 1e-10;

struct point{
  double x, y;
};

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double norm(point a){
  return sqrt(a.x*a.x+a.y*a.y);
}

int main(void){
  double D;
  point p,v;
 
  while(cin >> D,D){
  
    cin >> p.x >> p.y >> v.x >> v.y;
     
    double d=D+1;
    double cos=dot(p,v)/norm(p)/norm(v);

    if(abs(1.0 + cos) < EPS )d=norm(p);
    else if(abs(1.0 - cos) < EPS)d=2.0-norm(p);

    if(d<D || abs(d-D)<EPS)printf("%.8f\n",d);
    else cout << "impossible" << endl;
  }
 
  return 0;
}

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

const int INF = 1e9;
const int mod = 1e9+7;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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

    return 0;
}

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

using namespace std;
typedef long long int LL;
typedef long long int ll;
typedef pair<long long int, long long int> pii;
typedef pair<double, double> pdd;

#define SORT(c) sort((c).begin(),(c).end())
#define BACKSORT(c) sort((c).begin(),(c).end(),std::greater<LL>())
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SP << " " <<

LL mod = 1000000007;

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

  LL N;
  cin >> N;
  LL cnt = 0;
  FOR(i,1,N+1){
    LL j = N-i;
    if(i<j){
      cnt++;
    }
  }
  cout<<cnt<<endl;
}


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

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};


/////////////////////////////////////////////////////////////////////////////////////////
#define MAX 1e9
int dp[11][100000];
int main(){
    int d,g;
    cin >> d >> g;
    vector<int> p(d),c(d);
    for (int i = 0;i < d;i++){
        cin >> p[i] >> c[i];
    }

    long long ans = INF;
    for (int bit = 0;bit < (1 << d);bit++){
        long long sum = 0;
        long long solve = 0;
        for (int i = 0;i < d;i++){
            if (bit >> i & 1){
                sum += 100*(i+1)*p[i] + c[i];
                solve += p[i];
            }
        }
        if (sum >= g) ans = min(ans,solve);
        else {
            for (int i = d - 1;i >= 0;i--){
                if (bit >> i & 1){
                    continue;
                }
                for (int j = 0;j < p[i];j++){
                    if (sum >= g) break;
                    sum += 100*(i+1);
                    solve++;
                }
            }
            ans = min(ans,solve);
        }
    }

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

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

int main(){
    int N;
    cin >> N;
    ll ans = 0;
    rep(i,N){
        int a;
        cin >> a;
        if(i%2==0&&a%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
using namespace std;
static const int N=100;

int main(){
	int M[N][N]={};
	int n,u,k,v;
	
	cin>>n;
	
	for(int i=0;i<n;i++){
		cin>>u>>k;
		u--;
		for(int j=0;j<k;j++){
			cin>>v;
			v--;
			M[u][v]=1;
		}
	}
	
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j) cout<<" ";
			cout<<M[i][j];
		}
		cout<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define F first
#define S second
#define X real()
#define Y imag()
using namespace std;
typedef long long ll;
typedef long double ld;

vector<pair<int, ll> > g[202020];
int u[202020];
ll v[202020];

const int T=100010;
int f=0;
int i2=1;

void dfs(int x, int c, ll t){
	if (f!=0) return;
	//cout<<x<<" "<<t<<endl;
	if (u[x]==i2){
		if (v[x]>t){
			if (c==2){
				f=1;
			}
			else{
				f=2;
			}
		}
		else if(v[x]<t){
			if (c==2){
				f=2;
			}
			else{
				f=1;
			}
		}
		return;
	}
	u[x]=i2;
	v[x]=t;
	for (auto nx:g[x]){
		ll nt=nx.S-t;
		if (nt<0){
			if (c==1){
				f=2;//liian iso
			}
			else{
				f=1;
			}
			return;
		}
		dfs(nx.F, 3-c, nt);
	}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int r,c;
	cin>>r>>c;
	int n;
	cin>>n;
	for (int i=0;i<n;i++){
		int x,y,a;
		cin>>x>>y>>a;
		y+=T;
		g[y].push_back({x, a});
		g[x].push_back({y, a});
	}
	for (int i=1;i<=2*T;i++){
		if ((int)g[i].size()>0&&u[i]==0){
			ll mi=0;
			ll ma=1e18;
			int ok=0;
			while (mi<=ma){
				ll mid=(mi+ma)/2;
				f=0;
				i2++;
				dfs(i, 1, mid);
				if (f==0){
					ok=1;
					break;
				}
				if (f==1){
					mi=mid+1;
				}
				else{
					ma=mid-1;
				}
			}
			if (!ok){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
}

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

using namespace std;
int main(){

    int N; cin >> N;

    vector <int> D(N);
    for (int i = 0; i < N; i++) cin >> D[i];
    sort(D.begin(), D.end());

    int ans = D[(N / 2)] - D[(N / 2) - 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    val graph = Array(m) {
        readLine()!!.split(" ").map(String::toInt).let { it[0] to it[1] }
    }

    /**
     * 使用する前に昇順でソートしておく必要がある
     *
     * @param arr
     * @return
     */
    fun nextPermutation(arr: IntArray): Boolean {
        var i = arr.size - 1
        while (i > 0 && arr[i - 1] >= arr[i]) {
            i--
        }

        if (i <= 0) {
            return false
        }

        var j = arr.size - 1
        while (arr[j] <= arr[i - 1]) {
            j--
        }

        var temp = arr[i - 1];
        arr[i - 1] = arr[j];
        arr[j] = temp;

        j = arr.size - 1;
        while (i < j) {
            temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
            i++;
            j--;
        }

        return true;
    }

    val array = (2..n).toList().toIntArray()
    var count = 0
    loop@ do {

        val route = intArrayOf(1).plus(array)
        for (i in 0 until n - 1) {
            val c = route[i]
            val n = route[i + 1]
            if (!(graph.contains(c to n) || graph.contains(n to c))) {
                continue@loop
            }
        }
        count++
    } while (nextPermutation(array))
    println(count)
}

Measured memory_bytes: 41880
def test():

	points = input().split()

	x1 = float(points[0])
	y1 = float(points[1])
	x2 = float(points[2])
	y2 = float(points[3])

	output = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5

	print(f"{output:.8f}")

if __name__ == "__main__":
	test()


Measured memory_bytes: 5644
using System;

namespace ITP1
{
    class Program
    {
        static void Main(string[] args)
        {           
            while (true)
            {
                string str = Console.ReadLine(); 
                if (str == "-") break;

                int m = int.Parse(Console.ReadLine());
                char[] s = str.ToCharArray();
                char[] memo = new char[s.Length];

                for (int i = 0; i < m; i++)
                {
                    int h = int.Parse(Console.ReadLine());

                    for (int k = 0 ; k < s.Length; k++)
                    {                        
                        memo[k] = s[k];
                    }
                    for (int k = h; k < s.Length; k++)
                    {
                        s[k - h] = memo[k];
                    }
                    for (int k = 0; k < h; k++)
                    {
                        s[s.Length - h + k] = memo[k];
                    }
                }
                Console.WriteLine(s);
            }
          
        }
    }
}

Measured memory_bytes: 8964
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define endl                         '\n'	
#define Ceil(x,y)             ((x+y-1)/y)
#define sz(s)               (int)s.size()
#define RT(x)           return cout<<x,0;
#define mem(x,y)    memset(x,y,sizeof(x))
#define all(v) ((v).begin()), ((v).end())
#define vi                    vector<int>
#define fr(x,y) for(int x=0; x<(y); ++x)
#define fr2(x,z,y) for(int x=z; x<(y); ++x)
#define Rabee_Adel          file();
const double PI = acos(-1), EPS = 1e-7;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
ll gcd(ll x, ll y) { return (!y) ? x : gcd(y, x%y); }
ll lcm(ll x, ll y) { return ((x / gcd(x, y))*y); }
ll mod = 998244353;
ll power(ll x, ll y){if (y == 0)return 1;if (y == 1)return x;ll r = power(x, y / 2) % mod;return r%mod*r%mod*power(x, y % 2) % mod;}
void file() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif  !ONLINEJUDGE
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

}
int main()
{

	Rabee_Adel
		cout << fixed << setprecision(2);
		int n;
		cin >> n;
		long double ans = (long double)PI*n*2;
		cout << ans;

	 
}

Measured memory_bytes: 3804
#include<bits/stdc++.h>
using namespace std;
long long int maxans(int n,int a[][3])
{
    long long int dp[n+1][3];
    dp[1][0]=a[0][0];
    dp[1][1]=a[0][1];
    dp[1][2]=a[0][2];
    for(int i=2;i<=n;i++)
    {
        for(int j=0;j<3;j++)
        {
            dp[i][j]=a[i-1][j]+max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3]);
        }
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));



}

int main()
{

    int n;
    cin>>n;
    int a[n][3];

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        cin>>a[i][j];
    }
    cout<<maxans(n,a);
    return 0;
}


Measured memory_bytes: 3712
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc := newScanner(os.Stdin)
	//var n, m int
	//fmt.Scan(&n, &m)
	n := sc.i()
	m := sc.i()
	var node [][]int = make([][]int, m+10)
	for i := 0; i < m; i++ {
		//var a, b int
		//fmt.Scan(&a, &b)
		a := sc.i()
		b := sc.i()
		node[a-1] = append(node[a-1], b-1)
		node[b-1] = append(node[b-1], a-1)
	}
	q := make([]int, 0, n+10)
	q = append(q, 0)
	ans := make([]int, n)
	for i := range ans {
		ans[i] = -1
	}
	for len(q) > 0 {
		x := q[0]
		q = q[1:]
		for _, dist := range node[x] {
			if ans[dist] == -1 {
				ans[dist] = x
				q = append(q, dist)
			}
		}
	}
	fmt.Println("Yes")
	for _, a := range ans[1:] {
		fmt.Println(a + 1)
	}
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

Measured memory_bytes: 16404
from sys import stdin
from itertools import product

suits = ['S', 'H', 'C', 'D']
suits_priority = {
    'S': 1,
    'H': 2,
    'C': 3,
    'D': 4
}
ranks = list(range(1, 14))

original_deck = set(product(suits, ranks))

if __name__ == '__main__':
    n = int(stdin.readline().rstrip())
    deck = set()
    for _ in range(n):
        suit, rank = stdin.readline().rstrip().split()
        deck.add((suit, int(rank)))

    diff = list(original_deck - deck)
    diff.sort(key=lambda x: x[1])
    diff.sort(key=lambda x: suits_priority[x[0]])

    for card in diff:
        print("{} {}".format(*card))



Measured memory_bytes: 5648
#include <bits/stdc++.h>
#define int long long int
#define endl "\n"
using namespace std;
void solve()
{
	//Enter your cod
	int n,sum=0;
	cin>>n;
	int arr[n];
	for(int i=0;i<n;i++)
	{
		cin>>arr[i];
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum=sum+(arr[i]*arr[j]);
		}
	}
	cout<<sum;
}
signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
S = str(input())

flag = True
N = len(S)

for i in range(N // 2):
    if S[i] != S[-1 * i-1]:
        #print(i,-1*i,S[i],S[-1 * i-1])
        flag = False

for i in range((N-1)//2-1):
    if S[i] != S[(N-1)//2-1-i]:
        #print(i, (N-1)//2-1-i, S[i], S[(N-1)//2-1-i])
        flag = False

for i in range((N+3)//2,N-1):
    if S[i] != S[-1 * i-1]:
        #print(i, (N-1)//2-1-i, S[i], S[(N-1)//2-1-i])
        flag = False

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 62012
#include<iostream>
#include<cstdio>

using namespace std;

int main(){
  int N, K;
  int res = 0;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    int curr;
    cin>>curr;
    if(curr>=K){
      res++;
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 888
import sys
N, L = map(int, input().split())
A = [int(_) for _ in input().split()]


for n in range(N - 1):
    if A[n] + A[n + 1] >= L:
        print('Possible')
        tmp_ind = n + 1
        for m in range(1, tmp_ind):
            print(m)
        for m in range(N - 1, tmp_ind, -1):
            print(m)
        print(tmp_ind)
        sys.exit()
print('Impossible')

Measured memory_bytes: 14596
const lines=readlines(open("/dev/fd/0"))
let
    state=0
    global input
    input()=lines[state+=1]
end
int(s::String)=parse(Int32,s)
intSub(s::SubString{String})=parse(Int32,s)
intLine()=map(intSub,split(input()))
function main()
    a,b,c=intLine()
    a,b,_=sort([abs(a-b),abs(b-c),abs(c-a)])
    println(a+b)
end
main()

Measured memory_bytes: 119880
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	var a, b, m int
	fmt.Scan(&a, &b, &m)

	amin := int(1e9)
	bmin := int(1e9)

	as := make([]int, a)
	for i := 0; i < a; i++ {
		// fmt.Scan(&as[i])
		as[i] = nextInt()
		amin = min(amin, as[i])
	}
	bs := make([]int, b)
	for i := 0; i < b; i++ {
		// fmt.Scan(&bs[i])
		bs[i] = nextInt()
		bmin = min(bmin, bs[i])
	}

	ans := amin + bmin
	// var x, y, c int
	for i := 0; i < m; i++ {
		// fmt.Scan(&x, &y, &c)
		x := nextInt()
		y := nextInt()
		c := nextInt()
		x, y = x-1, y-1

		p := as[x] + bs[y] - c

		ans = min(ans, p)
	}

	fmt.Println(ans)
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}


Measured memory_bytes: 4992
# -*- coding: utf-8 -*-

import sys
import os

def is_prime_list():
    N = 105000
    lst = [True] * N
    lst[0] = False
    lst[1] = False
    for i in range(2, int(N ** 0.5) + 1):
        if lst[i] == True:
            for j in range(2, N):
                index = i * j
                if index < N:
                    lst[i * j] = False
    return [i for i in range(2, N) if lst[i]]


primes = is_prime_list()
for s in sys.stdin:
    n = int(s)
    if n == 0:
        break

    subset = primes[:n]
    print(sum(subset))

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

int cmp_int(void *a, void *b);

int main(){
    int N, K, A, keys[200001] = {0}, NotZeroCnt = 0, ans = 0;
    scanf("%d %d", &N, &K);
    for(int i = 0; i < N; i++){
        scanf("%d", &A);
        keys[A]++;
    }
    for(int i = 0; i < 200001; i++){
        NotZeroCnt += (keys[i] != 0);
    }
    qsort(keys, 200001, sizeof(int), cmp_int);

    for(int i = 200000; NotZeroCnt > K; i--){
        if(keys[i] != 0){
            ans += keys[i];
            NotZeroCnt--;
        }
    }
    printf("%d\n", ans);
    return 0;
}

int cmp_int(void *a, void *b){
    return *(int*)b - *(int*)a;
}

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

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

  vector<bool> from1(N), toN(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 1) from1[b - 1] = true;
    if (b == N) toN[a - 1] = true;
  }

  string ans = "IMPOSSIBLE";
  for (int i = 0; i < N; i++) if (from1[i] == true && toN[i] == true) ans = "POSSIBLE";

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int c[N-1],s[N-1],f[N-1];
  for(int i=0;i<N-1;i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  for(int i=0;i<N;i++){
    int t = 0;
    for(int j=i;j<N-1;j++){
      if(t<s[j]){
        t = s[j];
        t += c[j];
      }else{
        int tmp = (t-s[j]+f[j]-1)/f[j];
        t = s[j] + tmp * f[j];
        t += c[j];
      }
    }
    cout << t << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker,"/STACK:36777216")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma,tune=native")
#include <bits/stdc++.h>
using namespace std;
#define itoc(c) (char)((int)'0' + c)
#define ctoi(c) (int)(c - '0')
#define all(x) (x).begin(), (x).end()
#define ff first
#define ss second
#define emb emplace_back
#define pb push_back

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;

const int oo = 1e9;
const int MOD = 1e9+7;
const int N = 2e5+5;

int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int n; cin>>n;
  string s; cin>>s;
  int cnt=0;
  for (int i=2; i<n; ++i) {
    if (s[i]=='C' && s[i-1]=='B' && s[i-2]=='A') ++cnt;
  }
  cout<<cnt;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define FOR(n) for(int i=0;i<n;i++)
#define FORJ(n) for(int j=0;j<n;j++)
#define PRN(n) printf("%d\n",n)
#define PRF(n) printf("%lf\n",n)
#define PRL(n) printf("%lld\n",n)
#define PRS(s) printf("%s\n",s)
#define PRC(c) printf("%c",c)
#define mod 1000000007
typedef long long int ll;
int u(const void *a, const void *b){
    return *(ll*)a-*(ll*)b;
}
int d(const void *a, const void *b){
    return *(ll*)b-*(ll*)a;
}
int min(int a,int b){
  if(a>b)return b;
  return a;
}
int max(int a,int b){
  if(a>b)return a;
  return b;
}
int gcd(int a,int b){
  if(!b)return a;
  return gcd(b,a%b);
}
int kt(ll a){
  int sum=0;
  while(a){
    a/=10;
    sum++;
  }
  return sum;
}
int ks(ll a){
  int sum=0;
  while(a){
    sum+=a%10;
    a/=10;
  }
  return sum;
}
int x[30];
int main(void){
  int n,m;
  scanf("%d %d",&n,&m);
  int a,b;
  FOR(n){
    scanf("%d",&b);
    FORJ(b){
      scanf("%d",&a);
      x[a-1]++;
    }
  }
  int cnt=0;
  FOR(m)if(x[i]==n)cnt++;
  PRN(cnt);
  return 0;
}


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

using namespace std;

typedef long long ll;

#define REP(i, n) for(int i=0; i<n; ++i)
#define FOR(i, a, b) for(int i=a; i<b; ++i)
#define FORR(i, a, b) for(int i=b-1; i>=a; --i)

int n;
ll c;
ll x[110000], v[110000], s[110000], a1[110000], a2[110000], b1[110000], b2[110000];
ll ans;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>c;
	REP(i, n){
		cin>>x[i+1]>>v[i+1];
		s[i+1]=s[i]+v[i+1];
		a1[i+1]=max(a1[i], s[i+1]-x[i+1]);
		a2[i+1]=max(a2[i], s[i+1]-x[i+1]*2);
	}
	FORR(i, 1, n+1){
		b1[n-i+1]=max(b1[n-i], s[n]-s[i-1]-(c-x[i]));
		b2[n-i+1]=max(b2[n-i], s[n]-s[i-1]-(c-x[i])*2);
	}
	REP(i, n+1) ans=max(ans, max(a1[i]+b2[n-i], a2[i]+b1[n-i]));
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    bool map[3][3];
    rep(i,3) rep(j,3) map[i][j] = false;

    int ta[3][3];
    rep(i,3) rep(j,3) cin >> ta[i][j];
    int n;cin >> n;
    rep(i,n){
        int b;cin>>b;
        rep(j,3) rep(k,3){
            if(b==ta[j][k]){
                map[j][k] = true;
            }
        }
    }
    bool ans = false;
    rep(i,3){
        if(map[i][1] && map[i][0] && map[i][2]){
            ans = true;
        }
        if(map[0][i] && map[1][i] && map[2][i]){
            ans = true;
        }
    }
    if(map[0][0] && map[1][1] && map[2][2]){
        ans = true;
    }
    if(map[0][2] && map[1][1] && map[2][0]){
        ans = true;
    }
    cout << (ans? "Yes":"No") << endl;
}

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

int use_alphabet[26];

int main()
{
	char index_begin = 'a';
	string input;
	cin >> input;

	int length = input.size();
	int index;
	for (int i = 0; i < length; i++) {
		index = input.at(i) - index_begin;
		use_alphabet[index] = 1;
	}

	int flag = 0;
	for (int i = 0; i < 26; i++) {
		if (use_alphabet[i] == 0) {
			flag = 1;
			cout << (char)(index_begin + i);
			break;
		}
	}

	if (flag == 0)
		cout << "None";

	return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <queue>
#include <vector>
#include <algorithm>
#include <tuple>

typedef std::tuple<int,int,int> T;

const int INF = 1001001001;

int N, M, E, S, T_, R;
int d[1<<8][100][100], dp[1<<8][101][10];
T events[8];
bool used[1<<8];

void rec(int s){
    if(used[s]){return;}
    used[s] = true;
    
    for(int i=0;i<E;i++){
        if(s >> i & 1){continue;}

        int ns = s | (1 << i);
        int a = std::get<0>(events[i]),
            b = std::get<1>(events[i]);
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                d[ns][j][k] = d[s][j][k];
            }
        }
        for(int j=0;j<N;j++){
            for(int k=0;k<N;k++){
                int nd = std::min(d[ns][j][a] + 1 + d[ns][b][k], d[ns][j][b] + 1 + d[ns][a][k]);
                if(nd > R){continue;}
                d[ns][j][k] = std::min(d[ns][j][k], nd);
            }
        }

        rec(ns);
    }
}

int rec2(int s, int day, int index){
    if(dp[s][day][index] != -1){return dp[s][day][index];}
    
    int u = index == E ? S : std::get<2>(events[index]);
    
    int res = INF;
    for(int i=0;i<E;i++){
        if(s >> i & 1){continue;}
        if(i == index){continue;}
        
        int c = std::get<2>(events[i]);
        if(day + d[s][u][c] <= R){
            res = std::min(res, d[s][u][c] + rec2(s | (1 << i), day + d[s][u][c], i));
        }
    }

    if(day + d[s][u][T_] <= R){
        res = std::min(res, d[s][u][T_]);
    }
    if(day > 0){
        res = std::min(res, rec2(s, 0, E) + 1);
    }

    return dp[s][day][index] = res;
}

int main(){
    scanf("%d %d %d %d %d %d", &N, &M, &E, &S, &T_, &R);

    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            d[0][i][j] = i == j ? 0 : INF;
        }
    }
    
    for(int i=0;i<M;i++){
        int a, b;
        scanf("%d %d", &a, &b);

        d[0][a][b] = 1;
        d[0][b][a] = 1;
    }

    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++){
                if(d[0][i][k] + d[0][k][j] > R){continue;}
                d[0][i][j] = std::min(d[0][i][j], d[0][i][k] + d[0][k][j]);
            }
        }
    }

    for(int i=0;i<E;i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);

        events[i] = std::make_tuple(a, b, c);
    }
    rec(0);
    
    for(int i=0;i<1<<E;i++){
        for(int j=0;j<=R;j++){
            for(int k=0;k<=E;k++){
                dp[i][j][k] = -1;
            }
        }
    }
    int res = rec2(0, 0, E);
    if(res < INF){printf("%d\n", res);}
    else{puts("-1");}
}

Measured memory_bytes: 12020
def replace(str):
    for i, c in enumerate(command[3], command[1]):
        str[i] = c
    return str

def reverse(str):
    for i, c in enumerate(reversed(str[command[1]: command[2]+1]), command[1]):
        str[i] = c
    return str

def str_print(str):
    str = ''.join(str)
    print(str[command[1]: command[2]+1])
    str = list(str)
    return str

str = list(input())
q = int(input())
for i in range(q):
    command = input().split()
    command[1], command[2] = int(command[1]), int(command[2])
    if command[0] == 'replace':
        str = replace(str)
    elif command[0] == 'reverse':
        str = reverse(str)
    else:
        str = str_print(str)



Measured memory_bytes: 5636
#include <stdio.h>

typedef long long ll;

int main(void) {
  ll n, k, ans = 0, i, j;
  scanf("%lld%lld", &n, &k);
  for(i = k + 1; i <= n; ++i) {
    ans += (n / i) * (i - k);
    if((n -(n / i) * i) - k + 1 > 0) ans += (n -(n / i) * i) - k + 1;
    if(!k) --ans;
    //printf("%lld\n", ans);
  }
  printf("%lld", ans);
  return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    // (sx,sy) -> (tx,sy) -> (tx,ty) -> (sx,ty) ->
    // (sx,sy) -> (sx-1,sy) -> (sx-1,ty+1) -> (tx,ty+1) ->
    // (tx,ty) -> (tx+1,ty) -> (tx+1,sy-1) -> (sx, sy-1) -> (sx, sy)
    for (int x = sx; x != tx; ++x) cout << 'R';
    for (int y = sy; y != ty; ++y) cout << 'U';
    for (int x = tx; x != sx; --x) cout << 'L';
    for (int y = ty; y != sy; --y) cout << 'D';
    for (int x = sx; x != sx - 1; --x) cout << 'L';
    for (int y = sy; y != ty + 1; ++y) cout << 'U';
    for (int x = sx - 1; x != tx; ++x) cout << 'R';
    for (int y = ty + 1; y != ty; --y) cout << 'D';
    for (int x = tx; x != tx + 1; ++x) cout << 'R';
    for (int y = ty; y != sy - 1; --y) cout << 'D';
    for (int x = tx + 1; x != sx; --x) cout << 'L';
    for (int y = sy - 1; y != sy; ++y) cout << 'U' << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const int MOD=1000000007;

int main(){
    ll n,k,ans;
    ans=0;
    cin>>n>>k;
    int i;
    string s;
    cin>>s;
    ll count=0;
    rep(i,n-1){
        if(s[i]==s[i+1] && i==n-2){
            count++;
            ans+=count;
        }else if(s[i]==s[i+1]){
            count++;
        }else{
            ans+=count;
            count=0;
        }
    }
    ans=min(ans+2*k,n-1);
    cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>//..1..2..3:Correct:Solved by F2tekkz:)
#define ll long long
#define str string
#define sonic ios_base::sync_with_stdio(0)
using namespace std;
ll n , m , k , i , j , t , q , cnt , cnt1 , cnt2 , cnt3;
ll cnt4 , cnt5 , ans , ans1 , ans2 , ans3 , sum , sum1 , sum2;
ll mini = 1e9 , maxi = -999;
int main(){
	sonic;
	cin >> n >> m;
	ll a[m];
	cnt = 0;
	for(ll i = 0 ; i < m ; i ++){
		cin >> a[i];
		cnt += a[i];
	}
	if(cnt >= n){
		cout << "Yes";
	}
	else{
		cout << "No";
	}
}
//     *    *  *  ****    *    *   *
//    *	*   * *   *      * *   *   *
//   *****  **    ****  *****  *****
//   *   *  * *      *  *   *      *
//   *   *  *  *  ****  *   *  *****

//   *  *  *****  *
//   * *     *    *
//   **      *    *
//   * *     *    *
//   *  *    *    ****

//   ****  ****  *       *
//   *      **   *      * *
//   ****   **   *     *****
//      *   **   *     *   *
//   ****  ****  ****  *   *


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] str = stdR.readLine().split(" ");
        int N = Integer.parseInt(str[0]);
        int M = Integer.parseInt(str[1]);
        int C = Integer.parseInt(str[2]);
        str = stdR.readLine().split(" ");
        int[] B = new int[M];
        for(int i = 0 ; i < M ; i++) {
            B[i] = Integer.parseInt(str[i]);
        }
        int[][] A = new int[N][M];
        for(int i = 0 ; i < N ; i++) {
            str = stdR.readLine().split(" ");
            for(int j = 0 ; j < M ; j++) {
                A[i][j] = Integer.parseInt(str[j]);
            }
        }
        int count = 0;
        for(int i = 0 ; i < N ; i++) {
            int num = 0;
            for(int j = 0 ; j < M ; j++) {
                num += A[i][j] * B[j];
            }
            num += C;
            if(num > 0)count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23508
#include <bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
#define debug(n) cout<<n<<endl
#define debug2(a, b) cout<<a<<" "<<b<<endl;
#define forn(i, in, fin) for(int i = in; i<fin; i++)
#define all(v) v.begin(), v.end()
#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
 
using namespace std;
 
vector< double > p;
vector< vector<double> > dp;
lli posibles;
lli n; 
 
double eps = 1e-9;
 
double f(lli index, lli taken)
{
    if(taken > posibles) return 0;
    if(index == n) return (double)1;

    if( dp[index][taken] != -1) return dp[index][taken];
 
    double actual = p[index];
    //dp[index][taken] = 1;
 
    return dp[index][taken] = f(index+1, taken) * actual + f(index+1, taken+1)*(1-actual);
}
 
 
 
int main()
{
    fastIO();
    cin>>n;
    p.resize(n);
    posibles = (n-1)/2;
    dp.assign(n, vector<double>(3000, -1));
    for(double &x: p)
        cin>>x;
    cout<< fixed << setprecision(10) << f(0,0) <<endl;
    return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;

signed main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string str; cin >> str;
    int n = str.size();
    str = "-" + str;

    bool able = (str[1] == '1') && (str[n] == '0');
    for (int i = 1; i < n; ++i) {
		if (str[i] != str[n-i]) able = 0;
	}
    if (!able) {
		cout << -1 << endl;
		return 0;
    }

    int prv = 1;
    for (int i = 2; i < n; ++i) {
        if (str[i] == '1') {
            for (int j = prv; j < i; ++j) {
                cout << j << ' ' << i << endl;
            }
            prv = i;
        }
    }
    cout << n-1 << ' ' << n << endl;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std; 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a) (a).begin(),(a).end()
#define ll long long
long long min(long long x,long long y){return (x<y ? x:y);}
long long max(long long x,long long y){return (x>y ? x:y);}
#define ld long double
int stoi(string s) {return atoi(s.c_str());}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
#define LINEY "YES\n"
#define Liney "Yes\n"
#define LINEN "NO\n"
#define Linen "No\n"

int main(){
  int a[3]; REP(i,3){cin>>a[i];}
  sort(a,a+3);
  if(a[0]==a[2]){printf(Liney);}
  else{printf(Linen);}
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int dp[1000020] = {};
int main() {
	int n;
	cin >> n;
	vector<int> s;
	long long int sum = 0;
	for (int i = 0; i < n; i++) {
		long long int a;
		cin >> a;
		s.push_back(a);
		sum = sum + a;
	}
	long long int ans = 100000000000000000;
	long long int sunuke = 0;
	for (int i = 0; i < n-1; i++) {
		sunuke = sunuke + s[i];
		sum = sum - s[i];
		ans = min(abs(sunuke - sum), ans);
	}
	cout << ans;
}

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

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main()
{
    int n,a[200000],i,j;
    scanf("%d",&n);
    for (i = 0; i < n; i++)
    {
        scanf("%d",&a[i]);
    }
    qsort(a,n,sizeof(int),asc);

    for (i = 0; i < n - 1; i++)
    {
        if(a[i] == a[i + 1])break;
    }
    if(i == n - 1)printf("YES");
    else printf("NO");
}


Measured memory_bytes: 1788
#include<stdio.h>

int main(void){
	int N,M,A[20],B[20],C,i,j,formula=0,count=0;
	scanf("%d %d %d¥n",&N,&M,&C);
	/* B入力 */
	for(i=0;i<M;i++){
		scanf("%d",&B[i]);
	}
	/* A入力 & 判定処理 */
	for(j=0;j<N;j++){
		for(i=0;i<M;i++){ //A入力部
			scanf("%d",&A[i]);
		}
		for(i=0;i<M;i++){ //計算
			formula=formula+A[i]*B[i];
		}
		if(formula+C>0){ //Cを加えた後、判定処理
			count++;
		}
		formula=0;
	}
	printf("%d",count);
	return 0;
}

Measured memory_bytes: 128
S=input()
T=input()
ls=len(S)
lt=len(T)

ans='UNRESTORABLE'

if ls<lt:
    print(ans)
    exit()
for i in range(ls-lt,-1,-1):
    c=0
    for j in range(lt):
        if T[j]==S[i+j] or S[i+j]=='?':
            continue
        else:
            c=1
            break
    if c==0:
        ans=S.replace('?','a')
        ans=ans[:i] + T + ans[i+lt:]
        break
print(ans)


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

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    auto x = readln.split.to!(int[]).sort().group.count;
    writeln(x == 2 ? "Yes" : "No");
}



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

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

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

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
from sys import stdout
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)


n = inn()
a = inl()
b = inl()
c = inl()
sum = 0
for i in range(n):
    sum += b[a[i-1]-1]
    if i<n-1 and a[i+1]==a[i]+1:
        sum += c[a[i]-1]
print(sum)


Measured memory_bytes: 3064
from math import *
from itertools import *
import sys

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx, cy in product(range(101), range(101)):
    flag = 1
    H = h + abs(cx - x) + abs(cy - y)
    for input_list in all_input_list:
        if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
            flag = 0
            break
    if (flag == 1):
        print("%s %s %s" % (cx, cy, H))
        sys.exit(0)

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
map<string,int> mp;
map<string,bool> mp1;
int a,MAX;
int main(){
	cin>>a;
	string s[200005];
	for(int i=1;i<=a;i++){
		cin>>s[i];
		mp[s[i]]++;
	}
	for(int i=1;i<=a;i++){
		MAX=max(MAX,mp[s[i]]);
	}
	sort(s+1,s+a+1);
	for(int i=1;i<=a;i++){
		if(mp[s[i]]==MAX&&!mp1[s[i]]){
			cout<<s[i]<<endl;
			mp1[s[i]]=true;
		}
	}
} 

Measured memory_bytes: 39296
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n, t;
    cin >> n >> t;
    vector<pair<ll, ll>> v(n+1);
    for (ll i = 0; i < n; ++i) {
        ll a, b;
        cin >> a >> b;
        v[i] = make_pair(a,b);
    }
    v[n] = make_pair(0, 0);

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

    // cerr << "Input:" << endl;
    // for (ll i = 0; i <= n; ++i ) {
    //     cerr << v[i].first << "," << v[i].second << endl;
    // }
    // cerr << endl;

    vector<vector<ll>> dp(n+1, vector<ll>(t, 0));
    ll ans = 0;
    for (ll i = 1; i <= n; ++i) {
        for (ll j = 0; j < t; ++j) {
            dp[i][j] = dp[i-1][j];
            ans = max(ans, v[i].second + dp[i-1][j]);
            if (j - v[i].first >= 0) {
                dp[i][j] = max(dp[i][j], dp[i-1][j - v[i].first] + v[i].second);
            }
        }

        // for (ll j = 0; j <= n; ++j ) {
        //     cerr << "dp[" << i << "][" << j << "] = " << dp[i][j] << endl;
        // }
        // cerr << endl;
    }
    cout << ans << endl;
    //ll m = 0;
    //for (ll i = 1; i <= n; ++i) {
    //    m = max(m, dp[i-1][t-1] + v[i].second);
    //}
    //cout << m << endl;

    return 0;
}


Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using i64 = long long;
using f64 = double;

#define FOR(i, s, n) for (size_t i = (s); i < (size_t)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

template <typename T, typename U>
inline bool chmax(T &a, U b) {
  return a < b ? (a = b, true) : false;
}

template <typename T, typename U>
inline bool chmin(T &a, U b) {
  return a > b ? (a = b, true) : false;
}

int main() {
  int n;
  cin >> n;
  auto vec = vector<int64_t>(n);
  for (auto &x : vec) {
    cin >> x;
  }

  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  auto max = vec.front();

  int half_down = n / 2;
  int half_up = n - half_down;
  
  auto sum = 0 - max;
  REP(i, half_up) {
    sum += vec[i];
  }
  REP(i, half_down) {
    sum += vec[i];
  }

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


Measured memory_bytes: 4440