akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (Math.abs(N-a)<Math.abs(N-b)) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}

	}
}

Measured memory_bytes: 22612
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


a, b, c, x, y = map(int, input().split())

min_v = min(x, y)
max_v = max(x, y)

candidate1 = (a * x) + (b * y)
candidate2 = c * (max_v * 2)
candidate3 = c * (min_v * 2) + (a * (max_v - min_v) if max_v == x else b * (max_v - min_v))

print(min(candidate1, candidate2, candidate3))

Measured memory_bytes: 61832
#include <iostream>
#include <string>
using namespace std;
int sscheck(string str);

int main(){
	string str;
	int l;
	cin >> str;

	while(1){
		str.erase(str.end()-1,str.end());
		if(sscheck(str)==1){
			break;
		}
	}
	l = str.length();

	cout << l << endl;

	
	return 0;
}


//1 ok   0 not ss
int sscheck(string str){
	if (str.length() % 2 ==1)return 0;
	int l;
	string fh,sh;//first second

	l = str.length();
	sh = str;
	fh = str;

	fh.erase(fh.end()-l/2,fh.end());
	sh.erase(sh.begin(),sh.begin()+l/2);
	if (sh == fh) {
		return 1;
	}else{
		return 0;
	}

}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	string s;
	cin >> s;
	for (int i = 0; i < sz(s); i++)
	{
		if (i % 2 == 0)
		{
			if (s[i] == 'L')
			{
				cout << "No";
				return 0;
			}
		}
		else
		{
			if (s[i] == 'R')
			{
				cout << "No";
				return 0;
			}
		}

	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split(" ")]
swop = 0
for i, a in enumerate(A):
    j = N - 1
    while j >= i + 1:
        if A[j] < A[j - 1]:
            tmp = A[j]
            A[j] = A[j - 1]
            A[j - 1] = tmp
            swop += 1
        j -= 1
print(" ".join([str(a) for a in A]))
print(swop)

Measured memory_bytes: 7740
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>

int dcmp(double x) {
    static double eps = 1e-8;
    return (x > eps) - (x < -eps);
}

struct vec{
    double x, y;

    vec(double _x=0, double _y=0)
        :x(_x), y(_y) {}

    vec operator- () const{ return vec(-x, -y); }
    
    vec operator+ (const vec& v) const{ return vec(x+v.x, y+v.y); }
    vec operator- (const vec& v) const{ return vec(x-v.x, y-v.y); }
    vec operator* (double c) const{ return vec(x*c, y*c); }
    vec operator/ (double c) const{ return vec(x/c, y/c); }

    double dot(const vec& v) const{ return x*v.x + y*v.y; }
    double cross(const vec& v) const{ return x*v.y - y*v.x; }

    double len2() const{ return x*x + y*y; }
    double len() const{ return sqrt(len2()); }
    
    vec& norm() { return *this = *this / len(); }
    vec& rot(double rad) {
        return  *this = vec(x*cos(rad) - y*sin(rad), x*sin(rad) + y*cos(rad));
    }

    bool operator< (const vec& v) const{
        return dcmp(x-v.x) < 0 || (dcmp(x-v.x)==0 && dcmp(y-v.y) < 0);
    }
};

struct line{
    vec u, v; // u + x*v

    line() {}
    line(vec _u, vec _v)
        :u(_u), v(_v) {}
};

line makeline(vec a, vec b) {
    return line(a, (b - a).norm());
}

bool on_left(line l, vec u) {
    return dcmp(l.v.cross(u - l.u)) > 0;
}

vec line_intersection(line a, line b) {
    return b.u + b.v * b.v.cross(b.u-a.u) / a.v.cross(b.v);
}

bool segment_intersection(vec a, vec b, vec c, vec d) {
    line x = line(a, b-a), y = line(c, d-c);
    return on_left(x, c) != on_left(x, d) && on_left(y, a) != on_left(y, b);
}

std::vector<vec> convex_hull(std::vector<vec> p) {
    std::sort(p.begin(), p.end());
    std::vector<vec> ch;
    for (size_t i = 0; i < p.size(); ++i) {
        while (ch.size() > 1 && on_left(makeline(ch[ch.size()-2], p[i]), ch[ch.size()-1]))
            ch.pop_back();
        ch.push_back(p[i]);
    }
    size_t k = ch.size();
    for (int i = p.size() - 2; i >= 0; --i) {
        while (ch.size() > k && on_left(makeline(ch[ch.size()-2], p[i]), ch[ch.size()-1]))
            ch.pop_back();
        ch.push_back(p[i]);
    }
    ch.pop_back();
    return ch;
}

// end template

int main() {
    std::vector<vec> v;

    int n; scanf("%d", &n);
    while (n--) {
        int x, y;
        scanf("%d%d", &x, &y);
        v.push_back(vec(x, y));
    }

    std::vector<vec> p = convex_hull(v);
    int s = std::min_element(p.begin(), p.end(), [](vec a, vec b) { return a.y == b.y ? a.x < b.x : a.y < b.y; }) - p.begin();
    
    printf("%d\n", (int) p.size());
    for (int i = s; i < p.size(); ++i)
        printf("%.0f %.0f\n", p[i].x, p[i].y);
    for (int i = 0; i < s; ++i)
        printf("%.0f %.0f\n", p[i].x, p[i].y);
    return 0;
}



Measured memory_bytes: 7828
#pragma region include
#include "bits/stdc++.h"
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i >= 0; i--)
#define FOR(i,n,m) for(int i = (int)(n); i < int(m); i++)
#define MOD (int)(1e9+7)
#define INF (int)(1e9)
#define LLINF (int)(4e18)
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
void input() {}
template<typename... R> void input(int& f, R&... r) { scanf("%d", &f); input(r...); }
template<typename... R> void input(double& f, R&... r) { scanf("%lf", &f); input(r...); }
template<typename... R> void input(ll& f, R&... r) { scanf("%lld", &f); input(r...); }
template<typename... R> void input(char& f, R&... r) { scanf("%c", &f); input(r...); }
template<typename... R> void input(string& f, R&... r) { cin >> f; input(r...); }
template<typename T, typename... R> void input(vector<T>& f, R&... r) { REP(i, f.size())input(f[i]); input(r...); }
#pragma endregion

ll N, A, B;
vector<ll> h;

bool f(int k) {
    vector<ll> a = h;
    ll cnt = 0;
    REP(i, N) {
        a[i] -= B * k;
        if (a[i] > 0) {
            cnt += (a[i] + (A - B - 1)) / (A - B);  
        }
    }
    return cnt <= k;
}

// FFFFFTTTTT の時境界の右側を返す
int binarysearch() {
    int l = 0, r = INF;
    while (r - l > 1) {
        int k = (l - r) / 2 + r;
        if (f(k)) {
            r = k;
        }
        else {
            l = k;
        }
    }
    return r;
}

int main() {
    input(N,A,B);
    h.resize(N); input(h);
    cout << binarysearch() << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

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

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

using namespace std;

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

    vector <int> height(no_of_stones + 1, 0);
    for(int i = 1; i <= no_of_stones; i++)
        cin >> height[i];

    vector <int> minimum_cost(no_of_stones + 1);
    minimum_cost[2] = abs(height[2] - height[1]);
    for(int i = 3; i <= no_of_stones; i++)
        minimum_cost[i] = min(minimum_cost[i - 1] + abs(height[i] - height[i - 1]),
                              minimum_cost[i - 2] + abs(height[i] - height[i - 2]));

    cout << minimum_cost[no_of_stones];
    return 0;
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
typedef long long int ll;
using namespace std;
using Graph = vector<vector<int> >;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int N,M,X,Y;
cin>>N>>M>>X>>Y;
vector<int>x(N);
vector<int>y(M);
rep(i,N)cin>>x[i];
rep(i,M)cin>>y[i];
sort(x.begin(),x.end());
sort(y.begin(),y.end());
string ans;
if(x[N-1]<y[0] && X<Y && X<y[0] && x[N-1]<Y){ans="No War";}
else{ans="War";}
cout<<ans<<endl;

//system("pause");
return 0;
}

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

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for(T &x : vec) is >> x;
  return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
  os << "(" << pair_var.first << ", " << pair_var.second << ")";
  return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "{";
  for(int i = 0; i < vec.size(); i++) {
    os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
  }
  os << "}\n   ";
  return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
  os << "{";
  repi(itr, map_var) {
    os << *itr;
    itr++;
    if(itr != map_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
  os << "{";
  repi(itr, set_var) {
    os << *itr;
    itr++;
    if(itr != set_var.end()) os << ", ";
    itr--;
  }
  os << "}";
  return os;
}

#define DUMPOUT cerr

void dump_func() { DUMPOUT << endl; }
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
  DUMPOUT << head;
  if(sizeof...(Tail) > 0) {
    DUMPOUT << ", ";
  }
  dump_func(std::move(tail)...);
}
#ifdef DEBUG_
#define DEB
#define dump(...)                                                             \
  DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                             \
          << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]" << endl \
          << "    ",                                                          \
      dump_func(__VA_ARGS__)
#else
#define DEB if(false)
#define dump(...)
#endif

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  int cnt = 0;
  REP(i, N) {
    int p;
    cin >> p;
    p--;
    if(i == p) {
      cnt++;
    }
  }
  if(cnt == N - 2 || cnt == N) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}


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

using namespace std;

typedef long long ll;

const int N = 200010;
const int MOD = 998244353;

struct point {
  int x, y;
  point() {}
};

int ft[N];

int mul(int a, int b) {
  return (ll) a * b % MOD;
}

int add(int a, int b) {
  return (a + b) % MOD;
}

int sub(int a, int b) {
  return ((a - b) % MOD + MOD) % MOD;
}

void inc(int i) {
  while (i < N) {
    ++ft[i];
    i += i & -i;
  }
}

int get(int i) {
  int sum = 0;
  while (i) {
    sum += ft[i];
    i -= i & -i;
  }
  return sum;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n;
  cin >> n;
  vector<point> P(n);
  map<int, int> fake;
  for (point &p : P) {
    cin >> p.x >> p.y;
    fake[p.y];
  }
  int id = 0;
  for (auto &f : fake) {
    f.second = ++id;
  }
  vector<int> pw(n + 1, 1);
  for (int i = 1; i <= n; ++i) {
    pw[i] = mul(pw[i - 1], 2);
  }
  for (int i = 0; i <= n; ++i) {
    pw[i] = sub(pw[i], 1);
  }
  sort(P.begin(), P.end(), [&](const point &a, const point &b) {
    return a.x < b.x;
  });
  int asw = mul(n, pw[n]);
  for (int i = 0; i < n; ++i) {
    asw = sub(asw, pw[i]);
    asw = sub(asw, pw[n - i - 1]);
    int j = fake[P[i].y];
    int u = get(j);
    asw = add(asw, pw[u]);
    asw = add(asw, pw[i - u]);
    inc(j);
  }
  fill(ft, ft + N, 0);
  for (int i = n - 1; i >= 0; --i) {
    int j = fake[P[i].y];
    int u = get(j);
    asw = add(asw, pw[u]);
    asw = add(asw, pw[n - i - u - 1]);
    inc(j);
  }
  sort(P.begin(), P.end(), [&](const point &a, const point &b) {
    return a.y < b.y;
  });
  for (int i = 0; i < n; ++i) {
    asw = sub(asw, pw[i]);
    asw = sub(asw, pw[n - i - 1]);
  }
  cout << asw << endl;
  return 0;
}

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

char X[1001];
char Y[1001];

int LCS(int, int);

int main(){
  int n, i, commonlength;
  int len1, len2;
  
  scanf("%d",&n);
  
  for(i = 0 ; i < n ; i++){
    scanf("%s",X);
    scanf("%s",Y);
    len1 = strlen(X);
    len2 = strlen(Y);

    commonlength = LCS(len1,len2);
    printf("%d\n",commonlength);
  }

  return 0;
}
    
int LCS(int x, int y){
  int i, j;
  int Z[1001][1001];

  for(i = 0 ; i <= x ; i++) Z[i][0] = 0;
  for(i = 0 ; i <= y ; i++) Z[0][i] = 0;

  for(i = 1 ; i <= x ; i++){
    for(j = 1 ; j <= y ; j++){
      if(X[i-1] == Y[j-1]){
	Z[i][j] = Z[i-1][j-1]+1;
      }
      else if(Z[i-1][j-1] >= Z[i][j-1]){
	Z[i][j] = Z[i-1][j];
      }
      else{
	Z[i][j] = Z[i][j-1];
      }
    }
  }

  if(i == 0 || j == 0) return 0;
  else if(i > 0 && j > 0 && x == y) return Z[i-1][j-1];
  else if(i > 0 && j > 0 && x != y) return Z[x][y];
}



Measured memory_bytes: 5656
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    vector<pair<int,int>> l(n);

    for(int i = 0; i < n; i++){
        cin >> l[i].second >> l[i].first;
    }

    sort(l.begin(), l.end());

    int now = 0;

    for(int i = 0; i < n; i++){
        if(now + l[i].second > l[i].first){
            cout << "No" << endl;
            return 0;
        } else {
            now += l[i].second;
        }
    }

    cout << "Yes" << endl;
    
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
main(void)
{
	int k,odd,even;
  	cin>>k;
  	if(k%2==0)
    {
      odd=k/2;
      even=k/2;
    }
  	else
    {
    	even=k/2;
      	odd=k-even;
    }
  	cout<<odd*even<<endl;
}


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

using namespace std;

int main() {
  string O, E;
  cin >> O >> E;
  string answer;
  for (int i = 0; i < O.length(); i++) {
    answer += O[i];
    if (i < E.length()) {
      answer += E[i];
    }
  }
  cout << answer << "\n";

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

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

int main() {
  int n, ans = 0, a;
  scanf("%d", &n);
  for (size_t i = 0; i < n; i++) {
    scanf("%d", &a);
    ans = gcd(a, ans);
  }
  printf("%d\n", ans);
  return 0;
}


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

int main(void){
    long long N, K, x;

    scanf("%lld%lld", &N, &K);
    x = N;

    if(x > K)
        x %= K;
    if(x > K/2)
        x = K - x;

    printf("%lld\n", x);

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
  int i, j, H, W;
  int ff = 0;
  while(cin >> H >> W) {
	if (H == 0 || W == 0) { break; }
	for(i = 0; i < H; i++) {
	  for(j = 0; j < W; j++) {
		if((i + j) % 2 == 0) { cout << "#"; }
		else { cout << "."; }
	  }
	  cout << endl;
	}
	cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3064
# https://atcoder.jp/contests/abc165/submissions/12605117
# 写経

def main():
    from itertools import combinations_with_replacement
    import numpy as np

    N, M, Q = map(int, input().split())

    abcd = []
    for _ in range(Q):
        a, b, c, d = map(int, input().split())
        abcd.append((a - 1, b - 1, c, d))

    temp_As = np.array(
        tuple(combinations_with_replacement(
            iterable=range(1, M + 1),
            r=N
        )), dtype=np.int32
    )

    scores = np.zeros(len(temp_As), dtype=np.int32)
    for a, b, c, d in abcd:
        cond = temp_As[:, b] - temp_As[:, a] == c
        scores += d * cond

    print(scores.max())


if __name__ == '__main__':
    main()

# a = np.array([0] * 4)
# a += range(4)
# # array([0, 1, 2, 3])


Measured memory_bytes: 43148
class Dise():
    def __init__(self, d1,d2,d3,d4,d5,d6):
        self.s1 = d1
        self.s2 = d2
        self.s3 = d3
        self.s4 = d4
        self.s5 = d5
        self.s6 = d6

    def roll_N(self):
        sub = self.s1
        self.s1 = self.s2
        self.s2 = self.s6
        self.s6 = self.s5
        self.s5 = sub

    def roll_S(self):
        sub = self.s1
        self.s1 = self.s5
        self.s5 = self.s6
        self.s6 = self.s2
        self.s2 = sub

    def roll_E(self):
        sub = self.s1
        self.s1 = self.s4
        self.s4 = self.s6
        self.s6 = self.s3
        self.s3 = sub

    def roll_W(self):
        sub = self.s1
        self.s1 = self.s3
        self.s3 = self.s6
        self.s6 = self.s4
        self.s4 = sub

    def top(self):
        print(self.s1)



inline = input().split()
d1, d2, d3, d4, d5, d6 = (int(xi) for xi in inline)
roll1 = input()
dise1 = Dise(d1, d2, d3, d4, d5, d6)

length = len(roll1)
for xi in range(length):
    if roll1[xi]=="N":
        dise1.roll_N()
    if roll1[xi]=="E":
        dise1.roll_E()
    if roll1[xi]=="W":
        dise1.roll_W()
    if roll1[xi]=="S":
        dise1.roll_S()

dise1.top()



Measured memory_bytes: 5612
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;

long double a[10000],A=0;

int main() {
	ll n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		A += 1/a[i];
	}
	cout << setprecision(8) << 1/A << endl;
}




Measured memory_bytes: 384
# coding: utf-8
# Your code here!




def insert_str(target, i, char):
    return target[:i] + char + target[i:]

def calc(target, i):
    global ans
    
    if ans != "":
        return
    
    if i == 7:
        if eval(target) == 7:
            ans = target+"=7"
            return ans
        return
    calc(insert_str(target, i, "+"), i+2)
    calc(insert_str(target, i, "-"), i+2)
        
S = input()
N = len(S)
ans = ""
calc(S, 1)


print(ans)






Measured memory_bytes: 9040
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include<iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;
const ll mod=1000000007;
/*pi*/const double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 ll a,b;cin>>a>>b;
 //ll n;cin>>n;
 ll x,y,ans=0;
 b*=b;
 rep(i,0,a){
  cin>>x>>y;
  if(x*x+y*y<=b)ans++;
 }
 pr(ans);
return 0;}

Measured memory_bytes: 3636
#include <stdio.h>
#include <math.h>

int main()
{
 int d,t,t1		;
 float x=0,h,y=0,k  ;
 
  scanf("%d,%d",&d,&t);
  t1=270;
 while(1)
 {
  sincosf((-t1)*M_PI/180,&k,&h);
  x+=d*h;
  y+=d*k;
  
  t1+=t	;
  scanf("%d,%d",&d,&t);
  if(!(d+t)) break;
 }
 
 printf("%d\n%d\n",(int)x,(int)y);
 
 return 0;
}

Measured memory_bytes: 628
#include <bits/stdc++.h>
//#define int long long
#define re(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin,v.end()
using namespace std;
typedef pair<int,int>P;
struct UnionFind{
  int n;
  vector<int> r,p;
  UnionFind(){}
  UnionFind(int sz):n(sz),r(sz,1),p(sz,0){iota(p.begin(),p.end(),0);}
  int find(int x){
    return (x==p[x]?x:p[x]=find(p[x]));
  }
  bool same(int x,int y){
    return find(x)==find(y);
  }
  void unite(int x,int y){
    x=find(x);y=find(y);
    if(x==y) return;
    if(r[x]<r[y]) swap(x,y);
    r[x]+=r[y];
    p[y]=x;
  }
};
 
int dx[]={0,0,-1,1};
int dy[]={1,-1,0,0};
int n,m;
vector<P>v[100090];
int ans,x,y;
int h[100999];
signed main(){
  cin>>n>>m;
  int a[n];
  UnionFind U(n+10);
  re(i,n)cin>>a[i],a[i]--,h[a[i]]=i;
  re(i,m){
    cin>>x>>y;
    x--;y--;
    U.unite(x,y);
  }
  re(i,n)if(U.same(i,h[i]))ans++;
  cout<<ans<<endl;
}

Measured memory_bytes: 4224
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>

using ll = long long int;
using P = std::pair<ll, int>;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

ll c[30],s[400][30];

int main(void){
	int d,i,j,n=26;
	std::cin >> d;
	for(i=0; i<26; ++i){
		std::cin >> c[i];
	}
	for(i=0; i<d; ++i){
		for(j=0; j<n; ++j){
			std::cin >> s[i][j];
		}
		std::cout << ((i%26)+1) << std::endl;
	}
	return 0;
}


Measured memory_bytes: 3724
N = int(input())
ans = [0] * N
sqrt_N = (int(N**0.5 + 1))

for x in range(1,sqrt_N):
    for y in range(1,sqrt_N):
        for z in range(1,sqrt_N): 
            xyz = (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)
            if xyz <= N:
                ans[xyz - 1] = ans[xyz - 1] + 1

[print(i) for i in ans]

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

typedef long long ll;
typedef pair<ll, ll> P;


#define rep(i,n) for(ll (i)=0; (i)<(ll)(n); (i)++)
#define frep(i,m,n) for(ll (i)=(m); (i)<=(ll)(n); (i)++)
#define rrep(i,n) for(ll (i)=(n)-1; (i)>-1; (i)--)
#define frrep(i,m,n) for(ll (i)=(n); (i)>(ll)(m); (i)--)
#define ALL(x) (x).begin(), (x).end()

const ll INF = 100100100100100100;
const ll MOD = 1000000007;

// get abs
ll my_abs(ll a);
// a^n
ll a_n(ll a, ll n);
// get gcd
ll my_gcd(ll a, ll b);
// a^(-1) % MOD 
ll inv(ll a);
// (a+b+c)%MOD
ll madd(ll a, ll b, ll c);
// (a-b)%MOD
ll msub(ll a, ll b);
// (a*b*c)%MOD
ll mtime(ll a, ll b, ll c);


int main() {
    ll m, n, k; cin >> n >> m >> k;
    vector<ll> a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];

    vector<ll> asum(n, 0), bsum(m, 0);
    rep(i, n) {
        if(i == 0) {
            asum[i] = a[i];
        }
        else {
            asum[i] = asum[i-1]+a[i];
        }
    }
    rep(i, m) {
        if(i == 0) {
            bsum[i] = b[i];
        }
        else {
            bsum[i] = bsum[i-1]+b[i];
        }
    }
    ll ans = 0;

    // kより大きい最初のやつ
    auto iter = upper_bound(ALL(asum), k)-asum.begin();
    for(ll i = iter; i >= 0; i--) {
        ll x;
        if(i == 0) x = k;
        else {
            x = k - asum[i-1]; // 未使用
        }
        ll num = upper_bound(ALL(bsum), x)-bsum.begin();
        if(ans <= num + i) ans = num+i;
    }
    cout << ans << endl;

    return 0;
}

ll my_abs(ll a) {
    if(a >= 0) return a;
    else return -1 *a;
}

ll a_n(ll a, ll n) { 
    if(n == 0) return 1;
    
    ll ret = a, count = 1;
    while(count * 2 < n) {
        ret *= ret;
        count *= 2;
    }
    if(count == n) return ret;
    else return (ret * a_n(a, n-count));
}

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

ll inv(ll a) {
    return a_n(a, MOD-2);
}

ll madd(ll a, ll b, ll c) {
    ll ret = (a+b) % MOD;
    return (ret+c) % MOD;
}

ll msub(ll a, ll b) {
    if(a < b) return (a-b+MOD) % MOD;
    else return (a-b) % MOD;
}

ll mtime(ll a, ll b, ll c) {
    ll ret = (a*b) % MOD;
    return (ret*c) % MOD;
}


Measured memory_bytes: 9592
n, m, X, Y = map(int, input().split())

x = list(map(int, input().split()))
y = list(map(int, input().split()))

max_x = max(x)
min_y = min(y)
ans = 'War'
for z in range(X+1, Y+1):
    if z > max_x and z <= min_y:
        ans = 'No War'
        break

print(ans)


Measured memory_bytes: 3060
def find_ans(N,K):
    # K==0ならN^2が答え
    if K==0:
        return N**2
    
    # そうでなければK+1～Nについて一般式
    else:
        ans = 0
        for i in range(K+1,N+1):
            ans += (N//i)*(i-K) + max(N%i-(K-1), 0)
            
        return ans
    
N,K = map(int, input().split())
print(find_ans(N,K))


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

import math

def main():
    a, b, h, m = map(int, input().split())

    ra = 2.0 * math.pi * (h / 12 + m / (12 * 60))
    ax = math.cos(ra) * a
    ay = math.sin(ra) * a

    rb = 2.0 * math.pi * (m / 60)
    bx = math.cos(rb) * b
    by = math.sin(rb) * b

    d = math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)

    print(str(d) + '\n')


if __name__ == '__main__':
    main()


Measured memory_bytes: 62580
#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 <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define endl "\n"
using namespace std;
using ll = long long;
using bnum = int64_t;
ll pi= static_cast<ll>(3.1415926535897932384626433l);
int diff(ll a){
    a = floor(a / 2);
    return a;
}
void solve(){
    vector<ll> s(3);
    for(int i = 0;i<3;++i){
        cin >> s[i];
    }sort(s.begin(),s.end());
    ll d = diff(s.at(2));
    cout << ((s.at(2) - d) * s.at(1) * s.at(0)) - (d * s.at(1) * s.at(0)) << endl;
}
int main(){
    solve();
}


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

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx") 
using namespace std;
typedef long long lint;
typedef long double ldb;
typedef unsigned long long uli;

#define X first
#define Y second
#define F(i, l, r) for(auto i = l; i != r; i++)
#define Df(i, l, r) for(auto i = l; i != r; i--)
#define I(i, a) for(auto i : a)
#define pb push_back
#define rs resize
#define mk make_pair
#define asg assign
#define all(x) x.begin(),x.end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define era erase
#define fi0(x) memset(x, 0, sizeof(x))
#define finf(x) memset(x, 127, sizeof(x))
#define acpy(y, x) memcpy(y, x, sizeof(y))
#define y1 adjf
#define tm afhdhn

int n, a, b, c, d;

int main(){
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	if(b < a)swap(a, b);
	if(c == 0 && d == 0){
		if(a == b)printf("YES"); else printf("NO");
		ret 0;
	}
	lint f1 = b - a + d * 1ll * (n - 1);
	lint f2 = b - a + c * 1ll * (n - 1);
	lint ub = min(n - 1ll, f1/(c+d));
	lint lb = max(0ll, (f2%(d+c)==0) ? f2/(d+c) : (f2/(d+c)+1));
	if(lb > ub)printf("NO"); else printf("YES");
	ret 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <sstream>
#include <map>
#include <set>
#include <queue>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<30
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main() {
	int n;
	while(cin >> n && n) {
		vector<string> v(n), v2(n);
		rep(i, n) cin >> v[i] >> v2[i];

		string s, t;
		cin >> s >> t;

		queue<pair<string, int> > que;
		que.push(mp(s, 0));
		int ans = -1;

		while(que.size()) {
			pair<string, int> p = que.front();
			que.pop();

			if(p.first == t) {
				ans = p.second;
				break;
			}

			rep(i, n) {
				bool flag = false;
				string s2 = p.first;
				string::size_type id = s2.find(v[i]);
				while(id != string::npos) {
					flag = true;
					s2.replace(id, v[i].size(), v2[i]);
					id = s2.find(v[i], id + v2[i].size());
				}

				if(flag && s2.size() <= t.size()) {
					que.push(mp(s2, p.second + 1));
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int>a(n);
  for(int i=0;i<n;i++){
  cin >> a.at(i);
  }
  string s="YES";
  sort(a.begin(), a.end());
  for(int j=0;j<n-1;j++){
    if(a.at(j)==a.at(j+1)){
    s="NO";
    break;  
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;


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

  int keta_before = -1;
  if( N == 0){
    cout << 0 << endl;
    return 0;
  }

  while(1){
    int keta;

    if(N > 0){
      long long tmpN = 3*N + 1;
      long long tmp = 1;
      int k = 0;
      while(tmp < tmpN){
        tmp *= 4;
        k++;
      }
      k--;

      keta = 2*k;

      long long tmpPower = 1;
      for(int j=0;j<keta;j++){
        tmpPower *= -2;
      }
      N -= tmpPower;
    }else if(N < 0){
      long long tmpN = -3*N + 2;
      long long tmp = 2;
      int k = 0;
      while(tmp < tmpN){
        tmp *= 4;
        k++;
      }

      keta = 2*k - 1;
      long long tmpPower = 1;
      for(int j=0;j<keta;j++){
        tmpPower *= -2;
      }
      N -= tmpPower;
    }else{ // N == 0 のとき
      keta = -1;
    }

    if(keta_before != -1){
      keta_before--;
      while(keta_before > keta){
        cout << 0;
        keta_before--;
      }
      if(keta_before == -1){
        break;
      }
      if(keta != -1) cout << 1;

      //cout << "test:" << N << endl;

    }else{
      cout << 1;
    }
    keta_before = keta;
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	
	int w,h,x,y,r;
	
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	
	if(x+r<=w && y+r<=h){
		
		if(x>0 && y>0){
			
			printf("Yes\n");
			
		}
		else{
			
			printf("No\n");
		
		};
	}
	else{
		
		printf("No\n");
		
	};
	
	return 0;
	
};

Measured memory_bytes: 584
a = [[0,0,0],[0,0,0],[0,0,0]]
b =[[False,False,False], [False,False,False], [False,False,False]]
x = input()
z = x.split()
a[0][0] = z[0]
a[0][1] = z[1]
a[0][2] = z[2]

r = input()
t = r.split()
a[1][0] = t[0]
a[1][1] = t[1]
a[1][2] = t[2]

j = input()
k = j.split()
a[2][0] = k[0]
a[2][1] = k[1]
a[2][2] = k[2]


n = int(input())
for i in range(n):
  l = int(input())
  for s in range(3):
    for d in range(3):
      if(int(a[s][d]) == l):
        b[s][d] = True
        break

o = False;

if( (b[0][0]) & (b[0][1]) & (b[0][2])):
  o = True
elif( (b[1][0])& (b[1][1])& (b[1][2])):
  o = True
elif(b[2][0]& b[2][1]& b[2][2]):
  o = True
elif(b[0][0]& b[1][0]& b[2][0]):
  o = True
elif(b[0][1]& b[1][1]& b[2][1]):
  o = True
elif(b[0][2]& b[1][2]& b[2][2]):
  o = True
elif(b[0][0]& b[1][1]& b[2][2]):
  o = True
elif(b[0][2]& b[1][1]& b[2][0]):
  o = True

if(o == True):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3192
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

use std::collections::VecDeque;

fn main() {
    scan!(s; String);
    scan!(q; usize);

    let mut que = s.chars().map(|c| c)
        .collect::<VecDeque<char>>();

    let mut rev_flag = false;

    for _ in 0..q {
        scan!(query; Vec<String>);
        if query[0] == "1" {
            rev_flag = !rev_flag;
            continue;
        }

        let flag = (query[1] == "2") ^ rev_flag;
        let c = query[2].chars().nth(0).unwrap();

        if !flag {
            que.push_front(c);
        } else {
            que.push_back(c);
        }
    }

    let ans = if !rev_flag {
        que.iter().map(|&c| c).collect::<String>()
    } else {
        que.iter().rev().map(|&c| c).collect::<String>()
    };

    println!("{}", ans);
}


Measured memory_bytes: 8700
#include "iostream"
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (a == 1)a = 14;
	if (b == 1)b = 14;
	if (a > b)cout << "Alice" << endl;
	else if (a == b)cout << "Draw" << endl;
	else cout << "Bob" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>


void output(int i) {
  std::cout << " " << i;
}


void call(int n) {
  int x;
  for (int i = 1; i <= n; i ++) {
    x = i;
    if (x % 3 == 0 ) {
      output(i);
      continue;
    } else {
      do {
        if (x % 10 == 3) {
          output(i);
          break;
        } else {
          x /=10;
        }
      } while (x != 0);
    }
  }
  std::cout << std::endl;
}


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

  return 0;
}



Measured memory_bytes: 3092
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
#define P pair<int, int>
using namespace std;
int main(void){
    string s ;
    cin >> s ;
    size_t n = s.length() ;
    int count = 0 ;
    rep(i , n - 1 ){
        if(s[i] != s[i+1]){
            count++ ;
        }
    }
    cout << count << endl;
    return 0 ;
}
    
  

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

const int MAXINT = 1010;
int main (){
    int n, y1, x1, y2, x2, s, ans;
    cin >> n;
    int a[MAXINT+1][MAXINT+1] = {};
    for (int i = 0; i < n; i++){
    	cin >> y1 >> x1 >> y2 >> x2;
        a[y1][x1] += 1;
        a[y2][x2] += 1;
        a[y2][x1] -= 1;
        a[y1][x2] -= 1;
    }
    
    for (int i = 0; i <= MAXINT; i++){
    	s = 0;
    	for (int j = 0; j <= MAXINT; j++){
        	s += a[i][j];
            a[i][j] = s;
        }
    }    

    for (int j = 0; j <= MAXINT; j++){
    	s = 0;
    	for (int i = 0; i <= MAXINT; i++){
        	s += a[i][j];
            a[i][j] = s;
        }
    }   
    
    ans = 0;
    for (int i = 0; i <= MAXINT; i++){
    	for (int j = 0; j <= MAXINT; j++){
        	ans = max(ans, a[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 7108
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner (System.in)) {
            while (true) {
                int a = sc.nextInt();
                String op = sc.next();
                int b = sc.nextInt();
                int answer;
                switch (op) {
                    case "+":
                        answer = a + b;
                        break;
                    case "-":
                        answer = a - b;
                        break;
                    case "*":
                        answer = a * b;
                        break;
                    case "/":
                        answer = a / b;
                        break;
                    default:
                        return;
                }
                System.out.println(answer);
            }
        }
    }
}



Measured memory_bytes: 26340
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m);
    REP(i, m)
    cin >> a[i];

    ll total = accumulate(ALL(a), 0);

    if (n - total >= 0)
    {
        cout << n - total << endl;
    }
    else
    {
        cout << "-1" << endl;
    }
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline
'''
allinputs = iter(input().splitlines())
input = lambda : next(allinputs)
#'''
N, A, B, C = map(int, input().split())
l = [int(input()) for _ in range(N)]

m = 4 ** N - 1
group = [0] * N
flag1, flag2, flag3 = -1, -1, -1
sum1, sum2, sum3 = 0, 0, 0
min_cost = 3000

for i in range(m):
	tmp = i
	for j in range(N):
		group[j] = tmp % 4
		tmp //= 4
		if group[j] == 1:
			flag1 += 1
			sum1 += l[j]
		elif group[j] == 2:
			flag2 += 1
			sum2 += l[j]
		elif group[j] == 3:
			flag3 += 1
			sum3 += l[j]
			
	if flag1 >= 0 and flag2 >= 0 and flag3 >= 0:
		cost = 10 * (flag1 + flag2 + flag3) + abs(sum1 - A) + abs(sum2 - B) + abs(sum3 - C)
		if cost < min_cost:
			min_cost = cost
			
	flag1, flag2, flag3 = -1, -1, -1
	sum1, sum2, sum3 = 0, 0, 0
	
print(min_cost)

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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  long long N;
  cin >> N;
  vector<long long> A(N), B(N), C(N - 1);
  for (size_t i = 0; i < N; ++i) cin >> A[i];
  for (size_t i = 0; i < N; ++i) cin >> B[i];
  for (size_t i = 0; i < N - 1; ++i) cin >> C[i];

  long long dish, satisfaction = 0;
  long long prev_dish = -10;
  for (size_t i = 0; i < N; i++) {
    dish = A[i] - 1;
    satisfaction += B[dish];
    if (dish - prev_dish == 1) satisfaction += C[prev_dish];
    prev_dish = dish;
  }
  cout << satisfaction << endl;
  return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
// #include <C:\include\boost\multiprecision\cpp_int.hpp>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define divup(a,b) ( ( (a) + ( (b) - 1u) ) / (b) ) // a/b の余り切り上げ
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
// using namespace boost::multiprecision;
ll mod = 1000000007;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    rep(i,n){
        if(i==n-1) cout<<a[i]<<endl;
        else cout<<a[i]<<" ";
    }
    for(int i=1;i<n;i++){
        int v=a[i];
        int j=i-1;
        while(j>=0 && a[j]>v){
            a[j+1]=a[j];
            j--;
        }
        a[j+1]=v;
        rep(i,n){
            if(i==n-1) cout<<a[i]<<endl;
            else cout<<a[i]<<" ";
        }
    }
}



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

#define MIN(X,Y) ((X)<(Y)?(X):(Y))

int main(void){
  string s,t;
  int ans;
  
  cin >> s >> t;
  ans = t.size();
  for (int i=0; i<s.size()-t.size()+1; i++){
    int d=t.size();
    for (int j=0; j<t.size(); j++){
      d -= s[i+j]==t[j];
    }
    ans = MIN(ans, d);
  }
  cout << ans << endl;
  
  return 0;
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a[i];

    int ans = 100100100100;
    for (int i = -100; i <= 100; i++) {
        int cost = 0;
        rep(j, N) cost += (a[j] - i) * (a[j] - i);
        chmin(ans, cost);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}


int main(void) {

	int n;
	cin >> n;
	
	if ((int)(ceil(n / 1.08) * 1.08) != n)
		COUT(":(");
	else
		COUT((int)ceil(n / 1.08));




	return 0;
}


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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

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

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


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


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

ll solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto &&e:a) cin >> e;

    const ll LINF = 1ll << 60;
    typedef pair<ll, ll> pll;
    typedef vector<pll> vpll;
    vector<vpll> dp = vector<vpll>(n + 1, vpll(n + 1, make_pair(LINF, LINF)));

    REP(i, n) dp[i][i + 1] = make_pair(0, a[i]);

    FOR(size, 2, n + 1) {
        REP(i, n) {
            int j = i + size;
            if (j > n) continue;

            FOR(t, i + 1, j) {
                ll p = dp[i][t].second + dp[t][j].second;
                ll u = dp[i][t].first + dp[t][j].first + p;
                chmin(dp[i][j], make_pair(u, p));
            }
        }
    }

    return dp[0][n].first;
}


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

//    cout << (solve() ? "First" : "Second") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}

Measured memory_bytes: 2816
#include<iostream>
#include<map>
#include<string>

using namespace std;

int main() {
  string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int m=A.size();
  map<char, int> M, N;
  for(int i=0;i<m;++i) {
    M[A[i]] = i;
  }
  int n;
  cin >> n;
  string S;
  cin >> S;
  for(int i=0;i<S.size();++i) {
    int k = M[S[i]];
    cout << A[(k+n)%m];
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

  int a, b, c, d;


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

  /* 自然数 a > b を確認・入替 */
  if(a<b){
    c = a;
    a = b;
    b = c;
  }

  /* ユークリッドの互除法 */
  d = a % b;
  while(d!=0){
    a = b;
    b = d;
    d = a % b;
  }

  /* 最大公約数を出力 */
  printf("%d\n",b);

  return 0;
}



Measured memory_bytes: 2140