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

using namespace std;

#define int long long
vector < pair < int, int > > g[2505];
int dist[2505];
int inf = -1e17;
int dist1[2505];

main() {
    //freopen("input.txt", "r", stdin):
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, m, u, v, c, p;
    cin >> n >> m >> p;
    for (int i = 1; i <= m; ++i) {
        cin >> u >> v >> c;
        c -= p;
        g[u].push_back({v, c});
    }
    for (int i = 1; i <= n; ++i) dist[i] = inf;
    dist[1] = 0;
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (auto to : g[j]) {
                dist[to.first] = max(dist[to.first], dist[j] + to.second);
            }
        }
    }
    for (int i = 1; i <= n; ++i) dist1[i] = dist[i];
    for (int i = 1; i <= 3 * n; ++i) {
        for (int j = 1; j <= n; ++j) {
            for (auto to : g[j]) {
                dist[to.first] = max(dist[to.first], dist[j] + to.second);
            }
        }
    }
    if (dist[n] != dist1[n]) cout << -1 << '\n';
    else cout << max(dist[n], (long long)0) << '\n';
    return 0;
}



Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<functional>
#include <string>
#include<iomanip>
#include<cstdio>
#include<math.h>
#include<stack>
#include<queue>
#include<cstring>
#include<vector>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EREP(i,n) for(int i=(n-1);i>=0;--i)
#define D(n,retu) REP(i,n){cin>>retu[i];}
#define mod 1000000007
#define MIN -93193111451418101
#define INF 931931114518101
using namespace std;
typedef long long int ll;
template<typename T>
void fill_all(T& arr, const T& v) {
	arr = v;
}
template<typename T, typename ARR>
void fill_all(ARR& arr, const T& v) {
	for (auto& i : arr) { fill_all(i, v); }
}
#define MAX_NUM 50
long long comb[MAX_NUM + 1][MAX_NUM + 1];

ll par[100000], depth[100000];
static void calc_comb()
{
	for (uint32_t i = 0; i <= MAX_NUM; i++) {
		for (uint32_t j = 0; j <= i; j++) {
			if ((j == 0) || (i == j)) {
				comb[i][j] = 1;
			}
			else {
				comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
			}
		}
	}
}


//------------------変数-----------------------//
	ll h, w, a, b;
//-------------------関数----------------------//
ll yojou(ll a, ll b, ll p) {//aのb乗をpで割ったあまりを計算する関数
	if (b == 0) { return 1; }//0乗は1
	if (b % 2 == 0) {//２の倍数なら省略できて
		ll d = yojou(a, b / 2, p);//わるう
		return (d*d) % p;//２割ったので二乗う
	}
	return a*yojou(a, b - 1, p) % p;//２で割れないなら一個進める
}

ll combinationwithmod(ll h, ll w) {//h,wは点の数ではなく辺の数です
	ll cnt = 1;
	if (w < h) { swap(w, h); }
	for (int i = w + 1; i <= w + h; i++)
	{
		cnt = cnt * i%mod;
	}
	for (int i = 1; i <= h; i++)
	{
		cnt = cnt*yojou(i, mod - 2, mod) % mod;
	}return cnt;
}

int main() {
	string k; cin >> k;
	ll s = k.size();
	REP(i, s - 1) { if (k[i] == k[i + 1]) { cout << i + 1 << " " << i + 2 << endl; return 0; } }
	REP(i, s - 2) { if (k[i] == k[i + 2]) { cout << i + 1 << " " << i + 3 << endl; return 0; } }
	cout << "-1 -1" << endl;
	return 0;
}

Measured memory_bytes: 512
n, m = gets.chomp.split.map(&:to_i)
list = []
m.times do |i|
  s = gets.chomp.split.map(&:to_i)
  k = s.shift
  list[i] = [0] * n
  k.times do |j|
    list[i][s[j]-1] = 1
  end
end

p = gets.chomp.split.map(&:to_i)

count = 0
[0, 1].repeated_permutation(n) do |s|
  m.times do |i|
    break if list[i].zip(s).map{ |listi, si| listi * si }.reduce(&:+)%2 != p[i]
    count += 1 if i == m-1
  end
end

puts(count)

Measured memory_bytes: 1788
def main():
	N = int(input())
	A = [0]*N
	MOD = 998244353
	summation = 0

	for i in range(N):
		A[i] = int(input())
		summation += A[i]

	# dp[i][j] represents sum of red is j at i position
	dp = [[0 for _ in range(summation+1)] for _ in range(N)]
	dp[0][0] = 2 # green or blue
	dp[0][A[0]] = 1 # red

	for i in range(1, N):
		for j in range(len(dp[i])):
			dp[i][j] += dp[i-1][j] * 2 % MOD # don't use A[i] for red, i.e. use green or blue
			dp[i][j] += dp[i-1][j-A[i]] % MOD if 0 <= j - A[i] <= len(dp[i]) else 0 # use i red

	# total
	ans = (3 ** N) % MOD
	ceil = summation // 2
	if summation % 2 != 0:
		ceil += 1
	ans -= sum([dp[N-1][r] for r in range(ceil, summation+1)])*3
	ans %= MOD

	if summation %2 == 0:
		# case r = g = S/2
		dp  =[[0 for _ in range(summation//2+1)] for _ in range(N)]
		dp[0][0] = 1 # only blue
		dp[0][A[0]] = 1
		for i in range(1, N):
			for j in range(len(dp[i])):
				dp[i][j] += dp[i-1][j] % MOD
				dp[i][j] += dp[i-1][j-A[i]] % MOD if 0 <= j-A[i] <= len(dp[i]) else 0
		ans += dp[N-1][summation//2]*3
		ans %= MOD

	print(ans)


if __name__ == '__main__':
    main()

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

int main(){
	LL n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	n--;
	LL r = n*(d-c);
	b -= a;
	b += n*d;
	int ok = 0;
	LL f = c+d;
	for(LL i = 0; i <= n; i++){
		if((b-i*f >= 0) && (b - i*f) <= r){
			ok = 1;
		}
	}
	cout << (ok ? "YES" : "NO") << endl;
}


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

#define int long long int

int32_t main()
{
    int n;
    cin>>n;
  int ans=0;
    map<int,int> m;
    for(int i=0;i<n;i++)
    {
        cin>>ans;
        m[ans]++;
    }
    ans=0;
    for(auto i:m)
    if(i.second%2)
    ans++;

    cout<<ans<<endl;
}

Measured memory_bytes: 9820
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <cstdio>

int fact(int k) {
	int w = 1;
	for (int i = 2; i <= k; i++)
		w *= i;
	return w;
}

int main() {
	double sum = 0;
	std::vector<int> k;
	int n, x, y;
	std::cin >> n;
	std::vector<std::pair<int, int>> v(n);
	for (int i = 0; i < n; i++) {
		std::cin >> x >> y;
		v[i].first = x, v[i].second = y;
		k.push_back(i);
	}
	for (int i = 0; i < n - 1; i++) {
		sum += std::sqrt((v[k[i]].first - v[k[i + 1]].first) * (v[k[i]].first - v[k[i + 1]].first) +
			(v[k[i]].second - v[k[i + 1]].second) * (v[k[i]].second - v[k[i + 1]].second));
	}
	while (std::next_permutation(k.begin(), k.end())) {
		for (int i = 0; i < n - 1; i++) {
			sum += std::sqrt((v[k[i]].first - v[k[i + 1]].first) * (v[k[i]].first - v[k[i + 1]].first) +
				(v[k[i]].second - v[k[i + 1]].second) * (v[k[i]].second - v[k[i + 1]].second));
		}
	}
	printf("%.10f", sum / fact(n));
	return 0;
}


Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
vector < int > v;
int main(){

    int a,n,i,b,cnt=0,ans;
    cin>>n;
    for(i=1; i<=n; i++){
        cin>>a;

        while(a%2==0){
            cnt++;
            a/=2;
        }

    }

    cout<<cnt<<endl;





    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
ll dp[110][110000];
ll w[110],v[110];

int main(){cout<<fixed<<setprecision(10);
		   int n,W;
           cin>>n>>W;
           rep(i,1,n+1){
             cin>>w[i]>>v[i];
           }
           rep(i,1,n+1){
             rep(j,0,W+1){
               dp[i][j]=dp[i-1][j];
               if(j-w[i]>=0)chmax(dp[i][j],dp[i-1][j-w[i]]+v[i]);
             }
           }
           cout<<dp[n][W]<<endl;
}

Measured memory_bytes: 82048
#include<stdio.h>
#define max(x,y) ((x)>(y)?(x):(y))
int main(){
  int n,g,h,m,M=0,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    g=h;
    scanf("%d",&h);
    if(!i)
      m=0;
    else if(h<=g)
      m++;
    else{
      M=max(M,m);
      m=0;
    }
  }
  printf("%d\n",max(M,m));
  return 0;}


Measured memory_bytes: 128
package main
import (
  "fmt"
)

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

func main() {
  var a, b, c, d int
  fmt.Scan(&a, &b, &c, &d)
  var result string
  if diff(a, c) <= d || (diff(a, b) <= d && diff(b, c) <= d) {
  	result = "Yes"
  } else {
    result = "No"
  }
  fmt.Println(result)
  
}

Measured memory_bytes: 512
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    String s = sc.next();
    String t = sc.next();

    sc.close();
    
    String[] S = s.split("");
    String[] T = t.split("");

    int count = 0;

    for (int i = 0; i < 3; i++) {
      if (S[i].equals(T[i])) {
        count++;
      }
    }

    System.out.println(count);

  }

}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;

const int N=2e5+1;
int n, off, p[N], v[N], tr[2][1<<19];
char s[N];
int query(int *tr, int l) {
	int res=-1e9;
	for(l+=off; l; l/=2) if(~l&1) cmax(res, tr[l^1]);
	return res;
}
void modify(int *tr, int x, int v) {
	tr[x+=off]=v;
	while(x/=2) tr[x]=std::max(tr[2*x], tr[2*x+1]);
}
bool check(int x, int y) {
	return x>=0&&x<=query(tr[x&1], y);
}
int main() {
	int q=0, max[2]={}, cnt[2]={};
	n=rd();
	for(int i=1, max=0; i<=n; ++i) q+=v[i]=cmax(max, p[i]=rd());
	for(off=1; off<=n; off*=2);
	memset(tr[1], 192, 2*off*sizeof(int));
	for(int i=n; i>=1; --i) {
		int f[2];
		for(int j=0; j<2; ++j) f[j]=query(tr[j^v[i]^1], p[i])+v[i]+1;
		for(int j=0; j<2; ++j) modify(tr[j], p[i], f[j]);
	}
	if(!check(q, 0)) {
		puts("-1");
		return 0;
	}
	for(int i=1; i<=n; ++i) {
		int delta=cnt[1]-cnt[0]-(p[i]>max[0]);
		modify(tr[0], p[i], 0);
		modify(tr[1], p[i], -1e9);
		q-=v[i];
		int ans=!(check(q+delta, std::max(max[0], p[i]))||check(q-delta, max[1]));
		cnt[ans]+=cmax(max[ans], p[i]);
		s[i-1]=ans+'0';
	}
	puts(s);
	return 0;
}


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3005;
long long dp[maxn][maxn][2], vis[maxn][maxn][2], a[maxn];

long long dfs(int l, int r, int ty){
    if(l == r) return ty ? a[l] : -a[l];
    if(vis[l][r][ty]) return dp[l][r][ty];
    vis[l][r][ty] = 1;
    if(ty){
        return dp[l][r][ty] = max(dfs(l+1, r, ty^1) + a[l], dfs(l, r-1, ty^1) + a[r]);
    } else {
        return dp[l][r][ty] = min(dfs(l+1, r, ty^1) - a[l], dfs(l, r-1, ty^1) - a[r]);
    }
}
int n;
int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++) cin>>a[i];
    cout<<dfs(1, n, 1)<<endl;
}


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

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

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

  vector<ll> a(n);
  for (ll i = 0; i < n; ++i) {
    cin >> a[i];
  }

  ll cnt = 0;
  for (ll i = 0; i < n; ++i) {
    if (a[i] < 0) cnt++;
  }

  ll ans = 0;
  if (cnt % 2 == 0) {
    for (ll i = 0; i < n; ++i) {
      ans += abs(a[i]);
    }
  } else {
    for (ll i = 0; i < n; ++i) {
        a[i] = abs(a[i]);
    }
    sort(a.begin(), a.end());
    ans -= a[0];
    for (ll i = 1; i < n; ++i) {
      ans += a[i];
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1024
# 2019-11-28 00:36:19(JST)
import sys
import numpy as np 
def main():
    n = int(sys.stdin.readline().rstrip())
    ab = np.array(sys.stdin.read().split(), dtype=np.int64)
    a = ab[::2]
    b = ab[1::2]
    
    cnt = 0
    for i in range(n-1, -1, -1):
        x = a[i] + cnt
        y = b[i]
        if x % y != 0:
            cnt += y - x % y
    
    print(cnt)

if __name__ == '__main__':
    main()


Measured memory_bytes: 37276
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))

N,A,B,C=rl()
l=[0]*N
for i in range(N):
    l[i] = ri()
ans = float('inf')
for n in range(4**N):
    a,b,c=0,0,0
    ans_ = 0
    for i in range(N):
        sn = format(n>>(2*i),'0{}b'.format(N))[-2:]
        if sn=='01':
            a+=l[i]
            ans_ += 10
        elif sn=='10':
            b+=l[i]
            ans_ += 10
        elif sn=='11':
            c+=l[i]
            ans_ += 10
    if a!=0 and b!=0 and c!=0:
        ans_ += abs(A-a)+abs(B-b)+abs(C-c) -30
        if ans > ans_:
            ans = ans_

print(ans)

Measured memory_bytes: 3188
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto Q = readln.chomp.to!int;
    foreach (_; 0..Q) {
        auto X = readln.chomp;
        auto Y = readln.chomp;

        auto DP = new int[][](X.length, Y.length);
        foreach_reverse (i; 0..X.length) {
            foreach_reverse (j; 0..Y.length) {
                if (X[i] == Y[j]) {
                    DP[i][j] = max(
                        DP[i][j],
                        (i+1 != X.length && j+1 != Y.length ? DP[i+1][j+1] : 0) + 1
                    );
                } else {
                    DP[i][j] = max(
                        i+1 != X.length ? DP[i+1][j] : 0,
                        j+1 != Y.length ? DP[i][j+1] : 0
                    );
                }
            }
        }
        writeln(DP[0][0]);
    }
}


Measured memory_bytes: 23728
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long 
#define FI first 
#define SE second
#define pb push_back 
#define eb emplace_back
#define mod 1000000007
#define all(c) (c).begin(),(c).end()
#define LB  lower_bound
#define UB  upper_bound
#define max3(a,b,c) max(c,max(a,b))
#define min3(a,b,c) min(c,min(a,b))
#define mems(s, n) memset(s, n, sizeof(s))
#define NINF INT_MIN 
#define INF INT_MAX 
#define MP make_pair
#define int ll int

typedef pair<int,int> PII;
typedef pair<pair<int,int>,int> PPII;
typedef map<int,int>MII;
typedef vector<int> VI;
const int MAX = 1e4 + 5;
template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

/*int power(int a, int b)
{int x=1,y=a;while(b>0){if(b%2){x =(x*y)%mod;}y =(y*y)%mod;b/=2;}return x%mod;}
*/
//int modInverse(int a, int m) {return power(a, m-2);} //gcd(a,m)=1 
//int root(int x){return x==f[x]?x:f[x]=root(f[x]);}


signed main()
{
ios::sync_with_stdio(false); cin.tie(0);
int T=1,T1=0;//cin>>T;
while(T1++<T)
{
    int n,a,b;
    cin>>n>>a>>b;
    if(a<b)swap(a,b);
    if((a-b)%2==0)cout<<(a-b)/2<<endl;
    else
    {
        if(n-a<b)
        {
            cout<<(n-a)+(a-b+1)/2<<endl;
        }
        else
        {
            cout<<b-1+(a-b+1)/2<<endl;
        }
    }
    
}


return 0;
}





Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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 T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int a,b,c; cin >> a >> b >> c;
    out(max({a,b,c})-min({a,b,c}));

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

int main() {
	int N;
	cin >> N;
	int B[100];
	for (int i = 0; i < N - 1; i++) cin >> B[i];
	int sum = B[0] + B[N - 2];
	for (int i = 0; i + 1 < N - 1; i++) sum += min(B[i], B[i + 1]);
	cout << sum << endl;
}


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

int table[2000][10] = {};//table[0]は参照しない
int str[10] = {};
int univcnt;
void maketable(int floor,int c){
  int i = 0;
  if(floor == 1){
    str[0] = c;
    memcpy(table[univcnt],str,sizeof(table[0]));
    univcnt++;
    /*for(i=0;i<10;i++){
      printf("%d",table[univcnt-1][i]);
    }*/
    //printf("/");
    
  }else{
    str[floor-1] = c;
    maketable(floor-1,0);
    maketable(floor-1,1);
  }
}
    
  
  
int main(){
  int n = 0;
  int f[200][10] = {};
  int i = 0;
  int j = 0;
  int k = 0;
  long p[200][20] = {};
  int kaburi[200] = {};
  long sum = 0;
  long max = 0;
  long maxflag = 0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<10;j++){
      scanf("%d",&f[i][j]);
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<=10;j++){
      scanf("%ld",&p[i][j]);
    }
  }
  
  maketable(10,0);
  maketable(10,1);
  for(i=1;i<univcnt;i++){
    sum = 0;
    for(j=0;j<n;j++){
      kaburi[j] = 0;
      for(k=0;k<10;k++){
        if(table[i][k] == 1 && f[j][k]){
          kaburi[j]++;
        }
      }
      sum += p[j][kaburi[j]];
    }
    if(max < sum || maxflag == 0){
      max = sum;
      maxflag = 1;
    }
  }
  
  printf("%ld",max);
  return 0;
}


Measured memory_bytes: 256
"use strict";
const Main = (input) => {
	let xs = input.trim().split(' ').map(v=>parseInt(v,10));
  	let ans = '';
    if(xs[1] >= xs[2]){
    	ans = 'delicious';
    }else if(xs[0]  >= (xs[2] -xs[1])){
    	ans = 'safe';
    }else{
    	ans = 'dangerous';
    }
    console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));    

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
#define SZ(x) ((int)(x).size())
#define ALL(x) x.begin(), x.end()
#define PB push_back
#define EB emplace_back
using LL = long long;
using PII = pair<int, int>;
#define F first
#define S second
const LL mod = 1000000007;

const int maxn = 5050;
LL pow_mod(LL a, LL p, const LL m) {
  LL ret = 1;
  for (; p; p >>= 1, a = a * a % m)
    if (p & 1)
      ret = ret * a % m;
  return ret % m;
}
LL inv(LL a, LL n) {
  return a < 2 ? a : ((1 - n * 1LL * inv(n % a, a)) / a % n + n) % n;
}
LL frac[maxn], ifrac[maxn];
LL C(int a, int b) {
  return (frac[a] * ifrac[b] % mod) * ifrac[a - b] % mod;
}

int inv_t[maxn];
void inv_table(int n, int mod) {
  inv_t[1] = 1;
  for (int i = 2; i < n; ++i)
    inv_t[i] = (mod - 1LL * (mod / i) * inv_t[mod % i] % mod) % mod;
}
int n, m;

LL g(int sz, int y) {
  LL r = frac[sz - 1] * ifrac[y - 1] % mod;
  r = r * ifrac[sz - y] % mod;
  return r;
}

LL f(int x, int y) {
  if (m + m - x > n + x + y) return 0;
  LL a = g(m, x);
  LL b = g(m - x, y);
  int s = n - (m + m - x - x - y);
  LL r = frac[s + 2] * ifrac[s] % mod;
  r = r * ifrac[2] % mod;
  r = r * (a * b % mod) % mod;
  return r;
}

LL ff(int x) {
  if (m > n + x) return 0;
  LL a = g(m, x);
  int s = n - (m - x);
  LL r = frac[s + 1] * ifrac[s] % mod;
  r = r * a % mod;
  return r;
}

int main() {
  inv_table(maxn, mod);
  frac[0] = 1;
  ifrac[0] = 1;
  for (int i = 1; i < maxn; ++i) {
    frac[i] = frac[i-1] * i % mod;
    ifrac[i] = ifrac[i-1] * inv_t[i] % mod;
  }
  scanf("%d%d", &n, &m);
  LL ans = ff(m);
  for (int i = 1; i <= m; ++i) {
    for (int j = 1; i + j <= m; ++j) {
      ans += f(i, j);
      ans %= mod;
    }
  }
  printf("%lld\n", ans);
  return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())

LL sum[55];
LL dp[55];

LL go(int l, LL a) {
  if (a <= 0) {
    return 0;
  }
  if (l == 0) {
    return 1;
  }
  if (a <= sum[l-1]+1) {
    return go(l-1, a-1);
  }
  return dp[l-1] + 1 + go(l-1, a-sum[l-1]-2);
}

void init() {
  sum[0] = 1;
  FOR(i, 1, 55) {
    sum[i] = sum[i-1]*2 + 3;
  }
  dp[0] = 1;
  FOR(i, 1, 55) {
    dp[i] = dp[i-1]*2 + 1;
  }
}

LL n, x;
void input() {
cin >> n >> x;
}

void solve() {
  cout << go(n, x) << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <time.h>
#include <sys/timeb.h>
#include <cstdio>
#include <sys/time.h>

using namespace std;
#define ll long long
#define uint unsigned int
#define ulong unsigned long long int

template<typename T> bool InRange(T t, T l, T r){ return l <= t && t < r; }

int main(){
	
	int A,B,C;
	cin >> A >> B >> C;
	
	cout << min(C, B / A) << endl;
	
	
	
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int h, w;
int c[10][10];
int a[40000];

int main() {
    scanf("%d %d", &h, &w);
    for (int i = 0; i < 10; i++) {
        for (int j = 0; j < 10; j++) {
            scanf("%d", &c[i][j]);
        }
    }
    for (int i = 0; i < h * w; i++) scanf("%d", &a[i]);
    
    bool update = true;
    while (update) {
        update = false;
        for (int i = 0; i < 10; i++) {
            for (int j = 0; j < 10; j++) {
                for (int k = 0; k < 10; k++) {
                    if (c[i][j] > c[i][k] + c[k][j]) {
                        c[i][j] = c[i][k] + c[k][j];
                        update = true;
                    }
                }
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < h * w; i++) {
        if (a[i] >= 0) ans += c[a[i]][1];
    }

    printf("%d\n", ans);
    return 0;
}


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

int compar(const int *val1, const int *val2) {
	if (*val1 < *val2)  return -1;
	else if(*val1 == * val2)  return 0;
	else return 1;
}

/*
void showScoreList(int s[],int n){
	printf("s = [ ");
	for (int i = 0; i < n; ++i)	printf("%d ", s[i]);
	printf("]\n");
}
*/

int main(int argc, char const *argv[])
{	
	int N,s[100];
	int max = 0,min = 0x7F,pat,sum = 0;
	scanf("%d",&N);

	// Input
	for (int i = 0; i < N; ++i){
		scanf(" %d",&s[i]);
		sum += s[i];
	}

	// Output
	if(sum % 10 != 0){
		printf("%d\n",sum);
		return 0;
	}
	else{
		// showScoreList(s,N);
		qsort(s,N, sizeof(int), (int (*)(const void *, const void *))compar);
		// showScoreList(s,N);
		for (int i = 0; i < N; ++i)
		{
			if(s[i] % 10 != 0){
				sum -= s[i];
				break;
			}
		}
		sum = (sum % 10 == 0) ? 0 : sum;
		printf("%d\n", sum);
	}
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<string>
#include<cctype>
#include<cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<ll> vl;
typedef queue<int> qi;
typedef queue<ll> ql;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define pq priority_queue
#define rep(i,n) for (int i=1;i<=n;++i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define INF 200000009
#define init(x) memset(x,0,sizeof(x))
ll n,a,b,h[100005];
inline bool can(ll k){
	ll cnt=0;
	for (int i=1;i<=n;++i) cnt+= max(h[i]-k*b,0ll)/(a-b) + (h[i]-k*b>0&&(h[i]-k*b)%(a-b)>0);
	return cnt<=k;
}
int main()
{
	ios::sync_with_stdio(false);
	cin>>n>>a>>b;
	for (int i=1;i<=n;++i) cin>>h[i];
	ll l=0,r=1e9;
	while(l<r-1){
		ll mid=(l+r)/2;
		if (can(mid)) r=mid;// wide enough bound
		else l=mid;//too strict bound
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <vector>

using namespace std;

vector<int> input;

int main(){
    int N,M;
    scanf("%d%d",&N,&M);

    int c=0,total=0;
    for(int i=0;i<N;i++){
        int Ai;
        scanf("%d",&Ai);
        input.push_back(Ai);
        total+=Ai;
    }

    for(auto ele:input) if (ele*4*M>=total) c++;

    if (c>=M) puts("Yes");
    else puts("No");

    return 0;
}

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

def main():
    A = input()

    n = len(A)

    next_i = []
    ct = [n] * 26
    orda = ord("a")
    for i in range(n - 1, -1, -1):
        ct[ord(A[i]) - orda] = i
        next_i.append(ct.copy())

    next_i.reverse()

    dp = [0] * (n + 1)
    dp[n] = 1
    j = -1
    for i in range(n - 1, -1, -1):
        ct = next_i[i]
        if max(ct) < n:
            j = i
            break
        else:
            dp[i] = 1

    if j == -1:
        ct = next_i[0]
        for c in range(26):
            if ct[c] == n:
                print(chr(orda + c))
                return

    rt = [0] * n
    for i in range(j, -1, -1):
        ct = next_i[i]
        min_c = 0
        min_v = dp[ct[0] + 1]
        for c in range(1, 26):
            v = dp[ct[c] + 1]
            if v < min_v:
                min_c = c
                min_v = v
        rt[i] = min_c
        dp[i] = min_v + 1


    r = ''
    i = 0
    while i < n:
        if dp[i] == 1:
            for c in range(26):
                if not chr(orda + c) in A[i:]:
                    r += chr(orda + c)
                    break
            break
        r += chr(orda + rt[i])
        i = next_i[i][rt[i]] + 1


    print(r)


if __name__ == '__main__':
    main()



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

using namespace std;

static const int INF = 1e9 + 7;

template<typename T>
using Vec = vector<T>;

template<typename T, typename T2>
using P = pair<T, T2>;

template<typename... Args>
using Tup = tuple<Args...>;

template<typename T>
using qp = priority_queue<T, Vec<T>, greater<T> >;

template<typename T>
using pq = priority_queue<T>;

using llong = long long;
using ullong = unsigned long long;
using uint = unsigned int;

int gcd(int x, int y)
{
	return y ? gcd(y, x % y) : x;
}

string str;

bool check(long long n) {
	return (n & (n - 1)) == 0;
}

void hawawa()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b < c) {
		cout << "No\n";
	}
	else {
		cout << "Yes\n";
	}
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            int n,d;
            cin >> n >> d;
            int count = 0;
            for(int i = 0; i < n; i++)
            {
                int x,y;
                cin >> x >> y;
                if(x*x + y*y <= d*d)
                    count++;
            }
            cout << count << endl;





           return 0;
        }
          

Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

template<class Abel> struct UnionFind {
    vector<int> par;
    vector<int> rank;
    vector<Abel> diff_weight;

    UnionFind(int n = 1, Abel SUM_UNITY = 0) {
        init(n, SUM_UNITY);
    }

    void init(int n = 1, Abel SUM_UNITY = 0) {
        par.resize(n); rank.resize(n); diff_weight.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            diff_weight[x] += diff_weight[par[x]];
            return par[x] = r;
        }
    }

    Abel weight(int x) {
        root(x);
        return diff_weight[x];
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y, Abel w) {
        w += weight(x); w -= weight(y);
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y), w = -w;
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        diff_weight[y] = w;
        return true;
    }

    Abel diff(int x, int y) {
        return weight(y) - weight(x);
    }
};

int main(){
  int N,M;cin>>N>>M;
  UnionFind<int> Uni(N);
  rep(i,M){
    int l,r,d;
    cin>>l>>r>>d;
    l--;r--;
    if(Uni.issame(l,r)){
      if(d != Uni.diff(l,r)){
        cout<<"No"<<endl;
        return 0;
      }
    }
    else{
      Uni.merge(l,r,d);
    }
  }
  cout<<"Yes"<<endl;
}


Measured memory_bytes: 1408
const main = stdin => {
  const input = stdin.trim().split('\n')
  const S = input[0]

  if (S.includes('a') && S.includes('b') && S.includes('c')) {
    console.log('Yes')
  } else {
    console.log('No')
  }
}


// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29584
#include<iostream>
#include<cstdio>
#include<stack>
#include<algorithm>
#include<cstring>
#include<queue>
#include<vector>
#include<time.h>
#include<random>
#include<string>
#include<cmath>
#include <ctime>
#include<bitset>
#include <cctype>
#define low_bit(x) ((x)&(-(x)))
#define debug cout<<"*********degug**********";
#define index index_
#define ll long long
#define RE register
#define yn yn_
using namespace std;
mt19937 rnd(233);
const long long max_ = 1e5 + 7;
const double alpha = 0.75;
const int mod = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;
int read() {
	int s = 0, f = 1;
	char ch = getchar();
	while (ch<'0' || ch>'9') {
		if (ch == '-')
			f = -1;
		ch = getchar();
	}
	while (ch >= '0'&&ch <= '9') {
		s = s * 10 + ch - '0';
		ch = getchar();
	}
	return s * f;
}
inline int min(int a, int b) {
	return a < b ? a : b;
}
inline int max(int a, int b) {
	return a > b ? a : b;
}
int main() {
	int a = read(), b = read();
	cout << (int)ceil(a / (b*1.0));
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner stdin = new Scanner(System.in);
    while (true) {
      int H = stdin.nextInt();
      int W = stdin.nextInt();
      if (H == 0 && W == 0) {
        break;
      }

      StringBuilder rect = new StringBuilder();
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          rect.append("#");
        }
        rect.append("\n");
      }

      System.out.println(rect);
    }
  }

}

Measured memory_bytes: 20868
#include<stdio.h>
int main()
{
  int i,n,min,max;
  long int sum;
  scanf("%d",&n);
  int a[n-1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);

  max=a[0];
  min=a[0];
  sum=a[0];
  
  for(i=1;i<n;i++){
    if(a[i]>max) max=a[i];
    if(a[i]<min) min=a[i];
    sum+=a[i];
  }
  printf("%d %d %lld\n",min,max,sum);

  return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <stack>
#include <queue>
#include <cmath>
#include <list>
#include <map>
#include <set>
#define lson i<<1
#define rson i<<1|1
#define up(i,x,y) for(i=x;i<=y;i++)
#define down(i,x,y) for(i=x;i>=y;i--)
#define mem(a,x) memset(a,x,sizeof(a))
#define gi(x) scanf("%d",&x)
#define gi2(x,y) scanf("%d%d",&x,&y)
#define gll(x) scanf("%lld",&x)
#define gll2(x,y) scanf("%lld%lld",&x,&y)
#define gc(x) scanf("%c",&x)
#define gc2(x,y) scanf("%c%c",&x,&y)
using namespace std;
const double eps=1e-8; 
typedef long long ll;
const double PI = acos(-1.0); 
const int MAXN=100005;
const ll mod=1e7+9;
const ll llinf = (ll)(1e18) + 500;
const int inf=0x3f3f3f3f;

int main(){
	
	
	int a,b,c;
	cin>>a>>b>>c;
	cout<<c<<' '<<a<<' '<<b<<endl;
	//cout<<a<<' '<<b<<' '<<c<<endl;
	
	
	return 0;
}



















Measured memory_bytes: 256
#include <iostream>
using namespace std;
using P = pair<int, int>;
const int H = 20000;
const int INF = 100100100;
int main(){
    int h, n;
    P magic[1000];
    
    cin >> h >> n;
    for(int i = 0; i < n; i++){
        cin >> magic[i].first >> magic[i].second;
    }
    
    int memo[H];
    memo[0] = 0;
    for(int i = 1; i < H; i++) memo[i] = INF;
    
    for(int i = 1; i < H; i++){
        for(int j = 0; j < n; j++){
            if(i - magic[j].first >= 0 && memo[i] > memo[i-magic[j].first] + magic[j].second){
                memo[i] = memo[i-magic[j].first] + magic[j].second;
            }
        }
    }
    
    int res = INF;
    for(int i = h; i < H; i++){
        if(memo[i] < res) res = memo[i];
    }
    
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
const int twx=5e3+100;
const int inf=0x3f3f3f3f;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int n;
int xs[twx];
struct LV
{
    int y;
    int Next;
}a[twx];
int Link[twx];
int len;
int asd[twx];
int qwe[2][twx];
void Insert(int x,int y)
{
    a[++len].y=y;
    a[len].Next=Link[x];
    Link[x]=len;
}
void dfs(int x)
{
    f3(Link[x],a[i].Next,i)
    {
        int y=a[i].y;
        dfs(y);
    }
    memset(qwe[0],0x3f,sizeof qwe[0]);
    int tmp=0;
    qwe[tmp][0]=0;
    f3(Link[x],a[i].Next,i)
    {
        int y=a[i].y;
        tmp^=1;
        memset(qwe[tmp],0x3f,sizeof qwe[tmp]);
        f1(0,xs[x],j)
        {
            if(j-xs[y]>=0)
            {
                qwe[tmp][j]=min(qwe[tmp][j],qwe[tmp^1][j-xs[y]]+asd[y]);
            }
            if(j-asd[y]>=0)
            {
                qwe[tmp][j]=min(qwe[tmp][j],qwe[tmp^1][j-asd[y]]+xs[y]);
            }
        }
    }
    f1(0,xs[x],i)
    {
        asd[x]=min(asd[x],qwe[tmp][i]);
    }
}
void init()
{
	n=read();
    f1(2,n,i)
    {
        int p=read();
        Insert(p,i);
    }
    f1(1,n,i)
    {
        xs[i]=read();
    }
    memset(asd,0x3f,sizeof asd);
    dfs(1);
    if(asd[1]!=inf)
    {
        puts("POSSIBLE");
    }
    else
    {
        puts("IMPOSSIBLE");
    }
}
int main()
{
    init();
	return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for(int i = 0; i < n; i++)
            a[i] = sc.nextInt();
        
        int max1 = max(a);
        int max2 = sec_max(a);
        for(int i = 0; i < n; i++){
            if(max1 == a[i])
                System.out.println(max2);
            else
                System.out.println(max1);
        }
        sc.close();  
    }

    static int max(int[] a){
        int max = a[0];
        for(int i = 1; i < a.length; i++){
            if(a[i] > max) 
                max = a[i];
        }
        return max;
    }

    static int sec_max(int[] a){
        int max1;
        int max2;
        if(a[0] > a[1]){
            max1 = a[0];
            max2 = a[1];
        }else {
            max1 = a[1];
            max2 = a[0];
        }
        if(a.length > 2){
            for(int i = 2; i < a.length; i++){
                if(a[i] > max1) {
                    max2 = max1;
                    max1 = a[i];
                } else if(a[i] > max2){
                    max2 = a[i];
                }
            }
        }
        return max2;
    }
}

Measured memory_bytes: 107168
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
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; }
//ミョ(-ω- ?)
int main() {
    int e,y;
    cin >> e >> y;
    if(e == 0){
        /*
        １８６８年から１９１１年	明治元年から明治４４年
        １９１２年から１９２５年	大正元年から大正１４年
        １９２６年から１９８８年	昭和元年から昭和６３年
        １９８９年から２０１６年	平成元年から平成２８年
        */
       if(y <= 1911)cout << "M" << y-1867 << endl;
       else if(y <= 1925)cout << "T" << y - 1911 << endl;
       else if(y <= 1988)cout << "S" << y-1925 << endl;
       else cout << "H" << y-1988 << endl;
    }else if(e == 1){
        cout << y + 1867 << endl;
    }else if(e == 2){
        cout << y + 1911 << endl;
    }else if(e == 3){
        cout << y + 1925 << endl;
    }else {
        cout << y + 1988 << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<stdio.h>
 
int main(void){
int a,b,c;
  scanf("%d %d %d", &a, &b, &c);
  if(a==b && b==c){
  printf("No\n");
  }
  else if(a!=b && b!=c && c!=a){
  printf("No\n");
  }
  else if(a!=b && b==c){
  printf("Yes\n");
  }
  else if(a==b && b!=c){
  printf("Yes\n");
  }
  else if(a==c && c!=b){
  printf("Yes\n");
  }
}

Measured memory_bytes: 1656
#include<iostream>
using namespace std;
int main() {
	long long int N, M, sum;
	long long int A[10000];
	cin >> N >> M;
	sum = 0;
	for (int i = 0; i < M; i++) {
		cin >> A[i];
		sum = sum + A[i];
	}
	if (sum > N) {
		cout << -1 << endl;
		return 0;
	}
	cout << N - sum << endl;
	return 0;
}

Measured memory_bytes: 3660
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<algorithm>
#include<cstdio>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int bm = 3010;
ll BIT[bm];
void add(int A, ll B) {
	while (A <= bm) {
		BIT[A] = max(BIT[A], B);
		A += A & -A;
	}
}
ll query(int A) {
	ll kotae = 0;
	while (A > 0) {
		kotae = max(BIT[A], kotae);
		A -= A & -A;
	}
	return kotae;
}

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

ll V[200000], tmp[200000];

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


	int R = getint(), C = getint(), K = getint();

	rep(i, K) {
		ll r = getint(), c = getint(), v = getint();
		V[i] = v << 30 | r << 12 | c;
	}

	const int b = 12;
	int kazu[1 << b] = {}, kazu2[1 << b] = {};
	rep(i, K) kazu[V[i] & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
	for (int i = K - 1; i >= 0; i--) tmp[--kazu[V[i] & ((1 << b) - 1)]] = V[i];
	rep(i, K) kazu2[tmp[i] >> b & ((1 << b) - 1)]++;
	rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
	for (int i = K - 1; i >= 0; i--) V[--kazu2[tmp[i] >> b & ((1 << b) - 1)]] = tmp[i];

	int mae = -1;
	ll A[4] = {};
	ll L[3001];
	int l = 0;
	rep(k, K) {
		int v = V[k] >> 30;
		int i = V[k] >> 12 & 4095;
		int j = V[k] & 4095;
		if (mae != i) {
			mae = i;
			A[0] = 0;
			A[1] = 0;
			A[2] = 0;
			A[3] = 0;
			rep(a, l) add(L[a] & 4095, L[a] >> 12);
			l = 0;
		}
		ll kari = query(j);
		A[0] = kari;
		chmax(A[3], kari);
		chmax(A[2], kari);
		chmax(A[1], kari);
		chmax(A[3], A[2] + v);
		chmax(A[2], A[1] + v);
		chmax(A[1], A[0] + v);
		L[l++] = A[3] << 12 | j;
	}

	rep(a, l) add(L[a] & 4095, L[a] >> 12);
	ll kotae = query(C);

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

	Would you please return 0;
}

Measured memory_bytes: 4904
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
int N=0;
int func(int* i, int* dp){
if(*dp!=-1) return *dp;
if(*(i+1)==-1)
	return 0;
int a=abs(*i-*(i+1));
int b=abs(*i-*(i+2));
if(*(i+2)==-1) return *dp = a+func(&*(i+1), &*(dp+1));
return *dp = min(a+func(&*(i+1), &*(dp+1)), b+func(&*(i+2), &*(dp+2)));

}

int main(){
scanf("%d", &N);
int h[N+3];
int dp[N];
for(register int i=0; i<N; ++i){
	scanf("%d", &h[i]);
	dp[i]=-1;
}
h[N]=-1;
h[N+1]=-1;
h[N+2]=-1;
int resp=func(&h[0], &dp[0]);
printf("%d", resp);

return 0;
}

Measured memory_bytes: 3328
first_input = input().split()
x = int(first_input[0])
n = int(first_input[1])
if n != 0:
    second_input = map(int, input().split())
    p_a = list(map(int, second_input))
else:
    second_input = input()

def create_full_array(minimum, maximum):
    full_list = []
    for i in range(minimum,maximum+1):
        full_list.append(int(i))
    return full_list

if n == 0:
    print(x)
elif x > max(p_a) + 1 or x < min(p_a):
    ans = x - 1
    print(ans)
elif x == max(p_a) + 1:
    ans = x + 1
    print(ans)
else:
    full_array = create_full_array(min(p_a), max(p_a))
    if x in p_a:
        target_list = list(set(p_a)^set(full_array))
        abs_key = {}
        if len(target_list) == 0:
            if abs(x - min(p_a)) <= abs(x - max(p_a)):
                print(min(p_a) - 1)
            else:
                print(max(p_a) + 1)
        else:
            for i in target_list:
                abs_key[i] = abs(x-i)
            minimum = min(abs_key.values())
            t_k = []
            t_v = []
            [t_k.append(k) for k, v in abs_key.items() if v == minimum]
            print(min(t_k))

    else:
        print(x)



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

int main() {
  double a, b, c, d;
  cin >> a >> b >> c >> d;
  double e, f;
  e = c / b;
  f = a / d;
  int g, h;
  g = c / b;
  h = a / d;
  if(e > g) {
    g++;
  }
  if(f > h) {
    h++;
  }
  if(g <= h) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}




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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

bool isHamming(int n) {
  while (n % 2 == 0) n /= 2;
  while (n % 3 == 0) n /= 3;
  while (n % 5 == 0) n /= 5;
  return n == 1;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int cum[1000010] = {};
  for (int i = 1; i <= 1000000; i++) {
    cum[i] = isHamming(i);
    cum[i] += cum[i - 1];
  }
  int m, n;
  while (cin >> m, m) {
    cin >> n;
    cout << cum[n] - cum[m - 1] << endl;
  }

  return 0;
}


Measured memory_bytes: 6908