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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<vl> vvl;

double EPS=1e-9;
int INF=1000000005;
long long INFF=1000000000000000005ll;
double PI=acos(-1);
int dirx[8]={ -1, 0, 0, 1, -1, -1, 1, 1 };
int diry[8]={ 0, 1, -1, 0, -1, 1, -1, 1 };
const ll MOD = 1000000007;

ll sum() { return 0; }
template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }

#define DEBUG fprintf(stderr, "====TESTING====\n")
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
#define OUT(x) cout << x << endl
#define OUTH(x) cout << x << " "
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define READ(x) for(auto &(z):x) cin >> z;
#define FOR(a, b, c) for (int(a)=(b); (a) < (c); ++(a))
#define FORN(a, b, c) for (int(a)=(b); (a) <= (c); ++(a))
#define FORD(a, b, c) for (int(a)=(b); (a) >= (c); --(a))
#define FORSQ(a, b, c) for (int(a)=(b); (a) * (a) <= (c); ++(a))
#define FORC(a, b, c) for (char(a)=(b); (a) <= (c); ++(a))
#define EACH(a, b) for (auto&(a) : (b))
#define REP(i, n) FOR(i, 0, n)
#define REPN(i, n) FORN(i, 1, n)
#define MAX(a, b) a=max(a, b)
#define MIN(a, b) a=min(a, b)
#define SQR(x) ((ll)(x) * (x))
#define RESET(a, b) memset(a, b, sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(), v.end()
#define ALLA(arr, sz) arr, arr + sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr, sz) sort(ALLA(arr, sz))
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz))
#define PERMUTE next_permutation
#define TC(t) while (t--)
#define FAST_INP  ios_base::sync_with_stdio(false);cin.tie(NULL)
#define what_is(x) cerr << #x << " is " << x << endl;

void solve() {
	
}

int main()
{
    FAST_INP;
//    #ifndef ONLINE_JUDGE
//    freopen("input.txt","r", stdin);
//    freopen("output.txt","w", stdout);
//    #endif

//    int tc; cin >> tc;
//    TC(tc) solve();
	int k;
	cin >> k;
	REP(i,k) cout << "ACL";
    return 0;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		int v=sc.nextInt();
		int ans=0;
		while(v>0) {
			if(v%10==1)++ans;
			v/=10;
		}
		System.out.println(ans);
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}


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

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

constexpr int MAX = 3010000;
constexpr int MOD = 1000000007;

//Please set MAX and MOD!!========================================

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

ll COM(int n, int k) {
	if (n < k || n < 0 || k < 0) return (0);
	return (fac[n] * (finv[k] * finv[n - k] % MOD) % MOD);
}


void Main() {
	ll N, M, K; cin >> N >> M >> K;
	ll sum = 0;
	COMinit();
	for (int i = 1; i <= M-1; i++) (sum += N*N*(M-i)*i) %= mod;
	for (int i = 1; i <= N-1; i++) (sum += M*M*(N-i)*i) %= mod;
	(sum *= COM(N*M-2, K-2)) %= mod;
	cout << sum << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}

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

using namespace std;

typedef long long ll;

#define pii pair<ll,ll>
#define F first
#define S second
#define mp make_pair

int main()
{
    ll n , i , j , k , st , en ;
    scanf("%lld",&n);

    vector<pair<ll,pii > > vec;

    for(i = 0 ;i < n ;i ++)
    {
        scanf("%lld %lld",&k,&en);
        st =en-k+1;
        vec.push_back(mp(en,mp(k,st)));
    }

    ll now = 0;

    sort(vec.begin(),vec.end());

    for(i = 0 ; i < n ; i++)
    {
       // cout << now << "  " << vec[i].F << "  " << vec[i].F+vec[i].S.S-1 << endl;
        //if(now > vec[i].S.S)return !printf("No\n");

        now = now + vec[i].S.F ;
        if(now > vec[i].F)return !printf("No\n");
    }
    printf("Yes\n");


    return 0;
}



Measured memory_bytes: 8304
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using vvl = vector<vector<long>>;
using pii = pair<int, int>;
using pil = pair<int, long>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20)
#define YES cout << "Yes" << endl
#define NO cout << "No" << endl
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,s,t) for(int i=s; i<t; i++)
#define RNG(i,s,t,u) for(int i=s; i<t; i+=u)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()



void Main(){
  int h,w;
  cin >> h >> w;
  vs a(h);
  rep(i,h) cin >> a[i];
  vvl dp(h+1,vl(w+1,0));
  dp[1][1] = 1;
  rep(i,h){
    rep(j,w){
      if(i == 0 && j == 0) continue;
      if(a[i][j] == '#') dp[i+1][j+1] = 0;
      else dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % MOD;
    }
  }
  cout << dp[h][w] << endl;
}

long dfs(vvl &dp, vs &a, int x, int y){
  if(dp[x][y] != -1) return dp[x][y];
  if(x == 0 || y == 0 || a[x-1][y-1] == '#') return dp[x][y] = 0;
  if(x == 1 && y == 1) return dp[x][y] = 1;
  return dp[x][y] = (dfs(dp,a,x-1,y) + dfs(dp,a,x,y-1)) % MOD;
}

void Main2(){
  int h,w;
  cin >> h >> w;
  vs a(h);
  rep(i,h) cin >> a[i];
  vvl dp(h+1, vl(w+1,-1));
  cout << dfs(dp, a, h, w) << endl;
}

int main(){
  Main2();
}

Measured memory_bytes: 13160
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n,m; cin>>n>>m;
	string a[n],b[n]; rep(i,n)cin>>a[i]; rep(i,m)cin>>b[i];
	rep(i,n){
		rep(j,n){
			if(i+m-1>=n||j+m-1>=n) continue;
			bool flg = true;
			rep(k,m){
				rep(l,m){
					if(a[i+k][j+l]!=b[k][l]) flg=false;;
				}
			}
			if(flg) return cout<<"Yes"<<endl,0;
		}
	}
	cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
while True:
    list = input().split()
    a = int(list[0])
    op = list[1]
    b = int(list[2])
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)



Measured memory_bytes: 5596
A, B, C = map(int, input().split())
# op1 : 1つを-1する
# op2 : 1つを+2する
# ソートして、なるべくop2をしてop1で最終調整が良さそう

# abcをsort
A, B, C = sorted([A, B, C])

cnt = 0
cnt += (C - A) // 2 
cnt += (C - B) // 2

# 今、A, B , C の偶奇性は保存されてる
if (B - A) % 2 == 0:
    if (C - A) % 2 != 0:
        cnt += 1
else:
    cnt += 2

print(cnt)

Measured memory_bytes: 38256
#include <cstdio>
struct Node {
  int a;
  int b;
}a[1010];
int i,n,j;
int main () {
  scanf ("%d",&n);
  for (i=1;i<=n;i++) 
    scanf ("%d%d",&a[i].a,&a[i].b);
  for (i=1;i<=n-2;i++) 
    if (a[i].a==a[i].b&&a[i+1].a==a[i+1].b&&a[i+2].a==a[i+2].b) {
      puts ("Yes");
      return 0;
    }
  puts ("No");
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<P, int> P3;
const ll MOD = ll(1e9)+7;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    ll n, m, a[MAX_N], sum=0;
    string ans = "YES";
    cin >> n;
    REP(i,n) {
        cin >> a[i];
        sum += a[i];
    }
    if(sum%(n*(n+1)/2)>0) ans = "NO";
    else{
        m = sum/(n*(n+1)/2);
        ll cnt = 0;
        a[n] = a[0];
        REP(i,n){
            ll dif = a[i+1] - a[i]; // 前後の差を見るとm,m,,...,m-n,m,...になっている
            if(abs(dif-m)%n!=0){
                ans = "NO";
                break;
            }
            else{
                cnt += abs(dif-m)/n;
            }
        }
        if(cnt!=m) ans = "NO";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include<math.h>
int main()
{
    int n;
    scanf("%d", &n);
    int i;
    int t1, t2, x1, x2, y1, y2;
    t1 = x1 = y1 = 0;
    int dt, dx, dy;
    for (i = 0; i < n; i++)
    {
        scanf("%d %d %d", &t2, &x2, &y2);
        dt = t2 - t1;
        dx = abs(x2 - x1);
        dy = abs(y2 - y1);
        if (dt < dx + dy)
        {
            printf("No\n");
            return 0;
        }
        if ((dt - dx - dy) % 2 == 1)
        {
            printf("No\n");
            return 0;
        }
        t1 = t2;
        x1 = x2;
        y1 = y2;
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s(a), t(b), x(q);
    rep(i, 0, a) cin >> s[i];
    rep(i, 0, b) cin >> t[i];
    rep(i, 0, q) cin >> x[i];

    rep(i, 0, q) {
        ll left_s = 0, right_s = 0;
        if (x[i] <= s[0]) {
            left_s = s[0];
            right_s = s[0];
        } else if (s[a - 1] <= x[i]) {
            left_s = s[a - 1];
            right_s = s[a - 1];
        } else {
            ll tmp = lower_bound(all(s), x[i]) - s.begin();
            left_s = s[tmp - 1];
            right_s = s[tmp];
        }

        ll left_t = 0, right_t = 0;
        if (x[i] <= t[0]) {
            left_t = t[0];
            right_t = t[0];
        } else if (t[b - 1] <= x[i]) {
            left_t = t[b - 1];
            right_t = t[b - 1];
        } else {
            ll tmp = lower_bound(all(t), x[i]) - t.begin();
            left_t = t[tmp - 1];
            right_t = t[tmp];
        }

        ll p1 = abs(x[i] - left_s) + min(abs(left_s - left_t), abs(left_s - right_t));
        ll p2 = abs(x[i] - left_t) + min(abs(left_t - left_s), abs(left_t - right_s));
        ll p3 = abs(x[i] - right_s) + min(abs(right_s - right_t), abs(right_s - left_t));
        ll p4 = abs(x[i] - right_t) + min(abs(right_t - right_s), abs(right_t - left_s));

        cout << min({p1, p2, p3, p4}) << endl;
    }
    return 0;
}


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

const ll INF = 1e17;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N;
    cin >> N;
    ll min = INF;
    int ans=0;
    for (int i=0; i < N; i++)
    {
        ll p;
        cin >> p;
        if (p < min) {
            ans++;
            min = p;
        }
    }

    // output
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>

#define rep(i,x,y) for (int i=x;i<=y;i++)
#define dep(i,y,x) for (int i=y;i>=x;i--)
#define sz(x) (int)(x.size())

using namespace std;

typedef long long LL;   
typedef unsigned long long uLL;

const int maxn=100000+10;

int n,x,y;
vector<int> G[maxn];

int DFS(int k,int fa)
{
    int sg=0;
    rep(i,0,sz(G[k])-1)
    {
        if (G[k][i]==fa) continue;

        sg^=(DFS(G[k][i],k)+1);
    }
    return sg;
}

int main()
{
    scanf("%d",&n);
    rep(i,2,n)
    {
        scanf("%d%d",&x,&y);
        G[x].push_back(y);
        G[y].push_back(x);
    }

    if (DFS(1,-1)) printf("Alice\n"); else printf("Bob\n");

    // system("pause");
    return 0;
}


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

#define MOD (1000000000+7)
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;

typedef long long int ll;

void solve(){
	ll A, B;
	cin >> A >> B;
	ll ans = B*10;
	for(; ans < 10 + B*10; ans++){
		if((ans*8)/100 == A){
			cout << ans << endl;
			return ;
		} 
	}
	cout << -1 << endl;
}

int main(){
 	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

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




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d%d", &a,&b);
    if(b%2==0)
    {
        if(a>=13)
            printf("%d\n", b );
        else if(a<=12&&a>=6)
            printf("%d", b/2);
        else
            printf("0");
    }
    return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  ll X, Y, Z;
  scanf("%lld %lld %lld", &X, &Y, &Z);

  cout << Z << " " << X << " " << Y << endl;
}


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

int N;
string S;

int get(int x){
    int sum = 0, cnt = 0;
    for(int i = 0; i < N; i++){
        cnt++;
        if(S[i] == x) cnt = 0;
        sum = max(sum, cnt);
    }
    return sum;
    }




int main(){
    cin >> S;
    int ans = 1000;
    N = S.size();
    int crt;
    for(int i = 'a'; i <='z'; i++){
        crt = get(i);
        ans = min(ans, crt);
    }
    cout << ans << endl;
}

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

int main() {
    vector<int> x(5, 0);
    int sum = 0;
    for (int i = 0; i < 5; i++) {
        cin >> x[i];
    }

    sort(x.begin(), x.end(), [](int a, int b)
                {int i = a % 10, j = b % 10;
                 if (i == 0) i = 10;
                 if (j == 0) j = 10;
                 return i < j; });
    for (int i = 4; i > 0; i--) {
        if (x[i] % 10)
            sum += x[i] + (10 - (x[i]%10));
        else
            sum += x[i];
    }
    sum += x[0];
    cout << sum << endl;
    return 0;

}


Measured memory_bytes: 256
profit = 0
n = int(input())
v = []
c = []
v += map(int,input().split())
c += map(int,input().split())
a = []
for i in range(n):
    a.append(v[i] - c[i])
for i in range(n):
    if a[i] > 0:
        profit += a[i]
print(profit)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
# abc140/abc140_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    A = [0] * N
    B = i2nn()
    A[0] = B[0]
    for i in range(N-1):
        if A[i] > B[i]:
            A[i] = B[i]
        A[i + 1] = B[i]
    print(sum(A))
    return

main()


Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
  char chr[4] = {0};
  int success = 1;
  
  scanf("%s", chr);
  for (int i=0; i<3; i++) {
    if (chr[i] == chr[i+1]) {
      success = 0;
    }
  }
  if (success == 0) {
    printf("%s", "Bad");
  } else {
    printf("%s", "Good");
  }
  
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==5&&b==5&&c==7){cout<<"YES"<<endl;}
	else if(a==5&&b==7&&c==5){cout<<"YES"<<endl;}
	else if(a==7&&b==5&&c==5){cout<<"YES"<<endl;}
	else{cout<<"NO"<<endl;}
	
}


Measured memory_bytes: 256
#include <stdio.h>

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

  int i;
  for(i=0; i<N; ++i){
    int a,b,c;
    scanf("%d %d %d", &a, &b, &c);
    a *= a;
    b *= b;
    c *= c;
    if(a+b==c || b+c==a || c+a==b){
      printf("YES\n");
    }else{
      printf("NO\n");
    }
  }

  return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int num = sc.nextInt();
		int type = sc.nextInt();
		int need[] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
		boolean canUse[] = new boolean[10];
		for(int i = 0; i < type; i ++) {
			canUse[sc.nextInt()] = true;
		}
		int dp[][] = new int[num + 1][10];
		dp[0][0] = 0;
		for(int i = 1; i <= num; i ++) {
			dp[i][0] = -1;
			for(int j = 1; j < 10; j ++) {
				dp[i][j] = 0;
			}
		}
		for(int i = 1; i <= num; i ++) {
			for(int j = 1; j < 10; j ++) {
				if(i < need[j] || !canUse[j]) {
					continue;
				}else {
					int tmp[] = new int[10];
					for(int k = 0; k < 10; k ++) {
						tmp[k] = dp[i - need[j]][k];
					}
					if(tmp[0] == -1) {
						continue;
					}
					tmp[j] ++;
					tmp[0] ++;
					boolean replace = false;
					for(int k = 9; k > 0; k --) {
						if(tmp[k] > dp[i][k]) {
							replace = true;
							break;
						}else if (tmp[k] < dp[i][k]) {
							replace = false;
							break;
						}
					}
					if(tmp[0] > dp[i][0] || (replace && tmp[0] == dp[i][0])) {
						for(int k = 0; k < 10; k ++) {
							dp[i][k] = tmp[k];
						}
					}
				}
			}
		}
		for(int i = 9; i > 0; i --) {
			for(int j = 0; j < dp[num][i]; j ++) {
				System.out.print(i);
			}
		}
		System.out.println();
	}
}

Measured memory_bytes: 29964
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;

int N, A, B, C, l[8], pw4[9], res;

int main() {
	cin >> N >> A >> B >> C;
	for (int i = 0; i != N; ++i)
		cin >> l[i];
	pw4[0] = 1;
	for (int i = 1; i <= N; ++i)
		pw4[i] = pw4[i - 1] * 4;
	res = intmax;
	for (int i = 0; i != pw4[N]; ++i) {
		int k = i;
		int a, b, c;
		a = b = c = 0;
		int E869120 = -30;
		for (int j = 0; j != N; ++j) {
			if (k % 4 == 0) {
				E869120 += 10;
				a += l[j];
			}
			if (k % 4 == 1) {
				E869120 += 10;
				b += l[j];
			}
			if (k % 4 == 2) {
				E869120 += 10;
				c += l[j];
			}
			k /= 4;
		}
		if (a*b*c == 0)continue;
		res = min(res, E869120 + abs(A - a) + abs(B - b) + abs(C - c));
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
def ra(a): #圧縮された要素を非保持
    ll,l=[],1
    for i in range(len(a)-1):
        if a[i]==a[i+1]:
            l+=1
        else:
            ll.append(l)
            l=1
    ll.append(l)
    return ll
n=input()
print(len(ra(input())))

Measured memory_bytes: 3956
n = int(input())
s = list(input())

dp = [0] * n

WsW = 0
WsE = 0
EsW = 0
EsE = 0
count = float('inf')

for i in range(n):
    if s[i] =="W":
        WsW += 1
    else:
        WsE += 1

for j in range(n):
    if s[j] == "W" :
        WsW -= 1
    else:
        WsE -= 1
    count = min(count, WsE + EsW)
    if s[j] == "W" :
        EsW += 1
    else:
        EsE += 1
print(count)


Measured memory_bytes: 8052
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define between(a,x,b) ((a)<=(x)&&(x)<=(b))
#define INF 1 << 30
#define S second
#define F first
using namespace std;

int main(){
    int n, h1, h2, m1, m2, s1, s2;
    char str1[16], str2[16];
    while(scanf("%d", &n) && n){
        vector<pair<int, int> >time(n*2);
        rep(i, n){
            int a = 0, b = 0;
            pair<int, int>tmp;
            scanf("%d:%d:%d %d:%d:%d", &h1, &m1, &s1, &h2, &m2, &s2);
            a = h1 * 3600 + m1 * 60 + s1;
            b = h2 * 3600 + m2 * 60 + s2;
            time[i*2] = make_pair(a, 1);
            time[i*2+1] = make_pair(b, 0);
        }
        sort(time.begin(), time.end());
        int res = 0, cnt = 0;
        rep(i, time.size()){
            if(time[i].S){
                cnt++;
                res = max(res, cnt);
            }
            else cnt--;
        }
        
        printf("%d\n", res);
    }
    return 0;
}

Measured memory_bytes: 1284
import sys
import math
import heapq
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res
def gcd(x, y):
    if x < y: x, y = y, x
    div = x % y
    while div != 0:
        x, y = y, div
        div = x % y
    return y


N=II()
DATA=[[] for i in range(N+1)]

for i in range(1, N+1):
    for _ in range(II()):
        DATA[i].append(LI())

res = 0
for FLGS in range(1 << N):
    ok = True
    for i in range(N):
        if (FLGS >> i) & 1:
            for j, k in DATA[i+1]:
                ok = ok and ((FLGS >> (j-1)) & 1) == k
                # print("j:{} FLGS >> (j-1):{} k:{}".format(j, FLGS >> (j-1), k))
    if ok:
        pos_res = 0
        for s in range(N): pos_res += (FLGS >> s) & 1
        res = max(res, pos_res)
        # print("{:015b}".format(FLGS))
print(res)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define NIL -1
typedef long long ll;
const ll INF = 1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }


int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a+b+c >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

#define max 500000
int a[max];
int h;

int parent(int i){return i / 2;}
int left(int i){return 2 * i;}
int right(int i){return 2 * i + 1;}

void maxheap(int i){
    int l = left(i);
    int r = right(i);
    int largest;
    if(l <= h && a[l] > a[i]) largest = l;
    else largest = i;
    if(r <= h && a[r] > a[largest]) largest = r;
    if(largest != i){
        swap(a[i], a[largest]);
        maxheap(largest);
    }
}

int main(){
    cin >> h;
    rep(i, h) cin >> a[i + 1];
    for(int i = h / 2; i >= 1; i--) maxheap(i);
    rep(i, h) cout << " " << a[i + 1];
    cout << endl;
}


Measured memory_bytes: 5024
def matrixChainMultiplication(M):
    # P ??????
    n = len(M)
    P = [M[0][0]]
    P += [M[i][1] for i in range(n)]
    # ?¨???¶?????? m ??????
    m = [[[] for _ in range(n + 1)] for _ in range(n + 1)]
    for i in range(n + 1):
            m[i][i] = 0

    # l???????±???¨?????????????????°
    for l in range(2, n + 1):
        for i in range(1, n - l + 2):
            j = i + l - 1
            m[i][j] = 9999999999999999
            for k in range(i, j):
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + P[i -1] * P[k] * P[j])
    return m[1][n]


if __name__ == '__main__':
    n = int(input())
    M = [list(map(int, input().split())) for _ in range(n)]
    print(matrixChainMultiplication(M))

Measured memory_bytes: 8512
#include <bits/stdc++.h>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define all(v)   v.begin(), v.end()
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define START cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
#define isOdd(n)    (n&1)
#define LLMAX LLONG_MAX
#define LLMIN LLONG_MIN
#define IMN INT_MIN
#define IMX INT_MAX
#define pow(n, m) power((ll)n, (ll)m)
#define numOfDigits(n)  ((n)? (ll)(log10(n))+1 : 1)
#define mem(x, val)    memset(x, val, sizeof(x)) //be careful
#define sz(x)          (int) x.size()
#define MOD 1000000007
#define EPS 1e-7

typedef long long ll;
typedef long double ld;
typedef double dd;
typedef pair<int, int> pii;

int main()
{
    START
    //freopen("test cases\\in.txt", "r", stdin) ;
    ll n; cin>>n;
    ll x = 100, cnt = 0;
    while(x<n) x += x/100, cnt++;
    cout<<cnt;
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
 
// 型名の省略
typedef unsigned int uint;
typedef long long lint;
typedef unsigned long long ulint;
 
const int MOD = 1000000007;
const lint INF = 1LL << 60;
const double PI=acos(-1.0);
 
// cinとcoutの高速化
#define endl "\n"
struct cinacc{cinacc(){cin.tie(0);ios::sync_with_stdio(false);}}cinaccc;
struct coutacc{coutacc(){cout.setf(ios::fixed);cout.precision(12);}}coutaccc;
 
// 繰り返し
#define rep(i,n) for(lint i=0;i<(lint)(n);i++)
#define reps(i,n) for(lint i=0;i<=(lint)(n);i++)
#define rrep(i,n) for(lint i=(lint)(n)-1;i>0;i--)
#define rreps(i,n) for(lint i=(lint)(n)-1;i>=0;i--)

#define pb push_back

#define p pair<int, int>
#define plint pair<lint, lint>

#define ALL(s) (s.begin(), s.end())
#define SZ(s) (s.size())

template<class T>bool chmax(T&a,const T&b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T&a,const T&b){if(b<a){a=b;return true;}return false;}

// Union-Find-Tree
class UnionFind {
    vector<int> par;
    UnionFind(int n):par(n){rep(i,n)par[i]=i;}
    int root(int x){if(par[x]==x)return x;return par[x]=root(par[x]);}
    void unite(int x,int y){int rx=root(x);int ry=root(y);if(rx==ry)return;par[rx]=ry;}
    bool same(int x,int y){return root(x)==root(y);}
};

// Final Weapon!
// #define int lint

int main(void) {
    int n, r;
    cin >> n >> r;
    
    cout << (n < 10 ? r + (100 * (10 - n)) : r);
    
    return 0;
}


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

int main(){
	int n;
	cin>>n;
	int data[8];
	int max;
	int min;
	int ans[n];
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		data[0] = a%10;
		data[1] = a%100/10;
		data[2] = a%1000/100;
		data[3] = a%10000/1000;
		data[4] = a%100000/10000;
		data[5] = a%1000000/100000;
		data[6] = a%10000000/1000000;
		data[7] = a%100000000/10000000;
	sort(data,data+8);
	max = data[7]*10000000+data[6]*1000000+data[5]*100000+data[4]*10000+
		  data[3]*1000+data[2]*100+data[1]*10+data[0];
	min = data[0]*10000000+data[1]*1000000+data[2]*100000+data[3]*10000+
		  data[4]*1000+data[5]*100+data[6]*10+data[7];
	ans[i] = max-min;
	
	}
	for(int i=0;i<n;i++){
		cout << ans[i]<<endl;
	}
	return 0;
}
		

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define MAX 100010
using namespace std;

vector<pair<int, int>> tri;

void getTri(int l, int r)
{
	if (l + 1 == r)
	{
		tri.push_back({l, r});
		return;
	}
	if (l + 3 == r)
	{
		tri.push_back({l, r - 1});
		tri.push_back({l + 1, r});
		return;
	}
	int n = ((r - l + 1) / 2 + 1) / 2;
	for (int i = 0; i < n; i++) tri.push_back({l + i, r - (n - 1) + i});
	int m = (l + r + 1) / 2;
	for (int i = m; i <= r - n; i++) tri.push_back({l + n + i - m, i});
}

int mycmp(const pair<int, int> a, const pair<int, int> b)
{
	return a.first + a.second < b.first + b.second;
}

int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int N, K;
	cin >> N >> K;
	if (2 * K - 2 > N - 1)
	{
		cout << -1 << endl;
		return 0;
	}
	getTri(K, K + 2 * N - 1);
	sort(tri.begin(), tri.end(), mycmp);
	for (int i = 0; i < N; i++) cout << tri[i].first << " " << tri[i].second << " " << K + 2 * N + i << "\n";
	return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793


  
int main(){
    int n;
    cin >> n;
    VI a(n);
    ll ten=1;
    ll eig=1;
    ll nin=1;
    rep(i,n){
        ten*=10;
        ten%=MM;
        nin*=9;
        nin%=MM;
        eig*=8;
        eig%=MM;
    }
    ll ans ;
    ten+=2*MM;
     ans=ten-2*nin+eig;
    ans%=MM;
    cout << ans << endl;
}


Measured memory_bytes: 7124
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a[3];
	REP(i, 3)cin >> a[i];
	sort(a, a + 3);
	cout << a[2] - a[0] << endl;
}

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

vector<int> e[100001];

int ans,dp[100001];
void dfs(int x,int p){
	dp[x]=1;
	for(int it:e[x])
		if(it!=p){
			dfs(it,x);
			if(x==1)	continue;
			if(dp[it]==k)
				ans++;
			else
				dp[x]=max(dp[it]+1,dp[x]);
		}
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin>>n>>k;
	for(int i=1,x;i<=n;i++){
		cin>>x;
		if(i==1){
			ans+=x!=1;
			continue;
		}
		e[x].emplace_back(i);
		e[i].emplace_back(x);
	}
	dfs(1,0);
	cout<<ans<<endl;
}


Measured memory_bytes: 12416
import java.util.Scanner;

public class Main{

	static final Scanner	s	=new Scanner(System.in);

	public static void main(String args[]){
		input();
		solve();
	}

	private static void input(){
	}

	private static void solve(){
		char a=s.next().charAt(0),c[]= "aiueo".toCharArray();
		for(char i:c) {
			if(a==i) {
				System.out.println("vowel");
				return;
			}
		}
		System.out.println("consonant");
	}
}


Measured memory_bytes: 21844
from sys import stdin

def main():
    N, T = map(int, input().split())
    CT = [tuple(map(int, input().split())) for _ in [0] * N]

    cost = 1001
    for c, t in CT:
        if t <= T:
            cost = min(cost, c)
    if cost == 1001:
        print('TLE')
    else:
        print(cost)

input = lambda: stdin.readline()
main()


Measured memory_bytes: 2940
#include<stdio.h>
int main()
{
    int n,arr[2][105],max=0,i,j,a,b,c;
    scanf("%d",&n);
    for(i=0; i<2; i++)
    {
        for(j=0; j<n; j++)
        {
            scanf("%d",&arr[i][j]);
        }
    }
    for(i=0; i<n; i++)
    {
    a=0;
    b=0;
    c=arr[a][b];
        for(j=0; j<n; j++)
        {
            if(i==j && a==0)
            {
                a++;
            }
            else
            {
                b++;
            }
            c=c+arr[a][b];
        }
        if(c>max)
        max=c;
    }
    printf("%d",max);
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_T = 86400;

/* typedef */

struct Sched {
  int s, t, u;
  Sched() {}
  Sched(int _s, int _t, int _u): s(_s), t(_t), u(_u) {}
};

typedef vector<Sched> vs;

/* global variables */

/* subroutines */

bool check(vs& scds, double p, double c) {
  double w = c;
  for (int cnt = 0; cnt < 2; cnt++) {
    double w0 = w;
    for (vs::iterator vit = scds.begin(); vit != scds.end(); vit++) {
      double dw = (p - vit->u) * (vit->t - vit->s);
      w += dw;
      if (w <= 0.0) return false;
      if (w > c) w = c;
    }
    if (cnt > 0 && w < w0) return false;
  }

  return true;
}

/* main */

int main() {
  for (;;) {
    int n;
    double l;
    cin >> n >> l;
    if (n == 0) break;

    vs scds;
    int prev = 0;

    for (int i = 0; i < n; i++) {
      int s, t, u;
      cin >> s >> t >> u;
      if (prev < s)
	scds.push_back(Sched(prev, s, 0));
      scds.push_back(Sched(s, t, u));
      prev = t;
    }
    if (prev < MAX_T)
      scds.push_back(Sched(prev, MAX_T, 0));

    double p0 = 0.0, p1 = 1e7;

    for (int i = 0; i < 50; i++) {
      double p = (p0 + p1) / 2;
      if (check(scds, p, l)) p1 = p;
      else p0 = p;
    }

    printf("%.8lf\n", (p0 + p1) / 2);
  }

  return 0;
}

Measured memory_bytes: 3748
/**
 *    Creator :  bizarre
 *    Date : 4/2020
 *    Problem Number : 494
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long
#define ld long double
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}
void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n; i>n-r; i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
const int N = 1e6 + 5, inf = 2e9, mod = 1e9 + 7;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}
void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}

int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

*/
const int N=2e5+5;
ll dp[N],a[N],sum[N];
int main()
{
   bizarre
   ll n;
   cin>>n;
   for(int i=1;i<=n;i++) cin>>a[i];
   for(int i=1;i<=n;i+=2)
   {
       if(i==1)sum[i]=a[i];
       else sum[i]=sum[i-2]+a[i];
   }
   dp[1]=0;
   dp[2]=max(a[1],a[2]);
   for(int i=3;i<=n;i++)
   {
       if(i%2==1)
       {
           dp[i]=max(dp[i-1],dp[i-2]+a[i]);
       }
       else
       {
           dp[i]=max(sum[i-1],dp[i-2]+a[i]);
       }
   }
   cout << dp[n];
    return 0;
}


Measured memory_bytes: 8324
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a == b && a != c || a == c && a != b || b == c && b != a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 768
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <bitset>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

#define maxN 2018
#define maxLen 4000011

int n, i, a[maxN], need, sum;
bitset<maxLen> act;

int main()
{
    //freopen("test.in","r",stdin);

    scanf("%d", &n);
    act.reset(); act[0] = 1;


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

    sort(a + 1, a + n + 1);

    need = (sum + 1) / 2;
    for (i = 1; i <= n; i++) {
        act = act | (act << a[i]);
        if (act[need]) {
            printf("%d", need);
            return 0;
        }
    }

    while (act[need] == 0) need++;
    printf("%d", need);


    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define ll long long
#define ull unsigned long long
#define ld long double
#define vl vector<long long>
#define vvl vector<vector<long long>>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rrep(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define pll pair<long long,long long>
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vvc vector<vector<char>>
#define vc vector<char>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define maxe(x) *max_element(all(x))
#define mine(x) *min_element(all(x))
#define Size(x) ((int)(x).size())
#define umap unordered_map
const long long INF = 1LL << 60;
const long double pi = 3.1415926535897932;
long long MOD = 1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

//lis,modpow,uf,modncr,soinsubunkai,yakusurekkyo,gyakugen
//mint

    signed main(){
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
        ll N;
        cin>>N;
        vl A(N);
        rep(i,N)cin>>A[i];
        ll sum=0;
        ll from=0;
        rep(i,N){
            sum+=abs(A[i]-from);
            from=A[i];
        }
        sum+=abs(A[N-1]);
        from=0;
        rep(i,N-1){
            cout<<sum-abs(from-A[i])-abs(A[i]-A[i+1])+abs(A[i+1]-from)<<endl;
            from=A[i];
        }
        cout<<sum-abs(from-A[N-1])-abs(A[N-1])+abs(from)<<endl;
    }

Measured memory_bytes: 2048
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>

#define f first
#define s second
#define MAX_N 155
#define INF 100000000000000

using namespace std;

typedef long long ll;

typedef pair<int,int> P;

int main(void){

  ll n,m,k,a,b;

  while(cin >> n >> m,n|m){
    vector<P>v[MAX_N];
    
    for(int i=1;i<=n;i++){
      cin >> k;
      for(int j=0;j<k;j++){
	cin >> a >> b;
	v[i].push_back(make_pair(a,b));
      }
    }

    ll dp[MAX_N][11][80];

    for(int i=0;i<MAX_N;i++)
      for(int j=0;j<11;j++)
	for(int k=0;k<80;k++)
	  dp[i][j][k]=INF;

    for(int i=0;i<11;i++)
      for(int j=0;j<80;j++)
	dp[0][i][j]=dp[1][i][j]=0;

    for(int i=2;i<=n;i++){
      for(int j=0;j<v[i].size();j++){
	for(int l=m;l>=0;l--){
	  for(int k=0;k<v[i-1].size();k++){
	    dp[i][j][l]=min(dp[i][j][l],dp[i-1][k][l]+(v[i][j].s+v[i-1][k].s)*abs(v[i][j].f-v[i-1][k].f));
	  }
	  if(l<m){
	    if(i==2)dp[i][j][l]=0;
	    for(int p=0;p<v[i-2].size();p++)
	      dp[i][j][l]=min(dp[i][j][l],dp[i-2][p][l+1]+(v[i][j].s+v[i-2][p].s)*abs(v[i][j].f-v[i-2][p].f));
	    //dp[i][j][l]=min(dp[i][j][l],dp[i][j][l+1]);
	  }
	}
      }
    }
    
    ll ans=INF;
    /*
    for(int i=0;i<v[n].size();i++){
      for(int j=0;j<=m;j++){
      ans=min(ans,dp[n][i][j]);
      if(j>0)ans=min(ans,dp[n-1][i][j]);
      }
    }
    */
    for(int i=0;i<v[n].size();i++)ans=min(ans,dp[n][i][0]);
    if(m>=1)for(int i=0;i<v[n-1].size();i++)ans=min(ans,dp[n-1][i][1]);

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 2292
#include<iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int left = 0;
    for (int i = 0; i < M;i++){
        if(A[i]<X){
            left++;
        }
    }
    int right = 0;
    for (int i = M-1; i > 0;i--){
        if(A[i]>X){
            right++;
        }
    }
    int res = min(left, right);
    cout << res << endl;
}

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

int main(){
    
    char X;
    cin >> X;
    
    if (isupper(X)){
        cout << 'A' << "\n";
    } else {
        cout << 'a' << "\n";
    }

    return 0;
}



Measured memory_bytes: 3024
N,D = map(int,input().split())
X = []
for i in range(N):
    X.append([int(x) for x in input().split()])
    
ans = 0
for i in range(N-1):
    for j in range(i+1,N):
        sqr = 0   
        for d in range(D):
            sqr += (X[i][d]-X[j][d])**2
        if (sqr ** (1/2)).is_integer():
            ans += 1
print(ans)  


Measured memory_bytes: 38384
#include<stdio.h>

int k_r(int a,int b){
  int tmp,r;
  if(a<b){
    tmp=a;
    a=b;
    b=tmp;
  }
  r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
return b;
}
int k_r2(int a,int b,int c){
  return k_r(k_r(a,b) , k_r(a,c));
}

int main(){
  int K;
  long int count=0;
  scanf("%d",&K);
  int i=1;
  int j=1;
  int l=1;
  for(i=1;i<K+1;i++){
    for(j=1;j<K+1;j++){
      for(l=1;l<K+1;l++){
        count=count+k_r2(i,j,l);
      }
    }
  }
  printf("%ld",count);
}

Measured memory_bytes: 1732
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int t[10];
    t[5] = t[7] = 0;
    t[a] ++, t[b] ++, t[c] ++;
    if (t[5] == 2 && t[7] == 1) cout << "YES";
    else cout << "NO";
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = (a); i < int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;
using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void ioinit() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline vi32 plist(i32 n) { vi32 f(n, 1); f[0] = f[1] = 0; repi(i, 2, n) for (int j = i * 2; j < n; j += i) f[j] = 0; return f; }
inline bool isprime(i32 n) { if (n < 2) return 0; for (i32 i = 2; i * i <= n; i++) if (n % i == 0) return 0; return 1; }
template<class T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<class T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<class T> inline bool amax(T &x, T y) { if (x >= y) return 0; x = y; return 1; }
template<class T> inline bool amin(T &x, T y) { if (x <= y) return 0; x = y; return 1; }
template<class T> inline i64 lbi(vector<T> &v, T e) { return lower_bound(all(v), e) - v.begin(); }
template<class T> inline i64 ubi(vector<T> &v, T e) { return upper_bound(all(v), e) - v.begin(); }
template<class T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }

int main() {
  ioinit();
  int k, n;
  cin >> k >> n;
  if (k % 2 == 0) {
    rep(i, n) {
      if (i == 0) cout << k / 2;
      else cout << k;
      if (i == n - 1) cout << '\n'; 
      else cout << ' ';
    }
    return 0;
  }
  vi32 ans(n, (k + 1) / 2);
  int cnt = n / 2, zero = 0;
  while (cnt > 0) {
    if (ans[n - 1 - zero] == 1) {
      ans[n - 1 - zero]--;
      zero++;
    } else {
      ans[n - 1 - zero]--;
      rep(i, zero) ans[n - 1 - i] = k;
      zero = 0;
    }
    cnt--;
  }
  rep(i, n) {
    cout << ans[i];
    if (i == n - 1) cout << '\n';
    else {
      if (ans[i + 1] == 0) { cout << '\n'; break; }
      else cout << ' ';
    }
  }
  return 0;
}


Measured memory_bytes: 3456
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;


class RecurringDecimal{
	private int n, digit;
	private String minString;
	
	public RecurringDecimal(int n, int digit) {
		this.n = n;
		this.digit = digit;
		this.minString = getMinString();
	}
	
	private String getMinString(){
		char[] nCharArray = getPadZero().toCharArray();
		Arrays.sort(nCharArray);
		return new String(nCharArray);
	}
	
	private String getPadZero(){
		String nString = Integer.toString(n);
		int nLength = digit - nString.length();
		String zeros = "";
		for(int i = 0; i < nLength; i++) zeros += "0";
		return zeros+nString;
	}
	
	int getMin(){
		return new Integer(minString);
	}
	
	int getMax(){
		return new Integer(new StringBuffer(minString).reverse().toString());
	}
}

public class Main {
	public static void main(String[] args){
		Scanner sn = new Scanner(System.in);
		
		while(true){
			int n =sn.nextInt(), digit =sn.nextInt();
			if(n == 0 && digit == 0) break;
			HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
			map.put(n, 0);
			RecurringDecimal rd = new RecurringDecimal(n, digit);
			int idx =1;
			while(true){
				int newN = rd.getMax() - rd.getMin();
				if(map.containsKey(newN)){
					int j = map.get(newN);
					System.out.println(j+" "+newN+" "+(idx-j));
					break;
				} else{
					map.put(newN, idx);
					rd = new RecurringDecimal(newN, digit);
					idx++;
				}
			}
		}
		
	}
}

Measured memory_bytes: 21124