akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define sc second
#define takeline cin.ignore();
#define iactive cout.flush();
#define N 500005
#define endl "\n"
#define mod 1000000007
#define PI 3.141592653589793
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

	ll i,j,k,l,n;
	cin>>n;
	ll ar[n+1];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	ll an=0;
	for(i=1;i<=n;i++){
		for(j=i+1;j<=n;j++){
			for(k=j+1;k<=n;k++){
				if(ar[i]==ar[j]||ar[i]==ar[k]||ar[j]==ar[k]) continue;
				if(ar[i]+ar[j]>ar[k]&&ar[i]+ar[k]>ar[j]&&ar[j]+ar[k]>ar[i]) an++;
			}
		}
	}
	cout<<an;
	return 0;	
}

Measured memory_bytes: 3612
N, L = map(int, input().split())

count = 0
min = None
sum = 0
for i in range(N):
  i += 1
  num = abs(L + i - 1)
  if min == None:
    min = num
    count = i
    continue
  if min > num:
    min = num
    count = i
for i in range(N):
  i += 1
  if i != count:
    num = L + i - 1
    sum += num
print(sum)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/

void solve()
{
	int a,b;
  	cin >> a >> b;
  	cout << 6- a-b;
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
} 
               
			
 

				
		
		




Measured memory_bytes: 23680
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
long long q,a,b,p,t,ans,k;
int main()
{
	scanf("%lld",&q);
	while(q--)
	{
		scanf("%lld%lld",&a,&b);
		ans=0;
		p=sqrt(a*b-1);
		if (p*p>a*b-1) p--;
		ans=2*p;
		if (p>=a) ans--;
		if (p>=b) ans--;
		if (p*(p+1)>=a*b) ans--;
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <set>
#include <map>
#define range(i, r) for(int i=0;i<r;i++)
#define ranges(i, l, r) for(int i=l;i<r;i++)
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi std::vector<std::vector<int> >
#define vvl std::vector<std::vector<ll> >
#define MODs 1000000007;
#define MODn 1000000009;
typedef long long int ll;
using namespace std;

int main(int argc, char const *argv[]) {
  int N, Q;
  std::cin >> N >> Q;
  vvi work = vv(N, 3, 0, int);
  vvi d = vv(Q, 3, 0, int);
  for(int i=0;i<N;i++){
    std::cin >> work[i][0] >> work[i][1] >> work[i][2] ;
    work[i][0]-=work[i][2], work[i][1]-=work[i][2];
  }
  for(int i=0;i<Q;i++) {
    std::cin >> d[i][0];
    d[i][1]=i;
  }
  sort(d.begin(), d.end());
  multimap<int, pair<int, int> > event;
  multiset<int> spot;

  for(int i=0;i<work.size();i++){
    event.emplace(work[i][0], make_pair(1, work[i][2]) );
    event.emplace(work[i][1], make_pair(-1, work[i][2]) );
  }

  auto itr = event.begin();
  for(int i=0;i<d.size();i++){
    while(itr!=event.end() && (*itr).first<=d[i][0]){
      if((*itr).second.first==1){
        spot.insert((*itr).second.second);
      }else{
        spot.erase((*itr).second.second);
      }
      itr++;
    }

    if(spot.size()!=0) {
      auto it = spot.begin();
      d[i][2]=(*it);
    }else d[i][2] = -1;
  }
  sort(d.begin(), d.end(),
  [](std::vector<int>  &a, std::vector<int>  &b){
    return a[1] < b[1];
  });
  for(int i=0;i<d.size();i++) std::cout << d[i][2] << '\n';
  return 0;
}


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


int main()
{
	int a, b;
	cin >> a >> b;
	if (a > b) {
		cout << 2 * a - 1;
	}
	else if (a == b) {
		cout << 2 * a;
	}
	else{
		cout << 2 * b - 1;
	}
		}

Measured memory_bytes: 256
import java.io.PrintWriter

val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val (N, M) = listOfLong()
    var maxL = 0L
    var minR= N
    for (m in 0 until M) {
        val (l, r) = listOfLong()
        maxL = Math.max(maxL, l)
        minR = Math.min(minR, r)
    }
    val ans = Math.max(0, minR - maxL + 1)
    println(ans)
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map { it.toLong() }


Measured memory_bytes: 55668
#D - String Formation
S=input()
Q=int(input())
query=[]
for _ in range(Q):
    query.append(input().split())

flag = True
t=""
u=""

for i in query:
    if i[0]=="1":
        u,t=t,u
        flag = not flag
#        S=S[::-1]
    else:
        if i[1]=="1":
            t+=i[2]
        else:
            u+=i[2]
if flag:
    print(t[::-1]+S+u)
else:
    print(t[::-1]+S[::-1]+u)

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

int main() {
  int n;
  scanf("%d", &n);
  long a[n], sum=0, xor=0, ans=0; int k=0, cnt=0;
  for (int i=0; i<n; i++) scanf("%ld", a+i);
  for (int i=0; i<n; i++) {
    while (k<n && (sum+a[k] == (xor^a[k]))) {
      sum+=a[k];
      xor+=a[k];
      k++;
      cnt++;
    }
    ans+=cnt;
    cnt--;
    sum-=a[i];
    xor-=a[i];
  }
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n, m;
int pos[50][50];
char d;
int I;

int main(){
	while (cin >> n&&n){
		REP(i, 50)REP(j, 50)pos[i][j] = 0;
		int sy = 10, sx = 10;
		REP(i, n){
			ll x, y;
			cin >> x >> y;
			pos[y][x] = 1;
		}
		int co = 0;
		if (pos[sy][sx] == 1){
			pos[sy][sx] = 0;
			co++;
		}
		cin >> m;
		REP(i, m){
			cin >> d >> I;
			REP(i, I){
				if (d == 'N') sy++;
				else if (d == 'E') sx++;
				else if (d == 'S') sy--;
				else sx--;
				if (pos[sy][sx]){
					pos[sy][sx] = 0;
					co++;
				}
			}
		}
		if (co == n)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 1168
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <random>
#include <ctime>
#include <string>
#include <iomanip>
#include <set>
#include <map>
#include <queue>
#include <stack>

using namespace std;

typedef long long li;
typedef unsigned long long uli;
typedef pair<int, int> pii;
typedef long double ld;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define fr first
#define sc second
#define pb push_back
#define forn(i, n) for(int i = 0; i < int(n); ++i)
#define fore(i, l, r) for(int i = int(l); i < int(r); ++i)
#define forb(i, n) for(int i = int(n) - 1; i >= 0; --i)

const int INF = 1e9 + 1000;
const li INF64 = 1e15 + 1000;
const int M = 100 + 10;
const int N = 100 * 1000 + 100;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = 3.14159265359;

li gcd(li a, li b) {
    return a == 0 ? b : gcd(b % a, a);
}

int dp[N];
vector<int> g[N];
bool used[N];

int dfs(int v) {
    used[v] = true;

    int s = 0;
    for (auto to : g[v]) {
        if (!used[to]) {
            s = max(s, 1 + dfs(to));
        }
        else {
            s = max(s, dp[to] + 1);
        }
    }

    return dp[v] = s;
}

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

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, m;
    cin >> n >> m;

    forn(i, m) {
        int v, u;
        cin >> v >> u;
        v--; u--;
        g[v].pb(u);
    }

    forn(i, n) {
        if (!used[i]) {
            dfs(i);
        }
    }

    int ans = 0;

    forn(i, n) {
        ans = max(ans, dp[i]);
    }

    cout << ans << '\n';

}


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

using namespace std;
typedef long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> v[n+1];
    for(int i=0;i<m;i++)
    {
        int a,b;
        cin >> a >> b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int res=-1;
    vector<bool> vis(n+1,0);
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==1) continue;
        res++;
        queue<int> q;
        q.push(i);
        vis[i]=1;
        while(!q.empty())
        {
            int a=q.front();
            q.pop();
            for(int to:v[a])
            {
                if(vis[to]==1) continue;
                q.push(to);
                vis[to]=1;
            }
        }
    }
    cout << res << "\n";
    return 0;
}


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

int main(){
  string a,b,c;cin >> a >> b >> c;
  if(a.at(a.size()-1)==b.at(0) && b.at(b.size()-1)==c.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		for (int i = a; i <= b; i++) {
			if (i % k == 0) {
				System.out.println("OK");
				return;
			}
		}
		System.out.println("NG");
	}
}


Measured memory_bytes: 35756
#include<bits/stdc++.h>
#define fast ios::base_sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define M 1000000007
#define pie 3.141592653589793238
using namespace std;

int check(int a[], int b[], int n){
    ///int n = sizeof(a)/sizeof(a[0]);
    for(int i=0;i<n;i++){
        if(a[i] != b[i])
            return 0;
    }
    return 1;
}


signed main(){  
    int n;cin >> n;
    int a[n],b[n];
    int c[n];
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<n;i++){
        cin >> b[i];
        c[i] = b[i];
    }

    sort(c, c+n);

    int ac=0, bc=0;
    int f1=0, f2=0;
    int x = 1;
    while(1){
        if(f1 == 0){
            if(check(a, c, n)){
                f1 = 1;
                ac++;
            }
            else
                ac++;
        }
        if(f2 == 0){
            if(check(b, c, n)){
                f2 = 1;
                bc++;
            }
            else
                bc++;
        }
        if(f1 && f2)
            break;
        next_permutation(c, c+n);
    }
    cout << abs(ac - bc);
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<math.h>

struct Point {double x, y;};

void koch(int n, struct Point a, struct Point b) {
  if(n==0) return;
  struct Point s, t, u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1, a, s);
  printf("%.8f %.8f\n",s.x, s.y);
  koch(n-1, s, u);
  printf("%.8f %.8f\n",u.x, u.y);
  koch(n-1, u, t);
  printf("%.8f %.8f\n",t.x, t.y);
  koch(n-1, t, b);

}

int main() {
 struct Point a, b;
 int n;

scanf("%d",&n);
a.x=0;
a.y=0;
b.x=100;
b.y=0;

printf("%.8f %.8f\n",a.x,a.y);
koch(n, a, b);
printf("%.8f %.8f\n",b.x,b.y);
   return 0;
}

Measured memory_bytes: 640
#pragma warning(disable: 4996)

#include <iostream>
#include <iomanip>
#include <random>
#include <unordered_map>
#include <functional>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <vector>
#include <bitset>
#include <numeric>
#include <string>
#include <set>
#include <tuple>
#include <utility>
#include <regex>
using namespace std;

long long gcd(long long a, long long b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
	long long g = gcd(a, b);
	return a / g * b;
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	long long n;
	cin >> n;
	if (n % 2 == 1) {
		cout << 0;
		exit(0);
	}
	vector<long long> five;
	long long num = 1;
	for (int i = 0; i < 25; ++i) {
		num *= 5;
		five.push_back(num);
	}

	long long ans = 0;
	for (int i = 0; i < five.size(); ++i) {
		ans += n / five[i] / 2;
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
typedef long long ll;
int main(void)
{
    int q, com, x;
    string key;
    map<string, int> M;
    cin >> q;
    
    rep(i, q)
    {
        cin >> com;
        
        if (com == 0)
        {
            cin >> key >> x;
            M[key] = x;
        }
        else if (com == 1)
        {
            cin >> key;
            if(M.count(key))
            {
                cout << M[key] << endl;
            }
			else
			{
			    cout << 0 << endl;
			}
		}
        else if (com == 2)
        {
            cin >> key;
            M.erase(key);
        }
        else
        {
            string L, R;
            cin >> L >> R;
            map<string, int>::iterator st, en;
            st = M.lower_bound(L);
            en = M.upper_bound(R);
            for(; st!=en; st++){
				cout << (*st).first << ' ' << (*st).second << endl;
			}
        }
    }
}



Measured memory_bytes: 27692
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, a, b, c; cin >> n;
	int aa[201] = { 0 }, bb[201] = { 0 }, cc[201] = { 0 };
	for (int h = 0; h < n; h++) {
		cin >> a >> b >> c;
		aa[h] = a; bb[h] = b; cc[h] = c;
	}
	int test[201] = { 0 }, uiop[201] = { 0 };;
	for (int h = 0; h < n - 1; h++) {
		for (int i = h + 1; i < n; i++) {
			if (aa[h] == aa[i]) {
				uiop[h]++; uiop[i]++;
			}
		}
	}
	for (int h = 0; h < n; h++) {
		if (uiop[h] == 0) {
			test[h] += aa[h];
		}
	}
	int uio[201] = { 0 };
	for (int h = 0; h < n - 1; h++) {
		for (int i = h + 1; i < n; i++) {
			if (bb[h] == bb[i]) {
				uio[h]++; uio[i]++;
			}
		}
	}
	for (int h = 0; h < n; h++) {
		if (uio[h] == 0) {
			test[h] += bb[h];
		}
	}
	int uip[201] = { 0 };
	for (int h = 0; h < n - 1; h++) {
		for (int i = h + 1; i < n; i++) {
			if (cc[h] == cc[i]) {
				uip[h]++; uip[i]++;
			}
		}
	}
	for (int h = 0; h < n; h++) {
		if (uip[h] == 0) {
			test[h] += cc[h];
		}
	}
	for (int h = 0; h < n; h++) {
		cout << test[h] << endl;
	}
}


Measured memory_bytes: 3104
import java.util.Scanner;

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

		int a = sc.nextInt();
		int b = sc.nextInt();

		String ans;
		if (a > 0) {
			ans = "Positive";
		} else if (a == 0) {
			ans = "Zero";
		} else {
			if (b >= 0) {
				ans = "Zero";
			} else if ((a - b) % 2 == 0) {
				ans = "Negative";
			} else {
				ans = "Positive";
			}
		}

		System.out.println(ans);

		sc.close();
	}

}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

int num[3][3];
bool check[3][3];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	for(int i=0;i<3;i++){
		for(int j=0; j<3; j++){
			int n;
			cin >>n;

			num[i][j] = n;
			check[i][j] =false;
		}
	}

	int n;
	cin>>n;

	for(int i=0; i<n; i++){
		int d;cin>>d;

		for(int i=0;i<3;i++){
			for(int j=0; j<3; j++){
				if(num[i][j] ==d){
					check[i][j] =true;
					break;
				}
			}
	}
	}
		for(int i=0;i<3;i++){
			for(int j=0; j<3; j++){
				if(!check[i][j]){
					break;
				}
				if(j==2){
				writeln("Yes");
				return 0;
				}
			}
	}
		for(int i=0;i<3;i++){
			for(int j=0; j<3; j++){
				if(!check[j][i]){
					break;
				}
				if(j ==2){
				writeln("Yes");
				return 0;
				}
			}
	}

	if(check[0][0] && check[1][1] && check[2][2]){
				writeln("Yes");
				return 0;
	}
	if(check[0][2] && check[1][1] && check[2][0]){
				writeln("Yes");
				return 0;
	}
	writeln("No");




}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;
using static MyIO;


public class B
{
	public static void Main()
	{
		string[] s = Regex.Replace(GetString(), "BC", "D").Split('B', 'C');
		long ans = 0;
		for(int i = 0; i < s.Length; i++)
		{
			var bit = new BinaryIndexedTree<int>(s[i].Length, 0, (x, y) => x + y);
			int iD = 1;
			int iA = s[i].ToCharArray().Count(x => (x == 'D')) + 1;
			for(int j = 0; j < s[i].Length; j++)
			{
				if(s[i][j] == 'A')
				{
					ans += j - bit.Query(iA);
					bit.Update(iA, 1);
					iA++;
				}
				else
				{
					ans += j - bit.Query(iD);
					bit.Update(iD, 1);
					iD++;					
				}
			}
		}
		Console.WriteLine(ans);
	}
}


public class BinaryIndexedTree<T>
{
	private int N;
	private T INI;
	private Func<T, T, T> Func;
	private T[] bit;

	public BinaryIndexedTree(int n, T ini, Func<T, T, T> func)
	{
		N = n;
		INI = ini;
		Func = func;
			
		bit = new T[N + 1];  // 1-index
		for(int i = 0; i <= N; i++)
			bit[i] = INI;
	}

	public void Update(int i, T x)
	{
		while(i <= N)
		{
			bit[i] = Func(bit[i], x);
			i += i & -i;
		}
	}

	public T Query(int i)
	{
		T s = INI;
		while(i > 0)
		{
			s = Func(s, bit[i]);
			i -= i & -i;
		}
		return s;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 25356
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int main() {
   while (true) {
      string s;
      int m;
      cin >> s >> m;
      if (s == "-") break;
      rep(i, m) {
         int h;
         cin >> h;
         string t;
         t = s.substr(h, s.size()) + s.substr(0, h);
         s = t;
      }
      cout << s << endl;
   }
   return 0;
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int a[110];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    // it should sort
    sort(a, a + N, greater<int>());

    int Alice = 0;
    int Bob = 0;
    for(int i=0; i<N; i++){
        if(i%2 == 0){
            Alice += a[i];
        } else {
            Bob += a[i];
        }
    }
    cout << Alice - Bob << endl;

}


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

int main(int argc, char **argv){
	int i,j;
	int h,w;

	for(;;){
		// Input
		scanf("%d %d",&h, &w);
		// Finish Check
		if( h == 0 && w == 0 ){
			break;
		}
		// Output
		for(i=1;i<=h;i++){
			for(j=1;j<=w;j++){
				if( i==1 || i==h || j==1 || j==w ){
					printf("#");
				} else {
					printf(".");
				}
			}
			printf("\n");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  double ret = 0, a;
  for (int i=0; i<N; i++) {
    cin >> a;
    ret += 1.0 / a;
  }
  ret = 1.0 / ret;
  printf("%.12f\n", ret);
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Range Add Query (RAQ)
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_E&lang=ja

"""
import sys


def main(args):
    def add(b, k, x):
        while k <= n:
            b[k] += x
            k += k & -k

    def get(b, k):
        s = 0
        while k > 0:
            s += b[k]
            k -= k & -k
        return s

    n, queries = map(int, input().split())
    bit0 = [0] * (n + 1)
    bit1 = [0] * (n + 1)

    for _ in range(queries):
        q, *args = input().split()
        args = [int(a) for a in args]
        if q == '1':
            res = get(bit0, args[0]) + get(bit1, args[0]) * args[0]
            res -= get(bit0, args[0] - 1) + get(bit1, args[0] - 1) * (args[0] - 1)
            print(res)
        else:
            add(bit0, args[0], -args[2] * (args[0] - 1))
            add(bit1, args[0], args[2])
            add(bit0, args[1] + 1, args[2]* args[1])
            add(bit1, args[1] + 1, -args[2])


if __name__ == '__main__':
    main(sys.argv[1:])



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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    vector<bool> b(27);
    if(s.size()==26){
        reverse(s.begin(),s.end());
        for(int i = 0;i < 26;i ++){
            int x = s[i]-'a';
            for(int j = 0;j < 26;j ++){
                if(b[j] && x < j){
                    s[i] = char(j+'a');
                    s.erase(s.begin(),s.begin()+i);
                    reverse(s.begin(),s.end());
                    b[26] = 1;
                    break;
                }
            }
            if(b[26]) break;
            b[s[i]-'a'] = 1;
        }
    }else{
        for(int i = 0;i < s.size();i ++){
            b[s[i]-'a'] = 1;
        }
        for(int i = 0;i < 26;i ++){
            if(!b[i]){
                s += i + 'a';
                b[26] = 1;
                break;
            }
        }
    }
    if(b[26])cout << s << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,st,en,h) for(int i=st; i<=en; i+=h)
#define eb emplace_back
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,ans,p,q;
string s;

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

  cin>>s; string a;
  if(s=="Sunny")a="Cloudy";
  else if(s=="Cloudy")a="Rainy";
  else a="Sunny";
  cout<<a<<'\n';
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;


char so[10000001];

main(){
	so[0]=so[1]=1;
	
	for(int i=2;i*i<=10000000;i++){
		if(so[i]==1)continue;
		for(int j=i;j*i<=10000000;j++){
			so[j*i]=1;
		}
	}
	
	int n;
	while(cin>>n){
		if(n==0)break;
		
		while(1){
			if(so[n]|so[n-2]|so[n-6]|so[n-8]);
			else break;
			--n;
		}
		
		cout<<n<<endl;
	}
	return 0;
}

Measured memory_bytes: 10000
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.charAt(0)==s.charAt(1) && s.charAt(2)==s.charAt(3) && s.charAt(0)!=s.charAt(2)) {
			System.out.println("Yes");
		} else if (s.charAt(0)==s.charAt(2) && s.charAt(1)==s.charAt(3) && s.charAt(0)!=s.charAt(1)) {
			System.out.println("Yes");
		} else if (s.charAt(0)==s.charAt(3) && s.charAt(1)==s.charAt(2) && s.charAt(0)!=s.charAt(1)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}


	}




}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int n,l[1000],r[1000],a[1000],ans=0;
  cin >> n;
  for(int i=0;i<n;++i) cin >> l[i] >> r[i];
  for(int i=0;i<n;++i) {
    a[i] = r[i] - l[i] + 1;
    ans = ans + a[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int a;
  cin >> a;
  cout << 48 - a << endl;
}

Measured memory_bytes: 3644
use std::collections::HashMap;

fn solve() -> i32 {
    let _ = read();
    let s = read_line_str();
    // let mut hmap: HashMap<char, i32> = HashMap::new();

    for i in s.replace("\n", "").replace(" ", "").chars() {
        if i == 'Y' {
            println!("Four");
            return 0;
        }
    }
    println!("Three");
    return 0;
}

fn main() {
    // solve();
    let _ = read();
    let s = read_line_str();
    let mut hmap: HashMap<char, i32> = HashMap::new();

    for i in s.replace("\n", "").replace(" ", "").chars() {
        let mut n: i32 = 0;
        match hmap.get(&i) {
            Some(k) => n = *k,
            None => (),
        }
        hmap.insert(i, n + 1);
    }

    // for (k, v) in hmap.drain() {
    //     println!("{}:{}", k, v);
    // }

    if hmap.keys().len() == 3 {
        println!("Three");
    } else {
        println!("Four");
    }
}

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// fn read_line() -> (i32, i32) {
//     let mut s = String::new();
//     std::io::stdin().read_line(&mut s).ok();
//     let v : Vec<i32> = s.trim()
//         .split_whitespace()
//         .map(|e| e.parse().ok().unwrap())
//         .collect();
//     return (v[0], v[1]);
// }

fn read_line_str() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s;
}


Measured memory_bytes: 4352
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        string[] input = ReadLine().Split(' ');
        int A1 = int.Parse(input[0]);
        int A2 = int.Parse(input[1]);
        int A3 = int.Parse(input[2]);
        if(A1 + A2 + A3 > 21)
        {
            WriteLine("bust");
        }
        else
        {
            WriteLine("win");
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s, t;
  int q;
  cin >> s >> t >> q;
  vector<int> x(s.size()+1), y(t.size()+1);
  rep(i, s.size()) {
    x[i+1] = x[i]+1;
    if (s[i] == 'B')
      x[i+1]++;
  }
  rep(i, t.size()) {
    y[i+1] = y[i]+1;
    if (t[i] == 'B')
      y[i+1]++;
  }
  rep(i, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    --a, --c;
    int res = (x[b]-x[a])-(y[d]-y[c]);
    if (res%3)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}

Measured memory_bytes: 1744
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	long H = Long.parseLong(sc.next());
	long W = Long.parseLong(sc.next());
	long min = Long.MAX_VALUE;

	long lmin = Long.MAX_VALUE;
	long lmax = Long.MIN_VALUE;

	for(long i = 1; i<H; i++) {
	    // horizon
	    long middle = (H - i)/2;
	    lmin = Math.min(middle, i)*W;
	    lmax = Math.max(H-i-middle, i)*W;
	    min = Math.min(lmax- lmin, min);
	    // vertical
	    middle = W/2;
	    lmin = Math.min(middle*(H-i), i*W);
	    lmax = Math.max((W-middle)*(H-i),i*W);
            min= Math.min(lmax- lmin, min);
	}

	for(long i = 1; i<W; i++) {
            // vertical
	    long middle = (W - i)/2;
            lmin = Math.min(middle, i)*H;
	    lmax = Math.max(W-i-middle,i)*H;
            min= Math.min(lmax- lmin, min);
            // horizon
            middle = H/2;
            lmin = Math.min(middle*(W-i), i*H);
            lmax = Math.max((H-middle)*(W-i),i*H);
            min= Math.min(lmax- lmin, min);
	}

	System.out.println(min);
    }
}

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

int main(){
  string s;
  cin >> s;
  
  bool A=false,C=false,low=true;
  int idC=100;
  
  if(s[0]=='A') A=true;
  
  rep(i,s.length()-3){
    if(s[i+2]=='C'){
      if(i+2 > idC){
        C=false;
        break;
      }else{
        C=true;
        idC=i+2;
      }
    }
  }
  
  rep(i,s.length()){
    if(i==0 || i==idC){
      continue;
    }else{
      if(isupper(s[i])){
        low=false;
        break;
      }
    }
  }
  
  bool ac = A && C && low;
  if(ac) cout << "AC" << endl;
  else cout << "WA" << endl;
  
  return 0;
  
}


Measured memory_bytes: 384
#include <iostream>

using namespace std;
int selection_sort(int xs[], int n){
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        int mini = i;
        for(int j = i; j < n; ++j){
            if(xs[j] < xs[mini]){
                mini = j;
            }
        }
        if(mini != i){
            ++cnt;
            swap(xs[i], xs[mini]);
        }
    }
    return cnt;
}

template <class T>
void print_array(T xs[], int n){
    for(int i = 0; i < n-1; ++i){
        cout << xs[i] << ' ';
    }
    cout << xs[n-1] << '\n';
}

int main(){
    int n;
    cin >> n;
    int xs[n];
    for(int i = 0; i < n; ++i){
        cin >> xs[i];
    }
    int cnt = selection_sort(xs, n);
    print_array(xs, n);
    cout << cnt << '\n';
}

Measured memory_bytes: 1156
n = int(input())
a = list(map(int, input().split()))
flag = 0
b = 1

if 0 in a:
  print(0)
else:
  for i in range(n):
    b *= a[i]
    if b > 10**18:
      flag = 1
      break
  if b > 10**18:
    print(-1)
  else:
    print(b)

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

int main() {
    int n, m;
    std::cin >> n >> m;

    auto que = std::priority_queue<uint64_t>();
    
    for(int i = 0; i < n; ++i) {
        uint64_t a;
        std::cin >> a;
        que.push(a);
    }

    for(int i = 0; i < m; ++i) {
        const auto a = que.top() / 2;
        que.pop();
        que.push(a);
    }

    uint64_t answer = 0;
    while (que.size())
    {
        answer += que.top();
        que.pop();
    }

    std::cout << answer;

    return 0;
}


Measured memory_bytes: 1400
n=int(input())
s=input()
res=0
for i in range(1,n):
    a=s[:i]
    b=s[i:]
    sum=0
    for j in range(97,123):
        x=chr(j)
        if x in a and x in b:
            sum+=1
    res=max(sum,res)
print(res)

Measured memory_bytes: 9004
<?php

$num = trim(fgets(STDIN));
$arr = explode(' ', trim(fgets(STDIN)));

sort($arr);

$ret = 0.0;
for ($i = 0;$i < $num - 1;$i++) {
    for ($j = $i + 2; $j < $num - 1; $j++) {
        $m1 = 1.0 * ($arr[$j + 1] + $arr[$j]) / ($arr[$i + 1] - $arr[$i]);
        $m2 = 1.0 * ($arr[$i + 1] + $arr[$i]) / ($arr[$j + 1] - $arr[$j]);
        
        $ret = max($ret, $m1);
        $ret = max($ret, $m2);
    }
}

print $ret;

Measured memory_bytes: 15484
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));
		String[] inputNumber = br.readLine().split(" ");

		int height =  Integer.parseInt(inputNumber[0]);
		int width =  Integer.parseInt(inputNumber[1]);
		int area = height * width;
		int totalLength = (height*2) + (width*2);
		System.out.println(area + " " + totalLength);
	}


}

Measured memory_bytes: 16892
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n,k;cin>>n>>k;
  long long arr[n]={0};for(int i=0;i<n;i++)cin>>arr[i];
  
  long long dp[k+1]={0};
  sort(arr,arr+n);
  long long min=arr[0];
  //0 lose
  //1 win
  for(int i=1;i<min && i<=k;i++)
  {
      dp[i]=0;
  }
  for(int i=min;i<=k;i++)
  {
      for(int j=0;arr[j]<=i && j<n;j++)
      {
          if(dp[i-arr[j]]==0)
          {
              dp[i]=1;//sure win
          }
      }
 //     cout<<dp[i]<<" ";
  }
 // cout<<dp[k]<<"\n";
 if(dp[k]==1)
 {
     cout<<"First";
 }
 else
 {
     cout<<"Second";
 }
  return 0;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0036
{
    class Program
    {
        static void Main(string[] args)
        {
            Figure figure = new Figure();
            string input;

            input = figure.Input();
            Console.WriteLine(figure.IsShape(input));
            while (Console.ReadLine()!=null)
            {

                input = figure.Input();
                Console.WriteLine(figure.IsShape(input));
            }


        }
    }
    class Figure
    {
        public string Input()
        {
            string str = "";
            for (int i = 0; i < 8; ++i)
            {
                str += Console.ReadLine();
            }
            return str;
        }
        public string IsShape(string input)
        {
            string A = "1100000011";
            string B = "1000000010000000100000001";
            string C = "1111";
            string D = "1000000110000001";
            string E = "11000000011";
            string F = "100000001100000001";
            string G = "110000011";
            if (input.Contains(A))
            {
                return "A";
            }
            if (input.Contains(B))
            {
                return "B";
            }
            if (input.Contains(C))
            {
                return "C";
            }
            if (input.Contains(D))
            {
                return "D";
            }
            if (input.Contains(E))
            {
                return "E";
            }
            if (input.Contains(F))
            {
                return "F";
            }
            if (input.Contains(G))
            {
                return "G";
            }
            else
            {
                return "Miss";
            }
        }
    }
}



Measured memory_bytes: 15816
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};



int main(){
    LL a,b,n;cin >> a >> b >> n;
    cout << a * min(n, b - 1) / b << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
//	freopen(".in","r",stdin);
	int x;
	scanf("%d",&x);
	if(x==7||x==5||x==3)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int X,Y;
  cin>>X>>Y;
  int ANS = 1;
  int Z = 0;
  while(Z <= Y)
  {
    Z = pow(2,ANS)*X;
    ANS++;
  }
  ANS--;
  cout<<ANS<<endl;
  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector <int> a(N);
  for(int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int sumA=0;
  int sumB=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      sumA+=a.at(i);
    }else{
      sumB+=a.at(i);
    }
  }
  cout << sumA-sumB << endl;
  return 0;
}


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

import sys
import os
import math

for s in sys.stdin:
    d, w, h = map(int, s.split())
    if d == w == h == 0:
        break

    lst = [d, w, h]
    lst.sort()
    diameter = math.sqrt(lst[0] ** 2 + lst[1] ** 2)

    n = int(input())

    for i in range(n):
        r = int(input())
        if 2 * r > diameter:
            print('OK')
        else:
            print('NA')

Measured memory_bytes: 7640
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int A,B,K;
	scan(A);scan(B);scan(K);
	rep(i,K){
		if(i%2==0){
			A-=A%2;
			B+=A/2;
			A-=A/2;
		}
		else{
			B-=B%2;
			A+=B/2;
			B-=B/2;
		}
	}
	printf("%d %d\n",A,B);
	return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

const int MOD = int(1e9) + 7;

int n;
int a[1000] = {};

int main() {
    scanf("%d", &n);
    for (int i = 2; i <= n; ++i) {
        int rem = i;
        for (int j = 2; rem > 1; ++j) {
            while (rem % j == 0) {
                ++a[j];
                rem /= j;
            }
        }
    }
    int ans = 1;
    forn(i, 1000) {
        ans = (LL)ans * (a[i] + 1) % MOD;
    }
    cout << ans << endl;
    return 0;
}


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

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		int N = sc.nextInt();
		long S = sc.nextInt();
		long[] x = new long[N], p = new long[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
			p[i] = sc.nextInt();
		}
		int left = 0, right = N - 1;
		long[] order = new long[N];
		int idx = 0;
		while (x[left] < S && S < x[right]) {
			if (p[left] >= p[right]) {
				order[idx++] = x[right];
				p[left] += p[right];
				right--;
			} else {
				order[idx++] = x[left];
				p[right] += p[left];
				left++;
			}
		}
		while (right >= 0 && S < x[right]) {
			order[idx++] = x[right];
			right--;
		}
		
		while (left < N && x[left] < S) {
			order[idx++] = x[left];
			left++;
		}
		long ans = 0;
		for (int i = N - 1; i >= 0; i--) {
			ans += Math.abs(order[i] - S);
			S = order[i];
		}
		System.out.println(ans);
	}
}


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

int main(){
	int a,b,c,n;
	cin >> a >> b >> c;
	if(a>b){
		n=a;
		a=b;
		b=n;
	}
	if(b>c){
		n=b;
		b=c;
		c=n;
	}
	if(a>b){
		n=a;
		a=b;
		b=n;
	}
	cout << a << " "<< b << " " << c << endl;
	
	return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define IO() assert(freopen("in.in", "rt", stdin)),assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false);
#define debug(x) cout << __LINE__ << ": " << #x << " = " << (x) << endl

typedef long long ll;
const ll MOD=1e9+7;
const int N = 1e7+9, M = 1e5+9, OO = 0x3f3f3f3f;
const double EPS = 1e-10;

// inline int readi(){int n;scanf("%d", &n);return n;}
// inline ll readll(){ll n;scanf("%lld", &n);return n;}
// inline char readc(){char c;scanf("%c ", &c);return c;}
// inline double readd(){double n;scanf("%lf", &n);return n;}
inline bool dCMP(const long double& a, const long double& b){return fabsl(a-b)<EPS;}
pair<int,int> arr[N];
int main()
{
	// #ifdef _LOCAL_DEFINE
	// IO();
	// #endif
	int n,k;
	scanf("%d%d",&n,&k);
	int ans = ((n-1)*(n-2))/2;
	if(k>ans)
	{
		printf("-1\n");
		return 0;
	}
	printf("%d\n",n-1+ans-k);
	ans+=(n-1-k);
	for(int i=1;i<=n;++i) 
		for(int j=i+1;j<=n;++j)
			{
				if(ans--) printf("%d %d\n",i,j); 
				else
				{
					//printf("%d %d\n",i,j);
					return 0;
				}
			}

	
	return 0;
}

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

std::function<int(int, int)> CharcterToOperate(char Character)
{
    if(Character == '+') return [](int X, int Y){return X + Y;};
    if(Character == '-') return [](int X, int Y){return X - Y;};
    if(Character == '*') return [](int X, int Y){return X * Y;};
    return [](int X, int Y){return X / Y;};
}

int main()
{
    while(true){
        int X, Y;
        char Op;
        std::cin >> X >> Op >> Y;
        if(Op == '?') return 0;
        std::cout << CharcterToOperate(Op)(X, Y) << std::endl;
    }
}


Measured memory_bytes: 3084
import math
n = int(input())
x = list(map(int,input().split()))
sums = sum(x)
xsort = sorted(x,reverse=True)
temp = math.ceil((n-1)/2)
if n % 2 == 0:
    medi = xsort[temp]
else:
    medi = xsort[n//2]

medi2 = xsort[temp-1]

for i in range(n):
    if x[i] <= medi:
        print(medi2)
    else:
        print(medi)

Measured memory_bytes: 25220
#include<bits/stdc++.h>
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define pb push_back
#define sz(x) (int)x.size()
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define F first
#define S second
#define watch(x) cerr << "\n" << (#x) << " = " << (x) << "\n"
using namespace std;
ll h, w, dp[1005][1005];
char a[1005][1005];

int main(){
	ios_base::sync_with_stdio(0);
    cin.tie(0); 
    cout.tie(0);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	cin >> h >> w;
	for(int i = 1; i <= h; ++i){
		for(int j = 1; j <= w; ++j){
			cin >> a[i][j];
		}
	}

	dp[1][1] = 1;
	for(int i = 2; i <= h; ++i){
		if(a[i][1] == '#')
			break;
		dp[i][1] = 1;
	}

	for(int i = 2; i <= w; ++i){
		if(a[1][i] == '#')
			break;
		dp[1][i] = 1;
	}

	for(int i = 2; i <= h; ++i){
		for(int j = 2; j <= w; ++j){
			if(a[i][j] == '.'){
				dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod;
			}
		}
	}

	cout << dp[h][w];
	return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

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

  int n;
  cin >> n;
  vector<vector<int>>rec(10, vector<int>(10));
  for (int i = 1; i <= n; i++) {
    int t = ((i / 100000 > 0) ? i / 100000 : ((i / 10000 > 0) ? i / 10000 : ((i / 1000 > 0) ? i / 1000 : ((i / 100 > 0) ? i / 100 :((i / 10 > 0) ? i / 10: i)))));
    if (t == 0) cout << i << endl;
    rec[t][i%10]++;
  }  

  ll ans = 0;
  for (int i = 0 ; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      ans += rec[i][j] * rec[j][i];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256