akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    cin >> n;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            int buf = i * j;
            if (buf == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
# dpぽい気がするのでそうする
# なぜかREなる....
# pythonだとrecursion limitがアレなのを忘れていた...
# なぜかTLEなる....

import sys

sys.setrecursionlimit(10 ** 8)


s = input()
dp = {}


def rec(i, cur_g, cur_p, g, p):
    if i in dp:
        return dp[i]
    if i == len(s):
        ret = p - g
        dp[i] = ret
        return ret
    if cur_g > cur_p:
        # パーを出せる（出さなくてもいい）
        if s[i] == "g":
            ret = max(
                rec(i + 1, cur_g, cur_p + 1, g, p + 1),
                rec(i + 1, cur_g + 1, cur_p, g, p),
            )
            dp[i] = ret
            return ret
        elif s[i] == "p":
            ret = max(
                rec(i + 1, cur_g, cur_p + 1, g, p),
                rec(i + 1, cur_g + 1, cur_p, g + 1, p),
            )
            dp[i] = ret
            return ret
    else:
        # 勝てるかどうかにかかわらずグーを出すしか無い
        if s[i] == "g":
            ret = rec(i + 1, cur_g + 1, cur_p, g, p)
            dp[i] = ret
            return ret
        elif s[i] == "p":
            ret = rec(i + 1, cur_g + 1, cur_p, g + 1, p)
            dp[i] = ret
            return ret


print(rec(0, 0, 0, 0, 0))


Measured memory_bytes: 95324
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N=int(readline())
m=map(int,read().split())
UVW=zip(m,m,m)

graph =[[] for i in range(N+1)]
for u,v,w in UVW:
    graph[u].append((v,w))
    graph[v].append((u,w))

color=[0]*(N+1)
parent=[0]*(N+1)
stack=[1]
while stack:
    x=stack.pop()
    for dst,w in graph[x]:
        if (dst==parent[x]):
            continue
        stack.append(dst)
        color[dst]=color[x]^(w&1)
        parent[dst]=x

print('\n'.join(map(str,color[1:])))


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main() {
    string S, T;
    cin >> S >> T;
    int S_len = S.length();
    int T_len = T.length();
    int ans = 1010;
    rep(i,S_len - T_len+1) {
        int cnt = 0;
        rep(j,T_len) {
            if (S[i+j] != T[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;
using VI = vector<int>;
using VPI = vector<pair<int, int>>;
using LL = long long;

#define FOR(a,n) for(int i=a;i<n;i++)
#define rFOR(a,n) for(int i=n-1;i>=a;i--)
#define IN(n,a) for(int i=0;i<n;i++) cin>>a[i]
#define pIN(n,t) for(int i=0;i<n;i++){int a,b; cin>>a>>b; t.emplace_back(a,b);}
#define SORT(a) sort(a.begin(), a.end())
#define ALL(a) a.begin(), a.end()

int kai(int n)
{
	int v = 1;
	for (int i = 2; i <= n; i++)
	{
		v = v * i;
	}

	return  v;
}

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b + c > 21)cout << "bust";
	else cout << "win";
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var S = Console.ReadLine();

            for(int i=0; i<S.Length; i++)
            {
                var c = (char)(((S[i] - 'A' + N) % 26) + 'A');
                Console.Write(c);
            }

            Console.WriteLine();
        }
    }
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int k;
  cin >> k;
  
  vector<int> x = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << x.at(k - 1) << '\n';
}

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]A - Good Integer
            string n = Console.ReadLine();

            if (IsGoodInteger(n))
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }            
        }

        static bool IsGoodInteger(string n)
        {
            for (int i = 0; i <= 9; i++)
            {
                string s = i.ToString();
                string good = s + s + s;

                if (n.StartsWith(good) | n.EndsWith(good))
                {
                    return true;
                }
            }

            return false;
        }
    }
}

Measured memory_bytes: 13396
import java.util.Scanner;
class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String x = sc.next();
            if(x.equals("0")){
                break;
            }
            
            int sum = 0;
            for(int i = 0 ; i < x.length() ; i++){
                sum += Character.getNumericValue(x.charAt(i)) ;
            }
            
            System.out.println(sum);
        }
    } 
}


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

#define rep(i,n) for(int i=0; i<(n); ++i)
#define rrep(i,n) for(int i=1; i<=(n); ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define foreach(it, v) for(typeof(v.begin()) it=v.begin(); it!=v.end(); ++it)
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second

typedef unsigned int uint;
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef set<int> si;

int N;
int A;
int absA;
int minuscnt;
int absmin;
long int sum;

int main(){
  scanf("%d",&N);
  rep(i,N) {
    scanf("%d",&A);
    absA = abs(A);
    if (i==0) absmin = absA;
    if (A<0) ++minuscnt;
    absmin = min(absmin, absA);
    sum += absA;
  }
  if (minuscnt%2) sum -= absmin*2;
  cout << sum << "\n";
  return 0;
}


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


int main()
{
	#ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
    	
    int n,k,t;
    cin>>n>>k>>t;
    if(n%k==0)
    {
    	cout<<(n/k)*t<<endl;
    }
    else
    	cout<<((n/k)+1)*t<<endl;
	return 0;
}

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

int main()
{
        int n;
        int ret, min, tmp;

        cin >> n >> min;
        ret = -(1<<30);

        for(int i=0; i<n-1; i++){
                cin >> tmp;
                if( ret < tmp-min ){ ret = tmp-min; }
                if( min > tmp ){ min = tmp; }

        }
        cout << ret << endl;

        return 0;
}

Measured memory_bytes: 1164
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N; cin >> N;
	int ans = 0;
	for (int i = 1; i <= N; i++) {
		int const log = log10(i) + 1;
		if (log % 2 == 1) ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    string ans = "";
    int score = 0;
    rep(i, n) {
        char win;
        if (t[i] == 'r') win = 'p';
        if (t[i] == 's') win = 'r';
        if (t[i] == 'p') win = 's';
        if (i - k >= 0 && ans[i-k] == win) {
            ans += '-';
        } else {
            ans += win;
            if (win == 'p') score += p;
            if (win == 'r') score += r;
            if (win == 's') score += s;
        }
    }
    cout << score << endl;
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    if (a != 1 && b != 1) cout << 1 << endl;
    else if (a != 2 && b != 2) cout << 2 << endl;
    else if (a != 3 && b != 3) cout << 3 << endl;
}

Measured memory_bytes: 3540
#include<iostream>
using namespace std;
int d[1000005];
int e[1000005];
int main(void)
{
    int n,mx;
    cin >> n;
    mx=n;
    d[1]=n;
    e[n]=1;
    int i;
    for(i=2;;i++)
    {
        d[i]=(d[i-1]%2 ? d[i-1]*3+1 : d[i-1]/2);
        mx=max(d[i],mx);
        e[d[i]]++;
        int j;
        for(j=1;j<=mx;j++)
        {
            if(e[j]>1)
                break;
        }
        if(j!=mx+1)
            break;
    }
    cout << i;
    return 0;
}

Measured memory_bytes: 2304
n=int(input())
a_list=list(map(int,input().split()))
a_list=[0]+a_list
ans=[0]*(n+1)
count=0
for i in range(n,0,-1):
    temp=0
    c=n//i
    for j in range(2,c+1):
        temp+=ans[i*j]
    if temp%2==a_list[i]:
        ans[i]=0
    else:
        ans[i]=1
        count+=1
print(count)
for i in range(n+1):
    if ans[i]==1:
        print(i,end='')
        print(' ',end='')
            


Measured memory_bytes: 75228
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define sort(x) sort(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
using namespace std;
int a[100005], n, m;

int main(){
	int i, j;
	cin >> n >> m;
	if(n < 10){
		cout << m + 100*(10-n);
	}else {
		cout << m;
	}
}


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

const int mod = 1000000007;

int N;
string s;

long long dp[3009][3009];

int main() {
    cin >> N >> s;

    for(int j = 0; j < N; j++)
        dp[0][j] = 1;

    for(int i = 0; i < N - 1; i++) {
        // 累積和
        int sum[3009];
        sum[0] = 0;
        for(int j = 0; j < N - i; j++)
            sum[j + 1] = (sum[j] + dp[i][j]) % mod;

        if(s[i] == '<') {
            for(int j = 0; j < N - i; j++)
                if((dp[i + 1][j] = sum[N - i] - sum[j + 1] + mod) >= mod)
                    dp[i + 1][j] -= mod;
        }
        if(s[i] == '>') {
            for(int j = 0; j < N - i; j++)
                dp[i + 1][j] = sum[j + 1];
        }
    }

    cout << dp[N - 1][0] << endl;

    return 0;
}

Measured memory_bytes: 70016
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();
        String ans = "EQUAL";
        if (a.length() > b.length()) {
            ans = "GREATER";
        } else if (a.length() < b.length()) {
            ans = "LESS";
        } else {
            for (int i = 0; i < a.length(); i++) {
                char ac = a.charAt(i);
                char bc = b.charAt(i);
                if (ac < bc) {
                    ans = "LESS";
                    break;
                } else if (ac > bc) {
                    ans = "GREATER";
                    break;
                }
            }
        }

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

Measured memory_bytes: 24916
H, W = map(int, input().split())
area = []
for i in range(H):
  area.append(input())

for i in range(H):
  for j in range(W):
    if area[i][j] == '#':
      print('#', end='')
    else:
      count = 0
      for k in range(max(0, i-1), min(i+1, H-1)+1):
        for l in range(max(0, j-1), min(j+1, W-1)+1):
          if area[k][l] == '#':
            count += 1
      print(count, end='')
  print()

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

int main(){
	int n;
        cin >> n;
        int s[n];
	
	for( int i = 0; i < n; i++){
		cin >> s[i];
	}
	
	for( int j = 1; j <= n; j++){
          if( j == 1){
            cout << s[n - j];
          } else{
            cout << " " << s[n - j];
	  }
        }
	cout << endl;

	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int count = 0;
    for (int i=0;i<N-2;i++){
        if (S[i] == 'A'){
            if (S[i+1] == 'B' && S[i+2] == 'C') count++;
        }
    }
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
int main() {
	int a,c;
  std::string b;
  std::cin >>a>>b>>c;
  
  if(b == "+"){
  	std::cout<<a+c;
  }else if(b == "-"){
  	std::cout<<a-c;
  }else{}
}

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

using namespace std;

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

	int count = 0;

	for(int i = 0; i < S.size(); i++){
		if(S.at(i) != T.at(i)){
			count++;
		}
	}
	cout << count << "\n";
}


Measured memory_bytes: 3820
#include <iostream>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    int n, x, cnt, s;

    while (cin >> n >> x) { 
        cnt = 0;
        if (n == 0 && x == 0) break;
        for (int i = 1; i <= n; i++){
            for (int j = i + 1; j <= n; j++){
                for (int k = j + 1; k <= n; k++){
                    //if ( i !=)
                    s = i + j + k;
                    if (s == x) cnt++;
                    //cout << i << j << k << endl;
                }
            }
        }
        cout << cnt << endl;
    }

    return 0;
}



Measured memory_bytes: 3108
#include<stdio.h>
#include<ctype.h>

int main(){
	while(1){
	char ch;
	scanf("%c", &ch);

	if(ch == '\n'){
		printf("%c", ch);
		break;
	}else{
		if(islower(ch)==0){
			printf("%c", tolower(ch));
		}else{
			printf("%c", toupper(ch));

		}
	}
	}

return 0;

}

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

bool comp(pair<long long int,long long int> a, pair<long long int,long long int> b)
{
  if(a.first != b.first)
  {
    return a.first < b.first;
  }
  else if(a.second != b.second)
  {
    return a.second > b.second;
  }
  return false;
}
int main()
{
  int n;
  cin >> n;
  vector<pair<long long int,long long int> > v;
  for(int i = 0;i < n;i++)
  {
    long long int a,b;
    cin >> a >> b;
    v.push_back(make_pair(b,a));
  }
  sort(v.begin(),v.end(),comp);
  long long int work_sum = 0;
  for(int i = 0;i < n;i++)
  {
    work_sum = work_sum + v[i].second;
    if(v[i].first < work_sum)
    {
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 6384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int n, q;
vector<vector<int>> vec;
vector<int> nums;
vector<int> ans;

void getSum(int s,int thisNum,int p) {
	s += nums.at(thisNum);
	ans.at(thisNum) = s;
		for (int i : vec.at(thisNum)) {
			if (i != p) {
				getSum(s, i, thisNum);
			}
		}
}

int main() {
	cin >> n >> q;
	vec.resize(n);
	nums.resize(n);
	ans.resize(n);
	for (int i = 0; i < n; i++) {
		nums.at(i) = 0;
		ans.at(i) = 0;
		vec.at(i).resize(0);
	}

	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		vec.at(a - 1).push_back(b - 1);
		vec.at(b - 1).push_back(a - 1);
	}
	for (int i = 0; i < q; i++) {
		int a, b;
		cin >> a >> b;
		nums.at(a - 1) += b;
	}
	for (vector<int> v : vec) {
		for (int n : v) {
			//cout << n;
		}
		//cout << endl;
	}

	for (int i = 0; i < n; i++) {
		//cout << i << ' ' << nums.at(i) << endl;
	}

	getSum(0,0,0);

	for (int i : ans) {
		cout << i << ' ';
	}
}

Measured memory_bytes: 24320
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<numeric>
#include<algorithm>
#include<string>
#include<map>
#include<bitset>
#include<set>
#include<cmath>
//#define int long long
#define inf 1145141919ll
#define oku 1000000007ll
using namespace std;
int a,b,c,d;
int dx[]={0,-1,0,1,0};
struct A{
	A *e;
	int temp;

};
struct B{
	A *src;
	A *dst;
	int cost;
};
struct C{
	int u;
	int v;
	int len;
	C(int x,int y,int z):u(x),v(y),len(z){}
};
int i,j,k,n;
int p[2000],q[2000],r[2][2001][2001];
signed main(){
	fill(&r[0][0][0],&r[0][0][0]+2*2001*2001,-1);
	char ta[2];
	ta[0]='O';
	ta[1]='I';
	cin>>a>>b;
	string s,t;
	cin>>s>>t;
	queue<C> qu;
	for(i=0;i<=a;i++){
		for(j=0;j<=b;j++){
			if(r[0][i][j]>0)
				continue;
			qu.push({i,j,0});
			while(!qu.empty()){
				auto x=qu.front();
				qu.pop();
				if(r[x.len&1][x.u][x.v]>=x.len)
					continue;
				else
					r[x.len&1][x.u][x.v]=x.len;
				if(x.len&1)
					n=max(n,x.len);
				if(x.u<a&&s[x.u]==ta[(x.len&1)^1])
					qu.push({x.u+1,x.v,x.len+1});
				if(x.v<b&&t[x.v]==ta[(x.len&1)^1])
					qu.push({x.u,x.v+1,x.len+1});
			}
		}
	}
	cout<<n<<endl;
}

Measured memory_bytes: 34532
# abc175_b.py
N = int(input())
L = list(map(int,input().split()))
ans = 0
for i in range(N):
    for j in range(i+1,N):
        for k in range(j+1,N):
            if L[i]!=L[j] and L[k]!=L[j] and L[i]!=L[k]:
                if L[i] + L[j] > L[k] and L[k] + L[j] > L[i] and L[i] + L[k] > L[j]:
                    ans +=1
                    # print(L[i] , L[j] , L[k],"///",i,j,k)
print(ans)

Measured memory_bytes: 9204
#include <stdio.h>
int main(void){
	int N,M,c,d,i;
	scanf("%d %d",&N,&M);
	int a[200001]={0},b[200001]={0};
	for(int i=0;i<M;i++){
		scanf("%d %d",&c,&d);
		if( c==1){
			a[d]=1;
		}
		if( d==N){
			b[c]=1;
		}
	}
	for(i=0;i<N;i++){
		if(a[i]==1){
			if(b[i]==1){
				printf("POSSIBLE");
				return 0;
			}
		}
	}
	printf("IMPOSSIBLE");
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    int a,b;
    cin >> a >> b;
    if(a == b) cout << "a == b" << endl;
    else if(a > b) cout << "a > b" << endl;
    else cout << "a < b" << endl;
    return 0;
}


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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min (A * N, B) << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main()
{
    int h1,h2,m1,m2,k;
    scanf("%d%d%d%d%d",&h1,&m1,&h2,&m2,&k);
    m1+=60*h1;
    m2+=60*h2;
    printf("%d\n",m2-m1-k);
    return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int main() {
  int n;
  while(cin>>n,n) {
    string s;
    cin >> s;
    vector<int> a(n), b(n);
    REP(i, n) {
      cin >> a[i] >> b[i];
      a[i]--; b[i]--;
    }
    for (int i=n-1; i>=0; --i) {
      int dif = abs(a[i] - b[i]);
      s[a[i]] = (s[a[i]]-'a'+dif)%26+'a';
      s[b[i]] = (s[b[i]]-'a'+dif)%26+'a';
      swap(s[a[i]], s[b[i]]);
    }
    cout << s << endl;
  }
}

Measured memory_bytes: 0
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("YES")
#define p_no() p("NO")

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N, A, B, C;
    cin >> N >> A >> B >> C;

    vector<ll> L(N);
    FOR(i, 0, N){
        cin >> L.at(i);
    }


    ll min_cost = inf;

    FOR(i, 0, 1<<2*N){
        vector<ll> S(4); // sum of A, B, C, D
        vector<ll> merge(4);

        FOR(j, 0, N){
            ll b0 = i >> 2*j & 3;
            S[b0] += L[j];
            merge[b0]++;
        }

        if(S[0]==0 || S[1]==0 || S[2]==0){
            continue;
        }

        merge[0]--;
        merge[1]--;
        merge[2]--;

        ll costA = 10 * merge[0] + abs(A - S[0]);
        ll costB = 10 * merge[1] + abs(B - S[1]);
        ll costC = 10 * merge[2] + abs(C - S[2]);
        ll cost = costA + costB + costC;

        // pn(S[0]);
        // pn(S[1]);
        // pn(S[2]);

        // pn(merge[0]);
        // pn(merge[1]);
        // pn(merge[2]);

        // pn(i);
        // pn(costA);
        // pn(costB);
        // pn(costC);
        // pn(cost);
        // return 0;
        

        min_cost = min(min_cost, cost);
    }

    // p("answer");
    p(min_cost);
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
using namespace std;
#define df 0
typedef long int li;
const li MAX=10000000000;
#define rep(i,n) for(int i=0;i<n;i++)

int operator>(pair<int,int> p1,pair<int,int> p2){
  if(p1.second>p2.second)return 1;
  return 0;
}



int main(){
  if(df) printf("*debug mode*\n");
  int n;cin >>n;
  map<int,int> me,mo;
  rep(i,n/2){
    int u,v; cin >>u >>v;
    me[u]++; mo[v]++;
  }
  if(df){
    for(pair<int,int> p:me){
      printf("%d(%d) ",p.first,p.second);
    }
    printf(":me\n");
    for(pair<int,int> p:mo){
      printf("%d(%d) ",p.first,p.second);
    }
    printf(":mo\n");
  }
  pair<int,int> fe={0,0},se={0,0},fo={0,0},so={0,0};
  for(pair<int,int> p: me){
    if(p>fe){
      se=fe;fe=p;
    }else if(p>se)se=p;
  }
  for(pair<int,int> p: mo){
    if(p>fo){
      so=fo;fo=p;
    }else if(p>so)so=p;
  }
  if(df){
  printf("fe%d(%d),se%d(%d)\nfo%d(%d),so%d(%d)\n",fe.first,fe.second,se.first,se.second,fo.first,fo.second,so.first,so.second);
  }

  if(fe.first!=fo.first){
    printf("%d",n-fe.second-fo.second);
  } else {
    printf("%d",n-max(fe.second+so.second,fo.second+se.second));
  }
}

/// confirm df==0 ///


Measured memory_bytes: 4992
# Use numpy if you use column operation
import numpy as np
h, w =  map(int, input().split())

# Get grid colors
gird_colors = np.array([])
for _ in range(h):
    tmp_row = np.array(list(input()))
    if "#" in tmp_row: # If the row includes black
        gird_colors = np.concatenate((gird_colors, tmp_row))
gird_colors = gird_colors.reshape(-1, w)

# Search and delete white line
del_count = 0
for wi in range(w):
    if "#" not in gird_colors[:, wi - del_count]:
        gird_colors = np.delete(gird_colors, wi - del_count, 1)
        del_count += 1

# Print result
for line_val in gird_colors:
    print("".join(line_val)) 

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

int n,a[11],ans;

inline void dfs(int ci,int res)
{
	if(ci==n) {if(res==0) ans++;return;}
	dfs(ci+1,res*(a[ci]-1)%2);
	dfs(ci+1,res*a[ci]%2);
	dfs(ci+1,res*(a[ci]+1)%2);
}

int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>a[i];
	dfs(0,1);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_range(i, s, e) for (int i = (s); i < (int)(e); i++)
#define rep_rev(i, s, e) for (int i = (s)-1; i >= (int)(e); i--)
#define sort_vec(v) sort((v).begin(),(v).end())
typedef int64_t lint;
// lint mod = 998244353;
// lint mod = 1000000007;
template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void app() {
  int t;
  cin>>t;

  rep(_t,t){
    int n;
    cin>>n;

    lint ans=0;
    vector<multiset<lint>> cp(n+1),cm(n+1);
    rep(i,n){
      int k;
      lint l,r;
      cin>>k>>l>>r;
      if(l>r) cp[k].emplace(l-r),ans+=r;
      else cm[k].emplace(r-l),ans+=l;
    }

    priority_queue<lint,vector<lint>,greater<lint>> sp,sm;
    rep(k,n+1){
      for(lint c:cp[k]){
        ans+=c; sp.push(c);
        if(sp.size()>k){
          ans-=sp.top(); sp.pop();
        }
      }
    }

    rep_rev(k,n+1,0){
      for(lint c:cm[k]){
        ans+=c; sm.push(c);
        if(sm.size()>n-k){
          ans-=sm.top(); sm.pop();
        }
      }
    }

    cout<<ans<<endl;
  }

}

int main(){app();return 0;}


Measured memory_bytes: 33744
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b-1);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n){
    cin>>a[i];
  }
  vector<ll>b(n+1),c(n+1);
  b[0]=0;
  stack<pair<ll,ll>> st;
  rep(i,n-1){
    ll cnt=0;
    ll tc=0;
    ll ta=a[i];
    while(ta<a[i+1]){
      ta<<=2;
      cnt+=2;
    }
    while(ta/4>=a[i+1]){
      ta>>=2;
      tc+=1;
    }
    if(a[i]<=a[i+1]){
      ll ts=0;
      pair<ll,ll>tp={1,0};
      ll cc=(i+1)*cnt;
      while(!st.empty()&&cc>=ts){
        tp=st.top();st.pop();
        ts+=tp.first*tp.second;
      }
      ts-=tp.first*tp.second;
      if((cc-ts)/tp.first<tp.second)st.push({tp.first,tp.second-((cc-ts)/tp.first)});

      ts+=min((cc-ts)/tp.first,tp.second)*tp.first;
      ll d=cc-ts;
      b[i+2]=b[i+1]+d;
    }
    else {
      b[i+2]=b[i+1];
      st.push({(i+1)*2,tc});
    }

  }
  c[n]=0;
  c[n-1]=0;
  while(!st.empty())st.pop();
  rrepi(i,1,n){
    ll ta=a[i];
    ll cnt=0;
    ll tc=0;
    while(a[i-1]>ta){
      ta<<=2;
      cnt+=2;
    }
    while(a[i-1]<=ta/4){
      ta>>=2;
      tc+=1;
    }
    if(a[i-1]>=a[i]){
      ll ts=0;
      pair<ll,ll>tp={1,0};
      ll cc=(n-i)*cnt;
      while(!st.empty()&&cc>=ts){
        tp=st.top();st.pop();
        ts+=tp.first*tp.second;
      }
      ts-=tp.first*tp.second;
      if((cc-ts)/tp.first<tp.second)st.push({tp.first,tp.second-((cc-ts)/tp.first)});

      ts+=min((cc-ts)/tp.first,tp.second)*tp.first;
      ll d=cc-ts;
      c[i-1]=c[i]+d;
    }
    else {
      c[i-1]=c[i];
      st.push({(n-i)*2,tc});
    }
  }
  ll res=1e17;
  rep(i,n+1){
    //cout<<b[i]<<" "<<c[i]<<endl;
    chmin(res,b[i]+i+c[i]);
  }
  cout<<res<<endl;


  return 0;

}


Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define PB push_back
#define LL long long
#define pii pair<LL,LL>
#define MEM(x,y) memset(x,y,sizeof(x))
#define bug(x) cout<<"debug "#x" is "<<x<<endl;
#define FIO ios::sync_with_stdio(false);
#define ALL(x) x.begin(),x.end()
#define LOG 20
#define lson(x) ((x)<<1)
#define rson(x) ((x)<<1|1)
const int maxn=2e5;


int main(){
    FIO;
    string str;
    cin>>str;
	if((str[0]=='A'&&str[1]=='A'&&str[2]=='A')||
	(str[0]=='B'&&str[1]=='B'&&str[2]=='B'))
		puts("No");
	else
		puts("Yes");
    return 0;

	return 0;
}


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


#define int long long

int memo[(1 << 12)];
int dp[(1 << 12)];

signed main(){
    int n, m;
    cin >> n >> m;

    for(int i = 0;i < (1 << n);i++) memo[i] = INT_MAX;
    for(int i = 0;i < (1 << n);i++) dp[i] = INT_MAX;

    for(int i = 0;i < m;i++){
        int a, b;
        cin >> a >> b;

        int x = 0;
        for(int i = 0;i < b;i++){
            int c;
            cin >> c;
            c--;
            x |= (1 << c);
        }
        memo[x] = min(memo[x], a);
    }

    memo[0] = 0;

    for(int i = 0;i < (1 << n);i++){
        dp[i] = memo[i];
    }

    for(int j = 0;j < n;j++){
        for(int i = 0;i < (1 << n);i++){
            if(!(i & (1 << j))){
                dp[i] = min(dp[i], dp[i | (1 << j)]);
            }
        }
    }


    for(int i = 0;i < (1 << n);i++){
        for(int j = i;j > 0;j = (j - 1) & i){
            dp[i] = min(dp[i], dp[i^j] + dp[j]);
        }
    }


    cout << (dp[(1 << n)-1] >= INT_MAX ? -1 : dp[(1 << n)-1]) << endl;

    return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pb push_back
#define mp make_pair
#define in auto&it
#define out auto it 
#define rep(i,si,n) for(int i=si;i<n;++i)
ll pow(ll a){
	int b=2;
	ll ans=1;
	while(b>0){
		if(b&1) ans*=a;
		a*=a;
		b>>=1;
	}
	return ans;
}
int main(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		//freopen("error.txt","w",stderr);
	#endif
	fastio
	ll n,k;
	cin>>n>>k;
	ll check=pow(k);
	ll cnt=0;
	//cout<<check<<" ";
	while(n--){
		ll a,b;
		cin>>a>>b;
		if(pow(a)+pow(b)<=check) ++cnt;
		//cout<<pow(a)<<" "<<pow(b)<<'\n';
	}
	cout<<cnt<<" ";
	//cerr<<"time:  "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<'\n';
	return 0;
}


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

using namespace std;

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

   int maxv = -2000000000;
   int minv = v[0];
   for (int i = 1; i < n; i++) {
      maxv = max(maxv, v[i] - minv);
      minv = min(minv, v[i]);
   }

   cout << maxv << endl;
   return 0;
}


Measured memory_bytes: 3528
s = list(input())
result = []
for i in set(s):
    x = [0]
    y = 0
    for j in range(len(s)):
        if s[j] == i:
            x.append(y)
            y = 0
        else:
            y += 1
    x.append(y)
    if s[-1] == i:
        result.append(max(x))
    else:
        result.append(x[-1]+max(0, max(x[:-1])-x[-1]))
print(min(result))

Measured memory_bytes: 9140
inp = list(map(int,input().split()))
question = [int(input()) for i in range(inp[2])]
point = []
sinshutu = []
for i in range(inp[0]):
    point.append(inp[1])
    sinshutu.append('No')

for i in range(inp[2]):
    point[question[i]-1] = point[question[i]-1]+1

point = list(map(lambda x:x-inp[2], point))

for i in range(inp[0]):
    if point[i] > 0:
        sinshutu[i] = 'Yes'
    print(sinshutu[i])

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

#define POS(i,j) ((i)*(n+2)+(j))

void run(void){
  char *s=(char *)calloc(2000+1,sizeof(char));
  scanf("%s",s);
  int n=strlen(s);
  const int mod=998244353;
  int *dp=(int *)calloc((n+2)*(n+2),sizeof(int));
  int i=0;
  dp[POS(1,s[i]=='2'?2:s[i]=='1'?1:0)]=1;
  for(i=1;i<n;i++){
    int d=s[i]=='2'?2:s[i]=='1'?1:0;
    for(int j=0;j<=i+1;j++){
      if(j>0){
	dp[POS(i+1,j-1+d)]+=dp[POS(i,j)];
	dp[POS(i+1,j-1+d)]%=mod;
      }
      if(j<i+1){
	dp[POS(i+1,j+d)]+=dp[POS(i,j)];
	dp[POS(i+1,j+d)]%=mod;
      }
    }
  }
  memcpy(dp,dp+POS(n,0),sizeof(int)*(n+2));
  memset(dp+POS(1,0),0,sizeof(int)*(n+2)*n);
  for(i=0;i<=n;i++){
    for(int j=0;j<=n+1-i;j++){
      if(j>0){
	dp[POS(i+1,j-1)]+=dp[POS(i,j)];
	dp[POS(i+1,j-1)]%=mod;
      }
      if(j<n+1-i){
	dp[POS(i+1,j)]+=dp[POS(i,j)];
	dp[POS(i+1,j)]%=mod;
      }
    }
  }
  printf("%d\n",dp[POS(n+1,0)]);
}

int main(void){
  run();
  return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>


int main(){
    int N; cin>>N;
    int num_f = 0;
    int num_t = 0;
    int num_r = 0;
    REP(i,N){
        ll a; cin >> a;
        if(a%4==0){ ++num_f; }
        else if(a%2==0){ ++num_t;}
        else{ ++num_r; }
    }
    bool ok;
    if(num_f>=num_r){ ok = true; }
    else{ 
      if(num_t==0 && num_f>=num_r-1){ ok = true;}
      else{ ok = false;}
    }
    cout << (ok?Liny:Linn);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define inf 1000000007
#define MAXN 100100
#define ff first
#define ss second
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
	typedef pair<int,int> pii;
int A[MAXN];

	
int32_t main(){
	fastio;
	int n,m;
	cin>>n>>m;
	vector<pii> v;
	for(int i=0;i<n;i++){
		int a;
		cin>>a;
		v.push_back(pii(a,1));
	}
	for(int i=0;i<m;i++){
		int b,c;
		cin>>b>>c;
		v.push_back(pii(c,b));
	}
	
	sort(v.begin(),v.end(),greater<pii>()); 
	int tenho=0;
	int res=0;
	for(int i=0;i<(int)v.size();i++){
		int coloca = min(n-tenho,v[i].ss);
		tenho+=coloca;
		res+=coloca*v[i].ff;
		if(tenho==n)break;
	}
	cout<<res<<endl;
	   	
}

Measured memory_bytes: 6512
N=int(input())
x=[list(map(int,input().split())) for _ in range(N)]

A=[]
B=[]
C=[]
D=[]
for i in range(N):
    A.append(x[i][0]+x[i][1])
    B.append(-x[i][0]-x[i][1])
    C.append(x[i][0]-x[i][1])
    D.append(-x[i][0]-x[i][1])

print(max(max(A)-min(A),max(B)-min(B),max(C)-min(C),max(D)-min(D)))

Measured memory_bytes: 77692
import java.util.*;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
       int k = sc.nextInt();
       int x = sc.nextInt();
   if(k*500>=x){
   System.out.println("Yes");
   } else {
   System.out.println("No");
   }
       sc.close();
    }
}

Measured memory_bytes: 19796
def 解():
    iN = int(input())
    iD = 10**9 + 7

    if iN < 3:
        print(iN)
        exit()

    aS = [1]*(iN+1)
    d素={}
    for i in range(2,iN+1):
        if aS[i]:
            d素[i] = 1
            for j in range(i*2,iN+1,i):
                aS[j] = 0

    for i in range(2,iN+1):
        for i素 in d素:
            while i % i素 == 0:
                d素[i素]+=1
                i //= i素
    iAns = 1
    for i素 in d素:
        iAns *= d素[i素]
        iAns %= iD
    print(iAns)
解()


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

int main(){
  string s;
  cin >> s;
  string a;
  for (int i = 0; i < s.size(); i++){
    if (s.at(i) == '0'){
      a += '0';
    } 
    if (s.at(i) == '1'){
      a += '1';
    }
    if (s.at(i) == 'B'){
      if(a.size() > 0) {
        a.erase(a.size()-1);
      }
    }
  }
    cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
//#define int long long
const int INF = 1 << 30;

signed main(){

  int D; cin >> D;
  vector<int> C(26);
  for(int i = 0; i < 26; i++){
    cin >> C[i];
  }

  vector<vector<int>> S(D, vector<int>(26));
  for(int i = 0; i < D; i++){
    for(int j = 0; j < 26; j++){
      cin >> S[i][j];
    }
  }

  vector<int> t(D);
  for(int i = 0; i < D; i++){
    cin >> t[i];
    t[i]--;
  }
  // int m; cin >> m;
  // for(int i = 0; i < m; i++){
  //   int d, q; cin >> d >> q;
  // }

  int res = 0;
  vector<int> L(26, -1);
  for(int i = 0; i < D; i++){
    res += S[i][t[i]];
    L[t[i]] = i;
    for(int j = 0; j < 26; j++){
      res -= C[j] * (i - L[j]);
      //cout << C[j] * (i - L[j]) << " ";
    }
    cout << res << endl;
  }

  // int score = -INF;
  // vector<int> ans(D);
  // while(true){
  //   int res = 0;
  //   vector<int> L(26, -1);
  //   vector<int> dp(D);
  //   for(int i = 0; i < D; i++){
  //     int T = dist_T(rnd);
  //     res += S[i][t[i]];
  //     L[t[i]] = i;
  //     for(int j = 0; j < 26; j++){
  //       if(L[j] == -1) continue;
  //       res -= i - L[j];
  //     }
  //     dp[i] = T;
  //   }
  //   if(score < res){
  //     score = res;
  //     ans = dp;
  //   }

  //   clock_t end = clock();
  //   const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
  //   //printf("time %lf[ms]\n", time);
  //   if(time >= 1900) break;
  //   //cout << dp << " " << res << endl;
  // }

  // for(int p : ans){
  //   cout << p << endl;
  // }

  return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    
    int cmin = INF;
    int cnt;
    rep(i,n){
        cmin = min(a.at(i),cmin);
        if(a.at(i) == cmin) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

using namespace std;

int main(void) {
	int H,W;
	cin >> H >> W;
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	int cn = 0;
	vector< vector<int> > res(H,vector<int>(W));
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (i%2 == 0) {
				res[i][j] = cn + 1;
				--a[cn];
			}
			else {
				res[i][W-1-j] = cn + 1;
				--a[cn];
			}

			if (a[cn] == 0) {
				++cn;
			}
		}
	}

	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			cout << res[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}


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

int main() {
  int N,K,in,sum;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
  		cin >> in;
    if(in < (K-in)){
    	sum += in*2;
    }else{
     	sum += (K-in)*2; 
    }
  }
  
  cout << sum << endl;
  
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

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

/*
    freopen("input","r",stdin);
    freopen("output","w",stdout);
*/

ll X[1010];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    for (int i = 0;i < N;i++) cin >> X[i];
    ll a = 0, b = 0;
    bool ck = 0;
    ll ma = -1E18;
    int po = -1;
    for (int i = 0;i < N;i++) {
    	if (X[i] > ma) {
    		ma = X[i];
    		po = i;
    	}
    	if (X[i] > 0) ck = 1;
    }
    if (!ck) {
    	cout << ma << endl;
    	cout << N - 1 << endl;
    	for (int i = N - 1;i >= 0;i--) {
    		if (i < po) cout << 1 << endl;
    		else if (i > po) cout << i + 1 << endl;
    	}
    	return 0;
    }
    vector<int> aa, bb;
    for (int i = 0;i < N;i += 2) {
    	if (X[i] > 0) {
    		a += X[i];
    		aa.push_back(i);
    	}
    }
    for (int i = 1;i < N;i += 2) {
    	if (X[i] > 0) {
    		b += X[i];
    		bb.push_back(i);
    	}
    }
    if (a < b) {
    	swap(a, b);
    	swap(aa, bb);
    }
    cout << a << endl;
    vector<int> sol;
    vector<int> g(N, 0);
    for (int i = 0;i < aa.size();i++) g[aa[i]] = 1;
    while (g.size() > 1) {
    	vector<int> h;
    	if (g[0] == 1) {
    		if (g[g.size() - 1] == 0) {
    			sol.push_back(g.size());
    			for (int j = 0;j < g.size() - 1;j++) h.push_back(g[j]);
    		}
    	    else {
    	    	bool ok = 0;
    	    	for (int j = 1;j < g.size() - 1 && ok == 0;j++) {
    	    		if (g[j - 1] == 0 && g[j] == 0 && g[j + 1] == 0) {
    	    			sol.push_back(j + 1);
    	    			for (int k = 0;k < g.size();k++) {
    	    				if (k != j - 1 && k != j + 1 && k != j) h.push_back(g[k]);
    	    				if (k == j) h.push_back(0);
    	    			}
    	    			ok = 1;
    	    		}
    	    		else if (g[j - 1] == 1 && g[j] == 0 && g[j + 1] == 1) {
    	    			sol.push_back(j + 1);
    	    			for (int k = 0;k < g.size();k++) {
    	    				if (k != j - 1 && k != j + 1 && k != j) h.push_back(g[k]);
    	    				if (k == j) h.push_back(1);
    	    			}
    	    			ok = 1;
    	    		}
    	    	}
    	    }
    	} else {
    		sol.push_back(1);
    		for (int j = 1;j < g.size();j++) h.push_back(g[j]);
    	}
        swap(g, h);
    }
    cout << sol.size() << endl;
    for (int i = 0;i < sol.size();i++) cout << sol[i] << endl;
    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define int long long
#define x first
#define y second
#define inf 1000000000000000000
#define N 1000000007
#define speed ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.x<<','<< P.y<<')';}
template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}


//edge cases when n=1,m=1.wrong variable in loop.if<->while;merge resize;LLONG_MAX
signed main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //#endif
    speed
    //global var
    int n,x,t;cin>>n>>x>>t;
    int q=(n/x)+((n%x)!=0);
    cout<<q*t<<"\n";
}
//try thinking from a different angle after spending some time


Measured memory_bytes: 3648
/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.

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

int mod = 1000000007;
ll dp[100005];
const ll INF = 1e18;

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

bool sortbyval(const pair<string, int> &a,
               const pair<string, int> &b){
    return (a.second < b.second);
}

int main(){

string s;
 cin>>s;

 int start=0,ends=-2;

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

    if(s[i] == 'A'){
        start = i;
        break; }
 }

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

    if(s[i] == 'Z'){
        if(i>ends)
            ends = i; }
 }


 //ends = ends+1;

 cout<<ends-start+1<<endl;

return 0;
}


Measured memory_bytes: 3728
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int M = sc.nextInt();
    int D = sc.nextInt();
    
    int ans = 0;
    for(int i = 1; i <= M; i++){
      for(int j = 1; j <= D; j++){
        int d1 = j%10;
        int d2 = j/10;
        if(d1 < 2 || d2 < 2){
          continue;
        }
        if(d1*d2 == i){
          ans++;
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 20948
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long l,r; cin >> l >> r;
    long long mi = 2019;
    if(r-l >= 2019){
        cout << 0 << endl; return 0;
    }
    for(long long i = l; i < r; i++){
        for(long long  j = i+1; j <= r; j++){
            mi = min(mi, (i*j)%2019);
            if(mi == 0){
                cout << mi << endl; return 0;
            }
        }
    }
    cout << mi << endl;

}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, k int
	fmt.Scanf("%d %d", &n, &k)
	x := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &x[i])
	}

	sort.Ints(x)

	sum := 0
	for i := 0; i < k; i++ {
		sum += x[i]
	}
	fmt.Printf("%d", sum)
}


Measured memory_bytes: 1888
listS=[1,2,3,4,5,6,7,8,9,10,11,12,13]
listH=[1,2,3,4,5,6,7,8,9,10,11,12,13]
listC=[1,2,3,4,5,6,7,8,9,10,11,12,13]
listD=[1,2,3,4,5,6,7,8,9,10,11,12,13]

n=int(input())

for i in range(n):
    m, s = map(str,input().split())

    if m == "S":
        listS.remove(int(s))

    elif  m == "H":
        listH.remove(int(s))

    elif m == "C":
        listC.remove(int(s))

    else:
        listD.remove(int(s))

for i in listS:
    print("S "+str(i))
for i in listH:
    print("H "+str(i))
for i in listC:
    print("C "+str(i))
for i in listD:
    print("D "+str(i))

Measured memory_bytes: 7772
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

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

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
}
void File()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("story.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 1e5 + 15;
int dx[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };
int dy[8] = { 0, 0, 1, -1, 1, -1, -1, 1 };

int main()
{
	fast();
	//File();
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5])
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
A = [[int(x) for x in input().split()] for i in range(3)]
n = int(input())
B = {int(input()) for i in range(n)}
for i in range(3):
  for j in range(3):
    if A[i][j] in B:
      A[i][j] = 0
flg = False
for i in range(3):
  if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
    flg = True
  if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
    flg = True
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
  flg = True
if A[2][0] == 0 and A[1][1] == 0 and A[0][2] == 0:
  flg = True
print('Yes' if flg else 'No')

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

using namespace std;

uint64_t cal_lucas(int N)
{
  if(N == 0) return 2;
  else if(N == 1) return 1;
  else return cal_lucas(N - 2) + cal_lucas(N - 1);
}

int main(){
  int N;
  vector<uint64_t> L(87);
  cin >> N;
  if(N > 86 || N < 0) {
    printf("error");
    return 0;
  }else{
    L.at(0) = 2;
    L.at(1) = 1;
    for (int i = 2; i <= N; i++){
      L.at(i) = L.at(i - 1) + L.at(i - 2);
    }
  }
  //L = cal_lucas(N);
  cout << L.at(N) << endl;
}

Measured memory_bytes: 384