akhauriyash/Code-Regression huggingface dataset:
def con(var):
    var=str(var)
    while(len(var)<6):
        var="0"+var
    return var


def run():
    N,M=map(int,input().split())
    P=[-1]*M
    Y=[-1]*M
    arr=[]
    for i in range(M):
        P[i],Y[i]=map(int,input().split())
        P[i]=P[i]-1
        arr.append([P[i],Y[i],i])
    arr=sorted(arr,key=lambda x:x[1])
    ans=[0]*M
    cnt=[0]*N
    for i in range(M):
        cnt[arr[i][0]]=cnt[arr[i][0]]+1
        ans[arr[i][2]]=con(arr[i][0]+1)+con(cnt[arr[i][0]])
    for i in range(M):
        print(ans[i])
run()

Measured memory_bytes: 33736
// AB156
// A問題

using System;

class A
{
    public static void Main()
    {
        var input = Console.ReadLine().Split(' ');
        int N = int.Parse(input[0]);
        int R = int.Parse(input[1]);
        int x = 0;

        if(N >= 10)
        {
            x = R;
        }
        else
        {
            x = R + 100 * (10 - N);
        }

        Console.WriteLine(x);
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
using namespace std;

struct Node {
	int key;
	Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k) {
	Node *y = NIL;
	Node *x = root;
	Node *z;
	
	z = (Node *)malloc(sizeof(Node));
	z->key   = k;
	z->left  = NIL;
	z->right = NIL;
	
	while(x != NIL) {
		y = x;
		if(z->key < x->key) {
			x = x->left;
		} else {
			x = x->right;
		}
	}
	
	z->parent = y;
	if(y == NIL) {
		root = z;
	} else {
		if( z->key < y->key) {
			y->left = z;
		} else {
			y->right = z;
		}
	}
}

void inorder(Node *u) {
	if(u == NIL) return;
	inorder(u->left);
	printf(" %d",u->key);
	inorder(u->right);
}
void preorder(Node *u) {
	if(u == NIL) return;
	printf(" %d",u->key);
	preorder(u->left);
	preorder(u->right);
}
	
int main(void) {
	int n, i, x;
	string com;
	scanf("%d",&n);
	
	for(i=0;i<n;i++) {
		cin >> com;
		if(com == "insert") {
			scanf("%d",&x);
			insert(x);
		} else if(com == "print") {
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
	}

	return 0;
}


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

int main(){
	string s, t; cin >> s >> t;

	sort(s.begin(), s.end());
	
	sort(t.begin(), t.end());
	reverse(t.begin(), t.end());

	if (s < t )cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
e=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    e.append([a-1,b-1,-c])
M=10**18
d=[0]+[M]*~-n
k=0
v=0
while k<n*2:
    k+=1
    if k==n:v=d[-1]
    f=0
    for a,b,c in e:
        if d[b]>d[a]+c:
            d[b]=d[a]+c
            f=1
    if not f:
        break
if not v or v==d[-1]:
    print(-d[-1])
else:
    print('inf')

Measured memory_bytes: 45144
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <sstream>

using namespace std;

namespace {

}
int main()
{
	int N = 0, M = 0;

	cin >> N >> M;

	std::vector<int> ship1;
	std::vector<bool> reachN(N, false);

	int a(0), b(0);
	for (int i = 0; i < M; ++i){
		cin >> a >> b;
		if (a == 1){
			ship1.push_back(b);
		}
		else if (b == N){
			reachN[a - 1] = true;
		}
	}

	bool isFound = false;
	for (auto& elem1 : ship1){
		if (reachN[elem1 - 1]){
			isFound = true;
			break;
		}

	}


	if (isFound){
		cout << "POSSIBLE";
	}
	else {
		cout << "IMPOSSIBLE";
	}

	return 0;
}


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

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];
  rep(i, n) sort(s[i].begin(), s[i].end());
  
  map<string, ll> mp;
  rep(i, n) mp[s[i]]++;
  
  ll ans = 0;
  for(auto i : mp){
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18176
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//グラフのテンプレート
template<typename T>
struct edge {
	int from, to;
	T cost;

    edge(int to,T cost):from(0),to(to),cost(cost){}
	edge(int from, int to, T cost) :from(from), to(to), cost(cost) {}
};

template<typename T>
T prim(vector<vector<edge<T>>> &g){//プリム法(最小全域木)
    using P=pair<T,int>;//firstがcost,secondが行き先

    T sum=0;
    vector<bool>used(g.size(),false);
    priority_queue<P,vector<P>,greater<P>>pq;
    pq.emplace(0,0);
    while(!pq.empty()){
        auto p=pq.top();
        pq.pop();
        if(used[p.second])continue;
        used[p.second]=true;
        sum+=p.first;
        for(auto &x: g[p.second]){
            pq.emplace(x.cost,x.to);
        }
    }
    return sum;
}
  
int n;
struct dim{
    double x,y,z,r;
    dim(double x,double y,double z,double r):x(x),y(y),z(z),r(r){}
};

double func(dim &a,dim &b){
    return max(sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2)+pow(a.z-b.z,2))-(a.r+b.r),0.0);
}

void solve(){
    vector<dim>v;
    double a,b,c,d;
    rep(i,n){
        cin>>a>>b>>c>>d;
        v.eb(a,b,c,d);
    }
    vector<vector<edge<double>>>vv(n);
    rep(i,n){
        REP(j,i+1,n){
            double s=func(v[i],v[j]);
            vv[i].eb(j,s);
            vv[j].eb(i,s);
        }
    }
    double ans=prim(vv);
    cout<<ans<<"\n";
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(3);
    while(1){
        cin>>n;
        if(n==0)return 0;
        solve();
    }
    //solve();
    return 0;
}



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

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

    int n; cin >> n;
    vector<vector<double>> dp(n, vector<double>(n+1));
    vector<double> v(n);
    for (int i = 0; i < n; i++) cin >> v[i];
    dp[0][0] = (1-v[0]); dp[0][1] = v[0];

    for (int i = 1; i < n; i++) {
        dp[i][0] = dp[i-1][0] * (1-v[i]);
        for (int j = 1; j <= i+1; j++) {
            dp[i][j] = dp[i-1][j-1] * v[i] + dp[i-1][j] * (1-v[i]);
        }
    }
    double answer = 0.0;
    for (int i = (n/2)+1; i <= n; i++) {
        answer += dp[n-1][i];
    }
    cout << fixed << setprecision(10) << answer << endl;

    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N, Q; cin >> N >> Q;
    string S; cin >> S;
    vector<int> l(Q), r(Q);
    rep(i, Q) {
        cin >> l[i] >> r[i];
    }

    // Sの中でACを探し、liがAでli+1がCとなっている時にカウントする
    // c内では累積和を入れて行く
    vector<int> c(N);
    int acsum = 0;
    rep(i, N-1) {
        if (S[i] == 'A' && S[i+1] == 'C') {
            acsum += 1;
        }
        c[i] = acsum;
        // cout << c[i];
    }
    // cout << endl;
    rep(i, Q) {
        int li=l[i]-1, ri=r[i]-1;
        if (li == 0) {
            cout << c[ri-1] << endl;
        } else {
            cout << c[ri-1] - c[li-1] << endl;
        }
    }
    return 0;
}

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

int main()
{   
    string s;

    string temp  = "CODEFESTIVAL2016";
    int count = 0;

    cin >> s;
    for(int i=0;i<16;i++)
    {
      if(s[i]!= temp[i])
         count ++;
    }

    cout << count;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

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

using namespace std;

int n, q;
int p[10000];
int r[10000];

int pfind(int x){
    return p[x] == x ? x : p[x] = pfind(p[x]);
}

int same(int a, int b){
    return pfind(a) == pfind(b);
}

void unite(int a, int b){
    int x = pfind(a);
    int y = pfind(b);

    if(r[x] > r[y]){
        p[y] = x;
    }
    else{
        p[x] = y;
        if(r[x] == r[y]){
            r[y]++;
        }
    }
}

int main(){
    scanf("%d%d", &n, &q);
    rep(i, n){
        p[i] = i;
    }
    rep(i, q){
        int c, a, b;
        scanf("%d%d%d", &c, &a, &b);
        if(c == 0){
            unite(a, b);
        }
        else {
            printf("%d\n", same(a, b));
        }
    }
    return 0;
}


Measured memory_bytes: 2832
#include <iostream>
using namespace std;
int main(void){
    string number;
    while(1){
        cin >> number;
        if(number == "0") break;
        int sum = 0;
    
        for (int i = 0;i < number.size(); i++){
            sum += number[i] - '0';
        }
        cout << sum << endl;
    }
    return 0;
}



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

    int main()
    {
        std::string a, b, c;
        std::cin >> a >> b >> c;
        int i = 0, j = 0, k = 0;
        char ch = 'a';

        int aLen = a.length(), bLen = b.length(), cLen = c.length();
    //    i++;

        while(1)
        {
            if(ch == 'a')
            {
                if(i == aLen)
                {
                    std::cout << "A" << std::endl;
                    break;
                }

                ch = a[i];
                i++;
            }
            else if(ch == 'b')
            {
                if(j == bLen)
                {
                    std::cout << "B" << std::endl;
                    break;
                }

                ch = b[j];
                j++;
            }
            else
            {
                if(k == cLen)
                {
                    std::cout << "C" << std::endl;
                    break;
                }

                ch = c[k];
                k++;
            }
        }

        return 0;
    }


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int n = s.length();
    int i = 0;
    s += 'e';
    for (i; i <= n; i++) {
        if (s[i] == 'e') {
            cout << "Yes" << endl;
            break;
        }
        else if (i % 2 == 0) {
            if (s[i] == 'L') {
                cout << "No" << endl;
                break;
            }
        }
        else{
            if (s[i] == 'R') {
                cout << "No" << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(void) {
	long long n, p;
	int cnt[1000001] = { 0 };
	long long temp, ans = 1;

	scanf("%lld %lld", &n, &p);
	if (n == 1) printf("%lld", p);
	else {
		temp = p;
		for (long long i = 2; i <= sqrt(temp); i++) {
			while (temp % i == 0) {
				temp /= i;
				cnt[i]++;
			}
		}
		for (int i = 2; i <= sqrt(p); i++) {
			for (int j = 0; j < cnt[i]/n; j++) 
				ans *= i;
		}
			printf("%lld", ans);
	}
	return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
int main()
{
    int p,q,r,a,b,c;
    scanf("%d%d%d",&p,&q,&r);
a=p+q;
b=q+r;
c=r+p;


        if(a<=b && a<=c)
            printf("%d",a);
else if(b<=a && b<=c)
    printf("%d",b);

    else
        printf("%d",c);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i,l,r) for(int i=l;i<=r;i++)
int m[401][401];
int a[401],sum[401];
int fun(int i,int j)
{
    if(m[i][j]!=-1)return m[i][j];
    if(i==j)return m[i][j]=0;
      m[i][j]=1e18;
    for(int k=i;k<j;k++)
    {   
          int cost=fun(i,k)+fun(k+1,j)-sum[i-1]+sum[j];
          if(cost<m[i][j])m[i][j]=cost;
    }
    return m[i][j];
}
signed main()
{  // freopen("input.txt", "r", stdin);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
  
  for(int i=1;i<=n;i++)
  { cin>>a[i];
    if(i==1)sum[i]=a[i];
    else sum[i]=sum[i-1]+a[i];
  }
  for(int i=0;i<=n;i++)
  {
    for(int j=0;j<=n;j++)
        m[i][j]=-1;
  }
  cout<<fun(1,n)<<endl;


    return 0;
}


Measured memory_bytes: 1536
def main():
    n = int(input())
    W = list(map(int, input().split()))
    minv = 10**5
    for i in range(n - 1):
        d = abs(sum(W[:i+1]) - sum(W[i+1:]))
        if minv > d:
            minv = d
    print(minv)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>

using namespace std;

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

  if (x < 600)
  {
    cout << 8 << endl;
  }
  else if (x < 800)
  {
    cout << 7 << endl;
  }
  else if (x < 1000)
  {
    cout << 6 << endl;
  }
  else if (x < 1200)
  {
    cout << 5 << endl;
  }
  else if (x < 1400)
  {
    cout << 4 << endl;
  }
  else if (x < 1600)
  {
    cout << 3 << endl;
  }
  else if (x < 1800)
  {
    cout << 2 << endl;
  }
  else
  {
    cout << 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val x = sc.nextInt()
    val y = sc.nextInt()
    // first: current node, second: start node
    var open = LinkedList<Pair<Int,Int>>((1..n).map { Pair(it, it) })
    val used = Array(n + 1) {
        val res = Array(n + 1) {false}
        res[it] = true
        res
    }

    for (k in 1 until n) {
        val nextOpen = LinkedList<Pair<Int,Int>>()
        var ans = 0
        while (open.isNotEmpty()) {
            val p = open.poll()
            val cur = p.first
            val start = p.second
            if (cur - 1 >= 1 && !used[start][cur - 1]) {
                nextOpen.add(Pair(cur - 1, start))
                used[start][cur - 1] = true
                ans++
            }
            if (cur + 1 <= n && !used[start][cur + 1]) {
                nextOpen.add(Pair(cur + 1, start))
                used[start][cur + 1] = true
                ans++
            }
            if (cur == x && !used[start][y]) {
                nextOpen.add(Pair(y, start))
                used[start][y] = true
                ans++
            }
            if (cur == y && !used[start][x]) {
                nextOpen.add(Pair(x, start))
                used[start][x] = true
                ans++
            }
        }
        println(ans / 2)
        open = nextOpen
    }
}

Measured memory_bytes: 123648
import math
A, B, H, M = map(int, input().split())
short = H*30 + M/60*30
long = M*6
angle = abs(short-long)
if angle > 180:
    angle = 360 - angle
ans = math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(angle)))
print(ans)


Measured memory_bytes: 9436
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100050;
typedef long long ll;

int main()
{
    int n;
    scanf("%d",&n);
    long long cnt=0;
    for(int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        while(a%2 == 0)
        {
            cnt++;
            a/=2;
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

def function(n):
    a = []
    if n < 2:
        return a
    while n%2 ==0:
        a.append(2)
        n = n//2
    i = 3
    while i*i <= n:
        if n%i ==0:
            a.append(i)
            n = n//i
        else:
            i += 2
    if n > 1:
        a.append(n)
    return a



for k in set(function(n)):
    n *= (1-1/k)
print(int(n))

Measured memory_bytes: 7748
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;
int main(){
	long long int x, y,ans=1;
	cin >> x >> y;
	while (2 * x <= y) {
		ans++;
		x = 2 * x;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define sz(a) signed(a.size())
using namespace std;

void solve(){
	ll n,x,t;
	cin >> n >> x >> t;
	ll ans = 0,val = 0;
	for(ll i=1;i<=n;i++){
		ans = x*i;
		val += t;
		if(ans>=n) break;
	}
	cout << val << "\n";
}

int main() {
    FAST;
    ll t=1;
    //cin>>t;
    while(t--) solve();	
    return 0;
}



Measured memory_bytes: 3592
# input
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

ans = 0

for i in range(N):
    tmp = 0
    for j in range(i + 1):
        tmp += A[0][j]
    for k in range(i, N):
        tmp += A[1][k]
    if tmp >= ans:
        ans = tmp

print(ans)



Measured memory_bytes: 3060
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

const int mod=924844033;

int f[2333],n,k,ans,t;

int dp[2333][2333][2][2],g[2333],tmp[2333];
int main()
{
	f[0]=1;
	for(int i=1;i<2333;i++)
		f[i]=1ll*i*f[i-1]%mod;

	get2(n,k);t=n/k+1;
	
	dp[1][0][1][0]=1;
	for(int i=1;i<=t;i++)for(int j=0;j<=i;j++)
		for(int l1=0;l1<2;l1++)for(int l2=0;l2<2;l2++)
		{
			//a[i]!=i-1,a[i]!=i+1
			dp[i+1][j][l2][0]+=dp[i][j][l1][l2];if(dp[i+1][j][l2][0]>=mod)dp[i+1][j][l2][0]-=mod;
			//a[i]=i-1
			if(l1==0)dp[i+1][j+1][l2][0]+=dp[i][j][l1][l2];if(dp[i+1][j+1][l2][0]>=mod)dp[i+1][j+1][l2][0]-=mod;
			//a[i]=i+1
			dp[i+1][j+1][l2][1]+=dp[i][j][l1][l2];if(dp[i+1][j+1][l2][1]>=mod)dp[i+1][j+1][l2][1]-=mod;
		}
	
	g[0]=1;
	for(int i=0;i<n%k;i++)
	{
		memset(tmp,0,sizeof(tmp));
		for(int j=0;j<=n;j++)for(int k=0;k<=t;k++)
			tmp[j+k]=(tmp[j+k]+1ll*g[j]*(dp[t+1][k][0][0]+dp[t+1][k][1][0]))%mod;
		memcpy(g,tmp,sizeof(g));
	}
	for(int i=n%k;i<k;i++)
	{
		memset(tmp,0,sizeof(tmp));
		for(int j=0;j<=n;j++)for(int k=0;k<t;k++)
			tmp[j+k]=(tmp[j+k]+1ll*g[j]*(dp[t][k][0][0]+dp[t][k][1][0]))%mod;
		memcpy(g,tmp,sizeof(g));
	}
	for(int i=0;i<=n;i++)if(i%2==0)ans=(ans+1ll*g[i]*f[n-i])%mod;else ans=(ans-1ll*g[i]*f[n-i]%mod+mod)%mod;
	printendl(ans);
	return 0;
}

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

int N; string S;
int main(){
    scanf("%d", &N);
    cin >> S;
    if(N%2!=0){
        printf("No"); return 0;
    }
    for(int i = 0, j = N/2; i < N/2; i++, j++){
        if(S[i] == S[j]) continue;
        printf("No"); return 0;
    }
    printf("Yes");
    return 0;
}

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

int main(){
    int n;
    int l[200];

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

    sort(l, l+2*n);

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

    return 0;
}


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

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

  if(a <= b){
    cout << a;
  }
  else{
    cout << a - 1;
  }

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,a[100],i,j,swap=0,t;
    scanf("%d",&n);
    for(i=0; i<n; i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=n-1; j>=i+1; j--)
        {
            if(a[j]<a[j-1])
            {
                t=a[j];
                a[j]=a[j-1];
                a[j-1]=t;
                swap++;
            }
        }
    }
    for(i=0; i<n; i++)
    {
        if(i!=n-1) printf("%d ",a[i]);
        else printf("%d\n",a[i]);
    }
    printf("%d\n",swap);
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	int n, k;
	cin >> n >> k;
	vi cnt(n + 1, 0);
	while (k--) {
		int d;
		cin >> d;
		while (d--) {
			int a;
			cin >> a;
			cnt[a]++;
		}
	}
	int ans = 0;
	for (int i = 1;i <= n;i++)
		if (cnt[i] == 0)
			ans++;
	cout << ans << '\n';
}


Measured memory_bytes: 3648
n,t=map(int,input().split())
a=list(map(int,input().split()))
s=[]
for i in range(n-1):
    s.append(a[i+1]-a[i])
#print(s)
for i in range(n-1):
    if s[i]>t:
        s[i]=t
print(sum(s)+t)

Measured memory_bytes: 25200
/*
* @Author: Kabid
* @Date:   2020-04-26 18:01:07
* @Last Modified by:   Kabid
* @Last Modified time: 2020-05-03 18:16:08
*/
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<set>
#include<map>
#include<algorithm>
#define ll long long
#define  in(x) scanf("%d",&x);
#define out(x) printf("%d",x);
#define  ins(x)  scanf("%s",x);
#define outs(x) printf("%s",x);
#define lin puts("");
#define _ putchar(' ');
using namespace std;

int t;       //test cases
ll  n=0, k,m; //variables
long long w,x;
ll  a, b, d;
ll c;
ll p=100.0;
string s;
set<ll>st;
ll i;
int main() {
	cin>>n>>k;
	while(cin>>p){
		while(p--){
			cin>>d;
			st.insert(d);
		}
	}
	cout<<n-st.size();
	

	return 0;
}


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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
	ll a,b,c;
	cin>>a>>b>>c;
	if(c>=a+b)
	{
		cout<<"0 0";
	}
	else if(c>a)
	{
		cout<<"0 "<<b-(c-a);
	}
	else cout<<a-c<<" "<<b;
    return 0;
}



Measured memory_bytes: 256
import sys
from itertools import combinations

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline


# n = int(readline())
# d = list(map(int, readline().split()))

n, *d = map(int, read().split())
ans = 0

for v in combinations(d, 2):
    ans += v[0] * v[1]

print(ans)

Measured memory_bytes: 3060
import math
import sys
#読み込み
s = input()
num = len(s)

#偶数個の文字でなければno
if num % 2 != 0:
    print("No")
    sys.exit()

#偶数番目がhか判定
for i in range(math.floor(num/2)):
    if s[2 * i] != "h":
        print("No")
        sys.exit()

#奇数番目がiか判定
for j in range(math.floor(num/2)):
    if s[2 * j + 1]  != "i":
        print("No")
        sys.exit()
        
print("Yes")

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
  int A[3];
  for(int i=0; i < 3; ++i){
    cin >> A[i];
  }
  int count_5 = 0;
  int count_7 = 0;
  for(int i=0; i < 3; ++i){
    if(A[i] == 5){
      ++count_5;
    }
    if(A[i] == 7){
      ++count_7;
    }
  }
  if(count_5 == 2 && count_7 == 1){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <queue>
#include <set>

using namespace std;

#define A_MAX 100001
#define B_MAX 100001
#define Q_MAX 100001
#define INF 100000000000

void solv()
{
	int A, B, Q; scanf("%d%d%d", &A, &B, &Q);
	long long int s[A_MAX], t[B_MAX],x[Q_MAX];
	for (int i = 0; i < A; i++){
		scanf("%lld", s + i);
	}
	for (int i = 0; i < B; i++){
		scanf("%lld", t + i);
	}
	for (int i = 0; i < Q; i++){
		scanf("%lld", x + i);
	}

	for (int i = 0; i < Q; i++){
		int lefts, leftt, rights, rightt;
		rights = lower_bound(s, s + A, x[i]) - s;
		rightt = lower_bound(t, t + B, x[i]) - t;
		lefts = rights - 1;
		leftt = rightt - 1;

		long long int ret = INF;
		if (-1 != lefts && -1 != leftt){
			ret = min(ret, x[i] - min(s[lefts], t[leftt]));
		}
		if (A != rights && B != rightt){
			ret = min(ret,max(s[rights], t[rightt]) - x[i]);
		}
		if (-1 != lefts && B != rightt){
			ret = min(ret, t[rightt] - s[lefts] + min(t[rightt] - x[i], x[i] - s[lefts]));
		}
		if (A != rights && -1 != leftt){
			ret = min(ret, s[rights] - t[leftt] + min(s[rights] - x[i], x[i] - t[leftt]));
		}

		printf("%lld\n", ret);
	}

	return;
}

int main()
{
	FILE *fin = NULL, *fout = NULL;
	//fin = freopen("input.txt", "r", stdin);
	//fout = freopen("output.txt", "w", stdout);

	solv();

	//finalize
	if (NULL != fin) fclose(fin);
	if (NULL != fout) fclose(fout);

	return 0;
}

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

int main(){
    int m,f,b;
    cin >> m >> f >> b;
    if(m>b){
        cout << 0 << endl;
    }
    else if(m+f>=b){
        cout << b-m << endl;
    }else{
        cout <<"NA" << endl;
    }
    return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
//const int MODINF = 1000000007;
//const int64_t INF = 998244353;
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    int y = 1, count = 0;
    rep(i, 0, N){
        int x;
        cin >> x;
        if(x == y){
            count++;
            y++;
        }
    }
    if(count == 0) cout << - 1 << endl;
    else cout << N - count << endl;
}

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

int main() {
    string S;
    cin >> S;
    ll K;
    cin >> K;
    // string alphabet ="abcdefghijklmnopqrstuvwxyz";
    for(int i=0;i<S.size();i++){
        int t= S[i] -'a';
        // cerr <<"t=" <<t  <<"K=" <<K<< endl;
        if(i == S.size()-1){
            S[i] = 'a' +(t+K)%26;
            K=0;
            break;
        }
        if(t==0){
            continue;
        }
        if(26-t<=K){
            S[i] = 'a';
            K-= (26-t);
        }
    }
    cout << S << endl;

    return 0;
}

Measured memory_bytes: 512
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<functional>	
int gcd(int, int);

int main(void){
  int n, x, y[100000], i, D=0;
  scanf("%d%d", &n, &x);
  for(i=0; i<n; ++i){ scanf("%d", y+i); y[i]=abs(x-y[i]);}
  if(n==1){ printf("%d\n", y[0]); return(0);}
  std::sort(y, y+i, std::greater<int>());
  D=gcd(y[0], y[1]);
  for(i=2; i<n; ++i){
	D=gcd(D, y[i]);
  }
  printf("%d\n", D);
  return(0);    
}

int gcd(int x, int y){
	int buf;
	if(x<y){ buf=x; x=y; y=buf; }
	while(x%y!=0){ buf=x%y; x=y; y=buf; }
	return(y);
}

Measured memory_bytes: 512
/*input
2
1 2
*/
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n; cin >> n;
	int arr[n];
	int i;
	for(i=0;i<n;++i)
		cin >> arr[i];
	int ct = 0;
	for(i=0;i<n-1;++i){
		if(arr[i] == i+1){
			swap(arr[i],arr[i+1]);
			ct++;
		}
	}
	if(arr[n-1]==n)ct++;
	cout << ct << endl;
	return 0;
}

Measured memory_bytes: 640
#quoted LIS from https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5
import bisect

n=int(input())
arr=[int(input()) for _ in range(n)][::-1]
LIS=[arr[0]]
for i in range(1,n):
  if arr[i]>=LIS[-1]:
    LIS.append(arr[i])
  else:
    LIS[bisect.bisect_right(LIS,arr[i])]=arr[i]
print(len(LIS))

Measured memory_bytes: 7840
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <utility>
#include <queue>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <cmath>
#include <iomanip>
using namespace std;
#define sL(i) i << 1
#define sR(i) i << 1 | 1
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pair<int,int>, int> ppi;
const int MOD = 1e9 + 7;
const int INF = 2e9 + 5;
 
int n, k;
int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> k;
    if (k <= (n + 1) / 2) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

N,K,X,Y = inputILs(4)

if N<=K:
  print(N*X)
else:
  print(K*X+(N-K)*Y)

Measured memory_bytes: 64492
/**
 * @author: pr4shan7 (प्रशांत)
 */
// #define _DEBUG

#ifndef _DEBUG
#define NDEBUG
#endif

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

using namespace std;
using namespace __gnu_pbds;

// #define int long long
// #define double long double

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_set;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define endl '\n'
#define x first
#define y second
#define cai static_cast<int>
#define cal static_cast<long long>
#define cad static_cast<long double>
#define deb(z) cout << "// " << #z << " = " << z << endl;
const int N = 1e5 + 5;
const int INF = 1e9;
const int MV = 1e9 + 7;

inline int solve(string& n, int& k) {
  ll ans{};
  ll l = n.length();
  if (k == 3) {
    ans += ((9 * 9 * 3 * max(l - 1, 0LL) * max(l - 2, 0LL) * max(l - 3, 0LL)) >> 1) + ((max(n[0] - '0' - 1, 0) * max(l - 1, 0LL) * max(l - 2, 0LL) * 9 * 9) >> 1);
    if (l == 1)
      n = "0";
    else {
      do {
	n = n.substr(1, l - 1);
	l--;
      } while (l != 1 && n[0] == '0');
    }
  k--;
}

#ifdef _DEBUG
// deb(n); deb(l);
#endif

if (k == 2) {
  ans += ((9 * 9 * max(l - 1, 0LL) * max(l - 2, 0LL)) >> 1) + (max(n[0] - '0' - 1, 0) * max(l - 1, 0LL) * 9);
  if (l == 1)
    n = "0";
  else {
    do {
      n = n.substr(1, l - 1);
      l--;

      #ifdef _DEBUG
      	// deb(n); deb(l); 
      #endif
      
    } while (l != 1 && n[0] == '0');
  }
  k--;
}

#ifdef _DEBUG
deb(n);
#endif

if (k == 1) {
  ans += max(n[0] - '0', 0) + 9 * max(l - 1, 0LL);
}

return ans;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  // cin.tie(NULL);

#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  string n;
  int k;
  cin >> n >> k;
  cout << solve(n, k) << endl;

  return 0;
}


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

#define all(x) x.begin(),x.end()
#define pb(x) push_back(x)
#define forn(i,N) for(int i=0;i<N;i++)

using namespace std;
using ll=long long int;
using ld=long double;
using vi=vector<int>;
using vll=vector<ll>;

int main() {
//freopen("input.txt","rt",stdin);
ios::sync_with_stdio(false);
cin.tie(nullptr);

int ans=0;
string s,t;
cin>>s>>t;
for(int i=0;i<s.length();i++) {
  if(s[i]!=t[i]) ans++;
}
cout<<ans<<endl;
return 0;
}


Measured memory_bytes: 3820
#include <iostream>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
 
#define repd(i,a,b); for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
 
 
using namespace std;
int main() {
  int n=0;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
sort(a,a+n);
  int sum=0;
  rep(j,n-1){
  sum += a[j];
  }
  sum += a[n-1]/2;
  
  cout << sum;
  

 return 0;
}

Measured memory_bytes: 256
S = input()

dp = [0] * (len(S)+1)

acgt = ["A","C","G","T"]

for i in range(1,len(S)+1) :
   if S[i-1] in acgt:
       dp[i] = dp[i-1] + 1
   else:
       dp[i] = 0

print(max(dp))

Measured memory_bytes: 61816
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<28;
void solve(int a){cout<<( a?"Yes":"No")<<endl;}
int main(){
	int n,y;
	cin >>n>>y;
	int ans[3]={-1,-1,-1};
	for(int a=0;a<=n;a++){
		for(int b=0;b<=n-a;b++){
			if(a*10000 + b*5000 +(n-a-b)*1000==y){
				ans[0]=a;
				ans[1]=b;
				ans[2]=n-b-a;

			}
		}
	}
	printf("%d %d %d\n",ans[0],ans[1],ans[2]);
	}


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

int main() {
    int X, Y;
    cin >> X >> Y;
    for (int i = 0; i <= X; i++) {
        if (i * 4 + (X - i) * 2 == Y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3604
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]

if N == 1:
    for i in range(10):
        j = str(i)
        for s, c in sc:
            if s > len(j) or int(j[s - 1]) != c:
                break
        else:
            print(i)
            exit()
        continue
elif N == 2:
    for i in range(10, 100):
        j = str(i)
        for s, c in sc:
            if s > len(j) or int(j[s - 1]) != c:
                break
        else:
            print(i)
            exit()
        continue
elif N == 3:
    for i in range(100, 1000):
        j = str(i)
        for s, c in sc:
            if s > len(j) or int(j[s - 1]) != c:
                break
        else:
            print(i)
            exit()
        continue

print(-1)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
#include<random>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const int MOD=1e9+7;

int main(){

  int n, k;
  cin >> n >> k;
  int ans = 0;
  while(n){
    n /= k;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

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

int main(){

    int s[33] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << s[k - 1] << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
count = [0, 0, 0, 0]
for i in range(N):
  s = input()
  if s == 'AC':
    count[0] += 1
  elif s == 'WA':
    count[1] += 1
  elif s == 'TLE':
    count[2] += 1
  elif s == 'RE':
    count[3] += 1

print('AC x', count[0])
print('WA x', count[1])
print('TLE x', count[2])
print('RE x', count[3])

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

pub 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 = read::<i32>();
    println!("{}", (1..n+1).fold(0, |sum, i| sum + i));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l,n,m;
	cin>>n>>m;
	ll fl[100001]={0};

	for(i=1;i<=m;i++){
		cin>>k>>l;
		fl[k]+=1;
		fl[l+1]-=1;
	}

	ll c=0;
	for(i=1;i<100001;i++){
		fl[i]+=fl[i-1];
	}
	for(i=1;i<100001;i++){
		if(fl[i]==m){
			c++;
		}
	}
	cout<<c;
	return 0;
}


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


#define ll long long int

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast_io std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define trace3(x,y,z) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;
#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;

#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()
#define print(x) cout<<(x)<<endl;

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
int toInt(string s){int r=0;istringstream sin(s);sin>>r; return r;}
///////////////////////////////////////////////////////

const int N = 1e5+3;
const ll T = 1e10+5;

int n,start,m,l,r,d;
vector< pair<int,int> > adj[N];
bool done[N],calc[N];
ll dist[N];

int main()
{
	fast_io;
	cout<<fixed;

	cin>>n>>m;

	FOR(i,1,n){
		done[i] = calc[i] = false;
		dist[i] = T;
	}

	FOR(i,1,m){
		cin>>l>>r>>d;
		adj[l].pb(mp(r,d));
		adj[r].pb(mp(l,-d));
	
		done[l] = done[r] = true;
	}

	start = n+1;
	FOR(i,1,n){
		if(done[i]){
			dist[i] = 0;
			start = i;
			break;
		}
	}

	FOR(i,start,n){
		if(done[i] and !calc[i]){
			queue<int> Q;
			Q.push(i);
			calc[i] = true;

			while(!Q.empty()){
				int x = Q.front();
				int dx = dist[x];
				Q.pop();

				// trace(x);

				for(auto u:adj[x]){
					r = u.F;
					d = u.S;

					if(dist[r] == T){
						dist[r] = dx + d;

						if(!calc[r]){
							calc[r] = true;
							Q.push(r);
						}
					}
					else{
						if(dist[r]-dx != d){
							cout<<"No"<<endl;
							return 0;
						}
					}
				}
			}
		}
	}

	cout<<"Yes"<<endl;
}


Measured memory_bytes: 9984
'use strict'



function Main(input) {
  input = input.trim().split('\n')
  const N = parseInt(input[0])
  const array = input[1].split(' ')
  const S = array[0]
  const T = array[1]
  let ans = ''
  for(let i = 0; i < N; ++i) {
    ans += S[i]
    ans += T[i]
  }

  console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
 
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
 
typedef long long ll;
typedef unsigned long long int ull;
typedef long double ld;
 
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef pair<string, string> ss;
typedef pair<int, ss> iss;
 
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<ld> vld;
typedef vector<double> vd;
typedef vector<pll> vpll;
typedef vector<pii> vpii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<pair<int, pii>> vpiii;
 
typedef map<string, string> mss;
typedef map<string, int> msi;
typedef map<int, int> mii;
typedef map<int, vi> mivi;
typedef map<int, bool> mib;
typedef map<int, ll> mill;
typedef map<int, vpii> mivpii;

void fast_io() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

int main() {
	fast_io();
//	freopen("input/ABC144B.txt", "r", stdin);
	
	int n;
	cin >> n;
	
	set<int> s;
	for(int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++)
			s.insert(i * j);
	}
	
	cout << (s.count(n) ? "Yes" : "No") << '\n';
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i< (n); i++)
using ll = long long;
using P = pair<int, int>;
int main()
{
    double a,b,c,d;
    cin >> a >> b >> c >> d;
    if(ceil(a/d) >=ceil(c/b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> pairs(n);
    if(n%2 == 0){
        rep(i,n)pairs[i] = n-i-1;
    }
    else{
        rep(i,n)pairs[i] = n-i-2;
    }

    vector<P> res; 

    rep(i,n){
        rep(j,n){
            // if(i == j)continue;
            if(i >= j)continue;
            if(pairs[i] == j)continue;
            //cout << i+1 << " " << j+1 << endl;
            res.push_back(P(i+1,j+1));
        }
    }

    cout << res.size() << endl;
    for(auto i : res)cout << i.first << " " << i.second << endl;
    return 0;
}

Measured memory_bytes: 384