akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, gcd
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = [2,4,5,7,9]
B = [0,1,6,8]


if N%10 in A:
	print("hon")
elif N%10 in B:
	print("pon")
else:
	print("bon")

Measured memory_bytes: 10052
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            int[] scores = new int[n];
            double sum = 0;
            for (int i = 0; i < scores.length; i++) {
                scores[i] = sc.nextInt();
                sum += scores[i];
            }
            double average = 0, variance = 0;
            average = ((double) sum) / scores.length;
            for (int i = 0; i < scores.length; i++) {
                variance += ((scores[i] - average) * (scores[i] - average));
            }
            variance = (double) variance / n;
            System.out.println(Math.sqrt(variance));
        }
    }

}

Measured memory_bytes: 31036
x,y= list(map(int, input().split()))
i = list(map(int, input().split()))
i.sort(reverse=True)
k=sum(i)
flag=0
for j in range(x):
    if i[j]*4*y>=k:
        flag+=1
if flag<y:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <iostream>
#include <numeric>
#define rep(i,n) for (int i = 0;i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
int INF = 1e9;

int main(){
	ll a,b,c,d;cin >> a >> b >> c >> d;
	ll ans = b*d;
	ans = max(ans,b*c);
	ans = max(ans,a*c);
	ans = max(ans,a*d);
	//ans = max(ans,ll(0));
	cout << ans << endl;
}
 
 

Measured memory_bytes: 3632
x = int(input())
import math
if x < 4 :
    print(1)
elif 4 <= x :
    exponetiallist = []
    pmax = math.floor(math.log2(x))
    for b in range(2, x + 1) :
        for p in range(2, pmax +1) :
            if b ** p <= x :
                exponetiallist += [b ** p]
    print(max(exponetiallist))

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

using namespace std;

const int maxn = 2000100;
typedef long long int ll;

ll N, M;
char S[maxn], T[maxn];

ll gcd(ll m, ll n) { return (0 == n) ? m : gcd(n, m % n); }

int main(void)
{
    scanf("%lld%lld", &N, &M);
    scanf("%s", S);
    scanf("%s", T);
    ll g = gcd(N, M);
    ll l = N * M / g;
    ll a = M / g;
    ll b = N / g;
    for (int i = 0; i < N; i++)
    {
        ll pos_in_x = a * i;
        if (0 == (pos_in_x % b))
        {
            ll pos_in_t = pos_in_x / b;
            if (pos_in_t >= M) {
                puts("-1");
                return 0;
            }
            if (S[i] != T[pos_in_t]) {
                puts("-1");
                return 0;
            }
        }
    }
    printf("%lld\n", l);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<string> vs;
typedef vector<Def> vi;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
vs in,bl;
int n,m,out;
void f(int a,int b,vs NOW){
//	rep(i,3)cout<<in[i]<<endl;
//	cout<<endl;
	if(a==m){
		out=max(out,b);
		return;
	}
	for(int x=-1;x<2;x++){
		for(int y=-1;y<2;y++){
			vs now=NOW;
			bool h=true;
			rep(i,2)rep(j,2)rep(k,2){
				int dx=x+j;
				int dy=y+k;
				if(dx<0||dy<0||dx>=2||dy>=2);
				else continue;
				if(bl[a][i*4+j*2+k]=='#')h=false;
			}
			if(h){
				int pos=0;
				for(int w=30;w>=0;w--){
					bool h=true;
					rep(i,2)rep(j,2)rep(k,2){
						int dx=x+j,dy=y+k;
						if(dx<0||dy<0||dx>=2||dy>=2)continue;
						if(bl[a][i*4+j*2+k]=='#'&&now[w+i][dx*2+dy]=='#')
							h=false;
					}
					
					if(!h){
						pos=w+1;
						break;
					}
				}
				rep(i,2)rep(j,2)rep(k,2){
					int dx=x+j,dy=y+k;
					if(dx<0||dy<0||dx>=2||dy>=2)continue;
					if(bl[a][i*4+j*2+k]=='#'){
						now[pos+i][dx*2+dy]='#';
					}
				}
				int co=0;
				loop(i,1,now.size()){
					if(now[i]=="####"){
						co++;
						now.erase(now.begin()+i);
						i--;
					}
				}
				f(a+1,b+co,now);
			}
		}
	}
}
int main(){
	while(cin>>n>>m,n){
		in=vs(40,"....");
		in[0]="####";
		rep(i,n){
			string a,b;cin>>a>>b;
			in[i+1]=a+b;
		}
		bl=vs(m);
		rep(i,m){
			string a,b,c,d;cin>>a>>b>>c>>d;
			bl[i]=a+b+c+d;
		}
		out=0;
		f(0,0,in);
		cout<<out<<endl;
	}
}



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

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;
	vector<int> A(N);
	rep(i, 0, N)cin >> A[i];

	rep(i, 0, N)
	{
		if (K <= i)
		{
			if (A[i-K] < A[i])cout << "Yes" << endl;
			else cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 4760
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    ll a[n];rep(i,0,n)cin>>a[i];
    multiset<ll> st;
    int ans=0;
    rep(i,0,n){
        if(st.size()==0||*st.begin()>=a[i]){
            ans++;
            st.insert(a[i]);
            continue;
        }
        auto itr=st.lower_bound(a[i]);
        itr--;
        st.erase(itr);
        st.insert(a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5760
using System;

class Program
{
  
static void Main(string[] args)
{
  string[] input = Console.ReadLine().Split(' ');
  int r = int.Parse(input[0]);
  int g = int.Parse(input[1]);
  int b = int.Parse(input[2]);
  
  
  
  if((100*r+10*g+b)%4 == 0)
  {
    Console.WriteLine("YES");
  }
  else
  {
    Console.WriteLine("NO");
  }
  
}

}


Measured memory_bytes: 11092
#include <iostream>
#include <sstream>
#include <fstream>
#include <ctime>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>

using namespace std;
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
        os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
#define vv(type,w,h,init) vector<vector<type>>(h,vector<type>(w,init))
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

string const resstr[] = {"Impossible","Possible","No","Yes"};

int diff(int y, int m, int d){
    int res = (y-1)/3 * (195*2 + 200);
    if(y%3 == 1) res += 0;
    if(y%3 == 2) res += 195;
    if(y%3 == 0) res += 195+195;
     
    if(y%3 == 0)
        res += (m-1)*20;
    else{
        res += (m-1)/2 * (20+19);
        if(m%2 == 0)
            res += 20;
    }
    res += d-1;
    return res;
}
 
int main(){
    int n; cin >> n;
    int d1000 = diff(1000,1,1);
    rep(i,n){
        int y,m,d;
        cin >> y >> m >> d;
        cout << d1000 - diff(y,m,d) << endl;
    }
}

Measured memory_bytes: 1200
/* In the name of Allah */

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

#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pb push_back
#define LL_INF 1LL << 62
#define INF 1 << 30
#define SetBit(x, k) (x |= (1LL << k))
#define ClearBit(x, k) (x &= ~(1LL << k))
#define CheckBit(x, k) (x & (1LL << k))
#define mod 1000000007

int n;
ll x[100005];
ll dp[100005];

ll solve(int pos){
  if(pos>=n-1) return 0;
  if(dp[pos]!=-1) return dp[pos];

  ll res = LL_INF;
  if(pos+1<n) res = min(res, abs(x[pos+1]-x[pos])+solve(pos+1));
  if(pos+2<n) res = min(res, abs(x[pos+2]-x[pos])+solve(pos+2));

  return dp[pos] = res;
}

int main()
{
  memset(dp, -1, sizeof dp);
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> x[i];

  cout << solve(0) << "\n";

  return 0;
}

Measured memory_bytes: 9800
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int a[3];
    for(int i = 0; i < 3; i++){
        cin >> a[i];
    }
    sort(a, a + 3);
    cout << a[0] + a[1] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define N 36

struct Toramp{
  char c;
  char num;
};

int c1n[N], c2n[N];
struct Toramp C1[N], C2[N];

void Bubble(int n){
  int i, j, k;
  char x, y;
  for(i = 0; i <= n-1; i++){
    for(j = n-1; j >= i+1; j--){
      if(c1n[j] < c1n[j-1]){
        x = C1[j].c;
	y = C1[j].num;
	k = c1n[j];
	C1[j].c = C1[j-1].c;
	C1[j].num = C1[j-1].num;
	c1n[j] = c1n[j-1];
	C1[j-1].c = x;
	C1[j-1].num = y;
	c1n[j-1] = k;
      }
    }
  }
}

void SelectionSort(int n){
  int i, j, minj, k;
  char x, y;
  for(i = 0; i <= n-1; i++){
    minj = i;
    for(j = i; j <= n-1; j++){
      if(c2n[j] < c2n[minj]){
	minj = j;
      }
    }
    x = C2[i].c;
    y = C2[i].num;
    k = c2n[i];
    C2[i].c = C2[minj].c;
    C2[i].num = C2[minj].num;
    c2n[i] = c2n[minj];
    C2[minj].c = x;
    C2[minj].num = y;
    c2n[minj] = k;
  }
}

int isStable(int n){
  int i;
  for(i = 0; i < n; i++){
    if(C1[i].c != C2[i].c){
      return 0;
    }
  }
  return 1;
}

int numHenkan(char ccc){
  if(ccc == '0'){
    return 0;
  }else if(ccc == '1'){
    return 1;
  }else if(ccc == '2'){
    return 2;
  }else if(ccc == '3'){
    return 3;
  }else if(ccc == '4'){
    return 4;
  }else if(ccc == '5'){
    return 5;
  }else if(ccc == '6'){
    return 6;
  }else if(ccc == '7'){
    return 7;
  }else if(ccc == '8'){
    return 8;
  }else if(ccc == '9'){
    return 9;
  }
}

int main(){
  int i, n, k;
  char cc[3];
  
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", cc);
    C1[i].c = cc[0];
    C1[i].num = cc[1];
  }
  
  for(i = 0; i < n; i++){
    C2[i].c = C1[i].c;
    C2[i].num = C1[i].num;
    c1n[i] = numHenkan(C1[i].num);
    c2n[i] = c1n[i];
  }
  
  Bubble(n);
  SelectionSort(n);
  
  printf("%c%c", C1[0].c, C1[0].num);
  for(k = 1; k < n; k++){
    printf(" %c%c", C1[k].c, C1[k].num);
  }
  printf("\n");
  printf("Stable\n");
  
  printf("%c%c", C2[0].c, C2[0].num);
  for(k = 1; k < n; k++){
    printf(" %c%c", C2[k].c, C2[k].num);
  }
  printf("\n");
  if(isStable(n) == 1){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  
  return 0;
}



Measured memory_bytes: 2084
N = int(input())
arr = [int(i) for i in input().split()]
b = {}
length = []
tmp = -1
for i in range(N):
    if i == N-1 :
        length.append(i-tmp)
        break
    if arr[i] != arr[i+1]:
        length.append(i-tmp)
        tmp = i
count = 0
for i in length:      
    count += i//2
print(count)

Measured memory_bytes: 3064
N,Y = map(int,input().split())
ans = []
for i in range(N+1):
  for j in range(N-i+1):
    k = N-i-j
    if 10000*i + 5000*j + 1000*k == Y:
      ans = [i,j,k]
if ans == []:
  ans = [-1, -1, -1]
print(ans[0],ans[1],ans[2],end =' ')
      


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    int num;
    cin >> num;
    int current = 0;
    current += (num%100)/5;
    if(num%5!=0){
        current ++;
    }
    if(num>=current*100+num%100){
        cout << "1\n";
    }else{
        cout << "0\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000007
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;


bool bet(int i , int a ,int b)
{
     int sum =0;

     while(i)
     {
         sum+=i%10;
         i/=10;
     }
     if(sum<a||sum>b)
        return false;
     return true;
}
int main(){
   std::ios::sync_with_stdio(false);
   cin.tie(0);
ll x,y;
cin>>x>>y;

int ans =1;
int  mult = 2;
while(x*mult<=y)
{
x=x*mult;
ans++;
}
cout<<ans<<endl;
 return 0;
}


Measured memory_bytes: 3612
#include<stdio.h>

int search(int A[], int n, int key) {
    int i = 0;
    A[n] = key;     //番兵の設置
    while ( A[i] != key) i++;
    return i != n;  //番兵まで検索が達しなかった場合、trueを返却
}

int main() {
    int i, n, A[10000+1], q, key, sum = 0;
    
    scanf("%d", &n);
    for ( i = 0; i < n; i++ ) scanf("%d", &A[i]);
    
    scanf("%d", &q);
    for ( i = 0; i < q; i++ ) {
        scanf("%d", &key);
        if ( search(A, n, key) ) sum++;
    }
    printf("%d\n", sum);
    return 0;
}


Measured memory_bytes: 2700
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
typedef pair<int, int> pii;
typedef long long ll;
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, K;
vector<pii> es;
vector<int> to[2010];
int dist[2010][2010];

void dfs(int cur, int ini, int cnt=0, int prev=-1) {
    dist[ini][cur] = cnt++;
    for(auto x : to[cur]) {
        if(x == prev) continue;
        dfs(x, ini, cnt, cur);
    }
}

signed main() {
    memset(dist, -1, sizeof(dist));
    cin >> N >> K;
    rep(i,0,N-1) {
        int u, v; cin >> u >> v;
        u--; v--;
        to[u].push_back(v);
        to[v].push_back(u);
        es.push_back(pii(u, v));
    }
    rep(i,0,N) dfs(i, i);

    int ans = INF;
    if(K % 2 == 0) {
        // 各頂点を中心として、K / 2 を超えている頂点数の最小を求める
        rep(i,0,N) {
            int temp = 0;
            rep(j,0,N) {
                if(dist[i][j] > K / 2) temp++;
            }
            chmin(ans, temp);
        }
    }
    else {
        // 各辺を中心として、(K - 1) / 2 を超えている頂点数の最小を求める
        rep(i,0,es.size()) {
            int u = es[i].first, v = es[i].second, temp = 0;
            rep(j,0,N) {
                int d = min(dist[u][j], dist[v][j]);
                if(d > (K - 1) / 2) temp++;
            }
            chmin(ans, temp);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 32128
#include <cstdio>
main(){
int a[4],l[3],n=2;
while(n--)
scanf("%d%d%d%d",a,a+1,a+2,a+3),l[n]=*a+a[1]+a[2]+a[3];
printf("%d\n",*l>l[1]?*l:l[1]);
}

Measured memory_bytes: 0
N = int(input())

def num2alpha(num):
    if num<=26:
        s = chr(64+num)
        return s.lower()
    elif num%26==0:
        s = num2alpha(num//26-1)+chr(90) 
        return s.lower()
    else:
        s = num2alpha(num//26)+chr(64+num%26)
        return s.lower()
print( num2alpha(N))
    

Measured memory_bytes: 9068
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Stream;

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

        while(true){
            int a = sc.nextInt();
            int b = sc.nextInt();

            if (a == 0 && b == 0) break;

            for(int i=0; i<a; i++){
                for(int j=0; j<b; j++){
                    if(i == 0 || j == 0 || j == b-1 || i == a-1){
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println();
            }
            System.out.println();
        }
    }
}



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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int N, K; cin >> N >> K;
	vector<set<int>> boat(K, set<int>());
	rep(i, 0, K) {
		int m; cin >> m;
		rep(j, 0, m) {
			int b; cin >> b;
			b--;
			boat[i].insert(b);
		}
		dump(i);
	}
	int R; cin >> R;
	vector<int> flag(N, false);
	rep(i, 0, R) {
		int p, q; cin >> p >> q;
		p--, q--;
		rep(j, 0, K) {
			if (boat[j].count(p) && boat[j].count(q)) {
				flag[p] = flag[q] = true;
			}
		}
		dump(i);
	}
	dump(1);
	int cnt = 0;
	rep(i, 0, N) {
		if (flag[i])cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

using namespace std;
typedef long long unsigned int ll;

#define PI (acos(-1))
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int main(void){
    int n; cin >> n;
    int k; cin >> k;
    vector <int> xs;
    int x;
    REP(i, n){
        cin >> x;
        xs.push_back(x);
    }
    int ans = 1e9;
    REP(i, n-k+1){
        int t;
        int l = xs[i];
        int h = xs[i+k-1];
        if ((l<0 && h>0) or (l>0 && h<0)){
            t = min(abs(l*2-h), abs(l-h*2));
        } else {
            t = max(abs(l), abs(h));
        }
        ans = min(ans, t);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define INF 1000000001
#define ll long long
using namespace std;
using pint = pair<int, int>;

int main()
{
  ll X, Y;
  cin >> X >> Y;
  ll ans = 0;
  while (X <= Y)
  {
    X *= 2;
    ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll gya[200010];
ll kai[200010];
ll m;
ll beki(ll n,ll k){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=m;
    }
    now*=now;
    now%=m;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n){
  return beki(n,mod-2);
}
void nckinit(ll n){
  kai[0]=1;
  kai[1]=1;
  for(int i=2;i<=n;i++){
    kai[i]=kai[i-1]*i;
    kai[i]%=mod;
  }
  gya[n]=gyaku(kai[n]);
  for(int i=n-1;i>=1;i--){
    gya[i]=gya[i+1]*(i+1);
    gya[i]%=mod;
  }
  gya[0]=1;
}    
ll nck(ll n,ll k){
  if(k<0)return 0;
  if(k==0||n==k)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  ret*=gya[k];
  ret%=mod;
  return ret;
}
ll npk(ll n,ll k){
  if(k<0)return 0;
  if(k==0)return 1;
  ll ret=kai[n];
  ret*=gya[n-k];
  ret%=mod;
  return ret;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  ll ans=0;
  rep(i,1,n)ans+=i;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll =  unsigned long long;
int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> a(m);
    vector<ll> b(n+1);
    REP(i,n+1)b[i] = -1;
    REP(i,m){
        cin >> a[i];
        b[a[i]] = 0;
    }
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    else if(n == 2){
        if(b[1]==0)cout << 1 << endl;
        else cout << 2 << endl;
        return 0;
    }
    b[0]=1;
    if(b[1] != 0)b[1] = 1;

    FOR(i,2,n+1){
        if(b[i] == 0)continue;
        b[i] = (b[i-1]+b[i-2])%MOD;
        //printf("b[%d] = %lld + %lld\n",i,b[i-1],b[i-2]);
    }
    
    
    cout << b[n] << endl;
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> d(10);
    for(int i = 0;i < 10;i++)   d[i] = 0;
    for(int i = 0;i < K;i++){
        int di;
        cin >> di;
        d[di]++;
    }
    int ans = 0;
    bool f = false;
    for(int i = N;!f;i++){
        int j = i;
        while(true){
            if(d[j%10] == 1)    break;
            j /= 10;
            if(j == 0){
                ans = i;
                f = true;
                break;
            }
        }
    }
    cout << ans << endl;
}

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

#define NMAX 1000010

typedef long long i64;

namespace UF {
	i64 tata[NMAX + 1], g[NMAX + 1];

	void UF(i64 until = NMAX) { /// for changing in class if needed
		for (i64 i = 0; i <= until; i++)
			tata[i] = i, g[i] = 0;
	}
	i64 find(i64 x) {
		if (tata[tata[x]] != tata[x])
			tata[x] = find(tata[x]);
		return tata[x];
	}
	bool find(i64 a, i64 b) {
		return find(a) == find(b);
	}
	inline bool unite(i64 a, i64 b) {
		a = find(a);
		b = find(b);
		if (a == b)
			return false;
		if (g[a] < g[b])
			swap(a, b);
		tata[b] = a, g[a] += g[b];
		return true;
	}
}

i64 x[NMAX], y[NMAX];
vector <pair <i64, i64>> dif;
i64 n;


i64 verif(i64 dx, i64 dy)
{
	UF::UF(n + 1);

	for (i64 i = 1; i <= n; i++)
		for (i64 j = 1; j <= n; j++)
			if (x[i] == x[j] + dx && y[i] == y[j] + dy)
				UF::unite(i, j);

	i64 ans = 0;
	for (i64 i = 1; i <= n; i++)
		if (UF::find(i) == i)
			ans++;
	return ans;
}


int main()
{
	cin >> n;
	for (i64 i = 1; i <= n; i++)
		cin >> x[i] >> y[i];

	i64 best = 1e9;

	for (i64 i = 1; i <= n; i++)
		for (i64 j = 1; j <= n; j++)
			best = min(best, verif(x[i] - x[j], y[i] - y[j]));

	cout << best << '\n';
	return 0;
}

Measured memory_bytes: 6400
N = int(input())
A = list(map(int, input().split()))
S = 0
ans = 0
for k in range(N):
  S = S + A[k]

for i in range(N-1):
  S = S - A[i]
  ans = ans + S * A[i]

ans = ans % (10**9 + 7)
print(ans)



Measured memory_bytes: 94104
s = input()

if s[0] != "A":
    print("WA")
    exit()

c = 0

for i in range(1, len(s)):
    num = ord(s[i])
    if num >= 97:
        continue
    elif 2 <= i <= len(s)-2 and num == 67:
        c += 1
    else:
        print("WA")
        exit()

if c == 1:
    print("AC")
else:
    print("WA")

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  map<int,bool> mp;
  FOR(i,1,10){
    FOR(j,1,10){
      mp[i*j] = true;
    }
  }
  if(mp[n]) cout << "Yes" << "\n";
  else cout << "No" << "\n";
  return 0;
}


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

int n;
int x = 1;
int k = 0;
int a[30];
int i = 2;

int main() {
    cin >> n;
    int e = n;
    BUNKAI:
    while (n >= i * i) {
        if (n % i == 0) {
            n /= i;
            x = i;
            a[k] = i;
            k++;
            goto BUNKAI;
        }
        i++;
    }
    
    cout << e << ":";
    for (int i = 0; i < k; i++) {
        cout << " " << a[i];
    }
    
    if (k == 1 && n == 1) {
        cout << endl;
        return 0;
        
    } else {
        cout << " " << n;
        cout << endl;
        return 0;

    }
    
    
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define endl "\n"
#define ll long long
#define sz(s) (int)(s.size())
#define INF 0x3f3f3f3f3f3f3f3fLL
#define all(v) v.begin(),v.end()
#define watch(x) cout<<(#x)<<" = "<<x<<endl
const int dr[] { -1, -1, 0, 1, 1, 1, 0, -1 };
const int dc[] { 0, 1, 1, 1, 0, -1, -1, -1 };
#if __cplusplus >= 201402L
template<typename T>
vector<T> create(size_t n) {
	return vector<T>(n);
}
template<typename T, typename ... Args>
auto create(size_t n, Args ... args) {
	return vector<decltype(create<T>(args...))>(n, create<T>(args...));
}
#endif
void run() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifdef EZZAT
	freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
#else
#endif
}

int solveEq(int a, int b, int c) {
	return (-b + sqrt(b * b - 4 * a * c)) / (2 * a);
}

bool valid(int x, int y, int z, int i) {
	return x * x + y * y + z * z + x * y + x * z + y * z == i;
}
int main() {
	run();
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		int ans = 0;
		for (int x = 1; x * x <= i; x++)
			for (int y = 1; x * x + y * y + x * y <= i; y++) {
				int z = solveEq(1, x + y, -i + (x * x + y * y + x * y));
				if (z > 0 && valid(x, y, z, i))
					ans++;
			}
		cout << ans << endl;
	}
}


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

int main() {
  int N;
  bool is_four = false;
  cin >> N;
  
  for (int i = 1; i < N; i++) {
    string c;
    cin >> c;
    if (c == "Y") {
      is_four = true;
    }
  }
  
  if (is_four) {
    cout << "Four" << endl;
  }else{
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
#include <climits>
#include <bitset>
using namespace std;
int  gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

long long modinv(long long a, long long mod) {
	long long b = mod, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t*b; swap(a, b);
		u -= t*v; swap(u, v);
	}
	u %= mod;
	if (u < 0) u += mod;
	return u;
}
namespace NTT {
	const int MOD = 998244353;  // to be set appropriately
	const long long PR = 3;     // to be set appropriately

	void trans(vector<long long> &v, bool inv = false) {
		int n = (int)v.size();
		for (int i = 0, j = 1; j < n - 1; j++) {
			for (int k = n >> 1; k >(i ^= k); k >>= 1);
			if (i > j) swap(v[i], v[j]);
		}
		for (int t = 2; t <= n; t <<= 1) {
			long long bw = modpow(PR, (MOD - 1) / t, MOD);
			if (inv) bw = modinv(bw, MOD);
			for (int i = 0; i < n; i += t) {
				long long w = 1;
				for (int j = 0; j < t / 2; ++j) {
					int j1 = i + j, j2 = i + j + t / 2;
					long long c1 = v[j1], c2 = v[j2] * w % MOD;
					v[j1] = c1 + c2;
					v[j2] = c1 - c2 + MOD;
					while (v[j1] >= MOD) v[j1] -= MOD;
					while (v[j2] >= MOD) v[j2] -= MOD;
					w = w * bw % MOD;
				}
			}
		}
		if (inv) {
			long long inv_n = modinv(n, MOD);
			for (int i = 0; i < n; ++i) v[i] = v[i] * inv_n % MOD;
		}
	}

	// C is A*B
	vector<long long> mult(vector<long long> A, vector<long long> B) {
		int size_a = 1; while (size_a < A.size()) size_a <<= 1;
		int size_b = 1; while (size_b < B.size()) size_b <<= 1;
		int size_fft = max(size_a, size_b) << 1;

		vector<long long> cA(size_fft, 0), cB(size_fft, 0), cC(size_fft, 0);
		for (int i = 0; i < A.size(); ++i) cA[i] = A[i];
		for (int i = 0; i < B.size(); ++i) cB[i] = B[i];

		trans(cA); trans(cB);
		for (int i = 0; i < size_fft; ++i) cC[i] = cA[i] * cB[i] % MOD;
		trans(cC, true);

		vector<long long> res((int)A.size() + (int)B.size() - 1);
		for (int i = 0; i < res.size(); ++i) res[i] = cC[i];
		return res;
	}
};

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	int num[100005] = { 0 };
	int a, b;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		num[a] += 1;
		num[b] += 1;
	}
	string ans = "YES";
	for (int i = 1; i <= n; i++) {
		if (num[i] % 2)ans = "NO";
	}
	cout << ans;
}

Measured memory_bytes: 640
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>

#define INF 1000001
typedef long long llong;
using namespace std;



int main() {
	int n;
	int a_i;
	vector<int> vt;
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a_i;
		vt.push_back(a_i);
	}
	reverse(vt.begin(), vt.end());
	for (vector<int>::iterator it = vt.begin(); it != vt.end(); it++) {
		if (it == vt.begin())cout << *it;
		else cout << " " << *it;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define in_arr(n,A)                     for(int i=0;i<n;i++)cin>>A[i];
#define IOS                             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define vi                              vector <int>
#define vl                              vector <ll>
#define out_arr(n,A)                    for(int i=0;i<n;i++)cout<<A[i]<<" ";
#define LINE                            cout << endl
#define SPACE                           cout << " "
#define pb                              push_back
#define Fr                              first
#define Sc                              second
#define YES                             cout << "YES"
#define NO                              cout << "NO"
#define wrong                           cout << -1
#define pll                             pair <ll, ll>
#define pii                             pair <int, int>
#define OO                              INT_MAX
#define SMALL                           INT_MIN
#define BIGx2                           LONG_LONG_MAX
#define sz                              size()
//BIT_OP
#define isOn(s, j)                      (s & (1<<j))
#define setBit(s, j)                    (s |= ( 1<< j))
#define clearBit(s, j)                  (s &= ~( 1 << j ))
#define lowBit(s)                       (s & (-s))
#define setAll(s, n)                    ( s = ( 1 << n ) - 1)
#define modulo(s, n)                    ((s) & ( n - 1 ))
#define isPowerOfTwo(s)                 (!(s & (s - 1)))
#define nearestPowerOfTwo(s)            ((int)pow(2.0, (int)((log((double)s) / log(2.0)) + 50. )))
#define nextnearestPowerOfTwo(s)        (1<<(32 - __builtin_clz(s)))
#define turnoffLastBit(s)               ((s) & (s - 1))
#define turnonLastZero(s)               ((S) | (s + 1))
#define turnoffLastConsecutiveBits(s)   ((s) & (s + 1))
typedef long long ll;
using namespace std;
int A, B;
int Bla = 1, Cnt;
int main()
{
    IOS
    cin >> A >> B;
    while(Bla < B)
    {
        Bla--;
        Bla += A;
        Cnt++;
    }
    cout << Cnt << endl;
}


Measured memory_bytes: 256
#include <stdio.h> 
const int N=3000+5;

int main()
{
	int n,a[N],s=0;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
		s+=a[i];
	}
	printf("%d\n",s-n);	
	return 0;
}


Measured memory_bytes: 128
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

def f():
    if sum(A) < sum(B):
        return -1
    
    d = [a - b for a,b in zip(A, B)]
    d.sort()
    
    ret = 0
    tl = len(d) - 1
    hd = 0
    stock = 0
    while d[hd] < 0:
        stock += d[hd]
        hd += 1
        ret += 1
        while stock < 0:
            stock += d[tl]
            tl -= 1
            ret += 1
    
    return ret

print(f())

Measured memory_bytes: 18356
#include <iostream>
#include <cstdio>
#define N 200005
using namespace std;

typedef long long ll;
ll M = 1e9 + 7;
ll n, k, s, fac[N] = {1, 1}, inv[N] = {1, 1}, fiv[N] = {1, 1};

ll C(ll p, ll q) {
	if (p < q) return 0;
	return fac[p] * fiv[q] % M * fiv[p - q] % M;
}

ll H(ll p, ll q) {
	return C(p + q - 1, q);
}

int main()
{
	ll i;
	cin >> n >> k;
	for (i = 2; i <= n; i++) {
		fac[i] = fac[i - 1] * i % M;
		inv[i] = inv[M % i] * (M - M / i) % M;
		fiv[i] = fiv[i - 1] * inv[i] % M;
	}
	for (i = 0; i <= min(n, k); i++) {
		s = (s + C(n, i) * H(n - i, i)) % M;
	}
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 4992
import collections #deque

h,w = [int(i) for i in input().split()]
board = [input() for j in range(h)] # 縦「n」行

dx4=[0, 1, 0,-1]
dy4=[1, 0,-1, 0]
#dx8=[0, 1, 0,-1,1,-1,1,-1]
#dy8=[1, 0,-1, 0,1,1,-1,-1]

#memo: 負なら未確認、0以上なら最短距離
memo = [[-1]*w for _ in range(h)]

q = collections.deque()
#初期状態をキューに入れる-----------------------------------------------------
#キューに入れる時点で使用したかどうかのmemoを更新-----------------------------
for i in range(h):
    for j in range(w):
        if board[i][j] == "#":
            q.append((i,j)) #初期状態をキューに入れる
            memo[i][j] = 0 #初期状態を訪問済みにする

while len(q) != 0:
    x,y = q.popleft() #キューから情報を取り出す
    #foreach (x,y)のお隣さん に対して処理-------------------------------------
    for i in range(4):
        nx = x + dx4[i]
        ny = y + dy4[i]
        #範囲外ならスキップ---------------------------------------------------
        if nx < 0 or nx>=h or ny <0 or ny>=w: continue
        #壁ならスキップ-------------------------------------------------------
        #if board[nx][ny] == "#": continue
        #(nx,ny)が確認済みならスキップ----------------------------------------
        if memo[nx][ny] >= 0: continue
        #(nx,ny)が未確認のとき、確認済みにしてキューに入れる------------------
        memo[nx][ny] = memo[x][y]+1
        q.append((nx,ny))
        #経路復元が必要なとき-------------------------------------------------
        # prev[nx][ny] = [x,y]

ans = 0      
for i in range(h):
    for j in range(w):
        ans = max(ans,memo[i][j])

print(ans)


Measured memory_bytes: 87900
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
            int flag = 0;
        while(true){
            

            int N = sc.nextInt();

            if(N == 0) break;
           if(flag == 1) System.out.print("\n");

            int[] sco = new int[N];
            int sum = 0, bun2;
            double bun1=0.0;

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

             for(int i=0; i<N; i++){
                bun1 +=  (sco[i] - (double)sum/N) * (sco[i] - (double)sum/N);
               // System.out.println(sco[i] - (double)sum/N);
             }

             System.out.print(Math.sqrt((double)bun1/(double)N));
             flag = 1;
    }

    }
}

                                        
                                    
                    


Measured memory_bytes: 31148
#include <stdio.h>
char str[110];
int main(void){
    // Your code here!
    scanf("%s", str);
    int ok = 1;
    for(int i = 0; i < 110; i++){
        if(i & 1){
            if(str[i] == 'R') ok = 0;
        }else{
            if(str[i] == 'L') ok = 0;
        }
    }
    if(ok){
        printf("Yes");
    }else{
        printf("No");
    }
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<math.h>
// #include<bits/stdc++.h>
using namespace std;
#define ll long long
constexpr long long int INFLL = 1001001001001001LL;
constexpr int INFI = 1000000007;

int main(){
  int N;
  cin >> N;
  vector<int> A(N),B(N),C(N);
  for(int i=0; i<N; i++){
    cin >> A[i];
  }
  for(int i=0; i<N; i++){
    cin >> B[i];
  }
  for(int i=0; i<N; i++){
    cin >> C[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  sort(C.begin(),C.end());
  vector<int> sumAB(N+1);
  ll sum=0;
  int i=0,j=0;
  while(1){
    if(A[i] < B[j]){
      sum++;
      i++;
    }else{
      sumAB[j] = sum;
      j++;
    }
    if(i>=N){
      while(j<N){
        sumAB[j] = sum;
        j++;
      }
    }
    if(j>=N){
      break;
    }
  }
  sum = i = j = 0;
  vector<ll> sumBC(N+1);
  while(1){
    if(B[i] < C[j]){
      sum += sumAB[i];
      i++;
    }else{
      sumBC[j] = sum;
      j++;
    }
    if(i>=N){
      while(j<N){
        sumBC[j] = sum;
        j++;
      }
    }
    if(j>=N){
      break;
    }
  }
  ll Sum=0;
  for(int i=0; i<N; i++){
    Sum += sumBC[i];
  }
  cout << Sum << endl;
  return 0;
}


Measured memory_bytes: 2688
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
void read (int &x) {
    char ch = getchar(); x = 0;
    while (!isdigit(ch)) ch = getchar();
    while (isdigit(ch)) x = x * 10 + ch - 48, ch = getchar();
} const int N = 5e5 + 10, mod = 1e9 + 7;
int n, m, res, sum, p[N], inv[N];
int Pow (int x, int y) {
    int tmp = 1;
    while (y) {
        if (y & 1) tmp = tmp * x % mod;
        x = x * x % mod; y >>= 1;
    } return tmp;
}
void pre_work () {
    p[0] = 1; inv[0] = 1;
    for (int i = 1; i < N; ++i) p[i] = p[i - 1] * i % mod;
    inv[N - 1] = Pow (p[N - 1], mod - 2);
    for (int i = N - 2; i >= 1; --i) inv[i] = inv[i + 1] * (i + 1) % mod;

}
int C (int y, int x) {
    return p[y] * inv[x] % mod * inv[y - x] % mod;
}
signed main() {
    read (n), read (m); pre_work();
    for (int i = 1, tmp; i <= n; ++i) {
        tmp = C (n, i) * C (m - i, n - i) % mod * p[n - i] % mod;
        (i & 1) ? sum += tmp : sum -= tmp;
    } res = (C (m, n) * p[n] - sum) % mod * C (m, n) % mod * p[n] % mod;
    return printf ("%lld\n", res), 0;
}


Measured memory_bytes: 11516
#include <bits/stdc++.h>    
using namespace std;
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define int long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define fone for(i=0;i<n;i++)
#define endl "\n"
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N          = 5000*100+1;
const ll N2      = 1000*1000+5;
const ld PI  = 3.14159265;
const ll R   = 250;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;} 
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
    }


signed main ()
{
  fastio();
  int n,k,W;
  vector<pair<int,int>>vv;
  cin>>n>>W;

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


  //cout<<"*";
 vector<vector<ll> > dp(n+1,vector<ll>(W+1,0LL));
 //int dp[1000][1000];
  for (int i = 1; i <= n; i++)
  {
    for (int j = 0; j <= W; j++)
    {
      if(j-w[i-1]<0) dp[i][j] = dp[i-1][j];
      else dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i-1]] + v[i-1]);
    }
  }
  ll ans=0;
  for (int j = 0; j <= W; j++)
  {
    ans = max(ans,dp[n][j]);
  }
  
  cout << ans << endl;
  
return 0;
  
}




Measured memory_bytes: 80256
n=int(input())
w=[input()]
a=0
for i in range(1,n):
    x=input()
    if w.count(x)!=0:
        print('No')
        a+=1
        break
    else:
        w.append(x)
        if w[i][0]==w[i-1][len(w[i-1])-1]:
            continue
        else:
            print('No')
            a+=1
            break
if a==0:
    print('Yes')


    


Measured memory_bytes: 3060
#include <stdio.h>
  
int main(void)
{
	int a, b;

	scanf("%d%d", &a, &b);
	if (a < b) {
		printf("a < b\n");
	}
	else if (a > b) {
		printf("a > b\n");
	}
	else {
		printf("a == b\n");
	}
	return 0;

}


Measured memory_bytes: 2048
from functools import lru_cache
 
@lru_cache(maxsize=None)

def ryuka(n):
  if n==0:
    return 2
  elif n==1:
    return 1
  else:
    return ryuka(n-1)+ryuka(n-2)
  
N=int(input())

print(ryuka(N))



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

int main(){
    long long int n,a,b;
    cin >> n >> a >> b;
    if(n % (a+b) > a){
        cout << n/(a+b) * a + a << endl;
    }else{
        cout << n/(a+b) * a + n % (a+b) << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
using namespace std;

const int MAX_V = 100010;
using Flow = int;
const auto inf = numeric_limits<Flow>::max() / 8;
struct Edge {
    int dst;
    Flow cap, cap_orig;
    Flow cost;
    int revEdge; bool isRev;
    Edge(int dst, Flow cap, Flow cost, int revEdge, bool isRev)
        :dst(dst), cap(cap), cap_orig(cap), cost(cost), revEdge(revEdge), isRev(isRev) {
    }
};
struct PrimalDual {
    int n;
    vector<vector<Edge> > g;
    PrimalDual(int n_) : n(n_), g(vector<vector<Edge> >(n_)) {}
    void addEdge(int src, int dst, Flow cap, Flow cost) { // ?????????
        g[src].emplace_back(dst, cap, cost, g[dst].size(), false);
        g[dst].emplace_back(src, 0, -cost, g[src].size() - 1, true);
    }
    Flow solve(int s, int t, int f) {
        Flow res = 0;
        vector<Flow> h(g.size()), dist(g.size());
        vector<int> prevv(g.size()), preve(g.size());
        while (f > 0) {
            using State = pair<Flow, int>;
            priority_queue<State, vector<State>, greater<State> > q;
            fill(dist.begin(), dist.end(), inf);
            dist[s] = 0;
            q.emplace(0, s);
            while (q.size()) {
                State p = q.top(); q.pop();
                int v = p.second;
                if (dist[v] < p.first) continue;
                for(int i = 0; i < (int)g[v].size(); ++i){
                    Edge &e = g[v][i];
                    if (e.cap > 0 && dist[e.dst] > dist[v] + e.cost + h[v] - h[e.dst]) {
                        dist[e.dst] = dist[v] + e.cost + h[v] - h[e.dst];
                        prevv[e.dst] = v;
                        preve[e.dst] = i;
                        q.emplace(dist[e.dst], e.dst);
                    }
                }
            }
            if (dist[t] == inf) {
                return -1;
            }
            for (int i = 0; i < n; ++i) {
                h[i] += dist[i];
            }
            int d = f;
            for (int v = t; v != s; v = prevv[v]) {
                d = min(d, g[prevv[v]][preve[v]].cap);
            }
            f -= d;
            res += d * h[t];
            for (int v = t; v != s; v = prevv[v]) {
                Edge &e = g[prevv[v]][preve[v]];
                e.cap -= d;
                g[v][e.revEdge].cap += d;
            }
        }
        return res;
    }
};

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m, f;
    cin >> n >> m >> f;
    PrimalDual pd(n);
    for (int i = 0; i < m; i++) {
        int u, v, c, d;
        cin >> u >> v >> c >> d;
        pd.addEdge(u, v, c, d);
    }
    cout << pd.solve(0, n - 1, f) << endl;
}

Measured memory_bytes: 3280
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <cstdio>
using ll = long long;

// 処理内容
int main() {

    ll n; scanf("%lld", &n);

    ll ans[1024];
    for (ll j = 1, j_end = n-1; j <= j_end; j++) {
        ans[j-1] = 0;
        for (ll l = j & -j; l; ans[j-1]++) l >>= 1;
    }
    for (ll i = 0, i_end = n-2; i <= i_end; i++) {
        for (ll j = 0, j_end = n-2-i; j <= j_end; j++) {
            printf("%lld%c", ans[j], j == j_end ? '\n' : ' ');
        }
    }
    
}

Measured memory_bytes: 384
#include <cstdio>
#include <cstring>

const int MAX = 100;
int adj[MAX + 1][MAX + 1];

int main()
{
  std::memset(adj, 0, sizeof(adj));

  int n;
  scanf("%d", &n);

  int u, k, v;
  for (int i = 0; i < n; ++i)
  {
    scanf("%d%d", &u, &k);
    for (int j = 0; j < k; ++j)
    {
      scanf("%d", &v);
      adj[u][v] = 1;
    }
  }

  for (int i = 1; i <= n; ++i)
  {
    for (int j = 1; j <= n; ++j)
    {
      printf("%d", adj[i][j]);
      if (j < n)
        printf(" ");
      else
        printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 2716
#include <stdio.h>
 
int main(int argc, char const *argv[]) {
  int N,K;
  scanf("%d %d\n", &N,&K);
  if (K > 1) {
    printf("%d\n",N - K);
  } else {
    printf("%d\n",0);
  }
  return 0;
}

Measured memory_bytes: 128