akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int h, w;
vvc s(50, vc(50));
vvi cost(2500, vi(2500, 1e9));
vector<int> dist(2500, 1e9); //dist[i]はstartからiへの最短コスト
vector<bool> used(2500, true); //used[i]はstartから節点iへのコストが未確定か否かを示す
vector<int> prev_node(2500, -1);  //prev[i]は節点iへ繋ぐ節点番号を格納
//Dijkstra法(cost[i][j]は節点iから節点jへのコスト，startは始点番号，nは節点数)
void Dijkstra(int start, int n)
{
	int i, j, min_j, min;
							 //始点のコストは0
	dist[start]=0;
	for(i=0; i<n; i++){
		//節点コストが確定していない点の中で，startからのコストが最小の節点min_jを求める
		min=1e9+1;
		for(j=0; j<n; j++){
			if(min>dist[j]&&used[j]){
				min=dist[j]; min_j=j;
			}
		}
		//節点min_jのコストを決定する
		used[min_j]=false;
		for(j=0; j<n; j++){
			if(dist[j]>dist[min_j]+cost[min_j][j]&&used[j]){
				dist[j]=dist[min_j]+cost[min_j][j];
				prev_node[j]=min_j;
			}
		}
	}
}
int main(void)
{
	cin>>h>>w;

	vi prev;

	rep(i, h){
		rep(j, w) cin>>s[i][j];
	}
	rep(i, h){
		rep(j, w){
			if(s[i][j]=='.'){
				if(i!=0){
					if(s[i-1][j]=='.'){
						cost[(i-1)*w+j][i*w+j]=1;
						cost[i*w+j][(i-1)*w+j]=1;
					}
				}
				if(i!=h-1){
					if(s[i+1][j]=='.'){
						cost[(i+1)*w+j][i*w+j]=1;
						cost[i*w+j][(i+1)*w+j]=1;
					}
				}
				if(j!=0){
					if(s[i][j-1]=='.'){
						cost[i*w+j-1][i*w+j]=1;
						cost[i*w+j][i*w+j-1]=1;
					}
				}
				if(j!=w-1){
					if(s[i][j+1]=='.'){
						cost[i*w+j][i*w+j+1]=1;
						cost[i*w+j+1][i*w+j]=1;
					}
				}
			}
		}
	}
	Dijkstra(0, h*w);
	
	int k=h*w-1;
	bool flag=true;
	vb visited(h*w, false);
	while(k!=0){
		visited[k]=true;
		k=prev_node[k];
		if(k==-1){
			flag=false;  break;
		}
	}

	if(flag){
		int ans=-1;
		rep(i, h){
			rep(j, w){
				if(!visited[i*w+j]&&s[i][j]=='.') ans++;
			}
		}
		if(ans<0) ans=0;
		cout<<ans<<endl;
	}else{
		cout<<-1<<endl;
	}
}

Measured memory_bytes: 24832
import java.io.BufferedReader;
import java.io.InputStreamReader;
  
public class Main {
    public static void main(String[] args) throws Exception {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String str = br.readLine();
    	String[] array = str.split(" ");
    	
    	int a = Integer.parseInt(array[0]);
    	int b = Integer.parseInt(array[1]);
    	int c = Integer.parseInt(array[2]);
    	
    	int i,d = 0;
    	
    	for(i=a;i<=b;i++){
    		if(c%i==0){
    			d++;
    		}
    	}
    	System.out.println(d);
    	
    }
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }

const ll MOD=1000000007LL;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }
// ll comb(ll n, ll k) { ll v=1; for(ll i=1; i<=k; i++) v = DIV(MUL(v, n-i+1),i); return v; }
//

ll solve(int N,int W,vi& w,vi& v){
    int w0 = w[0];
    vi dw(N); rep(i,N) dw[i] = w[i] - w0;

    vvi dp(101, vi(301, -1));
    // dp[個数][Σdw] = Σv
    dp[0][0] = 0;
    rep(i, N) {
        // vvi dp2(101, vi(300, 0));
        int dw_i = dw[i];
        int v_i = v[i];
        for (int k=i; k>=0; --k) {
            for (int j=0; j<=300; ++j) {
                if (dp[k][j] == -1) continue;
                if (j+dw_i <= 300) {
                    dp[k+1][j+dw_i] = max(dp[k+1][j+dw_i], dp[k][j] + v_i);
                }
            }
        }
    }

    int ans = 0;
    for (int k=0; k<=100; ++k) {
        ll base = (ll)w0 * k;
        ll room = W - base;
        if (room < 0) break;
        int rmax = min(300, (int)room);
        // dp[k][0] .. dp[k][room]
        int best = 0;
        for (int j=0; j<=rmax; ++j) {
            if (dp[k][j] == -1) continue;
            best = max(best, dp[k][j]);
        }
        // fprintf(stderr, "k=%d, best=%d\n", k,best);
        ans = max(ans, best);
    }
    return ans;
}

int main() {
    int N, W; cin >> N >> W;
    vi w(N), v(N);
    rep(i,N) cin >> w[i] >> v[i];
    cout << solve(N,W,w,v) << endl;
    return 0;
}


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

int main() {
  int N,M;
  cin >> N >> M;
  
  vector<int> A(M);
  for (int i; i < M; i++) {
    cin >> A.at(i);
  }
  int result = 0;
  for (int i; i < M; i++) {
    result += A.at(i);
  }
  result = N - result;
  if (result < 0) {
    result = -1;
  }
  cout << result << endl;
  
}

Measured memory_bytes: 3604
import sys
import itertools
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    N =int(input())

    C =[]
    S =[]
    F =[]
    for i in range(N-1):
        c,s,f = map(int,input().split())
        C.append(c)
        S.append(s)
        F.append(f)

    for i in range(N-1):
        t = i
        time=0
        while t<N-1:

            if time <=S[t]:
                time =S[t]+C[t]
            else:
                if time %F[t] ==0:
                    time +=C[t]
                else:
                    div = time //F[t]
                    time = (div+1) *F[t] + C[t]
            t+=1

        print(time)

    print(0)





if __name__ == "__main__":
    main()


Measured memory_bytes: 71676
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0158

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        n = int(input())
        if n == 0:
            break

        count = 0
        while n != 1:
            if n % 2 == 0:
                n //= 2
            else:
                n *= 3
                n += 1
            count += 1
        print(count)


if __name__ == '__main__':
    main(sys.argv[1:])

Measured memory_bytes: 7760
#include<stdio.h>
int main(void)
{
    int i,j,wide=0,tate=0;
    char in[8][8];
    while(scanf("%s",in[0])!=EOF)
    {
        for(i=1;i<8;i++)
        {
            scanf("%s",in[i]);
        }
        for(i=0;i<8;i++)
        {
            for(j=0;j<8;j++)
            {
                if(in[i][j]=='1')
                {
                    if(in[i+1][j]=='1'&&in[i+1][j+1]=='1'&&in[i][j+1]=='1')
                    {
                        printf("A\n");break;
                    }
                    else if(in[i+1][j]=='1'&&in[i+2][j]=='1'&&in[i+3][j]=='1')
                    {
                        printf("B\n");break;//
                    }
                    else if(in[i][j+1]=='1'&&in[i][j+2]=='1'&&in[i][j+1]=='1')
                    {
                        printf("C\n");break;
                    }
                    else if(in[i+1][j]=='1'&&in[i+1][j-1]=='1'&&in[i+2][j-1]=='1')
                    {
                        printf("D\n");break;
                    }
                    else if(in[i][j+1]=='1'&&in[i+1][j+1]=='1'&&in[i+1][j+2]=='1')
                    {
                        printf("E\n");break;
                    }
                    else if(in[i+1][j]=='1'&&in[i+1][j+1]=='1'&&in[i+2][j+1]=='1')
                    {
                        printf("F\n");break;//
                    }
                    else if(in[i][j+1]=='1'&&in[i+1][j]=='1'&&in[i+1][j-1]=='1')
                    {
                        printf("G\n");break;
                    }
                }
            }
        }
    }
return 0;
}

Measured memory_bytes: 524
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_1_D
// O(n*log(n)) PCC p. 65 solution
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>

using namespace std;

int main(int argc, char **argv)
{
        int n;
        cin >> n;
        vector<int> dp(n, INT_MAX);
        for (int i = 0; i < n; i++) {
                int a;
                cin >> a;
                auto p = lower_bound(dp.begin(), dp.end(), a);
                (*p) = a;
        }
        auto p = lower_bound(dp.begin(), dp.end(), INT_MAX);
        cout << distance(dp.begin(), p) << endl;
        return 0;
}

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

using namespace std;
int S[10000];
int main()
{
  int N,M,s,count;
  cin>>N>>M;
  count=0;
  for(int i=0;i<M;i++){
    cin>>s;
    count+=s;
  }
  if(!(N-count<0)){
  cout<<N-count;
  }else{
  cout<<-1;
  }



  return 0;
}





Measured memory_bytes: 3636
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    long long a, b;
    string s;
    
    cin >> a >> b;
    cin >> s;
    
    for(int i = 0; i < a + b + 1; i++){
        if(i == a){
            if(s[i] != '-'){
                cout << "No" << endl;
                return 0;
            }
        }
        else{
            if(!(s[i] <= '9' && s[i] >= '0')){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

#define all(n) n.begin(),b.end()
#define F first
#define S second
#define INF (1<<27)

using namespace std;

typedef pair<int,int> P;
typedef vector<P> VP;
int n;

bool cmp(const P& a,const P& b){
    if(a.S != b.S)
        return a.S < b.S;
    return false;
}

int closest_pair(vector<P>::iterator begin, vector<P>::iterator end){
    int now = end - begin;
    if(now <= 1) return INF;
    int m = now/2;
    auto mid = begin + now/2;
    int x = begin[m].F;
    int d = min(closest_pair(begin,mid),closest_pair(mid, end));
    inplace_merge(begin, mid, end, cmp);
    VP b;
    for(int i=0;i<now;i++){
        if(abs(begin[i].F-x) >= d) continue;
        for(int j=b.size()-1;j>=0;j--) {
            int dx = begin[i].F-b[j].F;
            int dy = begin[i].S-b[j].S;
            if(dy >= d)
                break;
            d = min(d,dx*dx+dy*dy);
        }
        b.push_back(begin[i]);
    }
    return d;
}

int main(){
    cin >> n;
    vector<P> a(n);
    for(int i=0;i<n;i++)
        cin >> a[i].F >> a[i].S;
    sort(a.begin(), a.end());
    cout << closest_pair(a.begin(), a.end()) << endl;
    return 0;
}

Measured memory_bytes: 10704
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int a, b;
    cin >> a >> b;
    if (a < 10 && b < 10) {
        cout << a * b << "\n";
    } else {
        cout << -1 << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <set>
#include <set>
#include <cstring>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <ctime>
#include <cmath>
#include <sstream>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main() {
	int n, r, ans;
	cin >> n >> r;
	if(n >= 10) {
		ans = r;
	}
	else {
		ans = r + 100 * (10 - n);
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.stream.Collectors;


public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        long n=scanner.nextLong();
        long m=scanner.nextLong();
        long d=scanner.nextLong();
        System.out.println(func(n,d)*(m-1)/Math.pow(n,2));
    }
    public static long func(long n,long d){
        if(d==0){
            return n;
        }
        return (n-d)*2;
    }
}

Measured memory_bytes: 23764
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int main(){
  int A,B;
  cin >> A >> B;
  if(A<=5){
    cout << 0 <<endl;
  }else if(A<=12){
    cout << B/2 <<endl;
  }else{
    cout << B <<endl;
  }

  
  return 0;
}

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

using namespace std;

int main(){
    int M,D;    
    
    cin >> M >> D;
    
    int cnt;
    for(int i = 22; i <= D; i++) {
        int d1 = i % 10;
        int d10 = i / 10;
        
        if(d1 < 2 || d10 < 2) continue;
        
        int m = d1 * d10;
        if(m <= M) {
            cnt++;
        }
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int k = sc.nextInt();
		int ans;
		if (k > 1) {
			ans = n - k;
		} else {
			ans = 0;
		}
		System.out.println(ans);

	}
}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int INF = 2e9;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
  string s;
  cin >> s;
  ll count0 = 0;
  ll count1 = 0;
  rep(i,sz(s)){
    if(i%2==0&&s[i]=='1'){
      count0++;
    }
    else if(i%2==1&&s[i]=='0'){
      count0++;
    }
  }
  rep(i,sz(s)){
    if(i%2==0&&s[i]=='0'){
      count1++;
    }
    else if(i%2==1&&s[i]=='1'){
      count1++;
    }
  }
  ll ans = min(count0, count1);
  print(ans);
}


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

#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
#define FILL0(x) memset(x,0,sizeof(x))

using namespace std;

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

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

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

    ll A, B;
    cin >> A >> B;

    ll BA = B-A+1;

    bool flag = false;
    bool pflag =false;
    if(A%2==1)
    {
        pflag=true;
        BA--;
    }

    if(BA%2==1)
    {
        BA--;
        flag=true;
    }
    ll ans = 0;
    if(BA%4!=0)
    {
        ans=1;
    }

    if(pflag)
    {
        ans^=A;
    }

    if(flag)
    {
        ans ^=  B;
    }

    cout << ans << endl;
    

    

 

 

    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 2000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	long long n, h;
	cin >> n >> h;
	vector<pair<long long, long long>> wow;
	REP(i, n) {
		long long a, b;
		cin >> a >> b;
		wow.push_back(make_pair(a, b));
	}
	sort(wow.begin(), wow.end(), greater<pair<long long, long long>>());
	long long sword = wow[0].first;
	long long kill = wow[0].second;
	vector<long long> to_bring;
	for (int i = 1;i < n;++i) {
		to_bring.push_back(wow[i].second);
	}
	sort(to_bring.begin(), to_bring.end(), greater<long long>());
	long long ans = 0;
	for (int i = 0;i < n - 1;++i) {
		if (max(sword, kill) >= h) {
			cout << ans + 1 << endl;
			return 0;
		}
		if (sword >= to_bring[i]) break;
		ans++;
		h -= to_bring[i];
	}
	if (max(sword, kill) >= h) {
		cout << ans + 1 << endl;
		return 0;
	}
	if (sword >= kill) {
		cout << ans + (h+sword-1) / sword << endl;
		return 0;
	}
	else {
		ans++;
		h -= kill;
		cout << ans + (h + sword - 1) / sword << endl;
		return 0;
	}
}

Measured memory_bytes: 3696
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    string t;

    cin >> t;

    for (int i = 0; i < t.size(); i++)
    {

        if (t[i] == '?')
        {
            t[i] = 'D';
        }
    }

    cout << t << endl;
}


Measured memory_bytes: 3752
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


int main(void)
{
	long int w, h, x, y;
	long int i, j;
	long int min = 10000;
	long int first = 0, last = 0;
	long int flg;
	long int l[100] = {0};
	double sum = 0;
	
	scanf("%ld%ld%ld%ld", &w, &h, &x, &y);
	
	if( (w % 2 == 0) && (x == w / 2) && (h % 2 == 0) && (y == h / 2) ) {
		printf("%lf 1\n", (double)w * h / 2);
	} else {
		printf("%lf 0\n", (double)w * h / 2);
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
string s="RGBY";
int n,i,j,x,y,d,m;
inline int read(){
	int x=0,f=1;
	char c;
	c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-') f=-1;
		c=getchar(); 
	}
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return x*f;
}
int main(){
	n=read();m=read();d=read();
	for(i=0;i<=n-1;i++){
	  for(j=0;j<=m-1;j++){
	 	 x=(m+i+j)/d%2;
	 	 y=(m+i-j)/d%2;
	 	 cout << s[2*x+y];
	 }
	 cout << endl;
    }
	return 0;
} 

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  int N; cin>>N;
  vector<int> a(N);
  rep(i,N) {
    cin>>a[i];
    --a[i];
  }

  bool can = false;
  int now = 0;    // start: 0, goal: 1
  int res = 0;
  rep(i,N) {
    now = a[now];
    ++res;
    if(now==1) {
      can = true;
      break;
    }
  }

  if(can) cout<<res<<endl;
  else cout<<-1<<endl;

  return 0;
}


Measured memory_bytes: 768
rate=380000.0 #yen/btc

n=int(input())
otoshidama=0
for i in range(n):
  x,u=map(str,input().split())
  if u == "JPY":
    otoshidama+=float(x)
  else:
    otoshidama+=float(x)*rate
print(otoshidama)

Measured memory_bytes: 2940
/*
// Sample code to perform I/O:

#include <iostream>

using namespace std;

int main() {
	int num;
	cin >> num;										// Reading input from STDIN
	cout << "Input number is " << num << endl;		// Writing output to STDOUT
}

// Warning: Printing unwanted or ill-formatted data to output will cause the test cases to fail
*/

// Write your code here
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define mod 1000000009
typedef pair<int,int> pp;
#define ff first 
#define ss second 
#define pb push_back
#define lb lower_bound 
#define ub upper_bound

int main(){ 
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
	    int x;
	    cin>>x;
	    if(i%2&&x%2) ans++;
	} 
	cout<<ans;
    
}

Measured memory_bytes: 3644
#include<iostream>
#include <numeric>
#include <algorithm>
#include<queue>
#include<vector>
using namespace std;
typedef pair<int, int> P;
int n, m, ans=0;

int main(){
  cin >> n;
  vector<int> x(n);
  vector<int> l(n);
  vector<P> ps(n);
  for(int i=0; i<n; i++){
    int a, b;
    cin >> a >> b;
    x[i] = a, l[i] = b;
    ps[i] = P(a+b, a-b);
  }
  sort(ps.begin(), ps.end());
  int cur = -1000000000;
  for(int i=0; i<n; i++){
    if(cur <= ps[i].second){
      ans++;
      cur = ps[i].first;
    }
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4832
function Main(input) {
    input = input.split("\n");
    var a = Number(input[0].split(' ')[1]) == 100 ? 101 : Number(input[0].split(' ')[1])
    var ans = Math.pow(100, Number(input[0].split(' ')[0])) * a
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long X = sc.nextLong();
		long K = sc.nextLong();
		long D = sc.nextLong();
		if (X < 0) X = -X;
		if (X * 1.0 / D > K) {
			System.out.println(X - K * D);
			return;
		}
		if ((X / D + K % 2) % 2 == 0) {
			System.out.println(X % D);
		} else {
			System.out.println(Math.abs(X % D - D));
		}
	}
}


Measured memory_bytes: 35864
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll M = 1e9 + 7;
int si[8] = {-1,0,1,-1,1,-1,0,1};
int sj[8] = {-1,-1,-1,0,0,1,1,1};

struct UnionFind {
  vector<int> d;
  // 子は親のIDを，根は木のサイズ*-1を持つ
  UnionFind(int n = 0): d(n,-1){}
  // rootを探索する
  int find(int x){
    if(d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  // 集合を統合する
  bool unite(int x, int y){
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  // 同じ集合に属しているか判定
  bool same(int x, int y) {return find(x) == find(y);}
  // xの属している集合のサイズを返す
  int size(int x) {return -d[find(x)];}
};

int main() {
  ll n, m;
  cin >> n >> m;
  UnionFind uf(n);
  vector<ll> a(m), b(m);
  rep(i, m) cin >> a[i] >> b[i];
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());

  ll ans = (n * (n-1)) / 2;
  vector<ll> v;
  rep(i, m){
    a[i]--;
    b[i]--;
    if (uf.same(a[i],b[i])){
      v.push_back(ans);
      continue;
    }
    ans -= uf.size(a[i]) * uf.size(b[i]);
    v.push_back(ans);
    uf.unite(a[i],b[i]);
  }

  v.pop_back();
  reverse(v.begin(), v.end());
  v.push_back((n * (n-1)) / 2);

  rep(i,v.size()) cout << v[i] << endl;

  return 0;
}


Measured memory_bytes: 6188
from collections import defaultdict

s = input()

cnt = defaultdict(int)
cnt[0] += 1
tmp = 0
for i, c in enumerate(s[::-1]):
    c = int(c)
    tmp = (tmp + c * pow(10, i, 2019)) % 2019
    cnt[tmp] += 1
# print(cnt)

print(sum(c * (c - 1) // 2 for c in cnt.values()))


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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  vector<int> dp(n+1,INF);
  dp[0] = -1;
  rep(i,n) {
    if(dp[a[i]-1] != INF) dp[a[i]] = min(dp[a[i]],i);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    if(dp[i] != INF) ans = i;
  }
  if(ans == 0) cout << -1 << endl;
  else cout << n - ans << endl;
  return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <cmath>

int cost_min(int n, std::vector<int> &h, std::vector<int> &dp) {
	int ret;
	if(dp[n - 1] > -1) ret = dp[n - 1];
	else if(n == 1) ret = 0;
	else if(n == 2) ret = std::abs(h[1] - h[0]);
	else {
		ret = std::min(
			cost_min(n - 1, h, dp) + std::abs(h[n - 1] - h[n - 2]),
			cost_min(n - 2, h, dp) + std::abs(h[n - 1] - h[n - 3])
		);
	}
	dp[n - 1] = ret;
	return ret;
}

int main(void) {
	// input
	int n;
	std::cin >> n;
	std::vector<int> h(n);
	std::vector<int> dp(n);
	for(int i = 0; i < n; ++i) {
		std::cin >> h[i];
		dp[i] = -1;
	}
	
	// dp
	int cost = cost_min(n, h, dp);

	std::cout << cost << std::endl;

	return 0;
}


Measured memory_bytes: 4096
s = gets.chomp

l = s.length

count = 0

#0101...
for i in 0..l-1 do
  if i.even? && s[i] == "1"
    count += 1
  end

  if i.odd? && s[i] == "0"
    count += 1
  end

end

min = count
count = 0

#1010...
for i in 0..l-1 do
  if i.even? && s[i] == "0"
    count += 1
  end

  if i.odd? && s[i] == "1"
    count += 1
  end

end

if count < min
  puts count
else
  puts min
end


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

void print(int n)
{
  n = n%10;
  if(n==2 || n==4 || n==5 || n==7 || n==9)
    cout << "hon";
  else if(n==0 || n==1 || n==6 || n==8)
    cout << "pon";
  else
    cout << "bon";
}

int main()
{
  int n;
  cin >> n;
  print(n);
  return 0;
}



Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#define _USE_MATH_DEFINES
#include <cmath>
#include <numeric>
#include <iomanip>
#include <deque>
#include <tuple>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <sstream>
#include <stdexcept>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define FOR(i, a, done) for (int i = (a); i < (done); ++i)
#define all(a) (a).begin(), (a).end()
#define x first
#define y second
#define debug(a) cout << (a) << endl
namespace mp = boost::multiprecision;
using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;
template <class T>
bool chmax(T &a, const T &b)
{
	if (a < b)
	{
		a = b;
		return 1;
	}
	return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
	if (a > b)
	{
		a = b;
		return 1;
	}
	return 0;
}

ll M = 1000000007;

void solve()
{
	int n;
	cin>>n;
	set<int>a;
	map<int,ll>cnta,cntb;
	rep(i,n){
		int h;
		cin>>h;
		int ite=i+1;
		if(ite>=h){
			cntb[ite-h]++;
		}
		if(ite+h<=2e5){
			cnta[ite+h]++;
			a.insert(ite+h);
		}
		
	}
	ll ans=0;
	for(auto i=a.begin(); i!=a.end();i++){
		int t=*i;
		ans+=(ll)cnta[t]*cntb[t];
	}
	cout<<ans<<endl;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	solve();
	return 0;
}


Measured memory_bytes: 28656
#include <stdio.h>

int main()
{
  int n;
  scanf("%d",&n);
  int d[n];
  int i;
  i = 0;
  while (i < n)
  {
    scanf("%d",&d[i]);
    i++;
  }
  qsort(n, d, 0, n - 1);

  int mid;
  mid = (n - 1) / 2;
  int len;
  len = getRange(d[mid], d[mid + 1]);
  printf("%d",len);
}

int getRange(int f, int l)
{
  int i;
  i = 0;
  while (i < l - f)
  {
    i++;
  }
  return (i);
}

void qsort(int len, int d[len], int f, int l)
{
  int i,j;
  i = f;
  j = l;
  int threshold;
  int tmp;
  threshold = d[(f+l)/2];
  while(1)
  {
    while (d[i] < threshold)
      i++;
    while (d[j] > threshold)
      j--;
    if (i >= j)
    {
      break;
    }
    tmp = d[i];
    d[i] = d[j];
    d[j] = tmp;
    i++;
    j--;
  }
  if (f < i - 1)
    qsort(len, d, f, i - 1);
  if (l > j + 1)
    qsort(len, d, j + 1, l);
}

Measured memory_bytes: 512
import java.io.*;
import java.util.*;


//I have to use hashset
public class Main{
    static int count =0;
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str;
        
        str = br.readLine();
        int n = Integer.parseInt(str);

        str=br.readLine();
        String[] temp = str.split("\\s");
        
        int[] A = new int[temp.length];
        for(int i= 0;i<temp.length;i++){
            A[i] = Integer.parseInt(temp[i]);
        }
        
        mergeSort(A,0,n);
        
        for(int i=0;i<A.length;i++){
            if( i != A.length -1){
                System.out.print(A[i] + " ");
            }else{
                System.out.println(A[i]);
            }
        }
        System.out.println(count);
        
    }

    public static void mg(int[] A,int left,int mid,int right){
        int n1 = mid -left;
        int n2 = right -mid;

        int[] L = new int[n1+1];
        int[] R = new int[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] = Integer.MAX_VALUE;
        R[n2] = Integer.MAX_VALUE;

        int i=0;
        int 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++;
            }
        }
    }
    
    public static void mergeSort(int[] A,int left,int right){
        if(left+1 < right){
            int mid = (left +right)/2;
            mergeSort(A,left,mid);//2この配列まで分ける
            mergeSort(A,mid,right);
            mg(A,left,mid,right);
        }
    }
     
}



Measured memory_bytes: 163368
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define debug_v(x) cerr << #x << " = [";REP(__ind,(x).size()){cerr << (x)[__ind] << ", ";}cerr << "] (L" << __LINE__ << ")" << endl;

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"debug.hpp"
#include"print.hpp"
#endif
// }}}

Int pow10_Int(Int a){
	Int ret = 1;
	REP(i,a)ret *= 10;
	return ret;
}

//{{{ main function
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char result;
	const Int N = pow10_Int(10);
	cout<<"? "<<N<<endl;
	cin>>result;
	if(result=='Y'){//N = 10^t
		Int t = 0;
		for(int l = 1;l<=10;l++){
			t*=10;t+=9;
			cout<<"? "<<t<<endl;
			cin>>result;
			if(result=='Y'){
				int t = l - 1;
				cout<<"! "<<pow10_Int(t)<<endl;
				break;
			}
		}
		return 0;
	}
	int d = -1;
	for(int i = 1;i<=10;i++){
		cout<<"? "<<pow10_Int(i)<<endl;
		cin>>result;
		if(result=='N'){
			d = i;
			break;
		}
	}
	assert(d>=0);
	// # of digits is d
	Int ans = 0;
	for(int i = d - 1;i >= 0;i--){
		int l = 0, r = 10;
		while(r-l>1){
			int m = (l+r)/2;
//			cerr<<"    "<<l<<" "<<r<<endl;
			Int t = (ans + m * pow10_Int(i))*10 + 9;
			cout<<"? "<<t<<endl;
			cin>>result;
			if(result=='Y'){
				r = m;
			}else{
				l = m;
			}
		}
		assert(r == l + 1);
		ans += l * pow10_Int(i);
//		cerr<<"ans: "<<ans<<endl;
	}
	cout<<"! "<<ans + 1<<endl;
	// Failed to predict input format
	return 0;
}

//}}}


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

int main(){
  int N; cin >> N;
  int a[N];
  int sum = 0;
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    sum += a[i];
  }
  int M; cin >> M;
  for(int i = 0; i < M; ++i) {
	int p, x; cin >> p >> x;
    cout << sum - a[p-1] + x << endl;
 
  }
  return 0; 
}


Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

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

using namespace std;
using ll = long long;
const int INF = 1<<30;

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

    vector<int> C(N);
    vector<vector<int>> A(12, vector<int>(12));
    
    rep(i, N) {
        cin >> C[i];
        rep (j, M) cin >> A[i][j];
    }

    int ans = INF;

    // bit 全探索（2 の N 乗通りのループ）
    rep(s, 1 << N) {
        // 各アルゴリズムの理解度の合計の配列
        vector<int> d(M);
        // このパターンのコスト
        int cost = 0;

        rep(i, N) {
            // i ビット目が立っているときだけ処理をおこなう
            if (s >> i & 1) {
                cost += C[i];
                rep(j, M) d[j] += A[i][j];
            }
        }
        // X に到達しない理解度が一つでもあれば NG
        bool ok = true;
        rep(i, M) if (d[i] < X) ok = false;

        // OK だった場合は ans を更新
        if (ok) {
            ans = min(ans, cost);
        }
    }

    if (ans == INF) ans = -1;

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


Measured memory_bytes: 3604
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n;
    cin >> n;
    vector<LL> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    LL ans = 0;
    if(n%2 == 0){
        ans -= a[n/2-1];
        ans += a[n/2];
        for(int i = 0; i < n/2-1; i++){
            ans -= a[i]*2;
        }
        for(int i = n/2+1; i < n; i++){
            ans += a[i]*2;
        }
    }else{

        LL t = 0;
        ans -= a[n/2];
        ans -= a[n/2-1];
        for(int i = 0; i < n/2-1; i++){
            ans -= a[i]*2;
        }
        for(int i = n/2+1; i < n; i++){
            ans += a[i]*2;
        }
        t += a[n/2];
        t += a[n/2+1];
        for(int i = 0; i < n/2; i++){
            t -= a[i]*2;
        }
        for(int i = n/2+2; i < n; i++){
            t += a[i]*2;
        }
        ans = max(t,ans);
    }

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

Measured memory_bytes: 1152
[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

[<EntryPoint>]
let main _ =
    let [n;x] = reads int
    let ls = reads int
    Seq.scan (+) 0 ls
    |> Seq.takeWhile (fun y -> y <= x)
    |> Seq.length
    |> printfn "%i"
    0

Measured memory_bytes: 14172
{-# OPTIONS_GHC -Wall #-}

readInt :: String -> Int
readInt = read

data Vec = Vec Double Double

instance Show Vec where
    show (Vec x y) = show x ++ " " ++ show y

add :: Vec -> Vec -> Vec
add (Vec x1 y1) (Vec x2 y2) = Vec (x1+x2) (y1+y2)

sub :: Vec -> Vec -> Vec
sub (Vec x1 y1) (Vec x2 y2) = Vec (x1-x2) (y1-y2)

mul :: Vec -> Double -> Vec
mul (Vec x y) c = Vec (c*x) (c*y)

rot :: Vec -> Double -> Vec
rot (Vec x y) t = Vec (x*cos t-y*sin t) (x*sin t+y*cos t)

koch :: Int -> Vec -> Vec -> [Vec]
koch 0 _ _ = []
koch n p1 p5 =
    koch (n-1) p1 p2 ++
    [p2] ++
    koch (n-1) p2 p3 ++
    [p3] ++
    koch (n-1) p3 p4 ++
    [p4] ++
    koch (n-1) p4 p5
        where
            v = mul (sub p5 p1) (1/3)
            p2 = add p1 v
            p3 = add p2 $ rot v (pi/3)
            p4 = add p2 v

main :: IO ()
main = do
    n <- fmap readInt getLine

    let p1 = Vec 0.0 0.0
    let p5 = Vec 100.0 0.0
    let ans = [p1] ++ koch n p1 p5 ++ [p5]

    mapM_ print ans



Measured memory_bytes: 4936
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef double db;
//mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
//int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head
int main() {
	string s,t;
	cin>>s>>t;
	
	
    int lenS=s.length();
    int lenT=t.length();
    
	int maxx=0,cnt=0;
	for(int i=0;i+lenT<=lenS;i++){
		cnt=0;
		rep(j,0,t.size() ){
			if(i+j>=s.size())continue;
			
			if(s[i+j]==t[j]){
				cnt++;
		 }
			maxx=max(cnt,maxx);
		}
	}
	printf("%d",t.size()-maxx);
} 

Measured memory_bytes: 3672
n = int(input())
h = [int(i) for i in input().split()]
cnts = []
start = 0
i = 1
while i < n:
    while h[i-1] >= h[i]: 
        i += 1
        if i >= n: break
    cnts.append(i - start - 1)
    start = i
    i += 1

print(max(cnts) if cnts != [] else 0)


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

const int N = 220000;

int a[N];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n, k; cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> a[i];
    int ans = 1;
    set<int> s;
    for (int i = 1; i < k; i++) s.insert(a[i]);
    for (int i = 1; i + k - 1 < n; i++) {
        if (!(a[i-1] < *s.begin() && *s.rbegin() < a[i+k-1])) ans++;
        s.erase(a[i]); s.insert(a[i+k-1]);
    }
    int cnt = 1;
    int rlt = 0;
    for (int i = 0; i < n-1; i++) {
        if (cnt == k) rlt++;
        if (a[i+1] > a[i]) cnt++;
        else cnt = 1;
    }
    if (cnt == k) rlt++;
    if (rlt) ans -= rlt-1;
    cout << ans << "\n";
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  ll dp[3][100010];
  for(int i=0;i<N;i++){
    int a,b,c;
    cin >>a>>b>>c;
    if(i==0){
      dp[0][i]=a;
      dp[1][i]=b;
      dp[2][i]=c;
    }
    else{
      dp[0][i]=max(dp[1][i-1],dp[2][i-1])+a;
      dp[1][i]=max(dp[0][i-1],dp[2][i-1])+b;
      dp[2][i]=max(dp[0][i-1],dp[1][i-1])+c;
    }
  }
  int ans=max(dp[0][N-1],max(dp[1][N-1],dp[2][N-1]));
  cout << ans <<endl;
}
            
  

Measured memory_bytes: 5912
#include <stdio.h>
int main(void){
    // Your code here!
    int N,M,C,i,j,num=0;
    scanf("%d %d %d",&N,&M,&C);
    int B[M];
    int sum[N];
    for(i=0;i<N;i++){
        sum[i]=0;
    }
    int A[N][M];
    for (i = 0; i< M; i++){
        scanf("%d",&B[i]);
    }
    for (i = 0; i< N; i++){
        for(j = 0; j<M;j++)
        scanf("%d",&A[i][j]);
    }
    for (i = 0; i< N; i++){
        for(j = 0; j<M;j++){
        sum[i]+= A[i][j]* B[j];
        }
        sum[i] += C;
        if(sum[i]>0)
        num++;
    }
    printf("%d",num);
}

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

int main() 
{
	long long int a;
	char c[13];
	cin>>a;
	cin>>c;
	if(a>=3200)
	{
		cout<<c<<endl;
	}
	else if(a<3200)
	{
		cout<<"red"<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long u_ll;
typedef pair<int, int> pair_;
 
const int INF = 1001001001;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int main(){
    
    int n;
    string s;

    cin >> n >> s;
    int res=0;
    rep(i,n-2){
        if((s[i]=='A')&&(s[i+1]=='B')&&(s[i+2]=='C')) res++;
    }

    cout << res;
    
    return 0;
}

Measured memory_bytes: 256
_q = int(input())
v = []
for _ in range(_q):
    *q, = map(int, input().split())

    if q[0] == 0:
        v.append(q[1])
    elif q[0] == 1:
        print(v[q[1]])
    elif q[0] == 2:
        v.pop()


Measured memory_bytes: 13360
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        n:usize,
        s:Chars,
    }

    let mut res = 0;
    for i in 0..1000 {
        let pass = vec![i / 10 / 10, i / 10 % 10, i % 10 % 10];
        let mut done = 0;
        for j in 0..n {
            if s[j] as usize - 48 == pass[done] {
                done += 1;
                if done == 3 {
                    res += 1;
                    break;
                }
            }
        }
    }

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


Measured memory_bytes: 2324
S = input()
K = int(input())
flag = False
count = 0
for i in range(len(S)-1):
    if not flag:
        if S[i] == S[i+1]:
            count += 1
            flag = True
    else:
        flag = False
ans = 0

if len(S) == 1:
    ans = K // 2
elif S.count(S[0]) == len(S) and len(S) % 2 == 1:
    ans += count
    ans += (count + count + 1) * (K // 2)
elif S[0] == S[-1] and not flag:
    ans += count
    count = 0
    for i in range(1, len(S)-1):
        if not flag:
            if S[i] == S[i+1]:
                count += 1
                flag = True
        else:
            flag = False
    ans += (count + 1)*(K-1)

else:
    ans = count * K
print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>

#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;

template<typename T>
T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return (a * b) / gcd(a, b);
}

int main()
{
    int a, b, c; cin >> a >> b >> c;
    string ans = "No";
    if (a <= c && c <= b) {
        ans = "Yes";
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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;}
const ll INF = 1LL<<60;
const ll M = 1000000007;
ll mpow(ll a,ll b){ll res=1;while(b!=0){if(b&1)res=res*a%M;a=a*a%M;b=b>>1;}return res;}
ll mcomb(ll n,ll k){if(k>n/2)return mcomb(n,n-k);ll res=1;for(ll i=0;i<k;i++){res=res*(n-i)%M;res=res*mpow(k-i,M-2)%M;}return res;}
/*template*/

int main()
{
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll turn=0;
  while(a>0 && c>0){
    if(turn==0){
      c-=b;
    }else{
      a-=d;
    }
    turn=1-turn;
  }
  cout<<(c<=0 ? "Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 3632
n=int(input())
p=[0 for i in range(n+1)]
for i in range(2,n+1):
    t=2
    a=i
    while t<=10:
        if(a%t==0):
            p[t]+=1
            a//=t
        else:
            t+=1
    p[a]+=1
d={2:0,4:0,14:0,24:0,74:0}
for i in p[2:]:
    if(i>=2):
        d[2]+=1
    if(i>=4):
        d[4]+=1
    if(i>=14):
        d[14]+=1
    if(i>=24):
        d[24]+=1
    if(i>=74):
        d[74]+=1
print((d[2]-2)*d[4]*(d[4]-1)//2+(d[4]-1)*d[14]+(d[2]-1)*d[24]+d[74])

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

int main() {
  string S, T;
  cin >> S >> T;
  if (T.size()-S.size()!=1){
    cout << "No" << endl;
  }
  else{
    
      if (S == T.erase(S.size())){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
  }
    
  
    
}

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

#define ll long long

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin >> s;
	int cnt = 0;
	int mx = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'R') cnt++;
		else cnt = 0;
		mx = max(cnt, mx);
	}
	cout << mx;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n;
    cin>>n;
    string ans="No";

    REP(i,9){
        REP(j,9){
            if((i+1)*(j+1)==n) ans="Yes";
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5+100;
int a[N];
int main()
{
	int n, k, q;
	while(cin >> n >> k >> q){
		memset(a,0,sizeof(a));
		int x;
		for(int i = 1; i <= q; i++){
			cin >> x;
			a[x]++;
		}
		for(int i = 1; i <= n; i++){
			if(a[i] + k - q > 0)
				printf("Yes\n");
			else
				printf("No\n");
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>

using namespace std;

const static int MAX_N = 100000;

int N;

int rec(int price, int cnt) {
  if (price < 6) {
    return cnt + price;
  } 

  int value_nine = 9;
  while (price >= value_nine) {
    value_nine *= 9;
  }
  value_nine /= 9;
  int value_six = 6;
  while (price >= value_six) {
    value_six *= 6;
  }
  value_six /= 6;

  if (price >= 6 && price < 0) {
    return rec(price - value_six, cnt + 1);
  } else {
    return min(rec(price - value_nine, cnt + 1), rec(price - value_six, cnt + 1));
  }
}

int main() {
  cin >> N;

  int ans = rec(N, 0);

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


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

#define FOR(i,a) for (int i=0; i<a; i++)

int main()
{

  int n; cin >> n;
  int data[n];
  FOR(i,n) cin >> data[i];
  int start = 0;
  int ans = 0;
  for (int i = 1; i < n; i++)
  {
      if(data[i] > data[i-1]) start = i;
      ans = max(ans, i-start);
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 640