akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main()
{
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    b = b-a;
    c = c-a;
    d = d-a;
    e = e-a;
    if(b>k || c>k || d>k || e>k)
    {
        cout << ":(";
    }
    else
    {
        cout << "Yay! ";
    }
    
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <map>
#define ll long long
using namespace std;
const int  N=1e5+9;
int  n,a[N];
int main()
{
    while(~scanf("%d",&n))
    {
        for(int i=1; i<=n; i++)
        {
            scanf("%d",&a[i]);
        }
        a[n+1]=-1;
        int cnt=0;
        int i=1;
        while(i<=n)
        {
            if(a[i]==i)
            {
                i+=2;
                cnt++;
            }
            else
            {
                i++;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}


Measured memory_bytes: 640
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);
		
		int n = in.nextInt();
		int m = in.nextInt();
		int[] answer = new int[n];
		
		for (int i = 0; i < m; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			
			answer[a]++;
			answer[b]++;
		}
		
		for (int i = 0; i < n; i++) {
			System.out.println(answer[i]);
		}
	}
	
	
}

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

int n;
char t[100010];
long long int js[100010], is[100010];
long long int ans, ma;

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

	for(int i=0; i<n; ++i){
		if(t[i] == 'J') ++js[i+1];
		else if(t[i] == 'I') ++is[i];
	}
//	for(int i=0; i<=n; ++i) printf("%lld %lld\n", js[i], is[i]);
	for(int i=0; i<n; ++i){
		js[i+1] += js[i];
		is[n-i-1] += is[n-i];
	}
//	for(int i=0; i<=n; ++i) printf("%lld %lld\n", js[i], is[i]);
//	for(int i=0; i<=n; ++i) printf("%lld %lld\n", js[i], is[i]);
	for(int i=0; i<=n; ++i)
		ma = max(ma, js[i] * is[i]);
	for(int i=0; i<=n; ++i)
		if(i == n || t[i] != 'O'){
			js[i] = 0;
			is[i] = 0;
		}
	for(int i=0; i<n; ++i)
		js[i+1] += js[i];
	for(int i=n; i>0; --i)
		is[i-1] += is[i];
	for(int i=0; i<=n; ++i)
		if(t[i] == 'J') ans += is[i];
//	printf("%lld\n", ans);
/*	for(int i=0; i<=n; ++i)
		if(t[i] == 'I') ans += js[i];
	printf("%lld\n", ans);
*/
	ma = max(ma, max(is[0], js[n]));
	ans += ma;
	printf("%lld\n", ans);
}

Measured memory_bytes: 4412
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c,x,ans=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(int i=0;i<=a;i++)
    {
    	for(int j=0;j<=b;j++)
    	{
    		int k=i*500+j*100;
    		if(x-k>=0&&x-k<=c*50)ans++;
    		if(k>x)break;
		}
	}	
    printf("%d",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

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

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


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


constexpr int N = 10000;
char s[N+10], t[N+10];

int main(void){
    int n; scanf("%d%s%s", &n, s, t);
    REP(i, n) putchar(s[i]), putchar(t[i]);
    putchar('\n');

    


    return 0;
}


Measured memory_bytes: 760
#include<iostream>
using namespace std;
int main()
{
    int n, c=0;
    cin>>n;
    char s[n];
    for(int i=0;i<n; i++)
    {
        cin>>s[i];
    }
    for(int i=0;i<n/2; i++)
    {
     if(s[i]!=s[i+(n/2)])
      {
          c++;
          break;
      }
    }
    if(c==0 && n%2==0&& n!=0)

    cout<< "Yes"<< endl;

else
    cout<< "No"<< endl;


    return 0;
}



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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }
//
//
int main(){
	int n ; 
	cin >> n ;
	vector<double> a(n) ; 
	priority_queue<double> q; 
	for(double& d : a ){
		cin >> d; 
		q.push(-d); 
	}
	for(int i = 0 ; i < n-1 ; i++ ){
		double x = -q.top(); 
		q.pop(); 
		double y = -q.top();  
		q.pop(); 
		q.push(-(x+y)/2); 
	}
	// cout << -q.top()<<endl; 
	printf("%0.5f",-q.top()); 
}


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

#define ll long long
#define inf 1e9
#define eps 1e-10
#define md
#define N 310
using namespace std;
int a[N][N];
bool b[N][N];
int main()
{
	int n;scanf("%d",&n);
	int ok=1; ll sum=0;
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
			sum+=a[i][j];
		}
	memset(b,1,sizeof(b));
	for (int k=1;k<=n;k++)
		for (int i=1;i<=n;i++)
			for (int j=1;j<=n;j++)
			{
				if (i==j||i==k||j==k) continue;
				if (a[i][j]>a[i][k]+a[k][j])
				{
					printf("-1\n");
					//printf("wa %d %d %d\n",i,j,k);
					return 0;
				}
				else if (a[i][j]==a[i][k]+a[k][j])
				{
					if (b[i][j]) { b[i][j]=0; sum-=a[i][j];}
				}
			}
	printf("%lld\n",sum/2);
	return 0;
}
					



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

#define MIN_INT -2147483648
#define MAX_INT 2147483647
#define MIN_LONG -9223372036854775808L
#define MAX_LONG 9223372036854775807L

#define long long long int

using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    int c = 1;
    int t = 10;
    int res = 0;
    for (int i = 1; i <= n; i++) {
        if (i >= t) {
            t *= 10;
            c++;
        }
        if (c % 2 == 1) {
            res++;
        }
    }
    cout << res;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	
	public static void main(String[]args){
	Scanner scan=new Scanner(System.in);
		String a=scan.next();
		int count0=0;
		int count1=0;
		for(int i=0;i<a.length();i++) {
			char ch=a.charAt(i);
			if(ch=='0') {
				count0++;
			}
			else {
				count1++;
			}
		}
		System.out.println(count1>count0?count0*2:count1*2);
	}
}

Measured memory_bytes: 24452
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N;
    cin >>N;
    
     cout << fixed << setprecision(15) << 2*M_PI*N << endl;


    return 0;
    

}

Measured memory_bytes: 3760
from math import ceil, sqrt

N, M = map(int, input().split())
ans = 0
for i in range(1, ceil(sqrt(M))+1):
  if M % i==0:
    if i >= N:
      ans = max(ans, M//i)
    if M//i >= N:
      ans = max(ans, i)
      
print(ans)


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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

class modint {
  private:
    ll m_val;
    ll m_mod;
  public:
    constexpr modint() noexcept : m_val(0), m_mod() { m_mod = MOD; }
    constexpr modint(const ll x) noexcept : m_val(0), m_mod(0) { m_mod = MOD; m_val = x % m_mod; }
    constexpr modint(const ll x, const ll mod) noexcept : m_val(0), m_mod(0) { m_mod = mod; m_val = x % m_mod; }
    constexpr ll val() noexcept { return m_val; }
    constexpr const ll val() const noexcept { return m_val; }
    constexpr modint operator+(const modint rhs) const noexcept { return modint(*this) += rhs; }
    constexpr modint operator-(const modint rhs) const noexcept { return modint(*this) -= rhs; }
    constexpr modint operator*(const modint rhs) const noexcept { return modint(*this) *= rhs; }
    constexpr modint operator/(const modint rhs) const noexcept { return modint(*this) /= rhs; }
    constexpr modint &operator+=(const modint rhs) noexcept {
      m_val += rhs.m_val;
      if (m_val >= m_mod) m_val -= m_mod;
      return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
      if (m_val < rhs.m_val) m_val += m_mod;
      m_val -= rhs.m_val;
      return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
      m_val = m_val * rhs.m_val % m_mod;
      return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
      ll exp = m_mod - 2;
      while (exp) {
        if (exp % 2) *this *= rhs;
        rhs *= rhs;
        exp /= 2;
      }
      return *this;
    }
};

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

ll comb(modint n, modint r) {
  modint dividend(1);
  modint divisor(1);
  for (ll i = 1; i <= r.val(); ++i) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return (dividend / divisor).val();
}

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  modint ans(modpow(2, n) - 1);

  ans -= comb(n, a);
  ans -= comb(n, b);

  cout << ans.val() << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int main()
{
    fastio();
    int n,m,x; cin>>n>>m>>x; int arr[n]={0}; --x;
    for(int i=0;i<m;++i) {int k; cin>>k; arr[k-1]=1;}
    int sum1=0,sum2=0;
    for(int i=0;i<x;++i) sum1+=arr[i];
    for(int i=x+1;i<n;++i) sum2+=arr[i];
    cout<<min(sum1,sum2);
    return 0;
}

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

int main() {
    int n, num, b, f, r, v;
    int building[4][3][10] = {{ 0 }};
    
    cin >> n;
    
    for (int i = 0; i < n; i++) {
        cin >> b >> f >> r >> v;
        building[b-1][f-1][r-1] += v;
    }
    
    for (int j = 0; j < 4; j++) {
        for (int k = 0; k < 3; k++) {
            for (int l = 0; l < 10; l++) {
                if (l == 9) {
                    cout << " " << building[j][k][l] << endl;
                } else {
                    cout << " " << building[j][k][l];
                }
            }
        }
        
        if (j < 3) {
            cout << "####################" << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3092
//#include<bits/stdc++.h>
#include<iostream>
#include<string>

#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int main(){
    string a, b;
    cin >> a >> b;
    string temp = a, batas = a;
    for(int i = 0; i < stoi(b) - 1; i++){
        a += temp;
    }

    temp = b;
    for(int j = 0; j < stoi(batas) - 1; j++){
        b += temp;
    }
    if(a < b)
        cout << a << '\n';
    else
        cout << b << '\n';
    
    return 0;
}

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

#define F first 
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 2 * N;

int n, h[N];

int main()
{
	scanf("%d", &n);
	
	for (int i = 0; i < n; i ++ )
	{
		int x;
		scanf("%d", &x);
		h[x] ++ ;
	}
	
	int cnt = 0, res = 0;
	for (int i = 1; i < N; i ++ )
		if (h[i])
		{
			res ++ ;
			if (h[i] % 2 == 0) cnt ++ ;
		}
	
	if (cnt & 1) printf("%d\n", res - 1);
	else printf("%d\n", res);
    return 0;
}

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

#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl

typedef long long ll;

using namespace std;

void solve() {
    ll N, A, B;
    cin >> N >> A >> B;

    ll T = A + B;
    ll d = N / T;
    ll r = N % T;
    print(d * A + min(r, A));
}

signed main() {
    solve();
}


Measured memory_bytes: 256
from sys import stdin
H,W = [int(x) for x in stdin.readline().rstrip().split()]

data = [[""] * (W + 2) ]
for _ in range(H):
    data.append([""] + list(input()) + [""])
data.append([""] * (W + 2))

for i in range(1,H+1):
    for j in range(1,W+1):
        if data[i][j] == ".":
            mine = 0
            if data[i-1][j-1] == "#":
                mine += 1
            if data[i-1][j]   == "#":
                mine += 1
            if data[i-1][j+1] == "#":
                mine += 1
            if data[i][j-1]   == "#":
                mine += 1
            if data[i][j+1]   == "#":
                mine += 1
            if data[i+1][j-1] == "#":
                mine += 1
            if data[i+1][j]   == "#":
                mine += 1
            if data[i+1][j+1] == "#":
                mine += 1
            data[i][j] = str(mine)
        mine = 0

for k in data:
    print("".join(k))

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

int main(){
    const double PI=3.14159265358979323846;
    int r; cin >> r;
    cout << fixed << 2 * PI * r << endl;
}

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> nums(N);
    for (int i = 0; i < N; i++)
    {
        cin >> nums.at(i);
    }
    vector<ll> ruisekiNum(N + 1);
    for (int i = 0; i < N; i++)
    {
        ruisekiNum.at(i + 1) = ruisekiNum.at(i) + nums.at(i);
    }
    ll INF = 1e15;
    ll answer = INF;
    //(一つ目と二つ目) < i <= (三つ目と四つ目)で分け、それぞれの境界を二分探索
    vector<ll> hiPart(4);
    vector<ll> lowPart(4);
    for (int i = 2; i < N - 1; i++)
    {
        ll leftOk, rightOk;
        ll ok, ng;
        ok = i - 1;
        ng = 0;
        while (abs(ok - ng) > 1)
        {
            ll mid = ng + (ok - ng) / 2;
            if (ruisekiNum.at(mid) > ruisekiNum.at(i) - ruisekiNum.at(mid))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        leftOk = ok;
        ok = N - 1;
        ng = i;
        while (abs(ok - ng) > 1)
        {
            ll mid = ng + (ok - ng) / 2;
            if (ruisekiNum.at(mid) - ruisekiNum.at(i) > ruisekiNum.at(N) - ruisekiNum.at(mid))
            {
                ok = mid;
            }
            else
            {
                ng = mid;
            }
        }
        rightOk = ok;
        hiPart.at(0) = ruisekiNum.at(leftOk);
        lowPart.at(1) = ruisekiNum.at(i) - ruisekiNum.at(leftOk);
        hiPart.at(2) = ruisekiNum.at(rightOk) - ruisekiNum.at(i);
        lowPart.at(3) = ruisekiNum.at(N) - ruisekiNum.at(rightOk);

        if(leftOk > 1)
        {
            leftOk--;
        }
        lowPart.at(0) = ruisekiNum.at(leftOk);
        hiPart.at(1) = ruisekiNum.at(i) - ruisekiNum.at(leftOk);
        if(rightOk > i + 1)
        {
            rightOk--;
        }
        lowPart.at(2) = ruisekiNum.at(rightOk) - ruisekiNum.at(i);
        hiPart.at(3) = ruisekiNum.at(N) - ruisekiNum.at(rightOk);
        answer = min(answer, max({hiPart.at(0), lowPart.at(1), hiPart.at(2), lowPart.at(3)}) - min({hiPart.at(0), lowPart.at(1), hiPart.at(2), lowPart.at(3)}));
        answer = min(answer, max({hiPart.at(0), lowPart.at(1), lowPart.at(2), hiPart.at(3)}) - min({hiPart.at(0), lowPart.at(1), lowPart.at(2), hiPart.at(3)}));
        answer = min(answer, max({lowPart.at(0), hiPart.at(1), hiPart.at(2), lowPart.at(3)}) - min({lowPart.at(0), hiPart.at(1), hiPart.at(2), lowPart.at(3)}));
        answer = min(answer, max({lowPart.at(0), hiPart.at(1), lowPart.at(2), hiPart.at(3)}) - min({lowPart.at(0), hiPart.at(1), lowPart.at(2), hiPart.at(3)}));
    }
    cout << answer << endl;
    return 0;
}


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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

using namespace std;

typedef long long int lli;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    REP (i, 0, N) cin >> A[i];
    REP (i, 0, N) cin >> B[i];
    REP (i, 0, N) cin >> C[i];
    
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    vector<lli> BB(N, 0);
    REP (i, 0, N) {
        BB[i] = N - (upper_bound(C.begin(), C.end(), B[i]) - C.begin());
    }
    BB.insert(BB.begin(), 0);
    REP (i, 0, N) BB[i + 1] += BB[i];
    lli ans = 0;
    REP (i, 0, N) {
        int pos = upper_bound(B.begin(), B.end(), A[i]) - B.begin();
        ans += (BB[N] - BB[pos]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2944
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

using ll = long long;
using P = pair<double, double>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

const double time_limit = 1.9;
double start;

unsigned rando() {
	static unsigned y = 2463534242;
    y ^= y << 13;y ^= y >> 17;y ^= y << 5;
    return y;
}


double sec() {
	struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec + tv.tv_usec * 1e-6;
}

double pastTime() {
	return sec() - start;
}

int d;

int c[26];
int s[365][26];

int score(vector<int>& t) {
	int score = 0;
	vector<int> last(26,0);
	rep(i, d) {
		score += s[i][t[i]];
		last[t[i]] = (i + 1);

		rep(j,26) {
			score -= ((i + 1) - last[j]) * c[j];
		}
		//cout  << score << endl;

	} 


	return score;

}

void output(vector<int>& t) {
	rep(i, d) {
		cout << t[i] + 1 << endl;
	}
}


int main() {
	


	cin >> d;
	rep(i, 26) {
		cin >> c[i];
	} 
	rep(i, d) {
		rep(j,26) {
			cin >> s[i][j];
		}
	}
	start = sec();
	vector<int> t(d);

	rep(i, d) {
		int max_j = -1;
		int max_s = -1;
		rep(j, 26) {
			if (s[i][j] > max_s) {
				max_j = j;
				max_s = s[i][j];
			}
		}
		//t[i] = rando() % 26;
		t[i] = max_j;
		
	}

	int cur = score(t);


	while(true) {
		double cur_time = pastTime();
		if (cur_time > time_limit) {
			break;
		}
		//vector<int> nt = t;
		int size = (int) ((time_limit - cur_time) / time_limit * 3.5) + 1;
		
		for (int loop = 0; loop < 100; loop++) {
			stack<P> cd;
			rep(i ,size) {
				int cur_d = rando() % d;
				int cur_c = rando() % 26;
				cd.push(mkp(cur_d, t[cur_d]));
 
				t[cur_d] = cur_c;
			}
			int next = score(t);
			if (cur < next) {
				cur = next;
			} else {
				while(!cd.empty()) {
					auto cur = cd.top();
					t[cur.first] = cur.second;
					cd.pop();
				}
			}
		}
	}
	output(t);

	//cout << "score:" <<  << endl;

	return 0;
}


Measured memory_bytes: 3228
def main():
    N=int(input())
    abc=[0]*N
    for i in range(N):
        xyz=list(map(int,input().split()))
        abc[i]=xyz
    dp=[[0]*3 for _ in range(N+1)]
    for i in range(1,N+1):
        for j in range(3):
            dp[i][j]=max(dp[i-1][(j-1)%3]+abc[i-1][(j-1)%3],dp[i-1][(j-2)%3]+abc[i-1][(j-1)%3])

    print(max(max(dp[N][0],dp[N][1]),dp[N][2]))

if __name__=="__main__":
    main()

Measured memory_bytes: 47388
// C++ 14
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
#define chmax(x,y) (x = max(x, y))

int main() {
  []{
    string s; cin >> s;
    int n = s[s.size()-1]-'0';
    if (n==3) { cout << "bon" << endl; return; }
    if (n==0 or n==1 or n==6 or n==8) { cout << "pon" << endl; return; }
    cout << "hon" << endl;
  }();
  
  return 0;
}


Measured memory_bytes: 3624
import java.util.Scanner;

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

		String a=sc.next();
		String b=sc.next();

		if(a.charAt(0)==b.charAt(2)&&a.charAt(1)==b.charAt(1)&&a.charAt(2)==b.charAt(0)) {
			System.out.println("YES");
		}
		else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
h = tuple(map(int,input().split()))

dp = [0] + [float("inf")]*(n-1)
for i in range(1,n):
    for j in range(max(0,i-k),i):
        dp[i] = min(dp[i],dp[j]+abs(h[i]-h[j]))
print(dp[-1])

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a/gcd(a, b) * b;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> A(N+1);
    vector<bool> B(N+1, true);

    for(ll i=1; i<=N; i++){
        cin >> A[i];
    }

    bool flag = true;
    ll ans = 0;
    ll now = 1;
    while(flag){
        if(B[now] == false){
            flag = false;
        }
        ans++;
        if(A[now] == 2){
            cout << ans << endl;
            return 0;
        }
        B[now] = false;
        now = A[now];
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 4060
#!/usr/bin/env python
# coding: utf-8


def main():
    lc = list(map(int, list(input())))
    bc = lc[0]
    ret = 0
    for c in lc[1:]:
        if c == bc:
            bc = 1 - c
            ret += 1
        else:
            bc = c
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
#define pb push_back
#define fr(i,n) for(int i=0;i<n;i++)
#define Fr(i,n) for(int i=0;i++<n;)
#define ifr(i,n) for(int i=n-1;i>=0;i--)
#define iFr(i,n) for(int i=n;i>0;i--)

int main(){
  string s;
  int w;
  cin>>s>>w;
  fr(i,1+(s.length()-1)/w) cout<<s[w*i];
  cout<<endl;
}

Measured memory_bytes: 256
def main():
    S = list(input())
    N = len(S)

    kaibun_check(S)

    S1 = S[0:(N-1)//2]
    kaibun_check(S1)

    S2 = S[(N+3)//2:-1]
    kaibun_check(S2)

    print('Yes')


def kaibun_check(L):
    L_ = list(L.__reversed__())
    for s, s_ in zip(L, L_):
        if s != s_:
            print('No')
            exit()


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    ll n, a, b;
    cin >> n >> a >> b;
    if ( a > b ) {
        cout << 0 << endl;
        return 0;
    }
    else if ( n == 1 && a != b ) {
        cout << 0 << endl;
        return 0;
    }
    cout << ( ( ( n - 1LL ) * b + a ) - ( b + ( n - 1LL ) * a ) ) + 1LL  << endl;
    return 0;
}


Measured memory_bytes: 256
# coding:utf-8

INF = float('inf')


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


S = input()
ans = 'AC'
if S[0] != 'A': ans = 'WA'

cnt = 0
for s in S[2:-1]:
    if s == 'C':
        cnt += 1
    else:
        if s.isupper():
            ans = 'WA'

if cnt != 1: ans = 'WA'
if S[-1].isupper(): ans = 'WA'
if S[1].isupper(): ans = 'WA'
print(ans)


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

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

	ll n, k; cin >> n >> k;
	k++;
	vl a(n), b(n);	
	FOR(i,0,n) cin >> a[i] >> b[i];

	ll res = 0;
	FOR(i,0,31) {
		ll cur = 0;
		FOR(j,0,n) {
			ll x = a[j];
			ll hix = x >> i, hik = k >> i;
			if ((hix & hik) == hix && !(hix & 1) && (hik & 1)) cur += b[j];
		}
		res = max(res,cur);
	}
	cout << res << endl;


}



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

#define ul unsigned long long
#define ll long long

int main()
{
  size_t na,nb,m;
  cin>>na>>nb>>m;
  ll a[100000],b[100000],mina=999999,minb=999999;

  for (size_t i = 0; i < na; i++)
  {
    cin >> a[i];
    mina=min(mina,a[i]);
  }
  for (size_t i = 0; i < nb; i++)
  {
    cin >> b[i];
    minb = min(minb, b[i]);
  }

  ll ans=mina+minb;
  ll x,y,c,cc;

  for (size_t i = 0; i < m; i++)
  {
    cin>>x>>y>>c;
    x--;y--;
    cc=a[x]+b[y]-c;
    ans=min(cc,ans);
  }

  cout<<ans<<endl;
  

  return 0;
}




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

using namespace std;

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;



int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,gw;
	cin >>n >>gw;

	vector<ll> w(n), v(n);
	rep(i,n) cin >> w[i] >>v[i];
	
	map<ll,ll> mp;
	mp[0]=0;
	ll ans =0;
	rep(i, n){
		map<ll, ll> np;
		for(auto x: mp){
			ll cr = x.first+w[i];
			if(cr <= gw){
				ll tg = np.count(cr)? np[cr]: 0;
				if(x.second+v[i] > tg) np[cr] = x.second+v[i];
			}
			np[x.first] = max(np[x.first], x.second);
		}
		swap(mp, np);
	}
	for(auto x: mp) if(x.first<=gw) ans=max(ans, x.second);
	
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std; 
using ll=long long;
#define endl "\n"
#define F(i,n) for(ll i=0;i<n;i++)
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repp(i,a,b) for(ll i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define ALL(v) v.begin(),v.end()
void solve(){
    
    string s;
    cin>>s;
    sort(ALL(s));
    ll chk=0;
    if(s[0]!=s[1])  chk=1;
    if(s[2]!=s[3])  chk=1;
    if(s[1]==s[2])  chk=1;
    if(chk)   cout<<"No";
    else      cout<<"Yes";
}
signed main(){
    fast;
     
    solve();
 
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
//#include <vector>
//#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <bitset>
//#include <math.h>
using namespace std ;
//using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

int main(){
	int n ; cin >> n ;
	int cnt = 0 ;
	int p = 0 ; int q = 0 ;
	cin >> p ;
	for(int i=1;i<n;i++){
		cin >> q ;
		if(p==q){
			cnt++ ;
			p = 0 ;
		}else{
			p = q ;
		}
	}
	cout << cnt << endl ;
}


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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> v;

    for (int i = 0; i < M; i++)
    {
        int a, b;
        cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end(), [](auto &left, auto &right) {
        return left.second < right.second;
    });

    int ans = 0;
    int now_bri = 0;
    for (int i = 0; i < v.size(); i++)
    {
        //cout << now_bri << endl;
        if (v[i].first >= now_bri)
        {
            now_bri = v[i].second;
            ans++;
        }
    }

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

Measured memory_bytes: 1528
# Bを制約を満たす最小操作後の配列とし、
# sb[k][n]をB[0]>0 (k=1), B[0]<0 (k=1) である場合のB[n-1]までの累積和とする、
# この符号は+/-交互になる必要があるので、
# (sb[k][n-1] > 0 => sb[k][n] < 0) => (sb[k][n-1] + A[n-1] - op < 0)
# (sb[k][n-1] < 0 => sb[k][n] > 0) => (sb[k][n-1] + A[n-1] + op > 0)
# とする必要があり、k,nによる状態から最小操作数opがきまる
# dp[k][n]は上記opの累積和


N = gets.to_i
A = gets.split.map(&:to_i)

sb = 2.times.map{ Array.new(N + 1, 0) }
dp = 2.times.map{ Array.new(N + 1, 0) }
(1 .. N).each do |n|
  a = A[n - 1]
  2.times do |k|
    if (k + n).odd?
      if sb[k][n-1] + a > 0
        dp[k][n] = dp[k][n-1]
        sb[k][n] = sb[k][n-1] + a
      else
        dp[k][n] = dp[k][n-1] + (sb[k][n-1] + a).abs + 1
        sb[k][n] = 1
      end
    else
      if sb[k][n-1] + a < 0
        dp[k][n] = dp[k][n-1]
        sb[k][n] = sb[k][n-1] + a
      else
        dp[k][n] = dp[k][n-1] + (sb[k][n-1] + a).abs + 1
        sb[k][n] = -1
      end
    end
  end
end
puts [dp[0][N], dp[1][N]].min



Measured memory_bytes: 11668
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
#define fi   first
#define se   second
using namespace std;
int n,l[200005],r[200005],f[200005];
pair<int,int> p[200005];
void add(int &x,int y){x+=y;if(x>=orz)x-=orz;};
void upd(int x,int y){while(x<=n+1)add(f[x],y),x+=(x&-x);}
int sum(int x){
    int ans=0;
    while(x)add(ans,f[x]),x-=(x&-x);
    return ans;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d%d",&p[i].se,&p[i].fi);
    sort(p+1,p+n+1);
    l[1]=p[1].se,r[n]=p[n].se;
    for(int i=2;i<=n;++i)l[i]=max(l[i-1],p[i].se);
    for(int i=n-1;i;--i)r[i]=min(r[i+1],p[i].se);
    for(int i=1;i<=n;++i){
        int o=1;
        for(int j=18;j>=0;--j){
            int O=o+(1<<j)-1;
            if(O<i&&l[O]<p[i].se)o=O+1;
        }
        p[i].fi=o;
        o=n;
        for(int j=18;j>=0;--j){
            int O=o-(1<<j)+1;
            if(O>i&&r[O]>p[i].se)o=O-1;
        }
        p[i].se=p[i].fi;
        p[i].fi=o;
    }
    sort(p+1,p+n+1);
    upd(1,1);
    for(int i=1;i<=n;++i){
        int k=sum(p[i].fi+1);
        add(k,orz-sum(p[i].se-1));
        upd(p[i].fi+1,k);
    }
    printf("%d\n",(sum(n+1)+orz-sum(n))%orz);
    //system("pause");
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <set>
#include <map>
#include <iomanip>
#include <cassert>
#include <functional>

using namespace std;

typedef pair<int, int> P;
#define FOR(i, a, b) for(int (i)=a;(i)<(b);++(i))
#define rep(i, n)  FOR(i,0,n)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define all(c) (c).begin(),(c).end()
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define Print(p) cout<<(p)<<endl
#define _1 first
#define _2 second
#define pb push_back
#define mod 1000000007
#define INF 1050000000

const int maxn = 1e5 + 10;
const int n = 50;

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

	ll k; cin >> k; //cout << k << endl; return 0;
	ll a[n];

	if (k == 0)
	{
		cout << 2 << endl;
		cout << "0 0" << endl;
		return 0;
	}

	ll sousuu = (k - 1) / 50 + 1;
	ll temae = sousuu * 50 - k;
	ll kizyun = 49 + sousuu;

	rep(i, temae)
	{
		a[i] = kizyun - 50 + temae - 1;
	}

	FOR(i, temae, 50)
	{
		a[i] = kizyun + temae;
	}

	cout << 50 << endl;

	rep(i, 50) cout << a[i] << " ";

	cout << endl;



	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef long long ll;
ll Max(ll p,ll q){return p>q?p:q;}
int main(){
	ll a,b,c,d;
  	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
  	printf("%lld\n",Max(Max(a*c,a*d),Max(b*c,b*d)));
  	return 0;
}


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

int main() {
    int D;
    cin >> D;
    if (D == 25) {
        cout << "Christmas" << endl;
    } else if (D == 24) {
        cout << "Christmas Eve" << endl;
    } else if (D == 23) {
        cout << "Christmas Eve Eve" << endl;
    } else {
        cout << "Christmas Eve Eve Eve" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n, k, p[1001], m, s = 0;
    cin >> n >> k;
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    for(int i = 0; i < n; i++)
    {
        for(int j = i + 1; j < n; j++)
        {
            if(p[i] > p[j])
                {
                    m = p[i];
                    p[i] = p[j];
                    p[j] = m;
                }
        }
    }
    for(int i = 0; i < k; i++)
    {
        s = s + p[i];
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>

using namespace std;

int digitSum(int n) {
    int sum = 0;
    while (n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {

    int N;
    cin >> N;
    int minV = 46;

    for (int a = 1; a < N; a++) {

        int b = N - a;

        minV = min(minV, digitSum(a) + digitSum(b));

    }

    cout << minV << "\n";

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <math.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)if (i % 2 == 0)cout << s[i];
	cout << endl;
	return 0;
}

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    ll A, B;
    cin >> N >> A >> B;
    vector<int> X(N);
    for(int i=0; i<N; i++)
    {
        cin >> X.at(i);
        X.at(i)--;
    }

    ll ans = 0;
    for(int i=1; i<N; i++)
    {
        ans += min((X[i] - X[i-1])*A, B);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3712
w,h,n = map(int,input().split())
min_x = min_y = 0
max_x = w
max_y = h
for _ in range(n):
    x, y, a = map(int,input().split())
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        max_x = min(max_x, x)
    elif a == 3:
        min_y = max(min_y, y)
    elif a == 4:
        max_y = min(max_y, y)
if max_x <= min_x or max_y <= min_y:
    print(0)
else:
    print((max_x-min_x)*(max_y-min_y))


Measured memory_bytes: 3064
#include <stdio.h>

int main() {
    int n;
    int t[10] = { 100, 111, 222, 333, 444, 555, 666, 777, 888, 999 };

    scanf("%d", &n);
    for (int i = 0; i < 9; i++) {
        if (t[i] <= n && n <= t[i+1]) {
            printf("%d\n", t[i+1]);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#define MAXN 3006
#define MOD 1000000007
using namespace std;
int n,m,ll,rr,r[MAXN],d[MAXN][MAXN],sum[MAXN];
char s[MAXN];
int main()
{
	scanf("%d%d",&n,&m);
	scanf("%s",s+1);
	for(int i=1;i<=n+1;i++)
	{
		sum[i]=sum[i-1];
		if(i<=n) sum[i]+=s[i]-'0';
		r[i]=i;
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&ll,&rr);
		r[ll]=max(r[ll],rr);
	}
	for(int i=1;i<=n;i++)
		r[i]=max(r[i],r[i-1]);
	d[1][sum[r[1]]]=1;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=n;j++)
		{
			if(!d[i][j]) continue;
			if(j) d[i+1][j-1+sum[r[i+1]]-sum[r[i]]]=(d[i+1][j-1+sum[r[i+1]]-sum[r[i]]]+d[i][j])%MOD;
			if(r[i]-(i-1)-j) d[i+1][j+sum[r[i+1]]-sum[r[i]]]=(d[i+1][j+sum[r[i+1]]-sum[r[i]]]+d[i][j])%MOD;
		}
	printf("%d",(d[n+1][0]+MOD)%MOD);
}

Measured memory_bytes: 33792
#include <bits/stdc++.h>
using namespace std;
 
int main() 
{
    int n;
    string s;
    int t;
    string x;
    cin>>n;
    int tt=0;
    int st=0;
    bool sleep=0;
    vector<string>v(n);
    vector<int>vs(n);
    for(int i=0; i<n; i++){
        cin>>v.at(i)>>t;
        vs.at(i)=t;
        tt += t;
    }
    cin>>x;
    for(int j=0; j<n; j++){
        if(v.at(j)==x){
            sleep = 1;
            for(int k=j+1; k<n; k++){
                st += vs.at(k);
            }
            break;
        }
    }
    cout<<st<<endl;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(int i=0; i<n; i++)
    {
        if(arr[i]%2==0 && (arr[i]%3!=0) && (arr[i]%5!=0))
        {
            cout<<"DENIED"<<endl;
            return 0;
        }

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


}


Measured memory_bytes: 3568
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


n,m,d = MI()
if d != 0:
    print((2*(m-1)*(n-d))/(n**2))
else:
    print(((m-1)*(n-d))/(n**2))


Measured memory_bytes: 61860
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  string s;
  cin>>s;
  deque<char> dq;
  for(char c:s) {
    dq.push_back(c);
  }
  bool rev = false;
  int q;
  cin>>q;
  for(auto&& i:irange(0,q)) {
    int t;
    cin>>t;
    if (t == 1) {
      rev = !rev;
    } else {
      int f;
      string c;
      cin>>f>>c;
      bool ff = f == 1;
      if (ff == rev) {
        dq.push_back(c[0]);
      } else {
        dq.push_front(c[0]);
      }
    }
  }
  if (rev) {
    boost::reverse(dq);
  }
  for(auto&& e:dq) {
    cout<<e;
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
char a[110][110];
int dp[110][110];
signed main() {
    int h, w;
    cin >> h>>w;

    rep(i,h+2) rep(j, w+2) a[i][j]='.';
    FOR(i,1,h+1) {
        string s;
        cin>>s;
        FOR(j,1,w+1) {
            a[i][j]= s[j-1];
        }
    }

    FOR(j,1,w+2) {
        dp[1][j]=dp[1][j-1]+((a[1][j]!=a[1][j-1])?1:0);        
        dp[j][1]=dp[j-1][1]+((a[j][1]!=a[j-1][1])?1:0);   
        // cout <<(a[1][j]!=a[1][j-1])<<" "<<j<<" "<<a[1][j]<<" "<<a[1][j-1]<<" "<<" "<<dp[1][j-1]<< dp[1][j] << endl;    
    }
    FOR(i,2,h+1) {
        FOR(j,2,w+1) {
            int ii = ((a[i-1][j]!=a[i][j])?1:0);
            int jj = ((a[i][j-1]!=a[i][j])?1:0);
            dp[i][j]=min(dp[i-1][j]+ii,dp[i][j-1]+jj);
        }
    }
    // rep(i,h+2) {
    //     rep(j,w+2) {
    //         cout << dp[i][j]<<flush;
    //     }
    //     cout << "" << endl;
    // }
    int ans = dp[h][w] + ((a[h][w+1]!=a[h][w])?1:0);
    cout << ans/2 << endl;

  return 0;
}



Measured memory_bytes: 3708
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define pb push_back
#define pf push_front
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define endl "\n"
const ll maxn = 2*(1e5 + 5);
vll adj[maxn];

int main()
{
    ll i, j, k, t, n, m, a;

    cin>>n;

    for ( i = 2; i <= n; i++)
    {
        cin>>a;
        adj[a].pb(i);
    }
    
    for ( i = 1; i <= n; i++)
    {
        if(adj[i].size()!=0)
        cout<<adj[i].size()<<endl;
        else
        cout<<0<<endl;
    }
    

 
    return 0;
}

Measured memory_bytes: 14536
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int64_t n=s.size(),ans=0;
  for(int64_t mask=0;mask<(1<<n-1);mask++){
    int64_t num=s[0]-'0';
    for(int64_t i=0;i<n-1;i++){
      if(mask&(1<<i)){
        ans+=num;
        num=0;
      }
      num=num*10+s[i+1]-'0';
    }
    ans+=num;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3504
import java.io.*
import java.lang.*


fun solve() {
    val X = rd.readInt()

    val ans = if (X>=30) "Yes" else "No"
    println(ans)
}


//val rd = debug.Reader("abc", "174", "a", "sample-1")
val rd = Reader()


fun main(args: Array<String>) {
    try {
        var exception: Throwable? = null
        val sth = Thread(null, SolveThread(), "solveThread", 128 * 1024 * 1024)
        sth.setUncaughtExceptionHandler { _, e -> exception = e }
        sth.start(); sth.join()
        if (exception != null) throw exception!!
    } catch (e: Exception) { throw e }
}
const val MOD = 1_000_000_007L; const val INF = Int.MAX_VALUE/2; const val LINF = Long.MAX_VALUE/2
data class IntPair(val first: Int, val second: Int)
val errPrintln: (Any) -> Unit = { msg -> System.err.println(msg) }
fun rAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("EAssert Error: $msg"); throw Error(msg) }
}
fun tAssert(exp: Boolean, lazyMsg: () -> String = {""}) {
    if (!exp) { val msg = lazyMsg(); errPrintln("TAssert Error: $msg"); Thread.sleep(3000) }
}
class SolveThread : Runnable {
    override fun run() { solve() }
}
class Reader {
    private val br = BufferedReader(InputStreamReader(System.`in`))
    val readString: () -> String = { br.readLine() }
    val readInt: () -> Int = { br.readLine().toInt() }
    val readLong: () -> Long = { br.readLine().toLong() }
    val readIntArray: () -> IntArray = { br.readLine().split(' ').map { it.toInt() }.toIntArray() }
    val readLongArray: () -> LongArray = { br.readLine().split(' ').map { it.toLong() }.toLongArray() }
    val readListInt: () -> List<Int> = { br.readLine().split(' ').map { it.toInt() } }
    val readListLong: () -> List<Long> = { br.readLine().split(' ').map { it.toLong() } }
}


Measured memory_bytes: 34588
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
	  Scanner sc = new Scanner(System.in);
	  int n=sc.nextInt(),count=0;
	  int[] a=new int[n];
	  for(int i=0;i<n;i++)a[i]=sc.nextInt();
	  for(int i=0;i<n;i+=2) {
		  if(a[i]%2!=0)count++;
	  }
	  System.out.println(count);
  }
}


Measured memory_bytes: 35844
#include <stdio.h>

int main()
{
  int m,n;
  int a,b,c;
  int temp;
  
  scanf("%d\n",&m);

  a=m/100;
  temp=m%100;
  b=temp/10;
  c=temp%10;
  
  n=c*100+b*10+a;
  
  if(n==m){
	printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  
 return 0; 
}

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

int main(){
    string s;
    cin>>s;
    int n=0;
    for(int i=0;i<3;i++){
        if(s.at(i)==s.at(i+1)){
            n=1;
            }
        }
    if(n==1){
        cout<<"Bad"<<endl;
        }else{
            cout<<"Good"<<endl;
            }
    }


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

int main(){
long long a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  if(w>v){
cout<<"NO"<<endl;
  }
 else if(abs(v*t-w*t)>=abs(a-b)){
cout<<"YES"<<endl;
  }else{
cout<<"NO"<<endl;
  }
     }


Measured memory_bytes: 3600
S = input()
N = len(S)

def check(string):
    if string==string[::-1]:
        return True
    else:
        return False

ans = 'No'

if check(S):
    if check(S[0:(N-1)//2]):
        if check(S[(N+3)//2-1:N]):
            ans = 'Yes'

print(ans)

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

#define endl '\n'

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s, t; cin >> s >> t;
    if (t.substr(0, s.size()) == s) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 3648