akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<queue>
#include<stack>
#include<deque>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<numeric>
#include<cctype>
#include<random>
#include<bitset>


using namespace std;

#define rep(i,n) for(int i=0;i<n;i++) //0から
#define REP(i,n) for(int j=i;j<n;j++) //iから

typedef long long ll;



//英字ならture、数字ならfalse
bool isalpha(char s){
    if(('A'<=s&&s<='Z')||('a'<=s&&s<='z')){
        return 1;
    }else{
        return 0;
    }
}
//全ての文字が英字ならture、数字ならfalse
bool Isalpha(string s){
    ll n;
    bool tmp = true;
    rep(i,n){
        if(isalpha(s[i])){
            tmp = false;
        }
    }
    return tmp;
}




using Graph = vector<vector<ll>>;



//cout<<fixed<<setprecision(10);

ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

#define MOD 1000000007

ll INFLL =  pow(10,9)+1;




string periodic_table[104] = {
    "None","H(1)","He(2)", //2
    "Li(3)","Be(4)","B(5)","C(6)","N(7)","O(8)","F(9)","Ne(10)", //10
    "Na(11)","Mg(12)","Al(13)","Si(14)","P(15)","S(16)","Cl(17)","Ar(18)", //18
    "K(19)","Ca(20)","Sc(21)","Ti(22)","V(23)","Cr(24)","Mn(25)","Fe(26)","Co(27)","Ni(28)","Cu(29)","Zn(30)","Ga(31)","Ge(32)","As(33)","Se(34)","Br(35)","Kr(36)", //36
    "Rb(37)","Sr(38)","Y(39)","Zr(40)","Nb(41)","Mo(42)","Tc(43)","Ru(44)","Rh(45)","Pd(46)","Ag(47)","Cd(48)","In(49)","Sn(50)","Sb(51)","Te(52)","I(53)","Xe(54)", //54
    "Cs(55)","Ba(56)","La(57)","Ce(58)","Pr(59)","Nd(60)","Pm(61)","Sm(62)","Eu(63)","Gd(64)","Tb(65)","Dy(66)","Ho(67)","Er(68)","Tm(69)","Yb(70)","Lu(71)","Hf(72)","Ta(73)","W(74)","Re(75)","Os(76)","Ir(77)","Pt(78)","Au(79)","Hg(80)","Tl(81)","Pb(82)","Bi(83)","Po(84)","At(85)","Rn(86)", //86
    "Fr(87)","Ra(88)","Ac(89)","Th(90)","Pa(91)","U(92)","Np(93)","Pu(94)","Am(95)","Cm(96)","Bk(97)","Cf(98)","Es(99)","Fm(100)","Md(101)","No(102)" //102
};

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

    ll ans = 10000,cnt=0;
    for(int i=0;i<s.size();i++){
        cnt=0;
        for(int j=0;j<t.size();j++){
            if(i+j>=s.size()){
                cnt=10000;
                break;
            }
            if(s[i+j]!=t[j]){
                cnt++;
            }
        }
        ans=min(ans,cnt);
    }
    cout<<ans<<endl;

    return 0;
}



Measured memory_bytes: 3636
n = int(input())
if n==1:
  c=int(input())
  print(c)
  print(c)
  quit()
line = [list(map(int, input().split())) for i in range(n-1)]
c = list(map(int, input().split()))
c.sort(reverse=True)
print(sum(c)-c[0])
ans=[0]*n
vis=[True]*n
a, b = line[0]
a-=1
b-=1
ans[a]=c[0]
ans[b]=c[1]
vis[a]=False
vis[b]=False
for i in range(1, n-1):
  for l in line:
    a, b = l
    a-=1
    b-=1
    if (vis[a] and (not vis[b])):
      ans[a]=c[i+1]
      vis[a]=False
      break
    elif (vis[b] and (not vis[a])):
      ans[b]=c[i+1]
      vis[b]=False
      break
#print(ans)
ans = list(map(str, ans))
print(" ".join(ans))

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	ll t =1, a =1;
	rep(i, n){
		ll ti, ai;
		cin >>ti >>ai;

		t = (t+ti-1)/ti;
		a = (a+ai-1)/ai;
		ll mx = max(t, a);
		t = mx * ti;
		a = mx * ai;
		//dbg(t,a, mx);
	}
	cout << t + a <<"\n";
	return 0;
}


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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }


int main() {
  int a, b;
  cin >> a >> b;
  if (a < b)
  {
  	int temp = a;
  	a = b;
  	b = temp;
  }
  if ((a-b)%2==0)
  {
  	co((a + b)/ 2);
  }else{
  	co("IMPOSSIBLE");
  }



  return 0;
}


Measured memory_bytes: 256
//A
//Author : Sidiq Tri Pratikto
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(v) v.begin(), v.end()

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
//order_of_key(x) = number of elements stricly smaller than x
//find_by_order(x) = return x-th largest element
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	string s;
	cin >> s;
	if (s == "ABC") printf("ARC\n");
	else printf("ABC\n");
}

Measured memory_bytes: 3596
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    ll N;
    cin >> N;
    vector<ll> P(N), P_inv(N+1);
    for (int i = 0; i < N; i++) {
        ll p;
        cin >> p;
        P[i] = p;
        P_inv[p] = i;
    }
    ll ans = 0;
    std::multiset<ll> inds;
    inds.insert(-1);
    inds.insert(-1);
    inds.insert(N);
    inds.insert(N);
    inds.insert(P_inv[N]);
    for (ll now = N-1; now > 0; now--) {
        ll ind = P_inv[now];
        auto u = inds.upper_bound(ind);
        auto l = inds.lower_bound(ind);
        ll u1, u2, l1, l2;
        u1 = *u;
        u2 = *std::next(u);
        l1 = *std::prev(l);
        l2 = *std::prev(l, 2);
        //cerr << "ue@" << now << ": " << u1 << ", " << u2 << endl;
        //cerr << "st@" << now << ": " << l1 << ", " << l2 << endl;
        //l2 <= l1 <= ind <= u1 <=u2
        
        ll cnt = 0;
        cnt += (ind - l1) * (u2 - u1);
        cnt += (l1 - l2) * (u1 - ind);
        //cerr << now << ": " << cnt << endl;
        
        ans += cnt * now;
        inds.insert(P_inv[now]);
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 6528
lists = list(map(int, input().split()))

x = lists[2] // lists[1]
if lists[2] % lists[1] != 0:
    x += 1

y = lists[0] // lists[3]
if lists[0] % lists[3] != 0:
    y += 1

if x <= y:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9180
a,b=(int(i) for i in input().split())
#print(a,b)
if a>=b:
  ans=a
  if a-1>b:
    ans+=a-1
  else:
    ans+=b
else:
  ans=b
  if b-1 >=a:
    ans+=b-1
  else:
    ans+=a
print(ans)

Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        char[] s2=sc.next().toCharArray();
        char[] s=sc.next().toCharArray();
        int cou=0;
        for(int i=0;i<3;i++){
            if(s[i]==s2[i])cou++;
        }
        System.out.println(cou);
    }
}


Measured memory_bytes: 23764
# coding : utf-8
#
class HitAndBlow
  def game
    loop do
      line_a = gets
      break if line_a == nil
      line_b = gets
      break if line_b == nil

      array_a = line_a.chomp.split.map {|s| s.to_i}
      array_b = line_b.chomp.split.map {|s| s.to_i}

      cnt_hit = 0
      cnt_blow = 0
      4.times do |i|
        if array_a[i] == array_b[i] then
          cnt_hit += 1
        elsif array_a.include?(array_b[i]) then
          cnt_blow += 1
        end
      end
      puts "#{cnt_hit} #{cnt_blow}"
    end
  end

end

HitAndBlow.new.game

Measured memory_bytes: 6108
import math
def get_yakusuu(n):
  a = 1
  b = n
  f_max = int(math.sqrt(n)) + 1
  for i in reversed(range(1, f_max)):
    if n % i == 0:
      a = i
      b = n // i
      break
  return a, b
    
N = int(input())

nearest = get_yakusuu(N)
print(nearest[0] + nearest[1] - 2)

Measured memory_bytes: 3060
using System;

class Program {
  static void Main() {
    int n = int.Parse(Console.ReadLine());
    int t = 0;
    for (int i = 1; i <= n; i++) {
      t += i;
      if (n <= t) {
        Console.WriteLine(i);
        break;
      }
    }
  }
}

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <iomanip>
using namespace std;
#define all(x) x.begin(), x.end()
typedef vector <int> vi;
typedef pair<int,int> ii;
typedef long long ll;
typedef long double ld;
const int mod = 1e9 + 7;
const ll inf = 3e18 + 5;
int add(int a, int b) { return (a += b) < mod ? a : a - mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
int sub(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
int ctz(int x) { return __builtin_ctz(x); }
int clz(int x) { return __builtin_clz(x); }

int main(){
  ios_base::sync_with_stdio(false); cin.tie(0);
  #ifdef LOCAL
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int r;
  cin >> r;
  cout << r * r;
}

Measured memory_bytes: 384
import math

N, M = map(int, input().split())
C = 10** 9 + 7

fact = [1]
for x in range(1, max(N,M)+1):
	fact.append( (x * fact[x-1]) % C )
    
if math.fabs(N-M) >= 2:
    print(0)
elif math.fabs(N-M) == 1:
    print( (fact[N] * fact[M]) % C )
else:
    print( (fact[N] * fact[M] * 2) % C )

Measured memory_bytes: 7060
N = int(input())
base = ord('a')
r = []
q = N
for i in range(12):
    if q <= 26:
        r.append(q)
        break
    if q % 26 == 0:
        r.append(26)
        q = q // 26 - 1
    else:
        r.append(q % 26)
        q = q // 26
r.reverse()
ans = [chr(i+base-1) for i in r]
print(''.join(ans))

Measured memory_bytes: 9196
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
int main(void){
  long long int x;
  cin>>x;
  bool end=false;
  for(long long int i=-1000; i<=1000; i++){//mid=a
    if(end){
      break;
    }
    long long int high=1000;
    long long int low=-1000;
    long long int mid;
    while(high>=low){
      mid=(high+low)/2;
      long long int a=pow(mid,5);
      long long int b=pow(i,5);
      if(a-b==x){
        end=true;
        cout<<mid<<" "<<i<<endl;
        break;
      }else if(a-b>x){
        high=mid-1;
      }else{
        low=mid+1;
      }
    }
  }
}

Measured memory_bytes: 4100
#include <cstdio>
#include <cstdlib>

#define gc getchar
#define pc putchar
#define ll long long
#define iL inline
#define R0 register

template <class T>
iL void read(T&x) {
  R0 char c = gc();
  R0 bool f = 0;
  while ((c < '0' || c > '9') && c != '-') c = gc();
  (c == '-') && (f = 1, c = gc());
  x = 0;
  while (c >= '0' && c <= '9') x = (x << 1) + (x << 3) + (c ^ 48), c = gc();
  f && (x = -x);
}
template <class T>
iL void print(T x) {
  (x < 0) && (pc('-'), x = -x);
  if (x >= 10) print(x / 10);
  pc((x % 10) ^ 48);
}
template <class T>
iL void priln(T x) {
  print(x);
  pc('\n');
}
template <class T>
iL void prisp(T x) {
  print(x);
  pc(' ');
}

int r;

int main() {
  read(r);
  priln(r * r);
}


Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<numeric>

int main() {
	size_t x[3];
	for (size_t i{ 0 }; i < 3; i++) {
		std::cin >> x[i];
	}
	
	auto res =	std::accumulate(std::begin(x), std::end(x), 0);

	res -= *std::max_element(std::begin(x), std::end(x));
	std::cout << res << "\n";
	return 0;
}


Measured memory_bytes: 256
//minamoto
#include<bits/stdc++.h>
#define R register
#define int long long
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=1e5+5;
int a[N],st[N],mn[N],mx[N],id[N],top,n,k,sum,res;
void init(int x){
	fp(i,1,sqrt(x))if(x%i==0)st[++top]=i,st[++top]=x/i;
	sort(st+1,st+1+top);
}
inline bool cmp(const int &x,const int &y){return mn[x]<mn[y];}
bool ck(R int x){
//	printf("%d\n",x);
	R int s=0,c=0,p=0;
	fp(i,1,n)id[i]=i,mn[i]=a[i]%x,mx[i]=(x-a[i]%x)%x,s+=mx[i];
	sort(id+1,id+1+n,cmp);
	for(R int i=1;i<=n&&c<=k;c+=mn[id[i]],s-=mx[id[i]],p+=a[id[i]]/x,++i){
//		assert((s-c)%x==0);
		if(c>=s)return true;
		if((s-c+x-1)/x*x+c<=k&&(s-c+x-1)/x<=p)return true;
	}
	return false;
}
signed main(){
	scanf("%lld%lld",&n,&k);
	fp(i,1,n)scanf("%d",&a[i]),sum+=a[i];
	init(sum);
	fd(i,top,1)if(ck(st[i]))return printf("%lld\n",st[i]),0;
	return 0;
}

Measured memory_bytes: 256
#ifdef __GNUG__
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG // ArrayOutofBounds
#else
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#endif
#define rep(i, N) for (int i = 0; i < N; i++) //制御変数iを用いてN回転
using namespace std;
using ll = long long;
//0:上 1:左 2:下 3:右
const int di[] = { -1, 0, 1, 0};
const int dj[] = { 0, -1, 0, 1};

int main() {
    int D, T, S;
    cin >> D >> T >> S;
    if (D <= T * S) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 #define rep(i,n) for(int i=0;i<n;i++)
 using namespace std;
  int main(){
      vector<int> a(8);
      rep(i,6){
          cin >> a[i];
      }
      vector<int> b(4);
    rep(i,6){
        rep(j,6){
            if(a[i]==a[j]){
                b[a[i]]++;
                break;
            }
        }
    if(b[a[i]]>=3){
        cout << "NO" << endl;
       //cout << a[i] << " " <<  b[a[i]] << endl;
        break;
    }
    if(i+1==6){
        cout << "YES" << endl;
        break;
    }
    }
    return 0;

  }

Measured memory_bytes: 3604
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#include<iomanip>
#include<functional>
using namespace std;

#define ll long long
using vt = ll; //ここで数値の型を変えられる
#define rep(i, n) for (vt i = 0; i < (vt)(n); i++)
#define reps(i, s, n) for(vt i = (vt) (s); i < (vt) (n); i++) 
#define all(v) v.begin(), v.end()
#define P pair<ll, ll>
const ll  MOD = 1000000007;

vt pow_mod_rep_square(vt n, vt p, vt mod) { //mod付き
	if (p == 0) return 1;
	else if (p % 2 == 0) {
		vt t = pow_mod_rep_square(n, p / 2, mod);
		return t * t % mod;
	}
	else return n * pow_mod_rep_square(n, p - 1, mod) % mod;
}

int main() {
	ll n, k;
	cin >> n >> k;
	if (k == 1) {
		cout << 1;
		return 0;
	}
	vector<ll> v(1);
	reps(i, 1, k + 1) {
		ll x = pow_mod_rep_square(k / i, n, MOD);
		v.push_back(x);
	}
	ll ans = 0;
	for(ll i = k; i > 0; i--) {
		ll m = 2;
		while (k >= i * m) {
			v.at(i) -= v.at(i * m);
			m++;
		}
		ans += v.at(i) * i % MOD;
		ans %= MOD;
	}
	if (ans < 0) ans += MOD;
	cout << ans;
	return 0;
}

Measured memory_bytes: 4304
def operation_of_foa(input_seq, times)
	operated_seq = Array.new
	input_seq.each { |x| operated_seq << input_seq.count(x) }
	if operated_seq == input_seq
		return [operated_seq, times]
	else
		operation_of_foa(operated_seq, times+1)
	end
end

while gets
	n = $_.to_i
	break if n == 0
	input_seq = gets.chomp.split.map(&:to_i)
	operated_seq, times = operation_of_foa(input_seq, 0)
	puts times
	puts operated_seq.join(" ")
end

Measured memory_bytes: 6112
using System;

class main
{
    static void Main(string[] args)
    {
        string s;
        int f = 90, f2 = 0;
        double x = 0, y = 0;
        while ((s = Console.ReadLine()) != null)
        {
            string[] d = s.Split(',');
            if (d[0] == "0" && d[1] == "0")
            {
                break;
            }
            int m = int.Parse(d[0]);
            int n = int.Parse(d[1]);
            double r = (f * (Math.PI / 180));
            double r2 = (f2 * (Math.PI / 180));
            x += (Math.Cos(r) * m);
            y += (Math.Cos(r2) * m);
            f -= n;
            f2 += n;
        }
        Console.WriteLine((int)x);
        Console.WriteLine((int)y);
        Console.ReadKey();
    }
}

Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main(){
  long int n, i = 1;
  cin >> n;
  for(long int j = 1; j <= n; j++){
    i *= j;
    i %= MOD;
  }
  cout << i << endl;
  return 0;
}


Measured memory_bytes: 3552
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define P pair<ll,ll> 
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  n%=k;
  ll ans=min(n,abs(n-k));
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        Set<String> set = new HashSet<>();
        for (char c : s.toCharArray()) {
            set.add(String.valueOf(c));
        }

        System.out.println(set.size() == 2 ? "Yes" : "No");
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#define rep(i, n) for (int i = 0; i < n; i++)
#define reps(i, s, n) for (int i = s; i < n; i++)
#define all(v) v.begin(), v.end() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    vi x(5);
    rep(i, 5) cin >> x[i];
    rep(i, 5) {
        if(x[i] == 0) {
            cout << i + 1 << endl;
        }
    }
}


Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

int main(){
  int N, M; vi X(100010);

  cin >> N >> M;
  for(int i=0; i<M; i++) cin >> X[i];
  sort(X.begin(), X.begin()+M);

  vi dist(100010);
  for(int i=0; i<M-1; i++) dist[i] = X[i+1]-X[i];
  sort(dist.begin(), dist.begin()+M-1);

  int ans = 0;
  for(int i=0; i<M-N; i++) ans += dist[i];

  cout << ans << endl;
}

Measured memory_bytes: 1024
package main

import (
       "fmt"
       "strings"
       "sort"
)

func main() {
     var s string
     fmt.Scan(&s)
     split := strings.Split(s, "")
     sort.Strings(split)
     if "abc" == strings.Join(split, ""){
     	fmt.Println("Yes")
     } else{
	fmt.Println("No")
     }
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<array>
using namespace std;
#define int long long
// #define ll long long
#define endl "\n"
#define fast_cin ios_base::sync_with_stdio(false); cin.tie(NULL)
const int mod = 1e9+7;
const int N = 1e6+1;

void solve(){
 
    int n;
    cin >> n;
    int ch1=1, ch2=1, ch3=1;
    for(int i=1; i<=n; i++){
        ch1 = (ch1*10)%mod;
        ch2 = (ch2*9)%mod;
        ch3 = (ch3*8)%mod;
    }
    int ans = (ch1 + ch3 + (-2*ch2 + 2*mod)%mod)%mod;
    cout << ans;
}
 
int32_t main(){
 
    fast_cin;
    // int t;
    // cin >> t;
    // while(t-- > 0){
        solve();
        cout << "\n";
    // }
    
    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<algorithm>
using lint=int64_t;
using namespace std;

template<typename T>
T gcd(T a,T b)
{
	if(a==0 || b==0)return 0;
	T r;
	while(1)
	{
		r=a%b;
		if(r==0)break;
		a=b;
		b=r;
	}
	return b;
}

int main()
{
	int N;
	int A[100010]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> A[i];
	
	int sum[100010]={};
	int rsum[100010]={};
	sum[0]=A[0];
	rsum[N-1]=A[N-1];
	for(int i=1;i<N;i++)
	{
		sum[i]=gcd(sum[i-1],A[i]);
		rsum[N-i-1]=gcd(rsum[N-i],A[N-i-1]);
	}

	int ans=max(sum[N-2],rsum[1]);
	for(int i=1;i<N-1;i++)
		ans=max(ans,gcd(sum[i-1],rsum[i+1]));
	
	cout << ans << endl;
	return 0;
}


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

using namespace std;


const int MAX = 100005;
const int NIL = -1;
typedef long long ll;

struct Node { int p, l, r; };
Node T[MAX];
int n;

void preParse(int u) {
    if (u == NIL)
        return;
    cout << " " << u;
    preParse(T[u].l);
    preParse(T[u].r);
}

void inParse(int u) {
    if (u == NIL)
        return;
    inParse(T[u].l);
    cout << " " << u;
    inParse(T[u].r);
}

void postParse(int u) {
    if (u == NIL)
        return;
    postParse(T[u].l);
    postParse(T[u].r);
    cout << " " << u;
}


int main() {
    int root = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
        T[i].p = NIL;

    for (int i = 0; i < n; i++) {
        int v, l, r; cin >> v >> l >> r;
        T[v].l = l;
        T[v].r = r;
        if (l != NIL) T[l].p = v;
        if (r != NIL) T[r].p = v;
    }

    for (int i = 0; i < n; i++) {
        if (T[i].p == NIL)
            root = i;
    }

    cout << "Preorder" << endl;
    preParse(root);
    cout << endl;
    cout << "Inorder" << endl;
    inParse(root);
    cout << endl;
    cout << "Postorder" << endl;
    postParse(root);
    cout << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }

template <typename T> bool next_combination(const T first, const T last, int k) {
    const T subset = first + k;
    // empty container | k = 0 | k == n 
    if (first == last || first == subset || last == subset) {
        return false;
    }
    T src = subset;
    while (first != src) {
        src--;
        if (*src < *(last - 1)) {
            T dest = subset;
            while (*src >= *dest) {
                dest++;
            }
            iter_swap(src, dest);
            rotate(src + 1, dest + 1, last);
            rotate(subset, subset + (last - dest) - 1, last);
            return true;
        }
    }
    // restore
    rotate(first, subset, last);
    return false;
}

int main(){
    int n,m,q;
    in(n,m,q);
    vector<int> vec,a(q),b(q),c(q),d(q);
    rep(i,m){
        rep(j,n){
            vec.push_back(i+1);
        }
    }
    rep(i,q){
        in(a[i],b[i],c[i],d[i]);
    }
    int maxv=0,e=0;
    do{
        e=0;
        rep(i,q){
            if(vec[b[i]-1]-vec[a[i]-1]==c[i])e+=d[i];
        }
        maxv=max(maxv,e);
    }while(next_combination(all(vec),n));
    out(maxv);
}

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

const int N = 200005;
int n, k, bit[N];
int64_t a[N], Ans;

void update(int index, int val) {
	while(index <= n + 1) bit[index] += val, index += index & (-index);
}

int64_t get(int index) {
	int64_t res = 0;
	while(index != 0) res += bit[index], index -= index & (-index);
	return res;
}

int main(){
	iostream::sync_with_stdio(false);
	cin >> n >> k;

	map<int64_t, int> mappu;
	mappu[0] = 1;
	for(int i = 1; i <= n; ++ i) {
		cin >> a[i], a[i] -= k;
		a[i] += a[i - 1], mappu[a[i]] = 1;
	}

	int cnt = 0;
	for(auto it = mappu.begin(); it != mappu.end(); ++ it)
		it->second = ++ cnt;
	for(int i = 0; i <= n; ++ i) a[i] = mappu[a[i]];

	update(a[0], 1);
	for(int i = 1; i <= n; ++ i) {
		int x = get(a[i]);
		Ans += x, update(a[i], 1);
	}
	cout << Ans << endl;
}

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

int n, a[100003], i;
string s;
int main() {
  cin >> n >> s;
  rep(i, 2) rep(j, 2) {
    a[1] = i, a[2] = j;
    a[0] = i ^ j ^ (s[1] == 'o');
    for (int k = 3; k < n; ++k) a[k] = a[k - 1] ^ a[k - 2] ^ (s[k - 1] == 'o');

    if ((s[n - 1] == 'o') == a[n - 2] ^ a[n - 1] ^ a[0] &&
        (s[0] == 'o') == a[n - 1] ^ a[0] ^ a[1]) {
      rep(k, n) cout << (a[k] ? 'S' : 'W');
      cout << endl;
      return 0;
    }
  }

  cout << -1 << endl;
  return 0;
}

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

    #define ll long long
    #define ff first
    #define ss second
    #define pb push_back
    #define vll vector<ll>
    #define mll map<ll,ll>
    #define MOD 1000000007
    #define pll pair<ll,ll>
constexpr ll INF = 1999999999999999997; 
    #define fastio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
    int main() {
        fastio;

        int n,m;
        cin>>n>>m;
        vector<int>v[m];
        for(int i=0;i<m;i++)
        {
           int k;
           cin>>k;
           while(k--)
           { int x;
            cin>>x;
            x--;
            v[i].pb(x);
           }
        }
        int p[m];
        
        for(int i=0;i<m;i++)
        {
            cin>>p[i];
        }
     int ans=0;
        for(int i=0;i<=pow(2,n)-1;i++)
        {   int f=0;
            for(int j=0;j<m;j++)
            {   int c=0;
                int l=(int)v[j].size();
                for(int k=0;k<l;k++)
                {
                   if((1<<v[j][k])&i)
                    c++;
                }
                 if(p[j]!=c%2)
                  {
                    f=1;
                    break;
                  }
            }
            if(!f)
                ans++;

        }
        cout<<ans<<endl;
    }

Measured memory_bytes: 4036
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B;
	scanf("%d %d",&A,&B);

	if(A+B >= 24){

		printf("%d\n",A+B-24);

	}else{

		printf("%d\n",A+B);
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define rev(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = INT_MAX;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ O(logN)
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main() {
    int n, m, a; cin >> n >> m;
    priority_queue<int> q;
    rep(i,n) {
        cin >> a;
        q.push(a);
    }

    rep(i,m) {
        a = q.top();
        q.pop();
        q.push(a/2);
    }

    ll ans = 0;
    rep(i,n) {
        a = q.top();
        q.pop();
        ans += a;
    }

    out(ans);

    return 0;
}






Measured memory_bytes: 892
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define fir first
#define sec second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=55;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int n,X,D,val[MAXN],id[MAXN],Ans;ll m[MAXN],F[MAXN*MAXN*MAXN];
vector<int>G[MAXN];
void dfs(int x){val[x]=1;for(int i=0;i<G[x].size();i++)dfs(G[x][i]),m[x]+=m[G[x][i]],val[x]+=val[G[x][i]];}
inline bool cmp(int x,int y){return val[x]*m[y]>val[y]*m[x];}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	n=read(),X=read(),D=read(),m[1]=read();
	Rep(i,2,n)m[i]=read(),G[read()].push_back(i);dfs(1);
	int Mx=n*n*n,o=min(n,D);memset(F,0x3f,sizeof(F)),F[0]=0;
	Rep(i,1,n){
		int x=o;
		for(int j=0;1<<j<=x;j++){
			ll u=(1ll<<j)*m[i];int v=(1<<j)*val[i];x-=1<<j;
			Red(k,Mx,v)F[k]=min(F[k],F[k-v]+u);
		}if(x){ll u=x*m[i];int v=x*val[i];Red(k,Mx,v)F[k]=min(F[k],F[k-v]+u);}
	}
	Rep(i,1,n)id[i]=i;sort(id+1,id+n+1,cmp);
	for(;id[n]!=1;n--);
	Rep(i,0,Mx){
		if(F[i]>X)continue;
		int tmp=i,lst=X-F[i];
		Rep(j,1,n-1){int cnt=min(lst/m[id[j]],0ll+D-o);tmp+=cnt*val[id[j]],lst-=cnt*m[id[j]];}
		int cnt=lst/m[1];tmp+=cnt*val[1],lst-=cnt*m[1],Ans=max(Ans,tmp);
	}cout<<Ans<<"\n";
	return 0;
}




Measured memory_bytes: 4944
#include <bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define fi first
#define se second
#define pi pair<int, int>
#define ppi pair<pi, pi>
#define pb push_back
#define rep(i, a, n) for(int i = a; i <= n; i++)
#define REP(i, a, n) for(int i = a; i < n; i++)
#define per(i, a, n) for(int i = a; i >= n; i--)
#define PER(i, a, n) for(int i = a; i > n; i--)
#define pqi priority_queue<int>
#define Y "YES"
#define N "NO"
#define PI 3.14159265358979323846
using namespace std;

int n;
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	//freopen("in.txt", "r", stdin);

	cin >> n;
	n %= 10;
	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) cout << "hon";
	else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
	else cout << "bon";	
}

Measured memory_bytes: 3652
//DUEL
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define x first
#define y second
#define pii pair<int,int>
#define pb push_back
#define eb emplace_back
#pragma GCC optimize("unroll-loops")
#define shandom_ruffle(a, b) shuffle(a, b, rng)
#define vi vector<int>
#define vl vector<ll>
#define popcnt __builtin_popcount
#define popcntll __builtin_popcountll

using namespace std;
using namespace __gnu_pbds;

using ll=long long;
using ull=unsigned long long;
using ld=long double;
int MOD=1000000007;
int MOD2=998244353;
vector<int> bases;
const ll LLINF=1ll<<60;
const char en='\n';

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
void yes() {cout<<"YES"<<en; exit(0);}
void no() {cout<<"NO"<<en; exit(0);}
inline int rund() {int x576363482791fuweh=rng();return abs(x576363482791fuweh)%RAND_MAX;}
template<class T>
void prVec(vector<T> w,bool fl=false)
{
	cout<<w.size()<<en;
	for (int i=0;i<int(w.size())-1;++i) cout<<w[i]<<' ';
	if (w.size()) cout<<w[w.size()-1]<<en;
	if (fl) cout<<flush;
}

void M998()
{
	swap(MOD,MOD2);
}

ll raand()
{
	ll a=rund();
	a*=RAND_MAX;
	a+=rund();
    return a;
}

#define rand raand

ll raaand()
{
	return raand()*(MOD-7)+raand();
}

string to_upper(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
	return a;
}

string to_lower(string a)
{
	for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
	return a;
}

ll sti(string a,int base=10)
{
	ll k=0;
	for (int i=0;i<(int)a.size();++i)
	{
		k*=base;
		k+=a[i]-'0';
	}
	return k;
}

template<class T>
void eras(vector<T>& a,T b)
{
	a.erase(find(a.begin(),a.end(),b));
}

string its(ll k,int base=10)
{
	if (k==0) return "0";
	string a;
	while (k)
	{
		a.push_back((k%base)+'0');
		k/=base;
	}
	reverse(a.begin(),a.end());
	return a;
}

ll min(ll a,int b)
{
	if (a<b) return a;
	return b;
}

ll min(int a,ll b)
{
	if (a<b) return a;
	return b;
}

ll max(ll a,int b)
{
	if (a>b) return a;
	return b;
}

ll max(int a,ll b)
{
	if (a>b) return a;
	return b;
}

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

template<class T,class K>
pair<T,K> mp(T a,K b)
{
	return make_pair(a,b);
}

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

inline int pot(int n,int k)
{
	if (k==0) return 1;
	ll a=pot(n,k/2);
	a=mult(a,a);
	if (k%2) return mult(a,n);
	else return a;
}

int divide(int a,int b)
{
	return mult(a,pot(b,MOD-2));
}

inline int sub(int a,int b)
{
	if (a-b>=0) return a-b;
	return a-b+MOD;
}

inline int add(int a,int b)
{
	if (a+b>=MOD) return a+b-MOD;
	return a+b;
}

bool prime(ll a)
{
	if (a==1) return 0;
	for (int i=2;i<=round(sqrt(a));++i)
	{
		if (a%i==0) return 0;
	}
	return 1;
}

const int N=300010;
ll n;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for (int i=0;i<10;++i) bases.push_back(rand()%(MOD-13893829*2)+13893829);
	cin>>n;
	if (n%2) cout<<0;
	else
	{
		n/=2;
		ll a=0;
		while (n)
		{
			n/=5;
			a+=n;
		}
		cout<<a;
	}
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




typedef long long ll;
int N, K, A[15];
//-----------------------------------------------------------------------------------
int main() {
    cin >> N >> K;
    rep(i, 0, N) cin >> A[i];

    ll ans = 1LL << 60;
    rep(mask, 0, 1 << N) {
        ll cost = 0;
        int lim = 0, cnt = 0;
        rep(i, 0, N) {
            if (mask & (1 << i)) {
                if (A[i] <= lim) {
                    cost += lim - A[i] + 1;
                    lim++;
                }
                else {
                    lim = max(lim, A[i]);
                }
                cnt++;
            }
            else {
                if (lim < A[i]) cnt++;
                lim = max(lim, A[i]);
            }
        }
        if (K <= cnt) ans = min(ans, cost);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
  
  
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    dp[0]=0;dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));
    }
    cout<<dp[n-1]<<endl;
    return	0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  int A, B;
  int ans = 0;
  string s, t, u;

  cin >> s >> t;
  cin >> A >> B;
  cin >> u;

  if(s == u){
    A--;
  }else if(t == u){
    B--;
  }

  cout << A << " "<< B << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<lli> A(N), B(N), C(N);
	rep(i, 0, N)cin >> A[i]; sort(A.begin(), A.end()); 
	rep(i, 0, N)cin >> B[i]; sort(B.begin(), B.end()); 
	rep(i, 0, N)cin >> C[i]; sort(C.begin(), C.end()); 

	lli ans = 0;
	
	rep(i,0,N) {
		vector<lli>::iterator Iter1 = lower_bound(A.begin(), A.end(), B[i]);
		vector<lli>::iterator Iter2 = upper_bound(C.begin(), C.end(), B[i]);
		lli k1 = Iter1 - A.begin();
		lli k2 = C.end() - Iter2;
		ans += k1 * k2;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(), W = sc.nextInt();
		int item[][] = new int[N][2];
		for(int i=0;i<N;i++) {
			int w = sc.nextInt(), v = sc.nextInt();
			item[i][0] = w;
			item[i][1] = v;
		}
		sc.close();
		long INF = Long.MAX_VALUE/2;
		long dp[][] = new long[N+1][1000*N+5];
		for(long tmp[]:dp)Arrays.fill(tmp,INF);
		dp[0][0]=0;
		for(int i=0;i<N;i++) {
			int weigh = item[i][0], value = item[i][1];
			for(int j=1000*N+3;j>=0;j--) {
				if(j-value<0)dp[i+1][j]=Math.min(dp[i][j],dp[i+1][j+1]);
				else dp[i+1][j]=Math.min(Math.min(dp[i][j],dp[i][j-value] + weigh),dp[i+1][j+1]);
			}
		}
		int ans = 0;
		for(int i=0;i<=N;i++) {
			for(int j=0;j<1000*N+3;j++) {
				if(dp[i][j]<=W)ans = Math.max(ans, j);
			}
		}
		System.out.println(ans);
	}
}


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

int main(){

    int n;
    int c[500],s[500],f[500];

    cin>>n;
    for(int i=1;i<=n-1;i++){
        cin>>c[i]>>s[i]>>f[i];
    }

    int where,t;
    for(int i=1;i<=n;i++){
        where=i;
        t=0;
        while(1){
            if(where==n)break;
            if(s[where]<=t){
                if(t%f[where]==0){
                    t+=c[where];
                    where++;
                }else{
                    t++;
                }
            }else{
                t++;
            } 
        }
        cout<<t<<endl;

    }

    return 0;
}

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

using namespace std;
 
//#define int long long
using ll = long long;
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define reps(i,n) for(ll i=0;i<=n;i++)

ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
 
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

int main(){
    ios_base::sync_with_stdio(false);
    ll a,b,ans=0;
    cin >> a >> b;

    if(a==b){
        cout << a << endl;
        return 0;
    }

    if(b == a+1){
        ans = a^(a+1);
        cout << ans << endl;
        return 0;
    }

    if(a%2==0){
        if((b-a)%2==1){
            if((((b-a)/2))%2==0){
                cout << 1 << endl;
            }else{
                cout << 0 << endl;
            }
        }else{
            if((((b-a)/2))%2==0){
                cout << b << endl;
                }else{
                    ans = 1^b;
                    cout << ans << endl;
                }
        }
    }else{ //aが奇数のとき
        if(((b-a)/2)%2==0){
            ans = 0;
        }else{
            ans = 1;
        }
        if((b-a)%2==0){
            ans ^= a;
        }else{
            ans = ans ^ a ^ b;
        }
            cout << ans << endl;
        }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 1; i <= n; ++i) {
        a[i - 1] = i;
    }
    do {
        for (int i = 0; i < n; ++i) {
            if (i == 0) cout << a[i];
            else cout << " " << a[i];
        }
        cout << endl;
    } while (next_permutation(a.begin(), a.end()));
}



Measured memory_bytes: 3116
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>
#include <cassert>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    ll ans = 1;
    rep(i, N){
        ll t;
        cin >> t;
        ans = lcm(ans, t);
    }
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    int n;
    cin >> n;
    vector<vector<int>> v(10,vector<int> (10,0));

    for (int i = 1;i <= n;i++){
        string s;
        s = to_string(i);
        v[stoi(s.substr(0,1))][stoi(s.substr(s.size()-1,1))]++;
    }
    ll ans = 0;
    for (int i = 0; i < 10;i++){
        for (int j = 0; j < 10;j++){
            ans += ll(v[i][j])*v[j][i]; 
        }
    }
    cout << ans << endl;
    
   return 0;

}

Measured memory_bytes: 256
using System;


namespace ConsoleApplication11
{
    class Program
    {
        static void Main(string[] args)
        {
            double n = double.Parse(Console.ReadLine());
            string[] x = Console.ReadLine().Split(' ');
            string[] y = Console.ReadLine().Split(' ');
            for(int j = 0; j < 3; j++)
            {
                double Pn = 0;
                double Ans = 0;
                double p = j + 1;
                for (int i = 0; i < n; i++)
                {
                    double xn = double.Parse(x[i]);
                    double yn = double.Parse(y[i]);
                    double xxx = Math.Abs(xn - yn);
                    double aaa = Math.Pow(xxx, p);
                    Pn += aaa;
                }
                Ans = Math.Pow(Pn, 1 / p);
                Console.WriteLine(Ans);
            }
            //
            double sum = 0;
            for (int i = 0; i < n; i++)
            {
                double xn = double.Parse(x[i]);
                double yn = double.Parse(y[i]);
                double xxx = Math.Abs(yn - xn);
                sum = Math.Max(xxx,sum);
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 9564
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;
ll N;
ll M;
const ll MOD = 1000000007;
ll dp[100011];
set<int> st;
int main(void){
    // Your code here!
    cin >> N >> M;
    int a;
    for(int i = 0; i < M; i++) {
        cin >> a;
        st.insert(a);
    }
    
    for(int i = 0; i <= 100000; i++) dp[i] = 0;
    dp[0] = 1;
    
    for(int i = 0; i < N; i++) {
        bool plus1 = false;
        bool plus2 = false;
        if(st.count(i+1) == 1) plus1 = true;
        if(st.count(i+2) == 1) plus2 = true;
        
        if(!plus1){
            dp[i+1] += (dp[i] % MOD);
        }
        
        if(!plus2) {
            dp[i+2] += (dp[i] % MOD);
        }
    }
    
    cout << dp[N] % MOD << endl;
    
}


Measured memory_bytes: 5760
<?php
fscanf(STDIN, "%d %d", $N, $M);
$lineInput = trim(fgets(STDIN));
$A = explode(" ", $lineInput);

$all = array_sum($A);
$judge = $all * (1 / (4 * $M));
rsort($A);
$flg = true;
for($i=0;$i<$M;$i++){
    if((int)$A[$i] < $judge){
        $flg = false;
        break;
    }
}

if($flg) {
      echo ("Yes");
}else{
      echo ("No");
}

 
?>


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

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

  int ans = 0;
  rep(x, k + 1) {
    rep(y, k + 1) {
      if (s - x - y >= 0 && s - x - y <= k)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256