akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){
    int x, y;
    scanf("%d %d", &x, &y);

    if((x%2 == 0 && y%2 == 0) || (x%2 != 0 && y%2 != 0))
        printf("%d\n", (x+y)/2);
    else
        printf("%d\n", ((y+x)/2)+1);
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
  public static void main( String[] args ) {
	  Scanner scan = new Scanner(System.in);
	  String S = scan.next();
	  int strLen = S.length();
	  String ans = "";
	  for( int i = 0; i < strLen; i++ )ans += "x";
	  System.out.println(ans);
  }
}

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

int main() {
  int N;
  cin>>N;
  
  for(int i=0;i<N;i++){
    string x;
    cin>>x;
     if(x=="Y"){
       cout <<"Four"<<endl;
       break;
     }
    else if (N-1==i){
      cout<<"Three"<<endl;
      break;
    }
    else if (x=="P"||x=="G"||x=="W"){
      continue;
       
    }
    
    cout<<"Three"<<endl;
  
  }

 
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 int main(){
 int a,b,c;
 cin>>a>>b>>c;
 if(a==b && b==c)cout<<1<<endl;
 else if(a!=b && b!=c && a!=c)cout<<3<<endl;
 else  cout<<2<<endl;
 return 0;
}

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

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

		Arrays.parallelSort(a);
		for (int i = 0; i < k; i++) {
			a[2] *= 2;
		}
		System.out.println(a[0] + a[1] + a[2]);
	}
}


Measured memory_bytes: 23252
#include <iostream>
using namespace std;
#define ll long long
const char nl = '\n';
int main() {
   ll A, B; cin >> A >> B;
    char C; cin >> C;
    int D; cin >> D;
    B *= 100; B += D;
    ll X = A*B; X /= 100;
    cout << X << nl;
	return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e15;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    (a *= a) %= MOD;
    n >>= 1;
  }
  return res;
}

const ll maxf = 10000000;
ll fact[maxf+5];

void fact_init(){
  fact[0] = 1;
  for(ll i=1; i<=maxf; i++){
    fact[i] = (fact[i-1] * i) % MOD;
  }
}

ll comb(ll a, ll b){
  if(a<b || a<0 || b<0) return 0;
  if(fact[0] == 0) fact_init();
  return (fact[a] * modpow((fact[a-b]*fact[b])%MOD, MOD-2)) % MOD;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,k; cin>>n>>k;
  ll mod=1;
  rep(i,100){
    mod=(mod*10)%MOD;
  }
  set<ll> s;
  rep(i,n+1){
    s.insert((mod+i)%MOD);
  }
  ll m=s.size();
  // cout<<m<<endl;
  ll ans=0;
  ireps(i,k,n+1){
    ll min=(i-1)*i/2;
    ll max=(n+1)*n/2-(n-i+1)*(n-i)/2;
    // cout<<min<<" "<<max<<" "<<max-min<<endl;
    ans=(ans+max-min+1)%MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 12992
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cout << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cout << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

vector<vint> G;
vint par, ans;
bool visited[100010];

int dfs(int v, int p) {
	if (visited[v]) return 0;
	visited[v] = true;
	par[v] = p;
	ans[v] = 1;
	rep(i,G[v].size()) {
		ans[v] +=  dfs(G[v][i], v);
	}
	return ans[v];
}

int main() {
	int N = in();
	G.resize(N);
	par.resize(N);
	ans.resize(N);
	rep(i,N) {
		int a = in(); int b = in();
		a--; b--;
		G[a].pb(b); G[b].pb(a);
	}
	dfs(0, 0);
	int pathlen = 1;
	for (int v = N - 1; v; v = par[v]) pathlen++;
	int snuke = N-1;
	rep(i,(pathlen-2)/2) snuke = par[snuke];
	int S = ans[snuke];
	int F = N - S;
	if (F > S) cout << "Fennec" << endl;
	else cout << "Snuke" << endl;
	return 0;
}


Measured memory_bytes: 11264
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
# Set - Disjoint Set: Union Find Tree

class DisjointSet
  def initialize(size)
    @parent = Array.new(size, 0)
    @rank = Array.new(size, 0)
    size.times { |i| @parent[i] = i }
  end

  def find_set(x)
    @parent[x] = find_set(@parent[x]) if x != @parent[x]
    @parent[x]
  end

  def union(x, y)
    link(find_set(x), find_set(y))
  end

  def same_set?(x, y)
    find_set(x) == find_set(y)
  end

  private

  def link(x, y)
    if @rank[x] > @rank[y]
      @parent[y] = x
    else
      @parent[x] = y
      if @rank[x] == @rank[y]
        @rank[y] = @rank[y] + 1
      end
    end
  end
end

n, q = gets.split.map(&:to_i)
ds = DisjointSet.new(n + 1)
q.times do
  com, x, y = gets.split.map(&:to_i)
  if com.zero?
    ds.union(x, y)
  elsif com == 1
    puts ds.same_set?(x, y) ? 1 : 0
  end
end



Measured memory_bytes: 7036
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define mp make_pair
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const int M=1e9+7;

int32_t main(){
    IOS;
    int x;
    cin>>x;
    int sum=100;
    int ans;
    for(int i=1;;i++){
    	if(sum>=x){ans=i-1;break;}
    	ans=i;
    	sum=sum+sum/100;
    }
    cout<<ans<<endl;
}


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

char moge1[10];
char moge2[10];
char c[20];

int main() {

	int a,b;

	scanf("%d %d",&a,&b);

	sprintf(moge1, "%d", a);
	sprintf(moge2, "%d", b);

	int i;

	for(i=0;i<strlen(moge1);i++){
		c[i]=moge1[i];
	}
	for(i=0;i<strlen(moge2);i++){
		c[strlen(moge1)+i]=moge2[i];
	}


	for(i=1;i<=1000;i++){
		if(i*i==atoi(c)){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
#ifdef DEBUG
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)\
	{cerr << #a << " = {";\
	for(int qwq = (st); qwq <= (n); ++qwq) {\
		if(qwq == (st)) cerr << a[qwq];\
		else cerr << ", " << a[qwq];\
	} cerr << "}" << endl;}
#define displayv(v) displaya(v, 0, (int)(v).size() - 1)
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(v) ;
#define eprintf(...) if(0) fprintf(stderr, "...")
#endif
template<typename T> bool chmin(T &a, const T &b) { return a > b ? a = b, true : false; }
template<typename T> bool chmax(T &a, const T &b) { return a < b ? a = b, true : false; }

int main() {
	ios::sync_with_stdio(false);
	LL S, a, b, c, d;
	cin >> S;
	a = 1000000000;
	d = (S + a - 1) / a;
	c = 1;
	b = a * d - S;
	printf("%lld %lld %lld %lld %lld %lld\n", 0ll, 0ll, a, c, b, d);
	return 0;
}


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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

constexpr int inf = 1.01e9;
constexpr i64 inf64 = 4.01e18;
constexpr double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

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

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

template <typename A, typename T, size_t size>
void fill(A (&ary)[size], const T &val) {
    fill((T *)ary, (T *)(ary + size), val);
}

void solve() {
    //constexpr i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;
    vector<i64> A(N);
    rep(i,0,N) cin >> A[i];

    multiset<i64> st;
    rep(i,0,N){
        if(st.empty()){
            st.insert(A[i]);
            continue;
        }
        auto ub=st.lower_bound(A[i]);
            if(ub==begin(st)){
                st.insert(A[i]);

                print("B");
                continue;
            }
            auto it=ub;
            --it;
            st.erase(it);
            st.insert(A[i]);
            print("C");
    }

    cout << st.size() << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;

#define INF (1LL << 60)
#define MOD 1000000007

#define REP(i,m,n) for(ll (i)=(m),i_len=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back
#define mp make_pair

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

int main()
{
    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    ll L = C * D / gcd(C, D);
    ll P = B / C - (A - 1) / C;
    ll Q = B / D - (A - 1) / D;
    ll R = B / L - (A - 1) / L;
    PR(B-A+1-P-Q+R);

    return 0;
}

/*



*/

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String arg[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		sc.close();
		int count = 0;
		
		for(int a = 0; a <= A; a++) {
			for(int b = 0; b <= B; b++) {
				for(int c = 0; c <= C; c++) {
					if(X == a*500 + b*100 + c*50) {
						count++;
					}
				}
			}
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23508
import java.util.Scanner;

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

        long N = scanner.nextLong();

        StringBuilder builder = new StringBuilder();
        while (N > 0) {
            N--;
            builder.append((char)('a' + N % 26));
            N /= 26;
        }

        System.out.println(builder.reverse());
    }
}


Measured memory_bytes: 35620
#include<bits/stdc++.h>
#define ll long long 
#define inf 0x7fffffff
#define clr(c) memset(c,0,sizeof(c))
using namespace std;
int mod=998244353;
const int M=1e6+10;
const int N=1e5+10;
inline ll read(){
    ll b=1,sum=0; char c=getchar();
    while(!isdigit(c)){if(c=='-') b=-1; c=getchar();}
    while(isdigit(c)){sum=sum*10+c-'0'; c=getchar();}
    return b*sum;
}
int n,m,k,T;
ll ans,yu;

int main() 
{
    int i,j;
	n=read();
	m=read();
	for(i=1;i<=m;i++) {
		int x=read();
		n-=x;
	}
	if(n<0) n=-1;
	printf("%d",n);
    return 0;
}


Measured memory_bytes: 3764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String s = br.readLine();

		int x = Integer.parseInt(s);

		System.out.println(x*x*x);
	}
}

Measured memory_bytes: 16856
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

pll A[200000] = {};

int main(void) {

	lli N;
	cin >> N;

	FOR(N) {
		cin >> A[i].second >> A[i].first;
	}

	sort(A, A + N);

	lli sum = 0;

	FOR(N) {
		sum += A[i].second;
		if (sum > A[i].first) {
			COUT("No");
			return 0;
		}
	}

	COUT("Yes");

	return 0;
}

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

int main()
{
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++)
    {
        for (int j = 0; j <= X; j++)
        {
            if (2 * i + 4 * j == Y && i + j == X)
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n') *_q = 0; } while(0)

int main(){
    int n;
    while(cin >> n, n){
        int v[5001] = {0};
        int p = 0;
        int max = INT_MIN;
        REP(i, n){
            int in;
            cin >> in;
            REP(j, i+1){
                v[j] += in;
                max = MAX(max, v[j]);
                //printf("%d ", v[j]);
            }
            //printf("\n");
        }
        cout << max << endl;
    }
    return 0;
}

Measured memory_bytes: 1188
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << b ? "Yes" : "No"; }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }



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

	int sum = 0;
	for (int i = 1; i <= N; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
		{
		}
		else
		{
			sum += i;
		}
	}
	cout << sum << endl;
}




Measured memory_bytes: 3568
#include<iostream>

using namespace std;

int main() {
	
	char A; 
	int sum[26] = {};
	
	while( cin >> A ) {
	
		if( A > 96 && A < 123 )
		sum[A-97]++;
		else if( A > 64 && A < 91 )
		sum[A-65]++;
	
}
	char letters = 96;
	
	for(int i=0;i<26;i++) {
		
	letters++;
	cout << letters << " : " << sum[i] << "\n";

	}
	return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << ": " << x << endl;

using namespace std;
typedef long long ll;

signed main() {
  char c;
  cin >> c;

  if(c - 'a' < 26 && c - 'a' >= 0) {
    cout << 'a' << endl;
  } else {
    cout << 'A' << endl;
  }

  return 0;
}


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

using namespace std;

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

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

    vector<vector<double>> dp(n, vector<double>(n+1));
    dp[0][1]=A[0];
    dp[0][0]=(1-A[0]);
    for(int i=1;i<n;i++){
        dp[i][0]=dp[i-1][0]*(1-A[i]);
        for(int j=1;j<=i+1;j++){
            dp[i][j]=dp[i-1][j-1]*A[i]+dp[i-1][j]*(1-A[i]);
        }
    }

    double ans=0;
    int last=n/2;
    for(int i=n;i>last;i--){
        ans+=(dp[n-1][i]);
    }

    cout<<setprecision(10)<<ans<<endl;

}

Measured memory_bytes: 73796
x = gets.chomp.to_i
# A, B, C = gets.chomp.split.map(&:to_i)
# S = gets.chomp.chars

def grad(x)
  if x <= 599
    return 8
  elsif x <= 799
    return 7
  elsif x <= 999
    return 6
  elsif x <= 1199
    return 5
  elsif x <= 1399
    return 4
  elsif x <= 1599
    return 3
  elsif x <= 1799
    return 2
  else
    return 1
  end
end

puts grad(x)

Measured memory_bytes: 14340
using System;
using System.Collections.Generic;
using System.IO;

namespace aoj
{
    public class QQ

    {
        public static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false};
            Console.SetOut(sw);

            for (var i=1; i < 10; i++)
            {
                for(var j=1; j < 10; j++)
                {
                    Console.WriteLine(i + "x" + j + "=" + i*j);
                }

            }
            Console.Out.Flush();
        }

    }
}

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

int n,m;
int a[1001];
int cap[1001];
int dp[1001][1<<12];

int main(){
	
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif

	cin >> n >> m;
	for(int i=1;i<=m;i++){
		cin >> a[i];
		int b;
		cin >> b;
		for(int j=0;j<b;j++){
			int x;
			cin >> x;
			x--;
			cap[i] = cap[i]|(1<<x);
		}
	}
	for(int i=1;i<(1<<n);i++) dp[0][i]=1000000001;

	for(int i=1;i<=m;i++){
		dp[i][0]=0;
		for(int j=1;j<(1<<n);j++){
			dp[i][j]=1000000001;
			int old = j;
			for(int k=0;k<n;k++){
				if(cap[i]&(1<<k) && j&(1<<k)){
					old=old^(1<<k);
				}
			}
			dp[i][j]=min(a[i]+dp[i-1][old],dp[i-1][j]);
			// cout << i << " " << j << " " << dp[i][j] << endl;  
		}
	}
	if(dp[m][(1<<n)-1]>1000000000) cout << "-1";
	else cout << dp[m][(1<<n)-1];




	


 
 
	
 
}

Measured memory_bytes: 16256
#include<iostream>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  int A[M];
  int homework=0;
  int dull=N;
  for(int i=1;i<=M;i++){
    cin>>A[i];
    homework+=A[i];
    dull-=A[i];
  }
  int hima=N-homework;
  if(hima<0)hima=-1;
  
  if(dull<0)dull=-1;
  cout<<dull<<endl;
}


Measured memory_bytes: 3672
#include <stdio.h>

int main(void)
{
    int x,y;
    

    while (1)
    {
        scanf("%d %d",&x,&y);
        if (x == 0 && y == 0)
        {
            break;
        }
        if(x <= y){
            printf("%d %d\n",x,y);
        }
        else if(x >= y){
            printf("%d %d\n",y,x);
        }
    }
}


Measured memory_bytes: 1944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(...) cerr << "[(" << __LINE__ << ") " << (#__VA_ARGS__) << "]: " << __VA_ARGS__ << endl;

int gcd(int a, int b) {
    if (a > b)
        swap(a, b);
    int c;
    while (b != 0) {
        c = a%b;
        a = b;
        b = c;
    }
    return a;
}

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

    ll sm=0;

    for (int i=1; i<k+1; i++) {
        for (int j=1; j<k+1; j++) {
            int tans = gcd(i, j);
            for (int l=1; l<k+1; l++) {
                sm += gcd(tans, l);
            }
        }
    }
    cout << sm << "\n";

}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

void solve() {
    ll n; cin >> n;
    ll ans = (n / 500) * 1000;
    n %= 500;
    ll tmp = n/5;
    ans += tmp*5;
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 764
n = int(input())
heights = [int(i) for i in input().split()]

intermediate = [None for i in range(n)]
for i in range(n, 0, -1):
    h = heights[i - 1]
    if i == n:
        intermediate[i - 1] = 0
    elif i == n - 1:
        intermediate[i - 1] = abs(h - heights[-1])
    else:
        intermediate[i - 1] = min(
            abs(h - heights[i]) + intermediate[i],
            abs(h - heights[i + 1]) + intermediate[i + 1],
        )

print(intermediate[0])


Measured memory_bytes: 13928
import sys
input = sys.stdin.readline
n = int(input()) # 入力が1つ

matrix = []
for _ in range(2):
    row = [int(i) for i in input().split()]
    matrix.append(row)

ans = 0
for i in range(n):
    t = sum(matrix[0][:i + 1]) + sum(matrix[1][i:])
    ans = max(ans, t)
print(ans)

Measured memory_bytes: 38512
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	cin >> N;
	ll a[N + 10];
	for (ll i = 0; i < N; i++) {
		cin >> a[i];
	}
	ll cnt0_mod4 = 0;
	ll cnt0_mod2 = 0;
	ll cnt2_mod4 = 0;
	for (ll i = 0; i < N; i++) {
		if (a[i] % 4 == 0)
			cnt0_mod4++;
		if (a[i] % 4 == 2)
			cnt2_mod4++;
	}
	 if (cnt0_mod4 + (cnt2_mod4) / 2 >= N / 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}








Measured memory_bytes: 1024
/*Saurav Paul*/
#include<bits/stdc++.h>
using namespace std;

#define ll 					  long long int
#define boost		          ios_base::sync_with_stdio(0);


int main()
{
	boost ;
	string s ; cin >> s;
	int cnt = 0;
	for(int i = 0 , j = s.size() -1 ; i < j ; i++ , j--){
		if(s[i]!=s[j])
			cnt ++;
	}
	cout << cnt << endl ;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    string S;
    cin >> S;

    size_t end_add = S.length();

    if(S[end_add - 1] == (int)'s'){
        cout << S + "es" << endl;
    }else{
        cout << S + "s" << endl;
    }

}



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

int a, b;

int main() { 
	cin >> a >> b;
	if (a%b == 0) {
		cout << -1 << endl;
	}
	else {
		for(int i=a;i+=a;){
			if (i%b != 0) {
				cout << i << endl;
				return 0;
			}
		}
	}

	return 0;
}

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

char str[1009];
char st2[7]="Hoshino";

int main(void)
{
	int n,sp;
	int i,j,l;
	
	scanf("%d ",&n);
	for(i=0;i<n;i++){
		fgets(str,sizeof(str),stdin);
		sp=strlen(str);
		for(j=0;j<sp;j++){
			for(l=0;l<7;l++){
				if(str[j+l]==st2[l]){
					if(l==6){
						str[j+l]='a';
					}
				}
				else break;
			}
		}
		printf("%s",str);
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int, int >
#define F first
#define S second
#define int  long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("O2")
#pragma GCC optimize ("unroll-loops")
using namespace std;
const int N=2e5+100,mod=1e9+7;
int32_t main(){
    ll a,b,c;
    cin >> a >> b >> c;
    if (c>a) c-=a;
    else {
        cout << a-c << " " << b << endl;
        return 0;
    }
    if (c>b){
        cout << 0 << " " << 0 << endl;
        return 0;
    }
    b-=c;
    cout << 0 << " " << b << endl;

}


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

int main()
{
    int n;
    cin >> n;
    string t;
    map<char,int> mp;
    mp['M'] = 0;
    mp['A'] = 0;
    mp['R'] = 0;
    mp['C'] = 0;
    mp['H'] = 0;
    for(int i = 0; i < n; i++){
        cin >> t;
        if(mp.find(t[0]) == mp.end())
            mp[t[0]] = 1;
        else
            mp[t[0]]++;
    }
    long m = mp['M'],a = mp['A'],r = mp['R'], c= mp['C'], h = mp['H'],sum=0;
    sum += m*a*r;
    sum += m*a*c;
    sum += m*a*h;
    sum += m*r*c;
    sum += m*r*h;
    sum += m*c*h;
    sum += a*r*c;
    sum += a*r*h;
    sum += a*c*h;
    sum += r*c*h;
    cout << sum;
}

Measured memory_bytes: 256
from sys import exit
def dfs(i,f,sum):
  if i == n-1:
    if sum ==7:
      print(f+"=7")
      exit()
      
  else:
    dfs(i + 1, f + "+" + s[i + 1], sum+int(s[i+1]))
    dfs(i + 1, f + "-" + s[i + 1], sum-int(s[i+1]))



s=input()
n=len(s)
dfs(0, s[0],int(s[0]))

Measured memory_bytes: 38484
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
int bdx[]={0,1,1,1,0,-1,-1,-1};
int bdy[]={-1,-1,0,1,1,1,0,-1};
int wdx[]={0,1,0,-1};
int wdy[]={-1,0,1,0};
int h,w;
vector<int>v[10000];
bool used[111][111];
string s[111];
void Input(){
  memset(used,0,sizeof(used));
  r(i,10000)v[i].clear();
  r(i,111)s[i]="";
  r(i,h)cin>>s[i+1],s[i+1]='.'+s[i+1]+'.';
  h+=2;w+=2;
  r(i,w)s[0]+='.',s[h-1]+='.';
}
int cnt;
void tree(int d,int y,int x,int c){
  set<P>::iterator it;
  queue<P>q;
  set<P>st;
  q.push(P(y,x));
  used[y][x]=1;
  while(!q.empty()){
    P p=q.front();q.pop();
    if(d%2){
      r(i,8){
        int ny=p.first+bdy[i];
        int nx=p.second+bdx[i];
        if(ny<0||nx<0||ny>=h||nx>=w)continue;
        if(used[ny][nx])continue;
        if(s[ny][nx]==s[y][x]){
          used[ny][nx]=1;
          q.push(P(ny,nx));
        }
        else st.insert(P(ny,nx));
      }
    }
    else{
      r(i,4){
        int ny=p.first+wdy[i];
        int nx=p.second+wdx[i];
        if(ny<0||nx<0||ny>=h||nx>=w)continue;
        if(used[ny][nx])continue;
        if(s[ny][nx]==s[y][x]){
          used[ny][nx]=1;
          q.push(P(ny,nx));
        }
        else st.insert(P(ny,nx));
      }
    }
  }
  for(it=st.begin();it!=st.end();it++){
    int ny=(*it).first;
    int nx=(*it).second;
    if(used[ny][nx])continue;
    v[c].push_back(cnt+1);
    cnt++;
    tree(d+1,ny,nx,cnt);
  }

}

string isomo(int x){
  string res;
  vector<string>vs;
  r(i,v[x].size()){
    vs.push_back(isomo(v[x][i]));
  }
  sort(vs.begin(),vs.end());
  r(i,vs.size()){
    res+=vs[i];
  }
  return '('+res+')';
}
signed main(){
  while(cin>>h>>w,h){
    cnt=0;
    Input();
    tree(0,0,0,cnt);
    string s1=isomo(0);
    cin>>h>>w;
    cnt=0;
    Input();
    tree(0,0,0,cnt);
    string s2=isomo(0);
    cout<<(s1==s2?"yes":"no")<<endl;
  }
}


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

const long long INF = 1LL<<60;
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;}

/*vector<long long> h(100010);
vector<long long> dp(100010,INF);
int main(){
int N,K;cin>>N>>K;
for(int i=0;i<N;i++) cin>>h[i];
dp[0]=0;
for(int i=0;i<N;i++){
    for(int k=1;k<=K;k++){
        chmin(dp[i+k],dp[i]+abs(h[i]-h[i+k]));
    }
}
cout<<dp[N-1]<<endl;
    return 0;
}*/

/*vector<vector<int>> h(100010,vector<int>(3,0));
vector<vector<int>> dp(100010,vector<int>(3,0));//pairでもよさそう
int main(){
    int N;cin>>N;
    for(int i=0;i<N;i++){
        for(int j=0;j<3;j++){
            cin>>h[i][j];
        }
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<3;k++){
                if(j!=k) chmax(dp[i][k],dp[i-1][j]+h[i-1][k]);//chmaxの後ろが+h[i-1][j]じゃなくてh[i-1][k]なのは前日にした以外の行動が2通りあり、その2つでもkのfor文で比較する必要があるため。
            }
        }
    }
    int ans=0;
    for(int i=0;i<3;i++){
        ans=max(dp[N][i],ans);
    }
    cout<<ans<<endl;
    return 0;
}*/

vector<vector<long long>> dp(105,vector<long long>(100010,0));
int main(){
    int N,W;cin>>N>>W;
    vector<long long> w(105,0),v(105,0);
    for(int i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    for(int i=1;i<=N;i++){
        for(int j=0;j<=W;j++){//jは擬似的な重量制限Wともいえそう
            if(j>=w[i-1]) chmax(dp[i][j],dp[i-1][j-w[i-1]]+v[i-1]);
            chmax(dp[i][j],dp[i-1][j]);//ifを通過した後でも通らなければいけないのはなぜ？
                                       //確かに通ったところで結果は変わらない気がするが→それはこの問題では価値vがすべて正の値で設定されているためと考えられる
          //→ if(j>=w[i-1]) dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
            //else dp[i][j]=dp[i-1][j];
            //と同義らしい。確かにそうかも
            //chmaxは求めたい値を一度づつしか比較できないものと考えられる(maxを使うとifの条件の2パターンの同時比較が可能)
            //dp[i][j]とdp[i-1][j]の比較を2つめのchmaxでelseの条件のやつと同時に行っているようだ.
            //elseの方の条件だったらそもそもif文通らないしな       
        }                              
    }
    cout<<dp[N][W]<<endl;
    return 0;
}

Measured memory_bytes: 83328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll h,w;
	ll dx[4]={1,0,-1,0};
	ll dy[4]={0,1,0,-1};
	cin>>h>>w;
	char ch[22][22];
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			cin>>ch[i][j];
		}
	}
	ll ans=0;
	for(ll i=0;i<h;i++){
		for(ll j=0;j<w;j++){
			for(ll k=0;k<h;k++){
				for(ll l=0;l<w;l++){
					ll cnt[22][22];
					if(ch[i][j]=='#'||ch[k][l]=='#'){
						continue;
					}
					for(ll m=0;m<h;m++){
						for(ll n=0;n<w;n++){
							cnt[m][n]=-1;
						}
					}
					cnt[i][j]=0;
					queue<pair<ll,ll>>q;
					q.push(make_pair(i,j));
					while(q.size()!=0){
						pair<ll,ll> now;
						now=q.front();
						q.pop();
						ll nowx=now.first;
						ll nowy=now.second;
						if(nowx==k&&nowy==l){
							ans=max(ans,cnt[nowx][nowy]);
							break;
						}
						for(ll i=0;i<4;i++){
							ll nexx=nowx+dx[i];
							ll nexy=nowy+dy[i];
							if(nexx<0||nexx==h||nexy<0||nexy==w){
								continue;
							}
							if(ch[nexx][nexy]=='#'){
								continue;
							}
							if(cnt[nexx][nexy]!=-1){
								continue;
							}
							cnt[nexx][nexy]=cnt[nowx][nowy]+1;
							q.push(make_pair(nexx,nexy));
						}
					}
				}
			}
		}
	}
	cout <<ans;
	return 0;
}

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



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

    int diff=100000000;
    int test,testdiff,ans;

    for(int i=0;i<s.size()-2;i++){
        test = (int(s[i])-48) * 100 + (int(s[i+1])-48)*10 + int(s[i+2])-48;
        testdiff = abs(753-test);
        if(testdiff<diff){
            ans = testdiff;
            diff = testdiff;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import (division, absolute_import, print_function,
                        unicode_literals)
from sys import stdin
from math import copysign


def gradient(p):
    def fn(t):
        dx = p[0] - t[0]
        dy = p[1] - t[1]
        if dx:
            return dy / dx
        return copysign(float('inf'), -dy)
    return fn


def solve(n):
    L = []
    for i in range(n):
        L.append(tuple(float(s) for s in stdin.readline().split(',')))
    L.sort()

    p = p0 = L.pop(0)
    while True:
        p = max((t for t in L if t[0] >= p[0]), key=gradient(p))
        if p == L[-1]:
            break
        L.remove(p)

    p = p0
    while True:
        p = min((t for t in L if t[0] >= p[0]), key=gradient(p))
        if p == L[-1]:
            break
        L.remove(p)

    return len(L) - 1

while True:
    n = int(stdin.readline())
    if not n:
        break
    print(solve(n))

Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string S;
  cin >> S;
  int length = S.length();
  for(int i=1;i<length/2;i++){
    S.erase(S.length()-2);
    if(S.substr(S.length()/2)==S.substr(0,S.length()/2)){
      cout<<S.length()<<endl;
      return 0;
    }
  }
  return 0;
}


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

int main() {
    string n;
    cin >> n;
    bool flag = false;
    rep(i, 3) if(n.at(i) == '7') flag = true;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main(){
  int ans = 0;
  double n, m, border;
  double sum = 0;

  cin >> n >> m;

  vector<double> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);

    sum = sum + vec.at(i);
  }

  border = sum / (4 * m);

  for(int i = 0; i < n; i++){
    if(vec.at(i) >= border){
      ans++;
    }
  }

  if(ans >= m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}



Measured memory_bytes: 256
S = str(input())

dp = [[0]*13 for _ in range(100001)]

dp[0][0] = 1

for i in range(len(S)):  # Sへのアクセスは0-index
    for remain in range(13):
        if S[i] == '?':
            for j in range(10):
                next_remain = (remain*10 + j) % 13
                # dpの遷移
                dp[i+1][next_remain] += dp[i][remain]
                dp[i+1][next_remain] %= 1000000007
        else:
            next_remain = (remain*10 + int(S[i])) % 13
            # dpの遷移
            dp[i+1][next_remain] += dp[i][remain]
            dp[i+1][next_remain] %= 1000000007

print(dp[(len(S))][5])


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vll>;
using vb = vector<bool>;

const int INF = 2e9+5;
const ll LLINF = (1LL << 60) + 5;

/*
  filippos
  Contest : AtCoder DP contest
  Task : B - Frog 2
*/

int main(){
  cin.tie(0), cin.sync_with_stdio(0), cout.tie(0), cout.sync_with_stdio(0);

  int n, k; cin >> n >> k;
  vi v(n);
  for(int &i : v)
    cin >> i;

  vi dp(n);
  for(int i = n-2; i >= 0; i--){
    dp[i] = INF;
    for(int j = 1; j <= k && i + j < n; j++)
      dp[i] = min(dp[i], dp[i + j] + abs(v[i] - v[i+j]));
  }

  cout << dp[0];
  
  return cout << endl, 0;
}

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

int main(){
    int n;
    cin >> n;
    int d,x; cin >> d >> x;
    int a[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=d;j+=a[i]){
            ans++;
        }
    }
    cout << ans+x << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
from itertools import accumulate

buf = []
while True:
    n, m = map(int, input().split())
    if n == 0:
        break
    hs = [int(input()) for _ in range(n)]
    ws = [int(input()) for _ in range(m)]
    ha = [0] + list(accumulate(hs))
    wa = [0] + list(accumulate(ws))
    hd = defaultdict(int)
    wd = defaultdict(int)

    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            hd[ha[j] - ha[i]] += 1
    for i in range(m + 1):
        for j in range(i + 1, m + 1):
            wd[wa[j] - wa[i]] += 1
    ans = 0
    for h, cnt in hd.items():
        if h in wd:
            ans += cnt * wd[h]
    buf.append(ans)

print('\n'.join(map(str, buf)))

Measured memory_bytes: 63128
#include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define dec(i, n)  decID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define SI(v) static_cast<int>(v.size())
#define RF(e, v) for(auto & e: v)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
#define IN(T, ...) T __VA_ARGS__; IN_(__VA_ARGS__);
void IN_() { };
template<typename T, typename ... U> void IN_(T & a, U & ... b) { cin >> a; IN_(b ...); };
template<typename T> void OUT(T && a) { cout << a << endl; }
template<typename T, typename ... U> void OUT(T && a, U && ... b) { cout << a << " "; OUT(b ...); }

// ---- ----

template<typename T> istream & operator>>(istream & s, vector<T> & v) { RF(e, v) { s >> e; } return s; }
template<typename T> ostream & operator<<(ostream & s, vector<T> const & v) {
	inc(i, SI(v)) { s << (i == 0 ? "" : " ") << v[i]; }
	return s;
}

int main() {
	IN(int, n);
	vector<int> a(n);
	cin >> a;
	
	bool ans = true;
	inc(i, n) { ans &= (a[i] % 2 != 0 || a[i] % 3 == 0 || a[i] % 5 == 0); }
	OUT(ans ? "APPROVED" : "DENIED");
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#pragma warning(disable:4996)
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include<cstring>
#include <stack>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include <string>
#define itn int
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define F2(i,a,b) for(int i=a;i<(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
const int maxn = 100 + 6;
const int maxa = 1000 * 1000 * 1000 + 7;
typedef long long ll;
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;
int t, n, m, T;
int main()
{
#ifdef _DEBUG
	freopen("D:\\input.txt", "r", stdin);
	//	freopen("E:\\output.txt", "w", stdout);
#endif
	int i, j;
	std::ios::sync_with_stdio(false); cin.tie(0);	cout.tie(0);
	int x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	priority_queue<int,vector<int>,greater<int>>red,green;
	vector<int> p(a), q(b), r(c);
	for (int i = 0; i < a; i++) {
		cin >> p[i];
		red.push(p[i]);
		if (red.size() > x)red.pop();
	}for (int i = 0; i < b; i++) {
		cin >> q[i];
		green.push(q[i]);
		if (green.size() > y)green.pop();
	}for (int i = 0; i < c; i++) {
		cin >> r[i];
	}
	sort(r.begin(), r.end());
	while (r.size()&&(r.back() > red.top() || r.back() > green.top())) {
		if (red.top() > green.top()) {
			green.pop();
			green.push(r.back());
			r.pop_back();
		}
		else {
			red.pop();
			red.push(r.back());
			r.pop_back();
		}
	}
	ll sum = 0;
	while (red.size()) {
		sum += red.top();
		red.pop();
	}
	while (green.size()) {
		sum += green.top();
		green.pop();
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 2552
program ABC081B
    implicit none
    integer(8)::N,i,calc,ans=1000000000
    integer(8),allocatable::A(:)
    read*,N
    allocate(A(N))
    read*,A

    do i=1,N
        calc=0
        do
            if(mod(A(i),2)==1)exit
            A(i)=A(i)/2
            calc=calc+1
        end do
        ans=min(ans,calc)
    end do
    print'(i0)',ans
end program ABC081B

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

int main() {
	int n,k;
	cin >> n >> k;
	int ans = 0;
	rep(i, n) {
		int h;
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
# k = gets.chomp.to_i
# # if k % 7 != 0
# #     puts "-1"
# #     exit
# # end
# kai = k 
# i = 1
# kou = 10
# kazu = 1 
# hantei = 9 * kai + 7
# # p hantei
# # if hantei % 7 != 0
# #     puts "-1"
# #     exit
# # end
# # hantei = hantei / 7
# # if hantei % 10 != 0
# #     puts "-1"
# #     exit
# # end

# k = k / 7
# k = k * 9 + 1
# while true
#     if i % (kai / 7) == 0
#         puts kazu
#         break
#     else
#         i = i + kou ** kazu
#         kazu += 1
#     end

# end


# p k

# k = gets.chomp.to_i
# a = 0
# i = 0
# arr = [k+1]
# mod = k+1
# until mod == 0
#     a = 7 + 10 * a #7,77..を書いた
#     mod = a % k
#     if arr.include?(mod) || i == k
#         puts "-1"
#         exit
#     end
#     arr << mod 
#     i += 1
# end
# puts i

k = gets.chomp.to_i
i = 1
a = 7 % k
hazime = a
arr = [-1]
if k != 7
    until a == 0 
        a = (7 + a * 10) % k
        if a == hazime || i == k
            puts arr.shift
            exit
        end
        i += 1
    end
else
    puts "1"
    exit
end
puts i

Measured memory_bytes: 14444
#include<iostream>
#include<algorithm>
#include<limits.h>

using namespace std;

const long long MOD = 2019;

int main()
{
    long long l, r, lmod, rmod, minx;
    minx = LONG_MAX;
    cin>>l>>r;
    lmod = l % MOD;
    rmod = r % MOD;
    if(r-l>=MOD)
    {
        cout<<0;
        return 0;
    }
    if(rmod>lmod)
        for(int i=lmod;i<=rmod-1;i++)
            for(int j=i+1;j<=rmod;j++)
                minx = min(minx,(i*j)%MOD);
    else
    {
        cout<<0;
        return 0;
    }
    
    cout<<minx;
    
}

Measured memory_bytes: 256
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: usize
    }
    println!("{}", n.pow(3));
}
/* vim:set foldmethod=marker: */


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

int N;
vector<int> arr;
deque<int> dq;

int main() {
    scanf("%d", &N);
    arr.resize(N);
    for(int i = 0; i < N; i++) {
        scanf("%d", &arr[i]);
    }

    bool l = (N % 2);
    for(int i = 0; i < N; i++) {
        if(l) dq.push_front(arr[i]);
        else dq.push_back(arr[i]);
        l ^= 1;
    }

    for(int i = 0; i < N; i++) {
        printf("%d ", dq.front());
        dq.pop_front();
    }
}


Measured memory_bytes: 3840
//created by missever
 
#include<bits/stdc++.h>
#define MAX 1000000007
using namespace std;
typedef long long LL;
 
int main() {
    int n,m,i;
LL s = 1;
    scanf("%d%d",&n,&m);
    if(n < m) swap(n,m);
    if(n - m <= 1){
        for(i = 1;i <= n; i++) s = 1LL * s * i % MAX;
        for(i = 1;i <= m; i++) s = 1LL * s * i % MAX;
        if(n == m) s = 1LL * s * 2 % MAX;
    }
    else s = 0;
    printf("%lld\n",s);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());

typedef long long ll;

int main(){

  int n,m;
  cin >> n >> m;
  cout << n*(n-1)/2+m*(m-1)/2 << endl;
  
}


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

/*
最大のケースはN=10,M=10の時
1,1,1,1,1,1,1,1,1,1から
1,2,3,4,5,6,7,8,9,10まで
これが計算可能な個数に収まればよい -> 92378らしいのでOK
*/

typedef struct 	s_data
{
	int a;
	int b;
	int c;
	int d;
}				t_data;

int A[10];
t_data data[51];
int ans;

void dfs(int A[10], int num, int end, int max, t_data data[51], int q)
{
	if (num == end)
	{
		int tmp = 0;
		for (int i = 0; i <= q; i++)
		{
			if (A[data[i].b] - A[data[i].a] == data[i].c) tmp += data[i].d;
		}
		ans = std::max(ans, tmp);
		return ;
	}
	int pre;
	if (num == 0) pre = 1;
	else pre = A[num - 1];
	for (int i = pre; i <= max; i++)
	{
		A[num] = i;
		dfs(A, num + 1, end, max, data, q);
	}
}

int	main(void)
{
	int n, m, q;
	std::cin >> n >> m >> q;
	for (int i = 0; i < q; i++)
	{
		std::cin >> data[i].a >> data[i].b >> data[i].c >> data[i].d;
		data[i].a--; data[i].b--;
	}
	dfs(A, 0, n, m, data, q);
	std::cout << ans << std::endl;
	return (0);
}


Measured memory_bytes: 3604