akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];

//big priority queue
priority_queue <ll> pql;
priority_queue <P> pqp;

//small priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;

//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj,n,m;
ll a,b,c,d,e,g,h,r,l,w,num,ans;
ll x[500005],y[500005],z[500005];
ll dp[300005];
bool flag,dame,ng;

int main(){    
    cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> x[i];
	}
	dp[0] = 2;
	for(i=1;i<=k;i++){
		flag = false;
		for(j=0;j<n;j++){
			if(i - x[j] < 0)continue;
			if(dp[i-x[j]] == 2){
				flag = true;
			}
		}
		if(flag){
			dp[i] = 1;
		}else{
			dp[i] = 2;
		}
		//pe(dp[i]);
	}
	//el;
	if(dp[k] == 2){
		p("Second");
	}else{
		p("First");
	}

    return 0;
}

Measured memory_bytes: 28288
using System;
using System.Numerics;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split();
            var h = BigInteger.Parse(s[0]);
            var w = BigInteger.Parse(s[1]);

            if(h == 1 || w == 1){
                Console.WriteLine(1);
            }else{
                var x = h * w;
                Console.WriteLine(x % 2 == 0 ? x / 2 : x / 2 + 1);
            }
        }
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

    if (x % y == 0) {
        cout << "-1" << endl;
        exit(0);
    }

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


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <optional>
#include <vector>

#define REP(i, n) for (decltype(n) i = 0; i < (n); ++i)
using namespace std;
using i64 = long long;
using u64 = unsigned long long;

int N, M;
i64 INF = 1LL << 60;

optional<u64> bfs(const vector<i64>& xv, const vector<i64>& yv,
                  vector<vector<char>>& grid) {
  vector<tuple<int, int>> steps{{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
  deque<tuple<int, int>> que;
  int c0 = lower_bound(xv.begin(), xv.end(), 0) - xv.begin();
  int r0 = lower_bound(yv.begin(), yv.end(), 0) - yv.begin();
  que.emplace_back(2 * r0 + 1, 2 * c0 + 1);

  while (que.size()) {
    const auto& [r, c] = que.front();
    que.pop_front();
    for (const auto& [dr, dc] : steps) {
      int rn = r + dr, cn = c + dc;
      if (rn < 0 || rn >= int(grid.size()) || cn < 0 ||
          cn >= int(grid[0].size())) {
        return nullopt;
      }
      if (grid[rn][cn] != 0) {
        continue;
      }
      grid[rn][cn] = 1;
      que.emplace_back(rn, cn);
    }
  }

  u64 area = 0;
  REP(r, yv.size()) {
    REP(c, xv.size()) {
      char s = grid[2 * r + 1][2 * c + 1];
      if (s == 1) {
        area += (xv[c + 1] - xv[c]) * (yv[r + 1] - yv[r]);
      }
    }
  }
  return area;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  cin >> N >> M;
  vector<tuple<i64, i64, i64>> verticals(N);
  vector<tuple<i64, i64, i64>> horizontals(M);
  vector<i64> xv, yv;
  xv.reserve(N + 2 * M + 10);
  yv.reserve(2 * N + M + 10);
  xv.push_back(0);
  yv.push_back(0);
  yv.push_back(INF);
  yv.push_back(-INF);
  REP(i, N) {  // vertical lines
    i64 a, b, c;
    cin >> a >> b >> c;
    verticals[i] = make_tuple(a, b, c);
    yv.push_back(a);
    yv.push_back(b);
    xv.push_back(c);
  }
  REP(i, M) {  // horizontal lines
    i64 d, e, f;
    cin >> d >> e >> f;
    horizontals[i] = make_tuple(d, e, f);
    yv.push_back(d);
    xv.push_back(e);
    xv.push_back(f);
  }
  sort(xv.begin(), xv.end());
  xv.erase(unique(xv.begin(), xv.end()), xv.end());
  sort(yv.begin(), yv.end());
  yv.erase(unique(yv.begin(), yv.end()), yv.end());
  vector<vector<char>> grid(yv.size() * 2, vector<char>(xv.size() * 2, 0));
  REP(i, N) {
    auto [a, b, c] = verticals[i];
    int r1 = lower_bound(yv.begin(), yv.end(), a) - yv.begin();
    int r2 = lower_bound(yv.begin(), yv.end(), b) - yv.begin();
    int ci = lower_bound(xv.begin(), xv.end(), c) - xv.begin();
    for (int rd = 2 * r1; rd < 2 * r2; ++rd) {
      grid[rd][2 * ci] = 2;
    }
  }
  REP(i, M) {
    auto [d, e, f] = horizontals[i];
    int ri = lower_bound(yv.begin(), yv.end(), d) - yv.begin();
    int c1 = lower_bound(xv.begin(), xv.end(), e) - xv.begin();
    int c2 = lower_bound(xv.begin(), xv.end(), f) - xv.begin();
    for (int cd = 2 * c1; cd < 2 * c2; ++cd) {
      grid[2 * ri][cd] = 2;
    }
  }

  auto result = bfs(xv, yv, grid);
  if (!result) {
    cout << "INF" << endl;
  } else {
    cout << *result << endl;
  }
}


Measured memory_bytes: 38536
N, K = map(int, input().split())
D = list(map(int, input().split()))
iscollect = False
while(True):
    for i in D:
        if str(i) in str(N):
            N += 1
            break
        else:
            if i == D[-1]:
                iscollect = True
                break
    if iscollect:
        break
print(N)
        
                

Measured memory_bytes: 3060
N = int(input())
P = [list(map(int, input().split())) for _ in range(N)]

P.sort(key=lambda x: x[0]+x[1])

leave = [P[0]]
for i in range(1, N):
    # leaveの最大を取得
    leave_max = leave[-1][0] + leave[-1][1]
    p_min = P[i][0] - P[i][1]
    if leave_max <= p_min:
        leave.append(P[i])
    else:
        continue
        
print(len(leave))

Measured memory_bytes: 70232
# C - Rally

n = int(input())
x = list(map(int,input().split()))

c = []
x_ave = int(sum(x)/n)
s = 0
for i in range(n):
    s += (x[i]-x_ave)**2
c.append(s)
s = 0
for i in range(n):
    s += (x[i]-x_ave-1)**2
c.append(s)


print(min(c))


Measured memory_bytes: 9116
/*??£?¨?*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int main()
{
	static long long int n, m, a[100001] = { 0 }, b[100001] = { 0 }, c[100001] = { 0 }, p[100001] = { 0 }, mv[100001] = { 0 };
	long long int ans = 0;
	cin >> n >> m;
	rep(i, m)
		cin >> p[i];
	rep1(i, n - 1)
		cin >> a[i] >> b[i] >> c[i];
	rep1(i, m-1)
	{
		if (p[i-1] < p[i])
		{
			for (int j = p[i - 1]; j < p[i]; j++)
				mv[j]++;
		}
		else
		{
			for (int j = p[i - 1]-1; j >= p[i]; j--)
				mv[j]++;
		}
	}
	rep1(i, n - 1)
	{
		ans += min(a[i] * mv[i], b[i] * mv[i] + c[i]);
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
ll A[int(1e5+5)], sum[int(1e5+5)];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A, A + N);

  sum[0] = A[0];
  for (int i = 1; i < N; i++){
    sum[i] = sum[i-1] + A[i];
  }

  int ans = N;
  for (int i = 0; i < N - 1; i++){
    if (sum[i] * 2 < A[i + 1]) ans = N - i - 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5164
#include<bits/stdc++.h>
#define Re read()
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define fd(i,a,b) for(register int i=a;i>=b;--i)
using namespace std;
typedef long long ll;
const int N = 1e6;

inline int read(int n=0) {
    register char ch;while(!isdigit(ch=getchar()));
    for(n=ch^48;isdigit(ch=getchar());n=(n<<3)+(n<<1)+(ch^48));return n;
}
ll n,s;
int main() {
	cin>>n;
	int s=sqrt(n)+1;
	while(--s) if(n%s==0){
			if(n/s>9||s>9)cout<<"No";
			else cout<<"Yes";
			return 0;
		}
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
typedef long long ll;
#define DEBUG
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#else
#define s(...)
#endif
void show() {std::cout<<std::endl;}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<",";show(args...);}
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

int main(){
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    //s(A,B,C,K);
    if(A+B>=K)cout<<min(A,K);
    else cout <<A-(K-A-B);
    //auto w = new vector<vector<int>>(K, vector<int>(D));
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    return 0;
}


Measured memory_bytes: 3632
/*
THE BEST IS YET TO COME
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define r(i,s,l) for(int i=s;i<l;i++)
#define mod 1000000007
#define INT_BITS 32
#define ld long double
#define pp pair<long long,long long>
#define ss second
#define ff first
#define N 2000005
#define all(a) a.begin(),a.end()
#define pb push_back
using namespace std;
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
}

int main()
{
    fast();
    int n;
    cin>>n;
    vector<double> a(n);
    r(i,0,n)
    cin>>a[i];
    sort(all(a));
    double ans=0;
    r(i,1,n)
    {

        double x=a[i]+a[i-1];
        ans = double(x)/2;
       // cout<<ans<<endl;
        a[i]=ans;
    }
    //cout<<a[n-1]<<endl;
    cout<<setprecision(8)<<ans;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int k,x,m,M;
  cin >> k >> x;
  m=max(-1000000,x-k+1),M=min(1000000,x+k-1);
  for(int i=m; i<M; i++) {
    cout << i << " ";
  }
  cout << M << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(!isdigit(c)){	if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getchar();}
	return x*f;
}
inline void print(int x){
	if(x<0) x=-x,putchar('-');
	if(x>=10) print(x/10);
	putchar(x%10+48);
}
int n,m;
int L[200010],R[200010];
struct seg{
	int minn[800010],fi[800010];
	void pushdown(int p,int l,int r){
		if(fi[p]){
			int mid=l+r>>1;
			minn[p<<1]=fi[p];fi[p<<1]=fi[p];
			minn[p<<1|1]=fi[p]+mid+1-l;fi[p<<1|1]=minn[p<<1|1];
			fi[p]=0;
		}
	}
	void pushup(int p){
		minn[p]=min(minn[p<<1],minn[p<<1|1]);
	}
	void cover(int p,int l,int r,int L,int R,int fir){
		if(l>=L&&r<=R){
			fi[p]=fir+l-L;minn[p]=fir+l-L;return ;
		}
		pushdown(p,l,r);
		int mid=l+r>>1;
		if(L<=mid) cover(p<<1,l,mid,L,R,fir);
		if(R>mid) cover(p<<1|1,mid+1,r,L,R,fir);
		pushup(p);
	}
	int query(int p,int l,int r,int L,int R){
		if(l>=L&&r<=R){
			return minn[p];
		}
		pushdown(p,l,r);
		int mid=l+r>>1;
		int res=0x3f3f3f3f;
		if(L<=mid) res=min(res,query(p<<1,l,mid,L,R));
		if(R>mid) res=min(res,query(p<<1|1,mid+1,r,L,R));
		pushup(p);
		return res;
	}
}T;
int main(){
	n=read(),m=read();
	for(int i=1;i<=n;++i) L[i]=read(),R[i]=read();
	for(int i=1;i<=n;++i){
		if(L[i]==1){
			T.cover(1,1,m,L[i],R[i],0x3f3f3f3f);
		}
		else {
			int num=T.query(1,1,m,L[i]-1,L[i]-1);
			T.cover(1,1,m,L[i],R[i],num+1);
		}
//		for(int j=1;j<=m;++j) printf("%d ",T.query(1,1,m,j,j));
//		putchar('\n');
		int ans=T.query(1,1,m,1,m);
//		printf("%d\n",ans);
		if(ans>=0x3f3f3f15) printf("%d\n",-1);
		else printf("%d\n",ans+i);
	}
	return 0;
}

Measured memory_bytes: 9352
import os

def main():
	s = input()
	count = 0
	flag = True
	for i in s:
		count += 1
		if count%2 == 0:
			if i == "R":
				flag = False
				break
		else:
			if i == "L":
				flag = False
				break
	if flag:
		print("Yes")
	else:
		print("No")	


if __name__ == "__main__":
	main()


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
	ll h1,m1,h2,m2,k;
	cin>>h1>>m1>>h2>>m2>>k;
	ll x=h2*60+m2-h1*60-m1-k;
	if(x<0)
	x=0;
	cout<<x;
	return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repe(i, n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
const int INF = 1e9;
const ll mod = 1000000007;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main() {
    int a,b,h;
    cin >> a >> b >> h;
    int s = (a+b)*h/2;
    cout << s << "\n";
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const double PI2 = 8.0 * atan(1.0);
 
#define REP(i,n)	for(int i=0;i<(int)n;++i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define FOR(i,s,n)	for(int i=s;i<(int)n;++i)

int main(){
    string s;
    cin >> s;
    int ans = 0;
    char goopaa[] = {'g', 'p'};

    for(int i=0;i<s.size();i++) {
        if(s[i] == 'g' && goopaa[i%2] == 'p')
            ans++;
        else if(s[i] == 'p' && goopaa[i%2] == 'g')
            ans--;
    }
    cout << ans<< endl;


}


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

typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PDD;

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

LL dp[2005][2005];

int main() {
  _upgrade;
  int n;
  cin >> n;

  vector<PLL> A(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    A[i] = {a, i};
  }
  sort(all(A));
  reverse(all(A));

  for (int i = 0; i < n; i++) {
    LL val, pos;
    tie(val, pos) = A[i];

    for (int front = i; front >= 0; front--) {
      int back = i - front;
      dp[front + 1][back] =
          max(dp[front + 1][back], dp[front][back] + val * abs(front - pos));
      dp[front][back + 1] = max(
          dp[front][back + 1], dp[front][back] + val * abs(n - 1 - back - pos));
    }
  }

  LL res = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      if (i + j == n) {
        res = max(res, dp[i][j]);
      }
    }
  }

  cout << res << "\n";
  return 0;
}

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

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

	bool bad = false;
	char prev = code[0];
	int n = 4;
	for (int i = 1; i < n; ++i) {
		if (prev == code[i]) {
			bad = true;
		}
		prev = code[i];
	}

	if (bad) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	n, err := strconv.Atoi(nextString())
	if err != nil {
		fmt.Printf("strconv.Atoi failed: %v\n", err)
	}
	return n
}

var infty = 1000000000

type nodeKey int

type DirectedGraphNode struct {
	key       nodeKey
	adjacents []*DirectedGraphNode
	visited   bool
	d         int
	f         int
	parent    *DirectedGraphNode
}

type DirectedGraph struct {
	nodes []*DirectedGraphNode
}

func (g *DirectedGraph) setAdjacency(l, r nodeKey) {
	g.nodes[l].adjacents = append(g.nodes[l].adjacents, g.nodes[r])
}

func newDirectedGraph(nNodes int) *DirectedGraph {
	graph := DirectedGraph{}
	graph.nodes = make([]*DirectedGraphNode, nNodes)
	for iNodes := 0; iNodes < nNodes; iNodes++ {
		graph.nodes[iNodes] = &DirectedGraphNode{}
		graph.nodes[iNodes].key = nodeKey(iNodes)

		graph.nodes[iNodes].visited = false
		graph.nodes[iNodes].d = infty
		graph.nodes[iNodes].f = infty
		graph.nodes[iNodes].parent = nil
	}
	return &graph
}

type QueueEntry struct {
	node *DirectedGraphNode
	next *QueueEntry
}

type Queue struct {
	head, tail *QueueEntry
}

func (q *Queue) enqueue(node *DirectedGraphNode) {
	entry := QueueEntry{}
	entry.node = node

	if q.tail == nil {
		q.head = &entry
		q.tail = &entry
		return
	}

	q.tail.next = &entry
	q.tail = q.tail.next
}

func (q *Queue) dequeue() *QueueEntry {
	if q.head == nil {
		return nil
	}
	poped := q.head
	q.head = q.head.next
	if q.head == nil {
		q.tail = nil
	}
	return poped
}

func (q *Queue) isEmpty() bool {
	return q.head == nil
}

var time = 0

func fillDistancesByDepthFirstSearch(g *DirectedGraph) {
	for _, u := range g.nodes[1:] {
		if !u.visited {
			dfsVisit(g, u)
		}
	}
}

func dfsVisit(g *DirectedGraph, u *DirectedGraphNode) {
	time++
	u.d = time

	u.visited = true
	for _, v := range u.adjacents {
		if !v.visited {
			v.parent = u
			dfsVisit(g, v)
		}
	}
	time++
	u.f = time
}

func main() {
	scanner.Split(bufio.ScanWords)

	nNodes := nextInt()
	g := newDirectedGraph(nNodes + 1)

	for iNode := 0; iNode < nNodes; iNode++ {
		nodeKeyLeft := nodeKey(nextInt())
		nAdj := nextInt()
		for iAdj := 0; iAdj < nAdj; iAdj++ {
			nodeKeyRight := nodeKey(nextInt())
			g.setAdjacency(nodeKeyLeft, nodeKeyRight)
		}
	}

	fillDistancesByDepthFirstSearch(g)

	for iNode := 1; iNode <= nNodes; iNode++ {
		node := g.nodes[iNode]
		fmt.Println(node.key, node.d, node.f)
	}
}



Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 999999999
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
bool sosu(int n) {
  if (n <= 1)
    return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0)
      return false;
  return true;
}
int main() {
  int n, x;
  while (cin >> n >> x, n) {
    bool dp[1000001] = {};
    dp[0] = 1;
    int a[50];
    rep(i, n) { cin >> a[i]; }
    rep(i, n) rep(j, x) {
      if (j + a[i] < 1000001)
        if (dp[j])
          dp[j + a[i]] = 1;
    }
    for (int i = x; i > 1; i--) {
      if (dp[i])
        if (sosu(i)) {
          cout << i << endl;
          goto end;
        }
    }
    cout << "NA" << endl;
  end:;
  }
  return 0;
}

Measured memory_bytes: 3992
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,s,a;
	while(cin>>n,n){
		cin>>a;
		m=s=a;n--;
		while(n--){
			cin>>a;
			if(s<0)s=a;
			else s+=a;
			m=max(s,m);
		}
		cout<<m<<endl;
	}
}

Measured memory_bytes: 2980
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeMap;



 class Main{
	 
	 
	 
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		long h[] = new long[N+1];
		for(int i = 0;i<N;i++)h[i] =sc.nextLong();
		 
		long[]dp = new long[N+1];

		for(int i = 1;i<N;i++) {
			if(i-K>=0){
				long dpcost = Long.MAX_VALUE;
				
				for(int j = 1;j<=K;j++) {
					if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
						dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
						
					}
				}

				dp[i] =dpcost;

			}else {
				long dpcost = Long.MAX_VALUE;
				
				for(int j = 1;j<=i;j++) {
					if(dpcost>dp[i-j]+Math.abs(h[i]-h[i-j])) {
						dpcost = dp[i-j]+Math.abs(h[i]-h[i-j]);
						
					}

				}


				dp[i] =dpcost;

			}
		}

		System.out.println(dp[N-1]);
		
				
	}
	
	
	
	
 
	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}


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

using namespace std;

int main(){
	char s[15];
	scanf("%s",s); printf("%c",s[0]-'a'+'A');
	scanf("%s",s); printf("%c",s[0]-'a'+'A');
	scanf("%s",s); printf("%c",s[0]-'a'+'A');
} 

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

#define all(x) (x).begin(),(x).end()
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;



int main()
{
    int k, x;
    cin >> k >> x;
    if (k*500 >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}



Measured memory_bytes: 256
N = int(input())
ans = 0
D = []

for i in range(N):
    d1, d2 = map(int, input().split())
    D.append([d1,d2])

for i in range(N-2):
    if D[i][0] == D[i][1]:
        if D[i+1][0] == D[i+1][1]:
            if D[i+2][0] == D[i+2][1]:
                ans = 1

if ans:
    print("Yes")
else:
    print("No")

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

int main() {
  int A, B;
  cin >> A >> B;

  int count = 0;
  int outlets = 1;
  while (outlets < B) {
    ++count;
    outlets += A - 1;
  }

  cout << count << "\n";

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=998244353;
const ll LINF=1LL<<60;
const int INF=1<<30;
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; }

//nもrも10^5くらいのときにはこれ使うと良き
//二項係数の計算
const int MAX = 510000;
ll fac[MAX],finv[MAX],inv[MAX];

//テーブルの初期化
void COMinit(){
	fac[0] = fac[1] = 1;//階乗
	finv[0] = finv[1] = 1;//階乗の逆元
	inv[1] = 1;//逆元(1の逆元は1)
	for(int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % mod;//累積積的な感じ
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;//inv[i] = iの逆元(mod mod)
		finv[i] = finv[i - 1] * inv[i] % mod;//階乗の逆元の計算
	}
}

//繰り返し二乗法
ll mod_pow(ll x,ll n){
	ll res = 1;
	while(n > 0){
		if(n & 1){
			res = res * x % mod;
		}
		x = x * x % mod;
		n >>= 1;
	}
	return res;
}


ll COM(int n,int k){//二項係数の計算
	if(n < k){
		return 0;
	}
	if (n < 0 || k < 0){
		return 0;
	} 
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main(){
	ll ans = 0;
	ll n,m,k;cin>>n>>m>>k;
	COMinit();
	for(int i = 0; i <= k; i++) {
		ll x = m;
		x *= mod_pow(m - 1,n - i - 1);
		x %= mod;
		if (i != 0){
			x *= COM(n - 1,i);
			x %= mod;
		}	
		ans += x;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 15604
import bisect

s = input()

ans = [0] * len(s)

black_hole = [False] * len(s)
black_hole_index = []
for i in range(len(s) - 1):
    if s[i:i+2] == "RL":
        black_hole[i] = True
        black_hole[i+1] = True
        black_hole_index.append(i)

for i, c in enumerate(s):
    if black_hole[i]:
        ans[i] += 1
    elif c == "R":
        goal = black_hole_index[bisect.bisect(black_hole_index, i)]
        if (goal - i) % 2 == 0:
            ans[goal] += 1
        else:
            ans[goal+1] += 1
    else:
        goal = black_hole_index[bisect.bisect(black_hole_index, i) - 1]
        if (goal - i) % 2 == 0:
            ans[goal] += 1
        else:
            ans[goal+1] += 1

print(*ans)


Measured memory_bytes: 54364
//模範解答を写経
package main

import "fmt"

const MOD = 1e9 + 7

var h, w, k int //h:あみだくじの横線の本数 w:あみだくじの縦線の本数 k:あみだくじを1からスタートしたときの目的の箇所
var dp [][]int

func main() {
	fmt.Scan(&h, &w, &k)
	//あみだくじ縦1本線の時は、k==1以外は答え無し
	if w == 1 {
		if k == 1 {
			fmt.Println(1)
		} else {
			fmt.Println(0)
		}
		return
	}

	//(h+1,w)の形の配列(行列？）を作成する
	//dp[i][j] -> i番目の横線を通過した後に、j番目の縦線にいる数
	dp = make([][]int, h+1)
	for i := range dp {
		dp[i] = make([]int, w)
	}
	//0番目の横線を通過(スタート)時に、0番目の縦線には必ず1つデータがあるはず
	dp[0][0] = 1

	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			//bit表現
			//k0=0,k1=01,k2=10,k3=11
			//k0:1本も横線なし
			//k1:1本横線あり
			//k2:1本横線あり
			//k3:2本となりあう横線あり
			for k := 0; k < 1<<uint64(w-1); k++ {
				//i番目の横線がある場合の数
				//2^(w-1)個の場合の数がある隣り合う
				//2つの線がつながっていないか調べる
				ok := true
				for l := 0; l < w-2; l++ {
					//l:0~w-2, l+1:1~w-1
					if ((k>>uint64(l))&1 == 1) && ((k>>uint64(l+1))&1 == 1) {
						//隣り合うときは無視
						ok = false
						break
					}
				}
				//ここまできたらkの値だけを見ると、i番目の高さの横線の1パターンが決まる
				if ok {
					//左方向に横線があるとき
					//j番目の縦線は1以上
					if j >= 1 && ((k >> uint64(j-1) & 1) == 1) {
						dp[i+1][j-1] += dp[i][j]
						dp[i+1][j-1] %= MOD
					} else if j <= w-2 && ((k>>uint64(j))&1 == 1) { //右方向に横線があるとき
						dp[i+1][j+1] += dp[i][j]
						dp[i+1][j+1] %= MOD
					} else {
						//横線に行かないとき
						dp[i+1][j] += dp[i][j]
						dp[i+1][j] %= MOD
					}

				}
			}
		}
	}

	fmt.Printf("%d\n", dp[h][k-1])
	return
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int main(int argc, char *argv[])
{
  string s;
  cin >> s; 
  int size = s.size();
  for (int i = 0; i < s.size()-8; i++) {
    printf("%c",s[i]);
  }
  
  return 0;
}


Measured memory_bytes: 256
MOD = 10**9 + 7
INT_MAX = (1 << 63) - 1


if __name__ == "__main__":
    # test_case_num = int(input())

    # for _ in range(test_case_num):
    m, n = map(int, input().split())
    grid = [input().strip() for _ in range(m)]

    dp = [float('inf')] * n
    for i, row in enumerate(grid):
        for j, val in enumerate(row):
            if i == 0 and j == 0:
                dp[j] = grid[0][0] == '#'
            else:
                temp = INT_MAX
                if i > 0:
                    temp = min(dp[j] + (val == '#' != grid[i-1][j]), temp)
                if j > 0:
                    temp = min(dp[j-1] + (val == '#' != grid[i][j-1]), temp)
                dp[j] = temp
        # print(dp)

    print(dp[-1])


Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
int a,b;
char op;
while(1){
scanf("%d %c %d",&a ,&op ,&b);
if (op == '?')break;
else if (op == '+'){
printf("%d\n",a+b);
}else if (op == '-'){
printf("%d\n",a-b);
}else if (op == '*'){
printf("%d\n",a*b);
}else if (op == '/'){
printf("%d\n",a/b);
}
}
return 0;
}

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

int main(){
	int N, M;
	cin >> N >> M;
	int X[M];
	for(int i=0; i<M; i++){
		cin >> X[i];
	}
	sort(X, X+M);
	int ans[M-1];
	for(int i=0; i<M-1; i++){
		ans[i] = X[i+1] - X[i];
	}
	sort(ans, ans+M-1);
	int cnt = 0;
	if(N >= M){
		cout << 0 << endl;
		return 0;
	}
	for(int i=0; i<N-1; i++){
		cnt += ans[M-2-i];
	}
	cout << X[M-1] - X[0] - cnt << endl;
	return 0;
}


Measured memory_bytes: 1024
//k_tourist
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define mx 1005
#define non __builtin_popcount
#define ml map<ll, ll> 
#define uml unordered_map<ll, ll>
#define ms map<string , ll> 
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define pl pair<ll, ll>
#define vl vector<ll>
#define vll vector<pl>
#define tpl pair<ll, pl>
#define vlll vector<tpl>
#define vs vector<string>
#define pb push_back
#define mk make_pair
#define M_PI 3.14159265358979323846
#define endl '\n'
#define fst ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%I64d",&x)
#define inf ((ll)1e18 + 1)
#define bs binary_search
#define pq priority_queue
#define ub upper_bound
#define lb lower_bound
#define pow powr
#define sp(a) setprecision(a)
#define rep(i,a,b)  for (i=(a);i<(b);i++)
#define nrep(i,a,b) for (i=(a);i>(b);i--)
using namespace std;
using namespace __gnu_pbds;  

typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>  ordered_set;
 
ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

void flag(ll fl){

	if(fl)
	cout<<"NO";
	else
	cout<<"YES";
}

ll h, w, dp[mx][mx];
char a[mx][mx];

ll solve(ll x, ll y){

	if(x == h-1 && y== w-1)
	return 1;

	if(x == h || y== w)
	return 0;

	ll ans= 0;

	if(dp[x][y] != -1)
	return dp[x][y];

	if(a[x][y] == '.')
	ans= (solve(x+1, y) + solve(x, y+1))%mod;
	return dp[x][y] = ans; //(solve(x+1, y) + solve(x, y+1))%mod;
}

void bta_de_yarr(){

	ll n, i, j, fl=0, ans, m;
	
	cin>>h>>w;

	rep(i, 0, h){

		rep(j, 0, w){

			cin>>a[i][j];
			dp[i][j] = -1;
		}
	}

	ans= solve(0, 0);
	cout<<ans;
	// flag(fl);
	cout<<endl;
}

int main(){
    fst

	// freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
	ll t;
    t= 1;
	//cin>>t;
    while(t--){
        bta_de_yarr();
    }
    return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<pair<ll,ll> >adj[100005];
int main()
{
    ll i,j,k,n,m,s,x,y,c=0,mid,ans;
    cin>>n;
    for(i=0;i<n-1;i++){
        cin>>x>>y>>k;
        adj[x].push_back({y,k});
        adj[y].push_back({x,k});
    } ll ind;
    for(i=1;i<n;i++){
        if(adj[i].size()==1){ind=i;break;}
    }ll xx,yy;
    bool vis[n+3]={false};
    ll a[n+5];
    a[ind]=0;
    vis[ind]=true;
    priority_queue<pair<ll,ll> >q;
    q.push({ind,a[ind]});
    while(!q.empty()){
        x=q.top().first;
        y=q.top().second;
        q.pop();
        for(auto z:adj[x]){
            xx=z.first;yy=z.second;
            if(vis[xx]) continue;
            a[xx]=yy+y;
            q.push({xx,a[xx]});
            vis[xx]=true;
        }
    }
    for(i=1;i<=n;i++){
        if(a[i]&1) printf("1\n");
        else printf("0\n");
    }
}


Measured memory_bytes: 11884
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int K,X;cin>>K>>X;
    int d=X-K+1;
    int z=X+K-1;
    for(int i=d;i<=z;i++){
        cout<<i<<" ";
    }
    cout<<endl;
}

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N;
	string S;
	cin >> N >> S;

	if (SZ(S) % 2 == 1)
	{
		cout << "No" << endl;
		return 0;
	}
	bool ok = true;
	rep(i, 0, SZ(S) / 2)
	{
		if (S[i] != S[SZ(S) / 2 + i])
		{
			ok = false;
			break;
		}
	}
	if (ok)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
a=[0]*26
w='abcdefghijklmnopqrstuvwxyz'
try:
    while True:
        s=list(input().upper())
        for i in s:
            if i=='A':
                a[0]+=1
            elif i=='B':
                a[1]+=1
            elif i=='C':
                a[2]+=1
            elif i=='D':
                a[3]+=1
            elif i=='E':
                a[4]+=1
            elif i=='F':
                a[5]+=1
            elif i=='G':
                a[6]+=1
            elif i=='H':
                a[7]+=1
            elif i=='I':
                a[8]+=1
            elif i=='J':
                a[9]+=1
            elif i=='K':
                a[10]+=1
            elif i=='L':
                a[11]+=1
            elif i=='M':
                a[12]+=1
            elif i=='N':
                a[13]+=1
            elif i=='O':
                a[14]+=1
            elif i=='P':
                a[15]+=1
            elif i=='Q':
                a[16]+=1
            elif i=='R':
                a[17]+=1
            elif i=='S':
                a[18]+=1
            elif i=='T':
                a[19]+=1
            elif i=='U':
                a[20]+=1
            elif i=='V':
                a[21]+=1
            elif i=='W':
                a[22]+=1
            elif i=='X':
                a[23]+=1
            elif i=='Y':
                a[24]+=1
            elif i=='Z':
                a[25]+=1 

except EOFError:
    pass

for i in range(26):
    print(w[i:i+1], ':', str(a[i]))

Measured memory_bytes: 7564
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#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)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

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

int main() {

	int n, p[1000][3], co1 = 0, co2 = 0;

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

	for (int i = 0; i < n - 1; i++) {
		if (p[i][0] == 0) continue;
		for (int j = i+1; j < n; j++) {
			for (int k = 0; k < 3; k++) {
				for (int l = 0; l < 3; l++) {
					if (p[i][k] == p[j][l]) co1++;
				}
			}
			if (co1 == 3) {
				co2++;
				p[j][0] = 0;
			}
			co1 = 0;
		}
	}

	cout << co2 << endl;

	return 0;
}

Measured memory_bytes: 3116
N, Y = map(int, input().split())
ans = [-1, -1, -1]
for i in range(N + 1):
    for j in range((N + 1) - i):
        if Y == 10000 * i + 5000 * j + 1000 * (N - i - j):
            ans = [i, j, N - i - j]
for a in ans:
    print(a, end=' ')


Measured memory_bytes: 9184
#include <stdio.h>
#define len 100005

typedef struct {
    char name[100];
    int time;
} Process;

Process queue[len];
int head, tail, n;

void enqueue(Process x) {
    queue[tail] = x;
    tail = (tail + 1) % len;
}

Process dequeue(void) {
    Process p = queue[head];
    head = (head + 1) % len;
    return p;
}

int min(int a, int b) { return a < b ? a : b; }

int main(void) {
    int q, i, c, time;
    time = 0;
    Process tmp;
    scanf("%d %d", &n, &q);

    for (i = 1; i <= n; i++) {
        scanf("%s %d", queue[i].name, &queue[i].time);
    }

    head = 0; tail = n + 1;

    while (head != tail) {
        tmp = dequeue();
        c = min(q, tmp.time);
        tmp.time -= c;
        time += c;
        if (tmp.time > 0) enqueue(tmp);
        else if(time > 0) printf("%s %d\n", tmp.name, time);
    }
    return 0;
}



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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  int res = 0;
  for (int a = 1; a < N; a++) {
    res += (N - 1) / a;
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <set>
#include <map>

using namespace std;

int A, B, Q;
long long int s[100005], t[100005], x[100005];;
set<long long int> S, T;

map<long long int, long long int> DS, DT;

int main(void) {

	cin >> A >> B >> Q;

	for (int i = 1; i <= A; i++) { cin >> s[i]; }

	for (int i = 1; i <= B; i++) { cin >> t[i]; }

	for (int i = 1; i <= Q; i++) { cin >> x[i]; }

	for (int i = 1; i <= A; i++) {
		S.insert(s[i]);
	}
	S.insert(-9999999999999); S.insert(999999999999);

	for (int i = 1; i <= B; i++) {
		T.insert(t[i]);
	}
	T.insert(-999999999999); T.insert(999999999999);


	for (int i = 1; i <= A; i++) {
		DS[s[i]] = 999999999999;
	}
	for (int i = 1; i <= B; i++) {
		DT[t[i]] = 999999999999;
	}

	for (int i = 1; i <= A; i++) {
		T.insert(s[i]);
		auto it = T.find(s[i]);
		it--;
		DS[s[i]] = min(DS[s[i]], abs(s[i] - (*it)));
		it++; it++;
		DS[s[i]] = min(DS[s[i]], abs(s[i] - (*it)));
		T.erase(s[i]);
	}

	for (int i = 1; i <= B; i++) {
		S.insert(t[i]);
		auto it = S.find(t[i]);
		it--;
		DT[t[i]] = min(DT[t[i]], abs(t[i] - (*it)));
		it++; it++;
		DT[t[i]] = min(DT[t[i]], abs(t[i] - (*it)));
		S.erase(t[i]);
	}

	for (int i = 1; i <= Q; i++) {
		long long int ans = 999999999999;
		//cout << "i= " << i << endl;
		// S==//
		S.insert(x[i]);
		auto its = S.find(x[i]);
		its--;
		ans = min(ans, abs(x[i] - (*its)) + DS[(*its)]);// cout << "ans= " << ans << endl;
		its++; its++;
		ans = min(ans, abs(x[i] - (*its)) + DS[(*its)]); //cout << "ans= " << ans << endl;
		S.erase(x[i]);
		// T ==/
		T.insert(x[i]);
		auto itt = T.find(x[i]);
		itt--;
		ans = min(ans, abs(x[i] - (*itt)) + DT[(*itt)]); //cout << "ans= " << ans << endl;
		itt++; itt++;
		ans = min(ans, abs(x[i] - (*itt)) + DT[(*itt)]); //cout << "ans= " << ans << endl;
		T.erase(x[i]);
		cout << ans << endl;
	}

	

	//system("pause");
	return 0;
}

Measured memory_bytes: 26752
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<string>
using namespace std;
int pow(string sub){
    int r=0,t=1;
    for(int i=4;i>=0;i--){
        if(sub[i]=='1')r+=t;
        t*=2;
    }
    return r;
}
int main(){
    map<char,string>enc;
    enc[' ']="101";
    enc['\'']="000000";
    enc[',']="000011";
    enc['-']="10010001";
    enc['.']="010001";
    enc['?']="000001";
    enc['A']="100101";
    enc['B']="10011010";
    enc['C']="0101";
    enc['D']="0001";
    enc['E']="110";
    enc['F']="01001";
    enc['G']="10011011";
    enc['H']="010000";
    enc['I']="0111";
    enc['J']="10011000";
    enc['K']="0110";
    enc['L']="00100";
    enc['M']="10011001";
    enc['N']="10011110";
    enc['O']="00101";
    enc['P']="111";
    enc['Q']="10011111";
    enc['R']="1000";
    enc['S']="00110";
    enc['T']="00111";
    enc['U']="10011100";
    enc['V']="10011101";
    enc['W']="000010";
    enc['X']="10010010";
    enc['Y']="10010011";
    enc['Z']="10010000";
    string lis="ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-\'?";
    string str;
    while(getline(cin,str)){
        string ans;
        for(int i=0;i<str.length();i++){
            ans+=enc[str[i]];
        }
        for(int i=0;i<ans.length()%5;i++){
            ans+="0";
        }
        string Code;
        for(int i=0;i<ans.length()/5;i++){
            int value=pow(ans.substr(i*5,(i*5)+5));
            Code+=lis[value];
        }
        cout<<Code<<endl;
    }

}

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

using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vll vector<long long>
#define inf 1000000100
#define infll 1LL << 50

int main()
{
    int n;
    cin >> n;
    int sum = 0;
    priority_queue<int> q;
    while(n--)
    {
        int s;
        cin >> s;
        sum += s;
        if(s%10 != 0)
        {
            q.push(-s);
        }
    }
    if(sum %10 == 0)
    {
        if(!q.empty())
        {
            sum -= -q.top();
        }
        else
        {
            sum = 0;
        }
    }
    cout << sum << endl;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
 
int main(){
    char str[1000][50], max[50], strtemp[50], mfstr[50];
    int len = 0, len1 = 0, n=0, cnt = 0, mfreq = 0, i = 0, j = 0;

    while(scanf("%s", str[n]) != EOF){
        len = strlen(str[n]);
        if(len1 < len){
            len1 = len;
            strcpy(max, str[n]);
        }
        n++;
    }
    for(i=0; i < n; i++){
        cnt = 0;
        strcpy(strtemp, str[i]);
        for(j=0; j < n; j++){
            if(strcmp(str[j], strtemp) == 0) cnt++;
        }   
        if(mfreq < cnt){
            mfreq = cnt;
            strcpy(mfstr, strtemp);
        }
    }
     
    printf("%s %s\n", mfstr, max);
     
    return 0;
}

Measured memory_bytes: 580
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define PI 3.14159265358979323846;
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
/*
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
*/
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF
#define DUMMY

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }
int Max(int a, int b) { if (a > b) { return a; }return b; }
int Min(int a, int b) { if (a < b) { return a; }return b; }
long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
double dmin(double a, double b) { return a < b ? a : b; }
//long long llmax(long long a, long long b) { return a > b ? a : b; }
//long long llmin(long long a, long long b) { return a < b ? a : b; }
//double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }




int main() {
	int N, L;
	char S[100][101];
	char tmp[101];
	scanf("%d %d", &N, &L);
	for (int i = 0; i < N; i++) {
		scanf("%s", S[i]);
		//printf("%s\n", S[i]);
	}
	for (int j = 0; j < N; j++) {
		for (int i = 0; i < N - 1; i++) {
			if (strcmp(S[i], S[i + 1]) >= 0) {
				strcpy(tmp, S[i]);
				strcpy(S[i], S[i + 1]);
				strcpy(S[i + 1], tmp);
			}
		}
	}
	//for (int i = 0; i < N; i++) {
	//	printf("S[%d] = %s\n", i, S[i]);
	//}

	for (int i = 0; i < N; i++) {
		printf("%s", S[i]);
	}
	printf("\n");


#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 128
N, Y = map(int, input().split())
ax = ay = az = -1
for x in range(N+1):
	for y in range(N+1):
		if (N-x-y) < 0:
			continue
		total = 10000*x + 5000*y + 1000*(N-x-y)
		if total == Y:
			ax = x
			ay = y
			az = N-x-y
			break
	else:
		continue
	break
print(str(ax)+" "+str(ay)+" "+str(az))

Measured memory_bytes: 3064