akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	string s;
	int n;
	cin >> n;
	cin >> s;

	int cnt = 0;
	rep(i, s.length()) {
		if (s[i] == '(')cnt++;
		else {
			if (cnt > 0)cnt--;
			else 
				cout << '(';
		}
	}
	cout << s;
	rep(i, cnt)cout << ")";
	cout << endl;
	

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
import math

def main():
  n = int(input())
  a = list(map(int, input().split()))

  count = 0
  sum = 0
  min_number = 10000000000
  for i in a:
    count += 1 if i<0 else 0
    sum += abs(i)
    min_number = min(min_number, abs(i))
    
  if count % 2 == 0:
    print(sum)
  else:
    print(sum - min_number*2)
  
main()

Measured memory_bytes: 15020
/*ANKON GHOSH
  KUET,ECE 2K16*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define MAX 100000
#define mod 1000000007
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define Case(i) cout<<"Case #"<<i<<": "
#define pf(a) printf("%lld\n",a)
#define pfsn printf("NO\n")
#define pfs  printf("YES\n")
#define pff(a,b) printf("%lld %lld\n",a,b)
#define pfff(a,b,c) printf("%lld %lld %lld\n",a,b,c)
#define pffff(a,b,c,d) printf("%lld %lld %lld %lld\n",a,b,c,d)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define LOOP(x,y) for(ll r=x;r<=y;r++)
#define RFOR(i,n) for(ll i=n-1;i>=0;i--)
#define RFOR1(i,n) for(ll i=n;i>0;i--)
#define RLOOP(x,y) for(ll i=y;i>=x;i--)
#define m_p(a,b) make_pair(a,b)
#define p_b(a) push_back(a)
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
map<ll,ll>mp1,mp;
vector<pair<ll,pair<ll,ll> > >vpp,vpp1;
vector<pair<ll,ll> >v,vp,fin;
vector<ll>v1,v2,dummy;
map<pair<ll,ll>,bool>mbb;
map<ll,bool>mb;
ll n,k,a,b,c,d,ta,sum=0,cnt=0,m,l,req,sz,maxi;
bool sortbysec(const pair<pair<ll,ll>,ll> &a,const pair<pair<ll,ll>,ll> &b)
{
    return (a.second < b.second);
}
vector<ll>adj[MAX+10];
bool visited[MAX+10];
ll dep[MAX+10];
void reset()
{
   FOR(i,MAX)
   {
       visited[i]=0;
       dep[i]=0;
       adj[i].clear();
   }
   mp.clear();
   mp1.clear();
}
int main()
{
    fast;
    ///cin>>ta;
    //FOR(test,ta)
    //{
       string s;
       cin>>s;
       bool flag=0;
       FOR(i,s.size())
       {
           if(s[i]=='7')
           {
               flag=1;
           }
       }
       if(flag) cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
    ///}
    return 0;
}


Measured memory_bytes: 5996
#include <stdio.h>
#include <stdlib.h>
  
int linearSearch(int *, int, int);
  
main(){
  int n,q,i,findN=0;
  int *sAry, *tAry;
  
  scanf("%d", &n);
  sAry = (int *)malloc((n+1)*sizeof(int)); //????????¨???+1
  for(i=0; i<n; i++) scanf("%d", sAry+i);
  scanf("%d", &q);
  tAry = (int *)malloc(q*sizeof(int));
  for(i=0; i<q; i++) scanf("%d", tAry+i);
  
  for(i=0; i<q; i++) findN+=linearSearch(sAry, n, tAry[i]);
  
  printf("%d\n", findN);
  
  return 0;
}
  
int linearSearch(int *ary, int n, int a){
  int i=0;
  ary[n]=a;
  while(ary[i]!=a) i++;
  if(i==n) return 0;
  return 1;
}

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


int main(){
  int n;
  cin >> n;
  vector<ll> a(n, 0), b;
  rep(i, n)cin >> a.at(i);
  sort(a.rbegin(), a.rend()); //降順
  ll check = 0, s=0;

  while(check+1<n && check < n){
    if(a.at(check) == a.at(check+1)){
      b.push_back(a.at(check));
      check += 2;
    }
    else{
      check += 1;
    }
  //  cout << check<<endl;
  }
  sort(b.rbegin(), b.rend());
  ll bn = b.size();
  //cout << bn << endl;
  //rep(i, bn) cout << b.at(i);
  if(bn >= 2){
    s = b.at(0) * b.at(1);
  }
  cout << s;
  }



Measured memory_bytes: 4620
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>

using namespace std;

const int INF = (1<<30) - 1;
int S[10001][1262];

int main(){
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int N, M;
    while(cin>>N>>M, N|M){
        memset(S, 0, sizeof(S));
        
        int r;
        cin >> r;
        while(r--){
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            if(s)
                S[m][t]++;
            else
                S[m][t]--;
        }
        for(int i=1; i<=M; i++)
            for(int j=1; j<1262; j++)
                S[i][j] += S[i][j-1];
            
        int q;
        cin >> q;
        while(q--){
            int s, e, m;
            cin >> s >> e >> m;
            int sum = 0;
            for(int i=s; i<e; i++)
                sum += S[m][i] > 0;
            cout << sum << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 50468
#![allow(non_snake_case,unused_imports,dead_code)]
use std::io::Read;
use std::cmp::max;
use std::cmp::min;
use std::str::FromStr;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::BinaryHeap;
use std::cmp::Ordering;

fn comp_f64(a: &f64, b: &f64) -> Ordering {
    if a < b {
        return Ordering::Less;
    } else if a > b {
        return Ordering::Greater;
    }
    Ordering::Equal
}

fn main() {

    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut buf_it = buf.split_whitespace();

    let A = buf_it.next().unwrap().parse::<isize>().unwrap();
    let B = buf_it.next().unwrap().parse::<isize>().unwrap();
    let _C = buf_it.next().unwrap().parse::<isize>().unwrap();
    let K = buf_it.next().unwrap().parse::<isize>().unwrap();

    let ans;

    if K <= A{
        ans = K;
    } else if K <= A+B{
        ans = A;
    } else {
        ans = A+A+B-K;
    }

    println!("{}",ans);

}

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

using ll = int64_t;
#define int ll

#define FOR(i, a, b) for (int i = int(a); i < int(b); i++)
#define REP(i, b) FOR(i, 0, b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1)
    printEoln();
  if (suc == 2)
    printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

signed main() {
  int n, m;
  std::cin >> n >> m;
  int ans = 0;
  priority_queue<int> que;
  REP(i, n) {
    int a = read();
    que.push(a);
  }
  REP(i, m) {
    int top = que.top();
    que.pop();
    que.push(top / 2);
  }
  REP(i, n) {
    ans += que.top();
    que.pop();
  }
  print(ans);
}


Measured memory_bytes: 1400
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first1,
	BidirectionalIterator last1,
	BidirectionalIterator first2,
	BidirectionalIterator last2)
{
	if ((first1 == last1) || (first2 == last2)) {
		return false;
	}
	BidirectionalIterator m1 = last1;
	BidirectionalIterator m2 = last2; --m2;
	while (--m1 != first1 && !(*m1 < *m2)) {
	}
	bool result = (m1 == first1) && !(*first1 < *m2);
	if (!result) {
		// ???
		while (first2 != m2 && !(*m1 < *first2)) {
			++first2;
		}
		first1 = m1;
		std::iter_swap(first1, first2);
		++first1;
		++first2;
	}
	if ((first1 != last1) && (first2 != last2)) {
		// ???
		m1 = last1; m2 = first2;
		while ((m1 != first1) && (m2 != last2)) {
			std::iter_swap(--m1, m2);
			++m2;
		}
		// ??¢
		std::reverse(first1, m1);
		std::reverse(first1, last1);
		std::reverse(m2, last2);
		std::reverse(first2, last2);
	}
	return !result;
}

template < class BidirectionalIterator >
bool next_combination(BidirectionalIterator first,
	BidirectionalIterator middle,
	BidirectionalIterator last)
{
	return next_combination(first, middle, middle, last);
}

int main() {
	int N,M,K;cin>>N>>M>>K;
	vector<int>as(N),bs(N);
	for (int i = 0; i < N; ++i) {
		cin>>as[i];
	}
	for (int j = 0; j < N; ++j) {
		cin>>bs[j];
	}
	vector<int>perms(N);
	iota(perms.begin(),perms.end(),0);
	int ans=0;
	do {
		do {
			int nans=0;
			int rest(M);
			for (int i = 0; i < K; ++i) {
				int use=min(rest,bs[perms[i]]);
				nans+=use*as[perms[i]];
				rest-=use;
			}
			nans+=rest;
			ans=max(ans,nans);
		}while(next_permutation(perms.begin(),perms.begin()+K));
	}while(next_combination(perms.begin(),perms.begin()+K,perms.end()));
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3100
N = int(input())
ans = ((N*(N+1)*(2*N+1)//6) - (N*(N+1)*(2*N+3)//2) + (N*(N+1)*(N+2)))//2
for _ in range(N-1):
  u,v = [int(i) for i in input().split()]
  if v>u:
    u,v = v,u
  ans -= (N-u+1)*v
print(ans)

Measured memory_bytes: 74504
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll A, B;
    cin >> A >> B;
    cout << max((ll)0, A-2*B) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma comment(linker, "/STACK:16777216")
#pragma warning( disable : 6031)
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <map>
#include <stack>
#include <set>
#include <queue>
#include <numeric>
#include <algorithm>
#include <utility>
#include <bitset>
#include <cmath>
#include <sstream>
#include <functional>
#include <iomanip>
#include <limits>

#define all(a) (a).begin(),(a).end()
#define sz(a) (int)(a).size()
#define eps (1e-9)
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<double> vd;
typedef vector< vd > vvd;
typedef vector< string > vs;
typedef pair< int, int > pii;
typedef vector< pii > vpii;
typedef tuple<int, int, int> tiii;


int main()
{
#ifdef LOCAL_MACHINE
	freopen("input.txt", "rt", stdin);
	freopen("output.txt", "wt", stdout);
#endif
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	vi b(n - 1);
	for (int i = 0; i < n - 1; i++)
		cin >> b[i];
	vi a(n, INT_MAX);
	for (int i = 0; i < sz(b); i++)
	{
		a[i] = min(a[i], b[i]);
		a[i + 1] = min(a[i + 1], b[i]);
	}
	
	cout << accumulate(all(a), 0);
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)

	m := make(map[string]bool)
	for i := 0; i <= 999; i++ {
		ss := fmt.Sprintf("%03d", i)
		k := 0
		for j := 0; j < n; j++ {
			if s[j] == ss[k] {
				k++
				if k == 3 {
					m[ss] = true
					break
				}
			}
		}
	}

	fmt.Println(len(m))
}


Measured memory_bytes: 1024
#include <iostream>
#define inf 1000000000

using namespace std;

int n, m;
int a[55], b[55];
int dp[55][55][55][55][2][2][2];

int dfs(int i, int j, int k, int l, int t, int p, int c)
{
	if(dp[i][j][k][l][t][p][c] != -inf) return dp[i][j][k][l][t][p][c];
	
	int ret, sum;
	if(t == 0){
		ret = -inf;
		if(j <= n){
			if(a[j] >= 0) ret = max(ret, dfs(i, j+1, k, l, 1, 0, 1));
			else ret = max(ret, dfs(i, j+1, l-1, l, 1, 0, 1));
		}
		
		if(p == 1){
			ret = max(ret, 0);
		}else{
			sum = 0;
			for(int x = i+1; x < j; x++) if(a[x] >= 0) sum += a[x];
			for(int x = k+1; x < l; x++) if(b[x] >= 0) sum -= b[x];
			ret = max(ret, sum + dfs(j-1, j, l-1, l, 1, ((c == 0)?1:0), 0));
		}
	}
	else if(t == 1){
		ret = inf;
		if(l <= m){
			if(b[l] >= 0) ret = min(ret, dfs(i, j, k, l+1, 0, 0, 1));
			else ret = min(ret, dfs(j-1, j, k, l+1, 0, 0, 1));
		}
		
		if(p == 1){
			ret = min(ret, 0);
		}else{
			sum = 0;
			for(int x = i+1; x < j; x++) if(a[x] >= 0) sum += a[x];
			for(int x = k+1; x < l; x++) if(b[x] >= 0) sum -= b[x];
			ret = min(ret, sum + dfs(j-1, j, l-1, l, 0, ((c == 0)?1:0), 0));
		}
	}
	
	//cout << i << j << k << l << t << p << " " << ret << endl;
	return dp[i][j][k][l][t][p][c] = ret;
}


int main(void)
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++) cin >> a[i];
	for(int i = 1; i <= m; i++) cin >> b[i];
	
	for(int i = 0; i <= n+1; i++){
		for(int j = 0; j <= n+1; j++){
			for(int k = 0; k <= m+1; k++){
				for(int l = 0; l <= m+1; l++){
					for(int t = 0; t < 2; t++){
						for(int p = 0; p < 2; p++){
							dp[i][j][k][l][t][p][0] = -inf;
							dp[i][j][k][l][t][p][1] = -inf;
						}
					}
				}
			}
		}
	}
	
	cout << dfs(0, 1, 0, 1, 0, 0, 0) << endl;
	return 0;
}

Measured memory_bytes: 255244
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		String W = sc.next();

		int count = 0;

		while (sc.hasNext()) {
			String T = sc.next().toLowerCase();;

			if (T.equals("END_OF_TEXT")) {
				break;
			}
			if (T.equals(W)) {
				count++;
			}
		}


		System.out.println(count);
	}
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, k;

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

    cin>>n>>k;
    int i=1;
    while (--k) {
	i += 2;
    }

    cout<<(i <=n ? "YES\n" : "NO\n");
    
    
    return 0;
}


Measured memory_bytes: 3536
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<vector<int> > nyu(int h, int w) {
	vector<vector<int> > a(h + 2, vector<int>(w + 2, h*w + 1));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i + 1][j + 1];
		}
	}
	return a;
}
vector<int> nyu1(int n) {
	vector<int> c(n);
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	return c;
}
int main() {
	int n;
	cin >> n;
	string ans = "Christmas";
	string tui = " Eve";
	for (int i = 25; i > n; i--) {
		ans = ans + tui;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(700000)

def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

def print_l(l):
    print(' '.join(map(str, l)))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

s = s_in()
q = n_in()

d = True

pre = []
suf = []

for _ in range(q):
    query = s_in()
    if len(query) == 1:
        d = not d
    else:
        _, f, c = query.split()
        if d:
            if f == '1':
                pre.append(c)
            else:
                suf.append(c)
        else:
            if f == '1':
                suf.append(c)
            else:
                pre.append(c)

s = "".join(pre[::-1]) + s + "".join(suf)

if d:
    print(s)
else:
    print(s[::-1])


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

#define sz(s) (int)(s).size()
#define re(i, n) for (int i = 1; i <= n; i ++)
#define pb push_back
#define finish(x) return cout << x << endl, 0
#define MP make_mair
#define trav(x, a) for(auto& x: a)
#define all(x) (x).begin,(x).end()
#define Sor(x) sort(all(x))
#define REV(x) reverse(all(x))
#define F first
#define S second
#define I insert
#define N 222222
#define MOD 100000007

using namespace std;

typedef long long ll;
vector <ll> vll;
template <class T> bool umin(T& a, T b) {if(a>b){a = b; return 1;}return 0;}
template <class T> bool umax(T& a, T b) {if(a<b){a=b; return 1;}return 0;}
template <class T, class TT> bool pal(T a, TT n){int k = 0; for(int i =0; i <= n / 2; i ++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

ll powmod(ll a, ll b, ll m = MOD){ll r = 1;while(b>0){if(b&1)r=r*a%m;a=a*a%m;b>>=1;}return r;}

int i;
int main()
{	
	ll n;
	cin >> n;
	for(i = 1; i <= 1000; i ++)
	{
		ll k = pow(2, i);
		if (k > n)
			break;
	}
	ll ans = pow(2, i - 1);
	
	cout << ans * 2 - 1;
	







	getchar();
	getchar();
	return 0;
}

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

using namespace std;

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

  vector<int> B(N);
  for (int i = 0; i < N; i++) cin >> B[i];

  int64_t answer = 0;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= 1; j++) {
      int64_t attack = min(A[i + j], B[i]);
      answer += attack;
      A[i + j] -= attack;
      B[i] -= attack;
    }
  }
  cout << answer << "\n";

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define ld long double
#define mod 1000000007LL
#define eps 1e-13
// #define PI 3.141592653589793238L
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pil pair<int, long long>
#define pli pair<long long, int>
#define mp make_pair
#define F first
#define S second
#define pb push_back
#define fo(i,a,n) for(i = (a); i < (n); i++)
#define gtl(x) getline(cin, (x))
#define flsh fflush(stdout)
#define sws ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
#define sz(a) (int)((a).size())
#define io_file freopen("D:/Coding Problems/Contest/input_file.in", "r", stdin); freopen("D:/Coding Problems/Contest/output_file.out", "w", stdout)

ll modx(ll Base, ll exponent)
{
	ll ans = 1;
	if(Base == 1)
		return Base;
	while(exponent)
	{
		if(exponent & 1)
			ans = (ans * Base)%mod;
		Base = (Base * Base)%mod;
		exponent = exponent >> 1;
	}
	return ans;
}

ll inmodx(ll num)
{
	return (modx(num, mod-2LL));
}

bool cmp(pll a, pll b)//true for a before b
{
	if(a.F*b.S < b.F*a.S)
		return 1;
	if(a.F*b.S > b.F*a.S)
		return 0;
	if(a.F <= b.F)
		return 1;
	return 0;
}

const int N = (1e5) + 9;
const int M = (N<<2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 100;
const int SQRT = BUCK+9;

vi arr;

void solve()
{
	int m, k, i, val;
	cin >> m >> k;
	if(m == 1 && k == 0)
	{
		cout << "0 0 1 1\n";
		return;
	}
	arr.clear();
	val = 0;
	fo(i,0,(1<<m))
		if(i != k)
		{
			val ^= i;
			arr.pb(i);
		}
	if(val == k)
	{
		for(auto x : arr)
			cout << x << " ";
		cout << k << " ";
		reverse(all(arr));
		for(auto x : arr)
			cout << x << " ";
		cout << k << '\n';
	}
	else
		cout << -1 << '\n';
	return;
}

int main()
{
	sws;
	clock_t clk;
	clk = clock();
	// io_file;
	// srand (time(NULL));

	//Code here
	int t = 1, cs;
	cout << fixed << setprecision(9);
	// cin >> t;
	fo(cs,1,t+1)
	{
		// cout << "Case #" << cs << ": ";
		solve();
	}
	// Code ends here

	clk = clock() - clk;
	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	return 0;
}

Measured memory_bytes: 2424
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    ll n, m;
    cin >> n >> m;
    if(2*n > m){
        cout << m/2 << endl;
    }else{
        ll ans = 0;
        ans += n;
        m = m - 2*n;
        ans += m/4;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<vector>
#include<cctype>
using namespace std;
string s;
signed main()
{
	getline(cin,s);
	for(register int i(0);i<=(s.length()-9);i++){putchar(s[i]);}
	return putchar(10),0;
}

Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<ll,ll> P;

int main(void){
	int i;

	string x;
	cin >> x;
	string a=x;
	reverse(a.begin(),a.end());
	int n=x.size();
	REP(i,n){
		if(a[i]=='b') a[i]='d';
		else if(a[i]=='d') a[i]='b';
		else if(a[i]=='p') a[i]='q';
		else a[i]='p';
	}


	string ans="No";
	if(a==x) ans="Yes";

	cout << ans << endl;



	return 0;
}


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

int W,H,N;
int ex,ey;
bool used[222][222][4];
bool fie[222][222];
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


int solve( int x, int y, int d ){
  if( used[x][y][d] ) return -(1<<29);
  used[x][y][d] = true;
  if( x == ex && y == ey ) return 1;  
  for(int i=0;i<4;i++){
    int nd = (d+i-1+4)%4;
    int nx = x + 2*dx[nd], ny = y + 2*dy[nd];
    int cx = x + dx[nd], cy = y + dy[nd];
    if( fie[cx][cy] ) continue;
    return solve( nx, ny, nd ) + 1;
  }
  return -(1<<29);  
}

void nuri(int x1,int y1,int x2,int y2 ){
  for(int x=x1;x<=x2;x++)
    for(int y=y1;y<=y2;y++)
      fie[x][y] = true;
}

int main(){
  while( cin >> W >> H >> N && (H||H||N) ){
    memset( used,0,sizeof( used ) );
    memset( fie,0,sizeof( fie ) );
    for(int i=0;i<=2*W;i++)
      fie[i][0] = fie[i][2*H] = true;
    for(int i=0;i<=2*H;i++)
      fie[0][i] = fie[2*W][i] = true;

    for(int i=0;i<N;i++){
      int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
      if( x1 > x2 ) swap( x1, x2 );
      if( y1 > y2 ) swap( y1, y2 );
      x1*=2; y1*=2; x2*=2; y2*=2;
      nuri( x1,y1,x2,y2 );
    }

    int sa,sb,sc,sd;
    cin >> sa >> sb >> sc >> sd >> ex >> ey;
    if( sa > sc ) swap( sa,sc );
    if( sb > sd ) swap( sb,sd );
    sa *= 2; sb *=2; sc *=2; sd*=2;
    ex = 2*ex+1; ey = 2*ey+1;

    int res;
    if( sa == sc ){
      if( sa == 0 ) res = solve( 1, sb+1, 1 );
      else res = solve( 2*W-1, sb+1, 3 );
    } else {
      if( sb == 0 ) res = solve( sa+1, 1, 0 );
      else res = solve( sa+1, 2*H-1, 2 );
    }
    if( res < 0 ) cout << "Impossible" << endl;
    else cout << res << endl;
  }
}

Measured memory_bytes: 3312
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N, M, X;
int C[12], A[12][12];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> M >> X;
	rep(i, 0, N) {
		cin >> C[i];
		rep(j, 0, M) cin >> A[i][j];
	}

	int ans = inf;
	rep(msk, 0, 1 << N) {
		int cst = 0;
		vector<int> rikai(M, 0);

		rep(i, 0, N) if (msk & (1 << i)) {
			cst += C[i];
			rep(j, 0, M) rikai[j] += A[i][j];
		}

		bool ok = true;
		rep(i, 0, M) if (rikai[i] < X) ok = false;
		if (ok) chmin(ans, cst);
	}

	if (ans == inf) ans = -1;
	cout << ans << endl;
}







Measured memory_bytes: 3656
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        String str = sc.next();
        char c[] = str.toCharArray();
        
        if (c.length <= k) {
            // for (int i = 0; i < c.length; i++) {
                System.out.println(str);
            // }
        } else {
            for (int i = 0; i < k; i++) {
                System.out.print(c[i]);
            }
            System.out.print("...");
            System.out.println();
        }
    }
}


Measured memory_bytes: 35744
#include<stdio.h>
#include<stdlib.h>
int compare(const void *a, const void *b) {
    return *(long*)a - *(long*)b;
}
int main() {
    long n, a[111111], b[111111], c[111111], i, j, ans = 0,sum=0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &a[i]);
    for (i = 0; i < n; i++)
        scanf("%d", &b[i]);
    for (i = 0; i < n; i++) {
        c[i] = b[i] - a[i];
        sum += c[i];
    }
    if (sum > 0) {
        printf("-1\n");
        return 0;
    }
    qsort(c, n, sizeof(long), compare);
    i = 0;
    j = n - 1;
    sum = 0;
    while (c[j] > 0) {
        ans++;
        sum += c[j];
        while (sum > 0) {
            ans++;
            sum += c[i];
            i++;
        }
        j--;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 3452
#include <stdio.h>

char S[80001];
int A[80001], B[11];

int char_to_int(char c){
	return (int)c - (int)'0';
}

int main(){
	int N, i, j, ans;
	while(1){
		scanf("%s", S);
		for(N = 0; S[N] != '\0'; N++){}
		if(N == 1 && S[0] == '0'){
			return 0;
		}
		A[N] = 0;
		for(i = N - 1; i >= 0; i--){
			if(i % 2 == 0){
				A[i] = (A[i + 1] + char_to_int(S[i])) % 11;
			}
			else{
				A[i] = (A[i + 1] - char_to_int(S[i]) + 11) % 11;
			}
		}
		for(j = 0; j < 11; j++){
			B[j] = 0;
		}
		B[0] = 1;
		ans = 0;
		for(i = N - 1; i >= 0; i--){
			if(S[i] != '0'){
				ans += B[A[i]];
			}
			B[A[i]]++;
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 2072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		sc.close();

		int tAttack = ((c - 1) / b) + 1;
		int aAttack = ((a - 1) / d) + 1;

		boolean answer = tAttack <= aAttack;

		printBool(answer);
	}

	public static void printBool(boolean bool) {
		print(bool ? "Yes" : "No");
	}

	public static void print(Object obj) {
		System.out.println(obj);
	}

}


Measured memory_bytes: 35880
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;
const int INF=1<<17;

int dp[300][300]; //dp[i][j]:=[i,j)で取り除けるブロックの最大値
vector<int> W;

int rec(int l,int r){ //[r,l)
    if(~dp[l][r]) return dp[l][r];
    if(r-l<=1) return dp[l][r]=0;
    else if(r-l==2){
        if(abs(W[r-1]-W[l])<=1) return dp[l][r]=2;
        else dp[l][r]=0;
    }
    int ret=0;
    if(abs(W[l]-W[r-1])<=1&&rec(l+1,r-1)==r-l-2){
        ret=max(ret,rec(l+1,r-1)+2);
        return dp[l][r]=ret;
    }
    for(int i=l+1;i<r;i++){
        ret=max(ret,rec(l,i)+rec(i,r));
    }
    return dp[l][r]=ret;
}


int main(){
    int n;
    while(cin >> n){
        if(!n) break; 
        W.clear();
        for(int i=0;i<n;i++){
            int w;
            cin >> w;
            W.push_back(w);
        }
        memset(dp,-1,sizeof(dp));
        cout << rec(0,n) << endl;
    }
    return 0;
}


Measured memory_bytes: 3508
#include <stdio.h>

int main( void )
{
	int i, j, n, m, a[100][100], b[100], c[100] = { 0 };
	
	scanf("%d %d", &n, &m);
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			scanf("%d", &a[i][j]);
		}
	}
	
	for(i = 0; i < m; i++){
		scanf("%d", &b[i]);
	}
	
	for(i = 0; i < n; i++){
		for(j = 0; j < m; j++){
			c[i] += a[i][j] * b[j];
		}
	}
	
	for(i = 0; i < n; i++){
		printf("%d\n", c[i]);
	}

	return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 29;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int N;
  cin >> N;

  int cnt[100000 + 1];
  memset(cnt, 0, sizeof(cnt));

  rep (i, N) {
    int a;
    cin >> a;
    cnt[a]++;
  }

  int sum = 0;
  rep (i, 100000 + 1) sum += max(0, cnt[i] - 1);

  cout << N - sum - sum % 2 << endl;
}


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

void solve(int c, int sum);

int n, s, list[11][331], judge[10];
int main() {
   solve(1, 0);
   while (cin >> n >> s) {
      if (n > 10 || s > 330) {
	 n = 0;
	 s = 0;
      }
      cout << list[n][s] << endl;
   }
   return 0;
}

void solve(int c, int sum) {
   if (c == 11) return;
   for (int i = 0; i < 10; i++) {
      if (!judge[i]) {
	 judge[i] = 1;
	 ++list[c][sum + i * c];
	 solve(c + 1, sum + i * c);
	 judge[i] = 0;
      }
   }
}

Measured memory_bytes: 1172
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)
#define MP(a,b) make_pair(a,b)

#if __has_include("debug.hpp")
#include "debug.hpp"
#else
template<typename T>
void debug(T& obj) {}
#endif

template<typename T>
T in(){
	T val;
	cin >> val;
	return val;
}

template<typename T>
vector<T> inv(ll num) {
	vector<T> val(num);
	rep(i,num) cin >> val[i];
	return val;
}

//----------------------------------------------------------------------
void solve() {

	ll n,a,b;
	cin >> n >> a >> b;

	cout << n/(a+b)*a + min(a,n-n/(a+b)*(a+b));

}
//----------------------------------------------------------------------

int main(int argc, char* argv[]) {
	solve();
	return 0;
}


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

#define SIZE_OF_ARRAY(array) sizeof(array)/sizeof(array[0])

int main() {
    std::deque<char> A;
    string S;
    int Q;
    cin >> S >> Q;
    for(int i=0; i<S.length(); i++){
        A.push_back(S[i]);
    }
    bool b = 1;
    for(int i=0; i<Q; i++){
        int T;
        cin >> T;
        if(T==1){
            b = !b;
        } else {
            int F;
            char C;
            cin >> F >> C;
            if(b){
                if(F==1){
                    A.push_front(C);
                } else {
                    A.push_back(C);
                }
            } else {
                if(F==1){
                    A.push_back(C);
                } else {
                    A.push_front(C);
                }
            }
        }
    }
    
    if(!b){
        std::reverse(A.begin(), A.end());
    }
    while(A.size() > 0){
        cout << A.front();
        A.pop_front();
    }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

class UnionFind {
public:
  vector<int> par, rank; // parent(negative := its root and abs-value is its size), depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[y] += par[x];
      par[x] = y;
    } else {  // x becomes parent node
      par[x] += par[y];
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int size(int x){ return -par[find(x)]; }
};

long calc(int m, vector<long> &vec, int x){
  UnionFind uf(m*x);
  vector<bool> c(m*x, true);
  rep(i,x) for(auto j : vec) c[m*i+j]=false;

  rep(i,m*x) if(c[i]){
    if(i%7>0 && c[i-1]) uf.unite(i-1, i);
    if(i>6 && c[i-7]) uf.unite(i-7, i);
    if(i%7<6 && c[i+1]) uf.unite(i+1, i);
    if(i+7<m*x && c[i+7]) uf.unite(i+7, i);
  }

  long ret=0;
  rep(i,m*x) if(c[i] && uf.par[i]<0) ret++;
  return ret;
}

int main(){
  long n,m,q;
  cin>>n>>m>>q;
  vector<long> a(q);
  rep(i,q) cin>>a[i];

  if(m%7==0){
    long r1 = calc(m, a, 1);
    long r2 = calc(m, a ,2);
    cout << r1 + (r2-r1)*(n/(m/7) - 1)<< endl;
  } else {
    long r1 = calc(m, a, 7);
    long r2 = calc(m, a, 14);
    cout << r1 + (r2-r1)*(n/m - 1) << endl;
  }

  return 0;
}


Measured memory_bytes: 11424
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    if(k<=a+b){
        cout << min(k,a) << endl;
    }else{
        cout << a - (k-a-b) << endl;
    }

    
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define ull unsigned long long
#define M 1000000007

using namespace std;


int main(){
    char a;cin>>a;
    if(a>=65 && a<=90) cout<<'A'<<endl;
    else if(a>=97 && a<=122) cout<<'a'<<endl;
    
}

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

int main() {
    int n,x = 0, max = 0;
    string s;
    cin >> n;
    cin >> s;
    for (int i = 0; i < n; i++)
    {
        if (s.at(i) == 'I') ++x;
        else --x;

        if (max < x) max = x;
    }
    cout << max << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.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 main(void) {
	int N;
	cin >> N;
	int A, B;
	int cnt = 0, ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> A >> B;
		if (A == B) cnt++;
		else cnt = 0;
		ans = max(ans, cnt);
	}
	if (ans >= 3) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

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

long long rec(long long n){
  if(n==0)return 0;
  //cout << n << endl << endl;

  bool neg = n<0;
  long long x = 1, lim = 0;
  if(neg){
    x = 10; n *= -1;
  }
  for(;;){
    for(long long i=1;i<10;i++){
      //cout << x*i << endl;
      if(x*i==n)return n;
      if(n-x*i<=lim)return x*i+rec( (neg?-1:1) * (n-x*i));
    }
    lim += 9*x;
    x *= 100;
  }
}

int main(){
  long long n;
  while(cin >> n, n){
    cout << rec(n) << endl;
  }
}

Measured memory_bytes: 1156
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10 + 1e8;
int main()
{
	double l; cin >> l;
	cout <<fixed<<setprecision(10)<< (l / 3) * (l / 3) * (l / 3);
}


Measured memory_bytes: 3724
N, K=map(int,input().split())
D=list(map(int,input().split()))
ans=N
while ans<99999:
    flag=False
    num = list(map(int, str(ans)))
    for i in range(K):
        for digit in num:
            if digit==D[i]:
                ans +=1
                flag=True
                break
        if flag:
            break
    if flag==False:
        break
print(ans)

Measured memory_bytes: 3060
// In the name of God

#include <bits/stdc++.h>

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	for(int i=0;s[i];i++) {
		if(i % 2 == 0) {
			if(s[i]!='R'&&s[i]!='U'&&s[i]!='D') {
				cout << "No";
				exit(0);
			}
		}
		else {
			if(s[i]!='L'&&s[i]!='U'&&s[i]!='D') {
				cout << "No";
				exit(0);
			}
		}
	}
	cout << "Yes";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  ll N,K;cin >> N >> K;
  N;
  ll ans = 0;
  repp(b,K+1,N+1){
    ll n = N/b;
    ll r = N%b;
    ll num = 0;
    num += n*(b-K);
    num += max(0ll,r-K+1);

    ans += num;
  }
  if(K==0)ans-=N;
  cout << ans << endl;
  return 0;
}


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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;

    while ((readStr = reader.readLine()) != null) {
      int[] a = new int[4];
      int[] b = new int[4];
      String[] astrs = readStr.split(" ");
      String[] bstrs = reader.readLine().split(" ");
      for (int i = 0; i < a.length; i++)
        a[i] = Integer.parseInt(astrs[i]);
      for (int i = 0; i < b.length; i++)
        b[i] = Integer.parseInt(bstrs[i]);

      int hit = 0;
      int blow = 0;
      for (int i = 0; i < b.length; i++) {
        if (isBlow(a, b[i], i))
          blow++;
        if (isHit(a, b[i], i))
          hit++;
      }
      
      System.out.println(hit + " " + blow);
      
    }
  }

  public static boolean isHit(int[] array, int num, int index) {
    return array[index] == num;
  }

  public static boolean isBlow(int[] array, int num, int index) {
    if (isHit(array, num, index))
      return false;

    for (int n : array)
      if (n == num)
        return true;

    return false;
  }

}

Measured memory_bytes: 16916
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pii pair<int,int>
#define pf push_front
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%lld",&t)
#define p(t) printf("%lld\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define bits(x) __builtin_popcountll(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<pii,vector<pii>,greater<pii> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define spitr set<pii>:: iterator
#define mitr map<int,int>:: iterator

int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}
string tostring ( int number ) {stringstream ss; ss << number; return ss.str();}


typedef tree<pii, null_type, less<pii>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

int32_t main()
{
	fast;
	int n;cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int val=n/i;
		if(n%i==0)
			ans+=(val-1);
		else
			ans+=val;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3648
#include <iostream>

using namespace std;

int main(void) {
	int N,Z,W;
	cin >> N >> Z >> W;
	int prev,now = 0;
	for (int i = 0; i < N; ++i) {
		prev = now;
		cin >> now;
	}
	if (N == 1) {
		prev = now;
	}
	cout << max(abs(prev-now),abs(now-W)) << endl;
	return 0;
}

Measured memory_bytes: 256
# ABC084-B
A, B = map(int, input().split())
S = input()
ans = 'No'
flag = True
num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
if S[A] == '-':
    aa = S[0:A]
    bb = S[A+1:A+B+1]
    for i in range(len(aa)):
        if aa[i] not in num:
            flag  = False
    for k in range(len(bb)):
        if bb[k] not in num:
            flag = False
    if flag:
        ans = 'Yes'
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
//const int INF = 1e8;
using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	cout << (a + b) * c / 2 << endl;
}


Measured memory_bytes: 256
#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 FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

#define All(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1e9;

int main(){
   int w,a,b;
   cin >> w >> a >> b;
   if(abs(b-a) <= w)cout << 0 << endl;
   else cout << abs(b-a)-w << endl;
   return 0;
}

Measured memory_bytes: 256
O = input()
E = input()

s = []
if len(O)>len(E):
  for a,b in zip(O[:-1],E):
    s.append(a)
    s.append(b)
  s.append(O[-1])
else:
  for a,b in zip(O,E):
    s.append(a)
    s.append(b)

print(''.join(s))

Measured memory_bytes: 38256
import sys
from math import gcd
def input(): return sys.stdin.readline().strip()

def main():
    N = int(input())
    A =list(map(int, input().split()))

    all_gcd = A[0]
    max_num = A[0]
    for a in A:
        all_gcd = gcd(all_gcd, a)
        max_num = max(max_num, a)
    if all_gcd != 1:
        print("not coprime")
        return

    # エラトステネスの篩でprimes[i] = (iを割り切る最小の素数)を記録する
    min_prime = [i for i in range(max_num + 1)]
    for p in range(2, int(max_num**0.5) + 1):
        if min_prime[p] != p: continue
        for i in range(2, max_num // p + 1): min_prime[i * p] = p

    used = [0] * (max_num + 1)
    for a in A:
        while a > 1:
            p = min_prime[a]
            if used[p]:
                print("setwise coprime")
                return
            while a % p == 0: a //= p
            used[p] = 1
    print("pairwise coprime")




if __name__ == "__main__":
    main()


Measured memory_bytes: 216608
#include <stdio.h>
 
class Dice2{
public:
    Dice2(){
        number = new int[6];
        relative = new int[55];
        relative[31] = relative[43] = relative[24] = relative[12] = 0;
        relative[3] = relative[20] = relative[52] = relative[35] = 1;
        relative[1] = relative[40] = relative[54] = relative[15] = 2;
        relative[4] = relative[10] = relative[51] = relative[45] = 3;
        relative[2] = relative[30] = relative[53] = relative[25] = 4;
        relative[21] = relative[42] = relative[34] = relative[13] = 5;
    };
    ~Dice2(){
        delete[] number;
        delete[] relative;
    };
 
    void setNumber(int index,int num){
        number[index] = num;
    };
 
    int returnRight(int top,int front){
        int top_index,front_index;
        for(int i = 0; i < 6; i++){
            if(number[i] == top)
                top_index = i;
            if(number[i] == front)
                front_index = i;
        }
        return number[relative[10*top_index+front_index]];
    }
private:
    int* number;
    int* relative;
};
 
int main(){
    Dice2 dice2;
    int x,q,top,front;
    for(int i = 0; i < 6; i++){
        scanf("%d",&x);
        dice2.setNumber(i,x);
    }
    scanf("%d",&q);
    for(int i = 0; i < q; i++){
        scanf("%d %d",&top,&front);
        printf("%d\n",dice2.returnRight(top,front));
    }
}


Measured memory_bytes: 2700