akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    n = II()
    a = LI()
    a.sort()
    x = list(set(a))
    if len(x) > 3:
        print("No")
    elif len(x) == 3:
        x1 = bisect_right(a, x[0]) - bisect_left(a, x[0])
        x2 = bisect_right(a, x[1]) - bisect_left(a, x[1])
        x3 = bisect_right(a, x[2]) - bisect_left(a, x[2])
        if ((x[0] ^ x[1] ^ x[2]) == 0) and (x1 == x2 == x3):
            print("Yes")
        else:
            print("No")
    elif len(x) == 2:
        x1 = bisect_right(a, x[0]) - bisect_left(a, x[0])
        x2 = bisect_right(a, x[1]) - bisect_left(a, x[1])
        if x1 * 2 == x2:
            print("Yes")
        else:
            print("No")
    elif len(x) == 1:
        if x[0] == 0:
            print("Yes")
        else:
            print("No")
    return

#B
def B():
    n, m = LI()
    if m % 2:
        print(-1)
        return
    edg = [[] for _ in range(n)]
    ins = defaultdict(int)
    c = defaultdict(int)
    for _ in range(m):
        a, b = LI_()
        edg[a].append(b)
        edg[b].append(a)
        ins[a] += 1
        ins[b] += 1
    dag = [[] for _ in range(n)]
    q = deque()
    q.append((0, -1))
    for i in edg[0]:
        q.append((i, 0))
    while q:
        now, per = q.pop()
        if per == -1:
            continue
        if c[now]:
            pass
        
    for d in dag:
        if len(d) % 2:
            print(-1)
            return
    for num, d in enumerate(dag):
        for x in d:
            print(num + 1, x + 1)
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()


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


int main(){
    int n;
    cin>>n;
    vector<int> v;
    for(int i = 0; i < n; ++i){
        int tmp;
        cin>>tmp;
        v.push_back(tmp);
    }

    sort(v.begin(), v.end());
    if(n==2)
    {
        cout<<v[1]<< " "<<v[0];
        cout<<endl;
        return 0;
    }

        int i=0;
        int mx=v[n-1];
        int mm=(mx+1)/2;
        int ans1=(int)1e9;
  		int ans2=(int)1e9;
        v.pop_back();
        while(i<v.size()&&v[i]<=mm){
            ans1=v[i];
            ++i;
        }
  		i=v.size()-1;
        while(i>=0&&v[i]>=mm){
                  ans2=v[i];
                  --i;
              }
	int ans=ans2;
  	if(mm-ans1<ans2-mm)
      ans=ans1;

    cout<<mx<< " "<<ans;
    cout<<endl;


    return 0;
    
}

Measured memory_bytes: 892
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long sum = 0;
    for (int i = 1; i <= n;i++){
        if(!(i%3==0)&&!(i%5==0))
            sum += i;
    }
    cout << sum;
    return 0;
}

Measured memory_bytes: 3500
II = lambda: int(input())
SI = lambda: input()
LI = lambda: list(map(int,input().split()))
MI = lambda: map(int,input().split())
n,m = MI()
dp = [0]*(m+1)
for i in range(n):
	w,v = MI()
	for j in range(m,w-1,-1):
		dp[j] = max(dp[j-w]+v,dp[j])
print(dp[m])

Measured memory_bytes: 67460
#include<stdio.h>
#include<string.h>
#include<ctype.h>

int main (void)
{
	char str[1000],com[10],p[1000],temp[1000];
	int com_num,i,a,b,j,k,temp_count;
	
	scanf("%s",str);
	scanf("%d",&com_num);
	
	for(i = 0 ; i < com_num ; i++)
	{
		temp_count = 0;
		scanf("%s %d %d",com,&a,&b);
		if(strcmp(com,"replace") == 0)
		{
			scanf("%s",p);
		}
		if(strcmp(com,"print") == 0)
		{
			for(j = a ; j <= b ; j++)
			{
				if(j != b)
				{
					printf("%c",str[j]);
				}
				else
				{
					printf("%c\n",str[j]);
				}
			}
		}
		else if(strcmp(com,"reverse") == 0)
		{
			for(j = a ; j <= b ; j++)
			{
				temp[temp_count] = str[j];
				temp_count++;
			}
			for(j = a ; j <= b ; j++)
			{
				str[j] = temp[temp_count - 1];
				temp_count--;
			}
			for(j = 0 ; j < 1000 ; j++)
			{
				temp[j] = '\0';
			}
		}
		else if(strcmp(com,"replace") == 0)
		{
			for(j = a ; j <= b ; j++)
			{
				str[j] = p[temp_count];
				temp_count++;
			}
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 2144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    string s;
    cin >> s;
    if(s.back()=='1'||s.front()=='0'){
        cout << -1 << endl;
        return 0;
    }
    int n = s.size();
    string t = s.substr(0,n-1);
    if(t!=string(t.rbegin(),t.rend())){
        cout << -1 << endl;
        return 0;
    }
    vector<P> ans={P(0,1)};
    int id=1;
    for(int i=2;i<n;i++){
        if(s[i-1]=='1'){
            ans.push_back(P(id,i));
            id=i;
        }
        else{
            ans.push_back(P(id,i));
        }
    }
    rep(i,n-1){
        cout << ans[i].first+1 << " " << ans[i].second+1 << endl;
    }
    return 0;
}

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

vector<int> arr(200007);

int main()
{
  string s;
  cin>>s;
  for(int a=0;a<s.length();a++){
    string x="";
    x=s[a];
    arr[a]=stoi(x);
  }
  int sum=0;
  sum=accumulate(arr.begin(),arr.end(),sum);
  if(sum%9)
    printf("No");
  else
    printf("Yes");
}

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

int main(){
  int n,k,q; cin >>n>>k>>q; vector<int>a(n);
  for(int i=0; i<q; i++)
  {int x; cin >>x; a[x-1]++;}
  for(int i=0; i<n; i++)
  {
    if(a[i]>q-k){cout <<"Yes"<<endl;}
    else{cout <<"No"<<endl;}
  }

return 0;
}

Measured memory_bytes: 1024
def getlist():
	return list(map(int, input().split()))

N, K = getlist()
K -= 1
S = input()
if S[K] == "A":
	print(S[:K] + "a" + S[K + 1:])
elif S[K] == "B":
	print(S[:K] + "b" + S[K + 1:])
else:
	print(S[:K] + "c" + S[K + 1:])

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

int main(){
    int m,d;
    cin>>m>>d;
    int ans=0;
    for(int i=1;i<=m;i++){
        for(int j=10;j<=d;j++){
            int d1=j/10,d2=j%10;
            if(d1>=2&&d2>=2&&d1*d2==i) ans++;
        }
    }
    cout<<ans<<endl;
}


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

c_dict = {}
for _ in range(N):
    s = input()
    if s in c_dict.keys():
        c_dict[s]+=1
    else:
        c_dict[s]=1

keys = ["AC", "WA", "TLE", "RE"]
for key in keys:
    if not key in c_dict.keys():
        print("%s x 0"%(key))
    else:
        print("%s x %d"%(key, c_dict[key]))



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

int main(){
  int n;
  cin>>n;
  vector<int> p(n);
  for(int i=0;i<n;i++)cin>>p[i];
  map<int,int> mp;
  int ans=0;
  for(int i=0;i<n;i++){
    mp[p[i]]=mp[p[i]-1]+1;
    ans=max(ans,mp[p[i]]);
  }
  cout<<n-ans<<endl;
}


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

#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n"
#define ll long long
#define uint unsigned int
#define ushort unsigned short
#define ulong unsigned long

ll MOD = 10e9 + 7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    REP(i, n) cin >> a[i];
    bool ok = true;
    for(int i=1; i<n; i++) {
        if (a[i] > a[i-1]) {
            a[i]--;
        } else if (a[i] < a[i-1]) {
            ok = false;
        }
    }
    printf("%s\n", ok?"Yes":"No");
    return 0;
}



Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
long long  a;
cin >> a;
long long count = 0;
long long  y = 100;
while(true){
y = floor(y*1.01);
count++;

if(y >= a){
	cout << count << endl;
	return 0;
}
}
}

Measured memory_bytes: 3744
n = int(input())
u = [list(map(int,input().split())) for _ in range(n)]
ts = [[0,0] for _ in range(n)]
time = 0

def dfs(i):
  global time
  ts[i][0] = time
  for j in range(u[i][1]):
    a = u[i][j+2]-1
    if ts[a][0] == 0:
      time += 1
      dfs(a)
  time += 1
  ts[i][1] = time
  
for i in range(n):
  if ts[i][0] == 0:
    time += 1
    dfs(i)
  
for i in range(n):
  print(i+1, ts[i][0], ts[i][1])


Measured memory_bytes: 5652
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
N = int(stdin.readline())
nums = tuple(li())
total = 0
for n in nums:
    while n % 2 == 0:
        total += 1
        n = n / 2
print(total)


Measured memory_bytes: 4084
package main

import (
	"fmt"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)

	if len(a) < len(b) {
		fmt.Println("LESS")
		return
	}
	if len(b) < len(a) {
		fmt.Println("GREATER")
		return
	}
	for i := 0; i < len(a); i++ {
		if a[i] < b[i] {
			fmt.Println("LESS")
			return
		}
		if b[i] < a[i] {
			fmt.Println("GREATER")
			return
		}
	}
	fmt.Println("EQUAL")
}


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

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define MAXR 100000
#define _GLIBCXX_DEBUG

int threemax(int a, int b, int c) {
	if (a >= b && a >= c) {
		return a;
	}
	else if (b >= a && b >= c) {
		return b;
	}
	else {
		return c;
	}
}

int threemin(int a, int b, int c) {
	if (a <= b && a <= c) {
		return a;
	}
	else if (b <= a && b <= c) {
		return b;
	}
	else {
		return c;
	}
}

void chmaxl(ll &a,ll b){
	if(a<b){
		a=b;
	}
	return;
}

void chminl(ll &a,ll b){
	if(a>b){
		a=b;
	}
	return;
}

void chmaxi(int &a,int b){
	if(a<b){
		a=b;
	}
	return;
}

void chmini(int &a,int b){
	if(a>b){
		a = b;
	}
	return;
}



int main() {
  int K;
  string S;
  cin >> K >> S;
  if(S.size()<=K){
    cout << S;
  }
  else{
    for(int i=0;i<K;i++){
      cout << S.at(i);
    }
    cout << "...";
  }
}

Measured memory_bytes: 3628
#include <stdio.h>

int main(void);

int main(void)
{
    int n, i, j, num, ln;
    char mark;
    int cards[4][14];//絵柄と数字の組を入れる配列

    for(i = 0; i < 4; i++){//52枚のカードを配列に入れる
        for(j = 0; j < 14; j++){
            cards[i][j] = 0;
        }
    }

    scanf("%d", &n);//太郎が持っているカードの枚数を読み込む
    for(i = 0; i < n; i++){
        scanf("%c", &ln);//前の行の改行を読み込む
        scanf("%c %d", &mark, &num);//i行目の絵柄と数字の組を読み込む
        if(mark == 'S'){//読み込んだ絵柄がSだったとき、配列cardsに入れ、1を代入する
            cards[0][num] = 1;
        }
        else if(mark == 'H'){
            cards[1][num] = 1;
        }
        else if(mark == 'C'){
            cards[2][num] = 1;
        }
        else if(mark == 'D'){
            cards[3][num] = 1;
        }
    }

    for(j = 1; j < 14; j++){
        if(cards[0][j] != 1){//配列cardsが1でないということは読み込まれていないカードの組
        printf("S %d\n", j);
        }
    }
    for(j = 1; j < 14; j++){
        if(cards[1][j] != 1){
        printf("H %d\n", j);
        }
    }
    for(j = 1; j < 14; j++){
        if(cards[2][j] != 1){
        printf("C %d\n", j);
        }
    }
    for(j = 1; j < 14; j++){
        if(cards[3][j] != 1){
        printf("D %d\n", j);
        }
    }
    return(0);
}


Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    string s;
    cin >> s;
    if (s.back() == '1' || s.front() == '0') {
        cout << -1 << endl;
        return 0;
    }

    int n = SZ(s) - 1;
    REP(i, n / 2) {
        if (s[i] != s[n - i - 1]) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    vi a;
    REP(i, n / 2 + (n % 2)) if (s[i] == '1') a.pb(i + 1);
    a.pb(n + 1);

    vector<pii> ans;
    REPF(i, 1, SZ(a)) {
        ans.pb({a[i - 1], a[i]});
        int r = a[i] - a[i - 1] - 1;
        int v = a[i - 1] + 1;
        REP(j, r) {
            ans.pb({a[i], v});
            v++;
        }
    }

    assert(SZ(ans) == n);
    REP(i, SZ(ans)) {
        cout << ans[i].first << " " << ans[i].second << endl;
    }
    return (0^_^0);
}



Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios::sync_with_stdio(false);
    	cin.tie(0);
	long long N,K,a,b,now;
	now=0;
	cin>>N>>K;
	vector<pair<int,int>> v(N);
	for(long long i=0;i<N;i++){
		cin>>v[i].first>>v[i].second;
	}
	sort(v.begin(),v.end());
	for(long long i=0;i<N;i++){
		now+=v[i].second;
		if(now>=K){
			cout<<v[i].first<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 1024
S = input()
SL = list(S+(" "*10))
SS = list("AKIHABARA")
if len(S)>=10 or S.replace("A","")!="KIHBR":
  print("NO")
else:
  for i in range(len(SS)):
    if SL[i]!=SS[i]:
      SL.insert(i,"A")
  if SL[0:len(SS)]==SS:
    print("YES")
  else:
    print("NO")

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

#define M 1046527
string Hash[M];
long long key, hash_Num;

int h1(long long key){ return key % M; }
int h2(long long key){ return 1 + key % (M - 1); }

int get_Char(char ch){
    if(ch == 'A') return 1;
    else if(ch == 'B') return 2;
    else if(ch == 'C') return 3;
    else if(ch == 'D') return 4;
    else return 0;
}


long long get_Key(string str){
    long long sum = 0, p = 1;
    for(int i = 0; i < str.size(); i++){
        sum += p * (get_Char(str[i]));
        p *= 5;
    }
    return sum;
}


void str_Insert(string str){
    key = get_Key(str);
    for(int i = 0; ; i++){
        hash_Num = ( h1(key) + i * h2(key) ) % M;
        if(Hash[hash_Num] == str) return;
        else if( Hash[hash_Num].size() == 0){
            Hash[hash_Num] = str;
            return;
        }
    }
    return;
}


int str_Find(string str){
    key = get_Key(str);
    for(int i = 0; ; i++){
        hash_Num = ( h1(key) + i * h2(key) ) % M;
        if(Hash[hash_Num] == str) return 1;
        else if( Hash[hash_Num].size() == 0) return 0;
    }
    return 0;
}


int main(void){
    
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        string str, job;
        cin >> job >> str;
        
        if(job[0] == 'i'){ str_Insert(str); }
        
        else{
            if(str_Find(str)){ cout << "yes" << endl; }
            else{ cout << "no" << endl; }
        }
    }
    
    
}



Measured memory_bytes: 27392
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, x = mapint()
As = list(mapint())

last = As[0]
ans = 0
for i in range(1, N):
    a = As[i]
    if last+a>x:
        diff = (last+a)-x
        ans += diff
        last = max(0, a-diff)
    else:
        last = a
print(ans)

Measured memory_bytes: 87576
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

    int x[n][3];
    rep(i, n) {
        rep(j, 3) {
            int X;
            cin >> X;
            x[i][j] = X;
        }
    }

    vector<vector<int>> dp(n+1, vector<int>(3));

    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if(k == j) {
                    continue;
                }
                dp[i+1][j] = max(dp[i+1][j], dp[i][k] + x[i][j]);
            }
        }
    }

    int ans = 0;
    rep(j, 3) {
        ans = max(ans, dp[n][j]);
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6912
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>

#define rep(i,a,b) for(int (i) = (a) ; (i) < (b) ; (i) ++)
#define scin(a) scanf("%d",&a);
#define scdo(a) scanf("%lf",&a);
#define scch(a) scanf("%s",a);
#define anin(a) printf("%d\n",a);
#define ando(a) printf("%lf\n",a);
#define anch(a) printf("%s\n",a);

int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(void){
	int N,M;
	scin(N)
	scin(M)
	anin((M + N * 3) / 2)
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll arr[200005];

int main()
{
	boost
	ll i,n,sum=0,cnt1=0,cnt2=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>arr[i];
		sum+=abs(arr[i]);
		if(arr[i]<0)
			cnt1++;
		else if(arr[i]>0)
			cnt2++;
	}
	sort(arr,arr+n);
	if(n==2)
	{
		if(arr[0]-arr[1]>arr[1]-arr[0])
		{
			cout<<arr[0]-arr[1]<<"\n";
			cout<<arr[0]<<" "<<arr[1]<<"\n";
		}
		else
		{
			cout<<arr[1]-arr[0]<<"\n";
			cout<<arr[1]<<" "<<arr[0]<<"\n";	
		}
	}
	else if(cnt1==n)
	{
		cout<<sum-2<<"\n";
		cout<<arr[n-1]<<" "<<arr[0]<<"\n";
		arr[n-1]-=arr[0];
		for(i=1;i<n-1;i++)
		{
			cout<<arr[n-1]<<" "<<arr[i]<<"\n";
			arr[n-1]-=arr[i];	
		}
	}
	else if(cnt2==n)
	{
		cout<<sum-2<<"\n";
		cout<<arr[0]<<" "<<arr[1]<<"\n";
		arr[0]-=arr[1];
		for(i=2;i<n-1;i++)
		{
			if(arr[i]>=0)
			{
				cout<<arr[0]<<" "<<arr[i]<<"\n";
				arr[0]-=arr[i];
			}
		}
		cout<<arr[n-1]<<" "<<arr[0]<<"\n";
	}
	else
	{
		cout<<sum<<"\n";
		for(i=1;i<n-1;i++)
		{
			if(arr[i]>=0)
			{
				cout<<arr[0]<<" "<<arr[i]<<"\n";
				arr[0]-=arr[i];
			}
		}
		for(i=0;i<n;i++)
		{
			if(arr[i]<0)
			{
				cout<<arr[n-1]<<" "<<arr[i]<<"\n";
				arr[n-1]-=arr[i];
			}
		}
	}
	return 0;
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool chmax(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF 1000000007 //4000000000000000037
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;



void Main(){

  int N;
  cin>>N;

  bool f[N][10];

  rep(i,N){
    rep(j,10){
      cin>>f[i][j];
    }
  }

  int p[N][11];

  rep(i,N){
    rep(j,11){
      cin>>p[i][j];
    }
  }

  ll ans=-INF;

  reps(i,1,1024){
    int now=i;
    ll buff=0;
    int dopen[N]={};
    rep(j,10){ //時間
      bool openst=now>>j&1;
      rep(k,N){ //k店舗目
        if(openst and f[k][j]) ++dopen[k];
      }
    }
    rep(j,N){
      buff+=p[j][dopen[j]];
    }
    chmax(ans,buff);
  }

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


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

int main(){
	typedef long long ll;
	string alp = "zabcdefghijklmnopqrstuvwxyz";
	vector<char>res;
	string s;
	ll n;
	cin >> n;
	while(n>0){
		res.push_back(alp[n%26]);
		if(n%26==0)n--;
		n/=26;
	}
	for(ll i = (res.size()-1);i>=0;i--){
		s+=res[i];
	}
	cout << s;
}

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

int main() {
  string S;
  cin >> S;
  int x = stoi(S.substr(0, 2));
  int y = stoi(S.substr(2));
  string ans;
  if (1 <= x && x <= 12 && 1 <= y && y <= 12) ans = "AMBIGUOUS";
  else if (1 <= x && x <= 12) ans = "MMYY";
  else if (1 <= y && y <= 12) ans = "YYMM";
  else ans = "NA";
  cout << ans << "\n";
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> p) {
    os << p.first << ":" << p.second;
    return os;
}

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

template<class T1, class T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "[";
    for (auto it = mp.begin(); it != mp.end(); ++it) {
        if (it != mp.begin()) {
            os << ", ";
        }
        os << *it;
    }
    return os << "]";
}

// edit

void solve() {
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);

    ll dec = min(X / D, K);
    X -= dec * D;
    K -= dec;
    if (K % 2 == 0) {
        cout << X << endl;
    } else {
        X = abs(X - D);
        cout << X << endl;
    }


}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}


Measured memory_bytes: 3192
#define NODE 0
#define WEIGHT 1
#define COST_IDX 0
#define TIME_IDX 1
#define P_IDX 0
#define Q_IDX 1
#define R_IDX 2
#include <iostream>
#include <cstring>
using namespace std;

int n, m, k;
int weights[101][101][2];
int min_w[101][101][2];
int requests[200][3];

bool read_input() {
  cin >> n >> m;
  if (n*m == 0) 
    return false;
  memset(weights, 0, sizeof(int)*101*101*2);
  memset(min_w, 0, sizeof(int)*101*101*2);
  for (int i = 0; i < n; i++) {
    int a, b, c, t;
    cin >> a >> b >> c >> t;
    weights[a][b][COST_IDX] = weights[b][a][COST_IDX] = c;
    weights[a][b][TIME_IDX] = weights[b][a][TIME_IDX] = t;
  }
  cin >> k;
  for (int i = 0; i < k; i++) {
    cin >> requests[i][P_IDX] >> requests[i][Q_IDX] >> requests[i][R_IDX];
  }
  return true;
}

int resolve_request(int i_th) {
  int p, q, r;
  p = requests[i_th][P_IDX];
  q = requests[i_th][Q_IDX];
  r = requests[i_th][R_IDX];

  if (min_w[p][q][r])
    return min_w[p][q][r];

  int weight_sum_map[101];
  int in_queue[101] = {}; // set all to 0
  memset(weight_sum_map, -1, sizeof(int)*101);
  
  /* starting node has weight_sum of 0 */
  weight_sum_map[p] = 0;
  in_queue[p] = 1;
  int current_node = p; // first in queue is p

  while (current_node != q) {
    int weight_sum = weight_sum_map[current_node];
    in_queue[current_node] = 0;
    min_w[p][current_node][r] = weight_sum;
    
    for (int i = 1; i < 101; i++) {
      if (!weights[current_node][i][r]) 
	continue;
      int adj_node = i;
      int w = weights[current_node][adj_node][r];
      int new_weight_sum =  weight_sum + w;
      if (weight_sum_map[adj_node] == -1 || new_weight_sum < weight_sum_map[adj_node]) {
	weight_sum_map[adj_node] = new_weight_sum;
	in_queue[adj_node] = 1;
      }
    }
    
    int min_sum = -1;
    for (int i = 1; i < 101; i++) {
      if (in_queue[i] && (min_sum == -1 || weight_sum_map[i] < min_sum)) {
	min_sum = weight_sum_map[i];
	current_node = i;
      }
    }
  }
  return weight_sum_map[q];
}

void solve() {
  for (int i = 0; i < k; i++)
    cout << resolve_request(i) << endl;
}

int main() {
  while(read_input()) {
    solve();
  }
  return 0;
}

Measured memory_bytes: 3148
import java.util.Scanner;
public class Main {
	static long power(int n) {
		long ans = 1;
		for(int i = 1; i <= n; i++) {
			ans = ans * i%(int)(1e9+7);
		
		
		}
		return ans;
		
	}
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		System.out.println(power(n));
		
		
		
		
		
	}

}


Measured memory_bytes: 23380
//
//  main.cpp
//  ITP1_9-D
//
//  Created by Saicj on 2015/08/04.
//  Copyright (c) 2015??´ saicj. All rights reserved.
//

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {

    string str;
    int count;
    
    cin >> str;
    cin >> count;
    
    string order;
    int a;
    int b;
    string instead;

    
    for (int i = 0; i < count; i++) {
        
        cin >> order >> a >> b;
        
        if (order == "replace") {
            
            cin >> instead;
            
            str = str.replace(a, instead.length(), instead);
            
        }else if (order == "reverse"){
            
            string tempStr = str.substr(a,(b-a)+1);
            reverse(tempStr.begin(), tempStr.end());
            
             str = str.replace(a, tempStr.length(), tempStr);
            
        }else if (order == "print"){
            
            cout << str.substr(a, (b-a)+1) << endl;
        }
    }

    
    return 0;
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,a,b) for(int i=a;i<b;i++)
#define each(it,v) for(auto it : v)
#define mod 1000000007
#define all(v) (v).begin(),(v).end()
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define vpii vector<pair<int,int>>
#define vv vector<vector<int>>
using namespace std;

main()
{
    int n,k; cin>>n>>k;

    int cnt=0;
    while(n/k>0)
    {
        n/=k;
        cnt++;
    }
    cout<<cnt+1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
        int h1, h2, k1, k2, a, b, c, d;
        scanf("%d %d %d %d %d %d %d %d", &h1, &h2, &k1, &k2, &a, &b, &c, &d);
        int hp = h1*a + (h1/10)*c + h2*b + (h2/20)*d;
        int kp = k1*a + (k1/10)*c + k2*b + (k2/20)*d;
        if(hp>kp) puts("hiroshi");
        else if(hp==kp) puts("even");
        else puts("kenjiro");
}


Measured memory_bytes: 2112
#coding:utf-8

from __future__ import division, print_function
try:
    input = raw_input
    range = xrange
except NameError:
    pass


def solve(W, N, treasures):
    dp = [0] + [-1] * W
    for v, w in treasures:
        for j in range(W, w - 1, -1):
            if dp[j - w] >= 0:
                dp[j] = max(dp[j], dp[j - w] + v)

    ans = max(dp)
    return ans, dp.index(ans)

cnt = 1
while True:
    W = int(input())
    if W == 0:
        break
    N = int(input())
    
    treasures = [tuple(map(int, input().split(','))) for _ in range(N)]
    (v, w) = solve(W, N, treasures)
    print('Case %d:\n%d\n%d' % (cnt, v, w))
    cnt += 1

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

vector<int> adj[100001];
int n;
int visited[100001];

void dfs(int x, int cnt) {
    visited[x] = cnt;
    for (int nx : adj[x]) {
        if (!visited[nx]) {
            dfs(nx, cnt + 1);
        }
    }
}

int main() {
#ifdef DEBUG
    freopen("in.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    cin >> n;
    for (int i = 1; i <= n; i++) {
        int u; cin >> u;
        adj[i].push_back(u);
    }

    dfs(1, 0);
    if (visited[2] == 0) {
        cout << "-1\n";
    } else {
        cout << visited[2] << '\n';
    }

    return 0;
}


Measured memory_bytes: 9216
#include <stdio.h>

int main()
{
	int S0, h, m, s;

	scanf("%d", &S0);

	s = S0 % 60;
	h = S0 / 3600;
	m = S0 / 60;
	m = m % 60;

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

pt,px,py = 0,0,0
for t,x,y in src:
    d = abs(x-px) + abs(y-py)
    if t-pt < d or (t-pt)%2 != d%2:
        print('No')
        exit()
    pt,px,py = t,x,y
print('Yes')

Measured memory_bytes: 17312
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto ab = readln.split.to!(int[]);
    writeln(ab[0] < 10 && ab[1] < 10 ? ab[0] * ab[1] : -1);
}

Measured memory_bytes: 256
from collections import deque
s = input()
q = int(input())
flip = 0
d = deque(list(s))
for i in range(q):
    query = input().split()
    if query[0] == '1':
        flip ^= 1
    else:
        f = int(query[1]) - 1
        c = query[2]
        if f ^ flip == 1:
            d.append(c)
        else:
            d.appendleft(c)
if flip:
    d.reverse()
print(''.join(d))

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, k, a;
	cin>>n>>k;
	int tmp;
	cin>>tmp;
	int m=tmp;
	REP(i, n-1){
		cin>>a;
		tmp=gcd(tmp, a);
		m=max(m, a);
	}
	if(k%tmp || k>m){
		cout<<"IM";
	}
	cout<<"POSSIBLE"<<'\n';
	return 0;
}


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

int main()
{
    vector<int> x(3);
    cin >> x.at(0) >> x.at(1) >> x.at(2);
    sort(x.begin(),x.end());
    int count=0;
    int a;
    a=x.at(2)-x.at(1);
    count+=a;
    x.at(0)+=a;
    for(int i=0;i<10000000;i++){
    if(x.at(2)-x.at(0)==1){
        count+=2;
        cout<<count<<endl;
        break;
    }
    else if(x.at(2)-x.at(0)==0){
        cout<<count<<endl;
        break;
    }
    else{
        x.at(0)+=2;
      count+=1;
    }
    }
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

mod = int(1e9+7)

N,M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
if len(set(A)) < N or len(set(B)) < M:
  print(0)
  exit(0)

A.append(0)
B.append(0)
ai,bi = 0,0
ans = 1
for i in range(N*M,0,-1):
  if i == A[ai] and i == B[bi]:
    ai += 1
    bi += 1
  elif i == A[ai]:
    ans *= bi
    ai += 1
  elif i == B[bi]:
    ans *= ai
    bi += 1
  else:
    if min(ai,N) * min(bi,M) - (N*M - i) > 0:
      ans *= (min(ai,N) * min(bi,M) - (N*M - i))
    else:
      #print(0,i,ai,bi)
      print(0)
      exit(0)
  ans %= mod
  
print(ans)

Measured memory_bytes: 9272
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring> //memset
using namespace std;

int main()
{
	string S;

	cin >> S;

	if (S == "Sunny")
	{
		cout << "Cloudy" << endl;
	}
	else if(S == "Cloudy")
	{
		cout << "Rainy" << endl;
	}
	else {
		cout << "Sunny" << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
#define inf 1000000007
#define maxn 2000001
using namespace std;
struct node{int x, id;} a[maxn]; 
int n, x[maxn], y[maxn], d[maxn], go[maxn], cntx;
int num[maxn], dfn[maxn], low[maxn], vis[maxn];
int cnt, id[maxn], g[maxn], ans, fi[maxn], nt[maxn];
int  c[maxn], st[maxn], top, top1, tag[maxn];
inline int  read() {
    reg int s = 0, t = 0; reg char ch = getchar();
    while(ch > '9' || ch < '0') t |= ch == '-', ch = getchar();
    while(ch >= '0' && ch <= '9') s = (s << 1) + (s << 3) + (ch ^ 48), ch = getchar();
    return t ? -s : s;
}
bool cmp(node g, node h){return g.x < h.x;}
void add(int u, int v){
    nt[++cntx] = fi[u]; fi[u] = cntx; go[cntx] = v;
}
void build(int k, int l, int r){
    if(l == r) {num[l] = k; return; } 
    int mid = l + r >> 1;
    build(k << 1, l, mid); 
    build(k << 1 | 1, mid + 1, r);
    d[++cnt] = k; g[cnt] = k << 1;
    d[++cnt] = k; g[cnt] = k << 1 | 1;
}
void insert(int now, int k, int l, int r, int L, int R){
    if(l > r) return;
    if(L <= l && r <= R){
        d[++cnt] = now; g[cnt] = k; return;
    }
    int mid = l + r >> 1;
    if(L <= mid) insert(now, k << 1, l, mid, L, R);
    if(R > mid) insert(now, k << 1 | 1, mid + 1, r, L, R); 
}
void tarjan(int x){
    dfn[x] = low[x] = ++top; 
    st[++top1] = x; vis[x] = 1;
    for(int i = fi[x]; i; i = nt[i]){
        int v = go[i]; 
        if(!dfn[v]) tarjan(v);
        if(vis[v]) low[x] = min(low[x], low[v]);
    }
    if(low[x] == dfn[x]){
        while(int y = st[top1--]){
            tag[y] = x; vis[y] = 0;
            if(x == y) break;
        }
    }
}
bool solve(int x){
    
    for(int i = 1; i <= 1000000; i++) tag[i] = i, dfn[i] = 0, fi[i] = 0;
    top = 0; top1 = 0;  cnt = 0; cntx = 0;
    build(1, 1, n << 1); 
    for(int i = 1; i <= n; i++){
        int o = (i & 1) ? 1 : -1;
        d[++cnt] = num[id[i]]; g[cnt] = num[id[i + o] + n];
        d[++cnt] = num[id[i + o] + n]; g[cnt] = num[id[i]];
        int R = lower_bound(c + 1, c + n + 1, c[id[i]] + x) - c - 1;
        int L = upper_bound(c + 1, c + n + 1, c[id[i]] - x) - c;
        insert(num[id[i]], 1, 1, n << 1, L + n, id[i] + n - 1);
        insert(num[id[i]], 1, 1, n << 1, id[i] + n + 1, R + n); 
    }
    for(int i = 1; i <= cnt; i++) add(d[i], g[i]);
    tarjan(1);
    for(int i = 1; i <= n; i++){
        if(tag[num[id[i]]] == tag[num[id[i] + n]]) return false;
    }
    return true;
}
int main(){
    //freopen("1.in", "r", stdin);
    n = read(); 
    for(int i = 1; i <= n; i++) {
        int x = read(), y = read();
        a[i * 2 - 1].x = x; a[i * 2 - 1].id = i * 2 - 1;
        a[i * 2].x = y; a[i * 2].id = i * 2;
    }
    sort(a + 1, a + n + n + 1, cmp);
    for(int i = 1; i <= n << 1; i++) c[i] = a[i].x;
    for(int i = 1; i <= n << 1; i++) id[a[i].id] = i;
    int l = 0, r = inf; n <<= 1; ans = 0;
    //cout << 1 << endl;
    while(l <= r){
        int mid = l + r >> 1;
        //cout << l << " " << r << endl;
        if(solve(mid)) ans = mid, l = mid + 1;
        else r = mid - 1;
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 55552
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
using namespace std;

int main(){

    int N;
    cin >> N;

    vector<long long> num(N);
    long long cnt = 0;
    long long absMin = 10000000000;
    for(int i = 0; i < N; i++){
        cin >> num[i];
        if(num[i] < 0) cnt ++;
        num[i] = abs(num[i]);
    }
    sort(num.begin(), num.end() );
    if(cnt % 2 == 1){
        cout << accumulate(num.begin(), num.end(), 0ll) - 2 * num[0] << endl;
    }
    else{
        cout << accumulate(num.begin(), num.end(), 0ll)  << endl;
    }


}



Measured memory_bytes: 1152
N, shurui = map(int, input().split())
ls_n = []
ls = []

set_ls = set()

for i in range(shurui):
  ls_n.append(int(input()))
  tmp = list(map(int, input().split()))
  for t in tmp:
    set_ls.add(t)


print(N - len(set_ls))

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

int main(){
  long long int S;
  cin >> S ;
  long long int rS;
  rS = floor(sqrt(S));
  long long int scomp = rS * rS;
  long long int count = 0;
  long long int count2 = 0;
  for(long long int i= 1 ; i<=1000000000 ; i++){
    if(scomp>=S){
      break;
    }
    scomp = (rS+ i )*rS;
    count += 1;
    if(scomp>=S){
      break;
    }
    scomp = (rS + i )* (rS + i);
    count2 += 1;
  }
  long long int sec;
  sec = scomp - S;
  cout << 0 << " " << 0 << " " << rS+count << " " << 1 <<" " << sec<< " " << rS+count2 ; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;

int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	int n, a, b;
	cin >> n >> a >> b;
	cout << min(a*n, b); 
	return 0;
}


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

using namespace std;

const int MAXN = 100010;
int A[3][MAXN];
int N;
int DP[3][MAXN];

int main(){

    cin >> N;
    for (int i = 1; i <= N; i++) {
        cin >> A[0][i] >> A[1][i] >> A[2][i];
    }

    for (int i = 1; i <= N; i++) {
        DP[0][i] = max(DP[1][i - 1], DP[2][i - 1]) + A[0][i];
        DP[1][i] = max(DP[0][i - 1], DP[2][i - 1]) + A[1][i];
        DP[2][i] = max(DP[0][i - 1], DP[1][i - 1]) + A[2][i];
    }

    cout << max(max(DP[0][N], DP[1][N]), DP[2][N]);

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, int> p;
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    map<int, bool> m;

    for(int i = 0; i < 3; i++) {
        int a;
        cin >> a;
        m[a] = true;
    }

    cout << m.size() << endl;   
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll zenbu[900000];
ll tmp[900001];
void pakuri_sort(int N, ll A[]) {
	const int b = 8;
	rep(k, 8) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}

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


	int H = getint(), W = getint(), N = getint();
	int k = 0;
	rep(i, N) {
		int a = getint(), b = getint();
		for (int i = max(2, a - 1); i <= min(H - 1, a + 1); i++) {
			for (int j = max(2, b - 1); j <= min(W - 1, b + 1); j++) {
				zenbu[k++] = ((ll)i << 30) + j;
			}
		}
	}

	pakuri_sort(k, zenbu);

	ll kotae[10] = {};
	int total = -1;
	ll mae = -1;
	int kazu = 0;
	rep(i, k) {
		if (mae == zenbu[i]) kazu++;
		else {
			kotae[kazu]++;
			total++;
			mae = zenbu[i];
			kazu = 1;
		}
	}
	kotae[kazu]++;
	total++;
	kotae[0] = (ll)(H - 2) * (W - 2) - total;

	rep(i, 10) printf("%lld\n", kotae[i]);

	Would you please return 0;
}

Measured memory_bytes: 14464
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    string s;cin >> s;
    if(s=="ABC") cout << "ARC";
    else cout << "ABC";
}


Measured memory_bytes: 3596
#include <stdio.h>



int main(){

	int a[10000],b[10000],count=0;
	
	while(1){
		scanf("%d %d",&a[count],&b[count]);
		if(a[count]==0){
			if(b[count]==0){
				break;
			}
		}
		count++;
	}

	for(int i=0;i<count;i++){
		if(a[i]<b[i]){
			printf("%d %d\n",a[i],b[i]);
		}else{
			printf("%d %d\n",b[i],a[i]);
		}

	}
	
	return 0;
}


Measured memory_bytes: 1928
import java.util.Scanner;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int x = sc.nextInt();

    int ans = 0;
    for (int i = 0; i <= a; ++i) {
      for (int j = 0; j <= b; ++j) {
        for (int k = 0; k <= c; ++k) {
          if (500 * i + 100 * j + 50 * k == x) ++ans;
        }
      }
    }

    System.out.println(ans);
    
    sc.close(); 
  }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define H ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define ld long double
using namespace std;
const ll  mod = 998244353;


int main()
{
    H
    int n;
    cin >> n;
    ll x, cnt = 0, mn = 0x3f3f3f3f;
    while (n--){
        cin >> x;
        cnt = 0;
        while (x % 2 == 0){
            x /= 2;
            cnt++;
        }
        mn = min(cnt, mn);
    }
    cout << mn;
    return 0 ;
}


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

namespace ConsoleApp5
{
    class Program
    {

        static void Main(string[] args)
        {
            String S = Console.ReadLine();
            String[] L = S.Split(' ');
            long K = long.Parse(L[0]);
            long N = long.Parse(L[1]);
            long[] A = new long[N];
            long[] D = new long[N];
            S = Console.ReadLine();
            L = S.Split(' ');

            for (long i = 0; i < N; i++)
            {
                A[i] = long.Parse(L[i]);
            }


            D[0] = K - A[N - 1] + A[0];
            for (long i = 1; i < N; i++)
            {
                D[i] = A[i] - A[i - 1];
            }
          

            long ans = D.Sum() - D.Max();

            Console.WriteLine(ans);

        }
    }
}

Measured memory_bytes: 34140
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>


using namespace std;

typedef long long LL;

int an[100005];

int main()
{
    int n,k;
    cin >>n>>k; 
    for (int i=0; i<n; i++)
    {
        cin >>an[i];
    } 
    sort(an,an+n);
    int maxn =0x7fffffff;
    k--;
    for (int i=0; i<n-k; i++)
    {
        maxn = min(maxn,an[i+k]-an[i]);
    }
    cout<<maxn<<endl;




#ifdef VSCode
    system("pause");
#endif
    return 0;
}

Measured memory_bytes: 640