akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

struct point
{
    double x, y;
};
void kouch(int n, point a, point b)
{
    if(n == 0)   return;
    point s, u, t;
    double th = M_PI*60.0/180.0;
    s.x = (2.0*a.x + 1.0*b.x)/3.0;
    s.y = (2.0*a.y + 1.0*b.y)/3.0;
    t.x = (2.0*b.x + 1.0*a.x)/3.0;
    t.y = (2.0*b.y + 1.0*a.y)/3.0;
    u.x = (t.x-s.x)*cos(th) - (t.y-s.y)*sin(th) + s.x;
    u.y = (t.x-s.x)*sin(th) + (t.y-s.y)*cos(th) + s.y;

    kouch(n-1, a, s);
    cout << fixed << setprecision(8) << s.x << " " << s.y << endl;
    kouch(n-1, s, u);
    cout << fixed << setprecision(8) << u.x << " " << u.y << endl;
    kouch(n-1, u, t);
    cout << fixed << setprecision(8) << t.x << " " << t.y << endl;
    kouch(n-1, t, b);
}
int main()
{
    point a, b;
    int n;
    cin >> n;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;
   cout << fixed << setprecision(8) << a.x << " " << a.y << endl;
   kouch(n, a, b);
   cout << fixed << setprecision(8) << b.x << " " << b.y << endl;
   return 0;
}

Measured memory_bytes: 3220
import numpy as np

n, m, c = map(int, input().split())
b = np.array(list(map(int, input().split())))
ans = 0
for _ in range(n):
    a = np.array(list(map(int, input().split())))
    if sum(a*b)+c > 0:
        ans += 1

print(ans)

Measured memory_bytes: 22036
mod = 10 ** 9 + 7

n, m = map(int, input().split())
pattern = [1]
broken = -1
brokencnt = 0
if brokencnt < m:
    broken = int(input())
    brokencnt += 1
for i in range(1, n+1):
    if i == broken:
        pattern.append(0)
        if brokencnt < m:
            broken = int(input())
            brokencnt += 1
        continue

    if i == 1:
        pattern.append(pattern[i-1])
    if i > 1:
        pattern.append((pattern[i-1]+pattern[i-2]) % mod)

print(pattern[n])

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

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 (b<a) { a=b; return 1; } return 0; }

using ll = long long;

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

    else {
        return gcd(y, x % y);
    }
}

int main() {
  ll N;
  cin>>N;
  vector<ll> v(N);
  for(ll i = 0LL; i< N; i++) {
    cin>>v[i];
  }
  ll t = v[0];
  for(ll i = 0LL; i < N-1LL; i++) {
    t = gcd(t,v[i+1]);
  }
  cout<<t<<endl;
}

Measured memory_bytes: 1024
from collections import Counter


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N = read_int()
    A = read_ints()
    counter = Counter(A)
    total = 0
    for count in counter.values():
        total += count*(count-1)//2
    for a in A:
        if counter[a] > 1:
            print(total-(counter[a]-1))
        else:
            print(total)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 26780
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
const int MOD=1e9+7;
 
int main() {
    int n;
    string s,t;
    cin >> n >> s >> t;
    int ans;
    invrep(i,n+1) {
        bool flag=1;
        rep(j,i) {
            if (s[n-i+j]!=t[j]) flag=0;
        }
        if (flag) {
            ans=(n-i)*2+i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>

#define M 1000000
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
    if ( ch == 'A') return 1;
    else if ( ch == 'C') return 2;
    else if ( ch == 'G') return 3;
    else if ( ch == 'T') return 4;
    else return 0;
}

int getKey(char str[]){
    int sum = 0, p = 1, i;
    for ( i = 0; i < strlen(str); i++ ){
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1+(key%(M-1)); }

int find(char str[]){
    
   int key,i,h;
    key = getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h], str)==0) return 1;
        else if(strlen(H[h])==0) return 0;
    }

    
}

int insert(char str[]){
    
    int key,i,h;
    key = getKey(str);
    for(i=0;;i++){
        h=(h1(key)+i*h2(key))%M;
        if(strcmp(H[h], str)==0) return 1;
        else if (strlen(H[h])==0){
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
    for ( i = 0; i < n; i++ ){
        scanf("%s %s", com, str);
        
        if ( com[0] == 'i' ){
            insert(str);
        } else {
            if (find(str)){
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }
    
    return 0;
}



Measured memory_bytes: 15412
n, m = [int(x) for x in input().split(' ')]
ab = sorted([[int(x) for x in input().split(' ')] for _ in range(int(n))], key=lambda x: x[0])
res = 0
num = 0
for a, b in ab:
    if num + b >= m:
        print(res + a * (m - num))
        exit()
    else:
        res += a * b
        num += b

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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define what_is(x) cerr << #x << " is " << x << endl;

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	int n;
	cin >> n;
	if (n&1) n *= 2;
	cout << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

inline long long read()
{
	long long x=0,f=1;char ch=getchar();
	while(ch<'0' || '9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch && ch<='9')x=x*10+(ch^48),ch=getchar();
	return x*f;
}

const long long N=100009;

long long n,m,deg[N],cnt[4],col[N],tots,type;
vector<int> g[N];
bool vis[N];

inline void dfs(long long u)
{
	vis[u]=1;
	for(int i=0,v,e=g[u].size();i<e;i++)
	{
		if(!vis[v=g[u][i]])
		{
			col[v]=col[u]^1;
			cnt[col[v]]++;
			tots+=deg[v];
			dfs(v);
		}
		else if(col[v]==col[u])
			type=1;
	}
}

int main()
{
	n=read();
	m=read();

	for(long long i=1,u,v;i<=m;i++)
	{
		u=read();
		v=read();
		g[u].push_back(v);
		g[v].push_back(u);
		deg[u]++;
		deg[v]++;
	}

	long long ans=0;
	for(long long i=1;i<=n;i++)
		if(!vis[i])
		{
			type=tots=0;
			tots=deg[i];
			cnt[0]=cnt[1]=0;
			col[i]=0;cnt[col[i]]=1;
			dfs(i);
			if(!type)
				ans+=cnt[0]*cnt[1]-tots/2;
			else
				ans+=(cnt[0]+cnt[1])*(cnt[0]+cnt[1]-1ll)/2ll-tots/2;
		}

	printf("%lld\n",ans);
	return 0;
}


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

int main() {
  while(1) {
    int n, x;
    double min=1000000;
    cin >> n;
    if(n==0) break;

    for(int i=0; i<n; i++) {
      int name;
      double h, w, bmi;
      cin >> name >> h >> w;
      bmi=w/(h*h)*10000;
      if(abs(bmi-22)<min) {
	min=abs(bmi-22);
	x=name;
      }
    }
    cout << x << endl;
  }
  return 0;
}


Measured memory_bytes: 1228
#include<iostream>
#include<fstream>
#include<vector>
int main(){
    std::vector<int> v;
    char s[100];
    while(scanf("%s",s)!=EOF){
        if(s[0]=='+'){
            int a=v.back();
            //  std::cout<<"a:"<<a<<"\n";
            v.pop_back();
            int b=v.back();
            // std::cout<<"b"<<b<<"\n";
            int ans=a+b;
            v.pop_back();
            v.push_back(ans);
        }
        else if(s[0]=='-'){
            int a=v.back();
            // std::cout<<"a"<<a<<"\n";
            v.pop_back();
            int b=v.back();
            //  std::cout<<"b"<<b<<"\n";
            v.pop_back();
            int ans=b-a;
            v.push_back(ans);            
        }
        else if(s[0]=='*'){
            int a=v.back();
            //  std::cout<<"a"<<a<<"\n";
            v.pop_back();
            int b=v.back();
            // std::cout<<"b"<<b<<"\n";
            v.pop_back();
            int ans=a*b;
            v.push_back(ans);            
        }
        else{
            //  std::cout<<"x:"<<x<<"\n";
            int x=atoi(s);
            v.push_back(x);
            // std::cout<<v.back();
        }   
    }
    std::cout<<v[0]<<"\n";

}


Measured memory_bytes: 3224
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define pb push_back
const double PI = acos(-1.0);
using namespace std;

int main()
{
    faster

    ll n;
    cin>>n;

    vector<char> v;

    while(n!=0)
    {

        int z=n%26;
        n=n/26;
        if(z==0)
            z=26,n--;

        char c=char(z+96);

        //cout<<c<<endl;

        v.pb(c);


    }

    for(int i=v.size()-1; i>=0; i--)
        cout<<v[i];
    cout<<endl;




    return 0;
}


Measured memory_bytes: 3632
#define _CRT_SECURE_NO_DEPRECATE
#pragma comment(linker, "/STACK:102400000,102400000")
#include<iostream>  
#include<cstdio>  
#include<fstream>  
#include<iomanip>
#include<algorithm>  
#include<cmath>  
#include<deque>  
#include<vector>  
#include<assert.h>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include<queue>  
#include<string>  
#include<cstring>  
#include<map>  
#include<stack>  
#include<time.h>
#include<set>
#include <random>
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define mst(a,i) memset(a,i,sizeof(a))
#define fore(i,fa,fb) for(i=fa;i<=fb;++i)
#define all(n) (n.begin(),n.end())
#define F first
#define S second
typedef long long ll;
using namespace std;
const int maxn = 2e5;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll i, j, k, m, n;
	cin >> n;
	int ans = 0;
	while (n > 0)
	{
		ans++;
		n -= ans;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int N = 3e5 + 11;
int f[N][3][3], n;
char s[N];
inline int A(int x, int y){
    return x + y - (x + y >= mod ? mod : 0);
}
inline int M(int x, int y){
    return 1LL * x * y % mod;
}
int main(){
    scanf("%s", s + 1);
    n = strlen(s + 1);
    f[0][0][0] = 1;
    for(int i = 0;i < n; i++){
        for(int x = 0;x <= 2; x++){
            for(int y = 0;y <= 2; y++){
                int F = f[i][x][y];
                if(s[i+1] != '0'){
                    if(y == 0) f[i+1][x+(x!=2)][y] = A(f[i+1][x+(x!=2)][y], F);
                    else f[i+1][x][y-1] = A(f[i+1][x][y-1], F);
                }
                if(s[i+1] != '1'){
                    if(y == 2) f[i+1][x][y-1] = A(f[i+1][x][y-1], F);
                    else f[i+1][x][y+1] = A(f[i+1][x][y+1], F);
                }
            }
        }
    }
    int ans = 0;
    for(int x = 0;x <= 2; x++){
        for(int y = x;y >= 0; y--)ans = A(ans, f[n][x][y]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 11136
#include<iostream>
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;
  return 0;
}

Measured memory_bytes: 256
W,H,N = map(int,input().split())
d = 0
u = H
r = W
l = 0
for i in range(N):
    x,y,a = map(int,input().split())
    if a==1:
        l = max(l,x)
    elif a==2:
        r = min(r,x)
    elif a==3:
        d = max(d,y)
    else:
        u = min(u,y)
if r-l<=0 or u-d<=0:
    print(0)
else:
    print((r-l)*(u-d))

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define pp pop_back
#define in insert
#define ff first
#define ss second
#define e endl
#define MOD 998244353
int main()
{
    int n,p1=0,p2=0,i;
    cin>>n;
    string s,t,s1="";
    cin>>s>>t;
    for(i=0;i<2*n;i++)
    {
        if(i%2==0)
            {s1+=s[p1];
            p1++;
            }
        else
            {s1+=t[p2];
            p2++;
            }
    }
    cout<<s1<<e;


}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n,i;
	long long ans,a,b,max=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%lld%lld",&a,&b);
		if(a>max){
			max=a;
			ans=a+b;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
using namespace std;
int n,a[2000],ans;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=2*n;i++)scanf("%d",&a[i]);
	sort(a+1,a+2*n+1);
	for(int i=1;i<=2*n;i+=2)
	ans+=a[i];
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,y,x) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define print(x) printf("%lld\n",x)
#define print2(x) printf("%lld ",x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok = true, flag = false;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 333333


int main(void) {
  cin >> n >> m;
  ans = inf;
  rep(i, n) {
	ll c, t;
	cin >> c >> t;
	if (t <= m) ans = min(ans, c);
  }
  if (ans == inf) cout << "TLE" << endl;
  else cout << ans << endl;


  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sumvec(vector<S>&a){return accumulate(all(a),S());}
template<class S>S maxvec(vector<S>&a){return *max_element(all(a));}
template<class S>S minvec(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
    
    ll n,sl=0;
    cin>>n;
    char bc='D',c;
    rep(i,n){
        cin>>c;
        if(c!=bc)sl++;
        bc=c;
    }
    puta(sl);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<cstdio>
#include<string>
//#include<string>
//#include<sstream>
using namespace std;
int main()
{
	char s[30];
	int n;
	scanf("%s",&s);
	s[5]=' ';
	s[13]=' ';
	printf("%s\n",s);
}

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

int main()
{
	ll n,a,b;
    cin>>n>>a>>b;
    ll diff=max(a,b)-min(a,b);
    //cout<<diff<<"\n";
    if((diff%2)==0)
    {
        cout<<(diff/2);
        return 0;
	}
    ll x=min(2*n-(a+b), (a+b)-2);
   x=min(x, n-b+1+((b-a-1)/2));
    x=min(x, a+(b-a)/2);
    cout<<x;
        
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
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=1000000007;
//const ll mod=998244353;
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; }
ll dp[100005][2];
int main(){
    dp[0][0]=1;
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++){
       (dp[i+1][1]=3*dp[i][1])%=mod;
       if(s[i]=='0'){
           (dp[i+1][0]+=dp[i][0])%=mod;
       }
       else{
           (dp[i+1][0]+=dp[i][0]*2)%=mod;
           (dp[i+1][1]+=dp[i][0])%=mod;
       }
    }
    cout<<(dp[n][0]+dp[n][1])%mod<<endl;
}

Measured memory_bytes: 2000
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll int64_t
#define ull uint64_t
using namespace std;

int main() {
	IOS;
	int a;
	cin >> a;
	a = a + a * a + a * a * a;
	cout << a << endl;
	return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long double D;
const D EPS = 1e-10;

struct event{
	D t;
	int a, b;
	event(D t_, int a_, int b_)
	: t(t_), a(a_), b(b_) {}
	bool operator< (const event &e) const{
		return t < e.t;
	}
};

D sq(D x){ return x * x; }

int main(){
	cout << fixed << setprecision(10);
	int n;
	while(cin >> n, n){
		vector<D> px(n), py(n), pz(n), vx(n), vy(n), vz(n), r(n), vr(n);
		for(int i = 0; i < n; ++i){
			cin >> px[i] >> py[i] >> pz[i] >> vx[i] >> vy[i] >> vz[i] >> r[i] >> vr[i];
		}

		vector<event> es;
		for(int i = 0; i < n; ++i){
			es.push_back(event(r[i] / vr[i], i, i));
			for(int j = 0; j < i; ++j){
				D dx = px[i] - px[j];
				D dy = py[i] - py[j];
				D dz = pz[i] - pz[j];
				D dvx = vx[i] - vx[j];
				D dvy = vy[i] - vy[j];
				D dvz = vz[i] - vz[j];
				D sr = r[i] + r[j];
				D svr = vr[i] + vr[j];
				D a = sq(dvx) + sq(dvy) + sq(dvz) - sq(svr);
				D b = dx * dvx + dy * dvy + dz * dvz + sr * svr;
				D c = sq(dx) + sq(dy) + sq(dz) - sq(sr);

				D tm = -1.0;
				if(abs(a) < EPS){
					if(abs(b) > EPS){
						tm = -c / (2.0 * b);
					}
				}
				else{
					D d = b * b - a * c;
					if(d > EPS){
						d = sqrt(d);
						D t1 = (-b + d) / a;
						D t2 = (-b - d) / a;
						if(t1 > t2){ swap(t1, t2); }
						if(t1 > 0.0){
							tm = t1;
						}
						else{
							tm = t2;
						}
					}
				}

				if(tm > 0.0){
					es.push_back(event(tm, i, j));
				}
			}
		}

		sort(es.begin(), es.end());
		vector<D> ans(n, -1.0L);
		for(size_t i = 0; i < es.size(); ++i){
			int a = es[i].a, b = es[i].b;
			if(ans[a] < 0.0 && ans[b] < 0.0){
				ans[a] = ans[b] = es[i].t;
			}
		}

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

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////
ll H,W,K;
char s[333][333];
ll ans[333][333];
ll i, j, k,l;

int main(){
    scanf("%lld%lld%lld", &H,&W,&K);
    fornum(i,0,H){
        scanf("%s", s[i]);
    }
    ll a = 1, b = 0;
    fornum(i,0,H){
        fornum(j,0,W){
            if(s[i][j]=='#')
                break;
        }
        if(j<W){
            fornum(j,0,W){
                fornum(k,b,i+1){
                    ans[k][j] = a;
                }
                if(s[i][j]=='#')
                    break;
            }
            fornum(j,j+1,W){
                if(s[i][j]=='#')
                    a++;
                fornum(k,b,i+1){
                    ans[k][j] = a;
                }
            }
            a++;
            b = i + 1;
        }
    }
    fornum(i,b,H){
        fornum(j,0,W){
            ans[i][j] = ans[b - 1][j];
        }
    }
    fornum(i,0,H){
        fornum(j,0,W){
            printf("%lld ", ans[i][j]);
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 1664
n = int(input())
word_list = [ input() for i in range(n) ]

ng = 0
for i in range(n-1):
  if word_list[i][-1] != word_list[i+1][0]:
    ng = 1

if len(list(set(word_list))) == n and ng == 0:
  print("Yes")
else:
  print("No")



Measured memory_bytes: 3060
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <limits.h>
#include <stdbool.h>

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a==1){
		a+=13;
	}
	if(b==1){
		b+=13;
	}
	
	if(a>b){
		puts("Alice");
	}else if(b>a){
		puts("Bob");
	}else{
		puts("Draw");
	}
	
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(auto i=0;i<n;++i)
#define REPR(i,n) for(auto i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(auto i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d",&tmp);v.push_back(tmp);}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  cin >> n;
  vector<int> v(n);
  
  REP(i,n){
    cin >> v[i];
  }

  SORTV(v);
  int ans = 0;
  REP(i,n){
    if(i != n -1){
      ans += v[i];
    }else{
      ans += v[i] / 2;
    }
  }
  cout << ans<< endl;
  return 0;
}



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

int main()
{
  //**整数の入力
  int K, X;	
  cin >> K >> X;
  
  cout << (X-K+1);
  for(int i=X-K+2; i<=X+K-1 ; i++)cout << " " << i;
  
  cout << endl;
  return 0;
  
}

  

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

#define ll long long
#define pb push_back
#define fi first
#define se second
#define vi vector<int>
#define vii vector<int,int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define umii unordered_map<int,int>
#define mii map<int,int>
#define pii pair<int,int>
#define rep(i,a,b) for(int i=a ; i<b ; i++)

const long long MOD = 1e9+7;

void solve() {
	ll x,k,d;
	cin >> x >> k >> d;
	x=abs(x);
	if(x/d >= k) {
		x=x-k*d;
		cout << x << endl;
		return;
	}
	ll y=x/d;
	x-=y*d;
	k-=y;
	if(k%2) {
		cout << min(abs(x-d), abs(x+d)) << endl;
	}
	else {
		cout << abs(x) << endl;
	}
	return;
}

signed main() 
{
	int t=1;
	// cin>>t;
	for(int i=1; i<=t; i++) {
		solve();
	}
}

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

using namespace std;

#define int long long

const int MOD = 998244353;
const int N = 2e5 + 111;
const int INF = 1e9;

int n, k;
vector<int> graph[N];
int ans = 0;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n - 1; i++)
    {
        int a, b;
        cin >> a >> b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    if (k % 2 == 0)
    {
        for (int i = 1; i <= n; i++)
        {
            vector<int> q = {i};
            vector<int> dist(n + 1, INF);
            dist[i] = 0;
            for (int j = 0; j < q.size(); j++)
            {
                int v = q[j];
                for (auto u : graph[v])
                {
                    if (dist[u] > dist[v] + 1)
                    {
                        dist[u] = dist[v] + 1;
                        if (dist[u] <= k / 2)
                        {
                            q.push_back(u);
                        }
                    }
                }
            }
            ans = max(ans, (int)q.size());
        }
    }
    else
    {
        for (int i = 1; i <= n; i++)
        {
            for (auto x : graph[i])
            {
                vector<int> q = {i, x};
                vector<int> dist(n + 1, INF);
                dist[i] = 0;
                dist[x] = 0;
                for (int j = 0; j < q.size(); j++)
                {
                    int v = q[j];
                    for (auto u : graph[v])
                    {
                        if (dist[u] > dist[v] + 1)
                        {
                            dist[u] = dist[v] + 1;
                            if (dist[u] <= k / 2)
                            {
                                q.push_back(u);
                            }
                        }
                    }
                }
                ans = max(ans, (int)q.size());
            }
        }
    }
    cout << n - ans << "\n";
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,a,b,c,d,x,y,e,f=1000000000,cnt[25][25],ans[25];
void DFS(int set,int len){ans[set]=min(len,ans[set]);for(int i=0;i<n;i++)if(len+cnt[set][i]<ans[i])DFS(i,len+cnt[set][i]);}
int main(){cin>>n>>m;
	for(int i=0;i<n;i++){ans[i]=f;for(int j=0;j<n;j++)cnt[i][j]=f;}char z;
	for(int i=0;i<m;i++){cin>>a>>z>>b>>z>>c>>z>>d;a--,b--,cnt[a][b]=c,cnt[b][a]=d;}
	int tans=0;
	cin>>x>>z>>e>>z;x--,e--;DFS(x,0);tans+=ans[e];for(int i=0;i<n;i++)ans[i]=f;DFS(e,0);tans+=ans[x];cin>>x>>z>>y;cout<<x-y-tans<<endl;
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define PQ priority_queue
#define UM unordered_map
#define ALL(a) (a).begin(),(a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
const ll INF = (1ll << 60);
typedef pair<ll,ll> pii;

int main() {
  ll H,W; cin>>H>>W;
  ll N; cin>>N;
  vi a(N); REP(i,N) cin>>a[i];
  vi v; REP(i,N) REP(j,a[i]) v.PB(i+1);
  REP(i,H) REP(j,W) {
    if(i%2) cout<<v[i*W+j];
    else cout<<v[i*W+W-1-j];
    if(j==W-1) cout<<endl;
    else cout<<' ';
  }
}


Measured memory_bytes: 640
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>




using namespace std;
int main() {
	
	int a, b;
	cin >> a >> b;
	cout << a + b / 2 << endl;

	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = N
    
for i in range(N+1):
  t = i
  cc = 0
  while t > 0:
    cc += t % 6
    t = t // 6
  t = N - i
  while t > 0:
    cc += t % 9
    t = t // 9
    
  ans = min(cc,ans)

print(ans)

Measured memory_bytes: 40940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(10);

    int T;
    // cin >> T;
    T = 1;

    while (T--) solve();
}

int N = 2505 * 55 + 55; // コスト, 頂点
using pil = pair<int, ll>;
using pli = pair<ll, int>;
vector<vector<pil> > G(N); // 行き先と cost

vector<ll> dijkstra(int s) {
  vector<ll> d(N, INF);
  //頂点、最短距離、小さい順に
  priority_queue<pli, vector<pli>, greater<pli> > q;

  d[s] = 0;
  q.push(pli(0, s));

  while (!q.empty()) {
    pli p = q.top();
    q.pop();
    int v = p.S;
    if (d[v] < p.F) continue;
    for (pil np : G[v]) {
      int nv = np.F;
      ll cost = np.S;
      if (chmin(d[nv], d[v] + cost)) {
        q.push(pli(d[nv], nv));
      }
    }
  }
  return d;
}

// https://atcoder.jp/contests/abc164/submissions/12375623
void solve() {
  int n, m, s;
  cin >> n >> m >> s;
  rep(i, m) {
    int u, v, a, b;
    cin >> u >> v >> a >> b;
    u--; v--;
    rep(j, 2501) {
      if (j - a < 0) continue;
      G[j * n + u].eb((j - a) * n + v, b); // (コスト, 頂点), 銀貨 a 枚減る
      G[j * n + v].eb((j - a) * n + u, b);
    }
  }
  rep(i, n) {
    int c, d;
    cin >> c >> d;
    rep(j, 2501) {
      G[j * n + i].eb(min(j + c, 2500) * n + i, d);
    }
  }
  auto dijk = dijkstra(min(2500, s) * n + 0);
  rep3(i, 1, n) {
    ll ans = INF;
    rep(j, 2501) chmin(ans, dijk[j * n + i]);
    cout << ans << endl;
  }
}


Measured memory_bytes: 24200
#include<bits/stdc++.h>
using namespace std;
/*------- Constants---- */

#define LL                      long long
#define Ulong                   unsigned long long
#define REP(i,n)                for(long long i=0; i < n ; i++ )
#define mp                      make_pair
#define pb                      push_back
#define all(x)                  (x).begin(),(x).end()
#define PI                      acos(-1.0)
#define EPS                     1e-14
#define F                       first
#define S                       second
#define di(x)                   int x; input(x)
#define in(x)                   input(x)
#define in2(x,y)                in(x),in(y)
#define in3(x,y,z)              in(x),in2(y,z)
#define lc                      ((n)<<1)
#define rc                      ((n)<<1|1)
#define db(x)                   cout << #x << " -> " << x << endl
#define nl                      cout<<endl
#define ms(ara_name,value)      memset(ara_name,value,sizeof(ara_name))
#define IO                      ios_base::sync_with_stdio(0);cin.tie(0)
#define READ                    freopen("/home/matrixcode/Desktop/in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
template<class T> inline void input(T &x) {
  register char c = getchar();x = 0;
  int neg = 0;
  for(; ((c<48 || c>57) && c != '-'); c = getchar());
  if(c=='-'){neg = 1;c = getchar();}
  for(; c>47 && c<58 ; c = getchar()){x = (x<<1) + (x<<3) + c - 48;}
  if(neg) x = -x;
}
inline long long bigmod(long long p,long long e,long long M){
  long long ret = 1;
  for(; e > 0; e >>= 1){
    if(e & 1) ret = (ret * p) % M;
    p = (p * p) % M;
  } return ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}

/***************************** END OF TEMPLATE *******************************/

const int N = 1005;
char g[N][N];
LL dp[N][N];
const int mod = 1e9+7;


int main()
{
  int h,w;
  in2(h,w);
  for(int i = 0; i < h ; i ++) cin >> g[i];
  dp[0][0] = 1;
  for(int i = 0; i < h; i ++) {
    for(int j = 0; j < w; j ++) {
      if(g[i][j] == '#') dp[i][j] = 0;
      else {
        if(i -1 >= 0) dp[i][j] += dp[i-1][j];
        if(j -1 >= 0) dp[i][j] += dp[i][j-1];
      }
      dp[i][j] %= mod;
    }
  }
  cout << dp[h-1][w-1] << endl;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define a 'J'
#define b 'O'
#define c 'I'
int main(void)
{
	int n=0,m=0,d=0,j=0;
	char wd[10000];
	
	cin >> wd ;
	while(j < 5){
		d = strlen(wd);
		for(int i = 0;i < d - 2;i++){
			if(wd[i] == a){
				if(wd[i+1] == b){
					if(wd[i+2] == c){
						n++;
						i += 2;
					}
				}
			}
			if(wd[i] == c){
				if(wd[i+1] == b){
					if(wd[i+2] == c){
						m++;
						i += 1;
					}
				}
			}
		}
		cout << n << endl;
		cout << m << endl;
		n = 0;
		m = 0;
		j++;
		cin >> wd;
	}
	
	return 0;
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
ll a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,ans,tmp,hoge,fuga,piyo;
ll A[200100],B[200100],C[200100],D[200100];
string st,str;
char ch;
int main(){
  cin>>st;
  n=st.length();
  for(int i=0;i<n;i++){
    if(st[i]=='?')st[i]='D';
  }
  cout<<st;
  return 0;
}


Measured memory_bytes: 3716
import math
import sys
sys.setrecursionlimit(10**8)
n, k = map(int, input().split())
a = list(map(int, input().split()))
def binary_search(left, right):
    if right - left <= 0.01:
        return right
    middle = (right + left) / 2
    if is_can(middle):
        return binary_search(left, middle)
    else:
        return binary_search(middle, right)
def is_can(target):
    count = 0
    for i in range(n):
        if a[i] > target:
            count += a[i] // target
    return count <= k
p = binary_search(0, 10**10)
if int(p) != 0 and is_can(int(p)) :
    print(int(p))
else:
    print(int(p) + 1)


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

pair<long long, long long> a[100005];
pair<double, long long> b[100005];

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

    long long n, m;
    cin >> n >> m;
    for(long long i = 0; i < n; ++i){
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n);

    long long cans = 0;
    long long yen = 0;
    for(long long i = 0; i < n; ++i){
        if(a[i].second + cans > m){
            yen += (m - cans) * a[i].first;
            break;
        }else{
            yen += a[i].second * a[i].first;
            cans += a[i].second;
        }
    }

    cout << yen << "\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
  
  int n,k; cin>>n>>k;
  if(k%2==0){
    ll x = n/k;
    ll y = n/(k/2);
    y -= x;
    cout << x*x*x+y*y*y<<endl;
  }
  else{
    ll x = n/k;
    cout << x*x*x<<endl;
  }
  
  
  
}

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


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

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

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

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	if(s[s.length()-1] == 's') {
		cout<<s+"es"<<"\n";
	} 
	else cout<<s+"s";
 	return 0;
}


Measured memory_bytes: 3660
<?php
$data = array();
$data["a"] = trim(fgets(STDIN));
$data["b"] = trim(fgets(STDIN));
$data["c"] = trim(fgets(STDIN));
$next = 'a';
while (strlen($data[$next])>0){
    $tmp = substr($data[$next],0,1);
    $data[$next] = substr($data[$next],1);
    $next = $tmp;
}
echo strtoupper($next);
?>

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

using namespace std;

using ll = long long;

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

    string s;
    cin >> s;

    int ans = INT_MAX;
    for (size_t i = 0; i + 3 <= s.size(); ++i) {
        int x = stoi(s.substr(i, 3));
        ans = min(ans, abs(x - 753));
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	mint& operator+=(const mint a){
		if((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a){
		if((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a){
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const{
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const{
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const{
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const{
		if(!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if(t&1) a *= *this;
		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;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

//istream& operator>>(istream& is, const mint& a){return is >> a.x;}
//ostream& operator<<(ostream& os, const mint& a){return os << a.x;}

// 2^n
mint f(int n){
	if(n == 0) return 1;
	mint x = f(n/2);
	x *= x;
	if(n%2 == 1) x *= 2;
	return x;
}

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

struct Combination{
	vector<mint> fact, ifact;
	Combination(int n):fact(n+1),ifact(n+1){
		assert(n < mod);
		fact[0] = 1;
		for(int i = 1; i <= n; i++) fact[i] = fact[i-1]*i;
		ifact[n] = fact[n].inv();
		for(int i = n; i >= 1; i--) ifact[i-1] = ifact[i]*i;
	}
	mint operator()(int n, int k){
		if(k < 0 || k > n) return 0;
		return fact[n]*ifact[k]*ifact[n-k];
	}
};

int loc[100005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	memset(loc, -1, sizeof(loc));
	int l = -1, r = -1;
	rep(i,n+1){
		int a;
		cin >> a;
		if(loc[a] == -1) loc[a] = i;
		else{
			l = loc[a];
			r = i;
		}
	}
	Combination comb(100005);
	for(int k = 1; k <= n+1; ++k){
		mint ans = comb(n+1, k) - comb(l + n - r, k-1);
		cout << ans.x << endl;
	}
	return 0;
}


Measured memory_bytes: 5308
#include <bits/stdc++.h>
#define rep( i, n ) for (long long i = 0; i < ( long long )(n); i++)

using namespace std;
typedef long long ll;
//typedef pair< ll , string > P;

int main(){
	ll  n,k;
	cin>>n;
	double  ans=0;
	ll ansp =0;
	ll sum2=0;
	ll sum1=0;

	rep(i,n){
		int x;
		cin>>x;
		sum1+=x;
		sum2+=x*x;
	}
	ansp= round ((double)sum1/n);
	ans = n*ansp*ansp-2*sum1*ansp+sum2;
 	cout<<ans;
}

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

int main() {
    ll n; cin >> n;
    ll ans = 0;
    for (ll i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3636
#define lp(i,n) for(int i=0;i<n;i++)
#define pau system("pause")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    int n;
    cin>>n;
    vector<tuple<int,string,int>>p;
    for(int i=0;i<n;i++){
        string s;
        int tmp;
        cin>>s>>tmp;
        p.emplace_back(i+1,s,tmp);
    }
    sort(rbegin(p),rend(p),[](const auto& e1,const auto& e2){
        return get<1>(e1)==get<1>(e2)?get<2>(e1)<get<2>(e2):get<1>(e1)>get<1>(e2);
    });
    lp(i,n){
        cout<<get<0>(p[i])<<endl;
    }
}


Measured memory_bytes: 256
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
 
ans = [-1] * (N+1)
graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)
    

from collections import deque
import sys
ans = [-1] * (N+1)
todo = deque([(1,0)])
while todo:
    x,parent = deque.popleft(todo)
    #ans[x] = parent
    for y in graph[x]:
        # if y == parent:
        #     continue
        if ans[y] != -1:
            continue
        ans[y] = x
        todo.append((y,x))
        

for i in range(2,N+1):
    if ans[i] == -1:
        print('No')
        sys.exit()
        
print('Yes')
for i in range(2,N+1):
    print(ans[i])

Measured memory_bytes: 121876
n=int(input())
G=[[] for i in range(n)]
for i in range(n-1):
    a,b,c=map(int,input().split())
    G[a-1].append((b-1,c))
    G[b-1].append((a-1,c))
q,k=map(int,input().split())
k=k-1
stack=[k]
dis=[-1]*n
dis[k]=0
while stack!=[]:
    now=stack.pop()
    d=dis[now]
    for i in G[now]:
        if dis[i[0]]==-1:
            dis[i[0]]=d+i[1]
            stack.append(i[0])
for i in range(q):
    x,y=map(int,input().split())
    x=x-1
    y=y-1
    print(dis[x]+dis[y])



Measured memory_bytes: 79932
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
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;
}
long long int big[60][2] = {};
long long hand(long long int  a, long long int b) {
	if (a == 0) {
		return 1;
	}

	if (b == 1) {
		return 0;
	}
	if (b == big[a - 1][0]+big[a-1][1] + 2) {
		return 1+big[a-1][0];
	}
	if (b == (big[a - 1][0] + big[a - 1][1])*2 + 3) {
		return big[a - 1][0]*2 + 1;
	}

	if (b > big[a-1][0] + big[a-1][1]+2) {
		return hand(a - 1, b - big[a - 1][1]-big[a-1][1]-3) + 1 + big[a - 1][0];
	}
	else {
		return hand(a - 1, b - 1);
	}
}
int main() {
	long long int n;
	long long int x;
	cin >> n>>x;
	big[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		big[i][0] = big[i - 1][0] * 2 + 1;
		big[i][1] = big[i - 1][1] * 2 + 2;
	}
	cout << hand(n,x);
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

class BUnevenNumbers {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      int ans = 0;
      for(int i=1; i<=n; i++) {
        int cnt = 0;
        int tmp = i;
        while(tmp>0) {
          cnt++;
          tmp/=10;
        }
        if (cnt%2==1) {
          ans++;
        }
      }
      cout << ans << endl;
    }
};

signed main() {
  BUnevenNumbers solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {

  val n = StdIn.readLine().toInt
  val result = Array.fill[Int](n+1, n+1)(0)
  (0 until n).foreach { _ =>
    val a = StdIn.readLine().split(' ').map(_.toInt)
    (0 until a(1)).foreach { k =>
      result(a(0))(a(2+k)) = 1
    }
  }

  (1 to n).foreach { i =>
    println(result(i).drop(1).mkString(" "))
  }


}


Measured memory_bytes: 46128