akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;


int main()
{
    ll n;
    cin>>n;
    ll ans =0;
    for(int i=0;i<n;i++)
    {
        ll temp;
        cin>>temp;
        temp--;
        ans+= temp;
    }
    cout<<ans;
}

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

int main(){
  
  int n;
  cin>>n;
  long long a[n],cn,cr;
  double cn2;
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a,a+n);
  reverse(a,a+n);
  cn=a[0];
  cn2=a[0];
  pair<double,long long> P[n];
  for(int i=0;i<n;i++){
    P[i].first=abs(a[i]-cn2/2);
    P[i].second=a[i];
  }
  sort(P,P+n);
  cr=P[0].second;
  cout<<cn<<" "<<cr<<endl;
}

Measured memory_bytes: 2560
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;

public class Program
{

	public void Proc()
	{
        int inputCount = int.Parse(Reader.ReadLine());

        long[] inpt = Reader.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        int ans = 0;

        int idx = 0;
        while(idx<inpt.Length) {
            if(inpt[idx]==idx+1) {
                if(idx<inpt.Length-1&&inpt[idx+1]==idx+2) {
                    idx += 2;
                } else {
                    idx++;
                }
                ans++;
            } else {
                idx++;
            }
        }
        Console.WriteLine(ans);
    }


    public class Reader
	{
		private static StringReader sr;
		public static bool IsDebug = false;
		public static string ReadLine()
		{
			if (IsDebug)
			{
				if (sr == null)
				{
					sr = new StringReader(InputText.Trim());
				}
				return sr.ReadLine();
			}
			else
			{
				return Console.ReadLine();
			}
		}
		private static string InputText = @"



5
1 4 3 5 2


";
	}

	public static void Main(string[] args)
	{
#if DEBUG
		Reader.IsDebug = true;
#endif
		Program prg = new Program();
		prg.Proc();
	}
}


Measured memory_bytes: 23136
//84104971101048411497 - Can you guess what does this mean?
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef complex<double> point;
#define mapii map<int, int>
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) fto(i, l, r) cout << a[i] << " "; cout << endl
#define fdto(i, r, l) for(int i = (r); i >= (l); --i)
#define fto(i, l, r) for(int i = (l); i <= (r); ++i)
#define forit(it, var) for(__typeof(var.begin()) it = var.begin(); it != var.end(); it++)
#define forrit(rit, var) for(__typeof(var.rbegin()) rit = var.rbegin(); rit != var.rend(); rit++)
#define ii pair<int, int>
#define iii pair<int, ii>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define maxN 1005
#define oo 1000000000000000007LL
#define sz(a) (int)a.size()

const double PI = acos(-1.0);

double fRand(double fMin, double fMax)
{
    double f = (double)rand() / RAND_MAX;
    return fMin + f * (fMax - fMin);
}

template <class T>
T min(T a, T b, T c) {
    return min(a, min(b, c));
}

template <class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int main () {
    int n; scanf("%d", &n);

    if (n == 3) {
        puts("2 5 63");
        return 0;
    }

    vector<int> ans;

    int sum = 0;
    fto(i, 1, 30000) {
        if (sz(ans) == n-1) break;
        if ((i%2 == 0 || i%3 == 0) && (sz(ans) < n-2 || ((sum+i)%6 != 1 && (sum+i)%6 != 5))) {
            sum += i;
            ans.pb(i);
        }
    }

    fto(i, ans.back()+1, 30000) {
        if ((i%2 == 0 || i%3 == 0) && (sum+i)%6 == 0) {
            ans.pb(i);
            break;
        }
    }

    for(int x: ans) printf("%d ", x);

    return 0;
}


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

bool f_card(int *check);
bool f_house(int *check);
bool straight(int *check);
bool t_card(int *check);
bool t_pair(int *check);
bool o_pair(int *check);

int main()
{
  int c;
  
  while (~scanf("%d", &c)){
    int check[18] = {0};
    check[c]++;
    for (int i = 0; i < 4; i++){
      scanf(",%d", &c);
      check[c]++;
    }

    if (f_card(check)){
      printf("four card\n");
    }
    else if (f_house(check)){
      printf("full house\n");
    }
    else if (straight(check)){
      printf("straight\n");
    }
    else if (t_card(check)){
      printf("three card\n");
    }
    else if (t_pair(check)){
      printf("two pair\n");
    }
    else if (o_pair(check)){
      printf("one pair\n");
    }
    else {
      printf("null\n");
    }
  }

  return (0);
}

bool f_card(int *check)
{
  for (int i = 1; i <= 13; i++){
    if (check[i] == 4){
      return (true);
    }
  }

  return (false);
}

bool f_house(int *check)
{
  bool three = false, two = false;

  for (int i = 1; i <= 13; i++){
    if (check[i] == 3){
      three = true;
    }
    if (check[i] == 2){
      two = true;
    }
  }

  if (three && two){
    return (true);
  }
  else {
    return (false);
  }
}

bool straight(int *check)
{
  for (int i = 1; i <= 13; i++){
    if (check[i] == 1){
      if (check[i + 1] && check[i + 2] && check[i + 3] && check[i + 4]){
        return (true);
      }
      if (i == 10 && check[11] && check[12] && check[13] && check[1]){
        return (true);
      }
    }
  }

  return (false);
}

bool t_card(int *check)
{
  for (int i = 1; i <= 13; i++){
    if (check[i] == 3){
      return (true);
    }
  }

  return (false);
}

bool t_pair(int *check)
{
  for (int i = 1; i <= 13; i++){
    if (check[i] == 2){
      for (int j = 1; j <= 13; j++){
        if (j != i && check[j] == 2){
          return (true);
        }
      }
      break;
    }
  }

  return (false);
}

bool o_pair(int *check)
{
  for (int i = 1; i <= 13; i++){
    if (check[i] == 2){
      return (true);
    }
  }

  return (false);
}

Measured memory_bytes: 1168
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <functional>
# include <utility>
# include <queue>
# include <stack>
# define MOD 1000000007
# define INF 2000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
std::vector<bool> IsPrime;
typedef pair<int, int>P;



long long  counter = 0, maxi = -1, mini = INF, pass = 0;
	//new
	char maze[20][20];
	int n, m;
	int s_x, s_y;
	int d[20][20];
	int dx[4] = { 1,0,-1,0 }, dy[4] = {0,1,0,-1};
	int nx, ny;

int bfs(int sx,int sy) {
	queue<P> que;
	rep(i, n) {
		rep(j, m) {
			d[i][j] = INF;
		}
	}
	que.push(P(sx, sy));
	d[sx][sy] = 0;
	while (que.size()) {
		P p = que.front(); 
		que.pop();
		rep(i, 4) {
			nx = p.first + dx[i];
			ny = p.second + dy[i];

			if (0 <= nx && nx < n && 0 <= ny && ny < m && maze[nx][ny] != '#' && d[nx][ny] == INF) {
				que.push(P(nx, ny));
				d[nx][ny] = d[p.first][p.second] + 1;
			}
		}
	}

	/*
	cout << sx <<" "<< sy << endl;
	rep(i, n) {
		rep(j, m) {
			if (d[i][j] == INF) {
				cout << "IN";
			}
			else {
				cout << d[i][j];
			}
		}
		cout << endl;
	}
	cout << endl;
	*/

	int max_this=-1;
	rep(i, n) {
		rep(j, m) {
			if (d[i][j] != INF) {
				max_this = max(d[i][j], max_this);
			}
		}
	}
	return max_this;
}
int main() {
cin >> n >> m;
rep(i, n) {
	rep(j, m) {
		cin >> maze[i][j];
	}
}
rep(k, n) {
	rep(l, m) {
		if (maze[k][l] != '#') {
			maxi = max((int)maxi, bfs(k, l));
		}
	}
}
cout << maxi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,k,n) for(int i=k;i<n;i++)
using namespace std;

vector<int> f(110,0);
int p[110][11] = {0};
int n;
int calc(int b){
  int res = 0;
  rep(i,n){
    bitset<16> t = b&f[i];
    res += p[i][t.count()];
  }
  return res;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);


  cin >> n;
  rep(i,n){
    rep(j,10){
      f[i]<<=1;
      int t;
      cin >> t;
      if(t!=0) f[i]|=1;
    }
  }
  rep(i,n){
    rep(j,11){
      cin >> p[i][j];
    }
  }
  int ans = -(1<<30);
  for(int i = 1;i<pow(2,10);i++){
    ans = max(calc(i),ans);
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
	long long n, xx = 0, yy = 0, hh = 0; cin >> n;
	long long x[105], y[105], h[105];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i] >> h[i];
		if (h[i] >= 1) { xx = x[i], yy = y[i], hh = h[i]; }
	}

	for (int xi = 0; xi <= 100; xi++) {
		for (int yi = 0; yi <= 100; yi++) {
			bool ok = true;
			long long hi = max(abs(xx - xi) + abs(yy - yi) + hh, 0LL);
			for (int i = 0; i < n; i++) {
				if (max(hi - abs(x[i] - xi) - abs(y[i] - yi),0LL) != h[i])ok = false;
			}
			if (ok) {
				cout << xi << ' ' << yi << ' ' << hi << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(void){
  int N, max=0, sum=0, p;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> p;
    sum += p;
    max = std::max(max, p);
  }

  cout << sum - max/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lo(i, a, b) for(int i=a; i<b; i++)
#define sz(x) x.size()
#define nl cout<<"\n";
#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main()
{
    su;
    string s,t;
    cin>>s;
    int l=sz(s);
    lo(i,0,l)
    {
      if(s[i]!='B')
         t+=s[i];
      if(s[i]=='B'&&t.empty()==false)
         t.pop_back();
    }
    cout<<t;
    nl;
    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);
    
    int a, b; cin >> a >> b;
    cout << gcd(a, b) << endl;
    

    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

void temp(int *x, int *y)
{
	int temp;
	temp = *x;
	*x = *y;
	*y = temp;
}

int main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];

	int counter = 0;
	for (int i = 0; i < n; ++i)
	{
		int min = a[i];
		int min_n = i;
		for (int j = i+1; j < n; ++j)
		{
			if(min > a[j])
			{
				min = a[j];
				min_n = j;
			}
		}
		if(i != min_n)
		{
			temp(&a[i],&a[min_n]);
			counter++;
		}
	}
	for (int i = 0; i < n-1; ++i)
		cout << a[i] << " ";
	cout << a[n-1] << endl;
	cout << counter << endl;

	return 0;
}


Measured memory_bytes: 3100
from collections import deque
n,k = map(int,input().split())
r,s,p = map(int,input().split())
t = input()

q = deque([])
points = 0
for i in range(n):
    if i <= k-1:
        if t[i] == 'r':
            points += p
            q.append('p')
        elif t[i] == 's':
            points += r
            q.append('r')
        elif t[i] == 'p':
            points += s
            q.append('s')
    else:
        ban = q.popleft()
        if t[i] == 'r':
            if ban != 'p':
              points += p
              q.append('p')
            else:
                q.append('x')
        elif t[i] == 's':
            if ban != 'r':
              points += r
              q.append('r')
            else:
                q.append('x')
        elif t[i] == 'p':
            if ban != 's':
              points += s
              q.append('s')
            else:
                q.append('x')
                
print(points)

Measured memory_bytes: 9896
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
using ll = long long;
using P = pair<int, int>;
using LP = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

vector<vector<LP>> to;
vl color;

void dfs(int v, int p, int pc) {
    if (p != -1 && to[v].size() == 1) return;

    int c = 1;
    for (auto nv : to[v]) {
        if (p == nv.fi) continue;
        if (c == pc) c++;
        color[nv.se] = c;
        dfs(nv.fi, v, c);
        c++;
    }
}

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

    int n;
    cin>>n;
    to = vector<vector<LP>>(n);
    rep(i, n - 1) {
        ll v1, v2;
        cin>>v1>>v2; v1--; v2--;

        to[v1].emplace_back(v2, i);
        to[v2].emplace_back(v1, i);
    }
    int ans = 0;
    rep(i, n) {
        chmax(ans, sz(to[i]));
    }
    cout<<ans<<endl;
    color = vl(n - 1);
    dfs(0, -1, -1);
    rep(i, n - 1) cout<<color[i]<<endl;
}

Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  int n;
  cin >> n;
  vector<set<int>> a(26);
  string s;
  cin >> s;
  rep(i,n){
    int f=s[i]-'a';
    a[f].insert(i);
  }
  int q;
  cin >> q;
  rep(ii,q){
    int r;
    cin >> r;
    if (r==1){
      int f;
      char g;
      cin >> f >> g;
      int d=s[f-1]-'a';
      int dd=g-'a';
      s[f-1]=g;
      a[d].erase(f-1);
      a[dd].insert(f-1);
    }
    if (r==2){
      int f,g,ans=0;
      cin >> f >> g;
      f--;
      g--;
      rep(i,26){
        auto it=a[i].lower_bound(f);
        if (it!=a[i].end()){
          if (*it<=g) ans++;
        }
      }
      cout << ans << endl;
    }
  }
}


Measured memory_bytes: 24196
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    ArrayList<BigInteger> a = new ArrayList<>();
    for (int i = 0; i < n; i++) {
      a.add(new BigInteger(sc.next()));
    }
    a.sort(Comparator.comparing(BigInteger::longValue).reversed());
    if (n == 2) {
      System.out.println(a.get(0));
      return;
    }
    BigInteger result = a.get(0);
    for (int i = 2; i < n; i++) {
      result = result.add(a.get(i / 2));
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 69692
bingo = []
for i in range(3):
    bingo.extend(list(map(int,input().split())))

n = int(input())

b = []

for j in range(n):
    b.append(int(input()))
    
for k in range(9):
    for l in b:
        if bingo[k] == l:
            bingo[k] = 0
            
flag = 0

if (bingo[0] == 0 and bingo[1] == 0 and bingo[2] == 0) or (bingo[3] == 0 and bingo[4] == 0 and bingo[5] == 0) or (bingo[6] == 0 and bingo[7] == 0 and bingo[8] == 0):
    flag = 1

if (bingo[0] == 0 and bingo[3] == 0 and bingo[6] == 0) or (bingo[1] == 0 and bingo[4] == 0 and bingo[7] == 0) or (bingo[2] == 0 and bingo[5] == 0 and bingo[8] == 0):
    flag = 1

if (bingo[0] == 0 and bingo[4] == 0 and bingo[8] == 0) or (bingo[2] == 0 and bingo[4] == 0 and bingo[6] == 0):
    flag = 1
    
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using M = map<string,ll>;

ll MAX=1000007;
ll MOD=1000000007;
vector<ll> F(MAX,1);

void T(){
    for(int i=1;i<MAX;i++){
        F[i]=F[i-1]*i%MOD
    ;}
    return;
}
// mod. m での a の逆元 a^{-1} を計算する
//ただしmとaが互いにその時のみ
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}




int main(){
    T();
    ll X;
    cin >> X;
    ll Y ;
    cin >> Y ;
    ll ans=0;

    if(!(2*Y-X>=0&&(2*Y-X)%3==0&&2*X-Y>=0&&(2*X-Y)%3==0)){}
    else {ll x=(2*Y-X)/3,y=(2*X-Y)/3;
    ans=(F[x+y]*modinv(F[x],MOD)%MOD)*modinv(F[y],MOD)%MOD;}

cout<<ans<<endl;

return 0;


}  



Measured memory_bytes: 8192
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
import java.util.stream.Stream;

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

        int res = 0;

        while(true){
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();

            if (op.equals("?")) break;

            switch(op){
                case "+":
                    res = a + b;
                    break;
                case "-":
                    res = a - b;
                    break;
                case "*":
                    res = a * b;
                    break;
                case "/":
                    res = a / b;
                    break;
                default:
                    break;
            }
            System.out.println(res);
        }
    }
}



Measured memory_bytes: 26176
n, k, q = map(int, input().split())

cin =[0]*n
ans=[0]*n
cnt =0

for _ in range(q):
    a = int(input())
    cin[a-1] += 1

cnt = max(cin)

for i in range(n):
    ans[i] = k - q + cin[i]
    if ans[i] > 0:
        print('Yes')
    else:
        print('No')

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

int main(){
    int N;
    long long int Y;
    cin >> N >> Y;
    int sen = -1, man = -1, gosen = -1;
    
    for(int i = 0;i <= N;i++){
        for(int j = 0;j <= N - i;j++){
            if( Y == (10000*i)+(5000*j)+(1000*(N-i-j))){
                man = i;
                gosen = j;
                sen = N -i -j;
                break;
            }
        }
        if (man != -1)break;
    }
    cout << man << " " << gosen << " " << sen << endl;
}

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

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());
    int M = Integer.parseInt(sc.next());
    int[][] p = new int[M][3];

    for (int i = 0; i < M; i++) {
      p[i][0] = i;
      p[i][1] = Integer.parseInt(sc.next());
      p[i][2] = Integer.parseInt(sc.next());
    }

    sc.close();

    Arrays.sort(p, (o1, o2) -> o1[1] == o2[1] ? o1[2] - o2[2] : o1[1] - o2[1]);

    Map<Integer, Integer[]> map = new HashMap<>();

    int now = 0;
    int count = 1;

    for (int i = 0; i < M; i++) {
      if(now == p[i][1]){
        count++;
      } else {
        now = p[i][1];
        count = 1;
      }
      Integer[] c = {p[i][1], count};
      map.put(p[i][0],c);
    }

    PrintWriter out = new PrintWriter(System.out);
    
    for (int i = 0; i < M; i++) {
      Integer[] r = map.get(i);
      out.println(String.format("%06d%06d", r[0], r[1]));
    }
    
    out.flush();

  }

}

Measured memory_bytes: 114672
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

using Graph = vector<vector<int>>;

const int INF = 1LL << 60;
int N;
vector<int> P, X, dp;
Graph G;

void dfs(int v) {
    int cur = 0;
    vector<vector<int>> dp2(2, vector<int>(X[v] + 1, INF));
    dp2[cur][0] = 0;
    for (int nv : G[v]) {
        dfs(nv);
        fill(dp2[cur ^ 1].begin(), dp2[cur ^ 1].end(), INF);
        for (int i = 0; i <= X[v]; ++i) if (dp2[cur][i] != INF) {
            if (i + X[nv] <= X[v]) dp2[cur ^ 1][i + X[nv]] = min(dp2[cur ^ 1][i + X[nv]], dp2[cur][i] + dp[nv]);
            if (i + dp[nv] <= X[v]) dp2[cur ^ 1][i + dp[nv]] = min(dp2[cur ^ 1][i + dp[nv]], dp2[cur][i] + X[nv]);
        }
        cur ^= 1;
    }
    for (int i = 0; i <= X[v]; ++i) {
        dp[v] = min(dp[v], dp2[cur][i]);
    }
}

void _main() {
    cin >> N;
    P.resize(N - 1);
    X.resize(N);
    G.resize(N);
    REP (i, N - 1) {
        cin >> P[i];
        P[i]--;
        G[P[i]].push_back(i + 1);
    }
    REP (i, N) cin >> X[i];
    dp.resize(N, INF);
    dfs(0);
    cout << (dp[0] != INF ? "POSSIBLE" : "IMPOSSIBLE") << endl;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}

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

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	int cnt = 0;
	while(1){
		if(a % 2 || b % 2 || c % 2) break;
		int d = (a+b)/2;
		int e = (a+c)/2;
		int f = (c+b)/2;
		a=d;
		b=e;
		c=f;
		cnt++;
		if(a == b && a == c){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<stack>
#include<queue>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<math.h>
using namespace std; 
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define pp(...) "\033[94m [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define dg1(x) debug() << pp(x)
#define dg2(x,y) debug() << pp(x) pp(y)
#define dg3(x,y,z) debug() << pp(x) pp(y) pp(z)
#define dg4(w,x,y,z) debug() << pp(w) pp(x) pp(y) pp(z)
#define msg(x) debug() << x
#define int long long
#define sz(a) ((a).size())
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};

const int xx = 2e5;
const int MOD = 1e9 + 7;
int lcm(int a, int b){
  return  a * (b/__gcd(a,b));
}

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

    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
      a[i] = i + 1;
    }
    vector<int>p(n),q(n);
    for(int i=0;i<n;i++){
      cin >> p[i];
    }
    for(int i=0;i<n;i++){
      cin >> q[i];
    }
    int A = 0 , B = 0;
    int cnt = 0;
    while(next_permutation(a.begin() , a.end())){
      cnt++;
      if(a == p){
        A = cnt;
      }
      if(a == q){
        B = cnt;
      }
    //  dg1(a);


    }

    cout << abs(A - B) << '\n';

}


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

using namespace std;


int main(int argc, char** argv){
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    int sum = 0;
    for (int i=0; i<N; i++) cin >> V[i];
    for (int i=0; i<N; i++) cin >> C[i];
    for (int i=0; i<N; i++) V[i] -= C[i];
    for (int i=0; i<N; i++) if (V[i] > 0) sum += V[i];
    cout << sum << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
using namespace std;
int N[4][3][10];
int main() {
	int n,b,f,r,v;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> b >> f >> r >> v;
		N[b-1][f-1][r-1] += v;
	}
	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				if (k == 9) {
					cout << " " << N[i][j][k] << endl;
				}
				else {
					cout << " " << N[i][j][k];
				}
			}
		}
		if (i != 3) {
			for (int l = 0; l < 20; l++) {
				cout << '#';
			}
			cout << endl;
		}
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
int gcd(int a,int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
/*
*/

int main() {
   int N;
   cin >> N;
   vector<ll> A(N);
   rep(i,N){
       cin >> A[i];
   }
   sort(A.begin(),A.end());

   vector<ll> sum(N);
   sum[0] = A[0];

   rep(i,N-1){
       sum[i+1] = sum[i] + A[i+1];
   }
   int count = 0;//全ての生物を吸収できない生物の数
   rep(i,N-1){
       if(sum[i]*2 < A[i+1]) count = i+1;
   }

   cout << N - count << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
using ull = unsigned long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int Sum(const string&s){
  int n = (int)s.size();
  int sum = 0;
  for(int i = 0; i < n; ++i)sum += s[i] - '0';
  return sum;
}

int main(){
  string a,b; cin >> a >> b;
  int n = stoi(a+b);
  bool f = false;
  for(int i = 1; i * i <= n; ++i){
    f |= i*i == n;
  }
  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3576
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		int a[] = new int[n];
		for(int i=0; i<n; i++) {
			a[i]=sc.nextInt();
		}
		int l[] = new int[n+1];
		int r[] = new int[n+1];
		l[0]=0;
		r[n]=0;
		for(int i=0; i<n; i++) {
			l[i+1] = gcd(a[i], l[i]);
		}
		for(int i=n-1; i>=0; i--) {
			r[i] = gcd(a[i], r[i+1]);
		}
		int max = -1;
		for(int i=0; i<n; i++) {
			max = Math.max(max, gcd(l[i], r[i+1]));
		}
		System.out.println(max);
		sc.close();
	}

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

}


Measured memory_bytes: 49692
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
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; }
const long long INF = 1LL<<60;

// input
int N;
long long W, weight[110], value[110];

// DP table
long long dp[110][100100] = {0};

int main() {
    cin >> N >> W;
    for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

    // DP loop
    for (int i = 0; i < N; ++i) {
        for (int sum_w = 0; sum_w <= W; ++sum_w) {
            
            // choose ith goods
            if (sum_w - weight[i] >= 0) {
                chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
            }

            // not choose ith goods
            chmax(dp[i+1][sum_w], dp[i][sum_w]);
        }
    }

    // output optimal value
    cout << dp[N][W] << endl;
    return 0;
}

Measured memory_bytes: 79360
n,*s=map(int,open(0).read().split())
s,t,f,g=[s[i-n:i]for i in range(n,4*n+1,n)]
ans=[n*[0]for _ in range(n)]
for b in range(64):
  e=1<<b
  u=[a&e for a in f]
  v=[a&e for a in g]
  l=[0]*n
  m=[0]*n
  for i in range(n):
    for j in range(n):
      if(u[i]&v[j])|((s[i]^1)*u[i])|((t[j]^1)*v[j]):ans[i][j]|=e;l[i]+=1;m[j]+=1
  for i in range(n):
    if s[i]*u[i]*(l[i]==0):
      for j in range(n):
        if(t[j]^1)*(n-m[j]>1):ans[i][j]|=e;m[j]+=1;break
  for j in range(n):
    if t[j]*v[j]*(m[j]==0):
      for i in range(n):
        if(s[i]^1)*(n-l[i]>1):ans[i][j]|=e;l[i]+=1;break
h=ans[0][:]
w=[i[0]for i in ans]
for i in range(n):
  for j in range(n):
    if s[i]:w[i]|=ans[i][j]
    else:w[i]&=ans[i][j]
    if t[j]:h[j]|=ans[i][j]
    else:h[j]&=ans[i][j]
if(g!=h)|(f!=w):print(-1);exit() 
for i in ans:print(*i)

Measured memory_bytes: 107028
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def gcd(a,b):
    if b==0:return a
    return gcd(b,a%b)


def main():
    x,y = list(map(int, input().split()))
    print(gcd(x,y))

main()



Measured memory_bytes: 5608
function Main(input) {
    var input = input.split('\n');
    var a = input.slice(1,input.length).map(n => parseInt(n));
    var Filter = a.filter((x, i, self) => self.indexOf(x) == i);
    var result = Filter.length;
    console.log(result);
    }
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;

int main(){
    int x,y,z,k,s,res=0;

    scanf("%d%d",&k,&s);

    for(int i=0;i<=k;i++){
        for(int j=0;j<=k;j++){
            if(s-i-j<=k && s-i-j>=0)
                res++;
        }
    }
    printf("%d\n",res);
    return 0;
}

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

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr int INF = 1001001001;

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

int main() {
    string s;
    cin >> s;
    
    if (s.back() == 's')
        cout << s << "es" << endl;
    else
        cout << s << "s" << endl;
    
    return 0;
}


Measured memory_bytes: 3620
def main():
 num = list(map(int,input().split()))
 if(num[0]>num[1]):
  if(num[1]!=1):
   print('Alice')
  else:
   print('Bob')
 elif(num[1]>num[0]):
  if(num[0]!=1):
   print('Bob')
  else:
   print('Alice')
 else:
   print('Draw') 

main()


Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<map>
#include<random>
#include<unordered_map>
#include<unordered_set>
#include<bitset>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldb = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney, tree, chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun

#define REP(i,a,b) for(ll i = a; i < b; ++i)
#define PRI(s) cout << s << endl
#define PRIF(v, n) printf("%."#n"f\n", v)
#define PRIY PRI("Yes")
#define PRIN PRI("No")
#define MINS(a,b) a = min(a,(decltype(a))(b))
#define MAXS(a,b) a = max(a,(decltype(a))(b))


int main() {
	ll N, S;
	cin >> N >> S;
	ll mod = 998244353;
	vector<ll> A(N);
	vector<vector<ll>> dp(N+1);
	REP(i, 0, N)cin >> A[i];
	REP(i, 0, N + 1)dp[i].resize(S + 1, 0);
	REP(i, 1, N + 1) {
		if (A[i - 1] <= S) dp[i][A[i - 1]] += i;
		REP(j, 1, S + 1) {
			if (A[i - 1] + j <= S) dp[i][j + A[i - 1]] += dp[i - 1][j];
			dp[i][j] += dp[i - 1][j];
		}
		REP(j, 1, S + 1) {
			dp[i][j] %= mod;
		}
	}
	ll ans = 0;
	REP(i, 1, N + 1) {
		ans += dp[i][S];
		ans %= mod;
	}
	PRI(ans);
	return 0;
}




Measured memory_bytes: 74032
#include <bits/stdc++.h>
using namespace std;
#define endk '\n'
#define vi vector<int>

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);

  int n;
  vi p, q;
  cin >> n;
  int e;
  while (n--) {
    cin >> e;
    p.push_back(e);
  }
  while (cin >> e)
    q.push_back(e);
  
  int ans = 0;
  while(lexicographical_compare(begin(p), end(p), begin(q), end(q))) {
    next_permutation(p.begin(), p.end());
    ans++;
  }
  while(lexicographical_compare(begin(q), end(q), begin(p), end(p))) {
    next_permutation(q.begin(), q.end());
    ans++;
  }
  cout << ans << endk;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define vi vector<int>
#define ppi pair<int,pi>
#define ld long double
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << end
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define f(i, begin, end) for (__typeof(end) i = (begin); i != (end) ; i += 1 - 2 * ((begin) > (end)))
#define nl cout<<"\n";
#define endl "\n"
#define par(a,n) f(i,0,n) cout<<a[i]<<" "; nl
//void prt(int x) {cerr << x;}
#define vv(n,m) vector <vector <int> > v(n, vector <int> (m));

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... brgs>
void err(istream_iterator<string> it, T a, brgs... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);	
}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef pair<int,int> pii;
typedef vector<pii> vpii;
const int mod = 1000000007;
const int N = 3e5;

int kadane(int*a, int n);
bool isPrime(int n);
int mpow(int a, int b);

void solve(){
  int n,k;
  cin>>n>>k;
  int a[n];
  f(i,0,n) cin>>a[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  for(int i=2;i<k&&i<n;i++){
      dp[i]=INT_MAX;
      f(j,0,i){
          dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
      }
  }

  for(int i=k;i<n;i++){
      dp[i]=INT_MAX;
      f(j,i-1,i-1-k){
          dp[i]=min(dp[i],abs(a[i]-a[j])+dp[j]);
      }
  }

  cout<<dp[n-1]<<endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
        
}

int mpow(int a, int b){ /* pow(a, b) % m */
  int m=mod;
  int x=1;
  while (b>0){
    if (b&1){
      x=(x * a) % m;
    }
    a=(a*a) % m; /* compute the next power of 2 */
    b>>=1; /* this is equivalent to b = floor(b / 2) */
  }
  return x;
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
} 

int kadane(int*a, int n){
    int max_so_far = INT_MIN, max_ending_here = 0;
    f(i,0,n){
        max_ending_here+=a[i];
        max_so_far = max(max_so_far, max_ending_here);
        if(max_ending_here<0) max_ending_here=0;
    }
    return max_so_far;
}

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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  if(a+b> 2*c){
    int z=min(x,y);
    if(x == max(x,y) && a > 2*c){
      cout << 2*c*x << endl;
    }
    else if(y == max(x,y) && b > 2*c){
      cout << 2*c*y << endl;
    }
    else if(x>y) {
      cout << 2*c*z + a*(x-z) << endl;
    }
    else {
      cout << 2*c*z + b*(y-z) << endl;
    }
  }
  else{
    cout << a*x + b*y << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    int a,b,c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
    return 0;
}

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

int isPrime(int x){
    if(x==2){
        return true;
    }
    if(x%2==0){
        return false;
    }
    int i=3;
    while(i<=sqrt(x)){
        if(x%i==0){
            return false;
        }
        i+=2;
    }
    return true;
}

int main(){
    int n, cnt=0;
    cin >> n;
    
    for(int i=0; i<n; i++){
        int x;
        cin >> x;
        
        if(isPrime(x)){
            cnt++;
        }
    }
    cout << cnt << "\n";
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define INF 1e+9
#define MOD (int)1e9+7
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void){
    int A, B;
    string S;
    cin >> A >> B;
    cin >> S;

    int i;
    for(i = 0; i < A; i++){
        if('0' > S[i] or S[i] > '9'){
            cout << "No" << '\n';
            return 0;
        }
    }
    if(S[A] != '-'){
        cout << "No\n";
        return 0;
    }
    for(i++; i < A + B + 1; i++){
        if('0' > S[i] or S[i] > '9'){
            cout << "No" << '\n';
            return 0;
        }
    }

    cout << "Yes" << '\n';
    return 0;
}

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

using namespace std;

int n,seq[300050];
bool flg[300050];

bool chk(int l,int r)
{
	if(l > r) return 0;
	if(l == r) return seq[l] != l;
	int minn = 300001,maxn = 0;
	for(int i = l;i <= r; ++ i) minn = min(minn,seq[i]),maxn = max(maxn,seq[i]);
	if(minn != l || maxn != r) return 1;
	for(int i = l + 1;i <= r;i += 2)
		if(!flg[i])
			return 1;
	for(int i = l;i <= r;i += 2)
		if(flg[i])
			return 1;
	int lst1 = 0,lst2 = 0;
	for(int i = l;i <= r;i += 2)
		if(seq[i] > i)
		{
			if(lst1 > seq[i])
				return 1;
			lst1 = seq[i];
		}
		else
		{
			if(lst2 > seq[i])
				return 1;
			lst2 = seq[i];
		}
	return 0;
}

int main()
{
	scanf("%d",&n);
	for(int i = 1;i <= n; ++ i)
	{
		scanf("%d",&seq[i]);
		flg[i] = seq[i] == i;
	}
	flg[0] = 1;
	int las = 1;
	for(int i = 1;i <= n; ++ i)
	{
		if(flg[i] && flg[i - 1])
		{
			if(chk(las,i - 2))
			{
				printf("No\n");
				return 0;
			}
			las = i + 1;
		}
		else if(flg[i] && flg[i - 2]);
		else if(flg[i] && flg[i - 3])
		{
			if(chk(las,i - 2))
			{
				printf("No\n");
				return 0;
			}
			las = i - 1;
		}
		else if(flg[i])
		{
			printf("No\n");
			return 0;
		}
	}
	if(chk(las,n)) printf("No\n");
	else printf("Yes\n");
} 

Measured memory_bytes: 1664
# -*- coding: utf-8 -*-
def solve():
    S = input()
    T = input()
    b = any([T == (S[i:]+S[:i]) for i in range(len(S))])
    a = 'Yes' if b else 'No'
    return str(a)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3064
#include<stdio.h>

int main(){
    int s, a;
    int sum = 0, ave = 0, n = 0;

    while(scanf("%d,%d", &s, &a) != EOF){
        n++;
        sum += s * a;
        ave += a;
    }
    printf("%d\n%d\n", sum, (int)((float)ave / n + 0.5));
    return 0;
}

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

typedef long long LL;

const int OO = 1e9;
const int MOD = 1e9 + 7;

LL l, r;
LL dp[64][2][2][2];

LL dfs(int t, int x, int y, int z) {
	if (t == -1) return 1;

	LL& ans = dp[t][x][y][z];
	if (ans != -1) return ans;

	ans = 0;

	for (int a = 0; a < 2; ++a) {
		for (int b = 0; b <= a; ++b) {
			int t1 = x, t2 = y, t3 = z;

			if (x == 1 && (1LL << t) * a > ((1LL << t) & r))
				continue;
			if (y == 1 && (1LL << t) * b < ((1LL << t) & l))
				continue;
			if (z == 0 && a != b)
				continue;

			if ((1LL << t) * a < ((1LL << t) & r))
				x = 0;
			if ((1LL << t) * b > ((1LL << t) & l))
				y = 0;
			if (z == 0 && a == b && a == 1)
				z = 1;

			ans += dfs(t - 1, x, y, z);
			ans %= MOD;

			x = t1, y = t2, z = t3;
		}
	}

	return ans;
}

void solve() {
	scanf("%lld%lld", &l, &r);

	memset(dp, -1, sizeof(dp));
	printf("%lld\n", dfs(63, 1, 1, 0));
}

int32_t main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);

// 	clock_t begin = clock();
// #endif

	solve();

// #ifndef ONLINE_JUDGE
// 	clock_t end = clock();
// 	printf("ELAPSED TIME: %f\n", (double) (end - begin) / CLOCKS_PER_SEC);
// #endif

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    string s;
    cin>>s;
    int n = s.size();
    for(int i = 0; i<a; i++)
        if(!(s[i]>='0' && s[i]<='9')){
            puts("No");
            return 0;
        }
    if(s[a]!='-'){
        puts("No");
        return 0;
    }
    for(int i = a+1; i<=a+b; i++)
        if(!(s[i]>='0' && s[i]<='9')){
                puts("No");
                return 0;
        }
    puts("Yes");
    return 0;
}


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

int main() {
  const string alpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  int N; string S; cin >> N >> S;
  rep(i, S.size()) {
    int idx = (alpha.find(S[i]) + N) % alpha.size();
    S[i] = alpha[idx];
  }
  cout << S << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
    //cin >> t;
     t=1;
    while (t--)
    {
        string s;
        cin>>s;
        if(s[s.size()-1]=='s')cout<<s<<"es"<<e;
        else cout<<s<<"s"<<e;
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    string s;
    cin>>s;
    if(s=="SUN") cout<<7<<endl;
    if(s=="MON") cout<<6<<endl;
    if(s=="TUE") cout<<5<<endl;
    if(s=="WED") cout<<4<<endl;
    if(s=="THU") cout<<3<<endl;
    if(s=="FRI") cout<<2<<endl;
    if(s=="SAT") cout<<1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<string.h>
#include<stdio.h>
int main()
{
	int h,b,i,j;
	char r[5],a[5];
	while(1){
		scanf("%s %s",r,a);
		if(strcmp(r,"0")==0&&strcmp(a,"0")==0){
			break;
		}
		h=0;
		b=0;
		for(i=0;i<4;i++){
			if(r[i]==a[i]){
				h++;
				r[i]='r';
				a[i]='a';
			}
		}
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(r[i]==a[j]){
					b++;
					r[i]='r';
					a[j]='a';
				}
			}
		}
		printf("%d %d\n",h,b);
	}
	return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
Int dp[1010][1010];
template <class T> void chmin(T& x, T y) { if (x > y) x = y; }
int main() {
    for (;;) {
        Int N, M; cin >> N >> M;
        if (N == 0) break;
        vector<Int> A(N); for (auto &a : A) cin >> a;
        vector<Int> B(N); for (auto &b : B) cin >> b;
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N + 1; j++) {
                dp[i][j] = 1e18;
            }
        }
        for (int j = 0; j < N + 1; j++) {
            if (B[0] + M * j >= A[0]) {
                dp[0][j] = B[0] + M * j - A[0];
            }
        }
        for (int i = 1; i < N; i++) {
            for (int j = 0; j <= N; j++) {
                for (int k = max(0, j - 2); k <= min((int)N, j + 2); k++) {
                    if (B[i] + M * j >= A[i]) {
                        Int cost = max(0LL, (B[i] + M * j - A[i]) - (B[i - 1] + M * k - A[i - 1]));
                        chmin(dp[i][j], dp[i - 1][k] + cost);
                    }
                }
            }
        }
        Int ans = 1e18;
        for (int j = 0; j <= N; j++) {
            ans = min(ans, dp[N - 1][j]);
        }
        cout << ans << '\n';
    }
    return 0;
}



Measured memory_bytes: 10916
#include <stdio.h>

int main(void)
{
  int w, n, j, i, nextSearch;
  int index = 0;
  int a[30], b[30], result[30];
  int c = 0;

    do {
        scanf("%d",&w);
    } while (w > 30);

    do {
        scanf("%d", &n);
    } while (n > 30);
 
    while (index < n) {
        scanf("%d,%d",&a[index],&b[index]);
        if ((1 <= a[index]) && (a[index] <= w) && (1 <= b[index]) && (b[index] <= w)) {
            index++;
        }
    }

    for(i = 0; i < w; i++){
      nextSearch = i+1;
      for(j = 0; j < n; j++){
	if(nextSearch == a[j]){
	  nextSearch = b[j];
	}else if(nextSearch == b[j]){
	  nextSearch = a[j];
	}
      }
      result[nextSearch-1] = i+1;
    }

    for(i = 0; i < w; i++)
      printf("%d\n", result[i]);

  return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
using vc = vector<char>;
using vvc = vector<vc>;
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; 
 }
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n,k;
  cin>>n>>k;
  if(k>(n-1)*(n-2)/2){
    COUT(-1);
    return 0;
  }
  ll m=n-1;
  ll no=(n-1)*(n-2)/2-k;
  COUT(m+no);
  ll cu=2;
  ll kk=cu+1;
  for(int i=1;i<m+no+1;i++){
    if(i<n){
      cout<<1<<" "<<i+1<<endl;
    }
    else{
      cout<<cu<<" "<<kk<<endl;
      kk++;
      if(kk==n+1){
        cu++;
        kk=cu+1;
      }
    }
  }
}

Measured memory_bytes: 256