akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    string s;
    cin>>s;

    rep(i,0,s.length())
    {
        if ( s[i] == '?' )
        {
            s[i] = 'D';
        }
    }

    cout<<s<<endl;
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3744
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;



signed main(){
	int N;
	string S;
	cin>>N>>S;
	int a=0,b=0;
	REP(i,S.size()){
		if(S[i]=='R'){
			a++;
		}
		else{
			b++;
		}
	}
	if(a>b){
		cout<<"Yes"<<endl;
	}
	else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
import sys
import heapq
import bisect

mod = 10**9+7
dd = ((-1,0),(1,0),(0,-1),(0,1))

def I(): return(int(sys.stdin.readline()))
def LI(): return([int(x) for x in sys.stdin.readline().split()])
def S(): return(sys.stdin.readline()[:-1])
def IR(n): return([I() for _ in range(n)])

def GCD(a,b):
    while b!=0:
        a,b = b,a%b
    return a

def LCM(a,b):
    return a * b // GCD(a,b)

def Eratosthenes(N):
    r = [True]*(N+1)
    r[0] = False
    r[1] = False
    i = 2
    while i*i<=N:
        if r[i]: 
            j = i
            while i*j<=N:
                prime[i*j]=False
                j+=1
        i+=1
    return(r)

def main():
    N = I()
    A = LI()
    B = LI()
    if sum(B)>sum(A):
        return(-1)

    ques = []
    rest = 0
    ans = 0

    for i in range(N):
        if A[i] < B[i]:
            ans += 1
            rest += B[i]-A[i]
        else:
            heapq.heappush(ques,B[i]-A[i])

    while rest>0:
        cost = heapq.heappop(ques)
        rest += cost
        ans += 1
    return(ans)

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 75824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,ans=0;
  cin >> N;
  vector<long long>A(N);
  vector<long long>B(N);
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
   ans= A[N-1] + B[0];
  cout << ans << endl;
}


Measured memory_bytes: 4832
S=str(input())
a = int(S[:2])
b = int(S[2:])
if 0 < a <= 12 and (b > 12 or b == 0):
    print("MMYY")
elif (a > 12 or a == 0) and 0 < b <= 12:
    print("YYMM")
elif 0 < a <= 12 and 0 < b <= 12:
    print("AMBIGUOUS")
else:
    print("NA")

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

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define REP(i,n) for (int i = 0; i < n; ++i)

const ll MAX = 1e5+10;
const ll MOD = 1e9+10;

int N, L;

int main() {
    cin >> N >> L;
    int total = 0;
    int m = 10000;
    REP (i, N) {
        total += L+i;
        m = min(m, abs(L+i));
    }
    if (m != 0 && L < 0) m *= -1;
    cout << total - m << endl;
}

Measured memory_bytes: 256
def slove():
    import sys
    input = sys.stdin.readline
    n, x = list(map(int, input().rstrip('\n').split()))
    a = list(map(int, input().rstrip('\n').split()))
    a.sort()
    cnt = 0
    for v in a:
        x -= v
        cnt += 1
        if x == 0:
            break
        elif x < 0:
            cnt -= 1
            break
    print(cnt if x <= 0 else cnt - 1)


if __name__ == '__main__':
    slove()


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

int main() {
    char s[100];
    cin >> s;
    s[strlen(s) - 8] = 0;

    cout << s << endl;

    return 0;
}

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

#define itn int
#define LL long long
#define pb push_back
#define mp make_pair
#define x first
#define y second 

using namespace std;

int main(){
	int a,b;
	cin >> a >> b;
	int sum = a + b;
	if(sum > 24) sum = sum%24;
        if(sum == 24) sum = 0;
	printf("%d\n",sum);

	system("pause");
	return 0;  
}

Measured memory_bytes: 504
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    int k,a,b;
    cin >> k >> a >> b;
    bool f = false;
    for (int i = a;i <= b;i++)
    {
        if (i % k == 0)
        {
            f = true;
        }
    }

    cout << (f? "OK":"NG") << endl;
    
    return 0;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdbool.h>
#include<math.h>

bool isprime(int);
int cnt=0,num;

int main(){
    for(int i=0;scanf("%d",&num)!=EOF;i++){
        if(isprime(num)==true)cnt++;
        //printf("%3d/%3d/cnt:%3d\n",num,isprime(num),cnt);
    }
    printf("%d\n",cnt);
    return 0;
}

bool isprime(int x){
    for(int i=3;i<=sqrt(x);i+=2){
        if(x%i==0){
          return false;
        }
    }
    
    if(x == 2){
        return true;
    }else if(x < 2 || x%2==0){
        return false;
    }else{
        return true;
    }
}
 


Measured memory_bytes: 2108
#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 ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<double> p(n);
    rep(i, n) cin >> p[i];
    vector<vector<double>> dp(n+1, vector<double>(n+1, 0));
    dp[0][0] = 1;
    rep(i, n) {
        rep(j, n) {
            dp[i+1][j+1] += dp[i][j] * p[i];
            dp[i+1][j] += dp[i][j] * (1-p[i]);
        }
    }
    double ans = 0;
    for (int i=n/2+1; i<=n; ++i) {
        ans += dp[n][i];
    }
    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 70784
a,b,k=map(int,input().split())
if a-k>0 and a+b > k:
    print(str(a-k)+" "+str(b))
elif a-k <= 0 and a+b > k:
    print(str(0)+" "+str(b-(a-k)*(-1)))
else:
    print(str(0)+" "+str(0))


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

int main(){

  int h,w;
  cin>>h>>w;
  
  vector<string> data(h);
  
  vector<bool> g(h);
  vector<bool> r(w);
  
  for (int i=0;i<h;i++){
    cin>>data.at(i);
  }
  
  for (int i=0;i<h;i++){
    bool flag1=false;
    for (int j=0;j<w;j++){
      if (data.at(i).at(j)=='#'){
        flag1=true;
        break;
      }
    }
  g.at(i)=flag1;
  }
  
  
  
  for (int j=0;j<w;j++){
    bool flag2=false;
    for (int i=0;i<h;i++){
      if (data.at(i).at(j)=='#'){
        flag2=true;
        break;
      }
    }
    r.at(j)=flag2;
  }
  
  
  
  for (int i=0;i<h;i++){
    for (int j=0;j<w;j++){
      if (g.at(i)==true and r.at(j)==true){
        cout<<data.at(i).at(j);
      }
    }
    cout<<endl;
  }
  
  
}
  













Measured memory_bytes: 256
import * as fs from 'fs';

//in
// 2 3
//out
// 6
function main(inp: string) {
    const [a, b]: number[] = inp.split(' ').map(Number);
    console.log(lcm(a, b));
}

function gcd(a: number, b: number): number {
    if (b != 0)
        return gcd(b, a % b);
    else
        return a;
}

function lcm(a: number, b: number): number {
    return a * b / gcd(a, b);
}

main(fs.readFileSync('/dev/stdin', 'utf8').trim());

Measured memory_bytes: 7500
function main(input) {
  const formatted_input = input.split('\n').map(x => parseInt(x));

  var tmp_minimum=0;
  var result = 0;
  for(var i = 0;i<5;i++){
    if(formatted_input[i]%10==0){
      result+=formatted_input[i]
    }else{
      result+=(formatted_input[i] - formatted_input[i]%10)
      if(tmp_minimum==0){
        tmp_minimum=formatted_input[i]%10
      }else{
        result+=10;
        tmp_minimum=Math.min(tmp_minimum,formatted_input[i]%10)
      }
    }
  }
  result+=tmp_minimum;

  console.log(result);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 7372
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def main():
    n, w = map(int, input().split())
    WVs = [list(map(int, input().split())) for i in range(n)]
    Vs = [_[1] for _ in WVs]
    sum_v = sum(Vs)
    
    dp = [[10**11]*(sum_v+1) for i in range(n+1)]
    dp[0][0] = 0
    
    # dp[i+1][j] := i個目までの商品を見たときに，価値の総和がjを超えるように選んだたときの重さの最小値

    for i in range(n):
        for j in range(sum_v+1):
            vi = Vs[i]
            wi = WVs[i][0]
            

            if j-vi >= 0:
                dp[i+1][j] = min([dp[i][j-vi] + wi, dp[i][j]])
            else:
                dp[i+1][j] = dp[i][j]

    
    # print(dp[n])
    for k in reversed(range(sum_v+1)):
        # print(k)
        if dp[n][k] <= w:
            
            print(k)
            exit()

if __name__ == '__main__':
    main()

Measured memory_bytes: 125812
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
    
using namespace std;
  
const int LIMIT = 1000000000;
  
struct Data {
  int id;
  int st;
  int num;
  Data(int id, int st, int num) : id(id), st(st), num(num) {}
  bool operator<(const Data& rhs) const { return st<rhs.st; }
};
    
int N;
vector<Data> storage;
   
void dump() {
  cout << "-----------------------------" << endl;
  for(int i=0; i<(int)storage.size(); i++) {
    cout << "storage["<<i<<"]:" << endl;
    cout << "id: " << storage[i].id << " st: " << storage[i].st << " num: " << storage[i].num << endl;
  }
  cout << "-----------------------------" << endl;
}
  
void write(const int id, int remain) {
  int st = 0;
  while(remain > 0) {
    int num = -1;
    int into = -1;

    for(int i=0; i<(int)storage.size(); i++) {
      if(st < storage[i].st) {
        num = min(remain, storage[i].st - st);
        into = i;
        break;
      }
      else if(st < storage[i].st+storage[i].num) {
        st = st+storage[i].num;
      }
        
      if(st > LIMIT) return;
    }
    
    if(num == -1) {
      // insert data back
      num = remain;
      into = storage.size();
    }
    storage.insert(storage.begin()+into, Data(id, st, num));
    remain -= num;
  }
}
  
class EqualsID {
private:
  int id;
public:
  EqualsID(int id) : id(id) {}
  bool operator() (const Data &d) { return d.id == id; }
};
void del(int id) {
  storage.erase(remove_if(storage.begin(), storage.end(), EqualsID(id)), storage.end());
}

int refer(int sect) {
  for(int i=0; i<(int)storage.size(); i++) {
    if(storage[i].st<=sect && sect<storage[i].st+storage[i].num) {
      return storage[i].id;
    }
  }
  return -1;
}
    
int main() {
  while(scanf("%d", &N) && N) {
    storage.clear();
    for(int i=0; i<N; i++) {
      char ch; cin >> ch; //scanf("%c", &ch);
      if(ch=='W') {
        int id, num; scanf("%d%d", &id, &num);
        write(id, num);
        //dump();
      }
      if(ch=='D') {
        int id; scanf("%d", &id);
        del(id);
      }
      if(ch=='R') {
        int sect; scanf("%d", &sect);
        printf("%d\n", refer(sect));
      }
    }
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1304
// AOJ 2676: Typing Game
// 2018.1.3 bal4u@uu

#include <stdio.h>
#include <ctype.h>

char s[101][18];
int t[101];

int main()
{
	int n, h, i, ok, total, ans;
	char c[5], *p;

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

	ok = total = 0;
	for (i = 0; i < n; i++) {
		p = s[i];
		while (*p) {
			printf("? %s\n", s[i]), fflush(stdout);
			scanf("%s", c);
			total++;
			if (toupper(*c) == toupper(*p)) { ok++; *p++ = '_'; }
			else if (--t[i] < 0) { h--; break; }
		}
		if (h == 0) { puts("! Game Over"); fflush(stdout); return 0; }
	}
	ans = (ok*1000)/total;
	printf("! Game Clear %d.%0d\n", ans/10, ans % 10); fflush(stdout);
	return 0;
}



Measured memory_bytes: 3344
N, *A = map(int, open(0).read().split())

x = [0] * (N + 1)
ans = []
for i in reversed(range(1, N + 1)):
    if sum(x[i::i]) % 2 != A[i - 1]:
        x[i] += 1
        ans.append(i)

print(len(ans))
if ans:
    print(*ans)



Measured memory_bytes: 101732
#include <stdio.h>
#include <stdlib.h>
#include<string.h>
int main(void){
    char *p;
    p=malloc(sizeof(char )*4);
scanf("%s",p);
if(strcmp(p,"ABC")==0)
printf("ARC\n");
else
printf("ABC\n");
return 0;
}

Measured memory_bytes: 1608
#include<cstdio>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
    ll N,K;
    scanf("%lld%lld",&N,&K);
    ll ans = 0;
    for(ll b = K+1; b <= N; b++){
        //a=K,K+1,...,b-1,b+K,b+K+1,...,2*b-1,...(<=N)
        ans += (b-K) * (N/b);
        ll temp = N%b;
        if(temp >= K) ans += temp - K + 1;
    }
    if(K == 0) ans = N * N;
    printf("%lld",ans);
}

Measured memory_bytes: 128
//Atcoder083 B - Some Sums

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int total = 0;
		for (int i = 1; i <= n; i++) {
			int sum = calc(i);
			if (a <= sum && sum <= b) {
				total += i;
			}
		}
		System.out.println(total);
	}

	static int calc(int i) {
		int sum = 0;;
		while (i > 0) {
			sum += i % 10;
			i /= 10;
		}

		return sum;
	}
}




Measured memory_bytes: 35708
#include <stdio.h>

#define MAX 100

typedef struct {
	int num;
	int cor;
	int rank;
}team;

int main(void) {
	team teams[MAX];
	int i=0, j=0;
	int want[MAX];
	
	//input
	while(1) {
		scanf("%d,%d", &teams[i].num, &teams[i].cor);
		if(teams[i].num==0 && teams[i].cor==0) break;
		i++;
	}

	while( scanf("%d", &want[j++]) != EOF ){}
	
	//sort
	int m,n;
	
	for(m=0; m<i; m++) {
		for(n=m; n<i; n++) {
			if(teams[m].cor < teams[n].cor) {
				team temp = teams[m];
				teams[m] = teams[n];
				teams[n] = temp;
			}
		}
	}
	
	teams[0].rank = 1;
	int current = teams[0].cor;
	int ranknow = 1;
	
	for(m=1; m<i; m++){
		if(current == teams[m].cor) teams[m].rank=ranknow;
		else {		
			teams[m].rank = ++ranknow;
			current = teams[m].cor;
		}
	}
		
	
	for(m=0; m<j; m++){
		for(n=1; n<=i; n++){
			if(want[m] == teams[n-1].num) {
				printf("%d\n", teams[n-1].rank);
				break;
			}
		}
	}
	return 0;
}

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

int k[1000][1000];

int main(){
	int n,MIN,MIN2,sum=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>k[0][i];
	}
	for(int i=0;i<n-1;i++){
		MIN=1000000;
		MIN2=0;
		for(int j=i+1;j<n;j++){
			if(k[i][j]<MIN){
				MIN=k[i][j];
				MIN2=j;
			}
		}
		for(int j=0;j<n;j++){
			k[i+1][j]=k[i][j];
		}
		if(MIN<k[i][i]){
			k[i+1][i]=k[i][MIN2];
			k[i+1][MIN2]=k[i][i];
			sum++;
		}
	}
	for(int i=0;i<n;i++){
		cout<<k[n-1][i];
		if(i==n-1){
			cout<<endl;
		}
		else{
			cout<<' ';
		}
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 1548
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

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

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    ll N; cin >> N;

    vector<ll> A(N), B(N);
    rep(i, N) cin >> A[i] >> B[i];

    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    if (N % 2 == 1) {
        cout << B[N / 2] - A[N / 2] + 1 << endl;
    }
    else
    {
        ll M = N / 2;
        cout << (B[M] + B[M-1]) - (A[M] + A[M-1]) + 1 << endl;
    }
}

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

int main(){
	int K, N;
  	cin >> K >> N;
  	vector<int> A(N), B(N);
  	for(int i = 0;i< N;i++){cin >> A.at(i);}
  	for(int i = 0;i< N-1;i++){
		B.at(i) = min(K-A.at(i+1)+A.at(i),A.at(i+1)-A.at(i));
    }
  	B.at(N-1) = min(K-A.at(N-1)+A.at(0),A.at(N-1)-A.at(0));
//  	for(int i = 0;i < N; i++){cout << B.at(i) << endl;}
  	int mx = B.at(0);
  	for(int i = 1;i < N;i++){mx = max(mx,B.at(i));}
    cout <<  (K - mx) << endl;
  
}

Measured memory_bytes: 1792
# coding: utf-8

A,B,C,D = (int(x) for x in input())
OP = ['-', '+']

op_list = []
for op1 in (True, False):
    for op2 in (True, False):
        for op3 in (True, False):
            op_list.append((op1,op2,op3))

for ops in op_list:
    ans = A
    for num, op in zip([B,C,D], ops):
        if(op):
            ans += num
        else:
            ans -= num
    if ans == 7:
        print("%d%s%d%s%d%s%d=7" % (A, OP[ops[0]], B, OP[ops[1]], C, OP[ops[2]], D))
        break

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

using namespace std;

const int N=1e6+10;
int n,a[N];
int main(){
        cin>>n;
        for(int i=1;i<=n;i++) cin>>a[i];
        int ans=0;
        for(int en=1;en<=n;){
                int st=en;
                while (en<=n&&a[st]==a[en]) en++;
                int len=en-st;
                ans+=len/2;
        }
        cout<<ans;
}


Measured memory_bytes: 256
N = gets.chomp.to_i
arr = gets.chomp.split(" ").map(&:to_i)
# p arr
ans = Array.new(N)


(N-1).downto(0) do |n|
    box_num = n+1
    multi_arr = box_num.step(N,box_num)
    # p multi_arr
    # p "multi"
    sum = 0
    multi_arr.reverse_each do |i|
        # p arr[i-1]
        if not ans[i-1].nil?
            sum += ans[i-1]
        else
            ans[i-1] = (sum % 2) ^ arr[i-1]
        end
    end
end
# p ans
nums = []
b_n = 1
m = 0
ans.each do |n|
    if n == 1
        nums << b_n
        m+=1
    end
    b_n+=1
end
puts m
if not m == 0
    puts nums.join(" ")
end


Measured memory_bytes: 39948
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 28);
const ll LINF = 1e18;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A, B;
	cin >> A >> B;
	if (B % A == 0)cout << A + B << endl;
	else cout << B - A << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 504
#include<stdio.h>

int senkei(int A[],int n,int key){
  int i=0;
  A[n] = key;
  while(A[i] != key) i++;
  return i!=n;
}

int main(){
  int i,n,q,A[10000+1],key,sum=0;

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

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&key);
    if(senkei(A,n,key))sum++;
  }
  printf("%d\n",sum);

  return 0;
}


  



Measured memory_bytes: 2744
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

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

const ll mod = 1000000007;

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

  int x, y, z;
  cin >> x >> y >> z;

  cout << z << " " << x << " " << y << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;
#define N 101000
int v[3][N],i,j,n,d[3][N],k;
int main()
{
    cin >> n;
    ++n;
    for (i = 1; i < n; ++i)
        cin >> v[0][i] >> v[1][i] >> v[2][i];
    for (i = 1; i < n; ++i){
        for (j = 0; j < 3; ++j){
            for (k = 0; k < 3; ++k)
            if (k != j)
                d[j][i] = max (d[j][i],d[k][i - 1] + v[j][i]);
        }
    }
    cout << max(d[0][n - 1],max(d[1][n - 1],d[2][n - 1]));
    return 0;
}


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

int main( ){
    int n;
    string s;
    char c;
    int ans;
    cin>>n;
    c = 'A';
    ans = 0;
    cin>>s;
    for(auto i:s){
        if(c != i){
            ans++;
            c = i;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 512
#include <cstdio>
#include <string>
#include <vector>
#include <iostream>
using namespace std;
int main() {
string a, b;
cin >>a >> b;
int now = 0;
if (a.size() < b.size()) now = -1;
else if(a.size() > b.size()) now = 1;
else {
if (a < b) now = -1;
if(a > b) now = 1;
}
if (now > 0) cout <<"GREATER"<<endl;
if (now < 0) cout <<"LESS" << endl;
if (now == 0) cout <<"EQUAL" << endl;
return 0;
}

Measured memory_bytes: 256
// Author : Sarthak Kapoor
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define rep(i,n) for(int i=0;i<n;++i)
#define repa(i,a,n) for(int i=a;i<n;++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define repba(i,b,a) for(int i=b;i>=a;--i)
#define repab(i,a,b) for(int i=a;i<b;++i)
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define viip vector<pair<int,pair<int,int> > > 
#define mp make_pair
#define vip vector<pair<int,int> >
#define pb push_back 
#define fi first
#define sec second
#define all(v) v.begin(),v.end()
#define s(v) v.size()
ll mod = 1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());//use rng()%n for numbers in range [0,n-1]
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll fastexp(ll x,ll a){
    ll res = 1;
    while(a>0){
        if(a&1){
            res = (res*x)%mod;
        }
        a=a>>1;
        x=(x*x)%mod;
    }
    return res;
}
ll inverse(ll n){
    return fastexp(n,mod-2);
}
template <typename T>
void add(T &a, T b){
	a += b;
	if(a >= mod)a -= mod;
}
template <typename T>
void sub(T &a, T b){
	a -= b;
	if(a < 0)a += mod;
}
template <typename T>
void mul(T &a, T b){
	a *= b;
	if(a > mod)a %= mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	int n,m;
	cin>>n>>m;
	vi v(n);
	ll sum = 0;
	rep(i,n){
		cin>>v[i];
		sum += v[i];
	}	
	sort(all(v));
	int c = 0;
	double ans = 1.0*sum/(4.0*m);
	// cout<<sum<<" "<<ans<<"\n";
	rep(i,m){
		if(v[n-i-1] >= ans){
			c++;
		}
		else{
			break;
		}
	}
	if(c == m){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <ctime>
#include <vector>
#include <climits>
#include <algorithm>
#include <random>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <bitset> 
#include <queue>
#define inf 0x3f3f3f3f
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
#define rep(i, a, n) for(register int i = a; i <= n; ++ i)
#define per(i, a, n) for(register int i = n; i >= a; -- i)
using namespace std;
typedef long long ll;
const int mod=1e9+7;
template<typename T>void write(T x)
{
    if(x<0)
    {
        putchar('-');
        x=-x;
    }
    if(x>9)
    {
        write(x/10);
    }
    putchar(x%10+'0');
}
 
template<typename T> void read(T &x)
{
    x = 0;char ch = getchar();ll f = 1;
    while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
    while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;};
ll ksm(ll a,ll n){//看是否要mod 
	ll ans=1;
	while(n){
		if(n&1) ans=(ans*a)%mod;
		a=a*a%mod;
		n>>=1;
	}
	return ans%mod;
}
//==============================================================



int main()
{
	#ifndef ONLINE_JUDGE
	#endif
	//===========================================================
	int a[10];
    rep(i,1,5) read(a[i]);
    rep(i,1,5){
        if(a[i]!=i){
            write(i);
            return 0;
        }
    }
	//===========================================================
	return 0;
}

Measured memory_bytes: 3592
function dfs(x){
	if (x > Math.pow(10, 9)|| x > n){
	    return 0;
	}
	if ( String(x).indexOf(3) !== -1 &&  String(x).indexOf(5) !== -1 && String(x).indexOf(7) !== -1){
	    ans = 1;
	}else{
	    ans = 0;
	}
	
	ans += dfs(x*10+3);
    ans += dfs(x*10+5);
	ans += dfs(x*10+7);

	return ans;
	
}

function main(input) {
    var args = input.split('\n'); //各行を取り出し
    n = parseInt(args, 10);
    console.log( dfs(0));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9916
N, M = map(int, input().split())
X = sorted([int(c) for c in input().split()])

if N >= M:
    print(0)
    exit(0)

undeveloped_lengths = sorted(
    [X[i] - X[i - 1] - 1 for i in range(M - 1, 0, -1)], reverse=True)
length_have_to_be_covered = (X[-1] - X[0] + 1) - sum(
    undeveloped_lengths[:N - 1])
print(length_have_to_be_covered - N)


Measured memory_bytes: 13840
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, x = 1;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  cin >> m;
  vector<int> b(m);
  for (int i = 0; i < m; i++) {
    cin >> b.at(i);
  }
  for (int i = 0; i < m; i++) {
    int y = 1;
    for (int j = i; j < n; j++) {
      if (b.at(i) == a.at(j)) {
        y = 0;
        break;
      }
    }
    if (y == 1) {
      x = 0;
      break;
    }
  }
  cout << x << endl;
}



Measured memory_bytes: 4332
#include <iostream>
#include <string>
#include <queue>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <climits>
#include <map>

using namespace std;

long long dp[50][51][3000];
int x[50];
int main(){
  int N;
  int A;
  cin >> N >> A;
  for(int i = 0; i < N; i++){
    cin >> x[i];
  }

  int sum_x = accumulate(x, x + N, 0);

  dp[0][0][0] = 1;
  dp[0][1][x[0]] = 1;

  for(int i = 1; i < N; i++){
    for(int j = 0; j <= N; j++){
      for(int k = 0; k <= sum_x; k++){
        dp[i][j][k] = dp[i - 1][j][k];
        if(j  > 0 && k >= x[i]){
          dp[i][j][k] += dp[i - 1][j - 1][k - x[i]];
        }
      }
    }
  }

  long long ans = 0;
  for(int i = 1; i <= N; i++){
    for(int j = 0; j <= sum_x; j++){
      if(j  == i * A){
        ans += dp[N - 1][i][j];
      }
    }
  }
  /*
  for(int i = 0; i < N; i++){
    for(int j = 0; j <= sum_x; j++){
      cout << dp[N - 1][i][j] << " ";
    }
    cout << endl;
  }
  */
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 58880
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N ((ll)301*1000)

ll n;

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=1;;i++)
		if(i*(i+1)/2>=n)
			return cout<<i<<endl,0;
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;
  if (u==s) cout<<a-1<<' '<<b<<endl;
  else if (u==t) cout<<a<<' '<<b-1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int N;
    int a,b,c;
    scanf("%d",&N);
    a=N%10;
    b=((N-a)%100)/10;
    c=(N-b-a)/100;
    if(a==c)
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
}

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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS resize
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007
void init();
void solve();

signed main()
{
	init();
	solve();
}

struct BIT {
	vector<vector<int>> node;
	int n;
	BIT(int n_) : node(n_+1, vector<int>(n_+1, 0)), n(n_+1) {}
	void add(int r, int c, int v) {
		for (int i = r+1; i <= n; i += i & -i) {
			for (int j = c+1; j <= n; j += j & -j) {
				node[i][j] += v;
			}
		}
	}
	int get(int r, int c) {
		int res = 0;
		for (int i = r+1; i; i -= i & -i) {
			for (int j = c+1; j; j -= j & -j) {
				res += node[i][j];
			}
		}
		return res;
	}
	int get_sum(int r1, int c1, int r2, int c2) {
		return get(r2, c2) - get(r1, c2) - get(r2, c1) + get(r1, c1);
	}
};

void init()
{
	int N, M, Q;
	cin >> N >> M >> Q;
	BIT bit(N+20);
	rep(i, M) {
		int l, r;
		cin >> l >> r;
		l--;
		r--;
		bit.add(l, r, 1);
	}
	rep(i, Q) {
		int l, r;
		cin >> l >> r;
		l-= 2;
		r--;
		cout << bit.get_sum(l, l, r, r) << endl;
	}
}

void solve()
{
}

Measured memory_bytes: 2048
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
int res,m,d;
int main(){
	scanf("%d%d",&m,&d);
	fp(i,1,m)fp(j,10,d)if((j%10)>=2&&(j/10)>=2)res+=((j%10)*(j/10)==i);
	printf("%d\n",res);
	return 0;
}

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

int main(){
    int n, ab = 1000;
    vector<int> w;

    cin >> n;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >> tmp;
        w.push_back(tmp);
    }

    for(int i = 0; i < n; i++){
        ab = min(abs(accumulate(w.begin(),w.begin() + i,0)
                - accumulate(w.begin()+ i,w.end(),0)),ab);
    }
    cout << ab << endl;
}

Measured memory_bytes: 256
n,a,b,c,d = list(map(int, input().split()))
a,b,c,d = a-1,b-1,c-1,d-1 #indexに合わせる
s = input()
k = 0
swappable = False
possible = True

#A-C, B-D に岩が二つ並んでいる箇所があるなら不可能

#C>Dの場合B以上の位置で3マス以上の空白があれば
for i in range(a, max(c,d)):#+1):
    j = s[i]
    if j=='#':
        if (k==0) and ((a<i<c) or (b<i<d)):
            possible = False
            break
        k = 0
    if j=='.':
        k += 1
        if (k>=3) and (b<i<=(d+1)):
            swappable = True
    

if (c>d) and (not swappable):
    possible = False

print('Yes' if possible else 'No')

Measured memory_bytes: 3572
#include <iostream>
#include <string>
using namespace std;
string co(int n);
int re(string str);
int main(){
  
  int n,i;
  cin >> n;
  for(i=0;i<n;i++){
    string str1,str2;
    cin >> str1 >> str2;
    cout << co(re(str1)+re(str2)) << endl;
  }
  return 0;
}

string co(int n){
  string b="";
  int k=n/1000;
  string c;
  c[0]=(k+'0');
  if(k==1) b+="m";
  if(1<k&&k<=9) {b+= c[0];b+="m";}
  k=(n%1000)/100;
  c[0]=(k+'0');
  if(k==1) b+="c";
  if(1<k&&k<=9) {b+= c[0];b+="c";}
  k=(n%100)/10;
  c[0]=(k+'0');
  if(k==1) b+="x";
  if(1<k&&k<=9){b+= c[0];b+="x";}
  k=n%10;
  c[0]=(k+'0');
  if(k==1) b+="i";
  if(1<k&&k<=9){b+= c[0];b+="i";}
  return b;
}

int re(string str){
  int n=0;
  int p=str.find("m");
  if(p!=-1){
    if(p==0) n+=1000;
    else n+=(str[p-1]-'0')*1000;
  }
  p=str.find("c");
  if(p!=-1){
    if(p==0||str[p-1]=='m') n+=100;
    else n+=(str[p-1]-'0')*100;
  }
  p=str.find("x");
  
  if(p!=-1){
    if(p==0||str[p-1]=='m'||str[p-1]=='c') n+=10;
    else n+=(str[p-1]-'0')*10;
  }
  p=str.find("i");
  if(p!=-1){
    if(p==0||str[p-1]=='m'||str[p-1]=='c'||str[p-1]=='x') n+=1;
    else n+=(str[p-1]-'0')*1;
  }
  return n;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, out;

    cin >> a >> b;

    if (a*b % 2 == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }
    
    

}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include<climits>
#include<cmath>
#include<cstdio>
#include<deque>
#include<map>
#include<set>
#include<vector>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<numeric>
#include<string>
#include<tuple>
#include<queue>
using namespace std;
// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define pt pop_front
#define pk pop_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
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;}
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
long A,P;
inline void solve(void){
  in(A,P);
  out((A*3+P)/2);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
k = int(input())
n = list(map(str, range(10)))

i = 0
while len(n) < k+1:
    i += 1
    # -1, 0, 1
    for j in range(-1, 2):
        # 一の位
        m = n[i][-1]
        if j == -1 and m == "0":
            continue
        if j == 1 and m == "9":
            break
        p = n[i] + n[int(m)+j]
        n.append(p)


print(n[k])


Measured memory_bytes: 10148
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,e,i,j,ii,jj,zx,xc,pi,dp[3009],fct[400009],mod=1000000007LL,fc[400009];
pair <long long, pair <long long, long long> > p[3009];
long long xar(long long q, long long w){
	if(w==0) return 1LL;
	long long qw=xar(q,w/2);
	if(w%2==0) return (qw*qw)%mod; else return ((qw*qw)%mod*q)%mod;
}
long long C(long long q, long long w){
	return ((fct[q]*fc[w])%mod*fc[q-w])%mod;
}
int main(){
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>a>>b>>pi;
	for(i=1; i<=pi; i++){
		cin>>p[i].second.first>>p[i].second.second;
		p[i].first=p[i].second.first+p[i].second.second;
	}
	pi++;
	p[pi].first=a+b;p[pi].second.first=a;p[pi].second.second=b;
	sort(p+1,p+pi+1);
	fct[0]=1;
	for(i=1; i<=400002; i++){
		fct[i]=fct[i-1]*i;
		fct[i]%=mod;
	}
	for(i=0; i<=400002; i++){
		fc[i]=xar(fct[i],mod-2);
	}
	for(i=1; i<=pi; i++){
		c=p[i].second.first;d=p[i].second.second;
		dp[i]=C(c+d-2,c-1);
		for(j=1; j<i; j++){
			if(p[j].second.first>c||p[j].second.second>d) continue;
			zx=dp[j]*C(c+d-p[j].second.first-p[j].second.second,c-p[j].second.first);zx%=mod;
			dp[i]=dp[i]+mod-zx;dp[i]%=mod;
		}
	}
	cout<<dp[pi]<<endl;
	return 0;
}

Measured memory_bytes: 9992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>

using namespace std;

typedef long long ll;

string beautify(string str) {
	string ret = "";
	for (int i = 0; i < str.size(); ++i) {
		char c = str[i];
		if ('a' <= c && c <= 'z') ret += c;
		else if ('A' <= c && c <= 'Z') ret += (char)(c-'A'+'a');
	}
	return ret;
}

int main() {
	int n; cin >> n;
	int A = 0, B = 0;
	for (int i = 0; i < n; ++i) {
		string a, b; cin >> a >> b;
		if (a > b) A += 3;
		else if (a == b) ++A, ++B;
		else B += 3;
	}
	cout << A << " " << B << endl;
}

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

using namespace std;

string s,t;
int q;
int p[3][100001];

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

	cin >> s >> t;
	for (int i=0;i<s.size();i++)
		p[1][i+1] = p[1][i] + ((s[i] == 'A') ? 1 : -1);
	for (int i=0;i<t.size();i++)
		p[2][i+1] = p[2][i] + ((t[i] == 'A') ? 1 : -1);
	cin >> q;
	while(q--)
	{
		int l1,r1,l2,r2;
		cin >> l1 >> r1 >> l2 >> r2;
		int a = ((p[1][r1] - p[1][l1-1])%3 + 3)%3;
		int b = ((p[2][r2] - p[2][l2-1])%3 + 3)%3;
		cout << ((a == b) ? "YES\n" : "NO\n");
	}
}

Measured memory_bytes: 1744
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
long long n, k, d;
int a[maxn], lst[maxn], to[maxn], zz[maxn], t, hs[maxn];

int main() {
	scanf("%lld%lld", &n, &k);
	for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for (int i = n; i; --i) lst[a[i]] = i;
	for (int i = n; i; --i) {
		to[i] = lst[a[i]];
		lst[a[i]] = i;
	}
	int pos = 1;
	do {
		if(to[pos] <= pos) ++d;
		if(to[pos] == n) ++d;
		pos = to[pos] % n + 1;
	}while(pos != 1);
	k %= d;
	if(k == 0) return 0;
	pos = 1;
	while(1) {
		if(to[pos] <= pos) {
			if(k > 1) --k;
			else break;
		}
		pos = to[pos] % n + 1;
	}
	for (int i = pos; i <= n; ++i) {
		if(hs[a[i]]) {
			//cerr << a[i] << endl;
			while(zz[t] != a[i]) 
				hs[zz[t--]] = 0;
			hs[zz[t--]] = 0;
		}
		else {
			hs[a[i]] = 1;
			zz[++t] = a[i];
		}
	}
	for (int i = 1; i <= t; ++i) printf("%d ", zz[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 7416
#include <iostream>
#include <algorithm>

using namespace std;

int range(int left, int right);

int main()
{
    int n;
    int k;
    int x[100005];
    int ans = 1000000005;

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

    for (int i = 0; i <= n - k; i++) {
        ans = min(ans, range(x[i], x[i + k - 1]));
    }

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

int range(int left, int right)
{
    if (left < 0 && right < 0) {
        return left * -1;
    } else if (left >= 0 && right >= 0) {
        return right;
    } else {
        left *= -1;

        return min(left, right) * 2 + max(left, right);
    }
}


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

long long int A, B, N;

int floor_big (long long int A, long long int B, long long int x) {

}

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

    long long int x = min(N, B - 1);

    cout << (A * x) / B << endl;
}

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

using namespace std;

int n;
long long a[100005];
long long x;

int main(){
  cin>>n>>x;
  for(int i=0;i<n;i++)cin>>a[i];
  long long ans = 0LL;
  for(int i=1;i<n;i++){
    long long tmp = max(0LL,(a[i]+a[i-1]) - x);
    ans  += min(a[i], tmp);
    a[i] -= min(a[i], tmp);

    tmp = max(0LL,(a[i]+a[i-1]) - x);
    ans  += min(a[i-1], tmp);
    a[i-1] -= min(a[i-1], tmp);
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,l,r) for(int (i)=(l);(i)<(r);(i)++)
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<vector<int>> x(n),y(n);
    rep(i,0,n){
        int a;
        cin>>a;
        rep(j,0,a){
           int b,c;
           cin>>b>>c;
           x[i].emplace_back(b);
           y[i].emplace_back(c);
        }
    }
    int ans=0;
    rep(a,0,(1<<n)){
        int ng=0;
        rep(i,0,n){
           if((a>>i&1)){
               rep(j,0,(int)x[i].size()){
                  if((a>>(x[i][j]-1)&1)!=y[i][j])ng=1;
               }
           }
        }       
        if(!ng){
            int ma=0;
            rep(j,0,n)if(a>>j&1)ma++;
            ans=max(ans,ma);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
typedef long long ll;

int main()
{
	int i, j;
	char s[101], t[101], tmp;
	scanf("%s %s", s, t);

	for (i = 0; i < strlen(s) - 1; i++) {
		for (j = i + 1; j < strlen(s); j++) {
			if (s[i] > s[j]) {
				tmp = s[i];
				s[i] = s[j];
				s[j] = tmp;
			}
		}
	}
	for (i = 0; i < strlen(t) - 1; i++) {
		for (j = i + 1; j < strlen(t); j++) {
			if (t[i] < t[j]) {
				tmp = t[i];
				t[i] = t[j];
				t[j] = tmp;
			}
		}
	}
	if (strcmp(s, t) < 0) {
        puts("Yes");
    } else {
        puts("No");
    }

	return 0;
}

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

int64_t check( int b, int A[], int N )
{
    int64_t sum = 0LL;
    for ( int i = 1; i <= N; i++ ) {
        sum += llabs(((int64_t)b + i) - A[i - 1]);
    }
    return ( sum );
}

int main()
{
    int N;
    int A[200005];

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

    int ng = -1000000007, ok = 1000000007;
    while ( abs(ok - ng) > 1 ) {
        int b = (ok + ng) / 2;
        int64_t sad1 = check(b, A, N), sad2 = check(b + 1, A, N);
        if ( sad2 - sad1 < 0 ) {
            ng = b;
        } else {
            ok = b;
        }
    }
    cout << check(ok, A, N) << endl;
    return (0);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,x;
  cin>>n>>x;
  if (x == 1 || x == 2*n-1) {
    cout<<"No\n";
    return 0;
  }
  cout<<"Yes\n";
  set<int> ok;
  REP(i,2*n-1) ok.insert(i+1);
  vecint ans(2*n-1);
  if (x < 2*n-2) {
    ans[n-2] = x+1;
    ans[n-1] = 1;
    ans[n] = x;
    if (n > 2) ans[n+1] = 2*n-1;
  } else {
    ans[n-2] = x-1;
    ans[n-1] = 2*n-1;
    ans[n] = x;
    if (n > 2) ans[n+1] = 1;
  }
  for(auto&&e:ans) if(e) ok.erase(e);
  for(auto&&e:ans) {
    if (e == 0) {
      e = *begin(ok);
      ok.erase(begin(ok));
    }
    cout<<e<<"\n";
  }
  return 0;
}


Measured memory_bytes: 11648
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    int n,k;
    cin>>n>>k;
    cout<<n-k+1<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
map<string,int> memo;

int main() {
int n;
cin >> n;
string s;
for(int i = 0;i<n;i++){
	cin >> s;
	memo[s] += 1;
}
int maxv = 0;
for(const auto& x : memo){
	int v = x.second;
	if(v > maxv) maxv = v;
}
for(auto it = memo.begin();it != memo.end(); it++){
	if(it->second == maxv){
			cout << it->first << endl;
}
}
	return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0;i<N;i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  
  int alice=0,bob=0;
  for(int i=0;i<N;i++){
    if(i%2==0){
      alice+=vec[i];
    }
    else{
      bob+=vec[i];
    }
  }
  
  cout  << abs(alice-bob) <<endl;
}


Measured memory_bytes: 3576
awk 'BEGIN{;\
	getline s;\
    getline t;\
    i=0;\
    substr(s,1,1)==substr(t,1,1)?i++:0;\
    substr(s,2,1)==substr(t,2,1)?i++:0;\
    substr(s,3,1)==substr(t,3,1)?i++:0;\
    print(i);\
};\'

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

int n;
vector<int> v;//塗り分け方
vector<int> flag;
vector<pair<int, int> > deg[100005];

void dfs(int idx, int c){
    flag[idx]=1;
    for(auto p : deg[idx]){
        if(flag[p.first]==1) continue;
        if(p.second==0) {
            v[p.first]=c;
            dfs(p.first, c);
        }
        else {
            int tmp=0;
            if(c==0) tmp=1;
            v[p.first]=tmp;
            dfs(p.first, tmp);
        }
    }
}

int main(void){
    int n;
    cin>>n;
    v.resize(n);
    flag.resize(n);
    rep(i, n-1){
        int a, b;
        ll c;
        cin>>a>>b>>c;
        c=c%2;
        --a;
        --b;
        deg[a].push_back(make_pair(b, c));
        deg[b].push_back(make_pair(a, c));
    }
    dfs(0, 0);
    rep(i, n) cout<<v[i]<<endl;
    return 0;

}

Measured memory_bytes: 7936