akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int D;
  cin >> D;
  long long c[26];
  for (int i = 0; i < 26; i++) cin >> c[i];
  long long s[D][26];
  for (int d = 0; d < D; d++) {
    for (int i = 0; i < 26; i++) {
      cin >> s[d][i];
    }
  }
  long long t[D];
  for (int d = 0; d < D; d++) {
    cin >> t[d];
    t[d]--;
  }
  int M;
  cin >> M;
  for (int i = 0; i < M; i++) {
    int d, q;
    cin >> d >> q;
    d--, q--;
    t[d] = q;
    long long last[D + 1][26];
    fill(last[0], last[0] + 26, 0);
    long long ans = 0;
    for (int d = 0; d < D; d++) {
      ans += s[d][t[d]];
      for (int i = 0; i < 26; i++) {
        last[d + 1][i] = last[d][i];
      }
      last[d + 1][t[d]] = d + 1;
      for (int i = 0; i < 26; i++) {
        ans -= c[i] * (d + 1 - last[d + 1][i]);
      }
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3808
n, k = map(int, input().split())
d = set(input().split())
like = set(["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]) - d

for i in range(n, 100000):
    used = set(str(i))
    if used <= like:
        ans = i
        break

print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int,int> p;

ll tmp = 1;

void test(ll a){
  tmp *= a;
  tmp %= 1000000007;
  if (a > 1) {
    test(a-1);
  }
}

int main()
{
  ll n, m;
  cin >> n >> m;
  if (abs(n - m) > 1) {
    cout << 0 << endl;
    return 0;
  }else if (n == m) {
    test(n);
    ll tmpA = tmp;
    tmp = 1;
    test(m);
    ll tmpB = tmp;
    cout << (tmpA * tmpB)*2 % 1000000007 << endl;
  }else{
    test(n);
    ll tmpA = tmp;
    tmp = 1;
    test(m);
    ll tmpB = tmp;
    cout << (tmpA * tmpB) % 1000000007 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
#include <stack>
#include <iomanip>
#include <limits>
using namespace std;
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
using Graph=vector<vector<int>>;
using edge= struct{int to;ll cost;};

template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

typedef priority_queue<ll> PQ_HIGH;
typedef priority_queue<ll,VL,greater<ll>> PQ_LOW;

#define EPSILON 1.0e-12

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
};
//降順
bool compare_by_b_high(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        return a.first < b.first;
    }
};
bool compare_by_b_higheer(tuple<string, int, int> a, tuple<string, int, int> b) {
    if(get<0>(a) != get<0>(b)){
      return get<0>(a) <get<0>(b);
    }else{
        if(get<1>(a) != get<1>(b)){return get<1>(a) > get<1>(b);}
        else{return get<2>(a) > get<2>(b);}
    }
};


int main(){
  int N;cin>>N;
  vector<tuple<string,int,int>> data_base;
  REP(i,N){
    string tmp1;cin>>tmp1;
    int tmp2;cin>>tmp2;
    data_base.push_back(make_tuple(tmp1,tmp2,i));
  }
  sort(data_base.begin(),data_base.end(),compare_by_b_higheer);
  for(auto x:data_base){
    cout<<get<2>(x)+1<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
nk = list(map(int, input().split()))
n = nk[0]
k = nk[1]
h = list(map(int, input().split()))

#hの上からkばんめまでに必殺技を撃つのが最適解のはず
h_sorted = sorted(h)
l = 0
if k > 0 and k <= n:
    l = h_sorted[-k]
elif k > n:
    l = 0
else:
    l = 10 ** 10

r = 0
for hh in h:
    if hh < l:
        r += hh

print(r)

Measured memory_bytes: 26180
#include <bits/stdc++.h>
#define int long long
#define ALL(v) (v).begin(),(v).end()
#define Vi vector<int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>b;i--)
#define leng(n) (int)(log10(n)+1)
#define INF 9000000000000000000
using namespace std;

int gcd(int a,int b){return b?gcd(b,a%b):a;}  //  最大公約数gcd
int lcm(int a,int b){return a/gcd(a,b)*b;}  //  最小公倍数lcm

signed main() {
  int n;
  cin >> n;
  Vi a(n);
  rep(i,0,n) cin >> a[i];
  sort(ALL(a));
  cout << a[n-1]-a[0] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i) 
const long long INF = 10e9 + 7;
typedef long long ll;
using namespace std;
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; }
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	/
	/
	/
	*/
	ll n;
	cin >> n;
	ll ans = 0;
	rep0(j, n) {
		ll a;
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n, a;
  scanf("%d", &n);
  scanf("%d", &a);
  if (n % 500 <= a) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
#include <cctype>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//typedef pair<ll,ll> A;
//vector<A> pc;
//int ABS(int a){return max(a,-a);}
ll a[100000];
ll dom[100001];
 
ll gcd(ll a,ll b){
  if(b==0) return a;
  return gcd(b,a%b);
}

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(d==1) cout<<1;
  else cout<<0;
    return 0;
}

Measured memory_bytes: 256
from sys import stdin
n = int(stdin.readline().rstrip())
s = stdin.readline().rstrip()

def count(poi):
    point = 0
    for i in range(poi):
        bango = str(i).zfill(3)
        count = 0
        for j in range(n):
            if s[j] == bango[count]:
                count += 1
            if count == 3:
                point += 1
                break
    return point

print(count(1000))

Measured memory_bytes: 40048
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  vector<int> vec(n);
  for(auto &e: vec)cin>>e;
  int ans=0;
  for(int i=0;i<n-2;i++){
  	if(vec[i]<vec[i+1] && vec[i+1]<vec[i+2])ans++;
    else if(vec[i]>vec[i+1] && vec[i+1]>vec[i+2])ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
using ll=long long;
const ll MOD=1000000007,MOD2=998244353,INF=9223372036854775807;//INFはllの最大値で19桁



int main() {
    ll N,K;
    cin>>N>>K;
    ll ans=0;
    for(int i=K;i<=N+1;i++){
        ll now=i;
        now*=(N-i+1);
        now++;
        now%=MOD;
        ans+=now;
        ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <numeric>

int main() {
	int n;

	std::cin >> n;

	std::string s;

	std::cin >> s;

	int red = std::count(s.begin(), s.end(), 'R');
	int blue = s.length() - red;

	if (red > blue) {
		std::cout << "Yes" << std::endl;
	}
	else {
		std::cout << "No" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cmath>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <map>
#include <stdlib.h>
#include <set>
#include <cctype>
typedef long long ll;
using namespace std;

int main() {
	int cnt = 0, w = 0;
	bool f = true;
	string s;
	cin >> s;
	if (s.substr(0, 1) == "A") {
		for (int i = 2; i < s.length() - 1; i++) {
			if (s.substr(i, 1) == "C") {
				cnt++;
				if (cnt > 1) {
					f = false;
				}
			}
		}
		if (cnt != 1)
			f = false;
		string c = s;
		transform(s.begin(), s.end(), s.begin(), ::toupper);
		for (int i = 0; i < s.length(); i++) {
			if (s.substr(i, 1) != c.substr(i, 1)) {
				w++;
			}
		}
		if (w != s.length() - 2) {
			f = false;
		}
	} else {
		f = false;
	}
	if (f == true) {
		cout << "AC" << endl;
	} else {
		cout << "WA" << endl;
	}

	return 0;
}



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

// 周期を求めると言う方針 → OK
int main(){
    int n; ll k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    vector<int> s; // 訪れた頂点をメモ
    vector<int> ord(n+1, -1); // 訪れた回数をメモ　
    int c = 1, l = 0;
    {
        int v = 1;
        while(ord[v] == -1) {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v-1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }
    
    if (k < l) cout << s[k] << endl;
    else{
        k -= l;
        k %= c;
        cout << s[l+k] << endl;
    }
    return 0;
}

Measured memory_bytes: 5888
#include<iostream>
#include<vector>
#include<cstdlib>
#include <cmath>

#define INF 100000000
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; }

using namespace std;

int main(){
  int i,j,k,n,d,a[100];
  long long x=0;
  cin >>n;

  for(i=1;i<n+1;i++)
    x+=i-1;

  cout <<x<<endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long llu;
typedef long double ldo;
template <class C> void setmin(C &a,C b){if(a>b)a=b;}
template <class C> void setmax(C &a,C b){if(a<b)a=b;}
#define MOD				(ll)1000000007
#define pp				pair<ll,ll>
#define vll				vector<ll>
#define vpp				vector<pp>
#define forz(iter,n)	for(ll iter=0;iter<n;++iter)
#define urep(iter,s,e)	for(ll iter=s;iter>=e;--iter)
#define rep(iter,s,e)	for(ll iter=s;iter<e;++iter)
#define print(A,n)		{forz(iter,n)cout<<A[iter]<<' ';cout<<endl;}
#define printv(vec)		{for(auto const&iter:vec)cout<<iter<<' ';cout<<endl;}
#define take(A,n)		{forz(iter,n)cin>>A[iter];}
#define pb				push_back
#define pob				pop_back
#define eb				emplace_back
#define pf				push_front
#define pof				pop_front
#define mkp				make_pair
#define all(a)			a.begin(),a.end()
#define ff				first
#define ss				second
#define lcm(a,b)		(a*b)/__gcd(a,b)
#define bs(v,x)			binary_search(all(v),x)
#define ub(v,x)			upper_bound(all(v),x)		//x>a[<-pos]
#define lb(v,x)			lower_bound(all(v),x)		//x<=a[pos->]
#define zoom			ios_base::sync_with_stdio(false);cin.tie(NULL);
//for(auto const&x:mp)

int main()
{
	zoom;
	ll n,a,b;
	vll p(n);
	cin>>n>>a>>b;
	take(p,n);
	ll c[3]={0};
	forz(i,n)
	{
		if(p[i]<=a)
			c[0]++;
		else if(p[i]>b)
			c[2]++;
		else
			c[1]++;
	}
	cout<<min(c[2],min(c[0],c[1]))<<endl;
	return 0;
}

Measured memory_bytes: 33024
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int n = s.size();
    for(int i=0; i<n; i+=w)
        cout << s[i];
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
# coding: utf-8
# 整数の入力
n = input()

# 計算
def f(arg):
    s = 0
    for i in arg:
        s += int(i)
    if int(arg) % s == 0:
        return "Yes"
    else:
        return "No"

def main():
    print(f(n))

# 実行
main()

Measured memory_bytes: 3064
#include <iostream>
#include <set>
#include <string>
using namespace std ;

int main(){
    int n ; cin >> n ;
    string s ; cin >> s ;
    int ans = -1 ;
    for(int i=0;i<s.size();i++){
        set<char> a ;
        int cnt = 0 ;
        for(int j=0;j<i;j++){
            a.insert(s.at(j)) ;
        }
        for(int j=i;j<s.size();j++){
            if(a.count(s.at(j))){
                cnt++ ;
                a.erase(s.at(j)) ;
            }
        }
        if(ans<cnt) ans = cnt ;
    }
    cout << ans << endl ;
}


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

int main()
{
	long long n, k = 0;
	string s;

	cin >> n;

	if (n == 0)
		cout << 0 << endl;
	else {
		long long m = n;

		if (n < 0)
			m *= -1;

		for (int i = 0; (1ull << i) <= m; i++) {
			if ((1ull << i) & m)
				if ((i % 2 == 0 && n < 0) || (i % 2 == 1 && n > 0))
					m += (1ull << (i + 1));
		}

		while ((1ull << k) <= m)
			k++;

		for (int i = k - 1; i >= 0; i--) {
			if ((1ull << i) & m)
				s += '1';
			else
				s += '0';
		}

		cout << s << endl;
	}

	return 0;
}

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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

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

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int N;
  cin >> N;
  if (N == 1) {
    cout << "Hello World" << endl;
  } else {
    int A;
    cin >> A;
    int B;
    cin >> B;
    cout << A + B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 2e5 + 7;
const int Inf = 1 << 30;
const ll INF = 1ll << 60;
int n;
ll a[maxx], cnt[maxx];
bool vis[maxx];
ll ans;

int main() {
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
		cnt[a[i]]++;
	}
	for(int i = 1; i <= n; i++) {
		if(!vis[a[i]]) {
			vis[a[i]] = 1;
			ans += cnt[a[i]] * (cnt[a[i]] - 1) / 2;
		}
	}
	for(int i = 1; i <= n; i++) printf("%lld\n", ans - cnt[a[i]] + 1);
	return 0;
}

Measured memory_bytes: 4992
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
  var x= chunk.split(' ');
       x[0]  = Number(x[0]);
       x[1]  = Number(x[1]);
       x[2]  = Number(x[2]);
    x.sort();

console.log(x[0]+' '+x[1]+' '+x[2]);
    
  
});

Measured memory_bytes: 15592
using System;
using System.Collections.Generic;
using System.Linq;

class MainClass
{
        static void Main(string[] args)
        {
			AnswerB();
        }
  public static void AnswerB()
		{
			int N = int.Parse(Console.ReadLine());
			List<ulong> list = Console.ReadLine().Split(' ').Select(ulong.Parse).ToList();

			bool isAllEven;
			int cnt = 0;
			do
			{
				isAllEven = list.All(value => value % 2 == 0);
				if (isAllEven)
				{
					cnt++;
					list = list.Select(value => value / 2).ToList();
				}

			} while (isAllEven);
			Console.WriteLine(cnt.ToString());
		}
  
}

Measured memory_bytes: 13396
#include <stdio.h>

int main(){
   int i,j,k,l,n,b[101],a[101];
    
   scanf("%d",&n);
   for (i=1;i<=n;i++) scanf("%d",&b[i]);
   k=n-1;
   for (i=n;i>0;i--) {
      for (j=i;j>0;j--)
         if (b[j]==j) {
            a[k--]=j;
            for (l=j;l<i;l++) b[l]=b[l+1];
            break;
         }
      if (j==0) {
         puts("-1");
         return 0;
      }
   }
   for (i=0;i<n;i++) printf("%d\n",a[i]);
   return 0;
}


Measured memory_bytes: 128
import java.io.*;

public class Main {

    static final int N = 10000;

    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        long x=Long.parseLong(br.readLine());
        long sum=x/11;
        long temp=x%11;
        if(temp!=0){
            System.out.println((temp>6) ? sum*2+2:sum*2+1);
        }else{
            System.out.println(sum*2);
        }
    }
    
}


Measured memory_bytes: 8276
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int>P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template<class T> inline void chmax(T& a, T b) {
	a = std::max(a, b);
}
template<class T> inline void chmin(T& a, T b) {
	a = std::min(a, b);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n % i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
struct edge { int to, cost; };
int par[114514], rrank[114514];//親、木の深さ
void init(int n) {
	rep(i, n) {
		par[i] = i;
		rrank[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x) {
		return x;
	}
	else return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rrank[x] < rrank[y]) {
		par[x] = y;
	}
	else {
		par[y] = x;
		if (rrank[x] == rrank[y])rrank[x]++;
	}
}
bool same(int x, int y) {
	return find(x) == find(y);
}
int n;
int a[114514];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	int memo = 0, ans = 0;
	rep(i, n - 1) {
		memo += a[i];
		if (memo * 2 >= a[i + 1])ans++;
		else ans = 0;
	}
	cout << ans + 1 << endl;
	ggr
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void)
{
	int i,n,m,x,y,max,min;
	scanf("%d%d%d%d",&n,&m,&max,&min);
	for(i=0;i<n;i++){
		scanf("%d",&x);
		if(x>max)
			max=x;
	}
 
	for(i=0;i<m;i++){
		scanf("%d",&y);
		if(y<min)
			min=y;
	}
	
	if(max<min)
		printf("No War");
	else
		printf("War");
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;
ll f(ll n){
    return (n*n + 4) / 8;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    print(K * (ll)pow(K-1, N-1));
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    string s;
    cin >> s;
    bool ans = true;
    rep(i, 3) {
        if (s[i] == s[i+1]) ans = false;
    }
    cout << (ans?"Good":"Bad") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
                using namespace std;
                typedef long long ll;
                #define MAX 200005
                int arr[MAX],brr[MAX],c[MAX];
                multiset<int> s;
                int main()
                {
                    int n;
                    scanf("%d",&n);
                    for(int i = 0 ; i < n ; i++)scanf("%d",&arr[i]);
                    for(int i = 0 ; i < n ; i++)scanf("%d",&brr[i]);
                    for(int i = 0 ; i < n ; i++)c[i] = arr[i] - brr[i];
                    sort(c,c+n,greater<int>());
                    for(int i = 1 ; i < n ; i++)
                        c[i] = c[i] + c[i-1];
                    int ans = *max_element(c,c+n);
                    if(ans < 0)ans = 0;
                    printf("%d\n",ans);
                }


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

int main() {
	int n;
	long long A[100];
	cin >> n;
		for (int i = 0; i <= n; i++) {
			A[0] = 2;
			A[1] = 1;
			if (i >= 2) {
				A[i] = A[i - 1] + A[i - 2];
			}
		}
	cout << A[n] << endl;


	return 0;
}

Measured memory_bytes: 256
//-------All power is within you,you can do Anything and Everything.---------//
 
    #include <bits/stdc++.h>
    using namespace std;
  
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ M $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
 
    #define pb push_back
    #define MP make_pair
    #define F first
    #define S second
    #define sc(x) scanf("%lld",&x)
    #define pf(x) printf("%lld\n",x)
    #define int long long
    #define ld long double
    #define all(x) x.begin(),x.end() 
    #define rall(x) x.rbegin(),x.rend()
    #define fo(i,a,b) for(int i=a;i<b;i++)
    #define rfo(i,b,a) for(int i=b;i>=a;i--)
    #define mem( a, val ) memset(a, val, sizeof( a ) )
    #define deci( x ) cout<<fixed<<setprecision( x );
    #define bitcount( x ) __builtin_popcountll( x )
    #define endl "\n" 
    
    #define XOX 
    
    typedef vector<int> vi;
    typedef pair<int,int> pi; 
    
    const int INF = 1e15;
    const int MAX = 2e6 + 7;
    const int MOD =  1000000007;
    const long double PI  =3.141592653589793238463;
    const int dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
    const int dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ DEB $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
    
    #define deb(x) cout<<#x<<" "<<x<<endl;


    vector<string> vec_splitter(string s) 
    {
        for(char& c: s) c = c == ','?  ' ': c;
        stringstream ss; ss << s;
        vector<string> res;
        for(string z; ss >> z; res.push_back(z));
        return res;
    }
    void debug_out(vector<string> args, int idx) { cerr << endl; }
    template <typename Head, typename... Tail>
    void debug_out(vector<string> args, int idx, Head H, Tail... T) 
    {
        if(idx > 0) cerr << ", ";
        stringstream ss; ss << H;
        cerr << args[idx] << " = " << ss.str();
        debug_out(args, idx + 1, T...);
    }
    
    #ifdef XOX
    #define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__)
    #else
    #define debug(...) 42
    #endif

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ V $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//  
    
    int i,j,k,t,n,q,l,r,mid;

//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ F $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//

    int h1,s1,h2,s2;
    void solve()
    {
        cin>>h1>>s1>>h2>>s2;

        while(1)
        {
            h2-=s1;
            if(h2<=0)
            {
                cout<<"Yes"<<endl;
                return;
            }
            h1-=s2;
            if(h1<=0)
            {
                cout<<"No"<<endl;
                return ;
            }
        }
        
    }
    
//*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*//
//                          GAME STARTS FROM HERE                            //
 
    int32_t main() 
    {
    
        // int start,stop=clock();
        // cout<<"time:"<<(stop-start)/double(CLOCKS_PER_SEC)*1000<<endl;
        ios_base::sync_with_stdio(0);
        cin.tie(NULL);

        // sc(t);while(t--)
        // cin>>t;while(t--)
            solve();
    
        return 0;
    }

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define space " "
#define MOD (long long) 1000000007
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename T> void __f(const char* variable_name, T&& value){cout << variable_name << ": " << value << endl;}
template <typename T1, typename... T2> void __f(const char* names, T1&& arg1, T2&&... args){const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << ": " << arg1 << " |";__f(comma + 1, args...);}

const ll N = 5e5 + 5;
ll *v;
ll n;

void solve(){
    string s;
    cin >> s;
    if(s == "ABC")
        cout << "ARC" << endl;
    else    
        cout << "ABC" << endl;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll t = 1;
    // cout << "\n\nBLAH BLAH BLAH\n\n";
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i=0; i<(n); ++i)
#define per(i,n) for(int i=n-1;i>=0;++i)
#define rep1(i,n) for(int i=1; i<=n; ++i)
#define per1(i,n) for(int i=n; i>=1; ++i)
#define debug cout << "line : " << __LINE__ << " debug" << endl
#define Dcout(N) cout << setprecision(20) << N << endl
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() ) //被り削除
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define INF 1e8
#define MOD 1000000007
typedef long long ll;

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

    int n; cin >> n;
    string s; cin >> s;

    ll cnt1=0,cnt2=0,cnt3=0;

    rep(i,n){
        if(s[i]=='R') cnt1++;
        if(s[i]=='G') cnt2++;
        if(s[i]=='B') cnt3++;
    }

    ll ans = cnt1*cnt2*cnt3;

    rep1(d,n){
        rep(m,n){
            if(m-d<0 || m+d>=n) continue;

            if(s[m-d]!=s[m+d] && s[m]!=s[m+d] && s[m-d]!=s[m]) ans--;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3620
A,B,C,X,Y=map(int,input().split())
y=0
if A+B>=2*C:
  y+=2*C*min(X,Y)
  if X==Y:
      pass
  elif max(X,Y)==X:
      if A>=2*C:
        y+=2*C*(X-Y)
      else:
        y+=A*(X-Y)
  elif max(X,Y)==Y:
      if B>=2*C:
        y+=2*C*(Y-X)
      else:
        y+=B*(Y-X)
elif A+B<2*C:
  y+=A*X+B*Y
  
print(y)

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int IINF = INT_MAX;
int n,a[1010],X;

int get(int i){
  if( a[i] == IINF ) return X;
  return a[i];
}

bool check(int x){
  X = x;
  if( get(0) == get(1) ) return false;
  bool phase = ( get(0) < get(1) );
  if( !phase ) return false;
  REP(i,1,n-1){
    if( phase ) {
      if( get(i) <= get(i+1) ) return false;
    } else {
      if( get(i) >= get(i+1) ) return false;
    }
    phase = !phase;
  }
  return true;
}

void compute(){
  rep(i,n-1) if( a[i] == IINF && a[i+1] == IINF ) { puts("none"); return; }
  int cnt = 0;
  rep(i,n) if( a[i] == IINF ) ++cnt;
  if( cnt == 0 ) {
    if( check(-1) ) { puts("ambiguous"); return ; }
    else            { puts("none");      return ; }
  }
  set<int> S;
  rep(i,n) if( a[i] != IINF ) {
    if( check(a[i]+1) ) { S.insert(a[i]+1); }
    if( check(a[i]+2) ) { S.insert(a[i]+2); }
    if( check(a[i]-1) ) { S.insert(a[i]-1); }
    if( check(a[i]-2) ) { S.insert(a[i]-2); }
    if( S.size() >= 2 ) { puts("ambiguous"); return; }
  }
  if( S.size() != 1 ) { puts("none"); return; }
  cout << *S.begin() << endl;
}

int main(){
  while( cin >> n, n ){
    rep(i,n) {
      string s;
      cin >> s;
      if( s == "x" ) a[i] = IINF;
      else           a[i] = (atoi)(s.c_str());
    }
    compute();
  }
  return 0;
}

Measured memory_bytes: 1224
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String st;
		int a, b, c;
		int rectangle, diamond;

		rectangle = 0;
		diamond = 0;
		while (sc.hasNext()) {
			a = 0;
			b = 0;
			c = 0;
			st = sc.nextLine();
			for (int i = 0; i < st.length(); i++) {
				a *= 10;
				a += st.charAt(i) - '0';
				if (st.charAt(i + 1) == ',') {
					for (int j = i + 2; j < st.length(); j++) {
						b *= 10;
						b += st.charAt(j) - '0';
						if (st.charAt(j + 1) == ',') {
							for (int k = j + 2; k < st.length(); k++) {
								c *= 10;
								c += st.charAt(k) - '0';
							}
							break;
						}
					}
					break;
				}
			}
			if (a * a + b * b == c * c) {
				rectangle++;
			} else if (a == b) {
				diamond++;
			}
		}
		System.out.println(rectangle);
		System.out.println(diamond);
	}
}

Measured memory_bytes: 11000
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;

int dem[20];
int h, w, n, i, x, y, j, a, b;
map<ii, bool> painted;

main(){
	cin >> h >> w >> n;
	dem[0] = (h-2)*(w-2);
	while(n--){
		cin >> a >> b;
		a--;
		b--;
		painted[ii(a, b)] = true;
		for(x=max((int)0, a-2);x<=min(h-3, a);x++){
			for(y=max((int)0, b-2);y<=min(w-3, b);y++){
				int cnt = 0;
				for(i=x;i<=x+2;i++){
					for(j=y;j<=y+2;j++)
						if (painted[ii(i, j)])
							cnt++;
				}
				dem[cnt]++;
				dem[cnt-1]--;
			}
		}
	}
	for(i=0;i<=9;i++)
		cout << dem[i] << "\n";
}

Measured memory_bytes: 156544
#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;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<long long int> vl;
typedef vector<vector<int>> vvi;
typedef vector<vector<long long int>> vvl;
typedef pair<int, int> pii;
typedef pair<long long int, long long int> pll;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long int, long long int>> vll;
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test() long long int t; cin >> t; cin.ignore(); while(t--) 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define MOD 1000000007
#define SMOD 998244353
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sp " "
#define inp(a) ll a;cin>>a;cin.ignore()
#define inps(a,b) ll a,b;cin>>a>>b;cin.ignore()
#define out(a) cout<<SP(20)<<a<<'\n'
#define outs(a,b) cout<<SP(20)<<a<<" "<<b<<'\n'
#define ins insert
#define er erase
#define lb lower_bound
#define ub upper_bound
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define inpa(a,n) ll a[n]; for(int i=0; i<n; i++){cin>>a[i];}
#define inpv(a,n) vl a; for(int i=0; i<n; i++){inp(x);a.pb(x);}
#define outa(a,n) for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<'\n';
#define outv(v) for(auto i:v){cout<<i<<" ";}cout<<'\n';
set<char> vow = {'a','e','i','o','u','A','E','I','O','U'};
ll xpow(ll n, ll m){if(m==0){return 1;}else{ll x = xpow(n, m/2);if(m&1){return x*x*n;}else{return x*x;}}}
ll xmod(ll a, ll m){return (((a%m)+m)%m);}
ll xmodpow(ll n, ll m, ll y){if(m==0){return 1;}else{ll x = xmodpow(n, m/2, y);if(m&1){return xmod((xmod((xmod(x,y)*xmod(x,y)),y)*xmod(n,y)),y);}else{return xmod((xmod(x,y)*xmod(x,y)),y);}}}
 
int main(){
    fast();
 
/* you get what you work for not what you wish for */
    
    ll a, b, c;
    cin >> a >> b >> c;
    ll z = min(a, c);
    c-=z;
    a-=z;
    z = min(b, c);
    b-=z;
    c-=z;
    outs(a, b);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Graph=vector<vector<int>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
typedef long long ll;
int main(){
    string S;
    cin>>S;
    if(S.at(S.size()-1)=='3'){
        cout<<"bon"<<endl;
    }
    else if(S.at(S.size()-1)=='0'||S.at(S.size()-1)=='1'||S.at(S.size()-1)=='6'||S.at(S.size()-1)=='8'){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"hon"<<endl;
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int N,A,B; cin>>N>>A>>B;

    if((B - A + 1) % 2 == 0) cout << "Borys" << endl;
    else cout << "Alice" << endl;
    return 0;
}



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



void solve() {
  int a, b, h;
  cin >> a >> b >> h;
  cout << ((a + b) * h) / 2;
}

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <complex>
#include <fstream>
#include <cmath>

using namespace std;

int main(void){
    int a, b, c;
    cin >> a >> b >> c;
    cout << (((b-a)==(c-b)) ? "YES" : "NO" ) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
public static void main(String[] args){
    Scanner sc = new Scanner(System.in);

    while(true){
    int n = sc.nextInt();
    if(n==0){
        break;
    }
    int [] student;
    int sum=0;
    double ave=0,sub=0,varisum=0,vari=0;
    int i;
    student = new int[n];

    for(i=0;i<n;i++){
        student[i]=sc.nextInt();
        sum =sum+student[i];
    }
    ave = (double)sum/n;

    for(i=0;i<n;i++){
        sub = (student[i]-ave)*(student[i]-ave);
        varisum = varisum+sub;
    }

    vari = (double)varisum/n;


    System.out.printf("%f\n",Math.sqrt(vari));


}

   


    sc.close();

}

}


Measured memory_bytes: 31864
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld long double
const int N =1e2;
int a,b,c;
int main(){
     scanf("%d %d %d",&a,&b,&c);
     printf("%d\n",((a+b)*c)/2);
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, X, M = MAP()
ans = 0
flag = False
L = []
dic = dict()
for i in range(1, N+1):
    if X % M not in L:
        L.append(X % M)
    else:
        flag = True
        tmp = X % M
        l = len(L)
        break
    X = (X % M) ** 2
if flag == True:
    index = L.index(tmp)
    nR = L[:index]
    R = L[index:]
    amari = (N - len(nR)) % len(R)
    ans = sum(nR) + (N - len(nR)) // len(R) * sum(R) + sum(R[:amari])
    print(ans)    
else:
    ans = sum(L)
    print(ans)

Measured memory_bytes: 75824
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
const int maxn=105;
const int maxw=1e5+5;
int w[maxn];
ll v[maxn],maxx[maxw];
int main()
{
    int N,W;
    scanf("%d%d",&N,&W);
    for(int i=1;i<=N;i++)
        scanf("%d%lld",&w[i],&v[i]);
    for(int i=1;i<=N;i++)
        for(int j=W;j>=w[i];j--)
            maxx[j]=max(maxx[j],maxx[j-w[i]]+v[i]);
    ll ans=0;
    for(int i=1;i<=W;i++)
        ans=max(ans,maxx[i]);
    printf("%lld\n",ans);
    return 0;
}


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

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


int main(){

  int n;cin>>n;
  int p[n],q[n];
  rep(i,0,n)cin>>p[i];
  rep(i,0,n)cin>>q[i];

  int tp[n],tq[n];
  memcpy(tp,p,sizeof(p));
  memcpy(tq,q,sizeof(q));
  sort(tp,tp+n);
  sort(tq,tq+n);

  int pc=1;
  do{
    bool e=true;
    rep(i,0,n){
      if(tp[i]!=p[i]){
        e=false;
        break;
      }
    }
    if(e)break;
    else pc++;

  }while(next_permutation(tp,tp+n));

  int qc=1;
  do{

    bool e=true;
    rep(i,0,n){
      if(tq[i]!=q[i]){
        e=false;
        break;
      }
    }
    if(e)break;
    else qc++;

  }while(next_permutation(tq,tq+n));

  // out(pc);
  // out(qc);

  out(abs(pc-qc));
  // set<int>p,q;
  //  int array[]={1,2,3,4};
  //   do{
  //       for(int i=0; i<4; i++){
  //           cout<<array[i];
  //           if(i!=3)cout<<" ";
  //       }
  //       cout<<endl;
  //   }while(next_permutation(array,array+4));
  // rep(i,0,n){
  //   int r;cin>>r;
  //   p.insert(r);
  // }
  // rep(i,0,n){
  //   int r;cin>>r;
  //   q.insert(r);
  // }

  // int pp=0,qq=0;

  // int pn,qn;

  // for(set<int>::iterator itr=p.begin();itr!=p.end();itr++){
  //   if()
  // }





  return 0;
}


Measured memory_bytes: 256
package main

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

type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) PrintLn(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntLn(a []int) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func (io *Io) PrintStringLn(a []string) {
	b := []interface{}{}
	for _, x := range a {
		b = append(b, x)
	}
	io.PrintLn(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

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

func intMax(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func main() {
	// var ap [100000]int
	// var bp [100000]int
	// var x, y, c, p int

	io := NewIo()
	defer io.Flush()
	H := uint64(io.NextInt())
	M := uint64(io.NextInt())

	res := uint64(0)
	if H == 1 || M == 1 {
		res = 1
	} else if (H%2) == 1 && (M%2) == 1 {
		res = H*M/2 + 1
	} else {
		res = H * M / 2
	}
	// fmt.Printf("%v %v %v\n", H, M, res)
	io.PrintLn(res)

	// amin := 10000000
	// for i := 0; i < A; i++ {
	// 	ap[i] = io.NextInt()
	// 	if amin > ap[i] {
	// 		amin = ap[i]
	// 	}
	// }

	// bmin := 100000000
	// for i := 0; i < B; i++ {
	// 	bp[i] = io.NextInt()
	// 	if bmin > bp[i] {
	// 		bmin = bp[i]
	// 	}
	// }

	// min := amin + bmin

	// for i := 0; i < M; i++ {
	// 	x = io.NextInt()
	// 	y = io.NextInt()
	// 	c = io.NextInt()
	// 	p = ap[x-1] + bp[y-1] - c
	// 	if min > p {
	// 		min = p
	// 	}
	// }
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
int main()
{
	int num;
	
	while(1)
	{
		scanf("%d",&num);
		if(num==0)break;
		int i;
		int pointa,pointb;
		int *a,*b;
		a=(int *)malloc(sizeof(int)*num);
		b=(int *)malloc(sizeof(int)*num);
		for(i=0;i<num;i++)
		{
			int carda,cardb;
			scanf("%d %d",&carda,&cardb);
			a[i]=carda;
			b[i]=cardb;
		}
		pointa=0;pointb=0;
		for(i=0;i<num;i++)
		{
			if(a[i]>b[i])
			{
				pointa+=a[i]+b[i];
			}
			else if(a[i]<b[i])
			{
				pointb+=a[i]+b[i];
			}
			else 
			{
				pointa+=a[i];
				pointb+=b[i];
			}
		}

		printf("%d %d\n",pointa,pointb);
		free(a);free(b);
	}
  return 0;
}

Measured memory_bytes: 676
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long
#define MOD 1000000007

int main(){
  int N;
  cin >> N;
  vector<int> C(N);
  for(int i=0; i<N; i++)
    cin >> C[i];
  C.push_back(0);
  map<int, vector<int> > mp;
  for(int i=0; i<N; i++) {
    if(C[i] != C[i+1]) {
      if(mp.find(C[i]) != mp.end()) {
	mp[C[i]].push_back(i);
      } else {
	mp[C[i]] = vector<int>(1, i);
      }
    }
  }

  // for(map<int, vector<int> >::iterator it=mp.begin(); it!=mp.end(); it++) {
  //   cout << it->first << ": ";
  //   vector<int> v = it->second;
  //   for(int i=0; i<v.size(); i++) {
  //     cout << v[i] << ' ';
  //   }
  //   cout << endl;
  // }

  vector<ll> dp(N, 0);
  map<int, int> idx;
  for(map<int, vector<int> >::iterator it=mp.begin(); it!=mp.end(); it++) {
    idx[it->first] = 1;
  }
  dp[0] = 1;
  for(int i=0; i<N; i++) {
    if(i != 0) {
      dp[i] += dp[i-1];
      dp[i] %= MOD;
    }
    if(C[i] != C[i+1]) {
      int tmp = C[i];
      vector<int> tmpV = mp[tmp];
      if(idx[tmp] < tmpV.size()) {
	dp[tmpV[idx[tmp]]] += dp[i];
	dp[tmpV[idx[tmp]]] %= MOD;
	idx[tmp]++;
      }
    }
  }
  // for(int i=0; i<N; i++)
  //   cout << dp[i] << " ";
  // cout << endl;
  cout << dp[N-1] << endl;

  return 0;
}

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

using namespace std;

using ll = long long;

template<typename T> using V = std::vector<T>;
using Vi = V<int>;
using VVi = V<V<int>>;
using Vl = V<ll>;
using VVl = V<V<ll>>;
using Vs = V<string>;

template<typename T1, typename T2> using P = std::pair<T1, T2>;
using Pii = P<int, int>;
using Pll = P<ll, ll>;
using Pdd = P<double, double>;

template<typename T1, typename T2> using M = std::map<T1, T2>;
using Mii = M<int, int>;
using Msi = M<string, int>;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REP2(i,s,e) for(int i=(int)(s);i<(int)(e);++i)
#define RREP(i,s,e) for(int i=(int)(s);i>=(int)(e);--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin(),ie=(c).end();i!=ie;++i)
#define ALL(c) (c).begin(), (c).end()

const double PI = acos(-1);
const ll MOD = 1e9+7;

int n, w, h;
string s;
V<Pii> dir = {{1, 0}, {1, 1}, {1, -1}, {0, 1}, {0, -1}, {-1, 0}, {-1, 1}, {-1, -1}};

int main() {
    while (true) {
        cin >> w >> h;
        if (w == 0 && h == 0) {
            break;
        }

        VVi land(h, Vi(w));
        REP(i, h) REP(j, w) cin >> land[i][j];

        int res = 0;
        stack<Pii> s;
        while (true) {
            REP(i, h) {
                REP(j, w) {
                    if (land[i][j] == 1) {
                        s.push({i, j});
                        break;
                    }
                }
                if (!s.empty()) break;
            }
            if (s.empty()) break;

            res++;
            while (!s.empty()) {
                int y = s.top().first, x = s.top().second;
                s.pop();
                if (land[y][x] == 0) continue;
                land[y][x] = 0;
                FOR(i, dir) {
                    int Y = y + i->first, X = x + i->second;
                    if (Y < 0 || X < 0 || Y >= h || X >= w) continue;
                    if (land[Y][X] == 0) continue;
                    s.push({Y, X});
                }
            }
        }
        std::cout << res << '\n';
    }

    return 0;
}



Measured memory_bytes: 3236
#include <iostream>
#include <algorithm>

using namespace std;

int main (void) {

  char n[4];
  char j;
  int cnt = 0;

  for (int i = 0; i < 4; i++) {
    cin >> n[i];
  }

  for (int i = 0; i < 4; i++) {
    if (n[i] == j || i == 0) {
      cnt++;
    } else {
      cnt = 1;
    }
    j = n[i];
    if (cnt >= 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
    
  return 0;
  
}

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

int main()
{
    string S;
    cin >> S;
    cout << S.substr(0, S.length() - 8) << endl;
    ;
}


Measured memory_bytes: 256