akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>

using namespace std;

#define rep(i, a, b) for(int i=a;i<b;++i)
////////////////

int const N = 1e5 + 41;
int n;
int l;
int cnt, ans[N];
int le[N], ri[N];
int par[N];
long long len[N];

int find(int u){
	if(par[u] == u) return u;
	return par[u] = find(par[u]);
}

bool uni(int a, int b){
	a = find(a);
	b = find(b);
	if(a == b) return false;
	if(len[a] + len[b] >= l){
		par[b] = a;
		len[a] += len[b];
		le[a] = min(le[a], le[b]);
		ri[a] = max(ri[a], ri[b]);
		return true;
	}else{
		return false;
	}
}

bool canMerge(int l, int r){
	if(l < 0) return false;
	if(r >= n) return false;
	return uni(l, r);
}

bool tryMerge(int id){
	id = find(id);
	int pl = le[id] - 1;
	if(canMerge(pl, id)){
		ans[cnt++] = pl;
		return true;
	}
	int pr = ri[id] + 1;
	if(canMerge(id, pr)){
		ans[cnt++] = pr - 1;
		return true;
	}
	return false;
}

void solve(){
	cin >> n >> l;
	rep(i, 0, n){
		cin >> len[i];
		par[i] = i;
		le[i] = i;
		ri[i] = i;
	}

	rep(i, 0, n){
		while(tryMerge(i)){
			
		}
	}

	if(cnt < n - 1){
		cout << "Impossible" << endl; 
	}else{
		cout << "Possible" << endl;
		for(int i=cnt-1;i>=0;--i) cout << ans[i] + 1 << endl;
	}
}

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

	solve();

	return 0;
}

Measured memory_bytes: 3200
#include<cstdio>
#include<algorithm>
#define abs(a) ((a)>-(a)?(a):-(a))
int n,num[200005];
long long ans=0;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		{scanf("%d",&num[i]);num[i]-=i;}
	std::stable_sort(num+1,num+n+1);
	for(int i=1;i<=n/2;i++) ans+=abs(num[i]-num[n-i+1]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

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

        String s = sc.next();

        if (s.substring(5,7).equals("01") || s.substring(5,7).equals("02") || s.substring(5,7).equals("03") || s.substring(5,7).equals("04")) {
            System.out.println("Heisei");
        } else {
            System.out.println("TBD");
        }
    }
}

Measured memory_bytes: 24148
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include<climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<ll> vi;
typedef vector<long long> vl;
typedef pair<ll, ll> pi;
typedef vector<pair<ll, ll>> vpi;

//const long long INF = 1LL << 55;

#define itn ll
#define endl '\n'
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(ll i = 0;i < n;i++)
#define rep(i,n) for(ll i = 0;i < n;i++)
#define flush fflush(stdout)
#define rrep(i,n) for(ll i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define ioboost cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20)
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, ll mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl


int main(void){
    ioboost;
    double n;cin >> n;
    vector<pair<double,double>> p(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> p[i].ff >> p[i].ss;
    }

    double sum = 0;

    vector<int> arr(n);
    for (int i = 0; i < n; ++i)
    {
        arr[i] = i;
    }

    ll cnt = 0;
    do{
        vector<int> arr_i;
        for(auto i : arr)arr_i.pb(i);
        for (int i = 0; i < n-1; ++i)
        {
            int idx1 = arr_i[i];
            int idx2 = arr_i[i+1];
            //cout << idx1;
            double p1x = p[idx1].ff,p2x = p[idx2].ff;
            double p1y = p[idx1].ss,p2y = p[idx2].ss;
            sum += sqrt((p1x - p2x)*(p1x - p2x) + (p1y - p2y)*(p1y - p2y));

        }
       //cout << endl;
       cnt++;
    }while(next_permutation(arr.begin(),arr.end()));

    cout << sum / (double)cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define take_input freopen("input.txt","r",stdin),freopen("output.txt","w",stdout); 
#define ll long long int
const ll mod=1e9+7;
ll go(ll *a,ll low,ll high,ll dif)
{
	if(low>=high)
		return INT_MAX;
	ll mid=(low+high)>>1;
	if(a[mid+1]-a[mid]!=dif)
		return a[mid]+dif;
	if(mid>0 and a[mid]-a[mid-1]!=dif)
		return a[mid-1]+dif;
	if(a[mid]==a[0]+mid*dif)
		return go(a,mid+1,high,dif);
	return go(a,low,mid-1,dif);
}
int main()
{
	fast;
	// take_input;
	ll n;
	cin>>n;
	if(n%10==3)
		cout<<"bon";
	else if(n%10==0 or n%10==1 or n%10==6 or n%10==8)
		cout<<"pon";
	else
		cout<<"hon";
	cout<<endl;
}

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

typedef long ll;

int main() {
  int N;
  ll K;
  cin >> N >> K;
  vector<ll> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  ll ans = 0;
  for (int d = 40; -1 <= d; d--) {
    if (d != -1 && (1l << d & K) == 0) continue;

    ll tmp = 0;
    for (int e = 40; 0 <= e; --e) {
      ll mask = 1l << e;
      int num = 0;
      for (int i = 0; i < N; ++i) if (A[i] & mask) ++num;

      if (d < e) {
        if (K & mask) tmp += mask * (N - num);
        else tmp += mask * num;
      }
      else if (e == d) tmp += mask * num;
      else tmp += mask * max(num, N - num);
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i,n) for(int i = 0; i <= (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1<<30;
const ll MOD = 1000000007;

int main(void) {

    int x, y;
    cin >> x >> y;
    rep(i, x){
        if (i*2 + (x-i)*4 == y) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;



    return 0;
}

Measured memory_bytes: 3672
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, int> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int h;
	cin >> h;
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);

	int s = 0;

	rep(i, n) {
		s += a.at(i);
		if (s >= h) {
			cout << "Yes" << endl;
			break;
		}
		if (i == n - 1) {
			cout << "No" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>

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

Node root;

Node treeMinimum(Node x){
	Node c = x;
	while (c->left != NIL){
		c = c->left;
	}
	return c;
}

Node treeMaximum(Node x){
	Node c = x;
	while (c->right != NIL){
		c = c->right;
	}
	return c;
}

Node treeSearch(Node u, int k){
	if (u == NIL) return NIL;
	if (u->key == k){
		return u;
	}
	else if (u->key > k){
		Node n = treeSearch(u->left, k);
		if (n != NIL) return n;
	}
	else{
		Node m = treeSearch(u->right, k);
		if (m != NIL) return m;
	}
	return NIL;
}

/*Node treeSuccessor(Node x){


}*/

void treeDelete(Node z){
	if (z->left != NIL) treeDelete(z->left);
	if (z->right != NIL) treeDelete(z->right);
	if (z != root) delete z;
	return;
}

void insert(int k){
	Node y = NIL;
	Node x = root;
	Node z = new 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;
	}

	return;


}

void inorder(Node u){
	if (u->left != NIL) inorder(u->left);
	printf(" %d", u->key);
	if (u->right != NIL) inorder(u->right);
	return;
}
void preorder(Node u){
	printf(" %d", u->key);
	if (u->left != NIL) preorder(u->left);
	if (u->right != NIL) preorder(u->right);
	return;
}


int main(){
	int n, i, x;
	char com[20];
	scanf("%d", &n);

	for (i = 0; i < n; i++){
		scanf("%s", com);
		if (com[0] == 'f'){
			scanf("%d", &x);
			Node t = treeSearch(root, x);
			if (t != NIL) printf("yes\n");
			else printf("no\n");
		}
		else if (com[0] == 'i'){
			scanf("%d", &x);
			insert(x);
		}
		else if (com[0] == 'p'){
			inorder(root);
			printf("\n");
			preorder(root);
			printf("\n");
		}
		else if (com[0] == 'd'){
			scanf("%d", &x);
			treeDelete(treeSearch(root, x));
		}
	}

	return 0;
}


Measured memory_bytes: 21912
#include<cstdio>
#include<functional>
#include<algorithm>
#define M 2000000000

using namespace std;
int main(void)
{
	int n,i,j,s,a[5000],b[5000],m;
	scanf("%d",&n);
	for(i=0;i<n;i++) scanf("%d",&a[i]);
	m=M;
	for(i=0;i<=a[0];i++){
		for(j=0;j<n;j++) b[j]=a[j];
		b[0]-=i; s=i;
		for(j=0;j<n-1;j++){
			if(b[j]>0){
				b[j+1]-=b[j];
				s+=b[j]*2;
				b[j]=0;
			}
		}
		if(b[n-1]>0) s+=b[n-1];
		m=min(m,s);
	}
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 2784
#include <vector>
#include <iostream>

using namespace std;
struct _ { ios_base::Init i; _() { ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL); } } _;

int main() {

	int n, k; cin >> n >> k;
	vector<int> a(n); for (int i = 0; i <= n - 1; i++) cin >> a[i];

	bitset <100001> dp;

	for (int i = 1; i <= k; i++) {
		for (auto j : a) {
			if (i - j >= 0) dp[i] = (dp[i] or !dp[i - j]);
			if (dp[i]) break;
		}
	}
	cout << ((dp[k]) ? "First" : "Second");

	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define mp(a, b) make_pair(a, b)
typedef pair<int, int> pii;
const int maxn = 2e5 + 10;
int n;
int a[maxn], b[maxn];
typedef long long ll;
ll ans;
priority_queue<pii> Q;
inline int pre(int x) { return x == 1 ? n : x - 1;}
inline int nxt(int x) { return x == n ? 1 : x + 1;}
void no() { puts("-1"); exit(0);}
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = 1; i <= n; ++i) 
	{
		scanf("%d", &b[i]); 
		if(b[i] > a[i]) Q.emplace(b[i], i);
		if(b[i] < a[i]) no();
	}
	while(!Q.empty())
	{
		pii x = Q.top(); Q.pop();
		int i = x.second;
		int sum = b[pre(i)] + b[nxt(i)];
		if(b[i] < sum) no();
		if((b[i] - a[i]) % sum == 0)
		{
			ans += (b[i] - a[i]) / sum;
			b[i] = a[i];
			continue;
		}
		int step = b[i] / sum;
		b[i] -= step * sum;
		ans += step;
		if(b[i] < a[i]) no();
		Q.emplace(b[i], i);
	}
	printf("%lld\n", ans);
	return 0;
}
			
	
	

Measured memory_bytes: 3700
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n + 1];
        long[] b = new long[n];
        for (int i = 0; i < n + 1; i++) {
            a[i] = sc.nextLong();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextLong();
        }
        long ans = 0l;
        for (int i = 0; i < n; i++) {
            long l = Math.min(a[i], b[i]);
            a[i] -= l;
            b[i] -= l;
            ans += l;
            long r = Math.min(a[i+1], b[i]);
            a[i+1] -= r;
            b[i] -= r;
            ans += r;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 61612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using vll = vector<ll> ;
#define all(v) v.begin(),v.end()
#define MAXV 1e6+10

int main(){
  ll N;cin>>N;
  vll A(N);rep(i,N)cin>>A[i];
  sort(all(A));
  vll table(MAXV,0);
  ll ans = 0;
  rep(i,N){
    if(table[A[i]]==1) continue;
    for(int j=A[i];j<MAXV;j+=A[i]){
      table[j]=1;
    }
    if(i > 0)if(A[i-1]==A[i]) continue;
    if(i < N-1)if(A[i+1]==A[i]) continue;
    ans += 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 12708
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define rev(i, n) for(int i = n;i >= 0;i--)
#define Rep(i, m, n) for(int i = m;i < n;i++)
#define repeatrev(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 ll long long
#define pb(a) push_back(a)
#define INF 999999999
#define itn int
const int MAX = 510000;


using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
typedef priority_queue<int> Pr;

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int r;
    cin >> r;
    cout << 3 * r * r << endl;

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;


public class Main{
    static long MOD = 1000000007;
    static long dp[] = new long[1 << 21];
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        // Start writing your solution here. -------------------------------------
        long MOD = 1000000007;
        //int t = sc.nextInt();
        int t = 1;
        while(t -- > 0)
        {
            int res = 0;
            long n = sc.nextLong();
            if(n <= 4)
            {
                out.println(n - 1);
                out.close();
                return;
            }
            HashSet<Long> set = new HashSet();
            set.add(n);
            set.add(n - 1);
            for(long i = 2; i * i <= n; i++)
            {
                if(n % i == 0) {
                    long tmp = n;
                    while (tmp % i == 0) tmp /= i;
                    if ((tmp - 1) % i == 0) set.add(i);
                }
                else if((n - 1) % i == 0){
                    set.add(i);
                    set.add((n - 1) / i);
                }
            }
            out.println(set.size());
            //for(int ii = 0; ii <= n; ii++) System.out.println(Arrays.toString(dp[ii]));
        }
        out.close();
    }
    public static int solve(int x, int[] a){
        int max = 0, n = a.length - 1;
        for(int i = 1; i <= n; i++)
            if(a[i] > max) max = a[i];
        return 0;
    }
    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;
    //-----------MyScanner class for faster input----------
    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

        public MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
    //--------------------------------------------------------
}

Measured memory_bytes: 42708
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Team
    {
        internal int id, time;
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Team[] teams = new Team[n];

                for (int i = 0; i < n; i++)
                {
                    int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

                    Team temp;
                    temp.id = input[0];
                    temp.time = 0;

                    for (int j = 1; j < input.Length; j += 2)
                    {
                        temp.time += (input[j] * 60 + input[j + 1]);
                    }
                    teams[i] = temp;
                }
                Array.Sort(teams, (a, b) => a.time - b.time);
                sb.AppendLine(teams[0].id.ToString());
                sb.AppendLine(teams[1].id.ToString());
                sb.AppendLine(teams[n - 2].id.ToString());
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9392
from math import gcd
mod_val = 1000000007
def simplify(A, B):
  a = A//gcd(A,B)
  b = B//gcd(A,B)
  if b<0:
    return (-a, -b)
  return (a, b)
n = int(input())
count_simple_fish = dict()
bad_fish = 0
for _ in range(n):
  A, B = map(int, input().split())
  if A == B == 0:
    bad_fish = (bad_fish + 1)%mod_val
    continue
  if B == 0:
    if (1, 0) in count_simple_fish:
      count_simple_fish[(1, 0)][1] += 1
    else:
      count_simple_fish[(1, 0)] = [0, 1]
  elif A == 0:
    if (1, 0) in count_simple_fish:
      count_simple_fish[(1, 0)][0] += 1
    else:
      count_simple_fish[(1, 0)] = [1, 0]
  else:
    a, b = simplify(A, B)
    if a>0:
      if (a, b) in count_simple_fish:
        count_simple_fish[(a, b)][1] += 1
      else:
        count_simple_fish[(a, b)] = [0, 1]
    else:
      if (b, -a) in count_simple_fish:
        count_simple_fish[(b, -a)][0] += 1
      else:
        count_simple_fish[(b, -a)] = [1, 0]
big_total = 1
for simple_fish, count_leftright in count_simple_fish.items():
  group_pair_combos = 1
  group_pair_combos = (group_pair_combos + pow(2, count_leftright[1], mod_val) - 1)%mod_val
  group_pair_combos = (group_pair_combos + pow(2, count_leftright[0], mod_val) - 1)%mod_val
  big_total = (big_total * group_pair_combos)%mod_val
big_total = (big_total + bad_fish - 1)%mod_val
print(big_total)

Measured memory_bytes: 60480
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,m,n) for(int i=m;i<n;i++)
#define endre getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define INF 1000000007

signed main() {
	int a, b;
	cin >> a >> b;
	cout << a + 1 - b << endl;
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

pair<int, int> solve(string s, string p, int l) {
    if(s[l] == '[') {
//        cerr << "op:" << l << '\n';
        l++;
        char op = s[l];

        auto r = solve(s, p, l + 1);
        auto ret = solve(s, p, r.second);
        int ans;
        if(op == '+'){
            ans = r.first | ret.first;
        }
        else if(op == '*') {
            ans = r.first & ret.first;
        }
        else if(op == '^') {
            ans = r.first ^ ret.first;
        }
        else {
            cerr << "??????\n";
        }
        return {ans, ret.second+1};
    }
    else {
//        cerr << "LT: " << l << '\n';
        return {p[s[l] - 'a'] - '0', l+1};
    }
}

string to_str(int k){
    string ans{"0000"};
    for (int i = 0; i < 4; ++i) {
        ans[3-i] = k % 10 + '0';
        k /= 10;
    }
    return ans;
}

int count(string s, int k){
    int c = 0;
    for (int i = 0; i < 10000; ++i) {
        string p = to_str(i);
        if(k == solve(s, p, 0).first){
            c++;
        }
    }
    return c;
}

int main(){
    string s,p;
    while(1){
        cin >> s;
        if(s == ".") return 0;
        cin >> p;
        int ans = solve(s, p, 0).first;
        int c = count(s, ans);
        cout << ans << ' ' << c << '\n';
    }
}


Measured memory_bytes: 3180
#include <iostream>
#include <climits>
using namespace std;
long long n,d,x,y,xx,yy,moves,dif=LLONG_MAX;
int main()
{
    cin>>n;
    for (d=1;d*d<=n;++d)
    {
        if (n%d==0)
        {
            x=d;
            y=n/d;
            if (y-x<dif)
            {
                dif=y-x;
                xx=x;
                yy=y;
            }
        }
    }
    moves=xx+yy-2; /// xx-1+yy-2;
    cout<<moves;
}


Measured memory_bytes: 384
package main

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

var sc = bufio.NewScanner(os.Stdin)

const initBufSize, maxBufSize = 10000, 1000000

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

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

func nextInts(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = nextInt()
	}
	return res
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func pow(r, n int) int {
	return int(math.Pow(float64(r), float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initBufSize), maxBufSize)
	s := nextInt()
	w := nextInt()
	if w < s {
		fmt.Println("safe")
	} else {
		fmt.Println("unsafe")
	}
}

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

ll N, M;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
#ifdef LOCAL
	std::ifstream in("in");
	std::cin.rdbuf(in.rdbuf());
#endif

	cin >> N >> M;
	ll cnt = 1 << M;
	ll ans = cnt * 100 * (N - M);
	ans += 1900 * cnt * M;
	cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-27
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A,B;
    int K;
    cin >> A >> B >> K;

    for (int i = 0; i < K; ++i) {
        if(i % 2 == 0){
            if (A % 2 != 0) {
                A -= 1;
            }
            B += A / 2;
            A /= 2;
        }else{
            if (B % 2 != 0) {
                B -= 1;
            }
            A += B / 2;
            B /= 2;
        }
    }

    cout << A << " " << B << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char *argv[])
{
    char s[101], p[101], tmp[202];
    
    scanf("%s", s);
    scanf("%s", p);
    strcpy(tmp, s);
    strcat(tmp, s);
    if (strstr(tmp, p)) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<double,int>P;
typedef complex<double> C;

struct edge
{
    int to;
    double cost;
};

const int MAX_N = 105;

C v[MAX_N];
int r[MAX_N];
vector<edge> G[2*MAX_N];
int n;
double d[2*MAX_N];

namespace std {
  bool operator < (const C& a, const C& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}

double cross(const C& a, const C& b) {
  return imag(conj(a)*b);
}
double dot(const C& a, const C& b) {
  return real(conj(a)*b);
}

struct L : public vector<C> {
  L(const C &a, const C &b) {
    push_back(a); push_back(b);
  }
};

int ccw(C a, C b, C c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectLL(const L &l, const L &m) {
  return abs(cross(l[1]-l[0], m[1]-m[0])) > EPS || // non-parallel
         abs(cross(l[1]-l[0], m[0]-l[0])) < EPS;   // same line
}
bool intersectLS(const L &l, const L &s) {
  return cross(l[1]-l[0], s[0]-l[0])*       // s[0] is left of l
         cross(l[1]-l[0], s[1]-l[0]) < EPS; // s[1] is right of l
}
bool intersectLP(const L &l, const C &p) {
  return abs(cross(l[1]-p, l[0]-p)) < EPS;
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

L cross_line(C p1,int r1,C p2,int r2)
{
    double d = norm(p2-p1);
    double t = r2*r2 - r1*r1 - d;
    double aa = d,bb = t*(real(p2)-real(p1)),cc = t*t / 4.0 - (imag(p2) - imag(p1))*(imag(p2) - imag(p1))*r1*r1;
    double x2 = (-bb + sqrt(bb*bb - 4*aa*cc))/(2*aa),x1 = (-bb - sqrt(bb*bb - 4*aa*cc))/(2*aa);
    double y1,y2;
    if(imag(p1) == imag(p2)){
        y1 = -sqrt(r1*r1 - x1*x1);
        y2 = -y1;
    }else{
        y1 = (t+2*(real(p2)-real(p1))*x1)/(-2*(imag(p2)-imag(p1)));
        y2 = (t+2*(real(p2)-real(p1))*x2)/(-2*(imag(p2)-imag(p1)));
    }
    L ln = L(C(x1+real(p1),y1+imag(p1)),C(x2+real(p1),y2+imag(p1)));
    return ln;
}

int main()
{
    int x1,y1,r1,x2,y2,r2;
    cin >> x1 >> y1 >> r1 >> x2 >> y2 >> r2;
    L res = cross_line(C(x1,y1),r1,C(x2,y2),r2);
    printf("%.10f %.10f %.10f %.10f\n",real(res[0]),imag(res[0]),real(res[1]),imag(res[1]));
    return 0;
}

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

#define INF 1LL << 60
#define pb push_back
#define loop_type ll
#define REP(i, n) for (loop_type i = 0; i < (loop_type)(n); i++)
#define REPR(i, b, e) for (int i = (b); i <= (e); i++)
#define DEBUG(x) cout << #x << ": " << (x) << endl
#define DEBUGA(a) cout << #a << ": "; for (const auto& v: (a)) cout << v << endl

ll X, Y, Z, K, A[1005], B[1005], C[1005];
vector<ll> res;

int main() {
    cin.tie(0);
    cin >> X >> Y >> Z >> K;
    for (int i = 0; i < X; i++) cin >> A[i];
    for (int i = 0; i < Y; i++) cin >> B[i];
    for (int i = 0; i < Z; i++) cin >> C[i];
    sort(A, A+X, greater<ll>());
    sort(B, B+Y, greater<ll>());
    sort(C, C+Z, greater<ll>());

    for (int i = 0; i < X; i++) {
        for (int j = 0; j < Y; j++) {
            for (int k = 0; k < Z; k++) {
                if ((i + 1) * (j + 1) * (k + 1) <= K)
                    res.pb(A[i] + B[j] + C[k]);
                else
                    break;
            }
        }
    }
    sort(res.begin(), res.end(), greater<ll>());
    for (ll i = 0; i < K; i++) {
        cout << res[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
            new InputStreamReader(System.in));
        StringBuilder str = new StringBuilder();
        String[] data;
        int x, y;
        while (true) {
            data = br.readLine().split(" ");
            x = Integer.parseInt(data[0]);
            y = Integer.parseInt(data[1]);
            if (x == 0 && y == 0) {
                break;
            }
            if (x < y) {
                str.append(data[0]).append(" ").append(data[1]).append("\n");
            } else {
                str.append(data[1]).append(" ").append(data[0]).append("\n");
            }
        }
        System.out.print(str);
    }
}

Measured memory_bytes: 26304
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//size() use int
//__gcd, atan2(y,x)=y/x , __int128
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//log() = ln() , log(x)/log(y)=log(y)-base-x
//watch out LL
//INT_MAX 127,INT_MIN 128
int n;
struct Nd{
	int x,y,s;
};
vector<Nd>v;
bool cmp(Nd a,Nd b){
	if(a.x==b.x)return a.y<b.y;
	return a.x<b.x;
}
int main(){Accel
	cin>>n;
	FOR(i,1,n){
		int a,b;
		cin>>a>>b;
		v.PB(Nd{a,b,0});
	}
	FOR(i,1,n){
		int a,b;
		cin>>a>>b;
		v.PB(Nd{a,b,1});
	}
	sort(ALL(v),cmp);
	int tot=0;
	multiset<int>t;
	REP(i,2*n){
		//cout<<v[i].x<<endl;
		if(v[i].s==0)t.insert(v[i].y);
		else{
			auto it=t.lower_bound(v[i].y);
			//cout<<*it<<endl;
			if(it==t.begin())continue;
			it--;
			t.erase(it);
			tot++;
		}
	}
	cout<<tot<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] w = new int[n+1];
        w[0]=0;
        for (int i=0;i<n;i++)w[i+1]=w[i]+sc.nextInt();
        int ans = Integer.MAX_VALUE;
        for (int i=1;i<n;i++)ans=Math.min(ans,Math.abs(w[n]-2*w[i]));
        System.out.println(ans);
    }
}


Measured memory_bytes: 35808
A = int(input())
B = int(input())
C = int(input())
X = int(input())

def check(A, B, C, X):
    count = 0
    for a in range(A+1):
        for b in range(B+1):
            for c in range(C+1):
                if (a*500 + b*100 + c*50) == X:
                    count += 1
    return count

print(check(A, B, C, X))


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define FOR(i,a,n) for (int i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (int i=(n);i>=(a);--i)
#define FI(i,n) for (int i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

// I am questioning life and universe and 
// everything else after looking at this

const ll MOD = 1e9 + 7;
ll power(ll x,ll y){
    ll res = 1;
    while(y){
        if(y&1) res = (res*x)%MOD;
        x = (x*x)%MOD;
        y >>= 1;
    }
    return res;
}

void solve(){
    ll n; cin>>n;

    ll a[n+1]; 
    a[0] = 0;
    FOR(i,1,n) cin>>a[i];

    vector<ll> arr;

    FOR(i,1,n) if(a[i] != a[i-1]) arr.push_back(a[i]);

    n = arr.size();

    map<ll,set<ll>> m;
    for(ll i=0;i<n;i++){
        m[arr[i]].insert(i);
    }

    ll dp[n]; ZERO(dp);
    dp[0] = 1;

    for(ll i=0;i<n;i++){
        m[arr[i]].erase(i);
        if(i>0) dp[i] = (dp[i] + dp[i-1])%MOD;
        if(m[arr[i]].size() > 0){
            ll next = *m[arr[i]].begin();
            dp[next] = dp[i];
        }
    }
    
    cout<<dp[n-1]<<endl;
}

signed main(){


    FastRead;    

    ll t;
    t = 1;
    while(t--) solve();
    
}


Measured memory_bytes: 33136
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long A = sc.nextLong(), B = sc.nextLong(), K = sc.nextLong();
    if(A-K <= 0){
      K -= A;
      A = 0; 
      B = B-K < 0 ? 0 : B-K;
    }else{
      A = A-K;
    }
    System.out.println(A+" "+B);
  }
}


Measured memory_bytes: 22996
D = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for i in range(D)]
t = []
last = [[-1] for i in range(26)]

# max index greedy search
for i in range(D):
    # op = s[i].index(max(s[i]))
    op = c.index(max(c))
    t.append(op+1)
    last[op].append(i)
    # ans += s[i][op]
    # last[op]=i
    # for j in range(26):
    #     ans -= c[j]*(i-last[j])
    # for j in range(26):
    #     ans -= c[j]*(i-last[j][-1])

# update
from bisect import *
import random
m = 400000
def suminc(a,b):
    return b*(b-1)//2-a*(a-1)//2
while m:
    m-=1
    update = 0
    d = random.randint(1,D)
    q = random.randint(1,26)
    d-=1
    q-=1
    oq = t[d]-1
    update += s[d][q]-s[d][oq]
    idx = bisect_left(last[oq],d)
    if idx == len(last[oq])-1:
        cnt = D - last[oq][idx]
    else:
        cnt = last[oq][idx+1] - last[oq][idx]
    update += c[oq]*suminc(0,cnt)
    cntprv = last[oq][idx] - last[oq][idx-1]
    update -= c[oq]*suminc(cntprv,cntprv+cnt)

    idx2 = bisect_left(last[q],d)-1
    if idx2 == len(last[q])-1:
        cnt = D - d
    else:
        cnt = last[q][idx2+1] - d
    if idx2 == len(last[q])-1:
        cntprv = D - last[q][idx2] - cnt
    else:
        cntprv = last[q][idx2+1] - last[q][idx2] - cnt
    update += c[q]*suminc(cntprv,cntprv+cnt)
    update -= c[q]*suminc(0,cnt)

    if update > 0:
    # ans += update
        del last[oq][idx]
        last[q].insert(idx2+1,d)
        # print(ans)
        t[d] = q+1

# with open('ramdom.out', 'w') as f:
#     for i in range(D):
#         print(t[i],file=f)

for i in range(D):
    print(t[i])


Measured memory_bytes: 88628
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <algorithm>

int main() {
  int N;
  std::cin >> N;
  std::vector<long long> A(N);
  for (auto &i : A) { std::cin >> i; }
  for (int i = 0; i + 1 < N; ++i) { A[i + 1] += A[i]; }
  int split1 = 0;
  int split2 = 2;
  long long ans = 1000000000000;
  for (int i = 1; i + 2 < N; ++i) {
    while (split1 + 1 < i && A[split1] * 2 < A[i]) { ++split1; }
    split1 = split1 > 1 && A[i] - A[split1 - 1] < A[split1] ? split1 - 1 : split1;
    split2 = std::max(split2, i + 1);
    while (split2 + 1 < N && (A[split2] - A[i]) * 2 < (A[N - 1] - A[i])) { ++split2; }
    split2 = A[N - 1] - A[split2 - 1] < A[split2] - A[i] ? split2 - 1 : split2;
    split2 = std::max(split2, i + 1);
    auto P = A[split1];
    auto Q = A[i] - A[split1];
    auto R = A[split2] - A[i];
    auto S = A[N - 1] - A[split2];
    ans = std::min(ans, std::max({P, Q, R, S}) - std::min({P, Q, R, S}));
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
struct UnionFind {
    vector<int> A;
    UnionFind(int n) : A(n, -1) {}
    int find(int i) {
        if (A[i] < 0) return i;
        return A[i] = find(A[i]);
    }
    void unite(int i, int j) {
        i = find(i), j = find(j);
        if (i == j) return;
        if (A[i] > A[j]) swap(i, j);
        A[i] += A[j];
        A[j] = i;
    }
};
int main()
{
    int N, M; cin >> N >> M;
    UnionFind uf(N+M);
    for (int i = 0; i < N; i++) {
        int K; cin >> K;
        for (int j = 0; j < K; j++) {
            int l; cin >> l; l--;
            uf.unite(i, N+l);
        }
    }
    int root = uf.find(0);
    for (int i = 0; i < N; i++) {
        if (root != uf.find(i)) {
            cout << "NO\n";
            return 0;
        }
    }
    cout << "YES\n";
    return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#define LL long long
const int maxn = 1e5 + 5;
const int maxP = 1e4;
using namespace std;
LL a[maxn], b[maxn]; int n;
map <LL, int> m;
vector <LL> p;
bool f[maxn];
void install(){
	for (int i = 2; i <= maxP; i++){
		if (!f[i]) p.push_back(i);
		for (int j = 0; j < p.size() && i * p[j] <= maxP; j++){
			f[i * p[j]] = 1;
			if (i % p[j] == 0) continue;
		}
	}
}
LL split(LL &x){
	LL res1 = 1, res2 = 1;
	for (int i = 0; i < p.size(); i++){
		if (x % p[i] != 0) continue;
		int cnt = 0;
		while (x % p[i] == 0) ++cnt, x /= p[i];
		cnt %= 3;
		if (cnt == 2) res1 = res1 * p[i] * p[i], res2 = res2 * p[i];
		else if (cnt == 1) res1 = res1 * p[i], res2 = res2 * p[i] * p[i];
	}
	if (x != 1){
		if ((LL)sqrt(x) * (LL)sqrt(x) == x) res1 *= x, res2 *= (LL)sqrt(x);
		else res1 *= x, res2 *= x * x;
	}
	x = res1;
	return res2;
} 
int main(){
	scanf("%d", &n); install();
//	for (int i = 0; i < 20; i++) printf("%d\n", p[i]);
	for (int i = 1; i <= n; i++){
		scanf("%lld", a + i);
		b[i] = split(a[i]);
		m[a[i]]++;
	} int ans = (m[1] != 0); m[1] = 0;
	for (int i = 1; i <= n; i++){
		if (m[b[i]] != 0) ans += max(m[a[i]], m[b[i]]), m[a[i]] = 0, m[b[i]] = 0;
		else ans += m[a[i]], m[a[i]] = 0;
	} printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 14464
#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5;
LL a[N];
int sgn(LL x)
{
    if(x==0) return 0;
    if(x<0) return -1;
    else return 1;
}
LL solve(int n, LL a0)
{
    LL ans = 0;
    LL sum = a0;
    int prev = sgn(a0);
    for(int i = 1; i < n; i++)
    {
        sum += a[i];
        if(sgn(sum) != -1*sgn(prev))
        {
            LL delta = sum==0 ? -1*sgn(prev) : -1*(sum+sgn(sum));
            sum += delta;
            ans += abs(delta);
            //cout<<" "<<delta<<endl;
        }
        //cout<<sum<<endl;
        prev = sgn(sum);
    }
    return ans;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n; cin >> n;
    for(int i = 0; i < n; i++)
        cin >> a[i];
    
    LL ans;
    if(a[0] > 0)
        ans = solve(n,a[0]);
    else
        ans = solve(n,1)+(1-a[0]);

    if(a[0] < 0)
        ans = min(ans,solve(n,a[0]));
    else
        ans = min(ans,solve(n,-1)+(a[0]+1));
    
    cout<<ans<<endl;

    cout<<flush;
    return 0;
}

Measured memory_bytes: 1024
//二部マッチング
//辺の構造体を持つ隣接リストで表現

#include<bits/stdc++.h>
using namespace std;
#define MAX_V 1000000
#define INF 1e9

//辺を表す構造体　(行先、容量、逆辺の場所)
struct edge{
    int to, cap, rev;
};

vector<vector<edge> > G(MAX_V);       //グラフの隣接リスト表現
bool used[MAX_V];                    //DFSですでに調べたかのグラフ


// from から to へ向かう容量 cap の辺をグラフに張る
void add_edge(int from, int to, int cap){

    edge F;
    edge T;
    F.to = to;
    F.cap = cap;
    F.rev = G[to].size();
    G[from].push_back(F);

    T.to = from;
    T.cap = 0;
    T.rev = G[from].size() - 1;
    G[to].push_back(T);    
}

//増加パスをDFSで探す
int dfs(int v, int t, int f){
    if(v == t) return f;
    used[v] = true;
    for(int i = 0; i < G[v].size(); i++){
        edge &e = G[v][i];                          //すごい
        if(!used[e.to] && e.cap > 0){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;            //もっとすごい
                return d;
            }
        }
    }
    return 0;
}

//s から t への最大流を求める
int max_flow(int s, int t){
    int flow = 0;
    while(1){
        memset(used, 0, sizeof(used));
        int f = dfs(s, t, INF);
        if(f == 0) return flow;
        flow += f;
    }
}

int main(){

    //入力
    //xはuに属する
    //yはvに属する
    int u, v, e; cin >> u >> v >> e;               //uの頂点数　v超点数　辺数
    
    for(int i = 0; i < e; i++){
        int x, y; cin >> x >> y;
        x++;
        y++;
        y += u;
        add_edge(x, y, 1);
    }

    for(int i = 1; i <= u; i++) add_edge(0, i, 1);
    for(int i = u + 1; i <= u + v; i++) add_edge(i, u + v + 1, 1);
    
    cout << max_flow(0, u + v + 1) << endl;
    return 0;
}





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

int main() {
  int N, M, K, i, a_cnt, b_cnt, ans = 0;

  // N, M, Kの入力
  cin >> N >> M >> K;

  // 1回も読まないことを考慮して先頭に0を入れたい
  vector<long int> A(N + 1, 0);
  vector<long int> B(M + 1, 0);

  // A, Bの入力
  for (i = 1; i <= N; i++) cin >> A.at(i);
  for (i = 1; i <= M; i++) cin >> B.at(i);

  // N, M冊目まで読んだ時に合計で何分かかるかが格納される
  for (i = 1; i <= N; i++) A.at(i) += A.at(i - 1);
  for (i = 1; i <= M; i++) B.at(i) += B.at(i - 1);

  b_cnt = M;

  for (a_cnt = 0; a_cnt <= N; a_cnt++) {
    if (A.at(a_cnt) > K) continue;

    while (A.at(a_cnt) + B.at(b_cnt) > K) b_cnt--;

    ans = max(ans, a_cnt + b_cnt);
  }

  cout << ans << endl;
}

Measured memory_bytes: 6404
str=input()
q=int(input())
for i in range(q):
    cmd=input().split()
    cmd[2]=int(cmd[2])
    cmd[1]=int(cmd[1])
    if cmd[0]=='replace':
        str=str[:cmd[1]]+cmd[3]+str[cmd[2]+1:]
    elif cmd[0]=='reverse':
        str=str[:cmd[1]]+str[cmd[1]:cmd[2]+1][::-1]+str[cmd[2]+1:]
    elif cmd[0]=='print':
        print(str[cmd[1]:cmd[2]+1])


Measured memory_bytes: 5616
n, a, b = map(int, input().split())
mod = 10**9 + 7


def C(n, k):
    a = 1
    b = 1
    for i in range(k):
        a = a * (n-i) % mod
        b = b * (i+1) % mod
    return a * pow(b, mod-2, mod) % mod


ans = (pow(2, n, mod) - 1 - C(n, a) - C(n, b)) % mod

print(ans)


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

int main()
{
    long long N;
    cin >> N;
    long long ans = 0LL;
    for (long long i = 1; i <= N; i++)
    {
        long long Y = N / i;
        ans += (Y * (Y + 1LL) * i) / 2LL;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<b;i++)
#define INF 1000000000
#define MAX_N 105
#define X 1000000007
using namespace std;
bool debug=false;

int main(){
  string s;
  cin>>s;
  if(s.size()==2&&s[0]==s[1]){
    cout<<1<<" "<<2<<endl;
    return 0;
  }
  
  for(int i=0;i<s.size()-2;i++){
    //if((s[i]==s[i+1]&&s[i]!=s[i+2])||(s[i]==s[i+2]&&s[i]!=s[i+1])||(s[i+1]==s[i+2]&&s[i]!=s[i+2])||(s[i]==s[i+1]&&s[i+1]==s[i+2])){
    if(s[i]==s[i+1]||s[i+1]==s[i+2]||s[i+2]==s[i]){
      cout<<i+1<<" "<<i+3<<endl;
      return 0;
    }
  }
  cout<<-1<<" "<<-1<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <string>
#include <cmath>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<ll> vll;
 
#define all(v) v.begin(),v.end()
#define test() int t;cin>>t;while(t--) 
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int mod = 1e9+7;

int main()
{   
    fastio
    int k;
    cin>>k;
    int rem = 7%k, freq = 1;
    if(k%2==0 || k%5==0)
        cout<<-1<<endl;  
    else
    {   
        while(rem)
        {
            freq++;
            rem = (10*rem + 7)%k;
        }
        cout<<freq<<endl;
    }    
}

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

// macros
#define pb emplace_back
#define mk make_pair
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(itr, st) for(auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for(auto itr = (st).rbegin(); itr != (st).rend(); ++itr)
#define whole(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define bit(n) (1LL<<(n))
// functions
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}
template <typename T> istream &operator>>(istream &is, vector<T> &vec){for(auto &v: vec)is >> v; return is;}
template <typename T> ostream &operator<<(ostream &os, const vector<T>& vec){for(int i = 0; i < vec.size(); i++){ os << vec[i]; if(i + 1 != vec.size())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_set<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T> ostream &operator<<(ostream &os, const unordered_multiset<T>& st){for(auto itr = st.begin(); itr != st.end(); ++itr){ os << *itr; auto titr = itr; if(++titr != st.end())os << " ";} return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p){os << "(" << p.first << ", " << p.second << ")"; return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
template <typename T1, typename T2> ostream &operator<<(ostream &os, const unordered_map<T1, T2> &mp){for(auto itr = mp.begin(); itr != mp.end(); ++itr){ os << "(" << itr->first << ", " << itr->second << ")"; auto titr = itr; if(++titr != mp.end())os << " "; } return os;}
//  types
using ll = long long int;
using P = pair<int, int>;
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1000000007;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};
// io
struct fast_io{
  fast_io(){ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(20);}
} fast_io_;


int main(int argc, char const* argv[])
{
  int a, b, c; cin >> a >> b >> c;
  set<int> st;
  st.insert(a);
  st.insert(b);
  st.insert(c);
  if(sz(st) == 2)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)x.size())
#define ALL(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
int n, p[60000], top;
bool f[60000]={1,1};
int main() {
	for(int i=2; i<=55555; i++) {
		if(f[i]) continue;
		for(ll j=1ll*i*i; j<=55555; j+=i)
			f[j] = 1;
		p[++top] = i;
	}
	scanf("%d", &n);
	for(int i=1; i<=top; i++) {
		if(p[i] % 10 == 1) printf("%d ", p[i]), n--;
		if(!n) break;
	}
	return 0;
}

Measured memory_bytes: 384
open Scanf
open Printf

let explode s =
  let rec exp i l =
    if i < 0 then l else exp (i - 1) (s.[i] :: l) in
  exp (String.length s - 1) []

let symbol s =
  let lst = explode s in
  let rec sym lst = match lst  with
      [] -> 0
    | first :: rest -> if first = '+' then 1 + sym rest
                                      else (-1) + sym rest
  in
    sym lst

let () = scanf "%s" symbol |> printf "%d\n"


Measured memory_bytes: 3772