akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> namespace mp = boost::multiprecision; //mp::cpp_intで宣言
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
//ll inf=(ll)1E12;//10^12
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////
#define N 1004

ll kai[N];
ll kai2[N];
ll po(ll i,ll p){
    if(p==0)return 1;
    else if(p==1)return mod(i);
    else if(p%2==0)return mod(po(mod(mod(i)*mod(i)),p/2));
    else  return mod(mod(i)*mod(po(i,p-1)));
}
void calc(){
    kai[0]=1;
    kai2[0]=1;
    for(int i=1;i<N;i++){
        kai[i]=mod(kai[i-1]*i);
        kai2[i]=mod(po(kai[i],i_5));
    }
}
ll comb(ll n,ll k){
    if(n==0){
        if(k==0)return 1;
        else return 0;
    }
    else if(n<k)return 0;
    else return mod(mod(mod(kai[n])*mod(kai2[n-k]))*mod(kai2[k]));
}
ll c[8];
ll d(int a){
    if(a<=-1)return 1;
    else return c[a];
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    calc();
    ll h,w,k;cin>>h>>w>>k;
    if(w==1){
        cout<<1;return 0;
    }
    if(w==2){
        ll ans=0;
        rep(i,0,h){
            if(i%2==k-1){
                Add(&ans,comb(h,i));
            }
        }
        cout<<ans;return 0;
    }
    
    memset(c,0,sizeof(c));
    rep(i,0,7){
        rep(j,0,(1<<i)-1){
            bool flag=true;
            rep(k,0,i-2){
                if((j>>k)&1&&(j>>(k+1))&1)flag=false;
            }
            if(flag)c[i]++;
        }
    }
    //rep(i,0,7)cout<<i<<" "<<c[i]<<endl;
    
    ll dp[h+1][w];memset(dp,0,sizeof(dp));
    dp[0][0]=1;
    rep(i,1,h){
        rep(j,0,w-1){
            
            Add(&dp[i][j],mod(dp[i-1][j]*d(j-1)*d(w-j-2)));
            if(j+1<=w-1)Add(&dp[i][j],mod(dp[i-1][j+1]*d(j-1)*d(w-j-3)));
            if(j-1>=0)Add(&dp[i][j],mod(dp[i-1][j-1]*d(j-2)*d(w-j-2)));
            
        }
    }
   /* rep(i,0,h){
        rep(j,0,w-1){
            cout<<dp[i][j]<<" ";
        }cout<<endl;
    }*/
    cout<<mod(dp[h][k-1])<<endl;
    return 0;
}
//ios::sync_with_stdio(false);cin.tie(0);




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int p[N],count=0;
  for(int i=0;i<N;i++) cin>>p[i];
  for(int i=0;i<N;i++) if(p[i]!=i+1) count++;
  cout<<(count>2?"NO":"YES")<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
const int MOD = 1000000007;
const int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;



signed main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  string S;
  cin >> S;
  if(S[2] == S[3] && S[4] == S[5]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

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

  if (c=='a' || c=='e' || c=='i' || c=='o' || c=='u') {
    cout << "vowel" << endl;
  }
    
  else {
    cout << "consonant" << endl;
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   int n, m;
   cin >> n >> m;
   vector<int> a(n);
   rep(i, 0, n) cin >> a[i];
   int sum = 0;
   rep(i, 0, n) sum += a[i];
   int cnt = 0;
   rep(i, 0, n) {
      if (a[i] >= sum / (4.0 * m)) {
         cnt++;
      }
   }
   if (cnt >= m)
      cout << "Yes" << endl;
   else
      cout << "No" << endl;
   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int main()
{
  char s[13];
  scanf("%s",&s);
  int i;
  i = 0;
  while (s[i])
  {
    printf("%c",s[i]);
    if (i == 3)
    {
      printf(" ");
    }
    i++;
  }
  printf("\n");
}

Measured memory_bytes: 128
using System.Numerics;
using static System.Math;
using System;

class Modulo
{
    private const int MOD = 1000000007;
    private readonly int[] m_facs;
    public int Mul(int a, int b) => (int)(Math.BigMul(a, b) % MOD);
    public Modulo(int n)
    {
        m_facs = new int[n + 1];
        m_facs[0] = 1;
        for (int i = 1; i <= n; ++i)
            m_facs[i] = Mul(m_facs[i - 1], i);
    }
    public int Fac(int n) => m_facs[n];
    public int Pow(int a, int m)
    {
        switch (m)
        {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                int p1 = Pow(a, m / 2);
                int p2 = Mul(p1, p1);
                return ((m % 2) == 0) ? p2 : Mul(p2, a);
        }
    }
    public int Div(int a, int b) => Mul(a, Pow(b, MOD - 2));
    public int Ncr(int n, int r)
    {
        if (n < r) return 0;
        if (n == r) return 1;
        int res = Fac(n);
        res = Div(res, Fac(r));
        res = Div(res, Fac(n - r));
        return res;
    }
}

public class Hello
{
    public const int MOD = 1000000007;
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        var b = int.Parse(line[2]);
        var c = new Modulo(Max(a, b));
        var ans1 = (long)(BigInteger.ModPow(2, n, MOD) - 1);
        var ans2 = c.Div((int)getFac(n, a), c.Fac(a));
        var ans3 = c.Div((int)getFac(n, b), c.Fac(b));
        long ans = (ans1 - ans2 - ans3) % MOD;
        if (ans < 0) ans += MOD;
        Console.WriteLine(ans);
    }
    static long getFac(int n, int a)
    {
        var ans = 1L;
        for (int i = n - a + 1; i <= n; i++)
        {
            ans *= i;
            ans %= MOD;
        }
        return ans;
    }
}


Measured memory_bytes: 13664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s; cin>>s;
    if(s=="AAA"||s=="BBB")cout<<"No";
    else cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
int A,B,C,X,count=0,i,j,k;
scanf("%d",&A);
scanf("%d",&B);
scanf("%d",&C);
scanf("%d",&X);
for(i=0;i<=A;i++){
 for(j=0;j<=B;j++){
  for(k=0;k<=C;k++){
   if((500*i+100*j+50*k)==X) count++;
}
}
}
printf("%d",count);
return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int n[3];
	int i, j;
	int tmp;
	
	scanf("%d %d %d", &n[0], &n[1], &n[2]);
	
	for (i = 0; i < 3; i++){
		for (j = 1; j < 3; j++){
			if (n[j - 1] > n[j]){
				tmp = n[j];
				n[j] = n[j - 1];
				n[j - 1] = tmp;
			}
		}
	}
	
	printf("%d %d %d\n", n[0], n[1], n[2]);
	
	return (0);
}

Measured memory_bytes: 596
from sys import stdin
from collections import OrderedDict
import math


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    D,G = list(map(int,_in[0].split(' ')))  # type:list(int)
    p_c_arr = []
    for i in range(D):
        _ = list(map(int,_in[i+1].split(' ')))  # type:list(int)
        p_c_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = float('inf')
    for bit in range(1<<D):
        score = 0
        prob = 0
        cache = OrderedDict()
        for i in range(D-1,-1,-1):
            if bit&(1<<i):
                score += 100*(i+1)*p_c_arr[i][0]+p_c_arr[i][1]
                prob += p_c_arr[i][0]
            else:
                cache[i+1] = p_c_arr[i]
        else:
            if score < G:
                for k,v in cache.items():
                    if G-score <= 100*k*(v[0]-1):
                        prob += math.ceil((G-score)/(100*k))
                        break
                    elif G-score <= 100*k*v[0]+v[1]:
                        prob += v[0]
                        break
                    else:
                        score += 100*k*v[0]+v[1]
                        prob += v[0]
        cnt = min(cnt,prob)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 48492
// https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c

#include "algorithm"
#include "bitset"
#include "cmath"
#include "functional"
#include "iomanip"
#include "iostream"
#include "map"
#include "numeric"
#include "queue"
#include "set"
#include "string"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define rep1(i, to) for (ll i = 1; i <= (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define unless(cond) if (!(cond))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef long double ld;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;

template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}

const ll INF = 1e18;

void solve();

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

void solve() {
  ll N;
  string S;
  cin >> N >> S;

  // 左から i 個を白にするコスト
  VL white_costs(N + 1);
  // 右から i 個を黒にするコスト
  VL black_costs(N + 1);

  rep(i, N) { white_costs[i + 1] = white_costs[i] + (S[i] == '#'); }
  rep(i, N) { black_costs[i + 1] = black_costs[i] + (S[N - 1 - i] == '.'); }

  ll res = INF;

  rep(i, N + 1) { chmin(res, white_costs[i] + black_costs[N - i]); }

  cout << res << "\n";
}


Measured memory_bytes: 3732
#include<iostream>
#include<algorithm>
#include<string>
#include<functional>
#include<utility>
#include<stack>
#include<queue>
#include<cmath>
#include<list>
#include<cstdint>
#include<vector>
#include<map>
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;

ll nCr(ll n, ll r) {
	if (r > n) { return 0; }
	if (r * 2 > n) r = n - r;
	ll dividend = 1;
	ll divisor = 1;
	for (ll i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}
ll sumdigit(ll n) {
	ll dig = 0, sum = 0;
	while (n) {
		dig = n % 10;
		sum = sum + dig;
		n = n / 10;
	}
	return sum;
}



int main() {
	std::string n,suba,subb;
	int count = 0;
	bool flug = true;
	std::cin >> n;
	rep(i, n.length()) {
		suba = n[i];
		rep(j, n.length()) {
			subb = n[j];
			if (suba == subb) {
				count++;
			}
		}
		if (count > 1) {
			std::cout << "no" << std::endl;
			return 0;
		}
		count = 0;
	}
	std::cout << "yes" << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int x = 0, i,N,result = 0;
	char s[100];

	scanf("%d", &N);
	scanf("%s", &s);

	for (i = 0; i < N; i++)
	{
		if (s[i] == 'I')
		{
			x += 1;
			if (result < x)
			{
				result = x;
			}
		}
		if (s[i] == 'D')
		{
			x -= 1;
			if (result < x)
			{
				result = x;
			}
		}
	}
	printf("%d\n", result);
	return 0;
}

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

int main() {
    string S; cin >> S;
    int ans = 0;
    for (int i = 1; i <= S.length(); i++) {
        for (int j = 0; j <= S.length()-i; j++) {
            string t = S.substr(j, i);
            bool flag = true;
            for (int k = 0; k < t.length(); k++) {
                if (t[k] != 'A' && t[k] != 'C' && t[k] != 'G' && t[k] != 'T') {
                    flag = false;
                    break;
                }
            }
            if (flag) ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define nmax 100000
#define qmax 50000

int main(){
  int i,j;
  int n,q;
  int left = 0;
  int right;
  int mid;
  int S[nmax];
  int T[qmax];
  int count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }
  for(i=0;i<q;i++){
    right = n;
    left = 0;
  while(left<right){
    mid = (left + right)/2;
    if(S[mid] == T[i]){
      count++;
      break;
    }
    else if(T[i] < S[mid]) right = mid;
    else left = mid+1;
  }
  }
  printf("%d\n",count);

  
}



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

using Int = long long;
const char newl = '\n';

template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}
template<typename T=int>
vector<T> read(size_t n){
  vector<T> ts(n);
  for(size_t i=0;i<n;i++) cin>>ts[i];
  return ts;
}

//INSERT ABOVE HERE
const int MAX = 2e6;
int dp[MAX]={};
int cnt[MAX]={};

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

  int n;
  cin>>n;
  auto as=read(n);
  int g=as[0];
  for(int a:as) g=gcd(g,a);
  if(g!=1) drop("not coprime");

  for(int i=2;i<MAX;i++){
    if(dp[i]) continue;
    for(int j=i;j<MAX;j+=i) dp[j]=i;
  }

  for(int a:as){
    int t=a;
    while(t!=1){
      int p=dp[t];
      while(t%p==0) t/=p;
      cnt[p]++;
    }
  }

  if(*max_element(cnt,cnt+MAX)>1) drop("setwise coprime");

  drop("pairwise coprime");
  return 0;
}


Measured memory_bytes: 19120
#include<iostream>
#include<math.h>
#include<stdio.h>
using namespace std;
int main() {
    double r,R,S;
    
    cin >> r;
    
    R = 2 * M_PI * r;
    
    S = M_PI * r * r;
    
    printf("%f %f", S, R);
    
    return 0;
}


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

#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define IN(type,a) type a;cin >> a


using ll = long long;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

int main(void) {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];

    ll ret = 0;
    REP(i, 29) {
        vector<ll> va(a), vb(b);
        const ll t = 1LL<<i;
        REP(j, n) {
            va[j] %= t<<1;
            vb[j] %= t<<1;
        }
        sort(ALL(vb));
        ll num = 0;
        REP(j, n) {
            // [t-va[j],2t-va[j]) 
            {
                auto itr1 = lower_bound(ALL(vb), t-va[j]) - vb.begin();
                auto itr2 = lower_bound(ALL(vb), 2*t-va[j]) - vb.begin();
                num += itr2 - itr1;
            }
            // [3t-va[j],4t-va[j])
            {
                auto itr1 = lower_bound(ALL(vb), 3*t-va[j]) - vb.begin();
                auto itr2 = lower_bound(ALL(vb), 4*t-va[j]) - vb.begin();
                num += itr2 - itr1;
            }
        }
        if(num%2) ret |= t;
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 6572
import java.util.Scanner;

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

        while (true) {
            n = Integer.parseInt(sc.next());
            x = Integer.parseInt(sc.next());
            int cnt = 0;
            if (n == 0 && x == 0) {
                break;
            }

            for (int i = 1; i <= n; i++) {
                for (int j = i + 1; j <= n; j++) {
                    for (int k = j + 1; k <= n; k++) {
                        if (i + j + k == x) {
                            cnt++;
                        }
                    }
                }
            }
            System.out.println(cnt);
        }

        sc.close();
    }
}


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

#define int long long
#define ld  double
#define pii pair<int,int>
#define vi vector<int>
#define pb push_back
#define f first
#define s second
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;


ld maximum(ld a, ld b){
 	if (a > b){
		return a;
	}
	return b;
}


ld expectation(int n){
	ld x = n;
	return (x+1)/2;
}


signed main(){
	cout << fixed << setprecision(15);
	int n, k;
	cin >> n >> k;

	int p[n];
	ld prefix[n];	
	
	for (int i = 0; i < n; ++i)
	{
		cin >> p[i];
		if (i == 0){
			prefix[i] = expectation(p[i]);
		}
		else{
			prefix[i] = expectation(p[i]) + prefix[i - 1];
		}
	}

	ld res;
	if (k == n){
		res = prefix[n-1];
	}
	else{
		res = maximum(0, prefix[0]);	
		for (int i = 0; i < n-k; ++i)
		{	
			res = maximum(prefix[i+k] - prefix[i], res); 
		}
	}
	
	cout << res << endl;
	return 0;
}



/*

*/

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static Scanner sc;
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		int n[]=new int[500];
		int r[]=new int[500];
		int i=0;
		int count=0;
		int p[][]=new int[500][500];
		int c[][]=new int[500][500];
		//入力
		for(;;) {
			n[i]=sc.nextInt();
			r[i]=sc.nextInt();
			if(n[i]==0&&r[i]==0) {
				break;
			}
			for(int j=1;j<=r[i];j++) {//j回目のシャッフル
				p[i][j]=sc.nextInt();
				c[i][j]=sc.nextInt();
			}
			i++;
			count++;
		}
		//演算
		i=0;
		int cards[][]=new int[500][500];
		for(;;) {
			if(n[i]==0&&r[i]==0) {
				break;
			}
			for(int k=1;k<=n[i];k++) {
				cards[i][k]=n[i]-k+1;
			}
			for(int j=1;j<=r[i];j++) {
				int w[]=new int[50];
				System.arraycopy(cards[i], p[i][j], w, 0,c[i][j]);
				System.arraycopy(cards[i], 1, cards[i], c[i][j]+1, p[i][j]-1);
				System.arraycopy(w, 0, cards[i],1 , c[i][j]);
			}
			i++;
		}
		//出力
		for(i=0;i<count;i++) {
			System.out.println(cards[i][1]);
		}
	}
}


Measured memory_bytes: 40280
N=int(input())
h=list(map(int, input().split()))

dp=[float("inf")]*N
dp[0]=0

for i in range(1, N):
	if i==1:
		dp[i]=min(dp[i], abs(h[i]-h[i-1]))
	else:
		dp[i]=min(dp[i], dp[i-1]+abs(h[i]-h[i-1]))
		dp[i]=min(dp[i], dp[i-2]+abs(h[i]-h[i-2]))

print(dp[-1])

Measured memory_bytes: 20460
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using V = vector<int>;
using Vll = vector<ll>;
using VV = vector<V>;
using VVll = vector<Vll>;

char s[1000000];

int main() {
  int n, q;
  scanf("%d%s%d", &n, s, &q);

  VVll t(3, Vll(n+1));
  VV pos(3, V());
  string dmc = "DMC";

  rep(i, n) rep(j, 3) {
    t[j][i+1] = t[j][i];
    if (s[i] == dmc[j]) {
      ++t[j][i+1];
      pos[j].push_back(i);
    }
  }

  rep(_, q) {
    int k; 
    scanf("%d", &k);
    ll ans = 0;
    for (auto c : pos[2]) ans += t[1][c] * (t[0][c] - t[0][max(c-k+1, 0)]);
    for (auto a : pos[0]) ans -= t[1][a+1] * (t[2][min(a+k, n)] - t[2][a+1]);
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 32888
N=int(input())
N_max=10**5

Trig=[0]
k=1
T=0
while T<=N_max:
    T+=k
    k+=1
    Trig.append(T)

try:
    K=Trig.index(N)+1
except:
    print("No")
    exit()
S=[set() for _ in range(K)]
m=0
for i in range(K):
    for j in range(i+1,K):
        m+=1
        S[i].add(m)
        S[j].add(m)

print("Yes")
print(K)
X=[""]*K
for i in range(K):
    X[i]="{} ".format(len(S[i]))+" ".join(map(str,S[i]))

print("\n".join(X))

Measured memory_bytes: 82792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

//困ったら全探索
//全探索をしろ
//範囲を絞ればACするはずだ

int main(){
    int a,b;
    cin>>a>>b;
    if (a==b)
        cout << "Draw" << endl;
    else if (a==1)
        cout << "Alice" << endl;
    else if (b==1)
        cout << "Bob" << endl;
    else if (a>b)
        cout << "Alice" << endl;
    else if (b>a)
        cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <cstdlib>
#include <utility>
#include <map>
#include <set>
#include <ios>
#include <iomanip>
#include <functional>
#include <queue>

#define int long long
int inf = (1LL <<  62);
using namespace std;

signed main(){
    int a, p;
    cin >> a >> p;
    cout << (a * 3 + p) / 2;
}


Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  q=collections.deque(s)

  ans=0
  while len(q)>1:
    if q[0]==q[-1]:
      q.popleft()
      q.pop()
    else:
      if q[0]=='x':
        q.append('x')
      elif q[-1]=='x':
        q.appendleft('x')
      else:
        return -1
      ans+=1
  
  return ans


# main()
print(main())


Measured memory_bytes: 5960
n = int(input())
a = [int(input()) for _ in range(n)]
s = sum(a)
if s % 10 != 0:
    print(s)
else:
    for i in range(n):
        if min(a) % 10 != 0:
            print(s - min(a))
            break
        a.remove(min(a))
    else:
        print(0)

Measured memory_bytes: 9164
/**
     **author : _KMS_
     **created : 05-03-2020
**/
#include<bits/stdc++.h>
using namespace std;
const long long M =6e5,MOD=1e9+7;
typedef long long ll;
ll mi=100;
int main() {
      
   ios::sync_with_stdio(false);
   cin.tie(0);
   ll n;
   cin>>n;
   for(ll i=1;i*i<=n;i++)
   {
         if(n%i==0)
         {
               ll d=i;
               ll d1=n/i;
               ll cnt=0,cnt2=0;
               while(d>0)
               {
                     cnt++;
                     d/=10;
               }
                 while(d1>0)
               {
                     cnt2++;
                     d1/=10;
               }
               mi=min(mi,max(cnt,cnt2));
         }
   }
   cout<<mi<<endl;
  
   
   return 0;
}

Measured memory_bytes: 256
import std.stdio, std.string, std.array, std.conv;

void main() {
    int n = readln.chomp.to!int;
    int[] a = readln.split.to!(int[]);
    double sum = 0;
    foreach (x; a) {
        sum += 1.0 / x;
    }
    writefln("%.8f", 1.0 / sum);
}

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

 int main() {

int N ;
cin >> N;
vector<int>A(200);

for(int i=0; i<N; i++) cin >> A.at(i) ;
int res = 0;

while(true){
        bool fl = false ;
        for(int i=0; i<N; i++){
               if(A.at(i)%2 == 0) {
                       A.at(i) = A.at(i) / 2;
               }
               else{ 
                        fl = true ;
                        break;
                }
         }
        if(fl) break;
        res = res + 1;
}
cout << res << endl;

}


Measured memory_bytes: 256
n,m = map(int,input().split())

l = [[0 for i in range(m)]for j in range(n)]
b = [0 for k in range(m)]
c = [0 for l in range(n)]

for i in range(n):
    l[i] = list(map(int,input().split()))

for j in range(m):
    b[j] = int(input())

for i in range(n):
    for j in range(m):
        c[i] += l[i][j]*b[j]
    print(c[i])


Measured memory_bytes: 6028
# ある行について、
# 最初のイチゴが出てから、次のイチゴの手前までを一つの番号とする
# それ以降は、次のイチゴが出る手前までを次の番号とする
# イチゴがない行があったら、となりの行の結果をコピーする

import sys
readline = sys.stdin.readline

H,W,K = map(int,readline().split())
A = [readline().rstrip() for i in range(H)]
ans = [[0] * W for i in range(H)]
exist_straw = [True] * H
num = 0 # 次の番号
for i in range(H):
  # イチゴがない行はいったん後回し
  if "#" not in A[i]:
    exist_straw[i] = False
    continue
  num += 1
  # イチゴが出たらnumを1増やしてから更新　ただし最初のイチゴは無視
  first = True
  for j in range(W):
    if A[i][j] == "#":
      if first:
        first = False
      else:
        num += 1
    ans[i][j] = num

# 行を上から順に見て、ある行にはイチゴが存在して、次の行には存在しない場合、行をコピーする
# それを逆順も実行すると全ての行が埋まる

for i in range(H - 1):
  if exist_straw[i] and not exist_straw[i + 1]:
    ans[i + 1] = ans[i]
    exist_straw[i + 1] = True

for i in range(H - 1,0,-1):
  if exist_straw[i] and not exist_straw[i - 1]:
    ans[i - 1] = ans[i]
    exist_straw[i - 1] = True
    
for a in ans:
  print(*a)

Measured memory_bytes: 7624
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto X = readln.chomp.to!int;

  bool isPrime(int n)
  {
    if (n == 2)
    {
        return true;
    }
    else if (n % 2 == 0 || n < 2)
    {
        return false;
    }
    else
    {
        for (int i = 3; i <= sqrt(float(n)); i += 2)
        {
            if (n % i == 0)
            {
                return false;
            }
        }
    }
    return true;
  }
  
  for(int i = X; true; i++) {
    if (i > 2 && i % 2 == 0) continue;

    if (isPrime(i)) {
      writeln(i);
      break;
    }
  }
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll a, b, k;
    cin >> a >> b >> k;

    ll cnt = 0;
    for(ll i=min(a,b); i>=1; --i) {
        if(a%i==0 && b%i==0) {
            cnt++;
            if(cnt == k) cout << i << endl;
        }
    }

    return 0;
}


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

const int N = 2e5 + 10;

char s[N], t[N], a[N], b[N];
int vis[128];

int main() {
	scanf("%s%s", s, t);
	int len = strlen(s);
	char pos = 'A';
	for (int i = 0; i < len; ++i) {
		if (!vis[s[i]]) vis[s[i]] = pos++;
		a[i] = vis[s[i]];
	}
	memset(vis, 0, sizeof vis);
	pos = 'A';
	for (int i = 0; i < len; ++i) {
		if (!vis[t[i]]) vis[t[i]] = pos++;
		b[i] = vis[t[i]];
	}
//	printf("%s\n%s\n", a, b);
	for (int i = 0; i < len; ++i) if (a[i] != b[i]) {
		puts("No"); return 0;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7 ; 
int main() 
{ 
    int n ; 
    cin >> n ; 
    long long a=1,b=1,c=1 ; 
    for(int i = 0 ; i < n ; ++i) {
        a *= 10 ; 
        b *= 9 ; 
        c *= 8 ; 
        a %= mod ; 
        b %= mod ; 
        c %= mod ; 
    }
    cout << (a - 2*b + 2*mod + c) % mod ;

    return 0; 
} 


Measured memory_bytes: 3568
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}



int main() {
	int n; cin >> n;
	vector<Int> t(n);
	for (int i = 0; i < n; i++) {
		cin >> t[i];
	}
	Int ans=t[0];
	if (n > 1) {
		for (int i = 1; i < n; i++) {
			ans = lcm(t[i], ans);
		}
	}
	
	cout <<ans;
	

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define xlson kx<<1, xl, mid
#define xrson kx<<1|1, mid+1, xr
#define ylson ky<<1, yl, mid
#define yrson ky<<1|1, mid+1, yr
#define MAXN 1005
#define mem(a) memset(a, 0, sizeof(a))

using namespace std;

int main(void)
{
	char a,b;
	cin>>a>>b;
	if(a>b)printf(">");
	else if(a==b)printf("=");
	else cout<<"<";
	return 0;
}

Measured memory_bytes: 256
use::std::vec::Vec;
use::std::collections::VecDeque;
use std::cmp::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let n: usize = read();
  let mut chart = vec![vec![]; n];
  for i in 0..n {
    let a: usize = read();
    for _ in 0..a {
      let (x, y) = read_touple::<usize>();
      chart[i].push((x-1, y));
    }
  }

  let mut ans: usize = 0;
  for i in 0..(1<<n) {
    if check(i, &chart) {
       ans = max(ans, counter(i));
    }
  }
  println!("{}", ans);
}

fn check(bit: usize, chart: &Vec<Vec<(usize, usize)>>) -> bool {
  let n = chart.len();
  for j in 0..n {
    if ((1<<j) & bit) != (1<<j) {
       continue
    }
    for &(x, y) in &chart[j] {
      if y == 0 && (bit & (1<<x)) == (1<<x) {
        return false
      } else if y == 1 && (bit & (1<<x) != (1<<x)) {
        return false
      }
    }
  }

  true
}

fn counter(bit: usize) -> usize {
  if bit == 0 {
    return 0;
  }
  counter(bit>>1) + (bit & 1)
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    string s;
    getline(cin, s);
    if (s.size() > 0 && s[s.size()-1] == '\r') s.resize(s.size()-1);
    reverse(s.begin(), s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 0
import bisect

N = int(input())
L = sorted([int(n) for n in input().split()])
#print(L)

count = 0
for i in range(N-1):
    b = L[:i]
    c = L[i+1:]
    for j in b:
        count += bisect.bisect_left(c, L[i] + j)

print(count)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    int cnt = 0;
    for(auto c : s){
        if(c=='o') cnt++;
    }
    cout<<700+(cnt*100)<<'\n';
}

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

int N, M;
vector<P> edges;
vector<int> ans;

struct Unionfind {
    vector<int> par, rank;
    
    Unionfind(int n) {
        par.resize(n);
        fill(par.begin(), par.end(), -1);
        rank.resize(n);
    }
    
    int root(int x) {
        int r = x;
        while (!(par[r]<0)) r = par[r];
        int t = x;
        
        while (t!=r) {
            int tmp = t;
            t = par[t];
            par[tmp] = r;
        }
        
        return r;
    }
    
    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        
        if (rx==ry) return;
        
        if (rank[rx]<=rank[ry]) {
            par[ry] += par[rx];
            par[rx] = ry;
            
            if (rank[rx]==rank[ry]) rank[ry]++;
        }
        else {
            par[rx] += par[ry];
            par[ry] = rx;
        }
    }
    
    bool is_same(int x, int y) {
        return root(x)==root(y);
    }
    
    int count(int x) {
        return -par[root(x)];
    }
};

signed main() {
    cin.tie(0); ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, M) {
        int A, B; cin >> A >> B;
        edges.pb(P(A-1, B-1));
    }
    
    Unionfind uf(N);
    int inconv = N*(N-1)/2;
    ans.pb(inconv);
    for (int i=M-1; i>=0; i--) {
        int A = edges[i].first, B = edges[i].second;
        if (!uf.is_same(A, B)) {
            int ac = uf.count(A);
            int bc = uf.count(B);
            inconv -= ac*bc;
            uf.unite(A, B);
        }
        ans.pb(inconv);
    }
    reverse(ans.begin(), ans.end());
    for (int i=1; i<=M; i++) cout << ans[i] << endl;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
        if(b&1)
            r=(r*a)%m;
        b>>1;
        a=(a*a)%m;
    }
    return r%m;
}

int main(){
    ll n; cin>>n;
    vi arr(n);
    rep(i,0,n)cin>>arr[i];
    vi pnt(n);
    rep(i,0,n)cin>>pnt[i];
    vi add(n);
    rep(i,0,n-1)cin>>add[i];
    ll sum=0;
    rep(i,0,n-1)
    {
        if(arr[i]+1==arr[i+1])
            sum+=add[arr[i]-1];
    }
    rep(i,0,n)sum+=pnt[i];
    cout<<sum<<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);
        int n = sc.nextInt();
        int[] a = new int[n];
        int sum = 0;
        for (int i =0;i<n;i++) {
            a[i] = sc.nextInt();
            sum+=a[i];
        }

        int w = sum / n;
        int mod = sum % n;
        if (mod > n / 2) w++;

        int ans = 0;
        for (int i : a) {
            int abs = Math.abs(i - w);
            ans += abs * abs;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007

int main() {
	ll N, K, ans = 0;
	cin >> N >> K;
	vector<ll> A(N), B(N, 0), C(N, 0);
	for (int i = 0;i < N;i++) {
		cin >> A[i];
	}
	for (int i = 0;i < N;i++) {
		for (int j = 0;j < N;j++) {
			if (A[i] > A[j]) {
				B[i]++;
				if (i < j) C[i]++;
			}
		}
	}
	for (int i = 0;i < N;i++) {
		ans += ((2 * C[i] + (K - 1)*B[i]) % MOD * K % MOD) * 500000004;
		ans %= MOD;
	}
	cout << ans << endl;
}

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

int main(void){
 int a,b,c;
 scanf("%d %d %d", &a,&b,&c);
  if(a - b > 0 && c > 0){
    if(a - b >= c){
      c = 0;
    }else{
      c = c - (a-b);
    }
  }
  printf("%d\n",c);
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		while (true) {
			int n = sc.nextInt();
			if (n == 0)
				break;
			int[][] data = new int[n][5];
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 4; j++) {
					data[i][j] = sc.nextInt();
				}
				data[i][4] = data[i][1] * 4 + data[i][2] * 9 + data[i][3] * 4;
			}
			int[] lim = new int[5];
			for (int i = 1; i < 5; i++)
				lim[i] = sc.nextInt();
			boolean naflag = true;
			for (int i = 0; i < n; i++) {
				boolean flag = true;
				for (int j = 1; j < 4; j++) {
					if (data[i][j] > lim[j])
						flag = false;
				}
				if (data[i][4] > lim[4])
					flag = false;
				if (flag) {
					naflag = false;
					System.out.println(data[i][0]);
				}
			}
			if (naflag)
				System.out.println("NA");
		}
	}
}

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


//TEMPLATE
#define pb              push_back
#define mp              make_pair
#define ll              long long
#define ld              long double
//#define pi              3.1415926536
#define pi              acos(-1)
//#define mod             1000000007
#define newline         printf("\n")
#define printminusone   printf("-1\n")
#define scl1(n)         scanf("%lld", &n)
#define scl2(a, b)      scanf("%lld %lld", &a, &b)
#define scl3(a, b, c)   scanf("%lld %lld %lld", &a, &b, &c)
#define printl(n)       printf("%lld\n", n)
#define ssl1(str)       scanf(" %[^\n]", str)
#define scd1(n)         scanf("%lf", &n)
#define scd2(a, b)      scanf("%lf %lf", &a, &b)
#define printd(n)       printf("%lf\n", n)
#define printld(n)      printf("%Lf\n", n)
#define printcase       printf("Case %lld: ", i)
#define reversed(s)     reverse(s.begin(), s.end())
#define asorted(s)      sort(s.begin(), s.end())
#define dsorted(s)      sort(s.begin(), s.end(), cmp)
#define for0(i, n)      for (i = 0; i < n; i++)
#define for1(i, n)      for (i = 1; i <= n; i++)
#define fori(itt, stt)  for(itt = stt.begin(); itt != stt.end(); itt++)
#define pii             pair <ll, ll>
#define piii            pair <ll, pii>
//#define SIZE            100005
//#define INF             1000000005
#define F               first
#define S               second
#define FR              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ms(arr, x)      memset(arr, x, sizeof arr)
#define bitcount(n)     __builtin_popcountll(n)

const ll INF = 1e18;
const ll SIZE = 1e5+5;
const ll mod = 1e9+7;



bool vis[SIZE];
ll col[SIZE];
vector <pii> adj[SIZE];

void bfs() {
    col[1] = 1;
    vis[1] = 1;

    queue <ll> q;
    q.push(1);

    ll u, v, w, i;

    while(!q.empty()) {
        u = q.front();
        q.pop();

        for0(i, adj[u].size()) {
            v = adj[u][i].F;
            w = adj[u][i].S;

            if(vis[v]) continue;

            vis[v] = 1;

            if(w%2) col[v] = (col[u] == 1) ? 0 : 1;
            else col[v] = col[u];

            q.push(v);
        }
    }
}

int main() {
    ll t = 0, n, x, y, z, i, j, k, g, p, q, ans = 0, sum = 0, c = 0;
    scl1(n);

    for1(i, n-1) {
        scl3(x, y, z);
        adj[x].pb(mp(y, z));
        adj[y].pb(mp(x, z));
    }

    bfs();

    for1(i, n) printl(col[i]);


    return 0;
}



Measured memory_bytes: 8704
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

// double DP[301][301][301];
// int visited[301][301][301];

double DFS(int c1, int c2, int c3,int N,  vector<vector<vector<double> > >& DP,  vector<vector<vector<int> > > & visited)
{
  // DEBUG(c1,c2,c3,"\n");
  if(visited[c1][c2][c3] == 1)return DP[c1][c2][c3];
  visited[c1][c2][c3] = 1;
  if(c1 == 0 && c2 ==0 && c3 == 0)return 0;

  double res = (double)1/((double)1-(double)(N-c1-c2-c3)/(double)N);
  double X = res;
  if(c1 > 0)res += DFS(c1-1,c2,c3,N,DP,visited)*(double)c1/(double)N*X;
  if(c2 > 0)res += DFS(c1+1,c2-1,c3,N,DP,visited)*(double)c2/(double)N*X;
  if(c3 > 0)res += DFS(c1,c2+1,c3-1,N,DP,visited)*(double)c3/(double)N*X;

  return DP[c1][c2][c3] = res;
}

void solve(void)
{
  int C1 = 0,C2 = 0,C3 = 0;
  int N;
  cin>>N;
  for (int i = 0; i < N; i++)
  {
    int X ;cin>>X;
    if(X==1)C1++;
    else if(X==2)C2++;
    else C3++;
  }
  vector<vector<vector<int> > > visited (300+1,vector<vector<int> >(300+1,vector<int>(300+1,0)));
  vector<vector<vector<double> > > DP (300+1,vector<vector<double> >(300+1,vector<double>(300+1,0)));
  cout<<DFS(C1,C2,C3,N,DP,visited)<<endl;
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 432896
def main():
    N, H = map(int, input().split())
    katana = []
    for i in range(N):
        a, b = map(int, input().split())
        katana.append((a, b))
    cnt = 0
    num = 0
    
    k = sorted(katana, key=lambda x:x[1], reverse=True)
    ks = sorted(katana, key=lambda x:x[0], reverse=True)
    
    for i in range(N):
        if(k[i][1] > ks[0][0]):
            H -= k[i][1]
            cnt += 1
            if(H <= 0):
                break
            
        else:
            break    
    
    if(H > 0):
        if(H%ks[0][0] == 0):
            cnt += H//ks[0][0]
        else:
            cnt += H//ks[0][0]+1
    
    print(cnt)
       
main()

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define PI 3.14159265359 //πの値
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

 
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
  ll money; cin >> money;
  ll happy = 0;
  happy += (money / 500) * 1000;
  happy += (money % 500) / 5 * 5;
  cout << happy;
}

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

int main(){
    int a,b;    cin>>a>>b;
    if((a+b)%3==0||a%3==0||b%3==0)
        cout<<"Possible"<<endl;
    else
        cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256