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

const int maxn = 1e5 + 10;

int n, a[maxn];

int solve() {
	int ans = 0;
	
	for(int i = 1; i <= n; ++i) {
		if(a[i] != i)
			continue;
			
		int j = i;
		
		int total = 0;
		while(j <= n && a[j] == j) {
			++j;
			++total;
		}

		i = j - 1;
		
		ans += (total / 2) + (total % 2 != 0);
	}
	
	return ans;
}

int main() {
	scanf("%d", &n);
	
	for(int i = 1; i <= n; ++i)
		scanf("%d", &a[i]);
		
	printf("%d\n", solve());
	return 0;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

const yes = "Yes"
const no = "No"

func solve(n int64, k int64, q int64, as []int64) []bool {
	ret := make([]bool, n)
	ps := make([]int64, n)
	for _, a := range as {
		ps[a-1]++
	}
	for i, p := range ps {
		ret[i] = p+k-q > 0
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	n := nextInt()
	k := nextInt()
	q := nextInt()
	a := nextInts(q)
	for _, r := range solve(n, k, q, a) {
		if r {
			fmt.Fprintln(out, yes)
		} else {
			fmt.Fprintln(out, no)
		}
	}
}

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

func nextInt() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int64) []int64 {
	ret := make([]int64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int64) []float64 {
	ret := make([]float64, n)
	for i := int64(0); i < n; i++ {
		ret[i] = nextFloat()
	}
	return ret
}
func nextStrings(n int64) []string {
	ret := make([]string, n)
	for i := int64(0); i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func containStr(arr []string, target string) bool {
	for _, v := range arr {
		if v == target {
			return true
		}
	}
	return false
}

func PrintOut(src interface{}, joinner string) {
	switch reflect.TypeOf(src).Kind() {
	case reflect.Slice:
		s := reflect.ValueOf(src)
		for idx := 0; idx < s.Len(); idx++ {
			fmt.Fprintf(out, "%v", s.Index(idx))
			if idx < s.Len()-1 {
				fmt.Fprintf(out, "%s", joinner)
			} else {
				fmt.Fprintln(out)
			}
		}
	default:
		fmt.Fprintln(out, "orz")
	}
}

// mapからkeysとvaluesを返す
func splitKeyValue(m map[interface{}]interface{}) (keys, values []interface{}) {
	switch reflect.TypeOf(m).Kind() {
	case reflect.Map:
		s := reflect.ValueOf(m)
		for _, v := range s.MapKeys() {
			keys = append(keys, v)
			values = append(values, s.MapIndex(v))
		}
	default:
		fmt.Fprintln(out, "orz")
	}
	return
}


Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){
	while(1){
		int r, n; cin >> r >> n;
		if(!r && !n) break;
		int y[40] = {0};
		for(int i=0; i<n; i++){
			int xl, xr, h; cin >> xl >> xr >> h;
			for(int j=xl; j < xr; j++){
				y[j+20] = max(h, y[j+20]);
			}
		}

		double ans = 999;
		for(int i=-r+1; i<r; i++){
			int h = min(y[i+19], y[i+20]);
			double time = h + r - sqrt(r*r - i*i);
			ans = min(ans, time);
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3220
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

int main()
{
	ull x, y;
	cin >> x >> y;

	ull res = 0;
	for (ull i = x; i <= y; i*= 2)
	{
		res++;
	}

	cout << res << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>

using namespace std;

int h, w;


int board[410][410];	//0--黑色，1--白色 
int belongsTo[410][410];

struct Section	//每个区域为一个范围
{
	int id;	//编号
	long long numOfBlack;	//黑色块
	long long numOfWhite;	//白色块 
};
Section sections[160100];
int szSections;

struct Point
{
	int r, c;
};

int dr[4] = {-1, 1, 0, 0};
int dc[4] = { 0, 0,-1, 1};

void floodfill(int startR, int startC, int sectionFlag)
{
	sections[sectionFlag].id = sectionFlag;
	sections[sectionFlag].numOfBlack = 0;
	sections[sectionFlag].numOfWhite = 0;
	
	Point newPoint, curPoint;
	std::queue<Point> q;
	curPoint.r = startR;
	curPoint.c = startC;
	belongsTo[curPoint.r][curPoint.c] = sectionFlag;
	q.push(curPoint);
	
	while (!q.empty())
	{
		curPoint = q.front();
		q.pop();
		
		for (int d = 0 ; d < 4 ; d++)
		{
			newPoint.r = curPoint.r + dr[d];
			newPoint.c = curPoint.c + dc[d];
			
			if (0 <= newPoint.r && newPoint.r < h &&
			    0 <= newPoint.c && newPoint.c < w)	//范围内 
			{
				if (board[curPoint.r][curPoint.c] == board[newPoint.r][newPoint.c])	//颜色相等的剔除
					continue;
					
				if (belongsTo[newPoint.r][newPoint.c] != -1) 	//防止重复 
					continue;
					
				belongsTo[newPoint.r][newPoint.c] = sectionFlag;
				q.push(newPoint);
			}
		}
		
	}
}

int main()
{
	scanf("%d%d\n", &h, &w);
	char temp[410];
	
	for (int r = 0 ; r < h ; r++)
	{
		scanf("%s\n", temp);
		for (int c = 0 ; c < w ; c++)
		{
			if (temp[c] == '#')	//black
				board[r][c] = 0;
			if (temp[c] == '.')	//white
				board[r][c] = 1;
				
			belongsTo[r][c] = -1;
		}
	}
	
	szSections = 0;
	for (int r = 0 ; r < h ; r++)
	{
		for (int c = 0 ; c < w ; c++)
		{
			if (belongsTo[r][c] != -1)
				continue;
//			if (board[r][c] == 1)	//白色的不做
//				continue;
			 
			floodfill(r, c, szSections);
			szSections++;
		}
	}
	
	for (int r = 0 ; r < h ; r++)
		for (int c = 0 ; c < w ; c++)
		{
			int p = belongsTo[r][c];
			if (board[r][c] == 0)	//黑色
				sections[p].numOfBlack++;
			if (board[r][c] == 1)	//白色
				sections[p].numOfWhite++;
		}
	
	long long ans = 0;
	for (int i = 0 ; i < szSections ; i++)
	{
		ans = ans + sections[i].numOfBlack * sections[i].numOfWhite;
	}
	
	printf("%lld\n", ans);
	return 0;
}

//分片floodfill

Measured memory_bytes: 5248
n = gets.to_i
a = gets.split(/ /).map(&:to_i)
(1...n).each do |i|
    puts a.join(" ")
    v = a[i]
    j = i -1
    while j >= 0 && a[j] > v
        a[j+1] = a[j]
        j -= 1
    end
    a[j+1] = v
end
puts a.join(" ")

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

int main()
{
  int AB, BC, CA;
  cin >> AB >> BC >> CA;
  cout << (double)(AB * BC) / 2 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
	string a, b;
	cin >> a >> b;
	int temp = 1001;
	int q = 0;
	for (int i = 0; i <= a.length() - b.length(); i++) {
		q = 0;
		for (int j = 0; j < b.length(); j++) {
			
			//cout << a[i+j] << " " << b[j] << "\n";
			if (a[j+i] != b[j]) q++;
		}
		//cout << "\n";
		if (temp > q) temp = q;
	}
	cout << temp;

}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	vector<int> v(S.size(), 0);
	char f = 'R';
	int cnt = 0;

	for (int i = 0; i < S.size(); i++) {
		char ch = S[i];
		if (ch == 'R') cnt++;
		else {
			v[i] += cnt / 2;
			v[i - 1] += cnt - (cnt / 2);
			cnt = 0;
		}
	}

	cnt = 0;
	for (int i = S.size() - 1; i >= 0; i--) {
		char ch = S[i];
		if (ch == 'L') cnt++;
		else {
			v[i] += cnt / 2;
			v[i + 1] += cnt - (cnt / 2);
			cnt = 0;
		}
	}

	for (int i = 0; i < S.size(); i++) {
		if (i) cout << ' ';
		cout << v[i];
	}
	cout << endl;
}

Measured memory_bytes: 3848
s = (input().strip())
if s == 'SUN':
    print(7)
if s == 'MON':
    print(6)
if s == 'TUE':
    print(5)
if s == 'WED':
    print(4)
if s == 'THU':
    print(3)
if s == 'FRI':
    print(2)
if s == 'SAT':
    print(1)
    

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

int main(){
  vector<int> a(4);
  int ans = 0,j = 0;
  for(int i = 0; i < 5; i++){
    cin >> a[i];
    if(a[i]%10 == 0) ans+=a[i];
    else{
      ans =ans + a[i] +10 - a[i]%10;
      j = max(j,10-a[i]%10); 
    }
  }
  cout << ans-j << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long MOD = 1000000007LL; // 998244353LL;

// Repeat
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
// Container Util
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort((v).begin(),(v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())

int main() {
    int A,B,C; cin >> A >> B >> C;
    vector<int> x = {A,B,C};
    SORT(x);
    if (x[0] + x[1] == x[2]) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
using namespace std;
#define ll int64_t
#define REP(i, n) for (ll i=0; i<n; i++)

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

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

    if (A == B && B == C) cout << "Yes" << "\n";
    else cout << "No" << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define vul vector<ull>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi2d vector<vi >
#define vl2d vector<vl >
#define vpll vector<pll >

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rz resize
#define fr(i,n) for(i=0;i<(n);i++)
#define frr(i,n) for(i=(n-1);i>=0;i--)
#define fre(i,n) for(i=0;i<=(n);i++)
#define frre(i,n) for (i=(n);i>=0;i--)
#define frab(i,a,b) for(i=(a);i<(b);i++)
#define freab(i,a,b) for(i=(a);i<=(b);i++)
#define frrab(i,a,b) for(i=(b-1);i>=a;i--)
#define frreab(i,a,b) for(i=(b);i>=a;i--)

#define sz(a) int((a).size())
#define mset(a,b) (memset(a,b,sizeof(a)))
#define max3(a,b,c) (max((a),max((b),(c))))
#define min3(a,b,c) (min((c),min((a),(b))))
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector <ll> sprime;
vector<char> prime (1000000, true);
void sieve(ll n)
{
  //O(nloglogn) time
  sprime.pb(0);
  prime[0] = prime[1] = false;
  ll cnt = 0;
  for (ll i = 2; i <= n; ++i)
  {
    if (prime[i])
    {
      cnt++;
      sprime.pb(i);
      for (ll j = 2 * i; j <= n; j += i)
        prime[j] = false;
    }
  }
}
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p, ll MOD) { if (p == 0) return 1; ll z = fastpowMOD(a, p / 2, MOD); z = (z * z) % MOD; if (p % 2) z = (z * a) % MOD; return z; }
ll fastpow(ll a, ll p) { if (p == 0) return 1; ll z = fastpow(a, p / 2); z = (z * z); if (p % 2) z = (z * a); return z; }

#define mod 1000000007
#define inf LLONG_MAX
#define minf LLONG_MIN
#define pi 3.14
#define ex 2.71

//*********************************************///
const int N = 1e5 + 5;
int i,j;
char c[1005][1005];
ll dp[1005][1005];

void solve()
{
  int h,w;
  cin>>h>>w;
  freab(i,1,h)
    freab(j,1,w)
    {
      cin>>c[i][j];
      if(c[i][j]=='#')
        dp[i][j]=0;
    }
  dp[1][1]=1;

  freab(i,2,w)
    if(c[1][i]=='.')
      dp[1][i]=dp[1][i-1];

  freab(i,2,h)
  {
    if(c[i][1]=='.')
      dp[i][1]=dp[i-1][1];
    freab(j,2,w)
    {
      if(c[i][j]=='#')
        continue;
      dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
    }
  }
  cout<<dp[h][w]%mod<<endl;
}

int main()
{
  fast;
  int z;
  //cin>>z;
  z=1;
  while(z--)
  {
    solve();
  }
  return 0;
}


Measured memory_bytes: 10112
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define lowbit(x) (x&(-x))
#define rep(i,x,y) for(int i=x;i<=y;i++)
#define drep(i,x,y) for(int i=x;i>=y;i--)
#define repg(i,x) for(int i=p[x];i;i=e[i].nt)  
using namespace std;
typedef long long LL;
LL read(){
	LL rtn=0;char ch=getchar();
	while(ch>'9'||ch<'0')ch=getchar();
	while(ch<='9'&&ch>='0')rtn=(rtn<<3)+(rtn<<1)+ch-'0',ch=getchar();
	return rtn;
}
const int N=110;
const LL mod=1e9+7;
int n,last[250],f[N];
char ch[N];
int main(){
#ifdef WK
	freopen("in.txt","r",stdin);
#endif
	scanf("%s",ch+1);n=strlen(ch+1);
	int ans=1e9;
	for(int i=1;i<=n;i++){
		f[i]=max(f[i],f[last[ch[i]]]);
		f[i]=max(f[i],i-last[ch[i]]-1);
		last[ch[i]]=i;
	}
	for(int i=1;i<=n;i++)f[i]=max(f[i],n-i);
	for(int i=1;i<=n;i++)ans=min(ans,f[i]);
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int n,m,sum=0;
    cin >> n >>m;
    vector<int> k;
    vector< vector<int> > A;
    A.resize(n);
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        k.push_back(tmp);
        A[i].resize(m);
        for(int j=0;j<k[i];j++){
            int t;
            cin >> t;
            A[i][t-1] = 1;
        }
    }
    for(int i=0;i<m;i++){
        int s = 0;
        for(int j=0;j<n;j++){
            if(A[j][i]==1){
                s++;
            }
        }
        if(s==n){
            sum++;
        }
    }
    printf("%d\n",sum);
}

Measured memory_bytes: 256
// Garg's Code
#include <bits/stdc++.h>
#include <string.h>
using namespace std;
 
#define ll long long
#define vec vector < ll >
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++)
#define rf(i,x,n) for(ll i = x; i >= x; i--) 
#define all(c) c.begin(),c.end()
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const ll MAX = LLONG_MAX, mod = 1000000007, MODA = 1e9 - 1;
const ll MIN = LLONG_MIN;
const long double PI = 3.1415926535;
const ll N = 400009;

int main()
{
  fast();

  
  ll n, k;
  cin >> n >> k;
  ll arr[n];
  f(i,0,n)
  {
    cin >> arr[i];
  }
  sort(arr, arr+n);
  ll ans = 0;
  for(ll i = max(-1ll, n - 1 - k); i >= 0; i--)
  {
    ans += arr[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1792
/*#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(void){
	long long N,Q,x,y,cnt=0;
	long long c[300010],so[300010];
	bool   
	for(long long i=0;i<300000;i++){
		c[i]=1000000001;
		so[i]=c[i];
	}
	cin>>N;
	for(long long i=0;i<N;i++){
		cin>>c[i];
		so[i]=c[i];
	}
	sort(so,so+N);
	for(int i=0;i<N;i++)
	{
		if(so[i]==c[i])cnt++;
		else{cnt--;}
	}
	if(cnt==0)cnt1=0;
	cnt1++;
	while()
	return 0;
}*/
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int main(void){
	int n;
	cin>>n;
	int a[n],b[n],c[n]={},cnt=0;
	r(i,n)cin>>a[i],b[i]=a[i];
	sort(b,b+n);
	r(i,n)if(a[i]==b[i])c[i]=1,cnt++;
	if(cnt==n){
		cout<<0<<endl;
		return 0;
	}
	int m;
	cin>>m;
	r(i,m){
		int l,r;
		cin>>l>>r;l--;r--;
		if(a[l]==b[l])cnt--;
		if(a[r]==b[r])cnt--;
		if(a[l]==b[r])cnt++;
		if(a[r]==b[l])cnt++;
		swap(a[l],a[r]);
		if(cnt==n){
			cout<<i+1<<endl;
			return 0;
		}
		
	}
	cout<<-1<<endl;
}


Measured memory_bytes: 6672
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int n, m, a, b; cin >> n >> m;
	int test[123456] = { 0 };
	for (int h = 0; h < m; h++) {
		cin >> a >> b;
		test[a]++; test[b]++;
	}
	for (int h = 1; h <= n; h++) {
		if (test[h] % 2 != 0) {
			cout << "NO" << endl;
			cin >> n; return 0;
		}
	}
	cout << "YES" << endl;
	cin >> n;
}


Measured memory_bytes: 768
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <map>
#include <queue>
using namespace std;

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

int n, m, u, v;
int a[100050], fa[100050];

int find(int x){
	if(fa[x] == x) return x;
	else return fa[x] = find(fa[x]);
}
 
int main(){
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= n; i ++){
		scanf("%d", &a[i]);
		fa[i] = i;
	}
	for(int i = 1; i <= m; i ++){
		int u, v;
		scanf("%d %d", &u, &v);
		fa[find(u)] = find(v);
	}
	int res = 0;
	for(int i = 1; i <= n; i++){
		if(find(i) == find(a[i])) res++;
	}
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main()
{
    int t;
    cin>>t;
  char a[101],b[101],rez[202];
    cin>>a;cin >> b;
    for(int i=0; i< t*2; ++i)
    {
        if(i%2==0)
        rez[i]=a[i/2];
        else rez[i] = b[i/2];
    }
    for(int i=0; i<t*2; ++i)
        cout<<rez[i];
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
using namespace std;
int conut;
int n,N[100000];
int q, Q[50000];
int count = 0;

int binarySearch(int key) {
    int left = 0;
    int right = n;

    while(left < right) {
        int mid = (left + right) / 2;
        if (N[mid] == key) {
            count++;
            break;
        } //A little bit different.
        else if (key < N[mid]) right = mid;
        else left = mid + 1;
    }
    return count;
}

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

    cin >> q;
    for (int j = 0; j< q; j++) {
        cin >> Q[j];
    }

    for (int j = 0; j < q; j++) {
        int key = Q[j];
        binarySearch(key);
    }
    cout << count << endl;
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  
  if((a + b) == (c+d)){
    cout << "Balanced" << endl;
  }else if ( (a+b) > (c+d) ){
    cout << "Left" << endl;
  }else if ( (a + b) < (c + d) ){
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
b=A[0]

if(A.count(0)!=0):
    print('0')
    exit()

for i in range(1,len(A)):
    b=b*A[i]
    if(10**18<b):

        print('-1')
        exit()
        
print(b)


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

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

    int t, d, l;
    while (cin >> t >> d >> l) {
        if (t == 0) break;
        int last = -1e9;
        int cnt = 0;
        for (int i = 0; i < t; i++) {
            int a;
            cin >> a;
            if (i == t - 1) continue;
            if (a >= l) {
                last = i;
                cnt++;
            } else if (i - last < d) cnt++;
        }
        cout << cnt << '\n';
    }
}



Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;

int main(){

	int n,m,l;

	cin >> n >> m >> l;

	vector < vector < int> > A(n, vector <int>(m, 0));
	vector < vector < int> > B(m, vector <int>(l, 0));
	vector < vector < long > > C(n, vector <long>(l, 0));


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

	for (int i = 0; i < m; i++){
		for (int j = 0; j < l; j++){
			cin >> B[i][j];
		}
	}

	for (int i = 0; i < n; i++){
		for (int j = 0; j < l; j++){
			for (int k = 0; k < m; k++){
				C[i][j] += A[i][k] * B[k][j];
			}
			cout << C[i][j];
			if (j != l - 1) cout << " ";
		}
		cout << endl;
	}


	return 0;
}

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

const ll p = 1e9+7;

ll n, dp[5005][5005];
string s;

int main() {
	cin >> n >> s;
	dp[0][0] = 1;
	for (int i = 0; i <= n-1; ++i)
		for (int k = 0; k <= n; ++k) {
			dp[i+1][k+1] = (dp[i+1][k+1] + 2*dp[i][k])%p;
			dp[i+1][max(k-1, 0)] = (dp[i+1][max(k-1, 0)] + dp[i][k])%p;
		}
	ll ans = dp[n][s.length()];
	for (int i = 0; i < s.length(); ++i)
		ans = ans*(p+1)/2%p;
	cout << ans << endl;
}


Measured memory_bytes: 195712
#include<bits/stdc++.h>
using namespace std;
void *wmem;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline int rd(char c[]){
  int i, sz=0;
  for(;;){
    i = getchar_unlocked();
    if(i!=' '&&i!='\n'&&i!='\r'&&i!='\t'&&i!=EOF){
      break;
    }
  }
  c[sz++] = i;
  for(;;){
    i = getchar_unlocked();
    if(i==' '||i=='\n'||i=='\r'||i=='\t'||i==EOF){
      break;
    }
    c[sz++] = i;
  }
  c[sz]='\0';
  return sz;
}
inline void rd(string &x){
  char *buf=(char *)wmem;
  rd(buf);
  x = buf;
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmax(S &a, T b){
  if(a<b){
    a=b;
  }
  return a;
}
char memarr[96000000];
int N;
int M;
string S;
int main(){
  int i, res=0;
  map<string,int> mp;
  map<string,int>::iterator it;
  wmem = memarr;
  rd(N);
  for(i=0;i<N;i++){
    rd(S);
    mp[S]++;
  }
  rd(M);
  for(i=0;i<M;i++){
    rd(S);
    mp[S]--;
  }
  for(it=mp.begin(); it!=mp.end(); it++){
    chmax(res, it->second);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, M;
// string S;
// {
//   int i, res = 0;
//   map<string,int> mp;
//   map<string,int>::iterator it;
// 
//   rd(N);
//   rep(i,N){ rd(S); mp[S]++; }
//   rd(M);
//   rep(i,M){ rd(S); mp[S]--; }
// 
//   for(it=mp.begin(); it!=mp.end(); it++) res >?= it->second;
// 
//   wt(res);
// }


Measured memory_bytes: 256
bingo = [[int(i) for i in input().split()] for _ in range(3)]
N= [int(i) for i in input().split()][0]
bn =[int(input()) for _ in range(N)]

array = [[0 for _ in range(3)] for _ in range(3)]

for i in range(3):
  for j in range(3):
    a = bingo[i][j]
    for b in bn:
      if a == b:
        array[i][j] = 1
bing = False
cor1 = 0
cor2 = 0
for i in range(3):
  cor1 += array[i][i]
  cor2 += array[i][2-i] 
  sum1 = 0
  sum2 = 0
  for j in range(3):
    sum1 += array[i][j]
    sum2 += array[j][i]
  if sum1 == 3 or sum2 == 3:
    bing = True
if cor1 == 3 or cor2 == 3:
  bing = True
    
print("Yes" if bing else "No")
  



Measured memory_bytes: 3064
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

func init() {
	sc.Split(bufio.ScanWords)
}

func partition(A []int, p, r int) int {
	x := A[r]
	i := p - 1
	for j := p; j < r; j++ {
		if A[j] <= x {
			i++
			A[i], A[j] = A[j], A[i]

		}
	}
	A[i+1], A[r] = A[r], A[i+1]
	return i + 1
}

func main() {
	n := scanInt()
	A := make([]int, n)
	for i := range A {
		A[i] = scanInt()
	}

	index := partition(A, 0, n-1)
	buf := bytes.Buffer{}
	for i, e := range A {
		if i == index {
			buf.WriteString("[")
			buf.WriteString(strconv.Itoa(e))
			buf.WriteString("]")
		} else {
			buf.WriteString(strconv.Itoa(e))
		}
		buf.WriteString(" ")
	}
	fmt.Println(strings.TrimRight(buf.String(), " "))
}



Measured memory_bytes: 4856
using System;
using System.Linq;

namespace _0614
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int[] use = new int[x[0]];
            int[] p = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int i = 1; i < x[1]; i++)
            {
                use[Math.Min(p[i - 1],p[i]) - 1]++; use[Math.Max(p[i - 1],p[i]) - 1]--;
            }
            long ret = 0; long sum = 0;
            for (int i = 0; i < x[0] - 1; i++)
            {
                sum += use[i];
                int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                ret += Math.Min(a[0] * sum,a[1] * sum + a[2]);
            }
            Console.WriteLine(ret);
        }
    }
}


Measured memory_bytes: 18524
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++)cin >> A[i] >> B[i];

    long long maxV = *max_element(A.begin(), A.end());
    long long minV = *min_element(B.begin(), B.end());

    cout << maxV + minV << endl;

}















































Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string.h>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<cstdio>
#include<vector>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn=200;
int main()
{
	int n,a[55],cnt[55],k=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]!=i)
		{
			if(k>=2)
			{
				cout<<"NO"<<endl;
				return 0;
			}
			cnt[k++]=i;
		}
	}
	if(k==1)
	{
		cout<<"NO"<<endl;
		return 0;
	}
	else if(k==0)
	{
		cout<<"YES"<<endl;
	}
	else
	{
		if(a[cnt[0]]==cnt[1]&&a[cnt[1]]==cnt[0])
			cout<<"YES"<<endl;
		else cout<<"NO"<<endl; 
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  ll a,b,c; cin >>a >>b >>c;
  ll res = 0;
  if (c > a + b + 1) c = a + b + 1;
  res = b + c;
  cout <<res <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

void func(Int n, vector<double> &ex, vector<vector<Int>> &g, Int f, Int t){
	ex.assign(n, 0.0);
	for(Int i=n-2; i>=0; --i){
		Int cnt = 0;
		for(Int j=i+1; j<n; ++j)
			if(g[i][j] == 1 && (i != f || j != t))
				++cnt;
		for(Int j=i+1; j<n; ++j)
			if(g[i][j] == 1 && (f != i || t != j))
				ex[i] += (ex[j] + 1) / cnt;
		if(cnt == 0) ex[i] = 1e10;
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n, m; cin >> n >> m;
	vector<vector<Int>> g(n, vector<Int>(n, 0));
	for(Int i=0; i<m; ++i){
		Int s, t; cin >> s >> t;
		g[s-1][t-1] = 1;
	}
	vector<double> ex(n);
	func(n, ex, g, -1, -1);
	double ans = ex[0];
//	cerr << ans << "\n";
//	for(Int i=0; i<n; ++i)
//		cerr << i << " " << ex[i] << "\n";
	vector<Int> w(n-1, -1);
	for(Int i=0; i<n-1; ++i)
		for(Int j=i+1; j<n; ++j)
			if(g[i][j] == 1 && (w[i] == -1 || ex[w[i]] < ex[j]))
				w[i] = j;
	for(Int i=0; i<n-1; ++i){
		func(n, ex, g, i, w[i]);
		ans = min(ans, ex[0]);
//		cerr << i << " " << w[i] << " " << ex[0] << " " << ans << "\n";
//		if(i == 6)
//			for(Int j=0; j<n; ++j)
//				cerr << j << " " << ex[j] << "\n";
	}
	cout << fixed << setprecision(10) << ans << "\n";
}

Measured memory_bytes: 3072
#include <iostream>
#include <algorithm>
#include <iomanip>

using namespace std;

double dp[3001][3001]; //i枚のうち裏がj枚

int main() {
    dp[0][0] = 1.0;

    int n;
    cin >> n;
    double p;
    for(int i=1;i<=n;++i) {
        cin >> p;
        dp[i][0] = dp[i-1][0] * p;
        for(int j=1;j<=i;++j) {
            dp[i][j] = dp[i-1][j] * p + dp[i-1][j-1] * (1.0-p);
        }
    }

    double ans = 0.0;
    for(int j=0;j<=n/2;++j) ans += dp[n][j];
    cout << setprecision(12) << ans << "\n";
}

Measured memory_bytes: 68864
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    string s; cin >> s;
    stack<char> st;
    REP(i,s.size()) {
        if (!st.empty() && st.top() != s[i]) st.pop();
        else st.push(s[i]);
    }

    OUT(s.size() - st.size())

    return 0;
}

Measured memory_bytes: 512
use std::io::*;
use std::str::FromStr;

struct Scanner<R: Read> {
    reader: R,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }

    fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        let token = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            token.parse::<T>().ok()
        }
    }

    fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            writeln!(stderr(), "Terminated with EOF").unwrap();
            std::process::exit(0);
        }
    }
}

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let n: u32 = sc.read();
    let mut max: i64 = -1_000_000;
    let mut min: i64 = 1_000_000;
    let mut sum: i64 = 0;
    for _ in 0..n {
        let a: i64 = sc.read();
        if a > max {
            max = a;
        }
        if a < min {
            min = a;
        }
        sum += a;
    }
    println!("{} {} {}", min, max, sum);
}


Measured memory_bytes: 5056
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        final int W = sc.nextInt(),H = sc.nextInt(),x = sc.nextInt(),y = sc.nextInt(),r = sc.nextInt();
        sc.close();
        if(x - r < 0 || W < x + r || y - r < 0 || H < y + r) System.out.println("No");
        else System.out.println("Yes");
    }

}

Measured memory_bytes: 26276
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt(); //N問
		int M = sc.nextInt(); //M回提出
		//(Pi, penaの数or正解-1)
		Map<Integer, Integer> map = new HashMap<>();
		int ans = 0;
		int pena = 0;
		int p;
		String r;
		int re;
		for(int i = 0; i < M; i++) {
		    p = sc.nextInt();
		    r = sc.next();
		    if(r.equals("AC")) {
		        re = -1;
		    }else {
		        re = 1;
		    }
		     //すでに回答している問題
		    if(map.containsKey(p)) {
		        // WA
		        if(re == 1) {
		            if(map.get(p) != -1) {
		                map.put(p, map.get(p)+1);
		            }
		        //AC
		        }else {
		            //初めて正解
		            if(map.get(p) != -1) {
		                pena += map.get(p);
		                ans++;
		                map.put(p, -1);
	                //すでに正解
		            }
		        }
		    //新しい問題
		    }else {
		        //WA
		        if(re == 1) {
		            map.put(p, 1);
	            //AC
		        }else {
		            map.put(p, -1);
		            ans++;
		        }
		    }
		}
		
		System.out.println(ans+" "+pena);
		
	}
}


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

const int M = 1e9+7;

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

    int n , k;
    cin >> n >> k;
    cout << min(n%k , k - (n%k)) << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string st[110];
int w,h;
int main()
{
    cin>>w>>h;
    for(int i=1; i<=w; i++)
        cin>>st[i];
    for(int i=1; i<=w; i++)
    {
        cout<<st[i]<<endl;
        cout<<st[i]<<endl;
    }
    return 0;
}

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

int main(){
	
	int n;
	cin>>n;
	vector<int> v(n+1);
	for(int i=0;i<n;++i){
		cin>>v[i];
	}
	vector<int> dp(n+1,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;++i){
		for(int j=i+1;j<n && j<=i+2;++j){
			dp[j]=min(dp[j],abs(v[j]-v[i])+dp[i]);
		}
	}
	cout<<dp[n-1];
	return 0;
}


Measured memory_bytes: 3860
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<utility>
#include<functional>
#include<cmath>
#include<vector>
#include<assert.h>
//using namespace std;
using std::min;
using std::max;
using std::swap;
using std::sort;
using std::reverse;
using std::random_shuffle;
using std::lower_bound;
using std::upper_bound;
using std::unique;
using std::vector;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair<int,int> pii;
typedef std::pair<ll,ll> pll;
void open(const char *s){
#ifndef ONLINE_JUDGE
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
void open2(const char *s){
#ifdef DEBUG
	char str[100];sprintf(str,"%s.in",s);freopen(str,"r",stdin);sprintf(str,"%s.out",s);freopen(str,"w",stdout);
#endif
}
int rd(){int s=0,c,b=0;while(((c=getchar())<'0'||c>'9')&&c!='-');if(c=='-'){c=getchar();b=1;}do{s=s*10+c-'0';}while((c=getchar())>='0'&&c<='9');return b?-s:s;}
void put(int x){if(!x){putchar('0');return;}static int c[20];int t=0;while(x){c[++t]=x%10;x/=10;}while(t)putchar(c[t--]+'0');}
int upmin(int &a,int b){if(b<a){a=b;return 1;}return 0;}
int upmax(int &a,int b){if(b>a){a=b;return 1;}return 0;}
const int N=100010;
vector<int> s[N];
int main()
{
	int n;
	scanf("%d",&n);
	int k=-1;
	for(int i=1;i<=10000;i++)
		if(i*(i-1)/2==n)
		{
			k=i;
			break;
		}
	if(k==-1)
	{
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	printf("%d\n",k);
	int t=0;
	for(int i=1;i<=k;i++)
		for(int j=i+1;j<=k;j++)
		{
			s[i].push_back(++t);
			s[j].push_back(t);
		}
	for(int i=1;i<=k;i++)
	{
		printf("%d ",k-1);
		for(int j=0;j<k-1;j++)
			printf("%d ",s[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 4608
use std::io;
use std::str::FromStr;
use std::collections::HashSet;

fn input<T:FromStr>() -> T {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.trim().parse().ok().unwrap()
}

fn main() {
    let mut s: u64 = input();
    let mut set: HashSet<u64> = HashSet::new();
    let mut count = 1;
    loop {
        if set.contains(&s) {
            println!("{}", count);
            break;
        }
        set.insert(s);
        if s % 2 == 0 {
            s /= 2;
        } else {
            s = s * 3 + 1;
        }
        count += 1;
    }
}


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

using namespace std;

int n,w;

void solve(){
    cin >> n >> w;
    vector<long long> dp(100001,w+1);
    vector<int> ww(n),v(n);
    for(int i = 0;i < n;i++) cin >> ww[i] >> v[i];
    dp[0] = 0;
    for(int i = 0;i < n;i++){
        for(int j = dp.size()-1;j >= 0;j--){
            if(dp[j] < w){
                dp[j+v[i]] = min(dp[j+v[i]],dp[j]+ww[i]);
            }
        }
    }
    int ans;
    for(ans = dp.size()-1;ans >= 0;ans--) if(dp[ans] <= w) break;
    cout << ans << endl;
}

int main(){
    solve();
}


Measured memory_bytes: 1024
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
    int n,k;
    while(cin>>n>>k)
    {
        long long t=0,s=1,a,b;
        while(1)
        {
            a=s*2;
            b=s+k;
            if(a<b)
                s=a;
            else
                break;
            t++;
            if(t>=n)
                break;
        }
        s+=(n-t)*k;
        cout<<s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(int i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1<<30;
typedef long double ld;
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 dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
int main(){
  int n;  string s;
  cin >> n >> s;
  vector<set<int> > v(10);
  rep(i,0,n){
    v[s[i]-'0'].insert(i);
  }
  int ans = 0;
  rep(i,0,10)rep(j,0,10)rep(k,0,10){
    int pos = -1;
    if(v[i].upper_bound(pos) == v[i].end()) continue;
    pos = *v[i].upper_bound(pos);
    if(v[j].upper_bound(pos) == v[j].end()) continue;
    pos = *v[j].upper_bound(pos);
    if(v[k].upper_bound(pos) == v[k].end()) continue;
    ans++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int n=0;
  ll m=1000;
  cin >> n;
  vi a(n);
  rep(i,n) cin >> a[i];
  a.push_back(0);
  int l=0;
  int r=0;
  rep(i,n+1){
    if(a[i]<a[r]){
      m=m%a[l]+m/a[l]*a[r];
      l=i;
      r=i;
    }
    if(a[i]>a[r]){
      r=i;
    }
  }
  cout << m;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    vector<int> vec(N);
    rep(i,N){
        cin >> vec[i];
    }
    int ans = max(vec[0], -1 * vec[0]);
    rep(i,N - 1){
        ans += max(vec[i + 1] - vec[i], vec[i] - vec[i + 1]);
    }
    ans += max(vec[N - 1], -1 * vec[N - 1]);
    int ans_copy = ans;
    ans_copy += (max(vec[1], -1 * vec[1]) - max(vec[0], -1 * vec[0]) - max(vec[1] - vec[0], vec[0] - vec[1]));
    cout << ans_copy << endl;
    rep(i,N - 2){
        ans_copy = ans;
        ans_copy += (max(vec[i + 2] - vec[i], vec[i] - vec[i + 2]) - max(vec[i + 2] - vec[i + 1], vec[i + 1] - vec[i + 2]) - max(vec[i + 1] - vec[i], vec[i] - vec[i + 1]));
        cout << ans_copy << endl;
    }
    ans_copy = ans;
    ans_copy += max(vec[N - 2], -1 * vec[N - 2]) - max(vec[N - 1], -1 * vec[N - 1]) - max(vec[N - 2] - vec[N - 1], vec[N - 1] - vec[N - 2]);
    cout << ans_copy << endl;
}


Measured memory_bytes: 1664
#include <stdio.h>

int main(void){
    int a, b;
    int slot = 1;
    int count = 0;
    scanf("%d %d", &a, &b);

    while (slot < b){
        slot = 1 + (a-1) * (count+1);
        count += 1;
    }
    printf("%d\n", count);

    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int r = sc.nextInt();
        int g = sc.nextInt();
        int b = sc.nextInt();

        if ((g * 10 + b) % 4 == 0) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


Measured memory_bytes: 21332
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;

int a,b,c;
int tot;
string s;
int main(){
	cin >> s;
	int len = s.size();
	for(int i = 0; i < len; i++){
		if(s[i] == '0') a++;
		else b++;
	}
	cout << min(a,b)*2;
}
 

Measured memory_bytes: 512
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int MOD = 1000000007;
const int MOD1 = 998244353;
const int maxn = 100010;
const int lim = (int)1e9;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	int n = s.length();
	vector<vector<lli> > dp(n + 1, vector<lli>(13, 0ll));
	dp[0][0] = 1ll;
	for (int i = 0; i < n; ++i)
		for (int j = 0; j < 13; ++j)
		{
			if (s[i] == '?')
			{
				for (int k = 0; k < 10; ++k)
				{
					dp[i + 1][(j * 10 + k) % 13] = (dp[i][j] + dp[i + 1][(j * 10 + k) % 13]) % MOD;
					if (dp[i + 1][(j * 10 + k) % 13] < 0ll)
						dp[i + 1][(j * 10 + k) % 13] += MOD;
				}
			}
			else
			{
				dp[i + 1][(j * 10 + (int)(s[i] - '0')) % 13] = (dp[i][j] + dp[i + 1][(j * 10 + (int)(s[i] - '0')) % 13]) % MOD;
				if (dp[i + 1][(j * 10 + (int)(s[i] - '0')) % 13] < 0ll)
					dp[i + 1][(j * 10 + (int)(s[i] - '0')) % 13] += MOD;
			}
		}
	cout << dp[n][5] << endl;
}

Measured memory_bytes: 16612
A, B, C, D = list(map(int,input().split()))
countT = 0
countA = 0
if A % D == 0:
  countT = int(A/D)
else:
  countT = A//D + 1
if C % B == 0:
  countA = int(C/B)
else:
  countA = C//B + 1
if countT >= countA:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 9188
a, b, c, d = map(int, input().split())
from fractions import gcd
xc = (a-1)//c
yc = b//c
xd = (a-1)//d
yd = b//d    
xcd = (a - 1) // ((c * d) // gcd(c, d))
ycd = b // ((c * d) // gcd(c, d))

print(b - a + 1 -((yc - xc) + (yd - xd) - (ycd - xcd)))

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

using namespace std;
vector <int> v;

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

    int x;
    cin >> x;
    if(x >= 30)
        cout << "Yes";
    else
        cout <<"No";
}

Measured memory_bytes: 3608
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long int;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;

//struct edge {int from, to, cost;};

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

int gcd(int m, int n) {
    if (m < n) return gcd(n,m);
    while (n) {
        m %= n;
        swap(m,n);
    }
    return m;
}

void solve() {
    int n;
    cin >> n;
    VLL a(n);
    REP(i,0,n) cin >> a[i];
    VI cnt(n+1);
    constexpr int unit = 1000;
    int ans = 0;
    REP(i,0,(n + unit - 1)/unit) {
        int g = -1;
        REP(j,0,n) {
            if (j / unit == i) continue;
            if (g < 0) g = a[j];
            else g = gcd(g, a[j]);
        }
        REP(j,0,unit) {
            dump(j);
            if (i * unit + j >= n) break;
            int sg = -1;
            REP(k,0,unit) {
                if (j == k) continue;
                if (i * unit + k >= n) break;
                if (sg < 0) sg = a[i * unit + k];
                else sg = gcd(sg, a[i * unit + k]);
            }
            dump(g);
            dump(sg);
            dump(ans);
            if (sg > -1 && g > -1) ans = max(ans, gcd(g, sg));
            else if (g < 0) ans = max(ans, sg);
            dump(ans);
        }
    }
    cout << ans << endl;
}

int main() {
    solve();
    
    return 0;
}

Measured memory_bytes: 1408
import java.util.*;

public class Main {
    public static void main(String[] args) {

      Scanner sc = new Scanner(System.in);
      int N = sc.nextInt();
      int K = sc.nextInt();
      String S = sc.next();
      
      System.out.println(S.substring(0, K -1) + S.substring(K -1, K).toLowerCase() + S.substring(K));
      
      sc.close();
    }
}

Measured memory_bytes: 22740
#include<iostream>
#include <string>
#include<algorithm>
#include <set>
#include <cmath>
using namespace std;
typedef long long lint;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep0(i,n) rep(i,0,n)

int main(void) {
	ios::sync_with_stdio(false);
	int a, b, c, i, j, k, N, res;
	string S;
	cin >> S;
	N = S.length();
	res = 0;
	for (i = 0; i < N/2; i++) {
		if (S[i] != S[N - i - 1]) res++;
	}
	cout << res;
	return 0;
}
//
////sort Ｎ個の配列a
//sort(a, a + N); //昇順
//sort(a, a + N, greater<int>()); //降順
//
////最大公約数（ユークリッドの互除法利用）
//int gcd(int a, int b) {
//	if (a == 0) return b;
//	if (b == 0) return a;
//	int m = max(a, b);
//	int n = min(a, b);
//	if (m%n == 0) return n;
//	else return gcd(n, m%n);
//
//}
//
////最小公倍数
//int lca(int a, int b) {
//	if (a == 0) return 0;
//	if (b == 0) return 0;
//	return a * b / gcm(a, b);
//}
//
////n^k(整数)
//int pow_int(int n, int k) {
//	int re = 1;
//	for (int i = 0; i < k; i++) re *= n;
//	return re;
//}



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

int main(){
	long long int h,i,r = 1,count = 0,ans = 0;
	cin >> h;
	while(h > 1){
		h = h/2;
		count++;
	}
	for(i = 0; i < count+1; i++){
		r = r*2;
	}
	ans = r - 1;

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n){
    int d;
    cin >> d;
    mp[d]++;
  }
  cout << mp.size() << endl;
}


Measured memory_bytes: 256