akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}


// go だと固定長配列とか辛いので無理だった
type Vector struct {
	arr [] int
	back int
}
func NewVector() Vector {
	return Vector{make([]int, 0, 10000), 0}
}
func (this *Vector)PushBack(i int) {
	if len(this.arr) - 1 < this.back {
		this.arr = append(this.arr, i)
		this.back++
	} else {
		this.arr[this.back] = i
		this.back++
	}
}
func (this *Vector)Dump() {
	for i := 0; i < this.back; i++ {
		if i == 0 {
			fmt.Printf("%d", this.arr[i])
		} else {
			fmt.Printf(" %d", this.arr[i])
		}
	}
	fmt.Println()
}
func (this *Vector) Clear() {
	this.back = 0
}




func main() {
	var n int
	var q int

	fmt.Scanf("%d %d", &n, &q)
	// 構造体の初期化が走るの嫌だな
	vectors := make([]Vector, n)

	for i := 0; i < n; i++ {
		vectors[i] = NewVector()
	}
	lines, _ := ReadLongLines(q)
	for _, line := range lines {
		args := strings.Split(line, " ")
		cmd := args[0]
		switch cmd {
		case "0":
			t, _ := strconv.Atoi(args[1])
			x, _ := strconv.Atoi(args[2])
			vectors[t].PushBack(x)
		case "1":
			t, _ := strconv.Atoi(args[1])
			vectors[t].Dump()
		case "2":
			t, _ := strconv.Atoi(args[1])
			vectors[t].Clear()
		}
	}
}


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

int main() {

  vector<vector<int>> data(3, vector<int>(3));
  vector<vector<int>> ans(3, vector<int>(3));
  int n;

  rep(i,3){
    rep(j,3){
      cin >> data.at(i).at(j);
    }
  }

  cin >> n;
  vector<int> b(n);
  rep(i,n){
    cin >> b[i];
  }

  rep(i,n) {
    rep(j,3) {
      rep(k,3) {
        if (b[i] == data.at(j).at(k)) {
          ans.at(j).at(k) = 1;
        }
      }
    }
  }
  bool a1 = (ans.at(0).at(0)+ans.at(0).at(1)+ans.at(0).at(2)==3);
  bool a2 = (ans.at(1).at(0)+ans.at(1).at(1)+ans.at(1).at(2)==3);
  bool a3 = (ans.at(2).at(0)+ans.at(2).at(1)+ans.at(2).at(2)==3);

  bool a4 = (ans.at(0).at(0)+ans.at(1).at(0)+ans.at(2).at(0)==3);
  bool a5 = (ans.at(0).at(1)+ans.at(1).at(1)+ans.at(2).at(1)==3);
  bool a6 = (ans.at(0).at(2)+ans.at(1).at(2)+ans.at(2).at(2)==3);

  bool a7 = (ans.at(0).at(0)+ans.at(1).at(1)+ans.at(2).at(2)==3);
  bool a8 = (ans.at(2).at(0)+ans.at(1).at(1)+ans.at(0).at(2)==3);

  if (a1||a2||a3||a4||a5||a6||a7||a8) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  
}


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

int main(void) {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> ans(n);
  rep(i, n) { ans[a[i] - 1] = i + 1; }
  rep(i, n) {
    cout << ans[i];
    if (i == n - 1)
      cout << '\n';
    else
      cout << ' ';
  }
  return 0;
}

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

int main(void){
    int x,y,d,e;
    double sum,min;
    for(;min=10000.0,scanf("%d %d",&d,&e),e;){
        for(x=d,y=0;x>=y;x--,y++){
            sum=fabs(sqrt(x*x+y*y)-e);
            if(min > sum)
                min=sum;
        }
        printf("%f\n",min);
    }
    return 0;
}

Measured memory_bytes: 636
def findSumOfDigits(n):
    sum =0
    while n > 0:
        sum += n % 10
        n = n//10
    return sum

N = int(input())
examples = list()

for i in range((N//2)+1)[1:]:
    A = i
    B = N - i
    total = findSumOfDigits(A) + findSumOfDigits(B)
    examples.append(total)

print(min(examples))

Measured memory_bytes: 3480
#include<bits/stdc++.h>
#define MOD 1e9+7
using namespace std;
#define  pp push_back
#define  po pop_back
#define  mp make_pair
#define clr(a) memset(a,0,sizeof(a))
#define neg(a) memset(a,-1,sizeof(a))
#define fas(a) memset(a,false,sizeof(a))
#define debug(x) cout<<#x<<": "<<x<<endl
#define debug1(x) cout<<#x<<": "<<x<<" "
#define rev(x) reverse(x.begin(), x.end())
#define int long long 
#define F first
#define S second
//int a[2000];
void printvector(std::vector<int> v){  for (int i = 0; i < v.size(); ++i){cout<<v[i]<<" ";}cout<<""<<endl;}
void printarray(int a[],int n){for (int i = 0; i < n; ++i){cout<<a[i]<<" ";}cout<<""<<endl;}
 
 

 

void  solve()
{
  string s;cin>>s;
  int n=s.length();
  int dp[max(n,(int)4)][3];clr(dp);
  dp[0][1]=1; dp[0][2]=0;
  dp[1][1]=(s[0]!=s[1])*(dp[0][1]+1);dp[1][2]=1;
  for(int i=2;i<n;i++)
  {
      dp[i][1]=max((dp[i-1][1]+1)*(s[i-1]!=s[i]),dp[i-1][2]+1);
      if(i==2)dp[i][2]=max(dp[i-2][1]+1,(dp[i-2][2]+1)*(s[i-3]!=s[i-1]||s[i-2]!=s[i])); 
      dp[i][2]=dp[i-2][1]+1;
  }

  cout<<max(dp[n-1][1],dp[n-1][2]); 
 
}




 int32_t main() 
{

 
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
    
   solve();

return 0;

}

Measured memory_bytes: 5268
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int H, W, N;
	while (cin >> W >> H >> N, N) {
		vector<int> S(N);
		int sum = 0;
		for (int i = 0; i < N; ++i) {
			int b, x;
			cin >> b >> x; --b;
			S[b] = x;
			sum += x;
		}
		vector<vector<int> > C(H, vector<int>(W));
		for (int i = 0; i < H; ++i) {
			for (int j = 0; j < W; ++j) {
				cin >> C[i][j]; --C[i][j];
			}
		}
		vector<vector<int> > curstate(H, vector<int>(W, -1));
		vector<vector<vector<int> > > sols;
		function<void(int)> dfs = [&](int bit) {
			if (bit == 0) {
				sols.push_back(curstate);
				return;
			}
			int x = -1, y = -1;
			for (int i = 0; i < H && x == -1; ++i) {
				for (int j = 0; j < W && y == -1; ++j) {
					if (curstate[i][j] == -1) {
						x = i, y = j;
					}
				}
			}
			for (int i = 0; i < N; ++i) {
				if (!((bit >> i) & 1)) continue;
				for (int j = 1; j <= S[i]; ++j) {
					if (S[i] % j != 0) continue;
					int h = j, w = S[i] / j;
					if (x + h > H || y + w > W) continue;
					bool f1 = true, f2 = false;
					for (int k = 0; k < h; ++k) {
						for (int l = 0; l < w; ++l) {
							if (C[x + k][y + l] == i) f2 = true;
							else if (C[x + k][y + l] != -1 || curstate[x + k][y + l] != -1) f1 = false;
						}
					}
					if (f1 && f2) {
						for (int k = 0; k < h; ++k) {
							for (int l = 0; l < w; ++l) {
								curstate[x + k][y + l] = i;
							}
						}
						dfs(bit - (1 << i));
						for (int k = 0; k < h; ++k) {
							for (int l = 0; l < w; ++l) {
								curstate[x + k][y + l] = -1;
							}
						}
					}
				}
			}
		};
		if (sum == H * W) {
			dfs((1 << N) - 1);
		}
		if (sols.size() != 1) {
			cout << "NA" << endl;
		}
		else {
			for (int i = 0; i < H; ++i) {
				for (int j = 0; j < W; ++j) {
					if (j) cout << ' ';
					cout << sols[0][i][j] + 1;
				}
				cout << endl;
			}
		}
	}
	return 0;
}


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

int main(){

    int x, a, b;

    cin >> x >> a >> b;

    if(a - b >= 0){
        cout << "delicious" << endl;
    }
    else if(x+a-b >= 0){
        cout << "safe" << endl;
    }
    else{
        cout << "dangerous" << endl;
    }

    return 0;

}


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<atcoder/all>

using namespace std;
typedef long long Int;

struct Swap{
    Int cnt[2], swap_cnt;
    Swap(){
        cnt[0] = cnt[1] = 0;
        swap_cnt = 0;
    }
    Swap(int x){
        cnt[1-x] = 0;
        cnt[x] = 1;
        swap_cnt = 0;
    }    
};

Swap empty_swap(){return Swap();}

Swap combine(Swap a, Swap b){
    Swap c;
    c.cnt[0] = a.cnt[0] + b.cnt[0];
    c.cnt[1] = a.cnt[1] + b.cnt[1];
    c.swap_cnt = a.swap_cnt + b.swap_cnt + a.cnt[1] * b.cnt[0];
    return c;
}

Swap flip(bool flipped, Swap x){
    if(flipped){
        Int len = x.cnt[0] + x.cnt[1];
        swap(x.cnt[0], x.cnt[1]);
        Int all_pair = x.cnt[0] * x.cnt[1];
        x.swap_cnt = all_pair - x.swap_cnt;
    }
    return x;
}

bool bool_xor(bool a, bool b){return a^b;}

bool bool_false(){return false;}

int main(){
    int n, q;
    cin >> n >> q;
    vector<Swap> a(n);
    for(auto &elem:a){
        int tmp;
        cin >> tmp;
        elem = Swap(tmp);
    }

    atcoder::lazy_segtree<
        Swap,
        combine,
        empty_swap,
        bool,
        flip,
        bool_xor,
        bool_false
        > seg(a);
    
    while(q--){
        int t, l, r;
        cin >> t >> l >> r;l--,r--;
        if(t == 1){
            seg.apply(l, r+1, true);
        }
        if(t == 2){
            int ll = 3;
            auto swp = seg.prod(l, r+1);
            cout << swp.swap_cnt << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 19784
import java.util.Scanner;

class Main {

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int n = scanner.nextInt();
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    scanner.close();
    int max = a < b ? a : b;
    int min = n < a + b ? (a + b) - n : 0;
    System.out.println(max + " " + min);
  }

}


Measured memory_bytes: 21332
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scanf("%d %d %d\n", &n, &a, &b)
	var s string
	fmt.Scanf("%s", &s)

	t, f := 1, 1
	for _, l := range s {
		switch string(l) {
		case "c":
			fmt.Println("No")
		case "a":
			if t <= a+b {
				fmt.Println("Yes")
				t++
			} else {
				fmt.Println("No")
			}
		case "b":
			if (t <= a+b) && (f <= b) {
				fmt.Println("Yes")
				t++
				f++
			} else {
				fmt.Println("No")
			}
		}
	}
}


Measured memory_bytes: 2572
#include <stdio.h>

typedef long long ll;

int N;
ll dp[55][55][2505];
int x[55];

int main(){

	int A;
	scanf("%d %d",&N,&A);

	int i,j,k;

	for(i=0;i<N;i++){
		scanf(" %d",&x[i]);
	}
	dp[0][0][0]=1ll;

	for (i = 0; i < 55; i++) {
		dp[i][0][0] = 1ll;
	}

	for(i=0;i<N;i++){
		for(j=1;j<=N;j++){
			for(k=0;k<=2500;k++){
				if(k-x[i]>=0ll){
					dp[i+1][j][k]=dp[i][j][k]+dp[i][j-1][k-x[i]];	
				}
				else{
					dp[i+1][j][k]=dp[i][j][k];
				}
			}
		}
	}
	ll ans = 0ll;
	for (i = 1; i <= N; i++) {
		ans += dp[N][i][A*i];
	}
	printf("%lld\n",ans);


	return 0;
}

Measured memory_bytes: 56448
# import math
# from itertools import permutations as permus
# from fractions import gcd

# import numpy as np
# import scipy as scp

# 入力の受け取り
n = int(input())
s,t = input().split()

ans = ""
for x in range(n):
    ans = ans + s[x]
    ans = ans + t[x]

print(ans)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main
{
	public static void main(String[]  args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		scanner.nextLine();
		for(; n>0; n--)
		{
			String input = scanner.nextLine();
			
			String output = "";
	        for(int i=0; i<input.length(); i++)
	        {   
	            if(i <= input.length()-7)
	            {
	                if(input.substring(i, i+7).equals("Hoshino"))
	                {
	                    output += "Hoshina";
	                    i += 6;
	                }
	                else
	                {
	                    output += input.substring(i, i+1);
	                }
	            }
	            else
	            {
	                output += input.substring(i, i+1);
	            }
	        }
			System.out.println(output);
		}
	}
}

Measured memory_bytes: 32088
#include<stdio.h>

int main(){
	int n, q, S[10000], T[500], C = 0;
	int i = 0, j = 0;
	scanf("%d", &n);
	for( i = 0; i < n; i++ ){ scanf("%d", &S[i]); }
	scanf("%d", &q);
	for( i = 0; i < q; i++ ){ scanf("%d", &T[i]); }
	// check
	for( i = 0; i < q; i++ ){
		for( j = 0; j < n; j++ ){
			if( T[i] == S[j] ){ C++; break; }
		}
	}
	printf("%d\n", C);
	return 0;
}

Measured memory_bytes: 640
n = int(input())
for i in range(n):
    houseNum, genNum = map(int,input().split())
    location = list(map(int, input().split()))
    distance = []
    for j in range(1, houseNum):
        distance.append(location[j] - location[j-1])
    distance.sort(reverse=True)
    print(location[-1] - location[0] - sum(distance[:genNum-1]))

Measured memory_bytes: 23476
n = gets.to_i
s = gets.chomp.chars

cntB = 0
cntW = 0

left  = - 1
right = - 1

s.each do |c|
  if c == '.'
    cntW += 1
  else
    left = cntW
    break
  end
end

s.reverse.each do |c|
  if c == '#'
    cntB += 1
  else
    right = n - cntB - 1
    break
  end
end

if 0 <= left && right <= n - 1 && left < right
  ary = s[left..right]
  min = 1E6

  cntB = 0
  cntW = ary.count('.')

  ary.size.times do |i|
    if ary[i] == '.'
      cntW -= 1
    end
    if ary[i] == '#' || i == right
      min = [min, cntB + cntW].min
      cntB += 1
    end
  end

  puts min
else
  puts 0
end

Measured memory_bytes: 18300
using System;

namespace AtCoder
{
    internal static class Program
    {
        private static void Main()
        {
            int[] ABCK = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

            int A = ABCK[0];
            int B = ABCK[1];
            int C = ABCK[2];
            int K = ABCK[3];

            int res;

            if (K > A)
            {
                res = A;
                K -= A;
                if (K > B)
                {
                    K -= B;
                    res -= K;
                }
                    
            }
            else
                res = K;

            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 27544
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define int long long
using namespace std;
const int p = 2147483647;
int n, q, cm, x, y;
int a[123456];//0,1,2,...
int b[12345]; //0~9,10~19,20~29,...
int c[1234];  //0~99,100~199,100~299,...
int d[123];   //0~999,1000~1999,2000~2999...
signed main() {
	cin >> n >> q;
	for (int i = 0; i < n; i++)a[i] = p;
	for (int i = 0; i < n/10+1; i++)b[i] = p;
	for (int i = 0; i < n/100+1; i++)c[i] = p;
	for (int i = 0; i < n/1000+1; i++)d[i] = p;
	for (int w = 0; w < q; w++) {
		cin >> cm >> x >> y;
		if (!cm) {
			a[x] = y;
			x /= 10;
			b[x] = p;
			for (int i = 0; i <= 9; i++)b[x] = min(b[x], a[x * 10 + i]);
			x /= 10;
			c[x] = p;
			for (int i = 0; i <= 9; i++)c[x] = min(c[x], b[x * 10 + i]);
			x /= 10;
			d[x] = p;
			for (int i = 0; i <= 9; i++)d[x] = min(d[x], c[x * 10 + i]);
		}
		else {
			int r = p;
			while (x <= y) {
				if (x % 10 != 0 || y - x < 10) {
					r = min(r, a[x]);
					x++;
				}
				else if (x % 100 != 0 || y - x < 100) {
					r = min(r, b[x / 10]);
					x += 10;
				}
				else if (x % 1000 != 0 || y - x < 1000) {
					r = min(r, c[x / 100]);
					x += 100;
				}
				else {
					r = min(r, d[x / 1000]);
					x += 1000;
				}
			}
			cout << r << endl;
		}
	}
}


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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()

using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vi x,y,z;
    int X[101],Y[101],Z[101];
    int xu[51],yu[51],zu[51];
    rep(i,0,n){
        cin >> X[n+i] >> Y[n+i] >> Z[n+i];
        cin >> X[i] >> Y[i] >> Z[i];
        x.pb(X[n+i]);x.pb(X[i]);y.pb(Y[i]);y.pb(Y[i+n]);z.pb(Z[i]);z.pb(Z[i+n]);
    }
    sort(ALL(x));
    sort(ALL(y));
    sort(ALL(z));
    int ans=0;
    rep(i,1,n*2){
        rep(j,1,n*2){
            rep(k,1,n*2){
                int len=0;
                //cout << X[i] << " " << Y[j] << " " << Z[k] << endl;
                rep(l,0,n){
                  //  cout << X[l] << " | " << X[l+n] << endl;
                        if(x[i]<=X[l]&&X[l+n]<=x[i-1]){
                        if(y[j]<=Y[l]&&Y[l+n]<=y[j-1]){
                        if(z[k]<=Z[l]&&Z[l+n]<=z[k-1]){len++;}}}
                }
                //cout << len << "  ";
                if(len>=m){
                    //cout << "a" << endl;
                    ans+=(x[i]-x[i-1])*(y[j]-y[j-1])*(z[k]-z[k-1]);
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

int csum[1000000];

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

    int i;
    for (i = 1; i <= x; i++) {
        csum[i] = csum[i-1] + i;
        if (csum[i] > x) break;
    }

    int lo = lower_bound(csum, csum+i, x) - csum;
    cout << lo;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

char str[15];

void solve()
{
    int n;
    scanf("%d", &n);
    map<string,int> z;
    int i;
    for(i=0; i<n; i++) {
        scanf("%s", str);
        z[string(str)]++;
    }
    int max=-INF;
    auto it=z.begin();
    for(; it!=z.end(); ++it) {
        int num=it->second;
        max=MAX(max,num);
    }
    vector<string> aa;
    it=z.begin();
    for(; it!=z.end(); ++it) {
        int num=it->second;
        if(num==max) aa.push_back(it->first);
    }
    sort(aa.begin(),aa.end());
    for(i=0; i<(int)aa.size(); i++) {
        printf("%s\n", aa[i].c_str());
    }

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T; scanf("%d", &T);
    while(T--) {
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 25584
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int x = sc.nextInt();
		int[] a = new int[N];

		long count = 0;

		for (int i = 0; i < N; i++) {
			a[i] = sc.nextInt();
		}

		for (int i = 0; i < N - 1; i++) {
			if (x < a[i] + a[i + 1]) {

				if (a[i + 1] >= (a[i + 1] + a[i]) - x) {

					count += a[i + 1] + a[i] - x;
					a[i + 1] = a[i + 1] - ((a[i + 1] + a[i]) - x);

				} else {
					count+= a[i + 1];
					count +=  Math.abs( a[i + 1] - ((a[i + 1] + a[i]) - x));

					a[i + 1] = 0;
					a[i] = a[i] - Math.abs( a[i + 1] - ((a[i + 1] + a[i]) - x));


				}

			}
		}






		System.out.println(count);


		sc.close();
	}


}


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

int main()
{
    int n,k;
    cin >> n >> k;
    int dp[k+1] = {};
    int a[n] = {};
    for(int i=0; i<n; i++) cin >> a[i];
    for(int i=0; i<k; i++){
        for(auto l: a){
            if(i+l <= k){
                if(dp[i] == 0) dp[i+l] = 1; 
            }
        }
    }
    if(dp[k] == 0)
        cout << "Second" << endl;
    else
        cout << "First" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>
#define N 1000000

int all[N+1],odd[N+1];
int pollock[1000];
int num;

int BackTrack(int n,int type){
  int i,tmp,ans = N+1;
  if(type && odd[n]<=N)return odd[n];
  if(!type && all[n]<=N)return all[n];
  //if(n==0)return 0;

  for(i=num-1;i>=0;i--){
    //printf("%d\n",pollock[i]);
    if(pollock[i]>n)continue;
    if(type && !(pollock[i]&1) )continue;
    tmp = BackTrack(n-pollock[i],type);
    if(ans > tmp+1)ans = tmp+1;
  }

  if(type)odd[n] = ans;
  if(!type)all[n] = ans;
  return ans;
}

int main(){
  int i,n,tmp;

  for(i=0;i<=N;i++)all[i] = odd[i] = N+1;
  all[0] = odd[0] = 0;

  for(num=1;;num++){
    tmp = num*(num+1)*(num+2)/6;
    if(tmp>N)break;
    pollock[num-1] = tmp;
  }
  num--;
  while(scanf("%d",&n) && n){
    printf("%d %d\n",BackTrack(n,0),BackTrack(n,1));
  }
  return 0;
}

Measured memory_bytes: 8576
/**
 * File    : B.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-7-14 21:04:39
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

ll gcd(ll x, ll y)
{
  if (y == 0)
  {
    return x;
  }
  if (x < y)
  {
    return gcd(y, x);
  }
  return gcd(y, x % y);
}

bool solve(ll A, ll B, ll C, ll D)
{
  ll g = gcd(gcd(A, B), gcd(C, D));
  A /= g;
  B /= g;
  C /= g;
  D /= g;
  if (B > A)
  {
    return false;
  }
  if (D < B)
  {
    return false;
  }
  if (A <= C)
  {
    return true;
  }
  ll X = A - B;
  ll Y = A - C;
  ll g_bd = gcd(B, D);
  ll r_x = X % g_bd;
  if (Y - X > g_bd - r_x)
  {
    return false;
  }
  return true;
}

int T;
ll A[100010];
ll B[100010];
ll C[100010];
ll D[100010];

int main()
{
  cin >> T;
  for (auto i = 0; i < T; i++)
  {
    cin >> A[i] >> B[i] >> C[i] >> D[i];
  }
  for (auto i = 0; i < T; i++)
  {
    bool ok = solve(A[i], B[i], C[i], D[i]);
    if (ok)
    {
      cout << "Yes" << endl;
    }
    else
    {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 256
package main

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

//=====I/O=====

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanInt64() int64 {
	sc.Scan()
	a,_ := strconv.ParseInt(sc.Text(),10,64)
	return a
}

func scanFloat64() float64 {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return float64(a)
}

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ { res[i] = scanInt() }
	return res
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

func printInts(a ...int) {
	for i, e := range a {
		fmt.Fprint(wr, e)
		if i != len(a)-1 { fmt.Fprint(wr, " ") }
	}
	fmt.Fprintln(wr)
	wr.Flush()
}

//•*¨*•.¸¸♪func•*¨*•.¸¸♪
func min(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res > a[i] { res = a[i] }
	}
	return res
}

func max(a ...int) int {
	res := a[0]
	for i := 1; i < len(a); i++ {
		if res < a[i] { res = a[i] }
	}
	return res
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer(make([]byte, 10000), 100000000)

	a := scanInt()
	b := scanInt()

	if a<b {
		for i := 0; i < b; i++ {
			fmt.Print(a)
		}
	} else {
		for i := 0; i < a; i++ {
			fmt.Print(b)
		}
	}

	fmt.Println()
}


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

public class Main{
	static int n,m;
	static int ans;
	static void gen(int i,int prev,int[]vals) {
		if(i>=n) {
			int sum=0;
			for(int j=0;j<qs.length;j++) {
				int a=qs[j][0]-1,b=qs[j][1]-1,c=qs[j][2],d=qs[j][3];
				if(vals[b]-vals[a]==c) {
					sum+=d;
				}
			}
			ans=Math.max(ans, sum);
			return;
		}
		for(int j=prev;j<=m;j++) {
			int[]tmp=vals.clone();
			tmp[i]=j;
			gen(i+1, j,tmp);
		}
	}
	static int[][]qs;
	public static void main(String[] args) throws Exception{
		pw=new PrintWriter(System.out);
		sc = new MScanner(System.in);
		n=sc.nextInt();m=sc.nextInt();int q=sc.nextInt();
		qs=new int[q][];
		for(int i=0;i<q;i++) {
			qs[i]=sc.intArr(4);
		}
		
		gen(0, 1,new int[n]);
		
		pw.println(ans);
		pw.flush();
	}
	static PrintWriter pw;
	static MScanner  sc;
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] intArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] longArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public int[] intSortedArr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public long[] longSortedArr(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        shuffle(in);
	        Arrays.sort(in);
	        return in;
		}
		public Integer[] IntegerArr(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] LongArr(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
	static void shuffle(int[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			int tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
	static void shuffle(long[]in) {
		for(int i=0;i<in.length;i++) {
			int idx=(int)(Math.random()*in.length);
			long tmp=in[i];
			in[i]=in[idx];
			in[idx]=tmp;
		}
	}
}

Measured memory_bytes: 44308
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {
	int n;
	cin>>n;
	cout<<pow(n,3);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 4304
<?php
fscanf(STDIN, '%d', $N);
$s = ['.', '#'];
$r1 = '';
$r2 = '';
$right = true;
while ($N) {
	$idx = 0;
	while ($idx < 4) {
		$_r1 = ($right) ? $r1.$s[floor($idx/2)] : $s[floor($idx/2)].$r1;
		$_r2 = ($right) ? $r2.$s[$idx%2] : $s[$idx%2].$r2;
		echo $_r1."\n".$_r2."\n";
		fscanf(STDIN, '%s', $R);
		if ($R === 'T') {
			$r1 = $_r1;
			$r2 = $_r2;
			break;
		}
		$idx++;
	}
	if ($idx === 4) {
		$right = !$right;
	} else {
		$N--;
	}
}


Measured memory_bytes: 3920
#include <stdio.h>

int main(){
  int n, k, q;
  scanf("%d %d %d", &n, &k, &q);
  int a[q];
  for(int i = 0; i < q; i++){
    scanf("%d", &a[i]);
  }
  int p[n];
  for(int i = 0; i < n; i++){
    p[i] = k - q;
  }
  for(int i = 0; i < q; i++){
    p[a[i] - 1]++;
  }
  for(int i = 0; i < n; i++){
    if(p[i] > 0){
      printf("Yes\n");
    }else{
      printf("No\n");
    }
  }
  return 0;
}


Measured memory_bytes: 1280
def countdif(s, t):
  ans = 0
  for i in range(len(s)):
    if s[i] != t[i]:
      ans += 1
  return ans

s = input()
t = input()
ans = 10000
for i in range(len(s) - len(t) + 1):
  ans = min(ans, countdif(s[i:(i + len(t))], t))
  
print(ans)

Measured memory_bytes: 9020
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = INT_MAX;
const ll LLINF = LLONG_MAX;
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple
ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if(n&1==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

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


Measured memory_bytes: 256
// C - Cat Snuke and a Voyage
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;

string solve(int N, vvi &P){
	while(N--) if(P[N][0] & P[N][1]) return "POSSIBLE";
	return "IMPOSSIBLE";
}

int main(){
	int N,M; cin>>N>>M;
	vvi P(N, vi(2, false));
	while(M--){
		int a,b; cin>>a>>b;
		if(a==1) P[b-1][0] = true;
		if(b==N) P[a-1][1] = true;
	}
	cout<< solve(N, P) <<endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<double> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.txt", "r", stdin);
		//freopen("b.txt", "w", stdout);
	#endif

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

	int n, k;
	cin >> n >> k;
	cout << n-k+1 << "\n";

	return 0;
}


Measured memory_bytes: 256
MOD=10**9+7
N=int(input())
if N==3:
  print(61)
  exit()
  
dp=[[[[1]*4 for c in range(4)] for b in range(4)] for a in range(4)]
        
for x in range(4):
  dp[0][x][2][1]=0
  dp[0][2][x][1]=0
  dp[0][1][2][x]=0
  dp[2][0][1][x]=0
  dp[0][2][1][x]=0
  dp[x][0][1][2]=0
  dp[x][2][0][1]=0
  dp[x][0][2][1]=0
  
def f():
  tmp=[[[[0]*4 for c in range(4)] for b in range(4)] for a in range(4)]
  for a in range(4):
    for b in range(4):
      for c in range(4):
        t=sum([dp[x][a][b][c] for x in range(4)])
        t%=MOD
        for d in range(4):
          tmp[a][b][c][d]=t
          
  for x in range(4):
    tmp[0][x][2][1]=0
    tmp[0][2][x][1]=0
    tmp[0][1][2][x]=0
    tmp[2][0][1][x]=0
    tmp[0][2][1][x]=0
    tmp[x][0][1][2]=0
    tmp[x][2][0][1]=0
    tmp[x][0][2][1]=0
    
  return tmp
  
for k in range(4, N):
  dp=f()
  
print(sum([dp[a][b][c][d] for a in range(4) for b in range(4) for c in range(4) for d in range(4)])%MOD)

Measured memory_bytes: 3192
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int N;cin>>N;
    int C;ll K;cin>>C>>K;
    vector<ll> T(N);
    REP(i,N)cin>>T[i];
    sort(T.begin(),T.end());
    T.push_back(INF);
    ll wt=0;
    int cnt=1;
    int res=0;
    REP(i,N){
        if(wt+T[i+1]-T[i]<=K && cnt<C){
            wt+=T[i+1]-T[i];
            cnt++;
        }else{
            wt=0;
            cnt=1;
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int n1 = (s.at(0)-'0');
  int n2 = (s.at(1)-'0');
  int n3 = (s.at(2)-'0');
  if(max(max(n1, n2), n3) == n1)
    cout << n1*111 << "\n";
  else if(n1 == 9)
    cout << 999 << "\n";
  else
    cout << (n1+1)*111 << "\n";

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int N;
    vector<string> W;
    cin >> N;
    for (int i = 0; i < N; i++) {
        string Wi;
        cin >> Wi;
        auto result = find(W.begin(), W.end(), Wi);
        if (result != W.end()) {
            cout << "No" << endl;
            return 0;
        } else {
            W.push_back(Wi);
        }
    }
    for (int i = 0; i < N - 1; i++) {
        if (W[i][W[i].size()-1] != W[i+1][0]) {
            cout << "No" << endl;
            return 0;
        }
    }

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

Measured memory_bytes: 256
// SPDX-License-Identifier: X11
// 2020-06-21

#include <stdio.h>
#include <stdlib.h>

int compare( const void* a, const void* b);

int main(void) {
  int N, K;
  scanf("%d %d", &N, &K);

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

  qsort(arr, N, sizeof(int), compare);

  int ans = 0;
  for(int i = 0; i < K; i++)
    ans += arr[i];

  printf("%d\n", ans);

  return 0;
}

int compare( const void* a, const void* b) {
  int int_a = * ( (int*) a );
  int int_b = * ( (int*) b );

  if ( int_a == int_b ) return 0;
  else if ( int_a < int_b ) return -1;
  else return 1;
}


Measured memory_bytes: 1744
import java.util.Scanner;
public class Main{
		
    public void solve(){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		System.out.println(a * b+" "+(a+b)*2);
		
    }
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}
				
			
  

Measured memory_bytes: 17156
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, Q = in_nn()
    C = in_nl()
    LR = []

    for q in range(Q):
        l, r = in_nn()
        LR.append((r + 0.1, l, q))

    t = [-1] * (N + 1)
    sect = []
    for i in range(N):
        x = C[i]
        if t[x] != -1:
            sect.append((i + 1, t[x], -1))
        t[x] = i + 1

    sect += LR
    sort_index = sorted(list(range(len(sect))), key=lambda i: sect[i][0])

    bit = [0] * (N + 1)

    def add(i, val):
        while i <= N:
            bit[i] += val
            i += i & -i

    def sum(i):
        res = 0
        while i > 0:
            res += bit[i]
            i -= i & -i
        return res

    ans = [0] * Q
    for i in sort_index:
        r, l, n = sect[i]
        r = int(r)

        if n == -1:
            add(l, 1)
        else:
            t = sum(r) - sum(l - 1)
            ans[n] = r - l + 1 - t

    print('\n'.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 295340
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    // Your code here!
    ll N=0,sum=1;
    ll A,B;
    cin>>A>>B;
    while(B>sum){
        ++N;
        sum+=A-1;
    }
    cout<<N<<endl;
}


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


namespace ConsoleApp6
{
	class Program
	{
		static void Main(string[] args)
		{
			while (true)
			{
				string n = Console.ReadLine();
				string nn = "";
				
				if (n == "-")
					break;
				int m = int.Parse(Console.ReadLine());
				int[] h = new int[m];

				for(int m_i = 0; m_i < m; m_i++)
				{
					
					h[m_i] = int.Parse(Console.ReadLine());
					nn += n;

					if (m_i == m-1)
					{
						nn += n;
						nn = nn.Substring(h[m_i], n.Length);
						Console.WriteLine(nn);
					}
					else
					{
						nn = nn.Substring(h[m_i]);
					}
				}
			}

		}
	}
}



Measured memory_bytes: 21280
#include <stdio.h>

int main(void)
{
  int i,n,a,b,c;

  while (1) {
    scanf("%d %d",&a,&b);
    if (a == 0 && b == 0){
      break ;
    }
    for (i=0; i<a; i++){
      if (i % 2){
      for (n=0; n<b; n++){
        if (n % 2)
	  printf("#");
	else
	  printf(".");
      }
      }
      else
	{
	for (n=0; n<b; n++){
	  if (n % 2)
	    printf(".");
          else
	    printf("#");}
      }
    printf("\n");
    }
    printf("\n");
  }
  return 0;
}
  

Measured memory_bytes: 572
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const int INF = (1LL<<30);
#else
const ll INF = (1LL<<60);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

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); }

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

int a[100010];
int l1[100010], r1[100010], seg1[100010];
int l2[200010], r2[200010], seg2[200010];
int ret[100010];
signed main(void)
{
  int n, m;
  cin >> n >> m;
  int prev;
  cin >> prev;
  int all = 0;
  REP(i, n-1) {
    int a;
    cin >> a;
    if(prev < a) {
      l1[prev+1]++;
      r1[a]++;
      seg1[a] += a-prev-1;
      all += a-prev;
    } else {
      l2[prev+1]++;
      r2[a+m]++;
      seg2[a+m] += a+m-prev-1;
      all += a+m-prev;
    }
    prev = a;
  }

  int cnt = 0, sum = 0;
  FOR(i, 1, m+1) {
    ret[i] = sum;
    cnt += l1[i];
    cnt -= r1[i];
    sum += cnt;
    sum -= seg1[i];
  }

  cnt = 0, sum = 0;
  FOR(i, 1, 2*m+1) {
    ret[i>m?i-m:i] += sum;
    // cout << i << " " << sum << " " << cnt << endl;
    cnt += l2[i];
    cnt -= r2[i];
    sum += cnt;
    sum -= seg2[i];
  }

  // cout << all << endl;
  // FOR(i, 1, m+1) cout << ret[i] << " "; cout << endl;

  int ans = 0;
  FOR(i, 1, m+1) chmax(ans, ret[i]);
  cout << all - ans << endl;

  return 0;
}


Measured memory_bytes: 7680
#include<bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define forout(i,a,b) for(int i=a;i>=b;--i)
#define task ""
#define pii pair<int,int>
#define fi first
#define se second
#define sz(s) (int)(s.size())
#define pb push_back
#define int long long
using namespace std;
const int N=1e5+1,M=101;
const int inf=INT_MAX;
int n,W,w[M],v[M],f[M][N];
main()
{
    cin>>n>>W;
    forinc(i,1,n) cin>>w[i]>>v[i];
    forinc(i,0,n)
    forinc(j,0,100001) f[i][j]=inf;
    f[0][0]=0;
    forinc(i,1,n)
    {
        forinc(j,0,100000)
        {
            f[i][j]=f[i-1][j];
            if(j>=v[i]) f[i][j]=min(f[i-1][j-v[i]]+w[i],f[i][j]);
        }
    }
    int kq=0;
    forout(i,100000,0) if(f[n][i]<=W) {kq=i;break;}
    cout<<kq;
}


Measured memory_bytes: 79104
# coding: utf-8
# Your code here!
import numpy

N, D = map(int, input().split())
X = []
for _ in range(N):
    X.append(list(map(int, input().split())))

count = 0
for i in range(N):
    for j in range(N):
        if i != j:
            a = numpy.array(X[i])
            b = numpy.array(X[j])
            u = b - a
            distance = numpy.linalg.norm(u)
            if distance == int(distance):
                count += 1

print(int(count/2))

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

int main() {
  vector<int> A(3);
  for(int i=0;i<3;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  cout << A.at(0)+A.at(1)+10*A.at(2) << endl;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define mod 1000000007
int n;
ll x,y;
int main(){
	cin >> n;
	cin >> x >> y;
	for(int i=1;i<n;i++){
		ll a,b; cin >> a >> b;
		ll c = (x+a-1)/a; ll d = (y+b-1)/b;
		x = max(c,d)*a; y = max(c,d)*b;
	}
	cout << x+y << endl;
}

Measured memory_bytes: 256
n = int(input())
march = [0]*5
for _ in range(n):
    s = input()
    for i in range(5):
        if 'MARCH'[i] == s[0]:
            march[i] += 1
ans = 0
for i in range(3):
    for j in range(i+1,4):
        for k in range(j+1,5):
            ans += march[i]*march[j]*march[k]
print(ans)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var a = ab[0];
            var b = ab[1];
            Console.WriteLine("{0} {1}", a * b, (a + b) * 2);
           






        }
                
                
                
    }
}

Measured memory_bytes: 9340
r, c = map(int, input().split())
tbl = []
for i in range(r):
    row = list(map(int, input().split()))
    row.append(sum(row))
    tbl.append(row)

row = [0] * (c + 1)
for i in range(c+1):
    for j in range(r):
        row[i] += tbl[j][i]
tbl.append(row)

for row in tbl:
    print(" ".join(map(str, row)))



Measured memory_bytes: 5704
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P  = pair<int,int>;
using v  = vector<int>;
using vv = vector<v>;
const int MOD = 1000000007;

int main(){
    int n; cin >> n;
    
    string s,t;
    cin >>s>>t;
    int now,bef;
    
    ll ans = 1;
    
    for(int i=0; i<n; i++){
        
        if(s[i]!=t[i]){
            now = 1;
        }
        else
            now = 0;
        
        if(i==0){
            if(now)ans *= 6;
            else ans *= 3;
        }
        else{
            if(!bef)
                ans *= 2;
            else if(now)
                ans *= 3;
        }
        bef = now;
        ans %= MOD;
        if(now)i++;
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) ((v).begin(),(v).end())
using namespace std;

int main(){
    int n;
    cin >> n;
    int a[n];
    REP(i,n) cin >> a[i];

    double val=0.0;
    REP(i,n){
        val += 1.0 / a[i];
    }

    cout << 1.0/val << endl;
    return 0;
}

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

namespace ABC149A
{
    class Program
    {
        static void Main(string[] args)
        {
            string S, T;

            var word = Console.ReadLine().Split(' ');//全体をSpace区切りで文字列として認識

            S = (word[0]);//文字列から数字を取り出す
            T = (word[1]);//上意

            Console.WriteLine(T+S);//文字列XXXを表示する

            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>

#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define repf(i, a, b) for (int i = (int)a; i < (int)b; i++)
#define repv(x, arr) for (auto &x : arr)
#define all(v) (v).begin(), (v).end()
#define vec(name, num) vector<ll> name((num), 0);
#define mp(a, b) make_pair(a, b)
#define op(i) cout << (i) << endl;
#define F first
#define S second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;

const ll mod = 1e9 + 7;
const ll infl = 1e17;

typedef unsigned long long ull;

ll powmod(ll x, ll y, ll mod)
{
    map<ll, ll> Z;
    Z[0] = 1;
    Z[1] = x;
    ll nowy = 1;
    ll nowx = x;
    while (nowy * 2 < y)
    {
        nowy *= 2;
        nowx = nowx * nowx % mod;
        Z[nowy] = nowx;
    }
    ll nowz = nowy / 2;
    while (nowy < y)
    {
        if (nowz + nowy <= y)
        {
            nowy += nowz;
            nowx = (nowx * Z[nowz]) % mod;
        }
        nowz /= 2;
    }
    return nowx;
}


int main()
{
    ll n,k;
    cin>>n>>k;
    vector<ll> kaijo(n + 1, 0);
    kaijo[0] = 1;
    repf(i, 1, n + 1)
    {
        kaijo[i] = (kaijo[i - 1] * i) % mod;
    }
    vector<ll> gyaku(n + 1, 0);
    gyaku[n] = powmod(kaijo[n], mod - 2, mod);
    for (int i = n; i > 0; i--)
    {
        gyaku[i - 1] = (gyaku[i] * i) % mod;
    }

    repf(i,1,k+1){
        if (i-1>n-k)
            cout << 0 << endl;
        else{
            ll ans = 1;
            ans = (ans * kaijo[k - 1]) % mod;
            ans = (ans * gyaku[i - 1]) % mod;
            ans = (ans * gyaku[k - i]) % mod;
            ans = (ans * kaijo[n - k + 1]) % mod;
            ans = (ans * gyaku[i]) % mod;
            ans = (ans * gyaku[n - k + 1 - i]) % mod;
            cout << ans << endl;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,i,j;
    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

using namespace std;

const int N = 234567;

int n, a[N], b[N];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  int m = (n << 1) - 1;
  for (int i = 1; i <= m; ++i) {
    cin >> a[i];
  }
  auto check = [&] (int x) {
    for (int i = 1; i <= m; ++i) {
      b[i] = a[i] > x;
    }
    for (int i = 1; i < n; ++i) {
      if (b[n - i] == b[n - i + 1]) {
        return b[n - i];
      }
      if (b[n + i] == b[n + i - 1]) {
        return b[n + i];
      }
    }
    return b[n] ^ (n & 1) ^ 1;
  };
  int l = 1, r = m;
  while (l != r) {
    int mid = l + r >> 1;
    if (check(mid)) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  cout << l << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int t;
  cin>>t;
  int a[t];int g[n]={};
  for(int i=0;i<t;i++)cin>>a[i];
    for(int o=0;o<t;o++){
      int w=0;
      for(int i=0;i<n;i++){
        int p;
        cin>>p;
        if(a[o]==p)g[i]++,w++;
      }
      g[a[o]-1]+=n-w;
    }
    //sort(g,g+n);
  for(int i=0;i<n;i++)cout<<g[i]<<endl;
}

Measured memory_bytes: 3104