akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
  private static class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
      reader = new BufferedReader(new InputStreamReader(in));
      tokenizer = null;
    }

    public String next() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          tokenizer = new StringTokenizer(reader.readLine());
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }
      return tokenizer.nextToken();
    }

    public String nextLine() {
      if (tokenizer == null || !tokenizer.hasMoreTokens()) {
        try {
          return reader.readLine();
        } catch (IOException e) {
          throw new RuntimeException(e);
        }
      }

      return tokenizer.nextToken("\n");
    }

    public long nextLong() {
      return Long.parseLong(next());
    }

    public int nextInt() {
      return Integer.parseInt(next());
    }

    public double nextDouble() {
      return Double.parseDouble(next());
    }

    public int[] nextIntArray(int n) {
      int[] a = new int[n];
      for (int i = 0; i < n; i++)
        a[i] = nextInt();
      return a;
    }

    public long[] nextLongArray(int n) {
      long[] a = new long[n];
      for (int i = 0; i < n; i++)
        a[i] = nextLong();
      return a;
    }
  }

  public static void main(String[] args) {
    FastScanner sc = new FastScanner(System.in);
    int x = sc.nextInt();
    int result = 1;
    if (x < 600) result = 8;
    else if (x < 800) result = 7;
    else if (x < 1000) result = 6;
    else if (x < 1200) result = 5;
    else if (x < 1400) result = 4;
    else if (x < 1600) result = 3;
    else if (x < 1800) result = 2;
    System.out.println(result);
  }
}

Measured memory_bytes: 32764
A, B, C = map(int, input().split())
cnt = 0
while A % 2 == B % 2 == C % 2 == 0:
    # print(A, B, C)
    if A == B == C:
        print(-1)
        break
    A, B, C = (B+C)//2, (C+A)//2, (A+B)//2
    cnt += 1
else:
    print(cnt)


Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,N); for (int i = 0; i<N; i++)
#define in(N); cin >> N
#define out(ans); cout << ans << endl;

int main() {
  int64_t N;
  in(N);
  int64_t ans = 0;
  rep(i,N+1) {
    if (i%3 != 0 && i%5 != 0) ans+=i;
  }
  out(ans);

}

Measured memory_bytes: 3624
#input = ( ["("]*rand(100) + [")"]*rand(100) ).shuffle.inject(""){|memo, item| memo += item; memo}

gets
input = gets

s = input.chomp


while s.gsub!(/\(\)/, "")
end

l = s.count("(")
r = s.count(")")

puts "("*r + input.chomp + ")"*l  

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

int main() {
  int N; cin >> N;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  sort(A.begin(), A.end());
  sort(B.begin(), B.end(), greater<int>());
  if (N % 2 == 1) {
    int low = A.at(N/2);
    int high = B.at(N/2);
    cout << high - low + 1 << endl;
  }
  else {
    int low = A.at(N/2) + A.at(N/2-1);
    int high = B.at(N/2) + B.at(N/2-1);
    cout << high - low + 1 << endl;
  }
}

Measured memory_bytes: 4840
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#define ll long long
#define fr(i,k,N) for(decltype(N+k) i=k; i<N;i++)
#define rep(i,N) for(decltype(N) i=0; i<N;i++)
#define ALL(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}}
template <class X> void prrr(X test){int f=0;for(auto it:test){cout<<(f++!=0?" ":"")<<it;}cout<<endl;}
template<typename X>
istream&operator>>(istream&i,vector<X>&v){for(X&x:v)i>>x;return i;}

class UF { // union find from https://github.com/kartikkukreja/blog-codes (MIT)
    // [usage]
    // auto uf = new UF(n);
    // uf->merge(l, r); // 0 <= l, r <= n-1
    // ...
public:
    int *id; // inner id
    int cnt; // number of all vartices
    int *sz; // sz[i] means size of i's set
    UF(int N)   {
        cnt = N;
        id = new int[N];
        sz = new int[N];
        for(int i=0; i<N; i++) {
            id[i] = i;
            sz[i] = 1;
        }
    }
    ~UF() {
        delete [] id;
        delete [] sz;
    }
    int find(int p) {
        int root = p;
        while (root != id[root]) root = id[root];
        while (p != root) {
            int newp = id[p];
            id[p] = root;
            p = newp;
        }
        return root;
    }
    void merge(int x, int y) {
        int i = find(x);
        int j = find(y);
        if (i == j) return;
        
        if (sz[i] < sz[j]) {
            id[i] = j;
            sz[j] += sz[i];
        } else {
            id[j] = i;
            sz[i] += sz[j];
        }
        cnt--;
    }
    bool connected(int x, int y) {
        return find(x) == find(y);
    }
    int count() {
        return cnt;
    }
};

// return 約数unordered_set 1 <= x <= n
auto divv = [](auto n) {
  unordered_set<decltype(n)> v;
  for(decltype(n) i = 1; i*i <= n; i++) {
    if(n%i == 0) {
      v.insert(i);
      if(i*i != n) v.insert(n/i);
    }
  }
  return v;
};

// check prime (and n>=2) or not
auto isPrime = [](auto n){
  if(n <= 1) return false;
  for(decltype(n) i = 2; i <= sqrt(n); ++i) {
      if(n % i == 0) {
          return false;
      }
  }
  return true;
};

int main() {
    ll x,y;
    cin>>x>>y;
    if(x == 1 && y == 1){
        pr(1000000);
    } else{
        ll sum = 0;
        if(x == 1) sum+=300000;
        if(x == 2) sum+=200000;
        if(x == 3) sum+=100000;
        if(y == 1) sum+=300000;
        if(y == 2) sum+=200000;
        if(y == 3) sum+=100000;
        pr(sum);
    }
}


Measured memory_bytes: 764
h, w, a, b = map(int, input().split())

for i in range(b):
    print('0' * a + '1' * (w - a))
for i in range(h-b):
    print('1' * a + '0' * (w - a))


#1110000 1
#1110000 1
#0001111 1
#0001111 0
#0001111 0

#111000

Measured memory_bytes: 3956
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;

pair<VI, VI> dfs(ll n, int v) {
  if (n == 1) {
    return make_pair(vector<int>(), vector<int>());
  }
  if (n % 2 == 1) {
    auto sub = dfs(n - 1, v + 1);
    sub.first.push_back(v);
    sub.second.insert(sub.second.begin(), v);
    return sub;
  }
  auto sub = dfs(n / 2, v + 1);
  sub.first.push_back(v);
  sub.second.push_back(v);
  return sub;
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;
  cin >> n;
  auto s = dfs(n + 1, 1);
  VI t(s.first);
  for (int v: s.second) t.push_back(v);
  cout << t.size() << endl;
  REP(i, 0, t.size()) {
    cout << t[i] << (i + 1 == (int)t.size() ? "\n" : " ");
  }
}


Measured memory_bytes: 256
def main():

    import sys
    input = sys.stdin.readline

    n,m,l = map(int,input().split())
    Edge = [list(map(int,input().split())) for i in range(m)]
    q = int(input())
    Query = [list(map(int,input().split())) for i in range(q)]

    D2 = [[float("inf") for i in range(n)] for i in range(n)]
    for i in range(m):
        D2[Edge[i][0]-1][Edge[i][1]-1] = Edge[i][2]
        D2[Edge[i][1]-1][Edge[i][0]-1] = Edge[i][2]
    for i in range(n):
        D2[i][i] = 0

    def warshall_floyd(d):
        for k in range(n):
            for i in range(n):
                for j in range(n):
                    d[i][j] = min(d[i][j],d[i][k] + d[k][j])
        return d

    D2 = warshall_floyd(D2)

    D = [[float("inf") for i in range(n)] for i in range(n)]
    for i in range(m):
        if Edge[i][2] <= l:
            D[Edge[i][0]-1][Edge[i][1]-1] = 1
            D[Edge[i][1]-1][Edge[i][0]-1] = 1
    for i in range(n):
        D[i][i] = 0
    for i in range(n):
        for j in range(n):
            if D2[i][j] <= l:
                D[i][j] = 1

    D = warshall_floyd(D)

    for query in Query:
        if D[query[0]-1][query[1]-1] != float('inf'):
            print(D[query[0]-1][query[1]-1]-1)
        else:
            print(-1)
if __name__ == '__main__':
    main()


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

template<class T>
ostream& operator<<(ostream& os,vector<T> const& v){for(auto itr=v.begin();itr!=v.end();++itr){if(itr!=v.begin())os<<' ';os<<*itr;}return os;}

signed main(){

  int n;
  cin>>n;
  vector<int> a(n);
  for(auto& ai:a)cin>>ai;

  a.erase(unique(a.begin(),a.end()),a.end());

  cout<<(a)<<endl;

}


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

int main(void) {
    int X, Y;
    cin >> X >> Y;
    int a = X, b = 0;
    int sum = 2 * X;
    bool flag = false;
    for (b = 0; b <= X; b++) {
        if (sum == Y) {
            flag = true;
            break;
        }
        a--;
        sum += 2;
    }
    if (flag) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }
    return 0;
}


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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int cnt = 0;
    for (int x = a;x <= b;x++) {
         if (c % x == 0)cnt++;
    }
    cout<<cnt<<endl;
    
}


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

int main(void){
    int i, T[10], p1[10], MIN=100, MINT=10, ANS=0;
    for(i=0; i<5; i++){
        scanf("%d", T+i);
        p1[i] = T[i] % 10;
        if(p1[i]!=0 && p1[i]<MIN){
            MIN = p1[i];
            MINT = i;
        }
    }
    for(i=0; i<5; i++){
        if(i==MINT || p1[i] == 0) ANS += T[i];
        else ANS += T[i] + 10 - p1[i];
    }
    printf("%d\n", ANS);
    return 0;
}
//17m33s


Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
// using graph = vector<vector<edge>>;
using graph = vector<vector<int>>;

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

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

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 5000;
int n, k;
int p[maxn];
int c[maxn];

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

    cin >> n >> k;

    REP(i, n) cin >> p[i];
    REP(i, n) p[i]--;
    REP(i, n) cin >> c[i];

    int mm = (-1) * inf;
    REP(i, n) {
        vi pmax;
        pmax.push_back(-inf);
        int step = 0;
        int circ = 0;
        int next = i;
        while(true) {
            step++;
            if (step > k) break;
            next = p[next];
            circ += c[next];
            pmax.push_back(max(pmax[step-1], circ));
            if (next == i) break;
        }
        if (step > k) chmax(mm, pmax[k]);
        else if (next == i) {
            if (circ <= 0) chmax(mm, pmax[step]);
            else {
                int rot = k/step;
                int rem = k%step;
                chmax(mm, (rot-1)*circ + pmax[step]);
                chmax(mm, rot*circ + max(0LL, pmax[rem]));
            }
        }
    }
    cout << mm << "\n";
}


Measured memory_bytes: 3816
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll ,ll> pll;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
#define REP(i,x,y) for(ll i = x;i <= y;++i)
vector<string> vec_splitter(string s) {
    for(char& c: s) c = c == ','?  ' ': c;
    stringstream ss; ss << s;
    vector<string> res;
    for(string z; ss >> z; res.push_back(z))
        ;
    return res;
}
void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, Head H, Tail... T) {
    if(idx > 0) cerr << ", ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
void localTest() {
    #ifndef ONLINE_JUDGE
        freopen("inp", "r", stdin);
        freopen("out", "w", stdout);
    #endif      
}
const ll N = 3e3 + 5, MOD = 998244353;
ll dp[N][N], A[N], ans[N][N];
ll power(ll a, ll b, ll c) {
    ll ret = 1;
    while(b) {
        if(b & 1) ret = (ret * a) % c;
        a = (a * a) % c;
        b >>= 1LL;
    }
    return ret;
}
int main() {

    localTest();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, s;
    cin >> n >> s;
    for(ll i = 1;i <= n;++i) cin >> A[i];
    dp[0][0] = 1;
    for(ll i = 1;i <= n;++i) {
        for(ll j = 0;j <= s;++j) {
            dp[i][j] = 2 * dp[i - 1][j];
            if(j - A[i] >= 0) dp[i][j] += dp[i - 1][j - A[i]];
            dp[i][j] %= MOD;
        }
    }
    cout << dp[n][s] << "\n";
    
    return 0;
}

Measured memory_bytes: 74032
money_a, money_b, money_c, num_a, num_b = [int(x) for x in input().strip().split()]
sum_money = list()
temp = 0
for _ in range(num_a):
    temp += money_a
for _ in range(num_b):
    temp += money_b
sum_money.append(temp)
temp = 0
for _ in range(min(num_a, num_b)):
    temp += money_c*2
if num_a > num_b:
    temp += money_a * (num_a-num_b)
elif num_a < num_b:
    temp += money_b * (num_b-num_a)
sum_money.append(temp)
temp = 0
for _ in range(max(num_a, num_b)):
    temp += money_c*2
sum_money.append(temp)
print(min(sum_money))

Measured memory_bytes: 3064
n=int(input())
s=[]
t=[]
for i in range(n):
    x,l=map(int,input().split())
    s.append(x-l)
    t.append(x+l)
itv = []
for i in range(n):
    itv.append([t[i],s[i]])
itv.sort()

ass=0
tt=-10000000000
for i in range(n):
    if tt<=itv[i][1]:
        ass+=1
        tt=itv[i][0]
print(ass)


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

int main ()
{
	ll h,n,a;
	cin>>h>>n;
	ll ans=0;
	for(int i=0;i<n;i++)
	{
		cin>>a;
		ans+=a;
		
	}
	if(ans>=h) {
		cout<<"Yes"<<endl;
	}
	
	else  cout<<"No"<<endl;
	
	


}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll x, k, d, res;
    scanf("%lld %lld %lld", &x, &k, &d);
    x= abs(x);
    if((x/d)>=k)res= (x-(k*d));
    else
    {
        ll m= x/d;
        x-= (d*m);
        k-= m;
        if(k&(1ll))res= abs(x-d);
        else res= x;
    }
    printf("%lld\n", res);
    return 0;
}


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

int main()
{
    int n,m,l,r;
    int ml=1,mr=100010;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&l,&r);
        ml=max(ml,l);
        mr=min(mr,r);
    }
    r=min(n,mr);

    printf("%d\n",max(r-ml+1,0));
    return 0;
}


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

using namespace std;

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

    int table[20]; // 2の累乗テーブル
    
    for( int i = 0; i < 20; ++i){
        table[i] = 1 << i;
    }

    double x = 0.0;

    for(int dice=1; dice <= n; ++dice){
        int req_n = 0;
        for( int req = 0; req < 20; ++req ){ // 何連続で表を出す必要がある？
            if( k <= dice * table[req]){
                req_n = req;
                break;
            }
        }
        x += (double)1.0 / (table[req_n]);
    }

    x /= n; // 式中で共通 1/n

    printf("%0.14f\n",x);

	return 0;
}


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

int main(){
int a[100000][4];
int b=0;
for(int i=1;i<100000;i++){
cin>>a[i][0]>>a[i][1];
b++;
if(a[i][0]>a[i][1]){
a[i][3]=a[i][0];
a[i][2]=a[i][1];
}
else{
a[i][2]=a[i][0];
a[i][3]=a[i][1];
}
if(a[i][0]==0 && a[i][1]==0){
goto aa;
}
}
aa:;
for(int i=1;i<b;i++){
cout<<a[i][2]<<" "<<a[i][3]<<endl;
}
return 0;
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iterator>
#include <cctype>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <queue>
#include <list>
#include <functional>
#include <ctime>

#pragma comment(linker, "/STACK:102400000, 102400000")
#define debug puts("++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
#define Min(a, b) ( (a < b) ? a : b )
#define Max(a, b) ( (a > b) ? a : b )
#define lc o<<1
#define rc o<<1|1
#define mem0(x) memset(x, 0, sizeof x)
#define mem1(x) memset(x, -1, sizeof x)
#define MAXS 10000 + 8
#define MAXT 10000 + 8
#define MAXL 500000 + 8
#define INF ~0u>>2
#define EPS 1e-20
#define PI acos(-1.0)

using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
const int MOD = 1e9 + 7;
const int maxn = 100000 + 8;

set<int> s;
int n , n1, h, a, b;
char c1, c2;

int ha(int x, int y, int z) {
    return x * n * n + y * n + z;
}

int main() {
   while ( ~scanf("%d%d", &n, &h ) && n + h ) {
        s.clear();
        n1 = n * n * n;
        for (int i = 0;  i < h; i++) {
          getchar();
          scanf("%c%c", &c1, &c2); getchar();
          scanf("%d%d", &a, &b);
          if (c1 == 'x' && c2 == 'y')  for (int i = 1; i <= n; i++) s.insert( ha(a, b, i) );
          else if ( c1 == 'x' && c2 == 'z'  )  for (int i = 1; i <= n; i++) s.insert( ha(a, i, b) );
          else if ( c1 == 'y' && c2 == 'z'  ) for (int i = 1; i <= n; i++) s.insert( ha(i, a, b) );
        }
        printf("%d\n", n1 - s.size() );
   }
   return 0;
}

Measured memory_bytes: 5504
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <chrono>
using namespace std;

// 💖 Hi, thanks for using ICIE! 💖
// 🔧 To use a custom code template, press Ctrl+Shift+P and select "ICIE Template configure" from the list 🔧
// 📝 If you spot any bugs or miss any features, create an issue at https://github.com/pustaczek/icie/issues 📝

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    const int bill = 1000;
    int n, result;
    cin >> n;
    result = n % bill;
    result = result ? bill - result : 0;
    cout << result;
    return 0;
}


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

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int ans=0;
  for(int k=0;k<=999;k++){
  int dp[N+1][4];
  for (int i=0; i<=N; ++i) {
        for (int j=0; j<=3; ++j) {
          dp[i][j]=0;
        }
      }
      string t;
      int d=k;
      int d1=k%10;
      int d2=(k/10)%10;
      int d3=k/100;
      t=to_string(d3)+to_string(d2)+to_string(d1);

  for (int i=0; i<N; ++i) {
        for (int j=0; j<3; ++j) {
            if (S[i] == t[j]) {
                dp[i+1][j+1] = dp[i][j] + 1;
            }
            else {
                dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
            }
        }
    }
    if(dp[N][3]==3) ans++;
  }


cout<<ans<<endl;
}


Measured memory_bytes: 768
import numpy as np

N, K, Q = list(map(int, input().split()))
A = [int(input()) for _ in range(Q)]

B =[K] * N
#print(A,B)

for i in A:
    B[i-1] =B[i-1] + 1
    #print(B)

B = np.array(B)
C = [Q] * N
C = np.array(C)
ans = B - C
ans =ans.tolist()
#print(ans)

for i in ans:
    if i > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 22660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;
int mod;
ll powmod(ll a, ll b) { ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
void solve() {
	vector<int> a(6,0);
	for (int i = 1; i <= 5; i++)cin >> a[i];
	for (int i = 1; i <= 5; i++) {
		if (a[i] != i) {
			cout << i << endl;
			return;
		}
	}
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}







Measured memory_bytes: 3608
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#include <iomanip>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;i++)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecvec vector<vector<int>>
#define vecll vector<ll>
#define vecvecll vector<vector<ll>>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
vector<bool> done;
vector<queue<int>> edge;
int ans=0;
void dfs(ll v){
    if(done[v])return;
    done[v]=true;
    while(!edge[v].empty()){
        int p=edge[v].front();
        edge[v].pop();
        dfs(p);
    }
    return;
}
int main(){
    int n=in(),m=in();
    edge.resize(n);
    done.resize(n,false);
    rep(i,m){
        int u=in()-1,v=in()-1,w=in();
        edge[u].push(v);
        edge[v].push(u);
    }
    rep(i,n)if(!done[i]){
            dfs(i);
            ans++;
    }
    cout<<ans<<endl;
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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



int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    char c;
    cin >> c;
    c++;
    cout << c << endl;


    return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
//#define cocount cout << count << endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define Cinint(n) int n;\
cin >> n;
#define Cinvecint(a, n) vector<int> a(n);\
for (int i = 0; i < (int)(n); i++) {\
  int num;\
  cin >> num;\
  a.at(i) = num;\
}
#define Cinstring(s) string s;\
cin >>s;

  

int main() {
  double d, t, s;
  cin >> d >> t >> s;
  if (d/s <= t) {
    coYes;
  }
  else {
    coNo;
  }
}


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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

ll func(ll A, ll B, ll n){
	return B / n - (A-1) / n;
}

int main()
{
	ll A, B, C, D;
	cin >> A >> B >> C >> D;

	ll a = C, b = D;
	ll x = a * b;

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

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

	ll numC = func(A, B, C);
	ll numD = func(A, B, D);
	ll numCD = func(A, B, x);

	cout << B - A + 1 - (numC + numD - numCD) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define pf push_front
#define mod 1000000007
#define endl '\n'
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);



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


   ll ans,ct=0;
   ll i,n=s.length();
   for(i=0;i<n;i++)
   {
       if(i%2==0)
       {
           if(s[i]!='1')
           {
               ct++;
           }
       }
       else
       {
           if(s[i]=='1')
           {
               ct++;
           }
       }
   }
   ll ct2=0;
   for(i=0;i<n;i++)
   {
       if(i%2==0)
       {
           if(s[i]=='1')
           {
               ct2++;
           }
       }
       else
       {
           if(s[i]!='1')
           {
               ct2++;
           }
       }
   }

    ans = min(ct,ct2);
   cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MAX (ll)(1e5)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18 + 3)
#define PI (double)(3.14159265)

using namespace std;
using ll = long long;

int ma[301][301];

int main () {
	int h, w, k;
	cin >> h >> w >> k;
	bool mat[h][w];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			char ch;
			cin >> ch;
			mat[i][j] = ch == '#';
		}
	}
	for (int j = 0; j < w; j++) {
		vector<int> ve;
		for (int i = 0; i < h; i++) {
			if (mat[i][j]) {
				ve.push_back (i);
			}
		}
		if (ve.size ()) {
			ve.push_back (h);	
			for (int x = 0; x < ve[1]; x++) {
				ma[x][j] = k;
			}
			k--;
			for (int x = 1; x < (int)ve.size () - 1; x++) {
				for (int i = ve[x]; i < ve[x + 1]; i++) {
					ma[i][j] = k;	
				}
				k--;
			}
		}
	}
	for (int i = 0; i < h; i++) {
		vector<int> ve;
		for (int j = 0; j < w; j++) {
			if (ma[i][j]) {
				ve.push_back (j);
			}
		}
		ve.push_back (w);	
		for (int x = 0; x < ve[1]; x++) {
			ma[i][x] = ma[i][ve[0]];
		}
		for (int x = 1; x < (int)ve.size () - 1; x++) {
			for (int j = ve[x]; j < ve[x + 1]; j++) {
				ma[i][j] = ma[i][ve[x]];	
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << ma[i][j] << " ";
		}
		cout << "\n";
	}
}


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

import sys
import os

N, M = map(int, input().split())
# Node
# M: Edge num

# 隣接リスト
E = [[] for i in range(N)]
#print(E)

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    E[a].append(b)
    E[b].append(a)
#print(E)

# BFSだとvisitedリストも増えすぎる
# DFSがよい

visited = [False] * N

one_stroke_num = 0
def dfs(v):
    #print('dfs', v)
    global one_stroke_num

    if visited.count(True) == N:
        one_stroke_num += 1
        return
    else:
        # vから行けるところあるか
        for next_i in E[v]:
            if not visited[next_i]:
                # そこに行く
                visited[next_i] = True
                dfs(next_i)
                visited[next_i] = False
        # もう行くところない
        return

visited[0] = True
dfs(0)

print(one_stroke_num)

Measured memory_bytes: 3064
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<bitset>
using namespace std;

int main(void)
{
	string S;
	cin >> S;
	
	long long ret = 0;
	for(int i=(1<<(S.size()-1))-1; i>0; i--)
	{
		long long sum = 0;
		
		int l = 0;
		bitset<9> n(i);

		for(int j=0; j<9; j++)
		{
			if(n[j] == true)
			{
				int r = j+1;
				
				sum += stoll(S.substr(l, r-l));
				l = r;
			}
		}

		if(l!=S.size())
			sum += stoi(S.substr(l, S.size()-l+1));

		ret += sum;
	}

	ret += stoll(S);

	cout << ret << endl;

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 10000

int main(){
  int n, i, j, C[MAX + 1] = {0};
  unsigned short *A, *B;

  scanf("%d", &n);

  A = malloc(sizeof(short) *n+1);
  B = malloc(sizeof(short) *n+1);

  for(i = 0; i < n; i++)
    scanf("%hu", &A[i]);

  for(i = 0; i < n; i++)
    C[A[i]]++;

  for(i = 1; i <= MAX; i++)
    C[i] = C[i] + C[i - 1];

  for(j = n - 1; j >= 0; j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
  
  for(i = 1; i < n; i++)
    printf("%d ", B[i]);
  printf("%d\n", B[n]);
  
  return 0;
}

Measured memory_bytes: 8468
#include <iostream> 
using namespace std; 
  
int main() 
{
    long n;
    cin>>n;
    long a[n];
    for(long i=1;i<=n;i++){
      cin>>a[i];
    }
  long c=1,s=0,f=0;
  for(long i=1;i<=n;i++){
     if(a[i]!=c){
       s++;
     }
    else{
      c++;
    }
      
   }
    if (s == n) cout << -1;
    else cout<<s;
    return 0; 
} 


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

using namespace std;

#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vb vector<bool>
#define vl vector<long>
#define vi vector<int>
#define fastio ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define f first
#define s second

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
char dir[] = {'R', 'L', 'D', 'U'};
const int MOD = 1e9 + 7;

void solve()
{
    int n, k; cin >> n >> k;
    vi a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    vector<int> dp(n);

    for(int i = 0; i < n; i++)
    {
        for(int j = max(0, i - 100); j < i; j++)
        {
            if(abs(a[i] - a[j]) <= k) dp[i] = max(dp[i], dp[j] + 1);
        }
    }
    int ans = 0;
    for(int i = 0; i < n; i++) ans = max(ans, dp[i]);
    cout << ans + 1;
}

int main()
{
    fastio

    //ifstream fin(".in");
    //ofstream fout(".out");


    int t = 1;
    //cin >> t;

    while(t-- > 0) solve();
}


Measured memory_bytes: 5556
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	static int N = Integer.parseInt(sc.next());
	static int M = Integer.parseInt(sc.next());
	static int[] X = new int[M];
	static {
		Arrays.setAll(X, i -> Integer.parseInt(sc.next()));
	}
	public static void main(String[] args) {
		if (N>=M) {
			System.out.println("0");
			return;
		}
		int ans = 0;
		Arrays.sort(X);
		int[] deltaX = new int[M-1];
		for (int i = 0; i < M-1; i++) {
			deltaX[i] = X[i+1] - X[i];
		}
		Arrays.sort(deltaX);
		for (int i = 0; i < M-1 - (N-1); i++) {
			ans += deltaX[i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 47708
#include <iostream>
#include <cctype>
using namespace std;
int main(){
    char c;
    int cnt[26] = {0};
    while(cin>>c){
        if(isupper(c)) c = tolower(c);
        cnt[c-'a']++;
    }
    for(int i=0;i<26;i++){
        cout<<(char)(i+'a')<<" : "<<cnt[i]<<endl;
    }
}

Measured memory_bytes: 3104
/// Bismillahir Rahmanir Rahim
//Author: Tanvir Hussain
//ICE,NSTU
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

using namespace std;

const long long MOD = 1000000007;
#define SET(x) memset(x, 0, sizeof(x))
#define SET2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define SETBOOL(x) memset(x,false,sizeof(x))
#define CLR(x) memset(x, -1, sizeof(x))
#define mp make_pair
#define PII pair<int, int>
#define pf printf

#define sf scanf

#define ALL(x) x.begin(),x.end()
#define pb push_back

#define IOS ios::sync_with_stdio(false); cin.tie(0); 
#define np std::string::npos
#define for0(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=n-1;i>=0;i--)
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define cases(cs,t) for(int cs=1;cs<=t;cs++)
#define PI acos(-1)
#define no1 __builtin_popcount
#define BOUNDARY(i, j) ((i >= 0 && i < row) && (j >= 0 && j < column))
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const int maxx=100005;

//this fuction sorts vector pair according to first element in descending order.
bool sortinrev(const pair<int,int> &a,const pair<int,int> &b)
{
    return a.first>b.first;
}

template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}
double sq(double x) {return x*x;}
int ext_gcd(int a, int b, int & x, int & y) {
    //for finding modular inverse
    //if its return 1 ,then a has a mod inverse x mod b.
    if (a == 0) {
        x = 0;
        y = 1;
        return b;
    }
    int x1, y1;
    int d = ext_gcd(b % a, a, x1, y1);
    x = y1 - (b / a) * x1;
    y = x1;
    return d;
}

int main()

{
    IOS;
    //freopen("input.txt", "r", stdin);
     //freopen("output.txt", "w", stdout);
     string s;
     while(cin>>s){
            bool b=false;
        for(int i=0;i<s.size();i++){
            if(s[i]=='7') {
                cout<<"Yes"<<endl;
     b=true;
                break;
            }
        }
        if(!b) cout<<"No"<<endl;
     }

     return 0;

}
///Alhamdulillah


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int A, B;
	cin >> A >> B;


	co(A - B + 1);

	Would you please return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>p(m + 1), y(m + 1);
	vector<tuple<int,int,int>>vp;
	vector<tuple<int,int,int>>ans;
	int target;
	int num;
	repp(i, 0, m) {
		cin >> p[i] >> y[i];
		vp.push_back(make_tuple(y[i],p[i],i));
	}
	sort(vp.begin(),vp.end());
	vector<int>count(n+1, 0);
	repp(i, 0, m) {
	//tupleはgetを使って取得,0オリジン
		++count[get<1>(vp[i])];
		ans.push_back(make_tuple(get<2>(vp[i]), get<1>(vp[i]),count[get<1>(vp[i])]));
	}
	sort(ans.begin(), ans.end());
	repp(i, 0, m) {
		printf("%6.6d%6.6d\n", get<1>(ans[i]), get<2>(ans[i]));
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

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

  for(int i=0;i<(int)s.length();i++) {
    s[i]+=n;
    if(s[i]>'Z') {
      s[i]='A'+(s[i]-'Z')-1;
    }
  }
    cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;

int sz[N], parent[N], pw[N];
vector<int> adj[N];

int add(int a, int b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return (a + b) % mod;
}
int mul(int a, int b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return 1ll * a * b % mod;
}

int fp(int b, int p){
    if(!p) return 1;
    ll ret = fp(b, p >> 1);
    ret = ret * ret % mod;
    if(p&1) ret = ret * b % mod;
    return ret;

}

void dfs(int node, int par){
    parent[node] = par;
    sz[node] = 1;
    for(auto i: adj[node]){
        if(i == par) continue;
        dfs(i, node);
        sz[node] += sz[i];
    }
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    pw[0] = 1;
    for(int i = 1; i < N; i++) pw[i] = pw[i - 1] * 2 % mod;
    int n;
    cin >> n;
    for(int i = 1; i < n; i++){
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    dfs(1, 0);
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans = add(ans, add(pw[n - 1], -1));
        for(auto j: adj[i]){
            int kam;
            if(j == parent[i]) kam = n - sz[i];
            else kam = sz[j];
            ans = add(ans, -(pw[kam] - 1));
        }
    }
    ans = mul(ans, fp(pw[n], mod - 2));
    cout << ans;

    return 0;

}



Measured memory_bytes: 27984
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int A = sc.nextInt();
    	int B = sc.nextInt();
    	int C = sc.nextInt();
    	int D = sc.nextInt();

    	boolean flag = true;

    	while(flag) {
    		C -= B;
    		if(B<=0) {
    			flag = false;
    		} else {
        		A -= D;
        		if(A<=0) {
        			flag = false;
        		}
    		}
    	}
    	if(C<=0) {
    		System.out.println("Yes");
    	} else {
    		System.out.println("No");
    	}
    }

}

Measured memory_bytes: 27076
#include <algorithm>
#include <iostream>
#include <unordered_map>
#include <vector>

int main()
{
    std::string s, t;
    std::cin >> s >> t;

    std::unordered_map<char, std::vector<int>> char_map;

    for (int i = 0; i < s.length(); i++) {
        char_map[s[i]].push_back(i);
    }
    for (int i = 0; i < s.length(); i++) {
        char_map[s[i]].push_back(i + s.length());
    }

    long long ans = 0;
    int ptr = 0;
    for (auto c : t) {
        if (!char_map[c].size()) {
            std::cout << -1 << std::endl;
            return 0;
        }
        ptr = *std::lower_bound(char_map[c].begin(), char_map[c].end(), ptr) + 1;

        if (ptr >= s.length()) {
            ptr -= s.length();
            ans += s.length();
        }
    }

    ans += ptr;
    std::cout << ans << std::endl;
}


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

int main()
{
    int n, mx = 0;
    map<string, int> mp;
    cin >> n;
    rep(i, n)
    {
        string s;
        cin >> s;
        mp[s]++;
    }

    for (auto p : mp)
        mx = max(mx, p.second);
    for (auto p : mp)
    {
        if (p.second == mx)
            cout << p.first << endl;
    }

    return 0;
}

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

int main(){
    int N;
    cin >> N;
    
    int sum = 0;
    int a = 1;
    for(int i = 0;i <= 9;i++){
        sum += (N/a)%10;
        a *= 10;
    }
    
    if(N%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
void chmin(int &a, int b) { if (a > b) a = b; }
const int INF = 1<<29;

int N, A, B, C;
vector<int> L;

// 再帰
int rec(int i, int a, int b, int c) {
    if (i == N) {
        if (!a || !b || !c) return INF; // A, B, C いずれも竹は 1 本は必ず使ってないとダメ
        return abs(a - A) + abs(b - B) + abs(c - C); // 合体してできた a, b, c を A, B, C にするコスト
    }

    // 今ある竹を採用しない場合
    int res = rec(i+1, a, b, c);
    
    // A, B, C を使う場合、(a ? 10 : 0) とかは、最初の 1 本目は合体コストなし、2 本目からはコスト 10 かかることを意味する
    chmin(res, rec(i+1, a + L[i], b, c) + (a ? 10 : 0));
    chmin(res, rec(i+1, a, b + L[i], c) + (b ? 10 : 0));
    chmin(res, rec(i+1, a, b, c + L[i]) + (c ? 10 : 0));
    
    return res;
}

int main() {
    // 入力
    cin >> N >> A >> B >> C;
    L.resize(N);
    for (int i = 0; i< N; ++i) cin >> L[i];
    
    // 再帰する
    cout << rec(0, 0, 0, 0) << endl;
}

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


namespace ConsoleApp9
{
    class Program
    {
        public static void Main(string[] args)
        {
            double a = double.Parse(Console.ReadLine());
            double b = a * 2 * Math.PI;
            double c = a * a * Math.PI;
            Console.WriteLine(c+" "+b);
        }
    }
}

Measured memory_bytes: 9268
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

ll calc(ll x, ll y) {
    if (x > y) return TEN(18);
    return y-x;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
    ll x, y;
    cin >> x >> y;
    ll ans = TEN(18);
    ans = min(ans, calc(x, y));
    ans = min(ans, calc(-x, y)+1);
    ans = min(ans, calc(x, -y)+1);
    ans = min(ans, calc(-x, -y)+2);
    cout << ans << endl;
    return 0;
}


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


int main()
{
    int t=1;
    //cin>>t;

    while( t-- )
    {
        ll n;
        cin>>n;

        int a;

        ll sum=0;
        map <ll , ll> m;

        for( int i=0 ; i<n ; i++ )
        {
            cin>>a;
            m[a]++;
            sum+=a;
        }
        //cout<<sum<<endl;

        int q;
        cin>>q;

        while( q-- )
        {
            int b,c;
            cin>>b>>c;

            sum=sum-b*m[b]-c*m[c];
            m[c]+=m[b];

            //cout<<"sum = "<<sum<<" - "<<m[b]*b<<" + "<<m[c]*c<<endl;
            sum = sum + (m[c]*c) ;
            m[b]=0;

            cout<<sum<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 9364
//prepared by dumb
#include<bits/stdc++.h>
using namespace std;
#define   ll long long int
#define   dl double  
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
// Creates a min heap 
//priority_queue <int, vector<int>, greater<int> > pq; 
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
ll a, b, c=0, d, e, f = 0, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z;
ll cnt = 0, ans = 0, l1, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
    string str, str1, str2;
    char ch;
    unordered_map<ll,ll>mp;
    for(i=1;i<=101;i++)
    {
        for(j=1;j<=101;j++)
        {
            for(k=1;k<=101;k++)
            {
                mp[i*i+j*j+k*k+i*j+i*k+j*k]++;
            }
        }
    }
     scll(n);
     for(i=1;i<=n;i++)
     {
       cout<<mp[i]<<'\n';
     }
return 0;
}

Measured memory_bytes: 4928
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define MAX_V 200000
#define INF 1 << 29
using namespace std;
typedef long long ll;
typedef pair<ll, int> pli;
struct Edge {
    int to;
    ll cost;
};
vector<Edge> g[MAX_V];
ll d[MAX_V];
void solve() {
    d[0] = 0;
    queue<pli> q;
    q.push(pli(0LL, 0));
    while (!q.empty()) {
        pli p = q.front(); q.pop();
        int v = p.second;
        for (size_t i = 0U; i < g[v].size(); ++i) {
            Edge e = g[v][i];
            if (d[e.to] > e.cost + d[v]) {
                d[e.to] = e.cost + d[v];
                q.push(pli(d[e.to], e.to));
            }
        }
    }
}
int main(void) {
    int k; cin >> k;
    for (int i = 0; i <= k; ++i) {
        d[i] = INF;
    }
    for (int i = 0; i < k; ++i) {
        Edge e = { i + 1, 1LL };
        g[i].push_back(e);
    }
    for (int i = 1; i < k; ++i) {
        Edge e = { i * 10 % k, 0LL };
        if (e.to == 0) e.to = k;
        g[i].push_back(e);
    }
    solve();
    cout << d[k] << endl;
    return 0;
}






















Measured memory_bytes: 11008
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scan = new Scanner(System.in);
        long K = scan.nextLong();
        final long A = scan.nextLong();
        final long B = scan.nextLong();

        long biscuit = 1;
        long jpy = 0;

        if (B - A <= 2) {
            while (K > 0) {
                biscuit++;
                K--;
            }
            System.out.println(biscuit);
            return;
        }

        while (K > 0) {
            if (jpy > 0) {
                jpy--;
                biscuit += B;
                K--;
                continue;
            }

            if (biscuit >= A && K >= 2) {
                biscuit -= A;
                jpy++;
                K--;
                continue;
            }

            biscuit++;
            K--;
        }
        System.out.println(biscuit);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	int k, t, in, sum = 0, maxv = 0;
	cin >> k >> t;
	rep(i, t) {
		cin >> in;
		sum += in;
		maxv = max(in, maxv);
	}
	cout << max(0, sum-(sum-maxv)*2-1) << endl;

	
}

Measured memory_bytes: 256