akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#define MAXN 1000005
#define PLI pair<long long,int>
#define fi first
#define se second
#define mp make_pair
#define ha 99994711
#define ba 823
//#define ivorysi
using namespace std;
typedef long long int64;
int N,Lim,dis;
int64 X,D,m[55],cost[55];
int p[55],siz[55],q[125005],id[55];
int64 dp[125005],ans;
int ql,qr;
bool cmp(int a,int b) {
    return siz[a] * cost[b] > siz[b] * cost[a];
}
void update(int64 &x,int64 y) {
    x = min(x,y);
}
void Solve() {
    scanf("%d%lld%lld",&N,&X,&D);
    Lim = N * N * N;
    scanf("%d",&m[1]);
    for(int i = 2 ; i <= N ; ++i) scanf("%d%d",&m[i],&p[i]);
    for(int i = N ; i >= 1 ; --i) {
        cost[i] += m[i];siz[i]++;
        cost[p[i]] += cost[i];siz[p[i]] += siz[i];
        id[i] = i;
    }
    for(int i = 1 ; i <= Lim ; ++i) dp[i] = X + 1;
    sort(id + 1,id + N + 1,cmp);
    dis = min(N,(int)D);
    for(int k = 1 ; k <= N ; ++k) {
        int s =  siz[id[k]];int64 v = cost[id[k]];
        for(int j = 0 ; j < s ; ++j) {
            int T = min((Lim - j)/ s,dis);
            if(id[k] == 1) T = min((Lim - j) / s,N);
            int p = (Lim - j) / s;
            ql = 1,qr = 0;
            for(int i = (Lim - j) / s ; i >= 1 ; --i) {
                while(p >= 0 && i - p <= T) {
                    while(ql <= qr && dp[j + q[qr] * s] - q[qr] * v > dp[j + p * s] - p * v) --qr;      
                    q[++qr] = p;
                    --p;
                }
                while(ql <= qr && q[ql] >= i) ++ql;
                if(ql <= qr) {
                    update(dp[j + i * s],dp[j + q[ql] * s] + (i - q[ql]) * v);
                }
            }
        }
    }
    for(int i = 0 ; i <= Lim ; ++i) {
        int64 T = X - dp[i];
        if(T < 0) continue;
        int64 tmp = i;
        int num;
        for(int k = 1 ; k <= N ; ++k) {
            if(id[k] == 1) num = T;
            else num = D - dis;
            int t = min(T / cost[id[k]],(int64)num);
            tmp += 1LL * t * siz[id[k]];
            T -= t * cost[id[k]];
        }
        ans = max(ans,tmp);
    }
    printf("%lld\n",ans);
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
    return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>
int main(void)
{
	int n,h[100000],p=0,max=0,i,j;
	scanf("%d", &n);
	for(i=0; i<n; i++)
	scanf("%d", &h[i]);
	for(i=1; i<n; i++)
	{
		if(h[i-1]>=h[i])
		p++;
		if(h[i-1]<h[i]||i==n-1)
		{
			if(max<p)
			max=p;
			p=0;
		}
	}
	printf("%d\n", max);
	
	return 0;
}

Measured memory_bytes: 512
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(){
	int N,M;
	for(;~scanf("%d%d",&N,&M)&&N&&M;){
		int R=-1;
		vector<int>v(N);
		for(int i=0;i<N;i++){
			scanf("%d",&v[i]);v[i]=-v[i];
		}
		sort(v.begin(),v.end());
		for(int i=0;i<N;i++){
			int idx=distance(v.begin(),lower_bound(v.begin(),v.end(),-M-v[i]));
			if(idx==i)idx++;
			if(idx<N)R=max(R,-v[i]-v[idx]);
		}
		printf(R<0 ? "NONE\n" : "%d\n", R);
	}
}

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

int n, m;
const int MAXN = 5;

int s[MAXN], c[MAXN];

bool corr(int fn)
{
    for (int i = 0; i < m; ++i)
    {
        int cp = fn;
        for (int k = 0; k < n - s[i]; ++k) cp /= 10;
        if (cp % 10 != c[i]) return false;
    }
    return true;
}

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

    cin >> n >> m;
    for (int i = 0; i < m; ++i) cin >> s[i] >> c[i];

    if (n == 1)
    {
        for (int num = 0; num <= 9; ++num)
        {
            if (corr(num))
            {
                cout << num << "\n";
                return 0;
            }
        }
        cout << -1 << "\n";
    }
    else if (n == 2)
    {
        for (int num = 10; num <= 99; ++num)
        {
            if (corr(num))
            {
                cout << num << "\n";
                return 0;
            }
        }
        cout << -1 << "\n";
    }
    else
    {
        for (int num = 100; num <= 999; ++num)
        {
            if (corr(num))
            {
                cout << num << "\n";
                return 0;
            }
        }
        cout << -1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n,m;
  cin >> n >> m;
  int k[n];
  int a[n][1000];
  for(int i=0;i<n;i++){
  cin >> k[i];
    for (int j=0;j<k[i];j++){
    cin >> a[i][j];
    }
    }
  
   vector<int> vec(100);
for (int i = 0; i < k[0]; i++) {
   vec.at(i)=a[0][i];
  }
  
  int c[100][100];
  //
  for(int t=0;t<k[0];t++){
  for(int i=1;i<n;i++){
    for (int j=0;j<k[i];j++){
      if(vec.at(t)==a[i][j]){
        c[t][i]=1;
      }
    }
  }
  }
  //
    
  int ans;
  ans=k[0];
  for (int i=0;i<k[0];i++){
    
  for (int j=1;j<n;j++){
  if(c[i][j]!=1){
    ans--;
    break;
  }
  }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;
int p[MAXN];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>p[i];
    int m=p[0],ans=1;
    for(int i=1;i<n;i++)
    {
        if(p[i]<=m)
        {
            ans++;
            m=p[i];
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void){
	int n,i,sum=0;
	scanf("%d",&n);
	int a[n+1],b[n+1],c[n];
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	for(i=0;i<n;i++) scanf("%d",&b[i]);
	for(i=0;i<n-1;i++) scanf("%d",&c[i]);
	for(i=0;i<n;i++){
		sum+=b[a[i]-1];
		if(i>0) if(a[i]-a[i-1]==1) sum+=c[a[i]-2];
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    x=int(input())
    ans=0
    for i in range(1,33):
        if i>x:
            break
        for j in range(2,11):
            y=i**j
            if y<x:
                ans=max(y,ans)
            elif y==x:
                ans=max(y,ans)
                break
            else:
                break
    print(ans)
resolve()

Measured memory_bytes: 3064
import java.util.*;

public class Main {

    private static List<List<Integer>> lists;

    public static class query {
        private int a;
        private int b;
        private int c;
        private int d;

        public query(int aa, int bb, int cc, int dd) {
            a = aa;
            b = bb;
            c = cc;
            d = dd;
        }

        public int getA() {
            return a;
        }

        public int getB() {
            return b;
        }

        public int getC() {
            return c;
        }

        public int getD() {
            return d;
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int Q = sc.nextInt();

        lists = new ArrayList<>();
        getLists(N, M, 0, 0, new ArrayList<>());
        List<query> queries = new ArrayList<>();
        for (int i = 0; i < Q; i++) {
            int aa = sc.nextInt();
            int bb = sc.nextInt();
            int cc = sc.nextInt();
            int dd = sc.nextInt();

            query q = new query(aa, bb, cc, dd);
            queries.add(q);
        }
        sc.close();

        long max = 0;

        for (List<Integer> li : lists) {
            long tmp = 0;
            for (query q : queries) {
                long val = li.get(q.getB() - 1) - li.get(q.getA() - 1);
                if (val == q.getC()) {
                    tmp += q.getD();
                }
            }
            if (tmp > max) {
                max = tmp;
            }
        }
        System.out.println(max);
    }

    public static void getLists(int N, int M, int count, int lastNum, List<Integer> listss) {
        if (count == N) {
            lists.add(new ArrayList<>(listss));
            return;
        }
        for (int i = 1; i <= M; i++) {
            if (lastNum > i) {
                continue;
            }
            listss.add(i);
            getLists(N, M, count + 1, i, listss);
            listss.remove(listss.size() - 1);
        }
    }
}


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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i <= _##i poi i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi i < _##i poi i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i >= _##i poi i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi i > _##i poi i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

using namespace std;

template<class T> T lov_yet(T t){
    if(t) return t poi
    else return 0 poi
}

template<class T> T gcd(T a, T b){
    if(b) return gcd(b, a % b) poi
    else return a poi
}

int main(){
    long long a, b poi
    while(cin >> a >> b)
        cout << gcd(a, b) << " " << a * b / gcd(a, b) poipoi poi
    return 0 poi
}

Measured memory_bytes: 1152
h, w = map(int, input().split())
a = [list(map(int , input().split())) for _ in range(h)]

res = []
for hi in range(h):
    for wi in range(w-1):
        if a[hi][wi] % 2 == 1:
            a[hi][wi] -= 1
            a[hi][wi+1] += 1
            res.append((hi+1, wi+1, hi+1, wi+1+1))
for hi in range(h-1):
    wi = w - 1
    if a[hi][wi] % 2 == 1:
        a[hi][wi] -= 1
        a[hi+1][wi] += 1
        res.append((hi+1, wi+1, hi+1+1, wi+1))

print(len(res))
for resi in res:
    print(' '.join(map(str, resi)))


Measured memory_bytes: 26276
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define MOD 1000000007

ll fact[200000], fact_i[200000];

ll power(int x, int y) {
    if (y == 1) return x;
    ll p = power(x, y >> 1);
    if (y & 1) return p * p % MOD * x % MOD;
    else return p * p % MOD;
}

ll inv(ll n) {
    return power(n, MOD - 2);
}

void init(int n) {
    fact[0] = 1;
    REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
    fact_i[n] = inv(fact[n]);
    REP(i, n) fact_i[n - i - 1] = fact_i[n - i] * (n - i) % MOD;
}

ll nCr(ll n, ll r) {
    return fact[n] * fact_i[r] % MOD * fact_i[n - r] % MOD;
}

int main() {
    init(200000);
    ll N, M, K;
    cin >> N >> M >> K;

    ll ans = 0;
    FOR(i, 1, N) ans = (ans + i * (N - i) % MOD * M * M % MOD) % MOD;
    FOR(i, 1, M) ans = (ans + i * (M - i) % MOD * N * N % MOD) % MOD;
    ans = ans * nCr(N * M - 2, K - 2) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
 
#define ALL(x) x.begin(), x.end()
using namespace std;
 
typedef vector<vector<int> > G;
const int inf = 1e9;
 
int n, m;
G graph;
vector<int> ans;
 
int visited[100100];
 
void dfs(int u){
 
    ans.push_back(u);
    visited[u] = 1;
 
    for(int i=0; i<graph[u].size(); i++){
        int v = graph[u][i];
        if( !( visited[v] ) ){
            return dfs(v);
        }
    }
    return;
}
 
int main(void){
    cin >> n >> m;
    graph = G(n+100);
    for(int i=0; i<m; i++){
 
        int x, y;
        cin >> x >> y;
        graph[x].push_back(y);
        graph[y].push_back(x);
 
    }
    
    dfs(1);
    reverse(ans.begin(), ans.end());
    ans.pop_back();
    dfs(1);
 
    cout << ans.size() << endl;
 
    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << " ";
    }
 
    cout << endl;
    return 0;
}

Measured memory_bytes: 10104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
int main(){
    int N, K, X, Y;
    cin >> N >> K >> X >> Y;
    if(N >= K){
        cout << X*K + (N-K)*Y << endl;
    }else if(N < K){
        cout << X*N << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys, math
input = sys.stdin.readline

def main():
    a, b, theta = map(int, input().split())
    theta = theta * math.pi / 180
    c = pow(a*a+b*b-2*a*b*math.cos(theta), 0.5)
    h = b * math.sin(theta)
    print(a*h*0.5)
    print(a+b+c)
    print(h)



if __name__ == "__main__":
    main()


Measured memory_bytes: 5732
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  long long x,y;
  bool operator < (const P &a )const{
    //if(y!=a.y)
    return y<a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[200111];
long long l[200111];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[601011];
queue<int> q;
stack<P> s;
vector<int> v[200101];

bool as(P a,P b)
{
  return a.x<b.x;
}

void ini(int i,int n,int m)
{
  e=max(e,i);
  if(n!=m)
  {
    ini(i*2,n,(n+m)/2);
    ini(i*2+1,(n+m)/2+1,m);
  }
  u[i]={mod,mod};
}

void up(int i,int n,int m)
{
  if(n!=m)
  {
    u[i*2].x=min(u[i*2].x,u[i].y);
    u[i*2+1].x=min(u[i*2+1].x,u[i].y);
    u[i*2].y=min(u[i*2].y,u[i].y);
    u[i*2+1].y=min(u[i*2+1].y,u[i].y);
  }
  u[i].y=mod;
}

void g(int i,int n,int m,int c,int d,long long x)
{
  up(i,n,m);
  if(n>d||m<c) return ;
  if(c<=n&m<=d)
  {
    u[i].x=min(u[i].x,x);
    u[i].y=min(u[i].y,x);
    return;
  }
  g(i*2,n,(n+m)/2,c,d,x);
  g(i*2+1,(n+m)/2+1,m,c,d,x);
  u[i].x=min(u[i*2].x,u[i*2+1].x);
}

long long f(int i,int n,int m,int c,int d)
{
  up(i,n,m);
  //printf("##%d %d %d %lld\n",i,n,m,u[i].x);
  if(n>d||m<c) return mod;
  if(c<=n&&m<=d)
    return u[i].x;
  return min(f(i*2,n,(n+m)/2,c,d),f(i*2+1,(n+m)/2+1,m,c,d));
}

int main()
{
  scanf("%d",&a);
  ini(1,0,a);
  //printf("%d",e);
  for(int t=1;t<=a;t++)
  {
    l[t]=mod;
    //o[t]=0;
    //o[t]=(rand()^rand()^rand())%2;
    //printf("%d ",o[t]);
    scanf("%d",&o[t]);
    //if(o[t]==0) z++;
  }
  //puts("");
  scanf("%d",&b);
  for(int t=1;t<=b;t++)
  {
    scanf("%d %d",&n,&m);
    //n=rand()%t+1,m=t;
    //printf("%d %d\n",n,m);
    v[m].push_back(n);
  }
  g(1,0,a,0,0,0);
  for(int t=1;t<=a;t++)
  {
    if(o[t]) l[t]=min(l[t-1]+1,l[t]);
    else l[t]=min(l[t-1]-1,l[t]);
    g(1,0,a,t,t,l[t]);
    for(int h=0;h<v[t].size();h++)
    {
      l[t]=min(l[t],f(1,0,a,v[t][h]-1,v[t][h]-1));
      g(1,0,a,v[t][h],t,f(1,0,a,v[t][h]-1,v[t][h]-1));
    }
    if(o[t]==0) z++;
    //printf("@%lld \n",l[t]+z);
    //printf("%lld\n",f(1,0,a,t-1,t-1));
  }
  printf("%lld",l[a]+z);
}
//2




Measured memory_bytes: 21504
#!/usr/bin/env python3


def main():
    N, A, B, C = map(int, input().split())
    l = [int(input()) for _ in range(N)]
    ans = 10**9
    for i in range(4**N):
        # N本の竹がA,B,Cのどれに使われるか
        cost = [[] for _ in range(3)]
        tmp = i
        j = 0
        while j < N:
            if tmp % 4 < 3:
                cost[tmp % 4].append(l[j])
            j += 1
            tmp //= 4

        if len(cost[0]) == 0 or len(cost[1]) == 0 or len(cost[2]) == 0:
            continue

        tmpa = 0
        D = [A, B, C]
        # MPの計算
        for i in range(3):
            tmpa += abs(sum(cost[i]) - D[i]) + 10*(len(cost[i])-1)
        ans = min(ans, tmpa)

    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    cout << fixed << setprecision(12);
    ll a, b;
    cin >> a >> b;
    if(a < 10 && b < 10){
        cout << a*b << endl;
    }else{
        cout << -1 << endl;
    }

    return 0;
}


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

typedef long long int LL;
#define REP(n) for(LL i = 0; i < (n); i++)
#define COUT(val) cout << (val) << endl
#define CIN(val) cin >> (val)
#define SORT(vec) sort(vec.begin(), vec.end())
#define SORT_GRE(vec) sort(vec.begin(), vec.end(), greater<LL>())

int main(){
    int n, k , x, y;
    cin >> n >> k >> x >> y;
    int ans = 0;
    for(int i = 1; i <= n; i++){
        if(i <= k){
            ans += x;
        } else {
            ans += y;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

int main(){
    int n,d;
    cin>>n>>d;
    vector< vector<int> >arr;
    for(int i=0;i<n;i++)
    {
        vector<int>tp;
        for(int j=0;j<d;j++)
        {
            int x;
            cin>>x;
            tp.push_back(x);
        }
        arr.push_back(tp);
    }
    int ct = 0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            int dist = 0;
            for(int k=0;k<d;k++)
            {
                dist += (arr[j][k] - arr[i][k])*(arr[j][k] - arr[i][k]);
            }
            int rt = sqrt(dist);
            if (rt*rt == dist)
            {
                ct++;
            }
        }
    }
    cout<<ct<<"\n";
    return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
L = list(map(int, input().split()))

#print(L)

D = [0]
count = 1

#print(bound)

for i in range(1, N+1):
    D.append(D[i-1] + L[i-1])
    if D[i] <= X:
        count += 1
    
#print(D)
print(count)


Measured memory_bytes: 2940
n = int(input())
l=[]
tmp=1
if n%abs(tmp*2)!=0:
    n-=tmp
    l.append('1')
else:
    l.append('0')

while n!=0:
    tmp *= (-2)
    if n%abs(tmp*2)!=0:
        n-=tmp
        l.append('1')
    else:
        l.append('0')
print(''.join(reversed(l)))


Measured memory_bytes: 3060
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
  int n;
  cin >> n;
  vector<int>a;
  vector<vector<int>>x;
  x.resize(n);
  vector<vector<int>>y;
  y.resize(n);
  for(int i = 0; i < n; i++){
    int in;
    cin >> in;
    a.push_back(in);
    for(int j = 0; j < in; j++){
      int xn, yn;
      cin >> xn >> yn;
      x[i].push_back(xn);
      y[i].push_back(yn);
    }
  }
  int ans = 0;
  for(int i = 0; i < (1 << n); i++){
    vector<int>s;
    for(int j = 0; j < n; j++){
      if(i & (1 << j)){
        s.push_back(1);
      }else{
        s.push_back(0);
      }
    }
    int honestnum = 0;
    int ishonest = 1;
    for(int j = 0; j < n; j++){
      if(s[j] == 1){
        for(int k = 0; k < a[j]; k++){
        //cout << s[x[j][k] - 1] << " " << y[j][k] << endl;
          if(s[x[j][k] - 1] != y[j][k]){
            ishonest = 0;
          }
        }
        //if(ishonest != 1){
          /*
          for(const auto & x: s){
            cout << x;
          }
          cout << endl;
          cout << j << endl;
          
          for(int k = 0; k < a[j]; k++){
            cout << s[x[j][k] - 1] << " " << y[j][k] << endl;
          }
          honestnum ++;
          */
        //}
      }
    }
    if(ishonest == 1){
      honestnum = accumulate(s.begin(), s.end(), 0);
    }
    ans = max(ans, honestnum);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 256
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

string s;
int dpR[N];
int dpL[N];
int cnt[N];

int main(){
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == 'L')
            continue;
        dpR[i] += s[i] == 'R';
        dpR[i] += dpR[i - 1];
    }
    for(int i = s.size() - 1; i >= 0; i--){
        if(s[i] == 'R')
            continue;
        dpL[i] += s[i] == 'L';
        dpL[i] += dpL[i + 1];
    }
    for(int i = 0; i < s.size()-1; i++){
        if(s[i] == 'R' && s[i + 1] == 'L'){
            cnt[i] = cnt[i + 1] = 1;
            int R = dpL[i + 2];
            int L = dpR[i - 1];
            bool swp = 0;
            int stp = max(R , L);
            if(stp % 2 == 0)
                swp = 1;
            while(R || L){
                if(R){
                    cnt[i+1]++;
                    R--;
                }
                if(L){
                    cnt[i]++;
                    L--;
                }
                swap(cnt[i] , cnt[i + 1]);
            }
            if(swp){
                swap(cnt[i] , cnt[i + 1]);
            }
        }
    }
    for(int i = 0; i < s.size(); i++){
        cout << cnt[i] << " ";
    }
}
// it will be WA if he put RRRRRRRRR.....L

Measured memory_bytes: 1792
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         String S=gs();
         long K=gl();

         long tmp=1;
    	 char bc=S.charAt(0);
    	 List<Long>l= new ArrayList<Long>();
    	 for(int i=1; i<S.length();i++) {
    		 char c=S.charAt(i);
    		 if(bc==c) {
    			 tmp++;
    		 } else {
    			 l.add(tmp);
    			 tmp=1;
    		 }
    		 bc=c;
    	 }
    	 l.add(tmp);

         long ans=0;
         if(S.charAt(0)==S.charAt(S.length()-1)) {
             if(l.size()==1) {
            	 ans=S.length()*K/2;
             } else {
            	 long s=l.get(0);
            	 long e=l.get(l.size()-1);
            	 long a=0;
            	 a+=((s+e)/2)*(K-1);
            	 a+=s/2;
            	 a+=e/2;
            	 for(int i=1; i<l.size()-1;i++) {
            		 ans+=l.get(i)/2;
            	 }
            	 ans*=K;
            	 ans+=a;
             }
         } else {
        	 for(int i=0; i<l.size();i++) {
        		 ans+=l.get(i)/2;
        	 }
        	 ans*=K;
         }

         System.out.println(ans);
     }


     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 35724
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c;
  ll k;
  cin >> a >> b >> c >> k;
  if(k%2==0){ 
  	cout << a-b << endl;
  }else{
    cout << b-a << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,ans=0;
  cin>>n;
  vector<vector<int>> a(2,vector<int>(n));
  for(i=0;i<2;i++) for(j=0;j<n;j++) cin>>a.at(i).at(j);
  for(j=1;j<n;j++){
    a.at(0).at(j)+=a.at(0).at(j-1);
    a.at(1).at(n-1-j)+=a.at(1).at(n-j);
  }
  for(j=0;j<n;j++) ans=max(ans,a.at(0).at(j)+a.at(1).at(j));
  cout<<ans<<endl;
}

Measured memory_bytes: 3604
import java.math.BigDecimal;
import java.math.MathContext;
import java.math.RoundingMode;
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		BigDecimal x[],y[];
		x=new BigDecimal[N];
		y=new BigDecimal[N];
		for (int i=0;i<N;i++) {
			int x1,y1;
			x1 = sc.nextInt();
			y1 = sc.nextInt();
			x[i] = new BigDecimal(x1);
			y[i] = new BigDecimal(y1);
		}
		int c =2;
		for(int i=2;i<=N;i++ ) {
			c*=i;
		}
		c=c/N;
		int C =1;
		for(int i=2;i<=N;i++ ) {
			C*=i;
		}
		BigDecimal sum = new BigDecimal(0);
		for (int i=0;i<N;i++) {
			for (int j=i+1;j<N;j++) {
				BigDecimal x1 = x[i].add(x[j].multiply(new BigDecimal(-1)));
				BigDecimal y1 = y[i].add(y[j].multiply(new BigDecimal(-1)));
				x1= x1.multiply(x1);
				y1= y1.multiply(y1);
				x1 = x1.add(y1);
				x1 = Main.sqrt(x1,10);
				sum = sum .add(x1);
			}
		}
		sum = sum.multiply(new BigDecimal(c));
		sum =sum.divide(new BigDecimal(C),10,BigDecimal.ROUND_HALF_UP);
		System.out.println(sum.toPlainString());
	}

	public static BigDecimal sqrt(BigDecimal value, int scale){
	    BigDecimal num2 = BigDecimal.valueOf(2);
	    int precision = 100;
	    MathContext mc = new MathContext(precision, RoundingMode.HALF_UP);
	    BigDecimal deviation = value;
	    int cnt = 0;
	    while (cnt < precision) {
	        deviation = (deviation.add(value.divide(deviation, mc))).divide(num2, mc);
	        cnt++;
	    }
	    deviation = deviation.setScale(scale, BigDecimal.ROUND_HALF_UP);
	    return deviation;
	}
}

Measured memory_bytes: 58164
N=int(input())
a=[]
for i in range(N):
  a.append(0)
for x in range(1,N+1):
  if x**2>=N:
    break
  for y in range(1,N+1):
    if x**2 + y**2 >= N:
      break
    for z in range(1,N+1):
      if x**2+y**2+z**2>=N:
        break
      t=x**2+y**2+z**2+x*y+y*z+z*x
      if t<=N:
        a[t-1] += 1
for m in range(N):
  print(a[m])

Measured memory_bytes: 9312
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const double PI = acos(-1);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
///////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> D(N);
    rep(i,N) cin >> D[i];

    vector<int> d(13);
    rep(i,N) d[D[i]]++;
    vector<int> check;
    vector<bool> t(23);
    t[0] = true;
    if (d[12] == 1) t[12] = true;
    rep(i,13) {
        if (d[0] > 0 || d[i] > 2 || d[12] > 1) {
            cout << 0 << endl;
            return 0;
        }
        if (i < 12 && d[i] == 1) {
            check.emplace_back(i);
        }
        if (i < 12 && d[i] == 2) {
            t[i] = t[24-i] = true;
        }
    }

    int z = check.size();
    int ans = 0;
    for (int tmp = 0; tmp < (1 << z); tmp++) {
        bitset<12> s(tmp);
        int cnt = 24;
        rep(i,z) {
            if (s.test(i)) t[24-check[i]] = true;
            else t[check[i]] = true; 
        }
        rep(i,23) {
            for (int j = i+1; j < 24; j++) {
                if (t[i] && t[j]) chmin(cnt,min(j-i,i+24-j));
            }
        }
        chmax(ans,cnt);
        rep(i,z) {
            if (s.test(i)) t[24-check[i]] = false;
            else t[check[i]] = false; 
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 256
words     = $<.each_line.map{|l| l.split}.flatten.map(&:downcase)
counts    = words.uniq.map{|w| [w, words.count(w)]}
max_count = counts.map{|w, c| c}.max
modes     = counts.select{|n, c| c == max_count}.map{|n, c| n}.sort[0]
longest   = words.max_by(&:size)
puts "#{modes} #{longest}"

Measured memory_bytes: 8600
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin>>H>>W;
  vector<char> str(H*W);
  for(int i=0;i<H*W;i++)cin>>str.at(i);
  for(int i=0;i<W+2;i++)cout<<"#";
  cout<<"\n";
  for(int i=0;i<H;i++){
    cout<<"#";
    for(int j=0;j<W;j++)cout<<str.at(i*W+j);
    cout<<"#\n";
  }
  for(int i=0;i<W+2;i++)cout<<"#";
  cout<<"\n";
}

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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl




typedef long long ll;
const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  string s;
cin>>s;
if (s[1]=='B')s[1]='R'; else s[1]='B';
out(s);

    return 0;
}


Measured memory_bytes: 3608
import java.util.*;

public class Main {
    public void main(Scanner sc) {
        long n = sc.nextLong();
        long x = sc.nextLong();

        long ans = n;
        long a = n - x;
        long b = x;
        while (b != 0) {
            long r = a / b;
            long q = a % b;

            ans += 2 * b * r;
            if (q == 0) {
                ans -= b;
            }
            a = b;
            b = q;
        }

        System.out.println(ans);
    }

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


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    
    if(abs(x - a) < abs(x - b)) {
        cout << "A" << endl;
    }
    else {
        cout << "B" << endl;
    }
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.Locale;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Main {
  public static void main(String[] args ){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();

    System.out.println( B % A == 0 ? A + B : B - A);
  }
}


Measured memory_bytes: 23764
#include <iostream>
#include <complex>
#include <cstdio>
#include <utility>
#include <vector>
using namespace std;
typedef complex<double> P;
typedef pair<P,P> L;
typedef pair<P,double> C;
typedef vector<P> Poly;
#define X real()
#define Y imag()
const double EPS = (1e-10), pi = acos(-1);

//2D version

double dot(P a, P b){ return a.X * b.X + a.Y * b.Y;}
double cross(P a, P b){ return a.X * b.Y - a.Y * b.X;}
P projection(P a, P b){ return dot(a, b)/abs(b)/abs(b)*b;}

P intersection(L a, L b){
  //直線aと直線bの交点
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return af + cross(bs-bf,af-bf)/(-cross(bs-bf,as-bf)+cross(bs-bf,af-bf))*(as-af);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if(cross(b,c) > EPS) return +1;
  if(cross(b,c) < -EPS) return -1;
  if(dot(b,c) < 0) return +2;
  if(abs(b) + EPS < abs(c)) return -2;
  return 0;
}

double ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 && dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf), abs(a-ss));
}

double pl_dist(P a, L s){
  P sf = s.first, ss = s.second;
  return abs(cross(sf-ss,a-ss))/abs(sf-ss);
}


vector<P> cpcl(C c, L l){
  //円cと直線lの交点
  //接する場合は同一の点を二つ返す
  double d = pl_dist(c.first,l), r = c.second;
  P m = l.first + projection(c.first-l.first,l.second-l.first);
  P x = sqrt(r*r-d*d)/abs(l.second-l.first)*(l.second-l.first);
  vector<P> cp(2,m);
  cp[0] -= x;
  cp[1] += x;
  return cp;
}

double common_area_cp(C c, Poly p){
  //円と非凸多角形の共通面積
  double ret = 0, r = c.second;
  int n = p.size();
  for(int i = 0; i < n; ++i) p[i] -= c.first;
  for(int i = 0; i < n; ++i){
    if(abs(p[i]*p[(i+1)%n]) < EPS) continue;
    double d = arg(p[(i+1)%n]/p[i]);
    ret += r*r*d/2.0;
    if(ps_dist(P(0,0),L(p[i],p[(i+1)%n])) < r - EPS){
      vector<P> cps = cpcl(C(P(0,0),r),L(p[i],p[(i+1)%n]));
      P a, b;
      if(ccw(p[i],p[(i+1)%n],cps[0]) == 0 &&
         ccw(p[i],p[(i+1)%n],cps[1]) == 0)
        a = cps[0], b = cps[1];
      else if(!ccw(p[i],p[(i+1)%n],cps[0]))
        a = cps[0], b = p[(i+1)%n];
      else if(!ccw(p[i],p[(i+1)%n],cps[1]))
        a = p[i], b = cps[1];
      else
        a = p[i], b = p[(i+1)%n];
      if(abs(a*b) < EPS) continue;
      d = arg(b/a);
      ret += cross(a,b)/2.0 - r*r*d/2.0;
    }
  }
  return ret;
}

int main(){
  int n;
  double r;
  cin >> n >> r;
  Poly Pol;
  C c(P(0,0),r);
  for(int i = 0; i < n; ++i){
    double x, y;
    cin >> x >> y;
    Pol.emplace_back(x,y);
  }
  double ans = common_area_cp(c,Pol);
  printf("%.12f\n",ans);
  return 0;
}



Measured memory_bytes: 3536
use proconio::*;

fn run() {
    input! {
        n: usize,
        k: usize,
        s: usize,
        t: usize,
        a: [usize; n],
    }
    let a: Vec<usize> = a.into_iter().filter(|a| a & s == s && a | t == t).collect();
    if a.is_empty() || s & t != s {
        println!("0");
        return;
    }
    let mut comb = vec![vec![0i64; n + 1]; n + 1];
    comb[0][0] = 1;
    for i in 1..=n {
        comb[i][0] = 1;
        for j in 1..=i {
            comb[i][j] = comb[i - 1][j - 1] + comb[i - 1][j];
        }
    }
    let mut bit = vec![];
    for i in 0..18 {
        if (s >> i) & 1 != (t >> i) & 1 {
            bit.push(i);
        }
    }
    let n = std::cmp::min(n, a.len());
    let k = std::cmp::min(k, n);
    let mut cnt = vec![0; 1 << 18];
    let mut ans = 0i64;
    for b in 0..(1usize << bit.len()) {
        let sign = if b.count_ones() % 2 == 0 {1} else {-1};
        let mut mask = 0;
        for (i, &x) in bit.iter().enumerate() {
            if (b >> i) & 1 == 1 {
                mask |= 1 << x;
            }
        }
        for a in a.iter() {
            cnt[*a & mask] += 1;
        }
        for a in a.iter() {
            let x = *a & mask;
            if cnt[x] == 0 {
                continue;
            }
            let v = cnt[x];
            cnt[x] = 0;
            for c in comb[v].iter().skip(1).take(std::cmp::min(v, k)) {
                ans += sign * *c;
            }
        }
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4152
#include <iostream>
#include <cstdio>
#define INF 1e+9
using namespace std;

int h,w,ma = 0,mi = INF;
int field[2000][2000],tmp[2000][2000];
bool used[2000][2000];

bool C(int x){
	int remain = h * w,limit = w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) used[i][j] = false;
	}
	for(int i = 0;i < h;i++){
		for(int j = 0;j < limit;j++){
			if(!used[i][j] && ma - x <= field[i][j]){
				used[i][j] = true;
				remain--;
			}else {
				limit = j;
				break;
			}
		}
	}
	limit = -1;
	for(int i = h - 1;i >= 0;i--){
		for(int j = w - 1;j > limit;j--){
			if(!used[i][j] && mi + x >= field[i][j]){
				used[i][j] = true;
				remain--;
			}else {
				limit = j;
				break;
			}
		}
	}
	return !remain;
}

void rotate(){
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++){
			tmp[j][h - i - 1] = field[i][j];
		}
	}
	int t = h;
	h = w;
	w = t;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) field[i][j] = tmp[i][j];
	}
}

int main(){
	int res = INF;
	cin >> h >> w;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < w;j++) {
			scanf("%d",&field[i][j]);
			ma = max(ma,field[i][j]);
			mi = min(mi,field[i][j]);
		}
	}
	for(int i = 0;i < 4;i++){
		int low = -1,up = INF + 1;
		while(up - low > 1){
			int mid = (low + up) / 2;
			if(C(mid)) up = mid;
			else low = mid;
		}
		res = min(res,up);
		rotate();
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 38380
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True

    @staticmethod
    def fact(N):
        res = {}
        tmp = N
        for i in range(2, int(N ** 0.5 + 1) + 1):
            cnt = 0
            while tmp % i == 0:
                cnt += 1
                tmp //= i
            if cnt > 0:
                res[i] = cnt
        if tmp != 1:
            res[tmp] = 1
        if res == {}:
            res[N] = 1
        return res


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def solve():
    X, Y, A, B, C = Scanner.map_int()
    P = Scanner.map_int()
    Q = Scanner.map_int()
    R = Scanner.map_int()
    P.sort(reverse=True)
    P = P[:X]
    Q.sort(reverse=True)
    Q = Q[:Y]
    R.sort(reverse=True)
    R = R[:min(X + Y, C)]
    ans = P + Q + R
    ans.sort(reverse=True)
    print(sum(ans[:X + Y]))


def main():
    # sys.stdin = open("sample.txt")
    # T = Scanner.int()
    # for _ in range(T):
    #     solve()
    # print('YNeos'[not solve()::2])
    solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 24460
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	int pn = 1;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') { pn = -1; ct = getcha(); }
		A = ct - '0';
		while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
	else {
		if ((ct = *ci++) == '-') { pn = -1; ct = *ci++; }
		A = ct - '0';
		while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
		return pn * A;
	}
}

const int dm = 1 << 21;
char dn[dm], * di = dn;
inline void putintsp(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = ' ';
}
inline void putint(int X) {
	if (X < 0) {
		*di++ = '-';
		X = -X;
	}
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint();
	vector<int> Vp, Vn;
	int saidai = -1e9;
	int saishou = 1e9;
	rep(i, N) {
		int a = getint();
		if (a > saidai) {
			if (saidai != -1e9) {
				if (saidai >= 0) Vp.pb(saidai);
				else Vn.pb(saidai);
			}
			saidai = a;
		}
		else if (a < saishou) {
			if (saishou != 1e9) {
				if (saishou >= 0) Vp.pb(saishou);
				else Vn.pb(saishou);
			}
			saishou = a;
		}
		else if (a >= 0) Vp.pb(a);
		else Vn.pb(a);
	}
	for (int i : Vp) {
		putintsp(saishou);
		putint(i);
		saishou -= i;
	}
	for (int i : Vn) {
		putintsp(saidai);
		putint(i);
		saidai -= i;
	}
	putintsp(saidai);
	putint(saishou);

	int X = saidai - saishou;

	if (X == 0) {
		putchar_unlocked('0');
		putchar_unlocked('\n');
	}
	else {
		if (X < 0) {
			putchar_unlocked('-');
			X = -X;
		}
		int keta = 0;
		char C[10];
		while (X) {
			*(C + keta) = '0' + X % 10;
			X /= 10;
			keta++;
		}
		for (int i = keta - 1; i >= 0; i--) putchar_unlocked(*(C + i));
		putchar_unlocked('\n');
	}

	fwrite_unlocked(dn, di - dn, 1, stdout);

	Would you please return 0;
}

Measured memory_bytes: 4216
#include <stdio.h>
#include <stdlib.h>
int main(){
	int p,q,r,e = 0;
	scanf("%d %d %d",&p,&q,&r);
	e=p+q;
	if(e>r+q){
		e=r+q;
	}
	if(e>p+r){
		e=p+r;
	}
	if(e>q+r){
		e=q+r;
	}
	if(e>r+p){
		e=r+p;
	}
	if(e>q+p){
		e=q+p;
	}
	printf("%d",e);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,int> PLI;
const int MAXN=100005;
const int MAXM=200005;
const LL INF=1e18;
const int mod=1e9+7;

vector<PLI > edge[MAXN];
int n,m,s,t;
LL e[MAXM][3];
LL dis1[MAXN],dis2[MAXN];
LL num1[MAXN],num2[MAXN];

priority_queue<PLI,vector<PLI>,greater<PLI> > pq; 
void SPFA(int s,LL* dis,LL* num){
    for(int i=1;i<=n;i++){
        num[i]=0;
        dis[i]=INF;
    }
    dis[s]=0; num[s]=1;
    pq.push(PLI(0,s));
    while(!pq.empty()){
        PLI a=pq.top(); pq.pop();
        int u=a.second;
        if (dis[u]<a.first) continue;
        for(int i=0;i<edge[u].size();i++){
            int v=edge[u][i].first;
            LL d=edge[u][i].second;
            if (dis[v]>=dis[u]+d){
                if (dis[v]>dis[u]+d) num[v]=num[u],pq.push(PLI(dis[u]+d,v));
                else (num[v]+=num[u])%=mod;
                dis[v]=dis[u]+d;
            }
        }
    }
}

int main(){    
    scanf("%d%d%d%d",&n,&m,&s,&t);
    for(int i=1;i<=m;i++){
        int a,b,c; scanf("%d%d%d",&a,&b,&c);
        e[i][0]=a; e[i][1]=b; e[i][2]=c;
        edge[a].push_back(PLI(b,c));
        edge[b].push_back(PLI(a,c));
    }
    SPFA(s,dis1,num1);
    SPFA(t,dis2,num2);
    LL ans=num1[t]*num2[s]%mod;    
    LL ans1=0;
    for(int i=1;i<=n;i++){
        if (dis1[i]==dis2[i] && dis1[i]+dis2[i]==dis1[t]){
            LL tmp=num1[i]*num2[i]%mod;
            ans-=tmp*tmp%mod;
            if (ans<0) ans+=mod;
        }
    }
    //LL ans2=0;
    for(int i=1;i<=m;i++){
        LL a,b,c; a=e[i][0]; b=e[i][1]; c=e[i][2];
        if (dis1[a]>dis1[b]) swap(a,b);
        if (dis1[a]*2<dis1[t] && dis2[b]*2<dis1[t] && dis1[a]+dis2[b]+c==dis1[t]){
            LL tmp=num1[a]*num2[b]%mod;
            ans-=tmp*tmp%mod;
            if (ans<0) ans+=mod;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 21752
N, T = map(int, input().split())

record = []
for n in range(N):
    c, t = map(int, input().split())
    if t <= T:
        record.append([c, t])

if len(record) > 0:
    record.sort(key = lambda x :x[0], reverse = False)
    print(record[0][0])
else:
    print("TLE")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,x,y;
int gcd(int x,int y)
{
 	return x%y==0?y:gcd(y,x%y);
}
signed main()
{
	cin>>n>>x;
	for(int i=1;i<n;++i)
	{
		cin>>y;
		x/=gcd(y,x);
		x*=y;
	}
	cout<<x;
	return 0;
}

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

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

  if((n % 500) <= a) {
    cout << "Yes";
  } else {
    cout << "No";
  }
    
  //cout << ((n % 500) <= a) ? "Yes" : "No";
}


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

int n, sum, mi, a[105];
double avg, mn=1e9;
int main() {
	int i;
	cin >> n;
	for(i=0; i<n; i++) cin >> a[i], sum += a[i];
	avg = 1.0 * sum / n;
	for(i=0; i<n; i++) {
		if(abs(a[i] - avg) < mn) mn = abs(a[i] - avg), mi = i;
	}
	cout << mi;
	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    string a,b,c;
    cin >> a >> b >> c;
    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])
        cout << "YES" << endl;
    else
    {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void AnsYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void AnsYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}







//ここまでライブラリ
//ここから本文





int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a.at(i);
	}
	sort(a.begin(), a.end());
	int  c = -1000;
	int cnt = 0;
	for (const auto b : a ){
		if (c != b) {
			cnt++;
		}
		c = b;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 256