akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			Question.Exec();
		}
	}

	public static class Question
	{
		public static bool IsOdd(long n)
		{
			bool isOdd = n % 2 == 1;
			return isOdd;
		}

		public static void Exec()
		{
			var array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
			int a = array[0];
			int b = array[1];
			string s = Console.ReadLine();

			if (s.Length != a + b + 1) {
				Console.WriteLine($"No");
				Console.ReadKey();
				return;
			}

			if (s[a] != '-') {
				Console.WriteLine($"No");
				Console.ReadKey();
				return;
			}

			string astr = s.Substring(0, a);
			string bstr = s.Substring(a + 1, b);
			try {
				int.Parse(astr);
				int.Parse(bstr);
			} catch {
				Console.WriteLine($"No");
				Console.ReadKey();
				return;
			}

			Console.WriteLine($"Yes");

			Console.ReadKey();
		}
	}
}

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

int main(){
    int ans = 0;
    vector<int> v(5);
    for(int i=0; i<5; i++) cin >> v[i];
    int last = 9, ind = 0;
    for(int i=0; i<5; i++){
        if(last%10 >= v[i]%10 && v[i]%10 != 0){
            last = v[i];
            ind = i;
        }
    }
    for(int i=0; i<5; i++){
        if(i == ind) continue;
        ans += (v[i]/10 * 10) + (v[i]%10 != 0)*10;
    }
    ans += v[ind];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main() {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

object Problem {
    val MOD = 998244353L
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toLong()
        val X = sc.next().toLong()
        val M = sc.next().toInt()
        val S = LongArray(M * 100)
        val Q = LongArray(M) { -1L }
        var sum = 0L
        var a = X
        var i = 0L
        while (i < N) {
            if (a == 0L) break
            if (Q[a.toInt()] >= 0) {
                val d = (i - Q[a.toInt()]).toInt()
                val l = S[i.toInt()] - S[i.toInt() - d]
                val r = (N - i) / d
                if (r > 0) {
                    sum += l * r
                    i += d * r
                }
                while (i < N) {
                    sum += a
                    a = (a * a) % M
                    i++
                }
                break
            }
            Q[a.toInt()] = i

            sum += a
            S[i.toInt() + 1] = sum
            a = (a * a) % M
            i++
        }
        pw.println(sum)
    }
}


Measured memory_bytes: 117260
#include <stdio.h>
#define B (4)
#define F (3)
#define R (10)

int main(void) {
	char w[] = "####################";
	int room[B][F][R] = {};
	int i, num, b, f, r, v;
	scanf("%d", &num);
	for (i = 0; i < num; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		room[b - 1][f - 1][r - 1] += v;
	}
	for (b = 0; b < B; b++) {
		if (b != 0) {
			printf("%s\n", w);
		}
		for (f = 0; f < F; f++) {
			for (r = 0; r < R; r++) {
				printf(" %d", room[b][f][r]);
			}
			putchar('\n');
		}
	}

	return 0;
}

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

using namespace std;

int main()
{
    int N, K;
    cin >> N >> K;
    int cnt[26] = {};
    string s;
    for (int i = 0; i < N; i++) {
        cin >> s;
        cnt[s[0]-'A']++;
    }
    
    priority_queue<int> pq;
    for (int i = 0; i < 26; i++) {
        if (cnt[i] > 0) {
            pq.push(cnt[i]);
        }
    }
    int res = 0;
    while (!pq.empty()) {
        queue<int> q;
        bool finish = 0;
        for (int i = 0; i < K; i++) {
            if (!pq.empty()) {
                q.push(pq.top());
                pq.pop();
            } else {
                finish = 1;
                break;
            }
        }
        if (finish) break;
        res++;
        while (!q.empty()) {
            int v = q.front(); q.pop();
            if (v > 1) {
                pq.push(v - 1);
            }
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
#define inf 1e9


int main(){
	int n;
	cin>>n;
	vector<vector<int> > a(n+2,vector<int> (n+2,0) );
	for(int i=1;i<=n;i++)
	    for(int j=1;j<=n;j++){
		cin>>a[i][j];
	    }
	vector<vector<int> > dp(n+2,vector<int> (n+2,0) );
	for(int i=1;i<=n;i++){
	    	int tmp = 0;
		for(int j=1;j<=n;j++){
			tmp+=a[i][j];
			dp[i][j] = dp[i-1][j] + tmp;
		}
	}
	/*for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			cout<<dp[i][j]<<' ';
		}
		cout<<endl;
	}*/
	int res = - inf;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			for(int k=0;k<i;k++){
				for(int l = 0;l<j;l++){
					res = max(res,dp[i][j]-dp[i][l] - dp[k][j] + dp[k][l] );
				}
			}
		}
	}
	cout<<res<<endl;
	



	return 0;
}



Measured memory_bytes: 3192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define INF   (1000000000 + 7)
#define MAX_N (100000)
#define MAX_N (100000)

int N;
int A[MAX_N];
int COUNTS[MAX_N];

ll solve() {
  for (int i = 0; i < N; i++) {
    int a = A[i];
    if (a < 0 || N <= a) return 0;
    if (a % 2 == N % 2) return 0;
    COUNTS[a / 2]++;
  }

  if (N % 2 == 1) {
    if (COUNTS[0] != 1) return 0;
  } else {
    if (COUNTS[0] != 2) return 0;    
  }

  for (int i = 1; i < (N + 1) / 2; i++) {
    if (COUNTS[1] != 2) return 0;
  }

  ll ans = 1;
  for (int i = 0; i < N / 2; i++) {
    ans = (ans * 2) % INF;
  }
  return ans;
}

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

  printf("%lld\n", solve());

  return 0;
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int h,w,tmp,res=-1;
int cost[25][25];
char c[24][24];
queue<pair<int,int> > q;
int dx[]={0,1,0,-1,0};
int dy[]={0,0,1,0,-1};
void bfs(int X1,int Y1)
{
    q.push(make_pair(X1,Y1));
    cost[X1][Y1]=0;
    while(!q.empty())
    {
        int x=q.front().first,y=q.front().second;
        q.pop();
        for(int i=1;i<=4;i++)
        {
            int fx=x+dx[i],fy=y+dy[i];
            if(fx>=1&&fx<=h&&fy>=1&&fy<=w&&c[fx][fy]!='#')
            {
                if(cost[fx][fy]==-1)
                {
                    cost[fx][fy]=cost[x][y]+1;
                    q.push(make_pair(fx,fy));
                }
                
                
            }
        }
    }
}
int main()
{
    cin>>h>>w;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            cin>>c[i][j];
        }
    }
    memset(cost,-1,sizeof(cost));
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(c[i][j]!='#')
            {
                memset(cost,-1,sizeof(cost));
                tmp=-1;
                bfs(i,j);
                for(int k=1;k<=h;k++)
                {
                    for(int z=1;z<=w;z++)
                    {
                        tmp=max(cost[k][z],tmp);
                    }
                }
                res=max(res,tmp);
            }
        }
    }
    cout<<res;
}

Measured memory_bytes: 3616
program main
  implicit none
  integer :: n, m, x, pre, post, i
  integer :: a(100)
  read(*, *) n, m, x
  read(*, *) a(1:m)
  pre = 0
  post = 0
  do i = 1, m
    if (a(i) < x) then
      pre = pre + 1
    else
      post = post + 1
    end if
  end do
  write(*, "(i0)") min(pre, post)
end program main


Measured memory_bytes: 256
import java.util.*;
public class Main {
	int INF = 1 << 24;

	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			int [] dis = new int[n];
			int [] v = new int[n];
			for(int i = 0; i < n; i++){
				dis[i] = sc.nextInt();
				v[i] = sc.nextInt();
			}
			long [] data = new long[n];
			data[0] = v[0];
			long m = dis[0];
			for(int i = 1; i < n; i++){
				long g = gcd(dis[i], v[i]);
				long dis1 = dis[i] / g;
				long v1 = v[i] / g;
				long l = lcm(m, dis1);
				for(int j = 0; j < i; j++){
					data[j] = data[j] *  (l / m);
				}
				v1 = v1 * (l / dis1);
				data[i] = v1;
				m = l;
			}
			long gg = data[0];
			for(int i = 1; i < n; i++){
				gg = gcd(gg, data[i]);
			}
			for(int i = 0; i < n-1; i++){
				System.out.println(data[i] / gg);
			}
			System.out.println(data[n-1] / gg);
		}
	}


	private long lcm(long a, long b){
		return a / gcd(a, b) * b;
	}


	private long gcd(long a, long b) {
		if(b == 0){
			return a;
		}
		else{
			return gcd(b, a % b);
		}
	}


	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

Measured memory_bytes: 12000
// --------------
// Tejas Pandey  |
// 19 - 01 - 20  |
// ABC #152      |
// --------------

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

#define mod 1000000007
#define vi vector<int>
typedef long long int ll;

int main (void)
{
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	//cin >> t;
	while(t--)
	{
		//cout << "Case #" << c-t << ": ";
		int n;
		cin >> n;
		int a[n];
		for(int i = 0;i < n;i++)
			cin >> a[i];
		int ans = 1,lo = a[0];
		for(int i = 1;i < n;i++)
			ans += (a[i] <= lo?1:0),lo = min(lo,a[i]);
		cout << ans;
	}
	return 0;
}

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

int main() {
	ll nn;
	cin >> nn;
	vector<ll> aa(nn);
	
	rep(i,nn) cin >> aa[i];
	sort(aa.begin(), aa.end());
	rep(i, nn-1){
		if(aa[i] == aa[i+1]) {
			printf("NO");
			return 0;
		}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<iomanip>

int main(){
  int r, D;
  long x, ans;
  std::cin >> r >> D >> x;
  for(int i = 2001; i <= 2010; i++){
    ans = r * x - D;
    std::cout << std::fixed;
    std::cout << std::setprecision(20) << ans << std::endl;
    x = ans;
  }
}

Measured memory_bytes: 256
#include <map>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, x; map<int, int> d;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> x;
		d[x]++;
	}
	int ret = 0;
	for (pair<int, int> i : d) {
		if (i.first <= i.second) ret += i.second - i.first;
		else ret += i.second;
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 4736
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
		do{
			int a = scan.nextInt();
			String op = scan.next();
			int b = scan.nextInt();
				if("?".equals(op)){break;}
				
				else if("+".equals(op)){
					System.out.println(a + b);
				}
				else if("-".equals(op)){
					System.out.println(a - b);
				}
				else if("*".equals(op)){
					System.out.println(a * b);
				}
				else if("/".equals(op)){
					System.out.println(a / b);
				}
		}while(true);
	}
}

Measured memory_bytes: 26192
#include<stdio.h>
int t[101];
int c[100];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<=a;i++){
			scanf("%d",t+i);
		}
		bool OK=true;
		for(int i=1;i<=a;i++)if(t[1]-t[0]!=t[i]-t[i-1])OK=false;
		if(OK)while(1);
		for(int i=0;i<=a;i++){
			int I=0;
			
			for(int j=0;j<=a;j++)if(i!=j)c[I++]=t[j];
			bool ok=true;
			for(int j=1;j<a;j++)if(c[1]-c[0]!=c[j]-c[j-1])ok=false;
			if(c[1]<=c[0])ok=false;
			if(ok){
				printf("%d\n",t[i]);
				break;
			}
		}
	}
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
constexpr int tv[]={-3,-1,1,3};
constexpr int p10[]={100000000,10000000,1000000,100000,10000,1000,100,10,1};
 
int main(){
    int h,v;
    string a="123456789",b="123456789";
    using data=pair<int,int>;
    
    while(cin>>h>>v, h or v){
        int tc[]={v,h,h,v};
        rep(i,9)cin>>a[i];
        rep(i,9)cin>>b[i];
        int sa=stoi("1"+a)-1000000000,sb=stoi("1"+b)-1000000000;

        unordered_map<int,int> s;

        priority_queue<data> q;
        q.emplace(0,sa);
        
        while(1){
            int cost=q.top().fs;
            int board=q.top().sc;
            if(board==sb){
                cout<<-cost<<endl;
                break;
            }
            q.pop();
            int index=to_string(board).find('0');
            if(index==-1)index=0;
            rep(i,4){
                int fixed=(index+tv[i]+9)%9;
                int next=board;
                int fx=board/p10[fixed]%10;
                next=next+(p10[index]-p10[fixed]) * fx;
                int nc=cost-tc[i];
                if((s.find(next)==s.end() || s[next]<cost-tc[i])){
                    q.emplace(nc, next);
                    s[next]=nc;
                }
            }
        }
    }
}



Measured memory_bytes: 21228
x=int(input())
y=input()
A=[]
for i in range(0,x):
  if y[i]=='(':
    A.append(1)
  elif y[i]==")":
    A.append(-1)

st=0

s=0
for i in A:
  if s==0 and i==-1:
    st+=1
  else:
    s+=i

out=''
for i in range(0,st):
  out+='('
for j in A:
  if j==1:
    out+='('
  elif j==-1:
    out+=')'
for i in range(0,s):
  out+=')'
print(out)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#define cs ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M 1000000007
#define rep(i,b)  for(int i=0;i<(int)(b);i++)
#define Rep(i,n) for(int i=1;i<(int)(n);i++)
#define repp(i,a,b)  for(int i=a;i<=(int)(b);i++)
#define Repp(i,a,b)  for(int i=a;i>=(int)(b);i--)
typedef long long ll;
typedef long double ld;

using namespace std;
int main(){
    cs
    ll n,k,ans=0;cin>>n>>k;
    for(ll i=k;i<=n+1;i++) {
        ans+=(n-(i-1))*i+1;
    }
    cout<<ans%M;
}

Measured memory_bytes: 3628
#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 fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ll> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<ll>::iterator sit;
typedef map<ll,ll>::iterator mit;

template<typename TT, int MX, int LG, ll INF> struct SparseTable //Warning : Change query return value manually if needed. INF is the dummy val
{
	TT st[LG][MX];
	TT initial[MX];
	
	TT combine(TT a, TT b) //warning : change if neccesary
	{
		if(a<b) return a;
		return b;
	}
	
	SparseTable()
	{
		for(int i = 0; i < MX; i++) initial[i] = INF;
	}
	
	void init()
	{
		for(ll j = 0; j < LG; j++)
		{
			for(ll i = 0; i < MX; i++)
			{
				st[j][i] = INF;
				if(i + (1<<j) - 1 < MX)
				{
					if(j == 0) st[j][i] = initial[i];
					else st[j][i] = combine(st[j-1][i], st[j-1][i + (1<<(j-1))]);
				}
			}
		}
	}
	
	TT query(int l, int r)
	{
		int k = 31 - __builtin_clz(r-l);
		if(l==r) k=0;
		return combine(st[k][l], st[k][r - (1<<k) + 1]);
	}
};

SparseTable<int, 200001, 19, int(1e9)> st[2];

int query(int l, int r, int type)
{
	return st[type].query(l/2,r/2);
}

int p[200001];
int iperm[200001];

/*
void solve(int l, int r, deque<ii> &ans)
{
	//cerr<<l<<' '<<r<<'\n';
	if(l>r) return ;
	if(l+1==r)
	{
		ans.pb(mp(p[l],p[r])); return ;
	}
	int tmp = query(l,r-1,l&1);
	int R1 = iperm[tmp];
	int tmp2 = query(R1+1,r,r&1);
	int L2 = iperm[tmp2];
	ans.pb(mp(tmp,tmp2));
	//cerr<<tmp<<' '<<tmp2<<' '<<R1<<' '<<L2<<'\n';
	deque<ii> L[3];
	solve(l,R1-1,L[0]);
	solve(R1+1,L2-1,L[1]);
	solve(L2+1,r,L[2]);
	while(L[0].size()+L[1].size()+L[2].size()>0)
	{
		int fr = int(1e9); int idx = 0;
		for(int i = 0; i < 3; i++)
		{
			if(!L[i].empty())
			{
				if(L[i].front().fi<fr)
				{
					fr=L[i].front().fi;
					idx=i;
				}
			}
		}
		ans.pb(L[idx].front());
		L[idx].pop_front();
	}
}
*/

priority_queue<pair<int,ii>,vector<pair<int,ii> >,greater<pair<int,ii> > > pq;
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	//n = 200000;
	for(int i = 0; i < n; i++)
	{
		cin>>p[i];
		//p[i] = i;
		iperm[p[i]]=i;
		st[i&1].initial[i/2] = p[i];
	}
	st[0].init(); st[1].init();
	vector<ii> ans;
	pq.push(mp(query(0,n-2,0),mp(0,n-1)));
	while(!pq.empty())
	{
		int l = pq.top().se.fi; int r = pq.top().se.se; pq.pop();
		int tmp = query(l,r-1,l&1);
		int R1 = iperm[tmp];
		int tmp2 = query(R1+1,r,r&1);
		int L2 = iperm[tmp2];
		ans.pb(mp(tmp,tmp2));
		if(l<=R1-1)
		{
			pq.push(mp(query(l,R1-2,l&1),mp(l,R1-1)));
		}
		if(R1+1<=L2-1)
		{
			pq.push(mp(query(R1+1,L2-2,(R1+1)&1),mp(R1+1,L2-1)));
		}
		if(L2+1<=r)
		{
			pq.push(mp(query(L2+1,r-1,(L2+1)&1),mp(L2+1,r)));
		}
	}
	for(int i=0;i<n/2;i++)
	{
		cout<<ans[i].fi<<' '<<ans[i].se;
		if(i+1<n/2) cout<<' ';
	}
	cout<<'\n';
}


Measured memory_bytes: 35880
#include <iostream>
#include <string>

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

using namespace std;

int main()
{
  int n;
  cin >> n;
  string s;
  cin >> s;
  if(n % 2 != 0)
  {
    cout << "No" << endl;
    return 0;
  }
  int half = n / 2;
  //abcabc
  if(s.substr(0, half) == s.substr(half, half))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a[4];
    
    rep(i,0,4){
        cin >> a[i];
    }
    
    sort(a,a+4);
    
    if(a[0] == a[1] && a[2] == a[3]) cout << "yes" << endl;
    else cout << "no" << endl;
    return 0;
}


Measured memory_bytes: 3096
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main()
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    int taka,aoki;
    if(c % b == 0) taka = c/b;
    if(c % b != 0) taka = c/b + 1;
    if(a % d == 0) aoki = a/d;
    if(a % d != 0) aoki = a/d + 1;

    if(taka > aoki) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3624
def main():
    n, k = map(int, input().split())
    x = list(map(int, input().split()))

    i = 0
    ans = 10 ** 8 * n
    while i < n - k + 1:
        lr = abs(x[i]) + abs(x[i] - x[i + k - 1])
        rl = abs(x[i + k - 1]) + abs(x[i] - x[i + k - 1])
        i += 1
        ans = min(ans, lr, rl)
    print(ans)


main()


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

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

void chmax(int &a, int b) {
  if (a < b) a = b;
}

int main() {

  int q;
  cin >> q;
  while (q--) {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    vector<vector<int>> dp(n + 1, vector<int>(m + 1, 0));
    rep(i, n) rep(j, m) {
      chmax(dp[i + 1][j + 1], dp[i + 1][j]);
      chmax(dp[i + 1][j + 1], dp[i][j + 1]);
      if (s[i] == t[j]) { chmax(dp[i + 1][j + 1], dp[i][j] + 1); }
    }
    cout << dp[n][m] << endl;
  }

  return 0;
}



Measured memory_bytes: 6788
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const ll inf=1e9+7;
const ll INF=1e18;
const ll mod=99824453;

int MAX_N=2e5+20;

vin par(MAX_N);
vin deep(MAX_N);
vin sizee(MAX_N);
void init(int n);
int root(int x);
void unite(int x,int y);
bool same(int x,int y);
int group_size(int x);

int main(){
    int n,m;cin>>n>>m;
    init(n);
    int a,b;
    rep(i,m){
        cin>>a>>b;
        unite(a,b);
    }
    set<int> p;
    rep(i,n)p.insert(root(i+1));
    cout<<p.size()-1<<endl;
}

void init(int n){
    rep(i,n+1){
        par[i]=i;
        deep[i]=0;
        sizee[i]=1;
    }
}
int root(int x){
    if(par[x]==x)return x;
    else return par[x]=root(par[x]);
}
void unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y)return;
    if(deep[x]<deep[y]){
        par[x]=y;
        sizee[y]+=sizee[x];
    }
    else{
        par[y]=x;
        sizee[x]+=sizee[y];
        if(deep[x]==deep[y])deep[x]++;
    }
}
bool same(int x,int y){
    return root(x)==root(y);
}
int group_size(int x){
    return sizee[root(x)];
}

Measured memory_bytes: 9360
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(),(x).end()
#define COUT(x) cout<<(x)<<"\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, n) for(int i=0;i<n;i++)
#define YES(x) cout<<(x?"YES":"NO")<<"\n"
#define Yes(x) cout<<(x?"Yes":"No")<<"\n"
#define dump(x) cout<<#x<<" = "<<(x)<<"\n"
#define endl "\n"
using G = vector<vector<int>>;
using M = map<int,int>;
using P = pair<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int,vector<int>,greater<int>>;
using V = vector<int>;
using ll = long long;
using edge = struct { int to; int cost; };
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; }
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int n,a,b;
vector<int> h;

bool enough(int idx, ll mid, ll k) {
  for (int i = idx; i < n; i++) {
    ll nh = h[i]-k;
    mid -= nh/(a-b) + (nh%(a-b) > 0);
  }
  return 0 <= mid;
}

int main() {
  IOS;
  cin >> n >> a >> b;
  h.resize(n);
  REP(i,n) cin >> h[i];

  sort(ALL(h));

  int ng = 0, ok = h[n-1]/b+1;
  while(abs(ok-ng) > 1) {
    ll mid = (ok+ng)/2;
    ll key = b * mid;
    auto it = upper_bound(ALL(h), key);
    int idx = it-h.begin();

    if (enough(idx, mid, key)) ok = mid;
    else ng = mid;
  }

  COUT(ok);
  return 0;
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int INF=1000000000;
typedef pair<int,int> P;
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; }
vector<string> v;
queue<P> Q;
int N,A,B,C;
 vector<int> L(N);
int solve(int i,int a,int b,int c){
    if(i==N){
        if(!a||!b||!c) return INF;//いずれも一本は必ず使う。
        return abs(a-A)+abs(b-B)+abs(c-C);//短縮・延長を行ったコスト
    }
    //採用しない場合
    int res=solve(i+1,a,b,c);
    chmin(res,solve(i+1,a+L.at(i),b,c)+(a?10:0));//初回だけaはＦを返す
    chmin(res,solve(i+1,a,b+L.at(i),c)+(b?10:0));
    chmin(res,solve(i+1,a,b,c+L.at(i))+(c?10:0));
  return res;
}


int main(){
   
   cin>>N>>A>>B>>C;
    L.resize(N);
   for(int i=0;i<N;i++){
       cin>>L.at(i);
   } 
   cout<<solve(0,0,0,0)<<endl;
} 


Measured memory_bytes: 256
import math

def isprime(x):
	if x == 2:
		return 1
	if x <2 or x%2 ==0:
		return 0
	i=3
	while i <= math.sqrt(x):
		if x%i==0:
			return 0
		i+=2
	return 1
	
n=int(input())
num=0

for i in range(n):
	x=int(input())
	num+=isprime(x)
print(num)




Measured memory_bytes: 5672
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**7)
from pprint import pprint as pp
from pprint import pformat as pf

import math
#from sortedcontainers import SortedList, SortedDict, SortedSet # no in atcoder
import bisect


def is_good(tower_id, tower_info, connect):
    h = tower_info[tower_id]
    for neighbor_id in connect[tower_id]: # no road is skiped, so OK
        vs_h = tower_info[neighbor_id]
        if not (h > vs_h):
            return False
    return True


if __name__ == '__main__':
    num_tower, num_road = list(map(int, input().split()))
    tower_info = [0] + list(map(int, input().split())) # [0] is dummy
    connect = [None] * (num_tower + 1) # [0] is dummy # [tower_id] = set of connected tower id
    for i, _ in enumerate(connect):
        connect[i] = set()
    #print('connect') # debug
    #print(connect) # debug
    for i in range(num_road):
        frm, to = list(map(int, input().split())) # [0] is dummy
        connect[frm].add(to)
        connect[to].add(frm)
    #print('connect') # debug
    #print(connect) # debug
    # solve
    count = 0
    for tower_id in range(1, num_tower + 1):
        #print('tower_id') # debug
        #print(tower_id) # debug
        if is_good(tower_id, tower_info, connect):
            count += 1
    #print('count') # debug
    #print(count) # debug
    print(count)


    #print('\33[32m' + 'end' + '\033[0m') # debug


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

using namespace std;

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

int H, W, K;
int S[15][1005];

int main() {
  cin >> H >> W >> K;
  for (int i = 0; i < H; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < W; j++) {
      S[i + 1][j + 1] = s[j] - '0';
    }
  }
  for (int i = 1; i <= H; i++) {
    for (int j = 1; j <= W; j++) {
      S[i][j] += S[i - 1][j] + S[i][j - 1] - S[i - 1][j - 1];
    }
  }
  auto min_vcuts = [&](vector<int> hcuts) -> int {
    int last_j = 0;
    int vcuts = 0;
    for (int j = 1; j <= W; j++) {
      for (int i = 1; i < hcuts.size(); i++) {
        int s = S[hcuts[i]][j] - S[hcuts[i - 1]][j] - S[hcuts[i]][last_j] +
                S[hcuts[i - 1]][last_j];
        if (s > K) {
          if (j == 1) {
            return -1;
          } else {
            last_j = j - 1;
            j--;
            vcuts++;
            break;
          }
        }
      }
    }
    return vcuts;
  };
  int ans = 1e9;
  for (int bits = 0; bits < (1 << (H - 1)); bits++) {
    vector<int> cuts;
    cuts.push_back(0);
    int hcuts = 0;
    for (int i = 0; i < H - 1; i++) {
      if ((bits >> i) & 1) {
        cuts.push_back(i + 1);
        hcuts++;
      }
    }
    cuts.push_back(H);
    int vcuts = min_vcuts(cuts);
    if (vcuts >= 0) {
      chmin(ans, hcuts + vcuts);
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#!python3.8
# -*- coding: utf-8 -*-
# abc162/abc162_b
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    r = sum(i for i in range(1, N+1) if i % 3 and i % 5)
    print(r)
    return
main()


Measured memory_bytes: 9208
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate など
#include <cassert>    // assert
#include <stdexcept>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;

int n, m, x;
vector<int> cs;
vector<vector<int>> as(14);
constexpr int INF = 1300000;
int res = INF;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    cin>>n>>m>>x;
    REP(i,n){
        int c;
        cin>>c;
        cs.push_back(c);
        REP(j,m){
            int a; cin>>a;
            as[i].push_back(a);
        }
    }

    REP(b, 2 << n){
        bool ok = true;
        REP(j, m){
            int score = 0;
            REP(i, n){
                score += ((b >> i) & 1) * as[i][j];
            }
            ok &= (score >= x);
        }
        if (ok)
        {
            int tmpres = 0;
            REP(i, n){ tmpres += ((b >> i) & 1) * cs[i]; }
            res = min(res, tmpres);
        }
    }

    res = (res == INF) ? -1 : res;
    cout << res << endl;

    return 0;
}


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

int main() {
	char a, b;
	cin >> a >> b;
	if (a == 'H') {
		cout << b << endl;
	}
	else {
		if (b == 'H') {
			cout << 'D' << endl;
		}
		else {
			cout << 'H' << endl;
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int  a, b, x;
  cin >> a >> b;
  x = -1;
  for(int i = 0; i < 12625; i++){
    if(8*i/100 == a&& i/10 == b){
      x = i;
      break;
    }
  }
  
  cout << x <<endl;
}


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

using namespace std;

int main (){
	string s;
	cin >> s;
	int g=0;
	bool o=0;
	for(int i=0;i<s.size();i++){
		if(o){
			if(s[i-1]==s[i]){
				if(i!=s.size()-1){
					g++;
				}		
				i++;
				o=0;
			}
			else{
				g++;
			}
		}
		else{
			g++;
			o=1;
		}
	}
	cout << g << endl;

	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define double long double
#define Sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(all(a),greater<>())
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T> inline int out(const T &t){ print(t); putchar('\n'); return 0; }
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;}
typedef long long ll;
typedef pair<int,int> P;
const long long MOD=1000000007;


void solve(long long N){
    // debg((N*(N-1))/2)
    ll ans=0;
    ans = (N*(N-1))/2;
    std::cout << ans << std::endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
auto to_l(string& str){
  str[0]=tolower(str[0]);
  for(auto i=find(begin(str), end(str), '_'); i!=end(str); i=find(i, end(str), '_')){
    ++i; *i=toupper(*i);
  }
  str.erase(remove(begin(str), end(str), '_'), end(str));
}
auto l_to_u(string& str){
  str[0]=toupper(str[0]);
}
auto l_to_d(string& str){
  for(auto i=find_if(begin(str), end(str), [](const char c){ return isupper(c)!=0; });
    i!=end(str);
    i=find_if(i, end(str), [](const char c){ return isupper(c)!=0; })){
    i=str.insert(i, '_');
    ++i; *i=tolower(*i);
  }
}
int32_t main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string str; char c;
  for(cin>>str>>c; c!='X'; cin>>str>>c){
    to_l(str);
    switch(c){
    case 'D': l_to_d(str); break;
    case 'U': l_to_u(str);
    }
    cout<<str<<'\n';
  }
}


Measured memory_bytes: 3012
n, a, b = map(int,input().split())
s = input()


tuka = 0
kaigai = 0
for i in range(1,n+1):
    if s[i-1] == 'a':
        if tuka < a+b:
            print('Yes')
            tuka += 1
        else:
            print('No')
    elif s[i-1] == 'b':
        if tuka < a+b and kaigai < b:
            print('Yes')
            tuka += 1
            kaigai += 1
        else:
            print('No')
    else:
        print('No')


Measured memory_bytes: 9220
MOD = 10**9 + 7
N,M = map(int,input().split())

num = 500010
fact = [1] * (num+1)
ifact = [1] * (num+1)

for i in range(1,num+1):
    fact[i] = (fact[i-1] * i) % MOD
ifact[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(1,num+1)[::-1]:
    ifact[i-1] = (ifact[i] * i)% MOD

def nPr(n,r):
    if r > n:
        return 0
    return (fact[n] * ifact[n-r]) % MOD
def nCr(n,r):
    if r > n:
        return 0
    return (fact[n] * ifact[r] * ifact[n-r]) % MOD

ans = nPr(M,N) ** 2
sign = -1
for n in range(1,N+1):
    t = (nPr(M,n) * nCr(N,n) * (nPr(M-n,N-n) ** 2))
    ans += sign * t
    sign *= -1
    ans %= MOD
print(ans)


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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 105;

int n;
int d[maxn][2];

int main(){
	scanf("%d", &n);
	FOR(i, 0, n)
		scanf("%d%d", &d[i][0], &d[i][1]);
	REP(i, 0, n - 3){
		if(d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1] && d[i + 2][0] == d[i + 2][1]){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    double W,H,x,y;
    cin>>W>>H>>x>>y;
    cout<<fixed;
    cout<<setprecision(10)<<W*H/2.0<<" "<<((x == W/2.0) and (y == H/2.0));
    return 0;
}

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

typedef long long lint;
#define REP(i, x, n) for(lint i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(lint i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const lint inv = MOD - 2;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector< pair<int, int> > r(n), b(n);
    rep(i, n){
        cin >> r[i].second >> r[i].first;
    }
    rep(i, n){
        cin >> b[i].first >> b[i].second;
    }
    SORT(r);
    SORT(b);
    int ans = 0;
    vector<bool> done(n, false);
    rep(i, n){
        repr(j, n){
            if(b[i].first > r[j].second && b[i].second > r[j].first && !done[j]){
                done[j] = true;
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
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; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

vector<ll> a, sum;
vector<vector<ll> > dp;
ll rec (int l, int r) {
    if (r - l <= 1) return 0;
    else if (dp[l][r] != 0) return dp[l][r];

    ll ret = (ll)1e18;
    rep (i, l + 1, r) {
        ll x = rec(l, i);
        ll y = rec(i, r);
        if (chmin(ret, x + y)) eprintf("%d %d %d : %lld\n", l, i, r, ret);
    }
    return dp[l][r] = ret + sum[r] - sum[l];
}
int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    a.resize(n); rep (i, n) cin >> a[i];
    sum.resize(n + 1); rep (i, n) sum[i + 1] = sum[i] + a[i];
    dp.resize(n + 1); rep (i, dp.size()) dp[i].resize(dp.size());
    cout << rec(0, n) << "\n";
    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n >> m;
    intl a[m],b[m];
    rep(i,m){
        cin >> a[i] >> b[i];
    }
    intl c[n];
    m0(c);
    rep(i,m){
        c[a[i]-1]++;
        c[b[i]-1]++;
    }
    rep(i,n){
        cout << c[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <map>

int main(){
	int N;
	std::vector<int> S;
	scanf("%d", &N);
	//printf("%d\n",N);
	std::string S_string;
	std::cin>>S_string;
	for (int i=0; i<N; i++){
		S.push_back(int(S_string[i])-int('0'));
	}
	//printf("length=%d\n",S.size());
	int ans = 0;
	for (int i=0; i<10; i++){
		for (int j=0; j<10; j++){
			for (int k=0; k<10; k++){
				//printf("(%d, %d, %d)\n",i,j,k);
				int l=0;
				//printf("i check\n");
				while(i!=S[l]){
					//printf("%d != %d\n",i,S[l]);
					l++;
					if (l>=S.size()){
						break;
					}
				}
				l++;
				if (l>=S.size()){
					continue;
				}
				//printf("j check\n");
				while(j!=S[l]){
					//printf("%d != %d\n",j,S[l]);
					l++;
					if (l>=S.size()){
						break;
					}
				}
				l++;
				if (l>=S.size()){
					continue;
				}
				//printf("k check\n");
				while(k!=S[l]){
					//printf("%d != %d\n",k,S[l]);
					l++;
					//printf("l=%d\n",l);
					if (l>=S.size()){
						break;
					}
				}
				if (l>=S.size()){
					continue;
				}
				//printf("found\n");
				ans++;
			}
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <bitset>
#include <string>
#include <algorithm>

using namespace std;

const int kMaxN = 1e5 + 10;

int main(int argc, char const *argv[]) {
  int ans = 0;
  int n, m, p;
  vector<long> v;
  string s;

  cin >> n;
  v.push_back(2);
  v.push_back(1);
  int i = 2;
  while (i <= n) {
    v.push_back(v[i - 1] + v[i - 2]);
    ++i;
  }
  cout << v[n] << endl;

  return 0;
}


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

int main(){

    string s;
    string t;

    cin >> s >> t;

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

        if(s == t){

            cout << "Yes" <<endl;
            return 0;

        }

        s = s.back() + s;
        s.pop_back();

    }

    cout << "No" << endl;
    
    return 0;

}

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 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

int main() {
    int N; cin >> N;
    vector<int> num(100010);
    for (int i = 0; i < N; i++) {
        int a;
        scanf("%d", &a);
        if (a > 0) num[a - 1]++;
        num[a]++;
        num[a + 1]++;
    }

    int x = *max_element(num.begin(), num.end());

    cout << x << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define M(A) (((A) + n * 3) % n)
char a[3000],b[3000];
int x[3000],y[3000],z[3000];
int mini = INT_MAX;
int n;
bool solve(){

    if(strcmp(a,b) == 0){
        printf("0\n");
        return true;
    }
    bool ff = true;
    REP(i,n)
        if(b[i] == '1')ff = false;
    if(ff){
        printf("-1\n");
        return true;
    }
    REP(i,n){
        int j = 0;
        while(b[M(i - j)] == '0')j++;
        x[i] = j;
        j = 0;
        while(b[M(i + j)] == '0')j++;
        y[i] = j;
    }

    REP(d,n){
        int f = 0;
        REP(i,n)
            if(a[i] != b[M(i + d)])f++;
        if(f == 0){
            mini = min(mini,d);
            continue;
        }
        REP(i,n){
            z[i] = 0;
        }
        REP(i,n){
            if(a[i] != b[M(i + d)]  && y[i] > d){
                z[x[i]] = max(z[x[i]],y[M(i + d)]);
                //printf("b%d %d\n",x[i],y[M(i + d)]);
            }else
                ;//printf("b0 0 %d %d\n",a[M(i - d)] != b[i],y[i] > d);
        }
        int maxi = 0,minxy = INT_MAX;
        RREP(i,n){
            if(z[i] >= maxi){
                minxy = min(minxy,i + maxi);
                maxi = z[i];
            }
        }
        mini = min(mini,2 * minxy + d + f);
    }
    return false;
}
char ex[3000];
int main(){
    cin >> a >> b;

    n = strlen(a);

    if(solve())
        return 0;
    REP(i,n)
        ex[i] = a[n - i - 1];
    REP(i,n)
        a[i] = ex[i];
    REP(i,n)
        ex[i] = b[n - i - 1];
    REP(i,n)
        b[i] = ex[i];
    solve();
    printf("%d\n",mini);
    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100000;
 
int main(){
    int N;
    string ans = "second";

    cin >> N;
    for(int i = 0;i < N;i++){
        int n;
        cin >> n;
        if(n % 2)ans = "first";
    }

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

Measured memory_bytes: 256
# シカのAtCoDeerくんとTopCoDeerくんが「正直者か嘘つきか」ゲームをしています。
# このゲームでは、正直者は常にほんとうのことを言い、嘘つきは常に嘘を言います。
# 文字 a と b が入力として与えられます。
# これらはそれぞれ H か D のどちらかです。
# a=H のとき、AtCoDeerくんは正直者です。
# a=D のとき、AtCoDeerくんは嘘つきです。
# b=H のとき、AtCoDeerくんは「TopCoDeerくんは正直者だ」と発言しています。
# b=D のとき、AtCoDeerくんは「TopCoDeerくんは嘘つきだ」と発言しています。
#
# これらから判断して、TopCoDeerくんが正直者かどうか判定してください。

# 制約
# a='H' または 'D'
# b='H' または 'D'


# 標準入力から文字列 a と b を取得する
input_a, input_b = map(str,input().split())

reslut = "ret"

# TopCoDeerくんが正直者かどうか判定し、結果を出力する。
# ※ 正直者=="H"、嘘つき=="D"
if input_a == "H":  # AtCoDeerくんが正直者の場合
    if input_b == "H":
        result = "H"
    elif input_b == "D":
        result = "D"
elif input_a == "D":    # AtCoDeerくんが嘘つき者の場合（条件増えた時ようにelifにした）
    if input_b == "H":
        result = "D"
    elif input_b == "D":
        result = "H"
else:
    reslut = "I don't Know."

print(result)




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

int main() {
    ll N;
    string S;
    cin >> N >> S;
    for (char c : S) {
        ll tmp = c + N;
        if (tmp > ll('Z')) tmp -= (ll('Z') - ll('A') + 1);
        cout << char(tmp);
    }
    cout << endl;
    return 0;
}


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

int main() {
 
  int n, k;
  int r, s, p;
  cin >> n >> k >> r >> s >> p;
  string t;
  cin >> t;

  int ans = 0;
  vector<string> tmp(n);
  for(int i = 0; i < n; i++) {
    if(i >= k) {
      int b = 0;
      if(i + k <= n - 1) {
        b = 1; 
      }
      if(t.at(i) == 'r') {
        if(tmp.at(i-k) == "p") {
          if(b >= 1 && t.at(i+k) == 's') {
            tmp.at(i) = 's';
          } else {
            tmp.at(i) = 'r';
          }
        } else {
          ans = ans + p;
          tmp.at(i) = 'p';
        }
      } else if(t.at(i) == 's') {
        if(tmp.at(i-k) == "r") {
          if(b >= 1 && t.at(i+k) == 'p') {
            tmp.at(i) = 'p';
          } else {
            tmp.at(i) = 's';
          }
        } else {
        ans = ans + r;
        tmp.at(i) = 'r';
      }
      } else {
        if(tmp.at(i-k) == "s") {
          if(b >= 1 && t.at(i+k) == 's') {
            tmp.at(i) = 'p';
          } else {
            tmp.at(i) = 'r';
          }
        } else {
          ans = ans + s;
          tmp.at(i) = 's';
        }
      }
    } else {
      if(t.at(i) == 'r') {
        ans = ans + p;
        tmp.at(i) = 'p';
      } else if(t.at(i) == 's') {
        ans = ans + r;
        tmp.at(i) = 'r';
      } else {
        ans = ans + s;
        tmp.at(i) = 's';
      }
    }
  }
  cout << ans << endl;
  }


Measured memory_bytes: 5760