akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,N) for(i=0;i<N;i++)
typedef long long ll;
typedef pair<int, int> P;
typedef struct{
  int first;
  int second;
  int third;
}T;

//昇順
bool comp_Se(T& l, T& r){
  return l.second < r.second;
}

ll N,M;

int main(void){
  cin >> N >> M;
  int i;
  vector<ll> v;
  for(i=1; i<=sqrt(M); i++){
    if(M%i==0){
      v.push_back(i);
      v.push_back((ll)M/i);
    }
  }
  sort(v.begin(),v.end(),greater<ll>());
  REP(i,v.size()){
    if(M >= (ll)N*v[i])break;
  }
  cout << v[i] << endl;
  return 0;
}

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

int main() {
    int r;
    cin >> r;
    cout << 2 * 3.141592 * r;

    
}

Measured memory_bytes: 3788
/* Isn't passion overrated?*/

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
double pi = 3.14159265358979323846;
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	ll n,m;
	cin>>n>>m;
    vector<vector<ll> >arr(n+1);
    while(m--)
    {
        ll a,b;
        cin>>a>>b;
        arr[a].pb(b);
        arr[b].pb(a);
    }
    queue<ll>q;
    q.push(1);
    vector<ll>vis(n+1);
    vector<ll>ans(n+1);
    vis[1] = 1;
    while(!q.empty())
    {
        ll a = q.front();
        q.pop();
        for(ll i = 0; i < arr[a].size(); i++)
        {
            if(vis[arr[a][i]])
                continue;
            vis[arr[a][i]] = 1;
            ans[arr[a][i]] = a;
            //cout<<arr[a][i]<<" "<<a<<endl;
            q.push(arr[a][i]);
        }
    }
    for(ll i = 2; i <= n; i++)
    {
        if(ans[i] == 0)
        {
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(ll i = 2; i <= n; i++)
        cout<<ans[i]<<endl;
    return 0;
}


Measured memory_bytes: 13632
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
const ll BIG=1e15;

int main(){
  int N; string S; cin>>N>>S;
  bool ans=true;
  if(N%2==1) ans=false;
  int M=N/2;
  if(N%2==0){
    for(int i=0;i<M;i++){
        if(S.at(i)!=S.at(i+M)) ans=false;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


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

int main(){
  int M[N][N];
  int i,j,n,u,k,v;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      M[i][j] = 0;
    }
  }

  for(i = 0 ; i < n ; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

  for(i = 0 ; i < n ; i++){
    for(j = 0 ; j < n ; j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

const int inf = 1e9;

signed main () {
	int n, m;
	cin >> n >> m;
	vector < bool > b(n + 1, 0);
	for (int i = 0; i <= n; ++i) {
		char s;
		cin >> s;
		b[i] = (s == '1');
	}
	vector < int > pos = {n};
	bool zelimkhan_bakaev = 0;
	while (pos.back() != 0) {
		int nxt = -1;
		for (int j = pos.back() - 1; j >= max(pos.back() - m, 0); --j) {
			if (!b[j])
				nxt = j;
		}
		if (nxt == -1) {
			zelimkhan_bakaev = 1;
			break;
		}
		else
			pos.push_back(nxt);
	}
	if (zelimkhan_bakaev)
		cout << "-1\n";
	else {
		reverse(pos.begin(), pos.end());
		for (int i = 1; i < int(pos.size()); ++i)	
			cout << pos[i] - pos[i - 1] << ' ';
		cout << '\n';
	}
}


Measured memory_bytes: 1020
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
    
		// 整数の入力
		int w = sc.nextInt();
		int aMin = sc.nextInt();
		int bMin = sc.nextInt();
        int aMax = aMin + w;
        int bMax = bMin + w;
        int ans = 0;
        if (aMin > bMin) {
          ans = aMin > bMax ? aMin - bMax : 0;
        } else {
          ans = bMin > aMax ? bMin - aMax : 0; 
        }
        // 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 21204
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

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

int main(){
	int h, w;
	cin >> h >> w;
	priority_queue<tuple<int, int, int>> v;
	string s[h];
	for(int i=0; i<h; i++){
		cin >> s[i];
	}
	for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
			if(s[i][j]=='#') v.push(make_tuple(0,i,j));
		}
	}
	int cnt=0;
	while(!v.empty()){
		tuple<int, int, int> t=v.top();
		int k=get<0>(t), x=get<1>(t), y=get<2>(t);
		for(int i=0; i<4; i++){
			if(x+dx[i]<0 || x+dx[i]>=h || y+dy[i]<0 || y+dy[i]>=w) continue;
			if(s[x+dx[i]][y+dy[i]]=='#') continue;
			v.push(make_tuple(k-1, x+dx[i], y+dy[i]));
			s[x+dx[i]][y+dy[i]]='#';
		}
		v.pop();
		cnt=max(cnt, -k);
	}
	cout << cnt << endl;
	return 0;
}

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

void solve()
{
    int n;
    cin>>n;

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

    sort(a,a+n);
    sort(b,b+n);

    if(n&1)//n is odd
    {
        cout<<b[n/2]-a[n/2]+1;
    }
    else
    {
        int x=b[(n-1)/2]+b[n/2];
        int y=a[(n-1)/2]+a[n/2];

        cout<<x-y+1;
    }

}

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


        solve();
    return 0;
}


Measured memory_bytes: 5172
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    ll N, MAX = -1, ans = 0, tmp;
    cin >> N;

    for (int i = 0; i < N; i++) {
        cin >> tmp;
        ans += tmp;
        MAX = max(MAX, tmp);
    }

    cout << ans - MAX / 2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

const long long INF = 1e18;

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

    int n; cin >> n;
    int arr[n + 1]; for(auto &i : arr) cin >> i;
    long long l[n + 1], r[n + 1]; l[0] = r[0] = 1;
    for(int i = 0; i < n; ++i)
    {
        l[i] = max(l[i] - arr[i], 0ll);
        r[i] -= arr[i];
        l[i] = min(l[i], INF);
        r[i] = min(r[i], INF);
        if(l[i] > r[i]) { cout << -1; return 0; }
        l[i + 1] = l[i];
        r[i + 1] = r[i] * 2;
    }
    if(l[n] > arr[n] || r[n] < arr[n]) { cout << -1; return 0; }

    long long ans = arr[n], tmp = ans;
    for(int i = n - 1; i >= 0; --i)
    {
        tmp = min(tmp, r[i]);
        tmp += arr[i];
        ans += tmp;
    }

    cout << ans;
}


Measured memory_bytes: 5572
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
int last[200005],e_cnt;
int fa[200005],f[200005],v[200005],size[200005],num[200005],g[200005];
inline int get(int x){return g[x]==x?x:g[x]=get(g[x]);}
set<pair<double,int> > s;
#define p(x) make_pair(size[x]/(double)num[x],x)
int main(){
	int n;
	scanf("%d",&n);
	for(int i=2;i<=n;i++)scanf("%d",&fa[i]);
	for(int i=1;i<=n;i++)scanf("%d",&v[i]);
	for(int i=2;i<=n;i++)if(v[fa[i]])f[i]=fa[i]; else f[i]=f[fa[i]];
	for(int i=1;i<=n;i++)if(!v[i])size[f[i]]++;
	long long ans=0;
	for(int i=1;i<=n;i++)if(v[i]){
		num[i]=1;
		ans+=size[i];
		s.insert(p(i));
		g[i]=i;
	}
	while(!s.empty()){
		int x=s.rbegin()->second;
		s.erase(p(x));
		g[x]=get(f[x]);
		ans+=1ll*num[g[x]]*size[x];
		if(g[x])s.erase(p(g[x]));
		size[g[x]]+=size[x];
		num[g[x]]+=num[x];
		if(g[x])s.insert(p(g[x]));
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 17408
#include<stdio.h>

int main(void)

{

   int a,b,d,r;

 double f;

   scanf("%d %d",&a,&b);

   d=a/b;

 r= a%b; 

 f=(double)a/(double)b;

   printf("%d %d %lf\n",d,r,f); 

 return 0;

}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
vector <string> ans;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>s;
		ans.push_back(s);
	}
	sort(ans.begin(),ans.end());
	ans.erase(unique(ans.begin(),ans.end()),ans.end());
	cout<<ans.size();
	return 0;
}

Measured memory_bytes: 11628
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define sz(x) int(x.size())
#define input_code ifstream in("input.txt");cin.rdbuf(in.rdbuf())

using namespace std;

static const int MAX = 100001;

int n;
int alpha[MAX][30];
priority_queue<pair<int, vector<int> > > q;

int main(int argc, const char * argv[]) {
    
    //  [erase]
    //
    
    cin >> n;
    rep(i, MAX){
        rep(j, 30){
            alpha[i][j] = 0;
        }
    }
    
    rep(i, n){
        string tmp;
        cin >> tmp;
        int sum = 0;
        vector<int> tmp2;
        rep(j, tmp.length()){
            tmp2.push_back(tmp[j]-'0');
        }
        sort(tmp2.begin(), tmp2.end());
        rep(j, tmp.length()){
            rep(itr, j+1){
                sum+=tmp2[itr]-'0';
            }
        }
        
        pair<int, vector<int> > f = make_pair(sum, tmp2);
        q.push(f);
    }
    
    pair<int, vector<int> > bef_f;
    long long res=0;
    int continue_ = 1;
    while(!q.empty()){
        pair<int, vector<int>> f = q.top();
        q.pop();
        vector<int> cmp1 = f.second;
        vector<int> cmp2 = bef_f.second;
        if(f==bef_f){
            res+=continue_;
            continue_++;
        }else continue_=1;
        bef_f = f;
    }
    
    cout << res << endl;
    
    return 0;
}


Measured memory_bytes: 21104
n = int(input())
s = input().rstrip()
 
 
def check(length):
    d = set()
    for i in range(n - 2 * length + 1):
        d.add(s[i:i + length])
        if s[i + length:i + 2 * length] in d:
            return True
    return False
 
 
lo = 0
hi = n // 2 + 1
while lo + 1 < hi:
    mid = (lo + hi) // 2
    if check(mid):
        lo = mid
    else:
        hi = mid
print(lo)

Measured memory_bytes: 6388
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>
 
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
 
#define pb push_back
#define ld long double
#define int long long
#define mp make_pair
 
const int MOD = 1e9 + 7;
 
mt19937 rnd(51);
 
int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k;
	cin >> n >> k;
	int ans = 0, sum = 0, sum1 = 0;
	for (int i = 0; i < k; i++){
        sum += i, sum1 += n - i;
	}
	for (int i = k; i <= n + 1; i++){
        ans += sum1 - sum + 1;
        sum += i, sum1 += n - i;
	}
	cout << ans % MOD;
	return 0;
}

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

int main()
{
    int n; 
    cin >> n ;
  	int a[n];
  	int current=0;
  	int max=0;
    for(int i=0;i<n;i++)
    {
      cin>>a[i];
    }
    for(int i=1;i<n;i++)
    {
    	
      if(a[i]<=a[i-1])
      {
      current++;
      if(current>max)
         max=current;
      }
      else
      {
        current=0;
      }
      
    }
    cout<<max;
         return 0;
}
  


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>

int n, c, k;
long long a[100100];

int memo[100100];

int dp(int on)
{
	if(on>=n)
		return 0;
	int &ans=memo[on];
	if(ans)
		return ans;
	long long until=a[on]+k;
	int to=int(std::upper_bound(a,a+n, until)-&a[on]);
	to=std::min(to, c);
	ans=1+dp(on+to);
	//std::cout << "from " << on << ", to " << on+to << '\n';
	return ans;
}

int main()
{
	std::cin >> n >> c >> k;
	for(int i=0;i<n;i++)
		std::cin >> a[i];
	std::sort(a, a+n);
	std::cout << dp(0) << '\n';
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define Rep(i,n) for(ll i = 0; i <= n; i++)
#define REp(i,n) for(ll i = 1; i < n; i++)
#define REP(i,n) for(ll i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  int n, a, b;
  cin >> n >> a >> b;
  string s;
  cin >> s;
  int ra, rb;
  ra = rb = 0;
  rep(i,sz(s)) {
    if(s[i] == 'a') {
      if(ra+rb < a+b) {
        cout << "Yes" << endl;
        ra++;
      }
      else cout << "No" << endl;
    }
    else if(s[i] == 'b') {
      if(ra+rb < a+b && rb < b) {
        cout << "Yes" << endl;
        rb++;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }
}

Measured memory_bytes: 3708
#include <iostream>
using namespace std;
int main () {
	int n, m, p;
	while (cin >> n >> m >> p, n || m || p) {
		int gambler = 0;
		int hit;
		for (int i = 0; i < n; i++) {
			int x;
			cin >> x;
			gambler += x;
			if (i + 1 == m) hit = x;
		}
		if (hit) {
			int pool = gambler * 100 - gambler * p;
			cout << pool / hit << endl;
		}
		else {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int main() {
    string S; cin >> S;
    int ans = 0;
    for (int i = 0; i < S.size() / 2; i++) {
        if (S[i] != S[S.size() - 1 - i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
vector<int>adj[200001];
bool v[200001];
ll power(ll x, ll y, ll z){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2,z);
        if(y%2==0)
         return (p*p)%z;
        else
        return (x*((p*p)%z))%z;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
ll po(ll x)
{
    ll c=0;
    while(x>0)
    {
        x=x&(x-1);
        c++;
    }
    return c;
}
int dfs(int x)
{
    int c=1;
    v[x]=1;
    for(auto it=adj[x].begin();it!=adj[x].end();it++)
    {
        if(!v[*it])
        {
           c=c+ dfs(*it);
        }
    }
    return c;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
    ll n,m;
    int k=0;
    cin>>n>>m;
    ll a[m],b[m];
     map<pair<ll,ll>,ll>mp;
    for(int i=0;i<m;i++){
    cin>>a[i]>>b[i];
    if(mp[{a[i],b[i]}]==0&&mp[{b[i],a[i]}]==0)
    {
        ll x=min(a[i],b[i]),y=max(a[i],b[i]);
        adj[x].push_back(y);
        adj[y].push_back(x);
        mp[{x,y}]=1;
        mp[{y,x}]=1;
    }}
    for(int i=1;i<=n;i++)
    {
        if(v[i]==false)
        k=max(k,dfs(i));
    }
    cout<<k;
}
    

Measured memory_bytes: 52184
if __name__ == '__main__':
    from sys import stdin
    # from collections import defaultdict
    import math
    input = stdin.readline

    x = int(input())

    a = 100
    for i in range(4000):
        a = math.floor(a*1.01)
        if a >= x:
            print(i+1)
            exit()






Measured memory_bytes: 9100
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]

def main():
    from builtins import int, map
    N, K = map(int, input().split())
    count = [0] * (N + 1)
    for _ in range(K):
        di = int(input())
        Ai = list(map(int, input().split()))
        for a in Ai:
            count[a] += 1
    ans = 0
    # print(count)
    for v in count[1:]:
        if v == 0:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 68132
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
    string s,a,b,c;
    int i,j,k,n,m;
    while(1){
        cin >> a >> n;
        if(a == "-") break;
        for(i = 0;i < n;i++){
            cin >> m;
            s = a.substr(0,m);
            b = a.substr(m);
            a = b + s;
        }
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 3208
M=99;main(n,i,j,k,a,b,c){
	float p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%f,%f",X+i,Y+i);
		for(a=i=0;i<n;i++){
			for(b=k=0;k<M;k++){
				x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
				for(c=0,j=i;j<n;j++){
					if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-3)c++;
				}
				if(b<c)b=c;
			}
			if(a<b)a=b;
		}
	}
exit(0);}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=150;
//ここまでテンプレ
int main(){
	int N;
	cin>>N;
	vll A;
	for(int i=0;i<N;i++){
		ll a;
		cin>>a;
		A.pb(a);
	}
	ll ans=0;
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			ans=max(ans,abs(A[i]-A[j]));
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    vector<string> st;
    vector<bool> used(26);

    REP(i,s.size()){
        REP(j,26){
            if(!used[j] && s[i] - 'a' < j){
                string t = s.substr(0,i) + char('a'+j);
                st.push_back(t);
                break;
            }
        }
        used[s[i]-'a']=true;
    }

    REP(i,26){
        if(used[i]==0){
            string t = s + (char)('a'+i);
            st.push_back(t);
            break;
        }
    }

    VSORT(st);
    if(st.size()==0) cout<<-1<<endl;
    else cout<<st[0]<<endl;

}

Measured memory_bytes: 256
#include<atcoder/all>
using namespace atcoder;

#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
    string S; cin >> S;
    int N = S.size();
    vector<int> SA = suffix_array(S);
    vector<int> LCP = lcp_array(S, SA);
    LL ans = N - SA[0];
    rep(i, LCP.size())
        ans += (N - SA[i + 1]) - LCP[i];
    printf("%lld\n", ans);

    return 0;
}

Measured memory_bytes: 15632
import sys
argVec = sys.argv
if len(argVec) > 1:
    GBN_DEBUG = True
else:
    GBN_DEBUG = False

#S = input()
N = int(input())
#S, T = input().split()
#N, M = map(int, input().split())
#W = [input() for _ in range(N)]
#A = A = list(map(int, input().split()))

def dprn(s, i):
    if GBN_DEBUG:
        print(", " + s + " = " + str(i), end = "")

def dprns(s):
    if GBN_DEBUG:
        print(", " + s, end = "")

def dprni(i):
    if GBN_DEBUG:
        print(str(i), end=" ")

def puts(s):
    print(s)

def puti(i):
    print(str(i))

import math
sqrtN = int(math.sqrt(N))

div = 1
for i in range(sqrtN, 0, -1):
    if (N % i) == 0:
        div = i
        break

#ans = N / div + div - 2
ans = N // div + div - 2
puti(ans)

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

using namespace std;
typedef long long ll;

signed main(signed argc, char *argv[]) {
    int n;
    cin >> n;

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

    int cnt = 0;
    for(int i=1; i < n-1; i++) {
        if (P[i-1] < P[i] and P[i] < P[i+1]) cnt++;
        else if (P[i-1] > P[i] and P[i] > P[i+1]) cnt++;
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
// AtCoder Begginer Contest 136 B - Uneven Numbers
// https://atcoder.jp/contests/abc136/tasks/abc136_b

#include<iostream>
using namespace std;
using uint = unsigned int;

int main() {
	uint N;
	cin >> N;
	
	uint sum;
	
	if (N < 10) {
		sum = N;
	} else if (N < 100) {
		sum = 9;
	} else if (N < 1000) {
		sum = 9 + N - 99;
	} else if (N < 10000) {
		sum = 9 + 900;
	} else if (N < 100000) {
		sum = 9 + 900 + N - 9999;
	} else {
		sum = 9 + 900 + 90000;
	}
	
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#include<tuple>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

const ll mod = 1e9+7;
const ll INF = ll(1e18)+1;
const ll MAXN = 1e6;

const int MAX=510000;
struct mint
{
    ll x;
    //constructor
    mint(ll y=0):x((y%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==0)return 1;
        mint a=pow(t/2);
        a*=a;
        if(t%2==1)a*=2;
        return a;
    }

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

};

mint choose(int n, int a)
{
    mint x=1,y=1;
    rep(i,a)
    {
        x*=n-i;
        y*=i+1;
    }
    return x/y;
}
int main()
{

    int n,m;
    cin>>n>>m;
    mint dp[n+1];
    bool step[n+1];
    rep(i,n+1)
    {
        step[i]=false;
    }
    rep(i,m)
    {
        int a;
        cin>>a;
        step[a]=true;
    }
    dp[0].x=1;
    if(step[1])
    {
        dp[1].x=0;
    }
    else
    {
        dp[1].x=1;
    }
    
    for(int i=2;i<=n;i++)
    {
        dp[i]+=(step[i-1]?0:dp[i-1]);
        dp[i]+=(step[i-2]?0:dp[i-2]);
    }
    cout<<dp[n].x;
}

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

#define int long long

int toInt(std::string s){
	int ret;

	std::stringstream z;
	z << s;
	z >> ret;
	return ret;
}

int sum(std::string str){
	int n = str.size();
	int ret = 0;
	
	int pre = 0;
	for(int i = 0; i < n; ++i){
		if(str[i] == '+'){
			ret += toInt(str.substr(pre, i - pre));
			pre = i + 1;
		}
	}
	ret += toInt(str.substr(pre, n - pre));

	return ret;
}

signed main(){
	std::string s;
	std::cin >> s;
	int n = s.size();
	int a = (1 << (n - 1));

	int ans = 0;
	for(int i = 0; i < a; ++i){
		std::string p = s;
		for(int j = 0; j < (n - 1); ++j){
			if((i >> j) & 1)p.insert(n - j - 1, "+");
		}

		ans += sum(p);
	}

	std::cout << ans << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		int Count = 0;
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 1;i < 10; i++) {
			if( n % i == 0) {
				int j = n/i;
				if(j<= 9) {
					Count++;
				}
			}
		}
		if(Count == 0) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}
	}
}

Measured memory_bytes: 22740
// 解き直し.
// https://img.atcoder.jp/arc076/editorial.pdf
// C++(GCC 9.2.1)
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
#define repex(i, a, b, c) for(int i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define a first
#define b second

int main(){
    
    // 1. 入力情報.
    int R, C, N;
    scanf("%d %d %d", &R, &C, &N);
    priority_queue<P, vector<P>, greater<P>> lPQ, uPQ;
    priority_queue<P> rPQ, dPQ;
    rep(i, N){
        int x1, y1, x2, y2;
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
        bool b1 = (x1 > 0 && x1 < R && y1 > 0 && y1 < C);
        bool b2 = (x2 > 0 && x2 < R && y2 > 0 && y2 < C);
        if(b1 || b2) continue;
        int n = i + 1;
        if(x1 == 0 && y1 > 0) lPQ.push({y1, n}); // 左辺.
        if(y1 == C && x1 > 0) uPQ.push({x1, n}); // 上辺.
        if(x1 == R && y1 < C) rPQ.push({y1, n}); // 右辺.
        if(y1 == 0 && x1 < R) dPQ.push({x1, n}); // 下辺.
        if(x2 == 0 && y2 > 0) lPQ.push({y2, n}); // 左辺.
        if(y2 == C && x2 > 0) uPQ.push({x2, n}); // 上辺.
        if(x2 == R && y2 < C) rPQ.push({y2, n}); // 右辺.
        if(y2 == 0 && x2 < R) dPQ.push({x2, n}); // 下辺.
    }
    
    // 2. 長方形(4辺)を, 時計回りに見ていく.
    // 2-1. 左辺.
    stack<int> st;
    while(!lPQ.empty()){
        P p = lPQ.top();
        lPQ.pop();
        if(!st.empty()){
            // 前回出現した整数と同じ場合は, stackの要素を減らす.
            if(st.top() == p.b) st.pop();
            else                st.push(p.b);
        }else{
            st.push(p.b);
        }
    }
    
    // 2-2. 上辺.
    while(!uPQ.empty()){
        P p = uPQ.top();
        uPQ.pop();
        if(!st.empty()){
            // 前回出現した整数と同じ場合は, stackの要素を減らす.
            if(st.top() == p.b) st.pop();
            else                st.push(p.b);
        }else{
            st.push(p.b);
        }
    }
    
    // 2-3. 右辺.
    while(!rPQ.empty()){
        P p = rPQ.top();
        rPQ.pop();
        if(!st.empty()){
            // 前回出現した整数と同じ場合は, stackの要素を減らす.
            if(st.top() == p.b) st.pop();
            else                st.push(p.b);
        }else{
            st.push(p.b);
        }
    }
    
    // 2-4. 下辺.
    while(!dPQ.empty()){
        P p = dPQ.top();
        dPQ.pop();
        if(!st.empty()){
            // 前回出現した整数と同じ場合は, stackの要素を減らす.
            if(st.top() == p.b) st.pop();
            else                st.push(p.b);
        }else{
            st.push(p.b);
        }
    }
    
    // 3. 出力.
    bool ok = (st.size() == 0);
    printf("%s\n", ok ? "YES" : "NO");
    return 0;
    
}

Measured memory_bytes: 5488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	int ans = 1e9;

	vi digsum(n);
	rep(i,1,n)
		digsum[i] = i%10 + digsum[i/10];

	rep(a,1,n){
		int b = n - a;
		int res = digsum[a] + digsum[b];
		ans = min(ans, res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
typedef struct{
    int d;
    int p;
}Data;
int comp(const void *a,const void *b){
    Data c = *(Data *)a;
    Data d = *(Data *)b;
    if(c.p>d.p) return -1;
    else return 1;
}
int main(void){
    while(1){
        int n,m;
        scanf("%d%d",&n,&m);
        if(n+m==0)break;
        Data x[10000];
        for(int i=0;i<n;i++){
            scanf("%d%d",&x[i].d,&x[i].p);
        }
        qsort(x,n,sizeof(Data),comp);
        for(int i=0;i<n;i++){
            if(m>=x[i].d){
                m-=x[i].d; x[i].d=0;
            }else{
                x[i].d-=m; m=0;
            }
            if(m==0) break;
        }
        int sum=0;
        for(int i=0;i<n;i++){
            sum+=x[i].d*x[i].p;
        }
        printf("%d\n",sum);
    }
}



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

int main() {
	int a,b,c,d;
  cin >> a >> b >> c >> d;
  int ans = min(b,d) - max(a,c);
  if(ans < 0) ans = 0;
  cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
name:
Algorithm:
writer:Lxs(cdx)
place:
nothing is impossible
*/
#pragma GCC optimize(3,"Ofast","inline")
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
bool prime(int x){
	 int i;
	 if(x<2) return 0;
	 for(i=2;i*i<=x;i++){
		if(x%i==0){return 0;}
	 }
	 return 1;
}
int main()
{
	int i;
	int a,b;
	int n;
	cin>>n;
	cin>>a>>b;
	for(i=a;i<=b;i++){
		if(i%n==0){
			cout<<"OK"<<endl;return 0;
		}
	}
	cout<<"NG"<<endl;
	return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin >> n;
	string s ;
	cin >> s;
	if(n%2==1)cout <<"No";
	else{
		int i;
		for(i=0;i<n;i++){
			if(s[i]!=s[i+n/2])break;
		}
		if(i==n/2)cout<<"Yes";
		else cout << "No";
		
		
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <sstream>
#include <string>
#include <cstdio>
#include <array>

using namespace std;

int main(void) {
    int x,y,tmp;
    cin >> x >> y;
    
    if(x<y) swap(x,y); //y????°??????????????????????
    
    while( y!=0 ) {
        x = x%y;
        if(x<y) swap(x,y); //y????°??????????????????????
    }
    
    cout << x << endl;
    
    return 0;
}

Measured memory_bytes: 3080
#include<iostream>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <vector>
#include <map>
#include <functional>
#include <iomanip>
#include <queue>

#define PI 3.14159265358979
#define MOD 1000000007

//fixed << setprecision(15) <<

using namespace std;

int main(void) {
	long long int a, b, l, m, n;
	long long int h[100000];
	string s, t;
	char u;
	int i, j, k;
	bool flag[100000];
	cin >> n >> m;
	for (i = 0; i < n; i++) {
		cin >> h[i];
		flag[i] = true;
		}
	for (i = 0; i < m; i++) {
		cin >> a >> b;
		a--;
		b--;
		if (h[a] == h[b]) {
			flag[a] = false;
			flag[b] = false;
		}
		else if (h[a] > h[b])flag[b] = false;
		else if (h[a] < h[b])flag[a] = false;
	}
	l = 0;
	for (i = 0; i < n; i++) {
		if (flag[i] == true)l++;
	}
	cout << l << endl;
		/*if(flag)cout << "Yes" << endl;
			else cout << "No" << endl;*/
	return 0;
}

Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1e5+5;
vector<ll> adj[N];
ll dfs(ll node){
    vector<ll> a;
    for(auto &v:adj[node])a.push_back(dfs(v));
    sort(a.begin(),a.end());
    ll ans = 0;
    for(auto &ele:a)ans=max(ans,ele)+1;
    return ans;
}
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n;cin>>n;
    for(ll i=2,x;i<=n;i++)cin>>x,adj[x].push_back(i);
    cout<<dfs(1);
}

Measured memory_bytes: 13568
import java.util.Scanner;

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

		int k = sc.nextInt();
		String s = sc.next();

		int len = s.length();

		if (len <= k) {
			System.out.println(s);
		} else {
			System.out.println(s.substring(0, k) + "...");
		}
		sc.close();

	}
}

Measured memory_bytes: 26972
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions
from decimal import Decimal
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = [inpl() for _ in range(n)]
now = nx = ny = 0
for i,z in enumerate(a):
    t,x,y = z
    nex = now + abs(nx-x) + abs(ny-y)
    if nex > t or (t-nex)%2:
        print('No')
        break
    now = t
    nx = x; ny = y
    # print(now)
else:
    print('Yes')

Measured memory_bytes: 82136
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define pb(a) push_back(a)
using namespace std;
typedef long long ll;

int main()
{
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    int v, c;
    REP(i, N)
    {
        cin >> v;
        V.at(i) = v;
    }

    REP(i, N)
    {
        cin >> c;
        C.at(i) = c;
    }

    vector<int> data(N);

    REP(i, N)
    {
        data.at(i) = V.at(i) - C.at(i);
    }

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

    int ans = 0;
    REP(i, N)
    {
        if (data.at(i) > 0)
            ans += data.at(i);
        else
        {
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import heapq
N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range (0, N):
	A[i] = -1*A[i]

A = sorted(A)

heapq.heapify(A)

import math

for i in range (0, M):
	V = heapq.heappop(A)
	V = math.ceil(V/2)
	heapq.heappush(A, V)
  
print(-1*sum(A))

Measured memory_bytes: 87256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)

int main(){
	ll x1,x2,x3,y1,y2,y3,s,i,j,k=1000000000,m;
	cin >> s;
	double v;
	x1 = 0; y1 = 0;
	/*if(s<=k)cout << 0 << " " << 0 << " " << s << " " << 0<< " " << 0 << " " <<
		" " << 1;
	else*/
	v = double(s);
	v = sqrt(v);
	m = int(v);
	if(double(m)!=v)m++;
	
	for (i = 1; i <= (m/2)+1; i++) {
		
		for (j = i; (m / 2) + 1; j++) {
			if (i*j == s) {
				x2 = i; y3 = j; y2 = 0; x3 = 0; goto aaa;
			}
			if ((m * m - i * j) == s) {
				x2 = m; y3 = m; y2 = i; x3 = j; goto aaa;
			}
			if ((m-i) *(m- j) == s) {
				x2 = m-i; y3 = m-j; y2 = 0; x3 = 0; goto aaa;
			}
			if ((m * m - (m-i) * (m-j)) == s) {
				x2 = m; y3 = m; y2 = m-i; x3 =m- j; goto aaa;
			}
		}	
	}



aaa:
	cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 <<" " << y3;
	return 0;
}

Measured memory_bytes: 384
#短い版
n, m = [int(v) for v in input().split()]
a_s = [[1, int(v)] for v in input().split()]
bc_s = [[int(v) for v in input().split()] for i in range(m)]
bc_s.extend(a_s)

bc_s_sorted_by_c = sorted(bc_s, key=lambda x:x[1], reverse=True)

ans = 0
room = n
for i in range(len(bc_s_sorted_by_c)):
  bc = bc_s_sorted_by_c[i]
  count, value = bc
    
  if room < count:
    count = room
  ans += value * count
  room -= count
  if room <= 0:
    break
    
print(ans)

Measured memory_bytes: 40784
#include<bits/stdc++.h>
using namespace std;
int main(){
   int n,k;cin>>n>>k;
   double p=0;
   
   for (int i = 1; i <= n; i++)
   {
       /* code */
       double first=1.0/n;
       int sum=i;
       while (sum < k)
       {
           /* code */
           sum*=2;
           first/=2.0;
       }
       p+=first;

   }
   cout<<setprecision(20)<<p<<endl;

   
   
}

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

bb = 0
cc = 0
while  a >= b:
  b = 2*b
  bb += 1

while b >= c:
  c = 2*c
  cc += 1
  

if bb + cc <= k:
  print('Yes')
else:
  print('No')



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

using namespace std;

int main()
{
	string w, ans = "Yes";
	int k = 0;
	cin >> w;
	vector<int> n;
	n.push_back(0);

	sort(w.begin(), w.end());

	char ch = w[0];
	for (int i = 0;i < w.size();i++)
	{
		if (ch != w[i])
		{
			ch = w[i];
			n.push_back(0);
			k++;
		}

		n[k]++;
	}

	for (int i = 0;i < n.size();i++)
		if (n[i] % 2 != 0)ans = "No";

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
using System;

public class Program
{
    public void Solve()
    {
        var sc = new Scanner();
        string S = sc.Next();
        bool[] f = new bool[256];
        foreach (char c in S)
        {
            f[c] = true;
        }
        
        for (char c = 'a'; c <= 'z'; c++)
        {
            if (!f[c])
            {
                Console.WriteLine(c.ToString());
                return;
            }
        }
        Console.WriteLine("None");
    }

    public static void Main(string[] args)
    {
        new Program().Solve();
    }
}

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

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

int main(){
  int h,w;
  cin>>h>>w;
  vector<string> a(h);
  for(int i=0; i<h; ++i)cin>>a[i];
   
  int dp[1010][1010]={0};
  dp[0][0]=1;
  
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      if(j+1<w && a[i][j+1]=='.'){
        dp[i][j+1]+=dp[i][j];
        dp[i][j+1]%=1000000007;
      }
      if(i+1<h && a[i+1][j]=='.'){
        dp[i+1][j]+=dp[i][j];
        dp[i+1][j]%=1000000007;
      }
    }
  }

  cout<<dp[h-1][w-1]<<endl;
}


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

typedef long long ll;
#define INF 0x3f3f3f3f3f3f3f3f
#define MOD 1000000007
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define foreach(i, v) for (__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
const double pi = acos(-1.0);

int r;

int main(){
  cin>>r;
  cout<<r*r<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template<int mod>
struct ModInt{
    int x;

    ModInt() : x(0) {}
    
    ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    
    ModInt &operator+=(const ModInt &p){
        if((x += p.x) >= mod)   x -= mod;
        return *this;
    }
    
    ModInt &operator-=(const ModInt &p){
        if((x += mod - p.x) >= mod) x -= mod;
        return *this;
    }

    ModInt &operator*=(const ModInt &p){
        x = (int)(1LL * x * p.x % mod);
        return *this;
    }

    ModInt &operator/=(const ModInt &p){
        *this *= p.inverse();
        return *this;
    }
    
    ModInt operator-() const {return ModInt(-x);}

    ModInt operator+(const ModInt &p) const {return ModInt(*this) += p;}

    ModInt operator-(const ModInt &p) const {return ModInt(*this) -= p;}

    ModInt operator*(const ModInt &p) const {return ModInt(*this) *= p;}

    ModInt operator/(const ModInt &p) const {return ModInt(*this) /= p;}

    bool operator==(const ModInt &p) const {return x == p.x;}

    bool operator!=(const ModInt &p) const {return x != p.x;}

    ModInt inverse() const{
        int a = x, b = mod, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }

    ModInt pow(int64_t n) const{
        ModInt ret(1), mul(x);
        while(n > 0){
            if(n & 1)   ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }

    friend ostream &operator<<(ostream &os, const ModInt &p){
        return os << p.x;
    }

    friend istream &operator>>(istream &is, ModInt &a){
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }

    static int get_mod() {return mod;}
};

using modint = ModInt<mod>;

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

    int N;
    cin >> N;
    vector<modint> A(N);
    for(int i = 0; i < N; ++i)  cin >> A[i];
    vector<modint> S(N + 1);
    for(int i = 1; i <= N; ++i) S[i] = S[i - 1] + modint(i).inverse();
    modint ans = 0;
    for(int i = 0; i < N; ++i){
        modint P = S[i + 1] + S[N - i] - S[1];
        ans += P * A[i];
    }
    for(int i = 1; i <= N; ++i) ans *= i;
    cout << ans << endl;
}

Measured memory_bytes: 3860
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"

using namespace std;

const long long int MOD = 1000000007;
const long long int exa = 1000000000000000000;
//const int MOD = 1000000007;
//const int MOD = 998244353;

long long int N, M, K, H, W, L, R;
//int N, M, K, H, W, L, R;

long long int power(long long int x, long long int n, long long int M) {
	long long int tmp = 1;

	if (n > 0) {
		tmp = power(x, n / 2, M);
		if (n % 2 == 0) tmp = (tmp*tmp) % M;
		else tmp = (((tmp*tmp) % M)*x) % M;
	}
	return tmp;
}

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

	cin >> N >> K;
	vector<long long int>by(N + K + 1, 1);
	vector<long long int>two_by(N + K + 1, 1);
	vector<long long int>rev_by(N + K + 1, 1);
	vector<long long int>rev_two_by(N + K + 1, 1);
	for (int i = 1; i <= N + K; i++) {
		two_by[i] = two_by[i - 1] * 2;
		two_by[i] %= MOD;
		rev_two_by[i] = power(two_by[i], MOD - 2, MOD);
		by[i] = by[i - 1] * i;
		by[i] %= MOD;
		rev_by[i] = power(by[i], MOD - 2, MOD);
	}
	long long int nap = 0, nbp = 0;
	for (int i = 1; i <= N + K; i++) {
		if (i > 1) {
			if (N < i) {
				long long int add = by[i - 2];
				add *= rev_by[N - 1];
				add %= MOD;
				add *= rev_by[i - N - 1];
				add %= MOD;
				add *= rev_two_by[i - 1];
				add %= MOD;
				nap += add;
				nap %= MOD;
			}
			if (K < i) {
				long long int add = by[i - 2];
				add *= rev_by[K - 1];
				add %= MOD;
				add *= rev_by[i - K - 1];
				add %= MOD;
				add *= rev_two_by[i - 1];
				add %= MOD;
				nbp += add;
				nbp %= MOD;
			}
		}
		//cout << i << " " << nap << " " << nbp << endl;
		long long int ret = 1 + MOD * 2;
		ret -= nap;
		ret += nbp;
		ret %= MOD;
		ret *= rev_two_by[1];
		ret %= MOD;
		cout << ret << endl;
	}
	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define debug(a) cout << #a ": " << a << endl
using namespace std;
typedef long long ll;
const int N = 2e5 + 7;
vector<int> g[N];
int main(void){
    IOS;
    int n; cin >> n;
    for (int i = 2; i <= n; ++i){
        int f; cin >> f;
        g[f].push_back(i);
    }
    for (int i = 1; i <= n; ++i){
        cout << g[i].size() << endl;
    }
    return 0;
}

Measured memory_bytes: 14552
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
#define yes cout<<"Yes"
#define no cout<<"No"
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;
ll MOD=1000000007;
int main(){
 string n;
  cin>>n;
  ll x=0;
  rep(i,n.size()){
   int m=n[i]-'0';
    x+=m;
  }
  if(x%9==0) yes;
 else no;
return 0;
}

Measured memory_bytes: 3728
X, N = map(int, input().split(' '))
if N != 0:
    P_n = list(map(int, input().split(' ')))

    for i in range(X, 150):
        if i not in set(P_n):
            min_1 = i
            break
    for i in range(X, -150, -1):
        if i not in set(P_n):
            min_2 = i
            break
    if abs(min_1-X) == abs(min_2-X):
        print(min(min_1, min_2))
    elif abs(min_1-X) < abs(min_2-X):
        print(min_1)
    else:
        print(min_2)
else:
    print(X)

Measured memory_bytes: 9100