akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include "ext/pb_ds/tree_policy.hpp"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/rope"

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define f first
#define s second

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

struct custom_hash 
{
    static uint64_t splitmix64(uint64_t x) 
    {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const 
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
vector<ll> d;

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, t = 0;
    cin >> n;
    d.assign(n, 0);
    F0R(i, n) 
    {
        cin >> d[i];
        t += d[i] * pow(-1, i);
    }
    cout << t << " ";
    ll pm = t;
    FOR(i, 0, sz(d) - 1)
    {
        cout << (d[i] - pm/2) * 2 << " ";
        pm = (d[i] - pm/2) * 2;
    }
    return 0;
}

Measured memory_bytes: 2176
import heapq

x, y, a, b, c = map(int, input().split())

def max_listup(limit):
  l = list(map(lambda x:int(x)*-1, input().split()))
  heapq.heapify(l)
  cnt = 1
  res = []
  while l:
    if cnt > limit:
      break
    m = heapq.heappop(l)
    res.append(m*-1)
    cnt += 1
  return res

if __name__ == "__main__":
  all = sorted(max_listup(x) + max_listup(y) + list(map(int, input().split())))
  ans = 0
  for _ in range(x+y):
    ans += all.pop()

  print(ans)


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

int main() {
	int r; //2<=r<=5
	int d; //1<=d<=100
	int x2000; //西暦2000年になる瞬間に生えている重さの合計 d<=x2000<=200
	int next_x;

	cin >> r >> d >> x2000;

	next_x = x2000;
	for (int i = 0; i < 10; i++) {
		next_x = r * next_x - d;
		cout << next_x << endl;
	}
}

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

int  main(){
  int n,m,ans=0;cin>>n>>m;
  if(m<=n)ans=0;
  
  else{
  vector<int> v(m);
  rep(i,m){cin>>v.at(i);}
  sort(v.begin(),v.end());
  vector<int> vec(m-1);
  rep(i,m-1){
    vec.at(i)=v.at(i+1)-v.at(i);
    ans+=vec.at(i);
    //cout<<vec.at(i)<<" ";
  }
  sort(vec.begin(),vec.end());
  rep(i,n-1){
    ans-=vec.at(m-i-2);
  }
  }
  
  cout<<ans;
  
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long int
#define si(x)	scanf("%d",&x)
#define sl(x)	scanf("%lld",&x)
#define ss(s)	scanf("%s",s)
#define pi(x)	printf("%d\n",x)
#define pl(x)	printf("%lld\n",x)
#define ps(s)	printf("%s\n",s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
int mpow(int base, int exp); 
void ipgraph(int n, int m);
void dfs(int u, int par);
 
const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================
 
vi g[N];
int a[N];
 
void solve() {
  string s;cin>>s;
  int res=0,tp=0;
  for(auto i:s)
  {	if(i=='R')
  	tp++;
   else
     tp=0;
   res=max(res,tp);
  }
  cout<<res<<"\n";
  
}
 
int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
 
    int t = 1;
    //cin >> t;
    while(t--) {
      solve();
    }
 
    return 0;
}
 
int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}
 
void ipgraph(int n, int m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
    //u--, v--;
		g[u].pb(v);
		g[v].pb(u);
	}
}
 
void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10656
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s,week[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
    std::cin>>s;
    for(int i=0;i<7;i++){
        if(s==week[i]){
            std::cout<<7-i;
            break;
        }
    }
    std::cout<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x%MOD,n/2);
  return x*POW(x,n-1)%MOD;
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}


int main()
{
  ll a[300],n,d[300];
  cin >> n;
  rep(i,n)cin >> a[i];
  rep(i,n)d[i]=ORD(a[i],2);
  sort(d,d+n);
  printf("%lld",d[0]);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>

using namespace std;

int main(void)
{
	long long int a, b, x;
	cin >> a >> b >> x;
	long long int ans = 0;
	ans = b / x - (a - 1) / x;
	if (a == 0 && x != 1)
	{
		ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, k, c;
    string s;
    cin >> n >> k >> c >> s;

    vector<int> L(k, -1), R(k, -1);
    int cur = 0, pos = -INF;
    for(int i = 0; i < n; ++i){
        if(s[i] == 'x') continue;
        if(i - pos <= c)    continue;
        L[cur++] = i;
        pos = i;
        if(cur >= k)    break;
    }

    cur = k - 1, pos = INF;
    for(int i = n - 1; i >= 0; --i){
        if(s[i] == 'x') continue;
        if(pos - i <= c)    continue;
        R[cur--] = i;
        pos = i;
        if(cur < 0) break;
    }
    
    vector<int> ans;
    for(int i = 0; i < k; ++i){
        if(L[i] == -1 || R[i] == -1){
            cout << -1 << endl;
            return 0;
        }
        if(L[i] == R[i]){
            ans.push_back(L[i] + 1);
        }
    }

    for(int x : ans)    cout << x << '\n';
}

Measured memory_bytes: 5976
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
struct KACHI{
int v,w;
};
int p[101][10001]={0};
int main(){
int i,j,l,n,w;
struct KACHI s;
scanf("%d%d",&n,&w);
for(i=1;i<=n;i++){
	scanf("%d%d",&s.v,&s.w);
	for(j=1;j<=w;j++){
		if(j==s.w){
			p[i][j]=s.v;
			for(l=0;l<=w-j;l++){
				if(w>=j+l)
					p[i][j+l]=max(p[i][j+l],p[i][j]+p[i-1][l]);
			}
		}
		p[i][j]=max(p[i][j],max(p[i][j-1],p[i-1][j]));
	}
}
printf("%d\n",p[n][w]);
return 0;
}


Measured memory_bytes: 7104
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    static final char Q = '?';
    static final char A = 'a';

    public static void main(String[] args) throws IOException {
        final String S;
        final String T;

        StringBuilder sb = new StringBuilder();

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            S = reader.readLine();
            T = reader.readLine();
            sb.append(S);
        }

        PrintWriter out = new PrintWriter(System.out);

        int sl = sb.length();
        int tl = T.length();

        boolean flg = false;
        for (int i = sl - tl; 0 <= i; i--) {
            flg = true;

            for (int j = 0; j < tl; j++) {
                char sat = sb.charAt(i + j);
                char tat = T.charAt(j);
                if ((Q != sat) && sat != tat) {
                    flg = false;
                    break;
                }
            }

            if (flg) {
                sb.replace(i, i + tl, T);
                break;
            }
        }

        for (int i = 0; i < sl; i++)
            if (Q == sb.charAt(i)) sb.setCharAt(i, A);

        out.println(flg ? sb : "UNRESTORABLE");

        out.flush();
    }
}


Measured memory_bytes: 22356
#include <stdio.h>
int main(){
	int i,j,A[100],key,N,t;
	scanf("%d",&N);
	for(i=0;i<N;i++)
		scanf("%d",&A[i]);
	for(i=0;i<N;i++){
		key=A[i];
		j=i-1;
		while(j>=0&&A[j]>key){
			A[j+1]=A[j];
			j--;
			A[j+1]=key;
		}
		for(t=0;t<N;t++){
			printf("%d",A[t]);
			if(t<N-1)
				printf(" ");
		}
		printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2048
N,X,*a = `dd`.split.map(&:to_i)
ans = 0
(1...N).each{ |i|
  next if a[i]+a[i-1] <= X
  d = [X - a[i-1], 0].max
  ans += a[i] - d
  a[i] = d
  d = [X - d, 0].max
  ans += a[i-1] - d
  a[i-1] = d
}
p ans

Measured memory_bytes: 12040
import java.util.Scanner;

public class Main {

	/**
	 * Digit Number
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		while (scanner.hasNext()) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();

			System.out.println(String.valueOf(a + b).length());
		}
	}
}

Measured memory_bytes: 20632
from collections import deque

n, m = map(int, input().split())
a = [[] for _ in range(n)]
for i in range(m):
    x, y = map(int, input().split())
    a[x - 1].append(y - 1)
    a[y - 1].append(x - 1)
c = [0] * n
que = deque([])
que.append(0)
while len(que) > 0:
    e = que.popleft()
    for i in a[e]:
        if c[i] > 0:
            continue
        c[i] = e + 1
        que.append(i)
print("Yes")
for i in range(1, n):
    print(c[i])

Measured memory_bytes: 36920
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long


int p[100010];
int main()
{
	int N, Q, A[100010];
	ll K;
	cin >> N >> K >> Q;
	for (int i = 0; i < Q; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		p[i] = K - Q;
	}
	for (int i = 0; i < Q; i++) {
		p[A[i] - 1]++;
	}
	for (int i = 0; i < N; i++) {
		if (p[i] > 0) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}


Measured memory_bytes: 1408
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <utility>
#include <map>
#include <stack>
#include <set>
#include <vector>
#include <queue>
#include <deque>
#include <sstream>
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define LL long long
#define Pair pair<int,int>
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const int INF=0x7ffffff;
const int magic=348;

int n;

int main ()
{
	cin>>n;
	if ((n%10)==n/100)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

const int N = 100005, M = 200005, INF = 1000000000;

int n, m, D[N], col[N], flag[N], p[N];
std::vector<std::pair<int, int>> E[N];
int ans[M];

void paint(int u) {
	if (~col[u]) {
		return;
	}
	for (auto p : E[u]) {
		int v = p.first, id = p.second;
		if (col[v] == -1 && D[u] == D[v]) {
			col[u] = 0, col[v] = 1;
			ans[id] = D[u];
			return;
		}
		if (~col[v]) {
			col[u] = col[v] ^ 1;
			ans[id] = D[u];
		}
	}
}

int main() {
	read(n), read(m);
	for (int i = 1; i <= n; ++i) {
		read(D[i]);
		col[i] = -1;
		flag[i] = 0;
		p[i] = i;
	}
	for (int i = 1; i <= m; ++i) {
		int u, v;
		read(u), read(v), ans[i] = INF;
		E[u].push_back({v, i}), E[v].push_back({u, i});
		if (D[v] <= D[u]) {
			flag[u] = 1;
		}
		if (D[u] <= D[v]) {
			flag[v] = 1;
		}
	}
	if (*std::min_element(flag + 1, flag + 1 + n) == 0) {
		print(-1);
		return 0;
	}
	std::sort(p + 1, p + 1 + n, [&](int x, int y) {
		return D[x] < D[y];
	});
	for (int i = 1; i <= n; ++i) {
		paint(p[i]);
	}
	for (int i = 1; i <= n; ++i) {
		if (col[i] == 0) {
			putchar('W');
		} else {
			putchar('B');
		}
	}
	putchar('\n');
	for (int i = 1; i <= m; ++i) {
		print(ans[i]);
	}
}


Measured memory_bytes: 19200
#include <bits/stdc++.h>
using namespace std;
const int MAXN=2020;
const long long MOD=1e9+7;

long long n;
long long k;
long long a[MAXN];
long long ans=0;

int main()
{
    cin>>n>>k;
    long long prek=k*(k-1)/2;
    prek%=MOD;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(int i=1;i<=n;i++)
    {
        long long N=0,M=0;
        for(int j=i+1;j<=n;j++)
        {
            if(a[j]<a[i])
                M++;
        }
        for(int j=1;j<i;j++)
        {
            if(a[j]<a[i])
                N++;
        }
        N+=M;
        long long ret=((M*k)%MOD+(N*prek)%MOD)%MOD;
        ret%=MOD;
        ret+=MOD;
        ret%=MOD;
        ans+=ret;
        ans%=MOD;
        ans+=MOD;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>

using namespace std;

#define f first
#define s second
#define pb push_back
#define pp pop_back
#define mp make_pair
#define ll long long

const int N = 3e5 + 123;
const int inf = 1e9;
const int mod = 1e9 + 7;

string s;

int main() {
	#ifdef wws
		freopen("in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(0);
	cin >> s;
	string now = "";
	for (auto i : s) {
		if (i == ',') {
			cout << now << " ";
			now = "";
		}
		else now += i;
	}
	cout << now << endl;
	return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 998244353
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;

void solve()
{
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll f1=a*c,f2=a*d,f3=b*c,f4=b*d;
	cout<<max(f1,max(f2,max(f3,f4)))<<endl;
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

int main(){
    int c[2] = {500, 1};
    int a, n;

    cin >> n >> a;
    
    while(n >= c[0]) n -= c[0];
    if(n > a) cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cstring>
#include <deque>
#include <map>

#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

#define INF 1<<30

int main(){
  int h,w,m,i,wi,hi;
  cin>>h>>w>>m;
  vector<map<int,int> > target(h);
  vector<int> row(h);
  vector<int> col(w);
  rep0(i,m){
    int hi,wi;
    cin>>hi>>wi;
    hi--;wi--;
    target[hi][wi] = 1;
    row[hi]++;
    col[wi]++;
  }
 
  int c_max = 0;
  rep0(wi,w)c_max=max(c_max,col[wi]);
  vector<int> w_candidate;
  rep0(wi,w)
    if(col[wi]==c_max)
      w_candidate.push_back(wi);
  
  int ans = 0;
  rep0(hi,h)for(int wi:w_candidate){
    if(target[hi].count(wi))
      ans = max(ans,row[hi]+col[wi]-1);
    else{
      ans = max(ans,row[hi]+col[wi]);
      break;
    }
  }
 
  cout<<(ans)<<endl;
  return 0;
}

Measured memory_bytes: 35720
#include <stdio.h>

void merge_sort(long long x[], int n)
{
	static long long y[100001] = {};
	if (n == 1) return;
	merge_sort(&(x[0]), n/2);
	merge_sort(&(x[n/2]), (n+1)/2);
	
	int i, p, q;
	for (i = 0, p = 0, q = n/2; i < n; i++) {
		if (p >= n/2) y[i] = x[q++];
		else if (q >= n) y[i] = x[p++];
		else y[i] = (x[p] < x[q])? x[p++]: x[q++];
	}
	for (i = 0; i < n; i++) x[i] = y[i];
}

int main()
{
	int i, N;
	long long A[100001];
	scanf("%d", &N);
	for (i = 0; i < N; i++) scanf("%lld", &(A[i]));
	
	int j;
	long long max[2] = {};
	merge_sort(A, N);
	for (i = N - 1, j = 0; i > 0 && j < 2; i--) {
		if (A[i] == A[i-1])	max[j++] = A[i--];
	}
	
	printf("%lld\n", max[0] * max[1]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 1664
#include <stdio.h>
int main(void)
{
  int N = 0;
  scanf("%d", &N);

  int d[51];
  for(int i = 0; i < N; i ++){
    scanf("%d", &d[i]);
  }
  int s = 0;
  for(int j = 0; j < N; j ++){ 
    for(int k = 0; k < N; k ++){
      if(j != k){ 
        s = s + d[j] * d[k];
      }
    }
  }
  printf("%d",s/2);
  return 0;
}


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

int main() {
   int n; cin >> n;
   vector<string> red(n);
   for(int i = 0; i < n; i++){ cin >> red.at(i); }
   
   int m; cin >> m;
   vector<string> blue(m) ;
   for(int i = 0; i < m; i++){ cin >> blue.at(i); }

   int maxcount = 0;
   for(int i = 0; i < n; i++){
      int count_R = count(red.begin(), red.end(), red.at(i));
      int count_B = count(blue.begin(), blue.end(), red.at(i));
      //cout << red.at(i) << " " << count_R << " " << count_B << endl;
      int R_B = count_R - count_B;
      maxcount = max(maxcount, R_B);
   }
   cout << maxcount << endl;
}


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

int main()
{
	std::string str;
	int shift;
	std::cin >> shift >> str;
	
	for (auto& c : str)
	{
		c = 'A' + (c - 'A' + shift) % 26;
	}
	std::cout << str << std::endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main (args: Array<String>) {
  val scanner = Scanner(System.`in`)
  val n = scanner.nextInt()
  scanner.nextInt()

  val strings = mutableListOf<String>()
  repeat(n) {
    strings.add(scanner.next())
  }
  strings.sort()
  println(strings.joinToString(""))
}

Measured memory_bytes: 31524
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
typedef double db;
int n,A[1005],pre[1005],ans[1005],tot;
ll f[1005];
bool flag,Ans[1005];
void work(int pos)
{
	for(int i=pos;i<n;++i) Ans[i]=Ans[i+1];
	n--;
}
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	{
		scanf("%d",&A[i]);
		if(A[i]>0) flag=1;
	}
	if(!flag)
	{
		int Max=0;
		for(int i=1;i<=n;++i) if(!Max||A[i]>A[Max]) Max=i;
		printf("%d\n%d\n",A[Max],n-1);
		for(int i=n;i>Max;--i) printf("%d\n",i);
		for(int i=1;i<Max;++i) printf("1\n");
		return 0;
	}
	for(int i=1;i<=n;++i)
	{
		f[i]=A[i];
		int Max=0;
		for(int j=i-2;j>=1;j-=2) if(!Max||f[j]>f[Max]) Max=j;
		if(f[Max]>=0) f[i]+=f[Max],pre[i]=Max;
	}
	int Max=0;
	for(int i=1;i<=n;++i) if(f[i]>f[Max]) Max=i;
	int J=Max;
	while(J) Ans[J]=1,J=pre[J];
	while(n>1)
	{
		if(!Ans[n]) {ans[++tot]=n;work(n);continue;}
		if(!Ans[1]) {work(1);ans[++tot]=1;continue;}
		for(int i=2;i<n;++i)
		{
			if(Ans[i]) continue;
			flag=0;
			if(Ans[i-1]==Ans[i+1])
			{
				if(Ans[i-1]==1) flag=1;
				ans[++tot]=i;
				work(i-1);
				work(i);
				if(flag) Ans[i-1]=1;
				break;
			}
		}
		
	}
	printf("%lld\n%d\n",f[Max],tot);
	for(int i=1;i<=tot;++i) printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(long long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#define debug(x...) cout << #x << " = "; _print(x)
typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
#define rep(i,a,b) for (ll i = (a); i < (b); ++i)
#define per(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define mp make_pair 
#define pb push_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL) 
const int mod = 1e9 + 7, mxn = 1e5 + 1;

int solve(){
	int n, k;
	cin>> n>> k;
	vi v(n);
	rep(i, 0, n)
		cin>> v[i];
	sort(all(v));
	int ans = 0;
	rep(i, 0, k)
		ans += v[i];
	cout<< ans<< "\n";
	return 0;
}
 
int main()
{
    fast;
    int t = 1;
    //cin>> t;
    while(t--){  
        solve();
    }
    return 0;
}
//v.clear(), vis.clear(); vis.resize(n + 1, 0), v.resize(n + 1);
 
/*  inv[1] = 1; // inv is ll
    for(int i=2; i<=mxn; ++i)
        inv[i]=mod-mod/i*inv[mod%i]%mod;*/
        
// lower bound   >=  
// upper bound   >
// vector<int>().swap(vec); //free memory from vec


Measured memory_bytes: 3616
n = int(input())
a = [int(x) for x in input().split()]

even = []
odd = []

for i in range(n):
    if i % 2 == 0:
        odd.append(a[i])
    else:
        even.append(a[i])

if n % 2 == 0:
    even.reverse()
    ans = even + odd
    print(*ans)
else:
    odd.reverse()
    ans = odd + even
    print(*ans)


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

using ll = long long int;

int x_1, y_1, x_2, y_2;
int x_3, y_3, x_4, y_4;

int main(void) {
  // Here y_our code !
  scanf("%d %d %d %d", &x_1, &y_1, &x_2, &y_2);

  int x = x_2 - x_1;
  int y = y_2 - y_1;

  x_3 = x_2 - y;
  y_3 = y_2 + x;
  x_4 = x_1 - y;
  y_4 = y_1 + x;

  printf("%d %d %d %d\n", x_3, y_3, x_4, y_4);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
using ll = long long;
int main(int argc, char const *argv[]) {
  ll x;
  cin >> x;
  for(ll a = -118; a <= 119; a++){
    for(ll b = -119; b <= 118; b++){
      ll c = pow(a, 5);
      ll d = pow(b, 5);
      if((c - d) == x){
          cout << a << " " << b << endl;
          return 0;
      }
    }
  }
}


Measured memory_bytes: 4008
#include<iostream>
#include<vector>
using namespace std;
struct amida{
	int h,A,B;
};
int main(){
	int n,m,a;
	while(cin>>n>>m>>a,n+m+a!=0){
		vector<amida>kuzi;
		int now=a;
		for(int i=0;i<m;i++){
			int x,y,z;
			cin>>x>>y>>z;
			amida tmp;
			tmp.h=x,tmp.A=y,tmp.B=z;
			kuzi.push_back(tmp);
		}
		/*for(int i=0;i<kuzi.size();i++){
			for(int j=i;j<kuzi.size();j++){
				if(kuzi[i].h<kuzi[j].h)swap(kuzi[i],kuzi[j]);
			}	
		}*///別にソートせんでもええがな
		for(int i=1001;i>=1;i--){
			for(int j=0;j<kuzi.size();j++){
				if(kuzi[j].A==now&&kuzi[j].h==i){
					now=kuzi[j].B;
					break;
				}
				if(kuzi[j].B==now&&kuzi[j].h==i){
					now=kuzi[j].A;
					break;
				}
			}
		}
		cout<<now<<endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> b(n),ans;
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
        --b[i];
    }
    for (int i = 0; i < n; ++i) {
        int j;
        for (j = b.size() - 1; j >= 0; --j) {
            if (b[j] == j)
                break;
        }
        if (j < 0) {
            cout << "-1\n";
            return 0;
        }
        ans.push_back(j+1);
        b.erase(begin(b) + j);
    }
    for (int i = n-1; i >= 0; --i)
        cout << ans[i] << '\n';
}


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

int main(){
  int n;
  cin >> n;
  if (n == 1) {
    cout << "Hello World" << endl;
  }
  else if (n == 2)
  {
    int a, b;
    cin >> a >> b;
    cout << a+b << endl;
  }
  return 0;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define I int
#define S(a) scanf("%d",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define P(a) printf("%d\n",a)
#define PL(a) printf("%lld\n",a)
#define PT(t) printf("Case %d: ",t)
#define PB(a) push_back(a)
#define SET(a) memset(a,0,sizeof a)
#define SETR(a) memset(a,-1,sizeof a)
#define ll long long 
using namespace std;
#define mx 500004
#define md 1000000007ll
typedef pair<int, int >P;
typedef vector<ll>V;

////////define value/////
template <class T> inline T BM(T p, T e, T M)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    }
    return (T)ret;
}
template <class T> inline T gcd(T a, T b)
{
    if(b == 0)return a;
    return gcd(b, a % b);
}
template <class T> inline T mdINV(T a, T M)
{
    return BM(a, M - 2, M);
}
template <class T> inline T PW(T p, T e)
{
    ll ret = 1;
    for(; e > 0; e >>= 1)
    {
        if(e & 1) ret = (ret * p);
        p = (p * p);
    }
    return (T)ret;
}
 
 
template <class T>bool ISLEFT(T a, T b, T c)
{
    if(((a.xx - b.xx) * (b.yy - c.yy) - (b.xx - c.xx) * (a.yy - b.yy)) < 0.0)return 1;  //Uporer dike //A,b,c, x okkher ordera sorted
    else return 0;
}

int main(){
   int n;
   cin>>n;
   int f = n/100;
   int s = n%100;

   if( f >= 1 && f <= 12 && s >= 1 && s<=12)cout<<"AMBIGUOUS"<<endl;
   else if(f>=1&&f<=12)cout<<"MMYY"<<endl;
   else if(s>=1&&s<=12)cout<<"YYMM"<<endl;
   else cout<<"NA"<<endl;

    return 0;
}

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

vector<vector<int>> a;
int n, k;
vector<vector<int>> dist;

void bfs(int i) {
	queue<pair<int, int>> q;
	q.emplace(i, 0);
	vector<int> vis(n);
	while (q.size()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		if (vis[x]) continue;
		dist[i][x] = y;
		dist[x][i] = y;
		vis[x] = 1;
		for (int node : a[x]) {
			q.emplace(node, y + 1);
		}
	}
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> k;
	a = vector<vector<int>>(n);
	dist = vector<vector<int>>(n, vector<int>(n));
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y, x--, y--;
		a[x].push_back(y);
		a[y].push_back(x);
	}
	int ans = 1e9, ind;
	for (int i = 0; i < n; i++) {
		bfs(i);
	}
	if (k % 2 == 0) {
		for (int i = 0; i < n; i++) {
			int res = 0;
			for (int j = 0; j < n; j++) {
				res += (dist[i][j] > k / 2);
			}
			ans = min(ans, res);
		}
		cout << ans << '\n';
		return 0;
	}
	for (int i = 0; i < n; i++) {
		for (int node : a[i]) {
			int cnt = 0;
			for (int j = 0; j < n; j++) {
				cnt += (min(dist[i][j], dist[node][j]) > k / 2);
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans << '\n';
	return 0;
}





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

int main() {
  int N, L;
  cin >> N >> L;
  string S[N];
  string X = "";
  
  for(int i=0; i<N; i++){
    cin >> S[i];
  }
  
  sort(S, S+N);
  
  for(int i=0; i<N; i++){
    X += S[i];
  }
  
  cout << X << endl;
  
    
  return 0;
}

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

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<(n);i++)
#define all(x) (x).begin(),(x).end()
constexpr auto INF = 5000000000000000;
constexpr auto MOD = 1000000007;



int main() {

	int a,b;
	cin >> a>>b;
	if (a >= 10 || b >= 10) {
		cout << "-1" << endl;
	}
	else { cout << a * b << endl; }
}

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

using namespace std;

const int INF = 1e9;

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        int  h[1510] = {}, w[1510] = {};
        vector<int> dh, dw;
        for (int i = 1; i <= n; i++) {
            cin >> h[i];
            h[i] += h[i - 1];
        }
        for (int i = 1; i <= m; i++) {
            cin >> w[i];
            w[i] += w[i - 1];
        }

        for (int i = 0; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                dh.push_back(abs(h[j] - h[i]));
            }
        }
        for (int i = 0; i <= m; i++) {
            for (int j = i + 1; j <= m; j++) {
                dw.push_back(abs(w[j] - w[i]));
            }
        }
        dh.push_back(INF);
        dh.push_back(0);
        dw.push_back(INF);
        dw.push_back(0);
        sort(dh.begin(), dh.end());
        sort(dw.begin(), dw.end());
        int ans = 0;

        for (int i = 0; i < dh.size(); i++) {
            if (dh[i] == 0 || dh[i] == INF) continue;
            ans += upper_bound(dw.begin(), dw.end(), dh[i]) - lower_bound(dw.begin(), dw.end(), dh[i]); 
        }
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 19704
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int count=0;
		for(int i=0;i!=a+1;i++) {
			int C=0;
			for(int j=i;j!=0;j/=10) {
				C+=j%10;
			}
			if(C>=b&&C<=c) {
				count+=i;
			}
		}
		System.out.println(count);
	}
	}


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

int main(){
    int K,A,B;
    cin >> K >>A >> B;
	
  	for(int i=A;i<=B;i++){
    	if(i%K==0){		
			cout << "OK";
          	return 0;
    	   }
    }
  	cout << "NG";
    
}

Measured memory_bytes: 3624
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>

#define pb push_back
#define mp make_pair

using namespace std;

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }
template<typename T>inline bool upmax(T &x,T y) { return x<y?x=y,1:0; }

typedef unsigned int u32;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double lod;
typedef pair<int,int> PR;
typedef vector<int> VI;

const lod pi=acos(-1);
const int oo=1<<30;
const LL OO=1e18;

const int N=1e6;

int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

#define lc (i<<1)
#define rc (lc|1)
int tag[N];PR mi[N];
int a[N],b[N];
inline void build(int i,int l,int r) {
	mi[i]=mp(b[l],l);
	if (l!=r) {
		int mid=(l+r)>>1;
		build(lc,l,mid);
		build(rc,mid+1,r);
	}
}
inline void pushdown(int i) {
	if (tag[i]) {
		mi[lc].first+=tag[i],mi[rc].first+=tag[i];
		tag[lc]+=tag[i],tag[rc]+=tag[i];
		tag[i]=0;
	}
}
inline void modify(int i,int l,int r,int L,int R) {
	if (L<=l&&r<=R) tag[i]++,mi[i].first++;
	else {
		int mid=(l+r)>>1;
		pushdown(i);
		if (L<=mid) modify(lc,l,mid,L,R);
		if (mid<R) modify(rc,mid+1,r,L,R);
		mi[i]=min(mi[lc],mi[rc]);
	}
}
inline PR query(int i,int l,int r,int L,int R) {
	if (L<=l&&r<=R) return mi[i];
	int mid=(l+r)>>1;PR ans=mp(oo,0);
	pushdown(i);
	if (L<=mid) upmin(ans,query(lc,l,mid,L,R));
	if (mid<R) upmin(ans,query(rc,mid+1,r,L,R));
	return ans;
}
int main()
{
	int n=gi(),i,len,k;PR p;LL ans=0;
	for (i=1;i<=n;i++) a[i]=b[i]=gi();
	sort(b+1,b+1+n);
	len=unique(b+1,b+1+n)-b-1;
	build(1,1,len);
	for (i=1;i<=n;i++) {
		k=lower_bound(b+1,b+len+1,a[i])-b;
		p=query(1,1,len,k,len);
		ans+=p.first-a[i];
		if (p.second!=1)
			modify(1,1,len,1,p.second-1);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 15360
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <string>

using namespace std;

int main(void) {
  string s;
  cin >> s;
  int f = 0;
  for (int i = 0; i < s.size(); i++) {
    if ((i + 1) % 2 == 1) {
      if (s[i] == 'L') {
         f = 1;
      }
    } else {
      if (s[i] == 'R') {
        f = 1;
      }
    }
  }
  if (f == 1) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define EARTH_HANKEI 6378.1
 
int main(void) {
    double a,b,c,d;
    double ax1,ay1,ax2,ay2;
    double x1,y1,z1,x2,y2,z2;
    double cosine;
    double result;
    while(1) {
        scanf("%lf%lf%lf%lf",&a,&b,&c,&d);
        if(a==-1 && b==-1 && c==-1 && d==-1)
			break;
        ax1=b*M_PI/180;
		ay1=a*M_PI/180;
        ax2=d*M_PI/180;
		ay2=c*M_PI/180;
        y1=cos(ay1);
		z1=sin(ay1);
        x1=y1*sin(ax1);
		y1=y1*cos(ax1);
        y2=cos(ay2);
		z2=sin(ay2);
        x2=y2*sin(ax2);
		y2=y2*cos(ax2);
        cosine=x1*x2+y1*y2+z1*z2;
        result=EARTH_HANKEI*acos(cosine);
        printf("%d\n",(int)floor(result+0.5));
    }
    return 0;
}

Measured memory_bytes: 1108
N = int(input())
L = sorted(list(map(int, input().split())))
count = 0

for i in range(N - 2):
    for j in range(i, N - 1):
        for k in range(j, N):
            if L[i] != L[j] and L[j] != L[k] and L[i] != L[k] and L[i] + L[j] > L[k]:
                count += 1

print(count)

Measured memory_bytes: 9188
let () =
  let n = read_int () in
  let a = Array.make_matrix n n 0 in
  let rec read i =
    if i < n then begin
      let (id, k) = Scanf.scanf "%d %d " (fun id k -> id, k) in
      let rec g j =
        if j < k then (a.(id-1).(Scanf.scanf "%d " (fun i -> i) - 1) <- 1; g (j + 1))
      in
      g 0;
      read (i + 1)
    end
  in
  read 0;
  let rec print_line i j =
    if j < n then begin
      Printf.printf (if j = 0 then "%d" else " %d") a.(i).(j);
      print_line i (j + 1)
    end
  and print i =
    if i < n then begin
      print_line i 0;
      print_newline ();
      print (i + 1)
    end
  in
  print 0

Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll inf = 1e18;


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

    ll n;
    cin >> n;
    vll x(n);
    REP(i, n) cin >> x[i];
    ll l;
    cin >> l;

    // reach[k][i] : i から出発して 2^k 日で到達できる一番遠いホテル
    vvll reach(31, vll(n));

    REP(i, n){
        ll nxt = upper_bound(ALL(x), x[i] + l) - x.begin() - 1;
        reach[0][i] = nxt;
    }
    REP(k, 30){
        REP(i, n){
            reach[k + 1][i] = reach[k][reach[k][i]];
        }
    }
    ll q;
    cin >> q;
    ll a, b;
    while (q) {
        cin >> a >> b;
        a--, b--;
        if (a > b) swap(a, b);
        ll res = 1;
        REPR(k, 30) {
            if(reach[k][a] < b) {
                a = reach[k][a];
                res += (1 << k);
            }
        }
        cout << res << endl;
        q--;
    }
    return 0;
}

Measured memory_bytes: 26112
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,n) for(int i=1;i<=n;i++)
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)
#define ll int64_t
#define all(v) v.begin(), v.end()

const int MOD = 1000000007;

int main() {

ll N,K; cin>>N>>K;

vector<int> A(N); 

rep(i,N){
  cin>>A[i]; A[i]--;
}//input

int place=0;

vector<int> B(2000000,-1);

B[0]=0;

for(int i=1;;i++){

  K--;

  if(B[A[place]]!=-1){
    K%=(i-B[A[place]]);
  }

  else{
    B[A[place]]=i;
  }

  place=A[place];

  if(K==0) break;
}

cout << place+1 << endl;

return 0;
}

Measured memory_bytes: 11912
#include<stdio.h>

typedef struct point{
 float x;
 float y;
}point;

int main(){
 int n,i;
 point A,B,C,D;
 float m1,m2;
 scanf("%d",&n);
 for(i=0;i<n;i++){

  scanf("%f %f",&A.x,&A.y);
  scanf("%f %f",&B.x,&B.y);
  scanf("%f %f",&C.x,&C.y);
  scanf("%f %f",&D.x,&D.y);

  m1=(A.y-B.y)*(C.x-D.x);
  m2=(A.x-B.x)*(C.y-D.y);

  if(m1==m2)printf("YES\n");
  else printf("NO\n");

 }

 return 0;

}


Measured memory_bytes: 1996
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>

using namespace std;

#define sz(x) (int)(x.size())

typedef long long ll;
typedef tuple<int, int, int> tri;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;

const ll MODULO = 1000000007;

static int speed_increase = []() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(NULL);
    return 0;
}();

void solve()
{
    ll d, t, s;
    cin>>d>>t>>s;
    if(s*t >= d) {
        cout<<"Yes\n";
    } else {
        cout<<"No\n";
    }
}

int main()
{
    solve();
    // ftime();
    return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>

class union_find {
  std::vector<intmax_t> tree;

public:
  union_find(size_t n): tree(n, -1) {}

  size_t find(size_t v) {
    if (tree[v] < 0)
      return v;

    return (tree[v] = find(tree[v]));
  }

  bool unite(size_t u, size_t v) {
    u = find(u);
    v = find(v);
    if (u == v)
      return false;

    if (-tree[u] >= -tree[v])
      std::swap(u, v);

    tree[v] += tree[u];
    tree[u] = v;
    return true;
  }

  bool connected(size_t u, size_t v) {
    return (find(u) == find(v));
  }

  size_t size(size_t v) {
    return -tree[find(v)];
  }
};

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<size_t> p(N);
  for (auto& pi: p) {
    scanf("%zu", &pi);
    --pi;
  }

  union_find uf(N);
  for (size_t i = 0; i < M; ++i) {
    size_t x, y;
    scanf("%zu %zu", &x, &y);
    --x;
    --y;
    uf.unite(x, y);
  }

  int res = 0;
  for (size_t i = 0; i < N; ++i) {
    if (uf.connected(i, p[i])) ++res;
  }
  printf("%d\n", res);
}


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

def f(X,P):
    ans=0
    for i in range(len(X)):
        ans+=(X[i]-P)**2
    return ans
ans=10**9
for p in range(1,101):
    ans=min(ans,f(X,p))
print(ans)


Measured memory_bytes: 3060
import java.util.Scanner;

//20180508
//06

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

		while (true) {
			int h = scanner.nextInt();
			int w = scanner.nextInt();

			if(h == 0 && w == 0) {
				break;
			}

			for (int j = 0; j < h;j++) {
				for (int i = 0;i < w;i++) {
					System.out.print("#");
				}
				System.out.println("");
			}
			System.out.println("");
		}

    	scanner.close();
    }
}



Measured memory_bytes: 35560
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n-k;i++){
		if(a[i]>=a[i+k]) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 4432
#include<stdio.h>
#define MAX 200000
int main()
{
    long int r[MAX], minv, maxv;
    int n, i, temp;

    scanf("%d", &n);
    for(i=0;i<n;i++)
        scanf("%ld", &r[i]);

    minv=r[0];
    maxv=r[1]-r[0];

    for(i=1;i<n;i++)
    {
        temp=r[i]-minv;
        if(temp>maxv) maxv=temp;
        if(r[i]<minv) minv=r[i];
    }

    printf("%d\n", maxv);

    return 0;
}

Measured memory_bytes: 2156
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):                                          # 根を見つける関数を定義（同時にxを直接根にくっつける操作も行う）
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])        # 右辺で再帰的に根を探索。根に到達すると一つ目のif判定に引っかかるので、
                                                                # 最終的にself.parents[根]が返ってくる。
                                                                # これを左辺に代入することで、根が親になるように変更する。（根までの距離が長いとO(N)になってしまうので）
            return self.parents[x]

    def union(self, x, y):                                      # 二つの木をくっつける（子を多く持つ方を根とした親子関係）。これは破壊的操作を行う。
        x = self.find(x)                                        # xをxの根に置き換える
        y = self.find(y)                                        # yをyの根に置き換える

        if x == y:                                              # 根が同じなら置き換える必要なし
            return

        if self.parents[x] > self.parents[y]:                   # 子がたくさんある方を x とする（出来るだけ浅い木にするため）
            x, y = y, x

        self.parents[x] += self.parents[y]                      # xの子の数を更新
        self.parents[y] = x                                     # yの親を更新

    def same(self, x, y):                                       # xとyが同じ根の子かを判定
        return self.find(x) == self.find(y)

    def size(self, x):                                          # xの根のparent（= 要素数）を返す
        return -self.parents[self.find(x)]

    def members(self, x):                                       # xが属するグループの要素をリストとして返す
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):                                            # 全ての根の要素をリストとして返す
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):                                      # グループの数を返す
        return len(self.roots())

    def all_group_members(self):                                # {根:[根の子のリスト],...}を辞書で返す
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):                                          # print(self) での返し方を定義
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

##############################################################################################################
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
P = list(map(int, input().split()))
U = UnionFind(N)
for _ in range(M):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    U.union(a, b)
res = 0
for i, p in enumerate(P):
    if U.same(p-1,i):
        res += 1
print(res)

Measured memory_bytes: 84624
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
ll mod=1000000007;

ll primeFactors(ll n)
{
    // Print the number of 2s that divide n
    ll ans=1;
    while (n % 2 == 0)
    {
        ans=2;
        n = n/2;
    }

    // n must be odd at this point. So we can skip
    // one element (Note i = i +2)
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        int fl=0;
        // While i divides n, print i and divide n
        while (n % i == 0)
        {
            //cout << i << " ";
            if(fl==0){ans++;fl=1;}
            n = n/i;
        }
    }

    // This condition is to handle the case when n
    // is a prime number greater than 2
    if (n > 2)
        ans++;
    return ans;
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main() {
    std::ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    ll gc=gcd(a,b);
    cout<<primeFactors(gc);

	return 0;
}


Measured memory_bytes: 256