akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
#define DEBUG
#ifdef DEBUG
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << '(' << p.first << ',' << p.second << ')';
    return os;
}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << '{';
    for(int i = 0; i < (int)v.size(); i++) {
        if(i) {
            os << ',';
        }
        os << v[i];
    }
    os << '}';
    return os;
}
void debugg() { cerr << endl; }
template <class T, class... Args>
void debugg(const T &x, const Args &... args) {
    cerr << " " << x;
    debugg(args...);
}
#define debug(...)                                                             \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debugg(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __Setup;

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    int n;
    cin >> n;
    cout << (!n) << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<string.h>
char str[10][10];
int t,flag,book[10][10][10];
void get(int a,int b,int n)
{
    int i,j,k;
    for(j=0;j<8;j++)
        book[n][j][b]=1;
    for(j=0;j<8;j++)
        book[n][a][j]=1;
    for(j=a,k=b;j<8&&k<8;j++,k++)
        book[n][j][k]=1;
    for(j=a,k=b;j<8&&k>=0;j++,k--)
        book[n][j][k]=1;
    for(j=a,k=b;j>=0&&k<8;j--,k++)
        book[n][j][k]=1;
    for(j=a,k=b;j>=0&&k>=0;j--,k--)
        book[n][j][k]=1;
    return;
}
void clen(int n)
{
    int i,j;
    for(i=0;i<8;i++)
        for(j=0;j<8;j++)
        book[n][i][j]=0;
}
void cpy(int x,int y)
{
    int i,j;
    for(i=0;i<8;i++)
        for(j=0;j<8;j++)
            book[x][i][j]=book[y][i][j];
}
void dfs(int x,int y,int n)
{
    int i,j,k;
    if(n==9-t)
    {
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
                printf("%c",str[i][j]);
            printf("\n");
        }
        flag=1;
        return;
    }
    for(i=0;i<8;i++)
    {
        for(j=0;j<8;j++)
        {
            if(book[n-1][i][j]==0)
            {
                cpy(n,n-1);
                get(i,j,n);
                str[i][j]='Q';
                dfs(i,j,n+1);
                clen(n);
                str[i][j]='.';
            }
            if(flag)return;
        }
    }
}
int main()
{
    int n,m,a,b,i,j,k;
    scanf("%d",&t);
    memset(str,'.',sizeof(str));
    if(t==8)
    {
        for(i=0;i<t;i++)
        {
            scanf("%d%d",&a,&b);
            str[a][b]='Q';
        }
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
                printf("%c",str[i][j]);
            printf("\n");
        }
    }
    else
    {
        memset(book,0,sizeof(book));
        for(i=0;i<t;i++)
        {

            scanf("%d%d",&a,&b);
            str[a][b]='Q';
            get(a,b,0);
        }
        flag=0;
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
            {
                if(!book[0][i][j])
                {
                    cpy(1,0);
                    get(i,j,1);
                    str[i][j]='Q';
                    dfs(i,j,2);
                    clen(1);
                    str[i][j]='.';
                }
            }
        }
    }
}



Measured memory_bytes: 2128
#include <stdio.h>

int main(){

	int a, b, c;
	int l, m, h;

	scanf( "%d %d %d", &a, &b, &c );

	if( a < b ){
		l = a;
		m = b;
	}else{
		l = b;
		m = a;
	}

	if( c < l )
		printf( "%d %d %d\n", c, l, m );
	else if( m < c )
		printf( "%d %d %d\n", l, m, c );
	else
		printf( "%d %d %d\n", l, c, m );
	

	return 0;

}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

typedef pair<int,int> P;

signed main(){
	int n,l[100000],r[100000],mi = -1;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> l[i] >> r[i];
	}
	for(int i = 0;i < 2;i++){
		priority_queue<P,vector<P>,greater<P> > que1;
		priority_queue<P> que2;
		bool used[100000] = {};
		for(int j = 0;j < n;j++){
			que1.push(P(r[j],j));
			que2.push(P(l[j],j));
		}
		int tmp = i,pos = 0,ans = 0;
		for(int j = 0;j < n;j++){
			P p;
			if(!tmp){
				while(1){
					p = que1.top();que1.pop();
					if(!used[p.second]) break;
				}
			}else{
				while(1){
					p = que2.top();que2.pop();
					if(!used[p.second]) break;
				}
			}
			used[p.second] = true;
			if(l[p.second] > pos || r[p.second] < pos){
				ans += abs(pos - p.first);
				pos = p.first;
			}
			//cout << p.second << " " << pos << " " << ans << endl;
			tmp = !tmp;
		}
		mi = max(mi,ans + abs(pos));
	}
	cout << mi << endl;
	return 0;
}

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

void print(string str, int a, int b)
{
    for (int i=a; i<=b; i++)
    {
        cout << str.at(i);
    }
    cout << endl;
}


string reverse(string str, int a, int b)
{
    string str_new = str;
    for (int i=0; i<=b-a; i++)
    {
        str_new.at(a+i) = str.at(b-i);
    }
    return str_new;
}


string replace(string str, int a, int b, string p)
{
    for (int i=a; i<=b; i++)
    {
        str.at(i) = p.at(i-a);
    }
    return str;
}


int main()
{
    string str;
    cin >> str;
    int q;
    cin >> q;
    for (int i=0; i<q; i++)
    {
        string command;
        cin >> command;
        if (command=="print")
        {
            int a, b;
            cin >> a >> b;
            print(str, a, b);
        }
        else if (command=="reverse")
        {
            int a, b;
            cin >> a >> b;
            str = reverse(str, a, b);
        }
        else if (command=="replace")
        {
            int a, b;
            cin >> a >> b;
            string p;
            cin >> p;
            str = replace(str, a, b, p);
        }
    }
}


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

using namespace std;
#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++)

int main() {
  string s1, s2;
  cin >> s1 >> s2;
  if (s1.at(0) == s2.at(2) && s1.at(1) == s2.at(1) && s1.at(2) == s2.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
def factorize(n):
    ## 素因数分解
    # arr = factorize(20)
    # arr == [[2, 2], [5, 1]]
    
    result = []
    tmp = n
    for k in range(2, int(n ** 0.5) + 1):
        cnt = 0
        while tmp % k == 0:
            cnt += 1
            tmp //= k
        if cnt > 0:
            result.append([k, cnt])
    if tmp != 1:
        result.append([tmp, 1])
    return result

def divisorize(n):
    ## 約数
    # arr = factorize(20)
    # arr == [2, 4, 5, 10, 20]
    f = factorize(n)
    divisors = [1]
    for k in range(len(f)):
        num_divisors = len(divisors)
        for i in range(1, f[k][1] + 1):
            for j in range(num_divisors):
                divisors.append(divisors[j] * f[k][0] ** i)
    return sorted(divisors)

n = int(input())
a = []
for k in divisorize(n)[1:]:
    nn = n
    while True:
        if nn < k:
            break
        if nn % k == 0:
            nn = nn // k
        else:
            nn = nn % k
    if nn == 1:
        a.append(k)
s = divisorize(n - 1)
print(len(list(set(a + s))[1:]))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;

ll com(ll n)
{
        return n * (n-1) / 2;
}

int main()
{
        ll N, M;
        cin >> N >> M;
        vll A(N);
        rep(i, 0, N) cin >> A[i];

        vll acc(N+1);
        rep(i, 1, N+1) acc[i] += acc[i-1] + A[i-1];


/*
        ll right = 0;
        ll sm = 0;
        ll ans = 0;
        rep(left, 0, N) {
                while (right < N and (acc[right+1] - acc[left]) % M == 0) {
                        sm += A[right];
                        ++right;
                }
                cout << "left, right: " << left << ' ' << right << endl;
                ans += right - left;

                if (left == right) ++right;
                else sm -= A[left];

        }
*/
/*
        acc.erase(acc.begin());

        vector<bool> is(N);
        rep(i, 0, N) {
                if (acc[i] % M == 0) {
                        is[i] = 1;
                }
        }

        print1d(is);

        ll ans = 0;
        ll cnt = 0;

        rep(i, 0, N) {
                if (i == 0) {
                        if (is[i]) ++ans;
                        ++cnt;
                } else {        
                        if (is[i]) {
                                ans += (cnt+1) * cnt;
                                ++cnt;
                        }
                }
        }
        cout << ans << endl;
*/
        unordered_map<ll, ll> rems;
        rep(i, 0, N+1) {
                rems[acc[i] % M]++;
        }
        ll ans = 0;
        for (auto x : rems) {
                ans += com(x.second);
        }

        cout << ans << endl;
}

Measured memory_bytes: 5260
#include<stdlib.h>
#include<stdio.h>

#define LENGTH ((100))
int SelectionSort(int a[], int n)
{
    int minj, v, sw = 0;
    for (int i = 0; i < n -1; i++)
    {
        minj = i;
        for (int j = i + 1; j < n; j++)
        {
            if (a[j] < a[minj])
            {
                minj = j;
            }
            
        }
        if (i < minj)
        {
            v = a[i];
            a[i] = a[minj];
            a[minj] = v;
            sw++;    
        }
    }
    return sw;
}

int main()
{
    int n, sw;
    int a[LENGTH];

    scanf("%d", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &a[i]);
    }

    sw = SelectionSort(a, n);

    for (int j = 0; j < n; j++)
    {
        if (j > 0)
        {
            printf(" ");
        }
        printf("%d", a[j]);
    }

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


Measured memory_bytes: 2120
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    S = ns()
    if S == 'RRR':
        print(3)
    elif S == 'RRS' or S == 'SRR':
        print(2)
    elif S == 'SSR' or S == 'SRS' or S == 'RSS' or S == 'RSR':
        print(1)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9064
#include<iostream>
#include<stdio.h>
#include<vector>
#include<cmath>
#include<queue>
#include<string.h>
#include<map>
#include<set>
#include<algorithm>
#define ll long long
#define pi pair < ll,ll >
#define mp(a,b) make_pair(a,b)
#define rep(i,a,b) for(int i = a;i < b;i++)
#define N 21
#define INF 1e9+7

using namespace std;

ll n,mod=1e9+7;
bool ar[N][N];
ll dp[N][(1 << N)];

bool ison(ll mask,ll i)
{
    return (mask>>i)&1;
}

ll turnon(ll mask,ll i)
{
    return (mask | (1 << i));
}

ll solve(ll cur,ll mask)
{
    if(cur == n)
        return 1;
    if(dp[cur][mask] != -1)
        return dp[cur][mask];

    ll res = 0;

    rep(i,0,n)
    {
        if(ar[cur][i] && !ison(mask,i))
            res = (res+solve(cur+1,turnon(mask,i)))%mod;
    }

    return dp[cur][mask] = res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    memset(dp,-1,sizeof dp);

    cin >> n;

    rep(i,0,n)
    {
        rep(j,0,n)
        {
            cin >> ar[i][j];
        }
    }

    cout << solve(0,0);

    return 0;
}


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

int main(){
    string s;
    cin >> s;
    int first, last;
    for (int i = 0; i < s.size(); ++i){
        if (s[i] == 'A'){
            first = i;
            break;
        }
    }
    for (int i = s.size() - 1; i >= 0; --i){
        if (s[i] == 'Z'){
            last = i;
            break;
        }
    }
    cout << last - first + 1 << endl; 
}

Measured memory_bytes: 832
import java.util.*;
class Main{
  public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
	String s = stdIn.next();
    int ok=0;
    for(int i=0;i<s.length();i++){
      if(s.charAt(i)=='U'||s.charAt(i)=='D'){
        ok++;
      }
      if(i%2==0){
        if(s.charAt(i)=='R'){
          ok++;
        }
      }else{
        if(s.charAt(i)=='L'){
          ok++;
        }
      }
    }
    if(ok==s.length()){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}
        
        

Measured memory_bytes: 21844
#include<stdio.h>
int main()
{
  int h,a;
  scanf("%d%d", &h, &a);
  if(h<=a)
    printf("1\n");
  else{
  	if(h%a==0)
    	printf("%d\n", h/a);
  	else
    	printf("%d\n", h/a +1);
  }
  return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h" //template by Benq
using namespace std;

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

using pi = pair<int, int>;
using pl = pair<long long, long long>;
using pd = pair<long double, long double>;

using vi = vector<int>;
using vl = vector<long long>;
using vs = vector<string>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pair<long long, long long>>;
using vpd = vector<pair<double, double>>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<long long>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define si(s) ((int)(s).size())
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rs resize
#define ins insert
#define nl "\n"
#define trav(i, x) for(auto& i: x)

const long long INF = 1e18;
const long double PI = acos((long double)-1);
const long long MOD = 998244353;

template<class A> void re(complex<A>& c);
template<class A, class B> void re(pair<A, B>& p);
template<class A> void re(vector<A>& v);
template<class A, size_t SZ> void re(array<A, SZ>& a);
 
template<class T> void re(T& x) { cin >> x; }
void re(double& d) { string t; re(t); d = stod(t); }
void re(long double& d) { string t; re(t); d = stold(t); }
template<class H, class... T> void re(H& h, T&... t) { re(h); re(t...); }
 
template<class A> void re(complex<A>& c) { A a, b; re(a, b); c = {a, b}; }
template<class A, class B> void re(pair<A, B>& p) { re(p.first, p.second); }
template<class A> void re(vector<A>& x) { for(auto& i: x) re(i); }
template<class A, size_t SZ> void re(array<A, SZ>& x) { for(auto& i: x) re(i); }
 
void pr() {}
template <typename H, typename... T> 
void pr(H var1, T... var2) {
    cout << var1; 
    pr(var2...); 
}
void ps() { cout << nl; }
template<typename H, typename... T>
void ps(H var1, T... var2) {
	cout << var1 << ' ';
	ps(var2...);
}

void setIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a / (gcd(a, b)) * b); }
ll pow(ll a, ll b) { ll res = 1; while (b > 0) { if (b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res; }
void CowGoesMoo() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(20); }

char a;

int main() {
	CowGoesMoo();
	
	re(a);
	if(isupper(a)) {
		ps("A");
	} else {
		ps("a");
	}
}

Measured memory_bytes: 3620
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=998244353
from collections import deque
########################################################
n,x=INPUT()
A=[]
for i in range(n):
    A.append(int(input()))
A.sort()
print(n+(x-sum(A))//A[0])


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

using namespace std;
typedef long long lint;

int n, m, x, y, i;
int maxi = -0x3f3f3f3f, mini = 0x3f3f3f3f;

int main()
{
    cin >> n >> m >> x >> y;
    if(x > maxi)
        maxi = x;
    if(y < mini)
        mini = y;
    for(i = 1; i <= n; i ++)
    {
        cin >> x;
        if(x > maxi)
            maxi = x;
    }
    for(i = 1; i <= m; i ++)
    {
        cin >> x;
        if(x < mini)
            mini = x;
    }
    //cout << mini << ' ' << maxi << "\n";
    if(mini - maxi >= 1)
    cout << "No War";
    else cout << "War";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=0.0
p=input().rstrip().split(' ')
p.sort(key=int)
i=0;
while(i<len(p)):
    if i==0:
        A=int(p[i])
        B=int(p[i+1])
        F=(A+B)/2;
        i+=2;
    else:
        F=(F+int(p[i]))/2;
        i+=1;
print(F)
    


Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}





int main(){
  int a,b;
  cin>>a>>b;
  int c=b-a;
  int sum=0;
  for(int i=0;i<c;i++){
    sum+=i;
  }
  cout<<sum-a<<endl;







  





  



}


  

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,K = inputIL()

r = N%K

r2 = K-r

print(min(r,r2))

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

int main()
{
  ll N;
  scanf("%lld",&N);

  ll ans = 0;
  for (int i=1; i<=N; i++) {
    int t = floor(log10(i)+1);
    if (t%2 == 1) ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int ans[150][2][12];//二つ目の次元の0の0に数列の長さ、0の1に操作回数、1に答えの数列

int counter=0,flag=0;

void solve(){
	int n;
	cin >> n;
	if(n==0){flag=1;return;}
	ans[counter][0][0]=n;
	
	int S[12];//数列
	for(int i=0;i<n;i++){
		cin >> S[i];
	}
	
	bool check=false;//操作の有無のフラグ
	int time=0;//操作回数
	do{
		map<int,int> marker;
		for(int i=0;i<n;i++){
			marker[S[i]];
			marker[S[i]]++;
		}
		check=false;
		for(int i=0;i<n;i++){
			if(S[i]!=marker[S[i]]){
				check=true;
				S[i]=marker[S[i]];
			}
		}
		if(check) time++;
	}while(check);
	
	ans[counter][0][1]=time;
	for(int i=0;i<n;i++){
		ans[counter][1][i]=S[i];
	}
	counter++;
}

int main(){
	while(flag==0)solve();
	for(int i=0;i<counter;i++){
		cout << ans[i][0][1] << endl;
		for(int j=0;j<ans[i][0][0]-1;j++){
			cout << ans[i][1][j]<<" ";
		}
		cout << ans[i][1][ans[i][0][0]-1] << endl;
	}
}
			
	
	

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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int64_t solve() {
	int n = ri();
	int64_t base = 0;
	std::vector<int> first[n];
	std::vector<int> second[n];
	int first_cnt = 0;
	int second_cnt = 0;
	for (int i = 0; i < n; i++) {
		int k = ri();
		int l = ri();
		int r = ri();
		if (k == n || l == r) base += l;
		else if (l > r) {
			base += r;
			first[k].push_back(l - r);
			first_cnt++;
		} else {
			base += l;
			second[k].push_back(r - l);
			second_cnt++;
		}
	}
	int64_t r0 = 0;
	std::multiset<int> all;
	for (int i = n - 1; i >= 0; i--) {
		if (all.size() && i < first_cnt) r0 += *std::prev(all.end()), all.erase(std::prev(all.end()));
		for (auto j : first[i]) all.insert(j);
	}
	all.clear();
	int64_t r1 = 0;
	for (int i = 0; i < n; i++) {
		for (auto j : second[i]) all.insert(j);
		if (all.size() && i >= n - second_cnt) r1 += *std::prev(all.end()), all.erase(std::prev(all.end()));
	}
	return base + r0 + r1;
}

int main() {
	int t = ri();
	for (int i = 0; i < t; i++) printf("%" PRId64 "\n", solve());
	return 0;
}


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

public class Main{
	
	//0210 start
	//0308 sample matched
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			int d = sc.nextInt();
			if((n|d) == 0) break;
			ArrayList<ArrayList<Integer>> list = new ArrayList<ArrayList<Integer>>();
			int [] sum = new int[n];
			for(int i = 0 ; i< n; i++){
				int m = sc.nextInt();
				list.add(new ArrayList<Integer>());
				for(int j = 0; j < m; j++){
					int temp = sc.nextInt();
					sum[i] += temp;
					list.get(i).add(temp);
				}
			}
			
			while(true){
				int max = getmax(sum);
				int min = getmin(sum);
				int maxind = getmaxInd(sum);
				int secondmax = get2max(sum, max);
				boolean isremove = false;
				for(int i = 0; i < n; i++){
					if(list.get(i).size() == 0) continue;
					int now = sum[i] - list.get(i).get(list.get(i).size() - 1);
					int diff;
					if(i == maxind){
						diff = Math.max(now, secondmax) - Math.min(min, now);
					}
					else{
						diff = Math.max(now, max) - Math.min(min, now);
					}
					
					//System.out.println("diff = " + diff + " now = " + now + "maxind = " + maxind + "secondmax = " + secondmax);
					if(diff > d){
						continue;
					}
					sum[i] = now;
					list.get(i).remove(list.get(i).size() - 1);
					isremove = true;
					break;
				}
				if(! isremove){
					break;
				}
			}
			
			boolean ansflg = true;
			for(int i = 0; i < n; i++){
				if(list.get(i).size() != 0) ansflg = false;
			}
			System.out.println(ansflg ? "Yes" : "No");
		}
	}

	private int get2max(int[] sum, int max) {
		int res = 0;
		boolean flg = false;
		for(int i = 0; i < sum.length; i++){
			if(max == sum[i]){
				if(! flg){
					flg = true;
				}
				else{
					res = sum[i];
					return res;
				}
				
			}
			else{
				res = Math.max(res, sum[i]);
			}
			
		}
		return res;
	}

	private int getmin(int[] sum) {
		int res = sum[1];
		for(int i = 1; i < sum.length; i++){
			res = Math.min(res,  sum[i]);
		}
		return res;
	}

	private int getmax(int[] sum) {
		int res = sum[0];
		for(int i = 1; i < sum.length; i++){
			res = Math.max(res, sum[i]);
		}
		return res;
	}
	
	private int getmaxInd(int[] sum) {
		int res = sum[0];
		int ind = 0;
		for(int i = 1; i < sum.length; i++){
			if(res < sum[i]){
				res = sum[i];
				ind = i;
			}
			else if(res == sum[i]){
				ind = -1;
			}
		}
		return ind;
	}

	public static void main(String [] args){
		new Main().doit();
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a[50],b[50],c[50],d[50];
main()
{
	cin>>n>>m;
	for(int i=0;i<n;i++)cin>>a[i]>>b[i];
	for(int j=0;j<m;j++)cin>>c[j]>>d[j];
	for(int i=0;i<n;i++)
	{
		int s=1e9,k;
		for(int j=0;j<m;j++)
		{
			int t=abs(a[i]-c[j])+abs(b[i]-d[j]);
			if(s>t)s=t,k=j+1;
		}
		cout<<k<<endl;
	}
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		// N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
		cnt = 0;
		for (char c : str.toCharArray()) {
			if (c == 'x')
				cnt++;
		}
		if (cnt >= 8)
			System.out.println("NO");
		else
			System.out.println("YES");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


Measured memory_bytes: 21716
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// スペース区切りの整数の入力
		for(int i=1;i<6;i++){
          if(sc.nextInt()==0){
            System.out.println(i);
            break;
          }
        }
}
}

Measured memory_bytes: 35784
#include <iostream>
#include <vector>
#include <queue>
using namespace std;

using Graph = vector<vector<int>>;
using pint = pair<int,int>;

int N, M;
Graph G;
int s, t;

long long solve() {
    vector<vector<long long>> dist(N, vector<long long>(3, -1));
    dist[s][0] = 0;
    queue<pint> que;
    que.push({s, 0});
    while (!que.empty()) {
        pint cur = que.front(); que.pop();
        int v = cur.first;
        int parity = cur.second;
        for (auto nv : G[v]) {
            int np = (parity + 1) % 3;
            if (dist[nv][np] == -1) {
                dist[nv][np] = dist[v][parity] + 1;
                que.push({nv, np});
            }
        }
    }
    if (dist[t][0] == -1) return -1;
    else return dist[t][0] / 3;
}

int main() {
    cin >> N >> M;
    G.assign(N, vector<int>());
    for (int i = 0; i < M; ++i) {
        int u, v; cin >> u >> v; --u, --v;
        G[u].push_back(v);
    }
    cin >> s >> t;
    --s, --t;
    cout << solve() << endl;            
}

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

int main(){
    /* A
    int r;
    cin >> r;
    
    cout << 2*r*M_PI << endl;*/
    
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    for(int i=0;i<m;i++)cin >> a[i];

    int sum = 0;
    for(int i=0;i<m;i++)sum += a[i];
    if(n>=sum)cout << n-sum <<endl;
    else cout << "-1" << endl;

    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define out(ans) cout << ans << endl;
const long long mod = 1e9 + 7;

int main(){

  string o,e;cin>>o>>e;

  int oLen=o.size(),eLen=e.size();

  if(oLen==eLen){
    rep(i,o.size()){
      cout<<o[i]<<e[i];
    }
  }else{
    rep(i,e.size()){
      cout<<o[i]<<e[i];
    }
    cout<<o[o.size()-1];
  }
  cout<<endl;

  return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
s=[0]*m
for i in range(m):
  s[i]=list(map(int,input().split()))
  del s[i][0]
p=list(map(int,input().split()))
count=0
for i in range(2**n):
  for k in range(m):
    temp=0
    for j in range(n):
      if ((i >> j) & 1) and j+1 in s[k]:
        temp=temp+1
    if temp%2!=p[k]:
      break
  else:
    count=count+1
print(count)

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")

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

typedef unsigned long long int ull;
typedef long long ll;
#define pb push_back

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //your code starts here
    int n;
    cin >> n;
    ll diff[4][n];
    for (int i = 0; i < n; i++)
    {
        ll x, y;
        cin >> x >> y;
        diff[0][i] = x + y;
        diff[1][i] = x - y;
        diff[2][i] = -diff[1][i];
        diff[3][i] = -diff[0][i];
    }
    for (int i = 0; i < 4; i++)
        sort(diff[i], diff[i] + n);
    ll ans = INT_MIN;
    for (int i = 0; i < 4; i++)
        ans = max(ans, diff[i][n - 1] - diff[i][0]);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 9832
using System;
using System.Collections.Generic;

namespace abc166
{
    class Program
    {
        static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var aStrList = Console.ReadLine().Split(' ');
            var a = new int[n];
            for (var i = 0; i < a.Length; ++i)
            {
                a[i] = int.Parse(aStrList[i]);
            }
            var iaTable = new Dictionary<int, long>();
            for (var i = 0; i < a.Length; ++i)
            {
                var ia = i + a[i];
                if (iaTable.ContainsKey(ia))
                {
                    ++iaTable[ia];
                }
                else
                {
                    iaTable.Add(ia, 1);
                }
            }
            var jaTable = new Dictionary<int, long>();
            for (var j = 0; j < a.Length; ++j)
            {
                var ja = j - a[j];
                if (jaTable.ContainsKey(ja))
                {
                    ++jaTable[ja];
                }
                else
                {
                    jaTable.Add(ja, 1);
                }
            }
            var total = 0L;
            foreach (var key in iaTable.Keys)
            {
                if (jaTable.ContainsKey(key))
                {
                    total += iaTable[key] * jaTable[key];
                }
            }
            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 60500
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) throws Exception{
		
		Scanner sc = new Scanner(System.in);
		
 
		int N = sc.nextInt();
		int L = sc.nextInt();
		
		String[] S = new String[N];
		for(int i=0; i<N; i++){
			S[i] = sc.next();
		}
		
		Arrays.sort(S);
		
		for(int i=0; i<N; i++){
			System.out.print(S[i]);
		}
		System.out.println();
 
		sc.close();
	}
}

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  cin >> n >> k;
  // n-k*n/k
  int ans = 0;
  reps(i, k+1, n+1) {
    ans += n/i*(i-k);
    if(n-n/i*i-k+1 > 0) ans += n-n/i*i-k+1;
  }
  if(k == 0) ans -= n;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
typedef long long ll;
int main()
{
	ll a,b,c,k;
	cin>>a>>b>>c;
	cin>>k;int f1=0,f2=0;
	while(b<=a && k>0)
	{
		b*=2;k--;
	}
	if(b>a)f1=1;
	while(c<=b && k>0)
	{
		c*=2;k--;
	}
	if(c>b)f2=1;
	if(f1>0 && f2>0){cout<<"Yes"<<endl;return 0;}
	cout<<"No"<<endl;
}

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

namespace ConsoleApplication40
{
    class Program
    {
        static void Main()
        {
            while (true)
            {
                string a = Console.ReadLine();
                if (a == null) break;
                int[] b = a.Split().Select(int.Parse).ToArray();
                int c = 21 -b [0] -b [1];int r = 0;
                for(int q = 1; q < 11; q++)
                {
                    if (q == b[0] || q == a[1] || q == a[2]) continue;
                    if (q < c) r++;
                }
                if (r > 3) Console.WriteLine("YES");
                else Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 9208
import java.util.Scanner;

/**
 * https://abc042.contest.atcoder.jp/tasks/arc058_a
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		int[] d = new int[K];
		for(int i=0; i<K; i++) d[i] = sc.nextInt();
		sc.close();
		
		int ans = N;
		while(true){
			boolean check = true;
			String tmp = String.valueOf(ans);
			for(int i=0; i<K; i++){
				if(tmp.contains(String.valueOf(d[i]))){
					check = false;
					break;
				}
			}
			if(check){
				break;
			}
			ans++;
		}
		System.out.println(ans);

	}

}


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

#ifdef LOCAL
#include "contest.h"
#else
#define dump(x) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    int N;
    cin >> N;
    vector<int> L(2*N);
    REP(i, 2*N) cin >> L[i];
    sort(L.begin(), L.end());
    int ans = 0;
    REP(i, 2*N) {
        if(i % 2 == 0) {
            ans += L[i];
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll>PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;
int main() {
    string s;
    cin >> s;
    set<char> st;
    rep(i, s.length()) {
        st.insert(s[i]);
    }
    if ( st.count('W') != 0 && st.count('E') == 0 || 
         st.count('W') == 0 && st.count('E') != 0 ||
         st.count('N') != 0 && st.count('S') == 0 ||
         st.count('N') == 0 && st.count('S') != 0 ) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
fn main() {
    input! {//
        n:usize,
        mut a:[i64;n],
    }
    // gre?
    let mut ans = 0;
    let mut prev = 0;
    for i in 0..n {
        if (a[i] + prev) < 2 {
            prev = 0;
            continue;
        }
        if (a[i] + prev) % 2 == 1 {
            ans += (a[i] + prev) / 2;
            prev = 1;
        } else {
            ans += (a[i] + prev) / 2;
            prev = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 3680
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

#define x first
#define y second


int main() {
    int n,k;
    while(cin>>n>>k){
        if(n==0 && k==0)break;
        int num[200000]={};
        rep(i,n) cin>>num[i];
        
        int now=0;
        rep(i,k){
            now+=num[i];
        }
        int maxi=-1;
        for(int i=1;i<n-k+1;i++){
            now-=num[i-1];
            now+=num[i+k-1];
            maxi=max(now,maxi);
        }
        cout<<maxi<<endl;
    }
    
    return 0;
}

        
        

Measured memory_bytes: 1944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var d = new int[N];
            for (var i = 1; i <= N; i++)
            {
                d[i-1] = i;
            }

            var jyunretsus = GetPermutation(d);

            var p = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var q = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();


            var a = 0;
            var b = 0;
            var cnt = 0;

            foreach(int[] jyunretsu in jyunretsus)
            {
                if (a == 0)
                {
                    bool isEqual = true;

                    for (int i = 0; i < jyunretsu.Length; i++)
                    {
                        if (!jyunretsu[i].Equals(p[i]))
                        {
                            isEqual = false;
                            break;
                        }
                    }

                    if (isEqual) a = cnt + 1;
                }

                if(b == 0)
                {
                    bool isEqual = true;

                    for (int i = 0; i < jyunretsu.Length; i++)
                    {
                        if (!jyunretsu[i].Equals(q[i]))
                        {
                            isEqual = false;
                            break;
                        }
                    }

                    if (isEqual) b = cnt + 1;
                }


                cnt++;
            }

            Console.WriteLine(Math.Abs(a - b));
        }

        public static IEnumerable<T[]> GetPermutation<T>(IEnumerable<T> collection)
        {
            // 未確定要素が一個のみ
            if (collection.Count() == 1)
            {
                yield return new T[] { collection.First() };
            }

            foreach (var item in collection)
            {
                var selected = new T[] { item };
                var unused = collection.Except(selected);

                // 確定した要素以外の組み合わせを再帰で取り出し連結
                foreach (var rightside in GetPermutation(unused))
                {
                    yield return selected.Concat(rightside).ToArray();
                }
            }
        }
    }
}

Measured memory_bytes: 47356
<?php
  
 fscanf(STDIN,"%d",$N);

$S_list = array();

for($i=0;$i<$N;$i++){
  $S_list[] = trim(fgets(STDIN));
}


$moji_count = array();

foreach($S_list as $key => $value){
  $moji_count[$value]++;
}


arsort($moji_count);

$max_list = array();

$max = 0;

foreach($moji_count as $key=>$count){
  if($count>=$max){
  	$max_list[] = $key;
      $max = $count;
	}
}

sort($max_list);

foreach($max_list as $value){
  echo $value."\n";
}



  



                  
                  
                  



Measured memory_bytes: 37360
#include <iostream>
#include <istream>
#include <ostream>
#include <algorithm>
#include <cmath>

using namespace std;

template <class T>
class Vector2D
{
public:
	T x, y;
	Vector2D ( void ): x(0), y(0) {}
	Vector2D ( T v ): x(v), y(v) {}
	Vector2D ( T ix, T iy ): x(ix), y(iy) {}
	Vector2D ( const Vector2D<T> &v ): x(v.x), y(v.y) {}
	T length ( void ) { return sqrt(x*x + y*y); }
	T lengthSq ( void ) { return x*x + y*y; }
	T dot ( Vector2D<T> v ) { return (x * v.x) + (y * v.y); }
	T cross ( Vector2D<T> v ) { return (x * v.y) - (y * v.x); }
	Vector2D operator+ ( const Vector2D<T> &v ) { Vector2D t(*this); t.x += v.x; t.y += v.y; return t; }
	Vector2D operator+=( const Vector2D<T> &v ) { x += v.x; y += v.y; return *this; }
	Vector2D operator- ( const Vector2D<T> &v ) { Vector2D t(*this); t.x -= v.x; t.y -= v.y; return t; }
	Vector2D operator-=( const Vector2D<T> &v ) { x -= v.x; y -= v.y; return *this; }
	Vector2D operator* ( const T &k ) { Vector2D t(*this); t.x *= k; t.y *= k; return t; }
	Vector2D operator*=( const T &k ) { x *= k; y *= k; return *this; }

	friend std::istream& operator>>( std::istream &is, Vector2D<T> &v ) { if (is >> v.x) { is >> v.y; } return is; }
	friend std::ostream& operator<<( std::ostream &os, Vector2D<T> &v ) { os << v.x << " " << v.y; return os; }
};

const double EPS = 1e-5;

int main ( void )
{
	Vector2D<double> v1, v2, v3, v4;

	while (cin >> v1 >> v2 >> v3 >> v4) {
		Vector2D<double> t, p;
		double a;
		a = (t = v2 - v1).dot(p = v4 - v3);

		if (abs(a) <= EPS) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1216
import * as fs from 'fs';

//in
// 3 3
// 1 7
// 3 2
// 1 7
//out
// 702
const main = (inp: string) => {
    let inpArray: string[] = inp.split('\n');
    const [n, m]: number[] = inpArray[0].split(' ').map(Number);
    inpArray.shift();

    // if (m === 0 && n===1) {
    //     // console.log(0);
    //     // return;
    // }

    for (let i: number = 0; i < 1000; i++) {

        if (n != i.toString().length)
            continue;

        let ok: boolean = true;

        for (let j: number = 0; j < m; j++) {
            const [s, c]: number[] = inpArray[j].split(' ').map(Number);

            if (n < s) {
                console.log(-1);
                return;
            }

            if (i.toString().length < s)
                break;

//            console.log(`${parseInt(i.toString()[0])}  ${parseInt(i.toString()[1])}  ${parseInt(i.toString()[2])}`);
            if (s === 1) {
                if (parseInt(i.toString()[0]) !== c) {
                    ok = false;
                }
            }

            if (s === 2) {
                if (parseInt(i.toString()[1]) !== c) {
                    ok = false;
                }
            }

            if (s === 3) {
                if (parseInt(i.toString()[2]) !== c) {
                    ok = false;
                }
            }

        }

        if (ok) {
            console.log(i.toString());
            return;
        }

    }
    console.log(-1);
};

main(fs.readFileSync('/dev/stdin', 'utf8').trim());


Measured memory_bytes: 8080
/*     ####   ####  #               ####  #        ##   #    # #    # ###### #####
      #      #    # #              #      #       #  #  ##  ## ##  ## #      #    #
       ####  #    # #               ####  #      #    # # ## # # ## # #####  #    #
           # #  # # #                   # #      ###### #    # #    # #      #####
      #    # #   #  #              #    # #      #    # #    # #    # #      #   #
       ####   ### # ###### #######  ####  ###### #    # #    # #    # ###### #    #
*/

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

typedef long long int LLi;
typedef long long LL;
typedef vector<LLi> VLL;
typedef vector<string> VS;
typedef vector<pair<LLi, LLi> > VP;


#define For(in) for (LLi i = 0; i < (n); i++)
#define FOR(in) for(LLi i=1; i <= (n); i++)
#define pb push_back
#define sr(v) sort(v.begin(), v.end())
#define rev(v) reverse(v.begin(), v.end())
#define uniq(v) v.erase(unique(v.begin(), v.end()), v.end());
#define exit(); return 0;
#define no "NO"
#define yes "YES"
#define con continue;

LLi max_3(LLi a, LLi b, LLi c)
{
    return max(a,max(b,c));
}
LLi min_3(LLi a, LLi b, LLi c)
{
    return min(a,min(b,c));
}

LLi concate(LLi a, LLi b)
{
    ostringstream os;
    os <<a <<b;
    istringstream is(os.str());
    LLi c;
    is>> c;
    return c;
}


LLi check(char c)
{
    return c=='a' || c=='e' || c=='i' || c=='o' || c=='u';
}

main()
{
    LLi q,t;
//    cin>>t;
 //   while(t--)
   // {
        LLi a=0,b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,r=0,u=0,w=0,x=0,y=0,z=0;
        LLi aa[1000];
        LLi flag=0, flag1=0, co=0, co1=0, co2=0, co3=0, x1=0, x2=0, y1=0, y2=0, z1=0, z2=0;
        LLi ma=0, mi=100000000;
        LLi mid=0, temp=0, stop=0, start=0;
        double pi= 3.141592653589793;
        double d1=0.0, d2, d3, d4;
        VLL v,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10;
        VS vs, vs1, vs2, vs3, vs4;
        VP vp, vp1,vp2;
        char ch, ch1, ch2[1001];
        string str, str1, str2, str3, str4, str5;
        pair<LLi, LLi> pa;
//        list<LLi> li, li1;
  //      map<LLi, LLi> mp, mp1;
        set<LLi> st;
    //    map<LLi ,LLi> :: iterator imll;
        VLL :: iterator ivll;
        set<LLi> :: iterator isll;
        VP :: iterator ivp;

        cin>>n>>k;
        for(i=0; i<n; i++)
        {
            cin>>a;
            v.pb(a);
        }
        sr(v);
        for(i=0; i<k; i++)
        {
            co+=v[i];
        }
        cout<<co<<endl;


 //    }

    exit()


}


Measured memory_bytes: 3596
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int ans=0;
    rep(i,0,1){
        if(a>b){ans += a; a-=1;}
        else{ans += b; b-=1;}
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 888