akhauriyash/Code-Regression huggingface dataset:
///Astalavista Code........~CodeSlayer007
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define Br cout<<endl;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define PT(x) cout << (#x) << " is " << (x) << endl;
#define SPD_emergency ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int M = 1e9 + 7;
int IM = 1e17;
void PV(vi v) { for (int i = 0 ; i < v.size() ; i++) cout << v[i] << " "; cout << endl;}
void PA(int v[], int n) {for (int i = 0 ; i < n ; i++)cout << v[i] << " " ; cout << endl;}
void IN(int a[], int n) {for (int i = 0; i < n; i++)cin >> a[i];}
inline void PTN(int n = 1, int a = 0, int b = 0, int c = 0) { if (n--)cout << a << " "; if (n--)cout << b << " "; if (n--)cout << c << " "; cout << endl; }
inline void open() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
// <-------------------------------------------------------------------------------------------------------------------------------------------------------------------------> Ignore This--> insert tuple first second push_back string continue make_pair break deque stack queue sort reverse accumulate  count lower_bound upper_bound next_permutation copy_n __builtin_popcount make_tuple
// <========================================================================================================================================================================

int pw(int x, int y)
{   int t;
    if ( y == 0) return 1;
    t = pw(x, y / 2);
    if (y % 2 == 0) return t * t;
    else return x * t * t;
}

signed  main() {
    SPD_emergency
    // int t; cin >> t; int tt = 1; while (t--)
    {
        int x;
        cin >> x;
        int i, j, k, l, m;
        vii v;
        for ( i = 0; i < 120; i++) {
          j = pw(i,5);
          v.push_back({j,i});
          v.push_back({-j,-i});
        }
      for( i = 0;i<v.size();i++){
        for( j = 0; j<v.size();j++){
            k = v[i].first;
            l = v[j].first;
            if(k-l ==x){
               cout<<v[i].second<<" "<<v[j].se;
               return 0;
            }
        }
      }

    }
    return 0;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
using u64 = unsigned long long;
#define REP(i, n) for (int i = 0; (i64)(i) < (i64)(n); ++i)

#ifdef ENABLE_DEBUG
template <typename T>
void debug(T value) {
  cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  cerr << value << ", ";
  debug(args...);
}
#define DEBUG(...)                              \
  do {                                          \
    cerr << " \033[33m (L" << __LINE__ << ") "; \
    cerr << #__VA_ARGS__ << ":\033[0m ";        \
    debug(__VA_ARGS__);                         \
    cerr << endl;                               \
  } while (0)
#else
#define debug(...)
#define DEBUG(...)
#endif

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<i64> lsums(n + 1);
  vector<i64> rsums(n + 1);
  REP(i, n) { lsums[i + 1] = lsums[i] + int(s[i] == 'W'); }
  REP(i, n) {
    int j = n - 1 - i;
    rsums[j] = rsums[j + 1] + int(s[j] == 'E');
  }
  const i64 INF = 1LL << 50;
  i64 mincost = INF;
  REP(i, n) {
    i64 cost = lsums[i] + rsums[i + 1];
    mincost = min(mincost, cost);
  }
  cout << mincost << endl;
}

Measured memory_bytes: 8120
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }



int main(){
    string s;
    cin >> s;
    set<char> sset(s.begin(), s.end());
    if(sset.count('7') > 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}



Measured memory_bytes: 3132
# -*- coding: utf-8 -*-


def main():
    n, x, y = map(int, input().split())

    x -= 1
    y -= 1

    result = [0] * (n -1)
    for i in range(n - 1):
        for j in range(i + 1, n):
            result[min(j - i, abs(x - i) + abs(y - j) + 1, abs(y - i) + abs(x - j) + 1) - 1] += 1

    for ret in result:
        print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt();
    int[] h=new int[n];
    for(int i=0;i<n;i++){
      h[i]=sc.nextInt();
    }
    h[0]=h[0]-1;
    for(int i=1;i<n;i++){
      if(h[i-1]<h[i]){
        h[i]=h[i]-1;
      }else if(h[i-1]>h[i]){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
}

Measured memory_bytes: 50216
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

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

    int n;
    cin >> n;

    if (n % 2 == 0) {
        cout << n / 2 - 1;
    }
    else {
        cout << n / 2;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int X;
  cin >> X;
  int a = 0;
  int b = 0;
  
  while(500 <= X){
  X = X - 500;
  a++;
  }
  
  while(5 <= X){
  b++;
  X = X - 5;
  }
  
  cout << a * 1000 + b * 5 << endl; 
  
}

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

int main(){
  int n,cx=0,cy=0,ch=0,f=0;cin>>n;
  bool flag=0;
  vector<int> x(n,0),y(n,0),h(n,0);
  REP(i,n) cin>>x.at(i)>>y.at(i)>>h.at(i);
  REP(i,101){
    REP(j,101){
      REP(k,n){
        if(h.at(k)>0){
          ch=abs(x.at(k)-i)+abs(y.at(k)-j)+h.at(k);
          break;
        }
      }
      flag=1;
      REP(k,n) if(max((ch-abs(x.at(k)-i)-abs(y.at(k)-j)),0)!=h.at(k)) flag=0;
      if(flag){
        cx=i;
        cy=j;
        break;
      }
    }
    if(flag) break;
  }
  cout<<cx<<" "<<cy<<" "<<ch<<endl;
}

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

int main(){
  int a;
  cin >> a;
  if (a >= 1200) cout << "ARC" << endl;
  else cout << "ABC" << endl;
  
}

Measured memory_bytes: 256
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
const LL mod=1e9+7,inf=1LL<<60;
struct Node{
	LL x,y,c,next;
}a[400010];LL len=0,last[100010];
LL n,m,st,ed,f[2][100010];
struct node{
	LL x,d;
	node() {}
	node(LL a,LL b) {x=a;d=b;}
};
bool operator < (node a,node b) {return a.d>b.d;}
priority_queue<node> q;
void ins(LL x,LL y,LL c)
{
	a[++len].x=x;a[len].y=y;a[len].c=c;
	a[len].next=last[x];last[x]=len;
}
bool vis[100010];
LL dis[2][100010];
void dij(LL op,LL st)
{
	for(LL i=1;i<=n;i++) dis[op][i]=inf;
	memset(vis,false,sizeof(vis));
	dis[op][st]=0;q.push(node(st,0));
	while(!q.empty())
	{
		LL x=q.top().x;q.pop();
		if(vis[x]) continue;
		vis[x]=true;
		for(LL i=last[x];i;i=a[i].next)
		{
			LL y=a[i].y;
			if(dis[op][y]>dis[op][x]+a[i].c)
			{
				dis[op][y]=dis[op][x]+a[i].c;
				q.push(node(y,dis[op][y]));
			}
		}
	}
}
void solve(LL op,LL st)
{
	memset(vis,false,sizeof(vis));
	f[op][st]=1;
	q.push(node(st,dis[op][st]));
	while(!q.empty())
	{
		LL x=q.top().x;q.pop();
		if(vis[x]) continue;
		vis[x]=true;
		for(LL i=last[x];i;i=a[i].next)
		{
			LL y=a[i].y;
			if(dis[op][x]+a[i].c==dis[op][y])
			{
				(f[op][y]+=f[op][x])%=mod;
				q.push(node(y,dis[op][y]));
			}
		}
	}
}

LL get(LL x,LL y) {return f[0][x]*f[0][x]%mod*f[1][y]%mod*f[1][y]%mod;}

int main()
{
	scanf("%lld %lld %lld %lld",&n,&m,&st,&ed);
	for(LL i=1;i<=m;i++)
	{
		LL x,y,c;scanf("%lld %lld %lld",&x,&y,&c);
		ins(x,y,c);ins(y,x,c);
	}
	dij(0,st);dij(1,ed);
	solve(0,st);solve(1,ed);
	LL ans=f[0][ed]*f[1][st]%mod;
	for(int i=1;i<=n;i++) if(dis[0][i]==dis[1][i]&&dis[0][i]+dis[1][i]==dis[0][ed]) (ans-=get(i,i))%=mod;
	for(LL i=1;i<=len;i+=2){
		LL x=a[i].x,y=a[i].y;
		if(dis[0][x]>dis[0][y]) 
            swap(x,y);
		if(dis[0][x]+dis[1][y]+a[i].c==dis[0][ed]&&abs(dis[0][x]-dis[1][y])<a[i].c)
			(ans-=get(x,y))%=mod;
	}
	printf("%lld",(ans+mod)%mod);
}

Measured memory_bytes: 21356
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <numeric>
#include <ios> // std::left, std::right

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  int n, s = 0;
  cin >> n;
  vector<int> v(n, 0), c(n, 0);

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

  for (int i = 0; i < n; i++)
  {
    cin >> c[i];
    if (v[i] > c[i])
    {
      s += v[i] - c[i];
    }
  }
  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
from copy import deepcopy
input = sys.stdin.readline

N, M = map(int, input().split())
S = input()
out = []
for i, x in enumerate(S):
    if x == '1':
        out.append(N - i)
#print('out={}'.format(out))

p = 0
ans = []
while p < N:
    d = min(M, N - p)
    #print('start with d={}'.format(d))
    while p + d in out and d >= 1:
        d -= 1
    if d == 0:
        print(-1)
        exit()
    ans.append(d)
    p += d
if p == N:
    ans.reverse()
    print(' '.join(map(str, ans)))
else:
    print(-1)

Measured memory_bytes: 50228
#include<bits/stdc++.h>
#define fi        first
#define se        second
#define PI        acos(-1)
#define LC(a)     ((a<<1))
#define RC(a)     ((a<<1)+1)
#define MID(a,b)  ((a+b)>>1)
#define mem(a, b) memset(a, b, sizeof(a))
#define IOS()     std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef unsigned long long ULL;
typedef pair<int,int> PII;
typedef pair<ll,ll>   PLL;
typedef pair<ll,int>  PLI;
const int INF = 0X3F3F3F3F;
const int MIN = -(1<<30);
const ll N = 1e5+7;
int v[10];
int n;
ll k[10];
ll f(int a[])
{
	mem(v,0);
	ll ans=0;
	for(int i=0; i<n; i++)
	{
		int cnt=0;
		v[a[i]]=1;
		for(int j=1; j<a[i]; j++)
		{
			if(v[j]==0)
			{
				cnt++;
			}
		}
		ans+=cnt*k[n-i-1];
	}
	return ans+1;
}
int main()
{
	IOS();
	k[0]=0;
	k[1]=1;
	for(int i=2; i<10; i++)
		k[i]=i*k[i-1];

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

	ll aa=f(a);
	ll bb=f(b);
//	cout<<aa<<endl<<bb<<endl;
	cout<<abs(aa-bb)<<endl;

	return 0;
}



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

using namespace std;

int main() {
	string s;
	cin >> s;
	if (s[1] == 'A') cout << "1";
	else if (s[1] == 'R') cout << "2";
	else if (s[2] == 'U') cout << "3";
	else if (s[2] == 'D') cout << "4";
	else if (s[2] == 'E') cout << "5";
	else if (s[1] == 'O') cout << "6";
	else cout << "7";

	return 0;
}

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

int main(){
    int h, w;
    while(1){
        cin >> h >> w;
        if (h == 0 && w == 0) break;
        for (int i = 0; i < h; i++){
            int head = 0;
            if (i % 2) head++;
            for (int j = 0; j < w; j++){
                if ( j % 2 == head) cout << "#";
                else cout << ".";
            }
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3112
import math
from typing import Union


class Point(object):
    __slots__ = ['x', 'y']

    def __init__(self, x, y):
        self.x = x
        self.y = y

    def __add__(self, other):
        return Point(self.x + other.x, self.y + other.y)

    def __sub__(self, other):
        return Point(self.x - other.x, self.y - other.y)

    def __mul__(self, other: Union[int, float]):
        return Point(self.x * other, self.y * other)

    def __repr__(self):
        return f"({self.x},{self.y})"


class Vector(Point):
    __slots__ = ['x', 'y', 'pt1', 'pt2']

    def __init__(self, pt1: Point, pt2: Point):
        from_pt1_to_pt2 = pt2 - pt1
        super().__init__(from_pt1_to_pt2.x, from_pt1_to_pt2.y)
        self.pt1 = pt1
        self.pt2 = pt2

    def dot(self, other):
        return self.x * other.x + self.y * other.y

    def cross(self, other):
        return self.x * other.y - self.y * other.x

    def norm(self):
        return pow(self.x, 2) + pow(self.y, 2)

    def abs(self):
        return math.sqrt(self.norm())

    def __repr__(self):
        return f"{self.pt1},{self.pt2}"


class Segment(Vector):
    __slots__ = ['x', 'y', 'pt1', 'pt2']

    def __init__(self, pt1: Point, pt2: Point):
        super().__init__(pt1, pt2)

    def projection(self, pt: Point)-> Point:
        t = self.dot(Vector(self.pt1, pt)) / pow(self.abs(), 2)
        return Point(self.pt1.x + t * self.x, self.pt1.y + t * self.y)

    def reflection(self, pt: Point) -> Point:
        return self.projection(pt) * 2 - pt

    def point_geometry(self, pt: Point):
        vec_pt1_to_pt = Vector(self.pt1, pt)
        cross = self.cross(vec_pt1_to_pt)
        if cross > 0:
            print('COUNTER_CLOCKWISE')
            return
        elif cross < 0:
            print('CLOCKWISE')
            return
        else:           # cross == 0
            dot = self.dot(vec_pt1_to_pt)
            if dot < 0:
                print('ONLINE_BACK')
                return
            else:       # dot > 0
                if self.abs() < vec_pt1_to_pt.abs():
                    print('ONLINE_FRONT')
                    return
                else:
                    print('ON_SEGMENT')
                    return

    def __repr__(self):
        return f"{self.pt1},{self.pt2}"


def main():
    p0_x, p0_y, p1_x, p1_y = map(int, input().split())
    p0 = Point(p0_x, p0_y)
    seg = Segment(p0, Point(p1_x, p1_y))
    num_query = int(input())

    for i in range(num_query):
        p2_x, p2_y = map(int, input().split())
        seg.point_geometry(Point(p2_x, p2_y))
    return


main()


Measured memory_bytes: 7312
package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m int
	fmt.Scan(&n)
	fmt.Scan(&m)
	av := make([]bool, n+1)
	for i := range av {
		av[i] = true
	}
	for i := 0; i < m; i++ {
		var a int
		fmt.Scan(&a)
		av[a] = false
	}

	dp := make([]int, n+1)
	dp[0] = 1
	for now := range dp {
		for next := now + 1; next <= int(math.Min(float64(n), float64(now+2))); next++ {
			if av[next] {
				dp[next] += dp[now]
				dp[next] %= 1000000007
			}
		}
	}
	fmt.Println(dp[n])
}


Measured memory_bytes: 5504
#include <stdio.h>
#include <algorithm>

using namespace std;

const long long mod = 1000003;
long long n , x , d;
long long fac[2100000] , ifac[2100000];
long long ksm ( long long f , long long x ) {
	long long s = 1;
	while ( x ) {
		if ( x % 2 ) s = s * f % mod;
		f = f * f % mod; x = x / 2;
	}
	return s % mod;
}
long long inv ( long long x ) {
	return ksm ( x , mod - 2 );
}
void predo () {
	long long i;
	fac[0] = 1;
	for ( i = 1 ; i <= 2010000 ; i++ ) {
		fac[i] = fac[i-1] * i % mod;
	}
	ifac[mod-1] = inv ( fac[mod-1] );
	for ( i = mod - 2 ; i >= 0 ; i-- ) {
		ifac[i] = (ifac[i+1]*(i+1)) % mod;
	}
}
void work () {
	long long i;
	scanf ( "%lld%lld%lld" , &x , &d , &n );
	if ( d == 0 ) {
		printf ( "%lld\n" , ksm ( x , n ) );
		return ;
	}
	if ( n >= mod || x == 0 ) {
		printf ( "0\n" );
		return ;
	}
	x = x * inv ( d ) % mod;
	printf ( "%lld\n" , ksm ( d , n ) * fac[x+n-1] % mod * ifac[x-1] % mod );
}
int main () {
	int t;
	scanf ( "%d" , &t );
	predo ();
	while ( t-- ) work ();
	return 0;
}


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

int main(){
  string S;
  cin >> S;
  int count=0;
  bool too=false;
  for(int i=0; i<S.size(); i++){
    if(S.at(i)=='A'){
      too=true;
      count++;
      continue;
    }
    
    if(too)
      count++;
  }
  for(int i=S.size()-1; i>=0; i--){
    if(S.at(i)=='Z'){
      count=-S.size()+count+i+1;
      break;
    }
  }
  cout << count << endl;
}

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

int main() {
  int n, m; cin >> n >> m;
  vector<vector<int>> g(n);
  rep(i, m) {
    int a, b; cin >> a >> b; a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<int> dist(n, -1);
  vector<int> prev(n, -1);
  queue<int> que;
  dist[0] = 0;
  que.push(0);

  while (!que.empty()) {
    auto v = que.front(); que.pop();
    for (auto nv : g[v]) {
      if (dist[nv] != -1) continue;
      dist[nv] = dist[v] + 1;
      prev[nv] = v;
      que.push(nv);
    }
  }
  bool f = true;
  rep(i, n) {
    if (dist[i] == -1)
      f = false;
  }
  if (f) {
    cout << "Yes" << endl;
    for (int i = 1; i < n; i++) {
      cout << prev[i] + 1 << endl;
    }
  }else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 10636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    vl A(4);
    rep(i, 4) cin >> A[i];

    ll ans = abs(A[0] + A[2] - A[1] - A[3]);
    chmin(ans, abs(A[0] + A[3] - A[1] - A[2]));
    chmin(ans, abs(A[0] + A[1] - A[2] - A[3]));
    cout << ans << endl;
}


Measured memory_bytes: 3216
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int a, b, x, y;
    scanf("%d%d%d%d", &a, &b, &x, &y);
    printf("%lf %d\n", double(a)*double(b) / 2, x + x == a&&y + y == b);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#define ll long long
#define lld double
#define vi vector<int>
#define pii pair<int,int>
#define piii pair<pii, ll>
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define ppb pop_back
#define d0(x) cout<<x<<" "
#define d1(x) cout<<(x)<<"\n"
#define d2(x,y) cout<<x<<" "<<y<<"\n"
#define d3(x,y,z) cout<<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w) cout<<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define d5(x,y,z,w,s) cout<<x<<" "<<y<<" "<<z<<" "<<w<<" "<<s<<endl
using namespace std;
const ll mod = 998244353;


int n;ll a[200001];int b[200001];
void solve(int t)
{
    cin>>n;
    for(int i=1;i<=n;i++)a[i]=0;
    for(int i=0;i<n;i++)
    {
        int x;cin>>x;a[x]++;b[i]=x;
    }
    ll ans = 0;
    for(int i=1;i<=n;i++)
    {
        ans+=(a[i]*(a[i]-1))/2;
    }
    for(int i=0;i<n;i++)
    {
        //ll ans1 = 
        d1(ans-max(0LL,a[b[i]]-1LL));
    }
    //cout<<"\n";
}


int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int T=1;
    //cin>>T;
    for(int t=1;t<=T;t++)
        solve(t);
}

Measured memory_bytes: 4992
/*
    Author: shamsenur shanto
    AUST CSE 41th Batch

*/

#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef deque<ll> dl;
typedef stack<ll> stl;
typedef set<ll> sl;
typedef map<string, ll> msl;
typedef map<ll,ll> mll;
#define sf(n)     scanf("%lld",&n)
#define sff(n,m)     scanf("%lld %lld",&n,&m)
#define sfff(n,m,r)     scanf("%lld %lld %lld",&n,&m,&r)
#define sfs(n)     scanf("%s",n)
#define pf(n)     printf("%lld\n",n)
#define pff(n,m)     printf("%lld %lld\n",n,m)
#define pfff(n,m,r)     printf("%lld %lld %lld\n",n,m,r)
#define pfs(n)     printf("%s\n",n)
#define pfcs(i,n)     printf("Case %lld: %lld\n",i,n)
#define pb     push_back
#define prf     printf
#define inf     2e18
#define low     -1000000000000
#define PI        acos(-1.0)
#define rep1(i,n) for(i=1;i<n;i++)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,a,n) for(i=a;i<n;i++)
#define repe1(i,n) for(i=1;i<=n;i++)
#define repe0(i,n) for(i=0;i<=n;i++)
#define repe(i,a,n) for(i=a;i<=n;i++)

int main()
{

    ll a,b,c,d,r,e,f,n;
    sf(n);
    ll a1[n],dp[n];
    for(ll i=0;i<n;i++)
    {
        sf(a1[i]);
        dp[i]=0;

    }
    dp[0]=0;
    dp[1]=abs(a1[0]-a1[1]);
    for(ll i=2;i<n;i++)
    {
        dp[i]=min((dp[i-2]+abs(a1[i-2]-a1[i])),((dp[i-1]+abs(a1[i-1]-a1[i]))));
    }
    printf("%lld\n",dp[n-1]);

}


Measured memory_bytes: 1792
#include<iostream>
#include<math.h>
#include<stdlib.h>
#include<string>
#include<limits.h>
#include<utility>
#include<vector>
#include<tuple>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(A) A.begin(),A.end()
ll gcd(ll a, ll b, ll c) {
	ll A = a, B = b, C = c;
	if (A < B) {
		ll tmp = A;
		A = B;
		B = tmp;
	}
	ll r = A % B;
	while (r!=0) {
		A = B;
		B = r;
		r = A % B;
	}
	if (B < C) {
		ll tmp = B;
		B = C;
		C = tmp;
	}
	r = B % C;
	while (r != 0) {
		B = C;
		C = r;
		r = B % C;
	}
	return C;
}
int main() {
	ll k;
	cin >> k;
	ll sum = 0;
	for (ll a = 1; a <= k; a++) {
		for (ll b = 1; b <= k; b++) {
			for (ll c = 1; c <= k; c++) {
				sum += gcd(a, b, c);
			}
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"

using namespace std;
int main() {
	int N;
	cin >> N;
	vector<long long>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.rbegin(), A.rend());
	long long ans = 0;
	if (0 == N % 2) {
		{
			// 0 .... (N-3)/2
			for (int i = 0; i < (N - 2) / 2; ++i) {
				ans += 2 * A[i];
			}
			for (int i = (N - 2) / 2; i < (N) / 2; ++i) {
				ans += A[i];
			}
			for (int i = (N) / 2; i < (N + 2) / 2; ++i) {
				ans -= A[i];
			}
			for (int i = (N + 2) / 2; i < N; ++i) {
				ans -= 2 * A[i];
			}
		}
	}
	else {
		{
			long long ans0 = 0;
			// 0 .... (N-3)/2
			for (int i = 0; i < (N - 3) / 2; ++i) {
				ans0 += 2 * A[i];
			}
			for (int i = (N - 3) / 2; i < (N + 1) / 2; ++i) {
				ans0 += A[i];
			}
			for (int i = (N + 1) / 2; i < N; ++i) {
				ans0 -= 2 * A[i];
			}
			ans = max(ans0,ans);
		}
		{
			long long ans0 = 0;
			// 0 .... (N-3)/2
			for (int i = 0; i < (N - 1) / 2; ++i) {
				ans0 += 2 * A[i];
			}
			for (int i = (N - 1) / 2; i < (N + 3) / 2; ++i) {
				ans0 -= A[i];
			}
			for (int i = (N + 3) / 2; i < N; ++i) {
				ans0 -= 2 * A[i];
			}
			ans = max(ans0, ans);
		}
	}
	cout << ans << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, std::vector<long long> H){
    for (int i = N-1; i >=1; i--)
    {
        if(H[i]>=H[i-1]) 1;
        else{
            if(H[i-1]-1==H[i]){
                H[i-1]--;
            }
            else{
                cout<<NO<<endl;return;
            }
        }
    }
    
    cout<<YES<<endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    solve(N, std::move(H));
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    if (u == s) {
        cout << a - 1 << " " << b << endl;
    } else {
        cout << a << " " << b - 1 << endl;
    }
}

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

int main(){
  int A, B, M;
  cin >> A >> B >> M;
  vector<int> ai(A);
  vector<int> bi(B);
  int mina = 1000000, minb = 1000000;
  for(int i = 0; i < A; i++){
    cin >> ai.at(i);
    if(ai.at(i) < mina)
      mina = ai.at(i);
  }
  for(int i = 0; i < B; i++){
    cin >> bi.at(i);
    if(bi.at(i) < minb)
      minb = bi.at(i);
  }
  int ans = mina + minb;
  int x, y, c, tmp;
  for(int i = 0; i < M; i++){
    cin >> x >> y >> c;
    tmp = (ai.at(x - 1) + bi.at(y - 1) - c);
    if(ans > tmp)
      ans = tmp;
  }
  cout << ans << endl;

      
}

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

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	priority_queue<int> pq;
	int n,k,a; cin>>n>>k;
	while(n--) cin>>a, pq.push(a);
	int ret=0;
	while(k--) ret+=pq.top(), pq.pop();
	cout << ret << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <deque> 

using namespace std;


char s[12];

int year, month, day;

int main()
{
	scanf("%s\n", &s);
	
	year  = (s[0] - '0') * 1000 + (s[1] - '0') * 100 + (s[2] - '0') * 10 + (s[3] - '0');
	month = (s[5] - '0') * 10 + (s[6] - '0');
	day   = (s[8] - '0') * 10 + (s[9] - '0');
	
	if (month <= 4)
		printf("Heisei\n");
	else
		printf("TBD\n");
	

	return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
using P=pair<int,int>;

int i,j;
vector<int> w,s;
vector<int> prime(100001,1),prime_2017(100001,0);//素数なら１　合成数なら０
vector<int> sum;

void isprime(int N){
    prime[0]=0;
    prime[1]=0;
    for(i=2;i*i<=N;i++){
        if(prime[i]==0){continue;}
        for(j=i*i;j<=N;j+=i){
            prime[j]=0;
        }
    }
    return;
}

void isprime_2017(int N){
    for(i=0;i<N;i++){
        if(prime[i]==1 && prime[(i+1)/2]==1){
            prime_2017[i]=1;
        }
    }
}

void pre_process(vector<int> &a, vector<int> &S) {
    int n=(int)a.size();
    S.assign(n+1,0);
    for(i=0;i<n;i++){
        S[i+1]=S[i]+a[i];
    }
}
 
// [i,j) の区間和を求める
int query(int I,int J,vector<int> &S){
    return S[J]-S[I];
}

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

    isprime(100000);//prime table
    isprime_2017(100000);//2017number table
    pre_process(prime_2017,sum);//累積和を作る

    vector<int> ans(q);

    for(i=0;i<q;i++){
        int l,r;
        cin>>l>>r;
        r++;
        ans[i]=query(l,r,sum);
    }
    for(i=0;i<q;i++){
        cout<<ans[i]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FOR1(x,to) for(int x=1;x<(to);x++)

int selectionsort(int n,int a[]){
    int mini,res=0;
    FOR(i,n){
        mini=i;
        for(int j=i+1;j<n;j++){
            if(a[j]<a[mini])mini=j;
        }
        if(a[i]!=a[mini]){
            swap(a[i],a[mini]);
            res++;
        }
    }
    return res;
}

int main()
{
    int n;cin>>n;
    int a[n];
    FOR(i,n){
        cin>>a[i];
    }
    int res=selectionsort(n,a);
    FOR(i,n){
        if(i>0) cout<<" ";
        cout<<a[i];
    }
    cout<<endl<<res<<endl;

}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define show(x) cout<<x<<'\n'
#define showh(x) cout<<x<<' '
#define end      cout<<endl
#define go(i,a,n) for(ll i=a;i<n;i++)
#define gor(i,a,n) for(ll i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define mod 1000000007
bool prime[100001];
void sieve(ll n)
{
    memset(prime,true,sizeof(prime));
    prime[0]=false;
    prime[1]=false;
    for(ll i=2;i*i<=n;i++)
    {
        if(prime[i]==true)
        {
            for(ll j=i*i;j<=n;j+=i)
            {
                prime[j]=false;
            }
        }
    }
    show(prime[89]);
}
bool isprime(ll n)
{
    if (n<=1) return false;
    if (n<=3) return true;

    if(n%2==0 or n%3==0) return false;

    for(ll i=5;i*i<=n;i+=6)
    {
        if(n%i==0 or n%(i+2)==0) return false;
    }
    return true;
}

ll modinverse(ll a,ll m)
{
    ll m0 = m;
    ll y = 0, x = 1;

    if (m == 1)
      return 0;

    while (a > 1)
    {
        ll q = a / m;
        ll t = m;

        m = a % m; a = t;
        t = y;

        y = x - q * y;
        x = t;
    }

    if (x < 0)
       x += m0;

    return x;
}

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

ll power(ll A, ll B)
{
    if (A == 0)
        return 0;
    if (B == 0)
        return 1;

    ll y;
    if (B % 2 == 0) {
        y = power(A, B / 2);
        y = (y * y) % mod;
    }

    else {
        y = A % mod;
        y = (y * power(A, B - 1) % mod) % mod;
    }

    return (ll)((y + mod) % mod);
}

int main()
{
    ios_base::sync_with_stdio(false);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b and b==c)
    {
        show("Yes");
    }
    else
    {
        show("No");
    }

    return 0;

}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    long long n;
    std::cin >> n;

    long long min = std::numeric_limits<long long>::max();

    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            min = std::min(min, i + (n / i) - 2);
        }
    }

    std::cout << min << std::endl;
}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  vector<int> kai(N);
  for(int i=0;i<N;i++){
    kai.at(i)=0;
  }
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    kai.at(A.at(i)-1)++;
  }
  sort(kai.begin(),kai.end());
  int sum=0;
  for(int i=0;i<N-K;i++){
    sum+=kai.at(i);
  }
  cout<<sum<<endl;
  
  
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const int INF=1e9+10;
int n,ans,p[500010];
char s[500010];
int main(){
	cin>>n;
	scanf("%s",s+1);
	FOR(i,1,n) p[i]=p[i-1]+(s[i]=='#');
	ans=INF;
	FOR(i,0,n) ans=min(ans,p[i]+n-i-(p[n]-p[i]));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long
#define lli long long int

using namespace std;
using P = pair<int,int>;

int main(){

  int N, l;
  cin >> N;
  int ans = 0;

  vector<int> vec(N);

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

  if(N <= 2){
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      for (int k = j+1; k < N; k++) {
        if((vec.at(i) != vec.at(j)) && (vec.at(j) != vec.at(k)) && (vec.at(i) != vec.at(k)) ){
          
          if(vec.at(i) + vec.at(j) > vec.at(k) &&
             vec.at(i) + vec.at(k) > vec.at(j) &&
             vec.at(k) + vec.at(j) > vec.at(i)
           ){
             ans++;
           }
        }
      }
    }
  }




  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<map>
#include<set>
#include<array>
#include<vector>
using namespace std;
long conv(int a,int b,int c,int d){return 1000000000L*a+1000000L*b+1000L*c+d;}
long rotate(long a){return a%1000000000L*1000+a/1000000000L;}
bool same(long a,long b)
{
	if(a==b)return true;
	a=rotate(a);
	if(a==b)return true;
	a=rotate(a);
	if(a==b)return true;
	a=rotate(a);
	if(a==b)return true;
	return false;
}
int N;
map<long,array<array<long,15>,4> >M;
int a[400],b[400],c[400],d[400];
long C[400];
set<long>S;
main()
{
	cin>>N;
	for(int i=0;i<N;i++)
	{
		cin>>a[i]>>b[i]>>c[i]>>d[i];
		C[i]=conv(a[i],b[i],c[i],d[i]);
		for(int r=0;r<4;r++)
		{
			S.insert(C[i]);
			C[i]=rotate(C[i]);
		}
	}
	for(long it:S)
	{
		array<array<long,15>,4>&A=M[it];
		long sum=0;
		int ct[5]={};
		for(int i=0;i<N;i++)
		{
			int now=0;
			for(int r=0;r<4;r++)
			{
				now+=it==C[i];
				C[i]=rotate(C[i]);
			}
			sum+=now;
			ct[now]++;
		}
		for(int j=0;j<5;j++)for(int k=0;k<=j;k++)
		{
			if(j&&ct[j]==0||k&&ct[k]==0)continue;
			ct[j]--;
			ct[k]--;
			A[0][j*(j+1)/2+k]=sum-j-k;
			A[1][j*(j+1)/2+k]=(sum-j-k)*(sum-j-k-1)-ct[2]*2-ct[3]*6-ct[4]*12;
			A[2][j*(j+1)/2+k]=(sum-j-k)*(sum-j-k-1)*(sum-j-k-2)
				-(sum-j-k-2)*ct[2]*6
				-(sum-j-k-3)*ct[3]*3*6-ct[3]*6
				-(sum-j-k-4)*ct[4]*6*6-ct[4]*24;
			A[3][j*(j+1)/2+k]=(sum-j-k)*(sum-j-k-1)*(sum-j-k-2)*(sum-j-k-3)
				-(sum-j-k-2)*(sum-j-k-2-1)/2*ct[2]*24
				-(sum-j-k-3)*(sum-j-k-3-1)/2*ct[3]*3*24-(sum-j-k-3)*ct[3]*24
				-(sum-j-k-4)*(sum-j-k-4-1)/2*ct[4]*6*24-(sum-j-k-4)*ct[4]*4*24-ct[4]*24
				+ct[2]*(ct[2]-1)/2*24
				+ct[2]*ct[3]*3*24
				+ct[2]*ct[4]*6*24
				+ct[3]*3*(ct[3]-1)*3/2*24
				+ct[3]*3*ct[4]*6*24
				+ct[4]*6*(ct[4]-1)*6/2*24;
			ct[j]++;
			ct[k]++;
		}
	}
	long ans=0;
	for(int i=0;i<N;i++)
	{
		map<long,int>X;
		for(int r=0;r<4;r++)
		{
			X[C[i]]++;
			C[i]=rotate(C[i]);
		}
		for(int j=i+1;j<N;j++)
		{
			map<long,int>Y;
			for(int r=0;r<4;r++)
			{
				Y[C[j]]++;
				C[j]=rotate(C[j]);
			}
			for(int ccc=0;ccc<4;ccc++)
			{
				int tmp=a[j];
				a[j]=b[j];
				b[j]=c[j];
				c[j]=d[j];
				d[j]=tmp;
				long t[4]={
					conv(b[i],a[i],b[j],a[j]),
					conv(a[i],d[i],c[j],b[j]),
					conv(d[i],c[i],d[j],c[j]),
					conv(c[i],b[i],a[j],d[j]),
				};
				int cc[4]={1,1,1,1};
				for(int I=0;I<4;I++)for(int J=I+1;J<4;J++)
				{
					if(cc[J]==0)continue;
					if(same(t[I],t[J]))cc[I]+=cc[J],cc[J]=0;
				}
				long now=1;
				for(int k=0;k<4;k++)
				{
					if(cc[k]==0)continue;
					int a=X.find(t[k])==X.end()?0:X[t[k]];
					int b=Y.find(t[k])==Y.end()?0:Y[t[k]];
					if(a<b)a^=b^=a^=b;
					now*=M.find(t[k])==M.end()?0:M[t[k]][cc[k]-1][a*(a+1)/2+b];
				}
				ans+=now;
			}
		}
	}
	cout<<ans/3<<endl;
}


Measured memory_bytes: 1152
import java.util.Scanner;
import java.util.SortedSet;
import java.util.TreeSet;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String line = sc.next();
    int n = sc.nextInt();
    SortedSet<String> set = new TreeSet<>();
    for (int i = 1; i <= 5; i++) {
      for (int j = 0; j < line.length() + 1 - i; j++) {
        set.add(line.substring(j, j + i));
      }
    }
    int count = 1;
    for (String s : set) {
      if (count == n) {
        System.out.println(s);
        return;
      }
      count++;
    }
  }
}

Measured memory_bytes: 27072
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int d[10];
int n, k;

bool f(int n)
{
    while (n)
    {
        if (d[n % 10])
            return true;
        n /= 10;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < 10; ++i)
    {
        int x;
        cin >> x;
        d[x] = 1;
    }
    while (f(n))
        n++;
    cout << n;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
    int n;
    while (cin >> n && n != 0) {
        double avg = 0, variance = 0;
        double* sco = new double[n];
        for(int i = 0; i < n; i++) {
            cin >> sco[i];
            avg += sco[i];
        }
        avg /= n;
        for(int i = 0; i < n; i++) 
            variance += (sco[i] - avg) * (sco[i] - avg);
        variance /= n;
        double std = sqrt(variance);
        cout << setprecision(4) << fixed << std << endl;
    }
    return 0;
}


Measured memory_bytes: 3300
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  string S,T;
  ll ans=0;
  cin>>S>>T;
  for(int i=0;i<3;i++){
    if(S[i]==T[i]) ans++;
  }
  cout<<ans<<endl;

  return 0;
}



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

using namespace std;

#define mem(a,b) memset(a,b,sizeof(a))
#define FOR(i,j,k) for(int i=j;i<=k;i++)
#define read        freopen("in.txt", "r", stdin)
#define write       freopen("out.txt", "w", stdout)
#define pf          printf
#define sf(n)       scanf("%d", &n)
#define sff(a,b)    scanf("%d %d", &a, &b)
#define PB push_back
#define F first
#define S second
#define MP make_pair

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

const int M = 998244353 ;
const int MAX = (2e5) + 10;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, xl, yl, jo, ja;
vector<int> mat[MAX];

void dfs(int p,int pa,int lev) {
    if(lev <= xl) { jo++; }
    if(lev <= yl) { ja++; }

    for(int x: mat[p]) {
        if(x == pa) { continue; }
        dfs(x, p, lev + 1);
    }
}

int main() {
    ios::sync_with_stdio(false);
    //read;
    //write;
    int u, v, k;

    cin >> n >> k;
    FOR(i,1,n-1) {
        cin >> u >> v;
        mat[u].PB(v);
        mat[v].PB(u);
    }

    int prin = 0;

    xl = k / 2; yl = k - xl;
    FOR(p,1,n) {
        vector<pii> vovo;

        for(int x: mat[p]) {
            jo = ja = 0;
            dfs(x, p, 1);
            vovo.PB( {ja, jo} );
        }

        sort(vovo.begin(), vovo.end(), [](pii x,pii y) {
                return (x.F - x.S) > (y.F - y.S);
             });

        int rt = 1, fc = true;
        for(pii X: vovo) {
            rt += (fc ? X.F : X.S);
            fc = false;
        }
        prin = max(prin, rt);
    }

    cout << n - prin << endl;
    return 0;
}



Measured memory_bytes: 5120
let n, ans = read_int (), ref 0
let rec g n = if n < 10 then n else g (n / 10)
let f i j = let c = ref 0 in for k = 1 to n do if k mod 10 = j && g k = i then incr c done; !c
let _ = for i = 1 to 9 do for j = 1 to 9 do ans := !ans + f i j * f j i done done; Printf.printf "%d\n" !ans

Measured memory_bytes: 384
from sys import exit

n = int(input())
cs = [[0]*10 for i in range(10)]

i_list=[]
for i in range(1,n+1):
    i_list = list(str(i))
    cs[int(i_list[0])][int(i_list[-1])] += 1

ans=0
for i in range(10):
    for j in range(10):
        ans += cs[i][j]*cs[j][i]
print(ans)


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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
    return 0;
}

Measured memory_bytes: 3592
def matchCount(str1, str2):
  r = len(str1)
  for idx in range(0, len(str1)):
    if str1[idx] == str2[idx]:
      r -= 1
  return r

s=input()
t=input()
slength = len(s)
tlength = len(t)
r = slength

for idx in range(0, slength - tlength + 1):
  ss = s[idx:idx + tlength]
  rr = matchCount(ss,t)
  if rr < r:
    r = rr
print(r)

Measured memory_bytes: 8988
#include <stdio.h>

int main(){
	int W, H, x, y, r;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	
	if((x >= r)&&(y >= r)&&(x <= W-r)&&(y <= H-r))
		printf("Yes\n");
	else
		printf("No\n");	

	return 0;

}


Measured memory_bytes: 2100
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????
    cin.tie(0);
    ios::sync_with_stdio(false);
    //------------------------------
    int n,w;cin>>n>>w;
    vector<ll>v(n+1),wi(n+1);
    for(int i=1;i<=n;i++)
        cin>>wi[i]>>v[i];
    ll dp[101][100001];
    for(int i=0;i<=n;i++)
        for(ll j=0;j<=w;j++)
            dp[i][j]=0;
    for(int i=1;i<=n;i++)
        for(int j=1;j<=w;j++)
        {
            if(j>=wi[i])
                {
                    dp[i][j]=max(dp[i-1][j],dp[i-1][j-wi[i]]+v[i]);
                }
            else
            {
                dp[i][j]=dp[i-1][j];
            }
        }
    cout<<dp[n][w];
    
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------



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

int main(){
  ll N,P;
  cin>>N>>P;
  if(N == 1) return cout<<P<<endl, 0;
  int ans = 1;
  for(ll i=2;i<=sqrt(P);i++){
    int cnt = 0;
    while(P % i == 0){
      P /= i;
      cnt++;
      if(cnt == N){
        ans *= i;
        cnt = 0;
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
///*
#include<iostream>
using namespace std;

double trapezoid(double top, double bottom, double height);

int main() {

	int a, b, c;
	cin >> a >> b >> c;
	cout << (int)trapezoid(a, b, c);

	return 0;
}
//*/
double trapezoid(double top, double bottom, double height) {
	return (top + bottom)*height / 2;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N,K;
  cin>>N>>K;
  ll a[N+1];
  a[0]=1;
  for(int i=1;i<=N;i++){
    cin>>a[i];
  }
  for(int i=K+1;i<=N;i++){
    if(a[i-K]<a[i]) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

Measured memory_bytes: 5192
O = list(input())
E = list(input())
ans = list()
LEN = len(O)+len(E)
for i in range(LEN):
    if i%2==0:
        ans.append(O[0])
        del O[0]
    else:
        ans.append(E[0])
        del E[0]
result = "".join(ans)
print(result)

Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <iomanip>
#include <sstream>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 1LL << 60;
constexpr int inf = 1 << 30;

constexpr ll mod = 1000000007LL;

// a - bをmodをとりつつ計算する.
ll submod(ll a, ll b) {
    return a > b ? (a - b) % mod : ((a - b) % mod + mod);
}

// x^nをmodをとりつつ求める
ll powmod(ll x, ll n) {
    if (n == 0LL) return 1LL;
    x %= mod;
    if (n % 2LL == 0) {
        return powmod((x * x) % mod, n / 2LL);
    }
    else {
        return (x * powmod((x * x) % mod, n / 2LL)) % mod;
    }
}

// xの逆元を求める.
ll modinv(ll x) {
    return powmod(x, mod - 2LL);
}

ll mfac[200000+1];

void initFac() {
    mfac[0] = mfac[1] = 1LL;

    for (int i = 2; i <= 200000; ++i) {
        mfac[i] = mfac[i - 1] * i % mod;
    }
}

// nPkを求める
ll perm(ll n, ll k) {
    if (k > n) throw "k must be less or equal than n";
    return mfac[n] * modinv(mfac[n - k]) % mod;
}

// nCkを求める
ll comb(ll n, ll k) {
    if (k > n) return 0LL;
    else return mfac[n] * modinv(mfac[k] * mfac[n - k]) % mod;
}

int main() {
    initFac();
    int N, K; cin >> N >> K;
    for (int i = 1; i <= K; ++i) {
        if (((N - K) - (i - 1)) >= 0) {
            if (K >= i) {
                int M = (N - K) - (i - 1);
                cout << (comb(M + i, i) * comb(K - 1, i - 1) % mod) << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
        else {
            cout << 0 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 1920
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
using namespace std;

int main(){
    int N,M,X,Y,x[110],y[110];cin>>N>>M>>X>>Y;
    for(int i=0;i<N;i++)cin>>x[i];
    for(int j=0;j<M;j++)cin>>y[j];
    sort(x,x+N,greater<int>());
    sort(y,y+M);
    if(x[0]<Y&&X<y[0]&&x[0]<y[0])cout<<"No War"<<endl;
    else cout<<"War"<<endl;

    return 0;
}

Measured memory_bytes: 256
A = [[0] * 3, [0] * 3, [0] * 3]
Field = [[False] * 3, [False] * 3, [False] * 3]

for i in range(0, 3):
    A1, A2, A3 = list(map(int, input().split()))
    A[i][0] = A1
    A[i][1] = A2
    A[i][2] = A3

N = int(input())
B = [0] * N
for i in range(0, N):
    B[i] = int(input())

for b in range(0, N):
    for i in range(3):
        for j in range(3):
            if A[i][j] == B[b]:
                Field[i][j] = True

Ans = False
for i in range(3):
    field = True
    for j in range(3):
        if Field[i][j] == False:
            field = False
    
    if field==True:
        Ans = True
        break
else:
    Ans = False
    for i in range(3):
        field = True
        for j in range(3):
            if Field[j][i] == False:
                field = False
        
        if field==True:
            Ans = True
            break
    else:
        Ans = False
        if Field[0][0] and Field[1][1] and Field[2][2]:
            Ans = True
        if Field[0][2] and Field[1][1] and Field[2][0]:
            Ans = True

if Ans:
    print('Yes')
else:
    print('No')




Measured memory_bytes: 9312