akhauriyash/Code-Regression huggingface dataset:
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(long long i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    int count = 0;
    int min = 3000000;
    rep(i, N){
        if(P[i] < min){
            count++;
            min = P[i];
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 1024
#include<iostream>
#include<utility>
#include<string>
#include<vector>

using namespace std;
#define DBG(x) cerr << #x << ": " << x << endl
// http://genkisugimoto.com/jp/blog/procon/2015/04/15/print-debug-technique-in-cpp.html
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}

template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { s << v[i]; if (i < v.size() - 1) s << "\t"; } return s; }

typedef long long ll;

// 
int main(){
	string s;
	cin >> s;
	int k;
	cin >> k;
	int l = s.length();
	vector<int> a(l);
	for(int i=0; i<l; i++){
		a[i] = s[i]-'a';
	}
	for(int i=0; i<l; i++){
		if(a[i] == 0) continue; // 最初からaなら処理しないほうがよい
		if(26-a[i] <= k){
			int d = 26-a[i];
			k-=d;
			//k -= 26-a[i];
			a[i] = 0;
			DBG(d);
			DBG(k);
		}
	}
	if(k>0){
		k%=26;
		a[l-1] = (a[l-1]+k)%26;
	}

	for(int i=0; i<s.length(); i++){
		cout << (char)(a[i]+97);
	}
	cout << endl;

	return 0;
}



Measured memory_bytes: 896
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 1000000;

typedef long long int ll;

using namespace std;

int memo[N];


int main(){
    int n;
    cin>>n;
    string val;cin>>val;
    int ans = 0;
    fore(i,0,10){
        fore(j,0,10){
            fore(k,0,10){
                int gen[3];
                gen[0] = i;gen[1] = j;gen[2] = k;
                int act = 0;
                fore(pos,0,SZ(val)){
                    if(val[pos]-48 == gen[act]){
                        act++;
                    }
                    if(act == 3)break;
                }
                if(act == 3){
                    ans++;
                }
            }
        }
    }
    cout<<ans;
	return 0;
}



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



int main(void)
{

	//入力変数
	int n = 0;

	//DP変数
	long long int h_dp[31] = {0};

	h_dp[0] = 1;
	h_dp[1] = 1;
	h_dp[2] = 2;

	//DPを列挙
	for (int i = 3; i <= 30; i++)
	{
		h_dp[i] = h_dp[i - 1] + h_dp[i - 2] + h_dp[i - 3];
	}

	while (true)
	{
		cin >> n;
		if (n == 0)	{	return 0;	}

		//年数出力
		long long int year = 0;

		if (n <= 10)
		{
			year = 1;
		}
		else
		{
			//求めたDPを利用
			year = h_dp[n] / 3650;
			if (h_dp[n] % 3650 != 0)
			{
				year++;
			}
		}

		cout << year << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main{
	double p,e,t;
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int k = sc.nextInt();
			int l = sc.nextInt();
			int r = sc.nextInt();
			p = sc.nextDouble();
			e = sc.nextDouble();
			t = sc.nextDouble();
			double res = solve(k, l, r);
			System.out.printf("%.6f\n",res);
		}
	}

	private double solve(int k, double l, double r) {
		double h = (r + l) / 2;
		if(k == 0){
			if(t - e <= h && h <= t + e){
				return 1;
			}
			else{
				return 0;
			}
		}
		
		if((r < t - e && l < t - e) || (r > t + e && l > t + e)){
			return 0;
		}
		if(t - e <= l && r <= t + e){
			return 1;
		}
		
		if(h <= t){
			return (1-p) * solve(k-1, h, r) + p * solve(k-1, l, h);
		}
		else{
			return (1-p) * solve(k-1, l, h) + p * solve(k-1, h, r);
		}
	}

	private void debug(Object... o) {
		System.out.println("debug = " + Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().doit();
	}
}

Measured memory_bytes: 19156
nums = gets.split.map!(&:to_i)
i_ary = o_ary = []
nums[0].times{i_ary << gets.split('')}

nums[0].times{|i|
  nums[1].times{|j|
    if i_ary[i][j] == "#"
      o_ary[i][j] = "#"
      next
    end
    m = 0
    if i == 0
      if j== 0
        m += 1 if i_ary[i][j+1] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j+1] == "#"
      else
        m += 1 if i_ary[i][j-1] == "#"
        m += 1 if i_ary[i][j+1] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j-1] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j+1] == "#"
      end
    else  # i != 0
      if j == 0
        m += 1 if i_ary[i-1][j] == "#"
        m += 1 if i_ary[i-1][j+1] == "#"
        m += 1 if i_ary[i][j+1] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j+1] == "#"
      else
        m += 1 if i_ary[i-1][j-1] == "#"
        m += 1 if i_ary[i-1][j] == "#"
        m += 1 if i_ary[i-1][j+1] == "#"
        m += 1 if i_ary[i][j-1] == "#"
        m += 1 if i_ary[i][j+1] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j-1] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j] == "#"
        m += 1 if i_ary[i+1] && i_ary[i+1][j+1] == "#"
      end
    end
    o_ary[i][j] = m
  }
}

o_ary.each{|o| puts o.join}

Measured memory_bytes: 2172
def by_k(k):
    return k*(N+2) - k*(k+1) + 1

M = 10**9+7
N, K = [int(x) for x in input().split()]
ans = 0
for k in range(K, N+2):
    ans += by_k(k)
    while ans > M:
        ans -= M
print(ans)

Measured memory_bytes: 9188
#include <iostream>

int main() {
	char a[4];
	std::cin >> a[0] >> a[1] >> a[2] >> a[3];

	if (a[0] == a[1] && a[1] == a[2]) {
		std::cout << "Yes" << std::endl;
	} else if (a[1] == a[2] && a[2] == a[3]) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
}


Measured memory_bytes: 760
use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let d: i64 = it.next().unwrap().parse().unwrap();
    let a: i64 = it.next().unwrap().parse().unwrap();
    let mut p = vec![(0i64, 0i64); n];
    for p in p.iter_mut() {
        p.0 = it.next().unwrap().parse().unwrap();
        p.1 = it.next().unwrap().parse().unwrap();
    }
    p.sort();
    let mut deq = std::collections::VecDeque::<(i64, i64)>::new();
    let mut ans = 0;
    let mut sum = 0;
    for (x, h) in p.into_iter() {
        while let Some(&(y, s)) = deq.front() {
            if y >= x {
                break;
            }
            sum -= s;
            deq.pop_front();
        }
        if sum >= h {
            continue;
        }
        let c = (h - sum + a - 1) / a;
        ans += c;
        sum += c * a;
        deq.push_back((x + 2 * d, c * a));
    }
    println!("{}", ans);
}

fn main() {
    run();
}


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

vector<vector<ll> > d[111111]; 
string s[111111];

void Main() {
  ll n,m,t,sx,sy,tx,ty;
  cin >> n >> m >> t >> sx >> sy >> tx >> ty;
  sx--,sy--,tx--,ty--;
  rep(i,n) R s[i];
  rep(i,n) {
    d[i].resize(m);
    rep(j,m) {
      d[i][j].resize(4);
      rep(k,4) d[i][j][k]=MAXL;
    }
  }
  priority_queue<PP,vector<PP>,greater<PP> > que;
  rep(i,4) {
    d[sx][sy][i]=0;
    que.push(PP(P(0,i),P(sx,sy)));
  }
  while(!que.empty()) {
    PP p=que.top();que.pop();
    ll xx=p.S.F,yy=p.S.S,kk=p.F.S,cc=p.F.F;
    if(d[xx][yy][kk]<cc) continue;
    rep(i,4) {
      ll x=xx+dx[i],y=yy+dy[i],c=cc;
      if(kk!=i) {
        ll e=(t-c%t)%t;
        c+=e;
      }
      c++;
      if(check(n,m,x,y)&&s[x][y]=='.'&&d[x][y][i]>c) {
        d[x][y][i]=c;
        que.push(PP(P(c,i),P(x,y)));
      }
    }
  }
  ll ans=MAX;
  rep(i,4) {
    ll z=d[tx][ty][i];
    ll e=ceil((double)z/t);
    ans=min(ans,e);
  }
  if(ans==MAX) ans=-1;
  pr(ans);
}

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


Measured memory_bytes: 89332
def main():
    s = input()
    n = len(s)
    ans = 0
    for i in range(n + 1):
        for j in range(i + 1, n + 1):
            x = int(s[i:j])
            p = 2 ** max(0, i - 1)
            q = 2 ** max(0, n - j - 1)
            ans += x * p * q

    print(ans)

if __name__ == '__main__':
    main()


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

#define pb push_back
#define fi first
#define SZ(x) (int((x).size()))
#define se second
#define ll long long
#define pq priority_queue
#define MP make_pair
#define pii pair<int,int>
#define mod 998244353
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i, a, b) for (int i=a; i<(b); i++)

const int maxn=2e5+10;
int n;
vector <int> edge[maxn];
vector <int> nxt[maxn];
int c[maxn],lst[maxn],sz[maxn],f[maxn];
ll ans[maxn];

void dfs(int u,int fa) {
	f[u]=fa;
	nxt[lst[c[u]]].pb(u);
	int tmp=lst[c[u]];
	sz[u]=1;
	rep(i,0,SZ(edge[u])) {
		int v=edge[u][i];
		if (v==fa) continue;
		lst[c[u]]=v;
		dfs(v,u);
		sz[u]+=sz[v];
	}
	lst[c[u]]=tmp;
	return;
} 

int main(){
    std::ios::sync_with_stdio(false);
    cin>>n;
    rep(i,1,n+1) cin>>c[i],lst[i]=1;
    rep(i,1,n) {
    	int u,v;
    	cin>>u>>v;
    	edge[u].pb(v);
    	edge[v].pb(u);
	}
	dfs(1,0);
	rep(i,1,n+1) ans[i]=sz[1];
	rep(i,0,SZ(nxt[1])) {
		int cur=nxt[1][i];
		ans[c[cur]]-=sz[cur];
	}
	rep(i,1,n+1) ans[i]=ans[i]+ans[i]*(ans[i]-1)/2;
	rep(i,2,n+1) {
		int tmp=sz[i];
		rep(j,0,SZ(nxt[i])) {
			int v=nxt[i][j];
			tmp-=sz[v];
		}
		ans[c[f[i]]]+=(ll)tmp+(ll)tmp*(ll)(tmp-1)/2ll; 
	}
	rep(i,1,n+1) cout<<(ll)n+(ll)n*(ll)(n-1)/2ll-ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 45696
#include<stdio.h>

#define MAX 8

int retu[MAX], gyou[MAX];
int dpos[2*MAX-1],dneg[2*MAX-1];

int X[MAX][MAX];

int i=0;
int j=0;
int jk;
int r;
int c;

void Initialize();
void PrintBoard();

void recursive(int i){
  int j;

  if(i == MAX){
    PrintBoard();
    return;
  }

  for(j = 0 ; j < MAX ;j++){

    if(gyou[j] == 1 || dpos[i + j] == 1 || dneg[i - j + MAX - 1] == 1) continue;


    retu[i] = j;
    gyou[j] = dpos[i + j] = dneg[i - j + MAX -1] = 1;


    recursive(i + 1);

    retu[i] = gyou[j] = dpos[i + j] = dneg[i - j + MAX - 1] = -1;
  }
}



int main(){



  Initialize();

  while(i<MAX){
    while(j<MAX){
      X[i][j] = -1;
      j++;
    }
    i++;
  }

  scanf("%d",&jk);
  i=0;
  while(i < jk){
    scanf("%d %d",&r,&c);
    X[r][c] = 1;
    i++;
  }

  recursive(0);

  return 0;
}

void Initialize(){
  int i=0;

 while(i < MAX){
    retu[i] = -1;
    gyou[i] = -1;
    i++;
  }
i=0;
  while(i < 2 * MAX - 1){
    dpos[i] = -1;
    dneg[i] = -1;
    i++;
  }
}

void PrintBoard(){
  int i=0, j;

  while(i < MAX){
    j=0;
    while(j < MAX){
      if(X[i][j] == 1){

	if(retu[i] != j) return;
      }
      j++;
    }
    i++;
  }
i=0;
  while(i < MAX ){
    j=0;
    while( j < MAX ){
      if(retu[i] == j) printf("Q");
      else printf(".");
      j++;
    }
    printf("\n");
    i++;
  }
}



Measured memory_bytes: 2084
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for (int i = 1; i < s.length(); i++) {
		if (s[i-1] == s[i]) {
			cout << "Bad" << '\n';
			return 0;
		}
	}
	cout << "Good" << '\n';
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define DEBUG_ARR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]<<" "; cerr<<endl;
#define DEBUG_STR(x, a, b) for(int i=a; i<=b; i++) cerr<<x[i]; cerr<<endl;
#define DEBUG_MAP(x, it) for(it = x.begin(); it != x.end(); it++) cerr<<(it->first)<<" : "<<(it->second)<<endl; cerr<<endl;


using namespace std;

typedef long long ll;
typedef unsigned long long llu;

int main() {
	FIO;
	ll n;
	cin>>n;
	vector<ll> arr(n);
	for(int i=0; i<n; i++) cin>>arr[i];
//	DEBUG_ARR(arr, 0, n-1)
	map<ll,ll> freq;
	for(int i=0; i<n; i++){
		if(freq.find(arr[i]) != freq.end()){
			freq[arr[i]]++;
		} else {
			freq[arr[i]] = 1;
		}
	}
	map<ll,ll>::iterator it;
	ll total = 0;
//	DEBUG_MAP(freq, it);
	for(it = freq.begin(); it != freq.end(); it++){
		ll num = it->second;
		if(num >= 2)
			total += (num*(num-1))/2;
	}
	for(int i=0; i<n; i++){
		ll cnt = freq[arr[i]];
		ll ans = total;
		if(cnt >= 2){
			ans -= ((cnt*(cnt-1))/2);
			cnt--;
			ans += ((cnt*(cnt-1))/2);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 12288
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <stack>
typedef long long ll;

using namespace std;

int main() {
    int n;
    cin >> n;
    
    vector<ll> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    
    vector<int> ans(n, 0);
    for(int i = 0; i < n; i++) {
        if(i % 2 == 0) {
            ans[0] += v[i];
        }
        else {
            ans[0] -= v[i];
        }
    }
    
    for(int i = 1; i < n; i++) {
        ans[i] = 2 * v[i - 1] - ans[i - 1];
    }
    
    for(int i = 0; i < n; i++) {
        if(i == n - 1) {
            cout << ans[i] << endl;
        }
        else {
            cout << ans[i] << " ";
        }
    }
    
    return 0;
}



Measured memory_bytes: 2432
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
const int MX = 100001; //check the limits, dummy

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

    ll h, n; cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> b[i];
    }

    vector<ll> dp(h + 1, inf + 1);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j <= h; j++)
            dp[j] = min(dp[j], dp[max(0, j - a[i])] + b[i]);

    cout << dp[h] << endl;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define RFOR(i,a,b) for(int i = (int)(b-1);i>=(int)(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
 
signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(20);

  int n;
  cin >> n;
  vector<string> s(n);
  REP(i,n) cin >> s[i];
  
  map<string, bool> m;

  int sub = 0;
  REP(i, n){
    if(m[s[i]]){
      sub++;
    }
    else{
      m[s[i]] = true;
    }
  }

  cout << n - sub << endl;

  return 0;
}

Measured memory_bytes: 25028
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n = 0;
    string s;
    cin >> s;
    for(int i=0; i<4; i++){
        if(s[i] == '+'){
            n++;
        }else{
            n--;
        }
    }
    cout << n << endl;
    
    return 0;
}


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

int main(){
    int n, 
    s;
    cin >> n >> s;

    vector<int> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i];

    if(accumulate(a.begin(), a.end(), 0) < s){
        cout << 0 << endl;
        return 0;
    }

    int l = 0, r = 0, sum = 0, ans = n;
    while(l < n){
        while(r < n && sum < s){
            sum += a[r];
            r++;
        }
        if(sum < s)  break;
        ans = min(ans, r-l);
        sum -= a[l];
        l++;
    }

    cout << ans << endl;

    return 0;
}


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

#define ll long long
#define inf 1e18


int main()
{
  ll n,k;
  cin>>n>>k;
  ll a[n+1];
  ll c[n+1];
  for(ll i=1;i<=n;i++)
      cin>>a[i];
  for(ll i=1;i<=n;i++)
      cin>>c[i];

  ll ans=-inf;
  for(ll i=1;i<=n;i++)
  {
    vector<ll>v;
    v.push_back(0);
    ll sum=c[i];
    ll j=a[i];
    ll len=1;    
    while(j!=i)
    {
      
      sum+=c[j];
      j=a[j];
      len++; 
    }
    ll path=0;
    ll cnt=0;

    while(1)
    {
      cnt++;
      if(cnt>k)
        break;
      path+=c[j];
      j=a[j];
      ll score=path+(max(0ll,sum)*((k-cnt)/len));
      ans=max(ans,score);
      if(i==j)
        break;
    }


    
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>

using namespace std;
int main(){
  int n,x;
  cin >>n>>x;
  int a[n];
  for(int i=0;i<n;i++)
  cin >>a[i];

  sort(a,a+n);
  int sum=0;
  for(int i=0;i<n;i++){
    if(sum+a[i]>x) {cout <<i<<endl; return 0;}
    else if(sum +a[i]==x){cout <<i+1<<endl; return 0;}
    else sum+=a[i];
  }
  cout<<n-1<<endl;
}


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


int main(){
    long long A,B;
    cin >> A >> B;

    long long answer = 0;

    for(int i=1; i<=B; i++){
        if(A*i%B == 0){
            answer = A*i;
            break;
        }
    }

    cout << answer;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
typedef long long ll;

ll ans[55];
int main()
{
	ll K;scanf("%lld",&K);
	int n=50;
	printf("%d\n",n);
	for(int i=1;i<=n;i++)
		ans[i]=n-1+K/n;
	K%=n;
	for(int i=1;i<=K;i++)
		ans[i]+=n-(K-1);
	for(int i=K+1;i<=n;i++)
		ans[i]-=K;
	for(int i=1;i<=n;i++)
		printf("%lld%c",ans[i],i<n?' ':'\n');
}

Measured memory_bytes: 128
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>
#include<memory.h> 
#include<sstream>
#include<time.h>
using namespace std;
const long long BIGER=1000000000000000;
const int BIG=1000000000;
long long check(long long n)
{
	for(long long i=2;i*i<=n;i++)
	{
		if(n%i==0)return false;
	}
	return true;
}
long long ypa(long long a,long long b)
{
	long long s=0;
	long long t=a;
	while(t!=0)
	{
		t/=b;
		s+=t;
	}
	return s;
}
int main()
{
	long long n;
	cin>>n;
	long long s=1;
	for(long long i=2;i<=n;i++)
	{
		if(check(i))s=s*(ypa(n,i)+1)%1000000007;
	}
	cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int a, b;
	while(cin >> a >> b) {
		int aa = min(a / 0.08, b / 0.1);
		int bb = max(a / 0.08, b / 0.1);
		while(aa <= bb + 1) {
			if((int)(aa * 0.08) == a && (int)(aa * 0.1) == b) {
				cout << aa << endl;
				return 0;
			}
			aa++;
		}
		cout << -1 << endl;
	}
	return 0;
}	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;

    const int NMAX = 50;
    int A[NMAX], B[NMAX];

    for (int i=0; i < M; ++i) cin >> A[i] >> B[i];
    int road[NMAX];
    for (int i=0; i < N; ++i) {
        road[i] = 0;
    }
    for (int i=0; i < M; ++i){
        road[A[i] - 1] += 1;
        road[B[i] - 1] += 1;
    }
    for(int i = 0; i < N; ++i) cout << road[i] << endl;
}

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

public class Main {

	/**
	 * AOJ 0006 Reverse Sequence
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));
		StringBuilder builder = new StringBuilder(bufferedReader.readLine());
		System.out.println(builder.reverse());
	}
}

Measured memory_bytes: 16844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=1500003,INF=1<<30;

int main(){
  int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
  cout<<min({a,b,c})+min(d,e)-50<<endl;
}



Measured memory_bytes: 3100
use proconio::input;

fn main() {
    input! {
        x: u128,
    }

    let mut balance: u128 = 100;
    let mut year_count = 0;

    loop {
        if balance >= x {
            break;
        }
        balance += (balance / 100) as u128;
        year_count += 1;
    }

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


Measured memory_bytes: 2148
#include<iostream>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>


typedef long long ll;
#define REP(i,n) for(long long int (i)=0;(i) < (n);(i)++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;

int main(){
    int n;
    cin >> n;
    string s = "ai1333";
    REP(i,n/100) s +=  "3";
    cout << s << endl;


  return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
#define ll long long
#define UP(a,b,i) for(int i=(a);i<=(b);i++)
#define DOWN(a,b,i) for(int i=(a);i>=(b);i--)
#define rep(a,b,i) UP(a,b-1,i)
int ma=0x80000000;
int mi=0x7fffffff;
const ll zfc=0xffffffff;
const ll mod=1e9+7;
using namespace std;
inline void input(ll &x)
{
    x=0;
    int f=1;
    char ch=getchar();
    while(!isdigit(ch))
	{
		if(ch=='-')f=-f;
		ch=getchar();
	}
    while(isdigit(ch))
	{
		x=x*10+(ch-'0');
		ch=getchar();
	}
    x*=f;
}
inline void output(ll x)
{
	if(x<0)
    {
        x=-x;
        putchar('-');
    }
    if(x/10>0)output(x/10);
    putchar(x%10+'0');
}
#define I(n) cin>>(n);
#define O(n) cout<<(n);
#define Enter() cout<<endl;
ll a[10005];
int main()
{
	UP(1,3,i)
	input(a[i]);
	sort(a+1,a+4);
	if(a[1]+a[2]==a[3])cout<<"Yes";else cout<<"No";
	Enter();
	return 0;
}

Measured memory_bytes: 256
package main
import (
  "fmt"
  "math"
       )
func main(){
  var N float64
  fmt.Scanf("%f",&N)
 
  for i:= N;0<i;i--{
    for a:= 2.0;a<=i;a++{
      for j :=2.0;j<i;j++{
        if math.Pow(a,j) > N {break}
        if i == math.Pow(a,j){
        fmt.Println(i)
        return
      }
      }
    }
  }
  fmt.Println(1)
  return
}

Measured memory_bytes: 512
N = int(input())
src = list(map(int,input().split()))
cnt = [0]*(N+1)
ans = 1
mod = 10**9+7
for i in src:
    if i == 0:
        ans *= 3-cnt[0]
        cnt[0] += 1
    else:
        if cnt[i] == 0:
            ans *= cnt[i-1]
            cnt[i] += 1
        else:
            ans *= cnt[i-1] -cnt[i]
            cnt[i] += 1
    ans %= mod
print(ans)

Measured memory_bytes: 53428
n, x = map(int, input().split())

layers, putties = [1], [1]
for i in range(n):
        layers.append(layers[-1] * 2 + 3)
        putties.append(putties[-1] * 2 + 1)

def count_putties(N, X):
        if N == 0:
                return 1 if X > 0 else 0
        elif X <= layers[N-1] + 1:
                return count_putties(N-1, X-1)
        else:
                l = putties[N-1] + 1
                return l + count_putties(N-1, X-(layers[N-1] + 2))

print(count_putties(n, x))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll a,b;
	scanf("%*d%lld%lld",&a,&b);
	puts((a-b)%2?"Borys":"Alice");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long	ll;
typedef pair< int, ll > pii;
const int N = 302;
int father[N][N];
vector< pii > adj[N];
pair< ll, ll > dis[N][N];
const ll inf = ll(1e15);
priority_queue< pair< pair< ll, ll > , pair< int, int > > > pq;
int n, m;
ll l;
ll ar[N][N];
 
void dijkstra(int u){
	pq.push({{0LL, 0LL}, {u, 0}});
 
	for(int i = 1 ; i <= n ; i++){
		for(int j = 0 ; j <= n + 1 ; j++){
			dis[u][i] = {inf, inf};
		}
	}
 
	dis[u][u] = {0LL, 0LL};
 
	while(!pq.empty()){
		pii v = pq.top().second;
		auto d = pq.top().first;
		// printf("%d, %d\n", u, v);
		pq.pop();

		d.first *= -1;
		d.second *= -1;
 
		if(d > dis[u][v.first]){
			continue;
		}
 
		for(auto e: adj[v.first]){
			ll w = e.second;
			int t = e.first;
 
			if(w <= l){
				if(w + dis[u][v.first].second <= l && dis[u][t] > make_pair(v.second, w + dis[u][v.first].second)){
					dis[u][t] = {v.second, w + dis[u][v.first].second};
					pq.push({{-v.second, -dis[u][t].second}, {t, v.second}});
				}else if(dis[u][t] > make_pair(v.second + 1, w)){
					dis[u][t] = {v.second + 1, w};
					pq.push({{-v.second - 1, -w}, {t, v.second + 1}});
				}
			}
		}
	}
}
 
int main(){
	memset(father, -1, sizeof father);
 
	scanf("%d %d %lld", &n, &m, &l);
 
	for(int i = 1 ; i <= m ; i++){
		int ai, bi;
		ll ci;
 
		scanf("%d %d %lld", &ai, &bi, &ci);
 
		adj[ai].push_back({bi, ci});
		adj[bi].push_back({ai, ci});
	}
 
	for(int i = 1 ; i <= n ; i++){
		dijkstra(i);
	}
 
	int q;
 
	scanf("%d", &q);
 
	while(q--){
		int si, ti;
 
		scanf("%d %d", &si, &ti);
 		
 		int r = -1;

		if(dis[si][ti].first < inf){
			printf("%lld\n", dis[si][ti].first);
		}else{
			printf("-1\n");
		}
	}
 
	return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	auto f = [](long long x) { return x * (x + 1) / 2; };
	long long n;
	std::cin >> n;
	long long ans = 0;
	while(f(ans) < n) ans++;
	std::cout << ans << '\n';
}

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

long long GCD(long long A, long long B)
{
  long long a = A, b = B;
  while (a * b != 0  &&  a != 1  &&  b != 1)
  {
    if (a < b) b %= a;
    else a %= b;
  }
  if (a * b == 0) return max(a, b);
  else return 1;
}

long long LCM(long long A, long long B)
{
  return min(A, B) / GCD(A, B) * max(A, B);
}

int main()
{
  int N;
  cin >> N;
  vector<long long> T(N);
  for (int i = 0; i < N; i++) cin >> T.at(i);
  
  long long ans = T.at(0);
  for (int i = 1; i < N; i++)
  {
    ans = LCM(ans, T.at(i));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 200005
#define INF 1000000000000000000LL
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll n,m,a[MAXN],l[MAXN],r[MAXN],dp[MAXN];
vector<P> eve[MAXN];
struct SegTree
{
    ll lazy[4*MAXN],maxi[4*MAXN];
    void pushup(ll k)
    {
        maxi[k]=max(maxi[k*2],maxi[k*2+1]);
    }
    void pushdown(ll k)
    { 
        if(!lazy[k]) return;
        maxi[k*2]+=lazy[k];lazy[k*2]+=lazy[k];
        maxi[k*2+1]+=lazy[k];lazy[k*2+1]+=lazy[k];
        lazy[k]=0;
    }
    void update(ll k,ll l,ll r,ll x,ll y,ll p)
    {
        if(x>r||l>y) return;
        if(l>=x&&r<=y)
        {
            lazy[k]+=p;maxi[k]+=p;
            return;
        }
        pushdown(k);
        ll mid=(l+r)/2;
        update(k*2,l,mid,x,y,p);update(k*2+1,mid+1,r,x,y,p);
        pushup(k);
    }
    ll query(ll k,ll l,ll r,ll x,ll y)
    {
        if(x>r||l>y) return -INF;
        if(l>=x&&r<=y) return maxi[k];
        pushdown(k);
        ll mid=(l+r)/2;
        return max(query(k*2,l,mid,x,y),query(k*2+1,mid+1,r,x,y));
    }
}seg;
int main()
{
    scanf("%lld%lld",&n,&m);
    for(ll i=1;i<=m;i++) 
    {
        scanf("%lld%lld%lld",&l[i],&r[i],&a[i]);
        eve[l[i]].push_back(P(l[i]-1,a[i]));
        eve[r[i]+1].push_back(P(l[i]-1,-a[i]));
    }
    ll ans=0;
    for(ll i=1;i<=n;i++)
    {
        for(auto v:eve[i]) seg.update(1,0,n,0,v.F,v.S);
        dp[i]=seg.query(1,0,n,0,i-1);
        seg.update(1,0,n,i,i,dp[i]);
        ans=max(ans,dp[i]);
    }
    printf("%lld\n",ans);
    return 0;
}



Measured memory_bytes: 30720
#include <iostream>
#include <vector>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
typedef long long ll;

int main(void){
    int n;
    char p[100010];
    cin >> n;
    for (int i = 0; i < n; i++) cin >> p[i];
    
    for (int i = 1; i < n; i++) {
        if (p[i - 1] == 'F') {
            if (p[i] =='F') p[i] = 'T';
        }
    }
    
    cout << char(p[n - 1]) << endl;
}



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

int main() {
  int i,j,size,H,W;
  cin >> H >> W; 
  string pixel;
  

  for(i=0; i < (H+2) ; i++){
    if((i>0)&&(i<H+1)){
      cin >> pixel;
    }
    for(j=0; j < (W+2) ; j++){
      if((i==0)||(i==H+1)){
        cout << "#";
      }else if((j==0)||(j==W+1)){
        cout << "#";
      }else{
        cout << pixel.at(j-1);
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int a=sc.nextInt();
		int b=sc.nextInt();
		String s=sc.next();
		int arr[]=new int[a+1];
		arr[1]=0;
		for(int i=1;i<a;i++){
		if(s.charAt(i-1)=='A'&&s.charAt(i)=='C')
			arr[i+1]=1;
		}
		for(int i=1;i<=a;i++)
			arr[i]=arr[i-1]+arr[i];
		for(int i=0;i<b;i++){
			int sum=0;
			int m=sc.nextInt();
			int n=sc.nextInt();
			sum=arr[n]-arr[m];
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 63756
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

    ll n;
    cin >> n;
    vll a(n);
    REP(i, n) cin >> a[i];
    vll s(n + 1, 0);
    REP(i, n) s[i + 1] = s[i] + a[i];
    map<ll, ll> mp;
    REP(i, n + 1) mp[s[i]]++;
    ll ans = 0;
    for(auto i = mp.begin(); i != mp.end(); i++){
        ll res = i->second;
        ans += (res * (res - 1)) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
 
  if (a % 2 == 1 && b % 2 == 1) {
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 3608
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(10)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
 
int calcScore(vector<int> &plan, vector<int> &c, vector<vector<int>> &s) {
	int D = 365;
	int score = 0;
	vector<int> last(26, -1);
	for (int i = 0; i < D; i++) {
		score += s[i][plan[i]];
		last[plan[i]] = i;
		for (int j = 0; j < 26; j++) {
			score -= c[j] * (i - last[j]);
		}
	}
	return score;
}
 
int main() {
	int D;
	cin >> D;
	vector<int> c(26);
	for (int i = 0; i < 26; i++)cin >> c[i];
	vector<vector<int>> s(365,vector<int>(26,0));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++)cin >> s[i][j];
	}
	
	vector<int> plan(365, 0);
	for (int i = 0; i < 365; i++) {
		int mi = 0, m = -1;
		for (int j = 0; j < 26; j++) {
			if (m < s[i][j]) {
				mi = j;
				m = s[i][j];
			}
			plan[i] = j;
		}
	}
	int sc = calcScore(plan, c, s);
 
	for (int n = 0; n < 300000; n++) {
		if (rand() % 10 < 3) {
			int i = rand() % 365, j = rand() % 26, old = plan[i];
			plan[i] = j;
			int nsc = calcScore(plan, c, s);
			if (nsc > sc) {
				sc = nsc;
			}
			else {
				plan[i] = old;
			}
		}
		else {
			int k = rand() % 5;
			int i = rand() % (365 - k), j = i + k;
			swap(plan[i], plan[j]);
			int nsc = calcScore(plan, c, s);
			if (nsc > sc) {
				sc = nsc;
			}
			else {
				swap(plan[i], plan[j]);
			}
		}
	}
 
	for (int i = 0; i < 365; i++) {
		cout << plan[i] + 1 << endl;
	}
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; ll W; cin >> N >> W;
  vector<ll> w(N, 0); vector<ll> v(N, 0);
  REP(i, N){
    cin >> w[i] >> v[i];
  }
  ll INF = 1e18;
  vector<vector<ll> > dp(N+1, vector<ll>(1e5+1, INF));
  dp[0][0] = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= 1e5; j++){
      chmin(dp[i+1][j], dp[i][j]);
      if(dp[i][j] + w[i] <= W){
        chmin(dp[i+1][j+v[i]], dp[i][j] + w[i]);
      }
    }
  }
  ll ans = 0;
  for(int j = 1e5; j > 0; j--){
    if(dp[N][j] <= W){
      ans = j;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80256
import java.util.Scanner;

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

    	if(a < b){
    		System.out.println("a < b");
    	}else if(a > b){
    		System.out.println("a > b");
    	}else{
    		System.out.println("a == b");
    	}

    }
}

Measured memory_bytes: 26288
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] A = new long[N+1];
		Arrays.setAll(A, i -> sc.nextLong());
		long[] S = new long[N+1];
		S[0] = A[N];
		for(int i = 1; i <= N; i++)
			S[i] = S[i-1] + A[N-i];
		long ans = 1;
		long[] dp = new long[N+1];
		dp[0] = 1;
		for(int i = 0; i < N; i++) {
			dp[i+1] = Math.min((dp[i]-A[i])*2, S[N-i-1]);
			ans += dp[i+1];
		}	
		for(int i = 0; i <= N; i++)
			if(dp[i] < A[i]) {
				System.out.println(-1);
				return;
			}
		System.out.println(ans);
	}

}

Measured memory_bytes: 60192
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    char S;
    bool yellow_flag = false;
    
    for(int i=0;i<N;i++){
        cin >> S;
        if(S == 'Y'){
            yellow_flag = true;
            break;
        }
    }
    
    if(yellow_flag == true){
        cout << "Four" << endl;
    }
    else{
        cout << "Three" << endl;
    }
}

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

#define all(x) (x).begin(),(x).end()
#define init() \
  ios::sync_with_stdio(false); \
  cin.tie(0)

using namespace std;

using ll = long long;
using ull = unsigned long long;

template<typename M, typename N>
constexpr common_type_t<M, N> gcd(M a, N b) {
  return a == 0 ? b
    : b == 0 ? a
    : gcd(b, a % b);
}

template <typename M, typename N>
constexpr common_type_t<M, N> lcm(M a, N b) {
  return a * b / gcd(a, b);
}

int main() {
  init();

  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  
  int min = 9999999;
  for(int k:a){
    int r = 0;
    while(k != 0 && (k & 1) == 0){
      k >>= 1;
      if (r == min){
        break;
      }
      r++;
    }
    min = r;
    if(min==0){break;}
  }
  cout << min << '\n';

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,i,now=0,ans=0;
	string s;
	cin>>n>>s;
	for(i=0;i<n;i++){
		if(s[i]=='I'){
			now++;
			ans=max(ans,now);
		}
		else now--;
	}
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;


double Abs(double t,double a,double h){
    return fabs(a-(t-h*0.006));
}


int main(){
    double mi=E;
    ll I=-1;
    ll n;
    double t,a;
    cin>>n>>t>>a;
    for(int i=0;i<n;i++){
        double h;
        cin>>h;
        if(mi>Abs(t,a,h)){
            mi=Abs(t,a,h);
            I=i;
        }
    }
    cout<<I+1<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 256
N, K = map(int, input().split())
mod = 10**9 + 7 
ans = 0 
for i in range(K, N + 2): 
        l = N - i + 1 
        ans += ((l + N) * (N - l + 1) // 2) - ((i - 1)*i // 2) + 1 
print(ans % mod)

Measured memory_bytes: 63376
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner sc = new Scanner (System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int ans=1;
		for(int i=0;i<n;i++) {
			if(ans<m)ans*=2;
			else ans+=m;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22740
#include <cstdio>
 
int main(){
int a,b;
while(true){
scanf("%d %d",&a,&b);
if(a==0) break;
for(int i=0;i<a;i++){
for(int j=0;j<b;j++){
 
if((i!=0)&&(j!=0)&&(i!=a-1)&&(j!=b-1))printf(".");
else printf("#");
 
}
printf("\n");
}
printf("\n");
}
return 0;
}

Measured memory_bytes: 2588
import sys

def solve(n, s):
    if n % 2 == 1:
        print("No")
        return

    # print(s[0:n//2])
    # print(s[n//2:])
    if s[0:n//2] == s[n//2:]:
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    n = int(sys.stdin.readline().strip())
    s = sys.stdin.readline().strip()
    solve(n, s)

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

using namespace std;
using ll = long long int;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define FOR(i, a, b) for (ll i = (a), i < (N): i++)
#define all(A) (A).begin(), (A).end()

int main(){
    int A, B;
    cin >> A >> B;
    rep(i, 2000) {
        if (i * 8 / 100 == A and i * 10 / 100 == B) {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;

    return 0;
}


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

int main() {
  int a , b , c, d;
  cin >> a >> b >> c >> d;
  
  if( a+b > c+d ){
    cout << "Left" << endl;
  }
  else if( a+b < c+d ){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }
}

Measured memory_bytes: 256
from math import gcd
k = int(input())
sum = 0
for i in range(1, k + 1):
    for j in range(1, k + 1):
        gcd_ij = gcd(i, j)
        for k in range(1, k + 1):
            sum += gcd(gcd_ij, k)
print(sum)

Measured memory_bytes: 9020
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
int n;
vector<long long> wmemo, bmemo;
vector<vector<int>> p;
long long P = 1000000007;

long long dfs(int i, bool b, int from) {
  if (b && bmemo[i] >= 0)
    return bmemo[i];
  if (!b && wmemo[i] >= 0)
    return wmemo[i];
  if (b) {
    long long ret = 1;
    for (auto &j : p[i]) {
      if (from == j)
        continue;
      ret *= dfs(j, false, i);
      ret %= P;
    }
    return bmemo[i] = ret;
  } else {
    long long ret = 1;
    for (auto &j : p[i]) {
      if (from == j)
        continue;
      ret *= (dfs(j, true, i) + dfs(j, false, i)) % P;
      ret %= P;
    }
    return wmemo[i] = ret;
  }
}

int main() {
  cin >> n;
  p.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    p[x].push_back(y);
    p[y].push_back(x);
  }
  wmemo.resize(n);
  bmemo.resize(n);
  for (int i = 0; i < n; i++)
    wmemo[i] = bmemo[i] = -1;
  cout << (dfs(0, 0, -1) + dfs(0, 1, -1)) % P << endl;
  return 0;
}


Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5100+10;
const ll inf = 1e9+7;
int main() {
    ios::sync_with_stdio(0);
    ll a,b,c;
    cin>>a>>b>>c;
    if(c>=b)
        cout<<floor((a*(b-1))/b)-a*floor((b-1)/b)<<endl;
    else
        cout<<floor((a*c)/b)-a*floor(c/b)<<endl;
}


Measured memory_bytes: 3804
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
// rep(i, 1, 5) --> {1,2,3,4}
// rep(i, 5, 1) --> {4,3,2,1}
// rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    ll h, w;
    cin >> h >> w;
    if (h==1 || w==1)
        return cout << 1, 0;
    ll x = h*w;
    cout << (x%2==0?x/2:x/2+1);
    return 0;
}

Measured memory_bytes: 256
K, T = map(int, input().split())
A = list(map(int, input().split()))

maxix = 0
maxv = -1

for aix in range(T):
    if A[aix] > maxv:
        maxv = A[aix]
        maxix = aix

total = 0
for aix in range(T):
    if aix == maxix:
        continue
    else:
        total += A[aix]

if maxv - 1 > total:
    print(maxv-total-1)
else:
    print(0)



Measured memory_bytes: 9100
n = int(input())
h = list(map(int, input().split()))
dist = [10**9] * n
dist[0] = 0
for i in range(0, n):
	if i + 1 < n:
		dist[i + 1] = min(dist[i + 1], dist[i] + abs(h[i + 1] - h[i]))
	if i + 2 < n:
		dist[i + 2] = min(dist[i + 2], dist[i] + abs(h[i + 2] - h[i]))
print(dist[n - 1])

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

using namespace std;


int main()
{
    int h1, m1, h2, m2, k;

    cin >> h1 >> m1 >> h2 >> m2 >> k;

    if(h2 < h1)
        h2 += 24;

    int mi = (h2 - h1) * 60 - m1 + m2;

    cout << mi - k << "\n";

    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;
int R, C, N, X1, Y1, X2, Y2;
bool TREE[1 << 19];
vector<pair<int, int>>v;
set<int>st;

bool f(int x, int y) {
	if (x == 0 || x == R || y == 0 || y == C)return true;
	else return false;
}
pair<int, int> ff(){
	int a, b;
	if (Y1 == 0) {
		a = X1;
	}
	else if(Y1 == C){
		a = R + C + R - X1;
	}
	else if (X1 == 0) {
		a = R + C + R + C - Y1;
	}
	else if (X1 == R) {
		a = R + Y1;
	}
	if (Y2 == 0) {
		b = X2;
	}
	else if(Y2 == C){
		b = R + C + R - X2;
	}
	else if (X2 == 0) {
		b = R + C + R + C - Y2;
	}
	else if (X2 == R) {
		b = R + Y2;
	}
	
	if (a > b)swap(a, b);
	return mkp(a, b);
}
int main() {
	cin >> R >> C >> N;
	for (int i = 0; i < N; ++i) {
		cin >> X1 >> Y1 >> X2 >> Y2;
		if (f(X1, Y1) && f(X2, Y2)) {
			v.push_back(ff());
		}
	}
	sort(v.begin(), v.end());
	st.insert(-1);
	for (int i = 0; i != v.size(); ++i) {
		auto it = st.insert(v[i].second).first;
		--it;
		if (*it > v[i].first) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}

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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;

     double  j,n,m,k=0,p=0;
     cin>>n>>m;
     int i,r,a;
     for(i=0;i<=1000;i++)
     {
          k=floor(i*(.08));
          p=floor (i*(0.1));

        if(m==p&&k==n)
        {
            cout<<i<<endl;
        return 0;
        }

     }
   cout<<"-1"<<endl;


 return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _re(n) _rep(i,n)
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep,_re)(__VA_ARGS__)
#define _rre(n) _rrep(i,n)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep,_rre)(__VA_ARGS__)
#define rbr(i,a) for(auto&& i:a)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
template<typename T>
inline constexpr T gcd (T a,T b) {if(a==b)return a;else return gcd(b,(a-1)%b+1);}
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,size_t size>
istream& operator >> (istream& is, array<T,size>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <typename T>
inline void out(T t){cout<<t<<'\n';}
inline void out(){cout<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}



int main(){
    LL(n,k);
    ll ans=(n/k)*(n/k)*(n/k);
    if((k&1)^1)ans+=((n+k/2)/k)*((n+k/2)/k)*((n+k/2)/k);
    out(ans);
}









Measured memory_bytes: 256