akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>

int main(void)
{
	printf("1x1=1\n");
	printf("1x2=2\n");
	printf("1x3=3\n");
	printf("1x4=4\n");
	printf("1x5=5\n");
	printf("1x6=6\n");
	printf("1x7=7\n");
	printf("1x8=8\n");
	printf("1x9=9\n");
	printf("2x1=2\n");
	printf("2x2=4\n");
	printf("2x3=6\n");
	printf("2x4=8\n");
	printf("2x5=10\n");
	printf("2x6=12\n");
	printf("2x7=14\n");
	printf("2x8=16\n");
	printf("2x9=18\n");
	printf("3x1=3\n");
	printf("3x2=6\n");
	printf("3x3=9\n");
	printf("3x4=12\n");
	printf("3x5=15\n");
	printf("3x6=18\n");
	printf("3x7=21\n");
	printf("3x8=24\n");
	printf("3x9=27\n");
	printf("4x1=4\n");
	printf("4x2=8\n");
	printf("4x3=12\n");
	printf("4x4=16\n");
	printf("4x5=20\n");
	printf("4x6=24\n");
	printf("4x7=28\n");
	printf("4x8=32\n");
	printf("4x9=36\n");
	printf("5x1=5\n");
	printf("5x2=10\n");
	printf("5x3=15\n");
	printf("5x4=20\n");
	printf("5x5=25\n");
	printf("5x6=30\n");
	printf("5x7=35\n");
	printf("5x8=40\n");
	printf("5x9=45\n");
	printf("6x1=6\n");
	printf("6x2=12\n");
	printf("6x3=18\n");
	printf("6x4=24\n");
	printf("6x5=30\n");
	printf("6x6=36\n");
	printf("6x7=42\n");
	printf("6x8=48\n");
	printf("6x9=54\n");
	printf("7x1=7\n");
	printf("7x2=14\n");
	printf("7x3=21\n");
	printf("7x4=28\n");
	printf("7x5=35\n");
	printf("7x6=42\n");
	printf("7x7=49\n");
	printf("7x8=56\n");
	printf("7x9=63\n");
	printf("8x1=8\n");
	printf("8x2=16\n");
	printf("8x3=24\n");
	printf("8x4=32\n");
	printf("8x5=40\n");
	printf("8x6=48\n");
	printf("8x7=56\n");
	printf("8x8=64\n");
	printf("8x9=72\n");
	printf("9x1=9\n");
	printf("9x2=18\n");
	printf("9x3=27\n");
	printf("9x4=36\n");
	printf("9x5=45\n");
	printf("9x6=54\n");
	printf("9x7=63\n");
	printf("9x8=72\n");
	printf("9x9=81\n");
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int ans[10100];
int calc[10100];
void print(int r){
	cout<<ans[0]<<".";
	for(int i=1;i<=r;i++)	cout<<ans[i];
	cout<<endl;
	return;
}
int main(){
	int n,k,m,r;
	while(1){
		scanf("%d %d %d %d",&n,&k,&m,&r);
		if(n==0)	return 0;
		int temp=1;
		memset(ans,0,sizeof(ans));
		for(int i=0;i<10100;i++){
			ans[i]+=temp/n;
			temp=(temp%n)*10;
			if(temp==0)	break;
		}
		if(m==0){
			print(r);
			continue;
		}
		for(int i=1;i<n;i++){
			memset(calc,0,sizeof(calc));
			temp=1;
			for(int j=0;j<10100;j++){
				calc[j]=temp/(n*i);
				temp=(temp%(n*i))*10;
				if(temp==0)	break;
			}
			temp=0;
			for(int j=10099;j>=0;j--){
				ans[j]+=calc[j]+temp;
				temp=ans[j]/10;
				ans[j]%=10;
			}
		}
		print(r);
	}
	return 0;
}

Measured memory_bytes: 1292
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int n,k;
  cin >> n >> k;
  vector<int> x(n);
  for(auto& i:x)
    cin >> i;
  int sum = 0;
  for(int i = 0; i < n; i++){
    sum += (x[i] < (k - x[i]) ? x[i] : k - x[i]);
  }
  cout << sum * 2 << endl;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
S = input()
cnt = 0
cnt1 = 0
for i in range(len(S)):
    if S[i]=="a" or S[i]=="b":
        if S[i]=="a" and cnt<A+B:
            print("Yes")
            cnt+=1
        elif S[i]=="b"and cnt<A+B and cnt1<B:
            print("Yes")
            cnt+=1
            cnt1+=1
        else:
            print("No")
    else:
        print("No")

Measured memory_bytes: 4016
#include <iostream>
#include <string>

using namespace std;

int main(void) {
    string S;
    cin >> S;

    for(int i=0; i<S.size(); i++) {
        if(i%2 && S[i] == 'R' || i%2 == 0 && S[i] == 'L') {
            cout << "No" << endl;
            return 0;
        }
    }

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


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
signed main() {
	int a, b;
	cin >> a >> b;
	cout << b * 2 - a << endl;
	ggr
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b int
	var gcd, lcm int

	for {
		_, err := fmt.Scanf("%d %d", &a, &b)
		if err != nil {
			return
		}

		var big, small int
		// GCD
		if a > b {
			big = a
			small = b
		} else {
			big = b
			small = a
		}

		for {
			if big%small == 0 {
				gcd = small
				break
			} else {
				small, big = big%small, small
			}
		}

		// LCM
		lcm = a * b / gcd

		fmt.Println(gcd, lcm)
	}
}



Measured memory_bytes: 1160
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var nmc = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var bi = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var count = 0;
            for (var i = 0; i < nmc[0]; i++)
            {
                var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var sum = 0;
                for (var j = 0; j < ai.Length; j++)
                {
                    sum += ai[j] * bi[j];
                }
                sum += nmc[2];
                if (sum > 0) count++;
            }
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13396
namespace AdhocFs

open System

module Program =
  let modulo = 1000000007L
  let maxH = 100000
  let maxW = 100000

  module Field =
    let p = modulo

    let add x y =
      (x + y) % p

    let mul x y =
      (x * y) % p

    let pow x n =
      assert (n >= 0L)
      let rec loop x n =
        if n = 0L then
          1L
        elif n = 1L then
          x
        elif n % 2L = 0L then
          loop (mul x x) (n / 2L)
        else
          mul x (loop x (n - 1L))
      in loop x n

    let inverse x =
      pow x (p - 2L)

    /// facts.[i] = i!
    /// factInverses.[i] = (i!)^(-1)
    let (facts, factInverses) =
      let length = (maxH + maxW) + 1
      let fs = Array.zeroCreate length
      let fis = Array.zeroCreate length

      // 0! = 1
      fs.[0] <- 1L
      fis.[0] <- 1L

      // (i + 1)! = i! * (i + 1)
      for i in 0..(length - 2) do
        fs.[i + 1] <- fs.[i] |> mul ((i + 1) |> int64)
        fis.[i + 1] <- fs.[i + 1] |> inverse

      (fs, fis)

    let fact n =
      facts.[n]

    let factInverse n =
      factInverses.[n]

    let rec combi n r =
      if n < 0 || not (0 <= r && r <= n) then
        0L
      elif r > n / 2 then
        combi n (n - r)
      else
        fact n
        |> mul (factInverse (n - r))
        |> mul (factInverse r)

  [<EntryPoint>]
  let main argv =
    // h * w の矩形の左上マスから右下マスへ行く方法の個数 (mod modulus)
    let countWays h w =
      let y = h - 1
      let x = w - 1
      in Field.combi (y + x) y

    let [|h; w; a; b|] = Console.ReadLine().Split([|' '|]) |> Array.map int

    // マス (y, x) を通って右下へ行く経路の個数
    let countWaysVia y x =
      countWays (y + 1) (x + 1)
      |> Field.mul (countWays (h - y) (w - x))
      
    let solve () =
      let rec loop acc i =
        let y = h - 1 - a - i
        let x = b + i
        if not (0 <= y && x < w) then
          acc
        else
          loop (Field.add acc (countWaysVia y x)) (i + 1)
      in loop 0L 0

    printfn "%d" (solve ())

    // exit code
    0


Measured memory_bytes: 6868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const ll INF = mod * mod;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)

int main() {
    int N; cin >> N;
    vector<int> P(N + 10); rep(i, N) cin >> P[i];
    
    int minimum = P[0];
    int ans = 0;
    rep(i, N) {
        if (P[i] <= minimum) ans++;
        minimum = min(P[i], minimum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main()
{
	int num1,num2;
	int num3, gcd;
	int temp;

	scanf("%d %d", &num1, &num2);

	if(num1 < num2){
		temp = num1;
		num1 = num2;
		num2 = temp;
	}
    
    num3 = num1 % num2;
    gcd = num2;
    while(num3 != 0){
    	num1 = gcd;
    	gcd = num3;
    	num3 = num1 % gcd; 
    }

    printf("%d\n", gcd);
    return 0;

}


Measured memory_bytes: 2056
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

ll n, k, x, y, t, ans;
int main() {
	cin >> n;
	if(n==2) return puts("1")*0;
	for(k=1; k*k<=n; k++) {
		if(n%k) continue;
		x = k;
		if(x > 1) {
			for(t=n; t%x==0; ) t/=x;
			if(t%x==1) ans++;
		}
		y = n / k;
		if(y != x) {
			for(t=n; t%y==0; ) t/=y;
			if(t%y==1) ans++;
		}
	}
	for(k=1; k*k<=n-1; k++) {
		if((n-1) % k == 0) {
			if(k==1 || k*k==n-1) ans++;
			else ans += 2;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int n, len, tot = 1; 
char ch[N]; 
struct node {
	int sp, ch[3], ed;
} c[N * 10]; int cnt = 1;
inline void insert (int x) {
	int now = 1, tmp = x;
	for (int i = 0; i < n; ++i) {
		int m = x % 3; x /= 3;
		if (!c[now].ch[m]) c[now].ch[m] = ++cnt;
		now = c[now].ch[m];
	} c[now].ed = tmp;
}
inline void add () {
	int now = 1;
	for (int i = 0; i < n; ++i) {
		if (c[now].sp) {
			swap (c[now].ch[1], c[now].ch[2]); c[now].sp = 0;
			for (int j = 0; j < 3; ++j) c[c[now].ch[j]].sp ^= 1;
		} int t = c[now].ch[2]; 
		c[now].ch[2] = c[now].ch[1], c[now].ch[1] = c[now].ch[0];
		c[now].ch[0] = t, now = t;
	}
} int res[N * 10];
void dfs (int now, int dp, int g, int s) {
	if (c[now].sp) {
		swap (c[now].ch[1], c[now].ch[2]); c[now].sp = 0;
		for (int i = 0; i < 3; ++i) c[c[now].ch[i]].sp ^= 1;
	} if (dp == n) { res[c[now].ed] = s; return; }
	for (int i = 0; i < 3; ++i) dfs (c[now].ch[i], dp + 1, g * 3, s + g * i);
}
signed main() {
	scanf ("%d %s", &n, ch + 1);
	len = strlen (ch + 1);
	for (int i = 1; i <= n; ++i) tot *= 3;
	for (int i = 0; i < tot; ++i) insert (i);
	for (int i = 1; i <= len; ++i)
		if (ch[i] == 'S') c[1].sp ^= 1; else add ();
	dfs (1, 0, 1, 0);
	for (int i = 0; i < tot; ++i) printf ("%d ", res[i]);
	return puts (""), 0;
}

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<pair<int,int>> v;
  for(int i = 1; i <= n; i++){
    int x, y;
    cin >> x >> y;
    v.push_back({x, y});
  }
  int result = 0;
  for(int i = 1; i < v.size(); i++)
    if(v[i].second < v[0].second)
      swap(v[0], v[i]);
  sort(v.begin() + 1, v.end());

  for(int i = 0; i < v.size(); i++)
    result = max(result, v[i].second - v[i].first + 1);

  for(int i = 1;i < v.size() - 1; i++)
    result = max(result, (v[i].second - v[i].first + 1) + (v[0].second - max(v[0].first, v.back().first) + 1));


  int minr = v.back().second;
  for(int i = v.size() - 1; 1 <= i; i--){
    minr = min(minr, v[i].second);
    result = max(result, (minr - v.back().first + 1) + (v[0].second - max(v[0].first, v[i - 1].first) + 1));
  }
  cout << result;
  return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char input;
  cin >> input;
    
  if (input=='a'||input=='e'||input=='i'||input=='o'||input=='u'){
  	cout << "vowel" << endl;
  }else{
  	cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int a,b,c,d,e,f,g,h,i,sum=0;
    cin>>a>>b;
    vector<long long int>vec;
    for(i=0;i<a;i++)
    {
        cin>>c;
        vec.push_back(c);

    }
    sort(vec.begin(),vec.end());
if(a<=b)
    cout<<0<<endl;
else
{

    for(i=0;i<vec.size()-b;i++)
    {
        sum+=vec[i];
    }
    cout<<sum<<endl;



}



}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799;

int n;
int ans = 0;

int main(){
 cin >> n;
  for(int i = 1; i <= n; i++){
    if(1<=i&&i<10) ans++;
    if(100<=i&&i<1000) ans++;
    if(10000<=i&&i<100000) ans++;
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define loop(n) for(int i=0;i<n;i++)
using namespace std;
int main()
{
    int arr[3]={0},a;
    for(int i=0;i<2;i++){
        cin>>a;
        arr[a-1]++;
    }
    for(int i=0;i<3;i++){
        if(arr[i]==0){
            cout<<i+1;
        }
    }
	return 0;
}


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


int main(){
    int n;
    string s;
    cin>>n>>s;
    string ans;
    ans.resize(n);
    char l,r;
    for(int i=0; i<2; i++){
        if(i==0)l='S';else{l='W';}
        for(int j=0; j<2; j++){
            if(j==0)r='S';else{r='W';}
            ans[0]=l;ans[1]=r;
            for(int k=2; k<n; k++){
                ans[k]=(s[k-1]=='o')?((ans[k-1]=='S')?(ans[k-2]):((ans[k-2]=='S')?('W'):('S'))):((ans[k-1]=='S')?((ans[k-2]=='S')?('W'):('S')):(ans[k-2]));
            }
            char judge_c1=((s[n-1]=='o')?((ans[n-1]=='S')?(ans[n-2]):((ans[n-2]=='S')?('W'):('S'))):((ans[n-1]=='S')?((ans[n-2]=='S')?('W'):('S')):(ans[n-2])));
            char judge_c2=((s[0]=='o')?((ans[0]=='S')?(ans[n-1]):((ans[n-1]=='S')?('W'):('S'))):((ans[0]=='S')?((ans[n-1]=='S')?('W'):('S')):(ans[n-1])));
            bool judge=judge_c1==ans[0]&&judge_c2==ans[1];
            //cout<<l<<"-"<<r<<" : "<<judge_c1<<','<<judge_c2<<'-'<<ans[0]<<','<<ans[1]<<' '<<ans<<endl;
            if(judge){
                cout<<ans<<endl;
                return 0;
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}



Measured memory_bytes: 512
import sys
input = sys.stdin.buffer.readline

n = int(input())
a = list(map(int, input().split()))
mod = 10**9+7
from fractions import gcd

l = a[0]
for i in range(1,n):
  l = l*a[i]//gcd(l,a[i])

ans = 0
for i in range(n):
  ans += l//a[i]

print(ans%mod)


Measured memory_bytes: 5616
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    N, X = intin()
    xlist = intina()

    x_relative_list = [x - X for x in xlist]

    ans = None
    for xr in x_relative_list:
        xr = abs(xr)
        if ans is None:
            ans = xr
            continue
        ans = lcm(ans, xr)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14572
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

#define REP(i,n) for (int i=0;i<(n);i++)
#define PII pair<int,int>
#define LL long long

void swap(LL a[], int n) {
  REP(i,n/2) {
    LL temp = a[i];
    a[i] = a[n - i - 1];
    a[n - i - 1] = temp;
  }

  return;
}

int main(){
  LL n,m;
  LL b[200000];
  LL a;

  cin >> n;
  a = (n % 2 == 0) ? -1 : 1;
  m = n / 2;
  
  REP(i, n) {
    if (i % 2 == 0) {
      cin >> b[m - a*i / 2];
    }
    else {
      cin >> b[m + a*(i + 1) / 2];
    }
  }

  REP(i, n) {
    cout << b[i] << " ";
  }
  
  cout << endl;

  return 0;
}



Measured memory_bytes: 3712
#include<iostream>
#include<string>
#include<iomanip>
#include<algorithm>
#include<stdio.h>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<cstdlib>

using namespace std;

int main(void){

	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a,a+3);
	cout << (a[2] - a[1] ) + (a[1] - a[0]) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <locale>
#include <iostream>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> int len(const T &x) { return x.size(); }

template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
  auto val = table(args...);
  return vector<decltype(val)>(n, move(val));
}

struct yes_no : numpunct<char> {
  string_type do_truename()  const { return "Yes"; }
  string_type do_falsename() const { return "No"; }
};

void solve(ll N, ll M, vector<ll> a, vector<ll> b, vector<ll> c, vector<ll> d) {
  REP(i,N) {
    vector<pair<int,int>> vec;
    REP(j,M) {
      int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
      vec.emplace_back(dist, j + 1);
    }
    cout << min_element(ALL(vec))->second << endl;
  }
}

int main() {
  locale loc(locale(), new yes_no);
  cout << boolalpha << setprecision(12) << fixed;
  cout.imbue(loc);
	ll N;
	ll M;
	scanf("%lld", &N);
	vector<ll> a(N-1+1);
	vector<ll> b(N-1+1);
	scanf("%lld", &M);
	vector<ll> d(M-1+1);
	vector<ll> c(M-1+1);
	for (int i = 0 ; i <= N-1 ; i++) {
	  scanf("%lld", &a[i]);
	  scanf("%lld", &b[i]);
	}
	for (int i = 0 ; i <= M-1 ; i++) {
	  scanf("%lld", &c[i]);
	  scanf("%lld", &d[i]);
	}
	solve(N, M, a, b, c, d);
	return 0;
}


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

int main(){
    int N, D;
    long p, q;
    int count=0;

    scanf("%d %d", &N, &D);
    
    for(int i=0; i<N; i++){
        scanf("%ld %ld", &p, &q);
        if(sqrt(p*p+q*q) <= D){
            count++;
        }
    }
    
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 2124
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func stringifyArray(arr []int) string {
	return strings.TrimRight(fmt.Sprintf("%+v", arr)[1:], "]")
}

// LeftChild returns index of the left child of the current node
func LeftChild(i int) int {
	return 2*i + 1
}

// RightChild returns index of the right child of the current node
func RightChild(i int) int {
	return 2 * (i + 1)
}

// Parent returns index of the parent node of the current node
func Parent(i int) int {
	return (i - 1) / 2
}

// NewMaxHeap creates MaxHeap object
func NewMaxHeap(content []int) *MaxHeap {
	maxheap := &MaxHeap{content: content}
	return maxheap
}

// MaxHeap is
// - content: zero-indexed array
type MaxHeap struct {
	heapSize int
	content  []int
}

func (h MaxHeap) maxHeapify(i int) {
	l := LeftChild(i)
	r := RightChild(i)

	// fmt.Println(i, l, r, a)

	var largest int
	if (l < h.heapSize) && (h.content[l] > h.content[i]) {
		largest = l
	} else {
		largest = i
	}
	if (r < h.heapSize) && (h.content[r] > h.content[largest]) {
		largest = r
	}

	if largest != i {
		h.swap(i, largest)
		h.maxHeapify(largest)
	}
}

func (h MaxHeap) swap(i, j int) {
	temp := h.content[i]
	h.content[i] = h.content[j]
	h.content[j] = temp
}

// BuildMaxHeap returns max-heapified heap
func BuildMaxHeap(a []int) MaxHeap {
	h := MaxHeap{heapSize: len(a), content: a}
	for i := h.heapSize/2 - 1; i >= 0; i-- {
		h.maxHeapify(i)
	}
	return h
}

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

	h, _ := nextInt()
	arr := make([]int, h)
	for i := range arr {
		arr[i], _ = nextInt()
	}

	// fmt.Println(stringifyArray(arr))
	maxheap := BuildMaxHeap(arr)
	fmt.Println(" " + stringifyArray(maxheap.content))
}



Measured memory_bytes: 29488
import bisect
a, b, q = map(int, input().split())
inf = 10**18
s = [-inf] + [int(input()) for _ in range(a)] + [inf]
t = [-inf] + [int(input()) for _ in range(b)] + [inf]
#print(s)
#print(t)
for _ in range(q):
    start = int(input())
    x = bisect.bisect_right(s, start)
    y = bisect.bisect_right(t, start)
    ans = inf
    for i in [s[x], s[x-1]]:
        for j in [t[y], t[y-1]]:
            res = min(abs(i-start) + abs(j-i), abs(j-start) + abs(i-j))
            ans = min(ans, res)
    print(ans)

Measured memory_bytes: 78552
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    if n <= 2 { put!(1); return }
    let xs: Vec<usize> = sc.vec(n);

    let mut dp = vec![vec![ n + 10 ; 2]; n];
    dp[0][0] = 1;  // <=
    dp[0][1] = 1;  // >=
    for i in 1..n {
        dp[i][0] = if xs[i-1] <= xs[i] {
            min!(dp[i-1][0], dp[i-1][1] + 1)
        } else {
            min!(dp[i-1][0], dp[i-1][1]) + 1
        };
        dp[i][1] = if xs[i-1] >= xs[i] {
            min!(dp[i-1][0] + 1, dp[i-1][1])
        } else {
            min!(dp[i-1][0], dp[i-1][1]) + 1
        };
    }
    put!(min!(dp[n-1][0], dp[n-1][1]));
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 13296
s = input()
def check(s):
    if s!=s[::-1]:
        return False
    t = s[:(len(s)-1)//2]
    if t!=t[::-1]:
        return False
    l = s[(len(s)+3)//2-1:]
    if l!=l[::-1]:
        return False
    return True
if check(s):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;

int main(){
	cin.tie(NULL);
	ios::sync_with_stdio(false);
	//insert code
	int n;
	cin>>n;
	int xorval = 0;
	vi arr(n);
	rep(i,0,n){
		cin>>arr[i];
		xorval = xorval^arr[i];
	}
	rep(i,0,n){
		cout<<(xorval^arr[i])<<" ";
	}
	return 0;
}

Measured memory_bytes: 3980
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        solve(System.in, System.out);
    }

    static void solve(InputStream is, PrintStream os) {
        // Your code here!
        Scanner scan = new Scanner(is);
        int N = scan.nextInt();

        for(int i = 1; i <= 9; i++) {
            if(N % i == 0) {
                int j = N / i;
                if(1 <= j && j <= 9) {
                    os.println("Yes");
                    return;
                }
            }
        }

        os.println("No");

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define ALL(v) v.begin(), v.end()
const int INF = 1e9;
const int MAX = 510000;
const int MOD = 1000000007;
const double PI = acos(-1);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

/*C++になってるか確認したほうがよくない？WOWWOW*/
/*DP使ったほうがよくない？？WOWWOW*/

int main(){
    int A, B, H, M; cin>>A>>B>>H>>M;
    long double ans=sqrt(A*A+B*B-2*A*B*cos(11.0/360*(60*H+M)*PI));
    cout<<fixed<<setprecision(15)<<ans<<endl;
}

Measured memory_bytes: 4256
import java.util.Scanner;
import java.util.InputMismatchException;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int vvhatourist = sc.nextInt();
    int sub = vvhatourist/15;
    System.out.println(vvhatourist*800-sub*200);
  }
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    int s[N], l[N], p[N];
    rep(i, N) cin >> s[i] >> l[i] >> p[i];

    vector<vector<int>> dp(N+1, vector<int>(394, 0));

    rep(i, N) {
        rep(j, 394) {
            repd(k, s[i], l[i]+1) {
                
                if (j < k) chmax(dp[i+1][j], dp[i][j]);
                else chmax(dp[i+1][j], max(dp[i+1][j-k] + p[i], dp[i][j]));
                
            }
        }
    }

    int M;
    bool flag = true;
    cin >> M;

    int m[M];
    rep(i, M) cin >> m[i];

    rep(i, M) {
        if (dp[N][m[i]] == 0) {
            cout << -1 << endl;
            flag = false;
            break;
        }
    }

    if (flag) {
        rep(i, M) {
            cout << dp[N][m[i]] << endl;
        }
    }

    return 0;
}


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

typedef long long LL;
const int M=55;
const int MO=1e9+7;

inline int add(int x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
	return x;
}
inline void addv(int &x,int y)
{
	x+=y;
	if(x>=MO) x-=MO;
}
inline int mul(int x,int y)
{
	return 1LL*x*y%MO;
}


struct Ma
{
	int a[M][M];
	int n;
	Ma()
	{
		memset(a,0,sizeof(a));
	}
	void read(int n_)
	{
		n=n_;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				scanf("%d",&a[i][j]);
	}
	Ma operator=(const Ma &B)
	{
		n=B.n;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				a[i][j]=B.a[i][j];
		return *this;
	}
	Ma operator*(const Ma &B) const
	{
		Ma ans;
		ans.n=n;
		for(int i=0;i<n;i++)
			for(int j=0;j<n;j++)
				for(int k=0;k<n;k++)
					addv(ans.a[i][j],mul(a[i][k],B.a[k][j]));
		return ans;
	}
	Ma operator^(LL k) const
	{
		Ma ans;
		Ma a=*this;
		ans.n=n;
		for(int i=0;i<n;i++)
			ans.a[i][i]=1;
		while(k)
		{
			if(k&1) ans=ans*a;
			a=a*a;
			k>>=1;
		}
		return ans;
	}
	void show()
	{
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
				cout<<a[i][j]<<" ";
			cout<<endl;
		}
	}
}g,a;

int main()
{
	int n;
	LL k; 
	scanf("%d%lld",&n,&k);
	g.read(n);
	a=(g^k);
	//a.show();
	int ans=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			addv(ans,a.a[i][j]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
N,T = map(int, input().split())
tl = list(map(int, input().split()))
answer = 0
for i in range(N):
    if i == 0:
        answer = T
    else:
        if tl[i] - tl[i-1] >= T:
            answer += T
        else:
            answer += tl[i] - tl[i-1]
print(answer)

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T1,typename T2> using P = pair< T1, T2 >;
using Pii = P<int,int>;
using Pdd = P<double,double>;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

int main(){
    int n;
    cin>>n;
    V<P<string,Pii>> sp(n);
    REP(i,n){
        cin>>sp[i].fi>>sp[i].se.fi;
        sp[i].se.se = i+1;
    }

    sort(ALL(sp),[](const auto &x,const auto &y){if(x.fi==y.fi){return x.se.fi>y.se.fi;}else{return x.fi<y.fi;}});

    REP(i,n){
        cout<<sp[i].se.se<<endl;
    }

    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	array<int,3> a;
	for(int i=0;i<3;++i) cin>>a[i];
	sort(a.begin(),a.end());
	cout<<a[0]+a[1]<<'\n';
}




Measured memory_bytes: 3648
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    for (int j = 0; j < s.size(); j++) {
      if (s[i] == s[j] && i != j) {
        cout << "no" << endl;
        return 0;
      }
    }
  }
  cout << "yes" << endl;
  return 0;
}


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

int a[200005], b[200005];
int n, ans;

int main()
{
	cin >> n;
	for (int i = 0;i < n;i++) cin >> a[i];
	for (int i = 0;i < n;i++) cin >> b[i];
	for (int v = (1<<28); v; v>>=1)
	{
		for (int i = 0;i < n;i++) a[i] &= (v*2-1);
		for (int i = 0;i < n;i++) b[i] &= (v*2-1);
		sort(a, a+n); sort(b, b+n);
		int t = 0;
		for (int i = n-1, j = 0, k = 0, l = 0;i >= 0;i--)
		{
			while (j < n && a[i]+b[j] < v) j++;
			while (k < n && a[i]+b[k] < 2*v) k++;
			while (l < n && a[i]+b[l] < 3*v) l++;
			t += k-j+n-l;
			t &= 1;
		}
		if (t) ans |= v;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
// Problem : F - Bracket Sequencing
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_f
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                           \
  {                                      \
    cout << #v << " : ";                 \
    for (auto x : v) cout << x.s << ' '; \
    cout << endl;                        \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

struct braces {
  string s;
  int op, clo;
};

bool comp(braces b1, braces b2) {
  bool o1 = false, o2 = false;
  if (b1.op > b1.clo) o1 = true;
  if (b2.op > b2.clo) o2 = true;
  if (o1 && o2) {
    return b1.clo < b2.clo;
  } else if (!o1 && !o2) {
    return b1.op > b2.op;
  } else if (o1 && !o2) {
    return true;
  }
  return false;
}

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin>>testcases;

  while (testcases--) {
    int n;
    cin >> n;
    vector<braces> vec(n), fresh;
    rep(i, 0, n - 1) {
      cin >> vec[i].s;
      string t;
      stack<char> st;
      int len = vec[i].s.length();
      rep(j, 0, len - 1) {
        if (vec[i].s[j] == ')') {
          if (!st.empty() && st.top() == '(')
            st.pop();
          else
            t.push_back(vec[i].s[j]);
        } else
          st.push(vec[i].s[j]);
      }
      while (!st.empty()) {
        t.push_back(st.top());
        st.pop();
      }
      len = t.length();
      int op = 0, clo = 0;
      rep(j, 0, len - 1) {
        if (t[j] == '(')
          op++;
        else
          clo++;
      }
      fresh.pb({t, op, clo});
    }
    bool flag = true;
    sort(fresh.begin(), fresh.end(), comp);
    int s = sz(fresh);
    stack<char> st;
    rep(i, 0, s - 1) {
      int len = fresh[i].s.length();
      rep(j, 0, len - 1) {
        if (fresh[i].s[j] == ')') {
          if (st.empty()) {
            flag = false;
            break;
          } else
            st.pop();
        } else {
          st.push('(');
        }
      }
      if (!flag) break;
    }
    if (!st.empty()) flag = false;
    if (flag)
      cout << "Yes\n";
    else
      cout << "No\n";
  }

  return 0;
}


Measured memory_bytes: 99288
min = list(map(int,input().split()))[0]
min = int(min)
l = list(map(int,input().split()))
while True:
  temp = min
  flag = True
  for i in range(len(str(min))):
    temp_ = temp % 10
    if temp_ in l:
      min += 1
      flag = False
      break
    else:
      temp //= 10
  if i == len(str(min))-1 and flag:
    break
print(min)

Measured memory_bytes: 3064
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

ll nPrS(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--){
        ret *= i;
        ret %= MOD;
    }
    return ret;
}

int main(void){
    int n;
    cin >> n;
    vector<int> a(n);
    int farest = 0;
    int nearest = 1e9;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        farest = max(farest, a[i]);
        nearest = min(nearest, a[i]);
    }

    cout << abs(farest - nearest) << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int dp[3010][3010];

int main() {
	string s,t;
	cin >> s >> t;
	rep(i, 3010) rep(j,3010) dp[i][j] = 0;
	dp[0][0] = 0;
	rep(i, s.length()) rep(j,t.length()) {
		if (s[i] == t[j]) {
			dp[i+1][j+1] = dp[i][j] + 1;
		}
		else {
			dp[i+1][j+1] = max(dp[i+1][j], dp[i][j+1]);
		}
		//cout << "i: " << i << " j:" << j << " dp[" << i+1 << "][" << j+1 << "]:" << dp[i+1][j+1] << endl;
	}

	string ans = "";
	int x = s.length(), y = t.length();
	while(x > 0 && y > 0) {
		if(dp[x][y] == dp[x-1][y]) {
			x--;
		} else if (dp[x][y] == dp[x][y-1]) {
			y--;
		} else {
			x--;
			y--;
			ans = s[x] + ans;
		}
	}
	cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35712
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

const int Maxn = 60;
const int MOD = (int) 1e9 + 7;

ll a[Maxn], p[Maxn];

ll rec(int level, ll n) {
    if (level == 0) {
        if (n >= 1) return 1;
        else return 0;
    }
    if (n == 1) return 0;
    if (n <= a[level - 1] + 1) {
        return rec(level - 1, n - 1);
    }
    return p[level - 1] + 1 + rec(level - 1, n - 2 - a[level - 1]);
}

int n;
ll x;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> x;
    a[0] = 1;
    p[0] = 1;
    for (int i = 0; i < n; ++i) {
        a[i + 1] = 2 * a[i] + 3;
        p[i + 1] = 2 * p[i] + 1;
    }

    cout << rec(n, x) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
int main() {
  unordered_map<string,int> count;
  unordered_map<string,int> length;
  string word;
  int max1 = 0;
  int max2 = 0;
  string answer1, answer2;

  while (cin >> word) { // 入力がある限り読み込む
    count[word] += 1;
    length[word] = word.size();
    if (count[word] > max1) {
      max1 = count[word];
      answer1 = word;
    }
    if (length[word] > max2) {
      max2 = length[word];
      answer2 = word;
    }
    
  }

  cout << answer1 << " " << answer2 << endl;
 }


Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define db double
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
const int inf = 1 << 30;
const ll linf = 1e18;
template<class T> void chmin(T& x, T y){if(x > y) x = y;}
template<class T> void chmax(T& x, T y){if(x < y) x = y;}


int N;
ll A[200010];
ll dp[3][200010];
bool flag[3][200010];

ll ans = -linf;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N;
    for(int i = 1; i <= N; i++){
        cin >> A[i];
        dp[0][i] = -linf;
        dp[1][i] = -linf;
        dp[2][i] = -linf;
    }
    flag[0][1] = true;
    flag[1][2] = true;
    flag[2][3] = true;
    dp[0][1] = 0;
    dp[1][2] = 0;
    dp[2][3] = 0;
    for(int i = 1; i <= N; i++){
        if(flag[0][i]){
            dp[0][i] += A[i];
            chmax(dp[0][i + 2], dp[0][i]);
            chmax(dp[1][i + 3], dp[0][i]);
            chmax(dp[2][i + 4], dp[0][i]);
            flag[0][i + 2] = true;
            flag[1][i + 3] = true;
            flag[2][i + 4] = true;
        }
        if(flag[1][i]){
            dp[1][i] += A[i];
            chmax(dp[1][i + 2], dp[1][i]);
            chmax(dp[2][i + 3], dp[1][i]);
            flag[1][i + 2] = true;
            flag[2][i + 3] = true;

        }
        if(flag[2][i]){
            dp[2][i] += A[i];
            chmax(dp[2][i + 2], dp[2][i]);
            flag[2][i + 2] = true;
        }
    }

    if(N % 2 == 1){
        chmax(ans, dp[2][N]);
        chmax(ans, dp[1][N - 1]);
        chmax(ans, dp[0][N - 2]);
    }else{
        chmax(ans, dp[1][N]);
        chmax(ans, dp[0][N - 1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10532
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string.h>

using namespace std;
#define debug(x) cout << #x << ": " << x << endl
typedef long long ll;

void solve() {
    int n;
    scanf("%d", &n);
    int answer = (1000 - n % 1000) % 1000;
    printf("%i", answer);
}

int main() {
    // int t;
    // cin >> t;
    // while (t--)
    solve();
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define rep(i,e) for(int i= 0; i< (int)(e); i++)
#define reps(i,s,e) for(int i = s; i < (int)(e); i++)
#define repr(i,s,e) for(int i = s; i > (int)(e); i--)
#define pb push_back
typedef long long ll;
const ll INF = 1LL << 60;
ll bigp = 1000000007;

ll binary_search(ll key,vector<ll> &a) {
    ll ng = -1;
    ll ok = (ll)a.size(); 
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (a[mid] >= key) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main()
{
    ll a,b,q;
    cin >> a >> b >> q;
    vector<ll> s(a);
    vector<ll> t(b);
    rep(i,a){cin >> s[i];}
    rep(i,b){cin >> t[i];}
    vector<ll> ans;
    rep(i,q){
        ll x;
        cin >> x;
        ll ok = binary_search(x,s);
        ll ng = ok-1;
        ll left_s = -INF;
        ll right_s = INF;
        if(ng != -1){
            left_s = s[ng];
        }
        if(ok != s.size()){
            right_s = s[ok];
        }

        ok = binary_search(x,t);
        ng = ok-1;
        ll left_t = -INF;
        ll right_t = INF;
        if(ng != -1){
            left_t = t[ng];
        }
        if(ok != t.size()){
            right_t = t[ok];
        }
        ll s_l = abs(x-left_s);
        ll s_r = abs(x-right_s);
        ll t_l = abs(x-left_t);
        ll t_r = abs(x-right_t);
        ll tmp_ans = max(s_l,t_l);
        tmp_ans = min(tmp_ans, max(s_r,t_r));
        tmp_ans = min(tmp_ans, s_r+t_l+min(s_r,t_l));
        tmp_ans = min(tmp_ans, s_l+t_r+min(s_l,t_r));
        ans.pb(tmp_ans);
    }
    rep(i,q){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 3828
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
c = list(map(int,input().split()))

s = 0
a.append(0)

for i in range(n):
  s += b[i]
  if a[i]+1 == a[i+1]:
    s += c[a[i]-1]

print(s)

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

typedef long long ll;
pair<ll,ll> func(vector<vector<int> > &v, bool b[], int ind, ll &mod)
{
	b[ind]=1;
	ll t=1, t1=1;
	for(int i=0;i<v[ind].size();i++)
	{
		if(b[v[ind][i]]==0)
		{
			pair<ll,ll> p;
			p=func(v, b, v[ind][i],mod);
			t=(t*((p.first+p.second)%mod))%mod;
			t1=(t1*p.second)%mod;
		}
	}
	return {t1,t};
}
int main()
{
	int n;
	cin>>n;
	if(n==1){
	cout<<"2";
	return 0;	
	}
	vector<vector<int> > v(n+1);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	bool b[n+1];
	ll mod=1e9+7;
	for(int i=0;i<=n;i++)
	b[i]=0;
	pair<ll,ll> ans[n+1];
	for(int i=0;i<=n;i++)
	ans[i]={0,0};
	ans[1]=func(v,b,1,mod);
	ll k=(ans[1].first+ans[1].second)%mod;
	cout<<k;
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int r;
    cin >> r;
 
    int ans=0;
    if (n >= 10)
    {
        ans = r;
    }
    else
    {
        ans = r + (100 * (10 - n));
    }
    cout << to_string(ans);
}

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

using namespace std;

int main(){
	int N, H, B[100000];
	int amax = 0;
	int cnt = 0;
	cin >> N >> H;
	for (int i = 0; i < N; i++){
		int a;
		cin >> a >> B[i];
		amax = max(a, amax);
	}
	sort(B, B + N);
	for (int i = N - 1; i >= 0; i--){
		if (B[i]>=amax) {
			H -= B[i];
			cnt++;
		}
		if (H <= 0){
			cout << cnt << endl;
			return 0;
		}
	}
	cout << cnt + (H + amax - 1) / amax << endl;
	return 0;
}


Measured memory_bytes: 640
dxy = zip([1,0,-1,0],[0,1,0,-1])
def rec(x,y,t):
    global ans
    if t >= ans: return
    if field[y][x] == 3: ans = min(ans,t)
    for dx,dy in dxy:
        nx,ny = x+dx,y+dy
        while 0 <= nx < W and 0 <= ny < H:
            if   field[ny][nx] == 3: ans = t
            elif field[ny][nx] == 1:
                if abs(nx-x)+abs(ny-y) == 1: break
                field[ny][nx] = 0
                rec(nx-dx,ny-dy,t+1)
                field[ny][nx] = 1
                break
            nx += dx; ny += dy

while 1:
    W,H = map(int,raw_input().split())
    if W == 0: break
    field = [map(int,raw_input().split()) for _ in range(H)]
    for y in range(H):
        for x in range(W):
            if field[y][x] == 2: sx,sy = x,y
    ans = 11
    rec(sx,sy,1)
    print ans if ans <= 10 else -1

Measured memory_bytes: 4276