akhauriyash/Code-Regression huggingface dataset:
using System;
class ProgramA
    {
        static void Main(string[] args)
        {
            //日付を入力する
            string input_1 = Console.ReadLine();
            string input_2 = Console.ReadLine();
            int m1 = int.Parse(input_1);
            int m2 = int.Parse(input_2);

            //月が同じなら月末、それ以外は別
            if(m1 + m2 == 3)
                Console.WriteLine("3");
            else if(m1 + m2 == 4)
                Console.WriteLine("2");
            else
                Console.WriteLine("1");
                
        }
    }

Measured memory_bytes: 11092
#include <iostream>
#include <cstdio>
#define N 1000000007
#define lll long long
using namespace std;
lll q(lll a, lll p)
{
	lll ans = 1;
	while (p)
	{
		if (p % 2)
	    ans = ans * a % N;
	    a = a * a % N;
	    p >>= 1;
	}
	return ans%N;
}
int main()
{
	lll n;
	scanf ("%lld", &n);
	printf ("%lld", ( (q(10ll, n) - q(9ll, n) * 2 )%N+ q(8ll, n)%N +N)%N );
	return 0;
}


Measured memory_bytes: 3844
#include<bits/stdc++.h>
#define int long long
#define endl "\n"

using namespace std ;

const int N =2e5 +5 ;  
 
struct DSU
{
	int par[N+1]  ;
	int rnk[N+1] ; 
	int sz[N+1] ; 
	DSU(int n)
	{
		
		for(int i= 0 ; i < n +1 ; ++i)
		{
			par[i] = i ;	
			rnk[i]= 1 ;
			sz[i] = 1 ; 
		}		
	}	
	int findpar(int k)
	{
		while(k!=par[k])
		{
			par[k]=par[par[k]];
			k=par[k];
		}
		return k; 
	}
	void unite(int a, int b ) 
	{
		int x = findpar(par[a]) ; 	
		int y = findpar(par[b]) ;	
		if( x== y )
			return  ;
		else if (rnk[y] > rnk[x] )
		{
			par[x] = y ;
			sz[y] += sz[x] ; 	
		}	              
		else 
		{
			par[y] =x ; 
			if(rnk[x] == rnk[y])
				rnk[x]++ ; 
			sz[x] += sz[y] ; 
		}
	}
	
	
};
signed main ()
{
	ios_base::sync_with_stdio(false) ; 
	cin.tie(NULL) ; 

	int n , m; 
	cin >>n>> m ;
	DSU dsu(n) ; 
	for(int i = 0; i < m ; ++i)
	{
		int u , v ; 
		cin >>u >> v ;
		dsu.unite(u , v) ; 
	}
	int mx = *max_element(dsu.sz , dsu.sz +n +1) ; 
	cout << mx ; 

}








 


Measured memory_bytes: 8212
n,t=map(int,input().split())
T=list(map(int,input().split()))
if n==1:
	print(t)
	exit()
count=0
if t>T[1]:
    count+=t-T[1]
pre=T[1]
for i in range(2,n):
    sa=T[i]-pre
    if t>sa:
        count+=t-sa
    pre=T[i]
print(n*t-count)

Measured memory_bytes: 26708
import java.util.*;

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

    int allSunuke = sc.nextInt();
    int snackKind = sc.nextInt();

    int[] list = new int[allSunuke];
    for (int i = 0; i < snackKind; i++) {
      int d = sc.nextInt();
      for (int j = 0; j < d; j++) {
        int sunukeNumber = sc.nextInt();
        list[sunukeNumber - 1]++;
      }
    }

    int count = 0;

    for (int i = 0; i < list.length; i++) {
      if (list[i] == 0) {
        count++;
      }
    }

    System.out.println(count);

    sc.close();
  }
}

Measured memory_bytes: 45964
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> vec(m);
    rep(i,m){
        cin >> vec.at(i);
    }

    vector<ll> dp(n+1);
    dp.at(0) = 1;

    ll tmp = 0;
    rep(i,n+1){
        if(i == 1){
            if(tmp < m && vec.at(tmp) == 1){
                tmp++;
                continue;
            }else{
                dp.at(1) = 1;
                continue;
            }
        }
        if(tmp < m && i == vec.at(tmp)){
            tmp++;
            continue;
        }
        if(i >= 2){
            dp.at(i) = dp.at(i-1) % MOD + dp.at(i-2) % MOD;
            dp.at(i) = dp.at(i) % MOD;
        } 
    }

    cout << dp.at(n) << endl;

}


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

using namespace std;

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

    int a, b, c;
    cin >> a >> b >> c;
    set<int> s;
    s.insert(a);
    s.insert(b);
    s.insert(c);
    cout << s.size();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();


int main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b) << endl;


    return 0;
}





Measured memory_bytes: 256
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int x = saori.saori_hayami();
		boolean flg = true;
		int ans = 0;
		int count = 0;
		if(x >= 500){
			count = x/500;
			ans += count * 1000;
			x -= count*500;
		}
		if(x >= 5){
			count = x/5;
			ans += count * 5;
			x -= count*5;
		}
		System.out.println(ans);

		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	string s; cin >> s;
	int cnt1 = 0, cnt2 = 0;
	for (char c : s) cnt2 += (c == 'E');
	int ans = n;
	for (int i = 0; i < n; i++) {
        cnt2 -= (s[i] == 'E');
        ans = min(ans, cnt1 + cnt2);
        cnt1 += (s[i] == 'W');
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 720
#include<stdio.h>
#include<stdlib.h>
int main() {
    int arr[101];
    long long int n,i,max,sum=0,fsum;
    scanf("%lld",&n);
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    
    max=arr[0];
    for(i=1;i<n;i++){
        if(arr[i]>=max){
            max=arr[i];
        }
    }
    for(i=0;i<n;i++){
        sum+=arr[i];
    }
    fsum=abs(sum-max);
    if(fsum>max)
    printf("Yes");
    else 
    printf("No");
    return 0; 
    }

Measured memory_bytes: 1732
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;

int main() {
    int a,b;
    cin>>a>>b;
    if(a>=10 || b>=10){
        cout<<-1<<endl;
    }else{
        cout<< a*b <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int A,B,C,X;
long long int Ans;
int main()
{
    scanf("%d%d%d%d",&A,&B,&C,&X);
    for(int i=0;i<=A;i++)
    for(int j=0;j<=B;j++)
    for(int k=0;k<=C;k++)
    if(i*500+j*100+k*50==X)
    Ans++;
    printf("%lld",Ans);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
typedef pair<int, int> P;

vector<int> compress(vector<int> &a){
    vector<int> b = a, res(a.size());
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());
    for(int i = 0; i < a.size(); i++){
        res[i] = lower_bound(b.begin(), b.end(), a[i]) - b.begin();
    }
    return res;
}

struct UF{
    vector<int> par;
    vector<int> sz;
    UF(){}
    UF(int n){
        par.resize(n);
        sz.resize(n, 1);
        rep(i, 0, n) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

struct edge{
    int u, v, c;
    bool operator<(const edge &e)const{
        return c < e.c;
    }
};

int main(){
    int n, m;
    while(cin >> n >> m, n){
        vector<int> hi(n);
        rep(i, 0, n) cin >> hi[i];
        vector<int> h = compress(hi);
        int T = *max_element(h.begin(), h.end());
        vector<edge> es(m);
        rep(i, 0, m){
            int a, b, c;
            cin >> a >> b >> c;
            a--; b--;
            es[i] = {a, b, c};
        }
        sort(es.begin(), es.end());
        int edt = T;
        for(int i = 0; i <= T; i++){
            UF uf(n);
            rep(j, 0, es.size()){
                int u = es[j].u;
                int v = es[j].v;
                if(h[u] >= i && h[v] >= i){
                    if(!uf.same(u, v)){
                        uf.unite(u, v);
                    }
                }
            }
            bool f = true;
            int root = -1;
            rep(j, 0, n){
                if(h[j] >= i){
                    if(root == -1) root = uf.find(j);
                    else{
                        if(!uf.same(root, j)) f = false;
                    }
                }
            }
            if(!f){
                edt = i - 1; break;
            }
        }
        // cout << " " << edt << endl;
        int ans = 0;
        UF uf(n);
        bool f = true;
        for(int i = edt; i >= 0; i--){
            rep(j, 0, es.size()){
                int u = es[j].u;
                int v = es[j].v;
                if(h[u] >= i && h[v] >= i){
                    if(!uf.same(u, v)){
                        uf.unite(u, v);
                        ans += es[j].c;
                    }
                }
            }
            int root = -1;
            rep(j, 0, n){
                if(h[j] >= i){
                    if(root == -1) root = uf.find(j);
                    else{
                        if(!uf.same(root, j)) f = false;
                    }
                }
            }
        }
        if(!f) cout << 0 << endl;
        else cout << ans << endl;
    }
}


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

int main() {
  double a,b;
  double diff;
  double h;
  cin >> a >> b;
  
  // 13-8=5(1+...5メートルの塔)
  diff = b - a - 1;
  
  // 等差数列
  h = diff * (diff+1) / 2;
  cout << h - a;
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;
    array<int, 100005> a;
    for (auto& i : a) { i = 0; }
    cin >> N;
    int ans = 0;
    for (int i = 0; i < N; ++i) {
        int t;
        cin >> t;
        for (int j = t; j < t+3; ++j) {
            a[j] += 1;
            ans = a[j] > ans ? a[j] : ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int arr[3001][3001];
main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s,t,res="";
	cin>>s;
	cin>>t;
	int ls=s.length();
	int lt=t.length();
	for(int i=1;i<=ls;i++)
	{
		for(int j=1;j<=lt;j++)
		{
			if(s[i-1]==t[j-1])
			{
				arr[i][j]=arr[i-1][j-1]+1;
			}
			else
			{
				arr[i][j]=max(arr[i-1][j],arr[i][j-1]);
			}
		}
	}
	int i=ls,j=lt;
	while(arr[i][j]!=0)
	{
		if(arr[i-1][j]==arr[i][j])
		{
			i=i-1;
		}
		else if(arr[i][j-1]==arr[i][j])
		{
			j=j-1;
		}
		else
		{
			res=res+s[i-1];
			i=i-1;
			j=j-1;
		}
	}
	reverse(res.begin(), res.end());
	cout<<res;
}

Measured memory_bytes: 35456
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <random>
#define FOR(x, to) for(x=0; x<(to); x++) // for簡略表記
#define DUMP(ar) for(int i=0; i<ar.size(); i++) cout << "[" << i << "]:" << ar[i] << endl // 配列一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // 素数判定
    // 数列が与えられ、その中に素数がいくつ含まれるか探す
    int n, i;
    cin >> n;
    vector<int> v(n);
    FOR(i, n) cin >> v[i];
    // cout << "サイズ:" << n << endl;

    vector<int> ans;
    // 素数判定
    for(int i=0; i<v.size(); i++){
        if(v[i] < 2) continue;
        bool flag = true; // 素数フラグ
        for(int k=2; k<=sqrt(v[i]); k++){
            if(v[i] % k == 0){ flag = false; break; } // 割り切れてしまったら素数ではない
        }
        if(flag) ans.push_back(v[i]); // 素数フラグがtrueで追加
    }

    // 表示
    // DUMP(ans);
    cout << ans.size() << endl;

    return 0;
}


Measured memory_bytes: 3208
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<class T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<class T>inline auto vec2(class vector<T>::size_type h,class vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}
template<class RandomAccessIterator>inline void psortb(RandomAccessIterator first,RandomAccessIterator last){using P=pair<decltype(first->first),decltype(first->second)>;sort(first,last,[](const P&p1,const P&p2){return p1.second<p2.second||(p1.second==p2.second&&p1.first<p2.first);});}

int main()
{
    ll x=in(),y=in();
    cout<<(y%2==0&&2*x<=y&&y<=4*x?"Yes":"No")<<endl;
}



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

int main() {
  int x1, x2, x3, x4, y1, y2, y3, y4;
  cin >> x1 >> y1 >> x2 >> y2;
  
  int dx = x2 - x1;
  int dy = y2 - y1;
  
  x3 = x2 - dy;
  y3 = y2 + dx;
  x4 = x3 - dx;
  y4 = y3 - dy;
  
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << " " << endl;
  
  return 0;
}

Measured memory_bytes: 256
///
#include <stdio.h>
#include <math.h>
///
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) FOR(i,0,n)
///
typedef long long ll;
///
#define INF 1145141919

///
void swap(int *a, int *b) {
    int t = *b;
    *b = *a;
    *a = t;
}


int selectionSort(int *A, int N) {
    int cnt = 0;
    REP(i, N) {
        int minj = i;
        FOR(j, i, N) {
            if (A[j] < A[minj])
                minj = j;
        }
        if (A[i] != A[minj])cnt++;
        swap(&A[i], &A[minj]);
    }
    return cnt;
}

int N;
int A[10000];

void solver() {
    scanf("%d", &N);
    REP(i, N) scanf("%d", &A[i]);

    int ans = selectionSort(A, N);
    REP(i, N - 1) printf("%d ", A[i]);
    printf("%d\n", A[N - 1]);
    printf("%d\n", ans);
}


int main() {
    solver();
    return 0;
}


Measured memory_bytes: 2080
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

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 (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
ll A[200005], B[200005];
int main() {
    init();
    ll N;
    cin>>N;
    rep(i, N) cin >> A[i] >> B[i];
    sort(A, A + N), sort(B, B + N);

    if(N%2){
        ll a = A[N / 2], b = B[N / 2];
        cout << b - a + 1 << endl;
    }
    else{
        ll a = A[(N - 1) / 2] + A[N / 2], b = B[(N - 1) / 2] + B[N / 2];
        cout << b - a + 1 << endl;
    }
}

Measured memory_bytes: 6752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

int main(){
    ll X, K ,D;
    cin >> X >> K >> D;
    X = abs(X);
    ll count = abs(X / D);
    ll min_1 = X % D;
    ll min_2 = abs(min_1 - D);

    if(count >= K) {
        cout << X - (D * K) << endl;
        return 0;
    }

    else if((K - count) % 2 == 0) {
        cout << min_1 << endl;
        return 0;
    }
    else {
        cout << min_2 << endl;
        return 0;
    }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
int N;
cin >> N;
vector<int> vec(N);
int maxi = 0,count = 0;

cin >> vec.at(0);
for (int i = 1;i < N;i++) {
    cin >> vec.at(i);
    if (vec.at(i-1) >= vec.at(i)) {
        count++;
        if (count > maxi) maxi = count;

    }else {
        count = 0;
    }
}
cout << maxi << endl;

return 0;
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

typedef struct data {
  long B;
  long C;
} DATA;

int comp_C(const void *c1, const void *c2) {
  DATA d1 = *(DATA *)c1;
  DATA d2 = *(DATA *)c2;
  long t1 = d1.C;
  long t2 = d2.C;
  
  return t2 - t1;
}

int compare_long(const void *a, const void *b) {
	return *(long*)a - *(long*)b;
}

int main() {
	long N, M;
  long i, j;
  long A[100001];
  DATA d[100001];
  long b, c;
	long ans = 0;
	
  sl(N); sl(M);
	
  for(i=0;i<N;i++) {
    sl(A[i]);
  }
  qsort((void *)A, N, sizeof(long), compare_long);
  
  for(i=0;i<M;i++) {
    sl(b); sl(c);
    d[i].B = b;
    d[i].C = c;
  }
  qsort((void *)d, M, sizeof(DATA), comp_C);
  
  j = 0;
  b = d[j].B;
  c = d[j].C;
  for(i=0;i<N;i++) {
    if(A[i] < c) {
      A[i] = c;
      b--;
    } else {
      break;
    }
    if(b == 0) {
      j++;
      b = d[j].B;
      c = d[j].C;
    }
  }
  
  for(i=0;i<N;i++) {
    ans += A[i];
  }
  
  pl(ans);
  
	return 0;
}

Measured memory_bytes: 4084
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    r = int(readline())
    print(r * r)
    
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 61124
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;


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




int main() {
	int N, X;
	int x[100000 + 5];
	bool ok = true;
	cin >> N >> X;
	rep(i, N)
		cin >> x[i];


	if (N == 1) {

		cout << abs(x[0] - X);
		return 0;
	}


	int ans = gcd(abs(x[0] - X), abs(x[1] - X));
	rep(i, N-2) {
		ans = gcd(ans, abs(x[i + 2] - X));

	}

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

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

int main()
{
    ll N;cin >> N;
    ll len = 0;
    ll max = 0;
    bool zoro = false;
    bool prev = false;
    bool ok = false;
    rep(i,N) {
        ll D1, D2; cin >> D1 >> D2;
        if (D1 == D2) {
            zoro = true;
            if (prev) {
                len++;
            }
        }
        else {
            zoro = false;
            if (len != 0) {
                if (len >= 2) {
                    ok = true;
                }
            }
            len = 0;
        }
        prev = zoro;
       

    }
    if (len != 0) {
        if (len >= 2) {
            ok = true;
        }
    }
    if (ok) cout << "Yes" << endl;
    else cout << "No" << endl;


}


Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long D){
    string ans = "Christmas";
    D = 25 - D;
    rep(i, D){
        ans = ans + " Eve";
    }
    cout << ans << endl;
}

int main(){
    long long D;
    scanf("%lld",&D);
    solve(D);
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{
    private const long INF = 1000000007;
    public static void Main()
    {
        int[] a = IntLine();
        Console.WriteLine(a.Sum() - a.Max());
    }
}

public class Atcoder
{
    public static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static long LCM(long a, long b)
    {
        long c = a * b;
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static long GCD(long a, long b)
    {
        if (a < b) Swap(ref a, ref b);
        long d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return b;
    }
    public static string StrReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }
    public static string ToConvertBit(int N, int e)
    {
        string ret = "";
        int r = 0;
        while (N != 0)
        {
            r = N % e;
            ret += r.ToString();
            N -= r;
            N /= e;
        }
        ret = StrReverce(ret);
        return ret;
    }
    public static int IntRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static long LongRead()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] LongLine()
    {
        return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
    }
    public static int[] IntLine()
    {
        return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC106C()
{
	string S;
	cin >> S;
	ll K;

	cin >> K;
	--K;
	ll N = 5000000000000000;
	for (int i = 0; i < S.size(); ++i)
	{
		if (S[i] > '1')
		{
			cout << S[i] << endl;
			return;
		}
		if (i == K)
		{
			break;
		}
	}
	cout << '1' << endl;
}

int main()
{
	ABC106C();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
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;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int n,k;cin>>n>>k;
    vint h(n);
    rep(i,n)cin>>h[i];
    sort(all(h));

    int res=INF;
    rep(i,n-k+1){
        chmin(res,h[i+k-1]-h[i]);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3964
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner stdIn=new Scanner(System.in);
        
        
        int [][]a=new int[3][3];
        
        int sum=0;

        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                a[i][j]=stdIn.nextInt();
            }
        }
        int N=stdIn.nextInt();
        int []b=new int[N];
        for(int i=0; i<N; i++){
            b[i]=stdIn.nextInt();
        }
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                for(int k=0; k<N; k++){
                    if(a[i][j]==b[k]){
                        a[i][j]=0;
                    }
                }
            }
        }
        
        for(int i=0; i<3; i++){
            if(a[i][0]==a[i][1]&&a[i][1]==a[i][2]&&a[i][2]==0){
                sum++;
            }
        }
        for(int i=0; i<3; i++){
            if(a[0][i]==a[1][i]&&a[1][i]==a[2][i]&&a[2][i]==0){
                sum++;
            }
        }
        if(a[0][0]==a[1][1]&&a[1][1]==a[2][2]&&a[2][2]==0){
            sum++;
        }
        if(a[2][0]==a[1][1]&&a[1][1]==a[0][2]&&a[0][2]==0){
            sum++;
        }

        if(sum>=1){
            System.out.println("Yes");
            
        }
        else{
            System.out.println("No");
            
        }
        
    }

}

Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9 + 7);

int main(void) {
	string s;
	cin >> s;
	
	if( s[0] == 'R' && s[1] == 'R' && s[2] == 'R' ) {
		cout << 3 << endl;
		return  0;
	} else if( (s[0] == 'R' && s[1] == 'R' && s[2] != 'R') || (s[0] != 'R' && s[1] == 'R' && s[2] == 'R') ) {
		cout << 2 << endl;
		return 0;
	} else if( s[0] == 'R' || s[1] == 'R' || s[2] == 'R' ) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3620
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	auto encode = [](int y,int m,int d){
		return y*12*31+m*31+d;
	};

	int Y,M,D;
	while(cin>>Y){
		cin>>M>>D;

		int E = encode(Y,M,D);

		int Meiji = encode(1868,9,8);
		int Taisho = encode(1912,7,30);
		int Showa = encode(1926,12,25);
		int Heisei = encode(1989,1,8);
		if(E<Meiji){
			out("pre-meiji");
		}
		else if(Meiji<=E && E<Taisho){
			out("meiji",Y-1868+1,M,D);
		}
		else if(Taisho<=E && E<Showa){
			out("taisho",Y-1912+1,M,D);
		}
		else if(Showa<=E && E<Heisei){
			out("showa",Y-1926+1,M,D);
		}
		else if(Heisei<=E){
			out("heisei",Y-1989+1,M,D);
		}
	}
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
#define _cTime (chrono::system_clock::now())
#define progress (chrono::duration_cast<chrono::milliseconds>(_cTime-_sTime).count())
#define reset _sTime=_cTime
auto reset;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	ll mn=0,ans=0;
	cin>>n;
	vl v(n);
	rep(i,n){
		cin>>v[i];
		ll tmp=(v[i]-1)/(mn+1);
		if(tmp)ans+=tmp;
		else chmax(mn,v[i]);
		if(mn==0)mn++;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
import sys
from collections import deque
input = sys.stdin.readline

H, W = map(int, input().split())

m = [list(map(lambda x: 1 if x=="#" else 0, input())) for _ in range(H)]
black = [(i, j, 0) for i in range(H) for j in range(W) if m[i][j] == 1]

# print(m)
# print(black)

queue = deque(black)
queue_append = queue.append
ans = 0
while queue:
    p = queue.popleft()
    if ans < p[2]:
        ans += 1
    for i, j in ((-1, 0), (1, 0), (0, 1), (0, -1)):
        next_p = (p[0] + i, p[1] + j)
        if (0 <= next_p[0] < H) and (0 <= next_p[1] < W):
            if not m[next_p[0]][next_p[1]]:
                m[next_p[0]][next_p[1]] = 1
                queue_append((next_p[0], next_p[1], ans+1))
print(ans)


Measured memory_bytes: 138416
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<stdio.h>
using namespace std;
 
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1<<25
 
typedef pair<int, pair<int, int>> P;
int d[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
 
int main()
{
	int h, w;
	cin >> h >> w;
	char field[h + 1][w + 1];
	int white_count = 0;
	REP(i,1, h + 1) {
		REP(j, 1, w + 1) {
			cin >> field[i][j];
			if (field[i][j] == '.') white_count++;
		}
	}
	queue<P> q;
	q.push(make_pair(1, make_pair(1, 1)));
	field[1][1] = '#';
	int ans = INF;
	while (!q.empty()) {
		P p = q.front();
		q.pop();
		int v = p.first;
		int cx = p.second.second;
		int cy = p.second.first;
		if (cx == w && cy == h) {
			ans = min(ans, v);
			continue;
		}
		rep(i, 4) {
			int dx = cx + d[i][0];
			int dy = cy + d[i][1];
			if (dx > w || dx <= 0 || dy > h || dy <= 0) continue;
			if (field[dy][dx] == '#') continue;
			q.push(make_pair(v + 1, make_pair(dy, dx)));
			field[dy][dx] = '#';
		}
	}
	if (ans == INF) {
		cout << -1 << endl;
	} else {
		cout << white_count - ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

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

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

    for(int i=1; i<n; i++) ans[a[i]-1]++;

    rep(i,n) cout << ans[i] << " ";
    return 0;
}

Measured memory_bytes: 4776
#pragma comment(linker, "/STACK:1000000000")
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <bitset>
#include <memory>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <ctime> 
#include <stack>
#include <iostream>

#define mp make_pair
#define pb push_back

typedef long long ll;
typedef long double ld;

using namespace std;

const int MAXN = 400010;



int a[MAXN], b[MAXN];
int c[MAXN];

int f[MAXN][11];
int main() {
	ios_base::sync_with_stdio(0);
	//freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	int n, m, q;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", a + i, b + i);
	}
	memset(f, 0, sizeof(f));
	c[0] = 0;
	scanf("%d", &q);
	for (int i = 1; i <= q; i++) {
		int v, d;
		scanf("%d%d%d", &v, &d, c + i);
		f[v][d] = i;
	}
	for (int d = 10; d >= 1; d--) {
		for (int i = 1; i <= n; i++) f[i][d - 1] = max(f[i][d - 1], f[i][d]);
		for (int i = 0; i < m; i++) {
			f[a[i]][d - 1] = max(f[a[i]][d - 1], f[b[i]][d]);
			f[b[i]][d - 1] = max(f[b[i]][d - 1], f[a[i]][d]);
		}
	}
	for (int i = 1; i <= n; i++) printf("%d\n", c[f[i][0]]);
	return 0;
}

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

typedef long long ll;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];
    ll ans = 0;
    for (int i = N - 1; i >= 0; i--) {
        ll r = (ans + A[i]) % B[i];
        if (r > 0) ans += B[i] - r;
    }
    cout << ans << "\n";
}

Measured memory_bytes: 4032
#!/usr/bin/env python3
s = input()
a = int(s[: 2])
b = int(s[2 :])
yymm = 1 <= b <= 12
mmyy = 1 <= a <= 12
if yymm and mmyy:
    print('AMBIGUOUS')
elif yymm:
    print('YYMM')
elif mmyy:
    print('MMYY')
else:
    print('NA')


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

int main(){
    int n, y;
    cin >> n >> y;
    int ans10 = -1, ans5 = -1, ans1 = -1;

    for(int i=0; i<=n; i++){
        for(int j=0; j<=n-i; j++){
            int total = 10000*i + 5000*j + 1000*(n-i-j);
            if(total == y){
                ans10 = i;
                ans5 = j;
                ans1 = n-i-j;
            }
        }
    }

    cout << ans10 << " " << ans5 << " " << ans1 << endl;
}

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

using namespace std;
/*******************************************
****************** BY **********************
******* FUTURE GOOGLE EMPLOYEE *************
****** KARTHICK KUPPURAJ M *****************
********************************************/
#define ms(s, n) memset(s, n, sizeof(s))
#define pb push_back
#define pf push_front
#define mp make_pair
#define f first
#define s second
#define prec(n) fixed<<setprecision(n)
#define sll(x) scanf("%lld",&x);
#define pll(x) printf("%lld",x);
#define pn printf("\n");
#define ps printf(" ");
#define pc(c) printf("%c",c);
typedef long long int ll;
#define EPS 1e-9
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x;
    cin >> n>>x;
    cout<<3*(n-__gcd(n,x));
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
inline long long ri(){
	long long t = 0;
	char c;
	while((c=getchar()-48)>=0&&c<10)t=t*10+c;
	return t;
}

int main() {
    int n = ri();
    int ones = n%10;
    if (ones == 2 || ones == 4 || ones ==5 || ones ==7 || ones ==9) {
        cout << "hon" << "\n";
    } else if (ones == 3) {
        cout << "bon" << "\n";
    } else {
        cout << "pon" << "\n";
    }
}

Measured memory_bytes: 3672
import numpy as np

N,K = map(int,input().split())
A = list(map(int,input().split()))
F = list(map(int,input().split()))

Asum = sum(A)

Asort = np.array(sorted(A))
Fsort = np.array(sorted(F,reverse=True))

def test(x):
    res = np.maximum(0,Asort-x//Fsort).sum()
    return res <= K

left = -1
right = 10**13

while left+1 < right:
    mid = (left+right)//2
    if test(mid):
        right = mid
    else:
        left = mid

ans = right

print(ans)


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

using namespace std;
int main(){
    int N,X;
    cin>>N>>X;
     vector<int>L(N+1);
     L.at(0)=0;
    for(int i=0;i<N;i++){
     int D;
     cin>>D;
     L.at(i+1)=L.at(i)+D;
    }
    int ans=0;
    for (int i=0;i<=N;i++){
       if(L.at(i)<=X){
           ans++;
       }
        
    }
    cout<<ans<<endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W; cin >> H >> W;
  int a[510][510];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> a[i][j];
    }
  }
  int count = 0; int r = 0;
  vector<array<int,4>> action;
  int x = 0; int y = 0;
  int nx = 0; int ny = 0;
  while (r < H*W-1) {
    r++;
    if (y % 2 == 0) {
      nx = x + (x != W-1); ny = y + (x == W-1);
    }
    else {
      nx = x - (x != 0); ny = y + (x == 0);
    }
    if (a[y][x] % 2 != 0) {
      count++;
      a[y][x]--; a[ny][nx]++;
      action.push_back({y+1, x+1, ny+1, nx+1});
    }
    x = nx; y = ny;
  }
  cout << count << endl;
  for (int i = 0; i < action.size(); i++) {
    for (int j = 0; j < 4; j++)
    cout << action[i][j] << (j==3 ? '\n' : ' ');
  }
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const double eps=(int)1e-9;
const int mod=1e9+7;
const int N=1e5+9;
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
int32_t main() {
    IOS;
int a,b,c,d;
cin>>a>>b>>c>>d;
a--;
int ans=b/c-a/c;
ans+=b/d-a/d;
int e=lcm(c,d);
ans-=b/e-a/e;
cout<<(b-a)-ans<<endl;
}

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

int main(){

  int n;
  int sum = 0;
  cin >> n;

  int t[n];

  for(int i = 0; i < n; i++){
    cin >> t[i];
    sum += t[i];
  }

  int m;

  cin >> m;

  int p, x;

  for(int i = 0; i < m; i++){
    cin >> p;
    x = t[p - 1];
    cin >> t[p - 1];
    cout << sum - x + t[p - 1] << endl;
    t[p - 1] = x;
  }

  return 0;

}


Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
	int a[7] = {1,3,5,7,8,10,12};
	int b[4] = {4, 6, 9, 11};
	int c = 2;
	int x,y; cin >> x >> y;
	bool res=false;
	if(x==2){
		if(y==2) res=true;
	}else if(find(a,a+7,x)!=end(a)){
		if(find(a,a+7,y)!=end(a))res=true;
	}else if(find(b,b+4,x)!=end(b)){
		if(find(b,b+4,y)!=end(b))res=true;
	}
	if(res) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void fast(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
}
int main(){
	fast();
	int n;
	cin >> n;
	
	vector<vector<int>> counts(10 , vector<int>(10 , 0));
	for(int i = 1; i <= n; ++i){
		int l_d = i % 10;
		int f_d = i;
		while(f_d   >= 10){
			f_d /= 10;
		}
		++counts[f_d][l_d];
	}
	long long answer = 0;
	for(int i = 1; i <= 9; ++i){
		for(int j = 1; j <= 9; ++j){
			answer += (counts[i][j] *1ll* counts[j][i]);
		}
	}
	cout << answer << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <iomanip>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){
    int A,B;
    cin >> A >> B;
    int cnt = 0;
    int sum = 0;
    while(1){
        if(sum + 1 >= B){
            break;
        }
        else{
            cnt++;
            sum+=(A-1);
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int N;
pair<ll,ll> p[300010];

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>N;
	rep(i,N)cin>>p[i].sec>>p[i].fir;
	sort(p,p+N);
	reverse(p,p+N);
	ll lo=-1,hi=N+1;
	while(lo+1<hi){
		ll M=(lo+hi)/2;
		multiset<ll> S;
		multiset<ll>::ite it;
		ll sum=0;
		rep(i,M){
			S.insert(p[i].sec);
			sum+=p[i].sec;
		}
		int ok=0;
		rep(i,N-M+1){
			if(sum<=p[i+M-1].fir*M){
				ok=1;break;
			}
			if(i==N-M)break;
			S.insert(p[i+M].sec);
			sum+=p[i+M].sec;
			it=S.lower_bound(*S.rbegin());
			sum-=*it;
			S.erase(it);
		}
		if(ok)lo=M;
		else hi=M;
	}
	cout<<lo<<endl;
}

Measured memory_bytes: 19848
import java.util.*;
 
public class Main{
	public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
		int A = scan.nextInt();
      	int B = scan.nextInt();
      	int X = scan.nextInt();
      	if(X - A < 0 || X - A > B){
        	System.out.print("NO");
        }
      	else{
        	System.out.print("YES");
        }
    }
 
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n,mi=1e12;
    cin>>n;
    for(ll i=1;i<=sqrt(n);i++){
        if(n%i==0) mi=min((n/i+i)-2,mi);
    }
    
    cout<<mi<<endl;
}

Measured memory_bytes: 256