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

#ifdef _LOCAL
  #include <utils/debug.hpp>
  #include <utils/random_generate.hpp>
  #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
  #define debug(...) 42
  #define generate_string(...) 42
  #define generate_array(...) 42
  #define generate_unique_array(...) 42
#endif

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vl2;
const bool multiple_queries = false;
#define rep(i, n) for(ll i = 0; i < (n) ; ++i)
#define For(i, a, b) for(ll i = (a); i < (b) ; ++i)
#define revrep(i, n) for(ll i = (n) - 1; i >= 0 ; --i)
#define revFor(i, b, a) for(ll i = (b) - 1; i >= (a) ; --i)
#define all(v) v.begin(), v.end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(i) __builtin_popcountl((i))
#define substring(s, start, end) s.substr((start), (end) - (start) + 1)

void scan(){}
template <class Head, class... Tail>
void scan(Head&& head, Tail&&... tail) {
  cin >> head;
  scan(forward<Tail>(tail)...);
}

void print(){}
void println(){cout << endl;}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T>& vs){
  for (auto v: vs){
    cout << v;
    if (&v != &vs.back()) cout << " ";
  }
  cout << endl;
}

template <class Head, class... Tail>
void println(Head&& head, Tail&&... tail) {
  cout << head;
  if (sizeof...(tail) != 0) cout << " ";
  println(forward<Tail>(tail)...);
}

template <class T>
void println(vector<T>& vs){for (auto v: vs) cout << v << endl;}

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


vl eratosthenes(ll n, vl& div){
  // return the list of prime number up to n
  div = vl(n + 1, 0); vl ps;
  rep(i, n + 1) div[i] = i;
  For(i, 2, n + 1){
    if(div[i] == i){
      for(ll j = 2 * i; j <= n; j += i)
        chmin(div[j], i);
      ps.push_back(i);
    }
  }
  return ps;
}

map<ll, ll> quick_prime_factorization(vl& div, ll n){
  // ABC177E using the div from eratosthenes
  map<ll, ll> table;
  while (n != 1){
    table[div[n]]++;
    n /= div[n];
  }
  return table;
}

void solve(){
  ll n, ans = 0;
  scan(n);
  vl div;

  eratosthenes(n, div);

  For(c, 1, n){
    ll res = n - c;
    ll cnt = 1;
    map<ll, ll> m = quick_prime_factorization(div, res);
    for (auto& p: m) cnt *= p.second + 1;
    ans += cnt; 
  }
  println(ans);
}

void test(ll num = 0, bool verbose = false){
  rep(i, max(1LL, num)){
    ll t = clock();
    if (verbose) cout << "\n#####" << " " << i + 1 << " " << "#####" << " " << "\n## Answer ##\n";
    solve();
    if (verbose) {cout << "\nElapsed Time:" << " " << 1000.0 * (clock() - t) / CLOCKS_PER_SEC << " " << "[ms]" << endl;}
  }
}

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);
  #ifdef _LOCAL
    test(6, true);
  #else
    ll t = 0;
    if (multiple_queries) cin >> t;
    test(t, false);
  #endif
  return 0;
}

Measured memory_bytes: 12124
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

from functools import reduce
from operator  import mul

N = int(input())
S = input()
assert N == len(S)

# 各文字の出現数
C = set(S)
numOf = {c: sum(1 for s in S if s == c) for c in C}

# 部分列の数 (各文字について, いずれか1箇所を選択 or いずれも選ばない)
nSeq = reduce(mul, (n + 1 for n in numOf.values()))
nSeq -= 1  # 空列を除く

print(nSeq % (10 ** 9 + 7))

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

int main() {
 int a,b;
 string op ;
  cin >> a >> b ;
  for (int i=0 ; i<b+2 ; i++){
    cout << '#' ;
  }
  cout << endl;
  for (int j=0 ; j<a ; j++){
    cin >> op ;
    cout << '#' << op <<'#' <<endl;
  }
  for (int i=0 ; i<b+2 ; i++){
    cout << '#' ;
  }
  cout << endl;
}
  
      
  
  
 

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    char a, b, c;
    scanf("%c%c%c", &a, &b, &c);
    if (a == 'R' && b == 'R' && c == 'R') printf("3");
    else if (a == 'R' && b == 'R' ||
             b == 'R' && c == 'R') printf("2");
    else if (a == 'R' || b == 'R' || c == 'R') printf("1");
    else printf("0");
}


Measured memory_bytes: 1592
fun main(args: Array<String>) {
    //"Sunny", "Cloudy", "Rainy"
    val S = readLine()!!
    var ans = ""
    if (S == "Sunny") ans = "Cloudy"
    if (S == "Cloudy") ans = "Rainy"
    if (S == "Rainy") ans = "Sunny"
    println(ans)
}

Measured memory_bytes: 31840
K,A,B=map(int,input().split())
if A>=B-2:
    ans=1+K
else:
    if K<=A-1:
        ans=1+K
    else:
        bis=A
        if (K-(A-1))%2==0:
            ans=(B-A)*((K-(A-1))//2)+A
        else:
            ans=(B-A)*((K-(A-1))//2)+1+A
print(ans)
            

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int H, A; cin >> H >>  A;
    if(H % A == 0) cout << H/A  << endl;
    else cout << H/A +1<< endl;
    return 0;
}

Measured memory_bytes: 256
n, d = gets.chomp.split.map(&:to_i)
x = []
n.times do
  x << gets.chomp.split.map(&:to_i)
end
result = 0
0.upto(n-2) do |i|
  (i+1).upto(n-1) do |j|
    sum = 0
    0.upto(d-1) do |k|
      sum += (x[i][k] - x[j][k]) ** 2
    end
    result += 1 if (Math.sqrt(sum).to_i) ** 2 == sum 
  end
end
puts result

Measured memory_bytes: 1788
n, m = map(int, input().split())
k = [list(map(int, input().split())) for _ in range(m)]
p = list(map(int, input().split()))

ans = 0

s = [0] * n
for i in range(2 ** n):
    temp = i
    for j in range(n):
        s[j] = temp % 2
        temp //= 2
    for j in range(m):
        z = 0
        #print(k[j])
        for x in range(1, k[j][0]+1):
            z += s[k[j][x] - 1]
        if p[j] != z % 2:
            break
    else:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#include<cstdio>
int main() {
	int h, w, i, j;
	char s[50][51];
	scanf("%d%d", &h, &w);
	for (i = 0; i < h; i++)scanf("%s", s[i]);
	for (i = 0; i < h; i++) {
		for (j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				if ((i == 0 || s[i - 1][j] == '.') && (i == h - 1 || s[i + 1][j] == '.') && (j == 0 || s[i][j - 1] == '.') && (j == w - 1 || s[i][j + 1] == '.')) {
					printf("No");
					return 0;
				}
			}
		}
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
using namespace std;

int main(){
    int n,a,cnt=0;
    scanf("%d",&n);
    for(int i=0; i<n; i++){
        scanf("%d",&a);
        while(1){
            if(a&1){
                break;
            }
            cnt++;
            a>>= 1;
        }
    }
    printf("%d\n",cnt);
}

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

int main() {
	map<string, int> lst;
	int n, m; string s;
	bool isOpen = false;
	cin >> n;
	for(int i=0; i<n; ++i) {
		cin >> s;
		lst[s] = 1;
	}
	cin >> m;
	for(int i=0; i<m; ++i) {
		cin >> s;
		if(lst.count(s)==0) {
			cout << "Unknown " << s << endl;
		}else {
			isOpen = !isOpen;
			cout << (isOpen ? "Opened by " : "Closed by ") << s << endl;
		}
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    cout << n * (n - 1) / 2  - n / 2 << endl; 
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            if (i + j != n + ((n + 1) % 2)) cout << i << " " << j << endl;
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define pb push_back
#define mp make_pair
const int mod=1e9+7;
void solve()
{
  string s,t;
  cin>>s>>t;
  int n=s.length();
  int cnt=0;
  for(int i=0;i<n;i++)
  {
    if(s[i]!=t[i])
    cnt++;
  }
  cout<<cnt<<endl;
}

int main()
{
  fastio
  solve();
}


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

int main(){
	int n,nn;
	while(cin >> n,n){
		if(n % 1111 == 0) {
			cout << "NA" << endl;
		}else{
			int i = 0;
			for(;n != 6174;i++){
				int num[4] = {n / 1000,n / 100 % 10,n / 10 % 10,n % 10};
				sort(num,num + 4,greater<int>());
				n = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3];
				sort(num,num + 4);
				nn = num[0] * 1000 + num[1] * 100 + num[2] * 10 + num[3];
				n = n - nn;
			}
			cout << i << endl;
		}
	}
	return 0;
}

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

int main() {
  long long int N;
  cin >> N;
  long long int ans=0;
  //  cout << sqrt(N);
  for(int i=1; i < sqrt(N); i++){
    if(N/i *i == N){
      if(N/i -1 > i){
	ans += N/i -1;
	  }
    }
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int D;
    scanf("%d",&D);
    if(D==25)printf("Christmas\n");
    else if(D==24)printf("Christmas Eve\n");
    else if(D==23)printf("Christmas Eve Eve\n");
    else if(D==22)printf("Christmas Eve Eve Eve\n");
    return 0;

}


Measured memory_bytes: 128
# https://atcoder.jp/contests/abs/tasks/arc065_a


class String
  def cut_tail!(tail)
    if self[(self.length - tail.length)...(self.length)] == tail
      self.replace(self[0...(self.length - tail.length)])
    end
  end
end

s = gets.chomp

cond = true
while s != ''
  unless s.cut_tail!('dream') || s.cut_tail!('dreamer') || s.cut_tail!('erase') || s.cut_tail!('eraser')
    cond = false
    break
  end
end

puts cond ? 'YES' : 'NO'


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

int gcd(int a,int b){
  int tmp;
  if(a>b){
    tmp = a;
    a = b;
    b = tmp;
  }
  if(a == 0)return b;
  else return gcd(b%a,a);
}

int main()
{
  int a,b;

  while(cin >> a >> b){
    cout << gcd(a,b) << endl;
  }

  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

inline int topbit(unsigned long long x){
	return x?63-__builtin_clzll(x):-1;
}

inline int popcount(unsigned long long x){
	return __builtin_popcountll(x);
}

inline int parity(unsigned long long x){
	return __builtin_parity(x);
}

signed main(){
	string S;cin>>S;
	cout<<S.substr(0,3)<<endl;
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, K, a;
    cin >> N >> K;
    vector<ll> pos, neg;
    pos.push_back(0);
    for (int i = 0; i < N; i++) {
        cin >> a;
        if (a > 0) pos.push_back(a);
        else neg.push_back(-a);
    }
    neg.push_back(0);
    reverse(neg.begin(), neg.end());
    ll ans = LINF;
    for (int pi = 0; pi <= K; pi++) {
        int ni = K - pi;
        if (pi >= pos.size() || ni >= neg.size()) continue;
        ll tmp = min(pos[pi] * 2 + neg[ni], pos[pi] + neg[ni] * 2);
        ans = min(tmp, ans);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 1656
import bisect

n = int(input())
li = list(map(int,input().split()))
li2 = sorted(li)
cnt = 0

for i in range(n-2):
    for j in range(i+1,n-1):
        cnt += bisect.bisect_left(li2,li2[i]+li2[j]) - (j+1) 
print(cnt)

Measured memory_bytes: 3188
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

template<class T> inline bool chmin(T& a, T b){ if(a>b){a=b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b){ if(a<b){a=b; return 1;} return 0;}

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

//#define __DBG__




void solve(void){
  
  ll N, A, B;
  cin >> N >> A >> B;
  
  ll tmp = A+B;
  
  ll count=N/tmp;
  ll p=N%tmp;
  
  if(p>=A){
    tmp=A;
  }
  else
  {
    tmp=p;
  }
  
  ll ans = A*count+tmp;

  cout << ans << endl;

  return;
}

int main(int argc, const char * argv[]) {


    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





Measured memory_bytes: 256
import java.io.*;

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

        String line = reader.readLine();
        int len = line.length();
        char c[] = line.toCharArray();

        for(int i = 0; i < len; i++){
            
            if(c[i] >=65 && c[i]<= 90){
                c[i] = Character.toLowerCase(c[i]);
                System.out.print(c[i]);
            }else if(c[i]<=122&&c[i]>=97){
                c[i] = Character.toUpperCase(c[i]);
                System.out.print(c[i]);
            }else{
                System.out.print(c[i]);
            }
            
            if(i == len-1){
                System.out.print("\n");
            }
            
        }
        }
    }




Measured memory_bytes: 25052
use std::io::*;
use std::str::FromStr;
 
/* 
The read function reads a string according to each one. 
*/
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


//main function
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    if b%a==0 {
	println!("{}",a+b);
    }else{
	println!("{}",b-a);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
#define INF 1000000000
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int n,m,x; cin >> n >> m >> x;
    int ans = INF;
    vint c(n);
    vector<vint> a(n,vint(m));
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> a[i][j];
        }
    }

    for(int bit = 0; bit < (1 << n+1); ++bit){
        int cost = 0;
        vint a_(m,0);

        for(int i = 0; i < n; ++i){
            int index = (1 << i);
            if(bit & index){
                rep(j,m){
                    a_[j] += a[i][j];
                }
                cost += c[i];
            }
        }
        if(*min_element(a_.begin(),a_.end()) >= x){
            chmin(ans, cost);
        }
    }

    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;

    return 0;
}

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


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

int main(){
	int n,k;
	int res,ans = 1000000000;
	cin >> n >> k;

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

	for (int i = 0; i < n-(k-1); i++){
		xl = x[i],xr = x[i+k-1];
		if (xl <= 0 and xr <= 0 or xl >= 0 and xr >= 0){
			res = max(abs(xl),xr);
		}
		else{
			res = min(abs(xl)*2 + xr, xr*2 + abs(xl));
		}
		ans = min(ans,res);
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)
#define uniq(v) sort((v).begin(),(v).end()); (v).erase(unique((v).begin(),(v).end()),(v).end());
#define steprap(i,n,s) for(int (i)=0;i<(s)*(n);(i)+=(s))
#define rap(i,n) steprap((i),(n),1)

using namespace std;
namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);
	int gcm(int a,int b);
	int lcm(int a,int b);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
	int gcm(int a,int b){
		int p=max(a,b);
		int q=min(a,b);
		int r;
		while(true){
			if(p%q==0){
				return q;
			}
			r = p%q;
			p=q;
			q=r;
		}
	}
}

using namespace std;
// using StringMap = std::vector<std::vector<char>> map(h+2,vector<char>(w+2,'#'));
namespace tmp {
    template <typename T> bool inArry(T x,vector<T> v);

    template <typename T> bool inArry(T x,vector<T> v){
        int l = v.size();
        for(int i=0;i<l;i++){
            if(x==v[i]){
                return true;
            }
        }
        return false;
    }
}

using namespace std;

signed main (){
	vector<int> A(9);
	vector<int> C(9);
	rap(i,9){
		cin >> A.at(i);
	}
	incin(n);
	vector<int> b(n);
	rap(i,n){
		cin >> b.at(i);
		rap(j,9){
			if(A[j]==b[i]){
				C[j]=1;
				break;
			}
		}
	}
	
	for(int i=0;i<3*3;i+=3){
		if(C[i]==1 && C[i+1] == 1 && C[i+2]==1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	for(int i=0;i<3;i++){
		if(C[i]==1 && C[i+3] == 1 && C[i+6]==1){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	if(C[0]==1 && C[4] == 1 && C[8]==1){
			cout<<"Yes"<<endl;
			return 0;
	}
	if(C[2]==1 && C[4] == 1 && C[6]==1){
			cout<<"Yes"<<endl;
			return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
import sys
input = sys.stdin.readline

def get_sum(num):
    return num*(num-1)/2


N = int(input())
S = []
D = defaultdict(int)
ans = 0
for _ in range(N):
    s = str(sorted(input()))
    D[s] += 1

for k, v in D.items():
    ans += get_sum(v)


print(int(ans))



Measured memory_bytes: 85212
#include <cstdio>
#include <cmath>
#include <numeric>
#include <cstring>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <utility>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ul;

const int iinf = 1 << 29;
const long long linf = 1l << 61;

int main(int argc, char* argv[])
{
	char S[51];
	char T[51];
	scanf("%s", S);
	scanf("%s", T);
	int NS = strlen(S);
	int NT = strlen(T);
	char m[51];
	fill(begin(m), end(m), 'z');
	bool unres = true;
	for(int i = 0; i < NS; i++)
	{
		bool flag = true;
		for(int j = 0; j < NT; j++)
		{
			if(i + j >= NS || (S[i + j] != '?' && S[i + j] != T[j]))
			{
				flag = false;
				break;
			}
		}
		if(flag)
		{
			char str[51];
			strcpy(str, S);
			for(int j = 0; j < NT; j++)
			{
				str[i + j] = T[j];
			}
			for(int j = 0; j < NS; j++)
			{
				if(str[j] == '?') str[j] = 'a';
			}
			bool ismin = true;
			for(int j = 0; j < NT; j++)
			{
				if(m[j] < str[j])
				{
					ismin = false;
					break;
				}
			}
			if(ismin)
			{
				strcpy(m, str);
				unres = false;
			}
		}
	}
	if(unres) printf("UNRESTORABLE\n");
	else printf("%s\n", m);
	return 0;
}


Measured memory_bytes: 128
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void eratos(vector<bool>& cp_list,int max){
  cp_list.resize(max+1);
  fill(cp_list.begin(),cp_list.end(),true);
  cp_list[0]=false;
  cp_list[1]=false;
  for(ll i=2;i*i<=max;i++){
    if(cp_list[i]){
      for(ll j=2;j*i<=max;j++){
        cp_list[i*j]=false;
      }
    }
  }
}
signed main(){
  ll x;
  cin >> x;
  vector<bool> list;
  ll v = 10000000;
  eratos(list,v);
  for(int i=x;;i++){
    if(list[i]){
      cout << i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a, a+n);
    if (a[n-1] < sum-a[n-1])
        cout<< "Yes\n";
    else
        cout << "No\n";


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define mod 10e9+7

#define rep(i,n) for(int i=0;i<n;i++)
int main(){
   ll n,a,b;
   cin >> n ;
   if(n==1)
   cout << "Hello World" << endl;
   if(n==2){
      cin >> a >> b;
      cout << a+b << endl;
   }
   
   
  }



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

typedef long long ll;
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define endl '\n'
const int N = 1e5 + 5;
using namespace std;
set<int>v[26];

int main() {
    IO;
    int n, t;
    string s;
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) {
        v[s[i] - 'a'].insert(i);
    }
    while (t--) {
        int type, i, l, r, cnt = 0;
        cin >> type;
        if (type == 1) {
            char c;
            cin >> i >> c;
            i--;
            v[s[i] - 'a'].erase(i);
            s[i] = c;
            v[s[i] - 'a'].insert(i);
        } else {
            cin >> l >> r;
            l--, r--;
            for (int i = 0; i < 26; ++i) {

                // Finding the first element
                // which is greater than or equal to L
                auto first = v[i].lower_bound(l);
                // Check if first pointer exists
                // and is less than or equal to R
                if (first != v[i].end() && *first <= r) {
                    cnt++;
                }
            }
            cout << cnt << endl;

        }

    }


}


Measured memory_bytes: 27212
#include <iostream>
#include <cstdio>
#include <cstring>
#include <climits>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <sstream>
#include <numeric>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

// namespace
using namespace std;
namespace mp = boost::multiprecision;

// types
using pii = pair<int, int>;
using ll = long long int;
using ld = long double;
using mpi = mp::cpp_int;
using mpf = mp::number<mp::cpp_dec_float<1024>>;

// consts
int MOD = 1000000007;  // https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a


int main() {
    ll n, m, a;
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        cin >> a;
        n -= a;
    }
    if (n >= 0) cout << n <<endl;
    else cout << -1 <<endl;

    return 0;
}


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

int main(){
	int i, n, x;
	cin >> n;
	
	for( i = 3; i <= n; i++ ){
		x = i;
		
		if( x % 3 == 0 ){
			cout << ' ' << i;
			continue;
		}
		if( x % 10 == 3 ){
			cout << ' ' << i;
			continue;
		}
		
		for( x /= 10; x > 0; x /= 10 ){
			if( x % 10 == 3 ){
				cout << ' ' << i;
				break;				
			}
		}
	}
	cout << endl;
}

Measured memory_bytes: 1160
"""
全ての桁でa, b共に0ではない場合を考えれば良い。
"""
mod = 10 ** 9 + 7
L = input()

dp1 = 0
dp2 = 1

for l in L:
    if l == "1":
        dp1 = dp1 * 3 + dp2
        dp2 = dp2 * 2

    else:
        dp1 = dp1 * 3
    dp2 %= mod
    dp1 %= mod

print((dp1 + dp2) % mod)


Measured memory_bytes: 39664
A,B,N = map(int, input().split())

def f(a, b, n):
    fl1 = (a * n) // b
    fl2 = n // b
    fl = fl1 - (a * fl2)
    return fl
   #return int(a * n / b) - a * int(n / b)

print(f(A, B, B-1) if N >= B-1 else f(A, B, N))

Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
    int a,b,c;
	cin>> a>>b>>c;
	cout<<c<<" "<<a<<" "<<b;
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, s, e) for(int i = s; i < e; i++)
#define rrep(i, s, e) for(int i = s; i > (s)-(e); i--)
#define pr(s) std::cout << s << std::endl
#define prb(s) std::cout << s
using namespace std;



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


  int x, t;
  cin >> x >> t;

  if (x-t > 0) pr(x-t);
  else pr("0");


  return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

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

    #ans = -(10**10)
    ans = 0
    for pick in range(min(N+1,K+1)):
        throw = min(pick,K-pick)
        for left in range(pick+1):
            right = pick-left
            p = []
            minus = 0
            for i in range(left):
                if V[i] < 0:
                    minus += 1
                p.append(V[i])
            for i in range(right):
                if V[-i-1] < 0:
                    minus += 1
                p.append(V[-i-1])
            p.sort()
            if minus >= throw:
                rest = p[throw:]
            else:
                rest = p[minus:]
            ans = max(ans,sum(rest))

    print(ans)

if __name__ == "__main__":
    main()


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

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

bool topFlag[100100];

void func(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){

    REP(i,0,100100)topFlag[i]=true;

    REP(i,0,M){
        lli x = A[i];
        lli y = B[i];

        if(H[x]<=H[y])topFlag[x]=false;
        if(H[x]>=H[y])topFlag[y]=false;
    }

    lli cnt=0;
    REP(i,0,N){
        if(topFlag[i])cnt++;
    }
    cout<<cnt<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        A[i]--,B[i]--;
    }
    func(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 5644
n,q=map(int,input().split())
edge=[[]for _ in range(n)]
for _ in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
ans=[0]*n
for _ in range(q):
  p,x=map(int,input().split())
  ans[p-1]+=x
Q=[0]
visited={0}
while Q:
  P=[]
  for i in Q:
    for j in edge[i]:
      if j in visited:continue
      visited.add(j)
      ans[j]+=ans[i]
      P.append(j)
  Q=P
print(*ans)

Measured memory_bytes: 62368
#include <bits/stdc++.h>//Carefully Crafted by hetp111
using namespace std;
#define int long long
#define double long double
#define all(v) (v).begin(),(v).end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vii vector<pii>
#define MOD (1000000007)
#define MOD2 (998244353)
#define MOD3 (1000000009)
#define PI acos(-1)
#define eps (1e-8)
#define INF (1e18)
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0)
template<class A,class B>ostream&operator<<(ostream&out,const pair<A,B>&a){return out<<"("<<a.first<<","<<a.second<<")";}
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A,class B>istream&operator>>(istream&in,pair<A,B>&a){return in>>a.first>>a.second;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}
ifstream cinn("in.txt");ofstream coutt("out.txt");
int poww(const int &a,int b,const int &m=MOD){if(b==0)return 1;int x=poww(a,b/2,m);x=x*x%m;if(b&1)x=x*a%m;return x;}
int ceil(const int &a,const int &b){return (a+b-1)/b;}
////Read:
//Use __builtin_popcountll for ll;
//Check corner cases, n==1;
//
////Some function:
//__builtin_popcountll(), 

int fr[100000+1];

signed main(){
    FASTER;
    int n;cin>>n;
    int sum=0;
    for(int i=0;i<n;i++){
        int in;cin>>in;
        sum+=in;
        fr[in]++;
    }
    
    int q;cin>>q;
    while(q--){
        int a,b;cin>>a>>b;
        int fra=fr[a];
        int frb=fr[b];
        sum-=a*fr[a];
        sum-=b*fr[b];
        frb+=fra;
        fra=0;
        fr[a]=fra;
        fr[b]=frb;
        sum+=b*fr[b];
        cout<<sum<<"\n";
    }
}



Measured memory_bytes: 4448
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using ll = long long;
using namespace std;

int main() {
    long double a, b;
    cin >> a >> b;

    cout << (ll)(a * b) << endl;
}

Measured memory_bytes: 3728
package main
import(
  "fmt"
)
func main(){
  var n, i int
  var s string
  flag:=0
  fmt.Scan(&n, &s)
  if n%2==1{
    flag++
  }
  for i=0;i<n/2;i++{
    if s[i]!=s[i+n/2]{
      flag++
    }
  }
  if flag!=0{
    fmt.Println("No")
  }else{
    fmt.Println("Yes")
  }
}


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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int a,b,c;
void solve(){
    cin>>a>>b>>c;
    cout<<b+min(a+b+1,c)<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
int MOD = (int)1e9 + 7;
int INF = (int)2e18;
// Comment out below and program paste

// #include "UnionFind.hpp"
// #include "power.hpp"

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H, W, N;
    pair<int, int> piece;
    string S, T;
    cin >> H >> W >> N >> piece.first >> piece.second >> S >> T;
    int up = 0, down = H + 1, left = 0, right = W + 1;
    for (int i = N - 1; i >= 0; i--) {
        // aoki
        if (T[i] == 'L') {if (right > 1) right = min(W + 1, right + 1);}
        else if (T[i] == 'R') {if (left < W) left = max(0LL, left - 1);}
        else if (T[i] == 'U') {if (down > 1) down = min(H + 1, down + 1);}
        else {if (up < H) up = max(0LL, up - 1);}

        // takahashi
        if (S[i] == 'L') left = min(W, left + 1);
        else if (S[i] == 'R') right = max(1LL, right - 1);
        else if (S[i] == 'U') up = min(H, up + 1);
        else down = max(1LL, down - 1);
    }
    bool check = (up >= piece.first || down <= piece.first || right <= piece.second || left >= piece.second);
    cout << (check ? "NO" : "YES") << endl;
}


Measured memory_bytes: 920
import numpy as np
import sys
input = sys.stdin.readline

N, M, Q = map(int, input().split())
# city[L][R]
city = [[0] * (N + 1) for _ in range(N + 2)]

for _ in range(M):
    L, R = map(int, input().split())
    city[L][R] += 1

city = np.array(city).reshape(N + 2, N + 1)
np.cumsum(city, axis=0, out=city)
np.cumsum(city, axis=1, out=city)

for _ in range(Q):
    p, q = map(int, input().split())
    print(city[q][q] - city[q][p - 1] - city[p - 1][q] + city[p - 1][p - 1])

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

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
const int INF = 1<<30;
int calc(int a, int b, int c){
  if(a&1||b&1||c&1)return 0;
  if(a==b&&b==c)return -1;
  return calc((b+c)/2, (c+a)/2, (a+b)/2)+1;
}
int main(){
  int a, b, c;cin>>a>>b>>c;
  cout<<calc(a, b, c)<<endl;
}


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

int main(){
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    vector<int> AB;
    for (int i=0; i<=max({X, Y}); ++i){
        AB.push_back(2*C*i + A*max({0, X-i}) + B*max({0, Y-i}));
    }
    cout << *min_element(AB.begin(), AB.end()) << endl;
    return 0;
}

Measured memory_bytes: 892
import Data.List
import qualified Data.IntMap.Strict as M
import qualified Data.ByteString.Char8 as B

p2s = map (2^) [1..32]
main=do
    _<-getLine
    as<-foldl' (\m a->M.insertWith (+) a 1 m) M.empty.unfoldr (B.readInt.B.dropWhile(==' '))<$>B.getLine
    print $ sol 0 as
sol c as
    | M.null as = c
    | otherwise = case M.lookup fcc as' of
                    Just x  -> sol (c+1) (M.alter f fcc as')
                    Nothing -> sol c as'
    where
        (k,a) = M.findMax as
        as' = M.alter f k as
        fc = head $ dropWhile (<k) p2s
        fcc = if fc==k then k else fc-k

f (Just c) | c==1=Nothing | c>1 = Just (c-1)


Measured memory_bytes: 37500
fn main(){
  loop {
    let v: Vec<usize> = read_vec();
    let n = v[0];
    let m = v[1];

    if n == 0 { break; }
    
    let mut cst: Vec<Vec<u32>> = vec![vec![std::u32::MAX / 4; n]; n];

    for i in 0 .. n {
      cst[i][i] = 0;
    }
    
    let s = v[2] - 1;
    let g1 = v[3] - 1;
    let g2 = v[4] - 1;

    for _ in 0 .. m {
      let v: Vec<usize> = read_vec();
      cst[v[0]-1][v[1]-1] = v[2] as u32;
    }

    wf(&mut cst);

    let mp: u32 = (0 .. n).map(|i| cst[s][i] + cst[i][g1] + cst[i][g2]).min().unwrap();

    println!("{}", mp);
  }
}

fn wf<T>(v: &mut Vec<Vec<T>>)
  where T: Ord + std::ops::Add<Output=T> + Copy
{
  let n = v.len();
  
  for k in 0 .. n {
    for i in 0 .. n {
      for j in 0 .. n {
        if v[i][j] > v[i][k] + v[k][j] { v[i][j] = v[i][k] + v[k][j]; }
      }
    }
  }
}

fn read_vec<T>() -> Vec<T>
  where T: std::str::FromStr,
        T::Err: std::fmt::Debug
{
  let mut buf = String::new();
  std::io::stdin().read_line(&mut buf).expect("failed to read");
  buf.split_whitespace().map(|e| e.parse().unwrap()).collect()
}



Measured memory_bytes: 5056
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
using namespace std;
using ll = long long;
#define MAX_N 1010
#define MAX_M 100010
const long long mod = pow(10,9)+7;
#define vec vector<int>
#define vecll vector<ll>
#define vecllvec vector<vector<ll>>
#define vecb vector<bool>
#define vecBvec vector<vector<bool>>
#define vecst vector<string>
#define veche vector<char>
#define vecd vector<double>
#define vecvec vector<vector<int>>
#define vecDvec vector<vector<double>>
#define vecHvec vector<vector<char>>
#define all(x) (x).begin(),(x).end()
#define ent cout<<endl
#define printvec(vec) for(int aqw=0;aqw<vec.size();aqw++){cout<<vec[aqw]<<" ";}ent;
#define rep1(n) for(ll i = 0; i < (n); ++i)
#define rep2(i, n) for(ll i = 0; i < (n); ++i)
#define rep3(i, a, b) for(ll i = (a); i < (b); ++i)
#define rep4(i, a, b, c) for(ll i = (a); i < (b); i += (c))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define INF 1e+9
#define print(x) cout<<x<<endl;
using P = pair<int, int>;
#define PLL pair<ll, ll>;
#define MAX_V 10010
#define PI 3.141592653589793
#define vecP vector<P>
 //cout << setprecision(15) << std::fixed;

double wa(double n) {
	return double(n * (n + 1) / 2);
}

int main() {
	cout << setprecision(15) << std::fixed;
	int n,k;
	cin >> n >> k;
	double mx = 0;
	vector<double> ve(n);
	for (int i = 0;i < n;i++) {
		double a;
		cin >> a;
		ve[i] = wa(a) / a;
		mx = max(mx, ve[i]);
	}
	if (k == 1) {
		print(mx);
		exit(0);
	}
	vector<double> s(n + 1, 0.0);
	for (int i = 0; i < n; ++i) s[i + 1] = s[i] + ve[i];
	double ans = 0.0;
	for (int i = 0;i <=n-k;i++) {
		chmax(ans, s[i + k] - s[i]);
	}
	print(ans);
} 




Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    string s; cin >> s;
    if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) {cout << "Yes" << endl; return 0;}
    if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) {cout << "Yes" << endl; return 0;}
    if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) {cout << "Yes" << endl; return 0;}
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef TEST
#include <mytest.h>
#else
#define open(...) 0
#define print(...) 42
#endif
using namespace std;

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string s, t;
  cin >> s >> t;
  cout << ((s[0] == t[0]) + (s[1] == t[1]) + (s[2] == t[2])) << endl;
}


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

#define pb push_back

void solve(){
   int n;cin>>n;
   map<int,int> mp;
   int a;
   while(cin>>a){
    mp[a]++;
   }
   for(auto i=0;i<n;i++){
      if(n%2==1){
          if(i==0 && mp[i]!=1) { cout<<"0"<<endl; return ;}
          else if(i != 0 && mp[i]!=2 && i%2==0)
          {

            cout<<"0"<<endl; return ;
          }
      }
      else{
        if(mp[i]!=2 && i%2==1) {cout<<"0"<<endl; return; }

      }
   }
   long long r = 1;
  long long m = 1e9 +7;
  for(int i=0; i<n/2; i++){
    r = (r%m * 2)%m;
  }
 
  cout << r << endl;
}


int main() {
   #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
 ios_base::sync_with_stdio(0);
 cin.tie(0);
 cout.tie(0);
solve();
  return 0;
}


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

using namespace std;

typedef pair<string, int> P_;
typedef pair<P_, int> P;

int main(){
    P p[100];
    int N;
    cin >> N;
    for(int i = 0; i < N; i++){
        string S;
        int sc;
        cin >> S >> sc;
        p[i] = P(P_(S, -sc), i+1);
    }
    sort(p, p+N);
    for(int i = 0; i < N; i++){
        cout << p[i].second << endl;
    }
}

Measured memory_bytes: 256
K,A,B = map(int,input().split())
cnt = 0

if A>=B:
    print(K+1)
else:
    if A-1>=K:
        print(K+1)
    elif B-A <= 2:
        print(K+1)
    else:
        if (K-A+1)%2 == 0:
            print(A+(B-A)*((K-A+1)//2))
        else:
            print(A+(B-A)*((K-A)//2)+1)

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

using namespace std;

int n, k;
int cost[100001];
int dp[100001];

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

    dp[0] = 0;

    for(int i = 1; i < n; i++)
    {
        int mn = 0x7fffffff;
        for(int j = 1; j <= k; j++)
        {
            if((i-j) >= 0)
            {
                mn = min(mn, dp[i-j] + abs(cost[i] - cost[i-j]));
            }
        }

        dp[i] = mn;
    }
    
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;

typedef long long ll;
#define INF 100000000
#define MOD 1000000007

int main()
{
	int x, y, z, ans = 0;
	
	cin >> x >> y >> z;

	x = x - 2 * z;
	
	while (1) {
		x -= y;
		ans++;
		if (x < y + z) {
			break;
		}
		x -= z;
	}
	cout << ans << endl;

	return (0);
}

Measured memory_bytes: 256
s = input()

ichi = 0
l = len(s)
cnt = l

while True:
    s_dreamer = s.rfind ("dreamer",ichi,l)
    s_eraser = s.rfind ("eraser",ichi,l)
    s_dream = s.rfind ("dream",ichi,l)
    s_erase = s.rfind ("erase",ichi,l)

    if s_dreamer == l - 7 and 0 <= l - 7:
        l = s_dreamer
        cnt -= 7 

    elif s_eraser == l - 6 and 0 <= l - 6:
        l = s_eraser
        cnt -= 6  

    elif s_dream == l - 5 and 0 <= l - 5:
        l = s_dream
        cnt -= 5  

    elif s_erase == l - 5 and 0 <= l - 5:
        l = s_erase
        cnt -= 5

    elif cnt == 0:
        print("YES")
        break

    else:
        print("NO")
        break


Measured memory_bytes: 3188
n = int(input())
a = list(map(int,input().split()))
ans = [0] * n
ans[0] = sum(a) - sum(a[1::2])*2

for i in range(1,n):
    ans[i] = a[i-1]*2 - ans[i-1]

print(' '.join(map(str,ans)))

Measured memory_bytes: 19096
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
cs = A[:]
for i in range(1, N):
	cs[i] += cs[i-1]
sum = 0
for i in range(0, N-1):
	sum += A[i] * (cs[-1] - cs[i])
print(sum % mod)

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

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

const int INF = 1001001001;
// long long max => LLONG_MAX

int table[205][205];


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N, M, R; cin >> N >> M >> R;
    for(int i = 0; i < 205; i++){
        for(int j = 0; j < 205; j++){
            if(i==j) table[i][j] = 0;
            else table[i][j] = INF;
        }
    }

    vector<int> v(R);
    for(int i = 0; i < R; i++) {
        cin >> v[i];
        v[i]--;
    }
    

    for(int i = 0; i < M; i++){
        int a, b, c; cin >> a >> b >> c;
        a--; b--;
        table[a][b] = c;
        table[b][a] = c;
    }

    for(int k = 0; k < N; k++){
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                if(i == k || j == k) continue;
                table[i][j] = min(table[i][j], table[i][k]+table[k][j]);
            }
        }
    }

    int ans = INF;

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

    while(next_permutation(v.begin(), v.end())){
        int dist  = 0;
        for(int i = 1; i < v.size(); i++) dist += table[v[i]][v[i-1]];
        ans = min(ans, dist);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 384
/*
  Krishnakant Tiwari
  Problem Link:

 */
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define eb	emplace_back
#define ppb	pop_back
#define pf	push_front
#define ppf	pop_front
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define precise(x)	cout<<fixed<<setprecision(x)
const ll MAX = 1000004;
const ll INF = 1e18L + 5;
template <class T, class U>
void chmin(T &t, const U &u)
{
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T &t, const U &u)
{
    if (t < u) t = u;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}
template <typename Arg1>
void pn(Arg1 &&arg1)
{
    cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << "\n";
    pn(args...);
}
template <typename Arg1>
void ps(Arg1 &&arg1)
{
    cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << " ";
    ps(args...);
}
template <typename Arg1>
void read(Arg1 &&arg1)
{
    cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1 &&arg1, Args &&... args)
{
    cin >> arg1;
    read(args...);
}

ll g[MAX];
ll a[MAX];

void solve()
{
    string s;
    read(s);
    ll sum=0;
    for(auto c:s){
    	sum+=(c-'0');
    }
    if(sum%9==0) pn("Yes");
    else pn("No");
}


int main()
{

    _cin
// #ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// #endif
    // ll tc;
    // cin>>tc;
    // while(tc--){
    solve();
    // }

}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
#define rep(i,h,t) for (int i=h;i<=t;i++)
int n,m;
int a[1000000],b[1000000];
int main()
{
  ios::sync_with_stdio(false);
  cin>>n>>m;
  rep(i,1,m) cin>>a[i];
  if (n>=m)
  {
    cout<<0<<endl;
    return 0;
  } else
  {
    sort(a+1,a+m+1);
    rep(i,1,m-1) b[i]=a[i+1]-a[i];
    sort(b+1,b+m);
    long long ans=0;
    rep(i,1,m-n) ans+=b[i];
    cout<<ans<<endl; 
  }
  return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cout << " >> " << #x << " "<<x<<endl;
void Solve_Case()
{
    int N;
    cin >> N;
    string s;
    cin >> s;
    int answer = 0;
    for(int i=1;i<N;i++)
    {
        if(s[i] == s[i-1])
        {

        }
            else answer++;
    }
    cout << answer+1;
}
int main()
{
    int TestCases=1;
   // cin >> TestCases;
    while(TestCases--)
    {
        Solve_Case();
    }
	return 0;
}


Measured memory_bytes: 512