akhauriyash/Code-Regression huggingface dataset:
import sys
from math import ceil

def input():
    return sys.stdin.readline().strip()

def iinput():
    return int(input())

def finput():
    return float(input())

def tinput():
    return input().split()

def rinput():
    return map(int, tinput())

def rlinput():
    return list(rinput())

def nok(a, b):
    m = a * b
    while a != 0 and b != 0:
        if a > b:
            a %= b
        else:
            b %= a
    return m // (a + b)    


def main():
    n, l = rinput()
    a = []
    for i in range(n):
        a.append(l + i)
    w = sum(a)
    if a[0] >= 0:
        print(w - a[0])
    elif a[-1] <= 0:
        print(w - a[-1])
    else:
        print(w)
            
        
    
    
    
    
main() 

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(a,b) for(int a=0; a<b; ++a)
#define ran(a,b) for(auto &a:b)
#define all(v) v.begin(),v.end()
using namespace std;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vector<T>,greater<T>>;
template<typename T>
using vec = vector<T>;

using ll = long long;
using pi = pair<int,int>;
using ti = tuple<int,int,int>;
using tup = tuple<string,int,int>;

ll MOD=1000000007;

int main(){
	int N; cin>>N;
	vec<ll> a(N),b(N);
	rep(i,N) cin>>a[i];
	rep(i,N) cin>>b[i];
	int ans=0;
	for(int di=29; di>=0; --di){
		ll hi=(1<<(di+1)),lo=(1<<di);
		rep(i,N) a[i]%=hi,b[i]%=hi;
		sort(all(b));
		int cnt=0;
		ran(i,a){
			int add=0;
			if(lo-i>=0){
				add+=lower_bound(all(b),2*lo-i)-lower_bound(all(b),  lo-i);
			}
			else{
				add+=lower_bound(all(b),2*lo-i)-b.begin();
				add+=lower_bound(all(b),2*lo)-lower_bound(all(b),3*lo-i);
			}
			cnt+=add;
		}
		if(cnt&1) ans+=lo;
	}
	//ran(i,k) cout<<i<<" ";
	cout<<ans<<endl;
}

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

int main() {
	string s;
	cin >> s;
	bool ok = true;
	for (int i = 0; i < s.length(); i += 2)
		if (s[i] == 'L')
			ok = false;
	for (int i = 1; i < s.length(); i += 2)
		if (s[i] == 'R')
			ok = false;
			
	if (ok)
		cout << "Yes\n";
	else
		cout << "No\n";
	
	return 0;
}

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

void main() {
    auto tmp = readln.split.to!(long[]);
    auto N = tmp[0], M = tmp[1];
    struct Data { long price; long limit; }
    auto dataList = new Data[N];
    foreach (i; 0..N) {
        tmp = readln.split.to!(long[]);
        const A = tmp[0], B = tmp[1];
        dataList[i] = Data(A, B);
    }
    dataList = dataList.sort!((a,b) => a.price < b.price).array;
    long res;
    while (M > 0) {
        auto data = dataList[0];
        auto cnt = min(M, data.limit);
        M -= cnt;
        res += data.price * cnt;
        dataList = dataList[1..$];
    }
    writeln(res);
}



Measured memory_bytes: 5244
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder2 {
	class Program {
		static void Main(string[] args) {

          
			var inputArray = retreiveLongArray();
			var inputCount = 1;

			// 不正な入力は処理しない
			if (inputArray.Length != inputCount) {
				Console.WriteLine("invalid input");
				return;
			}
			var N = inputArray[0];

			var longArray = retreiveLongArray();

			//各桁で1が何回でてきたか記録するDic
			var resultDic = new Dictionary<long, long>();

			for (int i = 0; i < 61; i++) {
				resultDic.Add(i, 0);
			}

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

				for (int j = 0; j < 61; j++) {
					var x = (longArray[i] >> j) & 1;
					
					//j桁目が1の場合、1の登場回数を府やsy
					if (x == 1) {
						resultDic[j] += 1;
					}
				}			
			}

			long divisor = 1000000000 + 7;
			long sum = 0;

			foreach (var item in resultDic) {
				var x = (long)Math.Pow(2, item.Key) % divisor;
				var toujoukaisu = (item.Value*(N-item.Value)) % divisor;
				var tempSum = (x*toujoukaisu) % divisor;
				sum = (sum+tempSum) % divisor;

			}


			//答えの出力
			var ans = sum;
			Console.WriteLine(ans);

		}

		/// <summary>
		/// スペースで区切られた文字列配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static string[] retreiveStringArray() {
			var inputArray = Console.ReadLine().Split(' ');
			return inputArray;
		}

		/// <summary>
		/// スペースで区切られた整数配列の入力を受け取る
		/// </summary>
		/// <returns></returns>
		private static long[] retreiveLongArray() {
			var inputArray = Console.ReadLine().Split(' ');
			var longArray = inputArray.Select(s => long.Parse(s));
			return longArray.ToArray();
		}
	}
}


Measured memory_bytes: 60712
#include<iostream>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    char x;
    int total = 0;
    stack<int> s1;
    stack<pair<int, int>>s2;

    for(int i=0; cin >> x; ++i){
        if(x == '\\') s1.push(i);
        else if(x == '/' && s1.size() > 0){
            int j=s1.top(); s1.pop();
            total += i - j;
            int a = i - j;
            while(s2.size() > 0 && s2.top().first > j){
                a += s2.top().second; s2.pop();
            }
            s2.push(make_pair(j, a));
        }
    }

    vector<int> ans;
    while(s2.size() > 0) { ans.emplace_back(s2.top().second); s2.pop(); }
    reverse(ans.begin(), ans.end());
    cout << total << endl;
    cout << ans.size();
    for(int i=0; i<ans.size(); ++i){
        cout << " " << ans[i];
    }
    cout << endl;
}


Measured memory_bytes: 3212
#include <iostream>
using namespace std;
int main(void){
    // Your code here
    int a, b;scanf("%d%d",&a,&b);
    int c[b], d[b];
    for (int i =0; i<b; i++){scanf("%d%d",&c[i],&d[i]);}
    
    // 最小値と最大値の区切りを更新するアルゴリズム
    int start = c[0];
    int end = d[0];
    for (int j = 0; j < b; j++){
        if (c[j] > start){
            start = c[j];
        }
        if (d[j] < end){
            end = d[j];
        }
    }
    
    int result = max(0, (end - start + 1));
    printf("%d", result);

}

Measured memory_bytes: 4600
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define pb push_back
const int maxn=2e5+10;
const int mod=1e9+7;
const double pi=3.1415926535;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    double a,b,x;
    cin>>a>>b>>x;
    double v=a*a*b;
    double yu=v-x;
    if(yu<=x)
    {
        double jiao=atan(yu*2.0/(a*a*a));
        jiao=jiao/pi*180.0;
        cout<<fixed<<setprecision(10)<<jiao<<'\n';
    }
    else
    {
        double jiao=atan(x*2.0/(a*b*b));
        jiao=jiao/pi*180.0;
        jiao=90.0-jiao;
        cout<<fixed<<setprecision(10)<<jiao<<'\n';
    }



}


Measured memory_bytes: 4084
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static long Solve(int N, int[] A)
        {
            long ans = 1;
            var cnt = new int[3];
            foreach (int a in A)
            {
                ans *= cnt.Count(c => c == a);
                ans %= 1000000007;
                for (int i = 0; i < 3; ++i)
                {
                    if (cnt[i] == a)
                    {
                        ++cnt[i];
                        break;
                    }
                }
            }
            return ans;
        }

        static void Main(string[] args)
        {
            int N = ReadInt();
            var A = ReadInts();
            Console.WriteLine(Solve(N, A));
        }
    }
}


Measured memory_bytes: 26200
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner Input = new Scanner(System.in);
        int N = Input.nextInt();

        Integer A[] = new Integer[N];
        int Sum = 0;
        for (int I = 0; I < N; I++) {
            A[I] = Input.nextInt();
            Sum += A[I];
        }
        Arrays.sort(A);
        if (Sum % 10 == 0) {
            for (int I = 0; I < A.length; I++) {
                if ((Sum - A[I]) % 10 != 0) {
                    Sum = Sum - A[I];
                    System.out.println(Sum);
                    break;
                }
                if (I == N - 1) {
                    System.out.println("0");

                }
            }
        } else {
            System.out.println(Sum);
        }
    }
}

//WWW.IJustAnsweredWrong.COM

//Kappa


Measured memory_bytes: 21332
import java.util.*;

public class Main{
    void solve(){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] a = new int[n];
        int[] num = new int[100001];
        long sum = 0;
        for(int i = 0; i < n; i++){
            a[i] = scan.nextInt();
            num[a[i]]++;
            sum += a[i];
        }
        int q = scan.nextInt();
        int[] b = new int[q];
        int[] c = new int[q];
        for(int i = 0; i < q; i++){
            b[i] = scan.nextInt();
            c[i] = scan.nextInt();
            if(num[b[i]] > 0){
                sum += (c[i] - b[i]) * num[b[i]];
                num[c[i]] += num[b[i]];
                num[b[i]] = 0;
            }
            System.out.println(sum);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}


Measured memory_bytes: 63316
// package arc.arc096;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

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

        long a = in.nextInt();
        long b = in.nextInt();
        long ab = in.nextInt();
        int X = in.nextInt();
        int Y = in.nextInt();
        long min = Long.MAX_VALUE;

        for (int i = 0; i <= Math.max(X, Y); i++) {
            int reqX = Math.max(0, X-i);
            int reqY = Math.max(0, Y-i);
            long cost = ab * i * 2 + a * reqX + b * reqY;
            min = Math.min(min, cost);
        }
        out.println(min);
        out.flush();
    }

    public static void debug(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }

    public static class InputReader {
        private static final int BUFFER_LENGTH = 1 << 12;
        private InputStream stream;
        private byte[] buf = new byte[BUFFER_LENGTH];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        private int next() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public char nextChar() {
            return (char) skipWhileSpace();
        }

        public String nextToken() {
            int c = skipWhileSpace();
            StringBuilder res = new StringBuilder();
            do {
                res.append((char) c);
                c = next();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public long nextLong() {
            int c = skipWhileSpace();
            long sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public double nextDouble() {
            return Double.valueOf(nextToken());
        }

        int skipWhileSpace() {
            int c = next();
            while (isSpaceChar(c)) {
                c = next();
            }
            return c;
        }

        boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}

Measured memory_bytes: 24404
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int a[1001];
    int n, m;
    while (cin >> n >> m) {
        if (n == 0 && m == 0) { break; }
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        int ans = -1;
        for (int i = 0; i < n; i++) {
            for (int j = i+1; j < n; j++) {
                if (a[i] + a[j] <= m) {
                    ans = max(ans, a[i] + a[j]);
                }
            }
        }
        if (ans == -1) { cout << "NONE" << endl; }
        else { cout << ans << endl; }
    }
    return 0;
}


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


int main(){
  int n;
  cin >> n;
  unordered_map<string, int>mp;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    mp[s]++;
  }
  long long ans=0;
  for(auto p:mp){
    int s=p.second;
    ans += (long long)s*(s-1)/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int h,w,i,j;
    char c[110][110];
    cin>>h>>w;
    for(i=1;i<=h;i++)
        for(j=1;j<=w;j++)
            cin>>c[i][j];
    for(i=0;i<=h+1;i++)
    {
        for(j=0;j<=w+1;j++)
            if (i>=1 && i<=h && j>=1 && j<=w) cout<<c[i][j];
            else cout<<"#";
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&s[i])
	}

	var cnt int
	for evenAll(s) {
		for i, _ := range s {
			s[i] /= 2
		}
		cnt++
	}
	fmt.Println(cnt)
}

func evenAll(s []int) bool {
	for _, a := range s {
		if a%2 != 0 {
			return false
		}
	}
	return true
}


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

int main(){
  long K,A,B;
  cin >> K >> A >> B;
  if (A/K*K+K <= B || A%K == 0){
    cout << "OK";
  }else{
    cout << "NG";
  }
  cout << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int a, b, k, num = 0;
	cin >> a >> b >> k;

	for(int i=max(a,b);i>0;i--){
		if(a%i==0 && b%i==0) num++;
		if(num==k){
			cout << i << endl;
			return 0;
		}
	}
}

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

int main(int argc, char *argv[])
{
    int N;
    int sum = 0;
    scanf("%d",&N);
    int *val = (int*)malloc(N*sizeof(int));
    int *cost = (int*)malloc(N*sizeof(int));
    for (int i = 0; i < N; i++) scanf("%d", &val[i]);
    for (int i = 0; i < N; i++) scanf("%d", &cost[i]);
    for (int i = 0; i < N; i++)
    {
        int div = val[i] - cost[i];
        if(div> 0) sum += div;
    }
    printf("%d",sum);
    
    return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")

#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<climits>//上限値
// #include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


void printVector(const std::vector<double>& vec) {
	for (double value : vec) {
		std::cout << value << " ";
	}
	std::cout << std::endl;
}


int main(){
	ll a;
	ld b;
	std::cin >> a >> b;
	std::cout << (ll)(a*b) << std::endl;
	return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
#define maxn 5005
char s[maxn];
string sub[maxn<<3];
int k,n;
int main(){
	scanf("%s",&s);
	scanf("%d",&k);
	int cnt=0; n=strlen(s);
	for (int i=0; i<n; i++){
		cnt++; sub[cnt]=sub[cnt]+s[i];
		int t=1; 
		while ((i+t<n)&&(t<5)){
			cnt++; sub[cnt]=sub[cnt-1]+s[i+t]; t++;
		}
	}
	sort(sub+1,sub+cnt+1);
	int sum=0;
	for (int i=1; i<=cnt; i++){
		if ((i>1)&&((sub[i]==sub[i-1]))) continue;
		sum++; 
		if (sum==k){
			cout<<sub[i]<<endl; break;
		}
	}
	return 0;
}

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

#define int long long

const int N = 57;

ll dp[N][N * N][N];

int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, x;
    cin >> n >> x;
    vector <int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        dp[i + 1][0][0] = 1;
        for (int s = 0; s < N * N; s++) {
            for (int j = 1; j <= n; j++) {
                if (s - a[i] >= 0) dp[i + 1][s][j] += dp[i][s - a[i]][j - 1];
                dp[i + 1][s][j] += dp[i][s][j];
            }
        }
    }
    ll ans = 0;
    for (int i = 1; i <= n; i++) ans += dp[n][i * x][i];
    cout << ans << '\n';
    return 0;
} 

Measured memory_bytes: 74624
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card{
	char suit;
	int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left,  int mid, int right){
	int i, j, k;
	int n1 = mid - left;
	int n2 = right - mid;
	for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
	for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
	L[n1].value = R[n2].value = SENTINEL;
	i = j = 0;
	for ( k = left; k < right; k++ ){
		if ( L[i].value <= R[j].value ){
			A[k] =  L[i++];
		} else{
			A[k] =  R[j++];
		}
	}
}

void mergeSort(struct Card A[], int n, int left, int right){
	int mid;
	if ( left + 1 < right ){
		mid = (left + right) / 2;
		mergeSort(A, n, left, mid);
		mergeSort(A, n, mid, right);
		merge(A, n, left, mid, right);
	}
}

int partition(struct Card A[], int n, int p, int r){
	int i, j;
	struct Card t, x;
	x = A[r];
	i = p - 1;
	for ( j = p; j < r; j++ ){
		if ( A[j].value <= x.value ){
			i++;
			t = A[i];
			A[i] = A[j];
			A[j] = t;
		}
	}
	t = A[i + 1];
	A[i + 1] = A[r];
	A[r] = t;
	return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r){
	int q;
	if ( p < r ){
		q = partition(A, n, p, r);
		quickSort(A, n, p, q - 1);
		quickSort(A, n, q + 1, r);
	}
}

int main(){
	int n, i, v;
	struct Card A[MAX], B[MAX];
	char S[10];
	int stable = 1;
	
	scanf("%d", &n);
	
	for ( i = 0; i < n; i++ ){
		scanf("%s %d", S, &v);
		A[i].suit = B[i].suit = S[0];
		A[i].value = B[i].value = v;
	}
	
	mergeSort(A, n, 0, n);
	quickSort(B, n, 0, n - 1);
	
	for ( i = 0; i < n; i++ ){
		if ( A[i].suit != B[i].suit ) stable = 0;
	}
	
	if ( stable == 1 ) printf("Stable\n");
	else printf("Not stable\n");
	for ( i = 0; i < n; i++ ){
		printf("%c %d\n", B[i].suit, B[i].value);
	}
	
	return 0;
}



Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 

using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll

typedef pair<lld,lld> PA;

lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}

bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}

lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}

#define lim 500010
#define lim2 200003
#define qqqqqq 210
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];
// vector<lld> V[lim];
// int X[lim],Y[lim],C[lim];
// string R[lim];
lld A[lim],B[lim],C[lim];
// map<lld,lld> M;

int main(){
    lld T,i,m,n,p,j,l,e,r,b,c,k,q,a,d,w,x,y,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc3(n,a,b);
    if(a>b || (n==1 && a!=b)) printf("0\n");
    else prL(a+b*(n-1)-(b+a*(n-1))+1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    int N;
    int ans = 0;
    cin >> N;
    vector<int> A(N), B(N);
    
    for (int i = 0; i < N; i++){
        cin >> A[i];
        B[A[i] - 1] = i;
    }
    for (int i = 0; i < N; i++){
        cout << B[i] + 1;
        if (i < N - 1)
            cout << " ";
    }
    cout << endl;
    return 0;    
}


Measured memory_bytes: 1664
N=int(input())
S=list(map(int,input().split()))
LIST=list("")

for i in range(N):
    if((S[i] - i)>1):
        print("-1")
        exit()  

while(len(S)>0):
    c=10**10
    for i in range (len(S)):
        if(S[i]==i+1):
            c=i
    if(c==(10**10)):
        print("-1")
        exit()  
    LIST.append(S.pop(c))

for i in range(len(LIST)-1,-1,-1):
    print(LIST[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 90000000000000000
signed main(void){
    int n;cin>>n;
    string s;cin>>s;
    rep(i,s.size()){
        int x=s[i]-'A';
        s[i]='A'+(x+n)%26;
    }
    cout<<s<<endl;
    
}
        

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;


int main() {
    while(true){
        int n;
        cin >> n;
        if (n==0) break;
        vector<pp> a(n);
        rep(i,n){
           int f,g;
           cin >> f >> g;
           a[i]=mk(f,g);
        }
        int m;
        cin >> m;
        vector<vector<int>> b(21,vector<int>(21,0));
        int x=10,y=10;
        b[10][10]=1;
        rep(i,m){
           char s;
           int e;
           cin >> s >> e;
           if (s=='N') {
              rep(j,e){
                 y++;
                 b[x][y]=1;
              }
           }
           if (s=='S'){
              rep(j,e){
                 y--;
                 b[x][y]=1;
              }
           }
           if (s=='E'){
              rep(j,e){
                 x++;
                 b[x][y]=1;
              }
           }
           if (s=='W'){
              rep(j,e){
                 x--;
                 b[x][y]=1;
              }
           }
        }
        bool t=true;
      rep(i,n){
         if (b[a[i].first][a[i].second]==0) t=false;
      }
      if (t) cout << "Yes" << endl;
      else cout << "No" << endl;
}}




Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{

	ios_base::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);

	// #ifndef ONLINE_JUDGE
 //    freopen("input.txt" , "r" , stdin);
	// freopen("output.txt" , "w" , stdout);
	// #endif

	string s;
	cin>>s;
	ll n=s.length(),ans=0;
	vector<ll>v(n+1);
	// for(ll i=0;i<v.size();i++)
	// 	v[i]=0;
	for(ll i=0;i<n;i++)
	{
		if(s[i]=='<')
		{
			v[i+1]=max(v[i+1],v[i]+1);
		}
	}
	for(ll i=n-1;i>=0;i--)
	{
		if(s[i]=='>')
		{
			v[i]=max(v[i],v[i+1]+1);
		}
	}
	for(ll i=0;i<v.size();i++)
		ans+=v[i];
	cout<<ans<<endl;

	
	
}


Measured memory_bytes: 4764
a1, a2, a3 = map(int, input().split(" "))

orders = (
    (a1, a2, a3),
    (a1, a3, a2),
    (a2, a1, a3),
    (a2, a3, a1),
    (a3, a1, a2),
    (a3, a1, a2)
)


def get_cost(i1, i2, i3):
    return abs(i2-i1) + abs(i3-i2)


costs = [get_cost(*order) for order in orders]
print(min(costs))


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

using namespace std;

#define INF ((1<<30)-1)  //int32_t
#define MOD 1000000007
#define MOD2 

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

bool ok(vector<ll> f,vector<ll> a,ll k,ll x){
    ll sum=0;

    for (int i = 0; i < a.size(); i++){
        sum += max(0LL,a[i]-(x/f[i]));
    }
    
    return k >= sum;
}

int main(){

    bool flag=false;

    ll ans=0,sum=0;
    
    ll n,k;
    cin >>n>>k;
    vector<ll> a(n),f(n);

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

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

    sort(all(a));
    sort(all(f),greater<ll>());
    ll l = -1,r = 1e13;

    while(l+1 < r){
        ll c = (l+r)/2;

        if(ok(f,a,k,c)){
            r = c;
        }else{
            l = c;
        }
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    cout << r << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 6552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rep3(i, l, n) for (int i = l; i < n; ++i)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define out(a) cout << a << endl
#define SZ(v) (int)v.size()
#define inf (int)(1e9+7)

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i, SZ(s)) { // a
        rep3(j, i + 1, SZ(s)) { // b
            int c[26] = {0};
            rep(k, i + 1) {
                c[s[k] - 'a']++;
            }
            int sum = 0;
            rep3(l, i + 1, SZ(s)) {
                if (c[s[l] - 'a']) {
                    sum++; c[s[l] - 'a'] = 0;
                }
            }
            ans = (ans < sum ? sum : ans);
        }
    }
    out(ans);
}


Measured memory_bytes: 256
import java.util.*
import java.math.*
fun main(args: Array<String>) {

    val (N, K) = readLine()!!.split(" ").map(String::toInt)

    if (2 * K + 1 >= N) {
        print(N)
        return
    }
    var n = 0
    var isOder = false
    var ans = 0
    var tmp = IntArray(N){0}
    var from = 0
    var to = 0
    var tmpn = 0
    var k = K

    for (c in readLine()!!) {
        if (isOder) {
            if (c == '1') {
                isOder = false

                k--
                tmp[to++] = n
                tmpn += n

                n = 0
            }
            n++
        } else {
            if (c == '0') {
                isOder = true

                tmp[to++] = n
                tmpn += n
                if (k == 0) {
                    //println(tmp)
                    ans = Math.max(ans, tmpn)
                    tmpn -= tmp[from++] + tmp[from++]
                    k++
                }

                n = 0
            }
            n++
        }
    }
    if (n != 0) {
        //print(tmp)
        ans = Math.max(ans, tmpn+n)
    }


    //println(list)
    println(ans)
}

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

int main(){
	int a,b;
	while(cin >> a >> b,a){
		int c = b - a,x,y,z;
		z = c / 1000;
		c %= 1000;
		y = c / 500;
		c %= 500;
		x = c / 100;
		cout << x << " " << y << " " << z << endl;
	}
	return 0;
}

Measured memory_bytes: 2984
import math
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

counter=[]
for i in range(q):
    left,right=0,len(S)
    while left<right:
        mid=math.floor((left+right)/2)
        if T[i]==S[mid]:
            counter.append(T[i])
            break
        elif S[mid]<T[i]:
            left=mid+1
        elif T[i]<S[mid]:
            right=mid
            
print(len(set(counter)))


Measured memory_bytes: 16776
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ms(x, y) memset(x, y, sizeof(x))
int n, k, a[100001], dp[100001];
int main(){
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    ms(dp, INF); dp[0] = 0;
    for (int i = 0; i < n; i++){
        for (int j = 1; j <= k; j++){
            dp[i + j] = min(dp[i + j], dp[i] + abs(a[i + j] - a[i]));
        }
    }
    cout << dp[n - 1];
    return 0;
}

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

int first(int i){
	string S=to_string(i);
	return S[0]-'0';
}

int end(int i){
	string S=to_string(i);
	return S[S.size()-1]-'0';
}

signed main(){
	int N; cin>>N;
	vector<vector<int>> c(10,vector<int>(10,0));
	for(int i=1;i<=N;i++){
		c[first(i)][end(i)]++;
	}
	int ans=0;
	for(int i=0;i<10;i++){
		for(int j=0;j<10;j++){
			ans+=c[i][j]*c[j][i];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 400

int n, ma, mb;
int memo[N*2][N*2];

int main() {
  cin >> n >> ma >> mb;
  rep(i, N*2) rep(j, N*2) memo[i][j] = INF;
  memo[0][0] = 0;
  rep(t, n) {
    int a, b, c; cin >> a >> b >> c;
    repr(i, N+1) {
      repr(j, N+1) {
        memo[i+a][j+b] = mind(memo[i+a][j+b], memo[i][j] + c);
      }
    }
  }
  int ans = INF;
  int a = ma, b = mb;
  while(a < N*2 && b < N*2) {
    ans = mind(ans, memo[a][b]);
    a += ma; b += mb;
  }
  if(ans > 50000) {
    cout << -1 << endl;
  } else {
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
# define ll  long long
	
	int parent[200001];
	int ssize[200001];
	vector<pair<int,int>>v;
	int n;
	int m;
	int get_parent(int x){
		if(parent[x]==x){
			return x;
		}
		return parent[x]=get_parent(parent[x]);
	}
	void merge(int x,int y){
		int a=get_parent(x);
		int b= get_parent(y);
		if(a==b){
			return;
		}
		ssize[b]=ssize[a]+ssize[b];
		parent[a]=b;
	}
	int main() {

		#ifndef ONLINE_JUDGE
	        freopen("input.txt","r",stdin);
	        // freopen("output.txt","w",stdout);
	    #endif
	    ios::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);  
	   
	    cin>>n;
	
	    cin>>m;
	    for(int i=0;i<m;i++){
	    	int x,y; cin>>x>>y;
	    	v.push_back({x,y});
	    }
	    // make n -set

	    for(int i=0;i<n;i++){
	    	parent[i]=i;
	    	ssize[i]=1;
	    }
	 
	    for(int i=0;i<m;i++){
	    	int a=v[i].first;
	    	int b=v[i].second;

	    	if(get_parent(a)!=get_parent(b)){
	    		merge(a,b);
	    	}
	    }

	    int ans=0;
	    int sans=1;
	    for(int i=0;i<n;i++){
	    	if(get_parent(i)==i){
	    		ans++;
	
	    		sans=max(ssize[i],sans);
	    	}
	    }
	    cout<<sans<<endl;
	    // cout<<ans<<endl;

	}



	


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

using namespace std;


int main (void) 
{

  /* Variable_Proclamation */
  int N;    // input
  int ans;  // output

  int i;    // subscript
  int max_abs;


  /* Input, Array_Proclamation */
  cin >> N;
  vector<int> A(N);


  for(i=0; i<N; i++)
  {
    cin >> A.at(i);
  }


  /* Initialize */


  /* Calculation */
  sort( A.begin(), A.end() );

  max_abs = A.at(N-1) - A.at(0);

  /* Output */
  cout << max_abs << endl;


  return 0;

}


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

#define maxn 100005
#define inf (int) 2e9
#define ll long long
#define ii pair <int, int>
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a, b) for(int i = a; i >= b; i--)

int n;
int a[maxn], f[maxn];

int main() {
    //freopen("main.inp", "r", stdin);
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 2, n) f[i] = inf;
    FOR(i, 2, n) {
        f[i] = f[i - 1] + abs(a[i] - a[i - 1]);
        if(i - 2) f[i] = min(f[i], f[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << f[n];
}


Measured memory_bytes: 4316
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.numeric;


void main()
{
  int n, m;
  readf("%s %s\n", &n, &m);
  auto res = new int[](n);
  res[] = -1;
  foreach (i; 0..m) {
    int s, c;
    readf("%s %s\n", &s, &c);
    if (res[s-1] != -1 && res[s-1] != c) {
      writeln(-1);
      return;
    }
    res[s-1] = c;
  }
  int sum;
  foreach (i; 0..n) {
    if (res[i] == -1) {
      if (i == 0 && n != 1) {
        res[i] = 1;
      } else {
        res[i] = 0;
      }
    }
    sum += res[i] * (10 ^^ (n - i - 1));
  }

  auto l = sum.to!string.length;
  if (n == l) {
    sum.writeln;
  } else {
    writeln(-1);
  }
}


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

typedef complex<double> P;

int main(){
	double V;
	while(cin>>V){
		for(int i = 1 ; ; i++){
			double y = 5 * i - 5;
			double t = sqrt(y/4.9);
			double v = 9.8*t;
			if(v>=V-1e-9){
				cout << i << endl;
				break;
			}
		}

		
	}
}

Measured memory_bytes: 3040
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<tuple>
#include<cassert>
using namespace std;


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

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

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

const int mod = pow(10, 9) + 7;



struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){

	int x, y;
	cin >> x >> y;

	if((x + y) % 3){
		cout << 0 << endl;
		return 0;
	}

	int n = (x + y) / 3;
	x -= n; y -= n;

	if(x < 0 || y < 0){
		cout << 0 << endl;
		return 0;
	}

	combination c(x + y);
	mint ans = c(x + y, x);


	cout << ans.x << endl;

}

Measured memory_bytes: 10624
#include <iostream>

using namespace std;

int main()
{
	int32_t n, k, x, y;
	int32_t payment;
	
	cin >> n >> k >> x >> y;

	payment = n >= k ? k * x : n * x;
	payment += n >= k ? (n - k) * y : 0;

	cout << payment << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <algorithm>

#define rep(i,n) for(int i=0; i < n; i++)
using namespace std;
#define PI 3.14159265358979

int main()
{
    double r;
    cin >> r;
    

    cout << 2* r * PI << endl;
    return 0;
}

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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	vector<int> l(n + 1), r(n + 1);
	for(int i = 0; i < n; i++){
		if(s[i] == '#') l[i + 1]++;
		if(s[n - i - 1] == '.') r[n - i - 1]++;
		l[i + 1] += l[i];
		r[n - i - 1] += r[n - i];
	}
	int ans = 1001001001;
	for(int i = 0; i < n; i++){
		ans = min(ans, l[i] + r[i + 1]);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  
  int d = a / b, r = a % b;
  double f = (double) a / b;
  
  cout << d << " " << r << " " << fixed << setprecision(10) << f << '\n';
}


Measured memory_bytes: 3280
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int n, q, l, r;
string s;
vector<int> ac;
vector<int> ans;

void init()
{
    int cnt = 0;
    for (int i = 1; i < n; ++i) {
        if (s[i] == 'C' && s[i-1] == 'A') ++cnt;
        ac[i] = cnt;
    }
}

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

    cin >> n >> q;
    ac.resize(n, 0);
    ans.resize(q);
    cin >> s;
    init();

    for (int i = 0; i < q; ++i){
        cin >> l >> r;
        ans[i] = ac[--r] - ac[--l];
    }

    for (auto x : ans) printf("%d\n", x);

    return 0;
}

Measured memory_bytes: 1872
#include<bits/stdc++.h>
using namespace std;
#define N 100010
int main(){
  int n,m,h[N],ma[N];
  
  cin>>n>>m;
  for(int i=1;i<=n;i++) {
    cin>>h[i];
    ma[i]=0;
  }
  
  for(int i=0;i<m;i++) {
    int a,b;
    cin>>a>>b;
    ma[a]=max(ma[a],h[b]);
    ma[b]=max(ma[b],h[a]);
  }
  
  int ans=0;
  for(int i=1;i<=n;i++) {
    if(h[i]>ma[i]){
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
    ll n,i,j,sum=0,ans=0;
    j=(1e9)+7;
    vector<ll> a;
    cin>>n;
    a.resize(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum=(sum+a[i])%j;
    }
    for(i=0;i<n;i++)
    {
        sum=(sum-a[i]+j)%j;
        ans=(ans+(a[i]*sum))%j;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 4820
import itertools
import math

n = int(input())

xy = [map(int, input().split()) for _ in range(n)]
x, y = [list(i) for i in zip(*xy)]
sum = 0
def distance(a, b):
  return ((x[a]-x[b])**2+(y[a]-y[b])**2)**(1/2)


permutations_lis = itertools.permutations(range(n))# 全ての場合のリストを生成
# 以下出力

for one_case in permutations_lis: 
  for i in range(n-1):
    sum += distance(one_case[i], one_case[i+1])
    
print(sum/math.factorial(n))

Measured memory_bytes: 3188
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll a,b,k,t0,t1;
  cin >> a >> b >> k;
  for(int i=0;i<k;i++){
    if(i%2==0){
      if(a%2==1){
        a--;
      }
      t0= a/2;
      a/=2;
      b+=t0;
    }else{
      if(b%2==1){
        b--;
      }
      t1 = b/2;
      b/=2;
      a+=t1;
    }
  }
  cout << a<<" "<<b<<endl;
}


Measured memory_bytes: 256
//
//  bishop.cpp
//  learningCplusplus
//
//  Created by Tran Duc Chinh on 2020/04/04.
//  Copyright © 2020 Tran Duc Chinh. All rights reserved.
//

#include <iostream>
typedef long long ll;
int main(int argc, const char* argv[]) {
  ll h, w;
  std::cin >> h >> w;

  ll odd_in_row = w / 2 + w % 2;
  ll even_in_row = w - odd_in_row;

  ll odd_in_col = h / 2 + h % 2;
  ll even_in_col = h - odd_in_col;

  ll sum = odd_in_row * odd_in_col + even_in_row * even_in_col;
  if (h == 1 || w == 1) {
    sum = 1;
  }

  std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a,mini,ans=-(1<<30);
  cin>>n>>mini;
  for(int i=0;i<n-1;i++){
    cin>>a;
    if(a-mini>ans)ans=a-mini;
    if(mini>a)mini=a;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

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

    for (int i = 0; i < N; ++i) {
        int Ai;
        cin >> Ai;

        if (Ai % 2 == 0) {
            if (Ai % 3 != 0 && Ai % 5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }

    cout << "APPROVED" << endl;
    return 0;
}


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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

vector<ll> toDivisor(ll num)
{
	vector<ll> d;
	for (ll i = 1; i*i <= num; ++i)
	{
		if (i*i == num)
		{
			d.push_back(i);
		}
		else if (num % i == 0)
		{
			d.push_back(i);
			d.push_back(num/i);
		}
	}
	return d;
}

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;

	vector<ll> di = toDivisor(M);

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

	ll res{di[0]};
	for (auto &e : di)
	{
		if (e*N > M) break;
		res = e;
	}

	std::cout << res << std::endl;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/23  Problem: 065_arc_b / Link: https://arc065.contest.atcoder.jp/tasks/arc065_b?lang=en  ----- */
/* ------問題------

N 個の都市があり、K 本の道路と L 本の鉄道が都市の間に伸びています。 i 番目の道路は pi 番目と qi 番目の都市を双方向に結び、 i 番目の鉄道は ri 番目と si 番目の都市を双方向に結びます。 異なる道路が同じ 2 つの都市を結ぶことはありません。同様に、異なる鉄道が同じ 2 つの都市を結ぶことはありません。
ある都市から別の都市に何本かの道路を通って到達できるとき、それらの都市は道路で連結しているとします。また、すべての都市はそれ自身と道路で連結しているとみなします。
鉄道についても同様に定めます。
全ての都市について、その都市と道路・鉄道のどちらでも連結している都市の数を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N, K, L;

LL ans = 0LL;
void dfs(int v, int p, VVI& G, VI& color, int k) {
	color[v] = k;
	FOR(i, 0, SZ(G[v])) {
		int nx = G[v][i];
		if (nx != p&&color[nx]==0)dfs(nx, v, G, color, k);
	}
}

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

	cin >> N >> K >> L;

	VVI Rd(N);
	FOR(i, 0, K) {
		int p, q; cin >> p >> q;
		Rd[p - 1].push_back(q - 1);
		Rd[q - 1].push_back(p - 1);
	}
	VVI Ra(N);
	FOR(i, 0, L) {
		int p, q; cin >> p >> q;
		Ra[p - 1].push_back(q - 1);
		Ra[q - 1].push_back(p - 1);
	}

	VI rdc(N, 0);
	VI rac(N, 0);
	int k = 1;

	FOR(i, 0, N) {
		if (rdc[i] == 0)dfs(i, -1, Rd, rdc, k++);
	}
	k = 1;
	FOR(i, 0, N) {
		if (rac[i] == 0)dfs(i, -1, Ra, rac, k++);
	}
	map<PII, int>Map;
	FOR(i, 0, N) {
		Map[PII(rdc[i], rac[i])] ++;
	}
	FOR(i, 0, N) {
		cout<< Map[PII(rdc[i], rac[i])]<<endl;
	}

	return 0;
}


Measured memory_bytes: 27776