akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int> s(n);
  bool ok = true;
  for(int i=0; i<m; i++){
    int tmp1, tmp2;
    cin>>tmp1>>tmp2;
    if(s.at(tmp1-1)!=0&&s.at(tmp1-1)!=tmp2) ok =false;
    else s.at(tmp1-1) =tmp2;
    if(tmp1==1&&tmp2==0&&n>1) ok = false;
  }
  if(ok&&s.at(0)==0&&n>1) s.at(0)=1;
  if( ok ){
    for(int i =0; i<n; i++){
      cout<<s.at(i);
    }
    cout<<endl;
  }
  else cout<<-1<<endl;
}


Measured memory_bytes: 256
N = int(input())
b = list(map(int, input().split()))
ans = []
for i in range(N):
    if b[i] > i + 1:
        print(-1)
        exit()
for i in range(N):
    ans.insert(b[i] - 1, b[i])
for i in range(N):
    print(ans[i])

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

int main(){
int n, m;
cin >> n >> m;

//行列の読み込み
vector< vector<int> > data(n, vector<int>(m));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> data.at(i).at(j);
    }
  }

//ベクトルの読み込み
int v[m];
for( int j = 0; j < m; j++){
  cin >> v[j];
}

//結果の出力
 for( int i = 0; i < n; i++){
    int sum = 0;
  for(int j = 0; j < m; j++){
     sum += data.at(i).at(j) * v[j];
    }
    cout << sum << endl;
  }
return 0;
}




Measured memory_bytes: 3192
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int a = scanner.nextInt();
        final List<Integer> list = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.toList());
        final int sum = list.stream()
                .mapToInt(Integer::intValue)
                .sum();

        final long[][][] dpCube = new long[n][sum + 1][n + 1];
        dpCube[0][list.get(0)][1] = 1;
        for (int i = 1; i < n; i++) {
            for (int j = 0; j < dpCube[i].length; j++) {
                System.arraycopy(dpCube[i - 1][j], 0, dpCube[i][j], 0, dpCube[i][j].length);
            }
            final int value = list.get(i);
            dpCube[i][value][1]++;
            for (int j = 0; j <= sum - value; j++) {
                for (int k = 0; k < n; k++) {
                    if (dpCube[i - 1][j][k] == 0) {
                        continue;
                    }
                    dpCube[i][j + value][k + 1] += dpCube[i - 1][j][k];
                }
            }
        }

        long answer = 0;
        for (int i = a; i <= sum; i++) {
            for (int j = 1; j <= n; j++) {
                if (!isJustAvg(i, j, a)) {
                    continue;
                }
                answer += dpCube[n - 1][i][j];
            }
        }

        System.out.println(answer);
    }

    private static boolean isJustAvg(final long divided, final long divide, final long avg) {
        return divided == divide * avg;
    }
}


Measured memory_bytes: 90616
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define pri_que priority_queue
#define vint vector<int>
#define vvint vector<vector<int>>
#define vs vector<string>
#define vvc vector<vector<char>>
#define vc vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int a,b;cin>>a>>b;
    cout<<(a+b<24?a+b:a+b-24)<<endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

/* --------------------------------------------------- */

int main() {
    int x, y;
    cin >> x >> y;
    bool ans = false;
    rep(i, x + 1) {
        if(i * 2 + (x - i) * 4 == y) ans = true;
    }
    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
#include <random>
#include <utility>
#include <map>
#include <vector>
#include <queue>
#include <bitset>
#define REP(i,x) for(int i=0; i<(x); i++)
typedef long long ll;

using namespace std;

int main(int argc, const char * argv[]) {
    int n;
    cin >> n;
    bitset<2000*2001> bits;
    bits[0] =1;
    int sum = 0,x;
    REP(i, n){
        cin >> x;
        sum += x;
        bits = bits | (bits << x);
    }
    int pt = (sum+1)/2;
    while (!bits[pt]) {
        pt++;
    }
    cout << pt << endl;
    
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
#define M 200005
#define N 1005
#define ll long long
#define oo 1000000000
#define mod 5557
using namespace std;
int A[M],B[M],ans,n,m,dp[M],cnt[M],sum[M],t;
void check(int &a,int b){
	if(a==-1||a>b)a=b;
}
int main(){
	int i,j,a,b;
	cin>>n>>m;
	for(i=1;i<=n;i++){
		scanf("%d",&A[i]);
		cnt[A[i]]++;
	}
	for(i=1;i<=n;i++){
		for(j=min(cnt[i],i)-1;j>=0;j--){
			if(!sum[i-j])++t;
			sum[i-j]++;
		}
	}
	for(i=1;i<=m;i++){
		scanf("%d %d",&a,&b);
		cnt[A[a]]--;
		if(A[a]-cnt[A[a]]>0&&!(--sum[A[a]-cnt[A[a]]]))--t;
		A[a]=b;
		if(A[a]-cnt[A[a]]>0&&!sum[A[a]-cnt[A[a]]]++)++t;
		++cnt[A[a]];
		printf("%d\n",n-t);
	}
	return 0;
}
	
	

Measured memory_bytes: 3712
n = int(input())
h = list(map(int, input().split()))

c = 0
while any(h):
    ans = 0
    for l in range(n):
        tmp = 0
        r = l
        while h[r]:
            tmp += 1
            r += 1
            if r == n:
                break
        if ans < tmp:
            x = l
            y = r
            ans = tmp
    for i in range(x, y):
        h[i] -= 1
    c += 1
print(c)


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

typedef long long ll;
typedef pair<int, int> pii; 
const int N = 1e6+5, mod = 1e9+7;

void solve() {
    int k; cin >> k;

    int m[k];
    memset(m, 0, sizeof(m));
    
    int a = 7, ans = 1;

    a %= k;
    while (1) {
        if (a == 0) {
            cout << ans << endl;
            break;
        } else if (m[a]) {
            cout << -1 << endl;
            break;
        }

        m[a] = true;
        a = ((a * 10) + 7) % k;
        ++ans; 
    }
}

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


Measured memory_bytes: 7520
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
mod = 7 + 10 ** 9
factorial = [1] * (2 * 10 ** 5 + 1)
for i in range(1, 2 * 10 ** 5 + 1):
    factorial[i] = (factorial[i-1] * i) % mod
revfactorial = [1] * (2 * 10 ** 5 + 1)
revfactorial[-1] = pow(factorial[-1], mod - 2, mod)
for i in reversed(range(1, 2 * 10**5)):
    revfactorial[i] = (revfactorial[i+1] * (i+1)) % mod

def comb(n, r):
    return (factorial[n] * revfactorial[n-r] * revfactorial[r]) % mod

def solve():
    N, M, K = map(int, line_input())
    xsum, ysum = 0, 0
    for i in range(1, N): #xsum. (pairの取り方)  * d
        xsum += ((N - i) * M * M * i) % mod
        xsum %= mod
    for j in range(1, M):
        ysum += ((M - j) * N * N * j) % mod
        ysum %= mod
    print(((xsum + ysum) * comb(N*M-2, K-2)) % mod)
    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 19184
#include <iostream>
/*
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
*/
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))

ll scnt[26];
ll keisans[26][26];

ll Calc(int index,int wcnt){
    ll val=0;
    if (wcnt==0)return (ll)1;
    for(int i=index;i<26;i++){
        if(wcnt>(26-i))break;
        if(scnt[i]>0){
            if(keisans[i][wcnt]==0){
                keisans[i][wcnt]=(Calc(i+1,wcnt-1)*scnt[i])%MAX;
                if (0&&keisans[i][wcnt]>0){
                cout << "keisan("<<i<<","<<wcnt<<")="<<keisans[i][wcnt]<<endl;
                }
            }
            val=(val+keisans[i][wcnt])%MAX;
        }
    }
    return val;
}


int main(){
    ll ans,n;
    ll c=0;
    cin >>n;
    for(int i=0;i<26;i++){
        scnt[i]=0;
        for(int j=0;j<26;j++){
            keisans[i][j]=0;
        }
    }

    for(int i=0;i<n;i++){
        char a;
        cin>>a;
        if(scnt[a-'a']==0)c++;
        scnt[a-'a']++;
    }

    dbg for(int i=0;i<26;i++){
        cout << scnt[i]<<endl;
    }
    for(int i=1;i<=c;i++){
        ans=(ans+Calc(0,i))%MAX;
    }

    cout <<ans<<endl;

    return 0;

}

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

int main(){
    int n, k, q;
    cin >> n >> k >> q;
    set<int> all;
    vector<int> a(n);
    for(int i = 0; i < n; i++)  cin >> a[i], all.insert(a[i]);
    all.insert(0);
    int ans = 1<<30;
    for(int piv : all){
        multiset<int> res, tmp;
        for(int i = 0; i <= n; i++){
            if(i == n || a[i] <= piv){
                while(tmp.size() >= k)  res.insert(*tmp.begin()), tmp.erase(tmp.begin());
                tmp.clear();
            }else{
                tmp.insert(a[i]);
            }
        }
        if(res.size() >= q){
            auto it = res.begin();
            int low = *it;
            for(int i = 0; i < q-1; i++)    it++;
            ans = min(ans, *it-low);   
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
MOD = 1000000007
EPS = 0.000000001
#sys.setrecursionlimit(3**12)


class Info:
    def __init__(self,arg_item_A,arg_item_B):
        self.item_A = arg_item_A
        self.item_B = arg_item_B
        if self.item_B < self.item_A:
            self.item_A,self.item_B = self.item_B,self.item_A

    def __lt__(self,another):
        if self.item_A != another.item_A:
            return self.item_A < another.item_A
        else:
            return self.item_B < another.item_B


SIZE = 1000

N,F = map(int,input().split())
num_item = 0
ITEM = {}
rev_ITEM = {}

table = [[0]*SIZE for _ in range(SIZE)]

for _ in range(N):
    M,*input_str = map(str,input().split())
    M = int(M)
    for i in range(M):
        if input_str[i] not in ITEM:
            ITEM[input_str[i]] = num_item
            rev_ITEM[num_item] = input_str[i]
            num_item += 1
    for i in range(M-1):
        for k in range(i+1,M):
            table[ITEM[input_str[i]]][ITEM[input_str[k]]] += 1
            table[ITEM[input_str[k]]][ITEM[input_str[i]]] += 1

ANS = []

for i in range(num_item-1):
    for k in range(i+1,num_item):
        if table[i][k] >= F:
            ANS.append(Info(rev_ITEM[i],rev_ITEM[k]))

print("%d"%(len(ANS)))
ANS.sort()

for i in range(len(ANS)):
    print("%s %s"%(ANS[i].item_A,ANS[i].item_B))



Measured memory_bytes: 15300
[n, a, b] = list(map(int, input().split()))
ans = 0
for i in range(1, n + 1):
    p = i
    sum_of_digit = 0
    while p != 0:
        sum_of_digit += p % 10
        p = p // 10
    if sum_of_digit >= a and sum_of_digit <= b:
        ans += i
print(ans)


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

// Shrotening
#define fst first
#define snd second
#define pb push_back

// Loop
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define RFOR(i,a,b) for(long i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

struct UnionFind {
  std::vector<int> par;
  std::vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    REP(i,n) par[i] = i;
  }

  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);

    if (x == y) return;

    if (sizes[x] < sizes[y]) std::swap(x, y);

    par[y] = x;
    sizes[x] += sizes[y];
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  int size(int x) {
    return sizes[find(x)];
  }
};

int N, K, L;
int main() {
    std::cin >> N >> K >> L;
    UnionFind uf1(N);
    UnionFind uf2(N);

    REP(i, K) {
        int p, q;
        std::cin >> p >> q;
        p--;
        q--;
        uf1.unite(p, q);
    }
    REP(i, L) {
        int r, s;
        std::cin >> r >> s;
        r--;
        s--;
        uf2.unite(r, s);
    }

    std::map< PII, int > map;
    REP(i, N) {
        int r1 = uf1.find(i);
        int r2 = uf2.find(i);
        map[std::make_pair(r1, r2)]++;
    }

    REP(i, N) {
        int r1 = uf1.find(i);
        int r2 = uf2.find(i);
        std::cout << (i == 0 ? "" : " ") << map[std::make_pair(r1, r2)];
    }
    std::cout << std::endl;
}

Measured memory_bytes: 15756
#include<stdio.h>
#include<stdlib.h>
#include<inttypes.h>
#include<string.h>
int main(){
  uint64_t a;
  scanf("%" SCNu64 ,&a);
  char s[12]="";
  int i;
  for(i=0;a;i++){
    s[i]='a'+--a%26;
    a/=26;
  }
  for(i--;i>=0;i--)printf("%c",s[i]);
}

Measured memory_bytes: 1664
#include <stdio.h>

int main(void) {
    int i, j, H, W;
    while(scanf("%d %d", &H, &W), H || W) {
        for(i = 0; i < H; i++) {
            for(j = 0; j < W; j++) {
                printf("%c", (!i || i == ~-H || !j || j == ~-W) ? '#' : '.'); 
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

A, B, K = ISI()
if B - A + 1 <= 2 * K:
    for i in range(B-A+1):
        print(A)
        A += 1
else:
    for i in range(K):
        print(A)
        A += 1
    for j in range(K):
        print(B-K+1)
        B += 1

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

int count = 0;

void merge(int a[], int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  int l[n1 + 1], r[n2 + 1];
  for (int i = 0; i < n1; i++)
    l[i] = a[left + i];
  for (int i = 0; i < n2; i++)
    r[i] = a[mid + i];
  l[n1] = 1000000001;
  r[n2] = 1000000001;

  int i = 0, j = 0;
  for (int k = left; k < right; k++)
  {
    count++;
    if (l[i] <= r[j])
    {
      a[k] = l[i];
      i++;
    }
    else
    {
      a[k] = r[j];
      j++;
    }
  }
}

void mergeSort(int a[], int left, int right)
{
  if (left + 1 < right)
  {
    int mid = (left + right) / 2;
    mergeSort(a, left, mid);
    mergeSort(a, mid, right);
    merge(a, left, mid, right);
  }
}

int main()
{
  int n;
  scanf("%d", &n);
  int a[n];
  for (int i = 0; i < n; i++)
    scanf("%d", &a[i]);

  mergeSort(a, 0, n);

  for (int i = 0; i < n - 1; i++)
    printf("%d ", a[i]);
  printf("%d\n", a[n - 1]);
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 6448
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;

int main() {
	string S;
	cin >> S;

	vector<ll> children(S.size(), 0); // ans;

	int RLid = 0; // RLのRのindex
	bool afterRL = false;
	int Rcnt = 0;
	rep(i, S.size()) {
		if(afterRL) {
			if(S[i]=='L'){
				if((i-RLid)%2==0) children[RLid] += 1;
				else children[RLid+1] += 1;
			} else { //S[i] == 'R'
				afterRL = false;
				Rcnt += 1;			
			}
		} else { // beforeRL;
			if(S[i]=='L') {
				afterRL = true;
				RLid = i-1;
				children[i-1] += Rcnt - (Rcnt/2);
				children[i] += (Rcnt/2);
				children[i] += 1;
				Rcnt = 0;  //reset
			} else {
				Rcnt += 1;
			}

		}
	}

	rep(i, S.size()) {
		cout << children[i] << ' ';
	}
	cout << endl;
	
  return 0;
}

Measured memory_bytes: 1408
#include<iostream>

using namespace std;

int main(){
    int m, d;
    cin >> m >> d;
    int cnt=0;
    for(int i=1;i<=m;i++){
        for(int j=1;j<=d;j++){
            if(j%10>=2 && j/10>=2 && ((j%10) * (j/10) == i)){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(1000000)
input=sys.stdin.readline

N,M=map(int,input().split())
edge={i:[] for i in range(1,N+1)}
for i in range(M):
    x,y=map(int,input().split())
    edge[x].append(y)

memo={i:-1 for i in range(1,N+1)}
for i in range(1,N+1):
    if not edge[i]:
        memo[i]=0

def long_path(start):
    if memo[start]!=-1:
        return memo[start]

    memo[start]=max(1+long_path(i) for i in edge[start])

    return memo[start]

ans=0
for i in range(1,N+1):
    ans=max(ans,long_path(i))

print(ans)


Measured memory_bytes: 164452
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<long>a(3,0);string s;cin>>s;
  for(char c:s)a[c-97]++;
  sort(a.begin(),a.end());
  cout<<(a[2]-a[0]<=1?"YES":"NO")<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define eb 			emplace_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define inf        1000000000000000000
#define puts(n)		cout<<n;
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define setbits(x) __builtin_popcount(x)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,k;
	cin>>n>>m>>k;
	ll a[n];
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(i>0) a[i] +=a[i-1];
	}
	ll b[m];
	for(ll i=0;i<m;i++){
		cin>>b[i];
		if(i>0) b[i]+=b[i-1];
	}
	ll ans=0;
	for(ll i=0;i<n;i++){
		ll val = k-a[i];
		if(val<0) break;
		ll low=0,high=m-1;
		while(low<high){
			ll mid = low+(high-low+1)/2;
			if(b[mid]<=val) low=mid;
			else high=mid-1;
		}
		if(b[low]>val)  low=-1;
		
		ans = max(ans , i+1 + low+1);
	}
	for(ll i=0;i<m;i++){
		ll val = k-b[i];
		if(val<0) break;
		ll low=0,high=n-1;
		while(low<high){
			ll mid = low+(high-low+1)/2;
			if(a[mid]<=val) low=mid;
			else high=mid-1;
		}
		if(a[low]>val)  low=-1;
		
		ans = max(ans , i+1 + low+1);
	}
	cout<<ans;
	
	
	return 0;
}

Measured memory_bytes: 6700
#include <bits/stdc++.h>
using namespace std;
int main(){
	int a, b;
	cin>>a>>b;
	int c;
	if(a>=13)
	c = b;
	else if(a>=6 && a<=12)
	c = b/2;
	else c = 0;
	cout<<c;
	return 0;
}

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

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N; cin >> N;
    bool frag = true;
    REP(i, N)
    {
        int A; cin >> A;
        if(A % 2 == 0)
        {
            if(A % 3 != 0 && A % 5 != 0)
            {
                frag = false;
            }
        }
    }
    if(frag) cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
#include<stdio.h>
#include<cmath>
#include<limits>
#include<iomanip>

using namespace std;

template <class T> using V = vector<T>;

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 long long INF = 1LL << 60;

using ll = long long;
using db = long double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
using graph = V<V<int>>;
using pq = priority_queue<ll>;



#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>=(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define pb(a) push_back(a);




ll Sum(ll n) {
ll m=0;
  while(n){
    m+=n%10;
    n/=10;
  }
  return m;
}



const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}


#define comuse Comuse()

ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(int n,int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] % MOD) % MOD;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


vll div(ll n){
  vll ret;
  for(ll i=1;i*i<=n;i++){
    if(n%i==0){
      ret.push_back(i);
      if(i*i!=n){
        ret.push_back(n/i);
      }
    }
  }
  SORT(ret);
  return (ret);
}


ll modpow(ll a,ll n,ll mod){
  ll ans=1;
  while(n>0){
    if(n&1){
      ans=ans*a%mod;
    }

    a=a*a%mod;
    
    n>>=1;
  }

  return ans;
}

void Solve();


const int MAX_N = 131072;
//segment tree 
int NN;
int seg[MAX_N*2-1];
void seguse(){
  for(int i=0;i<2*NN-1;i++){
    seg[i]=INT_MAX;
  }
}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(20)<<fixed;
  Solve();
}



/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
//segtreeの葉の先頭の添え字はn-1
void Solve(){
  //ll N=262144;
  //vll segtree(2*N-1);
  st s;
    cin>>s;
  ll n=s.sz;
  ll ans=0;
  FOR(i,1,n){
    if(s[i-1]!=s[i]){
      ans++;
    }
  }
  cout<<ans<<"\n";
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=190;
const int MM= +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
int mat[NN][NN]={};
int rw[NN][NN]={};
int cl[NN][NN]={};
char s[NN]={};
int ver[2][NN][NN][NN],hor[2][NN][NN][NN]={};
inline void upd(int &x,int y){
	x=max(x,y);
}
void pre(){
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		for(int j=1;j<=m;++j){
			mat[i][j]=(s[j]=='#');
			rw[i][j]=rw[i][j-1]+mat[i][j];
			cl[i][j]=cl[i-1][j]+mat[i][j];
		}
	}
	for(int j=1;j<=m;++j){
		for(int k=j;k<=m;++k){
			int pre=0;
			int cnt=0;
			for(int i=n;i>=1;--i){
				int c=rw[i][k]-rw[i][j-1];
				int now=2;
				if(c==0)now=0;
				if(c==k-j+1)now=1;
				if(now==2)cnt=0;
				else{
					if(pre==now)
						++cnt;
					else
						pre=now,cnt=1;
				}
				ver[0][i][j][k]=cnt;
			}
		}
	}
	for(int j=1;j<=n;++j){
		for(int k=j;k<=n;++k){
			int pre=0;
			int cnt=0;
			for(int i=m;i>=1;--i){
				int c=cl[k][i]-cl[j-1][i];
				int now=2;
				if(c==0)now=0;
				if(c==k-j+1)now=1;
				if(now==2)cnt=0;
				else{
					if(pre==now)
						++cnt;
					else
						pre=now,cnt=1;
				}
				hor[0][i][j][k]=cnt;
			}
		}
	}
}
int mx[2][NN][NN][NN]={};
void dp(int now){
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			for(int k=j;k<=m;++k){
				ver[now][i][j][k]=ver[now^1][i][j][k]+ver[now^1][i+ver[now^1][i][j][k]][j][k];
				upd(mx[0][j][i][i+ver[now][i][j][k]-1],k-j+1);
			}
	for(int i=1;i<=m;++i)
		for(int j=1;j<=n;++j)
			for(int k=j;k<=n;++k){
				hor[now][i][j][k]=hor[now^1][i][j][k]+hor[now^1][i+hor[now^1][i][j][k]][j][k];
				upd(mx[1][j][i][i+hor[now][i][j][k]-1],k-j+1);
			}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=m;++j)
			for(int k=m;k>=j;--k){
				upd(mx[1][i][j][k],mx[1][i][j][k+1]);
				upd(ver[now][i][j][k],mx[1][i][j][k]);
			}
	for(int i=1;i<=m;++i)
		for(int j=1;j<=n;++j)
			for(int k=n;k>=j;--k){
				upd(mx[0][i][j][k],mx[0][i][j][k+1]);
				upd(hor[now][i][j][k],mx[0][i][j][k]);
			}

}
int main(){
	//open();
	n=read();
	m=read();
	pre();
	int now=0;
	int ans=0;
	while(ver[now][1][1][m]<n){
		++ans;
		now^=1;
		dp(now);
	}
	printf("%d\n",ans);
	close();
	return 0;
}

Measured memory_bytes: 160768
#include<iostream>
#include<vector>
#include<limits.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    vector<pair<int,int>>v1(n);
    vector<pair<int,int>>v2(m);
    for(int i=0;i<n;i++)
    {
        int f,s;
        cin>>f>>s;
        v1[i].first=f;
        v1[i].second=s;
    }
    for(int i=0;i<m;i++)
    {
        int f,s;
        cin>>f>>s;
        v2[i].first=f;
        v2[i].second=s;
    }
    for(int i=0;i<n;i++)
    {
        int fcor=v1[i].first;
        int scor=v1[i].second;
        int min=INT_MAX;
        int  index;
        for(int j=0;j<m;j++){
            if((abs(fcor-v2[j].first)+abs(scor-v2[j].second))<min){
                min=(abs(fcor-v2[j].first)+abs(scor-v2[j].second));
                index=j;
            }
        }
        cout<<index+1<<endl;
    }

}

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

int main() {
  double r;
  cin >> r;
  cout << setprecision(6) << r * 2 * M_PI << endl;
  return 0;
}

Measured memory_bytes: 3788
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int maxLength = s.length() - 1;
        for (int i = s.length() - 1; i > 0; i--) {
            if (i % 2 != 0) {
                continue;
            }
            String toTest = s.substring(0, i);
            boolean isSS = true;
            for (int t = 0; t < toTest.length() / 2; t++) {
                if (toTest.charAt(t) != toTest.charAt(toTest.length() / 2 + t)) {
                    isSS = false;
                    break;
                }
            }
            if (isSS) {
                maxLength = i;
                break;
            }
        }

        System.out.println(maxLength);
    }
}


Measured memory_bytes: 23636
from itertools import combinations
N, K = map(int, input().split())
nums = [0 for _ in range(N + 1)]
for i in range(N + 1):
    if i == 0:
        nums[i] = 0
    else:
        nums[i] = nums[i - 1] + i
# print(nums)
if N + 1 == K:
    print(1)
else:
    count = 1
    for i in range(K, N + 1):
        # iは組み合わせに使うかず
        # 2,3,4
        min_nums = nums[i - 1]
        max_nums = nums[N] - nums[N - i]
        # print(i, nums[:i], min_nums, nums[N + 1 - i:N + 1], max_nums)
        # print(i, max_nums - min_nums + 1)
        count += max_nums - min_nums + 1

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


Measured memory_bytes: 82548
#include <iostream>
using namespace std;
int main(){
  string s;cin>>s;
  for(int i = 0; 13 > i; i++){
    if(i < 4) cout << s[i];
    else if(i == 4)cout << " ";
    else cout << s[i-1];
  }
  cout << endl;
}

Measured memory_bytes: 256
import sys

def dp_all(dp):
  length = len(dp)
  for i in range(length):
    print(dp[i])

H,N= map(int,input().split())

a = []
b = []

for i in range(N):
  a_dash,b_dash = map(int,input().split())
  a.append(a_dash)
  b.append(b_dash)

#dp[i+1][j] = i番目までの魔法で体力jのモンスターに
#勝つことができる、魔力の最小値
INF = 10**9
dp = [[INF for _ in range(H+1)] for _ in range(N+1)]

for i in range(N+1):
  dp[i][0] = 0

for i in range(N):
  for j in range(H+1):
    if a[i] > j:
      dp[i+1][j] = min(dp[i][j],b[i])
    else:
      dp[i+1][j] = min(dp[i][j],dp[i+1][j-a[i]]+ b[i])

print(dp[N][H])


Measured memory_bytes: 125788
#include<stdio.h>
int main(void){
    int d,n,i,s=1;
    scanf("%d %d",&d,&n);
    for(i=0;i<d;i++){
        s*=100;
    }
    if(n==100)
        printf("%d\n",s*(n+1));
    else
        printf("%d\n",s*n);
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vint a(N);
    rep(i, N) cin >> a[i];
    int odd_num = 0;
    int four_num = 0;
    rep(i, N) {
        if (a[i] % 2 == 1) odd_num++;
        if (a[i] % 4 == 0) four_num++;
    }
    if (four_num >= odd_num ) {
        cout << "Yes" << endl;
    }
    else if (four_num >= odd_num - 1 && four_num + odd_num == N) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 640
a, op, b = input().split()
while op != '?':
    if op == '+':
        print(int(a)+int(b))
    elif op == '-':
        print(int(a)-int(b))
    elif op == '*':
        print(int(a)*int(b))
    elif op == '/':
        print(int(a)//int(b))
    a, op, b = input().split()
    


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef vector<int> vec1;
typedef vector<string> vec2;
typedef vector<double> vec3;

int main() {
  
  int n, k;
  cin >> n >> k;
  vec1 l(n);
  for(int i = 0; i < n; i++) cin >> l.at(i);

  sort(l.begin(),l.end());
  reverse(l.begin(),l.end());
  int ans = 0;
  for(int i = 0; i < k; i++) {
    ans = ans + l.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//NOT TO SUBMIT IN WRONG PLACE OR BY WRONG COMPILER
//ABC 179, task d, 2020/09/19
//ms,

/*
考察自体は正しい。ただそこを使ってどう高速化するかには手も足も出なかったな。
まあ愚直なDPを思いついて、計算量で捨てられたことは成長だろ。
*/

#define LAW 998244353

int main(void){
  int N, K;
  vector<pair<int, int>> section;
  vector<int64_t> dp(200001, 0);

  cin >>N >>K;
  for(int i=0;i<K;i++){
    int l, r;
    cin >>l >>r;
    section.push_back({l, r});
  }

  dp[1]=1;
  dp[2]--;
  for(int i=1;i<=N;i++){
    if(i>1) dp[i] += dp[i-1];
    dp[i] %= LAW;
    for(int j=0;j<K;j++){
      int left = section[j].first;
      int right = section[j].second;

      if(i+left<=N) dp[i+left] += dp[i];
      if(i+right+1<=N) dp[i+right+1] += LAW - dp[i];
    }
  }
/*
  for(int i=1;i<=N;i++){
    ans+=ans+dp[i];
    ans%=LAW;
  }
*/
  cout <<dp[N] <<endl;
  return 0;
}
/*
部分和問題？
部分和数え上げに少し手を加えれば勝ち。なのか？
手を加えずともNMだぞ？加えたらもっとだろ。間に合わない。
方程式に置き換えたらC問題の拡張として解けるか？いや。順序があるから厳しい。順序計算する？
カエルdp？いや。
Kが少ないことを利用する？
余事象？ちがう
累積和チックなこと？K個ある各区間に何等かの操作をしておく？
*/


Measured memory_bytes: 4644
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
typedef long long ll;
const int INF = 100000000, mod = 1000000007;
const ll LLINF = 1LL << 50;
using namespace std;


int main() {
    int n, a[10005];
  	ll ca = 0, cb = 0;
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
        int b;
        cin >> b;
        if (a[i] > b)cb += a[i] - b;
        else if (a[i] < b) ca += (b - a[i]) / 2;
    }
    if (ca>=cb)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

typedef vector<vector<int>> Graph;

class Topological_Sort{
    Graph G;
    public:vector<int> order;
    vector<bool> visited;
    void dfs(int v){
        if(visited[v]) return;
        visited[v]=true;
        for(auto &to:G[v]){
            dfs(to);
        }
        order.push_back(v);
        return;
    };
    Topological_Sort(Graph &g) : G(g) {
        visited = vector<bool>(G.size());
        for(int i=0;i<G.size();i++) dfs(i);
        reverse(order.begin(), order.end());
    };
};

int main(){
    int N,M;
    cin>>N>>M;
    Graph G(N);
    for(int i=0;i<M;i++){
        int s,t;
        cin>>s>>t;
        G[s].push_back(t);
    }
    Topological_Sort TS(G);
    for(auto o:TS.order){
        cout<<o<<endl;
    }

    return 0;
}

Measured memory_bytes: 4168
def printA(x)
   x.each_with_index{|a,i|
     print a
     if i<x.length-1 then print ' '
     else print "\n"
     end
   }
end

n=gets.to_i
A=gets.split(' ').map(&:to_i)
printA(A)
for i in 1..A.length-1 do
    key=A[i]
    j=i-1
    loop{
       if j<0 or A[j]<=key then break end
       A[j+1]=A[j]
       j=j-1
    }
    A[j+1]=key
    printA(A)
end

Measured memory_bytes: 8712
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 600050;
const int K = 30;
const int mod = 1e9 + 7;
int h, a[N], inv[N], p[N], v[N], b[N];
int f;
int binpow(int x, int y){
    int res = 1;
    while(y){
        if (y % 2) res = res * x % mod;
        y /= 2;
        x = x * x % mod;
    }
    return res;
}
void add(int x, int val, int z = 1, int d = h - 1, int ver = 1){
    a[ver] = z * (a[ver] + val) % mod;
    b[ver] = z * (b[ver] + 1);
    if (d == -1) return;
    if (x & (1 << d)){
        add(x, val, z, d - 1, 2 * ver + 1);
    } else{
        add(x, val, z, d - 1, 2 * ver);
    }
}
int calc(int x, int d = h - 1, int ver = 1){
    if (d == -1) return 0;
    if (x & (1 << d)){
        f += b[2 * ver];
        return (a[2 * ver] * inv[x >> (d + 1)] % mod * inv[x >> (d + 1)] % mod * (x >> (d + 1)) + calc(x, d - 1, 2 * ver + 1)) % mod;
    } else{
        f += b[2 * ver + 1];
        return (a[2 * ver + 1] * inv[x >> (d + 1)] % mod * inv[x >> (d + 1)] % mod * (x >> (d + 1)) + calc(x, d - 1, 2 * ver)) % mod;
    }
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> h;
    for (int i = 1; i <= (1 << (h - 1)); i++){
        cin >> p[i + (1 << (h - 1)) - 1];
        p[i + (1 << (h - 1)) - 1] += (1 << (h - 1)) - 1;
    }
    for (int i = 1; i < (1 << h); i++){
        if (i == 1) v[i] = 1; else{
            v[i] = v[i / 2] * i % mod;
        }
    }
    int ans = 0;
    for (int i = 1; i < (1 << h); i++){
        inv[i] = binpow(v[i], mod - 2);
    }
    for (int i = 0; i < h - 1; i++){
        for (int j = 0; j < (1 << i); j++){
            int x = (1 << (h - i - 1)) * ((1 << i) + j);
            int z = (1 << i) + j;
            for (int l = 0; l < (1 << (h - i - 2)); l++){
                add(p[x + l], v[x + l] * v[p[x + l]] % mod);
            }
            for (int l = 0; l < (1 << (h - i - 2)); l++){
                int y = x + l + (1 << (h - i - 2));
                ans = (ans + inv[z] * v[y] % mod * v[p[y]] % mod * calc(p[y]) % mod * inv[z] % mod * z % mod) % mod ;
            }
            for (int l = 0; l < (1 << (h - i - 2)); l++){
                add(p[x + l], v[x + l] * v[p[x + l]] % mod, 0);
            }
        }
    }
    cout << ans;
}


Measured memory_bytes: 12984
import java.util.*

fun main(args : Array<String>) {
    val sc = Scanner(System.`in`)
    val S = sc.next()
    if (S.toCharArray()[2] == S.toCharArray()[3]
        && S.toCharArray()[4] == S.toCharArray()[5]) {
        println("Yes")
    } else {
        println("No")
    }
}


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

int main() {
    ll n;
    cin >> n;
    ll l;
    cin >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];

    sort(all(s));
    rep(i, n) cout << s[i];
}


Measured memory_bytes: 256
# Import
from collections import deque
import math

# I/O
def read(): return input()
def read_int(): return int(input())
def read_array(type=int): return [type(i) for i in input().split()]
def read_tupple(type=None):
    tmp = input().split()
    if type is None: return map(int, tmp)
    assert len(tmp) == len(type)
    return [type[i](tmp[i]) for i in range(len(tmp))]

MOD = 998244353
N, S = read_tupple()
A = read_array()

dp = [[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0] = 1
for i in range(N):
    for j in range(S+1):
        dp[i + 1][j] += 2 * dp[i][j]
        if j - A[i] >= 0:
            dp[i + 1][j] += dp[i][j - A[i]]
        
        while dp[i+1][j] > MOD:
            dp[i+1][j] -= MOD
        
print(dp[N][S])


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

using namespace std;

int INF = 1 << 30;

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	vector<int> C(N);
	vector<int> understand(M);
	vector<vector<int>> A(N, vector<int>(M));
	for (int i = 0; i < N; i++) {
		cin >> C[i];
		for (int j = 0; j < M; j++) {
			cin >> A[i][j];
		}
	}

	int price = INF;

	for (int bit = 0; bit < (1 << N); bit++) {
		understand.assign(M, 0);
		int sum = 0;
		for (int i = 0; i < N; i++) {
			if (bit & (1 << i)) {
				sum += C[i];
				for (int j = 0; j < M; j++) {
					understand[j] += A[i][j];
				}
			}
		}
		bool ok = true;
		for (int i = 0; i < M; i++) {
			if (understand[i] < X) ok = false;
		}
		if (ok) price = min(price, sum);
	}

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

	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
//#include <algorithm>
//#include <vector> 

int main(int argc, char* argv[])
{
	char str[4] = {0};
    scanf("%s", str);

	long i;
	for(i=0; i<3; i++) {
		if(str[i]=='1') {
			str[i] = '9';
		}
		else if(str[i]=='9') {
			str[i] = '1';
		}
	}

	printf("%s\n", str);

    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
  
int main(void)
{
  int H, W, h, w;
  int result;
  
  scanf("%d %d", &H, &W);
  scanf("%d %d", &h, &w);
  
  result = H*W - h*W -H*w + h*w;
  
  printf("%d", result);
 
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
#include <array>
#include <numeric>
#include <regex>
#include <bitset>
#include <deque>

using namespace std;
typedef long long ll;
typedef pair<int, int> p_ii;

const int INF = 1e9;
const double PI = acos(-1.0);
const ll MOD = 1e9 + 7;



int main() {
    ll x;
    cin>>x;
    for (ll i = 1; i < 120000; i++) {
        if(i*(i+1)/2>=x){
            cout<<i<<endl;
            return 0;
        }
    }
    return 0;
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 1010, M = 20010;

int n, m;
int f[M];

int main()
{
	scanf("%d%d", &m, &n);
	memset(f, 0x3f, sizeof f);
	f[0] = 0;
	
	for (int i = 1; i <= n; i ++ )
	{
		int a, b;
		scanf("%d%d", &a, &b);
		
		for (int j = 0; j <= m; j ++ )
			f[j + a] = min(f[j + a], f[j] + b);
	}
	
	int res = 0x3f3f3f3f;
	for (int i = m; i < M; i ++ ) res = min(res, f[i]);
	printf("%d\n", res);
	return 0;
}


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

using namespace std;

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

    int n, m, sum = 0;

    cin >> n;

    vector <int> v(n);

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

    cin >> m;

    for(int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        sum = sum - v[x - 1] + y;
        cout << sum << "\n";
        sum = sum - y + v[x - 1];
    }

    return 0;
}


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

using namespace std;

const int OO = 1e9;
const double EPS = 1e-9;

#define ndl cout << '\n'
#define sz(v) int(v.size())
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define present(a, x) (a.find(x) != a.end())
#ifdef LOCAL
#define db(...) ({cout << "> Line " << __LINE__  \
		<< ": "; _db(#__VA_ARGS__, __VA_ARGS__);})
#define RNG() rng()
#else
#define db(...) true
#define RNG() true
#endif

template<class T>
void _db(const char *dbStr, T e) {
	cout << dbStr << " = " << e << endl;
}
template<class T, class... L>
void _db(const char *dbStr, T e, L... r) {
  while(*dbStr != ',') cout << *dbStr++;
  cout << " = " << e << ','; _db(dbStr + 1, r...);
}
template<class S, class T>
ostream& operator<<(ostream& o, const map<S, T>& v) {
	o << "["; int i = 0;
	for (const pair<S, T>& pr : v) o << (!i++ ? "" : ", ") << "{"
	<< pr.fs << " : " << pr.sc << "}"; return o << "]";
}
template<template <class, class...> class S, class T, class... L>
ostream& operator<<(ostream& o, const S<T, L...>& v) {
	o << "["; int i = 0;
	for (const auto& e : v) o << (!i++ ? "" : ", ") << e;
	return o << "]";
}
template<class S, class T>
ostream& operator<<(ostream& o, const pair<S, T>& pr) {
	return o << "(" << pr.fs << ", " << pr.sc << ")";
}
ostream& operator<<(ostream& o, const string& s) {
	for (const char& c : s) o << c;
	return o;
}

template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;
template<class T> using VVV = VV<V<T>>;
using ll = long long;
using pii = pair<int, int>;
using vi = V<int>;
using vii = V<pii>;
using vvi = VV<int>;
using mii = map<int, int>;
using umii = unordered_map<int, int>;
using si = set<int>;
using usi = unordered_set<int>;

const int MX = 2005;
int n;
ll mem[MX][MX];
vii A;

ll dp(int l, int r) {
	if (l > r)
		return 0;
	ll& ret = mem[l][r];

	if (ret != -1)
		return ret;
	int idx = n - (r - l);
	db(l, r, idx, A[idx]);
	return ret = max(A[idx].fs * 1LL * abs(l - A[idx].sc) + dp(l + 1, r), A[idx].fs * 1LL * abs(r - A[idx].sc) + dp(l, r - 1));
}



int main() {
	#ifdef LOCAL
	auto stTime = clock();
//	freopen("in.txt", "r", stdin);
	mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
	#endif
	ios::sync_with_stdio(false);
	cout.precision(10);
	cin.tie(0);

	cin >> n;

	A.assign(n + 1, pii());

	for (int i = 1; i <= n; ++i) {
		cin >> A[i].fs;
		A[i].sc = i;
	}

	sort(A.rbegin(), A.rend() - 1);

	db(A);

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

	cout << dp(1, n);


	#ifdef LOCAL
	cout << "\n\n\nExecution time: " <<
		(clock() - stTime) * 1e3 / CLOCKS_PER_SEC << " ms" << endl;
	#endif
	return 0;
}


Measured memory_bytes: 35172