akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LL long long
#define INF 0x7FFFFFFF//or 0x3f3f3f3f ? -Wall
using namespace std;

template<class T> inline
void read(T& x) {
	int f = 1; x = 0;
	char ch = getchar();
	while (ch < '0' || ch > '9')   {if (ch == '-') f = -1; ch = getchar();}
	while (ch >= '0' && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}

/*============ Header Template ============*/

const int N = 524288 + 5;
const int mo = 924844033;
const int g = 5;

int n, len;
int sz[N], rev[N];
vector<int> v[N];
LL c[N], a[N], b[N], f[N], wn[N];

void dfs(int x, int p) {
	sz[x] = 1;
	for (int i = 0; i < (int)v[x].size(); i++) {
		int y = v[x][i];
		if (y == p) continue;
		dfs(y, x);
		sz[x] += sz[y];
		c[sz[y]]--;
		c[n - sz[y]]--;
	}
}

LL get_pow(LL a, LL b) {
	LL ans = 1; a %= mo;
	while (b) {
		if (b & 1) ans = ans * a % mo;
		a = a * a % mo;
		b >>= 1;
	}
	return ans % mo;
}

LL getinv(LL x) {return get_pow(x, mo - 2);}

void NTT(LL *a, int len, int d = 1) {
	for (int i = 0; i < len; i++) if (i < rev[i]) swap(a[i], a[rev[i]]);
	int id = 0;
	for (int m = 2; m <= len; m <<= 1) {
		id++;
		LL wm = get_pow(g, (d * (mo - 1) / m) + mo - 1);
		for (int i = 0; i < len; i += m) {
			LL w = 1;
			for (int j = i; j < i + m / 2; j++) {
				LL u = a[j], v = w * a[j + m / 2] % mo;
				a[j] = (u + v) % mo;
				a[j + m / 2] = (u - v) % mo;
				w = w * wm % mo;
			}
		}
	}
	if (d == -1) {LL inv = getinv(len); for (int i = 0; i < len; i++) a[i] = a[i] * inv % mo;}
}

void pre() {
	for (int i = 1; i < len; i++) rev[i] = (rev[i >> 1] >> 1) | (i & 1 ? (len >> 1) : 0);
}

int main() {
	read(n);
	for (int i = 1, x, y; i < n; i++) {
		read(x), read(y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	dfs(1, 0); c[n] = n; f[0] = 1;
	for (int i = 1; i <= n; i++) f[i] = f[i - 1] * i % mo;
	for (int i = 0; i <= n; i++) a[i] = c[i] * f[i] % mo;
	for (int i = 0; i <= n; i++) b[i] = getinv(f[i]);
	for (int i = 0; i <= n / 2; i++) swap(a[i], a[n - i]);
	for (len = 1; len < 2 * (n + 1); len <<= 1);
	pre(); NTT(a, len); NTT(b, len);
	for (int i = 0; i < len; i++) c[i] = a[i] * b[i] % mo;
	NTT(c, len, -1);
	for (int i = n - 1; i >= 0; i--) {
		LL ans = c[i];
		ans = ans * getinv(f[n - i]) % mo;
		printf("%lld\n", (ans + mo) % mo);
	}
	return 0;
}

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

using namespace std;
using ll = long long;

const int mod = 1e9 + 7;

int n, k;
vector<ll> factorials;

void fact_init() {
    factorials.resize(n + 1);
    factorials[0] = 1;
    for (int i = 1; i <= n; i++) {
        factorials[i] = factorials[i - 1] * i % mod;
    }
}

ll rep_pow(int n, int p) {
    if (p == 0) {
        return 1;
    }
    if (p % 2 == 0) {
        int t = rep_pow(n, p / 2);
        return (ll)t * (ll)t % mod;
    } else {
        return n * rep_pow(n, p - 1) % mod;
    }
}

ll com(int n, int k) {
    if (n < k || n < 0 || k < 0) {
        return 0;
    }
    return factorials[n] * rep_pow(factorials[k], mod - 2) % mod * rep_pow(factorials[n - k], mod - 2) % mod;
}

int main() {
    cin >> n >> k;
    fact_init();
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    vector<ll> sums(n + 1, 0);
    for (int i = 1; i <= n; i++) {
        sums[i] = sums[i - 1] + a[i - 1];
    }
    ll ans = 0;
    for (int d = k; d <= n; d++) {
        ll mul = sums[n] - sums[d - 1] - sums[n - d + 1];
        mul %= mod;
        ans += mul * com(d - 2, k - 2) % mod;
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
// string b=to_string(a[0]);
deque<int>b;
rep(i,n){
    if(i%2==0){
        // b=to_string(a[i])+" "+b;
        b.push_front(a[i]);
    }
    else{
        b.push_back(a[i]);
    }
}
if(n%2==0){
    reverse(b.begin(),b.end());
}
rep(i,n){
    cout<<b[i]<<" ";
}
return 0;
}

Measured memory_bytes: 3840
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,t;
    cin>>k>>t;
    int p= 2*k-1;
    int j= t-k+1;
    for(int i=0;i<p;i++)
    {

        cout<<j<<" ";
        j=j+1;
    }
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <map>
#include <numeric>
#include <sstream>
#include <queue>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()
#define print(s) cout << (s) << endl

int main() {
    int a, b;
    cin >> a >> b;
    printf("%.6f\n", 1/3.305785*a*b);
    return 0;
}

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

int main() {
  int n, a, b, c, d;
  cin >> n;
  a = n/1000;
  b = n%1000/100;
  c = n%100/10;
  d = n%10;
  
  if (a + b + c + d == 7) {
    cout << a << '+' << b << '+' << c << '+' << d << "=7" << endl;
  }
  else if (a + b + c - d == 7) {
    cout << a << '+' << b << '+' << c << '-' << d << "=7" << endl;
  }
  else if (a + b - c + d == 7) {
    cout << a << '+' << b << '-' << c << '+' << d << "=7" << endl;
  }
  else if (a + b - c - d == 7) {
    cout << a << '+' << b << '-' << c << '-' << d << "=7" << endl;
  }
  else if (a - b + c + d == 7) {
    cout << a << '-' << b << '+' << c << '+' << d << "=7" << endl;
  }
  else if (a - b + c - d == 7) {
    cout << a << '-' << b << '+' << c << '-' << d << "=7" << endl;
  }
  else if (a - b - c + d == 7) {
    cout << a << '-' << b << '-' << c << '+' << d << "=7" << endl;
  }
  else if (a - b - c - d == 7) {
    cout << a << '-' << b << '-' << c << '-' << d << "=7" << endl;
  }
}

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

int main() {
  int N,K;
  int M=0;
  cin>>N>>K;
  vector<int>vec(N);
  for(int i=0;i<N;i++){
  cin>>vec.at(i);
  }
  sort(vec.begin(), vec.end());
  for(int j=0;j<K;j++){
  M+=vec.at(j);
  }
  cout<<M<<endl;
}



Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[,] sch = new int[3, N];
            int[,] dp = new int[3, N];
            for(int i = 0; i < N; i++)
            {
                int[] nums = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                sch[0, i] = nums[0];
                sch[1, i] = nums[1];
                sch[2, i] = nums[2];
            }
            dp[0, 0] = sch[0, 0];
            dp[1, 0] = sch[1, 0];
            dp[2, 0] = sch[2, 0];
            for (int i = 1; i < N; i++)
            {
                dp[0, i] = Math.Max(dp[1, i - 1], dp[2, i - 1]) + sch[0, i];
                dp[1, i] = Math.Max(dp[0, i - 1], dp[2, i - 1]) + sch[1, i];
                dp[2, i] = Math.Max(dp[0, i - 1], dp[1, i - 1]) + sch[2, i];
            }
            Console.WriteLine(Math.Max(dp[0, N - 1], Math.Max(dp[1, N - 1], dp[2, N - 1])));
        }
    }
}

Measured memory_bytes: 17340
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		System.out.println((a+b) * c / 2);
	}
}


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

int main() {
	int n, odd = 0, even = 0,num;
	cin >> n;
	for (int i = 0;i < n; i++) {
		cin >> num;
		if (num % 2 == 0)even++;
		else odd++;
	}
	cout << (int)pow(3, n) - ((int)pow(2, even) * (int)pow(1, odd)) << endl;
}


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

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<pi,int> pii;

#define mp make_pair
#define pb push_back
#define f first
#define s second 
#define MOD 10000000009
#define HASH 134762

int N, M, a, b, res=0;
vector<pi> v;

int main()
{
	cin>>N>>M;
	for(int i=0; i<M; i++)
	{
		cin>>a>>b;
		v.pb(mp(a, b));
	}
	sort(v.begin(), v.end());
//	cout<<endl;
	int l=v[0].f, r=v[0].s;
	for(int i=1; i<v.size(); i++)
	{
		if(v[i].f==l)
			res++;
		else if(v[i].f<r&&v[i].f>l)
			l=v[i].f, r=min(r, v[i].s), res++;
		else
			l=v[i].f, r=v[i].s;
	}
	cout<<M-res<<endl;
//	for(int i=0; i<v.size(); i++)
//		cout<<v[i].f<<" "<<v[i].s<<endl;
	return 0; 
}


Measured memory_bytes: 1400
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    double x1,x2,y1,y2;cin>>x1>>y1>>x2>>y2;
    printf("%.6lf\n",(double)pow((double)(x1-x2)*(double)(x1-x2)+(double)(y1-y2)*(double)(y1-y2),0.5));
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































Measured memory_bytes: 3440
#include<bits/stdc++.h>
using namespace std;
int a[1121];
string s[1121];
int len,n,m,ans;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
	    string q;
		cin>>q;
		bool f=0;
		for(int i=1;i<=len;i++)
		{
			if(s[i]==q) f=1,a[i]++;
		}
		if(!f) s[++len]=q,a[len]++;
	}
	cin>>m;
	for(int i=1;i<=m;i++)
	{
		string q;
		cin>>q;
		bool f=0;
		for(int i=1;i<=len;i++)
		{
			if(s[i]==q) f=1,a[i]--;
		}
		if(!f) s[++len]=q,a[len]--;
	}
	for(int i=1;i<=len;i++)
	ans=max(ans,a[i]);
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  int n; cin>>n; double s=0;
  double a[n];
  rep(i,n){
    cin>>a[i];
    s+=1/a[i];
  }
  cout<<setprecision(7)<<1/s;
}

Measured memory_bytes: 256
import numpy as np

H, W = map(int, input().split())
As = [list(map(int, input().split())) for _ in range(H)]
Bs = [list(map(int, input().split())) for _ in range(H)]

ds = [[abs(A-B) for A, B in zip(row_A, row_B)] for row_A, row_B in zip(As, Bs)]

size = 100005

dp = np.full((H, W, size), False)
dp[0][0][ds[0][0]] = True
for i in range(H):
    for j in range(W):
        if i+1 < H:
            d = ds[i+1][j]
            dp[i+1][j][d:] = np.logical_or(dp[i][j][:size-d], dp[i+1][j][d:])
            dp[i+1][j][:size-d] = np.logical_or(dp[i][j][d:], dp[i+1][j][:size-d])
            dp[i+1][j][:d+1] = np.logical_or(dp[i][j][d::-1], dp[i+1][j][:d+1])
        if j+1 < W:
            d = ds[i][j+1]
            dp[i][j+1][d:] = np.logical_or(dp[i][j][:size-d], dp[i][j+1][d:])
            dp[i][j+1][:size-d] = np.logical_or(dp[i][j][d:], dp[i][j+1][:size-d])
            dp[i][j+1][:d+1] = np.logical_or(dp[i][j][d::-1], dp[i][j+1][:d+1])

print(np.min(np.where(dp[-1][-1])))


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

int main(){
	int n,m;
	bool red[100000] = {true};
	int num[100000];
	cin >> n >> m;
	for(int i = 0;i < n;i++) num[i] = 1;
	for(int i = 0;i < m;i++){
		int x,y;
		cin >> x >> y;
		x--;
		y--;
		if(red[x]) red[y] = true;
		num[x]--;
		num[y]++;
		if(num[x] == 0) red[x] = false;
	}
	int cnt = 0;
	for(int i = 0;i < n;i++){
		if(red[i]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

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

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long[] A = new long[N];
    for (int i =0; i<N; i++) {
      A[i] = sc.nextLong();
    }
    Arrays.sort(A);
    long min = 1000000000;
    for (int i =0; i<N-1; i++) {
      min = Math.min(gcm(A[i],A[i+1]),min);
    }
    System.out.println(min);
  }
  
  public static long gcm(long a, long b) {
    if (a%b == 0) {
      return b;
    } else {
      return gcm(b,a%b);
    }
  }
}

Measured memory_bytes: 60344
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
X, N = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
p_list = list(map(int, input().split()))

ans = -1

for i in range(100):
    if not X-i in p_list:
        ans = X-i
        break
    elif not X+i in p_list:
        ans = X+i
        break

print(ans)


Measured memory_bytes: 9112
import java.util.*;
class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int K = sc.nextInt();
		int Ans = 0;
		int Max = Math.max(A, B);
		Max = Math.max(Max, C);
		double pow = Math.pow(2, K);
		if (Max == A) {
			Ans = (A * (int)pow) + B + C;
		} else if (Max == B) {
			Ans = (B * ((int)pow)) + A + C;
		} else {
			Ans = (C * ((int)pow)) + A + B;
		}
		System.out.println(Ans);
	}
}

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

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> c(N),t(N);
  for(int i = 0; i < N; i++){
    cin >> c[i] >> t[i];
  }
  
  int min = 10000;
  for(int i = 0; i < N; i++){
    if(min > c[i] && T >= t[i]){
      min = c[i];
    }
  }
    
  if(min == 10000){
    cout << "TLE" << endl;
  }else{
    cout << min << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;


template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x){
	input>>x.F>>x.S;
	return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x){
	for(auto& i:x)
		input>>i;
	return input;
}

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

const int mod=1e9+7;

int mul(int a,int b)
{
	return (a*1ll*b)%mod;
	}
	
void add(int &a,int b)
{
	a+=b;
	if(a>=mod)a-=mod;
	}
int powz(int a,int b)
{
	int res=1;
	while(b)
	{
		if(b&1)res=mul(res,a);
		b/=2;
		a=mul(a,a);
		}
	return res;
	}
const int N=100005;
int col[N];
vi adj[N];
map<pi,int>mp;
void dfs(int v,int p)
{
	if(p!=-1)
	{
		if(mp[{v,p}]&1){
			col[v]=1-col[p];
			}
			else col[v]=col[p];
		}
		for(auto i:adj[v])
		{
			if(i!=p)dfs(i,v);
			}
	}

void solve()
{
	int n;
	cin>>n;
	col[0]=1;
	for(int i=0;i<n-1;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		x--;y--;
		adj[x].pb(y);
		adj[y].pb(x);
		mp[{x,y}]=z;
		mp[{y,x}]=z;
		}
		dfs(0,-1);
		for(int i=0;i<n;i++)cout<<col[i]<<'\n';
	}
   
	
	

int main()
{   
    ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
    while(t--)
	{
        solve();
		}
	
	}


Measured memory_bytes: 22400
#include <iostream>

using namespace std;

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


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

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;


int main()
{
	int n,m;
	cin >> n >> m;
	int ans[n];
	memset(ans, 0, sizeof(ans));
	for (int i = 0; i < m; i++) {
		int tmpa, tmpb;
		cin >> tmpa >> tmpb;
		tmpa--;
		tmpb--;
		ans[tmpa]++;
		ans[tmpb]++;
	}
	for (int i = 0; i < n; i++) {
		cout << ans[i] << "\n";
	}
}


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

int main() {
	int H, W;
	cin >> H >> W;
	while(H != 0 || W != 0) {
		for(int j = 0; j < H; j++) {
			if(j == 0 || j == H -1) {
				for(int i = 0; i < W; i++) {
					cout << '#';
			}
			cout << endl;
			}
			else {
				for(int i = 0; i < W; i++) {
					if(i == 0 || i == W -1) cout << '#';
					else cout << '.';
				}
				cout << endl;
			}
		}
		cout << endl;
		cin >> H >> W;
	}
}


Measured memory_bytes: 3080
/*
 * ID: 0278
 * Problem: entrance fee
 */

#include <stdio.h>

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

    for (int i = 0; i < n; i++) {
        int fbath, fpool, nbath, npool;
        scanf("%d %d %d %d", &fbath, &fpool, &nbath, &npool);

        int fee = fbath * nbath + fpool * npool;
        if (nbath >= 5 && npool >= 2) {
            fee *= 0.8;
        } else {
            int fee2 = (fbath * (nbath < 5 ? 5 : nbath)
                      + fpool * (npool < 2 ? 2 : npool)) * 0.8;
            fee = fee < fee2 ? fee : fee2;
        }

        printf("%d\n", fee);
    }

    return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pi 3.14159265358979323846264
#define pii pair <int, int>
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vl vector <long long>
#define vpii vector <pair <int, int> >
#define ll long long
#define fi first
#define se second
char s[10];
int main() {
    scanf("%s", s);
    for (int i=0;i<strlen(s);i++) {
        if (s[i]=='A'&&s[i+1]=='C') {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    return 0;
}

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

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 7;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int n;
    cin>>n;
    vl a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(all(a));
    int ans=0;
    for(int i=0;i<n;i++) {
        for(int j=i+1;j<n;j++) {
            if(a[i]==a[j]) continue;
            for(int k=j+1;k<n;k++) {
                if(a[j]==a[k]) continue;
                if(a[i]+a[j]>a[k]) ans++;
            }
        }
    }
    cout<<ans;
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll n;
    cin >> n;
    ll ans = 0;
    FOR(x,1,n){
        if (x % 3 != 0 && x % 5 != 0) ans += x;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <tuple>
#include <queue>
#include <set>
#include <cstdio>
#include <climits>
#include <cmath>
#include <array>
#include <functional>
#include <list>
#include <iomanip>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
const double eps=1e-9;
const int inf=1e9;
typedef pair<int,int> P;

string func(string s,char x)
{
  string t;
  for(int i=0;i<s.size();i++)
    {
      if(s[i]==x) t+="ABC";
      else t+=s[i];
    }
  return t;
}

string inverse(string &s,char x)
{
  string t;
  for(int i=0;i<s.size();)
    {
      if(i+2<s.size() && s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
	{
	  t+=x;
	  i+=3;
	}
      else
	{
	  t+=s[i];
	  i++;
	}
    }
  return t;
}
int cnt[3];
bool check(string &s)
{
  memset(cnt,0,sizeof(cnt));
  for(int i=0;i<s.size();i++)
    {
      cnt[s[i]-'A']++;
    }
  return(cnt[0]>0 && cnt[1]>0 && cnt[2] >0);
}

int main(int argc,char const* argv[])
{
  string s;
  cin >> s;
  while(1)
    {
      if(!check(s)) 
	{
	  cout << "No" << endl;
	  return 0;
	}
      if(s=="ABC")
	{
	  cout << "Yes" << endl;
	  return 0;
	}    
      char last='?';
      for(char x='A';x<='C';x++)
	{
	  if(func(inverse(s,x),x)==s)
	    {
	      last=x;
	      break;
	    }
	}
      if(last=='?') break;
      s=inverse(s,last);
    }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 3232
using System;

namespace ABC026A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;

            var word = Console.ReadLine().Split(' ');

            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            //c = int.Parse(word[2]);


            if (a*b*1%2==1)
                Console.WriteLine("Yes");
            else if (a * b * 2 % 2 == 1)
                Console.WriteLine("Yes");
            else if (a * b * 3 % 2 == 1)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");

            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
s = input()
c = len(s)-1
r = 0
x = 97
while -2 < c:
    for i in range(x, 97+26):
        if chr(i) not in s:          
            s = s+chr(i)
            r = 1
            break
    if r == 1:
        break
    elif c < 0:
        break
    else:
        x = ord(s[-1]) +1
        c -= 1
        s = s[:len(s)-1]
if r==0:
    s = '-1'
print(s)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {

/*		int card[][] = {	{1,2,3,4,5,6,7,8,9,10,11,12,13},
							{1,2,3,4,5,6,7,8,9,10,11,12,13},
							{1,2,3,4,5,6,7,8,9,10,11,12,13},
							{1,2,3,4,5,6,7,8,9,10,11,12,13},	};*/

		boolean card[][] = new boolean[4][13];
		int n,x=0,y;
		String str;
		char ch = 0;

		Scanner scan = new Scanner(System.in);

		n = scan.nextInt();

		for(int i=0; i<n; i++)
		{
			str = scan.next();
			y = scan.nextInt();

			switch(str)
			{
				case "S":
					x = 0;
					break;
				case "H":
					x = 1;
					break;
				case "C":
					x = 2;
					break;
				case "D":
					x = 3;
					break;

				default:
			}

			card[x][y-1] = true;
		}

		for(int i=0; i<4; i++)
		{
			for(int j=0; j<13; j++)
			{
				if(card[i][j] == false)
				{
					if(i==0) ch = 'S';
					else if(i==1) ch = 'H';
					else if(i==2) ch = 'C';
					else if(i==3) ch = 'D';

					System.out.printf("%c %d\n",ch,j+1);
				}
			}

			//System.out.println();
		}

		scan.close();
	}
}

Measured memory_bytes: 26448
from collections import defaultdict 
import sys
import math 
import random
def get_array(): return list(map(int , sys.stdin.readline().strip().split()))
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def input(): return sys.stdin.readline().strip()

cnt = 0
n = int(input())
flag = False 
for i in range(n):
    (x,y) = get_ints()
    
    if x==y:
        cnt+=1
    else:
        cnt=0
    if cnt>=3:
        flag = True 

if flag:
    print("Yes")
else:
    print("No")

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

int main(){
    int n,a[5];
    for(int i=0 ; i<5 ; i++){
        cin >> a[i];
    }
    sort( a , a+5 );
    for(int i=4 ; i >= 0 ; i--){
        cout << a[i] ;
        if(i==0)
            cout << endl;
        else
            cout << " ";
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
const int N=8e5+5,P=924844033;
int n,hd[N],V[N],nx[N],t,p,A[N],G[2]={5,554906420},B[N],sz[N],r[N],jc[N],ny[N];
int X(int x){return x>=P?x-P:x;}
int K(int x,int y){
	int z=1;
	for (;y;y>>=1,x=1ll*x*x%P)
		if (y&1) z=1ll*z*x%P;
	return z;
}
void add(int u,int v){
	nx[++t]=hd[u];V[hd[u]=t]=v;
}
void dfs(int u,int fr){
	sz[u]=1;
	for (int i=hd[u];i;i=nx[i])
		if (V[i]!=fr){
			dfs(V[i],u);
			sz[u]+=sz[V[i]];
			A[sz[V[i]]]--;
		}
	if (u!=1) A[n-sz[u]]--;
}
void Ntt(int *a,int o){
	for (int i=0;i<t;i++)
		if (i<r[i]) swap(a[i],a[r[i]]);
	for (int wn,i=1;i<t;i<<=1){
		wn=K(G[o],(P-1)/(i<<1));
		for (int x,y,j=0;j<t;j+=(i<<1))
			for (int k=0,w=1;k<i;k++,w=1ll*w*wn%P)
				x=a[j+k],y=1ll*a[i+j+k]*w%P,
				a[j+k]=X(x+y),a[i+j+k]=X(x-y+P);
	}
	if (o)
		for (int i=0,v=K(t,P-2);i<t;i++)
			a[i]=1ll*a[i]*v%P;
}
int main(){
	cin>>n;jc[0]=1;
	for (int i=1,x,y;i<n;i++)
		scanf("%d%d",&x,&y),
		add(x,y),add(y,x);
	A[n]=n;dfs(1,0);
	for (int i=1;i<=n;i++)
		jc[i]=1ll*i*jc[i-1]%P;
	ny[n]=K(jc[n],P-2);
	for (int i=n;i;i--)
		ny[i-1]=1ll*i*ny[i]%P;
	for (int i=0;i<=n;i++)
		B[i]=ny[i],A[i]=1ll*X(A[i]+P)*jc[i]%P;
	reverse(B,B+n+1);
	for (t=1;t<n+n+2;t<<=1,p++);
	for (int i=0;i<t;i++)
		r[i]=(r[i>>1]>>1)|((i&1)<<(p-1));
	Ntt(A,0);Ntt(B,0);
	for (int i=0;i<t;i++) A[i]=1ll*A[i]*B[i]%P;
	Ntt(A,1);
	for (int i=1;i<=n;i++) printf("%lld\n",1ll*ny[i]*A[n+i]%P);
	return 0;
}

Measured memory_bytes: 31360
N = int(input())

if N >= 105:
    if N >= 135:
        if N >= 165:
            if N >= 189:
                if N >= 195:
                    print(5)
                else:
                    print(4)
            else:
                print(3)
        else:
            print(2)
    else:
        print(1)
else:
    print(0)



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

int main(){
  string S,T;
  cin >> S >> T;
  int N = S.size();
  bool ok = false;
  for(int i=0;i<N;i++){// i moji zurasu
    bool id = true;
    for(int j=0;j<N;j++){
      if(S.at(j) != T.at((j+i)%N)){
        id = false;
        break;
      }
    }
    if(id){
      ok = true;
      break;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	int k;
	cin>>s;
	cin>>k;
	for(int i=0;i<n;i++)
	{
		if(s[i]==s[k-1])
		{
			cout<<s[i];
		}
		else
		{
			cout<<'*';
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    ll ans = 1000;
    ll stake = 0;
    bool inc = false;
    rep(i, n-1){
        if(inc){
            if(a[i] <= a[i+1]){
                continue;
            }else{
                ans += a[i] * stake;
                stake = 0;
                inc = false;
            }
        }else{
            if(a[i] >= a[i+1]){
                continue;
            }else{
                stake = ans / a[i];
                ans -= a[i] * stake;
                inc = true;
            }
        }
    }
    ans += a[n-1] * stake;
    cout << ans << endl;
}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> b(n + 1);
  for (int i = 1; i <= n - 1; ++i) cin >> b[i];
  b[0] = b[1];
  b[n] = b[n - 1];

  int ans = 0;
  for (int i = b.size() - 1; i >= 1; --i) {
    ans +=  min(b[i], b[i - 1]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
int main(){
  std::string s;
  std::cin >> s;
  int n = s.size(),t;
  int a[26];
  memset(a, 0, sizeof(a));
  for(int i = 0; i < n; i++){
    t = s[i];
    t -= 97;
    a[t] += 1;
  }
  int j ;
  for( j = 0; j != n; j++)
    if(a[j] > 1)
      break;
  if(j == n)
    std::cout << "yes" << std::endl;
  else
    std::cout << "no" << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin>>a;
  cin>>b;
  if(a<=8&&b<=8){
    cout<<"Yay!"<<endl;
  }else{
    cout<<":("<<endl;
  }

  return 0;
}


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

int main()
{
	int n, a;
	int max = -1000000;
	int min = 1000000;
	long int sum = 0;

	cin >> n;


	for (int i = 0; i < n; i++){
		cin >> a;

		if (max < a)
			max = a;

		if (min > a)
			min = a;

		sum += a;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}

Measured memory_bytes: 3092
array = [0 for i in range(100001)]
N = int(input())
A = list(map(int, input().split()))
Q = int(input())

for a in A:
    array[a] += 1
souwa = sum(A)

B = []
C = []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)

for i in range(Q):
    souwa = souwa + (C[i]-B[i])*array[B[i]]
    array[C[i]] += array[B[i]]
    array[B[i]] = 0
    print(souwa)


Measured memory_bytes: 22416
#include <iostream>
#define rep(i, n) for (int i=0; i<n; i++)
#define ll long long
using namespace std;

int main() {
    char c;
    cin >> c;
    if (c >= 'a' && c <= 'z') cout << 'a' << endl;
    else cout << 'A' << endl;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
int gcd(int a, int b) {
	return b ? gcd(b, a%b) : a;
}
int gcd(int a, int b, int c) {
	return gcd(gcd(a, b), c);
}
int main() {
	int k;
	cin >> k;
	int ans = 0;
	for (int i = 1; i <= k; i++) {
		for (int j = 1; j <= k; j++) {
			for (int l = 1; l <= k; l++) {
				ans += gcd(i, j, l);
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
using namespace std;
const int N = 2000000 + 10;

int n,a[N],b[N];
int M(int x,int y,int z){
    if((x-y)*(x-z)<=0) return x;
    if((y-x)*(y-z)<=0) return y;
    return z;
}
int cac() {
    int dp[102][102];
    for(int i=1;i<=2*n-1;i++) dp[1][i]=a[i];
    for(int i=2;i<=n;i++){
        for(int j=i;j<=2*n-i;j++){
            dp[i][j] = M(dp[i-1][j],dp[i-1][j-1],dp[i-1][j+1]);
        }
    }
    printf("%d\n", dp[n][n]);
}
int chk(int x) {
    //printf("chk %d\n", x);
    for(int i=1;i<=2*n-1;i++) b[i]=a[i]<=x?0:1;
    int mid=n;
    int lb=mid-1,rb=mid+1;

    if(b[mid]==b[mid-1]) return b[mid]==0?1:0;
    if(b[mid]==b[mid+1]) return b[mid]==0?1:0; 
    
    while(lb>=2) {
        if(b[lb]!=b[lb+1] && b[lb]!=b[lb-1]) lb--;
        else break;
    }
    while(rb<2*n-1) {
        if(b[rb]!=b[rb-1] && b[rb]!=b[rb+1]) rb++;
        else break;
    }
    //printf("[%d, %d]\n", lb,rb);
    int R = min(mid-lb, rb-mid);
    if(lb==1 && rb==2*n-1) return (b[mid] ^ (R&1))==0?1:0;


    // [lb,mid,rb]

    if (mid-lb <= rb-mid) {
        int x1 = b[lb-1];    
        int x2 = b[mid] ^ (R&1);
        return x1 == 0 ? 1 : 0;
    } else {
        int x1 = b[rb+1];
        int x2 = b[mid] ^ (R&1);
        return x1 == 0 ? 1 : 0;
    }
}   

int main() {
    scanf("%d", &n);
    for(int i=1;i<=2*n-1;i++){
        scanf("%d",&a[i]);
        //a[i]=i;
    }
    //random_shuffle(a+1,a+1+n);
    int lef = 0, rig = n<<1|1;
    while(rig-lef>1) {
        int mid = (lef + rig) >> 1;
        if (chk(mid)) rig = mid;
        else lef = mid;
    }
    printf("%d\n", rig);
    //cac();
}




Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s, t;
  cin >> s >> t;
  ll res = 0;
  rep(i, 3) {
    if (s.at(i) == t.at(i)) res++;
  }
  cout << res << endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll r, d, x;

int main()
{
    int i, j;

    scanf("%lld%lld%lld", &r, &d, &x);
    for(i=1; i<=10; i++)
    {
        x=r*x-d;
        printf("%lld\n", x);
    }
}


Measured memory_bytes: 256
a, b, c = map(int, input().split())
k = int(input())

count = 0
while a >= b:
    b *= 2
    count += 1
    # print("b", b)

while b >= c:
    c *= 2
    count += 1
    # print("c", c)

if count <= k:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9132
#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() {
  int r;
  cin >> r;
  if (r < 1200) {
    cout << "ABC" << endl;
  } else if (r < 2800) {
    cout << "ARC" << endl;
  } else {
    cout << "AGC" << endl;
  }
  return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

template <class T>
struct BIT_interval {
    vector<T> dat1;
    vector<T> dat2;
    BIT_interval(int n) : dat1(n+1),dat2(n+1) { }
    // add w [l,r)
    void add_interval(int l,int r, T w) {
        for (int k=l+1; k < dat1.size(); k += k&-k) dat1[k] -= w*l;
        for (int k=r+1; k < dat1.size(); k += k&-k) dat1[k] += w*r;
        for (int k=l+1; k < dat2.size(); k += k&-k) dat2[k] += w;
        for (int k=r+1; k < dat2.size(); k += k&-k) dat2[k] -= w;
    }
    T sum(int x) {
        T s = 0;
        for (int k=x; k > 0; k &= k-1) s += dat1[k];
        for (int k=x; k > 0; k &= k-1) s += dat2[k]*x;
        return s;
    }
};

int main() {
  int N,M;cin >> N >> M;
  BIT_interval<int> bit(M+1);
  vector<Pii> A(N);
  repeat(i,N){
    int l,r;
    cin >> l >> r;
    A[i] = {r-l+1,l};
  }
  sort(A.begin(),A.end());
  int idx=0;
  for(int d=1;d<=M;d++){
    while(idx < N && A[idx].first<d){
      int l = A[idx].second;
      int r = l + A[idx].first;
      bit.add_interval(l,r,1);
      idx++;
    }
    int ans = N-idx;
    for(int i=d;i<=M;i+=d){
      ans += bit.sum(i+1)-bit.sum(i);
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4096
def main():
    n = int(input())
    F = [list(map(int, input().split())) for _ in range(n)]
    P = [list(map(int, input().split())) for _ in range(n)]
    ans = -float('inf')
    for i in range(1, 1 << 10):
        A = [0] * 10
        for j in range(10):
            if i >> j & 1:
                A[j] = 1
        C = [0] * n
        for k in range(n):
            c = 0
            for a, f in zip(A, F[k]):
                if a == f == 1:
                    c += 1
            C[k] = c
        ans = max(ans, sum([P[i][c] for i, c in enumerate(C)]))
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3192
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
   ll n,x;
   cin>>n>>x;
   ll a[n];
   for(int i=0;i<n;i++)
     cin>>a[i];
    vector<ll> v(n+1);
    v[0]=0;
    for(int i=0;i<n;i++)
    {
        v[i+1]=v[i]+a[i];
    }
    ll p=lower_bound(v.begin(),v.end(),x)-v.begin();
    if(v[p]==x)
     cout<<p+1;
     else
      cout<<p;
    return 0;
}

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

using namespace std;

int main(){
  int w,h;
  int maps[64][64];
  // [from][to] = cost
  int dp[64][64];
  cin >> h >> w;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      char c;
      cin >> c;
      maps[i][j] = c - '0';
    }
  }

  dp[0][0] = 0;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(i > 0 && j > 0){
	dp[i][j] = min(maps[i - 1][j] + dp[i - 1][j]
		       , maps[i][j - 1] + dp[i][j - 1]);
      }
      else if(i > 0 && !j){
	dp[i][j] = maps[i - 1][j] + dp[i - 1][j];
      }
      else if(j > 0 && !i){
	dp[i][j] = maps[i][j - 1] + dp[i][j - 1];
      }
    }
  }

  /*
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      printf("%d ", dp[i][j]);
    }
    printf("\n");
  }
  */
  
  cout << dp[h - 1][w - 1] << endl;
  return 0;
}

    

    

Measured memory_bytes: 0
using System;
using System.Linq;

class Program {
  static void Main() {
    var s = new string(Console.ReadLine().OrderBy(x=>x).ToArray());
    var t = new string(Console.ReadLine().OrderByDescending(x => x).ToArray());
    Console.WriteLine(s.CompareTo(t) == -1 ? "Yes" : "No");
  }
}

Measured memory_bytes: 13536
# -*- coding: utf-8 -*-

S=input()
T=input()

ls=len(S)
lt=len(T)

ans=lt

for i in range(ls-lt+1):
    ss=S[i:i+lt]
    c=0
    for j in range(lt):
        if ss[j]!=T[j]: c+=1

    if c<ans: ans=c

print(ans)

Measured memory_bytes: 9120
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner scan = new Scanner(System.in);
	static PrintWriter out = new PrintWriter(System.out);

	public static void main(String[] args) {
		while(scan.hasNext()){
			String[] cards = scan.next().split(",");
			int[] a = new int[5];
			for (int i = 0; i < 5; i++)
				a[i] = Integer.parseInt(cards[i]);
			Arrays.sort(a);
			if(pair(a).contains(4)) out.println("four card");
			else if(pair(a).contains(3) && pair(a).contains(2)) out.println("full house");
			else if(a[4]-a[0]==4 || (a[0]==1 && a[1]==10 && a[4]==13)) out.println("straight");
			else if(pair(a).contains(3)) out.println("three card");
			else if(pair(a).lastIndexOf(2)==1) out.println("two pair");
			else if(pair(a).contains(2)) out.println("one pair");
			else out.println("null");
		}
		out.flush();
	}

	static ArrayList<Integer> pair(int[] a){
		ArrayList<Integer> list = new ArrayList<Integer>();
		for (int i = 1; i <= 13 ; i++) {
			int tmp=0;
			for (int j = 0; j < 5; j++) if(a[j]==i) tmp++;
			if(tmp>=2) list.add(tmp);
		}
		return list;
	}

	static int si() {
		return Integer.parseInt(scan.next());
	}
}

Measured memory_bytes: 17196
#include <cstdio>

#define N 105

int n,m;
char s[N];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
		scanf("%s",s+1),
		printf("%s\n%s\n",s+1,s+1);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define pb push_back
#define mp make_pair
 #define mod 1000000007
 const int N=100005;
 const int inf=1e18;
int pow(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	string s;
	cin>>s;
	vector<int>l,r;
	vector<int>::iterator itr;
	for(int x=0;x<s.length();x++){
		if(s[x]=='L'){
			l.pb(x);
		}else{
			r.pb(x);
		}
	}
	int n=s.length();
	int ans[n]={0};
	for(int x=0;x<s.length();x++){
		//cout<<x<<" ";
		if(s[x]=='L'){
			itr=lower_bound(r.begin(),r.end(),x);
			itr--;
			int v=x-*itr;
		//	cout<<*itr<<" "<<v<<"\n";
			
			if(v%2==0){
				ans[*itr]++;
			}else{
				ans[*itr+1]++;
			}
		}else{
			itr=lower_bound(l.begin(),l.end(),x);
				int v=*itr-x;
		//	cout<<*itr<<" "<<v<<"\n";
		
			if(v%2==0){
				ans[*itr]++;
			}else{
				ans[*itr-1]++;
			}
		}
	}
	for(int x=0;x<n;x++){
		cout<<ans[x]<<" ";
	}
	
	








	
return 0;
}


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

string s;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> s;
    string rs = s;
    reverse(rs.begin(), rs.end());

    string fs = "";
    string fsr = "";
    string ss = "";
    string ssr = "";

    for (int i = 0; i < (s.size() - 1) / 2; i++)
    {
        fs.push_back(s[i]);
        ssr.push_back(rs[i]);
    }

    for (int i = ((s.size() + 3) / 2) - 1; i < s.size(); i++)
    {
        fsr.push_back(s[i]);
        ss.push_back(rs[i]);
    }

    if (s == rs && fs == fsr && ss == ssr)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    cin >> s;
}

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

int main() {
	string w;
	cin >> w;
	map<char, int> MAP;
	for (char c : w) MAP[c]++;
	for (const auto& m : MAP) {
		if (m.second % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
from collections import deque
import copy

def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]


    # スタート地点をqueueに追加
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])

    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))

        if nque:
            que = copy.copy(nque)
        else:
            break

    print(count - 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 115492
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int ma, mi,n ,a;
	long long sum = 0;
	cin >> n;	
	ma  = -20000000;
	mi = -ma;
	for (int i = 1; i <= n; i++)
	{	cin >> a;
		ma = max(ma, a);
		mi= min(mi, a);
		sum += a;
	}
	cout << mi << " " << ma << " " << sum << endl;
	return 0;
}


Measured memory_bytes: 3124
#include <iostream>

using namespace std;

int main() {
    while (true) {
        int N, A, B, C, X;
        int Y[101];

        cin >> N >> A >> B >> C >> X;

        if (N == 0 && A == 0 && B == 0 && C == 0 && X == 0) { break; }

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

        int ans = 0, i = 0;

        while (true) {
            if (X == Y[i]) { i++; }
            if (i == N || ans > 10000) { break; }

            X = (A*X + B) % C;
            ans++;
        }
        cout << (ans > 10000 ? -1 : ans) << endl;
    }
    return 0;
}


Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1<<30;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[8]={1,0,-1,0,1,1,-1,-1} , dy[8]={0,1,0,-1,1,-1,1,-1} ;
 
int main(){
    int n,m;
    cin>>n>>m;
    pint a[m];
    rep(i,m){
        int x,y;
        cin>>x>>y;
        x--;y--;
        a[i]={y,x};
    }
    int cnt=0;
    int pos=-1;
    sort(a,a+m);
    rep(i,m){
        if(a[i].second>pos){
            cnt++;
            pos=a[i].first-1;
        }
    }
    cout<<cnt<<endl;
    return 0;
}

Measured memory_bytes: 1152
#include<cstdio>

using namespace std;

typedef long long ll;

ll pow(int x, int n){
	return n == 0 ? 1 : x * pow(x, n - 1);
}

int main(){
	int n, k; scanf("%d %d", &n, &k);
	ll res = pow(n / k, 3);
	if(k % 2 == 0) res += pow((n + k / 2) / k , 3);
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
	int a,b,x;
	scanf("%d %d %d",&a,&b,&x);
	
	if(a+b>=x&&a<=x){
		printf("YES\n");
	}else{
		printf("NO\n");
	}
	
	return 0;
}

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

using namespace std;
#define ll long long
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
const int N=1e5+10;

int main()
{
    //freopen("ss.inp","r",stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ac,wa,tle,re;
    ac=wa=tle=re=0;
    int n;
    cin>>n;
    for (int i=1;i<=n;i++)
    {
        string s;
        cin>>s;
        if (s=="AC") ac++;
        else if (s=="WA") wa++;
        else if (s=="RE") re++;
        else tle++;
    }
    cout<<"AC x "<<ac<<"\nWA x "<<wa<<"\nTLE x "<<tle<<"\nRE x "<<re;
    return 0;
}


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

int main(){
	char a,b;
	cin >> a >> b;
	if (a == 'H'){
		if (b == 'H'){
			cout << "H" << endl;		
		}else{
			cout << "D" << endl;
		}
	}else{
		if (b == 'H'){
			cout << "D" << endl;
		}else{
			cout << "H" << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256