akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    double R; cin >> R;
    Out(2.0 * M_PI * R);

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    double x[n];
    string u[n];
    for(int i=0;i<n;i++){
        cin >> x[i] >> u[i];
    }
    double ans = 0;
    for(int i=0;i<n;i++){
        if(u[i] == "JPY"){
            ans += double(x[i]);
        }else{
            ans += x[i] * 380000.0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

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

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int Q;
    cin >> Q;
    long long int tp, pos, S;
    cin >> tp >> pos >> S;
    priority_queue<long long int> que1, que2;
    for(int loop = 0; loop < Q - 1; loop++){
        cin >> tp;
        if(tp == 2){
            cout << pos << " " << S << endl;
        }else{
            long long int a, b;
            cin >> a >> b;
            if(a <= pos){
                que1.push(a);
            }else{
                que2.push(-a);
            }
            S += b + abs(pos - a);
            if(que1.size() > que2.size()){
                que2.push(-pos);
                pos = que1.top();
                que1.pop();
            }else if(que2.size() - que1.size() == 2){
                long long int num = -que2.top();
                que2.pop();
                S -= abs(pos - num);
                que1.push(pos);
                pos = num;
            }
            /*
            cout << pos << " " << S << endl;
            cout << que1.size() << " " << que2.size() << endl;
            if(que1.size() > 0 && que2.size() > 0){
                cout << que1.top() << " " << que2.top() << endl;
            }
            */
        }
    }
    return 0;
}

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

int main() {
	int a, b;
	while (cin >> a >> b, a | b) {
		vector<int>c(a+b);
		for (int d = 0; d < a + b; d++)cin >> c[d];
		sort(c.begin(), c.end());
		int s = c[0];
		for (int e = 1; e < a + b; e++)s = max(s, c[e] - c[e - 1]);
		cout << s << endl;
	}
}

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int c[n-1];
  int s[n-1];
  int f[n-1];
  int i;
  int curSt;
  int time;
  for(i=0;i<n-1;i++){
    cin >> c[i] >> s[i] >> f[i];
  }
  for(i=0;i<n-1;i++){
    curSt = i+1;
    time = s[i]+c[i];
    while(curSt<n-1){
      if(time<s[curSt])time=s[curSt];
      else if(time%f[curSt]!=0)time += f[curSt] - time%f[curSt];
      else{
        time += c[curSt];
        curSt++;
      }
    }

    cout << time << endl;


    
  }
  cout << 0 << endl;
  
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
MAXAI = 100000

def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    i += 1
    A[i], A[r] = A[r], A[i]
    return i

r = partition(a, 0, n-1)

for i in range(n):
    if i == r:
        print('[', a[i], ']', sep='', end='')
    else:
        print(a[i], end='')
    if i < n-1:
        print(' ', end='')
print()



Measured memory_bytes: 16384
n = int(input())

machines = []
for i in range(n):
  x, l = map(int, input().split())
  machines.append([x+l, x-l])
machines.sort()

ans = 1
first = machines.pop(0)
stock_r = first[0]
for r,l in machines:
  if stock_r > l:
    continue
  else:
    ans += 1
    stock_r = r

print(ans)

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

typedef long long int ll;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = n / (a + b) * a;

    if(n % (a + b) > a){
        ans += a;
    }
    else{
        ans += n % (a + b);
    }

    cout << ans;

    return 0;
}

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

#ifdef DEBUG
#include "../.inc/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

const long long INF = 1e10;
const int MAXV = 2550;

struct Edge {
    long long from, to, cost;
};

long long shortest(vector<Edge> &edges, int n, int s, int t) {
    bool fromS[MAXV] = {}; fromS[s] = true;
    bool toT[MAXV] = {}; toT[t] = true;
    for (int i=0; i<n; ++i) {
        for (Edge &e: edges) {
            fromS[e.to] |= fromS[e.from];
            toT[e.from] |= toT[e.to];
        }
    }

    long long d[MAXV];
    for (int i=0; i<MAXV; ++i) d[i] = INF;
    d[s] = 0;
    for (int i=0; i<n; ++i) {
        for (Edge &e: edges) {
            if (d[e.to] > d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == n-1 && fromS[e.to] && toT[e.to]) {
                    return INF;
                }
            }
        }
    }
    return d[t];
}

int main(){
    int N, M, P;
    cin >> N >> M >> P;

    vector<Edge> edges;
    for (int i=0; i<M; ++i) {
        int A, B, C;
        cin >> A >> B >> C;
        edges.push_back((Edge){ A, B, -(C-P) });
    }

    long long score = shortest(edges, N, 1, N);
    cout << (score == INF ? -1 : max(0LL, -score)) << endl;
    
    return 0;
}


Measured memory_bytes: 576
#include <iostream>
#include <fstream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <vector>
#include <algorithm>
#include <stack>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
namespace ttkkggww
{
	class vector;
}


int main()
{
	ll S;
	cin>>S;
	//S*=2;
	ll x2,y2,x3,y3;
	ll left=0,right=1500000000;
	//二分探索
	while(1)
	{
		ll mid=(left+right)/2;
		if((mid*mid)<S)left=mid;
		else right=mid;
		if(right-left==1)break;
		//cout<<left*left<<':'<<right*right<<endl;
		//cout<<S<<endl;
	}
	x2=right;
	y3=right;
	//cout<<right*right<<endl;
	//cout<<S<<endl;
	S=(right*right)-S;
	//素因数分解
	for(ll i=1;i*i<=S;i++)
	{
		if(S%i==0)
		{
			x3=i;
			y2=S/i;
		}
	}
	cout<<0<<' '<<0<<' '<<x2<<' '<<y2<<' '<<x3<<' '<<y3<<endl;
	return 0;
}

/*
namespace ttkkggww
{
	template <typename TYPE>
	class vector
	{
		private:
		//配列の先頭のポインタ
		TYPE *ptr;
		//確保しているメモリサイズ
		int capacity;
		//使っている配列の大きさ
		int size;

		public:
		TYPE& operator [](unsigned int index);
		TYPE& operator [](int index);
		TYPE operator [](unsigned int index) const;
		TYPE operator [](int index) const;
		TYPE front ()const;
		TYPE& front();
		TYPE back()const;
		TYPE& back();

		//末尾に値を追加する
		push_back(TYPE val);
		//末尾の値を削除する
		pop_back();
		//指定した場所の値を追加する。
		insert(TYPE val,int index);
		//指定した場所の値を削除する。
		erace(TYPE val,int index);
		//最初のイテレータを返す。
		begin();
		//最後の値が入っている次のイテレータを返す。
		end();
		//コンストラクタ
		vector();
		//配列の長さを返す
		int size();
		//デストラクタ
		~vector();
	};

	template <typename TYPE>	
	vector<TYPE> ::vector(int size)
	{
		vector

	}
	
}
*/

Measured memory_bytes: 256
x, y = map(int,input().split())
ans = 0
if x == 1:
  ans += 300000
elif x == 2:
  ans += 200000
elif x == 3:
  ans += 100000

if y == 1:
  ans += 300000
elif y == 2:
  ans += 200000
elif y == 3:
  ans += 100000
if x == 1 and y == 1:
  ans += 400000
  
print(ans)
  
  
           


Measured memory_bytes: 3060
#include<stdio.h>
#define MAX 3000


void next(int B[],int n);





int main(){
int i,n,j,k;
int m;
int sum;
int A[MAX];
int B[MAX+1]={0};
int C[MAX];

scanf("%d",&n);
for(i=0;i<n;i++){scanf("%d",&A[i]);}
scanf("%d",&m);
for(i=0;i<m;i++){scanf("%d",&C[i]);}


for(j=0;j<m;j++){

for(k=0;k<=n;k++){B[k]=0;}

while(B[n]!=1){
 sum=0;
 for(i=0;i<n;i++){sum=sum+A[i]*B[i];}
 if(sum==C[j]){printf("yes\n");break;}
 else{next(B,n);}
}
if(B[n]==1){printf("no\n");}

}



return 0;
}

void next(int B[],int n){
int i;
B[0]++;
for(i=0;i<n;i++){
 if(B[i]==2){B[i+1]=B[i+1]+1;B[i]=0;}
}
}



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

using namespace std;

typedef vector<int> Vec;
typedef vector<Vec> Mat;

void dfs(int y, int x, Mat &a)
{
    if (a[y][x] == 0) return;
    a[y][x] = 0;

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

    for (int i = 0; i < 4; i++) {
        int nx = x + dx[i], ny = y + dy[i];
        if (a[ny][nx] == 1) {
            dfs(ny, nx, a);
        }
    }
}

int main()
{
    string s;
    while (cin >> s) {
        Mat a(14, Vec(14, 0));
        for (int i = 1; i < 13; i++) {
            a[1][i] = (s[i-1] - '0');
        }
            
        for (int i = 0; i < 11; i++) {
            cin >> s;
            for (int j = 1; j < 13; j++) {
                a[i+2][j] = (s[j-1] - '0');
            }
        }
        
        int cnt = 0;
        for (int i = 1; i < 13; i++) {
            for (int j = 1; j < 13; j++) {
                if (a[i][j] == 1) {
                    cnt++;
                    dfs(i, j, a);
                }
            }
        }
        cout << cnt << endl;
    }        
    return 0;
}

Measured memory_bytes: 3112
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int power(int base, int exp) {
    int res=1;
    while (exp > 0) {
       if (exp % 2 == 1) res = (res * base) % mod;
       base = (base * base) % mod;
       exp /= 2;
    }
    return res % mod;
}

int invmod(int n, int p) {
  int ans = n % mod;
  ans *= power(p, mod - 2);
  ans %= mod;
  return ans; 
}

int ncr(int n, int r) {
  int mn;
  mn = min(r, n - r);
  int pr = 1;
  int nn = n;
  for (int i = 1; i <= mn; i++) {
    pr *= nn;
    pr %= mod;
    nn--;
  }
  for (int i = 1; i <= mn; i++) {
    pr = invmod(pr, i);
  }
  return pr;
}

int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n, a, b;
  cin >> n >> a >> b;
  int ans = (power(2, n) - 1 + mod ) % mod;
  ans -= ncr(n, a);
  ans = (ans + mod) % mod;
  ans -= ncr(n, b);
  ans = (ans + mod) % mod;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())

counter = Counter(a)
sum_res = sum(a)

for i in range(q):
    b, c = map(int, input().split())
    sum_res += (c-b)*counter[b]

    counter[c] += counter[b]
    counter[b] = 0
    print(sum_res)


Measured memory_bytes: 23996
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

struct before_main{before_main(){cin.tie(0); ios::sync_with_stdio(false);}} before_main;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;

int const inf = 1e9;

template<class T> using PQ_G = priority_queue<T, vector<T>, greater<T>>;

ll dist[111][26];
ll bitcost[1<<8];
typedef tuple<int, int, int> state; // cost, time, pos

typedef tuple<int, ll, int, int> edge;
vector<vector<edge>> g;

int dijkstra(int start, int goal, int H, int S) {
  PQ_G<state> pq;
  pq.emplace(0, 0, start);

  while(!pq.empty()) {
    ll cost, stime; int pos; tie(cost, stime, pos) = pq.top(); pq.pop();

    if(pos == goal) return cost;

    for(auto && e: g[pos]) {
      int b, c, h, r; tie(b, c, h, r) = e;
      ll ntime = stime + h;
      if(ntime > H) continue;
      if(S >> r & 1) {
        if(dist[b][ntime] <= cost) continue;
        dist[b][ntime] = cost;
        pq.emplace(dist[b][ntime], ntime, b);
      }
      else {
        ll ncost = cost + c;
        if(dist[b][ntime] <= ncost) continue;
        dist[b][ntime] = ncost;
        pq.emplace(dist[b][ntime], ntime, b);
      }
    }
  }
  return inf;
}

signed main() {

  int N, M, H, K;
  while(cin >> N >> M >> H >> K && (N|M|H|K)) {
    g.clear();
    g.resize(N);

    rep(i, M) {
      int a, b, c, h, r; cin >> a >> b >> c >> h >> r;
      a --, b --; r --;
      g[a].emplace_back(b, c, h, r);
      g[b].emplace_back(a, c, h, r);
    }

    int start, goal; cin >> start >> goal; start --, goal --;

    rep(i, 1 << 8) bitcost[i] = inf;
    bitcost[0] = 0;

    int P; cin >> P;

    rep(i, P) {
      int l, d; cin >> l >> d;
      int S = 0;
      rep(j, l) {
        int k; cin >> k; k--;
        S |= 1 << k;
      }
      bitcost[S] = d;
    }

    rep(S, 1 << K) {
      if(bitcost[S] >= inf) continue;
      rep(T, 1 << K) {
        if(bitcost[T] >= inf) continue;
        bitcost[S|T] = min(bitcost[S|T], bitcost[S] + bitcost[T]);
      }
    }

    ll ans = inf;

    rep(S, 1 << K) {
      rep(i, 100) rep(j, 25)
        dist[i][j] = inf;
      dist[start][0] = 0;
      if(bitcost[S] < inf)
        minimize(ans, dijkstra(start, goal, H, S) + bitcost[S]);
    }

    cout << (ans == inf ? -1 : ans) << endl;
    
  }
  
  return 0;
}

Measured memory_bytes: 3268
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

n = int(input())
total = 0
for i in range(1,n+1):
    for j in range(i,n+1):
        for k in range(j,n+1):
            t = 1
            if i != k and i != j and j!= k:
                t = 6
            elif (i == j and i != k) or (i != j and j == k):
                t = 3
            total += gcd(i,j,k)*t
print(total)

Measured memory_bytes: 9632
#include <cstdio>
int main()
{
	int n = 0,k = 0;
	scanf ("%d %d",&n,&k);
	if (n == 1) {printf("%d",k);}
	else {
		int s = 1;
		for (int i = 1;i <=(n-1);i++)
		s =s*(k-1);
		printf ("%d\n",s*k);}
	return 0;
	}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#define rep(i,N) for(int i=0; i<N;i++)
using namespace std;

int main(){
    int N,M,ans1,ans2,p;
    string S;
    cin >> N>>M;
    vector<int> ac(N);
    vector<int> wa(N);
    rep(i,M){
        cin >> p >> S;
        if(S == "WA" and ac[p-1]!=1){
            wa[p-1]++;
        }else if(S=="AC"){
            ac[p-1]=1;
        }
    }
    ans1=0;
    ans2=0;
    rep(i,N){
        if(ac[i]==1){
            ans1+=ac[i];
            ans2+=wa[i];
        }
    }
    cout << ans1 << " " <<ans2 << endl;



    return 0;
}

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

int main() {
  int X;
  cin >> X;
  int a = X / 500;//500yenの枚数
  int b = (X % 500) / 5;//5yenの枚数
  cout << a * 1000 + b * 5 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,count=0,count1=0,count2=0,count3=0;
  cin>>n;
  string s;
  for(int i=0;i<n;i++)
  {
    cin>>s;
    if(s=="AC")
    count++;
    else if(s=="WA")
    count1++;
    else if(s=="TLE")
    count2++;
    else
    count3++;
  }
  cout<<"AC x "<<count<<endl;
  cout<<"WA x "<<count1<<endl;
  cout<<"TLE x "<<count2<<endl;
  cout<<"RE x "<<count3<<endl;
}

Measured memory_bytes: 3640
use std::io::Read;
use std::collections::HashMap;
use std::cmp::min;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    let mut counts_b: HashMap<usize, usize> = HashMap::new();
    let mut counts_c: HashMap<usize, usize> = HashMap::new();
    for i in 0..n {
        let ai = iterator.next().unwrap().parse().unwrap();
        if i % 2 == 0 {
            *counts_b.entry(ai).or_insert(0) += 1;
        } else {
            *counts_c.entry(ai).or_insert(0) += 1;
        }
    }

    let mut b = 0;
    let mut max_count_b = 0;
    for (&x, &count) in counts_b.iter() {
        if count > max_count_b {
            b = x;
            max_count_b = count;
        }
    }

    let mut c = 0;
    let mut max_count_c = 0;
    for (&x, &count) in counts_c.iter() {
        if count > max_count_c {
            c = x;
            max_count_c = count;
        }
    }

    if b != c {
        let ans = n - max_count_b - max_count_c;
        return ans.to_string();
    }

    let mut second_max_count_b = 0;
    for (&x, &count) in counts_b.iter() {
        if x == b {
            continue;
        }
        if count > second_max_count_b {
            second_max_count_b = count;
        }
    }

    let mut second_max_count_c = 0;
    for (&x, &count) in counts_c.iter() {
        if x == c {
            continue;
        }
        if count > second_max_count_c {
            second_max_count_c = count;
        }
    }

    let ans = min(
        n - second_max_count_b - max_count_c,
        n - max_count_b - second_max_count_c
    );

    return ans.to_string();
}


Measured memory_bytes: 12236
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;
#define MAX 5100000
#define MOD 1000000007
#define INF 100000000000000

int main(){
  int N;
  cin>>N;
  vector<vector<ll>> dp(N,vector<ll>(9,0));
  dp.at(0).at(0)=2;
  dp.at(0).at(1)=1;
  dp.at(0).at(2)=1;
  for(int i=1;i<N-1;i++){
    dp.at(i).at(7)=dp.at(i-1).at(3)+dp.at(i-1).at(5);
    dp.at(i).at(8)=dp.at(i-1).at(3);
    dp.at(i).at(3)=dp.at(i-1).at(1)+dp.at(i-1).at(6);
    dp.at(i).at(4)=dp.at(i-1).at(1);
    dp.at(i).at(5)=dp.at(i-1).at(1)+dp.at(i-1).at(6);
    dp.at(i).at(6)=dp.at(i-1).at(2)+dp.at(i-1).at(3)+dp.at(i-1).at(7);
    dp.at(i).at(0)=2*dp.at(i-1).at(0)+2*dp.at(i-1).at(2)+2*dp.at(i-1).at(4)+2*dp.at(i-1).at(5)+dp.at(i-1).at(7)+dp.at(i-1).at(8);
    dp.at(i).at(1)=dp.at(i-1).at(0)+dp.at(i-1).at(1)+dp.at(i-1).at(4)+dp.at(i-1).at(5)+dp.at(i-1).at(6)+dp.at(i-1).at(8);
    dp.at(i).at(2)=dp.at(i-1).at(0)+dp.at(i-1).at(2)+dp.at(i-1).at(7)+dp.at(i-1).at(8);
    for(int j=0;j<9;j++){
      dp.at(i).at(j)%=MOD;
    }
  }
  ll ans=4*(dp.at(N-2).at(0)+dp.at(N-2).at(1)+dp.at(N-2).at(2)+dp.at(N-2).at(5))+3*(dp.at(N-2).at(3)+dp.at(N-2).at(4)+dp.at(N-2).at(6)+dp.at(N-2).at(7)+dp.at(N-2).at(8));
  cout<<ans%MOD<<endl;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
Xlist = sorted(list(map(int, input().split())))[::-1]
sbn = sorted([abs(Xlist[i] - Xlist[i+1]) for i in range(M-1)])[::-1]
if N >= M:
    print(0)
else:
    print(sum(sbn[N-1:]))

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

#define INF 999999999
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pub push_back
#define pob pop_back
#ifdef LOCAL
  #define de(e) cout << "L" << __LINE__ << ": " << e << "\n" // debug echo
  #define dr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n" // debug repr
#else
  #define de(e)
  #define dr(e)
#endif
#define out(fmt, ...) printf(fmt, __VA_ARGS__); printf("\n")
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

//
// Implementation
//

#define MAXVAL 100000
bool flags[MAXVAL+1];
int counts[MAXVAL+1];

int main() {
  for (int i = 2; i <= MAXVAL; i++) {
    if (flags[i] == false) {
      for (int j = i * 2; j <= MAXVAL; j += i) {
        flags[j] = true;
      }
    }
  }

  for (int i = 3; i <= MAXVAL; i++) {
    counts[i] = counts[i-1];
    if (flags[i] == false && flags[(i+1) / 2] == false && (i % 2) != 0) {
      // cout << i << ":";
      // cout << counts[i] << " ";
      counts[i]++;
    }
  }

  int Q; cin >> Q;
  rep(i, Q) {
    int l, r; cin >> l >> r;

    int res = counts[r] - counts[l];
    if (l != 1 && flags[l] == false && flags[(l+1) / 2] == false && (l % 2) != 0) {
      res++;
    }
    cout << res << endl;
  }
}


Measured memory_bytes: 1152
score = 0
flag = 1
n = int(input())
task = []
for i in range(n):
  task.append(list(map(int,input().split())))
t = sorted(task, key=lambda x:x[1])
for i in range(n):
  score += t[i][0]
  if score > t[i][1]:
    print('No')
    flag = 0
    break
if flag == 1:
  print('Yes')

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

int main() {
	int N;
	cin >> N;
	int osum = 0;
	for(int i = 0; i < N; i++) {
		int a;
		cin >> a;
		osum |= a;
	}
	if(osum & 1)
		cout << "first" << endl;
	else
		cout << "second" << endl;
}


Measured memory_bytes: 256
n, k = gets.chomp.split.map(&:to_i)

ans = 0.0
n.times do |ii|
  i = ii + 1
  cnt = 0.0
  while i < k
    i = i * 2
    cnt += 1
  end
  ans += (1/2.0) ** cnt
end

puts ans / n.to_f


Measured memory_bytes: 1788
#[doc = " https://github.com/hatoo/competitive-rust-snippets"]
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
mod util {
    use std::fmt::Debug;
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    }
    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}
#[allow(unused_macros)]
macro_rules ! get { ( $ t : ty ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . trim ( ) . parse ::<$ t > ( ) . unwrap ( ) } } ; ( $ ( $ t : ty ) ,* ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; let mut iter = line . split_whitespace ( ) ; ( $ ( iter . next ( ) . unwrap ( ) . parse ::<$ t > ( ) . unwrap ( ) , ) * ) } } ; ( $ t : ty ; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ ( $ t : ty ) ,*; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ ( $ t ) ,* ) ) . collect ::< Vec < _ >> ( ) } ; ( $ t : ty ;; ) => { { let mut line : String = String :: new ( ) ; stdin ( ) . read_line ( & mut line ) . unwrap ( ) ; line . split_whitespace ( ) . map ( | t | t . parse ::<$ t > ( ) . unwrap ( ) ) . collect ::< Vec < _ >> ( ) } } ; ( $ t : ty ;; $ n : expr ) => { ( 0 ..$ n ) . map ( | _ | get ! ( $ t ;; ) ) . collect ::< Vec < _ >> ( ) } ; }
#[allow(unused_macros)]
macro_rules ! debug { ( $ ( $ a : expr ) ,* ) => { eprintln ! ( concat ! ( $ ( stringify ! ( $ a ) , " = {:?}, " ) ,* ) , $ ( $ a ) ,* ) ; } }
const BIG_STACK_SIZE: bool = true;
#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}
fn solve() {
    let (a, b) = get!(i64, i64);
    println!("{}", [a + b, a - b, a * b].into_iter().max().unwrap());
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef vector<double> Vec;
typedef vector<Vec> Mat;
typedef pair<ll,ll> P;
typedef pair<double,ll> Pd;
typedef pair<double,double> PD;
typedef priority_queue<P,vector<P>,greater<P> > P_queue;
typedef priority_queue<Pd,vector<Pd>,greater<Pd> > Pd_queue;

const ll MOD=998244353;
const ll mod=1000000007;
const ll INF=1e15;
const double DEL=1e-6;

#define _GLIBCXX_DEBUG
#define REP(i,a,b) for(int i=(int)a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define ALL(a) a.begin(),a.end()
#define U_ERASE(V) V.erase(unique(ALL(V)), V.end())

void Add(ll &a, ll b){a=(a+b)%mod;}
void Pro(ll &a, ll b){a=(a*b)%mod;}
const ll MAXN=2000;
mat d;

ll H,W; 
bool Kyokai(ll HH, ll WW){
    if(HH<0) return false;
    if(HH>=H) return false;
    if(WW<0) return false;
    if(WW>=W) return false;
    return true;
}

ll Solve(){
    cin>>H>>W;
    P St, Gl;
    ll x,y; cin>>x>>y; x--; y--; St=mp(x,y);
    cin>>x>>y; x--; y--; Gl=mp(x,y);
    d.resize(H);
    rep(i,H){
        string S; cin>>S;
        for(auto e:S) {
            if(e=='.') d[i].pb(INF);
            else d[i].pb(-INF);
        }
    }

    P_queue Q;
    //d[St.first][St.second]=0;
    Q.push(mp(0,St.first*MAXN+St.second));

    vec dx={1,0,-1,0}, dy={0,1,0,-1};
    vec DX, DY;
    rep(i,25) if(i!=7 && i!=11 && i!=12 && i!=13 && i!=17) DX.pb((i%5)-2);
    rep(i,25) if(i!=7 && i!=11 && i!=12 && i!=13 && i!=17) DY.pb((i/5)-2);

    //rep(i,20) cout<<DX[i]<<' '<<DY[i]<<endl;
    while(!Q.empty()){
        ll Cost=Q.top().first, hh=Q.top().second/MAXN, ww=Q.top().second%MAXN;
        //cout<<Cost<<' '<<hh<<' '<<ww<<endl;
        Q.pop();
        if(hh==Gl.first && ww==Gl.second) return Cost;
        if(Cost<d[hh][ww]){
            d[hh][ww]=Cost;
            rep(i,4){
                ll X=hh+dx[i], Y=ww+dy[i];
                if(Kyokai(X,Y)) if(d[X][Y]>Cost) Q.push(mp(Cost,X*MAXN+Y));
            }
            rep(i,20){
                ll X=hh+DX[i], Y=ww+DY[i];
                if(Kyokai(X,Y)) if(d[X][Y]>Cost+1) Q.push(mp(Cost+1,X*MAXN+Y));
            }
        }
    }
    return -1;
}

int main(){
    cout<<Solve()<<endl;
}

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


vector<int> ans;
vector<int> vec[200005]; 


void dfs(int v ,int p = -1){
  for(int u : vec[v]){
    if(u==p) continue;
    ans.at(u) += ans.at(v);
    dfs(u,v);
  }
  
}

int main() {
  int n, q;
  cin >> n;
  cin >> q;
  
  
  for (int i = 0; i < n - 1; i ++){
    int a, b;
    cin >> a;
    cin >> b;
    --a;
    --b;
    vec[a].push_back(b);
    vec[b].push_back(a);
  }
  
  ans.resize(n);

  for (int i = 0; i < q; i ++){
    int p, x;
    cin >> p;
    cin >> x;
    --p;
    
    ans[p] += x;
    
  }

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

  
}

Measured memory_bytes: 26624
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
ll n;
int main(){
    int h,w;
    cin>>h>>w;
    string s[h];
    rep(i,h) cin>>s[i];
    int a[w]={0},b[h]={0};

    for(int i=0;i<w;i++){
        bool ok = true;
        for(int j=0;j<h;j++){
            if(s[j][i]=='#') ok = false;
        }
        if(ok) a[i]=1;
    }

    for(int i=0;i<h;i++){
        bool ok = true;
        for(int j=0;j<w;j++){
            if(s[i][j]=='#') ok = false;
        }
        if(ok) b[i]=1;
    }
    /*
    rep(i,w) cout<<a[i]<<" ";
    cout<<endl;
    rep(i,h) cout<<b[i]<<" ";
    cout<<endl;
    */
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(b[i]==1 || a[j]==1);
            else cout<<s[i][j];
        }
        if(b[i]==0)cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.container;
import std.conv;
import std.format;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	input.popFront;
	auto ps = input.front.split.to!( long[] );
	ps[] -= 1;
	auto xys = new long[ 2 ][ m ];
	foreach( ref xy; xys )
	{
		input.popFront;
		xy = input.front.split.to!( long[] );
		xy[] -= 1;
	}
	
	auto uft = UnionFindTree( n );
	foreach( xy; xys )
	{
		uft.unite( xy[ 0 ], xy[ 1 ] );
	}
	
	auto ans = 0L;
	foreach( i, p; ps )
	{
		ans += uft.same( i, p );
	}
	return ans;
}

struct UnionFindTree
{
	long[] ps;
	long[] rs;
	
	this( long n )
	{
		ps.length = n;
		ps[] = -1;
		rs.length = n;
	}
	
	long root( long i )
	{
		if( ps[ i ] < 0 ) return i;
		else              return ps[ i ] = root( ps[ i ] );
	}
	
	auto same( long i, long j )
	{
		return root( i ) == root( j );
	}
	
	void unite( long i, long j )
	{
		i = root( i );
		j = root( j );
		if( i == j ) return;
		if( rs[ i ] < rs[ j ] )
		{
			ps[ j ] += ps[ i ];
			ps[ i ] = j;
		}
		else
		{
			ps[ i ] += ps[ j ];
			ps[ j ] = i;
			if( rs[ i ] == rs[ j ] ) rs[ i ]++;
		}
	}
	
	auto toString()
	{
		return ps.to!( string );
	}
}


Measured memory_bytes: 12784
#include<bits/stdc++.h>
#define ll long long
using namespace std;
inline long long read()
{
	long long s=0,f=1; char ch; for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar()) s=(s<<3)+(s<<1)+ch-'0'; return s*f;
}
int main()
{
	int N,top=0; char s[100010],ch[1000010];
	cin>>N; map<char,bool> flag;
	for(char i='a';i<='z';++i) flag[i]=0; 
	scanf("%s",s+1);
	for(int i=1;i<=N;++i)
	{
		int j=i+1;
		while(s[i]==s[j]&&j<=N) ++j;
		ch[++top]=s[i];
		i=j-1;
	}
	cout<<top<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
typedef long long ll;
using namespace std;

int main() {
	ll a,b,d;
	double c;
	cin>>a>>b;
	if(b<10){
		a=10*a+b;
	}
	else if(b==100){
		a=1000*a+b;
	}
	else{
		a=100*a+b;
	}
	c=sqrt(a);
	for(int i=0;i<=c;i++){
		d=i*i;
	}
	if(d==a){
		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;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int N;
	while (cin >> N, N) {
		vector<ll> v(N); cin >> v;
		vector<ll> s(N+1, 0);
		REP(i, N) {
			s[i+1] = s[i] + v[i];
		}
//		cout << v << endl;
//		cout << s << endl;
		ll ans = -linf;
		REP(i, N+1) FOR(j, i+1, N+1) {
			ans = max(ans, s[j]-s[i]);
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP2(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(v) (v).begin(),(v).end()
#define INF 2e9
typedef long long ll;

ll gcd(ll x,ll y){
  return y? gcd(y,x%y):x;
}

vector<pair<ll,int>> factorize(ll n){
  vector<pair<ll,int>> res;
  for(ll i=2;i*i<=n;i++){
    if(n%i) continue;
    res.emplace_back(i,0);
    while(n%i==0){
      res.back().second++;
      n/=i;
    }
  }
  if(n!=1) res.emplace_back(n,1);
  return res;
}

int main()
{
  ll a,b;
  cin>>a>>b;

  ll g=gcd(a,b);
  auto f=factorize(g);
  int ans=f.size()+1;
  cout<<ans<<endl;

  return 0;
}

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

int main() {
	int A, B, C, X;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	int ans = 0;
	int a, b, c;
	for (int x = 0; x <= A; x++) {
		a = 500 * x;
		for (int y = 0; y <= B; y++) {
			b = 100 * y;
			for (int z = 0; z <= C; z++) {
				c = 50 * z;
				if ((a + b + c) == X) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
BTC = 380000
[n] = [int(i) for i in input().split()]

sum = 0
for i in range(0, n):
    [x, u] = [i for i in input().split()]
    if u == "JPY":
        sum = sum + int(x)
    elif u == "BTC":
        sum = sum + float(x) * BTC

print(sum)


Measured memory_bytes: 2940
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }


int main() {
    ll n;
    cin>>n;
    vector<ll> v(n);
    vector<int> p(n+1);
    rep(i,n){
        cin>>v[i];
        p[v[i]]=i;
    }
    set<int> se;
    vector<pair<int,int>> left(n+1);
    vector<pair<int,int>> right(n+1);
    se.insert(p[n]);

    for(int i=n-1;i>0;i--){
        int point = p[i];
        auto c = se.lower_bound(point);
       

        if(c!=se.end()){
            right[i].first = *c;
            c++;
            if(c!=se.end()){
                right[i].second = *c;

            }else{
                right[i].second = n;
            }
        }else{
            right[i].first = n;
            right[i].second = n;
        }
        auto e = se.lower_bound(point);
        if(e!=se.begin()){
            e--;

            left[i].first= *e;

                if(e==se.begin()){
                    left[i].second= -1;
                }else{
                    e--;
                    left[i].second = *e;
                }

        }else{
            left[i].first= -1;
            left[i].second = -1;

        }

        se.insert(p[i]);
    }

//   for(int i=0;i<n;i++){
//       cout<<left[v[i]].first<<" "<<left[v[i]].second<<" ";
//       cout<<right[v[i]].first<<" "<<right[v[i]].second<<endl;
//   }
   ll ans = 0;

   for(int i=n-1;i>0;i--){
       int point = p[i];
       if(left[i].first!=-1) {
           ll lef1 = left[i].first - left[i].second ;
           ll lef2 = right[i].first - point;
           ans += lef1 * lef2*i;
       }

       if(right[i].first!=n) {
           ll ri1 = right[i].second - right[i].first ;
           ll ri2 = point - left[i].first;
           ans += ri1 * ri2*i;
       }
      

   }
   cout<<ans<<endl;







    return 0;
}


Measured memory_bytes: 7680
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    string s;
    cin >> s;

    int block_pos=0, ans = 0;
    bool flag = false;
    while(1){
        if (s.length() <= block_pos) break;
        if (s[block_pos] == '0' && s[block_pos+1] == '1') flag = true;
        else if (s[block_pos] == '1' && s[block_pos+1] == '0') flag = true;
        if (flag == true){
            flag = false;
            s.erase(s.begin()+block_pos, s.begin()+(block_pos+2));
            ans += 2;
            if (block_pos != 0) block_pos--;
        }
        else block_pos++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans = 1;
    for i in 1.. {
        if i * i > n {
            break;
        }
        ans = i * i;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
typedef long long int ll;
using namespace std;

int main()
{

    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <string>
#include <set>
#define INF 1000000000
#define LLINF 2000000000000000
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define LOOP(i,N) for(int i=0;i<N;i++)
#define LOOP1(i,N) for(int i=1;i<=N;i++)
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
// #define int long long

string deg3(int i){
	string s="000";
	s[0] += i/100;
	s[1] += (i/10)%10;
	s[2] += i%10;
	// cerr <<" " << s;
	return s;
}

signed main(){
	int n;
	cin >> n;
	string N;
	cin >> N;
	int ans = 0;
	LOOP(i,1000){
		int k = 0;
		string s=deg3(i);
		LOOP(j,N.length()){
			if(s[k]==N[j])k++;
			if(k==3){
				// cerr << "*";
				ans++;break;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
vector<int> all;
int dp[100100];
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n;
	memset(dp,63,sizeof(dp));
	dp[n]=0;
	int res=1e9;
	for(int i=n;i>0;i--){
		for(int j=6;j<=i;j*=6)
			dp[i-j]=min(dp[i-j],dp[i]+1);
		for(int j=9;j<=i;j*=9)
			dp[i-j]=min(dp[i-j],dp[i]+1);
	}
	for(int i=0;i<=n;i++){
		res=min(res,dp[i]+i);
	}
	cout<<res<<endl;
	return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    vector<ll> a(n);
    for(i = 0;i < n;++i){
        cin >> a.at(i);
    }
    sort(all(a));
    if(a.back() - a.front() > 1){
        cout << "No" << endl;
    }else if(a.back() == a.front()){
        ll k = a.back();
        ll mmin = 1;
        ll mmax;
        if(n%2) mmax = (n-1)/2;
        else mmax = n/2;
        if((mmin <= k && k <= mmax) || k == n-1){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        ll k = a.back();
        ll tmp = 0;
        for(i = 0;i < n;++i){
            if(a.at(i) == k) ++tmp;
        }
        ll mmin = 1;
        ll mmax;
        if(tmp%2) mmax = (tmp-1)/2;
        else mmax = tmp/2;
        if(mmin <= k-1 - (n - tmp - 1) && k-1 - (n - tmp - 1) <= mmax){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
# 参考URL https://note.nkmk.me/python-union-find/
class UnionFind():
    # 各要素の親要素の番号を格納するリスト
    # 要素が根（ルート）の場合は-(そのグループの要素数)を格納する
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    # 要素xが属するグループの根を返す
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # 要素xが属するグループと要素yが属するグループとを併合する
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # 要素x, yが同じグループに属するかどうかを返す
    def same(self, x, y):
        return self.find(x) == self.find(y)

def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()
    
    n, m = map(int, input().split())
    p = list(map(int, input().split()))

    uf = UnionFind(n)
    for _ in range(m):
        i, j = map(int, input().split())
        uf.union(i-1, j-1)
    
    ans = 0
    for i in range(n):
        if uf.same(i, p[i]-1):
            ans += 1
    
    print(ans)

main()

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

int main(void){
    int a, b, k;
    cin >> a >> b >> k;
    vector<int> s(101);
    for(int i=min(a, b); i >= 1; i--){
        if(a%i == 0 && b%i == 0){
            k--;
        }
        if(k == 0){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

ll power(ll x, ll n){
    ll res = 1;
    for(int i = 0; i < n; i++) res *= x;
    return res;
}

int main()
{
    char ans;
    ll n;
    cout << "? 9" << endl;
    cin >> ans;
    int l;
    if(ans == 'Y'){
        n = power(10, 10);
        cout << "? " << n << endl;
        cin >> ans;
        if(ans == 'Y'){
            cout << "! 1" << endl;
            return 0;
        }
        for(l = 10; l >= 1; l--){
            n = power(10, l - 1);
            cout << "? " << n << endl;
            cin >> ans;
            if(ans == 'Y') break;
        }
    }
    else{
        for(l = 2; l < 10; l++){
            n = power(10, l) - 1;
            cout << "? " << n << endl;
            cin >> ans;
            if(ans == 'Y') break;
        }
    }
    ll s = 0;
    for(int i = l; i > 1; i--){
        n = s + power(10, i - 2) * 8;
        cout << "? " << n << endl;
        cin >> ans;
        if(ans == 'Y'){
            n = s + power(10, i - 2) * 9;
            cout << "? " << n << endl;
            cin >> ans;
            if(ans == 'Y') s += power(10, i - 2) * 9;
            else s += power(10, i - 2) * 8;
        }
        else{
            n = s + power(10, i - 2) * 4;
            cout << "? " << n << endl;
            cin >> ans;
            if(ans == 'Y'){
                n = s + power(10, i - 2) * 6;
                cout << "? " << n << endl;
                cin >> ans;
                if(ans == 'Y'){
                    n = s + power(10, i - 2) * 7;
                    cout << "? " << n << endl;
                    cin >> ans;
                    if(ans == 'Y') s += power(10, i - 2) * 7;
                    else s += power(10, i - 2) * 6;
                }
                else{
                    n = s + power(10, i - 2) * 5;
                    cout << "? " << n << endl;
                    cin >> ans;
                    if(ans == 'Y') s += power(10, i - 2) * 5;
                    else s += power(10, i - 2) * 4;
                }
            }
            else{
                n = s + power(10, i - 2) * 2;
                cout << "? " << n << endl;
                cin >> ans;
                if(ans == 'Y'){
                    n = s + power(10, i - 2) * 3;
                    cout << "? " << n << endl;
                    cin >> ans;
                    if(ans == 'Y') s += power(10, i - 2) * 3;
                    else s += power(10, i - 2) * 2;
                }
                else{
                    n = s + power(10, i - 2) * 1;
                    cout << "? " << n << endl;
                    cin >> ans;
                    if(ans == 'Y') s += power(10, i - 2) * 1;
                    else s += power(10, i - 2) * 0;
                }
            }
        }
    }
    for(int i = 8; i >= 0; i--){
        cout << "? " << s * 100 + i * 10 << endl;
        cin >> ans;
        if(ans == 'N'){
            cout << "! " << s * 10 + i + 1 << endl;
            return 0;
        }
    }
    cout << "! " << s * 10 << endl;
}

Measured memory_bytes: 688
#include<bits/stdc++.h>
using namespace std;
long long nCk(int n,int k){
	long long r=1;
	for(int i=1;i<=k;++i){
		r*=n+1-i;
		r/=i;
	}
	return r;
}
int N,A,B,l,r;
long long v[50],p;
double s;
main(){
	cin>>N>>A>>B;
	for(int i=0;i<N;++i)cin>>v[i];
	sort(v,v+N);
	reverse(v,v+N);
	for(int i=0;i<A;++i)s+=v[i];
	l=r=A-1;
	while(l-1>=0&&v[l-1]==v[A-1])--l;
	while(r+1<N&&v[r+1]==v[A-1])++r;
	for(int i=A;i<=(l?A:B);++i)p+=nCk(r-l+1,i-l);
	printf("%.15f\n%lld",s/A,p);
}


Measured memory_bytes: 256
# https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/14/ALDS1_14_A


def solve():
    T = input()
    P = input()

    if len(T) < len(P):
        exit()

    for index, pos in enumerate(range(len(T) - len(P) + 1)):
        if T[pos:pos+len(P)] == P:
            print(index)


if __name__ == '__main__':
    solve()



Measured memory_bytes: 5576