akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  string s;
  cin >> s;
  for (int i = 0; i + 1 < s.size(); i++) {
    if (s[i] == 'A' && s[i+1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define lld long double
#define w(x) ll x;cin>>x;while(x--)
#define mod 1000000007
#define speed ios_base::sync_with_stdio(false);cin.tie(0);
using namespace std;

int main(){
    speed;
    string n;   cin>>n;
    ll sum=0;
    for(ll i=0;i<n.length();i++){
        sum+=(n[i]-48);
    }
    if(sum%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 3776
A,B=map(int,input().split())
a_line=(A-1)//50+1
b_line=(B-1)//50+1

print(2*a_line+2*b_line,99)
for i in range(a_line):
 if i == a_line-1:
  print(('.#'*((A-1)%50)+'#'*(99-2*((A-1)%50))))
 else:
  print(('.#'*49)+'.')
 print('#'*99)

for i in range(b_line):
 print('.'*99)
 if i == b_line-1:
  print(('#.'*((B-1)%50)+'.'*(99-2*((B-1)%50))))
 else:
  print(('#.'*49)+'#')


Measured memory_bytes: 3064
#おいらーつあー
H, W = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(H)]
res = []
d = []
for i in range(H):
  for j in range(W)[: : (-1) ** i]:
    d.append([i, j])
for i in range(len(d) - 1):
  y = d[i][0]
  x = d[i][1]
  if a[y][x] % 2:
    a[d[i + 1][0]][d[i + 1][1]] += 1
    a[y][x] -= 1
    res.append([y + 1, x + 1, d[i + 1][0] + 1, d[i + 1][1] + 1])
print(len(res))
for r in res:
  print(*r)

Measured memory_bytes: 59792
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    long S;
    cin >> S;
    int min = 100000;
    int num = 0;
    // cout << ((S<100)?"true":"false") << endl;
    for(;S>100;S=S/10){
        num = S%1000;
        //cout << abs(num-753) << " " << abs(min-753) << endl;
        if(abs(num-753)<abs(min-753)){
            min = num;
        }
    }
    cout << abs(min-753) << endl;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

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

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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

int N,P;
string S;

void solve25(){
  ll ans=0;
  rep(i,N){
    if((S.at(i)-'0')%P==0)  ans+=N-i;
  }
  cout << ans << endl;
}

int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  cin >> N >> P;
  cin >> S;
  reverse(all(S));

  if(P==2 || P==5){
    solve25();
    return 0;
  }

  ll ans=0;
  ll base=1;
  ll now=0;
  vector<ll> cnt(P,0);
  cnt.at(0)=1;
  rep(i,N){
    now+=(S.at(i)-'0')*base;
    now%=P;
    base*=10;
    base%=P;

    ans+=cnt.at(now);
    cnt.at(now)++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3716
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef long long ll;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int INF = INT_MAX;
const int mod = 1e9+7;

const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
clock_t time_p=clock();

#define int long long

int32_t main(){
  fast;

  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);

  int n,a,b;

  cin >> n >> a >> b;
  if((b - a) % 2 == 0)cout << (b - a) / 2 << "\n";
  else {
    cout << min(a + (b - a - 1)/2, (n - b + 1) + (n - (a + n - b + 1))/2 ) << "\n";
  }

  time_p=clock()-time_p;
  cerr<<"\nTime Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";

  return 0;
}

Measured memory_bytes: 256
def bubble_sort(n):
    arr = [int(input()) for _ in range(n)]
    cnt = 0
    for i in range(n):
        for j in range(n-1, i, -1):
            if arr[j] < arr[j-1]:
                arr[j], arr[j-1] = arr[j-1], arr[j]
                cnt += 1
    return cnt

while True:
    n = int(input())
    if n == 0: break
    print(bubble_sort(n))


Measured memory_bytes: 5608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrimeNumberGenerator pg = new PrimeNumberGenerator();
		
		while(true){
			int n = Integer.parseInt(br.readLine());
			
			if(n == 0){
				break;
			}
			
			System.out.println(pg.sumOfPrime(n));
		}
	}

}

class PrimeNumberGenerator {
    private boolean[] isPrime= new boolean[100000001];
    private int[] prime = new int[110000];
 
    public PrimeNumberGenerator() {
        //Date from = new Date();
        Arrays.fill(isPrime, true);
 
        isPrime[0] = false;
        isPrime[1] = false;
        isPrime[2] = true;
        
        prime[1] = 2;
 
        for(int i = 2; i <= Math.sqrt( isPrime.length ); i++){
            /*
            if(i % 2 == 0){
                isPrime[i] = false;
                continue;
            }
            */
 
            if(isPrime[i] == false){
                continue;
            }
 
            for(int j = i * 2; j <= isPrime.length - 1; j += i){
                isPrime[j] = false;
            }
        }
        
        for(int i = 3, j = 2; i < prime.length ; i++){
        	if(isPrime[i]){
        		prime[j] = i;
        		j++;
        	}
        }
        //Date to = new Date();
        //System.out.println("init takes "+ (to.getTime() - from.getTime())+ "milli sec");
    }
 
    public boolean isPrime(int index){
        if(index % 2 == 0 && index != 2){
            return false;
        }
        return isPrime[index];
    }
    
    public long sumOfPrime(int n){
    	int sum = 0;
    	for(int i = 1; i <= n; i++){
    		sum += prime[i];
    	}
    	
    	return sum;
    }
}

Measured memory_bytes: 123764
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for(int i = 0; i < n; i++) {
        	arr[n-1-i] = sc.nextInt();
        }
        int max = 0;
        int idx = 0;
        while(idx < n) {
        	int cnt = 0;
        	while(idx+1 < n && arr[idx] <= arr[idx+1]) {
        		cnt++;
        		idx++;
        	}
        	max = Math.max(max, cnt);
        	idx++;
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 50420
#include<stdio.h>
int main(){
  int n,m=100000,q[100010],r,t,s,d[100010];
  scanf("%d",&n);
  q[t=0]=1;
  for(r=0;r<n;r++)d[r]=1e9;
  for(r=d[1]=1;r-t;t++){//printf("%d %d\n",q[t],d[q[t]]);
    s=q[t];
    if(d[(s*10%n)]>d[s]){
      d[(s*10)%n]=d[s];
      q[t]=(s*10)%n;
      t--;
    }
    if(d[(s+1)%n]>d[s]){
      d[(s+1)%n]=d[s]+1;
      q[r++]=(s+1)%n;
    }
  }
  printf("%d\n",d[0]);
  return 0;
}


Measured memory_bytes: 896
from itertools import permutations

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

def main() :
    n, m ,r = input_list()
    road = input_list()
    road = [x-1 for x in road]
    d = [[float('inf')] * n for i in range(n)]
    for i in range(n) :
        d[i][i] = 0
    for i in range(m) :
        a, b, c = input_list()
        a -= 1
        b -= 1
        d[a][b] = c
        d[b][a] = c

    for k in range(n) :
        for i in range(n) :
            for j in range(n) :
                dist = d[i][k]+d[k][j]
                if d[i][j] > dist :
                    d[i][j] = dist

    ans = float('inf')
    for p in permutations(road) :
        dist = 0
        for i in range(r-1) :
            dist += d[p[i]][p[i+1]]
        if ans > dist :
            ans = dist

    print(ans)

main()

Measured memory_bytes: 4724
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

bool comp(const P& p1, const P& p2){
  	return p1.second > p2.second;
}

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

    ll n;
    cin >> n;
    ll x, y;
    vector<P> r(n), b(n);

    REP(i, n){
        cin >> x >> y;
        r[i] = P{x, y};
    }
    REP(i, n){
        cin >> x >> y;
        b[i] = P{x, y};
    }

    vll used(n);
    ll res = 0;
    VSORT(b);
    REP(i, n){
        vll rnum;
        REP(j, n){
            if(r[j].first < b[i].first && r[j].second < b[i].second) rnum.push_back(j);
        }
        ll ytmp = -1, match;
        REP(k, rnum.size()){
            if(!used[rnum[k]] && r[rnum[k]].second > ytmp){
                match = rnum[k];
                ytmp = r[rnum[k]].second;
            }
        }
        if(ytmp != -1){
            used[match] = 1;
            res++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL-1
double EPS=1e-9;
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef complex<double> P;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

/*
cin >> n;
vi a(n);
rep(i,n)cin>>a[i];
*/
int wt[114514]={0};
vi depth[114514];
vi child[114514];
int ma=0;
void dfs(int pa,int dep){
	depth[dep].pb(pa);
	ma=max(ma,dep);
	for(int i=0;i<child[pa].size();i++){
		dfs(child[pa][i],dep+1);
	}
	
}

int main(){
	int N;
	cin>>N;
	//int par[114514];
	int a;
	for(int i=2;i<=N;i++){
		cin>>a;
		child[a].pb(i);
	}
	
	dfs(1,0);
	for(int i=ma;i>=0;i--){
		for(int j=0;j<depth[i].size();j++){
			int now=depth[i][j];
			vi me;
			for(int k=0;k<child[now].size();k++){
				me.pb(wt[child[now][k]]);
			}
			sort(all(me));
			int n=me.size();
			for(int k=0;k<n;k++){
				wt[now]=max(wt[now],me[k]+n-k);
			}
		}
	}
	cout<<wt[1]<<endl;
}

Measured memory_bytes: 16896
H,W,K=map(int,input().split())
c=[list(input()) for _ in range(H)]
ans=0
for h in range(2**H):
    for w in range(2**W):
        tmp=0
        for i in range(H):
            for j in range(W):
                if h>>i&1 and w>>j&1 and c[i][j]=="#":
                    tmp+=1
        if tmp==K:
            ans+=1

print(ans)


Measured memory_bytes: 68608
#include <stdio.h>

int sosu(int);

int main()
{
  int n,i,count=0,data[10000];

  scanf("%d",&n);
  
  for(i=0 ; i<n ; i++){
    scanf("%d",&data[i]);
    if(sosu(data[i]) == 1)count++;
  }
  
  printf("%d\n",count);
  return 0;
}

int sosu(int x){
  int i;
  if(x<2)return 0;
  else if(x == 2)return 1;
  if(x%2 == 0)return 0;
  
  for(i=3; i<= x/i ; i+=2)
    if(x%i == 0)return 0;
  return 1;
}

Measured memory_bytes: 628
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

int main() {
	long long a, b, c;
	cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
	}
	else {
		long long res = min(a*b, min(b*c, a*c));
		cout << res << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MAXN = 200*1000+1;
int n,R;
int h[MAXN], beauty[MAXN];
LL T[(1<<19)];

void update(int a,LL x) {
    a+=R;
    T[a]=x;
    while(a>1) {
        a/=2;
        T[a] = max(T[2*a],T[2*a+1]);
    }
}

LL query(int a,int b) {
    a+=R; b+=R;
    LL w = max(T[a],T[b]);
    while(a/2!=b/2) {
        if(a%2==0) w=max(w,T[a+1]);
        if(b%2==1) w=max(w,T[b-1]);
        a/=2;
        b/=2;
    }
    return w;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0; i<n;i++) {
        cin>>h[i];
    }
    for(int i=0; i<n;i++) {
        cin>>beauty[i];
    }
    R = pow(2,(int)log2(n-1)+1);
    for(int i=0; i<n;i++) {
        LL tmp = query(1,h[i]);
        //cout<<tmp<<"\n";
        update(h[i],(LL)tmp+beauty[i]);
    }
    cout<<query(1,n);
}


Measured memory_bytes: 5504
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
start = time.clock()
while 1:
    try:
        a=map(int, raw_input().split())
        b=map(int, raw_input().split())
        j=k=0
        for i in range(4):
            if b[i]==a[i]:
                j+=1
            elif b[i] in a:
                k+=1
        print j,k
    except:
        break

Measured memory_bytes: 4564
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
read = sys.stdin.read

#n = int(input())
k,x = [int(i) for i in readline().split()]
#a = [int(i)//2 for i in read().split()]

if 500*k >= x:
    print("Yes")
else:
    print("No")





    
        
    



        








Measured memory_bytes: 2940
import math
a,b,h,m = map(int, input().split())
atheta = 2*math.pi*(60*h+m)/720
btheta = 2*math.pi*m/60
l = pow(a**2+b**2-2*a*b*math.cos(btheta-atheta),1/2)
print(l)

Measured memory_bytes: 62628
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getInts(N int) []int {
	ret := make([]int, N)
	for i := 0; i < N; i++ {
		ret[i] = getInt()
	}
	return ret
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	d := N / 2
	if N%2 == 1 {
		d++
	}
	out(float64(d) / float64(N))
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,m;cin >> n >> m;
	if(n>m){
		n=n^m;
		m=n^m;
		n=n^m;
	}
	if(n>=2){
		cout << (n-2)*(m-2) << endl;
	}
	else if(n==1){
		if(m==1) cout << 1 << endl;
		else cout << m-2 << endl;
	}
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<ll> vl;
typedef vector<vector<int, int> > vvi;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define in insert
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x>=k) cnt++;

    }
    cout << cnt;
}

Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n, m, c int 
  fmt.Scan(&n, &m, &c)
  b := make([]int, m)
  for i := 0; i < m; i++ {
    fmt.Scan(&b[i])
  }

  cnt := 0
  for i := 0; i < n; i++ {
    a := make([]int, m)
    for j := 0; j < m; j++ {
      fmt.Scan(&a[j])
    }
    s := c
    for j := 0; j < m; j++ {
      s += a[j] * b[j]
    }
    if s > 0 {cnt++}
  }
  fmt.Println(cnt)
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
using namespace std;
typedef signed long long ll;


int arr[57];
int main() {
	int n; cin >> n;
	string s; cin >> s;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == s[i + 1])
			cnt++;
	}

	cout << n - cnt << endl;
	 return 0;
}


Measured memory_bytes: 512
n, d = map(int, input().split())
x = []
r = 0
ans = 0
for i in range(n):
  x.append(list(map(int, input().split())))

for i in range(n-1):
  for k in range(1, n-i):
    for j in range(d):
      r_temp = (x[i][j] - x[i+k][j])**2 
      r += r_temp
    r = r**0.5
    if int(r) == r:
      ans += 1
    r = 0
    
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include <bits/stdc++.h>
#include <cstdio>
#include<set>
using namespace std;
int main()
{
    // �����̓���
    int N, K;
    int sum = 0;
    
    cin >> N;
    cin >> K;
    string S;
    
    cin >> S;
    int cnt = 0;
    for (int i = 0; i < N - 1; ++i) { 
        if (S[i] != S[i + 1]){
            cnt++;
        }
    }
    int ans = min(N - 1, N - 1 - cnt + 2 * K);
    cout << ans;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

const int N=2e5+5;
LL A[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    LL K, n;
    cin >> K >> n;
    LL ans=1e18;
    REP(i,n) cin >> A[i];

    REP(i, n) {
        int j=(i-1+n)%n;
        ans=min(ans, (A[j]-A[i]+K)%K);
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())

#define rep(i,n) for(int i = 0; i < (n);++i)
#define repc(i,a,b) for(int i = (a);i <(b);++i)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;

constexpr int IMAX = ((1<<30)-1)*2+1 ;
constexpr int INF = 100000000;
double EPS = 1e-10 ;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int num,max;
  vi tmp(101,0);
  while(cin >> num){
    ++tmp[num] ;
  }
  max = *max_element(all(tmp)) ;
  rep(i,101){
    if(tmp[i] == max){
      cout << i << endl ;
    }
  }
  return 0;
}

Measured memory_bytes: 1192
#標準入力　テスト
import sys
input = lambda: sys.stdin.readline().rstrip()
K=int(input())
S=input()
M=len(S)
N=K+M
mod=10**9+7
ans=pow(26,N,mod)
class Data():
    def __init__(self):
        self.power=1
        self.rev=1     
class Combi():
    def __init__(self,N,mod):
        self.lists=[Data() for _ in range(N+1)]
        self.mod=mod  
        for i in range(2,N+1):
            self.lists[i].power=((self.lists[i-1].power)*i)%self.mod
        self.lists[N].rev=pow(self.lists[N].power,self.mod-2,self.mod)
        for j in range(N,0,-1):
            self.lists[j-1].rev=((self.lists[j].rev)*j)%self.mod

    def combi(self,K,R):
        if K<R:
            return 0
        else:
            return ((self.lists[K].power)*(self.lists[K-R].rev)*(self.lists[R].rev))%self.mod
        
c=Combi(2*10**6,mod)
for i in range(M):
    ans-=c.combi(N,i)*pow(25,N-i,mod)
    ans%=mod
print(ans)


Measured memory_bytes: 313532
#include<iostream>
#include<vector>
#include<map>
#include<cassert>
#include<algorithm>
using namespace std;

struct Record{
  int s;
  int t;
  int n;
  int m;
  Record(int s,int t,int n,int m) : s(s), t(t), n(n), m(m) {;}
};

bool operator<(const Record &l, const Record &r) {
  return (r.t != l.t) ? l.t < r.t : l.m < r.m;
}

int main() {
  int N,M,r,q;
  while(cin>>N>>M, N|M) {
    cin>>r;
    int t,n,m,s;
    vector<Record> in;
    for(int i=0; i<r; ++i) {
      cin>>t>>n>>m>>s;
      in.push_back(Record(s,t,n,m));
    }
    cin>>q;
    int ts,te;
    sort(in.begin(), in.end());
    for(int i=0; i<q; ++i) {
      cin>>ts>>te>>m;
      int ans = 0,use = 0,start = -1,fans;
      vector<pair<int,int> > v;
      for(int j=0; j<in.size(); ++j) {
	if(in[j].m != m) continue;
	if(in[j].s == 1) {
	  if(use == 0 && start == -1)
	    start = in[j].t;
	  use++;
	}
	if(use > 0 && in[j].s == 0) {
	  use--;
	  if(use == 0) {
	    ans += in[j].t - start;
	    v.push_back(pair<int,int>(start,in[j].t));
	    start = -1;
	  }
	}
      }
      assert(use == 0);
      fans = 0;
      for(int j=0; j<v.size(); ++j) {
	if(v[j].first >= te || v[j].second <= ts) continue;
	if(v[j].first <= ts && v[j].second >= te) {
	  fans += te - ts;
	}else if(v[j].first <= ts) {
	  fans += v[j].second - ts;
	}else if(v[j].second >= te) {
	  fans += te - v[j].first;
	}else{
	  fans += v[j].second - v[j].first;
	}
      }
      cout<<fans<<endl;
    }
  }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    ll N, A;
    scanf("%lld %lld", &N, &A);
    printf("%lld\n", N*N-A);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;

class Main {

	private static final String SPLIT_STR = " ";
	private static final int NOT_TEST = -1;
	private static final int[] SCORE_ARRAY = {80, 65, 50, 30, 0};
	private static final String[] GRADE_ARRAY = {"A", "B", "C", "D", "F"};
	private static final int SCORE_D = 30;
	private static final int SCORE_RETEST = 50;

	public static void main(String[] args) {

		String input = null;

		Scanner sc = new Scanner(System.in);

		while (true) {
			input = sc.nextLine();
			String[] split = input.split(SPLIT_STR);
			int m = Integer.parseInt(split[0]);
			int f = Integer.parseInt(split[1]);
			int r = Integer.parseInt(split[2]);

			if (m == NOT_TEST && f == NOT_TEST && r == NOT_TEST) {
				break;
			}

			if (m == NOT_TEST || f == NOT_TEST) {
				System.out.println(GRADE_ARRAY[GRADE_ARRAY.length - 1]);
				continue;
			}

			for (int i = 0; i < SCORE_ARRAY.length; i++) {
				int score = m + f;
				if (score >= SCORE_ARRAY[i]) {
					if (SCORE_ARRAY[i] == SCORE_D && r >= SCORE_RETEST) {
						System.out.println(GRADE_ARRAY[i - 1]);
					} else {
						System.out.println(GRADE_ARRAY[i]);
					}
					break;
				}
			}
		}

		sc.close();
	}
}



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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

#define MAXN 401
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL {printf("-1\n"); return 0;}

int N;
LL A[MAXN];
LL S[MAXN];
LL dp[MAXN][MAXN];
int B[MAXN][MAXN];

LL sum(int i, int j) {
    LL ret = S[j];
    if (i) ret -= S[i-1];
    return ret;
}

LL f(int i, int j) {
    //printf("%d %d\n", i, j);
    if (B[i][j]) return dp[i][j];
    B[i][j] = 1;

    if (i+1 == j) dp[i][j] = A[i] + A[j];
    else {
        dp[i][j] = A[i] + sum(i+1,j) + f(i+1,j);
        dp[i][j] = min(dp[i][j], A[j] + sum(i,j-1) + f(i,j-1));

        for (int k = i+1; k < j-1; k++)
            dp[i][j] = min(dp[i][j], sum(i,k) + sum(k+1,j) + f(i,k) + f(k+1,j));
    }

    return dp[i][j];
}

int main(int argc, char **argv)
{
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif

    scanf("%d", &N);
    for (int i = 0; i < N; i++) scanf("%lld", &A[i]);
    S[0] = A[0];
    for (int i = 1; i < N; i++) S[i] = S[i-1] + A[i];

    printf("%lld\n", f(0,N-1));
    return 0;
}


Measured memory_bytes: 2176
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    As = list(map(int, input().split()))
    for a in As:
        if a%2==0:
            if a%3==0 or a%5==0:
                continue
            else:
                print("DENIED")
                return
    print("APPROVED")


if __name__ == "__main__":
    solve()


Measured memory_bytes: 2940
a = int(input())
ar = []
br = []
for i in range(a):
    x,y = map(int,input().split(" "))
    ar.append([x,y])
    br.append([x,y])
count = 0
for i in range(a):
    for j in range(a):
        if i != j:
            count += ( (abs(ar[i][0] - br[j][0]) ** 2 + (abs(ar[i][1] - br[j][1])) ** 2) )** 0.5
print(count / a)

Measured memory_bytes: 3064
import java.io.IOException;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt(); //数列Sの長さ
        int[] s = new int[n]; //数列S
        for(int i=0; i<n; i++) {
            s[i] = sc.nextInt();
        }

        int q = sc.nextInt(); //数列Tの長さ
        int count = 0; //出力結果（個数）
        int left,right,mid,t;

        for(int i=0; i<q; i++) {
            left = 0;
            right = n-1;
            t = sc.nextInt();
            while(left<=right) {
                mid = (left+right)/2;
                if(s[mid] < t) {
                    left = mid+1;
                } else if (s[mid] > t) {
                    right = mid-1;
                } else {
                    count++;
                    break;
                }
            }
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 67192
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int h,n,x;cin>>h>>n;
    while(n--)
    {
        cin>>x;
        h-=x;
    }
    cout<<(h<=0?"Yes":"No");
    return 0;
}


Measured memory_bytes: 256
s = list(input())
x,y = map(int,input().split())
i = 0
while i < len(s) and s[i] == "F":
    i += 1
    x -= 1

l = []
r = []
check = 1
count = 0
while i < len(s):
    if s[i] == "T":
        if count >0:
            if check == 1:
                l.append(count)
            else:
                r.append(count)
        check *= -1
        count = 0
    else:
        count += 1
    i += 1

if count >0:
    if check == 1:
        l.append(count)
    else:
        r.append(count)       

    
if abs(x) > sum(l) or abs(y) > sum(r):
    print("No")
    exit() 

dpx = [[0]*(sum(l)*2+3) for i in range(len(l)+1)]
lx = sum(l)*2+3
dpx[0][sum(l)] = 1
for i in range(len(l)):
    for j in range(lx):
        if dpx[i][j] == 1:
            dpx[i+1][j+l[i]] = 1
            dpx[i+1][j-l[i]] = 1

dpy = [[0]*(sum(r)*2+3) for i in range(len(r)+1)]
rx = sum(r)*2+3
dpy[0][sum(r)] = 1
for i in range(len(r)):
    for j in range(rx):
        if dpy[i][j] == 1:
            dpy[i+1][j+r[i]] = 1
            dpy[i+1][j-r[i]] = 1
if dpx[-1][sum(l)+x] == 1 and dpy[-1][sum(r)+y] == 1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 167004
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e5+5); // TODO : change value as per problem
const ll MOD = 1e9+7;
bool vis[N];
vector<int> adj[N];
void dfs(int u){
	vis[u]=true;for(auto v:adj[u])if(vis[v]==false)dfs(v);
}
void solve(){
	int n,m;
	cin >> n >> m;
	for(int i=1;i<=m;i++){
		int u,v;
		cin >> u >> v;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	int co=0;
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			co++;
			dfs(i);
		}
	}
	cout << co-1 << endl;
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 10428
#include <stdio.h>

int main()
{
	int S;
	int h, m, s;
	scanf("%d", &S);
	h = S/3600;
	m = (S-3600*h)/60;
	s = S%60;
	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

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

int main()
{
    int n,t,c,ct,i,j,res=2e9;
    scanf("%d %d",&n,&t);
    for(i=1;i<=n;i++)
    {
        scanf("%d %d",&c,&ct);
        if(ct<=t)
        {
            res=min(res,c);
        }
    }
    if(res==2e9)
    {
        printf("TLE");
    }
    else
        printf("%d\n",res);
}


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

int max(long long int a[3]){
	int m=0;
	int mpo=0;
	for(int i=0;i<3;i++){
		if(a[i]>m){
			m=a[i];
			mpo=i;
		}
	}
	return mpo;
}

int mid(long long int a[3]){
	int ma=max(a);
	int m=0;
	int mp=0;
	for(int i=0;i<3;i++){
		if(a[i]>m and i!=ma){
			m=a[i];
			mp=i;
		}
	}
	return mp;
}

int main(){
	int n;
	int x,y,i,j;
	cin>>n;
	long long int a[n][3], b[n][3];
	for(i=0;i<3;i++){
		cin>>a[0][i];
		b[0][i]=a[0][i];	
	}
	for(i=1;i<n;i++){
		cin>>b[i][0]>>b[i][1]>>b[i][2];
		x=max(a[i-1]);
		y=mid(a[i-1]);
		for(j=0;j<3;j++){
			if(j==x){
				a[i][j]=a[i-1][y]+b[i][j];
			}
			else{
				a[i][j]=a[i-1][x]+b[i][j];
			}
		}
	}
	cout<<a[n-1][max(a[n-1])];
}

Measured memory_bytes: 4992
package main

import (
  "fmt"
  "bufio"
  "os"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
  sc.Scan()
  return sc.Text()
}

func main() {
  var b = nextLine()
  var ret = 0
  var tmp = 0

  var max = 10
  if len(b) < max {
    max = len(b)
  }

  for i := 0; i < max; i++ {
    var str = b[i:i+1]
    if str == "A" || str == "C" || str == "G" || str == "T" {
      tmp++
    } else {
      if ret < tmp {
        ret = tmp
      }
      tmp = 0
    }
    if tmp > 0 {
      var str2 = str
      if ret < tmp && (str2 == "A" || str2 == "C" || str2 == "G" || str2 == "T") {
        ret = tmp
      }
    }
  }

  fmt.Println(ret)
}


Measured memory_bytes: 640
S=list(input())
m=list('abcdefghijklmnopqrstuvwxyz')[::-1]

if len(S)<26:
    for i in m[::-1]:
        if i not in S:
            S.append(i)
            break
    print(''.join(S))
else:
    x=S[-1]
    for i in range(25)[::-1]:
        if x>S[i]:
            y=m.index(S[i])
            S=S[:i]
            for j in range(y)[::-1]:
                if m[j] not in S:
                    S.append(m[j])
                    break
            break
        else:
            x=S[i]
        
        if i==0:
            print(-1)
            exit()
    print(''.join(S))

Measured memory_bytes: 9132
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,b,a) for(int i=b;i>=a;i--)
#define fori(a) for(auto i : a )
#define all(a) begin(a), end(a)
#define set(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pi 3.14159
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PF push_front //deque
#define mp make_pair
#define pq priority_queue
const ll mod=1000000007;
#define f first
#define s second
#define pii pair< int, int >
#define vi vector<int>
#define vpii vector<pii>
#define debug(v) for(auto i:v) cout<<i<<" ";
#define tc int t; cin >> t; while(t--)

using namespace std;
string repeat(string s, int n) {
    string s1 = "";
    for (int i=0; i<n;i++)
        s1+=s;
    return s1;
}
string getString(char x) {
    string s(1, x);
    return s;
}

void optimizeIO(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}


const int MOD = 1e9+7;
const int MAXR = 510000;

template<ll mod> class modint{
public:
    ll val=0;
    //コンストラクタ
    modint(ll x=0){while(x<0)x+=mod;val=x%mod;}
    //コピーコンストラクタ
    modint(const modint &r){val=r.val;}
    //算術演算子
    modint operator -(){return modint(-val);} //単項
    modint operator +(const modint &r){return modint(*this)+=r;}
    modint operator -(const modint &r){return modint(*this)-=r;}
    modint operator *(const modint &r){return modint(*this)*=r;}
    modint operator /(const modint &r){return modint(*this)/=r;}
    //代入演算子
    modint &operator +=(const modint &r){
        val+=r.val;
        if(val>=mod)val-=mod;
        return *this;
    }
    modint &operator -=(const modint &r){
        if(val<r.val)val+=mod;
        val-=r.val;
        return *this;
    }
    modint &operator *=(const modint &r){
        val=val*r.val%mod;
        return *this;
    }
    modint &operator /=(const modint &r){
        ll a=r.val,b=mod,u=1,v=0;
        while(b){
            ll t=a/b;
            a-=t*b;swap(a,b);
            u-=t*v;swap(u,v);
        }
        val=val*u%mod;
        if(val<0)val+=mod;
        return *this;
    }
    //等価比較演算子
    bool operator ==(const modint& r){return this->val==r.val;}
    bool operator <(const modint& r){return this->val<r.val;}
    bool operator !=(const modint& r){return this->val!=r.val;}
};

using mint = modint<MOD>;

//入出力ストリーム
istream &operator >>(istream &is,mint& x){//xにconst付けない
    ll t;is >> t;
    x=t;
    return (is);
}
ostream &operator <<(ostream &os,const mint& x){
    return os<<x.val;
}

//累乗
mint modpow(const mint &a,ll n){
    if(n<=0)return 1;
    mint t=modpow(a,n/2);
    t=t*t;
    if(n&1)t=t*a;
    return t;
}
struct comp{
  bool operator()(pii x, pii y){
    return x.s<y.s;
  }
};
void  solve(){
  int n,m;
  cin>>n>>m;
  vector<pair<int,int>> v1(m);
  rep(i,0,m){
    cin>>v1[i].f>>v1[i].s;
  }
  sort(all(v1),comp());
  int right_end=0,ans=0;;
  rep(i,0,m){
    if(right_end<=v1[i].f)  right_end=v1[i].s,ans++;
  }
  cout<<ans<<endl;
}
int main(){
    optimizeIO();
    // tc
    { solve();
    }
}


Measured memory_bytes: 4000
import java.util.Scanner

object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val cubes = sc.next()
    cubes
  }


  def solve(cubes: String): Int = {
    val n0 = cubes.count(c => c=='0')
    val n1 = cubes.count(c => c=='1')
    2 * Math.min(n0, n1)
  }


  def main(args: Array[String]): Unit = {
    val cubes = read()
    println(solve(cubes))
  }
}

Measured memory_bytes: 31032
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn=2e5+10;
const int mod=998244353;
struct Point{
	int x,y;
	// Point (int x = 0,int y = 0)
};
Point p[maxn];
bool operator <(const Point &a,const Point &b){
	return  a.x < b.x;
}
LL sum[maxn];
int lowbit(int x){return x&(-x);}
int s[maxn],pre[maxn];
int x[maxn],y[maxn];
LL tree[maxn];
void Add(int x,int p){
	for(;x < maxn; x += lowbit(x))
		tree[x] += p;//,x += lowbit(x);
}
LL Sum(int x){
	LL sum = 0;
	for(;x > 0; x -= lowbit(x))
		sum += tree[x];
	return sum;
}
LL pow2[maxn];
int A[maxn],B[maxn];
inline void Add(LL &a,LL b){
	a += b;
	while(a >= mod)
		a -= mod;
	while(a < 0)
		a += mod;
}
int main(void)
{
	pow2[0] = 1;
	for(int i = 1;i < maxn; ++i)
		pow2[i] = pow2[i-1]*2%mod;
	// cout<<pow2[10]<<endl;
	int n;cin>>n;
	for(int i = 1;i <= n;++i)
		cin>>p[i].x>>p[i].y,x[i]= p[i].x,y[i] = p[i].y;
	sort(p+1,p+n+1);
	sort(y+1,y+n+1);
	for(int i = 1;i <= n;++i)
		{
			p[i].x = i,p[i].y = lower_bound(y+1,y+n,p[i].y)-y;
		}
	LL ans = n*(pow2[n]-1)%mod;
	for(int i = 1;i <= n; ++i){
		A[i] = Sum(p[i].y);
		Add(p[i].y,1);
	}
	memset(tree,0,sizeof(tree));
	for(int i = n;i >= 1; --i){
		B[i] = Sum(p[i].y);
		Add(p[i].y,1);
	}
	for(int i = 1;i <= n; ++i){
		LL tmp = pow2[i-1]+pow2[n-i]+pow2[p[i].y-1]+pow2[n-p[i].y]-pow2[A[i]]-pow2[i-A[i]-1]-pow2[n-i-B[i]]-pow2[B[i]];
		tmp %= mod;
		Add(ans,-tmp);
	}
	cout<<(ans%mod+mod)%mod<<endl;

   return 0;
}


Measured memory_bytes: 11136
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yosiiii
 */


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

class CTsundoku {
public:
	void solve(std::istream& in, std::ostream& out) {
        ll n,m,k;
        in >> n >> m >> k;
        vector<ll> a(n+1),b(m);
        a[0]=0L;
        rep(i,n){
            in >> a[i+1];
        }
        rep(i,m){
            in >> b[i];
        }
        rep(i,n){
            a[i+1]+=a[i];
        }
        rep(i,m-1){
            b[i+1]+=b[i];
        }
        ll ans=0;
        for(ll i=0;i<=n;i++){
            ll t=k-a[i];
            if(t<0){
                break;
            }
            auto it = upper_bound(b.begin(),b.end(),t);
            ll  bn = distance(b.begin(),it);
            ans = max(ans,bn+i);
//            if(ans==2)out << bn <<" " <<i<< " " << a[i] << endl;
        }
        out << ans << endl;
	}
};


int main() {
	CTsundoku solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 6420
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
#else
using LONG = long long int;
#endif

int main(void) {
  int W, H;
  vector<pair<int, int>> p; // cost, i
  vector<pair<int, int>> q; // cost, i
  cin >> W >> H;
  int w_need = W + 1;
  int h_need = H + 1;
  for (int i = 0; i < W; i++) {
    int cost;
    cin >> cost;
    p.push_back(make_pair(cost, i));
  }
  for (int i = 0; i < H; i++) {
    int cost;
    cin >> cost;
    q.push_back(make_pair(cost, i));
  }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  int qindex = 0, pindex = 0;
  LONG totalCost = 0;
  while (pindex < W || qindex < H) {
    if (qindex == q.size() || pindex < p.size() && p[pindex].first <= q[qindex].first) {
      totalCost += (LONG)h_need * p[pindex].first;
      w_need--; w_need = max(w_need, 1);
      pindex++;
    } else {
      totalCost += (LONG)w_need * q[qindex].first;
      h_need--; h_need = max(h_need, 1);
      qindex++;
    }
  }
  cout << totalCost << endl;
  return 0;
}

Measured memory_bytes: 2548
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);i--)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<vector<P> > Graph;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int p,q,r;
  cin >> p >> q >> r;

  cout << min({p+q,p+r,q+r}) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    int m = 50 * 101 + 7;
    int s1 = 0, s2 = 0;
    for (int i = 0; i < n; ++i) {
        s1 += v[i];
        for (int j = i+1; j < n; ++j) {
            s2 += v[j];
        }
        m = min(m, abs(s1-s2));
        s2 = 0;
    }

    cout << m << '\n';
    return 0;
}



Measured memory_bytes: 256
#include "iostream"
#include "string"
#include "vector"
#include "limits.h"
#define INPUT_NUM 5
#define ORDER_START_TIME 0
#define ORDER_MULTIPLE 10

int GetRestMinIndex(std::vector<int> input);
int ConvertNecessaryTime(int time);

int main()
{
  // get data
  std::vector<int> input;
  for (int i=0; i<INPUT_NUM; i++)
  {
    std::string inputStr = "";
    std::cin >> inputStr;
    int num = std::stoi(inputStr);
    input.push_back(num);
  }
  
  // start order
  int NecessaryTime = ConvertNecessaryTime(ORDER_START_TIME);
  
  // end order
  int restMinIndex = GetRestMinIndex(input);
  NecessaryTime += input[restMinIndex];
  input.erase(input.begin() + restMinIndex);
  
  // others order
  for ( int time : input)
  {
    NecessaryTime += ConvertNecessaryTime(time);
  }
  
  std::cout << NecessaryTime;
  return 0;
}

int GetRestMinIndex(std::vector<int> input)
{
  int restMin = INT_MAX;
  int restMinIndex = 0;
  for (int i=0; i<input.size(); i++)
  {
    if ( 0 < input[i]%ORDER_MULTIPLE && input[i]%ORDER_MULTIPLE < restMin )
    {
      restMin = input[i]%ORDER_MULTIPLE;
      restMinIndex = i;
    }
  }
  return restMinIndex;
}
int ConvertNecessaryTime(int time)
{
  if ( time%ORDER_MULTIPLE == 0 )
  {
    return time;
  }
  else
  {
    return (time/ORDER_MULTIPLE+1)*ORDER_MULTIPLE;
  }
}

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

for i in range(N):
    cnt += min(A[i], B[i])
    if A[i] < B[i]:
        if A[i+1] < B[i] - A[i]:
            cnt += A[i+1]
            A[i+1] = 0
        else:
            cnt += B[i] - A[i]
            A[i+1] -= B[i] - A[i]
print(cnt)




Measured memory_bytes: 24088
#include <stdio.h>

int main(void) {
    int a, b, c, cnt;
    int tmp[3] = {};
    scanf("%d %d %d", &a, &b, &c);
    
    if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0 &&a == b && b == c && c == a) {
        printf("-1\n");
        return 0;
    }

    cnt = 0;

    for (cnt; a%2==0&&b%2==0&&c%2==0; cnt++) {
        tmp[1]+=a/2; tmp[2]+=a/2;
        tmp[0]+=b/2; tmp[2]+=b/2;
        tmp[0]+=c/2; tmp[1]+=c/2;
        a=tmp[0];b=tmp[1];c=tmp[2];
    }

    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128