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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
typedef pair< int, int > pii;

int h, w, s, u[33][33], sum;

void makeImos() {
	for_(y,1,h+1) for_(x,0,w) u[y][x+1] += u[y][x];
	for_(x,1,w+1) for_(y,0,h) u[y+1][x] += u[y][x];
	sum = u[h][w];
}

int getImos(int l, int t, int r, int b) { return u[b][r] + u[t][l] - u[b][l] - u[t][r]; }

const pii ini(-1, -1);
pii dp[33][33][33][33];

pii rec(int l, int t, int r, int b) {	
	pii& res = dp[l][t][r][b];
	
	if (res != ini) return res;
	
	int power = getImos(l, t, r, b);
	if (sum - power > s) return res = pii(0, 0);
	
	res = pii(1, s - (sum - power));
	
	for_(y,t+1,b) {
		pii nxt_a = rec(l, t, r, y);
		pii nxt_b = rec(l, y, r, b);
		pii nxt_p(nxt_a.first + nxt_b.first, min(nxt_a.second, nxt_b.second));
		res = max(res, nxt_p);
	}
	
	for_(x,l+1,r) {
		pii nxt_a = rec(l, t, x, b);
		pii nxt_b = rec(x, t, r, b);
		pii nxt_p(nxt_a.first + nxt_b.first, min(nxt_a.second, nxt_b.second));
		res = max(res, nxt_p);
	}
	
	return res;
}

void solve() {
	makeImos();
	for_(i,0,33) for_(j,0,33) for_(ii,0,33) for_(jj,0,33) dp[i][j][ii][jj] = ini;
	pii ans = rec(0, 0, w, h);
	cout << ans.first << " " << ans.second << endl;
}

int main() {
	while (cin >> h >> w >> s) {
		if (h == 0) break;
		memset(u, 0, sizeof(u));
		for_(y,0,h) for_(x,0,w) cin >> u[y+1][x+1];
		solve();
	}
}

Measured memory_bytes: 12380
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        boolean impossible = false;

        Map<Integer, Integer> map = new HashMap<>();

        int first = sc.nextInt();
        map.put(first, 1);
        if (first != 0) {
            impossible = true;
        }

        for (int i = 1; i < n; i++) {
            int tmp = sc.nextInt();
            if (map.containsKey(tmp)) {
                map.put(tmp, map.get(tmp) + 1);
            } else {
                map.put(tmp, 1);
            }
        }
        // for debug
        // System.out.println(map);

        // 0が 0 or 複数個はNG
        if (!impossible && map.get(0) != 1) {
            impossible = true;
        }

        // keyが0からの連続数でない場合はNG
        TreeSet<Integer> tree = new TreeSet<>(map.keySet());
        if (tree.size() - 1 != tree.last()) {
            impossible = true;
        }
        // for debug
        // System.out.println(tree);

        long ans = 1;
        if (impossible) {
            ans = 0;
        } else {
            for (int i = 2; i <= tree.last(); i++) {
                for (int j = 0; j < map.get(i); j++) {
                    ans *= map.get(i - 1);
                    ans %= 998244353;
                }
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


Measured memory_bytes: 63152
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string ans = "";
  rep(i, 0, tx-sx)  ans+='R';
  rep(i, 0, ty-sy)  ans+='U';
  rep(i, 0, tx-sx)  ans+='L';
  rep(i, 0, ty-sy)  ans+='D';
  ans+='D';
  rep(i, 0, tx-sx+1)  ans+='R';
  rep(i, 0, ty-sy+1)  ans+='U';
  ans+="LU";
  rep(i, 0, tx-sx+1)  ans+='L';
  rep(i, 0, ty-sy+1)  ans+='D';
  ans+='R';
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[200010];
signed main()
{
    int n;
    cin >> n;
    REP(i, n)
        cin >> a[i];
    int ans = 0;
    bool ok = false;
   
    
    for (int i = 0; i < n; i++)
    {
        if(a[i]!=i+1-ans){
            ans++;
          //  cerr << a[i] << endl;
        }
    }
    if(ans==n){
        cout << -1 << endl;
    }
    else
        cout << ans << endl;

    return 0;
}

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

int main() {
    long long ans = 0;
    int N, K, R, S, P;
    cin >> N >> K >> R >> S >> P;
    vector<char> T(N);
    for(int i = 0; i < N; i++) {
        cin >> T.at(i);
    }
    map<char, int> Points{{'r', R}, {'s', S}, {'p', P}};
    map<char, char> my_hands{{'r', 'p'}, {'s', 'r'}, {'p', 's'}};
    vector<char> ls(N);
    for(int i = 0; i < N; i++) {
        if(i < K) {
            ans += Points.at(my_hands.at(T.at(i)));
            ls.at(i) = my_hands.at(T.at(i));
        } else if(my_hands.at(T.at(i)) != ls.at(i - K)) {
            ans += Points.at(my_hands.at(T.at(i)));
            ls.at(i) = my_hands.at(T.at(i));
        }
    }
    cout << ans << endl;
}

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

using namespace std;

#define ff first
#define ss second
#define pb push_back

using ll = long long;
using ii = pair<int, int>;

const int oo = 1e9;
const int N = 1e5 + 5;

int main(){
	int n;
	scanf("%d", &n);
	if(n == 1){
		printf("1\n");
	}
	else if(n % 2){
		printf("%.15lf\n", (n/2 + 1.0) / n);
	}
	else{
		printf("0.5\n");
	}
	return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define ll long long int
#define fab(a,b,i) for(int i=a;i<b;i++)
#define pb push_back
#define db double
#define mp make_pair
#define endl "\n"
#define f first
#define se second
#define all(x) x.begin(),x.end()
#define MOD 1000000007
#define quick ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
const int N=21;
ll dp[1LL<<N+5];
int main()
{ quick;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin>>n;
    bool match[n][n];
    fab(0,n,i)
    fab(0,n,j)
    cin>>match[i][j];
    dp[0]=1;
    fab(0,1<<n,i)
    {
        int setbits=__builtin_popcount(i);
        fab(0,n,j)
        {
            if(((1<<j)&i)==0 and match[setbits][j])
            {
                dp[i|(1<<j)]+=dp[i];
                dp[i|(1<<j)]%=MOD;
            }
        }
    }
    cout<<dp[(1<<n)-1]<<endl;
    

 cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
    return 0;
}

Measured memory_bytes: 20220
l = list(input())
f = False

for i in range(len(l)):
    if i % 2:
        if l[i] == 'L' or l[i] == 'U' or l[i] == 'D':
            f = True
        else:
            f = False
            break
    else:
        if l[i] == 'R' or l[i] == 'U' or l[i] == 'D':
            f = True
        else:
            f = False
            break

if f:
    print('Yes')
else:
    print('No')

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

int main() {
  	int n;
  	cin >> n;
  	int v[n];
  	for (int i = 0; i < n; i++) cin >> v[i];
  
  	int num1[100010];
  	int num2[100010];
  	for (int i = 0; i < 100010; i++){
      	num1[i] = 0;
      	num2[i] = 0;
    }
    
  	for (int i = 0; i < n / 2; i++){
      	num1[v[i * 2]]++;
      	num2[v[i * 2 + 1]]++;
    }
  
  	int max1 = 0, max2 = 0;
  	int max_1 = 0, max_2 = 0; 
  	int res1 = 0, res2 = 0;
  	int res_1 = 0, res_2 = 0;
  	for (int i = 0; i < 100010; i++){
      	if (max1 <= num1[i]){
          	max_1 = max1;
          	max1 = num1[i];
          	res_1 = res1;
          	res1 = i;
        }
      	else if (max_1 <= num1[i]){
          	max_1 = num1[i];
          	res_1 = i;
        }
      	if (max2 <= num2[i]){
          	max_2 = max2;
          	max2 = num2[i];
          	res_2 = res2;
          	res2 = i;
        }
      	else if (max_2 <= num2[i]){
          	max_2 = num2[i];
          	res_2 = i;
        }
    }
  
  	int res;
  	if (res1 != res2) res = n - max1 - max2;
  	else res = min(n - max_1 - max2, n - max1 - max_2);
  
  	cout << res << endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String W = sc.next();
		int ct = 0;
		while (true) {
			String T = sc.next();
			if (T.equals("END_OF_TEXT")) {
				break;
			}
			if (T.equalsIgnoreCase(W)) {
				ct++;
			}
		}
		System.out.println(ct);
	}
}



Measured memory_bytes: 26344
n,h=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
b=max(a,key=lambda x:x[0])[0]
c=sorted(t for(s,t)in a if t>b)
d=0
while h>0 and c:
    h-=c.pop()
    d+=1
print(d+max(h-1,-1)//b+1)

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

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

  int graph[n+1][n+1];
  memset(graph, 0, sizeof(graph));
  int from, to;
  for(int i=0; i<m; i++){
    cin >> from >> to;
    graph[from][to]++;
    graph[to][from]++;
  }

  for(int i=1; i<=n; i++){
    int cnt=0;
    for(int j=1; j<=n; j++){
      cnt += graph[i][j];
    }
    cout << cnt << endl;
  }

  return 0;
}


Measured memory_bytes: 256
k = gets.chomp.to_i
if k == 7 || k == 1
  p 1
  exit
end
ans = 0
x = 7%k
i = 1
s =false
while i <= k
  x =(x*10+7)%k
  if x == 0
    s = true
    break
  end
  i += 1
end
if s
  p i+1
else
  p -1
end

Measured memory_bytes: 14256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Tarek
 */

#include <iostream>
#include <fstream>

#include <iostream>

using namespace std;

class ALucky7 {
public:
    void solve(std::istream &in, std::ostream &out) {
        string s;
        in >> s;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == '7') {
                out << "Yes\n";
                return;
            }
        }
        out << "No\n";
    }
};

int main() {
    ALucky7 solver;
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
#include <queue>
using namespace std;

int main()
{
  int n,q;
  long long m;
  scanf("%d%lld%d",&n,&m,&q);
  vector<vector<int> > e(n);
  vector<int> A,B;
  for(int i=0;i<q;i++){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(c==0){
      e[a].push_back(b);
      e[b].push_back(a);
    }
    else{
      A.push_back(a);
      B.push_back(b);
    }
  }
  bool ans;
  if(m==n-1){
    ans=(A.size()==0);
  }
  else{
    vector<int> P(n,-1);
    int k=0;
    for(int r=0;r<n;r++){
      if(P[r]!=-1)
	continue;
      k++;
      queue<int> Q;
      Q.push(r);
      P[r]=r;
      while(!Q.empty()){
	int i=Q.front();
	Q.pop();
	for(int x=0;x<e[i].size();x++){
	  int j=e[i][x];
	  if(P[j]==-1){
	    P[j]=r;
	    Q.push(j);
	  }
	}
      }
    }
    ans=(m<=(n-k)+(long long)k*(k-1)/2);
    for(int t=0;t<A.size();t++){
      if(P[A[t]]==P[B[t]]){
	ans=false;
      }
    }
  }
  puts(ans?"Yes":"No");
  return 0;
}


Measured memory_bytes: 6144
#include <iostream>
using namespace std;
int main(){
  int n,f;
  for(;cin>>n>>f&&n;){
    int c[100],r0=1,r1;
    for(int i=0;i<n;i++) cin>>c[i];
    for(int i=0;i<n-f+1;i++){
      int t=1;
      for(int j=0;j<f;j++) t*=c[i+j];
      r0=max(r0,t);
    }
    r1=r0;
    for(int k=0;k<n-1;k++){
      for(int l=k+1;l<n;l++){
        swap(c[k],c[l]);
        for(int i=0;i<n-f+1;i++){
          int t=1;
          for(int j=0;j<f;j++) t*=c[i+j];
          r1=max(r1,t);
        }
        swap(c[k],c[l]);
      }
    }
    cout<<r1-r0<<endl;
  }
  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define pb push_back
typedef long long ll;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;




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

    int t, f;
    char c;
    int flag = 0;//反転回数
    string pre, suf;//それぞれ無反転のとき前に着くほう、後ろにつく方

    rep(i,q){
        cin >> t;

        if(t==1){
            flag++;
        } 
        if(t==2){
            cin >> f >> c;

            if(f==1){
                if(flag % 2 == 0)
                {
                    pre = pre + c;
                }
                else
                {
                    suf = suf + c;
                }
            }
            if(f==2)
            {
                if (flag % 2 == 0)
                {
                    suf = suf + c;
                }
                else
                {
                    pre = pre + c;
                }
            }
        }

    }
    
    if(flag%2==0){
        reverse(pre.begin(), pre.end());
        
        s = pre + s + suf;
    } else
    {
        reverse(suf.begin(), suf.end());
        reverse(s.begin(), s.end());
        s = suf + s + pre;
    }
            
    cout << s << endl;
}

Measured memory_bytes: 1620
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: u64 = itr.next().unwrap().parse().unwrap();
    let q: usize = itr.next().unwrap().parse().unwrap();

    let mut out = Vec::new();
    for _ in 0..q {
        let mut v = itr.next().unwrap().parse::<u64>().unwrap() - 1;
        let mut w = itr.next().unwrap().parse::<u64>().unwrap() - 1;
        if n == 1 {
            writeln!(out, "{}", v + 1).ok();
            continue;
        }
        while v != w {
            while v > w {
                v = (v - 1) / n;
            }
            while w > v {
                w = (w - 1) / n;
            }
        }
        writeln!(out, "{}", v + 1).ok();
    }
    stdout().write_all(&out).unwrap();
}


Measured memory_bytes: 11256
#include<bits/stdc++.h>
#include<bits/stdc++.h>
#include <vector>
#define ll long long int
#define ve vector<ll>
#define vell vector<ll>
#define ve_pa vector<pair<ll,ll> >
#define pb push_back
#define mod 1000000007
#define ld long double 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define mll map<ll,ll>
#define mii map<int,int>
#define m_ve map<ll,vell >
#define min3(x,y,z) min(x,min(y,z))
#define max3(x,y,z) max(x,max(y,z))
#define se second
#define check cout<<"s"
#define checkx(x) cout<<x
#define W(x) while(x--)
#define ld long double
#define popcount(x) __builtin_popcountll(x)
#define rep(i,n) for(ll i=0;i<n;i++)
#define V 6 
using namespace std;
//int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL); 
cout.tie(NULL);
ll d,t,s;cin>>d>>t>>s;
if(t*s>=d)
{
	cout<<"Yes";
}
else
cout<<"No";


}
 
 
 


Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;

const int N=300005;

struct node{
	int x,w;
}a[N];
int n,cnt,m,now,pos;
int pre[N],nxt[N],b[N],tot[N],p[N];

bool cmp(node a,node b){
	return a.x<b.x;
}

void del(int k){
	pre[nxt[k]]=pre[k];
	nxt[pre[k]]=nxt[k];
}

int main(){
	int i,j;
	scanf("%d",&n); m=n*n;
	for (i=1;i<=n;i++) scanf("%d",&a[i].x),a[i].w=i;
	sort(a+1,a+1+n,cmp);
	for (i=1;i<=m;i++) pre[i]=i-1,nxt[i]=i+1;
	pre[m+1]=m; nxt[0]=1;
	for (i=1;i<=n;i++){
		if (b[a[i].x]){
			printf("No\n");
			return 0;
		}
		b[a[i].x]=a[i].w; del(a[i].x);
		for (j=nxt[0],cnt=1;j<=m;j=nxt[j]){
			if (cnt==a[i].w) break;
			if (j>a[i].x){
				printf("No\n");
				return 0;
			}
			b[j]=a[i].w; del(j);
			cnt++;
		}
	}
	now=a[1].w; pos=1;
	for (i=1;i<=n;i++) tot[i]=i;
	for (i=1;i<=n;i++) p[a[i].w]=a[i].x;
	if (tot[now]==n) now=a[++pos].w;
	for (i=nxt[0];i<=n*n;i=nxt[i])
		if (!b[i]){
			if (i<p[now]){
				printf("No\n");
				return 0;
			}
			p[now]=i; tot[now]++;
			b[i]=now;
			while (tot[now]==n) now=a[++pos].w;
		}
	printf("Yes\n");
	for (i=1;i<=n*n;i++) printf("%d ",b[i]); 
	return 0;
}
/*
4
1 5 10 8
*/

Measured memory_bytes: 5248
// atcoder/agc035/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  while (cin >> n) {
    vec<int> a(n);
    cin >> a;
    map<int, int> m;
    each (i, a) ++m[i];

    const int z = count(a.begin(), a.end(), 0);
    if (z == a.size()) {
      cout << "Yes" << endl;
      continue;
    }

    if (m.size() == 2 && z * 3 == a.size()) {
      cout << "Yes" << endl;
      continue;
    }

    sort(a.begin(), a.end());
    a.erase(unique(a.begin(), a.end()), a.end());
    if (m.size() == 3 && (a[0] ^ a[1]) == a[2] && m[a[0]] == m[a[1]] && m[a[0]] == m[a[2]]) {
      cout << "Yes" << endl;
      continue;
    }

    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	ll n, m;
	cin >> n >> m;
	vector<pair<ll, ll>>p;
	ll a, b;
	rep(i, m) {
		cin >> a >> b;
		p.eb(b, a);
	}
	sort(p.begin(), p.end());
	ll t = 0;
	ll ans = 0;
	rep(i, m) {
		if (t <=p[i].se){
			t = p[i].fi;
			++ans;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
 
int main()
{
    std::string s, ans;
    int slong;

    std::cin >> s;

    slong = s.length();

    for(int i = 0;i < slong;i++){
        if((i + 1) % 2 == 1){
            ans += s[i];
        }
    }

    std::cout << ans;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif
template<unsigned int mod_>
struct ModInt{
	using uint = unsigned int;
	using ll = long long;
	using ull = unsigned long long;

	constexpr static uint mod = mod_;

	uint v;
	ModInt():v(0){}
	ModInt(ll _v):v(normS(_v%mod+mod)){}
	explicit operator bool() const {return v!=0;}
	static uint normS(const uint &x){return (x<mod)?x:x-mod;}		// [0 , 2*mod-1] -> [0 , mod-1]
	static ModInt make(const uint &x){ModInt m; m.v=x; return m;}
	ModInt operator+(const ModInt& b) const { return make(normS(v+b.v));}
	ModInt operator-(const ModInt& b) const { return make(normS(v+mod-b.v));}
	ModInt operator-() const { return make(normS(mod-v)); }
	ModInt operator*(const ModInt& b) const { return make((ull)v*b.v%mod);}
	ModInt operator/(const ModInt& b) const { return *this*b.inv();}
	ModInt& operator+=(const ModInt& b){ return *this=*this+b;}
	ModInt& operator-=(const ModInt& b){ return *this=*this-b;}
	ModInt& operator*=(const ModInt& b){ return *this=*this*b;}
	ModInt& operator/=(const ModInt& b){ return *this=*this/b;}
	ModInt& operator++(int){ return *this=*this+1;}
	ModInt& operator--(int){ return *this=*this-1;}
	ll extgcd(ll a,ll b,ll &x,ll &y) const{
		ll p[]={a,1,0},q[]={b,0,1};
		while(*q){
			ll t=*p/ *q;
			rep(i,3) swap(p[i]-=t*q[i],q[i]);
		}
		if(p[0]<0) rep(i,3) p[i]=-p[i];
		x=p[1],y=p[2];
		return p[0];
	}
	ModInt inv() const {
		ll x,y;
		extgcd(v,mod,x,y);
		return make(normS(x+mod));
	}
	ModInt pow(ll p) const {
		if(p<0) return inv().pow(-p);
		ModInt a = 1;
		ModInt x = *this;
		while(p){
			if(p&1) a *= x;
			x *= x;
			p >>= 1;
		}
		return a;
	}
	bool operator==(const ModInt& b) const { return v==b.v;}
	bool operator!=(const ModInt& b) const { return v!=b.v;}
	friend istream& operator>>(istream &o,ModInt& x){
		ll tmp;
		o>>tmp;
		x=ModInt(tmp);
		return o;
	}
	friend ostream& operator<<(ostream &o,const ModInt& x){ return o<<x.v;}
};
using mint = ModInt<1000000007>;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	string s;
	cin >> s;
	V<mint> cur(13);
	cur[0] = 1;
	for(char c: s){
		V<mint> nxt(13);
		rep(i,13){
			if(c == '?'){
				rep(d,10){
					nxt[(i*10+d)%13] += cur[i];
				}
			}else{
				nxt[(i*10+c-'0')%13] += cur[i];
			}
		}
		swap(cur,nxt);
	}
	cout << cur[5] << endl;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
ll n, cnt, ans, tmp, sum, minimum, maximum, a, b, c, d, k, m, h, w, q, x, y;
string s, t;

int main() {
    cin >> n;
    for (int i = 0; i <= 100; i++) {
        for (int j = 0; j <= 100; j++) {
            if (i * 7 + j * 4 == n) {
                MSG("Yes")
                exit(0);
            }
        }
    }
    MSG("No")
}


Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    rep(i, n) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3508
#include <stdio.h>
#include <iostream>
#define INF 100000000
using namespace std;
typedef pair<int,int> P;
int main()
{
	for(int i=0;i<3;i++){
		int h,m,s,h2,m2,s2;cin>>h>>m>>s>>h2>>m2>>s2;
		int as=3600*(h2-h)+60*(m2-m)+(s2-s);
		int ah=as/3600;as-=ah*3600;
		int am=as/60;as-=am*60;
		printf("%d %d %d\n",ah,am,as);
	}
}

Measured memory_bytes: 1140
from collections import defaultdict

n = int(input())
M = []
for i in range(n):
    x, y = map(int, input().split())
    M.append([x, y])
M.sort(key=lambda x: (x[0], x[1]))
X = defaultdict(int)
for i in range(n - 1):
    for j in range(i + 1, n):
        a = M[i][0] - M[j][0]
        b = M[i][1] - M[j][1]
        X[(a, b)] += 1
print(n - max(X.values(), default=0))

Measured memory_bytes: 3572
#include "bits/stdc++.h"
using namespace std;


int main() {
    vector< int> v(3);
    for (int &a : v) cin >> a;
    sort(v.begin(), v.end());
    int res = 0;
    while (v[0] != v[2]) {
        res++;
        if (v[1] != v[2]) v[0] ++, v[1] ++;
        else v[0] += 2;
        sort(v.begin(), v.end());
    }
    printf("%d\n", res);
}

Measured memory_bytes: 256
import copy

H,W=map(int,input().split())
s=[['#']*(W+2)]
for i in range(H):
    s.append(['#']+list(input())+['#'])
s.append(['#']*(W+2))
#print(s)

c=copy.deepcopy(s)

L=[]
for i in range(H+2):
    for j in range(W+2):
        if c[i][j]!='#':
            L.append([i+1,j+1])

#print(L)

from collections import deque

def move(yxc):
    global Q
    y,x,cost=yxc[0],yxc[1],yxc[2]
    if c[y+1][x]=='.':
        c[y+1][x]=cost+1
        Q.append([y+1,x,cost+1])
    if c[y-1][x]=='.':
        c[y-1][x]=cost+1
        Q.append([y-1,x,cost+1])
    if c[y][x+1]=='.':
        c[y][x+1]=cost+1
        Q.append([y,x+1,cost+1])
    if c[y][x-1]=='.':
        c[y][x-1]=cost+1
        Q.append([y,x-1,cost+1])

ans=0
for i in range(len(L)):
    sx,sy=L[i][1],L[i][0]
    c=copy.deepcopy(s)
    Q=deque([[sy-1,sx-1,0]])
    c[sy-1][sx-1]='S'
    u=0
    while len(Q)>0:
        q=Q.popleft()
        move(q)
        u=max(q[2],u)
#    print(sx,sy)
#    print(c)
#    print(u)
    ans=max(ans,u)

print(ans)


Measured memory_bytes: 3572
#include <stdio.h>
#include <string.h>
int main (){
    int a;
    char c[101];
    scanf("%d " , &a);
    scanf("%s" , c);
    int len = strlen(c);
    if (len <= a) {
        printf("%s\n", c);
    }
    else {
        for (int i = 0; i < a; i++){
            printf("%c", c[i]);
        }
        printf("...\n");
    }
    return 0;
}

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


int main(){
    int t;
    string num;
    while(cin>>t>>num,t!=0 || num!="0"){
        vector<vector<int>> dp(num.size()+1,vector<int>(t+1,0));
        dp[0][0]=1;
        for(int i=0;i<num.size();i++){
            for(int j=0;j<=t;j++){
                for(int k=i+1;k<=num.size();k++){
                    //cut num[i,k)
                    int cutnum=stoi(num.substr(i,k-i));
                    if(cutnum+j<=t) dp[k][j+cutnum]+=dp[i][j];
                }
            }
        }
        for(int i=t;i>=-1;i--){
            if(i==-1){
                cout<<"error"<<endl;
                break;
            }
            if(dp[num.size()][i]){
                if(dp[num.size()][i]>=2){
                    cout<<"rejected"<<endl;
                }
                else{
                    vector<string> res;
                    int pos=num.size();
                    int val=i;
                    while(pos>0){
                        for(int j=0;j<pos;j++){
                            //cut num[j,pos)
                            int v=stoi(num.substr(j,pos-j));
                            if(val-v>=0 && dp[j][val-v]==1){
                                res.push_back(num.substr(j,pos-j));
                                pos=j;
                                val-=v;
                                break;
                            }
                        }
                    }
                    cout<<i<<" ";
                    reverse(res.begin(),res.end());
                    for(int j=0;j<res.size();j++){
                        cout<<res[j] <<(j+1==res.size() ? "\n" : " ");
                    }
                }
                break;    
            }
        }
        
    }

    return 0;
}


Measured memory_bytes: 29188
N = int(input())
A = [0]*N
A = list(map(int, input().split()))
total = 1
if 0 in A:
  total = 0
else:
  for i in range(N):
    total = total * A[i]
    if total > 10**18:
      total = -1
      break
print(total)

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

struct Dice
{
	int Top, Front, Right, Left, Back, Bottom;
};


void roll (Dice &d1, int r);
bool isEqual(Dice d1, Dice d2);

int main()
{
	int n;
	cin >> n;
	Dice d[101];
	for (int i = 0; i < n; i++)
	{
		cin >> d[i].Top >> d[i].Front >> d[i].Right >> d[i].Left >> d[i].Back >> d[i].Bottom;
	}
	bool ok = true;
	for (int i = 0; i < n; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
		    int m = 0;
			while (d[i].Top != d[j].Top || d[i].Front != d[j].Front)
			{
			    roll(d[i], rand()%4);
			    roll(d[j], rand()%4);
			    m++;
			    // 20回ロールしても一致にならない
			    if (m > 20)
			        break;
			}
				
			if (isEqual(d[i], d[j]))
			{
				ok = false;
				break;
			}
		}
		if (!ok)
			break;
	}
	if (ok)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

void roll (Dice &d1, int r)
{
	switch (r)
		{
			case 0:	  swap(d1.Top, d1.Back); 
					  swap(d1.Back, d1.Bottom);
					  swap(d1.Bottom, d1.Front);
					  break;
			case 1:	  swap(d1.Top, d1.Front);
					  swap(d1.Front, d1.Bottom);
					  swap(d1.Bottom, d1.Back);
					  break;
			case 2:   swap(d1.Top, d1.Left);
					  swap(d1.Left, d1.Bottom);
					  swap(d1.Bottom, d1.Right);
					  break;
			case 3:   swap(d1.Top, d1.Right);
					  swap(d1.Right, d1.Bottom);
					  swap(d1.Bottom, d1.Left);
					  break;
		}
}

bool isEqual(Dice d1, Dice d2)
{
    if (d1.Top != d2.Top)
        return false;
    else if (d1.Front != d2.Front)
        return false;
	else if (d1.Right != d2.Right)
		return false;
	else if (d1.Left != d2.Left)
		return false;
	else if (d1.Back != d2.Back)
		return false;
	else if (d1.Bottom != d2.Bottom)
		return false;
	return true;
}



Measured memory_bytes: 3096
import numpy as np

N, X = map(int, input().split())
L = list(map(int, input().split()))
# D = [np.array([])]
D = [0, 0]

for i in range(2, N + 2):
    D.append(D[i - 1] + L[i - 2])

D2 = np.array(D)

D3 = D2[D2 <= X]    # numpyを使ってX以下の要素を抽出

print('{}'.format(D3.size - 1))    # 回数を出力(D3[0]は不要なのでｰ1)



Measured memory_bytes: 12504
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    string s, t;
    cin >> s >> t;
    if(t.substr(0, s.size()) == s) {
        cout << "Yes\n";
    }
    else
        cout << "No\n";
    


  
    return 0;
}



Measured memory_bytes: 3640
import java.util.Arrays;
import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
      int x = sc.nextInt();
      int a = sc.nextInt();
      if(x<a){
        System.out.println(0);
      }else{
        System.out.println(10);
      }

  }
}



Measured memory_bytes: 22612
#include<stdio.h>
#include<string.h>
#define N 1001
void length(char*,char*);
int main(){
  char x[N],y[N];
  int n,i;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s %s",x,y);
    length(x,y);
  }
  return 0;
}
void length(char *x,char *y){
  int s[N][N];
  int i,j,n,m;

  m=strlen(x);
  n=strlen(y);
  for(i=1;i<=m;i++)
    s[i][0]=0;
    for(j=0;j<=n;j++)
      s[0][j]=0;
    for(i=1;i<=m;i++){
      for(j=1;j<=n;j++){
      if(x[i-1]==y[j-1])s[i][j]=s[i-1][j-1]+1;
      else if(s[i-1][j]>=s[i][j-1]) s[i][j]=s[i-1][j];
      else  s[i][j]=s[i][j-1];
    }
  }
    printf("%d\n",s[m][n]);
  }




Measured memory_bytes: 5624
// dp[i]=min cost occured to reach ith position


#include<bits/stdc++.h>

using namespace std;

int main(){
    int n, k;
    cin>>n>>k;
    vector<int> A(n);
    for(int i=0;i<n;i++){
        cin>>A[i];
    }

    vector<int> dp(n);
    for(int i=1;i<n;i++){
        dp[i]=INT_MAX;
        // we are sure that the inner loop will run atleast once
        for(int j=1;j<=k;j++){
            if(i-j>=0)
                dp[i]=min(dp[i], dp[i-j]+abs(A[i]-A[i-j]));
            else
                break;
        }
    }

    cout<<dp[n-1]<<endl;
    
}

Measured memory_bytes: 4052
#include<stdio.h>

int main(void)
{
  long long min=10000;
  long long l,r;
  scanf("%lld %lld",&l,&r);


  for(long long i=l;i<r;i++){
    for(long long j=l+1;j<=r;j++){

      if((i*j)%2019==0&&i<j){
        puts("0");
        return 0;
      }
      if((i*j)%2019<min&&i<j){
        min=(i*j)%2019;
      }
    }
  }

  printf("%lld\n",min);
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define all(a) (a).begin(), (a).end()


int main() {
    string s;
    cin >> s;
    string m = s.substr(5, 2);
    if(m == "01" or m == "02" or m == "03" or m == "04") printf("Heisei\n");
    else printf("TBD\n");
}


Measured memory_bytes: 3596
n = int(input())
S = ['']*n
alphabet = 'abcdefghijklmnopqrstuvwxyz'
cnt = [[0]*n for _ in range(26)]
for i in range(n):
    S[i] = input()
    for j in range(26):
        cnt[j][i] = S[i].count(alphabet[j])
ans = ''
for i in range(26):
    ans += alphabet[i]*min(cnt[i])
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<math.h>
//#inclde<map>                                                                                                         
using namespace std;

int main()
{
  // 入力                                                                                                              
  double A, B, T;
  cin >> A >> B >> T;

  int ans = 0;

  ans = (int)floor((T+0.5)/A)*B;

  //出力                                                                                                               
  cout << ans << endl;

  return 0;
}

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

int main (){    
    int X;
    cin>>X;
    int Y=pow(X, 0.5);
  	bool check=true;
  	vector<int> pr(0);
    int Siz=0;
  	for(int i=2; i<= Y; i++){
      	if(pr.size()==0){
              pr.push_back(i);
              Siz ++;
          }
          else{
              bool t=true;
              for(int j=0; j<Siz; j++){
                  if(i%pr[j]==0){
                      t=false;
                      break;
                  }
              }
              if(t){
                pr.push_back(i);
                Siz ++;
              }
          }
    }
    while(check){
      	check=false;
        for(int i=0; i<Siz; i++){
            if(X%pr[i]==0){
              	check=true;
                break;
            }
        }
      	X ++;
        
    }
    cout<<X-1;
  	//cout<<Y;
}




Measured memory_bytes: 256
import Data.Int (Int64)

factmod :: Integral a => a -> a -> a
factmod p n = foldr1 (\x y -> x * y `mod` p) [1 .. n] `mod` p

solve :: Integral a => a -> a -> a -> a
solve p n m
    | n > m = solve p m n
    | m - n > 1 = 0
    | m == n = 2 * f m * f n `mod` p
    | otherwise = f m * f n `mod` p
    where f = factmod p

main :: IO ()
main = do
    let p = 1000000007 :: Int64
    [n, m] <- fmap read . words <$> getLine :: IO [Int64]
    print $ solve p n m


Measured memory_bytes: 7292
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n;cin>>n;
  string s1;cin>>s1;
  string s2;cin>>s2;
  ll ans=1;
  rep(i,n){
    if(i==0){
      if(s1[i]==s2[i])ans*=3;
      else {
        ans*=6;
        i++;
      }
      continue;
    }
    else {
      if(s1[i]==s2[i]){
        if(s1[i-1]!=s2[i-1])ans*=1;
        else ans*=2;
      }
      else {
        if(s1[i-1]!=s2[i-1])ans*=3;
        else ans*=2;
        i++;
      }
    }
    ans%=MOD;
  }
  cout<<ans<<endl;
}
      

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) {
        cin >> v[i];
        v[i]--;
    }

    int ans = 0;
    int now = 0;
    vector<bool> visit(n);

    while(now != 1) {
        if (visit[now]) {
            ans = -1;
            break;
        }
        visit[now] = true;
        now = v[now];
        ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;
public class Main {
	public static void main(String[] args){
    //データ取り込み
		Scanner sc = new Scanner(System.in);
		//String S = sc.next();
    //int B = sc.nextInt();
    //System.out.println();
		int A = sc.nextInt();
		int B = sc.nextInt();

		if((A+B)%2==0){
			System.out.println((A+B)/2);
		}else{
			System.out.println((A+B)/2+1);
		}
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <string.h>
#include <numeric>
using namespace std;

#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(i,v) for(auto &(i):(v))
#define eachr(i,v) for(auto &(i)=(v).rbegin();(i)!=(v).rend();(i)++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define bln(i,n) (((i)==(n)-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln<<flush
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ')<<flush;}}
#define zero(a) memset(a,0,sizeof(a))
#define unq(a) sort(all(a)),a.erase(unique(all(a)),a.end())

//typedef complex<double> P;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b,ll m=mod) {ll r=1;a%=m;for(;b;b>>=1){if(b&1)r=r*a%m;a=a*a%m;}return r;}
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;}
bool ool(int x,int y,int h,int w) {return((x<0)||(h<=x)||(y<0)||(w<=y));}
bool deq(double a,double b) {return abs(a-b)<eps;}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;



// 最後に残した花がi番目のときの最大値 で普通に遷移するとO(N^2)

int n, h[200200], a[200200], res;

// RMQ<型> rmq(サイズ);
template<typename V> struct RMQ {
	private:
	int n;
	vector<V> node;
	public:
	explicit RMQ(int sz) {
		n = 1;
		while(n<sz) n *= 2;
		node.resize(2*n-1, 0);
	}
	void update(int x, V val) {
		x += n-1, node[x]=val;
		while (x>0) x = (x-1)/2, node[x] = max(node[2*x+1], node[2*x+2]);
	}
	V query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r<0) r = n;
		if (r<=a || b<=l) return 0;
		if (a<=l && r<=b) return node[k];
		return max(query(a,b,2*k+1,l,(l+r)/2), query(a,b,2*k+2,(l+r)/2,r));
	}
};

RMQ<int> rmq(200200);

signed main() {
	cin >> n;
	rep(i,n) cin >> h[i];
	rep(i,n) cin >> a[i];
	rep(i,n) {
		a[i] += rmq.query(0,h[i]);
		chmax(res, a[i]);
		rmq.update(h[i], a[i]);
	}
	cout << res << endl;
}

Measured memory_bytes: 7552
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<deque>
#include<iomanip>
#include<set>
#include<unordered_set>
#include<tuple>
#include<map>
#include<memory>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<double> VD;
typedef pair<int, int> P1;
typedef long long int ll;

//number
#define INF 1e9
#define NUM 1000000007

//itr
#define all(x) begin(x),end(x)

//repeat
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define RREPS(i,x) for(int i=((int)(x));i>=0;i--)

//max,min
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))

//function

/*ll gcd(ll a, ll b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}*/

/*ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a * (b / g);
}*/

/*int dig(int a) {
	int sum = 0;
	while (a) {
		sum += a % 10;
		a /= 10;
	}
	return sum;
}*/

//grid template
int x[] = { -1, 0, 1, 0 };
int y[] = { 0,-1,0,1 };
int xx[] = { -1,-1,1,1 };
int yy[] = { 1,-1,1,-1 };

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

	rep(i, n+1) {
		rep(j, n - i+1) {
			rep(k, n - j - i+1) {
				if (i * 10000 + j * 5000 + k * 1000 == y) {
					if (i + j + k == n) {
						cout << i << " " << j << " " << k << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << -1 << " " << -1 << " " << -1 << endl;
}


 

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
  int n,a,i,j,res=50;
  cin >> n;
  for(i=0;i<n;i++){
    cin >> a;
    j=0;
    while(a%2==0&&j<res){
      a/=2;
      j++;
    }
    res=min(res,j);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

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


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int a;
	cin>>a;
	cout<<48-a;
}

	


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


int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int count = 0;
    bool flag = true;
    while (flag) {
        rep(i, n) {
            if (v[i] % 2 == 1) {
                flag = false;
                break;
            }
            v[i] /= 2;
        }
        if (flag) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3624
N, M = map(int,input().split())
listH = list(map(int, input().split()))

listM = [list(map(int, input().split())) for i in range(M)]

listC = [1 for i in range(N)]

for pair in listM:
    if listH[pair[0]-1] > listH[pair[1]-1]:
        listC[pair[1]-1] -= 1
    elif listH[pair[0]-1] < listH[pair[1]-1]:
        listC[pair[0]-1] -= 1
    else:
        listC[pair[1]-1] -= 1
        listC[pair[0]-1] -= 1
        
cnt = 0

for i in listC:
    if i == 1:
        cnt += 1
        
print(cnt)

Measured memory_bytes: 31956
#include <iostream>
#include <vector>
#include <queue>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
#define INF 10000000000000000LL
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

struct state {
  ll v, d;

public:
  bool operator<(const state &s) const {
    return d > s.d;
  }
};

ll N, A, B, C;
vector<pll> E[100000];
ll Q, K, X[100000], Y[100000];

int main(void) {
  cin >> N;
  REP(i, 0, N - 1) {
    cin >> A >> B >> C, A--, B--;
    E[A].push_back(pll(B, C));
    E[B].push_back(pll(A, C));
  }
  cin >> Q >> K, K--;
  REP(i, 0, Q) cin >> X[i] >> Y[i], X[i]--, Y[i]--;

  ll dp[100000];
  REP(i, 0, N) dp[i] = INF;
  priority_queue<state> q;
  q.push((state) { K, 0 });
  while(q.size()) {
    state c = q.top();
    q.pop();

    if(dp[c.v] <= c.d) continue;
    dp[c.v] = c.d;

    REP(i, 0, E[c.v].size()) {
      if(dp[E[c.v][i].fi] > c.d + E[c.v][i].se) {
        q.push((state) { E[c.v][i].fi, c.d + E[c.v][i].se });
      }
    }
  }

  REP(i, 0, Q) {
    cout << dp[X[i]] + dp[Y[i]] << endl;
  }
}


Measured memory_bytes: 12656
// D - Road to Millionaire
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int64_t yen = 1000, stock = 0;
	int nxt; cin>>nxt;
	while(--N){
		int now = nxt; cin>>nxt;
		if(now < nxt){
			stock += yen / now;
			yen -= yen / now * now;
		}
		else{
			yen += stock * now;
			stock = 0;
		}
	}
	yen += stock * nxt;
	cout<< yen <<endl;
}


Measured memory_bytes: 3576
#! /usr/bin/env python3

H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
C = []
for i, j in enumerate(A):
    C += [str(i+1)] * j
for i in range(H):
    if i % 2 == 0:
        print(' '.join(C[i*W : i*W+W]))
    else:
        print(' '.join(C[i*W : i*W+W][::-1]))

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

using namespace std;

int main(){
    string s;
    while(cin >> s) {
        if(s == "0") {
            break;
        }
        int sum = 0;
        for(int i = 0; i < s.length(); i++)
        {
            sum += s[i] - '0';
        }
        
        cout << sum << endl;
    }
    
}


Measured memory_bytes: 3168