akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define int long long
#define P pair<long,long>
#define all(a) a.begin(),a.end()
using namespace std;
signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    a.push_back(-1);
    int cnt=0,ans=0;
    rep(i,n){
        cnt++;
        if(a.at(i)!=a.at(i+1)){
            ans+=cnt/2;
            cnt=0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
	static int sumOfDigit(int x) {
		int sum=0;
		while (true) {
			if (x<10) {
				sum+=x;
				break;
			}
			sum+=x%10;
			x=(x-x%10)/10;
		}
		return sum;
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();

		int sum=0;
		for (int i=1;i<=N;i++) {
			if (A<=sumOfDigit(i) && sumOfDigit(i)<=B) {
				sum+=i;
			}
		}
		System.out.println(sum);
	}
}

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

namespace Simple_Calculator
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                String[] str = Console.ReadLine().Split(' ');
                int a = int.Parse(str[0]);
                int b = int.Parse(str[2]);

                if (str[1] == "+") Console.WriteLine(a + b);
                else if (str[1] == "-") Console.WriteLine(a - b);
                else if (str[1] == "*") Console.WriteLine(a * b);
                else if (str[1] == "/") Console.WriteLine(a / b);
                else Environment.Exit(0);
            }
        }
    }
}


Measured memory_bytes: 9132
import collections
n = int(input())
l = []
s = collections.Counter([input() for i in range(n)])
mn = 0
for i in s.most_common():
    if i[1] >= mn:
        mn = i[1]
        l.append(i[0])
    else:
        break
for i in sorted(l):
        print(i)

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	string s;cin>>s;
	int m=stoi(s.substr(5, 2));
	int d=stoi(s.substr(8,2));
	
	if(m<=4&&d<=30) {
		cout << "Heisei";
	}else {
		cout << "TBD";
	}
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main()

{
    char s ;
    cin>>s ;

    if(s>='a' && s<='y')
    {
        cout<<(char)(s+1)<<endl ;
    }
    if(s>='A' && s<='Y')
    {
        cout<<(char)(s+1)<<endl ;
    }

    return 0;

}

Measured memory_bytes: 3632
# Code for B - Bishop
# Use input() to fetch data from STDIN
from math import ceil
import sys
[H, W] = map(int, input().split())

if H <= 1:
    print(1)
    sys.exit(0)

if W <= 1:
    print(1)
    sys.exit(0)


print(ceil(H * W / 2))


Measured memory_bytes: 2940
#include<iostream>
using namespace std;
int main(){
  int n,m;
  int num[3];
  for(int i=0;i<3;i++) num[i]=-1;
  cin>>n>>m;
  bool f=true;
  int s,c;
  for(int i=0;i<m;i++){
    cin>>s>>c;
    if(num[s-1]!=-1 && c!=num[s-1]){
      f=false;
    }
    num[s-1]=c;
  }
  if(num[0]==-1&&n>1) num[0]=1;
  if(num[0]==-1&&n==1) num[0]=0;
  if(num[0]==0 &&n>1) f=false;
  for(int i=1;i<3;i++){
    if(num[i]==-1) num[i]=0;
  }
  if(f==false) cout<<-1<<endl;
  else{
    for(int i=0;i<n;i++)
      cout<<num[i];
    cout<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int n,x,cnt[10],i;
	while(1){
		for(i=0;i<10;i++){
			cnt[i]=0;
		}
		scanf("%d",&n);
		if(n<1)break;
		for(i=0;i<n;i++){
			scanf("%d",&x);
			cnt[x]++;
		}
		if(cnt[0]>0){
			for(i=0;i<cnt[0];i++){
				printf("*");
				if(i==cnt[0]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[1]>0){
			for(i=0;i<cnt[1];i++){
				printf("*");
				if(i==cnt[1]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[2]>0){
			for(i=0;i<cnt[2];i++){
				printf("*");
				if(i==cnt[2]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[3]>0){
			for(i=0;i<cnt[3];i++){
					printf("*");
				if(i==cnt[3]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[4]>0){
			for(i=0;i<cnt[4];i++){
				printf("*");
				if(i==cnt[4]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[5]>0){
			for(i=0;i<cnt[5];i++){
				printf("*");
				if(i==cnt[5]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[6]>0){
			for(i=0;i<cnt[6];i++){
				printf("*");
				if(i==cnt[6]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[7]>0){
			for(i=0;i<cnt[7];i++){
				printf("*");
				if(i==cnt[7]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[8]>0){
			for(i=0;i<cnt[8];i++){
				printf("*");
				if(i==cnt[8]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
		if(cnt[9]>0){
			for(i=0;i<cnt[9];i++){
				printf("*");
				if(i==cnt[9]-1){
					printf("\n");
				}
			}
		}
		else{
			printf("-\n");
		}
	}
	return 0;
}

Measured memory_bytes: 996
#include <iostream>

using namespace std;

int main()
{
    int a, b;
    cin >> a >> b;

    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<numeric>
#define all(x) (x).begin(),(x).end()
typedef long long ll;
 
using namespace std;

int main()
{
    int N, K;   cin >> N;
    vector<int> v(N);
    for(int i=0; i<N; i++)  cin >> v[i];
    ll yen = 1000;
    ll kabu = 0;
    for(int i=0; i<N-1; i++){
        if(v[i+1] > v[i]){
            kabu += yen / v[i];
            yen -= yen / v[i] * v[i];
        }else if(v[i+1] < v[i]){
            yen += kabu*v[i];
            kabu = 0;
        }
        //cout << yen << endl;
    }
    yen += kabu*v[N-1];
    cout << yen;
}

Measured memory_bytes: 3588
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static boolean isPalindrome(String s) {
        int i = 0;
        int j = s.length() - 1;
        boolean isPalindrome = true;

        while (i < j) {
            if (s.charAt(i) != s.charAt(j)) {
                isPalindrome = false;
                break;
            }
            i++;
            j--;
        }
        return isPalindrome;
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        String s = in.next();
        int n = s.length();

        int c1 = (n - 1) / 2;
        int c2 = (n + 3) / 2;

        String s1 = s.substring(0, c1);
        String s2 = s.substring(c2 - 1);

        if (isPalindrome(s) && isPalindrome(s1) && s1.equals(s2)) {
            out.println("Yes");
        } else {
            out.println("No");
        }
    }
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if((a==b&&b==c)||(a!=b&&b!=c&&c!=a)){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>
#include <stack>

using namespace std;
using ll = long long int;

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N, long long M, std::vector<long long> A){
  double sum = 0;
  sort(A.rbegin(), A.rend());
  bool f = true;
  for(auto x : A)
    sum+=x;
  //std::cout << sum/((double)4*M) << std::endl;
  for(ll i=0; i<M; i++) {
    if(A[i] < sum/((double)4*M))
      f = false;
  }
  if(f)
    std::cout << YES << std::endl;
  else
    std::cout << NO << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> A(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&A[i]);
  }
  solve(N, M, std::move(A));
  return 0;
}



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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll X, Y;
    cin >> X >> Y;
    rep2(i, 0, X + 1) {
        ll t = i;
        ll k = X - i;
        if (2 * t + 4 * k == Y) {
            cout << "Yes" << '\n';
            return;
        }
    }
    cout << "No" << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3648
s = input()
s_ = s.replace('x', '')
if s_ != s_[::-1]:
    print(-1)
    exit()
else:
    cnt = 0
    num = 0
    for i, a in enumerate(s):
        if i + cnt >= len(s)-1:
            break
        if a == s[-1-cnt]:
            cnt += 1
            continue
        if a == 'x':
            num += 1
            continue
        else:
            while s[-1-cnt] == 'x':
                cnt += 1
                num += 1
            if a == s[-1 - cnt]:
                cnt += 1
                continue

    print(num)

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);
    int N; cin >> N;

    string ans;

    while (N != 0) {
        if (N & 1) {
            ans += '1';
            if (N < 0) N = (N-1) / (-2);
            else N /= -2;
        } else {
            ans += '0';
            N /= -2;
        }
    }
    if (ans.empty()) {
        ans = '0';
    } else {
        reverse(all(ans));
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int a,b;
    cin >> a>>b;

    int maxval = -100*100;

    maxval = max(maxval, a+b);
    maxval = max(maxval, a-b);
    maxval = max(maxval, a*b);

    cout << maxval << endl;

   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl




signed main(){
    int N,M;
    int A[114514],B[114514];
    bool Bap[114514]={};
    queue<int> G;
    vector<int> V[114514];
    int michimayoi[114514]={};
    int R=0;
    cin >> N >> M;
    REP(i,N-1+M){
        cin >> A[i] >> B[i];
        A[i]--;B[i]--;
        Bap[B[i]]=1;
        V[A[i]].push_back(B[i]);
        michimayoi[B[i]]++;
    }
    REP(i,N){
        if(Bap[i]==0){
            R=i;
        }
    }
    
    int cost[114514];
    REP(i,N+M){cost[i]=-INF;}
    cost[R]=0;
    G.push(R);
    while(G.size()!=0){
        int P=G.front();
        G.pop();
        michimayoi[P]--;
        if(michimayoi[P]>0)continue;
        REP(i,V[P].size()){
            G.push(V[P][i]);
            cost[V[P][i]]=max(cost[V[P][i]],cost[P]+1);
        }
    }
    
    int oya[114514]={};
    REP(i,N-1+M){
        if(cost[A[i]]+1==cost[B[i]]){
            oya[B[i]]=A[i];
        }
    }
    REP(i,N){
        if(i==R){
            cout << 0 << endl;
        }else{
            cout << oya[i]+1 << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 11136
X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

queue = [(A[0]+B[0]+C[0], 0, 0, 0)]
ans = [(A[0]+B[0]+C[0], 0, 0, 0)]

for i in range(K):
    cake = max(queue, key=lambda x: x[0])
    queue.remove(cake)
    a, b, c = cake[1], cake[2], cake[3]
    print(cake[0])
    for j in range(3):
        aa = a + [1, 0, 0][j]
        bb = b + [0, 1, 0][j]
        cc = c + [0, 0, 1][j]
        if aa < X and bb < Y and cc < Z:
            tmp = A[aa]+B[bb]+C[cc]
            if (tmp, aa, bb, cc) not in ans:
                ans.append((tmp, aa, bb, cc))
                queue.append((tmp, aa, bb, cc))


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
#define Puts(x) puts(x? "Yes":"No")
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(int n, int m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(int n, int m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[] = {1, 0, -1, 0, 1, -1, 1, -1};

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

  int n;
  cin >> n;
  vvt<int> a(2, vt<int>(n));
  rep(i, 0, 2) rep(j, 0, n) cin >> a[i][j];

  vvt<int> dp(3, vt<int>(n + 1, 0));
  rep(i, 1, 3) {
    rep(j, 1, n + 1) {
      dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]) + a[i - 1][j - 1];
    }
  }
  cout << dp[2][n] << endl;
}


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

int x[100010], y[100010];

int main() {
	ios::sync_with_stdio(false);
	int a,b,m; cin >> a >> b >> m;
	for (int i = 1; i <= a; i++) cin >> x[i];
	for (int j = 1; j <= b; j++) cin >> y[j];
	int ans = 10000000;
	while (m--) {
		int p,q,r; cin >> p >> q >> r;
		ans = min(ans, x[p] + y[q] - r);
	}
	sort(x+1,x+a+1);
	sort(y+1,y+b+1);
	cout << min(x[1] + y[1], ans) << "\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

/*


 */
int const MaxSize = 1e5 + 5;
int a[MaxSize], n;

int main() {

	ios_base::sync_with_stdio(false);
	//freopen("/Users/georgeli/A_1.in", "r", stdin);
	cin >> n;
	LP(i, 0, n)
	{
		cin >> a[i];
	}

	sort(a, a + n);

	int ai = a[n - 1];
	int lc = ai / 2, hc = ai / 2;
	int aj = 0, curMinDist = (ai + 1);

	if (n % 2) {
		hc++;
	}

	LP(i, 0, n - 1)
	{
		int minDist = min(abs(a[i] - lc), abs(a[i] - hc));

		if (minDist < curMinDist) {
			aj = a[i];
			curMinDist = minDist;
		}
	}

	cout << ai << " " << aj << endl;

	return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;

    int corrected = 0;
    for(int i = 1; i <= n; ++i){
        int p;
        cin >> p;
        if(i != p) corrected++;
    }

    if(corrected == 0 || corrected == 2) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = a; i < b; ++i)
#define ll long long
#define M 100000007
#define fr first
#define sc second
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll, ll>
#define psi pair<string, ll>
#define fast                                                                   \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define PI 3.14159265
#define r0 return 0
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for (typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c, x) ((c).find(x) != (c).end())
#define cpresent(c, x) (find(all(c), x) != (c).end())
#define what_is(x) cerr << #x << " is " << x << endl;
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;

const char char_max = (char)(((unsigned char) char(-1)) / 2);

int main() {
  fast
    ll n;
    cin>>n;
    map<ll,ll>m;
    rep(i,0,n-1){
        ll a;
        cin>>a;
        m[a]++;
    }
    vector<ll>v(n+1);
    for(auto i:m){
        v[i.first]=i.second;
    }
    rep(i,1,n+1) cout<<v[i]<<" ";
}



Measured memory_bytes: 17168
h, w = map(int, raw_input().split())
S = [raw_input().split() for i in xrange(h)]
for i in xrange(h):
    for j in xrange(w):
        if S[i][j] == "snuke":
            print "%s%d" % ("ABCDEFGHIJKLMNOPQRSTUVWXYZ"[j], i+1)

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

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

    set<int> s;
    vector<int> v(n);
    vector<string> str(n);
    for (auto &i : v) {
        cin >> i;
        s.insert(i);
    }

    for (int i = 0; i < n; i++) {
        str[i] = '0' + v[i];
    }

    for (int i = 0; i < 1000; i++) {
        if (s.size() < pow(10., (double)(i + 1))) break;
        for (int j = 0; j < str.size(); j++) {
            if (n > j + i + 1)
                str[j] += ('0' + v[j + i + 1]);
            stringstream ss;
            ss << str[j];
            int tmp;
            ss >> tmp;
            s.insert(tmp);
        }
    }

    for (int i = 0; i < 1000000; i++) {
        if (s.find(i) == s.end()) {
            cout << i << endl;
            break;
        }
    }

    return 0;
}

Measured memory_bytes: 3436
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    n = int(input())
    # 整数複数個
    # a, b = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    #N = [list(map(int, input().split())) for i in range(3)]

    A.sort()
    B.sort()
    C.sort()

    import bisect
    cnt = 0
    for bi in B:
        a_ok = bisect.bisect_left(A, bi)
        c_ok = bisect.bisect_right(C, bi)
        cnt += a_ok * (n - c_ok)
    print(cnt)

resolve()

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

namespace mondai0002
{
	class Program
	{
		static void Main(string[] args)
		{
			while( true ) {
				var	s	= Console.ReadLine();
				if( s == null ) {
					break;
				}
				var	ss	= s.Split();
				var	sum	= int.Parse( ss[ 0 ] ) + int.Parse( ss[ 1 ] );
				Console.WriteLine( sum.ToString().Length );
			}
		}
	}
}

Measured memory_bytes: 5580
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int n;
  cin>>n;
  cout<<n*n*n<<endl;
  return 0;
}


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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef long double         lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;

string s;

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "input", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif

  while(cin >> s) {
    if( (s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]) ) cout << "Yes\n";
    else cout << "No\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>


using namespace std;
typedef long long ll;
int main() {
	
	ios::sync_with_stdio(0); cin.tie(0);
	
	ll a, b, n;
    cin >> n >> a >> b;
    
    if( a > b ){
		cout << "0\n";
		return 0;
	}
	
	if ( n == 1 &&  a < b ){
		cout <<"0\n";
		return 0;
	}
	
	cout << ( a + b * ( n - 1 )  - ( a * ( n - 1) + b ) + 1 ) <<'\n';
   
    return 0;
}


Measured memory_bytes: 256
import sys

def biser(lst,func):
    n=len(lst)
    nh=n//2
    if n==1:
        if func(lst[0]):
            return lst[0]
        else:
            return -1
    if func(lst[nh]):
        return biser(lst[nh:],func)
    else:
        return biser(lst[:nh],func)

def mkns(a,s,m):
    if a==0:
        return s
    else:
        return (((s+1)<<a)|s) & m

def main():
    N,K=map(int,sys.stdin.readline().strip().split())
    a=list(map(int,sys.stdin.readline().strip().split()))
    a.sort()
    ss=[0]*(N+1)
    pm=(1<<K)-1
    mask=lambda c:(1<<K)-(1<<c)
    nn=0
    def isunnec(i):
        if a[i]>=K:
            return False
        for j in range(i+1,N):
            if a[j]>=K:
                break
            ss[i]=(((ss[i]+1)<<a[j])|ss[i]) & pm
        if ss[i]&mask(K-a[i])==0:
            return True
        return False
    
    for i in range(N):
        if a[i]>=K:
            break
        ss[i+1]=(((ss[i]+1)<<a[i])|ss[i]) & pm
    nn=biser(list(range(N)),isunnec)+1
    print(nn)

if __name__=='__main__':
    main()


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

int main(){
    int n,a=1000;
    cin>>n;

    while(n>a){
        a+=1000;
    }

    cout<<a - n <<endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <stack>
#include <math.h>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

#define rep(i,n) for(int i=0; i < n; i++)
using ll =  long long;
using namespace std;
#define pi 3.14159265358979


int main()
{
	int n, bestSpot = -1;
	double t, a, bestDistance = 10101010.0;
	cin >> n >> t >> a;
	
	rep(i, n)
	{
		double h;
		cin >> h;
		if (abs(a-(t - h * 0.006)) < bestDistance)
		{
			bestDistance = abs(a - (t - h * 0.006));	//最小値を記録
			bestSpot = i + 1;		  //最有力候補のインデックスを記録
		}
	}
	cout << bestSpot;
	return 0;
}

Measured memory_bytes: 3756
#include <cstdio>
#define N 200050
int dsetx[N],dsety[N];
int headx[N],heady[N];
int nxtx[N],nxty[N];
int cnt[N],tim[N],timetip;
int ans[N];
int findx(int p){return dsetx[p]==p? p:dsetx[p]=findx(dsetx[p]);}
int findy(int p){return dsety[p]==p? p:dsety[p]=findy(dsety[p]);}
void mergex(int p1,int p2)
{
	int f1=findx(p1),f2=findx(p2);
	if(f1!=f2)
	{
		if(f1<f2)
			dsetx[f2]=f1;
		else
			dsetx[f1]=f2;
	}
}
void mergey(int p1,int p2)
{
	int f1=findy(p1),f2=findy(p2);
	if(f1!=f2)
	{
		if(f1<f2)
			dsety[f2]=f1;
		else
			dsety[f1]=f2;
	}
}
void add(int p)
{
	tim[p]==timetip? cnt[p]++:(cnt[p]=1,tim[p]=timetip);
}
int calc(int p)
{
	return tim[p]==timetip? cnt[p]:0;
}
int main()
{
	int n,k,l;scanf("%d%d%d",&n,&k,&l);
	for(int i=1;i<=n;i++)
		dsetx[i]=dsety[i]=i;
	for(int i=1,p1,p2;i<=k;i++)
	{
		scanf("%d%d",&p1,&p2);
		mergex(p1,p2);
	}
	for(int i=1,p1,p2;i<=l;i++)
	{
		scanf("%d%d",&p1,&p2);
		mergey(p1,p2);
	}
	for(int i=1;i<=n;i++)
		if(findx(i)==i)
			headx[i]=i;
		else{nxtx[i]=headx[findx(i)];headx[findx(i)]=i;}
	for(int i=1;i<=n;i++)
		if(findy(i)==i)
			heady[i]=i;
		else{nxty[i]=heady[findy(i)];heady[findy(i)]=i;}
	for(int i=1;i<=n;i++)
		if(headx[i])
		{
			timetip++;
			for(int e=headx[i];e;e=nxtx[e])
				add(findy(e));
			for(int e=headx[i];e;e=nxtx[e])
				ans[e]=calc(findy(e));
		}
	for(int i=1;i<n;i++)
		printf("%d ",ans[i]);
	printf("%d\n",ans[n]);
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define fo(i, u, v) for(int i= u; i<=v; ++i)
#define fob(i, u, v) for(int i = u; i>=v; --i)
#define fi first
#define se second
#define si size()
#define pb push_back

using namespace std;
typedef double db;
typedef long long ll;
typedef pair <int ,int> pii;
typedef pair <ll, ll> pll;
const long long MOD = 1e9 +7;
const long long N = 1e6 + 7;
const long long inf = ll(1e18);
const string name = "";
template <class T> int getbit(T x,int y) {return x >> (y-1) & 1;}
template <class T> T offbit(T x, int y) {return x | 1 <<(y-1);}
template <class T> T onbit(T x, int y) {return x & (~1<<(y-1));}
template <class T> T sqr(T x) {return x*x;}
template <class T> void read_int(T &rs) {
    rs = 0;
    int neg = 1;
    char r;
    for(r = getchar(); r < '0' || r > '9'; r = getchar())
    if(r == '-') neg *= -1;
    rs = r - '0';
    for(r = getchar(); r >= '0' && r <= '9'; r = getchar())
    rs = rs*10 + (r - '0');
    rs *= neg;
}

ll n, s, k, k2, a[N], b[N];

int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen((name + ".inp").c_str(), "r", stdin);
    //freopen((name + ".out").c_str(), "w", stdout);
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    for(int i = 1; i <= n; ++i) cin >> b[i];
    for(int i = 1; i <= n; ++i) {
        s += b[i] - a[i];
        if(a[i] < b[i]) {
            k += (b[i] - a[i] + 1) / 2;
            a[i] = (b[i] + (b[i] - a[i]) % 2);
        }
        k2 += a[i] - b[i];
    }
    if(k2 > k) {cout << "No"; return 0;}
    else k += (k - k2);
    if(k == s) cout << "Yes";
    else cout << "No";
    return 0;
}



Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll N;
    cin >> N;
    vector<ll> D(N,0);
    for(ll i=0;i<N;i++)cin>>D[i];
    Map H;
    H[0]++;
    for(ll i=0;i<N;i++){
        H[D[i]]++;
        //高橋君との時差ごとにカウント
        if(H[D[i]]==3||H[12]==2||H[0]==2){
            print(0);
            return 0;
        }
    }
    vector<ll> d(0);;
    for(auto p: H)for(ll i=0;i<p.second;i++)
    d.emplace_back(p.first);;
    ll n=d.size();
    ll ans=0;
    for(ll i=0;i<(1<<n);i++){
        ll ans2=INF;
        vector<ll> vec(0);
        vector<bool> check(24,0);
        ll next=-1;
        for(ll j=0;j<n;j++){
            if(i&(1<<j)){
                vec.emplace_back(d[j]);
                check[d[j]]=1;
            }
            else {
                if(j>0&&d[j]==d[j-1]&&!(i&(1<<(j-1)))){
                    next+=(1<<j);
                }
                vec.emplace_back(24-d[j]);check[24-d[j]]=1;
            }
        }
        for(ll j=0;j<n-1;j++)
            for(ll k=j+1;k<n;k++){
                ll f=abs(vec[j]-vec[k]);
                chmin(ans2,min(f,24-f));
            }
        chmax(ans,ans2);
        if(next>=0)
        i+=next;
    }
    print(ans)



    return 0;
}


Measured memory_bytes: 256
n, x = map(int, input().split())

ans = [i for i in range(1, 2*n)]

if x == 1 or x == 2*n - 1:
    print("No")
    exit()

print("Yes")
ans[n-1], ans[x-1] = ans[x-1], ans[n-1]
ans[n-2], ans[0] = ans[0], ans[n-2]
ans[n], ans[2*n-2] = ans[2*n-2], ans[n]

if n == 2:
    for i in ans:
        print(i)
    exit()

if x < 2*n-2:
    ans[n-3], ans[2*n-3] = ans[2*n-3], ans[n-3]
else:
    ans[n+1], ans[1] = ans[1], ans[n+1]

for i in ans:
    print(i)

Measured memory_bytes: 12532
fun main( args : Array<String> ) {
  val (x, a, b) = readLine()!!.split(" ").map { it.toInt() }
  val expire    = b - a
  when {
    expire > x -> "dangerous"
    expire <= 0 -> "delicious"
    else -> "safe"
  }.let { println( it ) }
}

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

using namespace std;

using lr_table_t = std::array<std::array<int, 501>, 501>;
using pq_t = std::pair<int, int>;

std::vector<int> solve(const lr_table_t& lrs, const std::vector<pq_t>& pqs) {
  std::vector<int> rets(pqs.size());
  for (int i = 0; i < pqs.size(); ++i) {
    const auto& pq = pqs[i];
    int const p = pq.first;
    int const q = pq.second;
    int ret = 0;
    for (int l = p; l <= q; ++l) {
      ret += lrs[l][q] - lrs[l][p - 1];
    }
    rets[i] = ret;
  }
  return rets;
}

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, m, q;
  std::cin >> n >> m >> q;
  lr_table_t lrs{};
  for (int i = 0; i < m; ++i) {
    int32_t l, r;
    std::cin >> l >> r;
    for (int j = r; j <= n; j++) {
      lrs[l][j]++;
    }
  }
  std::vector<pq_t> pqs(q);
  for (auto& pq : pqs) {
    std::cin >> pq.first >> pq.second;
  }
  for (auto const ret : solve(lrs, pqs)) {
    std::cout << ret << std::endl;
  }
  return 0;
}


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

int main(){
  char a, b;
  cin >> a >> b;
  if(a < b) 
    for(int i = 0; i < b - '0'; i++) cout << a;
  else 
    for (int i =0; i < a - '0'; i++) cout << b;
}


Measured memory_bytes: 3560
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        while(true){
            String S = sc.next();
            	if(S.equals("-"))
                    break;
            String s = S;
            int m = sc.nextInt();
            for(int i=0;i<m;i++){
                int h = sc.nextInt();
                 	String s1 = s.substring(h);
                 	String s2 = s.substring(0,h);
               		s = s1 + s2;
            }
            System.out.println(s);
        }
        sc.close();
    }
}


Measured memory_bytes: 26320
open Batteries
open Printf

let ($) g f x = g (f x)

module MyList = struct
  include List
  let foldl = fold_left
  let foldli = fold_lefti
  let foldr = fold_right
  let foldri = fold_righti
  
  let flatmap = concat_map

  let zipf = map2
  let zipfi = map2i
end

module L = MyList

let atoi = int_of_string
let itoa = string_of_int
let atof = float_of_string
let ftoa = string_of_float
let ctoi = int_of_char
let itoc = char_of_int

let stocl = String.to_list
let cltos = String.of_list
let spsp s = String.split_on_char ' ' s

module MyString = struct
  include String

  let map' f s = L.map f (stocl s)
  let mapi' f s = L.map f (stocl s)

  let zipf f a b = L.zipf f (stocl a) (stocl b)
  let zipfi f a b = L.zipfi f (stocl a) (stocl b)

  let mkstr f sep ls =
    L.foldl (fun acc x -> acc ^ sep ^ (f x)) (f @@ L.hd ls) (List.tl ls)
end

module S = MyString

let rds () = read_line ()

let rdi () = atoi @@ rds ()

let rdhs () = spsp @@ rds ()
let rdhi () = rdhs () |> L.map atoi

let rdi2 () = match rdhi () with
  | a::b::_ -> (a, b)
  | _ -> (0, 0)

let rdi3 () = match rdhi () with
| a::b::c::_ -> (a, b, c)
| _ -> (0, 0, 0)

let rdi4 () = match rdhi () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0, 0, 0, 0)

let rdv n rdf =
  let rec rdv' n =
    if n <= 0 then []
    else (
      let s = rdf () in
      s::(rdv' (n - 1))
    )
  in rdv' n

let rdvi n = rdv n rdi
let rdvi2 n = rdv n rdi2
let rdvi3 n = rdv n rdi3
let rdvi4 n = rdv n rdi4

let puts s = print_endline s
let putyn b = puts (if b then "Yes" else "No")
let puti i = puts @@ itoa i

let set_power ls =
  let rec set_power' ls pls =
    match ls with
    | [] -> pls
    | hd::tl -> set_power' tl (L.flatmap (fun p -> [p; hd::p]) pls)
  in set_power' ls [[]]


let rdhf () = rdhs () |> L.map atof
let rdf4 () = match rdhf () with
| a::b::c::d::_ -> (a, b, c, d)
| _ -> (0., 0., 0., 0.)

let _ =
  let (a, b, h, m) = rdf4 () in
  let pi = Float.pi in
  let d2 = a *. a +. b *. b
  and c2 = a *. b *. (cos ((pi /. 6.) *. h -. (11. *. pi /. 360.) *. m)) in
  printf "%.15f" (sqrt (d2 -. 2. *. c2));;


Measured memory_bytes: 5648
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    int a[n],b[n];
    vector<pair<int,int>>p(n);
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        p[i]={a[i],b[i]};
    }
    sort(p.begin(),p.end());
    int rew=0,x=-1;
    priority_queue<int>q;
    for(int i=1;i<=m;i++){
        for(int j=x+1;p[j].first==i;j++){
            q.push(p[j].second);
            x=j;
        }
        if(q.size()){
            rew+=q.top();
            q.pop();
        }
    }
    cout<<rew<<endl;
    return 0;
}


Measured memory_bytes: 2428
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <deque>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#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 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 emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
void print(vec v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vecll v){for(auto e:v)cout<<e<<" ";cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}
const int INF=1e6;
int ans;
void proc(vec x){
    int n=x.size()-1;
    vector<vec> dp(n+1,vec(4,INF));
    dp[0][0]=0;
    rep(i,n){
        if(x[i]==1){
            chmin(dp[i+1][2],dp[i][0]+1);
            chmin(dp[i+1][0],min(dp[i][1],dp[i][2]));
            chmin(dp[i+1][0],dp[i][0]+1);
            chmin(dp[i+1][3],dp[i][0]+1);
        }
        else{
            chmin(dp[i+1][2],dp[i][0]+x[i]);
            chmin(dp[i+1][2],dp[i][1]+x[i]-1);
            chmin(dp[i+1][1],dp[i][0]+1);
            chmin(dp[i+1][1],dp[i][1]+1);
            chmin(dp[i+1][0],dp[i][2]);
            chmin(dp[i+1][0],dp[i][0]+x[i]);
            chmin(dp[i+1][0],dp[i][1]+x[i]-1);
            chmin(dp[i+1][3],dp[i][0]+x[i]);
            chmin(dp[i+1][3],dp[i][1]+x[i]-1);
            chmin(dp[i+1][2],dp[i][3]+1);
            chmin(dp[i+1][0],dp[i][3]+1);
            chmin(dp[i+1][3],dp[i][3]+1);
        }
    }
    int tmp=INF;
    chmin(tmp,dp[n][0]+x[n]);
    chmin(tmp,dp[n][1]+x[n]-1);
    chmin(tmp,dp[n][2]);
    // print(dp);
    ans-=tmp;
    ans+=accumulate(all(x),0);
}
main(){
    int n=in();
    string s;
    // vec v;
    // rep(i,n)v.pb(in());
    // proc(v);cout<<ans;return 0;
    cin>>s;
    vector<int> now={0};
    rep(i,n){
      if(now.size()==1 &&now[0]==0&& s[i]=='0'){
        continue;
      }
      if(s[i]=='0'&&(i==n-1||s[i+1]=='0')){
      proc(now);now=vec();now.pb(0);}
      else if(s[i]=='0')now.pb(0);
      else now.back()++;
    }
    proc(now);
    cout<<ans;
}


Measured memory_bytes: 900
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL<<60;

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

// 総重量w以下で,i番目の品物まで選んだときの価値の総和の最大値
vector<vector<long long>> knapsack(110, vector<long long>(101010, 0));

int main(void){
    
    int n, W;
    cin >> n >> W;
    
    vector<int> w(n), v(n);
    for (int i = 0; i < n; i++) cin >> w[i] >> v[i];
    
    
    // initialization
    knapsack[0][0] = 0;
    
    for (int i = 0; i < n; i++){
        
        for (int j = 0; j <= W; j++){
            
            // i番目の荷物を選ばないとき
            chmax(knapsack[i+1][j], knapsack[i][j]);
            
            // i番目の荷物を選ぶとき
            if(j - w[i] >= 0){
                chmax(knapsack[i+1][j], knapsack[i][j - w[i]] + v[i]);
            }
        }
    }
    
    cout << knapsack[n][W] << endl;
}


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

int main() {
  int ABC[3], K;
  cin >> ABC[0] >> ABC[1] >> ABC[2];
  cin >> K;

  sort(ABC, ABC + 3);
  for (int i = 0; i < K; i++) ABC[2] *= 2;
  int ans = ABC[0] + ABC[1] + ABC[2];
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<vector<int>> A(N, vector<int>(2));
  for (int i = 0; i < N; i++) {
    cin >> A.at(i).at(0);
    A.at(i).at(1) = i + 1;
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < N; i++) {
    cout << A.at(i).at(1) << " ";
  }
  cout << endl;
  
}

Measured memory_bytes: 8716
#include <iostream>
#include <vector>
#include <ios>
#include <iomanip>

constexpr double INF = 1e18;

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

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

int main() {
	std::size_t n;
	std::cin >> n;
	std::vector<double> x(n), y(n);
	std::vector<char> d(n);
	
	for (std::size_t i = 0; i < n; i++) {
		std::cin >> x[i] >> y[i] >> d[i];
	}
	
	auto f = [&](double t) -> double {
		double x_max = -INF, x_min = INF;
		double y_max = -INF, y_min = INF;
		
		for (std::size_t i = 0; i < n; i++) {
			double cur_x = x[i], cur_y = y[i];
			if (d[i] == 'U') cur_y += t;
			else if (d[i] == 'D') cur_y -= t;
			else if (d[i] == 'L') cur_x -= t;
			else cur_x += t;
			chmax(x_max, cur_x); chmin(x_min, cur_x);
			chmax(y_max, cur_y); chmin(y_min, cur_y);
		}
		
		return (x_max - x_min) * (y_max - y_min);
	};
	
	std::vector<double> dat;
	dat.push_back(0);
	
	{
		double ud = -INF, l = -INF, r = -INF;
		for (std::size_t i = 0; i < n; i++) {
			if (d[i] == 'L') chmax(l, x[i]);
			else if (d[i] == 'R') chmax(r, x[i]);
			else chmax(ud, x[i]);
		}
		if (l > -INF and r > -INF) dat.push_back(abs(l - r) / 2.0);
		if (ud > -INF and l > -INF) dat.push_back(abs(ud - l));
		if (ud > -INF and r > -INF) dat.push_back(abs(ud - r));
	}
	{
		double ud = INF, l = INF, r = INF;
		for (std::size_t i = 0; i < n; i++) {
			if (d[i] == 'L') chmin(l, x[i]);
			else if (d[i] == 'R') chmin(r, x[i]);
			else chmin(ud, x[i]);
		}
		if (l < INF and r < INF) dat.push_back(abs(l - r) / 2.0);
		if (ud < INF and l < INF) dat.push_back(abs(ud - l));
		if (ud < INF and r < INF) dat.push_back(abs(ud - r));
	}
	{
		double u = -INF, dd = -INF, lr = -INF;
		for (std::size_t i = 0; i < n; i++) {
			if (d[i] == 'U') chmax(u, y[i]);
			else if (d[i] == 'D') chmax(dd, y[i]);
			else chmax(lr, y[i]);
		}
		if (u > -INF and dd > -INF) dat.push_back(abs(u - dd) / 2.0);
		if (lr > -INF and u > -INF) dat.push_back(abs(lr - u));
		if (lr > -INF and dd > -INF) dat.push_back(abs(lr - dd));
	}
	{
		double u = INF, dd = INF, lr = INF;
		for (std::size_t i = 0; i < n; i++) {
			if (d[i] == 'U') chmin(u, y[i]);
			else if (d[i] == 'D') chmin(dd, y[i]);
			else chmin(lr, y[i]);
		}
		if (u < INF and dd < INF) dat.push_back(abs(u - dd) / 2.0);
		if (lr < INF and u < INF) dat.push_back(abs(lr - u));
		if (lr < INF and dd < INF) dat.push_back(abs(lr - dd));
	}
	
	double ans = INF;
	for (double t : dat) chmin(ans, f(t));
	
	std::cout << std::fixed << std::setprecision(10) << ans << '\n';
	
	return 0;
}

Measured memory_bytes: 1920
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N;
    cin >> N;
    vector<double> vs(N);
    for (int i = 0; i < N; ++i) cin >> vs[i];
    sort(vs.begin(), vs.end());
    double value = vs.front();
    for (int i = 1; i < N; ++i)
    {
        value += vs[i];
        value /= 2.0;
    }
    cout << value << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define low lower_bound
#define upp upper_bound
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define Rep(i,n) for (int i = (int)(n); i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define cend printf("\n");
#define prique(T) priority_queue<T, vector<T>, greater<T>>
#define prique2(T) priority_queue<T>

struct edge { int to, cost; };
using P = pair<int, int>;
using PP = pair<P, int>;
using D = pair<double, double>;
//const long long mod = 998244353;
const long long mod = 1e9 + 7, inf = 3e18;
const string sp = " ";

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

int modpow(int x, int n) {
	int ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans *= x;
			if (mod <= ans) ans %= mod;
		}
		x *= x;
		if (mod <= x) x %= mod;
		n >>= 1;
	}
	return ans;
}

int fact[1000000];
void f_init(int n) {
	if (1000000 <= n) return;
	fact[0] = fact[1] = 1;
	for (int i = 2; i <= n; ++i) {
		fact[i] = i * fact[i - 1];
		if (mod <= fact[i]) fact[i] %= mod;
	}
	return;
}

int comb(int n, int r) {
	if (n < r) return 0;
	if (n == r) return 1;
	int ans = fact[n] * modpow(fact[n - r], mod - 2) % mod * modpow(fact[r], mod - 2);
	if (ans < 0) return ans + mod;
	return ans;
}

int nck[1010][1010];
void comb(int n) {
	rep(i, n + 1) {
		rep(j, i + 1) {
			if (j == 0 || i == j) nck[i][j] = 1;
			else nck[i][j] = nck[i - 1][j - 1] + nck[i - 1][j];
		}
	}
}

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

int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}

bool pri(int p) {
	for (int i = 2; i * i <= p; ++i) if (p % i == 0) return false;
	return p > 1;
}

map<int, int> factring(int n) {
	map<int, int>ans;
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			n /= i;
			++ans[i];
		}
	}
	if (n != 1) ++ans[n];
	return ans;
}

int n, ans;
int l[2 * 1010];
signed main() {
	cin >> n;
	rep(i, n) {
		cin >> l[i];
	}
	sort(l , l + n);
	rep(i, n) {
		int a = l[i];
		for (int j = i + 1; j < n; j++) {
			int b = l[j];
			int cnt = (low(l, l + n, a + b) - l) - (upp(l, l + n, abs(a - b)) - l);
			if (abs(a - b) < a) cnt--;
			if (abs(a - b) < b) cnt--;
			ans += cnt;
		}
	}
	cout << ans / 3 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
using namespace std;
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int n;
    cin>>n;
    if(n<1200)
    {
     cout<<"ABC";
    }
    else if(n<2800)
    {
             cout<<"ARC";

    }
    else
    {
             cout<<"AGC";

    }

return(0);
}


Measured memory_bytes: 256
#include <stdio.h>
int main (){
int i;
double a,b,c,sum=0;
char s1[10]={"JPY"};
char s2[10] = {"BTC"};
char s[10];
  scanf ("%lf",&a);
  for (i=0;i<a;i++){
  scanf ("%lf ",&b);
  scanf ("%s ",s);
  if (strcmp(s,s1)==0){
  sum=sum + b;
  }
  else if (strcmp(s,s2)==0){
  sum=sum + b*380000;
  }
  }
  
 printf ("%f",sum);
return 0;
}

Measured memory_bytes: 128
#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);
  }

  int count = 0;
  int index = 1;
  int before = 0;
  while (count < N) {
    before = index;
    index = a.at(index - 1);
    count++;
    if (index == 2) {
      break;
    }
    if (a.at(index - 1) == before) {
      count = -1;
      break;
    }
  }

  if (count >= N) {
    count = -1;
  }

  cout << count << endl;
}

Measured memory_bytes: 768