akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
import sys
import operator


def solve(N: int, M: int, a: "List[int]", b: "List[int]"):

    AB = list(zip(a,b))
    AB.sort(key=operator.itemgetter(1))

    db = []
    for a,b in AB:
        bAppend = True
        for di in db:
            if a <= di < b:
                bAppend = False
                break
        if bAppend:
            db.append(b-1)

    print(len(db))


    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int()] * (M)  # type: "List[int]" 
    b = [int()] * (M)  # type: "List[int]" 
    for i in range(M):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
    solve(N, M, a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 19820
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    map<string,int>m;
    m.insert(make_pair("SAT",6));
    m.insert(make_pair("SUN",7));
    m.insert(make_pair("MON",1));
    m.insert(make_pair("TUE",2));
    m.insert(make_pair("WED",3));
    m.insert(make_pair("THU",4));
    m.insert(make_pair("FRI",5));
    string s;
    cin>>s;
    int d=m["SUN"]-m[s];
    if(d==0)
    {
        cout<<"7"<<endl;

    }
    else
        cout<<d<<endl;
    return 0;
}


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

   ll a,b;
  cin>>a>>b;
  vector<string>v;
  string h;
  for(int i=1;i<=b+2;i++)
  {
      h+="#";
  }
  //cout<<h<<endl;
  for(int i=1;i<=a;i++)
  {
      string s;
      cin>>s;
      v.push_back(s);
  }
  cout<<h<<endl;
  for(int i=0;i<a;i++)
  {
      cout<<"#"<<v[i]<<"#"<<endl;
  }
  cout<<h<<endl;



}










Measured memory_bytes: 3624
use std::io;

fn procon_read<T: std::str::FromStr>() ->  Vec<T> {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v: Vec<T> = Vec::new();
	for i in iter {
		v.push(i.parse().ok().unwrap());
	}
	v
}

fn main() {
	let v:Vec<i32> = procon_read();
	let r = v[0];
	let g = v[1];
	let b = v[2];
	let s = format!("{}{}{}", r, g, b);
	let i : i32 = s.parse().ok().unwrap();
	if i%4 == 0 {
		println!("YES");
	}else{
		println!("NO");
	}
}

Measured memory_bytes: 4352
S = input()
len_s = len(S)-1
count = 0
ss = []
for i in range(2**len_s):
  binary = format(i, 'b').zfill(len_s+2)[2:]
  tmp=[S[0]]
  for j in range(len(binary)):
    if binary[j] =='1':
      tmp.append(S[j+1])
    else:
      tmp[-1] = tmp[-1]+S[j+1]
  count += sum(int(i) for i in tmp)
print(count)

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  int n;
  cin >> n;
  vector<int> up(n+1),down(n+1);
  up[0] = 0;
  REP(i,n+1){
    if(!i)continue;
    cin >> up[i];
    up[i] += up[i-1];
  }
  down[0] = 0;
  REP(i,n+1){
    if(!i)continue;
    cin >> down[i];
    down[i] += down[i-1];
  }
  int res = 0;
  for(int i = 1;i <= n;i++){
    int sum = up[i]-up[0]+down[n]-down[i-1];
    res = max(res,sum);
  }
  cout << res << endl;



  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int Q = 998244353;
const int N = 209;
ll x[N], y[N], p[N], f[N], size[N];
inline int read() {
    int s = 1, a = 0; char ch = getchar();
    while (ch < '0' || ch > '9') {if (ch == '-') s = -1; ch = getchar();}
    while (ch >= '0' && ch <= '9') {a = a * 10 + ch - '0'; ch = getchar();}
    return s * a;
}
inline int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}
inline int findSet(int x) {
    return f[x] == x ? x : f[x] = findSet(f[x]);
}
inline void unionSet(int x, int y) {
    int fx = findSet(x), fy = findSet(y);
    if (fx != fy) {
        f[fy] = fx;
        size[fx] += size[fy];
    }
}
struct Seg {
    int p, q; ll hash;
    bool operator < (const Seg &rhs) const {
        return hash < rhs.hash;
    }
};
vector<Seg> seg;
int main() {
    p[0] = 1;
    for (int i = 1; i < N; i++) {
        p[i] = p[i - 1] << 1, p[i] %= Q;
    }
    int n = read();
    for (int i = 1; i <= n; i++) {
        x[i] = read(), y[i] = read();
    }
    ll res = (p[n] - n - 1) % Q;
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dx = x[i] - x[j], dy = y[i] - y[j], g = gcd(dx, dy);
            dx /= g, dy /= g;
            if (dx == 0) dy = 1;
            if (dy == 0) dx = 1;
            if (dx < 0) dx *= -1, dy *= -1;
            Seg s; s.p = i, s.q = j, s.hash = dx * 100000 + dy;
            seg.push_back(s);
        }
    }
    sort(seg.begin(), seg.end());
    for (int i = 0, j = 0; i < seg.size(); i = j) {
        for (int k = 1; k <= n; k++) {
            f[k] = k, size[k] = 1;
        }
        for (; j < seg.size() && seg[i].hash == seg[j].hash; j++) {
            unionSet(seg[j].p, seg[j].q);
        }
        for (int k = 1; k <= n; k++) {
            if (f[k] == k && size[k] >= 2) {
                res -= (p[ size[k] ] - size[k] - 1), res += Q, res %= Q;
            }
        }
    }
    res += Q, res %= Q;
    printf("%lld\n", res);
    return 0;
}

Measured memory_bytes: 892
def insertion_sort(A, increment):
    global N
    global swap
    for i in range(increment, N):
        key = A[i]
        j = i - increment
        while A[j] > key and j >= 0:
            A[j + increment] = A[j]
            j -= increment
            swap += 1
        A[j+increment] = key
    
def shell_sort(A, G): 
    for g in G:
        insertion_sort(A,g)
    return swap
        

N = int(input())
swap = 0 
A = [None for _ in range(N)]
for j in range(N):
    A[j] = int(input())
G = []
start = 1
while start <= N:
    G.append(start)
    start = 3 * start + 1
G = G[::-1]
print(len(G))
print(' '.join(list(map(str, G))))
swap = shell_sort(A, G)
print(swap)
for _ in A:
    print(_)


Measured memory_bytes: 45492
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    XY_pos = []
    XY_neg = []
    balance = 0
    for _ in range(N):
        S = input().rstrip('\n')
        st = []
        for s in S:
            if s == "(":
                st.append(s)
            else:
                if st:
                    if st[-1] == "(":
                        st.pop()
                    else:
                        st.append(s)
                else:
                    st.append(s)
        x = y = 0
        for s in st:
            if s == "(":
                y += 1
            else:
                x += 1
        balance += x - y
        if x > y:
            XY_neg.append((x, y))
        else:
            XY_pos.append((x, y))
    if balance:
        print("No")
        exit()

    XY_pos.sort(key=lambda p: p[0])
    val = 0
    for x, y in XY_pos:
        if x > val:
            print("No")
            #print(x, y, val)
            exit()
        val += y - x
    XY_neg.sort(key=lambda p: p[1], reverse=True)
    for x, y in XY_neg:
        if x > val:
            print("No")
            #print(x, y, val)
            exit()
        val += y - x
    print("Yes")


if __name__ == '__main__':
    main()


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

int main() {
    string s;
    cin >> s;
    int a, b;

    for (int i = 0; i < s.size(); i++) {
        if(s.at(i) == 'Z') {
            b = i;
        }
    }

    for(int j = s.size()-1; j >= 0; j--) {
        if(s.at(j) == 'A') {
            a = j;
        }
    }

    cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	char s;
	cin>>s;
	cout<<(char)(s+1)<<endl;
	return 0;
}


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

#define mod 1000000007

using namespace std;
typedef long long ll; 
 
int main(void){
	
	int N;
	
	cin >> N;
	
	int p[N], ps[N];
	
	for(int i=0; i<N; i++){
		cin >> p[i];
		ps[i] = p[i];
	}
	
	sort(ps, ps+N);
	
	int count = 0;
	for(int i=0; i<N; i++){
		if(p[i] != ps[i])
			count++;
	}
	
	if(count == 0 || count == 2)
		cout << "YES";
	else
		cout << "NO";

	/*int count = 0;
	int a[2], j = 0;
	for(int i=1; i<N; i++){
		if(p[i] < p[i-1]){
			count++;
			if(count >= 3){
				cout << "NO";
				return 0;
			}
			a[j] = p[i-1];
			j++;
		}	
	}
	*/
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <cmath>
#include <utility>

using namespace std;

int main(){

    int N = 0;
    cin >> N;
    string s;
    //cin >> s;
    
    int groupNum = 0;

    if(N == 3){
        groupNum = 1;
    }else if(N > 3){
        groupNum = N / 3 + 1;
        if(N % 3 < 3){
            groupNum--;
        }
    }else{
        groupNum = 0;
    }
    
    cout << groupNum;
}

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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int a, b, c;
    string s;
    cin >> a;// >> b >> c;
    //cin >> s;
    cout << a * a * 3 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int a[10];
string b[10];

bool isSet(int i,int j,int k){
	if(a[i]!=a[j]||a[j]!=a[k])
		if(a[i]+1!=a[j]||a[j]+1!=a[k])
			return false;
	if(b[i]!=b[j]||b[j]!=b[k])return false;
	return true;
}

int main() {
	int n=in();
	while(n--){
		int i;
		for(i=0;i<9;i++){
			cin>>a[i];
		}
		for(i=0;i<9;i++){
			cin>>b[i];
		}
		int per[]={0,1,2,3,4,5,6,7,8};
		int win=0;
		do{
			if(isSet(per[0],per[1],per[2])&&isSet(per[3],per[4],per[5])&&isSet(per[6],per[7],per[8])){
				win=1;
				break;
			}
		}while(next_permutation(per,per+9));
		cout<<win<<endl;
	}
	return 0;
}

Measured memory_bytes: 964
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
#define N 210000
using namespace std;
int n,m,a[N],b[N],ans,num;
struct node{int l,r,c;}A[N];
int solve(int lim)
{
    for(int i=1;i<=m;i++) b[i]=(a[i]>=lim);
    num=0;
    int i=1;
    while(i<m)
    {
        if(b[i]!=b[i+1]) {i++;continue;}
        A[++num].l=i;A[num].c=b[i];
        while(i<m && b[i+1]==b[i]) i++;
        A[num].r=i;
    }
    if(num==0) return b[1];
    A[0].r=0;
    for(int i=1;i<=num;i++)
    {
        int l=A[i-1].r+1,r=A[i].l-1;
        if(l>r) continue;
        int mid=(l+r)/2;
        A[i-1].r=mid;A[i].l=mid+1;
    }
    int l=A[num].r+1,r=m,mid;
    if(l<=r) {mid=(l+r)/2;A[num].r=mid;}
    for(int i=1;i<=num;i++) if(A[i].l<=n && A[i].r>=n) return A[i].c;
}
int main()
{
    scanf("%d",&n);
    m=2*n-1;
    for(int i=1;i<=m;i++) scanf("%d",&a[i]);
    int l=1,r=m;
    while(l<=r)
    {
        int mid=(l+r)/2;
        if(solve(mid)) ans=mid,l=mid+1;
        else r=mid-1;
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 2944
#include<cstdio>
using namespace std;
int za[10001][10001],kati[10001],omo[1001];
int main(void)
{
	int w,n,i,j,x,p,max,mm;
	x=0;

	scanf("%d",&w);
	scanf("%d",&n);
	while(!(w==0)){
		for(i=0;i<=n;i++){
			for(j=0;j<=w;j++){
				za[i][j]=-1;
			}
		}
		for(i=0;i<n;i++){
			scanf("%d,%d",&kati[i],&omo[i]);
		}
		za[0][0]=0;
		for(i=0;i<n;i++){
			for(j=0;j<=w;j++){
				if(za[i][j]!=-1){
					if(za[i+1][j+omo[i]]<za[i][j]+kati[i] && j+omo[i]<=w){
						za[i+1][j+omo[i]]=za[i][j]+kati[i];
						
					}
					if(za[i+1][j]<za[i][j]){
						za[i+1][j]=za[i][j];
					}
				}
			}
		}
		/*for(i=0;i<=n;i++){
			for(j=0;j<=w;j++){
				printf("%8d",za[i][j]);
			}
			printf("\n");
		}*/
		max=-1;
		mm=-1;
		for(i=0;i<=w;i++){
			if(za[n][i]!=-1){
				if(za[n][i]>max){
					max=za[n][i];
					mm=i;
				}
			}
		}
		x++;
		printf("Case %d:\n",x);
		printf("%d\n",max);
		printf("%d\n",mm);
		scanf("%d",&w);
		scanf("%d",&n);
	}
	
	return 0;
}

Measured memory_bytes: 40356
#include "bits/stdc++.h"

using namespace std;

//using Matrix = vector< vector<int> >;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9 + 10;
//const ll INF = 1e18 + 10LL;
int dx[5] = {0, 0, 1, -1, 0}, dy[5] = {1, -1, 0, 0, 0};
const double EPS = 1e-10;
bool cmp(P a, P b) { return a.second < b.second; } //End sort (Interval scheduling problem)
ll MOD = 1e9 + 7;

double n;
int k;

double ans;

int main(void){
	cin>>n>>k;
	
	for (int i = 1; i <= n; i++) {
		double tmp = 1.0 / n;

		int now = i;
		while (now < k) now *= 2, tmp /= 2;

		ans += tmp;
	}

	printf("%.12f\n", ans);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7L;

int N;
int d[105];
int ans;

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

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

sort(d,d+N);

for(int i=1; i<N; i++){
  if(d[i]>d[i-1]) ans++;
}

ans++;

cout<<ans<<endl;

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[200010],b[200010];
long long ans=0;
bool w=false;
struct node{
	long long pos,val;
	bool operator <(const node &b)const{
		return val<b.val;
	}
};
priority_queue<node>q;
int main(){
	scanf("%lld",&n);
	for(long long i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(long long i=1;i<=n;i++){
		scanf("%lld",&b[i]);
		node tmp={i,b[i]};
		q.push(tmp);
	}
	while(q.size()){
		node now=q.top();q.pop();
		long long l=(now.pos-2+n)%n+1,r=now.pos%n+1;
		if (b[now.pos]==a[now.pos]) continue;
		if (b[now.pos]<a[now.pos])
		{
			puts("-1");
			return 0;
		}
		if(b[now.pos]-b[l]-b[r]<a[now.pos]){
			puts("-1");
			return 0;
		}
		long long d=b[now.pos]-a[now.pos];
		ans+=d/(b[l]+b[r]);
		b[now.pos]=d%(b[l]+b[r])+a[now.pos];
		if(b[now.pos]==a[now.pos]) continue;
		node tmp={now.pos,b[now.pos]};
		q.push(tmp);
	}
	printf("%lld\n",ans); 
}


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;

const lint mod = 1e9 + 7;

lint powmod(long x, long n){
  lint ret = 1;
  while(n > 0){
    if(n&1) ret *= x, ret %= mod, n -= 1;
    else x *= x, x %= mod, n >>= 1;
  }
  return ret;
}

vector<lint> fact;
vector<lint> revfact;

void setfact(int n){
  fact.resize(n+1); revfact.resize(n+1);
  fact[0] = 1;
  rep(i, n) fact[i+1] = fact[i] * (i+1) % mod;
  
  revfact[n] = powmod(fact[n], mod-2);
  for(int i=n-1; i>=0; i--) revfact[i] = revfact[i+1] * (i+1) % mod;
}

lint getP(int n, int r){
  if(n < r) return 0;
  return fact[n] * revfact[n-r] % mod;
}

lint n, k;
vector<int> G[100010];
lint dp[100010];

lint dfs(int v){
    if(dp[v] >= 0) return dp[v];
    dp[v] = 1;
    lint cnt = 0;
    for(int nv: G[v])if(dp[nv] < 0){
        dp[v] = dp[v] * dfs(nv) % mod;
        ++cnt;
    }
    if(v == 0) dp[v] = dp[v] * k % mod * getP(k-1, cnt) % mod;
    else dp[v] = dp[v] * getP(k-2, cnt) % mod;
    return dp[v];
}

int main(){
    scanf("%lld%lld", &n, &k);
    setfact(100010);
    rep(i, n-1){
        int a, b;
        scanf("%d%d", &a, &b);
        G[--a].emplace_back(--b);
        G[b].emplace_back(a);
    }
    rep(i, n) dp[i] = -1;
    printf("%lld\n", dfs(0));
}

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

int main()
{
  int n;
  cin >> n;
  vector<P> a(n);
  rep(i,n) cin >> a[i].first >> a[i].second;
  
  vector<int> res(n);
  rep(i,n)
  {
    int cnt = 0;
    rep(j,n)
    {
      if(a[j].first < a[i].first) cnt++;
      else if(a[j].first == a[i].first && a[j].second > a[i].second) cnt++;
    }
    res[cnt] = i+1;
  }
  rep(i,n)cout << res[i] << "\n";
  
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    REP(i, N) {
        if (i == K - 1) {
            cout << (char)(int)(S[i] - 'A' + 'a');
        } else {
            cout << S[i];
        }
    }
    cout << endl;
    return 0;

    return 0;
}


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

typedef long long ll;
typedef int ii;
typedef vector<int> vi;

#define T while(t--)
#define for2(i,a,b) for(i=a;i>=b;i--)
#define for1(i,a,b) for(i=a;i<=b;i++)
#define pb push_back
//#define mp make_pair

ii main()
{
    
    ii  a; cin>>a;
    
    cout<<a+pow(a,2)+pow(a,3)<<"\n";
    

}


Measured memory_bytes: 4116
import math
N,M = map(int, input().split())
a = abs(N - M)
amari = (7 + (10**9))
if N < M:
    N,M = M,N
if a == 0:
    nd = math.factorial(N)
    print( ((nd**2)*2) % amari)

elif a == 1:
    md = math.factorial(M)
    nd = md * N
    print((md * nd) % amari)
else:
    print(0)



Measured memory_bytes: 5180
#include<cstdio>
#include<map>
#include<queue>
#include<functional>
#include<algorithm>

using namespace std;
typedef pair<int, int> P;
#define INF (1 << 30)
int n, m, a, b, c, d, x1, x2, y1, y2, cost[100][100], dist[100];
int distanc(int start, int goal){
    fill(dist, dist + n, INF);
    dist[start] = 0;
    priority_queue<P, vector<P>, greater<P> > PQ;
    PQ.push(P(0, start));
    while(!PQ.empty()){
	P tmp = PQ.top();PQ.pop();
	int from = tmp.second;
	if(dist[from] < tmp.first)continue;
	dist[from] = tmp.first;
	for(int i = 0;i < n;i++){
	    if(cost[from][i] == INF)continue;
	    if(cost[from][i] + dist[from] <= dist[i])PQ.push(P(dist[from] + cost[from][i], i));
	}
    }
    return dist[goal];
}

int main(){
    scanf("%d%d", &n, &m);
    for(int i = 0;i < n;i++)
	for(int j = 0;j < n;j++)
	    cost[i][j] = INF;
    for(int i = 0;i < m;i++){
	scanf("%d,%d,%d,%d", &a, &b, &c, &d);
	a--;b--;
	cost[a][b] = c;
	cost[b][a] = d;
    }
    scanf("%d,%d,%d,%d", &x1, &x2, &y1, &y2);
    x1--;x2--;
    int res = 0;
    res += distanc(x1, x2);
    res += distanc(x2, x1);
    printf("%d\n", y1 - y2 - res);
    return 0;
}

Measured memory_bytes: 1036
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int, input().split())
S = input()

prev = S[0]
i = 0
count = 0
run_length = []
if S[0] == '0':
    run_length.append(0)
while i < len(S):
    c = S[i]
    if c == prev:
        count += 1
    else:
        run_length.append(count) 
        count = 1
    prev = c
    i += 1
run_length.append(count) 

acc = [0] * (len(run_length) + 1)
acc[0] = 0

for i in range(len(acc) - 1):
    acc[i + 1] = acc[i] + run_length[i]

ans = 0
for i in range(0, len(acc), 2):
    j = 2 * K + 1
    x = 0
    if j + i >= len(acc):
        x = acc[-1] - acc[i]
    else:
        x = acc[j + i] - acc[i]
    ans = max(ans, x)

# for i in range(0, len(run_length), 2):
#     ans = max(ans, run_length[i])
# print(acc)
print(ans)




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

int main(){
	string ws;
	string strs[1000];
	int i = 0, j, k, counter = 0;
	cin >> ws;
	do{
		cin >> strs[i];
		i++;
	}while(strs[i-1] != "END_OF_TEXT");
	
	for(j = 0; j < ws.length(); j++){
		ws[j] = tolower(ws[j]);
	}
	for(j = 0; j < i; j++){
		for(k = 0; k < strs[j].length(); k++){
			strs[j][k] = tolower(strs[j][k]);
		}
	}
	
	for(j = 0; j < i; j++){
		if(strs[j] == ws){
			counter++;
		}
	}
	
	cout << counter << endl;
	return 0;
}

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

using namespace std;

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

}

int main()
{
    long long int n;
    cin>>n;long long sum=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            for(int k=1;k<=n;k++)
            {
                int a=gcd(i,j);
                int b=gcd(a,k);
                sum+=b;
            }
        }
    }cout<<sum;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
#include<regex>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl; }
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;


int main(void) {
	LL N, X;
	cin >> N >> X;

	vector<LL> x(N);
	rep(i, N) cin >> x[i];

	x.insert(lower_bound(ALL(x), X), X);

	if (x.size() == 2) {
		cout << abs(x[1] - x[0]) << endl;
		return 0;
	}

	vector<LL> city_dist(N);
	rep(i, N) city_dist[i] = abs(x[i] - x[i + 1]);

	LL ans = gcd(city_dist[0], city_dist[1]);
	for (int i = 2; i < N; i++) {
		ans = gcd(ans,city_dist[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1792
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

// ｎ進数を計算（-2進数などに対応）
func calcN(x, n int) []int {
	ret := make([]int, 0)
	for x != 0 {
		r := x % n
		if r < 0 {
			r += (-n)
		}
		x = (x - r) / n
		ret = append(ret, r)
	}
	if len(ret) == 0 {
		ret = append(ret, 0)
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N := getInt()

	r := calcN(N, -2)

	for i := len(r) - 1; i >= 0; i-- {
		fmt.Print(r[i])
	}
	out()
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long int
#define mp make_pair
#define pb push_back
#define ff first 
#define ss second
#define mod 1000000007
#define lim 100005
#define nfs_mw ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

ll dp[101][lim] = {}, ans = 0;

int main()
{
	int i,j,n,W,w[lim],v[lim];
	cin>>n>>W;
	for(i=1; i<=n; i++) cin>>w[i]>>v[i];
	
	for(i=1; i<=n; i++)
		for(j=1; j<=W; j++)
			dp[i][j] = max(dp[i-1][j], ((j>=w[i])?(dp[i-1][j-w[i]] + v[i]):0ll));
	
	for(i=1; i<=W; i++) ans = max(ans, dp[n][i]);
	cout<<ans;
}

Measured memory_bytes: 78336
//
// Created by yamunaku on 2020/09/20.
//

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

using namespace std;
using namespace atcoder;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

using ll = long long;
using ld = long double;
using vi = vector<int>;
using mti = vector<vector<int>>;
using vl = vector<ll>;
using mtl = vector<vector<ll>>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
template<typename T>
using heap = priority_queue<T, vector<T>, function<bool(const T, const T)>>;

using mint = modint998244353;

mint op(mint a, mint b) {
    return a + b;
}

mint e() {
    return (mint)0;
}


int main() {
    //CFS;
    int n, k;
    cin >> n >> k;
    segtree<mint, op, e> seg1(n), seg2(n);
    vi p(n);
    rep(i, n) {
        cin >> p[i];
        p[i]--;
    }
    mint ans = 0;
    mint w = k;
    w /= k - 1;
    mint geta = 1;
    rep(i, n) {
        if (i >= k) geta *= w;
        mint l = seg2.prod(0, p[i]) / geta;
        mint r = seg2.prod(p[i], n) / geta;
        ans += l - r + seg1.prod(p[i], n);
        seg1.set(p[i], 1);
        seg2.set(p[i], geta / 2);
    }
    cout << ans.val() << endl;
    return 0;
}


Measured memory_bytes: 8132
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
n = int(input())
#n, m, k = map(int, sys.stdin.readline().split())
#s = input()
#A = list(map(int, sys.stdin.readline().split()))

ans = 0
for i in range(1, n+1):
    x = n // i
    y = i * (x * (x + 1)) // 2
    ans += y

print(ans)










Measured memory_bytes: 10024
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;
int No(){
	cout<<"No";
	return 0;
}
int Yes(){
	cout<<"Yes";
	return 0;
}
int main(){
	int a[3][2]={},n;
	cin>>n;
	for(int i=0;i<n;i++){
		int tmp;
		cin>>tmp;
		for(int j=0;j<=3;j++){
			if(j==3){
				return No();
			}
			if(a[j][1]==0){
				a[j][0]=tmp;
				a[j][1]++;
				break;
			}else if(a[j][0]==tmp){
				a[j][1]++;
				break;
			}
		}
	}
	if(a[2][1]!=0){//
		if(a[0][1]!=a[1][1])return No();
		if(a[1][1]!=a[2][1])return No();
		if((a[0][0]^a[1][0])!=a[2][0])return No();
		return Yes();
	}else if(a[1][1]!=0){
		if(a[0][0]==0){
			if(a[0][1]*2!=a[1][1])return No();
			return Yes();
		}
		if(a[1][0]==0){
			if(a[1][1]*2!=a[0][1])return No();
			return Yes();
		}
		return No();
	}else if(a[0][1]!=0){//
		if(a[0][0]!=0)return No();
		return Yes();
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<tuple<string,int,int>>a;
  for(int i=1;i<=n;i++){
    string s;
    int p;
    cin>>s>>p;
    p=-p;
    a.push_back(tie(s,p,i));
  }
  sort(a.begin(),a.end());
    rep(i,n)
  cout << get<2>(a.at(i)) <<endl;
}

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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    vector<pii> games;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            games.emplace_back(i, j);
        }
    }

    int k = games.size();
    vector<vi> graph(k);
    vi in_degree(k, 0); //あるノードの入次数
    vi dp(k, 1);

    //グラフ作成
    for (int i = 0; i < n; ++i) {
        vi a(n - 1);
        for (auto& x : a) {
            cin >> x;
            --x;
        }

        for (int j = 1; j < n - 1; ++j) {
            //小さい方を前にしたい
            pii x = a[j - 1] < i ? pii{a[j - 1], i} : pii{i, a[j - 1]};
            pii y = a[j] < i ? pii{a[j], i} : pii{i, a[j]};
            
            int idx1 = lower_bound(all(games), x) - begin(games);
            int idx2 = lower_bound(all(games), y) - begin(games);

            graph[idx1].push_back(idx2);
            ++in_degree[idx2];
        }
    }

    queue<int> q;
    for (int i = 0; i < k; ++i) {
        if (in_degree[i] == 0) {
            q.push(i);
        }
    }

    int hits = 0;
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        ++hits;

        for (int v : graph[u]) {
            //dp[v] = max(dp[v], dp[u] + 1);
            dp[v] = dp[u] + 1;
            if (--in_degree[v] == 0) {
                q.push(v);
            }
        }
    }

    /*
    for (int i = 0; i < k; ++i) {
        cout << games[i].first << ' ' << games[i].second << ' ' << dp[i] << '\n';
    }
    */

    if (hits < k) {
        cout << "-1\n";
    } else {
        cout << *max_element(all(dp)) << '\n';
    }
    
    return 0;
}


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

#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define read()          freopen("in.txt","r",stdin)
#define write()         freopen("out.txt","w",stdout)
#define sf(n)           scanf("%d",&n)
#define sfd(n)          scanf("%lf",&n)
#define sl(x)           scanf("%I64d",&x)
#define sfl(n)          scanf("%lld", &n)
#define sfc(n)          scanf(" %c",&n)
#define sful(n)         scanf("%llu",&n)
#define ull             unsigned long long
#define endll           pf("\n")
#define pf              printf
#define PI              acos(-1.0)
#define eps             1e-12
#define mem(a,b)        memset(a,b,sizeof(a))
#define pb              push_back
#define xx              first
#define yy              second
#define pii             pair<int, int>
#define pll             pair<ll, ll>
#define MP make_pair
#define ll              long long
#define uniq(a)      a.erase(unique(a.begin(), a.end()), a.end())
#define cnd tree[idx]
#define lnd tree[idx<<1]
#define rnd tree[(idx<<1)+1]
#define lndp (idx<<1),(b),((b+e)>>1)
#define rndp ((idx<<1)+1),(((b+e)>>1)+1),(e)
#define inf 1999999999
#define MOD  1000000007
#define mod1 1000000009
#define var    int i,j,c=0,t,l,r,mid,z=0,k,x,y
#define aloc(n,t) ((t*)malloc((n)*sizeof(t)))

//int dx[8]={0,0,1,1,-1,-1,1,-1};  //8 direction
//int dy[8]={1,-1,1,-1,1,-1,0,0};
//int dx[4]={1,-1,0,0};  //4 direction
//int dy[4]={0,0,1,-1};

int n,m,a[200005];

int main()
{
    sf(n);sf(m);
    for(int i=0;i<m;i++)
    {
        int x;
        sf(x);
        a[x] = 1;
    }
    int c = inf,k;
    for(int i=0;i<=101;i++)
    {
        if(a[i])continue;

        if(abs(i-n)<c)
        {
            k = i;
            c = abs(i-n);
        }
    }
    pf("%d\n",k);
}


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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = INT_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;

    string dest = "AKIHABARA";

    for (char c : dest) {
        if (c == s[0])
            s = s.substr(1);
        else if (c != 'A') {
            print("NO");
            return 0;
        }
    }
    YN(s.length() == 0);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
struct edge{
    int to,weight;
    edge(int to,int weight):to(to),weight(weight){}
};
using Graph = vector<vector<int>> ;
using GraphEdge = vector<vector<int>> ;
long long modinv(long long a, long long m=MOD) {long long b = m, u = 1, v = 0;while (b) {    long long t = a / b;    a -= t * b; swap(a, b);    u -= t * v; swap(u, v);}u %= m; if (u < 0) u += m;return u;}
//MODの割り算の際にa/＝b;をa *= modinv(b,MOD);とする。
int gcd(int a, int b){if (a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a * b / gcd(a, b);}
 
int main(){
    int N;
    cin >> N;
    const int MAXN = 100001;
    int A[MAXN];
    rep(i,N){
        cin >> A[i];
    }

    map<int,int> odd;
    map<int,int> even;
    int odd_max = 0;
    int second_odd = 0;
    int second_even = 0;
    int even_max = 0;
    int odd_num,even_num;
    rep(i,N){
        if(i%2==0){
            if(odd.count(A[i])==0){
                odd[A[i]] = 1;
            }else{
                odd[A[i]]++;
            } 
            if(odd_max < odd[A[i]]){
                odd_max = odd[A[i]];
                odd_num = A[i];
            }
            
        }else {
            if(even.count(A[i])==0){
                even[A[i]] = 1;
            }else {
                even[A[i]]++;
            }
            if(even_max < even[A[i]]){
                even_max = even[A[i]];
                even_num = A[i];
            }
        }
    }
    rep(i,N){
        if(odd_num != A[i] && second_odd < odd[A[i]]){
            second_odd = odd[A[i]];
        }
        if(even_num != A[i] && second_even < even[A[i]]){
            second_even = even[A[i]];
        }
    }
    int ans ;
    if(even_num == odd_num){
        if((odd_max + second_even) > (even_max + second_odd)){
            ans = N - odd_max - second_even;
        }else ans = N - even_max - second_odd;
    }else ans = N - even_max - odd_max;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13188
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

// #define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M; cin >> N >> M ;
  vector<P> a(M);
  rep(i,M){
    cin >> a[i].first >> a[i].second ;
  }
  sort(ALL(a));
  int ans = 0;
  int i = 0;
  while(i<M){
    int l = a[i].first;
    int r = a[i].second;
    while(i<M){
      int l2 = max(a[i].first,l);
      int r2 = min(a[i].second,r);
      if(l2<r2){
        l = l2; r = r2;
        i++;
      }else{
        break;
      }
    }
    ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
lint N, K;
vector<lint> a, memo;

bool rec(lint rest){
	if(memo[rest] != -1) return memo[rest];
	for(lint i = 0; i < N; i++){
		if(rest - a[i] >= 0){
			if(!(rec(rest - a[i]))) return memo[rest] = true;
		}
	}
	return memo[rest] = false;
}

signed main(){
	cin >> N >> K;
	a.resize(N); memo.resize(K + 1, -1);
	for(lint i = 0; i < N; i++) cin >> a[i];
	if(rec(K)) cout << "First" << endl;
	else cout << "Second" << endl;
}

Measured memory_bytes: 4096
#include<iostream>
#include<string>
using namespace std;
int main(){
 int n,m;
 while(true){
 cin>>n;
 if(n==0)
 break;
 cin>>m;
 int ans=0;
 for(int i=n;i<=m;i++){
  int a=i;
  while(true){
   if(a%2!=0)
   break;
   a/=2;
  }
  while(true){
   if(a%3!=0)
   break;
   a/=3;
  }
  while(true){
   if(a%5!=0)
   break;
   a/=5;
  }
  if(a==1)
  ans++;
 }
 cout<<ans<<endl;
 }
 return 0;   
}

Measured memory_bytes: 1160
//https://blog.csdn.net/hesorchen
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define mod 1000000007
int main()
{
    string a;
    cin>>a;
    int len =a.size();
    while(len--)
    cout<<'x';
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque

N, u, v = map(int, input().split())
u -= 1
v -= 1

neighbors = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  neighbors[a-1].append(b-1)
  neighbors[b-1].append(a-1)

dist_from_u = [-1] * N
dist_from_u[u] = 0
dist_from_v = [-1] * N
dist_from_v[v] = 0

parent = deque([u])
while parent:
  p = parent.popleft()
  children = neighbors[p]
  for child in children:
    if dist_from_u[child] == -1:
      dist_from_u[child] = dist_from_u[p] + 1
      parent.append(child)

parent = deque([v])
while parent:
  p = parent.popleft()
  children = neighbors[p]
  for child in children:
    if dist_from_v[child] == -1:
      dist_from_v[child] = dist_from_v[p] + 1
      parent.append(child)

max_dist = 0
for du, dv in zip(dist_from_u, dist_from_v):
  if du < dv:
    max_dist = max(max_dist, dv)

print(max_dist - 1)

Measured memory_bytes: 29392
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import deque

def bfs(graph: list, start: int):
    n = len(graph)
    dist = [-1]*n

    que = deque([(start, 0)])

    while que:
        cur_node, cur_dist = que.popleft()
        dist[cur_node] = cur_dist

        for nex in graph[cur_node]:
            if dist[nex] < 0:
                dist[nex] = cur_dist + 1
                que.append((nex, cur_dist+1))

    return dist

n = ni()

graph = [[] for _ in range(n)]
for _ in range(n-1):
    x, y = li_()
    graph[x].append(y)
    graph[y].append(x)

fenec = bfs(graph, 0)
snuke = bfs(graph, n-1)

fenec_saki = 0
for d1, d2 in zip(fenec, snuke):
    if d1 <= d2:
        fenec_saki += 1
    elif d1 > d2:
        fenec_saki -= 1

if fenec_saki == 0:
    if n%2:
        print("Fennec")
    else:
        print("Snuke")

elif fenec_saki > 0:
    print("Fennec")

else:
    print("Snuke")

Measured memory_bytes: 59184
#include <cmath>
#include <iostream>

using namespace std;

int main(void) {
  int N, sum = 0;
  cin >> N;
  for (int i = 0; i <= N; i++) {
    if (i % 2 != 0) {
      int flag = 2;
      for (int j = 2; j <= sqrt(i); j++) {
        if (i % j == 0) {
          if (sqrt(i) != j) {
            flag += 2;
          } else {
            flag++;
          }
        }
      }
      if (flag == 8)
        sum++;
    }
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,a[105],ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n-2;i++)
		for(int j=i+1;j<=n-1;j++)
			for(int k=j+1;k<=n;k++)
			{
				int A=a[i],B=a[j],C=a[k];
				if(A>B)
					swap(A,B);
				if(B>C)
					swap(B,C);
				if(A>B)
					swap(A,B);
				if(A+B>C&&A!=B&&B!=C&&A!=C)
					ans++;
			}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3112
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s, t;
    cin >> s;
    cin >> t;
    bool isValid = true;
    for (size_t i = 0; i < s.size(); ++i) {
        if (s[i] != t[i]) {
            isValid = false;
            break;
        }
    }
    cout << (isValid ? "Yes" : "No") << endl;
    return EXIT_SUCCESS;
}

Measured memory_bytes: 3624
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)




int main() {

	ll A;
	string B;
	std::cin >> A >> B;

	ll ans = 0;
	rep(i, 0, B[3] - '0') {
		ans += A;
	}
	rep(i, 0, B[2] - '0') {
		ans += A * 10;
	}
	rep(i, 0, B[0] - '0') {
		ans += A * 100;
	}
	ans /= 100;

	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String sample = scanner.nextLine();
		if(sample.equals("A")){
			System.out.println("T");
		}else if(sample.equals("T")){
			System.out.println("A");
		}else if(sample.equals("C")){
			System.out.println("G");
		}else{
			System.out.println("C");
		}

	}
}



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

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

  if(N % 2 == 0){
    cout << 0.5 << endl;
    return 0;
    
  }else{
    double ans = (double)(N/2+1)/N;
    cout << ans << endl;
    return 0;
    
  }

}

Measured memory_bytes: 256