akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < j; ++i)
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double EPS = 1e-9;

int solve(int p, int q, stringstream &ss){
  map<int, int> m; for(int i = 0; m.find(p) == m.end(); ++i){
    if(p == 0) return -1;
    m[p] = i;
    p *= 10;
    ss <<p / q;
    p %= q;
  }
  return m[p];
}

int main() {
  int p, q;
  while(scanf("%d %d", &p, &q) != EOF){
    p %= q;
    stringstream ss;
    int d = solve(p, q, ss);
    cout <<ss.str() <<endl;
    if(d != -1){
      REP(i, ss.str().length()) cout <<(i < d ? " " : "^");
      cout <<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1248
# -*- coding: utf-8 -*-
n = int(input())
xyh = [list(map(int,input().split())) for i in range(n)]


#全探索すれば良い

#1つめの高さが0ではない情報を記録
for xi,yi,hi in xyh:
    if hi>0:
        memo = [xi,yi,hi]
        break

for cx in range(0,101):
    for cy in range(0,101):
        flg = True
        #cx,cyが中心座標の場合、memoの情報から高さを得られる
        ch = abs(memo[0]-cx)+abs(memo[1]-cy)+memo[2]
        for xi,yi,hi in xyh:
            #各情報の検証
            if hi!=max(ch-abs(xi-cx)-abs(yi-cy),0):
                flg = False
                break
        if flg:
            print("{} {} {}".format(cx,cy,ch))
            import sys
            sys.exit()


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

int main() {
    int n;
    cin >> n;
    vector<vector<int> > v(2, vector<int>(100005));
    vector<int> mode(2);
    vector<int> maxi(2);
    for (int i = 0; i < n / 2; i++) {
        int x, y;
        cin >> x >> y;
        v[0][x]++;
        v[1][y]++;

        if (mode[0] < v[0][x]) {
            mode[0] = v[0][x];
            maxi[0] = x;
        }
        if (mode[1] < v[1][y]) {
            mode[1] = v[1][y];
            maxi[1] = y;
        }
    }
    sort(v[0].begin(), v[0].end(), greater<int>());
    sort(v[1].begin(), v[1].end(), greater<int>());

    int ans = 0;
    if (maxi[0] != maxi[1]) {
        ans = n - mode[0] - mode[1];
    } else {
        ans = min(n - mode[0] - v[1][1], n - mode[1] - v[0][1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

int main()
{
    int n, cnt = 0;
    scanf("%d", &n);
    int a[n + 1];
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
        if (i != a[i])
            cnt++;
    }
    if (cnt == 0 || cnt == 2)
        printf("YES\n");
    else
        printf("NO\n");
    return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
#define pii pair<int, pair<int, int>>
#define ss second
#define ff first
#define all(x) ((x).begin(), (x).end())

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;
const ll oo = 1 << 30;

int main(){
    ios_base::sync_with_stdio(false);
    int n;
    bool pos = false;
    cin >> n;

    for (int i=1; i<=9; i++){
        if (n/i <= 9 and n%i == 0 ){
            pos = true;
            break;
        }
    }

    if (pos) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

int main()
{
	int n = 0;
	scanf("%d", &n);
	int* a = (int *)malloc(sizeof(int) * n);
	int ch,k=0;

	while(scanf("%d", &ch) != EOF){
		a[k] = ch;
		k++;
	}

	for(int i = 0; i < n; i++){
		int v = a[i];
		int j = i-1;
		while(j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;

		for(int j = 0; j < n; j++){
			printf("%d", a[j]);
			if(j != n-1) printf(" ");
		}
		printf("\n");
	}
	return 0;
}


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

using namespace std;
using namespace std::chrono;

/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
ll mod=1000000007;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    int n,k,i;
    cin>>n>>k;
    ll mi=0,ma=0,ans=0,m1=0,m2=n;
    REP(i,1,k){
        mi+=m1;
        ma+=m2;
        m1++;
        m2--;
    }
    REP(i,k,n+1){
        dbg(ans,mi,ma);
        ans+=ma-mi+1;
        ans%=mod;
        mi+=m1;
        ma+=m2;
        m1++;
        m2--;
    }
    cout<<ans;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<pii> v(m);
	REP(i, m)cin >> v[i].first>>v[i].second;
	sort(ALL(v));
	int a = 0, b = n + 1;
	int ans = 1;
	REP(i, m) {
		if (v[i].first<b && v[i].second>a) {
			a = max(a, v[i].first);
			b = min(b, v[i].second);
		}
		else {
			ans++;
			a = v[i].first;
			b = v[i].second;
		}
	}
	cout << ans << endl;

}

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

class Takoyaki{
private:
    int n,x,t;
public:
    Takoyaki(){
        cin>>n>>x>>t;
    }
    int solve(){
        int ans = ceil((float)n/x)*t;
        return ans;
    }
};

int main(){
    Takoyaki problem = Takoyaki();
    int ans = problem.solve();
    cout<<ans<<"\n";
}

Measured memory_bytes: 3596
# python 3.4.3
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# library
# -------------------------------------------------------------



# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = input().rstrip()

N = len(S)
ans = [-1,-1]

# 連続する2文字が同じ場合、アンバランスである
for i in range(N-1):
    if S[i] == S[i+1]:
        ans = [i+1,i+2]
        break

# 連続する3文字で、両端の文字が同じならアンバランスである
for i in range(N-2):
    if S[i] == S[i+2]:
        ans = [i+1, i+3]
        break

# 4文字以上においてある文字が過半数になる場合、上記の2条件を満たさずには実現不可能


print(ans[0], ans[1])

Measured memory_bytes: 3188
#include<bits/stdc++.h>
typedef long long ll;
#define INF 0x3f3f3f3f
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
using namespace std;
const int sz=1e5+1, mod=1e9+7;


int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n,j,i,x;
    cin>>n;
    int a[n+1]; vector<int> v;
    for(i=1;i<=n;i++){
        cin>>a[i];
    }

    for(i=n;i>=1;i--){
        if(a[i]){
            v.pb(i);
            for(j=1;j*j<=i;j++){
                if(i%j==0){
                    a[j]=(a[j]+1)%2;
                    if( j*j!=i ) a[i/j]=(a[i/j]+1)%2;
                }
            }
        }
    }
    bool good=true;
    for(i=1;i<=n;i++){
        if(a[i]!=0)good=false;
    }
    if(!good){
        cout<<"-1\n";
        return 0;
    }

    cout<<v.size()<<"\n";
    sort(v.begin(),v.end());
    for(auto x:v)cout<<x<<" ";

}


Measured memory_bytes: 2424
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  string s;
  cin >> s;
  vector<int> cnt(256);
  for (int i = 0; i < s.size(); i++) {
    cnt[s[i]]++;
  }
  for (int i = 0; i < 256; i++) {
    if (cnt[i] > 1) {
      cout << "no" << endl;
      return 0;
    }
  }
  cout << "yes" << endl;
  return 0;
}

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

using namespace std;
#define int long long
#define mp make_pair
#define pb push_back


const int inf = 1e18;
const double EPS = 0.00000001;

signed main(){
    int a,b;
    cin >> a >> b;
    string s1,s2;
    s1 = s2 = "";
    for(int i =0;i<a;i++) s1 += (b+'0');
    for(int i =0;i<b;i++) s2 += (a+'0');
    cout << (s1 < s2 ? s1 : s2);
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);i++)
#define PI 3.14159265358979323846264338327950L
using namespace std;
using P = pair<int,int>;
using ll = long long;
using namespace std;
int main(void){
    // Your code here!
    string s;
    cin >> s;
    if(s[2] == s[3] and s[4] == s[5]){cout << "Yes" << endl;}
    else {cout << "No" << endl;}
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(void){
  int i=0;
  char str[1200];

  gets(str);

  while(1)
    {
      if(str[i] == '\0')
        {
          break;
        }
      if('a' <= str[i] && str[i] <= 'z')
        {
          str[i] -= 0x20;
        }
      else if('A' <= str[i] && str[i] <= 'Z')
        {
          str[i] += 0x20;
        }
      i++;
    }

  printf("%s\n",str);
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;
 
// debugger
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
// 
 
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
 
#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define len length
#define ret0 return 0
#define ret return 
 
 
#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)
 
#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>
 
// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;
 
#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)2e5+5
#define N (1ll<<10)
#define pi 3.141592653589793238462643

void solve(){
    ll n, k;
    cin>>n>>k;
    ll a[n];
    loop(i,0,n){
        cin>>a[i];
    }
    sort(a, a+n);
    ll ans = 0;
    for(ll i=0; i<max(0ll, n-k); i++){
        ans += a[i];
    }
    print(ans);
}
 
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   
 
    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
   
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Runtime.ExceptionServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Read();

            var zero = 0;
            var one = 0;
            for (int i = 0; i < S.Length; i++)
            {
                if (i % 2 == 0)
                {
                    //0
                    if (S[i].ToString() == "0")
                    {
                        zero++;
                    }

                    //1
                    if (S[i].ToString() == "1")
                    {
                        one++;
                    }
                }
                else
                {
                    //0
                    if (S[i].ToString() == "0")
                    {
                        one++;
                    }

                    //1
                    if (S[i].ToString() == "1")
                    {
                        zero++;
                    }
                }
            }
            WriteLine(Min(zero, one));
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 31008
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)



class SEGMENTS{
private:
    
    struct seg{
        int l,r;
        bool operator < (seg obj)const {
            if(r!=obj.r) return r<obj.r;
            else return l<obj.l;
        }
    };
    
    set<seg> dat;
    
    bool isCross(int l1,int r1,int l2,int r2){ return ( (l1<=l2 && l2<r1) || (l2<=l1 && l1<r2)); }
    bool isInclude(int li, int ri, int L, int R){ return (L<=li && ri<=R); }
    
public:
    
    void erase(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end())break;
            
            int li = it->l;
            int ri = it->r;
            if( !isCross(li,ri,l,r) )break;
            
            if( isInclude(li,ri,l,r) ) dat.erase(it);
            else{
                int tl = li, tr = ri;
                if( isInclude(l,r,li,ri) ){
                    dat.erase(it);
                    if(li!=l) dat.insert(seg{li,l});
                    if(r!=ri) dat.insert(seg{r,ri});
                }else{
                    if(li<=l&&l<ri) tr = l;
                    if(l<=li&&li<r) tl = r;
                    dat.erase(it);
                    if(tl!=tr) dat.insert(seg{tl,tr});
                }
            }
        }
    }
    
    void insert(int l, int r){
        while(true){
            auto it = dat.upper_bound(seg{(int)INF,l});
            if(it==dat.end())break;
            
            int li = it->l;
            int ri = it->r;
            if( !isCross(li,ri,l,r) )break;
            
            if( isInclude(li,ri,l,r) ) dat.erase(it);
            else{
                if(li<l) l = li;
                if(r<ri) r = ri;
            }
        }
        
        auto it = dat.lower_bound(seg{(int)-INF,l});
        if( it!=dat.end() && it->r == l ){
            l = it->l;
            dat.erase(it);
        }
        it = dat.upper_bound(seg{(int)INF,r});
        if( it!=dat.end() && it->l == r ){
            r = it->r;
            dat.erase(it);
        }
        
        if(l!=r)dat.insert(seg{l,r});
    }
    
    int size(){ return dat.size(); }
    
    void output(){ for(auto e:dat)cout<<e.l<<" "<<e.r<<endl;cout<<endl; }
    
    void assertion(){ for(auto e:dat)assert(e.r-e.l>0); }
};


int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    
    SEGMENTS st;
    
    for(int i=0;i<n;){
        if(s[i]=='0')i++;
        else{
            int l=i;
            while(i<n && s[i]=='1') i++;
            st.insert(l,i);
        }
    }
    
    int q;
    cin>>q;
    while(q--){
        int l,r,b;
        cin>>l>>r>>b;
        l--;
        
        if(b==0)    st.erase(l,r);
        else        st.insert(l,r);
        
        cout<<st.size()<<endl;
        st.assertion();
//        st.output();
    }
}

Measured memory_bytes: 4228
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp23
{
    class Program
    {
        private static List<Restaurant> _restaurants = new List<Restaurant>();


        static void Main(string[] args)
        {
            var line = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var input_N = line[0];

            for (int i = 0; i < input_N; i++)
            {
                var line2 = Console.ReadLine().Split(' ');

                var name = line2[0];
                var point = int.Parse(line2[1]);

                var index = GetIndex(0, name, point);
                _restaurants.Insert(index, new Restaurant(name, point, i + 1));
            }

            foreach (var item in _restaurants)
            {
                Console.WriteLine(item.Order.ToString());
            }
        }

        static int GetIndex(int startIndex, string newCityName, int newPoint)
        {
            for (int i = startIndex; i < _restaurants.Count; i++)
            {
                var compare = newCityName.CompareTo(_restaurants[i].CityName);
                if (compare < 0)
                {
                    return i;
                }
                else
                {
                    if(compare == 0 && newPoint > _restaurants[i].Point )
                    {
                        return i;
                    }

                    return GetIndex(i + 1, newCityName, newPoint);
                }
            }

            return startIndex;
        }


    }

    class Restaurant
    {
        public string CityName { get; }
        public int Point { get; }
        public int Order { get; }

        public Restaurant(string cityName, int point, int order)
        {
            CityName = cityName;
            Point = point;
            Order = order;
        }
    }
}


Measured memory_bytes: 13536
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(void){
  ll d,g;
  cin>>d>>g;
  ll p[d],c[d];
  for(int i=0;i<d;i++){
    cin>>p[i]>>c[i];
  }
  ll ans=1001001001;
  for(int i=0;i<(1<<d);i++){
    bitset<10> bit(i);
    ll x=0,y=-1,z=0;
    for(int j=0;j<d;j++){
      if(bit.test(j)){
        x+=(j+1)*100*p[j]+c[j];
        z+=p[j];
      }else{
        y=j;
      }
    }
    if(x<g && g-x<100*(y+1)*p[y]){
      z+=((g-x)/100-1)/(y+1)+1;
      ans=min(ans,z);
    }else if(x>=g){
      ans=min(ans,z);
    }
  }
  cout<<ans<<endl;
  return 0;
}

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

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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  vector <vector <char>> v(n, vector <char> (n));
  vector <vector <char>> u(m, vector <char> (m));
  rep(i, n) {
    rep(j, n) {
      cin >> v.at(i).at(j);
    }
  }
  rep(i, m) {
    rep(j, m) {
      cin >> u.at(i).at(j);
    }
  }
  string res = "No";
  rep(i, n-m+1) {
    rep(j, n-m+1) {
      if (v.at(i).at(j) == u.at(0).at(0)) {
        bool flag = 1;
        rep(k, m) {
          rep(l, m) {
            if (v.at(i+k).at(j+l) != u.at(k).at(l)) {
              flag = 0;
              break;
            }
          }
        }
        if (flag) {
          res = "Yes";
          break;
        }
      }
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 256
d = [[[-1, -1], [0, -1], [1, -1], [1, 0], [0, 1], [-1, 0]],
      [ [-1, 0], [0, -1],  [1, 0], [1, 1], [0, 1], [-1, 1]]]

w, h = gets.split.map(&:to_i)
fld = (h+2).times.map{ [false]*(w+2) }
(1..h).each do |i|
  gets.split(" ").each_with_index{ |e, j| fld[i][j+1] = true if e == "1" }
end

prt = (h+2).times.map{ [false]*(w+2) }
arr = []
arr << [0, 0]
prt[0][0] = true
until arr.empty?
  y, x = arr.pop
  d[y%2].each do |dy, dx|
    u = y + dy; v = x + dx
    next if u < 0 || u > h+1 || v < 0 || v > w+1
    if !fld[u][v] && !prt[u][v]
      prt[u][v] = true
      arr << [u, v]
    end
  end
end

(1..h).each do |i|
  prt[i][1,w].each_with_index{ |e, j| fld[i][j+1] = true unless e }
end

sum = 0
(1..h).each do |i|
  (1..w).each do |j|
      d[i%2].each{ |y, x| sum += 1 if !fld[i+y][j+x] } if fld[i][j]
  end
end
p sum

Measured memory_bytes: 8904
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define ll long long
using namespace std;

int main() {
    int n;
    cin >> n;
    int tmp = n % 10;
    if (tmp == 3)
        cout << "bon" << endl;
    else if (tmp == 0 || tmp == 1 || tmp == 6 || tmp == 8)
        cout << "pon" << endl;
    else
        cout << "hon" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int N = 0;//12
    int S = 0;//3
    int NN = 0;
    
    scanf("%d",&N);
    
    NN = N;
    
    while (N != 0) {
        S = S + N % 10;
        N = N / 10;
    }
    
//割り切れるかどうかはどう判断するか
    if (NN % S == 0) {
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    
    return 0;
}

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


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    ll N,K;
    cin >> N >> K;
    vector<int> A(N) ;
    for (int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        A[i] = tmp-1;
    }
    vector<int> dest;
    int pos = 0;
    vector<bool> visited(N,false);
    while(!visited[pos]){
        dest.push_back(pos);
        visited[pos] = true;
        pos = A[pos];
    }
    int loop_end = dest.back();
    int loop_start = A[loop_end];
    int loop_res;
    for (int i=0;i<N;i++){
        if (dest[i] == loop_start){
            loop_res =i;
            break;
        }
    }
    int loop_size = dest.size() - loop_res;
    if (K < loop_res) printf("%d\n",dest[K]+1);
    else printf("%d\n",dest[loop_res + (K-loop_res)%loop_size]+1);
    return 0;
}


Measured memory_bytes: 5132
N,A,B=(int(i)for i in input().split())

AdefB = B-A
if AdefB%2 == 0:
    print(AdefB//2)
else:
    Ato1=A-1
    BtoN=N-B
    Ato1Pattern=Ato1+1+((B-Ato1-1)//2)
    BtoNpattern=BtoN+1+((N-BtoN-A-1)//2)
    print(min(Ato1Pattern,BtoNpattern))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef tuple<int,int,int> tp;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
void solve(int T,int P,int R){
    vector<tp> V(T);// cnt time tID
    int error[T][P];
    rep(i,0,T)rep(j,0,P)error[i][j] = 0;
    rep(i,0,T)get<2>(V[i]) = i+1;

    rep(i,0,R){
        int t,p,time;
        string res;
        cin >> t >> p >> time >> res;
        t--,p--;
        if(res == "CORRECT"){
            get<0>(V[t])++;
            get<1>(V[t]) += time + error[t][p] * 1200;
        }else{
            error[t][p]++;
        }
    }
    sort(V.begin(), V.end(), [](tp a, tp b){
        if(get<0>(a) != get<0>(b))return get<0>(a) > get<0>(b);
        if(get<1>(a) != get<1>(b))return get<1>(a) < get<1>(b);
        return get<2>(a) < get<2>(b);
    });
    rep(i,0,T){
        cout << get<2>(V[i]) << " " << get<0>(V[i]) << " " << get<1>(V[i]) << endl;
    }
}
main(){
    int T,P,R;
    cin >> T >> P >> R;
    while(T){
        solve(T, P, R);
        cin >> T >> P >> R;
    }
}


Measured memory_bytes: 3184
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstdio>

using namespace std;

struct NODE{
    int key;
    NODE *left, *right, *parent;
};

NODE *root, *NIL;

void insert(int k){
    NODE *y = NIL;
    NODE *x = root;
    NODE *z; 

    z = (NODE *)malloc(sizeof(NODE));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if (z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }

    z->parent = y;

    if (y == NIL){
        root = z;
    }else{
        if (z->key < y->key){
            y->left = z;
        }else{
            y->right = z;
        }
    }

}

void inorder(NODE *u){
    if (u == NIL){
        return;
    }
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}

void preorder(NODE *u){
    if (u == NIL){
        return;
    }
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(void){
    int m;
    string com;
    int k;

    cin >> m;

    for (int i = 0; i < m; i++){
        cin >> com;
        if (com == "insert"){
            cin >> k;
            insert(k);
        }else if (com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 26692
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<a*b/2<<endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[][] A = new int[3][N + 1];
		for (int i = 1; i <= N; i++)
			A[1][i] = sc.nextInt();
		for (int i = 1; i <= N; i++)
			A[2][i] = sc.nextInt();

		int max = 0;
		for (int i = 1; i <= N; i++) {
			int s = 0;
			for (int j = 1; j <= i; j++)
				s += A[1][j];
			for (int k = i; k <= N; k++)
				s += A[2][k];
			max = Math.max(max, s);
		}

		System.out.println(max);
	}
	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


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

long sum[1002001];
long sumnum;

int cmp(const void *a, const void *b);
long search(long,long,long,long);

int main(){
	int n,i,j;
	long m,p[1000],k,max,score;
	while(1){
		scanf("%d %ld",&n,&m);
		if(n==0) break;
		sum[0]=0;
		sumnum=1;
		for(i=0;i<n;i++){
			scanf("%ld",&p[i]);
			if(p[i]>m) continue;
			sum[sumnum]=p[i];
			sumnum++;
			for(j=0;j<=i;j++){
				if(p[i]+p[j]>m) continue;
				sum[sumnum]=p[i]+p[j];
				sumnum++;
			}
		}
		qsort(sum,sumnum,sizeof(long),cmp);
		max=0;
		for(k=0;k<sumnum;k++){
			score=search(sum[k],m,0,sumnum-1);
			max=(score>max)?score:max;
		}
		printf("%ld\n",max);
	}
	return 0;
}


long search(long num,long max,long s,long e){
	if(s==e) return num+sum[e];
	if(max-num>=sum[(e-s)/2+s+1]){
		return search(num,max,(e-s)/2+s+1,e);
	}
	return search(num,max,s,(e-s)/2+s);
}

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

Measured memory_bytes: 8820
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;

const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
ll n, p;
ll countodd = 0;
ll counteven = 0;
ll combination(ll n, ll r)
{
    if (n < r)
        return 0;
    if (r * 2 > n)
        r = n - r;
    ll dividend = 1;
    ll divisor = 1;
    for (ll i = 1; i <= r; ++i)
    {
        dividend *= (n - i + 1);
        divisor *= i;
    }
    return dividend / divisor;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> p;

    for (int i = 0; i < n; i++)
    {
        int j;
        cin >> j;
        if (j % 2 == 0)
        {
            counteven++;
        }
        else
        {
            countodd++;
        }
    }

    ll ans = 0;
    ll base = 1;
    for (ll i = 0; i < counteven; i++)
    {
        base *= 2;
    }
    if (p == 0)
    {
        for (ll i = 0; i <= countodd; i += 2)
        {
            ans += combination(countodd, i) * base;
        }
    }
    else
    {
        for (ll i = 1; i <= countodd; i += 2)
        {
            ans += combination(countodd, i) * base;
        }
    }
    cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int main() {
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define sz(x) (int)x.size()
#define int long long
typedef pair<int,int>pii;
typedef vector<int> vi;
typedef vector<vi> vii;
const int mxN=16,M=1e9+7;
//did u check when n=1?
//is mxN correct?
int n;
int  g[mxN][mxN];
int dp[(1<<16)],sum[(1<<16)];
void solve(int idx,int mask,int temp,vi& a,int k){
    if(idx==sz(a)){
        dp[mask]=max(dp[mask],k+sum[temp]);
        return;
    }
    solve(idx+1,mask,temp,a,k);
    solve(idx+1,mask^(1<<a[idx]),temp^(1<<a[idx]),a,k);
}
int32_t main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>g[i][j];
        }
    }
    for(int mask=0;mask<=(1<<n)-1;mask++){
        for(int i=0;i<n;i++){
            if(!(mask & (1<<i)))continue;
            for(int j=i+1;j<n;j++){
                if((mask & (1<<j))){
                    sum[mask]+=g[i][j];
                }
            }
        }
    }
    for(int mask=0;mask<(1<<n);mask++){
        vi aux;
        for(int i=0;i<n;i++){
            if(!(mask & (1<<i)))aux.pb(i);
            solve(0,mask,0,aux,dp[mask]);
        }

    }
    cout<<dp[(1<<n)-1];
    
}

Measured memory_bytes: 1280
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  w,h,i:Integer;
  s:array of string;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Read(h);
    Readln(w);
    SetLength(s,h);
    for i := 0 to h - 1 do
      Readln(s[i]);

    for i := 0 to h - 1 do begin
      Writeln(s[i]);
      Writeln(s[i]);
    end;
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
n=int(input())
nil=-1
sn=[[-1,-1,-1]for _ in range(n)]
child=[[]for _ in range(n)]
def getdepth(u):
	d=0
	while sn[u][0] != nil:
		u=sn[u][0]
		d+=1
	return d
def getheight(u):
	h1=h2=0
	if sn[u][2]!=nil:
		h1=getheight(sn[u][2])+1
	if sn[u][1]!=nil:
		h2=getheight(sn[u][1])+1
	return max(h1,h2)
aa=[]
for i in range(n):
	a=list(map(int,input().split()))
	aa.append(a)
aa.sort()
for i in range(n):
	a=aa[i]
	if a[1]!=-1:
		sn[a[0]][1]=a[1]
	if a[2]!=-1:
		sn[a[0]][2]=a[2]
	if a[1]!=-1:
		sn[a[1]][0]=a[0]
	if a[2]!=-1:
		sn[a[2]][0]=a[0]
for i in range(n):
	ans1="node "+str(i)+":"
	ans2="parent = "+str(sn[i][0])+","
	if sn[i][0]==-1:
		x=-1
	elif sn[sn[i][0]][1]==-1 or sn[sn[i][0]][2]==-1:
		x=-1
	else:
		x=sn[sn[i][0]][2] if i==sn[sn[i][0]][1] else sn[sn[i][0]][1]
	ans3="sibling = "+str(x)+","
	y=0
	if sn[i][1]!=-1:
		y+=1
	if sn[i][2]!=-1:
		y+=1
	ans4="degree = "+str(y)+"," 
	ans5="depth = "+str(getdepth(i))+","
	ans6="height = "+str(getheight(i))+","
	if sn[i][0]==-1:
		ans7="root"
	elif getheight(i)==0:
		ans7="leaf"
	else:
		ans7="internal node"
	print(ans1,ans2,ans3,ans4,ans5,ans6,ans7)


Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    int N; 
    cin>>N;
    vector<int> A(N);
    REP(i,0,N){
        cin>>A[i];
    }
    sort(A.begin(), A.end());
    REP(i,0,N-1){
        if(A[i]==A[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout << "YES" <<endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
    int ans = T.size();
 
    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<int,int>;
using Pll = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    int k;cin >>k;
    ll num=0;
    int i=0;
    char ans;
    while(num<k){
        if(s[i]=='1')num++;
        else num+=INFll;
        ans=s[i];
        i++;
    }
    cout <<ans <<endl;
}


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


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N,Z,W;
  cin >> N >> Z >> W;
  int a[N];
  rep(i,N) cin >> a[i];
  if(N==1) cout << abs(W-a[N-1]);
  else     cout << max(abs(W-a[N-1]),abs(a[N-2]-a[N-1]));
  return 0;
    

}


Measured memory_bytes: 256
fun main(arr:Array<String>) {
    val ans = isSquare(readLine()!!.replace(" ", "").toInt())
    println(if(ans) "Yes" else "No")
}

fun isSquare(num:Int):Boolean {
    for(i in (1..num)) {
        if(i*i == num) {
            return true
        }
        if(i*i>num) {
            return false
        }
    }
    return false
}

Measured memory_bytes: 35952
#include <stdio.h>
int main(){
	char a,b,c;
	scanf("%c%c%c",&a,&b,&c);
	if(a==b && a!=c) printf("Yes");
	if(b==c && b!=a) printf("Yes");
	if(a==c && b!=a) printf("Yes");
	if(a==b && a==c) printf("No");
	
	return 0;
	
}

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

int main(){
    long long n , w;
    cin >> n >> w;
    vector<long long> val(n) , wt(n);
    vector<vector<long long>> dp(n + 1 , vector<long long>(w + 1 , 0));

    for(int i = 0 ; i < n ; ++i){
      cin >> wt[i] >> val[i];
    }

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

    for(int i = 1 ; i <= n ; ++i){
      for(int j = 1; j <= w ; ++j){
        if(wt[i - 1] <= j){
          dp[i][j] = max(dp[i - 1][j] , val[i - 1] + dp[i - 1][j - wt[i - 1]]);
        }
        else{
          dp[i][j] = dp[i - 1][j];
        }
      }
    }

  cout << dp[n][w];
}

Measured memory_bytes: 83172
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        sc.close();
        StringBuilder sb = new StringBuilder();
        while (true) {
            if (n % 2 == 0) {

                sb.insert(0, 0);
                n = n / (-2);
            } else {

                sb.insert(0, 1);
                n = n > 0 ? n / (-2) : (n - 1) / (-2);
            }
            if (n == 0) {
                break;
            }

        }
        System.out.println(sb.toString());
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
string target="keyence";
int main(void){
    string s;cin>>s;
    map<char,int> mp;
    rep(i,s.size()) mp[s[i]-'a']++;
    vector<string> t((int)s.size());
    int maxi=0,mini=1e+6;
    rep(i,3){
        chmax(maxi,mp[i]);
        chmin(mini,mp[i]);
    }
    if(maxi-mini>1){
        cout<<"NO"<<endl;
        return 0;
    }
    else{
        cout<<"YES"<<endl;
        return 0;
    }
}

Measured memory_bytes: 1280
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length) sort(array, array + length, greater<>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion
#pragma endregion

int main()
{
    // ***  問題のpathを記載 ***
    // https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_D

    // 標準入力から値を取得
    int N, M;
    scanf("%d %d", &N, &M);

    int s[M], c[M];
    for (int i = 0; i < M; i++)
    {
        scanf("%d %d", &s[i], &c[i]);
    }

    int max;
    if (N == 1)
    {
        max = 9;
        if (M == 0)
        {
            printf("%d\n", 0);
            return 0;
        }
    } else if (N == 2)
    {
        max = 99;
        if (M == 0)
        {
            printf("%d\n", 10);
            return 0;
        }
    }
    else{
        max = 999;
        if (M == 0)
        {
            printf("%d\n", 100);
            return 0;
        }
    }

    //printf("%d\n", max);

    for (int i = 0; i <= max; i++)
    {
        // 条件を満たしているかどうかチェック
        string str = ToString(i);
        int size = str.size();
        //printf("%s %d\n", str.c_str(), size);
        if (size != N)
        {
            continue;
        }

        for (int j = 0; j < M; j++)
        {
            // if (str.size() < s[j])
            // {
            //     break;
            // }

            if (str[s[j] - 1] != ToString(c[j]).c_str()[0])
            {
                break;
            }
            if (j == M - 1)
            {
                printf("%d\n", i);
                return 0;
            }
        }
    }
    printf("%d\n", -1);
    return 0;
}


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

#define rep(i, a, b) for (int i = (a), i##end = (b); i <= i##end; ++i)
#define per(i, a, b) for (int i = (a), i##end = (b); i >= i##end; --i)

mt19937 Rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

template <typename T>
inline void chkmax(T &x, T y) { if (x < y) x = y; }

template <typename T>
inline void chkmin(T &x, T y) { if (x > y) x = y; }

inline int read() {
  #define nc getchar()
  int x = 0;
  char c = nc;
  while (c < 48) c = nc;
  while (c > 47) x = x * 10 + (c ^ 48), c = nc;
  return x;
  #undef nc
}

#define int long long

typedef long long ll;
const int maxn = 1e5 + 10;
int n, A[maxn], lim[maxn];

void solve() {
  cin >> n;
  int lst = 0, ans = 1;
  rep(i, 0, n) A[i] = read();
  if (!n) {
    if (A[0] != 1) {
      puts("-1");
    } else {
      puts("1");
    }
    return;
  }
  lim[n - 1] = A[n];
  per(i, n - 2, 1) lim[i] = lim[i + 1] + A[i + 1];
  rep(i, 0, n) {
    int x = A[i];
    if (i == 0) {
      if (x) {
        puts("-1"); return;
      }
      lst = 1;
      continue;
    }
    if (x > lst * 2) {
      puts("-1"); return;
    }
    lst = min(lim[i], lst * 2 - x);
    ans += lst + A[i];
//    printf("#%d %d\n", lst, ans);
  }
  printf("%lld\n", ans);
}

signed main() {
//  int T = read();
//  while (T--) solve();
  solve();
  return 0;
}

Measured memory_bytes: 5316
#include<stdio.h>
int main(){
int a,b=5,c=0;
while(1){
scanf("%d\n",&a);
if(a==0){
break;
}
else{
for(;a>=b;){
c=c+a/b;
b=b*5;
}
}
printf("%d\n",c);
b=5;
c=0;
}
return 0;
}


Measured memory_bytes: 1992