akhauriyash/Code-Regression huggingface dataset:
#pragma region Macros

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define int ll
using vi = vector<int>;
using vvi = vector<vi>;

#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
ostream &operator<<(ostream &out, vector<T> const &v) {
    for (auto &&a : v) out << a << " ";
    out << endl;
    return out;
}

// debug methods
// usage: debug(x,y);
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0, a1, a2, a3, a4, x, ...) x
#define debug_1(x1) cout << #x1 << ": " << x1 << endl
#define debug_2(x1, x2) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << endl
#define debug_3(x1, x2, x3) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << endl
#define debug_4(x1, x2, x3, x4) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << endl
#define debug_5(x1, x2, x3, x4, x5) cout << #x1 << ": " << x1 << ", " #x2 << ": " << x2 << ", " #x3 << ": " << x3 << ", " #x4 << ": " << x4 << ", " #x5 << ": " << x5 << endl
#ifdef _DEBUG
#define debug(...)                                                        \
    CHOOSE((__VA_ARGS__, debug_5, debug_4, debug_3, debug_2, debug_1, ~)) \
    (__VA_ARGS__)
#else
#define debug(...)
#endif

#pragma endregion

void Main() {
    int N, M;
    cin >> N >> M;
    vi a(N);
    int sum = 0;
    REP(i, N) {
        cin >> a[i];
        sum += a[i];
    }
    int count = 0;
    REP(i, N) {
        if (sum <= a[i] * (4 * M)) {
            count++;
        }
    }
    if (M <= count) {
        cout << "Yes";
        return;
    }
    cout << "No";
}

#pragma region main
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    Main();
    cout << flush;
}
#pragma endregion


Measured memory_bytes: 3552
var
	n,t,u,a,c,i:Longint;
begin
	c:=2000;
	read(n,t);
	for i:=1 to n do begin
		read(a,u);
		if(t>=u)and(a<c)then c:=a;
	end;
	if c<2000 then writeln(c)else writeln('TLE')
end.


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const ll INFS=1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    vector<ll> b(n-1);
    rep(i, n) cin >> a[i];
    rep(i, n-1){
        if(a[i+1] - a[i] == 0) b[i] = 0;
        else if(a[i+1] - a[i] > 0) b[i] = 1;
        else b[i] = -1;
    }
    // rep(i, n-1) cout << b[i] << endl;               1 2 3 4 3 2 2 2 3 4
    ll ans = 1, state = -2;                         //  1 1 1 - - 0 0 1 1
    rep(i, n-1){
        // cout << state << endl;
        if(b[i] == 0) continue;
        if(state == -2){
            state = b[i];
            continue;
        }
        if(b[i] == 1 && state == -1){
            ans++;
            state = -2;
        }
        else if(b[i] == -1 && state == 1){
            ans++;
            state = -2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4796
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(true) {
			int n = stdIn.nextInt();
			int s = stdIn.nextInt();
			if(n == 0 && s == 0) {
				break;
			}
			int c1 = sorv(0, n, s,0);
			System.out.println(c1);
			
		}
	}
	public static int sorv(int i, int n, int s,int p) {
		if(s == p && n == 0) {
			return 1;
		}
		if(i >= 10) {
			return 0;
		}
		if(n < 0) {
			return 0;
		}

		if(p > s) {
			return 0;
		}
		int c1 = sorv(i+1,n-1,s,p+i);
		int c2 = sorv(i+1,n,s,p);
		return c1+c2;
	}
}

Measured memory_bytes: 18040
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 998244353;
const ll MAX = 2000001;

ll mod(ll a){
  if(a % MOD < 0) return MOD + (a % MOD);
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll n,m; cin >> n >> m;
  
  ll ans = 0;
  
  for(ll i=1; i*i <= m; i++){
    if(m % i == 0){
      if(m/i >= n) ans = max(ans,i);
      if(i >= n) ans = max(ans,m/i);
    }
  }
  
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3636
S = input()
s = []
ans = []
num = 0
count = 0
for i in range(len(S)):
    s.append(ord(S[i]))
while num < len(s) - 2:
    if s[num] is not s[num + 2]:
        s.pop(num + 1)
        num = 0
        count += 1
    else:
        num += 1


for i in range(len(s)):
    ans.append(chr(s[i]))

if count % 2 is 1:
    print('First')
else:
    print('Second')


Measured memory_bytes: 4980
#include <iostream>
int main()
{
    int a,b,c,d;
    std::cin >> a >> b >> c >> d;

    for(int i=1;1>0;i++){
        if(b*i>=c){
            std::cout << "Yes" << std::endl;
            return 0;
        }
        else if(d*i>=a){
            std::cout << "No" << std::endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>

using namespace std;

int main(void){
	string str;
	
	while(1){
		getline(cin, str);
		if(str.size() == 0) break;
		int n = str.size();
		
		for(int i=0;i<=n-5;i++){
			if(str[i] == 'a' && str[i+1] == 'p' && str[i+2] == 'p' && str[i+3] == 'l' && str[i+4] == 'e'){
				str[i] = 'p'; str[i+1] = 'e'; str[i+2] = 'a'; str[i+3] = 'c'; str[i+4] = 'h';
			}else if(str[i] == 'p' && str[i+1] == 'e' && str[i+2] == 'a' && str[i+3] == 'c' && str[i+4] == 'h'){
				str[i] = 'a'; str[i+1] = 'p'; str[i+2] = 'p'; str[i+3] = 'l'; str[i+4] = 'e';
			}
		}
		cout << str << endl;
	}
}

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


int main(){
    string s, t;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    string u;
    cin >> u;
    
    if (u == s){
        a = a - 1;
    }else if (u == t){
        b = b - 1;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
////////////////////////////////////
///     Please Give Me AC!!!     ///
////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

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

int main(){
    int N, K; cin>> N >> K;
    vector<int> h (N);
    forin(h);

    vector<int> dp(N + K, 1e9);
    dp[0] = 0;

    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++) {
            chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
        }
    }

    cout<< dp[N - 1] << endl;
}

Measured memory_bytes: 4068
#include <cstdio>
using namespace std; 
int main() {
  short k, a, b; 
  scanf("%hd%hd%hd", &k, &a, &b); 
  for (short i = a; i <= b; i ++) {
    if (i % k == 0) {
     printf("%s", "OK"); 
      return 0; 
    }
  }
  printf("%s", "NG"); 
  return 0; 
}


Measured memory_bytes: 1736
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<map>
using namespace std;
const int N=10010,M=100010;
int p[N][2];
int ma[N];
struct node{
	int u,v,nxt;
}edge[M];
int head[N],mcnt;
bool vis[N];
void add(int u,int v){
	mcnt++;
	edge[mcnt].v=v;
	edge[mcnt].u=u;
	edge[mcnt].nxt=head[u];
	head[u]=mcnt;
}
bool dfs(int u){
	for(int i=head[u];i;i=edge[i].nxt){
		int v=edge[i].v;
		if(vis[v])
			continue;
		vis[v]=1;
		if(!ma[v]||dfs(ma[v])){
			ma[v]=u;
			return true;
		}
	}
	return false;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
		scanf("%d%d",&p[i][0],&p[i][1]);
	int x,y;
	int ans=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&x,&y);
		for(int j=1;j<=n;j++)
			if(p[j][0]<x&&p[j][1]<y)
				add(j,i);
	}
	for(int i=1;i<=n;i++){
		memset(vis,0,sizeof vis);
        ans+=dfs(i);
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		String S = stdIn.next();
		String T = stdIn.next();
		int c=0;
		for(int a=0; a<S.length(); a++){
			if(S.charAt(a) != T.charAt(a)){
				c++;
			}
		}
		System.out.println(c);
		stdIn.close();
	}
}


Measured memory_bytes: 41484
#include <bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  for (int i = 0; i < H; i++){
    cin >> S[i];
  }
  vector<vector<bool>> ok(H - 1, vector<bool>(W - 1));
  for (int i = 0; i < H - 1; i++){
    for (int j = 0; j < W - 1; j++){
      int sum = 0;
      if (S[i][j] == '#'){
        sum++;
      }
      if (S[i][j + 1] == '#'){
        sum++;
      }
      if (S[i + 1][j] == '#'){
        sum++;
      }
      if (S[i + 1][j + 1] == '#'){
        sum++;
      }
      if (sum % 2 == 0){
        ok[i][j] = true;
      } else {
        ok[i][j] = false;
      }
    }
  }
  vector<vector<int>> up(H - 1, vector<int>(W - 1));
  for (int i = 0; i < W - 1; i++){
    if (ok[0][i]){
      up[0][i] = 2;
    } else {
      up[0][i] = 1;
    }
  }
  for (int i = 1; i < H - 1; i++){
    for (int j = 0; j < W - 1; j++){
      if (ok[i][j]){
        up[i][j] = up[i - 1][j] + 1;
      } else {
        up[i][j] = 1;
      }
    }
  }
  int ans = H;
  for (int i = 0; i < H - 1; i++){
    vector<int> L(W - 1);
    stack<int> st1;
    for (int j = 0; j < W - 1; j++){
      while (!st1.empty()){
        if (up[i][st1.top()] >= up[i][j]){
          st1.pop();
        } else {
          break;
        }
      }
      if (st1.empty()){
        L[j] = 0;
      } else {
        L[j] = st1.top() + 1;
      }
      st1.push(j);
    }
    vector<int> R(W - 1);
    stack<int> st2;
    for (int j = W - 2; j >= 0; j--){
      while (!st2.empty()){
        if (up[i][st2.top()] >= up[i][j]){
          st2.pop();
        } else {
          break;
        }
      }
      if (st2.empty()){
        R[j] = W - 1;
      } else {
        R[j] = st2.top();
      }
      st2.push(j);
    }
    for (int j = 0; j < W - 1; j++){
      ans = max(ans, up[i][j] * (R[j] - L[j] + 1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 27548
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

int main() {
	int n, m;
    cin >> n >> m;
	if (m <= n) {
		cout << 0;
		return 0;
	}		
    vector<int> point(m);
    vector<int> len(m - 1);
    for (int i = 0; i < m; ++i) {
        cin >> point[i];
    }
    sort(point.begin(), point.end());
    for (int i = 0; i < m - 1; ++i) {
        len[i] = point[i + 1] - point[i];
    }
    sort(len.begin(), len.end(), greater<int>());
    int sum = 0;
    for (int i = n - 1; i < len.size(); ++i)
        sum += len[i];
    cout << sum;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<string.h>
#include<algorithm>
using namespace std;

int main() {
	int k,z;
	cin >> k;
	
	z = k - 1;
	

	if (k % 2 == 0) cout << k * k / 4 << endl;
	else cout << (z * z / 4) + z/2 << endl;

	return 0;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};


/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>auto cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}

/* main */

string s;

signed main(){


    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> s;
    int n = s.size();
    if(s == "keyence"){
        print("YES");
        return 0;
    }

    rep(i,0,n){
        rep(j,i, n){
            string t = (1 <= i ? cut(s, 0, i) : "") + (j <= n - 2 ? cut(s, j + 1, n) : "") ;


            if(t == "keyence"){
                print("YES");
                return 0;
            }
              
        }
    }

    print("NO");

    


    


    

}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
// 昇順sort
#define sorti(x) sort(x.begin(), x.end())
// 降順sort
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())

int main() {
  int n,C; cin >> n >> C;
  int s[n], t[n], c[n];

  int tt[200002];

  rep(i,n) {
    scanf("%d %d %d", &s[i], &t[i], &c[i]);
  }
  int sm[200002];
  rep(i,200002) sm[i] = 0;
  for (int i = 1; i <= C; ++i) {
    rep(j,200002) tt[j] = 0;
    rep(j,n) {
      if (c[j] == i) tt[s[j] * 2 - 1]++, tt[t[j] * 2]--;
    }
    for (int j = 1; j <= 200001; ++j) tt[j] += tt[j-1];
    rep(j,200002) if(tt[j] > 0) sm[j]++;
  }
  int ans = 0;
  rep(i,200002) ans = max(ans,sm[i]);
  cout << ans << endl;
}


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

typedef long long ll;

ll A, B, C, D;
vector<vector<vector<ll>>> Dp;
const ll MOD = 998244353;

int main() {
  cin >> A >> B >> C >> D;
  Dp.resize(C + 1);
  for (auto &Dpx : Dp) {
    Dpx.resize(D + 1);
    for (auto &Dpxy : Dpx) Dpxy.resize(2);
  }
  Dp[C][D][0] = 1;
  for (ll x = C; x >= A; --x) {
    for (ll y = D; y >= B; --y) {
      for (ll s = 0; s < 2; ++s) {
        if (x > A && s == 0) {
          (Dp[x - 1][y][s] += y * Dp[x][y][s]) %= MOD;
        }
        if (y > B) {
          if (x == A) {
            (Dp[x][y - 1][0] += x * Dp[x][y][s]) %= MOD;
          } else {
            (Dp[x][y - 1][1] += (x - 1) * Dp[x][y][s]) %= MOD;
            (Dp[x][y - 1][0] += Dp[x][y][s]) %= MOD;
          }
        }
      }
    }
  }
  cout << Dp[A][B][0] << endl;
  return 0;
}


Measured memory_bytes: 496100
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<int, vector<int>, greater<int> > gpq; //逆順priority_queue
typedef priority_queue<int> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    ll N,M;
    cin>>N>>M;
    if(N%2){
        ll v1=N/2,v2=N/2+1;
        for(int i=0;i<M;i++){
            cout<<v1<<" "<<v2<<endl;
            v1--;v2++;
        }
    }else{
        for(int i=0;i<M;i++){
            if(i<N/4){
                cout<<(1+i)<<" "<<(N/2-i)<<endl;
            }else{
                int j=i-N/4;
                cout<<(N/2+1+j)<<" "<<(N-1-j)<<endl;
            }
        }
    }
}


Measured memory_bytes: 3640
A, B, C, D = map(int, input().split())
if B < C:
    print(0)
elif A <= C <= B and B <= D:
    print(B-C)
elif A <= C and D <= B:
    print(D-C)
elif C <= A and A <= D <= B:
    print(D-A)
elif D <= A:
    print(0)
elif C <= A and B <= D:
    print(B-A)

Measured memory_bytes: 3060
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

struct UnionFind{
    vector<int> data;
    UnionFind(int size){
        data=vector<int>(size,-1);
    }
    bool union_set(int x,int y){
        x=root(x);
        y=root(y);
        if(x!=y){
            if(data[y]<data[x])swap(x,y);
            data[x]+=data[y];
            data[y]=x;
        }
        return x!=y;
    }
    bool find(int x,int y){
        return root(x)==root(y);
    }
    int root(int x){
        return data[x]<0?x:data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI(N);
    vector<ll> L(N+1);
    L[0]=2;
    L[1]=1;
    for(int i=2;i<=N;++i){
        L[i]=L[i-1]+L[i-2];
    }
    print(L[N]);
    return 0;
}

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

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail]=x;
  if(tail>=LEN)tail=0;
  else tail++;
}

P dequeue(){
  P m;
  m=Q[head];
  if(head>=LEN)head=0;
  else head++;
  return m;
}


int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head = 1;
  tail=n+1;
  while(head!=tail){
    if(Q[head].t>q){
      elaps+=q;
      Q[head].t-=q;
      enqueue(dequeue());
    }
    else{
      elaps+=Q[head].t;
      printf("%s %d\n",Q[head].name,elaps);
      dequeue();
      
    } 
  }
  return 0;
}

Measured memory_bytes: 10756
//
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
//
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// solution 
#[allow(unused_mut)]
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        a: [i64; N],
    }

    let mut xy: i64 = a.iter().sum();
    let mut min = std::i64::MAX;
    
    for &a in a.iter().take(N-1) {
        xy -= 2*a;
        min = std::cmp::min(min, xy.abs());
    }
    println!("{}", min);
}


Measured memory_bytes: 6396
fun main(args:Array<String>){


    var (n) = readLine()!!.split(" ").map { it.toInt() }
    var (a,b) = readLine()!!.split(" ").map { it.toInt() }
    var list  = mutableListOf<Int>()
    list = readLine()!!.split(" ").map { it.toInt() }.toMutableList()

    var ans = 0;
    list.sort()

    ans = Math.min(list.count{it<=a},Math.min(list.count{it>a && it<=b},list.count{it>b}))

    println(ans)

}

Measured memory_bytes: 37860
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<iomanip>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<sstream>
#define ll long long
#define mes(x,y) memset(x,y,sizeof(x))
using namespace std;
int main(){
    ll a,b,c,x[20];
	cin>>a>>b>>c;
		mes(x,0);
		x[0]=a*c-b;
		cout<<x[0]<<endl;
		for(int i=1;i<10;i++){
			x[i]=a*x[i-1]-b;
			cout<<x[i]<<endl;
		}
}

Measured memory_bytes: 256
N, K, Q = map(int,input().split())
As = []
for i in range(Q):
    As.append(int(input()))
 
points = [K - Q] * N
for a in As:
    points[a - 1] += 1
 
for p in points:
    if p > 0:
        print("Yes")
    else:
        print("No")
 

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

int main(){
    int d, n;
    cin >> d >> n;
    int ans = 1;
    for (int i = 0; i < d; i++)
        ans *= 100;
    if (n == 100)
        n++;
    ans *= n;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n,b[3];
  cin >> n;
  rep(i,3) R b[i];
  ll a[n],ans=MAX;
  rep(i,n) R a[i];
  rep(t,pow(4,n)) {
    vector<ll> v[4];
    ll r=t;
    rep(i,n) {
      v[r%4].pb(a[i]);
      r/=4;
    }
    ll sum=0,f=1;
    rep(i,3) {
      if(!v[i].size()) f=0;
    }
    if(!f) continue;
    rep(i,3) {
      ll c=0;
      rep(j,v[i].size()) c+=v[i][j];
      sum+=(v[i].size()-1)*10;
      sum+=abs(c-b[i]);
    }
    ans=min(ans,sum);
  }
  pr(ans);
}

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


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

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{
	int n;
	cin >> n;
	vector<int> p(n), q(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	for (int i = 0; i < n; i++) cin >> q[i];
	vector<int> vec(n);
	for (int i = 0; i < n; i++) vec[i] = i + 1;
	
	map<vector<int>, int> mp;
	do {
		mp[vec] = mp.size();
	} while (next_permutation(vec.begin(), vec.end()));

	cout << abs(mp[p] - mp[q]) << endl;
}

Measured memory_bytes: 5248
import java.util.Scanner;

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

		for(;;){
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();

			if(op.equals("?"))
				break;

			System.out.println(!op.equals("+") ? !op.equals("-") ? !op.equals("*") ? a/b : a*b : a-b : a+b);
		}
	}
}



Measured memory_bytes: 26368
N = input()

l = len(N)

# print(N[l-1])

k = N[l-1]

if k == '2' or k == '4' or k == '5' or k == '7' or k == '9':
    print('hon')
elif k == '0' or k == '1' or k == '6' or k == '8':
    print('pon')
elif k == '3':
    print('bon')

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

int main(){
	bool time[24][60],first=1;
	for (int i = 0; i < 24; i++) {
		for (int j = 0; j < 60; j++) {
			time[i][j] = 0;
		}
	}
	int n,h,m;
	for (int i = 0; i < 2; i++) {
		cin >> n;
		for (int j = 0; j < n; j++) {
			cin >> h >> m;
			time[h][m] = 1;
		}
	}
	for (int i = 0; i < 24; i++) {
		for (int j = 0; j < 60; j++) {
			if (time[i][j]) {
				if (!first)cout << " ";
				else first = 0;
				if (j < 10)cout << i << ":0" << j;
				else cout << i << ":" << j;
			}
		}
	}
	cout << endl;
	return 0;

}


Measured memory_bytes: 3096
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define REP(i,s,n) for(int i=s; i<(n); ++i)
#define ALL(n) begin(n),end(n)
using ll = long long;
const ll INF = numeric_limits<ll>::max();

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    A[0] = 0;
    REP(i, 1, N) cin >> A[i];
    
    vector<int> boss(N);
    REP(i, 1, N){
        ++boss[A[i] - 1];
    }

    REP(i, 0, N){
        cout << boss[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 4848
n = input()
kk = int(input())

mod = 10**9 + 7
l = 2*10**2

M = [1]  # i!のmod
m = 1
for i in range(1, l):
    m = (m * i) % mod
    M.append(m)

def pow(x, y, mod):  # x**y の mod を返す関数
    ans = 1
    while y > 0:
        if y % 2 == 1:
            ans = (ans * x) % mod
        x = (x**2) % mod
        y //= 2
    return ans

def inv(x, mod):  # x の mod での逆元を返す関数
    return pow(x, mod-2, mod)

# print(inv(8,13))

MI = [0] * (l-1) +[inv(M[l-1], mod)]  # i!の逆元
for i in range(l-2, -1, -1):
    MI[i] = MI[i+1] * (i+1) % mod

def C(x, y):  # コンビネーション
    if y < 0 or y > x:
        return 0
    ans = M[x]
    ans = (ans * MI[y]) % mod
    return (ans * MI[x-y]) % mod

ans = 0
k = kk
for i in range(len(n)):
    s = int(n[i])
    z = len(n)-i-1
    # print(s,z)
    if s >= 1 and k >= 0:
        ans += C(z, k) * (9**k) + C(z, k-1) * (9**(k-1)) * (s-1)
        k -= 1
    # print("ans",ans)
if n.count("0") == len(n)-kk:
    ans += 1
print(int(ans))

Measured memory_bytes: 38384
import java.io.*;
import java.util.*;

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

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int M = in.nextInt();
        long sum = 0;
        for(int i = 0; i < M; i++) {
            sum += in.nextInt();
        }
        if(sum <= N) {
            System.out.println(N - sum);
        } else {
            System.out.println(-1);
        }
    }

}


Measured memory_bytes: 46316
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
const long long int m=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,ans=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        ans=(ans%m*i%m)%m;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3588
def inpl():
    return list(map(int, input().split()))


def distance(X, Y):
    tmp = 0
    for i in range(len(X)):
        tmp += (X[i] - Y[i])**2
    return tmp**0.5


def isInteger(i):
    return i - int(i) == 0


N, D = inpl()
X = [inpl() for i in range(N)]

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        if isInteger(distance(X[i], X[j])):
            ans += 1

print(ans)


Measured memory_bytes: 3188
MOD = 10**6 + 3

def inv_mod(a):
  return pow(a,MOD-2,MOD)

U = MOD + 10

fact = [1] * (U+1)
for n in range(1,U+1):
  fact[n] = (n*fact[n-1])%MOD

Q = int(input())
XDN = [[int(x) for x in input().split()] for _ in range(Q)]

def F(x,d,n):
  if d == 0:
    return pow(x,n,MOD)
  k = inv_mod(d)
  # k^nをかけると
  # (kx)(kx+1)...(kx+n-1)
  y = (k*x)%MOD
  if y == 0:
    return 0
  z = y+n-1
  if z >= MOD:
    return 0
  # z! / (y-1)!
  result = fact[z]
  result *= inv_mod(fact[y-1])
  result %= MOD
  # 最後にk^nで割る
  result *= pow(d,n,MOD)
  result %= MOD
  return result

for x,d,n in XDN:
  print(F(x,d,n))

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

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007
#define P pair<ll, ll>

map<ll, string>m;
int main() {
	m[0] = "thu";
	m[1] = "fri";
	m[2] = "sat";
	m[3] = "sun";
	m[4] = "mon";
	m[5] = "tue";
	m[6] = "wed";
	ll n;
	cin >> n;
	cout << m[n % 7] << endl;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <math.h>

int is_prime1(int);
int is_prime2(int);

int prime[168];

int main()
{
	int input_count;
	int prime_count;
	int input;
	int cnt;
	int output[30];
	int prime_cnt;
	
	/*Make prime table*/
	prime[0] = 2;
	prime_cnt = 1;
	for(cnt = 3; cnt < 1000; cnt += 2)
	{
		if(is_prime1(cnt))
		{
			prime[prime_cnt] = cnt;
			prime_cnt++;
		}
	}
	
	/*Get, calculate input then save in output[]*/
	input_count = 0;
	while(scanf("%d", &input) != EOF)
	{
		prime_count = 0;
		if(input >= 2)
		{
			prime_count++;
		}
		for(cnt = 3; cnt <= input; cnt += 2)
		{
			if(is_prime2(cnt))
			{
				prime_count++;
			}
		}
		output[input_count] = prime_count;
		input_count++;
	}
	
	/*print output[]*/
	for(cnt = 0; cnt < input_count; cnt++)
	{
		printf("%d\n", output[cnt]);
	}
	
    return 0;
}

int is_prime1(int prime1_input)
{
	int prime1_cnt;
	
	if(prime1_input == 1)
	{
		return 0;
	}
	else if(prime1_input == 2 || prime1_input == 3 || prime1_input == 5 || prime1_input == 7)
	{
		return 1;
	}
	else if((prime1_input % 2) == 0)
	{
		return 0;
	}

	for(prime1_cnt = 3 ; prime1_cnt <= (sqrt(prime1_input)); prime1_cnt += 2)
	{
		if(prime1_input % prime1_cnt == 0)
		{
			return 0;
		}
	}
	
	return 1;
}

int is_prime2(int prime2_input)
{
	int prime2_cnt = 0;
	for( ;prime2_cnt <168; prime2_cnt++)
	{
		if(prime[prime2_cnt] > sqrt(prime2_input))
		{
			break;
		}
		if(prime2_input % prime[prime2_cnt] == 0)
		{
			return 0;
		}
	}
	return 1;
}

Measured memory_bytes: 596
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "


int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		//freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
		  int N;
  cin >> N;
  vector<ll> A(N);
  for (int i=0 ; i<N ; i++) cin >> A[i];
 
  ll ans = 0;
  for(int i = 1; i < N; i++) {
    if(A[i] < A[i - 1]) {
      ans += A[i - 1] - A[i];
      A[i] = A[i- 1];
    }
  }
  
  cout << ans << endl;
		return 0;
}  


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<ll, ll> ll_ll;
struct edge { int v, w; };
const int INF = INT_MAX / 2;
const int MOD = 1e9 + 7;
const ll e18 = 1e18;

int main() {
	int N; cin >> N;
	vector<vector<int>> a(2, vector<int>(N));
	rep(k, 2) rep(i, N) cin >> a[k][i];
	vector<vector<int>> A(2, vector<int>(N + 1));
	rep(k, 2) rep(i, N) A[k][i + 1] = A[k][i] + a[k][i];
	int ma = 0;
	rep(i, N) ma = max(ma, A[0][i + 1] - A[0][0] + A[1][N] - A[1][i]);
	cout << ma << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for (int(i) = (int)(a); (i) < (int)(b); ++(i))
#define rFor(i, a, b) for (int(i) = (int)(a)-1; (i) >= (int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T div_floor(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a >= 0 ? a / b : (a + 1) / b - 1;
}
template <class T>
T div_ceil(T a, T b) {
    if (b < 0) a *= -1, b *= -1;
    return a > 0 ? (a - 1) / b + 1 : a / b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main() {
    int n, m, R;
    scanf("%d%d%d", &n, &m, &R);
    int r[R];
    rep(i, R) scanf("%d", &r[i]), --r[i];
    int dist[n][n];
    rep(i, n) {
        rep(j, n) dist[i][j] = mod;
        dist[i][i] = 0;
    }
    rep(i, m) {
        int a, b, c;
        scanf("%d%d%d", &a, &b, &c);
        --a;
        --b;
        dist[a][b] = dist[b][a] = c;
    }
    rep(k, n) rep(i, n) rep(j, n) chmin(dist[i][j], dist[i][k] + dist[k][j]);

    int ans = mod;
    int p[R];
    iota(p, p + R, 0);
    do {
        int tmp = 0;
        rep(i, R - 1) tmp += dist[r[p[i]]][r[p[i + 1]]];
        chmin(ans, tmp);
    } while (next_permutation(p, p + R));
    printf("%d\n", ans);
}

Measured memory_bytes: 3880
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
	int a, b;
	string s;
	
	cin >> a >> b;
	cin >> s;

	int pos = s.find("-");
	if (string::npos != pos && s.rfind("-") == pos) {
		if (a == pos) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS
int n;
vector<int> a;
ll dp[500][500];

ll f(int l, int r){
	if(l > r){
		return 0;
	}
	if(l==r){
		return 0;
	}
	if(dp[l][r] != -1){
		return dp[l][r];
	}
	dp[l][r] = LLONG_MAX;
	for(int i=l;i<r;i++){
		dp[l][r] = min(dp[l][r], f(l,i) + f(i+1,r));
	}
	
	for(int i=l;i<=r;i++) dp[l][r] += a[i];
	return dp[l][r];
}

int main(){
	cin>>n;
	a.resize(n);
	memset(dp,-1,sizeof(dp));
	for(int i=0;i<n;i++){
		cin>>a[i];
	}		

	cout<<f(0,n-1)<<endl;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo (1LL<<63-1)
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >

using namespace std;

int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

const long double Pi=acos(-1),e=2.718;
const int N=2e5+10, mod=1e9+7;

int main ()
{
    FASTIO
    ll n,m;
    cin >> n >> m ;
    if(n<=m){
        cout << "unsafe" << endl;
    }
    else cout << "safe" << endl;
    return 0;
}
/**

*/


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define A a
#define B b
#define C c
#define D d
#define N n
#define M m
#define H h
#define W w
#define S s
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
int main(){
	int n;cin>>N;
	if(n==1){
		cout<<"Hello World"<<endl;
	}else{
		int a,b;cin>>A>>B;
		cout<<a+b<<endl;
	}
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int N, M;
int a[50], b[50];

bool e[50][50];
bool visited[50];

void dfs(int v) {
		visited[v] = true;		
		for (int v2 = 0; v2 < N; v2++) {
				if (e[v][v2] == false) continue;
				if (visited[v2] == true) continue;
				dfs(v2);
		}
}

int main() {
		cin >> N >> M;
		for(int i = 0; i < M; i++) {
				cin >> a[i] >> b[i];
				a[i]--; b[i]--;
				e[a[i]][b[i]] = e[b[i]][a[i]] = true;
		}

		int ans = 0;
		for (int i = 0; i < M; i++) {
				e[a[i]][b[i]] = e[b[i]][a[i]] = false;

				for (int j = 0; j < N; j++) {
						visited[j] = false;
				}

				dfs(0);

				for (int j = 0; j < N; j++) {
						if (visited[j] == false) {
								ans++;
								break;
						}
				}	

				e[a[i]][b[i]] = e[b[i]][a[i]] = true;
		}

		cout << ans << endl;
		return 0;
}


Measured memory_bytes: 256
#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 ...); }

// ---- ----

const double TAU = atan2(0, -1) * 2.0;
const double PI  = atan2(0, -1);

int main() {
	IN(int, n);
	OUT(TAU * n);
}


Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <climits>
using namespace std;


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

    long sum_right = accumulate(vec.begin(), vec.end(), 0);
    long sum_left = 0;
    long min_diff = INT_MAX;

    for (int i = 0; i < n; i++) {
        sum_left += vec.at(i);
        sum_right -= vec.at(i);
        long diff = abs(sum_left - sum_right);
        if (diff < min_diff) min_diff = diff;
    }
    cout << min_diff << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    x = [int(s) for s in input().split()]
    y = sorted(x)

    th = y[n // 2]
    for a in x:
        if a < th:
            print(y[n // 2])
        else:
            print(y[n // 2 - 1])

main()


Measured memory_bytes: 26016
#include<iostream>
#include<vector>

using namespace std;

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

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

	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}
	int ans = 0;

	for (int i = 0; i < N; i++)
	{
		while (A[i] % 2 == 0){
			ans++;
			A[i] /= 2;
	    }
	}
	
	cout << ans << endl;
	return 0;
}

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

bool kansu(const pair<int, int>a, const pair<int, int>b)
{
	return a.first*a.second < b.first*b.second;
}

int main()
{
	int n, w, d;
	while (cin >> n >> w >> d, w)
	{
		vector<pair<int, int> >data;
		data.push_back(pair < int, int > {w, d});
		int a, b;
		for (size_t i = 0; i < n; i++)
		{
			cin >> a >> b;
			a--;
			b %= (data[a].first + data[a].second);
			if (b>data[a].first)
			{
				b -= data[a].first;
				if (b < data[a].second - b)
				{
					data.push_back(pair < int, int > {data[a].first, b});
					data.push_back(pair < int, int > {data[a].first, data[a].second - b});
				} else
				{
					data.push_back(pair < int, int > {data[a].first, data[a].second - b});
					data.push_back(pair < int, int > {data[a].first, b});
				}
			} else
			{
				if (b < data[a].first-b)
				{
					data.push_back(pair < int, int > {b, data[a].second});
					data.push_back(pair < int, int > {data[a].first - b, data[a].second});
				} else
				{
					data.push_back(pair < int, int > {data[a].first - b, data[a].second});
					data.push_back(pair < int, int > {b, data[a].second});
				}
			}
			data.erase(data.begin() + a);
		}
		sort(data.begin(), data.end(), [](const pair<int, int>a, const pair<int, int>b)->bool {return a.first*a.second < b.first*b.second; });
		auto ite = data.begin();
		for (; ite != data.end() - 1; ite++)
		{
			cout << ((*ite).first)*((*ite).second) << " ";
		}
		cout << ((*ite).first)*((*ite).second) << endl;
	}
}

Measured memory_bytes: 1204
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}
vector<vector<ll>> mul(vector<vector<ll>> a, vector<vector<ll>> b, int n) {
	int i, j, k, t;
	vector<vector<ll>> c(n);
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			t = 0;
			for (k = 0; k < n; k++)
				t = (t + a[i][k] * b[k][j] % M) % M;
			c[i].push_back(t);
		}
	}
	return c;
}

template< typename Monoid >
struct SegmentTree {

	int sz;
	vector< Monoid > seg;

	const Monoid M1;

	SegmentTree(int n, const Monoid &M1) : M1(M1) {
		sz = 1;
		while (sz < n) sz <<= 1;
		seg.assign(2 * sz, M1);
	}

	void set(int k, const Monoid &x) {
		seg[k + sz] = x;
	}

	void build() {
		for (int k = sz - 1; k > 0; k--) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	void update(int k, const Monoid &x) {
		k += sz;
		seg[k] = x;
		while (k >>= 1) {
			seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
		}
	}

	Monoid query(int a, int b) {
		Monoid L = M1, R = M1;
		for (a += sz, b += sz; a < b; a >>= 1, b >>= 1) {
			if (a & 1) L = f(L, seg[a++]);
			if (b & 1) R = f(seg[--b], R);
		}
		return f(L, R);
	}

	Monoid value(const int &k) const {
		return seg[k + sz];
	}

	Monoid f(Monoid a, Monoid b) {
		return a + b;
	}
};

int main() {
	int n, h, w, ans;
	cin >> n >> h >> w;
	ans = (n - h + 1)*(n - w + 1);
	cout << ans << endl;
}

Measured memory_bytes: 4992