akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr int INF = 1001001001;
int H, W, K;
int cnt[20][1010];

int f(int i){
    int used = __builtin_popcount(i);
    std::vector<int> rows;

    rows.emplace_back(0);

    for(int j=0;j<H-1;++j){
        if(i >> j & 1){
            rows.emplace_back(j + 1);
        }
    }
      
    rows.emplace_back(H);
      
    std::vector<int> v(used + 1, 0);

    for(int j=0,k=0;j<W;){
        while(k < W){
            bool ok = true;

            for(int l=0;l+1<rows.size();++l){
                int r1 = rows[l], r2 = rows[l+1];
                v[l] += cnt[r1][k] - cnt[r2][k];

                if(v[l] > K){
                    ok = false;
                    break;
                }
            }

            if(ok){
                k += 1;
                continue;
            }

            std::fill(v.begin(), v.end(), 0);
            break;
        }

        if(k == j){
            used = INF;
            break;
        }

        used += 1;
        j = k;
    }

    used -= 1;

    return used;
}

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

  std::cin >> H >> W >> K;

  for(int i=0;i<H;++i){
      std::string S;
      std::cin >> S;

      for(int j=0;j<W;++j){
          if(S[j] == '1'){
              cnt[i][j] += 1;
          }
      }
  }

  for(int i=0;i<W;++i){
      for(int j=H-1;j>=0;--j){
          cnt[j][i] += cnt[j+1][i];
      }
  }

  int res = INF;

  for(int i=0;i<(1<<(H-1));++i){
      int used = f(i);

      res = std::min(res, used);
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi s(n),t(n);
	rep(i,n)cin>>s[i];
	rep(i,n)cin>>t[i];

	int out=0;
	rep(i,30){
		vi a=s,b=t;
		ll q=1<<(i+1);
		rep(i,n)a[i]%=q,b[i]%=q;
		q>>=1;
		sort(all(b));
		int co=0;
		rep(j,n){
			co+=lower_bound(all(b),2*q-a[j])-lower_bound(all(b),q-a[j]);
			co+=lower_bound(all(b),4*q-a[j])-lower_bound(all(b),3*q-a[j]);
		}
		if(co%2)out|=q;
	}
	cout<<out<<endl;
}










Measured memory_bytes: 3432
'use strict';
function main(input) {
  const arr = input.trim().split('\n');
  const a = arr[0];
  let isStep = true;

  for (let i = 0; i < a.length; i ++) {
    if ((i + 1) % 2 === 0 && a[i] === 'R') {
      isStep = false;
    } else if ((i + 1) % 2 !== 0 && a[i] === 'L'){
      isStep = false;
    }
  }
  
  console.log(isStep ? 'Yes' : 'No');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

int main(){
    int n;
    while(cin>>n){
        if(n==0) break;
        vector<int> ord;
        map<int, ll> total;
        int m, x, y;
        LOOP(n){
            cin >> m >> x >> y;
            if(!EXIST(ord, m)) ord.PB(m);
            total[m] += (ll)x*y;
        }
        bool f=true;
        EACH(ord, it)if(total[*it]>=1000000){
            f = false;
            cout << *it << endl;
        }
        if(f)cout << "NA" << endl;
    }
    return 0;
}

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

int main(){
  int i,a,b,sum1=0,sum2=0;

  for(i=0;i<4;i++){
    cin>>a;    
    sum1+=a;
  }
  for(i=0;i<4;i++){
    cin>>b;    
    sum2+=b;
  }
  if(sum1<sum2)cout<<sum2<<endl;
  else cout<<sum1<<endl;
  

return 0;
}

Measured memory_bytes: 0
import math
n=int(input())
A=[]
for i in range(0,n):
    v=int(input())
    A.append(v)
p=0
for i in range(0,n):
    x=math.sqrt(A[i])
    x=int(x)
    if A[i]==2 or A[i]==3:
        p=p
    else:
        for ii in range(2,x+1):
            if A[i]%ii==0:
                p=p+1
                break
p=n-p
print(p)



Measured memory_bytes: 6004
#include <iostream>
#define MAXA 10000
using namespace std;
int main(){
	int tax[MAXA][2];
	for(int i=0; i<MAXA; i++)
		tax[i][0] = i * 8 / 100, tax[i][1] = i * 10 / 100;
	int A, B;
	cin >> A >> B;
	for(int i=0; i<MAXA; i++)
		if(tax[i][0] == A && tax[i][1] == B){
			cout << i << endl;
			return 0;
		}
	cout << -1 << endl;
}


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

using namespace std;
typedef long long ll;
#define rep(i,j,n) for (ll i = j; i < (n); i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define IN(a, b, x) (a<=x&&x<b)
#define out(ans) cout << ans << endl
typedef pair<ll,ll>P;
const ll mod=1e9+7;
const ll INF = 1e9;

bool isprime(ll n){
  if(n == 0 || n == 1) return false;
  for(ll i=2; i*i<=n; ++i)if(n%i==0)return false;
  return true;
}


int main(){

  ll a,b;cin>>a>>b;
  set<ll>sa,sb;

  for(ll i=1;i*i<=a;i++){
    if(a%i==0){
      sa.insert(i);
      sa.insert(a/i);
    }
  }
  for(ll i=1;i*i<=b;i++){
    if(b%i==0){
      sb.insert(i);
      sb.insert(b/i);
    }
  }
  set<ll>res;
  set_intersection(sa.begin(),sa.end(),sb.begin(),sb.end(),inserter(res,res.end()));

  ll ans=1;

  for(set<ll>::iterator itr=res.begin();itr!=res.end();itr++){
    if(isprime(*itr))ans++;
  }

  out(ans);


  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int64_t i = 0; i < (n); ++i)
#define repe(i, n) for (int64_t i = 0; i <= (n); ++i)
#define reps(i, s, n) for (int64_t i = (s); i < (n); ++i)
#define repse(i, s, n) for (int64_t i = (s); i <= (n); ++i)
#define repr(i, n) for (int64_t i = (n); i >= 0; --i)
const int64_t inf = (int64_t)1e18;
const int64_t mod = (int64_t)1e9 + 7;


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

  int64_t N, K; cin >> N >> K;
  string S; cin >> S;

  vector<int64_t> stand, invert;
  stand.push_back(0);
  invert.push_back(0);

  bool is_stand = S[0] == '1';
  if (!is_stand) stand.push_back(0);

  int64_t a, b; a = b = 0;
  int64_t x = 0;
  rep(i, N) {
    if (is_stand) {
      if (S[i] == '1') a++;
      else {
        stand.push_back(a);
        is_stand = !is_stand;
        b++;
      }
    } else {
      if (S[i] == '0') b++;
      else {
        invert.push_back(b);
        is_stand = !is_stand;
        a++;
      }
    }
  }

  if (is_stand) stand.push_back(a);
  else {
    invert.push_back(b);
    stand.push_back(a);
  }

  // rep(i, stand.size()) cout << stand[i] << " ";
  // cout << endl;
  // rep(i, invert.size()) cout << invert[i] << " ";
  // cout << endl;

  int64_t ans = 0;

  if (invert.size() - 1 <= K) {
    cout << N << endl;
    exit(0);
  }


  for (int64_t i = 1; i <= invert.size() - K; ++i) {
    // cout << stand[i + K] << " " << stand[i - 1] << " " << invert[i + K - 1] << " " << invert[i - 1] << endl;
    int64_t y = stand[i + K] - stand[i - 1] + invert[i + K - 1] - invert[i - 1];
    // cout << y << endl;
    ans = max(ans, y);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1372
import math
import collections

N = int(input())
n = math.factorial(N)
a = []
ans = 1
while n % 2 == 0:
    a.append(2)
    n //= 2
f = 3
while f * f <= n:
    if n % f == 0:
        a.append(f)
        n //= f
    else:
        f += 2
if n != 1:
    a.append(n)
a = collections.Counter(a)
for i in a.values():
    ans *= (i + 1)
print(ans % 1000000007)


Measured memory_bytes: 3564
#include <iostream>
#include <iomanip>
#include <ios>
#include <string>
using namespace std;
int main(void){
  string s, t;
  cin >> s >> t;
  
  int m = s.length();
  int n = t.length();
  
  if(m == n - 1){
    bool ans = true;
    for(int i=0;i<m;i++){
      if(s[i] != t[i]) ans = false;
    }
    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  else cout << "No" << endl;
  
  return 0;
}

  

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

int BubbleSort(int *,int );
void OutputData(int *,int );

int main(){

  int *a;
  int i,n,c;

  scanf("%d",&n);

  a=(int*)malloc(n*sizeof(int));

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  c=BubbleSort(a,n);
  OutputData(a,n);
  printf("%d\n",c);

  return 0;
}


int BubbleSort(int *a,int n){
  int i,j,tmp,c=0;

  for(i=0;i<n-1;i++){
    for(j=n-1;j>i;j--){
      if(a[j-1]>a[j]){
	tmp=a[j];
	a[j]=a[j-1];
	a[j-1]=tmp;
	c++;
      }
    }
  }
  return c;
}
void OutputData(int *a, int n){
  int i;
  for(i=0;i<n;i++){
    if(i!=n-1){
      printf("%d " ,a[i]);
    }
    else{
      printf("%d",a[i]);
    }
  }
  printf("\n");
}



Measured memory_bytes: 2144
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        long S = 0;
        int[] a = new int[N];
        for (int i = 0; i < N; ++i) {
            a[i] = scanner.nextInt();
            S += a[i];
        }

        long[][] dp = new long[N + 1][N + 1];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N-i; j++) {
                if ((N - i) % 2 == 1) {
                    if (i==0) {
                        dp[j][j] = a[j];
                    } else {
                        dp[j][j+i] = Math.max(dp[j][j+i-1] + a[j+i], dp[j+1][j+i]+ a[j]);
                    }
                } else {
                    if (i==0) {
                        dp[j][j] = 0;
                    } else {
                        dp[j][j + i] = Math.min(dp[j][j+i-1], dp[j+1][j+i]);
                    }
                }
            }
        }

        long X = dp[0][N-1];
        long Y = S-X;

        System.out.println(X-Y);
    }
}

Measured memory_bytes: 129792
import heapq
import sys
input=sys.stdin.readline

hq=[]
while True:
	s=input()
	if s[0]=="e" and s[1]=="n":
		exit()
	elif s[0]=="e":
		print(-heapq.heappop(hq))
	else:
		q,w=s.split()
		w=int(w)
		heapq.heappush(hq,-w)
		


Measured memory_bytes: 45568
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  st s, t;
  ci(s, t);
  int ans = 0;
  rep(i, sz(s)){
    if(s.at(i) != t.at(i)){
      ans++;
    }
  }
  co(ans);
}


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

int sum(int x) {
	int s = 0;
	while (x > 0) {
		s += x % 10;
		x = x / 10;
	}
	return(s);
}

int main()
{
	int N;
	cin >> N;
	int max = 1000;
	for (int i = 1; i < N; i++) {
		int n = sum(i) + sum(N - i);
		if (n < max) {
			max = n;
		}
	}
	cout << max << endl;
}

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

int main()
{
    int h,w,i,j;
    
    cin >> h >> w;

    while(h != 0 and w != 0)
    {
        for(i=0; i < h ; ++i)
        {
            for(j=0; j < w; ++j)
            {
                if((i+j) % 2 == 0)
                cout << "#";
                else
                cout << ".";
            }
            cout << endl;
        }

        cout << endl;
        cin >> h >> w;

    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
void countFreq(string arr[], int n) 
{ 
	unordered_map<string, int> mp; 
	unordered_map<string, int> mp1;
    vector <int> v;
	// Traverse through array elements and 
	// count frequencies 
	for (int i = 0; i < n; i++) {
		mp[arr[i]]++;
			mp1[arr[i]]++;}
    
	  
	for (int i = 0; i < n; i++) { 
	if (mp[arr[i]] != -1) 
	{ 
	    v.push_back(mp[arr[i]]);
		
		mp[arr[i]] = -1; 
	} 
	} 
	 int k = *max_element(v.begin(), v.end());
	 
	 for (int i = 0; i < n; i++) { 
	if (mp1[arr[i]] != -1) 
	{ 
	   if(mp1[arr[i]] == k)
	    {
	        cout<<arr[i]<<endl;
	    }
		
		mp1[arr[i]] = -1; 
	} 
	} 
	 
	  
	 
}

int main() {
    int n,b=0;
    cin>>n;
	string a[n];
 
	for(int i = 0; i < n; i++){
	cin>>a[i];
 
	}
	
	sort(a,a+n);
	countFreq(a,n);
	 
	
	  
	return 0;
}

Measured memory_bytes: 38800
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
using ll = long long;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }
    vector<vector<int>> g(N, vector<int>());
    
    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int ans = 0;

    for (int i = 0; i < N; i++)
    {
        bool highest = true;
        for (auto elem : g[i])
        {
            if(H[elem] < H[i]){

            } else {
                highest = false;
                break;
            }
        }
        if(highest) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8788
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for (int i=0; i<(n); ++i)
#define rrep(i,n) for (int i=1; i<=(n); ++i)
#define drep(i,n) for (int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for (int i=s; i<t; ++i)
#define pi (acos(-1))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef pair<int, int> P;
const int INF = 1001001001;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
struct UnionFind {
  vector<int> par;
  UnionFind(int n=0): par(n,-1) {}
  int root(int x) {
    if (par[x] < 0) return x;
    return par[x] = root(par[x]);
  }
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x == y) return false;
    if (par[x] > par[y]) swap(x,y);
    par[x] += par[y];
    par[y] = x;
    return true;
  }
  bool same(int x, int y) {
     return root(x) == root(y);
  }
  int size(int x) {
    return -par[root(x)];
  }
};
struct Sieve {
	int n;
	vector<int> f, primes;
	Sieve(int n = 1) :n(n), f(n + 1) {
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; ++i) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i * i; j <= n; j += i) {
				if (!f[j]) f[j] = i;
			}
		}
	}
	bool isPrime(int x) { return f[x] == x; }
	vector<int> factorList(int x) {
		vector<int> res;
		while (x != 1) {
			res.push_back(f[x]);
			x /= f[x];
		}
		return res;
	}
	vector<P> factor(int x) {
		vector<int> fl = factorList(x);
		if (fl.size() == 0) return {};
		vector<P> res(1, P(fl[0], 0));
		for (int p : fl) {
			if (res.back().first == p) {
				res.back().second++;
			}
			else {
				res.emplace_back(p, 1);
			}
		}
		return res;
	}
};
ll gcd (ll a, ll b) {
  return b ? gcd(b, a%b) : a;
}
ll lcm (ll a, ll b) {
  return a/gcd(a,b)*b;
}
int main(void) {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
	int a;
	cin >> a;
	cout << a + a*a + a*a*a << endl;
	return 0;
}

	



Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define ALL(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 99999999999
#define PRINT(var) std::cout<<#var"= "<<var<<std::endl

using namespace std;
typedef long long  int ll;

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

ll h,w;
char x[101][101];



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

  cin >> h >>w ;

  FOR(i,1,h+1){
    FOR(j,1,w+1){
      cin >> x[i][j];
    }
  }

  FOR(i,1,2*h+1){
    FOR(j,1,w+1){
      cout << x[(i+1)/2][j];
    }
    cout <<endl;
  }

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
import random
from collections import deque
from decimal import *
import queue

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	N,K = inputMap()
	A = inputList()

	ans = 1
	ans_old = 1
	mae = 0
	for i,val in enumerate(A):
		if i < K:
			continue
		tmp = A[i-K]
		if val > tmp:
			print("Yes")
		else:
			print("No")



#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()


Measured memory_bytes: 101364
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  string s;
  cin >> s;
  cout << ((s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) ? "Bad" : "Good");
}
#endif


Measured memory_bytes: 3608
import java.util.Iterator;
import java.util.PrimitiveIterator;
import java.util.Scanner;
import java.util.function.Supplier;
import java.util.stream.IntStream;
import java.util.stream.Stream;

public class Main{
	static Scanner s=new Scanner(System.in);
	
	void solve(){
		String a=s.next();
		System.out.println((a+a).contains(s.next())?"Yes":"No");
	}

	public static void main(String[] A){
		new Main().solve();
	}

	static int gInt(){
		return Integer.parseInt(s.next());
	}
	static long gLong(){
		return Long.parseLong(s.next());
	}
	static double gDouble(){
		return Double.parseDouble(s.next());
	}

	SupplyingIterator<Integer> ints(int n){
		return new SupplyingIterator<>(n,Main::gInt);
	}
	SupplyingIterator<Long> longs(int n){
		return new SupplyingIterator<>(n,Main::gLong);
	}
	SupplyingIterator<Double> doubles(int n){
		return new SupplyingIterator<>(n,Main::gDouble);
	}
	SupplyingIterator<String> strs(int n){
		return new SupplyingIterator<>(n,s::next);
	}

	Range rep(int i){
		return Range.rep(i);
	}
	Range rep(int f,int t,int d){
		return Range.rep(f,t,d);
	}
	Range rep(int f,int t){
		return rep(f,t,1);
	}
	Range rrep(int f,int t){
		return rep(t,f,-1);
	}

	IntStream REP(int v){
		return IntStream.range(0,v);
	}
	IntStream REP(int l,int r){
		return IntStream.rangeClosed(l,r);
	}

	IntStream INTS(int n){
		return IntStream.generate(Main::gInt).limit(n);
	}
	Stream<String> STRS(int n){
		return Stream.generate(s::next).limit(n);
	}

}
class SupplyingIterator<T> implements Iterable<T>,Iterator<T>{
	int			t;
	Supplier<T>	supplier;

	SupplyingIterator(int t,Supplier<T> supplier){
		this.t=t;
		this.supplier=supplier;
	}

	@Override
	public Iterator<T> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return t>0;
	}

	@Override
	public T next(){
		--t;
		return supplier.get();
	}

}

class Range implements Iterable<Integer>,PrimitiveIterator.OfInt{
	int to,cur,d;

	Range(int from,int to,int d){
		this.cur=from-d;
		this.to=to;
		this.d=d;
	}

	Range(int n){
		this(0,n-1,1);
	}

	@Override
	public Iterator<Integer> iterator(){
		return this;
	}

	@Override
	public boolean hasNext(){
		return cur+d==to||(cur!=to&&(cur<to==cur+d<to));
	}

	@Override
	public int nextInt(){
		return cur+=d;
	}
	static Range rep(int i){
		return new Range(i);
	}
	static Range rep(int f,int t,int d){
		return new Range(f,t,d);
	}
	static Range rep(int f,int t){
		return rep(f,t,1);
	}
	static Range rrep(int f,int t){
		return rep(f,t,-1);
	}
}


Measured memory_bytes: 22868
#include <stdio.h>

int n;
int a[100100][4];
int dp[100100][4];

int max(int a, int b) {
    return (a > b ? a : b);
}

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= 3; j++) scanf("%d", &a[i][j]);
    }
    for (int i = 1; i <= 3; i++) dp[1][i] = a[1][i];
    for (int i = 2; i <= n; i++) {
        for (int j = 1; j <= 3; j++) {
            for (int k = 1; k <= 3; k++) {
                if (j != k) dp[i][k] = max(dp[i - 1][j] + a[i][k], dp[i][k]);
            }
        }
    }
    int ans = 0;
    for (int i = 1; i <= 3; i++) ans = max(ans, dp[n][i]);
    printf("%d\n", ans);
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=500010;
int n,m;
int a[maxn],b[maxn];
char s[maxn];
void read(int &k)
{
	int f=1;k=0;char c=getchar();
	while(c<'0'||c>'9')c=='-'&&(f=-1),c=getchar();
	while(c<='9'&&c>='0')k=k*10+c-'0',c=getchar();
	k*=f;
}
int main()
{
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	read(m);
	for(int i=1;i<=m;i++)read(b[i]);
	sort(a+1,a+1+n);sort(b+1,b+1+m);
	int i=1,j=1;
	for(i=1,j=1;i<=m;i++,j++)
	while(j<=n&&b[i]!=a[j])j++;
	if(j>n+1)return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 3072
a = $stdin.gets.to_i
b = $stdin.gets.to_i
c = $stdin.gets.to_i
x = $stdin.gets.to_i
count = 0

(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      sum = i * 500 + j * 100 + k * 50
      count += 1 if x == sum
    end
  end
end

p count


Measured memory_bytes: 1788
#pragma region GNUC
//以下を参考にした
//https://yukicoder.me/wiki/auto_vectorization
#ifdef __GNUC__
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#endif
#pragma endregion

#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>

#include <string>
#include <cstring>
#include <vector>
#include <valarray>
//#include <array>//x C++ (G++ 4.6.4)

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <cassert>//assert();
#include <fstream>
#include <random>
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)

/////////
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#define PII pair<int,int>
/////////
using namespace::std;

// 最大公約数
template<class T>
inline T gcd(T a, T b){return b ? gcd(b, a % b) : a;}
//inline T gcd(T a, T b){return b == 0 ? a : gcd(b, a % b);}

// 最小公倍数
template<class T>
inline T lcm(T a, T b){return a / gcd(a, b) * b;}
//inline T lcm(T a, T b){return a * b / gcd(a, b);}
////////////////////////////////

void solve(){
	LL A,B;
	string op;
	cin >> A >> op >> B;
	if( op[0] == '+' ){
		cout << A+B << endl;
	}else{
		cout << A-B << endl;
	}
}

signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	//std::cout << std::fixed;//小数を10進数表示
	//cout << setprecision(16);//小数点以下の桁数を指定
	
	solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;
const int BUF = 305;
const int BIT = 61;


class State {
public:
    int bit, aCarry, bCarry, subed;
    
    State() {}
    State(int bit, int aCarry, int bCarry, int subed):
        bit(bit), aCarry(aCarry), bCarry(bCarry), subed(subed) {}

    bool operator< (const State &opp) const {
        if (subed != opp.subed) return subed < opp.subed;
        return aCarry < opp.aCarry;
    }
};


int nVal;
long long val[BUF];

void read() {
    cin >> nVal;
    for (int i = 0; i < nVal; ++i) {
        cin >> val[i];
    }
}


bool rec(int bit, int aCarry, int bCarry, int dp[BIT][2][2], vector<State> next[BIT][2][2], long long result) {
    if (bit == BIT - 1) {
        return aCarry == 0 && bCarry == 0;
    }
    
    int &ret = dp[bit][aCarry][bCarry];
    if (ret != -1) return ret;

    ret = false;
    
    long long aBit = (val[0] - (aCarry ?  1LL << (bit) : 0)) & (1LL << bit);
    long long bBit = (val[1] + (bCarry ?  1LL << (bit) : 0)) & (1LL << bit);
    long long rBit = result & (1LL << bit);
    
    // A - (1 << bit),  B + (1 << bit)
    if ((aBit ^ bBit) == rBit) {
        int aNexCarry = (val[0] & (1LL << bit)) == 0 || aCarry;
        int bNexCarry = (val[1] & (1LL << bit)) || bCarry;
        if (rec(bit + 1, aNexCarry, bNexCarry, dp, next, result)) {
            next[bit + 1][aNexCarry][bNexCarry].push_back(State(bit, aCarry, bCarry, true));
            ret = true;
        }
    } 
    
 
    // A - 0,  B + 0
    if ((aBit ^ bBit) == rBit) {
        int aNexCarry = (val[0] & (1LL << bit)) == 0 && aCarry;
        int bNexCarry = (val[1] & (1LL << bit)) && bCarry;
        if (rec(bit + 1, aNexCarry, bNexCarry, dp, next, result)) {
            next[bit + 1][aNexCarry][bNexCarry].push_back(State(bit, aCarry, bCarry, false));
            ret = true;
        }
    }

    return ret;
}


void work() {
    long long result = 0;
    for (int i = 2; i < nVal; ++i) {
        result ^= val[i];
    }
    
    int dp[BIT][2][2];
    memset(dp, -1, sizeof(dp));
    
    vector<State> next[BIT][2][2];
    
    if (!rec(0, 0, 0, dp, next, result)) {
        cout << -1 << endl;
    } else {
        long long ans = 0;
        int bit = BIT - 1, aCarry = 0, bCarry = 0;
        
        while (!next[bit][aCarry][bCarry].empty()) {
            vector<State> &n = next[bit][aCarry][bCarry];
            sort(n.begin(), n.end());
            
            if (n[0].subed) {
                ans |= 1LL << (bit - 1);
            }

            bit = n[0].bit;
            aCarry = n[0].aCarry;
            bCarry = n[0].bCarry;
        }
        cout << (ans == val[0] ? -1 : ans) << endl;
    }
}


int main() {
    read();
    work();
    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#include <iomanip>
#define rep(i,N) for(int i=0;i<(int)N;++i)
//cout << fixed << setprecision(20) << *** << endl;
typedef long long ll;
using namespace std;
int main()
{
	ll N;
	cin>>N;
	vector<ll>A(N,0);
	vector<ll>B(N,0);
	vector<ll>ANS;
	rep(i,N){
		ll t;
		cin>>t;
		A[i]=t;
	}
	rep(i,N){
		ll t;
		cin>>t;
		B[i]=t;
	}
	rep(i,N){
		ll sum=0;
		ll f=0;
		rep(j,N){
			if(f==0){
				sum=sum+A[j];
			}
			if(i==j){
				sum=sum+B[j];
				f=1;
			}
			else if(f==1){
				sum=sum+B[j];
			}
		}
		ANS.push_back(sum);
	}
	sort(ANS.begin(),ANS.end());
	cout<<ANS.back()<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
const int N = 1005;
 
int n, t, a, b;
pair<int,int> v[N];
 
int main() {
  cin >> n >> t;
  for (int i = 0; i < n; i++) {
    cin >> a >> b;
    v[i] = make_pair(b,a); 
  }
  sort(v,v+n);
  if (v[0].first <= t) {
    int ans = v[0].second;
    for (int i = 1; i < n && v[i].first <= t; i++) ans = min(ans,v[i].second);
    cout << ans << endl;
  } else {
   cout << "TLE" << endl; 
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{

    char s[4];
    int a=0, b=0, c=0;

    cin>>s;

    for(int i=0; i<3; i++) if(s[i]=='a')
        {
            a=1;
            break;
        }
    for(int i=0; i<3; i++) if(s[i]=='b')
        {
            b=1;
            break;
        }
    for(int i=0; i<3; i++) if(s[i]=='c')
        {
            c=1;
            break;
        }

    if(a==1 && b==1 && c==1)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}


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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;




void solve(int z) {
    string s , t;
    cin >> s >> t;
    string a = "";
    for(int i = 0 ; i < (int)t.size() - 1 ; i ++) a += t[i];
    if(a == s) cout << "Yes";
    else cout << "No";
    cout << "\n";
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



Measured memory_bytes: 3596
#include<bits/stdc++.h> 
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp> 
#define mod 1000000007
#define mod2 998244353
#define int long long
#define endl "\n"
#define p_b push_back
#define fastIO ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
using namespace __gnu_pbds;
template <class T> 
using _ost = tree<
		T, 
		null_type, 
		less<T>, 
		rb_tree_tag, 
        tree_order_statistics_node_update>;
// char alphabet[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
void swap(int* a,int* b){
    int temp = *a;
    *a=*b;
    *b=temp;
}
bool check(string s){
	int n=s.size();
	int i=0,j=n-1;
	while(i<j){
		if(s[i]!=s[j])return 0;
		i++;j--;
	}
	return 1;
}
int32_t main(){
 	fastIO;
 	double l;cin>>l;
 	l=l/3.0;
 	l=l*l*l;
 	cout<<fixed<<setprecision(12)<<l<<endl;
} 	

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1000000000;/* 1e+9a */

void solve(istream &cin) {
    ll N;
    cin >> N;
    if(!cin) return;
    ll ans =2 * ( N / 11);
    N %= 11;
    ans += N / 6;
    N %= 6;
    ans += N != 0;

    cout << ans << endl;
}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    cerr << "DEBUG MODE" << endl;
    string test_cases = "test.txt";
    auto fs = fstream(test_cases, fstream::in);
    while(fs) {
        solve(fs);
    }
#else
    solve(cin);
#endif
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String[] a = sc.next().split("/", 0);;
		System.out.println(Integer.parseInt(a[1])*100+Integer.parseInt(a[2])<=430?"Heisei":"TBD");
	}
}

Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder.ABC169
{
    public class Problem1
    {
        public static void Main(string[] args)
        {
            var a = Console.ReadLine().Split(" ");

            var i = int.Parse(a[0]) * int.Parse(a[1]);

            Console.WriteLine(i.ToString());
        }
    }
}


Measured memory_bytes: 27536
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int sum=a+b+c;
  int MA=max({a,b,c});
  cout<<sum-MA+MA*std::pow(2,k)<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define faster ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
 
typedef vector<int> vi;;
typedef vector<ll> vll;

#define l() length()
#define sz() size()
 
#define b() begin()0
#define e() end()
#define all(x) x.begin(), x.end()
 
#define pb(i) push_back(i)
#define PB() pop_back()
 
 
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
#define mp make_pair
#define Fi first
#define Se second
 
const int maxx=100009;
 
// Happy Coding!



void solve(){
    int n,p,st;
    cin>>n>>p>>st;
    
    int l,r;
    l=r=0;
    for(int i=0;i<p;i++){
        int x;
        cin>>x;
        if(x<st){
            l++;
        }
        else{
            r++;
        }
    }
    cout<<min(l,r);
}

 
int main() {
    faster;
    int t=1;
    // cin>>t;
    
    while(t-->0){
        solve();
    }
	return 0;
}

Measured memory_bytes: 3536
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;
using P = pair<int, int>;

int main() {
    int n, m;
    cin >> n >> m;
    vector<tuple<int, int, int>> t(m);
    vector<P> v;
    for (int i = 0; i < m; ++i) {
        int p, q, c;
        scanf("%d %d %d", &p, &q, &c);
        t[i] = make_tuple(p-1, q-1, c);
        v.emplace_back(p-1, c);
        v.emplace_back(q-1, c);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    auto s = v.size();
    vector<vector<P>> G(s+n);
    auto getidx = [&](P a){ return lower_bound(v.begin(), v.end(), a)-v.begin();};
    for (auto &&i : t) {
        int p, q, c;
        tie(p, q, c) = i;
        auto x = getidx(P(p, c)), y = getidx(P(q, c));
        G[x].emplace_back(y, 0);
        G[y].emplace_back(x, 0);
        G[x].emplace_back(p+s, 1);
        G[p+s].emplace_back(x, 1);
        G[y].emplace_back(q+s, 1);
        G[q+s].emplace_back(y, 1);
    }
    vector<int> d(s+n, INF<int>);
    d[s] = 0;
    deque<P> Q;
    Q.emplace_front(0, s);
    while (!Q.empty()){
        int dist, u;
        tie(dist, u) = Q.front(); Q.pop_front();
        if(dist > d[u]) continue;
        for (auto &&e : G[u]) {
            int to, c;
            tie(to, c) = e;
            if(d[to] > d[u]+c){
                d[to] = d[u]+c;
                if(c == 0) Q.emplace_front(d[u], to);
                else Q.emplace_back(d[u]+1, to);
            }
        }
    }
    cout << (d[s+n-1] == INF<int> ? -1 : d[s+n-1]/2) << "\n";
    return 0;
}


Measured memory_bytes: 38636
#include<bits/stdc++.h>
using namespace std;
#define w(x) cout << (#x) << " is " << x << "\n" ;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
#endif
    int n,mx=0;
    string s ;
    map<string,int>m;
    cin >> n ;
    while(n--)
    {
        cin >> s ;
        mx=max(++m[s],mx);
    }
    for(auto i:m)
    {
        if(i.second==mx)
            cout << i.first << "\n";
    }
    return 0;
}

Measured memory_bytes: 19232
#include<bits/stdc++.h>
#define INF (1e9)
#define N 19
#define M 15
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
int sy,sx,cnt;
map<P1,int> memo;
map<P,int> num;
string s[N];
int dy[8]={-1,-1,-1,0,0,1,1,1};
int dx[8]={-1,0,1,-1,1,-1,0,1};

int dfs(int A,int y,int x){
  if(memo.count(P1(A,P(y,x))))return memo[P1(A,P(y,x))];
  if((N-1==y&&0<=x&&x<M)||N<=y)return 1;
  if(y<0||x<0||N<=y||M<=x)return INF;
  int res=INF;
  for(int i=0;i<8;i++){
    int ny=y+dy[i],nx=x+dx[i],nA=A;
    if(ny<0||nx<0||N<=ny||M<=nx||s[ny][nx]!='X')continue;
    while(0<=ny&&ny<N&&0<=nx&&nx<M&&s[ny][nx]=='X'){
      nA|=(1<<num[P(ny,nx)]);
      s[ny][nx]='.';
      ny+=dy[i]; nx+=dx[i];
    }
    res=min(res,dfs(nA,ny,nx));
    while(ny!=y||nx!=x){
      ny-=dy[i]; nx-=dx[i];
      s[ny][nx]='X';
    }
    s[y][x]='.';
  }
  return memo[P1(A,P(y,x))]=res+1;
}

int main(){
  for(int i=0;i<N;i++){
    cin>>s[i];
    for(int j=0;j<M;j++){
      if(s[i][j]=='O'){
	sy=i,sx=j;
	s[i][j]='.';
      }
      if(s[i][j]=='X')
	num[P(i,j)]=cnt++;
    }
  }
  int ans=dfs(0,sy,sx);
  cout<<(ans>=INF?-1:ans-1)<<endl;
  return 0;
}

Measured memory_bytes: 8376
package main

import (
	"fmt"
	"bufio"
	"os"
	"strings"
	"strconv"
)

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func solve(w []int, v []int, W int) int {
    dp := make([]int, W+1)
    for i := range w {
        wi, vi := w[i], v[i]
        for j:=W; j>=wi; j-- {
            dp[j] = max(dp[j], dp[j-wi]+vi)
        }
    }
    return dp[W]
}

func readLineNum(bf *bufio.Reader) int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	N, _ := strconv.Atoi(line)
	return N
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func main() {
	bf := bufio.NewReader(os.Stdin)
    nw := readLineNums(bf)
    N, W := nw[0], nw[1]
    w := make([]int, 0)
    v := make([]int, 0)
    for i:=0; i<N; i++ {
        wv := readLineNums(bf)
        w = append(w, wv[0])
        v = append(v, wv[1])
    }
    fmt.Println(solve(w, v, W))
}


Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int main(){
  int a,i;
  cin >> a;
  int h=0,m=0,s=0;
  for(i=1;i<=a;i++){
    s++;
    if(s==60){
      m++;
      s=0;
      if(m==60){
        h++;
        m=0;
      }
    }
  }
  cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())
#define MP(a,b) make_pair(a,b)
#define FORE(a,b) for(auto &&a:b)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

int main(void){
	int x,y;
	while(cin>>x>>y){
		if(x==0&&y==0) return 0;
		if(x<y) cout<<x<<" "<<y;
		else cout<<y<<" "<<x;
		cout<<endl;
	}
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define vec(x) vector<x>
ll gcd(ll a,ll b){while(b){ll tmp = a % b;a = b;b = tmp;}return a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define out(x) for(auto i : x) cout << i << " "; cout << endl;
#define outln(x) for(auto i : x) cout << i << " " << endl;
#define vec_cpy(to,from) copy(all(to),back_inserter(from))
#define ary_cpy(to,from) memcpy(to, from, sizeof from)
#define MOD = 1000000007; 
#ifdef DEBUG
#define debug_echo(e) cout << "L" << __LINE__ << ": " << e << endl
#define debug_var(e) cout << "L" << __LINE__ << ": " << #e << " = " << e << endl
#else
#define debug_echo(e)
#define debug_var(e)
#endif
#ifdef DEBUG
#define debug_echo_dp1(dp, N) { cout << "[ "; rep(i, N) cout << dp[i] << " ";  cout << "]" << endl; }
#else
#define debug_echo_dp1(dp, N)
#endif

#define MAX_N 100
#define MAX_W 10000

int N;
int W;
int v[MAX_N];
int w[MAX_N];

int dp[MAX_W+1];

int solve(){
  for (int i=0; i<N; i++) {
    for (int j=W-w[i]; j>=0; j--) {
      dp[j+w[i]] = max(dp[j+w[i]], dp[j] + v[i]);
    }
  }
}

int main() {
  cin >> N >> W;
  rep(i, N) {
    cin >> v[i] >> w[i];
  }
  memset(dp, 0, sizeof(dp));
  
  solve();
  debug_echo_dp1(dp, W);
  cout << dp[W] << endl;
}

Measured memory_bytes: 3144
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

unsigned long long int N, K;

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


    unsigned long long int q = N % K;
    unsigned long long int answer;

    answer = min(q, K - q);

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

    return 0;
}

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

using namespace std;

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

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

  for (int i = 0; i < s.size(); ++i) {
    if (s[i] != t[i]) {
      cout << "No" << '\n';
      return 0;
    }
  }
  cout << "Yes" << '\n';

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 200;
int h,w,n,a[N*N];
int c[N][N];

int main() {
	scanf("%d%d%d",&h,&w,&n);
	REP(i,1,n) scanf("%d",a+i);
	int now = 1, res = a[1];
	REP(i,1,h) {
		if (i&1) {
			REP(j,1,w) { 
				c[i][j]=now;
				if (!--res) res=a[++now];
			}
		}
		else {
			PER(j,1,w) {
				c[i][j]=now;
				if (!--res) res=a[++now];
			}
		}
	}
	REP(i,1,h) {
		REP(j,1,w) printf("%d ",c[i][j]);hr;
	}
}








Measured memory_bytes: 384
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int in,id,k,a,rev[N];
/* struct declaration */

struct node {

  int key;

  struct node *next;

};

typedef struct node *NodePointer;

/* prototype declaration */

NodePointer insert(int,int);

NodePointer finditem(int,int);

void listprint(void);

NodePointer make_1node(int, NodePointer);


/* Global Variable head */

NodePointer head[N];

NodePointer insert(int keydata,int idx)//keydataがリストになかったらそれをリストに追加する
{
  NodePointer newnode;

  newnode = make_1node(keydata, head[idx]->next);
  head[idx]->next = newnode;
    
  return newnode;
}

NodePointer make_1node(int keydata, NodePointer p)//ノードを追加する
{
  NodePointer n;

  n = (NodePointer)malloc(sizeof(struct node));
  
  n->key = keydata;
  n->next = p;

  return n;
}

bool used[N];
int dep[N],par[N],z[N];

void dfs(int x,int d){
  dep[x]=d;
  int f=0;
  NodePointer n;
  for (n = head[x]->next; n != NULL; n = n->next) dfs(n->key,d+1),f=1;
  if(!f&&z[x]!=3)z[x]=1;
  else if(z[x]!=3)z[x]=2;
}

int main(){
  cin>>in;
  for(int i=0;i<in;i++)head[i]=make_1node(-1,head[i]);
  for(int i=0;i<in;i++){
    cin>>id>>k;
    for(int j=0;j<k;j++){
      cin>>a;
      insert(a,id);
      used[a]=true;
      par[a]=id;
    }
  }
  for(int i=0;i<in;i++)
    if(!used[i])z[i]=3,dfs(i,0),par[i]=-1;
  for(int i=0;i<in;i++){
    cout<<"node "<<i<<": parent = "<<par[i]<<", depth = "<<dep[i]<<", ";
    if(z[i]==2)cout<<"internal node, [";
    if(z[i]==1)cout<<"leaf, [";
    if(z[i]==3)cout<<"root, [";
    int y=0;
    NodePointer n;
    for (n = head[i]->next; n != NULL; n = n->next)rev[y++]=n->key;
    for(int j=y-1;j>=0;j--){
      if(j!=y-1)cout<<", ";
      cout<<rev[j];
    }
    cout<<"]"<<endl;
  }
  return 0;
}

Measured memory_bytes: 9876