akhauriyash/Code-Regression huggingface dataset:
n = int(input())
d = {}
for i in range(n):
    l = input().split(" ")
    s = l[0]
    p = int(l[1])
    if s in d:
        d[s].append([p, i+1])
    else:
        d.setdefault(s, [[p, i+1]])

dd = sorted(d.items(), key=lambda x:x[0])

for item in dd:
    s = sorted(item[1], key=lambda x:x[0], reverse=True)
    for r in s:
        print(r[1])





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

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

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

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    ll ans = 0;
    vector<vector<vector<int>>> lis(21, vector<vector<int>>(21, vector<int>(11, 0)));
    REP(i, 0, n){
        string s; cin >> s;
        ll k = 0;
        int count = 0;
        REP(l, 0, s.size()){
            if(s[l] == '.'){
                count = s.size() - l - 1;
                continue;
            }
            k *= 10;
            k += (s[l] - '0');
        }
        //cout << count << endl;
        int c5 = 0, c2 = 0;
        while(k % 5 == 0){
            k /= 5;
            c5++;
        }
        while(k % 2 == 0){
            k /= 2;
            c2++;
        }
        REP(l, 0, 21){
            REP(k, 0, 21){
                REP(j, 0, 11){
                    int aa = c2 + l, bb = c5 + k;
                    int cc = min(aa, bb);
                    if(count + j <= cc){
                        ans += lis[l][k][j];
                    }
                }
            }
        }
        lis[min(c2, 20)][min(c5, 20)][count]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<climits>
#include<cctype>
#include<map>
#include<queue>
#include<iomanip>

using namespace std;

int main(){

	int N;

	cin >> N;

	int a[N];

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

	sort(a,a+N);


	int k = a[0];
	int l = a[N-1];

	int ans = 1e6;

	for(int i =k;i <= l;i++){
		int cost = 0;
		for(int j = 0;j < N;j++){
			cost += (a[j] - i)*(a[j] - i);
		}
		ans = min(ans,cost);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
fn main() {
    proconio::input!(
        s: String
    );
    let s: String = s;
    let date: Vec<usize> = s.split("/").map(|c| c.parse::<usize>().unwrap()).collect();
    let ans = if let [y, m, _d] = date[..] {
        if y > 2019 || (y == 2019 && m > 4) {
            "TBD"
        } else {
            "Heisei"
        }
    } else {
        ""
    };
    println!("{}", ans);
}


Measured memory_bytes: 2136
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
 
n = inp()
s = input()
t = input()
for i in range(n):
    for j in range(n-i):
        if s[i+j] != t[j]:
            break
    else:
        print(n+i)
        break
else:
    print(n*2)

Measured memory_bytes: 10420
#include<stdio.h>

int main (void)
{
	int a,b,c;

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

	if((a<b)&&(b<c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;
}


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

public class Main{
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int ar[]=new int[n];
        int x=in.nextInt();
        for (int i = 0; i < n; i++) {
            ar[i]=in.nextInt();
        }
        Arrays.sort(ar);
        int sum=0,c=0;
        while(x-->0){
            sum=sum+ar[c];
            c++;
        }
        System.out.println(sum);
    }
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  int i = 1;
  while(true) {
    c -= b;
    if(c < 1){
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if(a < 1){
      cout << "No" << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
#include<math.h>
#include<vector>
#include<deque>
#include <algorithm>
#include<set>
#include<map>
#include <limits>
#include<iomanip>
#include<string>
#include<bitset>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
#define d9_7 1000000007
int main(void){
  int n,m;
  cin>>n>>m;
  vector<int> s(n);
  vector<int> t(m);
  ll* dp1[2005];
  ll* dp2[2005];
  rep(i,2005){
    dp1[i]=(ll*)malloc(sizeof(ll)*2005);
    dp2[i]=(ll*)malloc(sizeof(ll)*2005);
  }
  rep(i,n){
    cin>>s[i];
  }
  rep(j,m){
    cin>>t[j];
  }
  rep(i,2005){
    rep(j,2005){
      dp1[i][j]=0;dp2[i][j]=0;
    }
  }
    rep(i,m){
      rep(j,n){
        if(s[j]==t[i]){
          dp1[i+1][j+1]=(dp2[i][j]+1)%d9_7;
        }else{
          dp1[i+1][j+1]=0;
        }
        dp1[i+1][j+1]%=d9_7;

          dp2[i+1][j+1]=dp2[i][j+1]+dp2[i+1][j]-dp2[i][j]+(dp1[i+1][j+1]);
          if(dp2[i+1][j+1]<0)dp2[i+1][j+1]+=d9_7;
        dp2[i+1][j+1]%=d9_7;
      }
    }
  /*rep(i,m){
    rep(j,n){
      cout<<dp[i+1][j+1]<<" ";
    }
    cout<<endl;
  }*/
  cout<<(dp2[m][n]+1)%d9_7<<endl;
  return 0;
}

Measured memory_bytes: 63104
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <cmath>

using namespace std;
const long long INF = (long long) (1e18)+1;

int main() {
  string s;
  cin >> s;
  // // map<string, int> words;
  for(int i=0; i<s.size(); ++i){
    if (s[i] == 'h' && s[i+1] == 'i') {
      ++i;
    } else {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
#define pff(a,b) printf("%d  %d\n",a,b);
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n, m;
	cin >> n >> m;
	map<int, int> foo;
	rep(i, n) {
		int k;
		cin >> k;
		rep(i, k) {
			int a;
			cin >> a;
			foo[a]++;
		}
	}
	int cnt = 0;
	for (int i = 1; i <= m; i++) {
		if (foo[i] == n) cnt++;
	}
	pf(cnt);

	return 0;
}

Measured memory_bytes: 3724
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
from collections import deque
#import heapq
from fractions  import gcd

#input=sys.stdin.readline
n=int(input())
a=list(map(int,input().split()))
i=0
f=False
while True:
    for j in range(n):
        if (a[j]>>i)&1:
            f=True
            break
    else:
        i+=1
    if f:
        break
print(i)

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

sum_list = [0] * 8

l_ppp = [0] * n
l_ppm = [0] * n
l_pmp = [0] * n
l_mpp = [0] * n
l_pmm = [0] * n
l_mpm = [0] * n
l_mmp = [0] * n
l_mmm = [0] * n

for i in range(n):
    l_ppp[i] = l[i][0] + l[i][1] + l[i][2]
    l_ppm[i] = l[i][0] + l[i][1] - l[i][2]
    l_pmp[i] = l[i][0] - l[i][1] + l[i][2]
    l_mpp[i] = - l[i][0] + l[i][1] + l[i][2]
    l_pmm[i] = l[i][0] - l[i][1] - l[i][2]
    l_mpm[i] = - l[i][0] + l[i][1] - l[i][2]
    l_mmp[i] = - l[i][0] - l[i][1] + l[i][2]
    l_mmm[i] = - l[i][0] - l[i][1] - l[i][2]
    
l_ppp = sorted(l_ppp, reverse=True)
l_ppm = sorted(l_ppm, reverse=True)
l_pmp = sorted(l_pmp, reverse=True)
l_mpp = sorted(l_mpp, reverse=True)
l_pmm = sorted(l_pmm, reverse=True)
l_mpm = sorted(l_mpm, reverse=True)
l_mmp = sorted(l_mmp, reverse=True)
l_mmm = sorted(l_mmm, reverse=True)

sum_list[0] = sum(l_ppp[:m])
sum_list[1] = sum(l_ppm[:m])
sum_list[2] = sum(l_pmp[:m])
sum_list[3] = sum(l_mpp[:m])
sum_list[4] = sum(l_pmm[:m])
sum_list[5] = sum(l_mpm[:m])
sum_list[6] = sum(l_mmp[:m])
sum_list[7] = sum(l_mmm[:m])

print(max(sum_list))

Measured memory_bytes: 9688
#!/usr/bin/perl

use strict;
use warnings;

my ($a, $b, $k);
{
    my $in = <STDIN>;
    ($a, $b, $k) = split(" ", $in);
}

if($a > $k) {
    $a -= $k;
    $k = 0
} else {
    $k -= $a;
    $a = 0;
}
if($b > $k) {
    $b -= $k;
    $k = 0
} else {
    $k -= $b;
    $b = 0;
}
print $a . " " . $b . "\n";

Measured memory_bytes: 640
#include<stdio.h>
#include<math.h>
int main(void){
  int n,sum=0,min=1000000;
  int x[105];
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    scanf("%d",&x[i]);
  }
  for(int i=0;i<100;i++){
    for(int j=0;j<n;j++){
      sum+=pow(x[j]-i,2);
    }
    if(sum<min){
      min=sum;
    }
    sum=0;
  }
  printf("%d\n",min);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 15;
const int MOD = 1e9 + 7;

int add(int a, int b)
{
  a += b;
  if (a >= MOD)
    a -= MOD;
  return a;
}

int sub(int a, int b)
{
  a -= b;
  if (a < 0)
    a += MOD;
  return a;
}

int mul(int a, int b)
{
  return (int) (((ll) a * b) % MOD);
}

int pot2[MAX*MAX];
int dp[1<<MAX];
int e[MAX];
int sajz[MAX][1<<MAX];
int n, m;

inline int gb(int x, int pos) {
  return x>>pos & 1;
}

int rek(int msk) {
  if (dp[msk] != -1) return dp[msk];

  int ret = 1;
  for (int pod=(msk-1) & msk; pod; pod = (pod - 1) & msk) {
    int veci = pod, manji = msk ^ pod;
    if (gb(veci, 0) != gb(veci, 1))
      continue;

    int tmp = 1;
    REP(i, n) {
      if (gb(veci, i))
	tmp = mul(tmp, sub(pot2[sajz[i][manji]], 1));
      else if (gb(manji, i))
	tmp = mul(tmp, pot2[sajz[i][veci]]);
    }

    tmp = mul(tmp, rek(veci));
    ret = add(ret, tmp);
  }

  return dp[msk] = ret;
}

int main()
{
  pot2[0] = 1;
  FOR(i, 1, MAX*MAX)
    pot2[i] = mul(2, pot2[i-1]);

  scanf("%d%d", &n, &m);
  REP(i, m) {
    int a, b;
    scanf("%d%d", &a, &b); a--; b--;
    e[a] |= 1<<b;
  }
    
  REP(i, n)
    REP(j, 1<<n)
    sajz[i][j] = __builtin_popcount(e[i] & j);

  memset(dp, -1, sizeof dp);  
  printf("%d\n", sub(pot2[m], rek((1<<n)-1)));

  return 0;
}


Measured memory_bytes: 2304
#include<stdio.h>
int main() {
	int K,ans,a,b;
	scanf("%d",&K);
	if (K % 2 == 0) {
		ans = (K / 2)*(K / 2);
		printf("%d\n", ans);
		return 0;
	}
	else {
		a = K/2;
		b = (K / 2) + 1;
		ans = a * b;
		printf("%d\n", ans);

	}


	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  	vector<int> A(N-1);
	vector<int> B(N);
    for(int i = 0; i < N-1; i++){
		cin >> A.at(i);
      	B.at(A.at(i) - 1) = B.at(A.at(i) - 1) + 1;
    }
  	for(int i = 0; i < N; i++)
      	cout << B.at(i) << endl;
}

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

#define ll             long long
#define LL             long long
#define pii            pair<int, int>
#define pll            pair<ll, ll>
#define pil            pair<int, ll>
#define pli            pair<ll, int>
#define vi             vector<int>
#define vl             vector<ll>
#define vii            vector<pii>
#define vll            vector<pll>
#define vil            vector<pil>
#define vli            vector<pli>
#define pb             push_back
#define ppb            pop_back
#define mp             make_pair
#define ff             first
#define ss             second
#define TN             typename
#define all(v)         v.begin(), v.end()
#define fill(a, b)     memset(a, b, sizeof a)
#define endl           '\n'

template <TN T> T gcd(T a, T b) {return !b ? a : gcd(b, a % b);}
template <TN T> T lcm(T a, T b) {return a * (b / gcd(a, b));}
template <TN T> T sqr(T a) {return a * a;}
template <TN T> T cube(T a) {return a * a * a;}
template <TN T> inline void smin(T &a, T b) {a = a < b ? a : b;}
template <TN T> inline void smax(T &a, T b) {a = a > b ? a : b;}

int in() {int n; scanf("%d", &n); return n;}
ll Lin() {ll n; scanf("%lld", &n); return n;}
double Din() {double n; scanf("%lf", &n); return n;}

const ll inf = (ll)1e17;
const ll mod = (ll)1e9 + 7;
const int N = 1e5 + 5;

ll dp[N];
int w[N], v[N];

int solve() {
	int n = in();
	ll W = Lin(), total = 0;
	for (int i = 1; i <= n; i++) {
		w[i] = in(), v[i] = in();
		total += v[i];
	}
	for (int i = 1; i <= total; i++) {
		dp[i] = inf;
	}

	for (int i = 1; i <= n; i++) {
		for (int j = total; j >= 1; j--) {
			if (j - v[i] >= 0) dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
		}
	}

	int ans = 0;
	for (int i = 1; i <= total; i++) {
		if (dp[i] <= W) ans = i;
	}
	cout << ans << endl;
	return 0;
}

int main() {
	int test = 1, tc = 0;
	//scanf("%d", &test);
	while (test--) {
		//printf("Case %d: ", ++tc);
		solve();
	}
	return 0;
}



Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Main {

	static List<String> values = new ArrayList<>();

	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String l1 = r.readLine();
		String l2 = r.readLine();
		String l3 = r.readLine();

		int[][] b = new int[3][];
		b[0] = Arrays.stream(l1.split(" ")).mapToInt(Integer::parseInt).toArray();
		b[1] = Arrays.stream(l2.split(" ")).mapToInt(Integer::parseInt).toArray();
		b[2] = Arrays.stream(l3.split(" ")).mapToInt(Integer::parseInt).toArray();

		boolean[][] res = new boolean[3][3];

		int n = Integer.parseInt(r.readLine());
		for (int i = 0; i < n; ++i) {
			String s = r.readLine();
			int v = Integer.parseInt(s);
			check(v, b, res);
		}

		if (hantei(res)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

		r.close();
	}

	public static void check(int v, int[][] bingo, boolean[][] res) {
		for (int x = 0; x < res.length; ++x) {
			for (int y = 0; y < res[x].length; ++y) {
				if (bingo[x][y] == v) {
					res[x][y] = true;
					return;
				}
			}
		}
	}

	public static boolean hantei(boolean[][] res) {
		return res[0][0] & res[0][1] & res[0][2] | res[1][0] & res[1][1] & res[1][2] | res[2][0] & res[2][1] & res[2][2]
				| res[0][0] & res[1][1] & res[2][2] | res[0][2] & res[1][1] & res[2][0]
				| res[0][0] & res[1][0] & res[2][0] | res[0][1] & res[1][1] & res[2][1]
				| res[0][2] & res[1][2] & res[2][2];
	}
}

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

const int ALP_NUM = 30;
vector<int> alp[ALP_NUM];

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

    for(int i = 0; i < s.length(); i++){
        alp[s[i] - 'a'].push_back(i);
    }

    int count = 0;
    int now = -1;
    for(int i = 0; i < t.length(); i++){
        int t_num = t[i] - 'a';
        auto it = lower_bound(alp[t_num].begin(), alp[t_num].end(), 0);
        if (it == alp[t_num].end()){
            cout << -1 << endl;
            return 0;
        }
        auto it2 = upper_bound(alp[t_num].begin(), alp[t_num].end(), now);
        if (it2 == alp[t_num].end()){
            count++;
            now = *it;
        }
        else now = *it2;
    }
    long long int ans = (long long int)s.length() * count + now + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3708
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N, M, C;
void solve() {
    cin >> N >> M >> C;
    vector<int> B(M);
    vector<int> A(M);
    for (int i = 0; i < M; i++) {
        cin >> B[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++) {
        int sum = 0;
        for(int i = 0; i < M; i++) {
            cin >> A[i];
            sum += (B[i] * A[i]);
        }
        if ((sum + C) > 0) {
            ans++;
        }
    }
    cout << ans << endl;
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  cin >> N >> M;
  ;
}
void solve() {
  // rironti
  // N + M/4 . -> Nがすくないとき．
  // N -> Nがおおいとき．
  if (N == M / 2) {
    cout << N << endl;
  } else if (N > M / 2) {
    cout << M / 2 << endl;
  } else if (N < M / 2) {
    // int a = M / 2 - N;
    M -= N * 2;
    cout << N + M / 4 << endl;
  }

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

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

#define int long long
#define pii pair<int, int>
#define pb push_back

signed main(){

    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    int N, K;
    cin >> N >> K;
    int a[N];
    int pre[N]{};
    for(int i = 0; i < N; i++){
        cin >> a[i];
        if(i)
            pre[i] = pre[i-1] + a[i];
        else{
            pre[i] = a[i];
        }
    }

    int ans = 0;
    double best = 0;
    for(int i = 0; i <= N - K; i++){
        ans = (i == 0) ? pre[K - 1] : pre[K + i - 1] - pre[i - 1];
        best = max(best, (double)(ans + K) / 2.0);

    }
    cout << setprecision(6) << fixed;
    cout << best << endl;

    return 0;
}


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

// 数字の各桁の和を返す
int sumDigits (int n) {
    int s;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}

// 最大公約数を返す
int gcd (int x, int y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

int main () {
    int N, K; cin >> N >> K;
    vector<int> x(N);
    rep(i, N) cin >> x[i];

    int ans = 0;
    rep(i, N) ans += 2*min(x[i], K-x[i]);
    
    cout << ans << endl;
}

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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    double base = 0.0;

    rep(i, n) {
        double tmp;
        cin >> tmp;
        base += 1.0 / tmp;
    }

    cout << Decimal << 1.0 / base << endl;
     

    return 0;
}


Measured memory_bytes: 256
// AOJ 0542: Authentication Level
// 2018.1.28 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 150000
typedef struct { int t; short r, c; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int r, int c, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].r = r, que[i].c = c, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int l[501][501];
int level[2][100001], lsz[2];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char mk[501][501];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
    int R, W, H, X, Y;
	int i, j, r, c, r2, c2, t, max, ans;

    while (R = in()) {
        for (i = 0; i < 2; i++) {
			W = in(), H = in(), X = in()-1, Y = in()-1;
			for (r = 0; r < H; r++) for (c = 0; c < W; c++) l[r][c] = in();

			memset(mk, 0, sizeof(mk));
			qsize = 0, level[i][0] = max = 0, lsz[i] = 1;
			enq(Y, X, l[Y][X]), mk[Y][X] = 1;
			while (qsize) {
				t = que[0].t, r = que[0].r, c = que[0].c, deq();
				if (t > max) max = t;
				level[i][lsz[i]++] = max;
				if (lsz[i] > R) break;

				for (j = 0; j < 4; j++) {
					r2 = r + mv[j][0], c2 = c + mv[j][1];
					if (r2 < 0 || r2 >= H || c2 < 0 || c2 >= W) continue;
					if (mk[r2][c2]) continue;
					mk[r2][c2] = 1;				// 同一部屋は２度とQに入れない
					enq(r2, c2, l[r2][c2]);
				}
			}
		}

		ans = 0x7ffffff;
		max = lsz[0]; if (max > R+1) max = R+1;
		for (i = 0; i < max; i++) {
			j = R - i;
			if (j < lsz[1]) {
				t = level[0][i] + level[1][j];
				if (t < ans) ans = t;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



Measured memory_bytes: 3872
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
using System.Text;//テキストの高速出力に必要
class Program
{
	static void Main()
	{
		string s = Console.ReadLine();
    string t = Console.ReadLine();
    int sn = s.Length;
    int tn = t.Length;
    int q = int.Parse(Console.ReadLine());
    int[] sumS = new int[sn+1];
    int[] sumT = new int[tn+1];
    for(int i = 0; i < sn; i++)
    {
      if(s[i] == 'A') sumS[i+1] = sumS[i] + 1;
      else sumS[i+1] = sumS[i] + 2;
    }
    for(int i = 0; i < tn; i++)
    {
      if(t[i] == 'A') sumT[i+1] = sumT[i] + 1;
      else sumT[i+1] = sumT[i] + 2;
    }

    for(int i = 0; i < q; i++)
    {
      string[] input = Console.ReadLine().Split(' ');
      int a = int.Parse(input[0]);
      int b = int.Parse(input[1]);
      int c = int.Parse(input[2]);
      int d = int.Parse(input[3]);
      
      if((sumS[b]-sumS[a-1])%3 == (sumT[d]-sumT[c-1])%3)
      {
        Console.WriteLine("YES");
      }else Console.WriteLine("NO");
    }
	}
}

Measured memory_bytes: 17512
import sys

sys.setrecursionlimit(1000000)


n=int(input())

#ノードクラスの定義
class Node:
    def __init__(self,name):
        self.name=name
        self.near=[]
        self.length=[]
    def coloring(self,color):
        self.color=color


#ノードリストの作成
nodelist=[]
for i in range(n):
    nodelist.append(Node(i))
   
    
#辺の作成
for i in range(n-1):
    u,v,w=[int(i) for i in input().split()]
    w=w%2
    nodelist[u-1].near.append(nodelist[v-1])
    nodelist[u-1].length.append(w)
    nodelist[v-1].near.append(nodelist[u-1])
    nodelist[v-1].length.append(w)
    
#行ったかカラーでチェックリスト
color=[None for i in range(n)]
color[0]=0



def paint(node):
    nodecolor=node.color
    for j in range(len(node.near)):
        nearnode=node.near[j]
        if color[nearnode.name]!=None:
            continue
        if node.length[j]==0:
            nearnode.coloring(nodecolor)
        else:
            nearnode.coloring((nodecolor+1)%2)
        color[nearnode.name]=0
        paint(nearnode)

nodelist[0].coloring(0)
paint(nodelist[0])


for i in nodelist:
    print(i.color)
            
        
    

Measured memory_bytes: 153888
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int a,b,c,d,e;
  cin >> a >> b>> c >> d >> e;
  int N=5;
  vector<int> time={a,b,c,d,e};
  vector<int> nexttime(N);
  for (int i=0; i<N; i++) {
    if (time[i]%10 == 0) {
      nexttime[i] = time[i];
    }
    else {
      nexttime[i] = time[i]-time[i]%10+10;
    }
  }
  int besttime =1000000;
  for (int i=0; i<N; i++) {
    int sumtime = 0;
    for (int j=0; j<N; j++) {
      if (i==j) {
        sumtime += time[j];
      }
      else {
        sumtime += nexttime[j];
      }
    }
    besttime = min(besttime,sumtime);
  }
  cout << besttime << endl;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    #[allow(unused_mut)]
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

fn gain(way: &Vec<(usize, usize)>, init: usize) -> usize {
  let mut g = vec![0usize; init + 1];
  for i in 0 .. init + 1 {
    g[i] = i;
  }
  for i in 1 .. init + 1 {
    for &(before, after) in way {
      if let Some(j) = i.checked_sub(before) {
        g[i] = cmp::max(g[i], g[j] + after);
      }
    }
  }
  g[init]
}

use cmp::Ordering::*;

fn main() {
  input! {
    n: usize,
    v: [[usize; 3]; 2],
  }
  let mut ab = vec![];
  let mut ba = vec![];
  for i in 0 .. 3 {
    match v[0][i].cmp(&v[1][i]) {
      Less => ab.push((v[0][i], v[1][i])),
      Greater => ba.push((v[1][i], v[0][i])),
      _ => ()
    }
  }
  let temp = gain(&ab, n);
  let ans = gain(&ba, temp);

  println!("{}", ans);
}


Measured memory_bytes: 200956
#include<stdio.h>
int main(void){
  long mod=1000000007;
int n,k;
  scanf("%d%d",&n,&k);
  long min=0,max=0;		
  long count=0;
  for(int i=0;i<k;i++){//累積和の開始点
    min+=i;
    max=max+n-i;
  }
//  printf("min=%ld max=%ld\n",min,max);
  count+=max-min+1;
  //printf("パターン数=%ld\n",count);
  for(int i=k;i<n+1;i++){
    min+=i;
    max+=n-i;   
  count+=max-min+1;
  //printf("min=%ld max=%ld\n",min,max);
  //printf("パターン数=%ld\n",count);
  }
  printf("%ld",count%mod);
  return 0;
}

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

using namespace std;

const int MOD=1e9+7;

typedef long long ll;

int main(){
	int N;
	ll dp[201][201];
	string st;
	scanf("%d",&N);
	for(int i=0;i<N;i++){
		char c;
		cin>>c;
		if(c!='-') st+=c;
	}
	N=st.size();
	dp[0][0]=1;
	for(int i=0;i<N;i++){
		for(int j=0;j<=i;j++){
			if(st[i]=='D'){
				dp[i+1][j]+=dp[i][j]*j%MOD;
				if(j!=0) dp[i+1][j-1]+=dp[i][j]*j*j%MOD;
			}
			else{
				dp[i+1][j+1]+=dp[i][j]%MOD;
				dp[i+1][j]+=dp[i][j]*j%MOD;
			}
		}
	}
	printf("%lld\n",dp[N][0]);
}


Measured memory_bytes: 3628
package main

import (
	"bufio"
	"fmt"
	"math/bits"
	"os"
	"strings"
)

func main() {
	N := ReadInt()
	X := ReadString()

	originalPopcount := strings.Count(X, "1")
	originalMinusOneMod := 0
	originalPlusOneMod := 0
	for _, c := range X {
		b := 0
		if c == '1' {
			b = 1
		}
		if originalPopcount > 1 {
			originalMinusOneMod = ((originalMinusOneMod << 1) + b) % (originalPopcount - 1)
		}
		originalPlusOneMod = ((originalPlusOneMod << 1) + b) % (originalPopcount + 1)
	}

	ans := make([]int, N)
	bMinusOneMod := 1
	bPlusOneMod := 1
	for i := N - 1; i >= 0; i-- {
		var a int
		if X[i] == '1' {
			if originalPopcount > 1 {
				a = 1 + f((originalPopcount-1+originalMinusOneMod-bMinusOneMod)%(originalPopcount-1))
			} else {
				a = 0
			}
		} else {
			a = 1 + f((originalPlusOneMod+bPlusOneMod)%(originalPopcount+1))
		}
		ans[i] = a
		if originalPopcount > 1 {
			bMinusOneMod = (bMinusOneMod * 2) % (originalPopcount - 1)
		}
		bPlusOneMod = (bPlusOneMod * 2) % (originalPopcount + 1)
	}
	for _, a := range ans {
		fmt.Println(a)
	}
}

func f(n int) int {
	if n == 0 {
		return 0
	}
	v := n % bits.OnesCount(uint(n))
	if v == 0 {
		return 1
	}
	return 1 + f(v)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


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

typedef long long int ll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vll> vvl;
typedef pair<ll, ll> pll;
typedef vector<pll> vpl;
typedef unordered_set<ll> usl;
typedef set<ll> sl;
typedef unordered_map<ll, ll> uml;
typedef map<ll, ll> ml;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;

#define all(v) v.begin() , v.end()
#define ceil(a, b) (a + b - 1) / b
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll inf = 1e9 + 7;
const double pie = 3.14159265358979323846;
const char nl = '\n';
const char spc = ' ';

template<typename Type>
istream &operator>>(istream &in, vector<Type> &v)
{
    ll n = v.size();
    for (int i = 0; i < n; i++)
        in >> v[i];
    return in;
}

template<typename Type>
ostream &operator<<(ostream &out, vector<Type> &v)
{
    for (auto value : v)
        out << value << ' ';
    out << nl;
    return out;
}

bool isPrime (ll n)
{
    if (n < 4)
        return true;
    if (n % 2 == 0)
        return false;
    ll i = 3;
    while (i * i <= n)
    {
        if (n % i == 0)
            return false;
        i += 2;
    }
    return true;
}

void solve ()
{
    ll n, W;
    cin >> n >> W;
    vll w(n + 1), v(n + 1);
    for (ll i = 1; i <= n; ++i)
        cin >> w[i] >> v[i];
    ll cost = 0;
    vvl dp (n + 1, vll(W + 1, 0));
    for (ll i = 1; i <= n; ++i)
    {
        ll wi = w[i], vi = v[i];
        for (ll wt = 0; wt <= W; ++wt)
        {
            if (wi <= wt)
                dp[i][wt] = max (vi + dp[i - 1][wt - wi], dp[i - 1][wt]);
            else
                dp[i][wt] = dp[i - 1][wt];
        }
    }
    cout << dp[n][W] << nl;
}

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

    ll t;
    t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

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

int main() {
	int n, x;
	std::cin >> n >> x;
	
	int l, bp = 0, ans = 1;
	for (int i = 0; i < n; i++) {
	    std::cin >> l;
	    bp += l;
	    if (bp <= x) ans++;
	}
	
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    ans = 0
    for i in range(N):
        ans += min(A[i], B[i])
        B[i] -= min(A[i], B[i])

        ans += min(A[i+1], B[i])
        A[i+1] -= min(A[i+1], B[i])

    print(ans)

main()

Measured memory_bytes: 18468
#include <stdio.h>

int main(void){
    int n, q;
    scanf("%d %d", &n, &q);
    char s[n];
    scanf("%s", &s);
    int l[q], r[q]; 
    for(int i = 0;i < q;i++){
        scanf("%d %d", &l[i], &r[i]);
    }
    int t[n];
    t[0] = 0;
    int count = 0;
    for(int i = 0;i < n-1;i++){
        if(s[i] == 'A'){
            if(s[i+1] == 'C'){
                count++;
            }
        }
        t[i+1] = count;
    }
    for(int i = 0;i < q;i++){
        printf("%d\n", t[r[i]-1]-t[l[i]-1]);
    }
    return 0;
}

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

using namespace std;

int main(int argc, char const *argv[]) {
  string a, b, c;
  cin >> a >> b >> c;
  int la = a.length(), lb = b.length();
  if (a[la-1] == b[0] and b[lb-1]==c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
const int N=105;
const int M=100050;
ll dp[N][M],w[N],v[N];
int main()
{
int n,W;
scanf("%i %i",&n,&W);
for(int i=1;i<=n;i++)
scanf("%lld %lld",&w[i],&v[i]);
for(int i=1;i<=n;i++)
for(int j=1;j<=W;j++)
dp[i][j]=max(dp[i-1][j],j>=w[i]?dp[i-1][j-w[i]]+v[i]:0);
printf("%lld",dp[n][W]);
return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	string s,t;cin>>s>>t;
	map<char,int> num;
	rep(i,0,s.size()) num[s.at(i)]++;
	rep(i,0,t.size()){
		if(num[t.at(i)]==0){ cout<<-1<<endl;return 0; }
	}
	int n=s.size();s+=s;
	int temp;vector<map<char,long>> next(n);
	rep(i,0,26){
		char c=(char)(i+97);
		if(num[c]==0) continue;
	    for(int j=2*n-1;j>=0;j--){
		    if(temp) next[j%n][c]=(temp-j-1)%n+1;
		    if(s.at(j)==c) temp=j;
		}
	}
	long ans;
	rep(i,0,n)if(s.at(i)==t.at(0)){ ans=i;break; }
	rep(i,1,t.size()){
		ans+=next[ans%n][t.at(i)];
	}cout<<ans+1<<endl;
}

Measured memory_bytes: 169728
<?php

fscanf(STDIN,"%d %d",$n,$limit);

$cost = PHP_INT_MAX;
$answer = 0;
for($i=1;$i<=$n;$i++){
    fscanf(STDIN,"%d %d",$ncost,$time);
    if($time<=$limit){
        if($ncost<$cost){
            $cost = $ncost;
            $answer = $i;
        }
    }
}

if($answer==0){
    echo "TLE";
}else{
    echo $cost;
}

?>

Measured memory_bytes: 4728
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int L, ans = 0;
	string S;
	
	cin>>L>>S;
	
	for(int i = 0; i < L; i++){
		if(S[i] != '.') continue;
		S[i] = 'W';
		int con = 0, conb = 0;
		// cout<<"i = "<<i<<endl;
		for(int j = 0; j < L; j++){
			for(int k = j+1; k < L; k++){
				// if(j == k) continue;
				if(S[j] != 'W' || S[k] != 'W') continue;
				bool flag = true;
				for(int l = j+1; l < k; l++){
					if(S[l] != 'B'){
						flag = false;
						break;
					}
				}
				if(flag) con += k-j-1;
			}
		}
		
		for(int j = 0; j < L; j++){
			for(int k = j+1; k < L; k++){
				// if(j == k) continue;
				if(S[j] != 'B' || S[k] != 'B') continue;
				bool flag = true;
				for(int l = j+1; l < k; l++){
					if(S[l] != 'W'){
						flag = false;
						break;
					}
				}
				if(flag) conb += k-j-1;
			}
		}
		if(!conb) ans = max(ans, con);
		
		S[i] = '.';
	}
	
	cout<<ans<<endl;
	
	return 0;
}


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

class PriorityQueue {
private:
  int size;
  int queue[2000000];

  // max-ヒープ条件を適用する
  void max_heapify(int i) {
    int l, r, largest;

    l = i * 2;
    r = i * 2 + 1;

    // largestを決める
    if (l <= size && queue[l] > queue[i]) largest = l;
    else largest = i;    
    if (r <= size && queue[r] > queue[largest]) largest = r;

    if (largest != i) {
      // 要素を交換
      swap(queue[i], queue[largest]);
      // 再帰的に呼び出す
      max_heapify(largest);
    }
  }
  
public:
  PriorityQueue () {
    size = 0;
  }
  
  void push(int key) {
    int parent, pos;
    
    pos = ++size;
    queue[pos] = key;  // 要素を挿入
    // 適切な位置に配置する
    parent = pos / 2;
    while (pos > 1 && queue[pos] > queue[parent]) {
      swap(queue[pos], queue[parent]);
      pos = parent;
      parent = pos / 2;
    }
  }

  int pop() {
    if (size < 1) return -1;

    int max_value = queue[1];

    // 末尾の値を根に配置した後、要素を適切に配置する
    queue[1] = queue[size--];
    max_heapify(1);

    return max_value;
  }
};

int main() {
  int key, top;
  string command;
  PriorityQueue q;

  while (1) {
    cin >> command;
    if (command == "end") break;
    else if (command[0] == 'i') {
      cin >> key;
      q.push(key);
    } else {
      top = q.pop();
      cout << top << endl;
    }
  }  

  return 0;
}



Measured memory_bytes: 6920
# DP
N, M = map(int, input().split())
broken = set([int(input()) for _ in range(M)])

MOD = 10**9+7
dp = [0 for i in range(N+2)]
dp[N] = 1

for i in reversed(range(N)):
    if i in broken:
        continue
    dp[i] = dp[i+1] + dp[i+2]
    dp[i] %= MOD

print(dp[0])


Measured memory_bytes: 59476
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e6 + 5;

int main()
{
	ll l, r, x;
	cin >> l >> r >> x;
	ll res = (r / x) - (l / x);
	if (l % x == 0 )res++;
	cout << res << endl;
}

Measured memory_bytes: 3160
n=200
N=int(input())
if 2*n<=N<3*n:
  print(8)
elif 3*n<=N<4*n:
  print(7)
elif 4*n<=N<5*n:
  print(6)
elif 5*n<=N<6*n:
  print(5)
elif 6*n<=N<7*n:
  print(4)
elif 7*n<=N<8*n:
  print(3)
elif 8*n<=N<9*n:
  print(2)
else:
  print(1)

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

int main() {
	int N, M, a, b;
	cin >> N >> M;
	vector<int> S(N + 1, 0);
	for (int i = 0;i < M;i++) {
		cin >> a;
		S[a] = -1;
	}
	for (int i = 0;i < N + 1;i++) {
		if (S[i] == -1) continue;
		if (i == 0) S[i] = 1;
		if (i == 1) S[i] = 1;
		if (i > 1) {
			a = S[i - 1];
			b = S[i - 2];
			S[i] = max(0, a) + max(0, b);
			S[i] %= MOD;
		}
	}
	cout << S[N] << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
int main()
{
	int n,m;
	while(1)
	{
	string s;
	cin >> n;
	if(n==0)break;
	cin >> m;
	cin >> s;
	vector<int> vec;
	vec.clear();
	int count=0;
	for(int i=1;i<s.size();i++)
	{
		if(count==0)
		{
			if(s[i-1]!=s[i])
			{
				if(s[i-1]=='I')count=2;
				else count=1;
			}
			else count=0;
		}
		else
		{
			if(s[i-1]==s[i])
			{
				if(s[i-1]=='O')
				{
					count--;
					vec.pb((count-1)/2);
					count=0;
				}
				else
				{
					vec.pb((count-1)/2);
					count=0;
				}
			}
			else
			{
				count++;
			}
		}
	}
	int ans=0;
	for(int i=0;i<vec.size();i++)
	{
		ans+=max(0,vec[i]-n+1);
	}
	cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}


vector<int> argmin_subseq(const vector<int> &seq,const int K){
  vector<int> A=seq;
  const int mi=numeric_limits<int>::min();
  int N=A.size(),mx=mi,amx;
  assert(0<K && K<=N);
  vector<int> idx,nx;
  for(auto &I:A){I*=-1;}
  for(int i=0;i+K<=N;i++){mx=max(mx,A[i]);}
  for(auto &I:A){I-=mx;}
  for(int i=0;i+K<=N;i++){
    if(A[i]==0){A[i]++; idx.push_back(i);}
  }
  for(int len=1;len<K;){
    mx=mi;
    amx=-1;
    for(auto I:idx){
      if(mx<=A[I+len]){
        mx=A[I+len];
        amx=I;
      }
    }
    if(mx<=0){
      for(auto I:idx){
        if(A[I+len]==mx){A[I]++; nx.push_back(I);}
      }
      len++;
    }
    else{
      reverse(idx.begin(),idx.end());
      int ls=idx[0];
      if(ls+len+K>N){
        for(int j=0;j<mx && len+j<K;j++){
          if(seq[amx+len+j]>seq[ls+len+j]){return {ls};}
          else if(seq[amx+len+j]==seq[ls+len+j]){
            A[ls]++;
            if(amx+len==ls){mx++;}
          }
          else{break;}
        }
      }
      mx=mi;
      for(auto I:idx){
        A[I]+=max(0,min(A[I+len],K-len));
        mx=max(mx,A[I]);
      }
      reverse(idx.begin(),idx.end());
      for(auto I:idx){
        if(A[I]==mx){nx.push_back(I);}
      }
      len=mx;
    }
    idx.clear();
    swap(nx,idx);
  }
  return idx;
}

int main(){
  ll N,K;
  cin>>N>>K;
  string s;
  cin>>s;
  string t=s;
  reverse(t.begin(),t.end());
  s+=t;
  vector<int> A(s.size());
  for(int i=0;i<(int)s.size();i++){A[i]=(int)s[i];}
  vector<int> ret=argmin_subseq(A,N);
  int idx=ret[0];
  int cnt=0,c=0;
  for(int i=0;i<N;i++){
    if(A[idx]==A[idx+i]){cnt++;}
    else{break;}
  }
  c=cnt;
  while(K>1 && cnt<N){cnt*=2; K--;}
  string ans;
  for(int i=0;i<cnt && i<N;i++){ans+=s[idx];}
  for(int i=cnt;i<N;i++){ans+=s[idx+c+(i-cnt)];}
  cout<<ans<<endl;

  
  return 0;
}


Measured memory_bytes: 384
N, A, B = map(int, input().split())
v = list(map(int, input().split()))
v.sort(reverse=True)
 
def combination(a, b):
    u, d = 1, 1
    for i in range(b):
        u *= a - i
        d *= b - i
    
    return u // d
 
s_i = sum(v[:A])
c_i = A
ans = 0
a = A
while s_i * a == sum(v[:a]) * c_i and a <= B:
    last_num = None
    c = 0
    for i in range(a):
        n = v[i]
        if n == last_num:
            c += 1
        else:
            c = 0
        
        last_num = n
 
    ans += combination(v.count(v[a - 1]), c + 1)
    a += 1
 
print(sum(v[:A]) / A)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define N	 100
void solve(){
	int n;
	cin>>n;
	cout<<24+24-n<<endl;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

int a[14][14];

int bomb(int y, int x)
{
    a[y][x] = 0;
    for (int i = 1; i <= 3; i++)
    {
       
        if (a[y + i][x] == 1)
            bomb(y + i, x);
        if (a[y - i][x] == 1)
            bomb(y - i, x);
        if (a[y][x + i] == 1)
            bomb(y, x + i);
        if (a[y][x - i] == 1)
            bomb(y, x - i);
    }

    return 0;
}

int main()
{
    rep(i, 14) rep(j, 14) a[i][j] = 0;
    int n;
    cin >> n;

    rep(k, n)
    {
        for (int i = 3; i <= 10; i++)
        {
            string s;
            cin >> s;
            for (int j = 3; j <= 10; j++)
            {
                a[i][j] = s[j - 3] - '0';
            }
        }
        int x, y;
        cin >> y >> x;

        bomb(x + 2, y + 2);

        printf("Data %d:\n", k + 1);
        for (int i = 3; i <= 10; i++)
        {
            for (int j = 3; j <= 10; j++)
            {
                cout << a[i][j];
            }
            cout << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M,ans=0;
    cin>>N>>M;
    vector<vector<bool>> graph(N,vector<bool>(N,false));

    rep(i,0,M){
        int A,B;
        cin>>A>>B;
        graph[A-1][B-1] = true;
        graph[B-1][A-1] = true;
    }

    vector<int> path(N-1);
    rep(i,1,N) path[i-1] = i;

    do{
        int before = 0,res = 1;
        rep(i,0,N-1){
            if(!graph[before][path[i]]){
                res = 0;
                break;
            }
            before = path[i];
        }
        ans += res;
    }while(next_permutation(all(path)));

    put(ans);

}

Measured memory_bytes: 256