akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];


int main(){
    ll A,B,K;
    ll tmp = 0,ans=0;
    cin >> A >> B >> K;
    if(K >= A){
        K -= A;
        if(K >= B){
            cout << 0 << " " << 0 << endl; 
        }else{
            cout << 0 << " " << B-K << endl; 
        }
    }else{
        cout << A-K << " " << B << endl; 
    }
}

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

//AtCoderC++.cpp

using namespace std;

template<typename T> void Show(const vector<vector<T>>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		for (int j = 0; j < v[i].size(); j++) {
			cout << v[i][j];
			if (j != v[i].size() - 1) {
				cout << delimiter;
			} else {
				cout << endl;
			}
		}
	}
}
template<typename T> void Show(const vector<T>& v, string delimiter = " ") {
	for (int i = 0; i < v.size(); i++) {
		cout << v[i];
		if (i != v.size() - 1) {
			cout << delimiter;
		} else {
			cout << endl;
		}
	}
}
template<typename T> vector<T> getUniform(T value, int n) {
	vector<vector<T>> ts;
	ts.resize(n);
	for (int i = 0; i < n; i++) {
		ts[i] = value;
	}
	return ts;
}
template<typename T> vector<vector<T>> getUniform(T value, int row, int col) {
	vector<vector<T>> ts;
	ts.resize(row);
	for (int i = 0; i < row; i++) {
		ts[i].resize(col);
		for (int j = 0; j < col; j++) {
			ts[i][j] = value;
		}
	}
	return ts;
}
bool All(vector<vector<bool>> ts) {
	int h = ts.size();
	int w = ts[0].size();
	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++)
			if (!ts[i][j])return false;
	return true;
}


vector<string> split(string& content, char delim) {
	auto ss = vector<string>();
	string s = "";
	for (size_t i = 0; i < content.length(); i++) {
		if (content[i] == delim) {
			ss.push_back(s);
			s = "";
			continue;
		}
		s += content[i];
	}
	if (s != "")ss.push_back(s);
	return ss;
}

int main() {
	int A, B; cin >> A >> B;
	if (A < 6)cout << 0 << endl;
	else if (A < 13)cout << B / 2 << endl;
	else cout << B << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
    char s[100];
    int i;
    long long k,ans = 0;

    scanf("%s %lld",s,&k);

    int len = strlen(s);
    int cnt = 1,a = 0,b = 0;

    for (i = 1; i < len; i++)
    {
        if(s[i - 1] != s[i])break;
    }
    a = i;
    if(i == len)
    {
        printf("%lld",k * len / 2);
    }
    else
    {
        for (i = 1; i < len; i++)
        {
            if(s[i - 1] == s[i])cnt++;
            else
            {
                ans += cnt / 2;
                cnt = 1;
            }
        }
        ans += cnt / 2;

        if(s[0] == s[len - 1])
        {
            for (i = len - 1; i > 0 ;i--)
            {
                if(s[i - 1] != s[i])break;
            }
            b = len - i;
            printf("%lld",k * ans - (a / 2 + b / 2 - (a + b) / 2) * (k - 1));
        }
        else
        {
            printf("%lld",k * ans);
        }
        
    }
    
}

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

class D
{
public:
	int A; //????¨???????
	int B; //???
	int n;
	bool operator > (D d)
	{
		return n > d.n;
	}
	bool operator < (D d)
	{
		return n < d.n;
	}
};

int main()
{
	int N, M, p;
	vector<D> d;
	int ans = 99999999;

	cin >> N >> M >> p;

	for (int i = 0; i < M; i++)
	{
		d.push_back(D());
		cin >> d[i].n;
		if (d[i].n > p)
		{
			d[i].A = d[i].n - p;
			d[i].B = N - d[i].A;
		}
		else
		{
			d[i].B = p - d[i].n;
			d[i].A = N - d[i].B;
		}
	}

	sort(d.begin(), d.end());
	for (int i = 0; i < d.size(); i++)
	{
		if (d[i].n > p)
		{
			D P;
			P.n = p; P.A = 0; P.B = 0;
			d.insert(d.begin() + i, P);
			break;
		}
		else if (i == d.size() - 1)
		{
			D P;
			P.n = p; P.A = 0; P.B = 0;
			d.push_back(P);
			break;
		}
	}

	for (int i = 0; i < d.size(); i++)
	{
		int a = d[i].A;
		int b = d[(i + 1) % d.size()].B;
		if (a > b) swap(a, b);
		ans = min(a * 2 + b, ans);
	}

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

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

class Test {
	static void Main(string[] args) {
      var X = System.Console.ReadLine()
    	.Split(' ')
    	.Select(s => int.Parse(s))
    	.ToArray();
      if(X[0] >= 30){
        Console.WriteLine("Yes");
      }else{
        Console.WriteLine("No");
      }
	}
}

Measured memory_bytes: 18884
#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
 
int main() {
  ll h,w;
  cin >> h >> w;
  vector<string> s(h);
  for(ll i=0;i<h;i++) {
    cin >> s[i];
  }
  vector<vector<ll>> hn(h,vector<ll>(w));
  vector<vector<ll>> wn(h,vector<ll>(w));
  ll f=-1;
  ll temp=0;
  for(ll i=0;i<w;i++) {
    f=-1;
    temp=0;
    for(ll j=0;j<h;j++) {
      if(s[j][i]=='#') {
        for(ll k=f+1;k<j;k++) {
          hn[k][i]=temp;
        }
        f=j;
        temp=0;
      }
      else {
        temp++;
        if(j==h-1) {
          for(ll k=f+1;k<=j;k++) {
            hn[k][i]=temp;
          }
        }
      }
    }
  }
  for(ll i=0;i<h;i++) {
    f=-1;
    temp=0;
    for(ll j=0;j<w;j++) {
      if(s[i][j]=='#') {
        for(ll k=f+1;k<j;k++) {
          wn[i][k]=temp;
        }
        f=j;
        temp=0;
      }
      else {
        temp++;
        if(j==w-1) {
          for(ll k=f+1;k<=j;k++) {
            wn[i][k]=temp;
          }
        }
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<h;i++) {
    for(ll j=0;j<w;j++) {
      ans=max(ans,hn[i][j]+wn[i][j]-1);
    }
  }
  cout << ans << endl;
}

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

int main(){
	string s;
	int a, b;
	stack<int> st;
	while(cin >> s){
		if(s[0] == '+'){
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(b + a);
		}else if(s[0] == '*'){
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(b * a);
		}else if(s[0] == '-'){
			a = st.top();
			st.pop();
			b = st.top();
			st.pop();
			st.push(b - a);
		}else{
			st.push(atoi(s.c_str()));
		}
	}
	cout << st.top() << endl;
}

Measured memory_bytes: 3164
#cmb
mod=10**9+7
MAX=2*10**5+100

g1=[1,1]
g2=[1,1]
for i in range(2,MAX+1):
    num_1=g1[-1]*i%mod
    g1.append(num_1)
    g2.append(pow(num_1,mod-2,mod))
    
def cmb(n,r,MOD):
    return g1[n]*g2[r]*g2[n-r]%MOD

n,m,k=map(int,input().split())
s=0
t=0
for i in range(1,n):
    s+=i*(n-i)
for i in range(1,m):
    t+=i*(m-i)

ans=(n*n*t+m*m*s)%mod
ans=(ans*cmb(n*m-2,k-2,mod))%mod
print(ans)

Measured memory_bytes: 66800
#   ABC128 D


def make_switch_pattern(N, M):
    for i in range(2**N):
        tmp_lst = [0]*N
        for j in range(N):
            tmp_lst[j] = i % 2
            i = int(i/2)
        tmp_lst.reverse()
        switch_pattern = tuple(tmp_lst)
        yield switch_pattern


def all_light_41_pi(switch_pattern, light_lst, pi_lst):
    for i in range(len(light_lst)):
        switches = light_lst[i]
        pi = pi_lst[i]
        on_count = 0
        for k in switches:
            if switch_pattern[k-1] == 1:
                on_count += 1
        on_count %= 2
        if on_count != pi:   #   条件を満たさない時
            return False
    return True


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

light_lst = []  #   ライトについているスイッチのタプル のリスト
for i in range(M):
    tmp_lst = list(map(int, input().split()))
    tmp_tple = tuple(tmp_lst[1:])
    light_lst.append(tmp_tple)

pi_lst = list(map(int, input().split()))

count = 0
for switch_pattern in make_switch_pattern(N, M):
    if all_light_41_pi(switch_pattern, light_lst, pi_lst):
        count += 1

print(count)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
}


Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var vv= ToIntArray(input.ReadLine(), n);
        var cc = ToIntArray(input.ReadLine(), n);

        var sum = 0;

        for(int i=0; i<n; i++) {
            if(vv[i] - cc[i] > 0) {
                sum += vv[i] - cc[i];
            }
        }

        return sum;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e2+11;
const ll INF=1e18+11;
struct Edge{int nxt,to;ll cap,flow;}edge[N*N*2];
int num_edge=1,n,cur[N],head[N],d[N],s,t;
ll ans;
bool vis[N];
void add_edge(int from,int to,ll cap){
	edge[++num_edge].nxt=head[from];edge[num_edge].to=to;edge[num_edge].cap=cap;edge[num_edge].flow=0;head[from]=num_edge;
	edge[++num_edge].nxt=head[to];edge[num_edge].to=from;edge[num_edge].cap=0;edge[num_edge].flow=0;head[to]=num_edge;
}
bool bfs(){
	memset(vis,0,sizeof(vis));
	queue<int> Q;
	Q.push(s);vis[s]=1;
	while(!Q.empty()){
		int u=Q.front();Q.pop();
		for(int i=head[u];i;i=edge[i].nxt){
			int v=edge[i].to;
			if(!vis[v]&&edge[i].cap>edge[i].flow){
				d[v]=d[u]+1;
				vis[v]=1;
				Q.push(v);
			}
		}
	}
	return vis[t];
}
ll dfs(int u,ll a){
	if(a==0||u==t) return a;
	ll flow=0,f;
	for(int &i=cur[u];i;i=edge[i].nxt){
		int v=edge[i].to;
		if(d[v]==d[u]+1&&(f=dfs(v,min(a,edge[i].cap-edge[i].flow)))>0){
			flow+=f;
			edge[i].flow+=f;
			edge[i^1].flow-=f;
			a-=f;
			if(!a) break;
		}
	}
	return flow;
}
ll dinic(){
	ll ret=0;
	while(bfs()){
		for(int i=0;i<=t;++i) cur[i]=head[i];
		ret+=dfs(s,INF);
	}
	return ret;
}
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d",&n);t=n+1;
	for(int i=1;i<=n;++i){
		ll a;
		scanf("%lld",&a);
		if(a<=0) add_edge(s,i,-a);
		else add_edge(i,t,a),ans+=a;
	}
	for(int i=1;i<=n;++i){
		for(int j=2*i;j<=n;j+=i){
			add_edge(i,j,INF);
		}
	}
	ans-=dinic();
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    int n;
    cin >> n;

    vector<int> a(1 << n);
    rep(i, 1 << n) cin >> a[i];

    vector<P> fst(1 << n, {a[0], 0}), snd(1 << n);
    for(int s = 1; s < (1 << n); s++){
        if(fst[s].first <= a[s]){
            snd[s] = fst[s];
            fst[s] = {a[s], s};
        }else if(snd[s].first <= a[s]){
            snd[s] = {a[s], s};
        }

        rep(j, n){
            if((s >> j) % 2 == 1){
                continue;
            }
            int t = s | (1 << j);

            if(fst[t] < fst[s] && fst[t].second != fst[s].second){
                snd[t] = fst[t];
                fst[t] = fst[s];
            }else if(snd[t] < fst[s] && fst[t].second != fst[s].second){
                snd[t] = fst[s];
            }

            if(snd[t] < snd[s] && snd[t].second != snd[s].second){
                snd[t] = snd[s];
            }
        }
    }

    int ans = 0;
    for(int i = 1; i < (1 << n); i++){
        ans = max(ans, fst[i].first + snd[i].first);
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 13312
import java.util.Scanner;

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

		int n = sc.nextInt();
		long t = sc.nextInt();
		long[] time = new long[n];

		for (int i = 0; i < n; i++) {
			time[i] = Long.parseLong(sc.next());
		}
		long ans = t;

		for (int i = 0; i < n - 1; i++) {
			if (time[i + 1] - time[i] > t)
				ans += t;
			else {
				ans += time[i + 1] - time[i];
			}
		}

		System.out.println(ans);
	}

}


Measured memory_bytes: 58392
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N, K = LI()
    if N < K:
        ans = min(abs(K-N), N)
    else:
        N = N % K
        ans = min(abs(K-N), N)
    print(ans)

main()



Measured memory_bytes: 6480
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int inv2 = 500000004;
const int MAXN = 200005;
int n, ans, pw2[MAXN];
int fir[MAXN], to[MAXN<<1], nxt[MAXN<<1], cnt;
inline void link(int u, int v) {
	to[++cnt] = v; nxt[cnt] = fir[u]; fir[u] = cnt;
	to[++cnt] = u; nxt[cnt] = fir[v]; fir[v] = cnt;
}
int sz[MAXN];
void dfs(int u, int ff) {
	sz[u] = 1;
	int p0 = 1, p1 = 0, q0, q1, p;
	for(int i = fir[u], v; i; i = nxt[i])
		if((v=to[i]) != ff) {
			dfs(v, u); sz[u] += sz[v];
			p = pw2[sz[v]];
			q0 = 1ll * p0 * p % mod;
			q1 = (1ll * p1 * p + 1ll * p0 * (mod+1-p)) % mod;
			p0 = q0, p1 = q1;
		}
	p = pw2[n-sz[u]];
	q0 = 1ll * p0 * p % mod;
	q1 = (1ll * p1 * p + 1ll * p0 * (mod+1-p)) % mod;
	p0 = q0, p1 = q1;
	ans = (ans + (1ll+mod+mod-p0-p1) % mod * inv2 % mod) % mod;
}
int main () {
	scanf("%d", &n);
	pw2[0] = 1;
	for(int i = 1, x, y; i < n; ++i)
		scanf("%d%d", &x, &y), link(x, y), pw2[i] = 1ll * pw2[i-1] * inv2 % mod;
	pw2[n] = 1ll * pw2[n-1] * inv2 % mod;
	dfs(1, 0);
	printf("%d\n", ans);
}

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

int a, b, h;

signed main()
{
	cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
}


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

int main() {
  
  int N,Y;
  cin >> N >> Y;
  int y=Y/1000;
  
  int s=0;
  for (int i=0; i<N+1; i++) {
    for (int j=0; j<N-i+1; j++) {
      if (10*i+5*j+1*(N-i-j)==y) {
          s++;
          cout << i << " " << j << " " << N-i-j << endl;
          }
      if (s!=0) break;
    }
    if (s!=0) break;
  }
  
  if (s==0) cout << -1 << " " << -1 << " " << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
//---------------------------------------------------------------------------//

int main(){
        int n,a[101];
        ll min01=inf;
        cin>>n;
        rep(i,n) cin>>a[i];
        for(int i=-200; i<=200; i++) {
                ll min1=0;
                rep(j,n){
                        min1+=(i-a[j])*(i-a[j]);
                }
                min01=min(min1,min01);
        }
        cout<<min01<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long n,m,a[333][333],pw[666],cnt,pos,cur,upper;
/*long long Guass(long long Row,long long Column)
{
    long long row=1,col=1,max_r;
    for(row=1;row<=Row&&col<=Column;row++,col++)
    { 
        max_r=row;
        for(long long i=row+1;i<=Row;i++)
            if(abs(a[i][col])>abs(a[max_r][col]))
                max_r=i;
        if(a[max_r][col]==0)
        {
            row--;
            continue;
        }
        if(max_r!=row)
            for(long long i=col;i<=Column;i++)
                swap(a[row][i],a[max_r][i]);

        for(long long i=row+1;i<=Row;i++)
        {
            if(a[i][col]!=0)
            {

                for(long long j=col;j<=Column;j++)
                    a[i][j]^=a[row][j];
            }
        }
    }
	return Column-row+1;
}*/
void gauss()
{
	upper=1;
	for (long long i=1;i<=m;i++)
	{
		pos=-1;
		for (long long j=upper;j<=n;j++)
		{
			if (a[j][i])
			{
				pos=j;
				break;
			}
		}
		if (~pos)
		{
			cnt++;
			for (long long j=1;j<=m;j++) swap(a[upper][j],a[pos][j]);
			for (long long j=upper+1;j<=n;j++)
			{
				if (a[j][i])
				{
					for (long long k=i;k<=m;k++)
					{
						a[j][k]^=a[upper][k];
					}
				}
			}
			upper++;
		}
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for (long long i=1;i<=n;i++)
	{
		for (long long j=1;j<=m;j++)
		{
			scanf("%lld",&a[i][j]);
		}
	}
	pw[0]=1;
	for (long long i=1;i<=600;i++) pw[i]=pw[i-1]*2%mod;
	gauss();
	cur=pw[m-cnt];
	printf("%lld\n",((pw[n+m-1]-pw[n-1]*cur)%mod+mod)%mod);
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

	int a,b,S,M;
	
	scanf ("%d %d",&a,&b);
	
	S = a * b;
	
	M = (2 * a) + (2 * b);
	
	printf ("%d",S);
	
	printf (" ");
	
	printf ("%d\n",M);
	
	return 0;
	
}


Measured memory_bytes: 2100
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define MIN(a, b) (a < b ? a : b)
#define MAX(a, b) (a > b ? a : b)
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int64_t A[200000];

double my_pow(const double val, const uint32_t num) {
	double ret = 1;
	for (uint32_t i = 0; i < num; i++) {
		ret *= val;
	}

	return ret;
}

int main(void) {
	uint32_t n, m, d;

	scanf("%"PRIu32" %"PRIu32" %"PRIu32, &n, &m, &d);

#if 0
	double tmp = my_pow((double)((n - d) * 2), m - 1);
	for (uint32_t i = 0; i < m; i++) {
		tmp /= (double)n;
	}
#endif

	const double ans = (double)(n - d)*(double)(m - 1)*(d != 0 ? (double)2 : (double)1) / (double)n / (double)n;
	printf("%.10lf", ans);

	return 0;
}


Measured memory_bytes: 128
##C
X,N = map(int,input().split())
P = list(map(int,input().split()))
i=0
j = 0
while X+i<=101:
    if X+i not in P:
        ans1 = X+i
        break
    i += 1
while X-j>=-1:
    if X-j not in P:
        ans2 = X-j
        break
    j += 1
if ans1-X>=X-ans2:
    print(ans2)
else:
    print(ans1)

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

ll solve() {
    ll N, M, V, P;
    cin >> N >> M >> V >> P;
    vector<ll> A(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    sort(A.begin(), A.end());
    if ( P >= V ) {
        ll cr = A[N-1-(P-1)] - M;
        ll i = lower_bound(A.begin(), A.end(), cr) - A.begin();
        return N - i;
    } else {
        ll cr = A[N-1-(P-1)] - M;
        ll i0 = lower_bound(A.begin(), A.end(), cr) - A.begin();
        if ( i0 > V - P ) {
            return N - i0;
        } else {
            vector<ll> ca(N);
            ll sm = 0;
            for ( int i = 0; i < N; i++ ) {
                sm += A[i];
                ca[i] = sm;
            }
            for ( ll j = i0; j < N-P; j++ ) {
                ll rm = (V - P - j) * M;
                ll f = (A[j]+M) * (N-P-j) - (ca[N-P] - ca[j]);
                if ( f >= rm ) {
                    return N - j;
                }
            }
            return P;
        }
    }
    return -1;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#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;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;



int n,k;

int dp[11][2010];

vi books[10];

int main(void){
	cin >> n >> k;
	rep(i,n){
		int c,g;
		cin >> c >> g;
		books[g-1].pb(c);
	}
	rep(i,10){
		sort(books[i].rbegin(),books[i].rend());
		rep(j,books[i].size()){
			 if(j)
				 books[i][j]+=books[i][j-1];
		} 
	}
	
	rep(i,10)rep(j,n+1){
		dp[i+1][j]=dp[i][j];
		rep(k,books[i].size()){
			if(j-(k+1)>=0)
				dp[i+1][j]=max(dp[i+1][j],dp[i][j-(k+1)]+books[i][k]+(k+1)*k);
		}
	}
	cout << dp[10][k] << endl;
	return 0;
}

Measured memory_bytes: 1316
#include<iostream>
#include<vector>
#include<cstdio>

using namespace std;
vector<int> books;

int m, n;

bool judge(int obs)
{
	int sum = 0;
	int cont = 1;
	for(int i = 0; i < books.size(); i++)
	{
		if(books[i] > obs) return false;
		if(sum + books[i] > obs)
		{
			cont++;
			sum = 0;
		}
		sum += books[i];
	}
	return ( (m >= cont)? true : false );
}

int main()
{
	int c;
	while(cin >> m >> n)
	{
		if(m ==0 && n == 0) break;
		for(int i = 0; i < n; i++)
		{
			cin >> c;
			books.push_back(c);
		}
		
		int ub = 1500000, lb = 0;

		while(ub - lb > 1)
		{
			int mid = (ub + lb) / 2;
			if(judge(mid)){
				ub = mid;
			}
			else{
				lb = mid;
			}
		}
		cout << ub << endl;
		books.clear();
	}
}

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

int main(){
  int n, x;
  cin >> n >> x;
  while(true){
    if(n == 0 && x == 0)
      break;
    int i, j, k;
    int ans = 0;
    for(int i = 1; i <= n; i++){
      for(int j = i + 1; j <= n; j++){
        for(int k = j + 1; k <= n; k++){
          if(i + j + k == x){
            ans++;
          }
        }
      }
    }
    cout << ans << endl;
    cin >> n >> x;
  }
  return 0;
}


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

int main() {
  int n, x;
  cin>>n>>x;
  vector<int> m;
  int min=1001;
  for(int i=0;i<n;i++){
    int j;
    cin>>j;
    m.push_back(j);
    if (min>j){
      min =j;
    }
    x-=j;
  }
  cout<<n+x/min<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	static int n;
	static String s;
	static Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args){
		n = sc.nextInt();
		s = sc.next();
		System.out.println(calcSlimesNum());
	}
	
	static int calcSlimesNum(){
		int sameLength = 0, res = 1;
		char prevChar = 'p';
		
		for(int i = 0; i < n; ++i){
			if(sameLength == 0){
				prevChar = s.charAt(i);
				++sameLength;
			}else if(s.charAt(i) == prevChar){
				++sameLength;
			}else{
				prevChar = s.charAt(i);
				sameLength = 1;
				++res;
			}
		}
		return res;
	}
}

Measured memory_bytes: 25556
l,r = map(int,input().split())

if (l==2019)or(r==2019)or(r-l>=2019):
    ans=0
    
elif r-l==1:
    ans = (r*l)%2019
else:
    ans=2019
    for i in range(l,r):
        for j in range(i+1,r+1):
            if (i*j)%2019 < ans:
                ans = (i*j)%2019
            if ans == 1:
                break
print(str(ans))

Measured memory_bytes: 39152
require "prime"
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
kind=Hash.new(0)
2.upto(N) do|x|
  primes=Prime.prime_division(x)
  primes.each do|k,v|
    kind[k]+=v
  end
end
p3=0
p5=0
p15=0
p25=0
p75=0
kind.each do|k,v|
  p3+=1 if v>=2
  p5+=1 if v>=4
  p15+=1 if v>=14
  p25+=1 if v>=24
  p75+=1 if v>=74
end
puts p5*(p5-1)/2*(p3-2)+p25*(p3-1)+p75+p15*(p5-1)

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

using namespace std;

using ll = long long;

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const int inf = (int) 1e9;
const int mod = (int) 1e9 + 7;

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

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

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];
	
	ll cnt = 0;
	bool remain = false;
	rep(i, n) {
		if (a[i] == 0) {
			remain = false;
			continue;
		}
		if (remain) {
			a[i]++;
		}
		if (a[i] % 2 == 0) {
			remain = false;
		} else {
			remain = true;
		}
		cnt += a[i] / 2;
	}
	
	
	cout << cnt << endl;
	
	return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    ll K;
    scanf("%lld", &K);

    string s;
    cin >> s;

    for (ll i = 0; i < min(K, (ll)s.length()); i++)
    {
        printf("%c", s[i]);
    }

    if (s.length() > K)
        printf("...");
}


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

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();

		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	public static boolean go(char[][] a,char[][] b,int m,int n){
		for(int i = 0 ; i + m <= n;i++){
			for(int j =0;j+m<=n;j++){
				boolean ok = true;
				for(int k = 0; k < m;k++){
					for(int l = 0; l < m;l++){
						if(a[i+k][j+l]!=b[k][l]) ok = false;
					}
				}
				if(ok){
					return true;	
				}	
			}
		}
		return false;	
	}	
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		int  m = in.nextInt();
		char[][] a = new char[n][n];
		char[][] b = new char[m][m];
		for(int i = 0; i < n ; i++){
			a[i] = in.next().toCharArray();
		}
		for(int i = 0 ; i < m ; i++){
			b[i] = in.next().toCharArray();
		}
		boolean check = go(a,b,m,n);
		if(check){
			out.println("Yes");
		}
		else{
			out.println("No");
		}
		out.flush();
		out.close();  
	}

}





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

#define count_ones __builtin_popcountl
#define all(a) a.begin(), a.end()
#define gcd(a, b) __gcd(a, b)
#define lca(a, b) a / __gcd(a, b) * b
typedef long long ll;
typedef long double ld;
using namespace std;

vector<vector<pair<ll, ll>>> g;
vector<ll> colors;

void dfs(ll cur, ll pred, ll color) {
    ll cur_color = 1;
    for (auto e : g[cur]) {
        ll to = e.first;
        if (to == pred) continue;
        if (cur_color == color) cur_color++;
        colors[e.second] = cur_color;
        dfs(to, cur, cur_color);
        cur_color++;
    }
}

int main() {
    ios::sync_with_stdio(false);

    ll n;
    cin >> n;

    g.resize(n);
    colors.resize(n - 1);

    for (ll i = 0; i < n - 1; i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back({b, i});
        g[b].push_back({a, i});
    }
    dfs(0, -1, 0);
    cout << *max_element(all(colors)) << "\n";
    for (auto c : colors) cout << c << "\n";

    return 0;
}

Measured memory_bytes: 9856
#include <iostream>
using namespace std;
int main(void) {
  int a, b, c;
  cin >> a >> b >> c;
  int mi, ma;
  mi = min(a, min(b, c));
  ma = max(a, max(b, c));
  cout << mi << " " << a + b + c - mi - ma << " " << ma << endl;
}



Measured memory_bytes: 3096
#include <iostream>

struct Node{int l, r, p, d, h;};

Node T[100];
int Preorder[100] = {};
int Inorder[100] = {};
int Postorder[100] = {};
int n = 0;

void SetDepth(int id, int d = 0) {
    T[id].d = d;
    if (T[id].l < 0) {
    }
}

int pos = 0;

int Reconstruct(int l, int r, int o = 0) {
    if (l >= r) {
        return o;
    }
    if (pos == n) {
        return o;
    }
    int tgt = Preorder[pos++];
    int idx = -1;
    for (int i = 0; i < n; i++) {
        if (Inorder[i] == tgt) {
            idx = i;
            break;
        }
    }
    o = Reconstruct(l, idx, o);
    o = Reconstruct(idx + 1, r, o);
    Postorder[o] = tgt;
    return ++o;
}


int main() {
    std::cin >> n;
    for (int i = 0; i < n; i++) {
        T[i] = {-1, -1 ,-1, -1, -1};
    }

    for (int i = 0; i < n; i++) {
        std::cin >> Preorder[i];
    }

    for (int i = 0; i < n; i++) {
        std::cin >> Inorder[i];
    }

    Reconstruct(0, n, 0);
    for (int i = 0; i < n; i++) {
        if (i) std::cout << " ";
        std::cout << Postorder[i];
    }
    std::cout << std::endl;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    cout << 6 - a - b << endl;


	return 0;
}


Measured memory_bytes: 3584
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050208;
/*------------main part------------*/



char maze[1005][1005];
char maze2[1005][1005];
int ans=0;
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			cin>>maze[i][j];
		}
	}
	for(int b=0;b<n;b++)
	{
		bool ok=true;
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				maze2[i][j]=maze[i][(j+b)%n];
			}
		}
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(maze2[i][j]!=maze2[j][i])
				{
					ok=false;
					break;
				}
			}
			if(ok==false)
				break;
		}
		if(ok)
		{
			ans++;
		}
	}
	cout<<ans*n;
	return 0;
}


Measured memory_bytes: 896
# -*- coding: utf-8 -*-
A, B = map(int,input().split())
import fractions

def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i:
        divisors.append(n//i)
  # divisors.sort()
  return divisors

n1 = make_divisors(A)
n2 = make_divisors(B)

answer = 0
n1_n2_set = set(n1) & set(n2)
n1_n2_list = list(n1_n2_set)
common_fractions = sorted(n1_n2_list)
# print(common_fractions)
varL = []
for i in range(len(common_fractions)):
  varsum = 0
  if len(varL) >= 1:
    for j in range(len(varL)):
      # print(common_fractions[i], varL[j], fractions.gcd(common_fractions[i], varL[j]))
      if fractions.gcd(common_fractions[i], varL[j]) != 1:
        varsum += 1
    if varsum == 0:
      answer += 1
      varL.append(common_fractions[i])
  else:
    varL.append(common_fractions[i])
    answer += 1

print(answer)

Measured memory_bytes: 7224
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) throws IOException {
		final Scanner sc = new Scanner(System.in);
		
		final int n = sc.nextInt();
		final int m = sc.nextInt();
		
		int[] from = new int[m];
		int[] to = new int[m];
		int[] cost = new int[m];
		for(int i = 0; i < m; i++){
			final int f = sc.nextInt() - 1;
			final int t = sc.nextInt() - 1;
			final int c = sc.nextInt();
			
			from[i] = f;
			to[i] = t;
			cost[i] = c;
		}
		
		long[][] adj = new long[n][n];
		for(int i = 0; i < n; i++){
			for(int j = 0; j < n; j++){
				adj[i][j] = Integer.MAX_VALUE;
			}
		}
		
		for(int i = 0; i < m; i++){
			adj[from[i]][to[i]] = adj[to[i]][from[i]] = cost[i];
		}
		
		for(int k = 0; k < n; k++){
			for(int i = 0; i < n; i++){
				for(int j = 0; j < n; j++){
					adj[i][j] = Math.min(adj[i][j], adj[i][k] + adj[k][j]);
				}
			}
		}
		
		int count = 0;
		for(int i = 0; i < m; i++){
			final int f = from[i];
			final int t = to[i];
			final int c = cost[i];
			
			if(adj[f][t] < c){
				count++;
			}
		}
		
		System.out.println(count);
	}
	
	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;
 
		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}
 
		private void getLine() throws IOException {
			while (!hasNext()) {
				tok = new StringTokenizer(br.readLine());
			}
		}
 
		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}
 
		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
		
		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}
 
		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 9428
/*
 * atcoder/abc130/a.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

int x;

void input() {
  cin >> x;
}

void solve() {
  if (x==3||x==5|x==7) {
    cout << "YES" << endl;
  }
  else cout << "NO" << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<math.h>
#include<utility>
#include<climits>

using namespace std;

 int main(){
	long long int n;
	cin>>n;
	long long int ar[n];
	long long int sum[n];
	long long int flag=1;
	for(long long int i=0;i<n;i++){
		cin>>ar[i];
		if(flag){
			sum[i]=ar[i];
			flag=0;	
		}
		else
		sum[i] = sum[i-1]+ar[i];

	}

	long long int dp[n][n];
	for(long long int i=0;i<n;i++) 
        dp[i][i]=0;
   

	for(long long int l=2;l<=n;l++){
		for(long long int i=0;i<=n-l;i++){
			long long int j = i+l-1;
			long long int temp = LONG_MAX;
			for(long long int k=i;k<i+l-1;k++){
				if(i==0)
					temp = min(temp,dp[i][k]+dp[k+1][j]+sum[j]);
				else
					temp = min(temp,dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
			}
			dp[i][j] = temp;
		}
	}
	cout<<dp[0][n-1];

}


Measured memory_bytes: 1536
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    D = int(input())
    c = [0] + list(map(int, input().split()))
    s = [[0]*27]
    for _ in range(D):
        s.append([0] + list(map(int, input().split())))
    i = 1
    for _ in range(D):
        print(i)
        i += 1
        if i > 26:
            i = 1

if __name__ == '__main__':
    main()

Measured memory_bytes: 9584
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
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; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    int ans = 0;
    rep(i,n){
        int h;
        cin >> h;
        if(h >= k) ++ans;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
using namespace std;
int INF = 1e9;

bool has_loop(vector< vector<int> > G){
  int n = G.size();
  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
        G[i][j] = min(G[i][j],G[i][k] + G[k][j]);
      }
    }
  }
  for(int i = 0; i < n; ++i){
    if(G[i][i] < INF) return true;
  }
  return false;
}

int main(){
  int n;
  while(cin >> n, n){
    vector<string> S(n);
    for(int i = 0; i < n; ++i){
      cin >> S[i];
    }
    if(n == 1){
      cout << "yes" << endl;
      continue;
    }
    vector< vector<int> > G(26, vector<int>(26,INF));
    bool f = true, g = false;
    for(int i = 1; i < n; ++i){
      if(S[i-1] == S[i]) continue;
      for(int j = 0; j < min(S[i].length(),S[i-1].length()); ++j){
        f = true;
        if(S[i][j] != S[i-1][j]){
          //G[S[i-1][j] - 'a'].push_back(S[i][j] - 'a');
          G[S[i-1][j] - 'a'][S[i][j] - 'a'] = 1;
          f = false;
          break;
        }
      }
      if(f && S[i-1].size() > S[i].size()){
        cout << "no" << endl;
        g = true;
        break;
      }else{
        f = false;
      }
    }
    if(g) continue;

    if(has_loop(G)) cout << "no" << endl;
    else cout << "yes" << endl;
  }
  return 0;
}



Measured memory_bytes: 3196
n = int(input())
s = input()
r = s.count('R')
g = s.count('G')
b = s.count('B')
ans = r*g*b
for i in range(n):
  for j in range(i+1,n):
    k = 2*j-i
    if k < n:
      if  s[i] != s[j] and s[j]!= s[k] and s[i] != s[k]:
        ans -= 1
print(ans)

Measured memory_bytes: 68072
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

int d[17];
int dk[101];
int g[101][101];
int co[1<<17];
int main(){
    int n,m,k;
    cin>>n>>m>>k;
    memset(dk,-1,sizeof(dk));
    rep(i,m){
        cin>>d[i];
        --d[i];
        dk[d[i]]=i;
    }
    int vi;
    rep(i,n){
        rep(j,k){
            cin>>vi;
            --vi;
            g[i][j]=vi;
        }
    }
    rep(i,1<<m) co[i]=1000100010;
    co[(1<<m)-1]=0;
    queue<int> q;
    q.push((1<<m)-1);
    while(!q.empty()){
        int b=q.front();q.pop();
        rep(i,k){
            int nb=0;
            rep(j,m){
                if(b&(1<<j)){
                    if(dk[g[d[j]][i]]>=0) nb|=(1<<dk[g[d[j]][i]]);
                }
            }
            if(co[nb]>co[b]+1){
                co[nb]=co[b]+1;
                if(nb==0){
                    cout<<co[nb]<<endl;
                    return 0;
                }
                q.push(nb);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <algorithm>
using namespace std;
pair <int,int> a[1000005];
inline bool cmp(pair <int,int> x,pair <int,int> y)
{
	if(x.second-x.first>=0&&y.second-y.first<0) return 1;
	if(x.second-x.first<0&&y.second-y.first>=0) return 0;
	if(x.second-x.first>=0) return x.first<y.first;
	else return -x.first+x.second-y.first>-y.first+y.second-x.first;
}
int main(int argc, char** argv) {
	int n;
	cin >> n;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin >> s;
		int l=0,r=0;
		for(auto x:s)
		{
			if(x=='(') ++l;
			else if(l) --l;
			else ++r;
		}
		a[i]={r,l};
	//	cout << a[i].first << " " << a[i].second << "\n";
	}
	sort(a+1,a+n+1,cmp);
	int now=0;
	for(int i=1;i<=n;i++)
	{
		now-=a[i].first;
		if(now<0)
		{
			puts("No");
			return 0;
		}
		now+=a[i].second;
	}
	if(now) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 10828
#include<iostream>
#include<cstdio>
using namespace std;
int k,n,now;
const int N=505;
int A[N][N];
int main()
{
	cin>>k;
	if(k<=500)
	{
		cout<<k<<endl;
		for(int i=1;i<=k;++i,puts(""))
			for(int j=1;j<=k;++j)printf("%d ",i);
	}
	else
	{
		n=500;cout<<500<<endl;k-=n;
		for(int i=1,a,b,x,y;i<=n;++i)
		{
			a=++now;b=k?++now:now;k-=b-a;
			x=1;y=i;
			for(;x<=n;++x,y=(y==n?1:y+1))A[x][y]=x&1?a:b;
		}
		for(int i=1;i<=n;++i,puts(""))
			for(int j=1;j<=n;++j)printf("%d ",A[i][j]);
	}
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>

int main(){
  char a[4];
  scanf("%s%s%s%s",&a[0],&a[1],&a[2],&a[3]);
  int flag = 1;
  if(a[0] == a[1]){
    if(a[2] == a[3] && a[0] != a[2]) flag = 0;
    else flag = 1;
  }
  else{
    if(a[0] == a[2] && a[1] == a[3]) flag = 0;
    else if(a[0] == a[3] && a[1] == a[2]) flag = 0;
  }
  if(flag == 0) printf("Yes\n");
  else printf("No\n");
  return 0;
}

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

int main(void){
    int n,h_max,cnt,i;
    cnt = 1;
    cin >> n;
    vector<int> h(n+1);
    cin >> h.at(1);
    h_max = h.at(1);

    for(i=2; i<=n; i++){
        cin >> h.at(i);
        if(h.at(i) - h_max >= 0){
            cnt++;
        }
        h_max = max(h_max,h.at(i));
    }
    cout << cnt << endl;
    return 0;
}

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

 ll n; cin>>n;
  ll ans=1;
  
  vector<ll>a(n); 
  rep(i,n){cin>>a.at(i); 
          if(a.at(i)==0){ans=0;}}
  
  long double asa=1000000000000000000.0;
  
  if(ans==0){cout<<0<<endl;}
  else{
  rep(j,n){ if(asa/a.at(j)<ans){ans=-1;break;}
    else{ans*=a.at(j);} 
          }
 
    if(ans==-1){cout<<-1<<endl;}
  else{cout<<ans<<endl;}
  }
 
  
return 0; }



Measured memory_bytes: 4040
import Control.Applicative
import Data.Fixed

main = do
    [a,b] <- map (read :: String -> Int) . words <$> getLine
    putStrLn $
        show (a `div` b) ++ " " ++
        show (a `mod` b) ++ " " ++
        show ((realToFrac a) / (realToFrac b) :: Fixed E9)

Measured memory_bytes: 4080
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
ll mod =  1000000007;
ll maxn = 1000000000;
 
//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------
 
int main(){
    int n,l,min_taste=1000000,sum_taste=0;
    cin>>n>>l;
    vi taste(n);
    rep(i,n){
        taste.at(i)=l+i;
        
        min_taste= min(min_taste , abs(taste.at(i)));

        sum_taste+=taste.at(i);
    }
    if(sum_taste<0){
            cout<<sum_taste + min_taste<<endl;

    }
    else cout<<sum_taste-min_taste<<endl;
}
   



Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) throws IOException{
	Scanner sc = new Scanner(System.in);
	double r;
	double cir,area;

	r = Double.parseDouble(sc.next());
	cir = 2*Math.PI*r;
	area = Math.PI*r*r;

	System.out.printf("%.6f %.6f", area,cir);
	sc.close();
	}
}

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

long long k, s, t;
int main(){
	cin >> k >> s;
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= min(k, s-i); j++){
			if(s-i-j <= k) t++;
		}	
	}
	cout << t;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,X,Y;
    cin >> N >> X >> Y;
    
    int Ans[10000]={};
    
    //閉路はY-X+1個構成
    int K = Y-X+1;
    REP(i,(K-1)/2){
        Ans[i+1]+=K;
    }
    if(K%2==0){
        Ans[(K+1)/2]+=(K/2);
    }
    
    int P=X-1,Q=N-Y;
    REP(i,P){
        Ans[i+1]+=1;
        REP(j,(K-1)/2){
            Ans[i+j+2]+=2;
        }
        if(K%2==0){
            Ans[i+1+(K+1)/2]++;
        }
    }
    REP(i,Q){
        Ans[i+1]+=1;
        REP(j,(K-1)/2){
            Ans[i+j+2]+=2;
        }
        if(K%2==0){
            Ans[i+1+(K+1)/2]++;
        }
    }
    
    
    REP(i,P-1){
        Ans[i+1]+=P-i-1;
    }
    REP(i,Q-1){
        Ans[i+1]+=Q-i-1;
    }
    
    REP(i,P){
        REP(j,Q){
            Ans[i+j+3]++;
        }
    }
    
    
    
    REP(i,N){
        if(i==0)continue;
        cout << Ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 384
use std::io;
use std::io::Read;

fn main(){
    let mut stdin = io::stdin();
    let mut lines_str = String::new();
    let _ = stdin.read_to_string(&mut lines_str);
    let lines_vec = lines_str.lines().collect::<Vec<&str>>();
    let n :usize = lines_vec[0].trim().parse().unwrap();
    let s_vec = lines_vec[1].trim().chars().collect::<Vec<char>>();

    let mut max_len = 0;
    let mut len :Vec<Vec<usize>> = Vec::new();
    for i in 0..n {
        len.push(vec![0;i]);
        for j in 0..i {
            if s_vec[i] != s_vec[j] {
                continue;
            }
            if j == 0 {
                len[i][j] = 1;
                if max_len < len[i][j] {
                    max_len = len[i][j];
                }
            } else {
                len[i][j] = len[i-1][j-1] + 1;
                if len[i][j] > i-j {
                    len[i][j] = i-j;
                }
                if max_len < len[i][j] {
                    max_len = len[i][j];
                }
            }
        }
    }

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


Measured memory_bytes: 99880