akhauriyash/Code-Regression huggingface dataset:
n = gets.chomp.to_i
# n, m = gets.chomp.split(" ").map(&:to_i)
a = []
b = []

n.times do |i|
  a[i], b[i] = gets.chomp.split(" ").map(&:to_i)
end

a.sort!
b.sort!

def median(arr)
  n = arr.length
  if n%2 == 0
    return arr[n/2-1]+arr[n/2]
  else
    return arr[(n+1)/2-1]
  end
end

p median(b) - median(a)+1

Measured memory_bytes: 20000
<?php

fscanf(STDIN, "%d", $n);

$arr1 = [];
$arr2 = [];

for ($i = 0; $i < $n; ++$i) {
    $inputs = explode(' ', trim(fgets(STDIN)));

    $arr1[$inputs[1]] = $i;
   
    $arr2[$inputs[0]][] = $inputs[1];
}

ksort($arr2);

foreach ($arr2 as $city => $points) {
    rsort($points);

    foreach ($points as $point) {
        echo $arr1[$point] + 1, PHP_EOL;
    }
}


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

const int inf = 1e9;
const ll linf = 1e18;

int main()
{
    int a, b, c; cin >> a >> b >> c;
    int x[] = {a, b, c};
    sort(x, x + 3);
    int d13 = x[2] - x[0];
    int d12 = x[1] - x[0];
    int d23 = x[2] - x[1];

    int ans = min({
        d13 + d12,
        d23 + (d12 + 1) / 2 + (d12 % 2 == 1),
        (d13 + 1) / 2 + (d13 % 2 == 1) + (d23 + 1) / 2 + (d23 % 2 == 1)
    });
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
using namespace std;

const int maxn = 200000 + 10;
struct Node {
    int l,r;
    bool operator < (const Node& b) const {
        return r == b.r && l > b.l || r < b.r;
    }
}P[maxn];
vector<int> sl,sr;
int n;

int main() {
    scanf("%d",&n);
    for(int i = 0; i < n; i++) {
        scanf("%d %d",&P[i].l,&P[i].r);
        sl.push_back(P[i].l);
        sr.push_back(P[i].r);
    }
    sort(sl.begin(),sl.end());
    sort(sr.begin(),sr.end());
    int mmax = 0;
    for(int i = 0; i < n; i++) {
        int t1 = upper_bound(sr.begin(),sr.end(),P[i].l) - sr.begin();
        int t2 = lower_bound(sl.begin(),sl.end(),P[i].r) - sl.begin();
        t2 = n - t2;
        mmax = max(mmax,n - t1 - t2);
    }
    sort(P, P + n);
    multiset<int> s;
    multiset<int>::iterator it;
    for(int i = 0; i < n; i++) {
        if(s.empty()) {
            s.insert(-P[i].r);
        } else {
            it = s.lower_bound(-P[i].l);
            if(it == s.end()) {
                s.insert(-P[i].r);
            } else {
                s.erase(it);
                s.insert(-P[i].r);
            }
        }
    }
    cout << mmax << " " << s.size() << endl;
    return 0;
}



Measured memory_bytes: 15316
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;
typedef long long ll;

const int    INF = 1000000000;
const int    MOD = 1000000007;
const double EPS = 1e-8;

int main(){
    int N, T;
    cin >> N >> T;
    string tmp;
    cin >> tmp >> tmp;
    vector<pair<string, int>> ans;
    for(int i = 0; i < N - 1; i++){
        int a, b;
        scanf("%d:%d", &a, &b);
        int t = a * 60 + b;
        cin >> tmp;
        scanf("%d:%d", &a, &b);
        t = a * 60 + b - t;
        cin >> tmp;
        if(t >= T){
            ans.push_back(make_pair(tmp, t));
        }
    }
    cout << ans.size() << endl;
    for(auto p : ans){
        cout << p.first << " " << p.second << endl;
    }
    return 0;
}

Measured memory_bytes: 1264
import java.io.BufferedReader;
import java.io.*;
import java.util.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Collections;
public class Main {
	public static void main(final String[] args){
    
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    List<Character> list = new ArrayList<>();

    for(int i = 0; i < s.length(); i++){
        list.add(s.charAt(i));

        //切り出した文字列を一文字ずつ出力
    }

    if(list.get(2).equals(list.get(3)) && list.get(4).equals(list.get(5))){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }

   
    
    
    
	}
}

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

using ll = long long;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)

/***** MAIN *****/
signed main() {
  int n;
  scanf("%d", &n);
  int bars[n];
  ll sum_from_begin[n] = {}, sum_from_end[n] = {};
  REP(i, n) {
    scanf("%d", &bars[i]);
    if(i == 0) sum_from_begin[i] = bars[i];
    else {
      sum_from_begin[i] = sum_from_begin[i-1] + bars[i];
    }
  }
  sum_from_end[0] = sum_from_begin[n-1];
  REPS(i, 1, n) {
    sum_from_end[i] = sum_from_end[i-1] - bars[i-1];
  }
  ll ans = abs(sum_from_begin[0] - sum_from_end[1]);
  REPS(i, 1, n-1) {
    ans = min(ans, abs(sum_from_begin[i] - sum_from_end[i+1]));
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(n);
    int cnt = 0;
    ll x = INF;
    rep(i, n)
    {
        cin >> a[i];
        if(a[i] < 0){
            a[i] *= -1;
            cnt++;
        }
        x = min(a[i], x);
        sum += a[i];
    }
    if(cnt % 2){
        sum -= 2*x;
    }
    cout << sum << endl;
}

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

using namespace std;

int keisan(string a) {
	int counter = 0;
	int counter2 = 1;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] == 'm') {
			counter += counter2 * 1000;
			counter2 = 1;
		} else if (a[i] == 'c') {
			counter += counter2 * 100;
			counter2 = 1;
		} else if (a[i] == 'x') {
			counter += counter2 * 10;
			counter2 = 1;
		} else if (a[i] == 'i') {
			counter += counter2;
			counter2 = 1;
		} else {
			counter2 = a[i]-'0';
		}
	}
	return counter;
}

int main() {
	int n;
	cin >> n;
	string a, b;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		int aa, bb;
		aa = keisan(a);
		bb = keisan(b);
		int c = aa+bb;
		if (c/1000 > 1) {
			cout << c/1000 << 'm';
		} else if (c/1000 == 1) {
			cout << 'm';
		}
		c %= 1000;
		if (c/100 > 1) {
			cout << c/100 << 'c';
		} else if (c/100 == 1) {
			cout << 'c';
		}
		c %= 100;
		if (c/10 > 1) {
			cout << c/10 << 'x';
		} else if (c/10 == 1) {
			cout << 'x';
		}
		c %= 10;
		if (c > 1) {
			cout << c << 'i';
		} else if (c == 1) {
			cout << 'i';
		}
		cout << endl;
	}
	return 0;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
#define int long long

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) {
        cin >> h[i];
    }
    sort(h.begin(), h.end());
    int res = 0;
    for (int i = 0; i < n - k; ++i) {
        res += h[i];
    }
    cout << res << endl;
}

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

int main()
{
    data_type t,n,te=0;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    cin>>str;
    if(str[2]==str[3] && str[4]==str[5])
      cout<<"Yes"<<endl;
    else
      cout<<"No"<<endl;
    return 0;
}
/*
3
3
.#.
11
...##....##
2
##
*/


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using V = vector<int>;
using VV = vector<V>;

struct P {
  int z;
  int x;
  int y;
};

struct State {
  int t;
  int f;
};

// r[t][f] = number on the right side in state(t, f)
const int r[7][7] = {
    {0, 0, 0, 0, 0, 0, 0},
    {0, 0, 3, 5, 2, 4, 0},
    {0, 4, 0, 1, 6, 0, 3},
    {0, 2, 6, 0, 0, 1, 5},
    {0, 5, 1, 0, 0, 6, 2},
    {0, 3, 0, 6, 1, 0, 4},
    {0, 0, 4, 2, 5, 3, 0},
};

State s;  // state[t][f]
P p;

// dice[z][x][y] = number on the top side
vector<VV> dice;

// dir[4] = {f, r, b, l}
P rotate(int dir) {
  if (dir == 0) return {p.z - 1, p.x - 1, p.y};
  if (dir == 1) return {p.z - 1, p.x, p.y + 1};
  if (dir == 2) return {p.z - 1, p.x + 1, p.y};
  if (dir == 3) return {p.z - 1, p.x, p.y - 1};
}

void move(int dir) {
  if (dir == 0) s = {7 - s.f, s.t};
  if (dir == 1) s = {7 - r[s.t][s.f], s.f};
  if (dir == 2) s = {s.f, 7 - s.t};
  if (dir == 3) s = {r[s.t][s.f], s.f};
  p = rotate(dir);
}

int direction(int x) {
  if (x == s.f) return 0;
  if (x == r[s.t][s.f]) return 1;
  if (x == 7 - s.f) return 2;
  if (x == 7 - r[s.t][s.f]) return 3;
  return -1;
}

bool can_roll(int dir) {
  if (p.z == 0) return false;
  P n = rotate(dir);
  if (dice[n.z][n.x][n.y] > 0) return false;
  return true;
}

bool fall() {
  for (int i = 6; i >= 4; i--) {
    int dir = direction(i);
    if (dir > -1 && can_roll(dir)) {
      move(dir);
      return true;
    }
  }
  return false;
}

int main() {
  int n;
  while (cin >> n, n) {
    dice = vector<VV>(101, vector<V>(201, V(201, 0)));
    for (int i = 0; i < n; i++) {
      int t, f;
      cin >> t >> f;
      s = {t, f};
      p = {100, 100, 100};
      while (true) {
        while (p.z - 1 >= 0 && dice[p.z - 1][p.x][p.y] == 0) p.z--;
        if (!fall()) break;
      }
      dice[p.z][p.x][p.y] = s.t;
    }
    vector<int> ans(7, 0);
    for (int i = 0; i <= 200; i++) {
      for (int j = 0; j <= 200; j++) {
        int k = 100;
        while (k > 0 && dice[k][i][j] == 0) k--;
        ans[dice[k][i][j]]++;
      }
    }
    for (int i = 1; i <= 6; i++) {
      cout << ans[i] << ((i == 6) ? '\n' : ' ');
    }
  }
}



Measured memory_bytes: 36476
#include<string.h>
#include<stdio.h>

int main()
{
	char sent[201], temp[201];
	int i, j, k;
	while (scanf("%s", sent))
	{
		if (strcmp(sent, "-") == 0) break;
		scanf("%d", &i);
		for (j = 1; j <= i; j++)
		{
			scanf("%d", &k);
			strcpy(temp, sent);
			strcpy(sent, temp + k);
			temp[k] = '\0';
			strcat(sent, temp);
		}
		puts(sent);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
#define ll long long int
#define N 10000
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.14159265
#define cot cout.tie(0)
using namespace std;

string s;
ll n;
ll dp[101][3][4];
ll rec(ll i, ll tight, ll k)
{

    if (i == n && k==0)
        return 1;
    else if(i==n)
    return 0;

    if(dp[i][tight][k]!=-1)
    return dp[i][tight][k];
     

    ll no = (int)s[i] - 48;
    ll ans = 0;

    if (i == 0)
    {
        ans += rec(i + 1, tight, k);

        if (k > 0)
        {
            f(j, 1, no - 1)
                ans += rec(i + 1, tight, k - 1);

            ans +=rec(i + 1, 1, k - 1);
        }
    }
    else
    {
        if (!tight)
        {
            ans +=rec(i + 1, 0, k);
            if (k > 0)
            {
                f(j, 1, 9)
                {
                    ans +=rec(i + 1, tight, k - 1);
                }
            }
        }
        else
        {
            if (no != 0)
                ans +=rec(i + 1, 0, k);
            else if (no == 0)
                ans +=rec(i + 1, 1, k);

            if (k > 0)
            {
                f(j, 1, no - 1)
                {
                    ans +=  rec(i + 1, 0, k - 1);
                }
                if (no != 0)
                    ans +=  rec(i + 1, tight, k - 1);
            }
        }
    }

    return dp[i][tight][k]=ans;
}

int main()
{
    //freopen("input.txt", "r", stdin);
    memset(dp,-1,sizeof(dp));

    cin >> s;
    ll k;
    cin >> k;

    n = s.length();
     cout << rec(0, 0, k);
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    visited = [False] * N
    visited[0] = True
    path = [1]
    loop_s_idx = -1
    loop_e_idx = -1
    a = 1
    while True:
        a = A[a - 1]
        if visited[a - 1]:
            loop_s_idx = path.index(a)
            loop_e_idx = len(path) - 1
            break
        else:
            visited[a - 1] = True
            path.append(a)

    if K < len(path):
        ans = path[K]
    else:
        loop_length = loop_e_idx - loop_s_idx + 1
        q, r, = divmod(K - loop_s_idx, loop_length)
        ans = path[loop_s_idx + r]

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 31448
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int MAX = 51;
typedef pair<int,int> PP;
typedef pair<int,PP> P;

int main(){
  int t,p,r,tID,pID,time;
  string judge;

  while(cin >> t >> p >> r ,t + p + r){
    int ans[MAX][MAX] = {{0}},pe[MAX][MAX] = {{0}},AC[MAX]={0};
    while(r--){
      cin >> tID >> pID >> time >> judge;

      if(judge == "CORRECT"){
	ans[tID][pID] += time+pe[tID][pID];
	AC[tID]++;
      }
      else{
	pe[tID][pID] += 1200;
      }
    }

    vector<P> v(t);
    for(int i = 0 ; i < t ; i++){
      for(int j = 0 ; j < p ; j++){
	v[i].second.first += ans[i+1][j+1];
      }
      v[i].first = -AC[i+1];
      v[i].second.second = i+1;
    }
    sort(v.begin(),v.end());
    for(int i = 0 ; i < t ; i++){
      cout << v[i].second.second << ' ' << -v[i].first 
	   << ' ' << v[i].second.first << endl; 
    }
  }

  return 0;
}

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

int main(){
  unsigned long long int N,A,B;
  cin>>N>>A>>B;
  if(A+B == 0) cout << 0 << endl;
  else cout << N/(A+B)*A+(N%(A+B)<A?N%(A+B):A) << endl;
  return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())

h=list(map(int,input().split()))
for i in range(101):
  h.append(0)
  
big=10**5+100
dp=[float('inf') for i in range(big)]

dp[0]=0

for i in range(N):
  for j in range(1,K+1):
    if dp[i+j] > dp[i] + abs(h[i+j]-h[i]):
      dp[i+j] = dp[i] + abs(h[i+j]-h[i])
      
print(dp[N-1])

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

int main()
{
  string s;
  cin >> s;
  
  int strlen = s.size();
  char last = s.at(strlen - 1);
  
  if (last == 's') {
    cout << s + "es" << endl;
  } else {
    cout << s + "s" << endl;
  }  
}

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

using namespace std;

int main(){
	int N; cin >> N;
	vector<int> A(N);
	for(int i = 0; i < N; ++i) { cin >> A[i]; A[i]--; }

	vector<pair<int, int> > ans(N);

	for(int i = 0; i < N; ++i){
		ans[i].first = A[i];
		ans[i].second = i;
	}

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

	cout << ans[0].second+1;
	for(int i = 1; i < N; ++i){
		cout << " " << ans[i].second+1;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 2048
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int n;

void solve(int pieces[],int sum,int dep){
    int pieces_c[30]={};
    for(int i=0;i<dep;i++) pieces_c[i]=pieces[i];
    if(sum==n){
        printf("%d",pieces[0]);
        for(int i=1;pieces[i]!=0;i++){
            printf(" %d",pieces[i]);
        }puts("");
        return;
    }
    for(int i=n;i>0;i--){
        if((dep!=0 && pieces[dep-1]<i) || sum+i>n) continue;
        pieces_c[dep]=i;
        solve(pieces_c,sum+i,dep+1);
    }
}

int main(){
    while(cin>>n,n){
        int pieces[30]={};
        solve(pieces,0,0);
    }
    return 0;
}

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

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

struct edge {
    int to;
    double cost;
};

vector<edge> G[33];
int N, M, P, A, B;
double T[10];
double dp[33][1 << 8];
void init() {
    REP(i, M) {
        REP(bit, 1 << 8) { dp[i][bit] = 1e9; }
    }
    int bit = (1 << (N + 1)) - 1;
    // dp[A][bit] = 0;
    REP(i, M) { G[i].clear(); }
}

using arr3 = array<int, 3>;
struct Data {
    double res;
    int pos, rem;
    Data(double a, int b, int c) : res(a), pos(b), rem(c) {}
    bool operator>(const Data &d) const { return res > d.res; }
    bool operator<(const Data &d) const { return res < d.res; }
};
pair<int, int> pre[101][1 << 8];
bool solve() {
    cin >> N >> M >> P >> A >> B;
    REP(i, N) cin >> T[i];
    if (N == 0) return false;
    A--, B--;
    init();
    REP(i, P) {
        int u, v;
        double c;
        cin >> u >> v >> c;
        u--, v--;
        G[u].push_back({v, c});
        G[v].push_back({u, c});
    }
    priority_queue<Data, vector<Data>, greater<Data>> que;
    int bit = 0;
    REP(i, N) { bit |= (1 << i); }
    que.push({0, A, bit});
    while (!que.empty()) {
        Data ar = que.top();
        que.pop();
        int n = ar.pos, rem = ar.rem;
        double res = ar.res;

        if (res > dp[n][rem]) continue;
        // cout << n << " " << bitset<8>(rem) << " " << res << endl;
        for (auto e : G[n]) {
            REP(j, N) {
                if (rem & (1 << j)) {
                    int nrem = rem - (1 << j);
                    if (dp[e.to][nrem] > res + (double)e.cost / T[j]) {
                        dp[e.to][nrem] = res + (double)e.cost / T[j];
                        pre[e.to][nrem] = {n, rem};
                        que.push({dp[e.to][nrem], e.to, nrem});
                    }
                }
            }
        }
    }
    double ans = 1e9;
    pair<int, int> stat;
    REP(bit, 1 << N) {
        if (dp[B][bit] < ans) {
            ans = dp[B][bit];
            stat = {B, bit};
        }
    }
    if (ans >= 1e9)
        cout << "Impossible" << endl;
    else
        cout << fixed << setprecision(10) << ans << endl;
    return true;
}

signed main() {
    while (solve())
        ;
}


Measured memory_bytes: 5604
x, y = map(int, input().split())
tmp = abs(abs(x) - abs(y))
if (y == 0 and 0 < x) or (x == 0 and y < 0):
    print(tmp + 1)
elif 0 <= x * y and x <= y:
    print(tmp)
elif 0 <= x * y and y < x:
    print(tmp + 2)
else:
    print(tmp + 1)

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

using namespace std;

using ll = long long;

int main() {
	string s, t;
	cin >> s >> t;
	ll s_size = s.length();
	ll t_size = t.length();
	
	ll s_table[26][s_size];
	ll s_cur[26];
	bool used[26];

	for (int i = 0; i < 26; i++) {
		for (int j = 0; j < s_size; j++) {
			s_table[i][j] = -1;
		}
		s_cur[i] = -1;
		used[i] = false;
	}


	for (int i = s_size - 1; i >= 0 ; i--) {
		ll c = s.at(i) - 'a';
		s_cur[c] = i;
		used[c]= true;
		for (int j = 0; j < 26; j++) {
			s_table[j][i] = s_cur[j];
		}
	}

	ll ans = 0;
	ll s_pos = 0;
	for (int i = 0; i < t_size ; i++) {
		int c = t.at(i) - 'a';
		if (used[c] == false) {
			cout << -1 << endl;
			return 0;
		}
		int cur = s_table[c][s_pos];
		//cout << "cur1:" << cur << endl;
		if (cur == -1) {
			ans += (s_size - s_pos);
			s_pos = 0;
			cur = s_table[c][s_pos];
		} 
		//cout << "cur2:" << cur << endl;
		//cout << "s_pos:" << cur << endl;
		ans += cur - s_pos + 1;
		s_pos = (cur + 1) % s_size;
		//cout << "ans:" << ans << endl;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 20864
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MON 1000000007
#define INF (1<<29)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

#define max(x, y) ((x)>(y)?(x):(y))
#define min(x, y) ((x)<(y)?(x):(y))

class Vec{
public:
  double x, y;
  Vec(double x = 0, double y = 0):x(x),y(y){}

  void read(){
    cin >> x >> y;
  }
  
  Vec operator+(const Vec &other)
  {
    Vec result = *this;
    result.x += other.x;
    result.y += other.y;
    return result;
  }

  Vec operator-(const Vec &other)
  {
    Vec result = *this;
    result.x -= other.x;
    result.y -= other.y;
    return result;
  }

  Vec operator*(const float &k)
  {
    Vec result = *this;
    result.x *= k;
    result.y *= k;
    return result;
  }

  Vec operator/(const float &k)
  {
    Vec result = *this;
    result.x /= k;
    result.y /= k;
    return result;
  } 
  
  double cross(const Vec &other)
  {
    return x*other.y - y*other.x;
  }

  double dot(const Vec &other){
    return x*other.x + y*other.y;
  }
  
  bool operator==(const Vec &other) const
  {
    return abs(x - other.x) < EPS && abs(y - other.y) < EPS;
  }

  float norm()
  {
    return sqrt(x*x+y*y);
  }

  float norm2()
  {
    return x*x+y*y;
  }

  Vec standard(){
    Vec result = *this;
    return result/result.norm();
  }
};

class Line{
public:
  Vec a, b;
  Vec vect;
  Line(Vec a = Vec(), Vec b = Vec()):a(a),b(b),vect(b-a){}

  //projection
  Vec proj(Vec p){
    p = p - a;
    return a + vect * vect.dot(p) / vect.norm2();
  }

  //reflection
  Vec reflect(Vec p){
    return proj(p) * 2 - p;
  }
};

int main(){
  Vec p1, p2, p0;
  Int q;
  p1.read();
  p2.read();
  Line l(p1, p2);
  cin >> q;
  while(q--){
    p0.read();
    Vec ans = l.reflect(p0);
    printf("%.10lf %.10lf\n",ans.x, ans.y);
  }
  return 0;
}


Measured memory_bytes: 3300
#include <stdio.h>

int main()
{
    char s[4];
    scanf("%s",s);

    int i;
    for (i = 0; i < 2; i++)
    {
        if(s[i] != s[i + 1])break;
    }
    if(i == 2)printf("No");
    else printf("Yes");
}


Measured memory_bytes: 128
// writer: w33z8kqrqk8zzzx33
#include <bits/stdc++.h>
using namespace std;
 
#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

int aray[200005];

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int N, K; cin >> N >> K;
    ll v = 0, bes = 0; int cnt = 0;
    rep(i, N) {
        cin >> aray[i]; aray[i]++;
        v += aray[i];
        bes = max(bes, v);
        cnt++;
        if(cnt == K) {
            v -= aray[i-K+1];
            cnt--;
        }
    }
    cout << bes/2;
    if(bes%2) cout << ".5";
    cout << endl;
}



Measured memory_bytes: 1024
import java.util.*;

class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        long[] x = new long[N];

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

        long ans = 0;

        for(int i = 0; i < N-1; i++){
            ans += Math.min(A * (x[i+1] - x[i]), B);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 50120
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-8;
using vi = vector <int>;
using vvi = vector <vi>;

signed main() {
	int n;
	cin >> n;
	vvi a(2, vi(n + 1));
	rep (i, 2) {
		rep (j, n) {
			cin >> a[i][j + 1];
		}
	}
	rep (i, 2) {
		rep (j, n) {
			a[i][j + 1] += a[i][j];
		}
	}
	int macs = -INF;
	rep (i, n) {
		macs = max(macs, a[0][i + 1] - a[0][0] + a[1][n] - a[1][i]);
	}
	cout << macs << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int n;

/*
\sum_{i<j} di dj = ((sum_i di)^2 - \sum_i di^2) / 2
*/

int main(){
  int i, sum, sum2;
  scanf("%d",&n);
  sum = sum2 = 0;
  for(i = 0; i < n; i++){
    int d;
    scanf("%d", &d);
    sum += d;
    sum2 += d*d;
  }
  printf("%d\n", (sum*sum - sum2) / 2);

  return 0;
}


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

int main()
{
	int rows, columns;
	cin >> rows >> columns;
	int **HW;
	HW = new int * [rows];
	for (int i = 0; i < rows; i++) {
		HW[i] = new int[columns];
	}
	for (int i = 0; i < rows; i++) {
		for (int j = 0; j < columns; j++) {
			HW[i][j] = 0;
		}
	}
	//填格子开始

	int Num;
	cin >> Num;
	int *a;
	a = new int[Num];
	for (int i = 0; i < Num; i++) {
		cin >> a[i];
	}
	int var = 0; int x = -1, y = 0;
	for (int i = 0; i < Num; i++) {
		for (int j = 0; j < a[i]; j++) {
			if (var == 0) {
				x++;
				if (x < columns && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x--; j--; var++;
				}
			}else if (var == 1) {
				y++;
				if (y < rows && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y--; j--; var++;
				}
			}else if (var == 2) {
				x--;
				if (x >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					x++; j--; var++;
				}
			}else if(var == 3) {
				y--;
				if (y >= 0 && HW[y][x] == 0) {
					HW[y][x] = i + 1;
				}
				else {
					y++; j--; var = 0;
				}
			}
		}
	}
	//填格子结束
	for (int i = 0; i < rows; i++) {
		cout << HW[i][0];
		for (int j = 1; j < columns; j++) {
			cout << " " << HW[i][j];
		}
		cout << endl;
	}
	    return 0;
}

Measured memory_bytes: 384
use std::io::Read;

#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord)]
enum QueenPos {
    Unfixed,
    Fixed(usize),
}

fn is_placeable(row: usize, col: usize, queens: &[usize]) -> bool {
    (0..row).all(|r| queens[r] != col)
        && (0..row).all(|r| queens[r] != col.wrapping_sub(row - r))
        && (0..row).all(|r| queens[r] != col + (row - r))
}

fn rec(
    row: usize,
    queens: &mut Vec<usize>,
    height: usize,
    width: usize,
    initial_queens: &[QueenPos],
) -> bool {
    if row == height {
        true
    } else {
        match initial_queens[row] {
            QueenPos::Unfixed => (0..width)
                .find(|&col| {
                    is_placeable(row, col, queens) && {
                        queens[row] = col;
                        rec(row + 1, queens, width, height, initial_queens)
                    }
                })
                .map_or(false, |_| true),
            QueenPos::Fixed(col) => {
                is_placeable(row, col, queens) && {
                    queens[row] = col;
                    rec(row + 1, queens, width, height, initial_queens)
                }
            }
        }
    }
}

fn solve(height: usize, width: usize, rc: &[(usize, usize)]) -> Vec<Vec<char>> {
    let mut initial_queens = vec![QueenPos::Unfixed; height];
    for &(r, c) in rc {
        initial_queens[r] = QueenPos::Fixed(c);
    }

    let mut queens = vec![0; height];
    assert!(rec(0, &mut queens, height, width, &initial_queens));
    queens
        .into_iter()
        .map(|col| {
            (0..width)
                .map(|c| if c == col { 'Q' } else { '.' })
                .collect()
        })
        .collect()
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let k: usize = iter.next().unwrap().parse().unwrap();
    let rc = (0..k)
        .map(|_| {
            let r = iter.next().unwrap().parse().unwrap();
            let c = iter.next().unwrap().parse().unwrap();
            (r, c)
        })
        .collect::<Vec<_>>();
    let f = solve(8, 8, &rc);
    for r in f {
        println!("{}", r.iter().collect::<String>());
    }
}



Measured memory_bytes: 5036
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
using namespace std;
typedef long long ll;

int main() {
	int n;
	string s;
	//char a[110];
	//bool flag = true;
	cin >> n >> s;
	int res = n;
	int w = 0;
	int e = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'W') {
			w++;
		}
		else {
			e++;
		}
	}
	//cout << e << endl;
	//cout << w << endl;
	int cw = 0;
	int ce = 0;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'E'){
			res = min(cw + e - ce - 1, res);
		}
		else {
			res = min(cw + e - ce, res);
		}
		if (s[i] == 'W') {
			cw++;
		}
		else {
			ce++;
		}
		//cout << cw + e - ce << endl;
		//res = min(cw + e - ce, res);
	}
	cout << res << endl;
	return 0;

}


Measured memory_bytes: 900
s = input()
max = 0
for i in range(len(s)):
  cnt = 0
  for j in range(i, len(s)):
    if(s[j] == 'A' or s[j] == 'C' or s[j] == 'G' or s[j] == 'T'):
      cnt += 1
    else:
      break
  if(max < cnt):
    max = cnt
print(max)


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

int main(){
  string S, T;
  cin >> S >> T;
  bool flag = true;
  map<char,char> mp;
  for(int i=0; i<S.size(); i++){
    if(mp.count(S.at(i))){
      if(mp[S.at(i)] != T.at(i)){
        flag = false;
      }
    }
    else{
      mp[S.at(i)] = T.at(i);
    }
  }
  map<char,char> mp2;
  for(int i=0; i<S.size(); i++){
    if(mp2.count(T.at(i))){
      if(mp2[T.at(i)] != S.at(i)){
        flag = false;
      }
    }
    else{
      mp2[T.at(i)] = S.at(i);
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> foods(m);
  rep(i,m) foods[i] = 0;
  rep(i,n) {
    int k;
    cin >> k;
    rep(j,k) {
      int a;
      cin >> a;
      foods[a-1]++;
    }
  }
  int ans = 0;
  rep(i,m) {
    if (foods[i] == n) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn
  map solve <$> replicateM n (getLine >> f) >>= mapM_ putStrLn
  where
    f = map read <$> words <$> getLine

solve :: [Int] -> String
solve xs = g . foldl' f (0, 0) $ zip xs (tail xs)
  where
    f (mxu, mxd) (a, b) = (max mxu (b - a), max mxd (a - b))
    g (a, b) = unwords . map show $ [a, b]



Measured memory_bytes: 5244
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(M)]

lst=set()
for a,b in AB:
    if b==N:
        lst.add(a)

for a,b in AB:
    if a==1:
        if b in lst:
            print("POSSIBLE")
            exit()
print("IMPOSSIBLE")


Measured memory_bytes: 84568
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var L = cin.ReadIntArray(N);
            Array.Sort(L);
            var ans = 0;

            for (int i = 0; i < N - 2; i++)
            {
                for (int j = i + 1; j < N - 1; j++)
                {
                    var k = LowerBound(L, j + 1, N, L[i] + L[j]);
                    ans += k - j - 1;
                }
            }

            Console.WriteLine(ans);
        }

        public static int LowerBound(int[] arr, int start, int end, int value)
        {
            int low = start;
            int high = end;
            int mid;
            while (low < high)
            {
                mid = ((high - low) >> 1) + low;
                if (arr[mid] < value)
                    low = mid + 1;
                else
                    high = mid;
            }
            return low;
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13272
#include <map>
#include <cmath>
#include <string>
#include <cstdio>
#include <cstring>
#include <algorithm>
using std::map; using std::string;
using std::min; using std::max;
using std::swap; using std::sort;
typedef long long ll;

template<typename T>
void read(T &x) {
	int flag = 1; x = 0; char ch = getchar();
	while(ch < '0' || ch > '9') { if(ch == '-') flag = -flag; ch = getchar(); }
	while(ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); x *= flag;
}
#if __cplusplus >= 201103l
template<typename T, typename... V>
void read(T &x, V&... v) { read(x), read(v...); }
#endif

const int _ = 4e5 + 10;
int n, q, ff[_], d[_];
struct Edge { int u, v, w; } e[_]; int cnt;
inline bool operator < (const Edge &a, const Edge &b) { return a.w < b.w; }
inline void addEdge(int u, int v, int w) { e[++cnt] = {u, v, w}; }
void ChkMin(int &a, int b) { if(b < a) a = b; }
int find(int x) { return ff[x] == x ? x : ff[x] = find(ff[x]); }

int main () {
	read(n, q), memset(d, 127, sizeof(d[0]) * n);
	for(int i = 1, x, y, z; i <= q; ++i)
		read(x, y, z), addEdge(x, y, z), ChkMin(d[x], z + 1), ChkMin(d[y], z + 2);
	for(int i = 0; i < n; ++i) ChkMin(d[i], d[(i + n - 1) % n] + 2);
	for(int i = 0; i < n; ++i) ChkMin(d[i], d[(i + n - 1) % n] + 2);
	for(int i = 0; i < n; ++i) addEdge(i, (i + 1) % n, d[i]), ff[i] = i;
	sort(e + 1, e + cnt + 1); int blo = n; ll MST = 0;
	for(int i = 1; i <= cnt && blo > 1; ++i) {
		int u = find(e[i].u), v = find(e[i].v);
		if(u == v) continue; ff[u] = v, MST += e[i].w, --blo;
	}
	printf("%lld\n", MST);
	return 0;
} 


Measured memory_bytes: 9344
n = int(input())
a_n = list(map(int,input().split(" ")))
k = 0
t = 0
while True:
  for i in range(len(a_n)):
    if a_n[i] % 2 == 0:
      a_n[i] = a_n[i] / 2
    else:
      t = -1
      break
  if t == -1:
    break
  k += 1
print(k)

Measured memory_bytes: 2940
/* This code is written by Nemlit */
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define rep(i, a, b) for(re int i = (a); i <= (b); ++ i)
#define drep(i, a, b) for(re int i = (b); i >= (a); -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define D double
#define inf 1023456789
#define mod 1000000007
#define lb(x) (x)&(-(x))
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define maxn 1000005
int n, m, ch[maxn][27], rt, cnt, is[1000005][27], ton[27], fa[1000005], pax, ans;
struct node {
    string c;
    int len;
}e[maxn];
il bool cmp(node a, node b) {
    return a.len > b.len;
}
il void insert(int &now, int pa, int x) {
    if(x == -1) return;
    if(!now) now = ++ cnt;
    pax = now;
    insert(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    fa[ch[now][e[pa].c[x] - 'a' + 1]] = now;
}
il int find(int now, int pa, int x) {
    if(x == 0) return is[now][e[pa].c[0] - 'a' + 1];
    if(ch[now][e[pa].c[x] - 'a' + 1]) return find(ch[now][e[pa].c[x] - 'a' + 1], pa, x - 1);
    return 0;
}
signed main() {
	n = read();
    rep(i, 1, n) cin >> e[i].c, e[i].len = e[i].c.size();
    sort(e + 1, e + n + 1, cmp);
    rep(i, 1, n) {
        ans += find(rt, i, e[i].len - 1);
        insert(rt, i, e[i].len - 1);
        rep(j, 0, e[i].len - 1) {
            ton[e[i].c[j] - 'a' + 1] = 1;
            rep(k, 1, 26) is[pax][k] += ton[k];
            pax = fa[pax];
        }
        rep(i, 1, 26) ton[i] = 0;
    }
    cout << ans;
	return 0;
}
 

Measured memory_bytes: 300668
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename T>
vector<pair<T, int>> prime_factorization(T val) {
  vector<pair<T, int>> res;
  for (T i = 2; i * i <= val; ++i) {
    if (val % i != 0) continue;
    int exponent = 0;
    while (val % i == 0) {
      ++exponent;
      val /= i;
    }
    res.emplace_back(i, exponent);
  }
  if (val != 1) res.emplace_back(val, 1);
  return res;
}

vector<bool> sieve_of_eratosthenes(int val) {
  vector<bool> res(val + 1, true);
  res[0] = false;
  if (val >= 1) res[1] = false;
  for (int i = 2; i * i <= val; ++i) {
    if (res[i]) {
      for (int j = i * i; j <= val; j += i) res[j] = false;
    }
  }
  return res;
}

int main() {
  int n; cin >> n;
  vector<int> a(n); REP(i, n) cin >> a[i];
  vector p(1000001, false);
  bool is_p = true;
  REP(i, n) {
    for (auto [k, v] : prime_factorization(a[i])) {
      if (p[k]) {
        is_p = false;
        break;
      }
      p[k] = true;
    }
    if (!is_p) break;
  }
  if (is_p) {
    cout << "pairwise coprime\n";
    return 0;
  }
  int g = a[0];
  FOR(i, 1, n) g = gcd(g, a[i]);
  cout << (g == 1 ? "setwise coprime\n" : "not coprime\n");
  return 0;
}


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

typedef long long ll;

int dp[100][100] = {0};

ll maxPrice(ll price[], ll wt[], int total, int i, int n, ll dp[][100001]){
    if(i == n || total<=0){
        return 0;
    }
    ll p1 = 0, p2 = 0;
    if(dp[i][total]!=-1){
        return dp[i][total];
    }
    if(total>=wt[i]){
        p1 = maxPrice(price,wt,total-wt[i],i+1,n,dp) + price[i];
    }
    p2 = maxPrice(price,wt,total,i+1,n,dp);
    dp[i][total] = max(p1,p2);
    return dp[i][total];
}

int main() {
    ll n,k;
    cin>>n>>k;
    ll price[n],wt[n];
    for(ll i = 0; i<n; i++){
        cin>>wt[i]>>price[i];
    }
    ll dp[n+1][100001] = {0};
    for(int i = 0; i<=n; i++){
        for(int j = 0; j<=k; j++){
            dp[i][j] = -1;
        }
    }
    
    cout<<maxPrice(price,wt,k,0,n,dp)<<endl;
}


Measured memory_bytes: 82452
import collections

n=int(input())
l=list(map(int,input().split()))
s=collections.Counter(l)
s=s.most_common()
#print(s)
a=1
if n%2==0:
    for i in s:
        if i[1]!=2:
            print(0)
            exit()
        elif i[0]%2!=1 or i[1]//2>n//2:
            print(0)
            exit()
    else:
        for j in range(n//2):
            a=(2*a)%1000000007
    print(a)
elif n%2==1:
    if (0,1) not in s:
        print(0)
        exit()
    else:
        del s[-1]
        #print(s)
        for i in s:
            if i[1]!=2 or i[0]%2!=0 or i[0]//2>n//2:
                print(0)
                exit()
        else:
            for j in range(n//2):
                a=(2*a)%1000000007
    print(a)

Measured memory_bytes: 16096
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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


    int mae = atoi(S.substr(0,2).c_str());
    int ushiro = atoi(S.substr(2,2).c_str());

    string ans = "";

    // MMYY, か両方ありのパターン
    if(mae >= 1 && mae <= 12) {
        if(ushiro == 0) {
            cout << "MMYY" << endl;
            return 0;
        } else if(ushiro >= 1 && ushiro <= 12) {
            cout << "AMBIGUOUS" << endl;
            return 0;
        } else if(ushiro >= 13 && ushiro <= 99) {
            cout << "MMYY" << endl;
            return 0;
        }
    } else if(mae >= 0 && mae <= 99) {
        if(ushiro == 0) {
            cout << "NA" << endl;
            return 0;
        } else if(ushiro >= 1 && ushiro <= 12) {
            cout << "YYMM" << endl;
            return 0;
        } else if(ushiro >= 13 && ushiro <= 99) {
            cout << "NA" << endl;
            return 0;
        }
    }

    cout << "NA" << endl;
    return 0;

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

struct range_t {
    char ch;
    int begin, end;
};

int main() {
    int N, K;
    char str[(int)1e5] = {'\0'};

    cin >> N >> K;
    cin >> str;

    string S(str);

    std::vector<range_t> blockRange;

    int begin = 0;
    char prev = S.front();
    for (int i = 0; i < S.size(); i++) {
        if (prev != S.at(i)) {
            blockRange.push_back({ prev , begin, i });
            begin = i;
        } else if (i == S.size() - 1) {
            blockRange.push_back({ prev , begin, i + 1 });
        }
        prev = S.at(i);
    }


    int max = 0;
    //if (blockRange.size() >= K * 2 + 1) {
        for (int rb = 0; rb < blockRange.size(); rb++) {
            int size = (blockRange.at(rb).ch == '0') ? K * 2 : K * 2 + 1;
            if (rb + size >= blockRange.size())
                size = blockRange.size() - rb;

            if (size == 0) break;

            //cout << blockRange[rb + size - 1].end << " " << blockRange[rb].begin << "\n";
            
            int cnt = blockRange[rb + size - 1].end - blockRange[rb].begin;
            if (cnt > max) max = cnt;
        }
    //}
    // else {
    //     for (int rb = 0; rb < blockRange.size(); rb++) {
    //         int cnt = 0;
    //         int flip = 0;
    //         for (int offset = 0; rb + offset < blockRange.size(); offset++) {
    //             const auto & target = blockRange.at(rb + offset);
                
    //             if (target.ch == '0') flip++;
    //             if (flip > K) break;

    //             cnt += target.end - target.begin;
    //         }
        
    //         if (cnt > max) max = cnt;
    //     }
    // }
   
    cout << max;

    return 0;
}



Measured memory_bytes: 2168
#include<stdio.h>
int main(void)
{
	int d,n,t[201],a[201],b[201],c[201],dp[201][201],x,max,i,j,k;
	scanf("%d%d",&d,&n);
	for(i=0;i<d;i++) scanf("%d",&t[i]);
	for(i=0;i<n;i++) scanf("%d%d%d",&a[i],&b[i],&c[i]);
	for(i=0;i<=d;i++){
		for(j=0;j<n;j++) dp[i][j]=0;
	}
	for(i=0;i<n;i++){
		if(a[i]<=t[0]&&t[0]<=b[i]) dp[0][i]=1;
	}
	for(i=1;i<d;i++){
		for(j=0;j<n;j++){
			if(dp[i-1][j]!=0){
				for(k=0;k<n;k++){
					if(a[k]<=t[i]&&t[i]<=b[k]){
						x=0; x=c[j]-c[k];
						if(x<0) x*=-1;
					//	printf("%d\n",x);
					//	printf("%d %d\n",dp[i][k],dp[i-1][j]+x);
						if(dp[i][k]<dp[i-1][j]+x) dp[i][k]=dp[i-1][j]+x;
					}
				}
			}
		}
	}
	max=0;
	for(i=0;i<n;i++){
		if(max<dp[d-1][i]) max=dp[d-1][i];
	}
	/*for(i=0;i<d;i++){
		for(j=0;j<n;j++) printf("%d ",dp[i][j]);
		printf("\n");
	}*/
	printf("%d\n",max-1);
	return 0;
}

Measured memory_bytes: 1936
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m; cin>>n>>m;
    vector<pair<int,int>> v;
    for(int i=0;i<m;i++){
        int p,y; cin>>p>>y;
        v.push_back(pair<int,int>(p,y));
    }
    vector<pair<int,int>>cv = v;
    sort(begin(cv),end(cv),[](auto x, auto y){return x.second<y.second;});
    map<int,int> ken;
    map<int,int> num;
    vector<int> el(n+1,1);
    for(auto x:cv){
        ken[x.second]=x.first;
        num[x.second]=el[x.first];
        el[x.first]++;
    }
    for(auto x:v){
        printf("%06d%06d\n",ken[x.second],num[x.second]);
    }
}

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

vector<int> forintinput(int n) {
	vector<int> x;
	for(int i = 0;i < n;i++){
		int ia;
		cin >> ia;
		x.push_back(ia);
	}
	return x;
}
int main(){
	int n,k;
	cin >> n >> k;
	vector<bool> TorT(n,false);
	for(int i = 0;i < k;i++){
		int t;
		cin >> t;
		for(int i = 0;i < t;i++){
			int u;
			cin >> u;
			if(TorT[u-1] == false){
				TorT[u-1] = true;
			}
		}
	}
	int cnt = 0;
	for(int i = 0;i < n;i++){
		if(TorT[i] == false){
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3600
n,a,b = gets.split.map(&:to_i)

def function(n,a,b)
  train_fare = caliculat_train_fare(n,a)
  if train_fare > b
    puts b
  else
    puts train_fare
  end
end

def caliculat_train_fare(people, carfare)
  people * carfare
end

puts function(n,a,b)

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")


signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a == b && b == c ? "Yes" : "No") << nl;
}


Measured memory_bytes: 256
import Control.Applicative

f :: [Int] -> String
f [w,h,x,y,r]
  | 0 > (x-r) || w < (x+r) = "No"
  | 0 > (y-r) || h < (y+r) = "No"
  | otherwise              = "Yes"

main :: IO ()
main = do
  s <- map read . words <$> getLine
  putStrLn $ f s


Measured memory_bytes: 3640
fun solve(a:Int, b:Int){
    if(a in 1..9 && b in 1..9){
        println(a*b)
    }
    else{
        println(-1)
    }
}

fun main(){
    val (a, b) = readLine()!!.split(" ").map{it.toInt()}
    solve(a,b)
}

Measured memory_bytes: 36476