akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	void run() {
		long dp[][] = new long[10][1001];
		dp[0][0] = 1;
		for (int i = 0; i <= 100; i++) {
			for (int j = 8; j >= 0; j--) {
				for (int k = 0; k <= 1000; k++) {
					if (k + i <= 1000) dp[j + 1][k + i] += dp[j][k];
				}
			}
		}
		for (;;) {
			int n = sc.nextInt();
			int s = sc.nextInt();
			if ((n | s) == 0) return;
			System.out.println(dp[n][s]);
		}
	}

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

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

int main() {
	std::vector<std::string> v;
	std::string answer;

	v.resize(3);


	for (auto&& x : v) {
		std::cin >> x;
	}

	for (int i = 0; i < 3; i++) {
		answer+= v[i].substr(0, 1);
	}

	std::transform(answer.begin(), answer.end(), answer.begin(), toupper);

	std::cout << answer << std::endl;

	return 0;
}

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

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(i*m+j*n-2*i*j==k){
        cout<<"Yes"<<endl;
        return 0;
      }
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
    int h[10];
    for(int i=0;i<10;i++)scanf("%d",&h[i]);


    for(int i=0;i<10;i++)
        for(int j=i+1;j<10;j++)
        {
            if(h[i]<h[j])
            {
                int box=h[j];
                h[j]=h[i];
                h[i]=box;
            }
        }


    for(int i=0;i<3;i++)printf("%d\n",h[i]);
    return 0;
}

Measured memory_bytes: 1028
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define  fo(i,a,b) for(ll i=a;i<b;i++)
#define rfo(i,a,b) for(ll i=a;i>=b;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)

#define err() cout<<"----------"<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
#define pi 3.141592653589
const ll MOD=1e9+7;
ll mod(ll x)
{
   return (x%MOD+MOD)%MOD;
   // works for neg and pos values of x.
}
void solve()
{
    ll n;
    cin>>n;
    vector<vector<ll>> v(4,vector<ll>(n));
    fo(i,0,n)
    {
        ll x,y;
        cin>>x>>y;
        v[0][i]=x+y;
        v[1][i]=x-y;
        v[2][i]=y-x;
        v[3][i]=-x-y;
    }
    fo(i,0,4)
    {
        sort(all(v[i]));
    }
    ll a=-1e18;
    fo(i,0,4)
    {
        a=max(a,v[i][n-1]-v[i][0]);
    }
    cout<<a;
}
int main()
{
//  clock_t time_req;
//  time_req = clock();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }

// time_req = clock()-time_req;
//  cout<<"Time taken: "<<(float)time_req/CLOCKS_PER_SEC<<"s"<<endl;

    return 0;
}

Measured memory_bytes: 11140
#include <stdio.h>
#define N 100

int dp[N][N], a[N], b[N];

main(){
  int n, i, j, z;
  
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%d%d", &a[i], &b[i]);
  for(i=0;i<n;i++) for(j=0;j<n;j++) dp[i][j] = 100000000;
  for(i=0;i<n;i++) dp[i][i] = 0;
  
  for(i=1;i<n;i++){
    for(j=0;j+i<n;j++){
      for(z=0;z<i;z++){
	
        int cost = dp[j][j+z] + dp[j+z+1][j+i] + a[j] * b[j+z] * b[j+i];
        if(dp[j][j+i] > cost) dp[j][j+i] = cost;
      }
    }
  }
  
  printf("%d\n", dp[0][n-1]);

  
  return 0;
}



Measured memory_bytes: 2108
#include <iostream>
#include <string>
#include <algorithm>
#include <sstream>
 
const std::string answer="6174";
 
int main()
{
    std::string in_str;
        std::cin>>in_str;
        int L,S;
        int i;
        while(in_str[0]!='0'||in_str[1]!='0'||in_str[2]!='0'||in_str[3]!='0'){
                if(in_str[0]!=in_str[1]||in_str[1]!=in_str[2]||in_str[2]!=in_str[3]){
                        for(i=0;in_str!=answer;i++){
                {
                    std::stringstream sss;
                                std::sort(in_str.begin(),in_str.end());
                                sss<<in_str;
                                sss>>S;
                }
                {
                    std::stringstream sss;
                                std::sort(in_str.begin(),in_str.end(),std::greater<char>());
                                sss<<in_str;
                                sss>>L;
                }
                L-=S;
                {
                    std::stringstream sss;
                                sss<<L;
                                in_str=sss.str();
                    while(in_str.length()!=4){
                        in_str='0'+in_str;
                    }
                }
                        }
                        std::cout<<i<<std::endl;
                }else{
                        std::cout<<"NA"<<std::endl;
                }
                std::cin>>in_str;
        }
}

Measured memory_bytes: 1256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int X = sc.nextInt();
        
        if(X == 3 || X == 5 || X == 7){
        	System.out.println("YES");
        } else {
        	System.out.println("NO");
        }
        
        sc.close();
        
    }
}


Measured memory_bytes: 22868
/*
    Problem

*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    while(1) {
        int n;
        cin >> n;
        if (n == 0) return 0;
        vector<int> a(n);
        for (int i = 0; i < n; i++) cin >> a[i];
        sort(a.begin(), a.end());
        int minD = INF;
        for (int i = 0; i < n-1; i++) {
            int d = a[i+1] - a[i];
            minD = (d < minD ? d : minD);
        }
        cout << minD << '\n';
    }
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	queue<string>q;
	for(int i=1; i<=9; i++){
		string s;
		s.push_back(i+'0');
		q.push(s);
	}
	while(1){
		k--;
		string curr = q.front();
		q.pop();
		if(k==0){
			cout<<curr;
			return 0;
		}
		int last = curr[curr.length()-1]-'0';
		for(int i=last-1; i<=last+1; i++){
			if(i>=0 && i<=9){
				string temp = curr;
				temp.push_back(i+'0');
				q.push(temp);
			}
		}
	}
}

Measured memory_bytes: 9660
#include <iostream>
#include <fstream>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>

using namespace std;

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

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

ll MOD = 924844033;

vector<int> L, R;

ll F[2010];
vector<vector<ll> > C;
vector<ll> D;

unordered_map<int, vector<ll> > H;

void init() {
	ll A[2010], B[2010], AP[2010], BP[2010];
	vector<ll> C;
	C.push_back(1);
	C.push_back(1);
	H[2] = C;
	memset(A, 0, sizeof(A));
	memset(B, 0, sizeof(B));
	A[1] = 1;
	B[0] = 1;
	for (int i = 3;i <= 4000;i++) {
		memset(AP, 0, sizeof(AP));
		memset(BP, 0, sizeof(BP));
		AP[0] = 0;
		BP[0] = 1;
		for (int j = 1;j <= 2000;j++) {
			AP[j] += B[j - 1];
			AP[j] %= MOD;
			BP[j] += A[j];
			BP[j] += B[j];
			BP[j] %= MOD;
		}
		int k = 0;
		C.clear();
		while (1 > 0) {
			if (AP[k] + BP[k] > 0) {
				C.push_back(AP[k] + BP[k]);
				k++;
			}
			else break;
		}
		H[i] = C;
		swap(A, AP);
		swap(B, BP);
	}
	F[0] = 1;
	for (ll i = 1;i <= 2000;i++) {
		F[i] = F[i - 1] * i;
		F[i] %= MOD;
	}
	return;
}

void cal() {
	for (int i = 0;i < L.size();i++) {
		C.push_back(H[L[i]]);
	}
	return;
}

void merge() {	
	D = C[0];
	vector<ll> E;
	for (int i = 1;i < C.size();i++) {
		E.clear();
		E.resize(D.size() + C[i].size() - 1);
		for (int j = 0;j < E.size();j++) {
			for (int n = 0;n < D.size();n++) {
				int m = j - n;
				if (m < 0 || m >= C[i].size()) continue;
				E[j] += D[n] * C[i][m];
				E[j] %= MOD;
			}
		}
		swap(D, E);
	}
	return;
}

int main() {
    ios::sync_with_stdio(false);
    ll N, K;
    cin >> N >> K;
    for (int i = 1;i <= 2 * K;i++) {
    	int l = i;
    	int lc = 0;
    	if (i > K) lc++;
    	while (l <= N) {
    		lc++;
    		l += K;
    	}
    	if (lc > 1) L.push_back(lc);
    }
    init();
    cal();
    merge();
    ll res = 0;
    ll crt = 1;
    for (int i = 0;i < D.size();i++) {
    	res += ((D[i] * F[N - i] * crt) % MOD);
    	res = (res + MOD) % MOD;
    	crt *= -1;
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

#define mod 1000000007LL
#define pi 3.141592653589793238462643383279;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define pic pair<char,long long >

void scan(vector<int> & v)
{
    for(int i=0;i<v.size();i++)
        scanf("%d",&v[i]);
}

void print(vector<int> & v)
{
    for(int i=0;i<v.size();i++)
        printf("%d ",v[i]);
}
void fun()
{
    ll n,c,k;
    cin>>n>>c>>k;
    vector<ll> v(n);
    for(ll i=0;i<n;i++)
        cin>>v[i];
    sort(v.begin(),v.end());
    ll ans=1;
    ll left=c-1;
    ll ma=v[0]+k;
    for(ll i=1;i<n;i++)
    {
        if(ma<v[i]||left==0)
        {
            ans++;
            left=c-1;
            ma=v[i]+k;
        }
        else
            left--;
    }
    cout<<ans<<endl;
}
int main()
{
    bool test=0;
    if(test==1)
    {
        freopen("input_file_name.txt","r",stdin);
        freopen("output_file_name.txt","w",stdout);
    }
    int t=1;
    //cin>>t;
    for(int i=1;i<=t;i++)
    {
        //cout<<"Case #"<<i<<": ";
        fun();
        //cout<<endl;
    }
    //int acc;cin>>acc;
    return 0;
}



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

int main(){
  int n;
  long long a, sum = 0, counter = 0;
  map<long long, int> mp;
  cin >> n;
  mp[sum] = 1;
  for(int i=1; i<=n; i++){
    cin >> a;
    sum += a;
    counter += mp[sum];
    mp[sum]++;
  }
  cout << counter << endl;
}

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

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;
}

int main()
{
    string s,t,u;
    int a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u)a--;
    else b--;
    cout << a << " " << b << endl;
}
    

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
#define endl "\n"
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}

ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 

 
ll mul_inv(ll a, ll b) {
    ll b0 = b, t, q;
    ll x0 = 0ll, x1 = 1ll;
    if (b == 1ll) return 1ll;
    while (a > 1ll) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0ll) x1 += b0;
    return x1;
}
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
#define arr2 array<ll,2>
#define arr3 array<ll,3>
#define varr2 vector<array<ll,2> >
#define varr3 vector<array<ll,3> >
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }


const ll maxn=2e5+2;





int main()
{ fastio;
//freopen("input.txt, "r", stdin); 
//freopen("output.txt", "w", stdout);

ll n;cin>>n;
cout<<1-n;


  







return 0;
}





  







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

const int MAX_N = 110;
const int MAX_M = 1010;
const int INF = (1 << 28);

struct Edge {
    int endpoint1;
    int endpoint2;
    int weight;

    Edge() {}
    Edge(int ep1, int ep2, int w)
        : endpoint1(ep1), endpoint2(ep2), weight(w) {}
};

int cost[MAX_N][MAX_N];
Edge edges[MAX_M];

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

    // Floyd-Warshall algorithmのための初期化
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cost[i][j] = (i == j) ? 0 : INF;
        }
    }

    for (int m_i = 0; m_i < m; m_i++) {
        int a, b, c;
        cin >> a >> b >> c;

        a--; b--;
        edges[m_i] = Edge(a, b, c);
        edges[m_i] = Edge(b, a, c);

        cost[a][b] = min(cost[a][b], c);
        cost[b][a] = min(cost[b][a], c);
    }

    // Floyd-Warshall algorithm
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
            }
        }
    }

    int ans = 0;
    for (int m_i = 0; m_i < m; m_i++) {
        int ep1 = edges[m_i].endpoint1,
            ep2 = edges[m_i].endpoint2,
            w = edges[m_i].weight;
        if (cost[ep1][ep2] < w) {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
while True:
  h, w = map(int, input().split())
  
  if h==0 and w==0:
    break
    
  else:
    for i in range(h):
      for j in range(w):
        if (i+j)%2==0:
          print('#', end='')
        else:
          print('.', end='')
      print('')
  
  print('')



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

int main(){
  string s;
  cin >>s;
  if(s[0]!=s[1]) cout << "Yes" << endl;
  else if(s[1]!=s[2]) cout << "Yes" << endl;
  else if(s[0]!=s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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 main(){
    ll a, b, c, k; cin >> a >> b >> c >> k;
    ll ans = 0;
    ll count = 0;
    if(a >= k){
        cout << k << endl;
        return 0;
    }else{
        ans += a;
        count += a;
    }
    if(count + b >= k){
        cout << a << endl;
        return 0;
    }else{
        count += b;
    }

    cout << ans - (k - count) << endl;
}

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
n,m = map(int,input().split())
ab = [list(map(int,input().split()))for i in range(n)]
cd = [list(map(int,input().split()))for i in range(m)]

def distance(i,j):
    return abs(ab[i][0] - cd[j][0]) + abs(ab[i][1] - cd[j][1])
ans = []
for i in range(n):
    mn = 10**18
    s = 0
    for j in range(m):
        if mn > distance(i,j):
            s = j
            mn = distance(i,j)
    ans.append(s)

for i in range(n):
    print(ans[i]+1)


Measured memory_bytes: 40048
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	bh := 0
	for i := 0; i < n; i++ {
		sc.Scan()
		h, _ := strconv.Atoi(sc.Text())
		if bh > h {
			fmt.Println("No")
			return
		}
		if h == bh {
			bh = h
		} else {
			bh = h - 1
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 2176
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<(n);i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll
// #define MAX 20
#define INF (int)1e18

template<class T> ostream& operator<<(ostream& cout,vector<T> V)
{cout<<"[ ";for(auto v:V)cout<<v<<' ';return cout<<']';}
template<class L,class R> ostream& operator<<(ostream& cout,pair<L, R> P)
{return cout<<'('<<P.F<<','<< P.S<<')';}


signed main()
{
	fio
	inp(n) inp(k)
	inpa(a,n)
	sort(all(a));
	int ans=0;
	fo(i,k)
		ans+=a[i];
	cout<<ans<<'\n';
	printclock;
}

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

int main(){
  long N,M;
  cin >> N >> M;
  vector<pair<int,int>> Y(M);
  for(int i=0; i<M; i++){
    cin >> Y[i].first >> Y[i].second;
  }
  sort(Y.begin(),Y.end());
  reverse(Y.begin(),Y.end());
  
  int la=N,ans=0;
  for(int i=0; i<M; i++){
    if(Y[i].second<=la){
      ans++;
      la=Y[i].first;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	int x=0,A=0,B=0;
	cin >> x >> A>>B;
	if(abs(x-A)>abs(x-B)) 
	{
		cout<<"B";
	}else 
	{
		cout<<"A";
	}
	
	return 0;
 } 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
 
#define ll long long int
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define rev(i,a,b) for(ll i=a;i>=b;i--)
#define pll pair<ll,ll>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define V vector<ll>
#define print2(x) cout <<"####"<< #x <<"  =>  "<<x<< endl
#define print1(x) cout <<"****"<< #x <<"  =>  "<<x<< endl
#define N 35005
#define M 55

int main()
{
	fast_io;
	map<ll,ll> m;
	ll n,a;
	cin>>n;
	rep(i,0,n-1)
	{
		cin>>a;
		m[a]++;
	}
	ll ans=0;
	ll count=0;
	for(std::map<ll,ll>::reverse_iterator i=m.rbegin();i!=m.rend();i++)
	{
		if( i->second>=2)
		{
			if(count==0)
			{
				count++;
				ans=i->first;
				i->second-=2;
			}
			else
			{
				ans*=i->first;
				break;
			}
		}
		if(i->second>=2)
		{
			ans*=i->first;
			break;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 6528
n=int(input())
from math import sqrt as S 
pf=[]
for i in range(2,int(S(n))+1):
    if n%i==0:
        c=0 
        while n%i==0:
            n//=i 
            c+=1 
        pf.append([i,c])
if n>1:
    pf.append([n,1])
cnt=0 
def search(x):
    lo=0
    hi=10**9 
    ans=0 
    while lo<=hi:
        mi=(lo+hi)//2 
        if mi*(mi+1)//2<=x:
            ans=mi 
            lo=mi+1 
        else:
            hi=mi-1 
    return ans 
for x in range(len(pf)):
    a=pf[x][0]
    b=pf[x][1]
    cnt+=search(b)
print(cnt)

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

typedef struct {
  char s[100];
  int p;
  int a;
} res;

int main()
{
  int n, i, j;
  res b[100];
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> b[i].s >> b[i].p;
    b[i].a = i+1;
  }
  for (i = 1; i < n; i++) {
    for (j = 1; j < n; j++) {
      if (strcmp(b[j-1].s, b[j].s) > 0) {
	swap(b[j-1], b[j]);
      }
      else if (strcmp(b[j-1].s, b[j].s) == 0) {
	if (b[j-1].p < b[j].p) {
	  swap(b[j-1], b[j]);
	}
      }
    }
  }
  for (i = 0; i < n; i++) {
    cout << b[i].a << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if ( A + B > C + D){
    cout << "Left" << endl;
  }
  else if ( A + B == C + D){ 
    cout << "Balanced" << endl;
  }
    else {
      cout << "Right" << endl;
    }
  }

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int cont(string& t){
    int f = 0;
    for(int i = 1; i < t.size(); i++){
        if(t[0] != t[i]){
            f = 1;
            break;
        }
    }
    return f;
}
int main()
{
    string s, t, u;
    cin >> s;
    int ans[100] = {0};
    for(size_t i = 0; i < s.size(); i++){
        t = s;
        while(cont(t)){
            ans[i]++;
            for(size_t j = 0; j < t.size() - 1; j++){
                u += (t[j] == s[i] || t[j+1] == s[i] ? s[i] : t[j]);
            }
            t = u;
            u = "";
        }
    }
    sort(ans, ans + s.size());
    cout << ans[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    ll N;
    cin >> N;
    if(N==0){
        cout << 0 << endl;
        return 0;
    }
    string S = "";
    while(N!=0){
        if(N%2==0){
            if(N<0){
                N*=(-1);
                N/=2;
            }else{
                N/=2;
                N*=(-1);
            }
            S+='0';
            continue;
        }
        if(N<0){
            N*=(-1);
            N+=1;
            N/=2;
        }else{
            N/=2;
            N*=(-1);
        }
        S+='1';
    }
    reverse(S.begin(),S.end());
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#define MIN(x,y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

int b[200001];
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n - 1; i++) {
    int a;
    scanf("%d", &a);
    b[a-1]++;
  }
  for (int i = 0; i < n; i++) {
    printf("%d\n", b[i]);
  }
  return 0;
}

Measured memory_bytes: 2848
from collections import deque

def main():
	n = int(input())
	lst = deque()
	for _ in range(n):
		s = input()
		if s == "deleteFirst":
			lst.popleft()
		elif s == "deleteLast":
			lst.pop()
		else:
			cmd, num = s.split()
			if cmd == "insert":
				lst.appendleft(num)
			else:
				try:
					lst.remove(num)
				except ValueError:
					pass
	print(" ".join(list(lst)))

main()


Measured memory_bytes: 69736
import sys

stdin = sys.stdin

ns = lambda: stdin.readline()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

N = ni()
a = na()

a.sort()
sum = 0
for i in range(1,N+1):
    sum += a[3*N-2*i]

print (sum)


Measured memory_bytes: 37084
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long int64;

int main(void){
    int64 R,G,B,N;
    cin>>R>>G>>B>>N;
    int64 r,g,b,ans=0;
    for(int64 i=0;i*R<=N;i++){
        for(int64 j=0;i*R+j*G<=N;j++){
            if((N-i*R-j*G)%B==0) {
                ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	fio;
	int n;
	cin >> n;
	vector<int> v(n + 1);
	map<int, int> m;
	ll ans = 0;
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i];
		ans += m[-i + v[i]];
		m[-i - v[i]]++;
	}
	cout << ans;
}

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

int myPower(int a, int n) { // aのn乗の計算
	int x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	int i, j;
	int n;
	cin >> n;
	long long int a[n+1];
	long long int b[n];
	for (i = 0; i < n+1; i++) {
		cin >> a[i];
	}
	for (i = 0; i < n; i++) {
		cin >> b[i];
	}
	long long int ans = 0;
	for (i = 0; i < n; i++) {
		long long int x = min(a[i], b[i]);
		long long int y = min(a[i+1], max(b[i] - a[i], (long long)0));
		ans += x + y;
		a[i] -= x;
		a[i+1] -= y;
	}

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

Measured memory_bytes: 1792
N = int(input())
s = input()
mod = 10 ** 9 + 7


def main():
    dp = [[0 for _ in range(N+1)] for _ in range(2)]
    dp[0][0] = 1
    for i in range(N):
        for j in range(N):
            dp[(i+1)%2][j] = 0
        for j in range(N):
            dp[(i+1)%2][j+1] = (dp[(i+1)%2][j+1] + dp[i%2][j] * 2) % mod
            if j-1 >= 0:
                dp[(i+1)%2][j-1] = (dp[(i+1)%2][j-1] + dp[i%2][j]) % mod
            else:
                dp[(i+1)%2][j] = (dp[(i+1)%2][j] + dp[i%2][j]) % mod

    pow2 = pow(2, len(s), mod)
    inv_pow2 = pow(pow2, mod-2, mod)
    print((dp[N%2][len(s)] * inv_pow2) % mod)


if __name__=='__main__':
    main()


Measured memory_bytes: 42184
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include<cstdio>
#include <vector>
#include<queue>
#include<limits.h>
#include<string.h>
#include<functional>
#include<map>
#include<set>
#include<list>
using namespace std;

int a[100];
signed main() {
	int b; cin >> b;
	for (int c = 0; c < b; c++)cin >> a[c];
	for (int i = 1; i <= b; i++) {
		sort(a, a + i);
		for (int j = 0; j < b; j++) {
			if (j)cout << " ";
			cout << a[j];
		}
		cout << endl;
	}
}

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

int main() {
	// your code goes here
	int a, b;
	cin >> a >> b;
	int sum = 1;
	int n = 0;
	
	for(int i=0; sum<b; i++)
	{
		sum += a - 1;
		n += 1;
	}
	
	cout << n << endl;
	
	return 0;
}

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

queue<pair< pair<int, int>, int> > que;

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

    int p = 1;
    int n = 1;
    while(p*2 <= l){
        p *= 2;
        n += 1;
    }
    int ans_n = n;

    int xx = 1;
    for(int i = n-1;i >= 1;i--){
        que.push(make_pair(make_pair(i, i+1), 0));
        que.push(make_pair(make_pair(i, i+1), xx));
        xx *= 2;
    }

    l = l ^ (1 << (n-1));

    int r = n;
    int w = p;
    int x = 1;

    while(l > 0){
        if(l & 1){
            que.push(make_pair(make_pair(1, r), w));
            w += x;
        }
        x *= 2;
        l >>= 1;
        r--;
    }

    cout << ans_n << " " << que.size() << endl;
    while(!que.empty()){
        pair<pair<int, int> , int> p = que.front();
        cout << p.first.first << " " << p.first.second << " "<< p.second << endl;
        que.pop();
    }

    return 0;
}


Measured memory_bytes: 256
import numpy as np
N, M = map(int,input().split())
A = [list(map(lambda x: 1 if x == "." else 0, list(input()))) for n in range(N)]
B = [list(map(lambda x: 1 if x == "." else 0, list(input()))) for m in range(M)]

A = np.array(A)
B = np.array(B)

flag = False
for r in range(N-M+1):
    for c in range(N-M+1):
        if (A[r:r+M, c:c+M] == B).all():
            flag = True
if flag:
    print("Yes")
else:
    print("No")


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

int a[22][22], c[22];
int main() {
    int n, m, x;
    cin >> n >> m >> x;
    for(int i = 0; i < n; i++) {
        cin >> c[i];
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    int M = 1e9;
    for(int i = 0; i < 1 << n; i++) {
        int d = 0;
        for(int j = 0; j < m; j++) {
            int b = 0;
            for(int k = 0; k < n; k++)
                if(i & 1 << k)
                    b += a[k][j];
            if(b < x)
                goto pn;
        }
        for(int k = 0; k < n; k++)
            if(i & 1 << k)
                d += c[k];
        M = min(M, d);
    pn:;
    }
    cout << (M < 1e8 ? M : -1) << endl;
    return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int main(){
queue<ll> q;
int n,k;
cin>>n>>k;
ll sum1=0,sum2=0;
V<ll> a(n);
for(int i=0;i<n;i++){
cin>>a[i];
if(i<k){q.emplace(a[i]);sum2+=a[i];}
else if(a[i]>0){sum1+=a[i];sum2+=a[i];}
}
ll ans=0;
ans=max({ans,sum1,sum2});
for(int i=k;i<n;i++){
    if(a[i]>0)sum1-=a[i];
    if(a[i]<0)sum2+=a[i];
    q.emplace(a[i]);
    ll tmp=q.front();
    q.pop();
    if(tmp<0)sum2-=tmp;
    if(tmp>0)sum1+=tmp;
    ans=max({ans,sum1,sum2});
}
cout<<ans<<"\n";
}

Measured memory_bytes: 1792
import java.util.*;
class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    String s = sc.next();
    int count = s.length();
    String add = "...";
    
    if(count <= k){
      System.out.println(s);
    }else if(count > k){
      String result = s.substring(0, k) + add;
      System.out.println(result);
    }
  }
}

Measured memory_bytes: 39228
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
int W, H, ans;
int grid[30][30];
void dfs(int x, int y, int count) {
  if (grid[x][y] == 3) {
    ans = min(ans, count); 
    return;
  }
  if (count >= 10) {
    return;
  }
  int mx[4] = { 1, 0, -1, 0 };
  int my[4] = { 0, 1, 0, -1 };
  for (int i = 0; i < 4; i++) {
    int nx = x+mx[i], ny = y+my[i];
    if (nx >= 0 && nx < W && ny >= 0 && ny < H && (grid[nx][ny] == 0 || grid[nx][ny] == 3)) {
      for (int j = 0; j < 30; j++) {
        if (grid[nx][ny] == 3) {
          ans = min(ans, count+1);
          break;
        }
        nx += mx[i];
        ny += my[i];
        if (nx < 0 || nx >= W || ny < 0 || ny >= H) {
          break;
        } else if (grid[nx][ny] == 1) {
          int rx = nx-mx[i], ry = ny-my[i];
          grid[nx][ny] = 0;
          dfs(rx, ry, count+1);
          grid[nx][ny] = 1;
          break;
        }
      }
    }
  }
}

signed main() {
  while (cin>>W>>H, W+H!=0) {
    int startX, startY;
    ans = INF;
    for (int i = 0; i < H; i++) {
      for (int j = 0; j < W; j++) {
        int k; cin>>k;
        if (k==2) {
          grid[j][i]=0;
          startX=j;
          startY=i;
        } else {
          grid[j][i]=k;
        }
      }
    }
    dfs(startX, startY, 0);
    ans = (ans==INF) ? -1 : ans;
    cout << ans << endl;
  }
  return 0;
}




Measured memory_bytes: 3092
let (n1, n2, n_limit) = (4, 16, 45)

let area =
  [| [1; 4]; [0; 2; 5]; [1; 3; 6]; [2; 7]
   ; [0; 5; 8]; [1; 4; 6; 9]; [2; 5; 7; 10]; [3; 6; 11]
   ; [4; 9; 12]; [5; 8; 10; 13]; [6; 9; 11; 14]; [7; 10; 15]
   ; [8; 13]; [9; 12; 14]; [10; 13; 15]; [11; 14] |]

let goal = Array.init n2 (fun i -> (i + 1) mod n2)

let md = Array.make_matrix n2 n2 0

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space lower =
  let rec doit i space moved lower =
    if i = limit then
      if a <> goal then ()
      else begin
        Printf.printf "%d\n" limit;
        exit 0;
      end
    else
      List.iter (fun j ->
        let x = a.(j) in
        match moved with
        | y :: _ when y = x -> ()
        | moved ->
          let lower = lower - md.(x).(j) + md.(x).(space) in
          if lower + i > limit then ()
          else begin
            a.(j) <- 0;
            a.(space) <- x;
            doit (i + 1) j (x :: moved) lower;
            a.(j) <- x;
            a.(space) <- 0;
          end)
      area.(space) in
  doit 0 space [] lower

let findi a x =
  let n = Array.length a in
  let rec doit i =
    if i = n then assert false
    else if a.(i) = x then i
    else doit (i + 1) in
  doit 0

let () =
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let space = findi a 0 in
  let lower =
    Array.fold_left (fun (i, sum) e -> (i + 1, sum + md.(e).(i))) (0, 0) a |> snd in
  for limit = lower to n_limit do
    idastar a limit space lower
  done

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

struct Plan {
  int s, t, x;
  bool operator < (const Plan &p) const {
    return x < p.x;
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  Plan p[n];
  rep(i, n) cin >> p[i].s >> p[i].t >> p[i].x;
  sort(p, p+n);

  int d[q];
  for (int i = q-1; i >= 0; --i) cin >> d[i];
  rep(i, q) d[i] *= -1;

  set<int> sets;
  rep(i, q) sets.insert(i);
  int ans[q];
  rep(i, q) ans[i] = 0;
  
  rep(i, n) {
    int l = distance(d, upper_bound(d, d+q, p[i].x-p[i].t));
    int r = distance(d, upper_bound(d, d+q, p[i].x-p[i].s));
    auto itrl = sets.lower_bound(l);
    auto itrr = sets.lower_bound(r);
    while (itrl != itrr) {
      ans[*itrl] = p[i].x;
      itrl = sets.erase(itrl);
    }
  }

  for (int i = q-1; i >= 0; --i) {
    cout << (ans[i] ? ans[i] : -1) << endl;
  }
  return 0;
}

Measured memory_bytes: 15104
n = int(input())
b = n
def pf(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
l = list(set(pf(n)))
cnt = 0
for i in l:
    n = b
    t = 1
    j = i
    while i <= n:
        if n % i == 0:
            cnt += 1
            n = n // i
        i *= j
print(cnt)

Measured memory_bytes: 9224
#include<stdio.h>

int Max(int a,int b){
    if(a>b) return a;
    return b;
}


int main(void){
    int A,B,K,count=0;
    scanf("%d %d %d",&A,&B,&K);

    for(int i=Max(A,B);i>=0;i--){
        if(A%i==0&&B%i==0){
            count++;
            if(count==K){
                printf("%d",i);
                break;
            }
        }
        
    }

    return 0;
}

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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        System.out.println(solve(n));
    }

    private static long solve(long n) {
        return dfs("", n);
    }

    private static long dfs(String s, long n) {
        long res = 0;
        if (!s.isEmpty()) {
            if (check(s, n)) {
                res++;
            } else if (Long.parseLong(s) > n) {
                return 0;
            }
        }
        for (String next : Arrays.asList("7", "5", "3")) {
            res += dfs(s + next, n);
        }
        return res;
    }

    private static boolean check(String s, long n) {
        long sl = Long.parseLong(s);
        if (sl > n) {
            return false;
        }
        if (!s.contains("3") || !s.contains("5") || !s.contains("7")) {
            return false;
        }
        return true;
    }
}


Measured memory_bytes: 40744
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
string a, b;
int n;
inline int lcp() {
	int ans = 0;
	for(int i = 0; i <= n; i ++ ) {
		if(a.substr(n-i, i) == b.substr(0, i)) ans = i;
	}
	return ans;
}
int main() {
	cin >> n >> a >> b;
	printf("%d\n", n*2-lcp());
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
const int sz=1e5+9;
int n,m,a[sz];
pair<int,int> p[sz];
priority_queue<int> q;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    scanf("%d %d",&n,&m);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        q.push(-a[i]);
    }
    for(int i=0;i<m;i++) scanf("%d %d",&p[i].y,&p[i].x);
    for(int i=0;i<m;i++) p[i].x=-p[i].x;
    sort(p,p+m);
    for(int i=0;i<m;i++){
        int rem=p[i].y;
        int v=-p[i].x;
        while(rem--){
            int curr=-q.top();
            if(curr>=v) break;
            q.pop();
            q.push(-v);
        }
    }
    long long ans=0;
    while(!q.empty()){
        ans-=q.top();
        q.pop();
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 1912
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
using namespace std;

int main()
{
	string line;
	while (cin >> line)
	{
		if (line.compare("#") == 0)break;
		int index = line.size() - 1;
		vector<char> v;
		while (index >= 0)
		{
			if (line.at(index) == 'h')
			{
				index -= 5;
				v.push_back('h');
			}
			else if (line.at(index) == 't')
			{
				index -= 4;
				v.push_back('t');
			}
		}

			int angle = 0;
			int l = pow(2, v.size() - 1);
			if (v.at(0) == 't')
			{
				angle = 90 * l;
			}
			for (int i = 1; i < v.size(); i++)
			{
				if (v.at(i) == 'h')
				{
					angle -= 90 * l / pow(2, i);
				}
				else
				{
					angle += 90 * l / pow(2, i);
				}
			}

			while (l != 1 && angle % 2 == 0)
			{
				angle /= 2;
				l /= 2;
			}

			if (l > 1)
			{
				cout << angle << "/" << l << endl;
			}
			else
			{
				cout << angle << endl;
			}
		}
	return 0;
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main(){
  string s;
  cin >> s;
  map<int, int> mp;
  int n=s.size();
  vector<int> T(n);
  mp[0]++;
  for(int i=n-1; i>=0; i--){
    int a=s[i]-'0';
    if(i==n-1){
      T[i]=a;
      mp[T[i]]++;
    } else {
      T[i]=T[i+1]+a*modpow(10, n-1-i, 2019);
      T[i]%=2019;
      mp[T[i]]++;
    }

  }
  ll ans=0;
  for(auto p:mp){
    int m=p.second;
    ans+=m*(m-1)/2;
  }
  cout << ans << endl;
  return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int K;
  cin >> K;
  rep (i, K)
    cout << "ACL";
  cout << endl;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	ll n,i;
	cin>>n;
	for(i=i;;++i){
		if(i*i>n){
			cout<<(i-1)*(i-1)<<endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#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>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    cout << (int)pow((int)sqrt(n), 2);
    cout << endl;
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef vector <int> vi;
typedef pair< int ,int > pii;
#define endl "\n"
#define sd(val) scanf("%d",&val)
#define ss(val) scanf("%s",&val)
#define sl(val) scanf("%lld",&val)
#define debug(val) printf("check%d\n",val)
#define all(v) v.begin(),v.end()
#define PB push_back
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val,0,sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
 
int main()
{
 
 //OJ;
  ll n,m,x,flag=0;
 cin>>n>>m>>x;
 ll c[n],a[n][m];
 for(int i=0;i<n;i++)
 {
     cin>>c[i];
     for(int k=0;k<m;k++)
    {
        cin>>a[i][k];
    }
 }
ll minim=1e9;
for(int i=0;i<m;i++)
{   ll sum=0;
    for(int k=0;k<n;k++)
    {
        sum+=a[k][i];
    }
    //cout<<sum<<" ";
    if(sum<x){flag=1;break;}
}
if(flag)
{
    cout<<-1;
}else
{
    for(int i=0;i<pow(2,n);i++)
    {
        ll sum=0,b[m]={0};
        for(int z=0;z<n;z++)
        {   
            ll f=pow(2,z);
            if((f&i)!=0)
            {
                sum+=c[z];
                for(int q=0;q<m;q++)
                {
                    b[q]+=a[z][q];
                }
            }
        }
        ll e=0;
        for(int i=0;i<m;i++)
        {
            if(b[i]<x)e=1;
        }
        if(e==0)
        {
            minim=min(minim,sum);   
        }

        
    }
    cout<<minim;



}


 
 
 
 
 
return 0;
   
}

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

const int mod = (int)1e+9 + 7;

bool binary_search(int start, int end, int value, vector<int>&sorted){
    
    while(start <= end){
        int mid = start + (end - start)/2;
        if(sorted[mid] == value){
            return true;
        }else if(sorted[mid] > value){
            start = mid + 1;
        }else{
            end = mid - 1;
        }
    }
    
    return false;
    
}


int main(){
    
    int n, m;
    cin >> n >> m;
    vector<int>broken(m);
     vector<int>dp(n+1, INT_MAX);
    for(int i = 0; i < m; i++){
      cin >> broken[i];  
      dp[broken[i]] = 0;
     }
    
    dp[n] = 1;
    for(int i = n-1; i >= 0; i--){
        if(dp[i] == 0){
            continue;
        }
        else{
            dp[i] = 0;
            if(i + 1 <= n){
                (dp[i] += dp[i+1]) %= mod;
            }
            if(i+2 <= n){
                (dp[i] += dp[i+2]) %= mod;
            }
            
        }
    }
    
    cout << dp[0] << endl;
    
    
    
    
    
}


Measured memory_bytes: 3876
N = int(input())
L = list(map(int,input().split()))

num_2 = 0
num_4 = 0
odd = 0

for i in L:
    if i % 4 == 0:
        num_4 += 1
    elif i % 2 == 0:
        num_2 += 1
    else:
        odd += 1
        
if num_2 != 0:
    if num_4 >= odd:
        print("Yes")
    else:
        print("No")
        
if num_2 == 0:
    if num_4 >= odd -1:
        print("Yes")
    else:
        print("No")

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

int binarySearch(int *arr, int len, int key) {
    int left = 0, right = len;
    while (left < right) {
        int mid = (left + right) / 2;
        if (arr[mid] == key) return mid;
        else if (key < arr[mid]) right = mid;
        else left = mid + 1;
    }
    return -1;
}

int main() {
    int n;
    scanf("%d", &n);
    int s[n];
    rep(i, n) scanf("%d", &s[i]);
    int q;
    scanf("%d", &q);
    int t[q];
    rep(i, q) scanf("%d", &t[i]);
    int c = 0;

    rep(i, q) {
        if (binarySearch(s, n, t[i]) > -1) c++;
    }
    printf("%d\n", c);
    return 0;
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int ab, bc, ca;
	cin >> ab >> bc >> ca;

	cout << (ab * bc) / 2 << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=1000010;
const ll mod=1e9+7;

int main(){
  ll n;
  cin >> n;
  cout << "ABC"<<n << endl;
  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535;
#define MOD 1000000007;


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


int main(void) {
	ll a, b, cnt = 1;
	cin >> a >> b;
	ll m = gcd(a, b);
	
	for (ll i = 2; i <= sqrt(m); i++) {
		if (m%i == 0)cnt++;
		while (m%i == 0) {
			m /= i;
		}

	}
	if (m != 1) {
		cout << cnt + 1 << endl;
	}
	else {
		cout << cnt << endl;
	}
	return 0;
}

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

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

    vector<int> buka(n+1);

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

    for (int i = 1; i < n + 1; i++) {
        cout << buka[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4020
import sys
from fractions import gcd as gcd_base
from functools import reduce

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
LIST = lambda: list(map(int, INPUT().split()))

sys.setrecursionlimit(10 ** 9)


def main():
    _ = INT()
    A = LIST()

    gcd = lambda *numbers: reduce(gcd_base, numbers)
    print(gcd(*A))


if __name__ == '__main__':
    main()

Measured memory_bytes: 88300
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int N=scanner.nextInt();
    int ans=0;
    int nn=N;
    while(N>=1){
      ans+=N%10;
      N/=10;
    }

    if(nn%ans==0){
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }

  }
}


Measured memory_bytes: 22612