akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
#include <queue>
#include <set>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

const int maxi = 1e6+10;
string s;
vector<int> v[maxi];
ll n;
ll a[maxi];

int main () {
  cin >> n;
  cout << (n-1)*n/2 << endl;
}


Measured memory_bytes: 25344
#include<iostream>
using namespace std;
#include<vector>
int main()
{
    long long int n;
    cin>>n;
    vector<char>c;
    while(n>0){
    long long int p=n%26;
    if(p==1)
    c.push_back('a');
    
    else if(p==2)
    c.push_back('b');
    
    
    else if(p==3)
    c.push_back('c');
    
    
    else if(p==4)
    c.push_back('d');
    
    else if(p==5)
    c.push_back('e');
    
    else if(p==6)
    c.push_back('f');
    
    else if(p==7)
    c.push_back('g');
    else if(p==8)
    c.push_back('h');
    
    
    else if(p==9)
    c.push_back('i');
    else if(p==10)
    c.push_back('j');
    else if(p==11)
    c.push_back('k');
    else if(p==12)
    c.push_back('l');
    
    else if(p==13)
    c.push_back('m');
    else if(p==14)
    c.push_back('n');
    else if(p==15)
    c.push_back('o');
    
    else if(p==16)
    c.push_back('p');
    
    else if(p==17)
    c.push_back('q');
    
    else if(p==18)
    c.push_back('r');
    
    else if(p==19)
    c.push_back('s');
    else if(p==20)
    c.push_back('t');
    
    else if(p==21)
    c.push_back('u');
    else if(p==22)
    c.push_back('v');
    else if(p==23)
    c.push_back('w');
    else if(p==24)
    c.push_back('x');
    else if(p==25)
    c.push_back('y');
    else if(p==0)
    c.push_back('z');
      if(p==0)n--;
    
    n=n/26;
    
    }
    long long int len=c.size();
    for(long long int j=len-1;j>=0;j--)
    cout<<c[j];
    return 0;
}

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

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 gcd(int a,int b){
  while(b!=0){
    a%=b;
    swap(a,b);
  }
  return a;
}

int kaizyou(int N){
  int num=1;
  for(int i=1;i<=N;i++){
  num*=i;
  }
  return num;
}

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

int mod=1e9+7;

string keta(int a) {
	string res;
	while (a > 0) {
		res.push_back((a % 10) + '0');
		a /= 10;
	}
	while ((int)res.size() < 12) {
		res.push_back('0');
	}
	reverse(res.begin(), res.end());
	return res;
}
signed main() {
	int N, M;
	cin >> N >> M;
	vector<vector<pair<int,int> > > A(N);
	int p, y;
	for (int i = 0; i < M; i++) {
		cin >> p >> y;
		p--;
		A[p].emplace_back(y, i);
	}
	vector<int> res(M);
	for (int i = 0; i < N; i++) {
		sort(A[i].begin(), A[i].end());
		for (int j = 0; j < A[i].size(); j++) {
			res[A[i][j].second] = (j + 1) + 1000000 * (i + 1);
		}
	}
	for (int i = 0; i < res.size(); i++) {
		cout << keta(res[i]) << endl;
	}
}
      
  
  
  

Measured memory_bytes: 7808
#include<stdio.h>
int main(){
  int k, s;
  int x, y, z;
  int cnt=0;
  scanf("%d%d", &k, &s);
  for( x=0; x<=k; x++){
    for( y=0; y<=k; y++){
      if(x+y<=s&&s-x-y<=k) cnt++;
    }
  }
  printf("%d", cnt);
  return 0;
}
  

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

int main()
{
	int N;
	cin >> N;
	vector<int> dia(100, 0);
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> tmp;
		dia[tmp - 1]++;
	}
	int ans = 0;
	for (int i = 0; i < 100; i++)
	{
		if (dia[i] != 0)
			ans++;
	}
	cout << ans << endl;
	return 0;
}

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

int N,M;
const int MAX_N = 100000;

int main(){    
  cin >> N >> M;
  int count[N];
  bool flag[N];
  for(int i = 0 ; i < N ; i++){
    count[i] = 1;
    flag[i] = false;
  }
  flag[0] = true;

  for(int i = 0 ; i < M ; i++){
    int x,y;
    cin >> x >> y;
    x--,y--;
    if(count[x]){
      count[x]--;
      count[y]++;
      if(flag[x])flag[y] = true;
      if(count[x] == 0)flag[x] = false;
    }
  }

  int sum = 0;
  for(int i = 0 ; i < N ; i++){
    if(count[i] && flag[i]){
      sum++;
    }
  }
  cout << sum << endl;
  
  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
using vint = vector<int>;
using vLL = vector<LL>;

int main(){
	int N, M;
	cin >> N >> M;
	vint a(M), dp2(N+10, -INF);
	int b[] = {0,2,5,5,4,5,6,3,7,6};
	for(int i = 0;i < M;i++)	cin >> a[i];
	dp2[0] = 0;
	for(int i = 0;i <= N-2;i++)	for(int j = 0;j < M;j++)	dp2[i+b[a[j]]] = max(dp2[i+b[a[j]]], dp2[i]+1);
	int r = N;
	sort(a.rbegin(), a.rend());
	while(r > 0){
		for(int i = 0;i < M;i++){
			if(r-b[a[i]] >= 0 && dp2[r-b[a[i]]] == dp2[r]-1){
				cout << a[i];
				r -= b[a[i]];
				break;
			}
		}
	}
}

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

int main(){
    int ABCD = 0;
    cin >> ABCD;
    int A = ABCD / 1000;
    int B = ABCD / 100 - 10 * A;
    int C = ABCD / 10 - 10 * B - 100 *A;
    int D = ABCD - 1000 * A - 100 * B - 10 * C;
    int op1, op2, op3;
    bool flag = false;
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2;j++)
        {
            for (int k = 0; k < 2;k++)
            {
                int sum = A;
                if (i == 0)
                {
                    sum += B;
                }
                else{
                    sum -= B;
                }
                if(j == 0){
                    sum += C;
                }
                else{
                    sum -= C;
                }
                if(k == 0){
                    sum += D;
                }
                else{
                    sum -= D;
                }
                if(sum == 7){
                    op1 = i;
                    op2 = j;
                    op3 = k;
                    flag = true;
                }
            if(flag){
                break;
            }
            }
        if(flag){
            break;
        }
        }
    if (flag)
    {
       break;
    }
    }
    cout << A;
    if(op1 == 0){
        cout << "+";
    }
    else{
        cout << "-";
    }
    cout << B;
    if (op2 == 0)
    {
        cout << "+";
    }
    else{
        cout << "-";
    }
    cout << C;
    if (op3 == 0)
    {
        cout << "+";
    }
    else{
        cout << "-";
    }
    cout << D << "=7" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define p pair<int, int>
#define endl '\n'

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    string s, t;
    cin >> s >> t;
    if (s.size() == t.size()-1 && s == t.substr(0, s.size())){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

using namespace std;

int n;
vector<int> t;
vector<int> x;
vector<int> y;

int main(){
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int ti, xi, yi;
        cin >> ti >> xi >> yi;
        t.push_back(ti);
        x.push_back(xi);
        y.push_back(yi);
    }

    int ct = 0, cx = 0, cy = 0;
    bool ok = true;
    for (int i = 0; i < n; ++i) {
        int dist = abs(x[i] - cx) + abs(y[i] - cy);
        int dt = t[i] - ct;
        //cout <<dt << ", " << dist << endl;
        if (dist <= dt && dt % 2 == dist % 2) {
            ct = t[i];
            cx = x[i];
            cy = y[i];
            //cout << "ok" << endl;
        } else {
            ok = false;
            break;
        }
    }

    cout << (ok ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1644
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    for (int i = 0; i < n; i++) {
        if (s.substr(i, n-i) == t.substr(0, n-i)) { cout << n + i << endl; return 0; }
    }
    cout << 2 * n << endl;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    int sum = 0;
    bool ok = false;
    int t = 0;
    for (int i = 1; sum < N; i++) {
        sum += i;
        if (sum == N) {
            ok = true;
            t = i;
            break;
        }
    }
    if (!ok) {
        cout << "No" << endl;
        return;
    }

    vector<vector<int>> ans;
    int now = 0;
    for (int k = 0; k < t + 1; k++) {
        vector<int> a;
        for (int i = 0; i < t - k; i++) {
            a.push_back(now);
            now++;
        }
        ans.push_back(a);
    }


    for (int i = 1; i < t + 1; i++) {
        int d = t - 1;
        int now = i - 1;
        for (int k = 0; k < i; k++) {
            ans[i].push_back(now);
            now += d;
            d--;
        }
        sort(all(ans[i]));
    }
    cout << "Yes" << endl;
    cout << ans.size() << endl;
    for (int i = 0; i < ans.size(); i++) {
        cout << ans[i].size() << " ";
        for (int j = 0; j < ans[i].size(); j++) {
            cout << ans[i][j] + 1;
            if (j != ans[i].size()) cout << " ";
        }
        cout << endl;
    }
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 2050
int f[N][N],opt[N<<1],a[N<<1],cw[N<<1][N],cb[N<<1][N],pos[2][N],n;
char str[10];
int main() {
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=(n<<1);i++) {
		scanf("%s%d",str,&a[i]);
		opt[i]=(str[0]=='B'); pos[opt[i]][a[i]]=i;
	}
	for(i=1;i<=(n<<1);i++) {
		for(j=0;j<=n;j++) {
			cw[i][j]=cw[i-1][j];
			cb[i][j]=cb[i-1][j];
			if(a[i-1]>j) opt[i-1]?cb[i][j]++:cw[i][j]++;
		}
	}
	memset(f,0x3f,sizeof(f));
	f[0][0]=0;
	for(i=0;i<=n;i++) {
		for(j=0;j<=n;j++) {
			int u=pos[0][i+1],v=pos[1][j+1];
			f[i+1][j]=min(f[i+1][j],f[i][j]+cw[u][i+1]+cb[u][j]);
			f[i][j+1]=min(f[i][j+1],f[i][j]+cw[v][i]+cb[v][j+1]);
		}
	}
	printf("%d\n",f[n][n]);
}

Measured memory_bytes: 82304
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
    int ans=0;
    int n,k;cin>>n>>k;
    int fx=((n)*(n+1))/2;
    //cout<<fx<<'\n';
    rep(i,k,n+2)
    {
    	int sm=((i-1)*(i))/2;
    	int sm2=((n-i)*(n-i+1))/2;
    	//cout<<sm<<" "<<sm2<<'\n';
    	ans=(ans+(fx-sm2)-sm+1)%mod;
    }
    cout<<ans;
}

int32_t main(){

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

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	ll a, b, n;
	cin >> n >> a >> b;
	
	if(n == 0) cout << 0;
	else if(n == 1 && a==b) cout << 1;
	else if(n== 1) cout << 0;
	else if( b < a) cout << 0;
	else cout << a+(n-1)*(b-a) - b + 1;

}


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

char a[3][3];

int main(){

    for(int i=0; i<3; ++i){
        scanf("%s", a[i]);
    }

    string s="";
    for(int i=0; i<3; ++i){
        for(int j=0; j<3; ++j){
            if(i==j)
                s+=a[i][j];
        }
    }

    cout<<s;



    return 0;
}


Measured memory_bytes: 256
use List::Util 'min';
use List::Util 'sum';

while(<>){
	chomp;
	if($. == 1){
		@x = split(/ /, $_);
	}elsif($. == 2){
		@g = split(/ /, $_);
	}elsif($. == 3){
		@r = split(/ /, $_);
	}else{
		@n = split(/ /, $_);
	}
}

@g = sort{$b <=> $a}(@g);
@r = sort{$b <=> $a}(@r);
@n = sort{$b <=> $a}(@n);

@apples = (@g[0 .. $x[0] - 1], @r[0 .. $x[1] - 1], @n[0 .. min($#n, $x[0] + $x[1] - 1)]);
@apples = sort{$b <=> $a}(@apples);

print sum(@apples[0 .. $x[0] + $x[1] - 1]) . "\n";



Measured memory_bytes: 75888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  string s;
  cin >> s;
  
  list<char> a;
  rep(i, s.size()) a.push_back(s[i]);
  int re = 0;
  
  int q;
  cin >> q;
  rep(i, q) {
    int t;
    cin >> t;
    if (t == 1) re = (re + 1) % 2;
    else {
      int f;
      char c;
      cin >> f >> c;
      f--;
      if ((re + f) % 2 == 0) {
        a.push_front(c);
      }
      else {
        a.push_back(c);
      }
    }
  }

  if (re == 0) {
    while (!a.empty()) {
      cout << a.front();
      a.pop_front();
    }
  }
  else {
    while (!a.empty()) {
      cout << a.back();
      a.pop_back();
    }
  }
  cout << endl;



  
  return 0;
}

Measured memory_bytes: 9984
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long A = in.nextLong();
            long B = in.nextLong();
            long C = in.nextLong();
            long D = in.nextLong();
            long CD = lcm(C, D);
            long A2 = A - 1;
            out.println((B - B / C - B / D + B / CD) - (A2 - A2 / C - A2 / D + A2 / CD));
        }

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

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

    }
}



Measured memory_bytes: 21844
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	int H, W, A, B;
	cin >> H >> W >> A >> B;

	vector<vector<int>> mat(H, vector <int> (W, 0));

	if ( (A==0) && (B==0) ){
		//何もしない
	} else if (A==0) {
		for (int ii = 0; ii < B; ++ii){
			for (int jj = 0; jj < W; ++jj){
				mat[ii][jj] = 1;
			}
		}
	} else if (B==0) {
		for (int ii = 0; ii < H; ++ii){
			for (int jj = 0; jj < A; ++jj){
				mat[ii][jj] = 1;
			}
		}
	} else {
		int offset = 0;
		for (int ii = 0; ii < H; ++ii){
			for (int jj = 0; jj < A; ++jj){
				int idx = (jj + offset) % W;
				mat[ii][idx] = 1;
			}
			offset = (offset + A) % W;
		}
	}

	bool OK = true;
	//行のチェック
	for (int ii = 0; ii < H; ++ii){
		int cntZero = 0;
		int cntOne = 0;
		for (int jj = 0; jj < W; ++jj){
			if (mat[ii][jj] == 0){
				cntZero++;
			} else {
				cntOne++;
			}
		}
		int num = min(cntOne, cntZero);
		if (num != A){
			OK = false;
			break;
		}
	}
	//列のチェック
	if (OK){
		for (int jj = 0; jj < W; ++jj){
			int cntZero = 0;
			int cntOne = 0;
			for (int ii = 0; ii < H; ++ii){
				if (mat[ii][jj] == 0){
					cntZero++;
				} else {
					cntOne++;
				}
			}
			int num = min(cntOne, cntZero);
			if (num != B){
				OK = false;
				break;
			}
		}
	}

	//別の方法を試す
	if (!OK){
		OK = true;
		for (int ii = 0; ii < H; ++ii){
			for (int jj = 0; jj < W; ++jj){
				mat[ii][jj] = 0;
			}
		}

		for (int ii = 0; ii < B; ++ii){
			for (int jj = 0; jj < A; ++jj){
				mat[ii][jj] = 1;
			}
		}
		for (int ii = B; ii < H; ++ii){
			for (int jj = A; jj < W; ++jj){
				mat[ii][jj] = 1;
			}
		}

		//行のチェック
		for (int ii = 0; ii < H; ++ii){
			int cntZero = 0;
			int cntOne = 0;
			for (int jj = 0; jj < W; ++jj){
				if (mat[ii][jj] == 0){
					cntZero++;
				} else {
					cntOne++;
				}
			}
			int num = min(cntOne, cntZero);
			if (num != A){
				OK = false;
				break;
			}
		}
		//列のチェック
		if (OK){
			for (int jj = 0; jj < W; ++jj){
				int cntZero = 0;
				int cntOne = 0;
				for (int ii = 0; ii < H; ++ii){
					if (mat[ii][jj] == 0){
						cntZero++;
					} else {
						cntOne++;
					}
				}
				int num = min(cntOne, cntZero);
				if (num != B){
					OK = false;
					break;
				}
			}
		}
	}


	if (OK){
		for (int ii = 0; ii < H; ++ii){
			for (int jj = 0; jj < W; ++jj){
				cout << mat[ii][jj];
			}
			cout << "\n";
		}
	} else {
		cout << "No" << "\n";
	}

	return 0;
}


Measured memory_bytes: 5120
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef pair<int, int>P;
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
typedef vector<vector<ll>> mat;
typedef vector<int> vec;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
const ll mod = 1000000007;
const ll INF = mod * mod;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll qp(ll a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };



void solve() {
    ll a, b, c, d, e , m, n, k, x, y, l,r, h, w;
    string s, t;
    ll ans = 0;
    double dans = 0;
    string sans = "Yes";
    vector<ll> ar;
    vector<string> sr;
    vector<vector<char>> arr;

    cin >> a >> b;


    if(a>b){
        ans += a;
        a--;
    }
    else{
        ans += b;
        b--;
    }
    ans += max(a,b);

    std::cout << ans << endl;

    // std::cout << sans << endl;
}

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    String[] stri = str.split(" ");
    Stack<Integer> st = new Stack<Integer>();
    for (int i = 0; i < stri.length; i++) {
      int i1, i2;
      switch (stri[i]) {
        case "+":
          i1 = st.pop();
          i2 = st.pop();
          st.push(i1 + i2);
          break;
        case "-":
          i1 = st.pop();
          i2 = st.pop();
          st.push(i2 - i1);
          break;
        case "*":
          i1 = st.pop();
          i2 = st.pop();
          st.push(i1 * i2);
          break;
        default:
          st.push(Integer.parseInt(stri[i]));
      }
    }
    System.out.println(st.pop());
  }
}

Measured memory_bytes: 24168
#include<iostream>
using namespace std;
int m,f,b,k,n;
int main(){
cin>>m>>f>>b;
k=m-b;
n=(m+f)-b;
if(k>0){
    cout<<0<<endl;
}else if(n>=0){
    cout<<b-m<<endl;
}else{
    cout<<"NA"<<endl;
}

return 0;
}


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

int n,k;
int a[200010];

bool calc(int x, int y){
    rep(i,n){
        y-=((a[i]+x-1)/x)-1;
    }
    if(y<0)return false;
    else return true;
}

int main(){
    cin>>n>>k;
    rep(i,n)cin>>a[i];
    int l=0,r=1e9+1;
    while(r-l>1){
        int mid=(l+r)/2;
        if(calc(mid,k))r=mid;
        else l=mid;
    }
    cout<<r<<endl;
}

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

const ll MOD = 1e9 + 7;
const int N = 1e5 + 10;
ll ways[N];

ll pwr(ll a, ll n) {
  a %= MOD;
  ll r = 1;
  for (; n > 0; n >>= 1) {
    if (n & 1) r = r * a % MOD;
    a = a * a % MOD;
  }
  return r;
}

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  int n, k; cin >> n >> k;
  ll ans = 0;
  for (int g = k; g >= 1; g--) {
    int m = k / g;
    ways[g] = pwr(m, n);
    for (int gg = 2 * g; gg <= k; gg += g) {
      ways[g] -= ways[gg];
    }
    ways[g] %= MOD;
    ways[g] += MOD;
    ways[g] %= MOD;

    ans += (ways[g] * g) % MOD;
  }
  ans %= MOD;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4416
#include <stdio.h>
int main(void){
    int a,b;
    scanf("%d %d",&a,&b);
  
   if(a<b){
       printf("a < b\n");
   }
   else if(a>b){
       printf("a > b\n");
   }
   else 
   {
       printf("a == b\n");
   } 
   
   return 0;
}

Measured memory_bytes: 580
d = int(input())
ci = list(map(int, input().split()))
sdi_list = []
for i in range(d):
    sdi = list(map(int, input().split()))
    sdi_list.append(sdi)
td_list = []
for i in range(d):
    td = int(input())
    td_list.append(td)
lastdi = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
manzoku = 0
for i in range(d):
    manzokuteika = 0
    lastdi[td_list[i]-1] = i + 1
    for j in range(26):
        manzokuteika = manzokuteika + ci[j] * (i + 1 - lastdi[j])
    manzoku = manzoku + sdi_list[i][td_list[i]-1] - manzokuteika
    print(manzoku)


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

int CountOfDigits(int64_t n) {
  int sum = 0;
  while (n > 0) {
    sum ++;
    n /= 10;
  }
  return sum;
}

int main() {
  int64_t N;
  cin >> N;
  
  int ans = CountOfDigits(N);
  
  for(int64_t i = 1ll; i*i <= N; i++){
    if(N%i!=0) continue;
    const int64_t j = N/i;
 	const int cur = abs(CountOfDigits(i)- CountOfDigits(j));

 	if(ans>cur){
 	ans = max(CountOfDigits(i), CountOfDigits(j));
 	}
 }
  cout << ans << endl;
}


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

int main() {
    int n, m;
    cin >> n >> m;
    
    vector<int> city(n);
    
    for (int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        city.at(a-1)++;
        city.at(b-1)++;
    }
    
    for (int i=0; i<n; i++) {
        cout << city.at(i) << endl;
    }
    

}

Measured memory_bytes: 3624
N,M = map(int,input().split())
sc = []
for _ in range(M):
  s,c = map(int,input().split())
  for i in range(len(sc)):
    if s == sc[i][0]:
      if c != sc[i][1]:
        print(-1)
        exit()
  if s == 1 and c == 0 and N != 1:
    print(-1)
    exit()
  sc.append([s,c])
def get_unique_list(seq):
    seen = []
    return [x for x in seq if x not in seen and not seen.append(x)]
sc = get_unique_list(sc)
ans = 0
for a in range(1,N+1):
  for row in sc:
    if a == row[0]:
      ans += row[1]*(10**(N-a))

if len(str(ans)) == N:
  print(ans)
else:
  print(ans+10**(N-1))

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

int main() {
  ll x;
  cin >> x;

  ll output = (x / 11) * 2;
  if (x % 11 > 6) {
    output += 2;
  } else if (x % 11 > 0) {
    output += 1;
  }

  cout << output << endl;

  return 0;
}

Measured memory_bytes: 3608
n = int(input())
d = []

for i in range(n):
    d.append(int(input()))

i = 1
c = 1
list.sort(d,reverse = True) 
j = d[0]

for i in range(len(d)):
    if j > d[i]:
        c += 1
        j = d[i]

print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define PI 3.141592653589793238462
using namespace std;
typedef long long ll;
typedef long double db;
int a[105],b[105];
int main(){
    int n;cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=1;i+2<=n;i++){
        if(a[i]==b[i]&&a[i+1]==b[i+1]&&a[i+2]==b[i+2]){
            cout<<"Yes"<<endl;return 0;
        }
    }
    cout<<"No"<<endl;
}

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

using namespace std;

int main() {
  int m, nmin, nmax;
  while (cin >> m, cin >> nmin, cin >> nmax, m && nmin && nmax) {
    vector<int> p(m);
    for (int i = 0; i < m; i++) {
      cin >> p[i];
    }
    // sort(p.begin(), p.end());
    // reverse(p.begin(), p.end());
    int ans = 0;
    int diffmax = 0;
    for (int i = nmin - 1; i <= nmax - 1; i++) {
      //cerr << p[i] - p[i + 1] << " ";
      if (diffmax <= p[i] - p[i + 1]) {
        diffmax = p[i] - p[i + 1];
        ans = i+1;
      }
    }
   // cerr << endl;
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3064
// Build Stairs.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
using namespace std;

const int N = 1e5;
int arr[N];

int main()
{
	int n;

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

	for (int i = n - 1; i >=1; i--) {
		if (arr[i] < arr[i - 1]) {
			if (arr[i - 1] - arr[i] > 1) {
				cout << "No";
				return 0;
			}
			else if(arr[i - 1] - arr[i] == 1)
				arr[i - 1]--;
		}
	}
	cout << "Yes";


}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
//next_permutation
void nexp(int*a,int cnt){
	int l=cnt-1,r=cnt-1;
	int t;
	while(--l>=0&&a[l]>a[l+1]);
	if(l>=0){
		while(a[l]>a[r])r--;
		t=a[l];a[l]=a[r];a[r]=t;
	}
	for(l++,r=cnt-1;l<r;l++,r--)t=a[l],a[l]=a[r],a[r]=t;
}

int a[9]={1,2,3,4,5,6,7,8,9};
char s[100010];
int cnt[10][10];
int m=1e9;
int ans[9];
int main(){
	int n;
	scanf("%d%s",&n,s);
	for(int i=1;i<n;i++)cnt[s[i-1]-'0'][s[i]-'0']++;
	for(int _=0;_<362880;_++){
		int temp=0;
		for(int i=0;i<9;i++)for(int j=0;j<9;j++){
			temp+=cnt[a[i]][a[j]]*(abs(i/3-j/3)+abs(i%3-j%3));
		}
		if(temp<m){
			m=temp;
			for(int i=0;i<9;i++)ans[i]=a[i];
		}
		nexp(a,9);
	}
	for(int i=0;i<9;i++,i%3==0?puts(""):0)printf("%d",ans[i]);
}


Measured memory_bytes: 2148
#include<iostream>
    using namespace std;
    int main()
    {
      int a,b,c,k;
      cin>>a>>b>>c>>k;
      if(k<=a) cout<<k;
      else if(k<=(a+b)) cout<<a;
      else cout<<2*a+b-k;
      return 0;
    }

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

int main(){
	int N;
	string S;
	cin >> N >> S;
	int ans=0;
	for(int i=0;i+2<N;i++)if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C')ans++;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String op;
    int a;
    int b;
    int sum = 0;
    int dec = 0;
    int multi = 0;
    int div = 0;

    do{
       a = sc.nextInt();
       op = sc.next();
       b = sc.nextInt();

    if(op.equals("+")){
       sum = a+b;
       System.out.println(sum);
    }else if(op.equals("-")){
       dec = a-b;
       System.out.println(dec);
    }else if(op.equals("*")){
       multi = a*b;
       System.out.println(multi);
    }else if(op.equals("/")){
      switch(b){
        case 0:
        break;
      default:
       div = a/b;
       System.out.println(div);
      }
    }
  }while(!(op.equals("?")));
  sc.close();
  }
}



Measured memory_bytes: 26312
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    
    ll x, y; cin >> x >> y;
    ll ans = INFL;
    if(x <= y) ans = min(ans, y-x);
    if(-x <= y) ans = min(ans, y-(-x)+1);
    if(-x <= -y) ans = min(ans, -y-(-x)+2);
    if(x <= -y) ans = min(ans, -y-x+1);
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = input()
    y = input()

    if x == y[::-1]:
        print("YES")
    else:
        print("NO")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61880
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h> 
using namespace std;

typedef long long ll;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) 
#define rep(pp,nn) for (int ii = pp; ii < nn; ++ii)
#define vi vector<int>
#define vll vector<ll>
#define vs vector<string>

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

string int_to_string(int x) {
    stringstream ss;
	ss << x;
	string ni = ss.str();
	return ni;
}
int string_to_int(string x) {
	int n;
	stringstream s(x);
	s >> n;
	return n;
}

int64_t power_mod(ll a, ll b, ll mo) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = (ans % mo * a % mo) % mo;
		}
		a = (a % mo * a % mo) % mo;
		b /= 2;
	}
	return ans;
}
int64_t POW(ll a, ll b) {
	ll ans = 1;
	while (b) {
		if(b & 1) {
			ans = ans * a;
		}
		a = a * a;
		b /= 2;
	}
	return ans;
}

vector<int64_t> INVERSE(int64_t nn, int64_t mo) {
	vector<int64_t> inv(nn + 1);
	vector<int64_t> mul(nn + 1);
	inv[0] = 1;
    inv[1] = 1;
	for (ll i = 2; i <= nn; ++i) {
		inv[i] = (mo - (mo / i) * inv[mo % i] % mo) % mo; 
	}
	mul[0] = 1;
	for (int i = 1; i <= nn; ++i) {
		mul[i] = (mul[i - 1] * inv[i]) % mo;
	}
	return mul;
}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


int main() {
	IOS;
	//int64_t n, k;
	//cin >> n >> k;
	//cout << 999983 / 101 << " " << 999983 % 101;
	int64_t n;
	cin >> n;
	string k = int_to_string(n);
	int size = (int)k.size();
	string c = "";
	for (int i = 0; i < size; ++i) {
		c += "7";
	}
	int64_t z = string_to_int(c);
	map<int,bool> m;
	//int rem = -1;
	int cnt = size;
	bool ans = 0;
	//debug(z);
	while (1) {
		int p = z % n;
		if (p == 0) {
			ans = 1;
			break;
		}
		if (m[p]) {
			break;
		}
		m[p] = 1;
		z = p * 10 + 7;
		cnt++;
	}
	if (ans) {
		cout << cnt;
	}else {
		cout << -1;
	}
}













Measured memory_bytes: 50480
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que)  priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
 int n; cin>>n;
 int a[n]; REP(i,n)cin>>a[i];
 vector<int> v;

 REP(i,n){
  if(n%2==(i+1)%2)
   v.insert(v.begin(),a[i]);
  else v.push_back(a[i]);
 }
 
 REP(i,v.size()){
     cout<<v[i]<<" ";
 }
}

Measured memory_bytes: 3828
#include<iostream>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
using namespace std;
typedef pair<double,string> P;
struct edge{
	double cost;
	string st;
};
int cmp(const edge &a,const edge &b){
	if(a.cost!=b.cost)
	return a.cost>b.cost;
	else return a.st<b.st;
}
int main(){
	string str;
	int n,a,b,c,d,p,e,f,s,m;
	double pre;
	vector<edge> mp;
	while(cin>>n,n){
		edge temp;
		for(int i=0;i<n;i++){
			cin>>str>>p>>a>>b>>c>>d>>e>>f>>s>>m;
			pre=(double)(f*m*s-p)/(a+b+c+(d+e)*m);
			temp.cost=pre;
			temp.st=str;
			mp.push_back(temp);
		}
		sort(mp.begin(),mp.end(),cmp);
		for(int i=0;i<mp.size();i++)
			cout<<mp[i].st<<endl;
		cout<<'#'<<endl;
		mp.clear();
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define W while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
#define mp make_pair

  int main()
  {
        ll a;
        cin>>a;
        cout<<a+a*a+a*a*a;
  }

Measured memory_bytes: 3604
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    #define sqr(x) ((x)*(x))
    #define mp make_pair
    #define uint unsigned
    #define PI pair<int,int>
    inline char gc(){
        static char buf[100000],*p1=buf,*p2=buf;
        return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
    }
    #define gc getchar
    inline int read(){
    	int x = 0; char ch = gc(); bool positive = 1;
    	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
    	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
    	return positive ? x : -x;
    }
    inline void write(ll a){
        if(a<0){
        	a=-a; putchar('-');
    	}
        if(a>=10)write(a/10);
        putchar('0'+a%10);
    }
    inline void writeln(ll a){
        if(a<0){
        	a=-a; putchar('-');
    	}
    	write(a); puts("");
    }
    inline int rnd(int x){
    	return (rand()<<16|rand())%x;
    }
    const int N=100005;
    ll k;
    int n,m,ans[N],q[N],a[N],que[N];
    ll dq[N];
    int main(){
    	n=read();
    	for(int i=1;i<=n;i++)a[i]=read();
    	for(int i=1;i<=n;i++)q[i]=i;
    	m=read(); cin>>k;
    	for(int i=1;i<=m;i++){
    		int pos=read();
    		swap(q[pos],q[pos+1]);
    	}
    	for(int i=1;i<=n;i++)if(!ans[i]){
    		que[0]=i; int jb=1;
    		for(int j=q[i];j!=i;j=q[j])que[jb++]=j;
    		for(int j=0;j<jb;j++)ans[que[j]]=que[(j+k%jb)%jb];
    	}
    	for(int i=1;i<=n;i++)dq[i]=a[ans[i]]-a[ans[i]-1];
    	for(int i=1;i<=n;i++)dq[i]+=dq[i-1];
    	for(int i=1;i<=n;i++)writeln(dq[i]);
    }
    /*
    1 2 3 4 5
    1 3 2 4 5
    1 3 4 2 5
    1 3 4 5 2
    */

Measured memory_bytes: 3584
n = int(input())
check = True
trip = [[0,0,0]]
for i in range(n):
    trip.append(list(map(int,input().split())))
for i in range(1,n+1):#1~nまでの繰り返し
    times = trip[i][0] - trip[i-1][0]#移動可能回数 
    distanceX = abs(trip[i][1] - trip[i-1][1])
    distanceY = abs(trip[i][2] - trip[i-1][2])
    distance = distanceX + distanceY
    if times < distance or (times + distance) % 2 != 0:
        check = False
        break
if check:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 27300
#include <iostream>
#include <vector>
using ll = long long;
constexpr ll MOD = 1e9 + 7;
int main()
{
    int N;
    std::cin >> N;
    const int maximum = 1 << N;
    std::vector<std::vector<ll>> a(N, std::vector<ll>(N));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) { std::cin >> a[i][j]; }
    }
    std::vector<ll> sum(maximum, 0);
    for (int i = 0; i < maximum; i++) {
        std::vector<int> ind;
        for (int j = 0; j < N; j++) {
            if (i & 1 << j) { ind.push_back(j); }
        }
        for (const int e : ind) {
            for (const int f : ind) { sum[i] += a[e][f]; }
        }
        sum[i] /= 2;
    }
    std::vector<ll> memo(maximum, -1);
    auto dp = [&](auto&& self, const int mask) -> ll {
        if (memo[mask] != -1) { return memo[mask]; }
        ll max = sum[mask];
        for (int sub = mask;;) {
            sub = (sub - 1) & mask;
            if (sub == 0) { break; }
            max = std::max(max, self(self, sub) + self(self, mask - sub));
        }
        return memo[mask] = max;
    };
    std::cout << dp(dp, maximum - 1) << std::endl;
    return 0;
}


Measured memory_bytes: 1280
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long a, b;
  cin >> a >> b;
  if (a + b == 15) cout << "+" << endl;
  else if (a * b == 15) cout << "*" << endl;
  else cout << "x" << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    n = int(input())
    l = list(map(int,input().split()))
    ans = 0
    for i in range(n-2):
        if l[i] < l[i+1] < l[i+2] or l[i+2] < l[i+1] < l[i]:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
        def dump(*args):
            names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
            print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
    except:
        def dump(*args):
            pass

    solve()

# vim: set foldmethod=marker:}}}


Measured memory_bytes: 104812
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

long long h;
long long cnt = 1;
long long ans = 0;

int main() { 

  cin >> h;

  while (h > 0) {
    if (h == 1) {
      ans += cnt;
      h = 0;
      break;
    }
    ans += cnt;
    cnt *= 2;
    h /= 2;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;

public class Program {
    public static void Main() {
        while (true) {
            int n = int.Parse(Console.ReadLine());
            if (n == 0) break;
            int[] score = new int[n];
            for (int i = 0; i < n; i++) {
                score[i] = int.Parse(Console.ReadLine());
            }
            Array.Sort(score);
            Console.WriteLine((score.Sum() - score[0] - score[n-1])/(n-2));
        }
    }
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
    ll res = 1LL; 
    x = x % p;
    if (x == 0) return 0;
    while (y > 0){
        if (y & 1LL)  
            res = (res*x) % p;
        y = y>>1LL; 
        x = (x*x) % p;  
    }  
    return res;  
}  

int main(){
	IO
	int n, k;
	cin >> n >> k;

	int mx = -1;
	int arr[n];
	rep(i, 0, n){
		cin >> arr[i];
		mx = max(mx, arr[i]);
	}

	int st = 1, en = mx, md;
	int ans = mx;
	while(st <= en){
		md = st + (en - st)/2;
		int total = 0;
		bool possible = false;
		rep(i, 0, n){
			total+=ceil(arr[i]*1.0/md) - 1;
		}
		if(total <= k) possible = true;

		if(possible){
			en = md - 1;
			ans = md;
		}
		else
			st = md + 1;
	}

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

Measured memory_bytes: 4284
#include "bits/stdc++.h"
using namespace std;
struct ${$(){ios_base::sync_with_stdio(0);cin.tie(0);}}$;

const int N = 200005;

void go(vector <int> v) {
   for(auto c: v) {
      if(c == -1) cout << "-";
      else if(c == 10) cout << "+";
      else cout << c;
   }
   cout << "=7" << endl;
   exit(0);
}
int main() {
   string s;
   cin >> s;
   vector <int> v;
   for(auto c: s)
      v.push_back(c - '0');

   for(int mask = 0; mask < 8; mask++) {
      vector <int> tmp;
      int ans = v[0];
      tmp.push_back(v[0]);

      for(int j = 0; j < 3; j++) {
         if(mask & (1 << j)) {
            ans += v[j + 1];
            tmp.push_back(10);
            tmp.push_back(v[j + 1]);
         }
         else {
            ans -= v[j + 1];
            tmp.push_back(-1);
            tmp.push_back(v[j + 1]);
         }
      }
      if(ans == 7) {
         go(tmp);
      }
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    ll n, l;
    cin >> n >> l;
    vector<ll> v(n);
    rep(i, n) v.at(i) = (i + 1) + l - 1;
    ll amin = INF;
    rep(i, n) if(abs(amin) > abs(v.at(i))) { amin = v.at(i); }
    ll sum = 0;
    rep(i, n) sum += v.at(i);

    // cout << amin << endl;

    cout << sum - amin;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc =new Scanner(System.in);
        StringBuilder build = new StringBuilder();
        int z = sc.nextInt();
        int[] ary = new int[z];
        for(int i = 0 ; i < ary.length; i++){
            ary[i] = sc.nextInt();
        }
        boolean flag = true;
        int count = 0;
        while(flag){
            int j = 0;
            flag = false;
            for(int i = ary.length-1; i > j; i--){
                if(ary[i] < ary[i-1]){
                    int temp = ary[i];
                    ary[i] = ary[i-1];
                    ary[i-1] = temp;
                    count++;
                    flag = true;
                }
            }
            j++;
        }
        for(int i = 0; i < ary.length; i++){
            build.append(ary[i]);
            if(i == ary.length-1){
                build.append("\n");
            }else{ build.append(" ");
            }
        }
        build.append(count);
        System.out.println(build);
    }
}

Measured memory_bytes: 26252
#include<bits/stdc++.h>
using namespace std;
int ans=0;
char last='\n',now;
int main(){
while((now=getchar())!='\n'){
    if(last=='\n'){  last=now; continue;
}
    
    if(last!=now)
    ans++;
		 last=now;
}
cout<<ans;
return 0;
}

Measured memory_bytes: 256
from collections import Counter, defaultdict

alp = list("abcdefghijklmnopqrstuvwxyz")

n = int(input())
INF = 100
d = defaultdict(lambda: INF)

for i in range(n):
    s = input()
    count = Counter(s)
    for k in alp:
        d[k] = min(d[k], count[k])

# print(d)
ans = ""
for k in alp:
    if d[k] == 0:
        continue
    ans += k * d[k]
print(ans)


Measured memory_bytes: 3316