akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    print(([S[0]==T[0], S[1]==T[1], S[2] == T[2]]).count(True))
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
n = gets
line = gets.split(" ").map(&:to_i)

line.unshift(0)
all = 0
for value in 0...line.length do
  all = all + ( line[(value + 1)%line.length] - line[(value)%line.length] ).abs
end

for value in 1...line.length do
  sum = all + ( line[(value + 1)%line.length] - line[(value - 1)%line.length] ).abs - (( line[(value + 1)%line.length] - line[(value)%line.length] ).abs + ( line[(value)%line.length] - line[(value -1)%line.length] ).abs)
  puts sum
end


Measured memory_bytes: 12044
#include <stdio.h>

int main(void)
{
	char str[16] = {0};
	
	while (scanf("%s", str) != EOF){
		int array[10][10] = {0};
		int i, j;
		
		for (i = 0; i < 10; i++){
			array[0][i] = str[i] - '0';
		}
		for (i = 1; i < 10; i++){
			for (j = 0; j < 10 - i; j++){
				array[i][j] = array[i - 1][j] + array[i - 1][j + 1];
				array[i][j] %= 10;
			}
		}
		printf("%d\n", array[9][0]);
	}
	
	return 0;
}

Measured memory_bytes: 536
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j,k;
		Scanner sc = new Scanner(in);
		int n = parseInt(sc.next());
		int[] t = new int[n+1];
		int[] x = new int[n+1];
		int[] y = new int[n+1];
		for (i = 1; i <= n; i++) {
			t[i] = parseInt(sc.next());
			x[i] = parseInt(sc.next());
			y[i] = parseInt(sc.next());
		}
		sc.close();
		int dt=0;
		int dxy=0;
		boolean f = true;
		for (i = 0; i < n; i++) {
			dt = t[i+1] - t[i];
			dxy = abs(x[i+1] - x[i])+abs(y[i+1] - y[i]);
			if(dxy > dt) {
				f = false;
				break;
			}
			if((dt-dxy)%2!=0) {
				f = false;
				break;
			}
		}
		out.println(f?"Yes":"No");
	}
}


Measured memory_bytes: 62532
import java.awt.geom.Point2D;
import java.util.*;
 
public class Main {
    Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        new Main(); 
    }
 
    public Main() {
    	new aoj0052().doIt();
    }
    class aoj0052{
    	void doIt(){
    		int a[] = new int [20001];
    		int num[] = {1,5,25,125,625,3125,15625};
    		for(int i = 1;i < 20001;i++){
    			for(int j = 6;j >= 0;j--){
    				if(i % num[j] == 0){
    					a[i] = a[i-1] + j;
    					break;
    				}
    			}
    		}
    		while(true){
    			int n = sc.nextInt();
    			if(n == 0)break;
    			System.out.println(a[n]);
    		}
    	}
    }
}

Measured memory_bytes: 26628
import java.math.BigInteger;
import java.util.Scanner;

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

    public static void solve(Scanner sc) {
        int n = sc.nextInt();
        BigInteger tlc = BigInteger.valueOf(0l);
        BigInteger[] as = new BigInteger[n];
        for (int i = 0; i < n; i++) {
            as[i] = BigInteger.valueOf(sc.nextLong());
            tlc = i == 0 ? as[i] : tlc(tlc, as[i]);
        }

        BigInteger ans = BigInteger.valueOf(0);
        for (int i = 0; i < n; i++) {
            ans = ans.add(tlc.subtract(BigInteger.valueOf(1)).mod(as[i]));
        }

        System.out.println(ans);
    }

    static BigInteger tlc(BigInteger a, BigInteger b) {
        BigInteger gcd = a.gcd(b);
        return a.divide(gcd).multiply(b);
    }
}

Measured memory_bytes: 50320
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
using namespace std;
int a[2000010];
int b[2000010];
char s[1000010],t[1000010];
int sta[1000010],head=0;
int tmp[1000010];
int n,m,k;
void work(int i)
{
	if(!a[i]&&!b[i])return ;
	if(!(a[i]&&b[i])){
		sta[++head]=i;
		return ;
	}
	a[i]=b[i]=0;
	int rest=k;
	int cur=i;
	int cnt=0;
	while(1)
	{
//		printf("???\n");
		if(!head||sta[head]-cur>rest)
		{
			a[cur+rest]=b[cur+rest]=1;
			break;
		}
		rest-=sta[head]-cur;
		int pos=sta[head];
		tmp[++cnt]=pos;
		if(a[pos]){
			b[pos]=1;
			while(head&&sta[head]==pos&&a[pos]){
				a[pos]=0;
				head--;
				pos++;
			}
			a[pos]=1;
			if(!b[pos]){
				tmp[++cnt]=pos;
				break;
			}
			else{
				a[pos]=b[pos]=0;
				head--;cur=pos;
			}
		}
		else{
			a[pos]=1;
			while(head&&sta[head]==pos&&b[pos]){
				b[pos]=0;
				head--;
				pos++;
			}
			b[pos]=1;
			if(!a[pos]){
				tmp[++cnt]=pos;
				break;
			}
			else{
				a[pos]=b[pos]=0;
				head--;cur=pos;
			}
		}
	}
	while(cnt>0)sta[++head]=tmp[cnt--];
	return ;
}
int main()
{
	scanf("%d %d %d",&n,&m,&k);
	scanf("%s",s);
	for(int i=0;i<n;i++)
		a[n-i]=s[i]-'0';
	scanf("%s",t);
	for(int i=0;i<m;i++)
		b[m-i]=t[i]-'0';
	for(int i=max(n,m);i>=1;i--)
		work(i);
	int lena=n+k,lenb=m+k;
	while(!a[lena])lena--;
	while(!b[lenb])lenb--;
	for(int i=lena;i>0;i--)
		printf("%d",a[i]);printf("\n");
	for(int i=lenb;i>0;i--)
		printf("%d",b[i]);printf("\n");
	return 0;
}

Measured memory_bytes: 22656
# import math
# import bisect
# import heapq
# from collections import deque
# import numpy as np

# a,b,c = map(int, input().split())
# n = int(input())
# a = list(map(int,input().split()))
s = input()

l = len(s)
ans = 'x' * l
print(ans)

Measured memory_bytes: 2940
w,h,n = map(int, input().split())
s = w * h
l = [0,0]
r = [w,h]

for i in range(n):
    x,y,a = map(int, input().split())
    if a == 1:
        if l[0] < x:
            l[0] = x
    elif a == 2:
        if r[0] > x:
            r[0] = x
    elif a == 3:
        if l[1] < y:
            l[1] = y
    else:
        if r[1] > y:
            r[1] = y

tate = r[1] - l[1]
yoko = r[0] - l[0]

if l[0] < r[0] and l[1] < r[1]:
    print(tate * yoko)
else:
    print(0)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
const int MAX = 2e5+5;
ll a, b;

int main(int argc, char ** argv) {
	cin >> a >> b;
	cout << (a*b)/__gcd(a, b) << "\n";
	return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : AOL.cpp
// Author      : Akari Fujii
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cctype>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {


	int a,b,n;
	int s[101],f[101];
	int d=0;


	cin>>a>>b;
	cin>>n;


	for(int i=1; i<n+1; ++i){
		cin>>s[i]>>f[i];
		if(a<=s[i]&&b>s[i]){
			d=1;
		}else if(f[i]<=b&&f[i]>a){
			d=1;

		}else if(a>s[i]&&b<f[i]){
			d=1;
		}
	}
		cout<<d<<endl;

		return 0;




}

Measured memory_bytes: 3096
#include <stdio.h>

int main()
{
    int a, b, c;

    scanf("%d %d %d", &a, &b, &c);

    if(a < b && a < c) {
        if(b < c) {
            printf("%d %d %d\n", a, b, c);
        } else {
            printf("%d %d %d\n", a, c, b);
        }
    } else if(b < a && b < c) {
        if(a < c) {
            printf("%d %d %d\n", b, a, c);
        } else {
            printf("%d %d %d\n", b, c, a);
        }
    } else {
        if(a < b) {
            printf("%d %d %d\n", c, a, b);
        } else {
            printf("%d %d %d\n", c, b, a);
        }
    }

    return 0;
}


Measured memory_bytes: 2056
N,C=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(N)]
cost=[[0 for _ in range(C)],[0 for _ in range(C)],[0 for _ in range(C)]]
for i in range(N):
    for j in range(N):
        for x in range(C):
            cost[(i+j+2)%3][x]+=D[c[j][i]-1][x]
            

ar=[[cost[0][i],i] for i in range(C)]
br=[[cost[1][i],i] for i in range(C)]
cr=[[cost[2][i],i] for i in range(C)]
sa=sorted(ar)
sb=sorted(br)
sc=sorted(cr)
outp=[]
for i in range(3):
    for j in range(3):
        for k in range(3):
            if(sa[i][1]!=sb[j][1] and sa[i][1]!=sc[k][1] and sb[j][1]!=sc[k][1]):
                outp.append(sa[i][0]+sb[j][0]+sc[k][0])
print(min(outp))

Measured memory_bytes: 43868
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	scanInit()

	n := nextInt()
	pl := make([]int, n)
	for i := 0; i < n; i++ {
		pl[i] = nextInt()
	}
	ql := make([]int, n)
	for i := 0; i < n; i++ {
		ql[i] = nextInt()
	}
	p := Arrtoi(pl)
	q := Arrtoi(ql)
	if p > q {
		p, q = q, p
	}

	pall := permutations([]int{1, 2, 3, 4, 5, 6, 7, 8}[:n])
	pallnum := make([]int, len(pall))
	for i := 0; i < len(pall); i++ {
		tmp := 0
		for j := 0; j < n; j++ {
			tmp += pall[i][j] * pow(10, n-j-1)
		}
		pallnum[i] = tmp
	}

	sort.Ints(pallnum)

	pidx := sort.SearchInts(pallnum, p)
	qidx := sort.SearchInts(pallnum, q)

	fmt.Println(qidx - pidx)

}

// Arrtoi = Array to Integer
// int列->数値化 (powが必要)
func Arrtoi(a []int) int {
	n := len(a)
	tmp := 0
	for j := 0; j < n; j++ {
		tmp += a[j] * pow(10, n-j-1)
	}
	return tmp
}

// 順列
// 順列作成 (ランダム順)
func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}
func pow(a, b int) int {
	var ret int = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret *= a
		}
		a *= a
		b >>= 1
	}
	return ret
}

// ---- readfunc
func scanInit() {
	const cap = 200 * 1024 // Default=64
	var buf = make([]byte, cap)
	sc.Buffer(buf, cap)
	sc.Split(bufio.ScanWords)
	return
}
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 9400
#include<stdio.h>

 int main(){
   int h,w;
   int i,j;
   
   while(1)
     {
       scanf("%d %d",&h ,&w);
       
       if(h==0 && w==0)break;

       for(i=0;i<h;i++)
	 {
	   for(j=0;j<w;j++)
	     {
	       if(i == 0 || i == h-1)
		 {
		   printf("#");
		 }
	       else
		 {
		   if(j==0 || j==w-1)
		     {
		       printf("#");
		     }
		   else
		     {
		       printf(".");
		     }
		 }
	     }
	   printf("\n");
	 }
       printf("\n");
     }
 }



Measured memory_bytes: 2024
#include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;

#define N_MAX 100
#define WHITE 1
#define GREY 2
#define BLACK 3
#define INF 1000000000
#define NIL -1

int G[N_MAX][N_MAX];
int V[N_MAX];
int V_value[N_MAX];

void init(void){
    for(int i = 0; i < N_MAX; i++){
        V[i] = WHITE;
        V_value[i] = INF;
    }
}

int main(void){
    init();
    int n;
    scanf("%d\n", &n);

    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            scanf("%d", &G[i][j]);
        }
    }

    V[0] = BLACK;
    V_value[0] = 0;
    int new_node = 0;
    int sum = 0;
    while(1){
        for(int i = 0; i < n; i++){
            if(G[new_node][i] != -1 && V[i] == WHITE){
                V_value[i] = min(V_value[i], G[new_node][i]);
            }
        }

        int min_value = INF;
        int min_index = NIL;
        for(int i = 0; i < n; i++){
            if(V[i] == WHITE){
                if(V_value[i] < min_value){
                    min_index = i;
                    min_value = V_value[i];
                }
            }
        }
        if(min_index == NIL){
            break;
        }else{
            V[min_index] = BLACK;
            new_node = min_index;
            sum += min_value;
        }
    }

    printf("%d\n", sum);
}



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

int x[100000], y[100000], md = 1e9 + 7;

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	f(i, 0, n)scanf("%d", x + i);
	int a = 0;
	f(i, 1, n){
		int d = x[i] - x[i - 1];
		a = (a + (ll)d * i % md * (n - i)) % md;
	}
	f(i, 0, m)scanf("%d", y + i);
	int b = 0;
	f(i, 1, m){
		int d = y[i] - y[i - 1];
		b = (b + (ll)d * i % md * (m - i)) % md;
	}
	printf("%d\n", (int)((ll)a * b % md));
}


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

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

  int sum = 0;
  rep(i, n) sum += s[i];
  bool dp[110][10010];
  memset(dp, 0, sizeof(dp));
  dp[0][0] = true;

  rep(i, n) {
    rep(j, sum + 1) {
      dp[i + 1][j] |= dp[i][j];
      if (j >= s[i]) dp[i + 1][j] |= dp[i][j - s[i]];
    }
  }
  int ans = 0;
  rep(i, n) {
    rep(j, sum + 1) {
      if (!dp[i + 1][j]) continue;
      if (j % 10 == 0) continue;
      if (j > ans) ans = j;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            Main2(str);
            //MainSS();

        }

        static void MainSS(string str)
        {
            for (int i = 2; i < str.Length; i+=2)
            {
                if (JudgeGu(str.Substring(0, str.Length - i)))
                {
                    Console.WriteLine(str.Length - i);
                    break;
                }
            }
        }

        static bool JudgeGu(string str)
        {
            if (str.Length % 2 != 0) return false;

            string sub = str.Substring(0, str.Length / 2);
            return (sub + sub) == str;
        }

        static void Main2(string str)
        {
            var kakaku = str.Split().Select(int.Parse).ToArray();
            Array.Sort(kakaku);
            Console.WriteLine(kakaku[0] + kakaku[1]);
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int biao[1000];
inline int search(int x) {
    int l = 1,r = 999;
    while (l <= r) {
        int mid = l+r>>1;
        if (biao[mid] == x) return mid;
        if (biao[mid] > x) r = mid-1;
        else l = mid+1;
    }
    return  -1;
}
int main() {
    int a,b;
    scanf("%d%d",&a,&b);
    biao[1] = 1;
    for (int i = 2;i <= 999;i++) biao[i] = biao[i-1]+i;
    for (int ans = 0;;ans++) {
        if (search(a+ans)+1 == search(b+ans)) {
            printf("%d",ans);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int>n(3);
    for (int i=0;i<3;i++) {
        cin>>n[i];
    }
    int k;
    cin>>k;
    int sum=0;

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

    for(int i=0;i<k;i++){
        n[2]+=n[2];
        sort(n.begin(),n.end());
    }

    cout<<n[0]+n[1]+n[2]<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX 51
#define inf (1e8)
using namespace std;

int n,m,a,b,c;
vector<int> re[MAX];
bool can[MAX][MAX][110]={};

int main()
{
  int x,y;

  cin>>n>>m>>a>>b>>c;

  for(int i=0;i<m;i++){
    cin>>x>>y;
    x--;y--;
    re[y].push_back(x);
  }

  for(int i=0;i<n;i++){
    queue<int> q;
    q.push(i);
    for(int j=1;j<110;j++){
      vector<int> v;
      while(!q.empty()){
	int now=q.front();
	q.pop();
	for(int k=0;k<re[now].size();k++){
	  int next=re[now][k];
	  if(!can[i][next][j]){
	    can[i][next][j]=true;
	    v.push_back(next);
	  }
	}
      }
      for(int k=0;k<v.size();k++)q.push(v[k]);
    }
  }
 
  queue<int> q;
  q.push(n-1);
  int dis[n];
  bool A[n],B[n],C[n];
  for(int i=0;i<n;i++){
    dis[i]=inf;
    A[i]=B[i]=C[i]=false;
  }
  dis[n-1]=0;
  while(!q.empty()){
    int now=q.front();
    q.pop();
    for(int i=0;i<n;i++){
      if(can[now][i][a])A[i]=true;
      if(can[now][i][b])B[i]=true;
      if(can[now][i][c])C[i]=true;

      if(A[i] && B[i] && C[i] && dis[i]==inf){
	dis[i]=dis[now]+1;
	q.push(i);
      }
    }
  }
  if(dis[0]==inf)cout<<"IMPOSSIBLE"<<endl;
  else cout<<dis[0]<<endl;
  return 0;
}

Measured memory_bytes: 1512
def to_key(s)
  s.gsub!('A', '1')
  s.gsub!('C', '2')
  s.gsub!('G', '3')
  s.gsub!('T', '4')
  s.to_i
end
def h1(key)
  key % 1046527
end
def h2(key)
  1 + (key % (1046527 - 1))
end

class Dict
  def initialize
    @arr = []
  end
  def insert(s)
    key = to_key(s)
    i = 0
    loop do
      h = (h1(key) + i * h2(key)) % 1046527
      if @arr[h] == s
        return
      elsif @arr[h].nil?
        @arr[h] = s
        return
      end
      i = i + 1
    end
  end
  def find(s)
    key = to_key(s)
    i = 0
    loop do
      h = (h1(key) + i * h2(key)) % 1046527
      if @arr[h] == s
        return true
      elsif @arr[h].nil?
        return false
      end
      i = i + 1
    end
    false
  end
end

n = STDIN.gets.to_i

dict = Dict.new
n.times.each {
  ss = STDIN.gets.split(' ')
  if ss[0] == 'insert' then
    dict.insert(ss[1])
  else
    if dict.find(ss[1]) then
      puts 'yes'
    else
      puts 'no'
    end
  end
}

Measured memory_bytes: 48764
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K; 
  cin >> N >> K;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int ans = 0;
  if(A[0] >= K){
    ans -= K-A[0];
    A[0] = K;
  }

  FOR(i, 1, N){
    if(A[i]+A[i-1] >= K){
      ans -= K-(A[i]+A[i-1]);
      A[i] = K-A[i-1];
    }
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
ll ma[111][111];
ll dp[111][111];
pair<ll,ll> nxt[111][111];
const int MAX_N = 2010;
ll row,col;
ll rui[MAX_N][MAX_N];
ll ele[MAX_N][MAX_N];
void make_sum(){
  for(int i=0;i<row;i++)
    for(int j=0;j<col;j++)
      rui[i+1][j+1] = ele[i][j] + rui[i+1][j] + rui[i][j+1] - rui[i][j];
}

ll get_sum(int lx,int ly,int rx,int ry){
  if(lx>rx||ly>ry)return 0;
  else return rui[rx][ry] - rui[lx][ry] - rui[rx][ly] + rui[lx][ly]; 
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll h,w;cin>>h>>w;
  row = h;col = w;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      char c;cin>>c;
      if(c=='#'){ma[i][j]=1;ele[i][j] = 1;}
      else ma[i][j]=0;
      dp[i][j]=llINF;
    }
  }
  make_sum();
 
  dp[0][0]=0;
  //cout<<get_sum(0,0,3,3)<<endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(ma[i][j]){
	if(ma[i+1][j]==0)dp[i+1][j] = min(dp[i+1][j],dp[i][j]+1);
	if(ma[i][j+1]==0)dp[i][j+1] = min(dp[i][j+1],dp[i][j]+1);
	for(int ii=i;ii<h;ii++){
	  for(int jj=j;jj<w;jj++){
	    if(get_sum(i,j,ii+1,jj+1) == (ii-i+1)*(jj-j+1)){
	      dp[ii][jj] = min(dp[ii][jj],dp[i][j]);
	    }
	  }
	}
      }else{
	dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
	dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
      }
    }
  }
  /*
   for(int i=0;i<=h;i++){
    for(int j=0;j<=w;j++)
      cout<<dp[i][j]<<" ";
    cout<<endl;
    }*/
  /*
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++)
      cout<<dp[i][j][1]<<" ";
    cout<<endl;
  }
  */
  //ll cnt=0;
  //if(ma[0][0])cnt++;
  //if(ma[h-1][w-1])cnt++;
  cout<<dp[h-1][w-1]+ma[h-1][w-1]<<endl;
  return 0;
}


Measured memory_bytes: 6912
// https://atcoder.jp/contests/abc164/tasks/abc164_e
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i, n) for(int i=0; i<(int)(n); ++i)

const int MAX_V = 50;
const int MAX_S = 50*MAX_V;
const ll INF = 1e18;

struct Edge {
  int to, a, b;
  Edge(int to, int a, int b):to(to), a(a), b(b) {}
};

struct Data {
  int v, s;
  ll x;
  Data(int v, int s, ll x):v(v), s(s), x(x) {}
  bool operator<(const Data& r) const {
    return x > r.x;
  }
};

vector<Edge> g[MAX_V];
ll dp[MAX_V][MAX_S+5];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int n, m, s;
  cin >> n >> m >> s;
  rep(i, m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    --u, --v;
    g[u].emplace_back(v, a, b);
    g[v].emplace_back(u, a, b);
  }
  vector<int> c(n), d(n);
  rep(i, n) cin >> c[i] >> d[i];
  rep(i, n) rep(j, MAX_S+5) dp[i][j] = INF;
  
  priority_queue<Data> q;
  auto push = [&] (int v, int s, ll x) {
    if (s < 0) return;
    if (dp[v][s] <= x) return;
    dp[v][s] = x;
    q.emplace(v, s, x);
  };
  push(0, min(s, MAX_S), 0);
  while (!q.empty()) {
    Data t = q.top(); q.pop();
    int v = t.v, s = t.s;
    ll x = t.x;
    // if (dp[v][s] != x) continue;
    push(v, min(s+c[v], MAX_S), x+d[v]);
    for (auto e : g[v]) {
      push(e.to, s-e.a, x+e.b);
    }
  }
  for (int i = 1; i < n; ++i) {
    ll ans = INF;
    rep(j, MAX_S+5) ans = min(ans, dp[i][j]);
    cout << ans << endl;
  }
}

Measured memory_bytes: 6264
h=[]
3.times do 
 a=gets.chomp.split.map(&:to_i)
  h.push(a)
end
h=h.flatten
c=gets.chomp.to_i
c.times do 
  d=gets.chomp.to_i
  if h.include?(d)
     t=h.index(d)
     h[t]=0
  end
end
f=0
1.times do 
 if h[0]==0&&h[1]==0&&h[2]==0
  puts "Yes"
   f+=1
   break
 end
 if h[3]==0&&h[4]==0&&h[5]==0
  puts "Yes"
   f+=1
   break
 end
 if h[6]==0&&h[7]==0&&h[8]==0
   f+=1
  puts "Yes"
   break
  end
  if h[0]==0&&h[3]==0&&h[6]==0
    puts "Yes"
    f+=1
   break
  end
   if h[1]==0&&h[4]==0&&h[7]==0
    puts "Yes"
     f+=1
   break
   end
   if h[2]==0&&h[5]==0&&h[8]==0
    puts "Yes"
     f+=1
   break
   end
   if h[0]==0&&h[4]==0&&h[8]==0
    puts "Yes"
     f+=1
   break
   end
   if h[2]==0&&h[4]==0&&h[6]==0
    puts "Yes"
     f+=1
   break
   end
end
if f==0
  puts "No"
end


Measured memory_bytes: 3836
#include<bits/stdc++.h>
using namespace std;
 
#define int long long
typedef long long ll; 
typedef vector<ll> vi; 
typedef pair<int, int> ii; 
typedef vector<ii> vii; 
typedef vector<vi> vvi;
#define F first
#define S second
#define pb emplace_back
#define M 1000000007
#define watch(x) cout << (#x) << " is " << (x) << endl
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr(i,a,b) for(int i = a; i<= b; i++)
#define all(c) c.begin(), c.end()
 

 
main() {
IOS;

    
    int k, x;
    cin >> k >> x;
    fr(i, -1000000, 1000000) {
        if (abs(i - x) < k) {
            cout << i << " ";
        }
    }
 
}
 
/*  Check for base cases such as n == 1
and cases like it where code can fail */

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;

    std::cout << 180 * (N - 2) << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
    int n  = sc.nextInt();
    
    if(n%1000 == 0) {
    	System.out.println("0");
    }else {
     	System.out.println(1000 - n%1000);
    }
}
}

Measured memory_bytes: 36244
#include<stdio.h>
int main()
{
    long int a,b,c,d,i,p=0,q=0;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&d);
    for(i=1;i<=a;i++){
        if(i>b){
            p+=d;
        }
        else{
            q+=c;
        }
    }
    printf("%ld\n",p+q);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N ;
	cin >> N ;
  
  if( N % 1110 <= 9 || N % 1000 % 111 == 0){
    cout << "Yes" << endl ;
  }
  else{
    cout << "No" << endl ;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main(){

	int N;
	map<int,int> M;
	scanf("%d",&N);
	for(int i=0,x;i<N;i++){
		scanf("%d",&x);
		M[x]++;
	}

	long long int A=0,B=0;
	for(auto it=M.end();it!=M.begin();it--){
		auto jt = it;
		jt--;
		if(jt->second>=2){
			if(!A){
				if(jt->second>=4){
					A=B=jt->first;
				}else{
					A=jt->first;
				}
			}
			else if(!B)B=jt->first;
		}
	}

	printf("%lld\n",A*B);


	return 0;
}


Measured memory_bytes: 4864
#include <stdio.h>

int main() {
  int num[5];
  int i, j;
  int temp;
  for(i = 0; i < 5; i++) {
    scanf("%d", &num[i]);
  }
  for(j = 0; j < 5; j++) {
    for(i = 4; i > j; i--) {
      if(num[i] > num[i-1]) {
	temp = num[i-1];
	num[i-1] = num[i];
	num[i] = temp;
      }
    }
  }
  for(i = 0; i < 5; i++) {
    printf("%d", num[i]);
    if(i < 4) printf(" ");
  }
  printf("\n");
  return 0;
}

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

int main()
{
    string s;
    int t;
    cin >> n;
    pair<pair<string, int>, int> p[n];
    for (int i = 0; i < n; i++) 
    {
        cin >> s >> t;
        p[i] = make_pair(make_pair(s, -t), i+1);
    }
    sort(p, p+n);
    for (int i = 0; i < n; i++) cout << p[i].second << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace CsProgramSpace
{
    class Program
    {
        static void Main(string[] args)
        {
            long[] temp;
            temp = Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray();
            long n = temp[0], m = temp[1], l = temp[2];
            long[][] a = new long[n][], b = new long[m][], c = new long[n][];
            for (long i = 0; i < n; i++)
            {
                a[i] = (Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray());
            }
            for (long i = 0; i < m; i++)
            {
                b[i] = (Console.ReadLine().Split(' ').Select(_ => long.Parse(_)).ToArray());
            }
            string s = "";
            for (long i = 0; i < n; i++)
            {
                c[i] = new long[l];
                for (long j = 0; j < l; j++)
                {
                    for (long k = 0; k < m; k++)
                    {
                        c[i][j] += a[i][k] * b[k][j];
                    }
                }
            }
            for (long i = 0; i < n; i++)
            {
                for (long j = 0; j < l; j++)
                {
                    s += c[i][j] + " ";
                }
                s = s.Remove(s.Length - 1);
                Console.WriteLine(s);
                s = "";
            }
        }
    }
}


Measured memory_bytes: 22608
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;

class UnionFind {
  public:
    vi Parent;
    UnionFind(int N) {
      Parent = vi(N,-1);
    }
  
    int root(int A) {
      if(Parent[A] < 0) return A;
      return Parent[A] = root(Parent[A]);
    }
  
    int size(int A) {
      return -Parent[root(A)];
    }
  
    bool connect(int A,int B) {
      A = root(A);
      B = root(B);
      if(A == B) return false;
      if(size(A) < size(B)) swap(A,B);
      Parent[A] += Parent[B];
      Parent[B] = A;
      return true;
    }
};
  
int main() {
  int n,m;
  cin >> n >> m;
  UnionFind uf(n);
  rep(i,m) {
    int a,b;
    cin >> a >> b;
    a--;b--;
    uf.connect(a,b);
  }
  map<int,int> mp;
  rep(i,n) {
    mp[uf.root(i)]++;
  }
  cout << sz(mp)-1 << endl;
  return 0;
}

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

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

  vector<int long long> a(100);

  a[0] = 2;
  a[1] = 1;

  for(int i = 2;i <= n;i++){
    a[i] = a[i-1]+a[i-2];
  }

  cout << a[n] <<endl;
}


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

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

int main() {
        int n;
        cin >> n;
        deque<int> dq;
        rep(i, n) {
                int a;
                cin >> a;
                if (n & 1) {
                        if (i & 1) dq.push_front(a);
                        else dq.push_back(a);
                } else {
                        if (i & 1) dq.push_back(a);
                        else dq.push_front(a);
                }
        }
        while (!dq.empty()) {
                cout << dq.back();
                if (dq.size() != 1) cout << ' ';
                else cout << endl;
                dq.pop_back();
        }
        return 0;
}



Measured memory_bytes: 2944
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

#define N               200005
#define ff              first
#define ss              second
#define ll              long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define mii             map<ll,ll>
#define pq_max          priority_queue<ll>
#define pq_min          priority_queue<ll,vi,greater<ll> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define inp(arr,n)      for(ll x=0;x<n;x++) cin>>arr[x];
#define w(x)            ll x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void fio(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

int main(){
    fio();

    ll j;
    cin>>j;
    if(j == 0) cout<<1;
    else cout<<0;
    return 0;
}

Measured memory_bytes: 3620
package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	max := func(a, b int) int {
		if a > b {
			return a
		}
		return b
	}

	var n, maxW int
	Fscan(in, &n, &maxW)
	w := make([]int, n)
	v := make([]int, n)
	for i := range w {
		Fscan(in, &w[i], &v[i])
	}
	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, maxW+1)
	}
	for i, vi := range v {
		wi := w[i]
		for j, dpij := range dp[i] {
			if j < wi {
				dp[i+1][j] = dpij
			} else {
				dp[i+1][j] = max(dpij, dp[i][j-wi]+vi)
			}
		}
	}
	Fprintln(out, dp[n][maxW])
}

func main() { run(os.Stdin, os.Stdout) }


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	string S,T="AKIHABARA";
	cin>>S;
	x=0;
	FORR(c,T) {
		if(c=='A') {
			if(x<S.size()&&S[x]=='A') x++;
		}
		else {
			if(x==S.size() || S[x]!=c) return _P("NO\n");
			x++;
		}
	}
	if(x<S.size()) return _P("NO\n");
	cout<<"YES"<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


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

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  string s;
  cin >> s;

  string ts = s;
  for (;;) {
    size_t pos = ts.find("()");
    if (pos == string::npos) break;
    ts.replace(pos, 2, "");
  }

  int cb = 0, ce = 0;;
  for (string::iterator i = ts.begin(); i != ts.end(); ++i) {
    (*i == '(')? cb++ : ce++;
  }
  s = string(ce, '(') + s + string(cb, ')');
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

var a = []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
var i int
func main() {
	fmt.Scan(&i)
	fmt.Println(a[i-1])
}


Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
#define f first
#define s second
const int N = 2e5+100;
long long int tree[4*N];
long long int temp=-1e16;
long long int power(long long int x,long long int y,long long int mod)
{
    long long int res=1LL;
    while(y>0)
    {
        if(y&1) res=(res*x)%mod;
        y>>=1;
        x=(x*x)%mod;
    }
    return res;
}
bool compare(pair<long long int,long int> a,pair<long long int,long int> b)
{
    return a.s<b.s;
}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void update(long int node,long int l,long int r,long int ind,long int val)
{
    if(l==r)
    {
        tree[node]=val;
    }
    else
    {
        long int mid=(l+r)/2;
        if(ind<=mid)
        update(2*node+1,l,mid,ind,val);
        else
        update(2*node+2,mid+1,r,ind,val);
        tree[node]=max(tree[2*node+1],tree[2*node+2]);
    }
}
long long int query(long int node,long int l,long int r,long int L,long int R)
{
    if(r<L || R<l)
    return temp;
    else if(L<=l && R>=r)
    return tree[node];
    else
    {
        long int mid=(l+r)/2;
        return max(query(2*node+1,l,mid,L,R),query(2*node+2,mid+1,r,L,R));
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long int n;
    cin>>n;
    pair<long long int,long long int> a[n];
    for(long int i=0;i<n;i++)
    {
        cin>>a[i].f;
    }
    for(long int i=0;i<n;i++)
    cin>>a[i].s;
    long long int ans=0;
    for(long int i=0;i<n;i++)
    {
        long long int ans1 = query(0,0,n,1,a[i].f);
        ans1+=a[i].s;
        ans=max(ans1,ans);
        update(0,0,n,a[i].f,ans1);
    }
    cout<<ans;
	// your code goes here
	return 0;
}


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

int main(){

	ll n, m, ans=1;
	cin >> n >> m;

	if(n==m){
		for(int i=1; i<=n; i++){
			ans*=i;
			ans%=1000000007;
			ans*=i;
			ans%=1000000007;
		}
		ans*=2;
		ans%=1000000007;
	} else if(abs(n-m)>=2){
		cout << 0 << endl;
		return 0;
	} else {
		if(n<m){
			for(int i=1; i<=m; i++){
				ans*=i;
				ans%=1000000007;
			}
			for(int i=1; i<=n; i++){
				ans*=i;
				ans%=1000000007;
			}
		} else {
			for(int i=1; i<=n; i++){
				ans*=i;
				ans%=1000000007;
			}
			for(int i=1; i<=m; i++){
				ans*=i;
				ans%=1000000007;
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
let readString() = stdin.ReadLine()
let readStringArray() = stdin.ReadLine().Split(' ');
let readInt() = readString() |> int
let readIntArray() = readStringArray() |> Array.map (fun x -> int x)

let a, b = readIntArray() |> fun x -> (x.[0], x.[1])

match (a, b) with 
| (a, _) when a % 3 = 0 -> "Possible"
| (_, b) when b % 3 = 0 -> "Possible"
| (a, b) when (a + b) % 3 = 0 -> "Possible"
| _ -> "Impossible"
|> printfn "%s"

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

int main(){
  int N;
  int l, r;
  int s=0;
  
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> l >> r;
    s+=r-l+1;
  }
  cout << s << endl;
}

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

int calc_next(int a, int b, char s){
  if(s=='o'){
    if(a==b) return 1;
    else return 0;
  }else{
    if(a==b) return 0;
    else return 1;
  }
}
 
int main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int a[n+2];
  for(int i=0; i<2; i++){
    for(int j=0; j<2; j++){
      bool ok=false;
      a[0] = i;
      a[1] = j;
      for(int i=2; i<n+2; i++){
        a[i]=calc_next(a[i-2],a[(i-1)%n],s[(i-1)%n]);
      }
      if(a[0]==a[n]&&a[1]==a[n+1]) ok = true;
      if(ok){
        for(int k=0; k<n; k++){
          if(a[k]==1) cout << "S";
          else cout << "W";
        }
        cout << endl;
        return 0;
      }
      
    }
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;

int main(){
    ll N; cin >> N;
    vector<ll> d(N);
    for(int i=0;i<N;++i){
        cin >> d[i] ;
    }
    sort(d.begin(),d.end());
    ll res = 0;
    for(int i=0;i<N;++i){
        ll cur , par;
        cur = d[i];
        if(i == N/2){
            res = cur - par;
            break;
        }
        par = cur;
    }
    cout << res << endl;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
const int mm=1e6;
ll mod=2019;
map<ll,ll> name;
int main()
{
	ll n,m,i,j,k,kk,a,b,t,d,ans,num;
	string s; 
	cin>>s;
	d=1;
	num=0;
	ans=0;
	name[0]=1;
	for(i=s.size()-1;i>=0;i--)
	{
		num+=((s[i]-'0')*d%mod);
		num%=mod;
		name[num]++;
//		cout<<num<<endl;
		if(name[num]>0)
		ans+=(name[num]-1);
		d=d*10%2019;
	}
	cout<<ans<<endl;

}

Measured memory_bytes: 3704
/* Tejus Tiwari */
#include <bits/stdc++.h>
using namespace std;
#define ff                first
#define ss                second
#define INF               1e18L+1
#define pb                push_back
#define mp                make_pair
#define all(v)            v.begin(),v.end()
#define f(i,a,b,c)        for( i=a; i<b;i+=c)
#define rf(i,a,b,c)       for( i=b-1;i>=a;i-=c)
#define fo(i,n)           for( i=0; i < n ; i++)
#define rfo(i,n)          for( i=n-1; i >=0 ; i--)
#define MEM(a,b)          memset(a, (b), sizeof(a))
#define alldec(v)         v.begin(),v.end(),greater<int>()
#define fio               ios_base::sync_with_stdio(false); cin.tie(0);
#define dbg1(x)           cout<<#x<<"="<<x<<endl;
#define dbg2(x,y)         cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define dbg3(x,y,z)       cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
#define dbg4(x,y,z,w)     cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<" "<<#w <<"="<<w<<endl;
#define dbgarray(arr,n)   for(int i=0;i<n;i++) {cout<<"i="<<i<<" arr[i]="<<arr[i]<<"\n";}
#define dbgmatrix(a,n,m)  cout<<setw(5*m+8)<<"MATRIX\n\n";for(int i=0;i<n;i++){for(intj=0;j<m;j++){cout<<setw(10)<<a[i][j];}cout<<"\n";}
typedef long long int ll; typedef vector<int> vi; typedef vector<ll> vll;   typedef pair<int,int>	pi;  typedef pair<ll,ll>	 pll;
const  ll M =1000000007;  /* const ll M = 998244353; */     /* const double PI = 3.141592653589793; */  vll primefactors, factors, fact;
bool isPowerTwo(ll x)     {return (x && !(x & (x - 1))); }
ll   modadd(ll a,ll b)    {return((a%M)+(b%M)+M)%M;} ll modsub(ll a,ll b){return((a%M)-(b%M)+M)%M;}ll modmul(ll a,ll b){return((a%M)*(b%M))%M;}
void getFactorial(ll n)   {fact.pb(1);for(ll i=1;i<=n;i++)fact.pb((i*1ll*fact[i-1])%M);}
bool isPrime(ll n)        {if(n<2)return false;for(ll i=2;i*i<=n;i++)if(n%i==0)return false;return true;}
ll   power(ll a, ll b)    {ll res=1;while(b){if(b&1) res=(res*a);a=(a*a);b>>=1;}return res;}
ll   powerM(ll a, ll b)   {ll res=1;while(b){if(b&1) res=(res*a)%M;a=(a*a)%M;b>>=1;}return res;}
ll   modi (ll a)          {ll m=M,s=1,p=0; while(a>1){ll q=a/m,t=m;m=a%m;a=t;t=p;p=s-q*p;s=t;}return s>=0?s:s+M;}
void getPrimeFactors(ll n){primefactors.clear();for(ll i=2;i*i<=n;i++){if(n%i==0){primefactors.pb(i);while(n%i==0)n=n/i;}}if(n!=1)primefactors.pb(n);}
ll   ncr(ll n, ll r)      {if(r==0)return 1;fact[0]=1;for(int i=1;i<=n;i++)fact[i]=fact[i-1]*i%M;return(fact[n]*modi(fact[r])%M*modi(fact[n-r])%M)%M;}
void getFactors(ll n)     {factors.clear();for(ll i=1;i*i<=n;i++){if(n%i==0){factors.pb(i);if(n/i!=i)factors.pb(n/i);}}sort(all(factors));}

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

int main()
{
  fio
  ll i,n; cin>>n;
  ll flg=0,cnt=0;
  fo(i,n){
    ll a,b;
    cin>>a>>b;
    if(a==b)
      cnt++;
    else
      cnt=0;
    if(cnt==3)
      flg=1;
  }
  cout << (flg ? "Yes" : "No") ;
return 0;
}

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


Measured memory_bytes: 3656
move = {
	("000", "lu") : ("010", 0), ("000", "ru") : ("001", 0), 
	("010", "ld") : ("000", 0), ("001", "rd") : ("000", 0),
	("010", "ru") : ("111", 1), ("001", "lu") : ("111", 1),
	("111", "ld") : ("101", 0), ("111", "rd") : ("110", 0),
	("101", "lu") : ("111", 0), ("110", "ru") : ("111", 0),
	("101", "rd") : ("000", 1), ("110", "ld") : ("000", 1)
	}
while 1:
	n = int(raw_input())
	if n == 0:
		break
	f = raw_input().split(" ")
	status = "000"
	count = 0
	for foot in f:
		status, result = move[(status,foot)]
		count += result
	print count

Measured memory_bytes: 4260
a=input()
b=input()

flag=0

if len(a)==1 and len(b)==1:
  if int(b) < int(a):
    print('GREATER')
    flag=1
  elif int(b) > int(a):
    print('LESS')
    flag=1
  else:
    print('EQUAL')
    flag=1
    
if len(a)==1 and len(b) > 1:
    print('LESS')
    flag=1
    
if len(a) > 1 and len(b)==1:
    print('GREATER')
    flag=1

if len(b) < len(a) and flag==0:
  print('GREATER')
  flag=1
if len(b) > len(a) and flag==0:
  print('LESS')
  flag=1

  
if len(a)==len(b):  
  for i in range(len(a)):
    if b[i] < a[i] and flag==0:
      print('GREATER')
      flag=1
    elif b[i] > a[i] and flag==0:
      print('LESS')
      flag=1
    
if flag==0:
  print('EQUAL')
  

Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr); //入出力高速化
  string L; cin >> L;
  int N = L.size();
  vector<vector<ll>> dp(N+1, vector<ll>(2));
  dp[0][0] = 1;
  rep(i,N) {
    if (L[i] == '1') {
      dp[i+1][0] = dp[i][0] * 2 % MOD;
      dp[i+1][1] = ((dp[i][1] * 3 % MOD) + dp[i][0]) % MOD;
    } else {
      dp[i+1][0] = dp[i][0];
      dp[i+1][1] = dp[i][1] * 3 % MOD;
    }
  }

  ll ans = (dp[N][0] + dp[N][1]) % MOD;
  cout << ans << endl;
}

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

const int sz=1e6+10;

void solve()
{
    string s;
    cin>>s;

    ll y=s.size();
    ll sum=0,prev=1,i;

    for(i=y-1;i>=0;i--)
    {
        ll x=s[i]-'0';
        sum+=x;
    }
    if(sum%9) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

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

    int t=1;
    //cin>>t;

    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3728
#include <iostream>
#include <utility>
#include <vector>
#include <stack>
using namespace std;

int numpath(int cur, vector<int> visited, vector<pair<int, int> > p){
	visited[cur]=1;
	int r=0;
	int f=0;
	for(int &n: visited){
		if(n==0) f=1;
	}
	if(f==0) return 1;
	else{
		for(pair<int, int> &n: p){
			if(n.first==cur && visited[n.second]==0){
				r+=numpath(n.second, visited, p);
			}
		}
		return r;
	}
}

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

	vector<pair<int, int> > p(2*m);

	for(int i=0; i<m; i++){
		int j, k;
		cin >> j >> k;
		p[i]=make_pair(j, k);
		p[m+i]=make_pair(k, j);
	}

	int r;
	vector<int> visited(n+1,0);
	visited[0]=1;

	r=numpath(1,visited,p);

	cout << r << endl;

	return 0;

}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  int add = a + b;
  int sub = a - b;
  int mul = a * b;
  int ans = add > sub ? (add > mul ? add : mul) : (sub > mul ? sub : mul);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n,T;
  cin>>n>>T;
  vector<pair<int,int>> v;
  for(int i=0;i<n;i++){
    int c,t;
    cin>>c>>t;
    v.push_back(make_pair(t,c));
  }

  sort(v.begin(),v.end());
  if(v[0].first>T) cout<<"TLE"<<endl;
  else{
    int ans=10000;
    for(int i=0;i<n;i++){
      if(v[i].first<=T){
        ans=min(ans,v[i].second);
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}


Measured memory_bytes: 256