akhauriyash/Code-Regression huggingface dataset:
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s,t;
	cin>>s>>t;
	cout<<t<<s<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());



signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int a, b; cin >> a >> b;
  int ans = 0;
  if (a >= b) {
    ans += a;
    a--;
  } else {
    ans += b;
    b--;
  }
  if (a >= b) {
    ans += a;
  } else {
    ans += b;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int x=1000;
    if(n<x)
        cout<<(x-n)<<"\n";
    else
    {
        int i;
        for(i=1000;x<n;i+=1000)
            x+=1000;
        cout<<(x-n)<<"\n";
    }
  return 0;  
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {

    int N;
    cin >> N;
    vector<int> a(N + 1);
    vector<int> b(N + 1, 0);
    rep(i,N) cin >> a[i + 1];

    int ans = 0;

    for (int i = N; i >= 1; i--) {
        int count = 0;
        for (int j = i * 2; j <= N; j += i) {
            count += b[j];
        }
        if (count % 2 != a[i]) {
            b[i] = 1;
            ans++;
        }
    }
    cout << ans << endl;
    for (int i = 1; i <= N; i++) {
        if (b[i] > 0) cout << i << " ";
    }
    
    return 0;
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
int k,n;
cin>>n>>k;
vector<int>arr(n);
long long sum=0;
long long sum1=0;
for(int i=0;i<n;i++){
cin>>arr[i];
sum+=arr[i];
}
sort(arr.begin(), arr.end(), greater<int>());
if(k>=n){
  cout<<"0"<<endl;
}
else if(k==0){
  cout<<sum<<endl;
}
else{

for(int i=0;i<k;i++){
 sum1+=arr[i];
}
cout<<sum-sum1<<endl;
}

}


Measured memory_bytes: 1024
#line 1 "/mnt/c/Users/leafc/dev/compro/lib/template.hpp"


#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
#define MM << " " <<

using namespace std;

template <class T> void say(bool val, T yes = "Yes", T no = "No") { cout << (val ? yes : no) << endl; }

template <class T> void chmin(T &a, T b) {
  if (a > b)
    a = b;
}

template <class T> void chmax(T &a, T b) {
  if (a < b)
    a = b;
}


#line 2 "abc162_c.cpp"

template <class T> T gcd(T n, T m) { return n ? gcd(m % n, n) : m; }

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

  int n;
  cin >> n;
  int ans = 0;
  FOR(a, 1, n + 1) {
    FOR(b, 1, n + 1) {
      int tmp = gcd(a, b);
      FOR(c, 1, n + 1) { ans += gcd(tmp, c); }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include <iostream>
using namespace std;
typedef long long ll;
int A[55];
ll C[55][55];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, P;
  cin >> N >> P;
  int d[2] = {0,0};
  for( int i=0; i<N; i++ ){
    cin >> A[i];
    d[A[i]%2]++;
  }

  C[0][0] = 1;
  for( int i=1; i<=N; i++ ){
    C[i][0] = C[i-1][0];
    for( int j=1; j<i; j++ ){
      C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
    C[i][i] = C[i-1][i-1];
  }

  ll ret = 0;

  for( int i=P; i<=d[1]; i+= 2 ){
    ll a = C[d[1]][i];
    for( int j=0; j<=d[0]; j++ ){
      ll b = C[d[0]][j];
      ret += a * b;
    }
  }

  cout << ret << endl;
}

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

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=1000000007;

int main()
{
    int n;cin>>n;
    int a[n];
    rep(i,0,n)cin>>a[i];

    int c=0;
    rep(i,0,n)
    if(a[i]!=i+1)
        c++;

    (c==0 || c==2) ? cout<<"YES\n" : cout<<"NO\n";
}


Measured memory_bytes: 256
const main = stdin => {
  const input = stdin.trim().split('\n')
  const N = parseInt(input[0])
  const nums = input[1].split(' ').map(x => BigInt(x))
  if (nums.includes(0n)) {
    console.log(0)
    return
  }

  let ans = 1n
  for (let i = 0; i < N; i++) {
    ans = ans * nums[i]
    if (ans > 1000000000000000000n) {
      console.log(-1)
      return
    }
  }
  console.log(ans.toString())
}
// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 44000
N = int(input())
d = list(map(int, input().split()))
more = N - 1
total = 0
for i in range(N):
  for j in range(more):
    try:
      total +=  int(d[i]) * int(d[i + j + 1])
    except IndexError:
      break
  more -= 1
print(total)

Measured memory_bytes: 38640
#include<bits/stdc++.h>
using namespace std;
int A[100001];
int main(){
	int a,i;
	cin>>a,scanf("%d",&A[1]),A[1]--;
	for(i=2;i<=a;i++){
		scanf("%d",&A[i]);
		if(A[i]>A[i-1])A[i]--;
		if(A[i]<A[i-1]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 640
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;

int main(){
  int n;
  cin >> n;
  int p[n];
  rep(i,n) cin >> p[i];
  int q[n];
  q[0] = p[0];
  for(int i = 1; i < n; i++){
    q[i] = min(q[i-1],p[i-1]);
  }
  int cnt = 0;
  rep(i,n){
    if(p[i] <= q[i]) cnt++;
  }
  printf("%d\n", cnt);
  return 0;
}


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

int main()
{
	int x,y;	cin>>x>>y;
	if ((x>y or x==1) and y != 1 )
		cout<<"Alice";
	else if ((y>x or y==1) and x!=1)
		cout<<"Bob";
	else 
		cout<<"Draw";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
using namespace std;
map<int, set<int> > adj;
int a, b, n, m;
vector <int> ones;
int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		adj[b].insert(a);
		adj[a].insert(b);
		if (a == 1) 
			ones.push_back(b);		
		else if (b == 1)
			ones.push_back(a);
	}	
	bool found = false;
	for (int i = 0; i < ones.size(); i++) {
		if (adj[ones[i]].find(n) != adj[ones[i]].end()) {
			found = true;
			break;
		}
	}
	if (found)
		cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
}

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

int main(){
	
	int a, b, c, d, e, f, g;

	cin >> a >> b >> c >> d >> e >> f;

	g = a + 5*b + 10*c + 50*d + 100*e + 500*f;
	
	if (g >= 1000){
		cout << "1" << endl;
	}

	if (g < 1000){
		cout << "0" << endl;
	}

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int p, cnt=0;
  for(int i=1; i<=n; i++){
    cin >> p;
    if(p!=i)cnt++;
  }
  if(cnt<=2)cout << "YES";
  else cout << "NO";
  return 0;
}

Measured memory_bytes: 256
N,M = [int(i) for i in input().split()]

q = [0] * N
for _ in range(M):
    a,b = [int(i) for i in input().split()]
    q[a-1] += 1
    q[b-1] += 1

for i in range(M):
    if q[i]%2 != 0:
        print('NO')
        exit()

print('YES')


Measured memory_bytes: 3828
#include<bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define rep(i, j, k) for (auto i = j; i < k; i++)
#define rrep(i, j, k) for (auto i = j; i > k; i--)
using namespace std;

void solve(int &n) {
  map<int, string> name;
  vector<pair<int, int>> v;
  rep(i, 0, n) {
    string l;
    int p, a, b, c, d, e, f, s, m;
    cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
    int t = a + b + c + m * (d + e);
    int mon = m * f * s - p;
    v.push_back({mon, t});
    name[i] = l;
  }
  bool past[51];
  fill(past, past + 51, false);
  vector<string> ans;
  rep(i, 0, n) {
    rep(j, 0, n) {
      if (past[j]) continue;
      bool ok = true;
      rep(k, 0, n) {
        if (past[k]) continue;
        if (v[j].fi * v[k].se < v[k].fi * v[j].se) ok = false;
        if (v[j].fi * v[k].se == v[k].fi * v[j].se && name[j] > name[k]) ok = false;
      }
      if (ok) {
       ans.push_back(name[j]);
       past[j] = true;
      }
    }
  }
  rep(i, 0, n) cout << ans[i] << endl;
  cout << "#" << endl;
}

int main() {
  int n;
  while (cin >> n, n) solve(n);
}



Measured memory_bytes: 3004
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<vector>
#include<cstdio>

using namespace std;
/*
int find(int x, vector<int> &p) {
if (p[x] == x)return x;
return p[x] = find(p[x], p);
}

void uni(int x, int y, vector<int> &p) {
x = find(x, p);
y = find(y, p);
p[x] = y;
}

int same(int x, int y, vector<int> p) {
if (find(x, p) == find(y, p))return 1;
return 0;
}
*/

//long long a[1002];


int main()
{
	long long N, cnt = 0, tmp, ans = 0;
	cin >> N;
	vector<int> L(N);
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	sort(L.begin(), L.end());
	for (int i = 0; i < N-1; i++) {
		cnt += L[i];
	}

	if (L[N-1] < cnt) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}

	char qq;
	cin >> qq;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <numeric>
#include <iomanip>
#define fi first
#define se second
#define fcout(n) cout<<fixed<<setprecision((n))
#define cinl(str) getline(cin,(str))
using namespace std;
bool value(int y,int x,int R,int C){return 0<=y&&y<R&&0<=x&&x<C;}
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long > vll;
typedef vector< vi > vvi;
double pie=acos(-1);
int INF=1000000007;
int dx[4] = { 0,-1,0,1 };
int dy[4] = { -1,0,1,0 };


int main() {
	int n;
	string ans="";
	string s;
	string y=".,!? abcdefghijklmnopqrstuvwxyz";
	int x,count=0;
	cin>>n;
	for(int j=0;j<n;j++){
		ans="";
		cin>>s;
		for(int i=0;i<s.size();i++){
			if(s[i] == '0' && count==0){
				//cout<<"C"<<endl;
				continue;
			}
			else if(s[i] != '0'){
				x=s[i]-'0';
				count++;
				//cout<<"B"<<endl;
			}
			else if(s[i] == '0' && count!= 0) {
				if(x==1){
					ans=ans+y[(count-1)%5];
				}
				if(x==2){
					ans=ans+y[5+(count-1)%3];
				}
				if(x==3){
					ans=ans+y[8+(count-1)%3];
				}
				if(x==4){
					ans=ans+y[11+(count-1)%3];
				}
				if(x==5){
					ans=ans+y[14+(count-1)%3];
				//	cout<<"A"<<endl;
				}
				if(x==6){
					ans=ans+y[17+(count-1)%3];
				}
				if(x==7){
					ans=ans+y[20+(count-1)%4];
				}
				if(x==8){
					ans=ans+y[24+(count-1)%3];
				}
				if(x==9){
					ans=ans+y[27+(count-1)%4];
				}
				count=0;
			}
			if(count!=0 && i==s.size()-1){
				if(x==1){
					ans=ans+y[(count-1)%5];
				}
				if(x==2){
					ans=ans+y[5+(count-1)%3];
				}
				if(x==3){
					ans=ans+y[8+(count-1)%3];
				}
				if(x==4){
					ans=ans+y[11+(count-1)%3];
				}
				if(x==5){
					ans=ans+y[14+(count-1)%3];
				//	cout<<"A"<<endl;
				}
				if(x==6){
					ans=ans+y[17+(count-1)%3];
				}
				if(x==7){
					ans=ans+y[20+(count-1)%4];
				}
				if(x==8){
					ans=ans+y[24+(count-1)%3];
				}
				if(x==9){
					ans=ans+y[27+(count-1)%4];
				}
				count=0;
			}

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

Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  ll n;
  cin >> n;
  vector<string> s(n);
  set<string> st;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    st.insert(s[i]);
  }

  cout << st.size() << ln;

  return 0;
}

Measured memory_bytes: 25044
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)

# Debug output
def chkprint(*args):
    names = {id(v):k for k,v in inspect.currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' = '+repr(arg) for arg in args))

# Binary converter
def to_bin(x):
    return bin(x)[2:]

# Set 2 dimension list
def dim2input(N):
    li = []
    for _ in range(N):
        li.append(list(map(int, input())))
    return li

# --------------------------------------------

dp = None

def main():
    N = input()

    if N[0] == N[1] and N[1] == N[2]:
        print("Yes")
        return

    if N[1] == N[2] and N[2] == N[3]:
        print("Yes")
        return


    print("No")




main()


Measured memory_bytes: 4672
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<map>

#define INF 1000000007
#define LINF 1000000000000000007

using namespace std;

typedef long long Int;
typedef pair<Int, Int> P;

Int gcd(Int x, Int y){
	if(y == 0)
		return x;
	return gcd(y, x % y);
}

Int lcm(Int x, Int y){
	return x * y / gcd(x, y);
}

int n;
string s[51];
int c[51][26] = {0};
int ans[26];

int main(){
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	
	for(int i  = 0; i < 26; i++)
		ans[i] = INF;
	
	for(int i = 0; i < n; i++){
		for(int j = 0; j < s[i].size(); j++){
			c[i][s[i][j] - 'a']++;
		}
		for(int j = 0; j < 26; j++){
			ans[j] = min(ans[j], c[i][j]);
		}
	}
	
	for(int i = 0; i < 26; i++){
		if(ans[i] == 0) continue;
		for(int j = 0; j < ans[i]; j++){
			cout << (char)('a' + i);
		}
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 384
N = gets.strip.to_i
A = gets.split.map(&:to_i)
res = Array.new
res << A.join(' ') + "\n"
for i in 1..(N-1)
  key=A[i]
  j=i-1
  while j >= 0 and A[j] > key
    A[j+1]=A[j]
    j=j-1
  end
  A[j+1] = key
  res << A.join(' ') + "\n"
end
print res.join

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

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976


int main()
{
    int n,l;
    cin >>  n >> l;
    vector<string> v;
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        v.push_back(s);
    }
    sort(v.begin(),v.end());
    for(int i = 0; i < n; i++){
        cout << v[i];
    }
    cout << endl;
}

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

int main() {
	int a=0;
	string q;
	cin >> q;
	int w = q.length();
	/*cout << w;
	cout << q[w-1];
	char c = q[w-1];
	cout << c;*/
	if ( q[w - 1] == '2' || q[w - 1] == '4' || q[w - 1] == '5' || q[w - 1] == '7' || q[w - 1] == '9') {
		cout << "hon";
	}
	else if (q[w-1] == '3') {
		cout << "bon";
	}
	else {
		cout << "pon";
	}
}

Measured memory_bytes: 3032
import java.util.Scanner;

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

        int mot = (int)(n / 1.08);

        String ans = ":(";

        int at = (int)(mot * 1.08);
        int at2 = (int)((mot + 1) * 1.08);

        if(at == n) {
            ans = String.valueOf(mot);
        } else if(at2 == n) {
            ans = String.valueOf(mot+1);
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(a) cerr << #a << ": " << a << endl
 
typedef long long ll;
typedef pair<int, ll> il;
 
#define x first
#define y second
 
const int N = 2e5 + 10;
const int INF = 1e9 + 10;

struct q_data {
	int type, a, b;
};

int tot_q;
q_data q[N];
vector<int> comp;
ll b_sum;

il st[4 * N];
void insert(int at, int stI, int L, int R) {
	if (at < L || R < at) return;

	if (L == R) {
		st[stI].x++;
		st[stI].y += comp[L - 1];

		return;
	}

	int mid = (L + R) / 2;
	insert(at, (stI << 1), L, mid);
	insert(at, (stI << 1) + 1, mid + 1, R);

	st[stI].x = st[(stI << 1)].x + st[(stI << 1) + 1].x;
	st[stI].y = st[(stI << 1)].y + st[(stI << 1) + 1].y;
}
void insert(int at) {
	insert(at, 1, 1, comp.size());
}
il query(int split_at, int pref, int stI, int L, int R) {
	if (L == R) {
		il res;
		
		int left = max(0, split_at - 1 - pref);
		left = min(st[stI].x, left);
		int right = st[stI].x - left;

		res.y = comp[L - 1] * 1LL * (right - left);

		if (pref < split_at && split_at <= pref + st[stI].x)
			res.x = comp[L - 1];
		else res.x = INF;

		return res;
	}

	if (split_at <= pref) {
		return {INF, st[stI].y};
	}
	if (pref + st[stI].x < split_at) {
		return {INF, -st[stI].y};
	}

	int mid = (L + R) / 2;
	il q1 = query(split_at, pref, (stI << 1), L, mid);
	il q2 = query(split_at, pref + st[(stI << 1)].x, (stI << 1) + 1, mid + 1, R);

	return {min(q1.x, q2.x), q1.y + q2.y};
}
il query(int n) {
	int split_at = (n + 1) / 2;
	il res = query(split_at, 0, 1, 1, comp.size());

	int mid = res.x;
	ll optimal = res.y
			+ (split_at - 1) * 1LL * mid
			- (n - split_at + 1) * 1LL * mid;

	return il(mid, optimal);
}

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
 
	cin >> tot_q;

	for (int i = 1; i <= tot_q; i++) {
		scanf("%d", &q[i].type);

		if (q[i].type == 1) {
			scanf("%d %d", &q[i].a, &q[i].b);
			comp.push_back(q[i].a);
		}
	}

	sort(comp.begin(), comp.end());
	comp.resize(unique(comp.begin(), comp.end()) - comp.begin());

	int n = 0;

	for (int i = 1; i <= tot_q; i++) {
		if (q[i].type == 1) {
			n++;
			b_sum += q[i].b;
			
			int at = lower_bound(comp.begin(), comp.end(), q[i].a) - comp.begin() + 1;
			insert(at);
		}
		else {
			il res = query(n);
			printf("%d %lld\n", res.x, res.y + b_sum);
		}
	}
 
	return 0;
}

Measured memory_bytes: 11768
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.nextInt();
            var b = cin.nextInt();
            Console.WriteLine(a + b/2);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const ll mod=1e9+7;
// const int imax = 100000;

int main(){
	int n;
	cin >> n;
	int l[n];
	rep(i,n) cin >> l[i];
	sort(l,l+n,greater<int>());
	int sum = 0;
	for(int i = 1; i < n; i++) sum += l[i];
	if(sum > l[0]) printf("Yes\n");
	else printf("No\n");

	return 0;
}

Measured memory_bytes: 3600
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int Q = Integer.parseInt(sc.next());
		ArrayList<ArrayList<Integer>> edge = new ArrayList<ArrayList<Integer>>();
		for (int i=0;i<N;i++) {
			ArrayList<Integer> edge_list = new ArrayList<Integer>();
			edge.add(edge_list);
		}
		for (int i=0;i<N-1;i++) {
			int a = Integer.parseInt(sc.next())-1;
			int b = Integer.parseInt(sc.next())-1;
			edge.get(a).add(b);
		}
		int[] p = new int[Q];
		int[] x = new int[Q];
		HashMap<Integer, Integer> query = new HashMap<Integer, Integer>();
		for (int i=0;i<Q;i++) {
			p[i] = Integer.parseInt(sc.next())-1;
			x[i] = Integer.parseInt(sc.next());
			if (!query.containsKey(p[i])) {
				query.put(p[i], x[i]);
			} else {
				query.put(p[i], query.get(p[i]) + x[i]);
			}
		}
		// System.out.println(query);
		long[] ans = new long[N];
		// Comparator<int[]> comparator = new Comparator<int[]>() {
  //   		@Override
  //   		public int compare(int[] o1, int[] o2) {
  //   			return Integer.compare(o1[0], o2[0]);
  //   		}
		// };

		ArrayDeque<int[]> queue = new ArrayDeque<int[]>();
		int add_value_2 = 0;
		if (query.containsKey(0)) {
			add_value_2 += query.get(0);
		}
		int[] first = {0, add_value_2};
		queue.add(first);
		while (!queue.isEmpty()) {
			int[] rem = queue.poll();
			ans[rem[0]] = rem[1];
			for (int index : edge.get(rem[0])) {
			// System.out.println(index);

				int add_value = rem[1];
				if (query.containsKey(index)) {
					add_value += query.get(index);
				}
				int[] add_queue = {index, add_value};
				queue.add(add_queue);
			}
		}
		// System.out.println(Arrays.toString(ans));
		// System.out.println(edge);
		// System.out.println(N);
		for (int i=0;i<N;i++) {
			if (i==N-1) {
				System.out.print(ans[i]);
			} else {
				System.out.print(ans[i] + " ");
			}
		}
	}
}

Measured memory_bytes: 179756
#include<bits/stdc++.h>
#define LL long long
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define For(i,a,b) for(int i=a;i>=b;i--)
//#define debug

using namespace std;

int read(){
    char c=getchar(); int flag=1, x=0;
    while(!isdigit(c)){ if(c=='-') flag=-1; c=getchar(); }
    while( isdigit(c)){ x=x*10+(c-'0'); c=getchar(); }
    return flag*x;
}

signed main(){
    
    int n=read(), m=read();
    int num=0, pre=-1;

    FOR(i,1,n){
        char c; cin>>c;
        int now=( c=='L'?1:0 );
        if(now!=pre) num++;
        pre=now;
    }

    int Block=max( 1,num-m*2 );

    #ifdef debug
    cout<<num<<" "<<Block<<endl;
    #endif
    
    cout<<n-Block<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  
  cout << (X-A)%B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <limits.h>
using namespace std;
 
int main()
{
    int n,k;
    cin >> n >> k;
    std::vector<long long int> v;
    std::vector<long long int> sum;

    for(int i=0; i<n; i++){
        long long int tmp;
        cin >> tmp;
        v.push_back(tmp);
        long long int tmpsum = tmp;
        if(i >= 1){
            tmpsum *= sum[i-1];
            if(i >= k){
                tmpsum /= v[i-k];
                //cout << tmp << ":" << sum[i-1] << ":" << v[i-k] << endl;
            }
        }
        sum.push_back(tmpsum);
        //cout << sum[i] << "," << endl;;

    }
    for(int i=k; i<n; i++){
        if(v[i-k] < v[i]){
            cout << "Yes"<< endl;
        }else{
            cout << "No"<< endl;
        }
    }

    return 0;
}

Measured memory_bytes: 6632
#include<cstdio>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<string>
#include<assert.h>
#include<sstream>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e18 + 7;
const int N = 1e5 + 7;
const int INF = 1e9 + 7;
const int MOD = 21092013;
const double EPS = 1e-8;
//-------------head-------------
int n, Q, top;
ll len[N], cnt[N], ans[N];
ll solve(int D, ll p) {
	int d = D;
	while (d && p) {
		int l = 1, r = d - 1;
		while (l + 1 < r) {
			int m = (l + r) >> 1;
			len[m] <= p ? l = m : r = m;
		}
		if (l > r)
			break;
		d = (len[r] <= p ? r : l);
		cnt[d] += p / len[d] * cnt[D];
		p %= len[d];
	}
	return p;
}
int main() {
	scanf("%d%d", &n, &Q);
	len[top = 1] = n;
	rep(_Q, 0, Q)
	{
		ll qi;
		scanf("%lld", &qi);
		while (top && len[top] >= qi)
			--top;
		len[++top] = qi;
	}
	cnt[top] = 1;
	for (int i = top; i > 0; --i) {
		ll p = solve(i, len[i]);
		ans[p] += cnt[i];
	}
	for (int i = n - 1; i >= 1; --i)
		ans[i] += ans[i + 1];
	rep(i, 1, n + 1)
		printf("%lld\n", ans[i]);
	return 0;
}


Measured memory_bytes: 4096
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
    }

    let mut edges = vec![];

    let num_remove = if n % 2 == 0 {
        n + 1
    } else {
        n
    };

    for i in 1..n {
        for j in i+1..=n {
            if i + j == num_remove {
                continue;
            }
            edges.push((i, j));
        }
    }

    println!("{}", edges.len());
    for (a, b) in edges {
        println!("{} {}", a, b);
    }
}


Measured memory_bytes: 2176
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Main {

  static int n;
  static List<Long> a, b;
  static long ans;

  public static void main(String[] args) throws Exception {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter out = new PrintWriter(System.out);

    String[] in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);

    a = new ArrayList<>();
    b = new ArrayList<>();

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

      in = br.readLine().split(" ");
      a.add(Long.parseLong(in[0]));
      b.add(Long.parseLong(in[1]));
    }

    br.close();

    List<Long> sa = a.stream().sorted().collect(Collectors.toList());
    List<Long> sb = b.stream().sorted().collect(Collectors.toList());

    if(n % 2 == 0){
      ans = ((sb.get(n/2) + sb.get(n/2 - 1)) - (sa.get(n/2) + sa.get(n/2 - 1))) + 1;
    }else{
      ans = sb.get(n/2) -  sa.get(n / 2) + 1;
    }

    out.println(ans);

    out.flush();
  }
}


Measured memory_bytes: 71956
M,D = map(int,input().split())
months = range(1,M+1)
days = range(10,D+1)
cnt = 0
for month in months:
  for day in days:
    day = str(day)
    if (int(day[0])>1)&(int(day[1])>1):
      if (int(day[0])*int(day[1]))==month:
        cnt += 1

print(cnt)

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

int main() {
  int N, T;
  cin >> N >> T;
  // <B美味しさ, A時間>
  vector<pair<int, int>> foods(N);
  rep(i, 0, N) {
    cin >> foods[i].second >> foods[i].first;
  }

  sort(All(foods));

  auto most_good_food = foods[foods.size() -  1];
  if (T == 1) {
    cout << most_good_food.first << endl;
    return 0;
  }

  vector<vector<int>> dp1(N + 1, vector<int> (T + 1, 0));
  rep(i, 1, N + 1) {
    auto food = foods[i - 1];
    rep(j, 1, T + 1) {
      int time = j;
      dp1[i][j] = dp1[i - 1][j];
      if (time >= food.second) {
        dp1[i][j] = max(dp1[i - 1][j - food.second] + food.first, dp1[i][j]);
      }
    }
  }

  reverse(All(foods));
  vector<vector<int>> dp2(N + 1, vector<int> (T + 1, 0));
  rep(i, 1, N + 1) {
    auto food = foods[i - 1];
    rep(j, 1, T + 1) {
      int time = j;
      dp2[i][j] = dp2[i - 1][j];
      if (time >= food.second) {
        dp2[i][j] = max(dp2[i - 1][j - food.second] + food.first, dp2[i][j]);
      }
    }
  }

  reverse(All(foods));

  int ans = 0;
  rep (i, 1, N+1) {
    rep(j, 0, T) {
      ans = max(ans, dp1[i-1][j] + dp2[N - i][T - 1 - j] + foods[i-1].first);
    }
  }
  cout << ans << endl;
};


Measured memory_bytes: 70912
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    int N = Integer.parseInt(sc.nextLine());
    int[] num = new int[N];
    for(int i = 0; i < N; i++){
      num[i] = Integer.parseInt(sc.next());
    }
    
    Set<Integer> set = new HashSet<>();
    for(int i = N-1; i >= 0; i--){
      int a = i+1;
      if(a > N/2 && num[i] == 1){
        set.add(a);
      }else{
        int j = 2;
        int b = a * j;
        int count = 0;
        while(b <= N){
          if(set.contains(b)){
            count++;
            count %= 2;
          }
          j++;
          b = a * j;
        }
        if((count == 0 && num[i] == 1) || (count == 1 && num[i] == 0)){
          set.add(a);
        }
      }
    }
    List<Integer> list = new ArrayList<>(set);
    System.out.println(list.size());
    for(int i = 0; i < list.size(); i++){
      if(i+1 != list.size()){
        System.out.print(list.get(i));
        System.out.print(" ");
      }else{
        System.out.println(list.get(i));
      }
    }
  }
}

Measured memory_bytes: 70252
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;

const int INF = 99999999;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int H, W;
vector<string> s;

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

int bfs(int sx, int sy, int gx, int gy) {
    queue<P> que;
    que.push(P(sx, sy));
    vector<vector<int>> d(H, vector<int>(W, INF));
    d[sx][sy] = 0;

    while (!que.empty()) {
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy)
            return d[gx][gy];

        rep(k, 4) {
            int nx = p.first + dx[k], ny = p.second + dy[k];

            if (inside(nx, ny) && s[nx][ny] != 'x' && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }

    // not reachable
    return INF;
}

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

    while (cin >> W >> H, W) {
        s.clear();
        s.resize(H);
        vector<P> dust;
        int sx, sy;
        rep(i, H) {
            cin >> s[i];
            rep(j, W) {
                if (s[i][j] == 'o') {
                    sx = i;
                    sy = j;
                } else if (s[i][j] == '*') {
                    dust.emplace_back(P(i, j));
                }
            }
        }

        int n = dust.size();
        vector<int> ds(n);
        rep(i, n) {
            ds[i] = bfs(sx, sy, dust[i].first, dust[i].second);
        }

        vector<vector<int>> dd(n, vector<int>(n));
        rep(i, n) {
            rep(j, n) {
                dd[i][j] = bfs(dust[i].first, dust[i].second, dust[j].first, dust[j].second);
            }
        }

        int ans = INF;
        rep(i, n) {
            vector<int> perm(n);
            iota(all(perm), 0);
            do {
                if (perm[0] != i) continue;
                int t = ds[i];
                rep(j, n - 1) {
                    t += dd[perm[j]][perm[j + 1]];
                }
                ans = min(ans, t);
            } while (next_permutation(all(perm)));
        }

        cout << (ans == INF ? -1 : ans) << endl;
    }
}

Measured memory_bytes: 3036
import random

class Dice():
    def __init__(self, numbers):
        self.numbers = numbers
        S = [1, 5, 2, 3, 0, 4]
        N = [4, 0, 2, 3, 5, 1]
        W = [3, 1, 0, 5, 4, 2]
        E = [2, 1, 5, 0, 4, 3]
        self.tumble = {0: S, 1: N, 2: W, 3: E}
        self.table = []
        
    def rol(self, command):
        prev = self.numbers.copy()
        for i, t in enumerate(self.tumble[command]):
            self.numbers[t] = prev[i]

    def equal(self, dice2):
        if len(self.table) == 0:
            for _ in range(1000):
                self.rol(random.randint(0, 3))
                numbers = self.numbers.copy()
                if numbers not in self.table:
                    self.table.append(numbers)
        if dice2.numbers in self.table:
            return True
        else:
            return False
            
n = int(input())

dices = []

for _ in range(n):
    dice = Dice((list(map(int, input().split()))))
    dices.append(dice)

frag = True
for i in range(n-1):
    for j in range(i+1, n):
        if dices[i].equal(dices[j]):
            frag = False
            break
if frag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 8436
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>
#include <stdio.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;
ll MODP = 998244353;

ll kai(ll x,ll y){
  if(y == 0)return 1;
  if(y == 1)return x;
  if(y&1){
    return (x*kai(x,y-1))%MOD;
  }else{
    ll t = kai(x,y/2);
    return (t*t)%MOD;
  }
}

ll comb(ll a,ll b,vector<ll> &p){
  if(a == 0)return 1;
  if(b == 0)return 1;
  ll ans = p[a+b];
  ans = (ans*kai(p[a],MOD-2))%MOD;
  ans = (ans*kai(p[b],MOD-2))%MOD;
  return ans;
}

ll mind(int x,vector<int> &v){
  int ok = v.size()-1,ng = -1;
  while(ok - ng > 1){
    int next = (ok+ng)/2;
    if(v[next] > x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}

ll maxd(int x,vector<int> &v){
  int ok = 0,ng = v.size();
  while(ng - ok > 1){
    int next = (ok+ng)/2;
    if(v[next] < x){
      ok = next;
    }else{
      ng = next;
    }
  }
  return ok;
}


int main(){
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  bool flag = false;
  while(k > 0){
    if(a < b){
      c *= 2;
      k--;
    }else{
      b *= 2;
      k--;
    }
  }
  if(a < b && b < c){
    flag = true;
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 3676
import sys
input = sys.stdin.readline
N, Q = map(int, input().split())
graph = [[] for _ in range(N)]
for _ in range(N - 1):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    graph[a].append(b)
    graph[b].append(a)

count = [0] * N
for _ in range(Q):
    p, x = map(int, input().split())
    count[p - 1] += x

used = [False] * N
stack = [0]
s_pop = stack.pop
s_append = stack.append
used[0] = True
while len(stack) != 0:
    tmp = s_pop()
    for i in graph[tmp]:
        if not used[i]:
            s_append(i)
            count[i] += count[tmp]
            used[i] = True

print (*count)

Measured memory_bytes: 55856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

int main(){
  int N;
  cin>>N;
    
vector<int> A(N);
  for(int i=0;i<N;i++){
  cin>>A[i];
  }
  
  sort(A.begin(),A.end());
  int flag=0;
  for(int i=0;i<N-1;i++){
   if(A[i]==A[i+1]){flag=1;}
  }
  
  if(flag==1)cout<<"NO"<<endl;
  if(flag==0)cout<<"YES"<<endl;
  
 
}


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater <>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
using namespace std;
using ll = long long;
typedef std::pair<ll,ll> P;
//#include <boost/multiprecision/cpp_int.hpp>
//using bint = boost::multiprecision::cpp_int;
const int mod = 1000000007;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};



ll mod_pow(ll x, ll n, ll mod){
    if (n==0) return 1;
    ll res = mod_pow(x*x%mod,n/2,mod);
    if(n&1) res = res*x%mod;
    return res;
}
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    ll temp = mod_pow(2,n,mod);
    mint ans = temp;
    ans -= 1;
    
    a = min(n-a,a);
    b = min(n-b,b);
    
    mint  bfact = 1;
    rep(i,b){
        bfact *= (i+1);
    }
    mint afact = 1;
    rep(i,a){
        afact *= (i+1);
    }
    
    mint am = 1;
    rep(i,a){
        am *= (n-i);
    }
    
    mint bm = 1;
    rep(i,b){
        bm *= (n-i);
    }
    ans -= bm/bfact;
    ans -= am/afact;
    
    cout << ans.x;
}



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

using namespace std;

int main() {
  string s,t;
  cin >> s >> t;
  for(int i = 0; i < s.size(); i++) {
    if(s == t) {
      cout << "Yes";
      return 0;
    }
    else {
      s = s.back() + s.substr(0,s.size()-1);
    }
  }
  cout << "No";
  return 0;
}

Measured memory_bytes: 256
N = int(input())

def dfs(s):
    if int(s) > N:
        return 0
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    else:
        ret = 0
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int maxa, maxb;
	cin >> maxa >> maxb;
	int a, b;
	cin >> a >> b;
	int maxt = 0;
	if (maxa%a != 0) maxt = maxa / a + 1;
	else maxt = maxa / a;
	if (maxb%b != 0) maxt = max(maxt, maxb / b + 1);
	else maxt = max(maxt, maxb / b);
	cout << n - maxt << endl;
	return 0;
}

Measured memory_bytes: 3092
#include <iostream>
#include <deque>
#define llint long long
#define inf 1000000000000000000

using namespace std;

llint M, N, K;
llint A[100005];
llint dp[100005][305];
deque<llint> deq[305];

int main(void)
{
	cin >> N >> M >> K;
	for(int i = 1; i <= N; i++) cin >> A[i];
	
	for(int i = 0; i <= K; i++){
		dp[0][i] = -inf;
		deq[i].push_back(0);
	}
	dp[0][0] = 0;
	
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= K; j++){
			dp[i][j] = dp[deq[j-1].back()][j-1] + j * A[i];
		}
		for(int j = 1; j <= K; j++){
			if(deq[j].back() == i-M) deq[j].pop_back();
			while(deq[j].size() && dp[deq[j].front()][j] <= dp[i][j]) deq[j].pop_front();
			deq[j].push_front(i);
		}
	}
	
	llint ans = 0;
	for(int i = 0; i <= N; i++) ans = max(ans, dp[i][K]);
	
	cout << ans << endl;
	return 0;
}

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

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define mod (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vb vector<bool>
#define vs vector<string>
#define vii vector<vector<int>>
#define vllll vector<vector<ll>>
#define ALL(a) (a).begin(), (a).end()

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

void print(bool f)
{
    cout << (f ? "Yes" : "No") << endl;
}

void Print(bool f)
{
    cout << (f ? "YES" : "NO") << endl;
}

int main(void)
{
    ll n;
    cin >> n;
    vll a(n);
    ll m = 1;
    rep(i, 0, n)
    {
        cin >> a[i];
        if (a[i] == 0)
            return cout << 0 << endl, 0;
    }
    rep(i, 0, n)
    {
        if (m > 1000000000000000000 / a[i])
            return cout << -1 << endl, 0;
        m = m * a[i];
    }
    cout << m << endl;
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

ll x,y,z,k;
ll a[1000], b[1000], c[1000];

int main()
{
#define FASTIO
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> x >> y >> z >> k;
  forn(i,x) cin >> a[i];
  forn(i,y) cin >> b[i];
  forn(i,z) cin >> c[i];

  sort(a,a+x); reverse(a,a+x);
  sort(b,b+y); reverse(b,b+y);
  sort(c,c+z); reverse(c,c+z);

  vl ab;
  forn(i,x) forn(j,y) {
    ab.push_back(a[i]+b[j]);
  }

  sort(ab.begin(),ab.end());

  vl ab2;
  for (int i = 0; i < (int)ab.size() && i <= k; i++)
    ab2.push_back(ab[ab.size()-i-1]);

  vl res;
  forn(i,z) forn(j,ab2.size()) {
    res.push_back(c[i]+ab2[j]);
  }

  sort(res.begin(),res.end());

  for (int i = 0; i < k; i++)
    cout << res[res.size()-i-1] << "\n";

  return 0;
}


Measured memory_bytes: 42756
S = input()
N = len(S)
nums = []
if N>2:
    for i in range(2**(N-1)):
        bi = bin(i)[2:].zfill(N-1)
        bi = '1' + bi + '1'
        l = 0
        for r in range(1,N+1):
            if bi[r] == '1':
                nums.append(int(S[l:r]))
                l = r
    res = sum(nums)
else:
    if N==1:
        res = int(S)
    else:
        res = int(S)+int(S[0]) + int(S[1])
print(res)

Measured memory_bytes: 3064
#include<stdio.h>
#define X 2000

int n,A[X];
int solve(int, int);

int main(){

  int i,q;
  int m[X];

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

  scanf("%d",&q);
  for(i=0;i<q;i++)scanf("%d",&m[i]);

  for(i=0;i<q;i++){
    if(solve(0,m[i])==1)printf("yes\n");
    else printf("no\n");
  }

  return 0;
}

int solve(int i, int m){

  if(m == 0)return 1;
  if(i >= n)return 0;
  int res1 = solve(i+1,m-A[i]);
  if(res1 == 1)return 1;

  int res2 = solve(i+1,m);
  if(res2 == 1)return 1;
  return 0;
}

Measured memory_bytes: 588