akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[10000001];
//char str[1010][1010];
//vector<pair<int,int> > pc[100001];
//int ABS(int a){return max(a,-a);}
int main(){
	ll n;
	cin>>n;
	ll a[n],cnt=0,ch=1;
	for(int i=0;i<n;i++) cin>>a[i];
	while(1){
		for(int i=0;i<n;i++){
			if(a[i]%2==1) ch=0;
          a[i]/=2;
		}
		if(ch==0) break;
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
/*
    ████████╗██╗███████╗██╗    ██╗ █████╗ ██╗   ██╗███████╗ █████╗
    ╚══██╔══╝██║██╔════╝██║    ██║██╔══██╗╚██╗ ██╔╝██╔════╝██╔══██╗
       ██║   ██║█████╗  ██║ █╗ ██║███████║ ╚████╔╝ ███████╗╚██████║
       ██║   ██║██╔══╝  ██║███╗██║██╔══██║  ╚██╔╝  ╚════██║ ╚═══██║
       ██║   ██║███████╗╚███╔███╔╝██║  ██║   ██║   ███████║ █████╔╝
       ╚═╝   ╚═╝╚══════╝ ╚══╝╚══╝ ╚═╝  ╚═╝   ╚═╝   ╚══════╝ ╚════╝

    @Author: TieWay59
    @Date: 2019/11/22 13:38
    @Link: https://atcoder.jp/contests/agc040/tasks/agc040_b
    @Tags: idea
*/

#include <bits/stdc++.h>

#define  debug(x)  cerr <<#x << " = "<<x<<endl

#define endl '\n'
#define STOPSYNC ios::sync_with_stdio(false);cin.tie(nullptr)
#define MULTIKASE int Kase=0;cin>>Kase;for(int kase=1;kase<=Kase;kase++)
typedef long long ll;
const int MAXN = 2e5 + 59;
const int MOD = 1e9 + 7;
const int INF = 0x3F3F3F3F;
const ll llINF = 0x3F3F3F3F3F3F3F3F;
using namespace std;

int n, m;
struct node {
    ll l, r;
} a[MAXN];
ll maxL;
ll minR;
ll ans;
ll ansInLeft[MAXN];
ll ansInRight[MAXN];
node pairInLeft[MAXN];
node pairInRight[MAXN];

void solve(int kaseId = -1) {

    cin >> n;

    for (int i = 1; i <= n; ++i) {
        cin >> a[i].l >> a[i].r;
        ans = max(ans, a[i].r - a[i].l + 1);
    }

    sort(a + 1, a + 1 + n, [](node x, node y) {
        if (x.l == y.l)return x.r < y.r;
        return x.l < y.l;
//        return (x.r - x.l) < (y.r - y.l);
    });

    maxL = 0;
    minR = llINF;
    for (int i = 1; i <= n; ++i) {
        maxL = max(maxL, a[i].l);
        minR = min(minR, a[i].r);
        if (maxL <= minR) {
            ansInLeft[i] = minR - maxL + 1;
            pairInLeft[i] = {maxL, minR};
        } else {
            break;
        }
    }

    maxL = 0;
    minR = llINF;
    for (int i = n; i >= 1; --i) {
        maxL = max(maxL, a[i].l);
        minR = min(minR, a[i].r);
        if (maxL <= minR) {
            ansInRight[i] = minR - maxL + 1;
            pairInRight[i] = {maxL, minR};
        } else {
            break;
        }
    }

    for (int i = 1; i < n; ++i) {
        ans = max(ans, ansInLeft[i] + ansInRight[i + 1]);
    }

    for (int i = 2; i < n; ++i) {
        ll len = a[i].r - a[i].l + 1;
        if (ansInRight[i + 1] &&
            ansInLeft[i - 1] &&
            pairInRight[i + 1].l <= pairInLeft[i - 1].r) {
            ans = max(ans, len +
                           min(pairInLeft[i - 1].r, pairInRight[i + 1].r)
                           - pairInRight[i + 1].l + 1);
        }
    }

    cout << ans << endl;
}

/*void solves() {
    MULTIKASE {
        solve(kase);
    }
}*/

int main() {
    STOPSYNC;
//    solves();
    solve();
    return 0;
}
/*

 */

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
#define N 305
double dp[N][N][N];
int n;
double fn(int x,int y,int z,int n) {
	if(x<0 || y<0 || z<0) {return 0;}
  	if(!x && !y && !z) {return 0;}
  	if(dp[x][y][z]>0) {return dp[x][y][z];}
  	int t=x+y+z;
  	return dp[x][y][z]=(n+x*fn(x-1,y,z,n)+y*fn(x+1,y-1,z,n)+z*fn(x,y+1,z-1,n))/t;
}
int main() {
  	int x=0,y=0,z=0,a;
  	cin>>n;
  	for(int i=0;i<n;i++) {
      cin>>a;
      x+=(a==1)?1:0;
      y+=(a==2)?1:0;
      z+=(a==3)?1:0;
    }
  	memset(dp,-1,sizeof(dp));
  	cout<<fixed<<setprecision(9);
  	double t=fn(x,y,z,n);
  	cout<<t<<endl;
return 0;
}


Measured memory_bytes: 225508
#include<iostream>
#include<functional>
#include<cmath>
#include<numeric>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,m,ans=0,tmp;
  cin>>n>>m;
  map<ll,ll> mp;
  vector<ll> v;
  ll a[n],b[m],c[m];
  rep(i,n){
    cin>>a[i];
    mp[a[i]]++;
  }
  rep(i,m){
    cin>>b[i]>>c[i];
    mp[c[i]]+=b[i];
  }
  for(auto p:mp){
    v.push_back(p.first);
  }
  sort(v.begin(),v.end(),greater<ll>());
  ll kosuu=0;
  rep(i,n+m){
    tmp=mp[v[i]];
    if(kosuu+tmp>n){
      ans+=v[i]*(n-kosuu);
      break;
    }else{
      ans+=v[i]*tmp;
      kosuu+=tmp;
    }
  }
  cout<<ans;
}


Measured memory_bytes: 17268
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    int a, b, c;
    cin >> a >> b >> c;
    cout << (a+b >= c ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
#include<vector>
#define debug(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
const int inf=1e9;
const int maxn=1e5+50;
const int maxp=maxn<<1;
int n,m;
int N;
int a[maxn];
int b[maxn];
int P[maxn];
int Q[maxn];
int head[maxp];
struct edge
{
	int to,nex,cap,flow;
	edge(int to=0,int nex=0,int cap=0,int flow=0):to(to),nex(nex),cap(cap),flow(flow){}
};
vector<edge> G;
inline void addedge(int u,int v,int c)
{
	G.push_back(edge(v,head[u],c,0)),head[u]=G.size()-1;
	G.push_back(edge(u,head[v],0,0)),head[v]=G.size()-1;
}
namespace dinic
{
	int cur[maxp];
	int dis[maxp];
	bool BFS(int s,int t)
	{
		static int que[maxp];
		int hd=0,tl=0;
		memset(dis,-1,sizeof(dis));
		que[tl++]=s;
		dis[s]=0;
		while(hd<tl)
		{
			int u=que[hd++];
			for(int i=head[u];~i;i=G[i].nex) if(G[i].cap!=G[i].flow)
			{
				int v=G[i].to;
				if(dis[v]==-1)
				{
					dis[v]=dis[u]+1;
					que[tl++]=v;
				}
			}
		}
		return dis[t]!=-1;
	}
	int DFS(int u,int flow,int t)
	{
		if(u==t||flow==0) return flow;
		int rec=flow;
		for(int &i=cur[u];~i;i=G[i].nex)
		{
			int v=G[i].to;
			if(dis[v]==dis[u]+1)
			{
				int d=DFS(v,min(flow,G[i].cap-G[i].flow),t);
				G[i].flow+=d,G[i^1].flow-=d;
				flow-=d;
				if(flow==0) break;
			}
		} 
		return rec-flow;
	}
	int maxflow(int s,int t)
	{
		int flow=0;
		while(BFS(s,t))
		{
			memcpy(cur,head,sizeof(head));
			flow+=DFS(s,inf,t);
		}
		return flow;
	}
}
void findcircle(int &n,int *a,int *P)
{
	for(int i=0;i<N;++i) if(!a[i])
	{
		a[i]=++n;
		for(int u=P[i];u!=i;u=P[u]) a[u]=n;
	}
}
int solve()
{
	findcircle(n,a,P);
	findcircle(m,b,Q);
	memset(head,-1,sizeof(head));
	int an=N;
	int p=n+m;
	for(int i=0;i<N;++i)
	{
		if(P[i]==i&&Q[i]==i) --an;
		else if(P[i]==i)
		{
			addedge(n+b[i],p+1,1);
		}
		else if(Q[i]==i)
		{
			addedge(0,a[i],1);
		}
		else
		{
			addedge(n+b[i],a[i],1);
			if(P[i]==Q[i])
			{
				addedge(a[i],n+b[i],1);
			}
		}
	}
	an-=dinic::maxflow(0,p+1);
	return an;
}
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;++i) scanf("%d",&P[i]);
	for(int i=0;i<N;++i) scanf("%d",&Q[i]);
	printf("%d\n",solve());
	return 0;
} 

Measured memory_bytes: 12908
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n){
        cin >> a[i];
    }
    sort(a, a + n);
    ll now = a[0];
    rep(i,n - 1){
        if(now == a[i + 1]){
            cout << "NO" << endl;
            return 0;
        }
        now = a[i + 1];
    }
    cout << "YES" << endl;
    return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int a; cin >> a;
        int b; cin >> b;
        if (a >= 13) cout << b;
        else if (a >= 6) cout << b / 2;
        else cout << 0;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int N;
	cin>>N;
	vector<int> ds(N);
	rep(i,N)cin>>ds[i];
	sort(all(ds));
	cout<<ds[N/2]-ds[N/2-1]<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
void p(int *x, int *y, int n)
{
    *x = n % 10;
    while(n){
        if(n / 10 == 0)  *y = n;
        n /= 10;
    }
}
int main()
{
    int  count = 0,i,j, n;
    int std;
    int x1, y1, x2, y2;
    scanf("%d",&n);
    if(n < 10) printf("%d\n",n);
    else {
    std = (n / 10) *(n / 10) + 8;
    for(i=n/10 * 10 + 1; i<=n; i++)
    {
        p(&x1, &y1, i);
        for(j=1; j<=n; j++){
            p(&x2, &y2, j);
            if(x1 == y2 && x2 == y1){
                if(j==i) count++;
                else count+=2;}
        }
    }
    printf("%d\n",count + std);
    }
    return 0;
}

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

int main(){
  stack<int> S1;
  stack<pair<int, int> > S2;
  char ch;
  int sum = 0;
  for(int i = 0; cin >> ch; i++){
    if(ch == '\\') S1.push(i);
    else if(ch == '/' && S1.size() > 0){
      int j = S1.top(); S1.pop();
      sum += i - j;
      int a = i - j;
      while(S2.size() > 0 && S2.top().first > j){
        a += S2.top().second; S2.pop();
      }
      S2.push(make_pair(j,a));
    }
  }

  vector<int> ans;
  int t = 0;
  while(S2.size() > 0){ans.push_back(S2.top().second); S2.pop();}
  reverse(ans.begin(), ans.end());
  cout << sum << endl;
  cout << ans.size();
  for(int i = 0; i < ans.size(); i++){
    cout << " ";
    t += ans[i];
    cout << ans[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 3208
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int total = 0;
        for (int i = 0; i < N; i++) {
            int l = in.nextInt();
            int r = in.nextInt();
            total+= (r-l+1);
        }
        
        System.out.println(total);
    }
}

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

using namespace std;

class Solution {
public:
	void solve() {
		long long n, k;
		cin >> n >> k;
		vector<int> a(n, 0);
		for (int i = 0; i < n; i++) cin >> a[i];
		for (int i = 0; i < n; i++) a[i]--;
		vector<int> d(n, -1);
		int pos = 0;
		d[0] = 0;
		bool flag = true;
		while (1) {
			if (k == 0) {
				cout << pos + 1 << endl;
				return;
			}
			if (d[a[pos]] != -1 && flag) {
				int p = d[pos] + 1 - d[a[pos]];
				k %= p;
				flag = false;
			} else {
				d[a[pos]] = d[pos] + 1;
				pos = a[pos];
				k--;
			}
		}
		return;
	};
};

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 4784
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;

#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    if(b%a==0){
        cout << a+b<<endl;
    }else{
        cout<<b-a <<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author AnandOza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AServalVsMonster solver = new AServalVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class AServalVsMonster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.nextInt(), a = in.nextInt();

            out.println((h + a - 1) / a);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

const int64_t MOD = 1000000007;
const int MAX_N = 1000005;
int64_t mem[MAX_N][2][2];
int64_t N;

int64_t dp(int n, bool had9, bool had0) {
  if (n == N) {
    return had9 && had0;
  }
  if (mem[n][had9][had0] != -1) return mem[n][had9][had0];
  int64_t mul = 10 - !had9 - !had0;
  int64_t ans = 0;
  if (!had9) ans = (ans + dp(n + 1, 1, had0)) % MOD;
  if (!had0) ans = (ans + dp(n + 1, had9, 1)) % MOD;
  ans = ((ans + dp(n + 1, had9, had0) * mul) % MOD);
  mem[n][had9][had0] = ans % MOD;
  return ans % MOD;
}

int main() {
  scanf("%lld", &N);
  memset(mem, -1, sizeof(mem));
  printf("%lld\n", dp(0, 0, 0));
}


Measured memory_bytes: 128748
import java.util.Scanner;

public class Main {

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

		int tap = Integer.parseInt(sc.next());
		int socketGoal = Integer.parseInt(sc.next());

		int socket = 1;

		for (int i = 0;; i++) {
			if (socket >= socketGoal) {
				System.out.println(i);
				break;
			}
			socket += tap - 1;
		}

	}

}


Measured memory_bytes: 22740
//
// Created by Huang,Zhiqiang on 2018/7/16.
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

typedef long long ll;

typedef long long ll;
int n;
ll a,b,c,d;
ll gcd(ll x,ll y){
    if(y==0)
        return x;
    return gcd(y,x%y);
}
int main(){
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> a >> b >> c >> d;
        if(a < b){
            cout << "No" << endl;
            continue;
        }
        if(b > d){
            cout << "No" << endl;
            continue;
        }
        if(c + 1 >= b){
            cout << "Yes" << endl;
            continue;
        }
        ll g = gcd(b,d);
        if((a-c-1ll)/g-(a-b)/g>0)
            cout << "No" << endl;
        else
            cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX	(100)

int main(void)
{
	int data[MAX + 1] = { 0 };
	int most_num = 0;
	int i;
	
	while (scanf("%d", &i) != EOF) data[i]++;
	for (i = 1; i <= MAX; i++) if (most_num < data[i]) most_num = data[i];
	for (i = 1; i <= MAX; i++) if (most_num == data[i]) printf("%d\n", i);
	
	return (0);
}

Measured memory_bytes: 0
#include<iostream>
#include<cstdio>
#include<cctype>
#include<algorithm>
#include<cstring>
//This code is written by Itst
using namespace std;

inline int read(){
	int a = 0;
	char c = getchar();
	while(!isdigit(c))
		c = getchar();
	while(isdigit(c)){
		a = a * 10 + c - 48;
		c = getchar();
	}
	return a;
}

#define ll long long
const int MAXN = 2e5 + 3;
struct Edge{
	int end , upEd , w;
}Ed[MAXN << 1];
struct edge{
	int s , t;
	ll w;
	bool operator <(const edge a)const{return w < a.w;}
}cur[MAXN << 5];
int head[MAXN] , val[MAXN] , fa[MAXN];
int cnt , cntEd , nowSz , minSz , rt , N;
ll minVal , minInd;
bool vis[MAXN];

inline void addEd(int a , int b , int c){
	Ed[++cntEd] = (Edge){b , head[a] , c};
	head[a] = cntEd;
}

void getSz(int x){
	vis[x] = 1;
	++nowSz;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(!vis[Ed[i].end]) getSz(Ed[i].end);
	vis[x] = 0;
}

int getRt(int x){
	int maxN = 0 , sz = 1;
	vis[x] = 1;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(!vis[Ed[i].end]){
			int t = getRt(Ed[i].end);
			maxN = max(maxN , t); sz += t;
		}
	maxN = max(maxN , nowSz - sz);
	if(minSz > maxN){minSz = maxN; rt = x;}
	vis[x] = 0;
	return sz;
}

void getVal(int x , ll dis){
	vis[x] = 1;
	if(minVal > val[x] + dis) minVal = val[minInd = x] + dis;
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(!vis[Ed[i].end])	getVal(Ed[i].end , dis + Ed[i].w);
	vis[x] = 0;
}

void getEd(int x , ll dis){
	vis[x] = 1;
	cur[++cnt].s = x; cur[cnt].t = minInd;
	cur[cnt].w = dis + minVal + val[x];
	for(int i = head[x] ; i ; i = Ed[i].upEd)
		if(!vis[Ed[i].end])	getEd(Ed[i].end , dis + Ed[i].w);
	vis[x] = 0;
}

void dfz(int x){
	nowSz = 0; minSz = 1e9; minVal = 1e18;
	getSz(x); getRt(x);
	getVal(rt , 0); getEd(rt , 0);
	vis[rt] = 1;
	for(int i = head[rt] ; i ; i = Ed[i].upEd)
		if(!vis[Ed[i].end]) dfz(Ed[i].end);
}

int find(int x){return fa[x] == x ? x : (fa[x] = find(fa[x]));}

int main(){
	N = read();
	for(int i = 1 ; i <= N ; ++i) val[fa[i] = i] = read();
	for(int i = 1 ; i < N ; ++i){
		int a = read() , b = read() , c = read();
		addEd(a , b , c); addEd(b , a , c);
	}
	dfz(1);
	sort(cur + 1 , cur + cnt + 1);
	ll sum = 0;
	for(int i = 1 ; i <= cnt ; ++i)
		if(find(cur[i].s) != find(cur[i].t)){
			fa[find(cur[i].s)] = find(cur[i].t);
			sum += cur[i].w;
		}
	cout << sum;
	return 0;
}


Measured memory_bytes: 69760
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll r,c;
    cin>>r>>c;
    ll a[r+2][c+2],i,j,k=0,sum=0,sum2=0;
    for(i=1; i<=r; i++)
    {
        for(j=1; j<=c; j++)
        {
            cin>>a[i][j];
        }
    }
    for(i=1; i<=r; i++)
    {
        sum=0;
        for(j=1; j<=c; j++)
        {
            cout<<a[i][j]<<" ";
            sum+=a[i][j];
        }
        k+=sum;
        cout<<sum<<endl;
    }
    for(i=1; i<=c; i++)
    {
        sum2=0;
        for(j=1; j<=r; j++)
        {
            sum2+=a[j][i];
        }
        cout<<sum2<<" ";
    }
    cout<<k<<endl;
    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	string c;
	cin>>c;
	int lr=0;
	int lw=0;
	int rr=0;
	int rw=0;
	for(int i=0;i<n;i++){
		if(c[i]=='R')rr++;
		else rw++;
	}
	int ans=rr;
	for(int i=0;i<n;i++){
		if(c[i]=='R'){
			lr++;
			rr--;
		} else {
			lw++;
			rw--;
		}
		int cur=0;
		int nr=i+1-lr;
		cur+=min(nr,rr);
		cur+=i+1-lr-min(nr,rr);
		cur+=n-i-1-rw-min(nr,rr);
		ans=min(ans,cur);
	}
	cout<<ans;
}



Measured memory_bytes: 3748
#include <bits/stdc++.h>
#define N 1000005
#define ll long long
#define For(i,x,y) for(int i=(x);i<=(y);++i)
#define Rof(i,x,y) for(int i=(x);i>=(y);--i)
#define Edge(x) for(int i=head[x];i;i=e[i].nxt)
#define mset(x,y) memset(x,y,sizeof(x))
#define strL strlen
#define p_b push_back
#define mcpy(x,y) memcpy(x,y,sizeof(x))
#define lson l,mid,(o<<1)
#define rson mid+1,r,((o<<1)|1)
#define Ls (t[o].ls)
#define Rs (t[o].rs)
#define mod 1000000007
using namespace std;
ll sum[N],dp[N],_[N];
int main(){
	int n;ll ans=0;
	scanf("%d",&n);
	dp[0]=sum[0]=1;
	For(i,1,n-1){
		dp[i]=dp[i-1];
		if(i>=3) (dp[i]+=sum[i-3])%=mod;
		sum[i]=(sum[i-1]+dp[i])%mod; 
	}
	For(i,0,n-2) (ans+=1ll*dp[i]*n%mod*(1ll*n-1)%mod)%=mod;
	(ans+=dp[n-1]*(1ll*n-1)%mod)%=mod;
	printf("%lld\n",(ans+1)%mod);
}

Measured memory_bytes: 17536
#include <iostream>
#include <cmath>
#include <iomanip>
#include <utility>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#define ll long long
         
using namespace std;
     
long long gcd(int x, int y){
     if ( x == 0 ) return y;
     
     return gcd(y%x, x);
}
     
long long lcm(int x, int y){
     if ( y == 0 ){
          return x;
     }
     
     return x*y/gcd(x, y);
}
     
int min(int a, int b){
     return a > b ? b : a;
}
     
double max(double a, double b){
     return a > b ? a : b;
}

int main()
{
     cin.sync_with_stdio( false );

     int h,n;
     cin>>h>>n;

     int a = 0;
     for (int i=0;i<n;i++){
          int b;
          cin>>b;
          a+=b;
     }

     if ( a >= h ){
          cout<<"Yes"<<endl;
     }else{
          cout<<"No"<<endl;
     }
}

Measured memory_bytes: 3616
N = int(input())
ans = [0 for i in range(N)]
import math
for i in range(N-1):
  c, s, f = map(int, input().split())
  for j in range(i+1):
    if ans[j]>=s:
      x = math.ceil((ans[j]-s)/f)
      ans[j] = s+f*x+c
    else:
      ans[j] = s+c
for i in range(N):
  print(ans[i])

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
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; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    int a, b, c; cin >> a >> b >> c;
    int k; cin >> k;
    int ans = 0;
    ans += min(a, k);
    k -= a;
    k -= b;
    if(k > 0){
        ans -= k;
    }
    cout << ans << endl;
}


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

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

int n, K;
set<int> mySet;
vector<int> v;

vector<int> getDigits(int x) {
	vector<int> v;
	while (x) {
		v.pb(x % 10);
		x /= 10;
	}
	reverse(v.begin(), v.end());
	return v;
}

void faCelMaiMic() {
	// cout << "in el";
	for (int i = 1; i < 10 ; ++i) {
		if (mySet.find(i) == mySet.end()) {
			cout << i;
			break;
		}
	}
	for (int k = 0; k < v.size(); ++k) {
		for (int i = 0; i < 10 ; ++i) {
			if (mySet.find(i) == mySet.end()) {
				cout << i;
				break;
			}
		}
	}
}

int main() {
	ios::sync_with_stdio(false);
	// #ifndef ONLINE_JUDGE
	// freopen("test.in", "r", stdin);
	// //freopen("test.out", "w", stdout);
	// #endif

	cin >> n >> K;
	for (int i = 1; i <= n; ++i) {
		int x;
		cin >> x;
		mySet.insert(x);
	}

	v = getDigits(n);
	vector<int> nextDigit(v.size());
	for (int i = 0; i < v.size(); ++i) {
		int currDigit = v[i];
		nextDigit[i] = -1;
		for (int j = currDigit; j < 10; ++j) {
			if (mySet.find(j) == mySet.end()) {
				nextDigit[i] = j;
				break;
			}
		}
	}

	int firstPos = -1;
	for (int i = 0; i < v.size(); ++i) {
		if (nextDigit[i] == -1) {
			firstPos = i;
			break;
		}
	}


	if (firstPos == 0) {
		// cout << "aic\n";
		faCelMaiMic();
		return 0;
	}
	bool ok = false;
	for (int i = 0; i < firstPos; ++i) {
		if (nextDigit[i] > v[i]) {
			ok = true;
		}
	}
	if (ok == false && firstPos > -1) {
		bool flagMare = false;
		for (int i = firstPos - 1; i >= 0; --i) {
			bool flag = false;
			for (int j = nextDigit[i] + 1; j < 10; ++j) {
				if (mySet.find(j) == mySet.end()) {
					nextDigit[i] = j;
					flag = true;
					break;
				}
			}
			if (flag) {
				flagMare = true;
				break;
			}
		}
		if (!flagMare) {
			// cout << "aicicic\n";
			faCelMaiMic();
			return 0;
		}
	}
	ok = false;
	for (int i = 0; i < v.size(); ++i) {
		if (ok) {
			for (int i = 0; i < 10; ++i) {
				if (mySet.find(i) == mySet.end()) {
					cout << i;
					break;
				}
			}
			continue;
		}
		if (nextDigit[i] > v[i]) {
			ok = true;
		}
		cout << nextDigit[i];
	}


	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

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

s = lc()
t = lc()

s.sort()
t.sort(reverse=True)

if "".join(s) < "".join(t):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
using namespace std;

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

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

	vector <int> v(3);
	REP(i, 3) cin >> v[i];
	VSORT(v);

	ostringstream v21s;
	v21s << v[2] << v[1];

	int v21i;
	istringstream v21;
	v21 = istringstream(v21s.str());
	v21 >> v21i;

	cout << v21i + v[0] << "\n";
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int k, s;
  cin >> k >> s;
  int ans = 0;
  REP(tx, k+1) {
    FOR(ty, tx, k+1) {
      FOR(tz, ty, k+1) {
        if(tx + ty + tz == s) {
          if(tx == ty && ty == tz) {
            ans += 1;
          }
          else if(tx == ty || tx == tz || ty == tz) {
            ans += 3;
          }
          else {
            ans += 6;
          }
        }
      }
    }
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main{


	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int[] C =new int[N];
		int[] S = new int[N];
		int[] F = new int[N];

		for(int i = 0;i < N-1;i++){
			C[i] = scanner.nextInt();
			S[i] = scanner.nextInt();
			F[i] = scanner.nextInt();
		}

		int[] data = new int[N];
		int count = 0;
		for(int i = 0;i < N;i++){
			count = i;
			data[i] += C[count] + S[count];

			while(count< N-2){
				while(data[i] % F[count+1] != 0 || data[i] < S[count+1]){
					data[i]++;
				}
				count++;
				data[i] += C[count] ;

			}
		}
		
		for(int i = 0;i < N;i++){
			System.out.println(data[i]);
		}






	}
}
class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}



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

#define szv(V) ((int)(V).size())
#define allv(V) ((V).begin(), ((V).end()))
#define sortv(V) sort(allv(V))
#define uniquev(V) (V).erase(unique(allv(V)), (V).end())
#define compv(V) sortv(V), uniquev(V)
#define fs first
#define se second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int mod = 1e9 + 7;
const ll inf = 4e18;

ll gcd(ll x, ll y) { while (y) x %= y, swap(x, y); return x; }
pll operator+(pll a, pll b) { return pll(a.fs + b.fs, a.se + b.se); }
pll operator-(pll a, pll b) { return pll(a.fs - b.fs, a.se - b.se); }
ll operator*(pll a, pll b) { return a.fs * b.se - a.se * b.fs; }
int sign(ll x) { return x < 0 ? -1 : x > 0 ? 1 : 0; }
int ccw(pll a, pll b, pll c) { return sign((b - a) * (c - b)); }
template <class T> void setmin(T &x, T y) { if (x > y) x = y; }
template <class T> void setmax(T &x, T y) { if (x < y) x = y; }
template <class T> void addval(T &x, T y) { x += y; x %= mod; }

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int x, y;
    cin >> x >> y;
    cout << x + y / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<algorithm>
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 chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
inline int getintA() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = ((tmp & ma0) ^ ma0) ? 68 - __builtin_ctzll((tmp & ma0) ^ ma0) : 0;
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += (64 - dig >> 3);
	while ((ct = *ci++) >= '0') tmp = tmp * 10 + ct - '0';
	return tmp;
}
char dn[1300000], *di = dn;
inline void putint(int 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--)* di++ = (*(C + i));
	*di++ = '\n';
}
int N;
int A[200001];
int E[400001], ne[400001], he[200001], it[200001];
int V[200001], v;
int S[200001], s;

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

	N = getint();
	rep1(i, N) A[i] = getintA();
	int k = 1;
	rep(i, N - 1) {
		int u = getint(), v = getint();
		E[k] = v;
		ne[k] = he[u];
		he[u] = k++;
		E[k] = u;
		ne[k] = he[v];
		he[v] = k++;
	}

	V[v++] = 2000000000;
	S[s++] = 1;
	while (s) {
		int p = S[s - 1];
		if (p > 0) {
			S[s - 1] = -p;
			if (V[v - 1] < A[p]) {
				it[p] = v;
				swap(V[v++], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			else {
				it[p] = lower_bound(V, V + v, A[p]) - V;
				swap(V[it[p]], A[p]);
				for (auto to = he[p]; to; to = ne[to]) {
					if (he[E[to]] > 0) {
						S[s++] = E[to];
					}
				}
			}
			he[p] = -v;
		}
		else {
			s--;
			p = -p;
			V[it[p]] = A[p];
			v -= !A[p];
		}
	}

	rep1(i, N) putint(-he[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

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

int x;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> x;
	if(x == 3 || x == 5 || x == 7) cout << "YES\n";
	else cout << "NO\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const ll md = 998244353;

ll mem[301][301][301] = {};

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);
	cin.exceptions(cin.failbit);

	string s;
	int k;
	cin >> s >> k;
	s.push_back('0');
	k = min(k, 300);

	vi ls;
	for(int i = 0, cnt = 0; i < sz(s); ++i){
		if(s[i] == '0'){
			ls.push_back(cnt);
			cnt = 0;
		} else ++cnt;
	}
	while(!ls.empty() && ls.back() == 0) ls.pop_back();

	mem[0][0][k] = 1;

	rep(i,0,sz(ls)){
		rep(t,0,301) rep(c,0,k+1){
			ll cur = mem[i][t][c];
			cur %= md;
			mem[i+1][t][c] += cur; // neutral
			rep(x,1,c+1) if(t+x <= 300) mem[i+1][t + x][c - x] += cur; // get stuff
			rep(x,1,1+min(ls[i], t)) mem[i+1][t-x][c] += cur; // give stuff
		}
	}

	ll ans = 0;
	rep(c,0,k+1) ans += mem[sz(ls)][0][c];
	ans %= md;
	if(ans < 0) ans += md;
	cout << ans << endl;
}


Measured memory_bytes: 196132
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    x, t = LI()
    print(max(0, x-t))
    return

#B
def B():
    s = S()
    print("".join(s[::2]))
    return

#C
def C():
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    B()


Measured memory_bytes: 46832
import * as fs from 'fs';
function main(input) {
  input = input.split("\n");
  const [D, S, T] = input[0].split(' ').map(i => parseInt(i));
  // console.log(D, S, T);
  console.log('%s', D / S <= T ? 'Yes' : 'No');
}

main(fs.readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29596
S = input()
N = len(S)
ret = [0] * (N+1)
r = 0
for i in range(N-1):
    if S[i] + S[i+1] == "RL":
        if r % 2 == 0:
            ret[i] += (r // 2 + 1)
            ret[i+1] += (r // 2 + 1)
        else:
            ret[i] += (r // 2 + 1)
            ret[i+1] += ((r-r//2) + 1)
        r = 0
    elif S[i] == "R":
        r += 1

l = 0
for i in range(N-1, 0, -1):
    if S[i-1] + S[i] == "RL":
        if l % 2 == 0:
            ret[i] += l // 2
            ret[i-1] += l // 2
        else:
            ret[i] += l // 2
            ret[i-1] += (l-l//2)
        l = 0
    elif S[i] == "L":
        l += 1

print(*ret[:N], sep=" ")

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
int main(){
		int a,b;
		cin>>a>>b;
		int y = 1;
		
		y=((a<=8)&&(b<=8))?1:0;
		
		if(y==1) cout<<"Yay! "<<endl;
		else cout<<":( "<<endl;
		
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>

using namespace std;

void toUpper(string &text);

int main(void) {
	string text;
	while(1) {
		getline(cin, text);
		if(cin.eof())		break;
		toUpper(text);
		cout << text << endl;
	}
	
	return 0;
}

void toUpper(string &text) {
	for(unsigned int i = 0; i < text.size(); i++) {
		if(text[i] >= 'a' && text[i] <= 'z') {
			text[i] -= 32;
		}
	}
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define MOD 1000000007

int main(){
  int n,a;
  cin>>n>>a;
  n%=500;
  if(n>a){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}


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

int main(){
  int n;
  while(cin >> n,n){
    vector< vector<int> > v(n,vector<int>(n));
    
    for(int i=0;i<n;i++){
      for(int j=0;j<n;j++){
	cin >> v[i][j];
      }
    }
  
    vector<int> sum(n+1,0);
    for(int i=0;i<n;i++){
      int tmp = 0;
      for(int j=0;j<n;j++){
	tmp += v[i][j];
	sum[j] += v[i][j];
      }
      v[i].push_back(tmp);
      sum[n] += tmp;
    }
    v.push_back(sum);
    
    for(int i=0;i<n+1;i++){
      for(int j=0;j<n+1;j++){
	cout << setw(5) << v[i][j];
      }
      cout << endl;
    }
  }
}

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

#define ALL(a)  (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define REP(i,n) for(int i=0;i<(int)n;++i)

#define CLEAR(a) memset((a), 0, sizeof(a))

inline int toInt(string s) { int x; istringstream iss(s); iss >> x; return x; }
template<class T> inline string toString(T x) { ostringstream oss; oss <<x ; return oss.str(); }
template<class T> inline T sqr(T x) { return x * x; }

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

static const auto io_sync_off = []() {
    // turn off sync
    std::ios::sync_with_stdio(false);
    // untie in/out streams
    std::cin.tie(nullptr);
    return nullptr;
}();

bool f[26][26];

int main(int argc, char *argv[]) {
    string s, t;
    cin >> s; cin >> t;

    bool ans = true;
    if (s != t) REP(i, SZ(s)) {
        int x = s[i] - 'a', y = t[i] - 'a';
        f[x][y] = true;
        int cnt = 0;
        REP(j, 26) if (f[j][y]) cnt++;
        if (cnt >= 2) { ans = false; break; }
        cnt = 0;
        REP(j, 26) if (f[x][j]) cnt++;
        if (cnt >= 2) { ans = false; break; }
    }

    if (ans) cout << "Yes" << endl; else cout << "No" << endl;


    return 0;
}



Measured memory_bytes: 916
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        
        for(int i=1; i<=N; i++){
            map.put(i, 0);
        }
        
        for(int i=0; i<M*2; i++){
            int a = Integer.parseInt(sc.next());
            map.put(a, map.get(a) + 1);
        }
        
        for(int i=1; i<=N; i++){
            System.out.println(map.get(i));
        }
    }
}

Measured memory_bytes: 21844
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int n = in.nextInt();
		int m = in.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++)
			h[i] = in.nextInt();
		boolean[] t = new boolean[n];
		for (int i = 0; i < m; i++) {
			int a = in.nextInt() - 1;
			int b = in.nextInt() - 1;
			if (h[a] <= h[b])
				t[a] = true;
			if (h[a] >= h[b])
				t[b] = true;
		}
		int r = 0;
		for (int i = 0; i < n; i++)
			if (!t[i])
				r++;
		System.out.println(r);
	}
}

Measured memory_bytes: 59244
import java.util.Scanner;

class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		for(;;){
			String str = scan.next();

			if(str.equals("0"))
				break;

			int ans = 0;

			for(int i=0; i<str.length(); i++){
				ans += Character.getNumericValue(str.charAt(i));
			}

			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
        cin >> vec.at(i);
    }
    
    int cnt = 0;

    sort(all(vec));

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            for (int k = j + 1; k < N; k++) {
                if (vec.at(i) != vec.at(j)
                && vec.at(j) != vec.at(k)
                && vec.at(k) != vec.at(i)) {
                    if (vec.at(i) + vec.at(j) > vec.at(k)) {
                        cnt++;
                    }
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3632
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;



void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct 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(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}

Measured memory_bytes: 24040
N = int(input())
Data = []
for _ in range(N):
    Data.append(int(input()))

MP = sum(Data)
DP = []
for i in range(N+1):
    DP.append([0]*(MP+1))

for i in range(1,N+1):
    point = Data[i-1]
    DP[i][point] = 1
    for p in range(0,MP+1):
        if DP[i-1][p] == 1:
            DP[i][p] = 1
            DP[i][p+point] = 1

ans = 0
for i in range(MP+1):
    if DP[N][i] == 1 and i % 10 != 0:
        ans = i

print(ans)


Measured memory_bytes: 10868
s=input()
ans=[0]*4
check='NWSE'
for i in range(len(s)):
  for j in range(len(check)):
    if s[i]==check[j]:
      ans[j]+=1
if ans[0]!=0 and ans[2]!=0 and ans[1]!=0 and ans[3]!=0:
  print('Yes')
elif ans[0]!=0 and ans[2]!=0 and ans[1]==0 and ans[3]==0:
  print('Yes')
elif ans[0]==0 and ans[2]==0 and ans[1]!=0 and ans[3]!=0:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int main(int argc, char *argv[])
{
	int total = 0;

	while (scanf("%d", &total) != EOF) {
		int i, j, k;
		int count = 0;

		for (i = 0; i <= 9; i++)
			for (j = 0; j <= 9; j++)
				for (k = 0; k <= 9; k++) {
					int rest = total - (i + j + k);
					if (rest >= 0 && rest <= 9)
						count++;
				}

		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 596
def BFS(t):
    inf=10**3
    D=[inf for _ in range(n)]
    D[-1]=1

    for i in range(n):
        if s[i]==t:D[i]=0

    for i in range(1,n)[::-1]:
        if D[i-1]==inf:D[i-1]=D[i]+1

    return max(D)


s=input()
n=len(s)
ans=10**4
for i in range(26):
    ans=min(ans,BFS(chr(97+i)))
print(ans)

Measured memory_bytes: 41072
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var A, B int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &A, &B)

	fmt.Println(max(A+B, A-B, A*B))
}

func max(ns ...int) int {
	ret := math.MinInt64
	for _, n := range ns {
		if n > ret {
			ret = n
		}
	}
	return ret
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int x;
    cin>>x;
    int temp=x/__gcd(x,360);
    cout<<(360*temp)/x<<"\n";
	return 0;
}

Measured memory_bytes: 3532
#include<stdio.h>
int main(){
  int i,j,N,S,c=0,minj;
  int A[100];
  scanf("%d",&N);
 
  for (i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j]<A[minj]){
	minj=j;

      }
    }
      S=A[i];
      A[i]=A[minj];
      A[minj]=S;
        if(A[minj]>A[i]){
	c++;
	}
      
    
  
  }
 
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[i]);
  printf("%d\n",c);	 
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end());
#define vecmin(A) *min_element(A.begin(),A.end());
#define vecmax(A) *max_element(A.begin(),A.end());
typedef long long ll;

int calc(string s){
  int ans = 0;
  ans += s[0] - '0';
  int tmp = s[2] - '0';
  if(s[1] == '+') ans += tmp;
  else ans -= tmp;
  tmp = s[4] - '0';
  if(s[3] == '+') ans += tmp;
  else ans -= tmp;
  tmp = s[6] - '0';
  if(s[5] == '+') ans += tmp;
  else ans -= tmp;
  return ans;
}

int main(){
  string s = "";
  rep(i,4){
    char tmp;
    cin >> tmp;
    s.push_back(tmp);
  }
  vector<string> t(8,"");
  rep(i,8){
    rep(j,4){
      t[i].push_back(s[j]);
      bool bit = (i>>j)&1;
      if(j<3){
        if(bit) t[i].push_back('+');
        else t[i].push_back('-');
      }
    }
  }
  for(auto p : t){
    if(calc(p) == 7){
      cout << p << "=7" << endl;
      return 0;
    }
  }
}

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

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

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

  int n;
  cin >> n;

  vector<int> a(n + 1);
  vector<int> b(n);
  rep(i, n + 1) { cin >> a.at(i); }
  rep(i, n) { cin >> b.at(i); }

  long long ans = 0;
  rep(i, n) {
    int tmp = min(a.at(i), b.at(i));
    ans += tmp;
    a.at(i) -= tmp;
    b.at(i) -= tmp;

    tmp = min(a.at(i + 1), b.at(i));
    ans += tmp;
    a.at(i + 1) -= tmp;
    b.at(i) -= tmp;
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
n, m = map(int, input().split())
*h, = map(int, input().split())
cnd = [0]*n
for i in range(n): cnd[i] = list()
for _ in [0]*m:
    a, b = map(int, input().split())
    cnd[a-1] += [b-1]
    cnd[b-1] += [a-1]
ans = 0
for i in range(n):
    if len(cnd[i])==0 or all(h[i] > h[j] for j in cnd[i]):
        ans += 1
print(ans)

Measured memory_bytes: 30100
L,R=map(int,input().split())
X=2019
for i in range (R-L):
    for j in range(R-L-i):
        if (L+i)*(L+i+j+1)%2019==0:
            X=0
            break
        elif X >(L+i)*(L+i+j+1)%2019:
            X=(L+i)*(L+i+j+1)%2019
    if X==0:
        break        
print(X)


Measured memory_bytes: 2940