akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define mod 1000000007
int H, W, K, fact[300000], inv[300000], factinv[300000];
int ncr(int n, int r) { return (n - r >= 0 && r >= 0) ? 1LL * fact[n] * factinv[r] % mod * factinv[n - r] % mod : 0; }
int cal(int a, int b) { return (ncr(a + b, b) - ncr(a + b, b - 1) + mod) % mod; }
int main() {
	scanf("%d%d%d", &H, &W, &K);
	fact[0] = 1;
	for (int i = 1; i < 300000; i++) fact[i] = 1LL * fact[i - 1] * i % mod;
	inv[1] = 1;
	for (int i = 2; i < 300000; i++) inv[i] = 1LL * inv[mod % i] * (mod - mod / i) % mod;
	factinv[0] = 1;
	for (int i = 1; i < 300000; i++) factinv[i] = 1LL * factinv[i - 1] * inv[i] % mod;
	int ret = 0;
	for (int i = 0; i <= K; i++) {
		int tx = i;
		int ty = K - i;
		int re1 = cal(W + tx, tx);
		int re2 = cal(H + ty, ty);
		int res = 1LL * re1 * re2 % mod * ncr(H + W + 2 * K, W + 2 * tx) % mod;
		ret = (ret + res) % mod;
	}
	printf("%d\n", ret);
	return 0;
}

Measured memory_bytes: 6260
/** 
 *                                                                   
 *   |    |                        ,   .              ,--.,--.,--.,--.
 *   |    |    ,---..    ,,---.    |   |,---..   .      -||  ||  ||  |
 *   |    |    |   | \  / |---'    `---'|   ||   |       ||  ||  ||  |
 *   `    `---'`---'  `'  `---'      |  `---'`---'    `--'`--'`--'`--'
 *                                   `                                
**/
#include <bits/stdc++.h>
using namespace std;

int n, a[100005][3], dp[100005][3];

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

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

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

	dp[0][0] = dp[0][1] = dp[0][2] = 0;
	for (int i = 1; i <= n; i++) {
		dp[i][0] = a[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
		dp[i][1] = a[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
		dp[i][2] = a[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
	}

	cout << max(dp[n][0], max(dp[n][1], dp[n][2])) << '\n';

	return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//



int main(void) {

    ll N, K; cin >> N >> K;
    bool flag[N+1];
    rep(i,N+1) {
        flag[i] = false;
    }
    rep(i,K) {
        int d; cin >> d;
        rep(j,d) {
            int a; cin >> a;
            flag[a] = true;
        }
    }
    ll ans = 0;
    for (int i = 1; i <= N; ++i) {
        if (!flag[i]) ++ ans;
    }
    out(ans);
    



    
    
    return 0;
}











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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    string s;
    int k;
    cin >> s >> k;

    REP(i, s.size()){
        if(s[i] != 'a' && 'z' - s[i] + 1 <= k){
            k -= 'z' - s[i] + 1;
            s[i] = 'a';
        }
    }
    
    s.back() = 'a' + (s.back() - 'a' + k) % 26;

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 512
# coding:utf-8
n = int(input())
h = list(map(int, input().split()))
counter = 0

for i in range(n):
    #print(h[0:i+1])
    h_max = max(h[0:i+1])
    if (h[i] >= h_max) and (h[i] >= h[0]):
        #print(h[i])
        counter += 1
print(counter)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

char m[505][505];
int h, w;

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

vector<pair<pair<int, int>,char>> extends(int y, int x){
    vector<pair<pair<int,int>,char>> ret;
    rep(i,4){
        int ny = y, nx = x;
        while(true){
            ny += dy[i];
            nx += dx[i];
            if(ny < 0 || ny >= h || nx < 0 || nx >= w) break;
            if(m[ny][nx] != '.'){
                ret.emplace_back(make_pair(make_pair(ny,nx),m[ny][nx]));
                break;
            }
        }
    }
    return ret;
}

void compress(vector<int> &v) {
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}

int lb(vector<int> v, int num){
    return lower_bound(all(v), num) - v.begin();
}

int main(){
    cin >> h >> w;

    vector<pair<pair<int, int>,char>> v;
    vector<int> x,y;
    rep(i,h){
        rep(j,w){
            char c;
            cin >> c;
            m[i][j] = c;
            if(c != '.'){
                v.emplace_back(make_pair(make_pair(i,j),c));
                y.emplace_back(i);
                x.emplace_back(j);
            }
        }
    }
    //compress(x);
    //compress(y);
    //h = y.size();
    //w = x.size();

    //rep(i,h + 1) rep(j,w + 1) m[i][j] = '.';
    //rep(i,v.size()){
    //    int fy = lb(y,v[i].first.first);
    //    int fx = lb(x,v[i].first.second);
    //    m[fy][fx] = v[i].second;
    //}
    //cout << endl; rep(i,h){ rep(j,w){ cout << m[i][j]; } cout << endl; } cout << endl;

    bool f = true;
    int cnt = 0;
    while(f){
        f = false;
        rep(i,h){
            rep(j,w){
                vector<pair<pair<int, int>,char>> v;
                if(m[i][j] == '.') v = extends(i,j);
                rep(i,v.size()){
                    rep(j,v.size()){
                        if(i == j) continue;
                        if(v[i].second == v[j].second){
                            if(m[ v[i].first.first ][ v[i].first.second ] == '.') continue;
                            m[ v[i].first.first ][ v[i].first.second ] = '.';
                            m[ v[j].first.first ][ v[j].first.second ] = '.';
                            f = true;
                            cnt++;
                        }
                    }
                }
            }
        }
    }
    cout << cnt * 2 << endl;
}

Measured memory_bytes: 3408
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();
        if (a >= 10 || b >= 10) {
            System.out.println(-1);
        } else {
            System.out.println(a * b);
        }
    }

}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
int x, p;
int main() {
    DAU
    cin >> x >> p;
    if (x * 500 >= p)
        cout << "Yes";
    else cout << "No";
    PLEC
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX;
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;



int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
	
	int i;
	string s;
	cin>>s;
	for(i=s.length()-2;i>=0;i--){
		if(s[i]=='S'&&s[i+1]=='T'){
			s=s.erase(i,2);
		}
	}
	cout<<s.length()<<endl;
	
//////////////////////////////////////////////////////
	return 0;
}


Measured memory_bytes: 720
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;
bool my_compare(pair<ll, ll> a, pair<ll , ll> b) {
    // 基本はfirstで比較
    if(a.first != b.first){
         return a.first < b.first; // 昇順
        //return a.first > b.first; // 降順
    }

    // それ以外はsecondで比較
    if(a.second != b.second){
        return a.second > b.second;
    }else{
        // どちらも同じ
        return true;
    }
}

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

    ll a,b,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str,sub;
    ll h,w;
    string str1;
    cin>>str;
    cin>>str1;
    if(str1==str){
        Yes;
        return 0;
    }
    rep(i,str.length()){
        char c=str[str.length()-1];
        for(ll j=str.length()-2;j>=0;j--){
            str[j+1]=str[j];
        }
        str[0]=c;
        //cout<<str<<endl;
            if(str==str1){
            Yes;
            return 0;
        }
    }
     No;


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;

int N, D, X[11][11];

int main() {
    cin >> N >> D;
    rep(i, N) {
        rep(j, D) {
            cin >> X[i][j];
        }
    }

    int ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int sqdist = 0;
            for (int k = 0; k < D; k++) {
                int diff = X[i][k] - X[j][k];
                sqdist += diff * diff;
            }

            // check
            bool flg = false;
            for (int n = 1; n * n <= sqdist; n++) {
                if (sqdist == n * n) {
                    flg = true;
                }
            }
            if (flg) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    long long A;
    long long B;
    long long K;
    long long J;
    scanf("%lld%lld%lld",&A,&B,&K);

    if(A==K){
        printf("%lld %lld",A=0,B);
    }
    else if(A+B==K){
        printf("%lld %lld",A=0,B=0);
    }
     else if(A+B<K){
        printf("%lld %lld",A=0,B=0);
   }
    else if(A>K){
         printf("%lld %lld",A-K,B);
    }
   else if(A<K){
    J=K-A;
    B=B-J;
     printf("%lld %lld",A=0,B);
   }
   else if(A+B<K){

   }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
int main(int argc, char** argv) {
	int n,max=0,min=999999999,x=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{scanf("%d",&x);
	if(max<x)max = x;
	if(min>x)min = x;
}
cout<<max-min;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] a){
			Scanner input = new Scanner(System.in);
			String OrigWord = input.nextLine();
			int OrigLen = OrigWord.length(); 
			String NewWord = "";
			for (int x=OrigLen-1; x >= 0; x--){
				
				NewWord = NewWord + (OrigWord.charAt(x)); 
				
			}
						
			System.out.println(NewWord);
		    input.close();
	}

}

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



int main(){
    int n , m ;
    cin >> n >> m ;
    vector<int> dist(n,1e7) ;
    vector<int> dista[n] ;
    vector<int> G[n] ;
    rep(i,m){
        int a , b ;
        cin >> a >>b ;
        a-- ;b-- ;
        G[a].push_back(b) ;
        G[b].push_back(a) ;
    }
    queue<int> H ;
    auto update =[&](int i , int x){
            if(dist[i] != 1e7) return ;
            dist[i] = x ;
            dista[x].push_back(i);
            H.push(i) ;
    } ;
    update(0,0) ;
    while(!H.empty()){
            int i = H.front() ;
            H.pop() ;
            for(auto p : G[i]){
                update(p,dist[i]+1) ;
            }
    }
    rep(i,n){ if(dist[i] == 1e7){
        cout << "No" << endl;
        return 0 ;
    }
    }
    cout <<"Yes" << endl;
    //rep(i,n-1) cout << dist[i+1] << endl;
    rep(i,n-1){
        int count = 0 ;
        if(dist[i+1] == 1 ){
            cout << 1 << endl;
            continue ;
        }
        else{
            for(auto p : G[i+1] ){
             if(dist[p]+1 == dist[i+1]&& count == 0 ){
                cout << p+1 << endl;
                count++ ;
             } 
        }
        }
    }
}

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

int main(void) {
	int a, b, c, x; cin >> a >> b >> c >> x;
	int i, j, k, sum = 0;

	for (i = 0; i <= a; i++) {
		for (j = 0; j <= b; j++) {
			for (k = 0; k <= c; k++) {
				if (i * 500 + j * 100 + k * 50 == x) {
					sum += 1;
				}
			}
		}
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a;
    vector<lli> v;
    cin >> n;
    vector<vector<lli>> men;
    men.resize(n + 2);
    lli mod = 1e9 + 7;

    fr(i, 0, n) {
        fr(j, 0, n) {
            cin >> a;
            if (a == 1) {
                men[j].pb(i);
            }
        }
    }

    vector<vector<lli>> dp(1 << n, vector<lli>(n + 2, 0));

    fr(i, 0, men[0].size()) {
        a = men[0][i];
        dp[1 << a][0] = 1;
    }

    for (lli mask = 1; mask < (1 << n); mask++) {
        lli c = -1;
        lli temp = mask;
        while (temp > 0) {
            if (temp % 2 == 1) {
                c++;
            }
            temp /= 2;
        }
        if (c == 0) {
            continue;
        }
        for (lli j = 0; j < men[c].size(); j++) {
            a = men[c][j];
            if ((mask & (1 << a)) != 0) {
                lli p = 1 << n;
                --p;
                p = p ^ (1 << a);
                dp[mask][c] += dp[mask & p][c - 1];
                dp[mask][c] %= mod;
            }
        }
    }

    lli ans = 0;
    for (lli mask = 1; mask < (1 << n); mask++) {
        ans += dp[mask][n - 1];
        ans %= mod;
    }

    cout << ans << endl;
    rt;
}


Measured memory_bytes: 442624
#include<stdio.h>
int main()
{
	int a,b,c;
	1<=a<=100;
	1<=b<=100;
	1<=c<=100;
	scanf("%d%d%d",&a,&b,&c);
	if(b-a==c-b)
	printf("YES");
	else
	printf("NO");
	return 0;
} 

Measured memory_bytes: 128
X=int(input())
def sosuhantei(n):
    for i in range(2,n):
        if n%i==0:
            return 0
    return 1

if X==2:
    print(2)
    exit()

while True:
    if sosuhantei(X)==1:
        print(X)
        break
    X+=1

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

int main(){
    int n,m;    cin >> n >> m;
    vector<int>h(n);
    rep(i, n)   cin >> h[i];
    vector<vector<int>>G(n);
    rep(i, m){
        int a,b;    cin >> a >> b;
        --a;    --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    int ans = 0;
    rep(i, n){
        int num = 0;
        rep(j, G[i].size()){
            int next = G[i][j];
            if(h[i] > h[next])  num++;
        }
        if(num == G[i].size())  ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 8752
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
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; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

ll n, k;
V< V<int> > edges;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    edges.resize(n);
    for (ll i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b;
        a--, b--;
        edges[a].emplace_back(b);
        edges[b].emplace_back(a);
    }

    ll ans = HIGHINF;
    if (k & 1) {
        for (ll i = 0; i < n; i++) {
            for (int j: edges[i]) {
                vll d(n, HIGHINF); d[i] = 0, d[j] = 0;
                queue<int> que; que.push(i), que.push(j);
                while (!que.empty()) {
                    int q = que.front(); que.pop();
                    for (int e: edges[q]) {
                        if (d[e] > d[q] + 1) {
                            d[e] = d[q] + 1;
                            que.push(e);
                        }
                    }
                }

                ll tmp = 0;
                for (ll i = 0; i < n; i++) {
                    if (d[i] > k / 2) tmp++;
                }
                chmin(ans, tmp);
            }
        }
    } else {
        for (ll i = 0; i < n; i++) {
            vll d(n, HIGHINF); d[i] = 0;
            queue<int> que; que.push(i);
            while (!que.empty()) {
                int q = que.front(); que.pop();
                for (int e: edges[q]) {
                    if (d[e] > d[q] + 1) {
                        d[e] = d[q] + 1;
                        que.push(e);
                    }
                }
            }

            ll tmp = 0;
            for (ll i = 0; i < n; i++) {
                if (d[i] > k / 2) tmp++;
            }
            chmin(ans, tmp);
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 384
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def main():
    N=int(input())
    ary = list(map(int,input().split()))
    ans = ary[0]
    for elem in ary:
        ans = gcd(ans,elem)
    print(ans)

if __name__=='__main__':
    main()

Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

ll dp[110][100010];
ll sum[110][100010];

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

    for(int i=0; i<=a[0]; i++){
        dp[1][i] = 1;
        sum[1][i+1] = sum[1][i] + dp[1][i]; 
    }

    ll ub=a[0];
    for(int i=1; i<n; i++){
        for(ll j=0; j<=100000; j++){

            dp[i+1][j] += (sum[i][min(j+1, ub+1)] - sum[i][max(0LL, j-a[i])]);
            dp[i+1][j] %= MOD;

            sum[i+1][j+1] = sum[i+1][j] + dp[i+1][j];

        }
        ub += a[i];
    }
    
    cout << dp[n][k] << endl;
}

Measured memory_bytes: 159232
def main():
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    L = [int(i) for i in input().split()]
    L.sort()

    def is_ok(i, j, k):
        if L[j]+L[k] > L[i]:
            return True
        else:
            return False

    def binary_search_meguru(i, j):
        ng = -1
        ok = j
        while abs(ok - ng) > 1:
            mid = ng + (ok - ng) // 2
            if is_ok(i, j, mid):
                ok = mid
            else:
                ng = mid
        return ok
    ans = 0
    for i in range(2, N):
        # i番目を最長辺とする
        for j in range(i):
            k = binary_search_meguru(i, j)
            # print(i, j, k)
            ans += j-k
    print(ans)


if __name__ == '__main__':
    main()


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

public class AtCoderE
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] s = Console.ReadLine().ToArray();

        BinaryIndexedTree[] counts = new BinaryIndexedTree[26];
        for (int i = 0; i < 26; i++)
        {
            counts[i] = new BinaryIndexedTree(n);
        }
        for (int i = 0; i < n; i++)
        {
            int num = StringToInt(s[i]);
            counts[num].Add(i + 1, 1);
        }

        int q = int.Parse(Console.ReadLine());
        for (int i = 0; i < q; i++)
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            int a = int.Parse(words[0]);
            if (a == 1)
            {
                int pos = int.Parse(words[1]);
                char c = s[pos - 1];
                int before = StringToInt(c);
                int after = StringToInt(words[2][0]);
                counts[before].Add(pos, -1);
                counts[after].Add(pos, 1);
                s[pos - 1] = words[2][0];
            }
            else
            {
                int b = int.Parse(words[1]);
                int c = int.Parse(words[2]);
                int count = 0;
                for (int j = 0; j < 26; j++)
                {
                    if (counts[j].Sum(b, c) > 0) count++;
                }
                Console.WriteLine(count);
            }
        }
    }

    private static int StringToInt(char c)
    {
        return c - 'a';
    }

    class BinaryIndexedTree
    {
        public int N { get; set; }
        public long[] Array { get; set; }
        public BinaryIndexedTree(int n)
        {
            this.N = n;
            this.Array = new long[N + 1];
        }
        public void Add(int index, long value)
        {
            while (index <= this.N)
            {
                this.Array[index] += value;
                index += index & (-index);
            }
        }
        public long Sum(int l, int r)
        {
            return this.Sum(r) - this.Sum(l - 1);
        }
        public long Sum(int index)
        {
            var sum = 0L;
            while (index > 0)
            {
                sum += this.Array[index];
                index -= index & (-index);
            }
            return sum;
        }
    }
}

Measured memory_bytes: 117756
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <iomanip>
#include <typeinfo>
#include <iterator>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <set>
using namespace std;


typedef long long       ll;
struct edge { ll to; ll cost; };
typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<string>  vs;
typedef vector<char>    vc;
typedef vector<edge>    ve;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;
typedef vector<vll>		vvll;
typedef vector<ve>      vve;
typedef vector<vc>		vvc;

// マクロ
#define repr(itr, bgn, end) for (ll itr = (ll)bgn; itr < (ll)end; ++itr)
#define rep(itr, end) repr(itr, 0, end)
#define reprrev(itr, bgn, end) for (ll itr = (ll)end - 1; itr >= (ll)bgn; --i)
#define reprev(itr, end) reprrev(itr, 0, end)
#define all(container) container.begin(), container.end()
#define sortall(container) sort(all(container))
#define yn(cond) cond ? (cout << "Yes" << endl) : (cout << "No" << endl)
#define YN(cond) cond ? (cout << "YES" << endl) : (cout << "NO" << endl)

// 定数
#define LLONG_MAX 9223372036854775807
constexpr double PI = 3.14159265358979323846;
constexpr ll INF = 1 << 15;
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-7;

// よく使うもの
constexpr int dy[4] = { 0, 1, 0, -1 };
constexpr int dx[4] = { 1, 0, -1, 0 };


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (T& x : vec) os << x << " ";
	return os;
}

// ***<ここから>****************************************************************



int main(void) {

	string S;
	ll K;
	cin >> S >> K;

	int cnt = 0;
	rep(i, S.length()) {
		if (S[i] != '1') break;
		cnt++;
	}

	if (K <= cnt) {
		cout << 1 << endl;
	}
	else {
		rep(i, S.length()) {
			if (S[i] != '1') {
				cout << S[i] << endl;
				break;
			}
		}
	}

	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define vi vector<int>
#define printv(v) for(int i = 0;i < v.size();i++)P(v[i]);
#define printt(a,b) cout << a << " " << b << endl; 
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0};
int dy[] = { 0,  0,  1, -1};
int MOD = 1e9 + 7;

void solve() {
    string s;
    ll k;
    cin >> s >> k;
    rep(i,s.length()){
        if(s[i] == '1'){
            k--;
        }else{
            P(s[i]);
            return;
        }
        if(k == 0){
            P(1);
            return;
        }
    }
}

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


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int ans = 0;
        for (int i = 1; i <= 5; i++) {
            int x = sc.nextInt();
            if (x == 0) ans = i;
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 35804
import collections
import sys

S1 = collections.deque()
S2 = collections.deque()
S3 = collections.deque()

for i, j in enumerate(sys.stdin.readline()):
    if j == '\\':
        S1.append(i)
    elif j == '/':
        if S1:
            left_edge = S1.pop()
            new_puddle = i - left_edge
            while S2 and (S2[-1] > left_edge):
                if S2[-1] > left_edge:
                    S2.pop()
                    new_puddle += S3.pop()
            S2.append(left_edge)
            S3.append(new_puddle)
        else:
            pass


print(sum(S3))

print(len(S3), *S3)

Measured memory_bytes: 8396
N = int(input())
H = list(map(int,input().split()))

for i in range(N-1):
  if (H[N-2-i] - 1) == H[N-1-i]:
    H[N-2-i] -= 1
  elif (H[N-2-i] - 1) < H[N-1-i]:
    pass
  else:
    print('No')
    break
else:
  print('Yes')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    ll N,M; cin >> N >> M;
    if(M < N*2) cout << M/2 << "\n";
    else cout << (N + (M-2*N)/4) << "\n";
    //cout << (flag?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr ll inf = LLONG_MAX;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */

int main() {
    int n;
    cin >> n;
    int a = n/100;
    int b = n%100;
    if(a>=1&&a<=12 && b>=1&&b<=12) cout << "AMBIGUOUS" << endl;
    else if(b>=1&&b<=12) cout << "YYMM" << endl;
    else if(a>=1&&a<=12) cout << "MMYY" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 3540
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int n;
  cin >> n;

  pr("ABC" << n);


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define FOR(i,n) for(int i = 0;i<n ;i++)
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define pb push_back
#define MOD 1e9+7
#define INF 0x3f3f3f3f
#define print(x) cout<<x<<"\n";

//#include<boost/multiprecision/cpp_int.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//(Uncomment when needed and be sure it not give TLE bcoz it requires time)
//#pragma GCC optimize "trapv"//to check integer overflow and gives RE.
//typedef tree<pair<int,int>,null_type, 
//less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>   ordered_set;
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("O3")
//uncoment for large int requirement
//using boost::multiprecision::cpp_int;
//using namespace _gnu_pbds;

using namespace std;

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
//use it with unordered_map<T,T,custom_hash> safe_map

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

int main()
{fast_io

int t;
//cin>>t;
t = 1;
while(t--)
{
ll x,k,d;
cin>>x>>k>>d;
x = abs(x);
//x smaller absolute value
ll one = (x/d);
if(one>k){
    x = x- k*d;
    cout<<x<<endl;
}
else 
{
    x = x- one*d;
    k-=one;
    if(k>0){
        if(k==1)
        cout<<min(abs(x-d),abs(x+d));
        else 
        {
            if(k&1){
                cout<<min(abs(x-d),abs(x+d));
            }
            else {
                cout<<x<<endl;
            }
        }
        //cout<<min(abs(x-d),x)<<endl;
    }
    else 
    cout<<x<<endl;
}
}
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <assert.h>
#include <numeric>
#include <iomanip>
#define rep(i, a, b) for (int(i) = (a); i < (b); i++)
using namespace std;

using ll = long long;

typedef pair<int, int> P;

const int INF = 100000000;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll MOD = 1000000007;

ll pow_mod(ll x, ll y, ll mod)
{
	ll ans=1;
	for(;y>0;y>>=1){
		if(y&1)(ans*=x)%=mod;
		(x*=x)%=mod;
	}
	return ans;
}

int n;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	//問題文中の添え字が0-indexか1-indexか確認!
	cin >> n;
	vector<int> d(n);
	rep(i, 0, n) cin >> d[i];
	sort(d.begin(), d.end(),greater<int>());
	cout << d[(n / 2) - 1] - d[n / 2];
	return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(void){
	int n,i,j,d1,d2,temp,max;
	int ind[10001];
	int dist[10001];
	
	while(scanf("%d",&n)){
		if(n==0)
		break;
		for(i=0;i<n;i++){
			scanf("%d %d %d",&ind[i],&d1,&d2);
			dist[i] = d1+d2;
		}
		temp = 0;
		for(i=0;i<n;i++){
			if(temp<dist[i]){
				temp=dist[i];
				max = i;
			}
		}
		printf("%d %d\n",ind[max],dist[max]);
	}
	return 0;
}

Measured memory_bytes: 680
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	ll x, y;
	cin >> x >> y;
	int ans = 0;
	for(ll i = x; i <= y; i *= 2){
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  StdIn.readLine

  Iterator.continually(StdIn.readLine)
    .takeWhile(_ != null)
    .filter(_.contains('#'))
    .map(_.toCharArray)
    .toArray
    .transpose
    .filter(_.contains('#'))
    .transpose
    .toArray
    .foreach(ch => println(ch.mkString))
}

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

ll cnt[200005];

int main(){
	
    ll n, k; cin >> n >> k;
    if(k%2 == 1){
        ll aux = n/k;
        cout << aux*aux*aux << endl;
    }
    else{
        ll aux = n/k;
        ll sum = aux*aux*aux;
        for(int i = 1; i <= n; i++)
            cnt[i%k]++;
        sum += cnt[k/2]*cnt[k/2]*cnt[k/2];
        cout << sum << endl;
    }
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
vector<long long> a;
pair<long long, long long> fnc (int l, int r) {
  long long sum = a[r] - a[l];
  int i = lower_bound(a.begin() + l, a.begin() + r, a[l] + ((sum + 1) >> 1)) - a.begin();
  long long maxv = min(a[i] - a[l], sum - a[i - 1] + a[l]);
  long long minv = sum - maxv;
  return {maxv, minv};
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  a.resize(n + 1);
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[i] += a[i - 1];
  }
  long long minv = 9e18;
  for (int q = 2; q <= n - 2; q++) {
    auto x = fnc(0, q);
    auto y = fnc(q, n);
    minv = min(minv, max(x.first, y.first) - min(x.second, y.second));
  }
  cout << minv << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(void)
{
	int H = 1, W = 1, i, j;

	while (1)
	{
		scanf("%d %d", &H, &W);

		if ((H == 0) && (W == 0)) break;

		for (i = 0; i < H; i++)
		{
			for (j = 0; j < W; j++)
			{
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<iostream>
#include<vector>
using namespace std;
int n, m;
int ans = 0;

int solve(vector<int>a, vector<int>b, vector<int>tmp, int deep) {
	if (deep + 1 == n) {
		ans++;
		return 0;
	}
	for (int i = 0;i < m;i++) {
		if (a[i] == tmp[deep]) {
			for (int j = 0;j <= deep;j++) {
				if (tmp[j] == b[i]) {
					break;
				}
				if (j == deep) {
					tmp[deep + 1] = b[i];
					solve(a, b, tmp, deep + 1);
				}
			}
		}
		if (b[i] == tmp[deep]) {
			for (int j = 0;j <= deep;j++) {
				if (tmp[j] == a[i]) {
					break;
				}
				if (j == deep) {
					tmp[deep + 1] = a[i];
					solve(a, b, tmp, deep + 1);
				}
			}
		}
	}
	return 0;
}

int main() {
	cin >> n >> m;
	vector<int>tmp(2 * n);
	vector<int>a(2 * m);
	vector<int>b(2 * m);
	for (int i = 0;i < m;i++) {
		cin >> a[i] >> b[i];
	}
	tmp[0] = 1;
	solve(a, b, tmp, 0);
	cout << ans << endl;
	return 0;
}

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

typedef long long int ll;
const int mod = 1e9+7;
const ll inf = 1e18;
const double pi = 3.1415926535897932384626;

ll mpow(ll a,ll b){
    ll res=1;
    //a%=mod;
    while(b){
    	if(b%2) res=res*a; //%mod;
		a=a*a; //%mod;
		b/=2;
	}
	return res;
}

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

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

void solve(){
	//code
	int n;
	cin>>n;
	int d[n];
	for(int i=0;i<n;i++)
		cin>>d[i];
		
	int count=0;	
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			count+=(d[i]*d[j]);
		}
	}
	cout<<count;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	solve();
 	return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll X, N;
  cin >> X >> N;
  if(N == 0){
    cout << X << endl;
    return 0;
  }

  set<ll> se;
  for(int i = 0; i < N; i++){
    ll p;
    cin >> p;
    se.insert(p);
  }
  ll ans = INF;
  for(int i = 0; i < 10000; i++){
    ll tmp = X - i;
    if(!se.count(tmp)){
      cout << tmp << endl;
      return 0;
    }
    ll tmp2 = X + i;
    if(!se.count(tmp2)){
      cout << tmp2 << endl;
      return 0;
    }
  }
}

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

using namespace std;
#define inf 1000000000
#define unvisited -1
#define visited 1
#define eps 1e-9
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)
#define uint64 unsigned long long
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;

int main(){
	int n;
	scanf("%d",&n);
	double bil = sqrt(n);
	int angka = floor(bil);
	printf("%d\n",angka*angka);
	return 0;
};

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>

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

int main() {
	int x;
	cin >> x;

	rep(i, x) {
		int lef = 100 * i;
		int rig = 105 * i;

		if (lef <= x && x <= rig) {
			cout << 1 << endl;
			return 0;
		}
	}

	cout << 0 << endl;


	return 0;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

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



int main()
{
    int h[2], s[2];
    for (int t = 0; t < 2; ++t)
        cin >> h[t] >> s[t];

    for (int it = 0; ; it ^= 1) {
        h[it ^ 1] -= s[it];
        if (h[it ^ 1] <= 0) {
            it == 0 ? cout << "Yes\n" : cout << "No\n";
            return 0;
        }
    }
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <stdio.h>

int main(){
  long long a=100,i,x;
  std::cin >> x;
  for(i=0;a<x;i++){
    a=a+a/100;
  }
  std::cout << i;
}

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

int solve(int n ,  int dp[] , int h[] , int k )
{
	int c = 999999999;
	if(dp[n] != -1) return dp[n];
  	if(n == 1) return dp[n] = abs(h[1] - h[0]);
  	if(n == 0) return dp[n] = 0 ;
  	else 
    {
    	for(int i = 1 ; i<= k ; i++){
      		if(n-i >= 0)
      		c = min(abs(h[n-i] - h[n]) + solve(n-i , dp , h , k ) , c);
      	}
      		return dp[n] = c ;
    }
}



int32_t main()
{






  	int n , k;
  	cin>>n>>k;
  	int i;
  	int h[n];
  	int dp[n];
  	memset(dp , -1 , sizeof(dp));
  	for(i=0;i<n;i++) cin>>h[i];
  	int ans = solve(n-1  , dp ,  h , k );
  	cout<<ans<<endl;
  	return 0; 
  	

	

}	

Measured memory_bytes: 13684
/**
*    author:  Dooloper
*    created: 29.08.2020 21:04:09
**/

#pragma region Macros
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
using P = pair<int,int>;
using ll = long long;

#define rep(i,n) for(int i = 0; i < (n); i++)
#define repn(i,n) for(int i = 1; i <= (n); i++)
#define pb push_back
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

const double PI = acos(-1);
const int mod = 1000000007;
class mint {
   long long x;
public:
   mint(long long x=0) : x((x%mod+mod)%mod) {}
   mint operator-() const {
     return mint(-x);
   }
   mint& operator+=(const mint& a) {
       if ((x += a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator-=(const mint& a) {
       if ((x += mod-a.x) >= mod) x -= mod;
       return *this;
   }
   mint& operator*=(const  mint& a) {
       (x *= a.x) %= mod;
       return *this;
   }
   mint operator+(const mint& a) const {
       mint res(*this);
       return res+=a;
   }
   mint operator-(const mint& a) const {
       mint res(*this);
       return res-=a;
   }
   mint operator*(const mint& a) const {
       mint res(*this);
       return res*=a;
   }
   mint pow(ll t) const {
       if (!t) return 1;
       mint a = pow(t>>1);
       a *= a;
       return a;
   }
   // for prime mod
   mint inv() const {
       return pow(mod-2);
   }
   mint& operator/=(const mint& a) {
       return (*this) *= a.inv();
   }
   mint operator/(const mint& a) const {
       mint res(*this);
       return res/=a;
   }

   friend ostream& operator<<(ostream& os, const mint& m){
       os << m.x;
       return os;
   }
};
#pragma endregion

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n);
  mint ans = 0;
  vector<mint> sum(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    if(i == 0) sum[0] = a[0];
    else{
      sum[i] = sum[i-1] + a[i];
    }
  }
  for(int i = 1; i < n; i++){
    ans += sum[i-1]*a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5580
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n;
    vector<ii> ar;
    for (int ctr1 = 0; ctr1 < n; ++ctr1)
        cin >> t, ar.push_back(make_pair(t, ctr1));

    sort(ar.begin(), ar.end());
    reverse(ar.begin(), ar.end());

    set<int> larger, smaller;
    ll rez = 0;
    for (auto nxt : ar) {
        auto up = larger.upper_bound(nxt.second);
        auto down = smaller.upper_bound(-nxt.second);
        if (up != larger.end()) {
            auto it = up;
            ++it;
            int up_two = (it == larger.end() ? n : *it);
            int down_two = -(down == smaller.end() ? 1 : *down);
            rez += 1LL * nxt.first * (up_two - *up) * (nxt.second - down_two);
        }

        if (down != smaller.end()) {
            auto it = down;
            ++it;
            int down_two = (it == smaller.end() ? 1 : *it);
            int up_two = (up == larger.end() ? n : *up);
            rez += 1LL * nxt.first * (up_two - nxt.second) * (down_two - *down);
        }
        larger.insert(nxt.second);
        smaller.insert(-nxt.second);
    }
    cout << rez << "\n";
    return 0;
}

Measured memory_bytes: 10356