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

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-12;
static const double PI = acos(-1.0);

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define dbg(x) true
#endif

bool done[100005];

void solve(long long N, long long X, long long M) {
  done[X] = true;
  ll a = X;
  ll i = 1;
  ll ans = a;
  vector<ll> v;
  v.push_back(a);
  while (i < N) {
    a = (a * a) % M;
    if (done[a]) {
      break;
    }
    v.push_back(a);
    ans += a;
    done[a] = true;
    i++;
  }
  if (i == N) {
    cout << ans << endl;
    return;
  }
  if (a == 0) {
    cout << ans << endl;
    return;
  }
  ll j = 0;
  while (v[j] != a) {
    j++;
  }
  ll y = (N - i) / (v.size() - j);
  ll sum = 0;
  FOR(k, j, v.size()) {
    sum += v[k];
  }
  ans += sum * y;
  ll z = (N - i) % (v.size() - j);
  FOR(k, j, j + z) {
    ans += v[k];
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 3992
//
// Created by ??? on 2017/4/20.
//

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<map>
#include<vector>
#define maxn 1000010
#define p 9901
#define mod 1000000007

using namespace std;

vector<int>G[maxn];
long long hashh[maxn];
map<long long, long long>mp;

void dfs(int u)
{
    hashh[u] = 1;
    for(int i = 0; i < G[u].size(); i++)
    {
        int v = G[u][i];
        dfs(v);
        hashh[u] = (hashh[u] + hashh[v] * p) % mod;
    }
    mp[hashh[u]]++;
}

int main (void)
{
    int n;
    int u, v;
    while(scanf("%d", &n) != EOF)
    {
        for(int i = 0; i <= n; i++)
            G[i].clear();
        mp.clear();

        for(int i = 0; i < n - 1; i++)
        {
            scanf("%d %d", &u, &v);
            G[u].push_back(v);
        }
        dfs(1);
        long long ans = 0;
        for(map<long long, long long>:: iterator it = mp.begin(); it != mp.end(); it++)
            ans += it->second * (it->second - 1) / 2;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 44168
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int k,t; cin >> k >> t;
    vi a(t);
    int ma = 0;
    rep(i,t){
        cin >> a[i];
        chmax(ma,a[i]);
    }
    cout << max(0, (ma-1)-(k-ma)) << endl;
    return 0;
}


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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

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

    ll N;
    cin >> N;

    double ans = 0;
    if (N%2 == 0) {
        ans = (1.0)/2;
    } else {
        ans = (double)(N/2+1)/N;
    }

    cout << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	A := sc.NextLine()
	B := sc.NextLine()
	C := sc.NextLine()

	ans := 0
	for i := 0; i < N; i++ {
		mp := map[byte]bool{}
		mp[A[i]] = true
		mp[B[i]] = true
		mp[C[i]] = true

		if len(mp) == 2 {
			ans += 1
		} else if len(mp) == 3 {
			ans += 2
		}
	}
	fmt.Println(ans)

}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<stdio.h>
int main(){
    int n,l,s=0,a,b=400;
    scanf("%d %d",&n,&l);
    for(int i=1;i<=n;i++){
        a=l+i-1;
        s+=a;
        if(b*b>a*a){
            b=a;
        }
    }
    printf("%d\n",s-b);
    return 0;
}


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

int main(){
  long n,c;
  cin >> n;
  
  vector<long> num(n,0);
  for(long i = 0; i < n-1; i++){
    cin >> c;
    num.at(c-1)++;
  }
  for(long i = 0; i < n; i++)
    cout << num.at(i) << endl;
}

Measured memory_bytes: 4844
import sys
import itertools

n = int(input())
l = {}
for i in sys.stdin.readlines():
    i = i.rstrip()
    if i[0] in ['M','A','R','C','H']:
        l.setdefault(i[0], []).append(i)

s = list(itertools.combinations(l.keys(), 3))
ans = 0
for v in s:
    tmp = 1
    for k in v:
        tmp *= len(l[k])
    ans += tmp
print(ans)


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

int main(){
    int n; cin >> n;
    vector<ll> alis(n), blis(n), aplus;
    ll asum = 0, bsum = 0, bminus = 0, cnum = 0;
    for(int i = 0; i < n; i++){
        cin >> alis[i];
        asum += alis[i];
    }
    for(int i = 0; i < n; i++){
        cin >> blis[i];
        bsum += blis[i];
    }
    if(asum < bsum){
        cout << -1 << endl;
        return 0;
    }
    for(int i = 0; i < n; i++){
        ll c = alis[i] - blis[i];
        if(c >= 0){
            aplus.push_back(c);
        }else{
            bminus += -1 * c;
            cnum++;
        }
    }
    if(bminus == 0){
        cout << 0 << endl;
        return 0;
    }
    ll mid = 0;
    sort(aplus.begin(), aplus.end(), greater<>());
    for(int i = 0; i < aplus.size(); i++){
        mid += aplus[i];
        if(mid >= bminus){
            cout << i + 1 + cnum << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 2936
dy = [1, 0, -1, 0, 1, -1, 1, -1]
dx = [0, 1, 0, -1, 1, 1, -1, -1]

h, w = map(int, input().split())
field = []

for _ in range(h):
  field.append(list(input()))
  
for y in range(h):
  for x in range(w):
    if field[y][x] == '#':
      continue
      
    ans = 0
      
    for tips in range(8):
      ny = y + dy[tips]
      nx = x + dx[tips]
        
      if ny < 0 or ny >= h or nx < 0 or nx >= w:
        continue
      
      if field[ny][nx] == '#':
        ans += 1
        
    field[y][x] = str(ans)
    
for y in range(h):
  print("".join(field[y]))

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

int main() {
	double n,m,x,y;
	cin>>n>>m>>x>>y;
	cout<< n*m/2<< " ";
	cout << ( n==2*x&&m==2*y? "1":"0" );
	return 0;
}

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

int main(void) {
	int N;

	cin >> N;
	int n10 = N / 10;
	int n01 = N - n10 * 10;
	if (n10 == 9 || n01 == 9)
		cout << "Yes\n";
	else
		cout << "No\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi acos(-1.0)

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    ll valid = 0;
    cin >> n;
    priority_queue<ll> maxpq;
    REP(i, n){
        ll a;
        cin >> a;
        maxpq.push(a);
    }

    ll long_edge = 0;
    while(!maxpq.empty()){
        if(maxpq.top() == long_edge) {
            maxpq.pop();
            break;
        }
        long_edge = maxpq.top();
        maxpq.pop();
    }

    ll short_edge = 0;
    while(!maxpq.empty()){
        if(maxpq.top() == short_edge) {
            maxpq.pop();
            valid = 1;
            break;
        }
        short_edge = maxpq.top();
        maxpq.pop();
    }

    cout << long_edge * short_edge * valid << "\n";

    return 0;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
string ds[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
int main()
  {string S; cin >> S;
  auto i = find(ds, ds + 7, S) - ds;
  cout << 7 - i << endl;}

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

#define MAXN (110)
#define ll long long

int n, W, w1;
ll a[4][MAXN], len[4];

int main(){
	scanf("%d%d", &n, &W);
	for(int i = 1; i <= n; ++ i){
		int w, v;
		scanf("%d%d", &w, &v);
		if(!w1) w1 = w;
		a[w - w1][len[w - w1] ++] = v;
	}
	for(int i = 0; i < 4; ++ i){
		std::sort(a[i], len[i] + a[i], std::greater<int>());
		for(int j = 1; j < len[i]; ++ j){
			a[i][j] += a[i][j - 1];
		}
	}
	ll ans = 0;
	for(int i = 0; i <= len[0]; ++ i){
		for(int j = 0; j <= len[1]; ++ j){
			for(int k = 0; k <= len[2]; ++ k){
				for(int p = 0; p <= len[3]; ++ p){
					if(1ll * w1 * i + 1ll * (w1 + 1) * j + 1ll * (w1 + 2) * k + 1ll * (w1 + 3) * p <= W){
						ans = std::max(ans, (i ? a[0][i - 1] : 0) + 
						                    (j ? a[1][j - 1] : 0) + 
											(k ? a[2][k - 1] : 0) + 
											(p ? a[3][p - 1] : 0));
					}
				}
			}
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int n, m;
vector <int> g[100010];
int col[100010];
long long isolate, bipartite, normal;
bool good;

void dfs(int x) {
	for(auto i : g[x]) {
		if(col[i] == -1) {
			col[i] = col[x] ^ 1;
			dfs(i); 
		} else if (col[i] == col[x]) {
			good = false;
		}
	}
}

int main(int argc, char const *argv[])
{
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++) {
		int p, q;
		scanf("%d %d", &p, &q);
		g[p].push_back(q);
		g[q].push_back(p);
	}
	memset(col, -1, sizeof col);
	for(int i = 1; i <= n; i++) {
		if(col[i] == -1) {
			col[i] = 0;
			good = true;
			dfs(i);
			if(g[i].empty()) {
				++isolate;
			} else if (good) {
				++bipartite;
			} else {
				++normal;
			}
		}
	}
	// cout << isolate << " " << bipartite << " " << normal << endl;

	long long ans = 0;
	ans += normal;
	ans += 2 * bipartite; 
	ans += (normal * (normal - 1));
	ans += 2 * bipartite * (bipartite - 1);
	ans += 2 * normal * bipartite;
	ans += 2 * isolate * (n - isolate);
	ans += isolate * isolate;

	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 9088
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;


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

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


    int H, W, h, w;
    cin >> H >> W >> h >> w;

    cout << H*W-(h*W+w*H)+(h*w) << endl;

    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(ll i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(void) {
    int X, Y;
    cin >> X >> Y;
    string ans = "No";

    REP (a, 101) {
        REP (b, 101) {
            if (a + b == X) {
                int sum = a * 2 + b * 4;
                if (sum == Y) {
                    ans = "Yes";
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3104
while true do
  num=Array.new
  str=gets.chomp
  number=str.split
  num[0]=number[0].to_i
  num[1]=number[1].to_i
  if num[0]==0 && num[1]==0 then
    break
  end
  for i in 1..num[0] do
    for j in 1..num[1] do
      print "#"
    end
    print "\n"
  end
  print "\n"
end

Measured memory_bytes: 8792
s1=input()
s2=input()
ans=0
for i in range(len(s1)-len(s2)+1):
    c=0
    j=0
    while j<len(s2):
        if s1[i+j]==s2[j]:
            c+=1
        j+=1
    ans=max(ans,c)
print(len(s2)-ans)


Measured memory_bytes: 9024
import heapq
n,m = map(int,input().split())
b_list = [[] for _ in range(10**5+10)]

for i in range(n):
    a,b = map(int,input().split())
    b_list[a].append(-b)

candy = []
heapq.heapify(candy)
ans = 0
for i in range(1,m+1):
    for j in b_list[i]:
        heapq.heappush(candy,j)
    if candy: 
        ans += (-1*heapq.heappop(candy))

print(ans)

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

using namespace std;

struct edge {
    int to, cost;
};

vector<edge> G[200010];
bool vis[100010];
int d[100010];

bool dfs(int v, int dist) {
    if (vis[v]) {
        if (d[v] != dist) {
            return true;
        }
        else {
            return false;
        }
    }
    vis[v] = true;
    d[v] = dist;
    for (int i = 0; i < (int)G[v].size(); i++) {
        if (dfs(G[v][i].to, d[v] + G[v][i].cost)) {
            return true;//その頂点における判定で一つでも矛盾があれば、全てtrueを返して強制終了。
        }
        //何も矛盾が無ければ次のリストを見る。
    }
    return false;//連結している頂点が最後まで探索できたという証。
}

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

    for (int i = 0; i < M; i++) {
        int L, R, D;
        cin >> L >> R >> D;
        L--; R--;
        G[L].push_back({ R,D });
        G[R].push_back({ L,-D });
    }
    for (int i = 0; i < N; i++) {//連結していない頂点があった場合に探索していく
        if (!vis[i] && dfs(i, 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 14464
#include<iostream>
#include<vector>
#include<unordered_set>
using namespace std;
const int N=2e5+1;
const long long inf=1e18;
long long tree[N],ar[N],beau[N];
void upd(int x,long long val){
	while(x<N){
		tree[x]=max(tree[x],val);
		x+=(x&-x);
	}
}
long long getmax(int x){
	long long max1=-inf;
	while(x){
		max1=max(max1,tree[x]);
		x-=(x&-x);
	}
	return max1;
}
int main(){
	int n,i,k;
	long long j,ans=0;
	cin>>n;
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}
	for(i=1;i<=n;i++){
		cin>>beau[i];
	}
	for(i=1;i<=n;i++){
		if(ar[i]>1){
			j=getmax(ar[i]-1)+beau[i];
			upd(ar[i],j);
			ans=max(ans,j);
		}
		else{
			upd(ar[i],beau[i]);
			ans=max(ans,beau[i]);
		}
	}
	cout<<ans;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> data(n);
	int result = 1;
	for (int i = 0; i < n; i++) {
		cin >> data.at(i);
	}
	sort(data.begin(), data.end());
	for (int i = 0; i < n-1; i++) {
		if (data.at(i) < data.at(i + 1)) {
			result++;
		}
	}
	cout << result << endl;
}

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

typedef long long ll;

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

int main()
{
  int n, m;
  string s, t;
  cin >> n >> m >> s >> t;

  for(int i = 0; i < gcd(n, m); i++){
    if(s[i*n/gcd(n, m)] != t[i*m/gcd(n, m)]){
      cout << -1 << endl;
      return 0;
    }
  }

  cout << (ll)n*m/gcd(n, m) << endl;

  return 0;
}


Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main(){
    input!{
        v:[[usize;3];3],
        size:usize,
        s:[usize; size]
    }
    let mut ans = [[false, false, false], [false, false, false],[false, false, false]];
    for i in 0..size {
        for x in 0..3{
            for y in 0..3{
                if s[i] == v[x][y] {
                    ans[x][y] = true;
                }
            }
        }
    }
    let mut result = false;
    for x in 0..3 {
        if (ans[x][0] && ans[x][1] && ans[x][2]) || (ans[0][x] && ans[1][x] && ans[2][x]) {result = true}
    }

    if !result {
        result = (ans[0][0] && ans[1][1] && ans[2][2]) || (ans[0][2] && ans[1][1] && ans[2][0])
    }

    println!("{}", if result {"Yes".to_string()} else {"No".to_string()})
}

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

int main() {
  string s,t;
  cin >>s>>t;
  int kotae=0;
  for(int i=0;i<s.size();i++){
    if(s[i]!=t[i])kotae++;
  }
  cout<<kotae<<endl;
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  rep(i, N) {
    cin >> A.at(i);
  }
  
  int count = 0;
  rep(i, N) {
    if (A.at(i) != i + 1) {
      count++;
    }
  }
  
  if (count <= 2) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



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

    ans=max(1,3-((a==b)+(b==c)+(c==a)));

    cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  double x1, y1, x2, y2, x3, y3, x4, y4;
  for (int i = 0; i < N; i++) {
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    double dx1 = x2 - x1;
    double dy1 = y2 - y1;
    double dx2 = x4 - x3;
    double dy2 = y4 - y3;
    if (dy1/dx1 == dy2/dx2) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 0
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;
LL n, k;
LL a[1010];
LL sum = 0;
 
bool cond(LL d){
    vector<LL> v;
    for(int i = 1;i <= n;i++)v.emplace_back(a[i]%d);
    sort(ALL(v));
    vector<LL> rui(n + 1, 0);
    for(int i = 1;i <= n;i++){
        rui[i] = rui[i - 1] + v[i - 1];
    }
    for(int i = 0;i <= n;i++){
        LL a = rui[i];
        LL b = (n - i)*d - (rui[n] - rui[i]);
        //cout << d << " " << a << " " << b << endl; 
        if(a == b && max(a, b) <= k)return true;
    }
    return false;
}
 
int main(){
    cin >> n >> k;
    for(int i = 1;i <= n;i++){
        cin >> a[i];
        sum += a[i];
    }
    LL ans = 0;
    for(LL i = 1;i * i <= sum;i++){
        if(sum % i == 0){
            if(cond(i))ans = max(ans, i);
            if(cond(sum/i))ans = max(ans, sum/i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Text;

class TEST{
	static void Main(){
		int T=int.Parse(Console.ReadLine());
		
		for(int i=0;i<T;i++){
			int N=int.Parse(Console.ReadLine());
			String s=Console.ReadLine();
			var mySol=new Sol(N,s);
			Console.WriteLine(mySol.Ans);
		}
	}
}


class Sol{
	int ans;
	public int Ans{
		get{return ans;}
		set{this.ans=value;}
	}
	
	public Sol(int N,String books){
		
		int[,] cost=new int[3,N+1];

		//DP processing;
		String ss="N"+books.Substring(0,2*N)+"NN"+books.Substring(2*N,2*N)+"N";
		
		cost[0,0]=0;
		if(ss[0]=='Y'||ss[1]=='Y')cost[0,0]=1;
		if(ss[2*N+2]=='Y'||ss[2*N+3]=='Y')cost[0,0]=3;
		
		cost[1,0]=1;
		if(ss[2*N+2]=='Y'||ss[2*N+3]=='Y')cost[1,0]=2;
		
		cost[2,0]=2;
		
		
		for(int i=1;i<=N;i++){
			int x,y,z;
//Console.WriteLine(ss.Substring(2*i,2));			
//Console.WriteLine(ss.Substring(2*i+2*N+2,2));			
			
			//cost[0,*]
			x=cost[0,i-1]+1;
			if(ss[2*i]=='Y'||ss[2*i+1]=='Y')x=cost[0,i-1]+2;
			if(ss[2*i+2*N+2]=='Y'||ss[2*i+2*N+3]=='Y')x=cost[0,i-1]+4;
			
			y=cost[1,i-1]+2;
			if(ss[2*i+2*N+2]=='Y'||ss[2*i+2*N+3]=='Y')y=y+1;
			
			z=cost[2,i-1]+3;
			
			cost[0,i]=Calc.calMin(x,y,z);
//Console.WriteLine("cost[0,{0}]={1}\tx={2},y={3},z={4}",i,cost[0,i],x,y,z);
			
			
			//cost[1,*]
			x=cost[0,i-1]+2;
			if(ss[2*i+2*N+2]=='Y'||ss[2*i+2*N+3]=='Y')x=x+1;
			
			y=cost[1,i-1]+1;
			if(ss[2*i]=='Y'||ss[2*i+1]=='Y')y=y+1;
			if(ss[2*i+2*N+2]=='Y'||ss[2*i+2*N+3]=='Y')y=y+1;
			
			z=cost[2,i-1]+2;
			if(ss[2*i]=='Y'||ss[2*i+1]=='Y')z=z+1;
			
			cost[1,i]=Calc.calMin(x,y,z);
//Console.WriteLine("cost[1,{0}]={1}\tx={2},y={3},z={4}",i,cost[1,i],x,y,z);
			
			//cost[2,*]
			x=cost[0,i-1]+3;
			
			y=cost[1,i-1]+2;
			if(ss[2*i]=='Y'||ss[2*i+1]=='Y')y=y+1;
			
			z=cost[2,i-1]+1;
			if(ss[2*i+2*N+2]=='Y'||ss[2*i+2*N+3]=='Y')z=cost[2,i-1]+2;
			if(ss[2*i]=='Y'||ss[2*i+1]=='Y')z=cost[2,i-1]+4;
			cost[2,i]=Calc.calMin(x,y,z);

//Console.WriteLine("cost[2,{0}]={1}\tx={2},y={3},z={4}",i,cost[2,i],x,y,z);
			
			
		}
		ans=cost[0,N];
	}
}

class Calc{
	public static int calMin(params int[] args){
		int Min;
		if(args.Length==0)return -9999;
		
		Min=args[0];
		for(int i=0;i<args.Length;i++){
			if(Min>=args[i])Min=args[i];
		}
		return Min;
	}
}

Measured memory_bytes: 6432
import java.util.Scanner;

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

    int n = in.nextInt();
    int m = in.nextInt();
    int[][] a = new int[n][m];
    int[] b = new int[m];
    int[] c = new int[n];

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        a[i][j] = in.nextInt();
      }
    }
    for (int i = 0; i < m; i++) {
      b[i] = in.nextInt();
    }
    for (int i = 0; i < n; i++) {
      c[i] = 0;
      for (int j = 0; j < m; j++) {
        c[i] += a[i][j] * b[j];
      }
    }
    for (int i = 0; i < n; i++) {
      System.out.println(c[i]);
    }
  }
}

Measured memory_bytes: 40284
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

const int N = 3e5 + 10, mod = 998244353;

ll fact[N], fInv[N];

ll pwr(ll x, ll e);

int main() {
	ll n, a, b, k;
	cin >> n >> a >> b >> k;
	fact[0] = fInv[0] = 1;
	for (int i = 1; i < N; ++i) {
		fact[i] = (i * fact[i - 1]) % mod;
		fInv[i] = pwr(fact[i], mod - 2);
	}
	ll ans = 0;
	for (ll x = 0; x <= n; ++x) {
		ll y = (k - a * x) / b;
		if (y >= 0 and y <= n and a * x + b * y == k) {
			ll temp = (fact[n] * fact[n]) % mod;
			temp = (temp * fInv[x]) % mod;
			temp = (temp * fInv[y]) % mod;
			temp = (temp * fInv[n - x]) % mod;
			temp = (temp * fInv[n - y]) % mod;
			ans += temp;
		}
	}
	cout << ans % mod;
}

ll pwr(ll x, ll e) {
	ll res = 1;
	while (e) {
		if (e & 1) {
			res = (res * x) % mod;
		}
		x = (x * x) % mod;
		e >>= 1;
	}
	return res;
}

Measured memory_bytes: 4992
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		
		int a = stdIn.nextInt();
		int b = stdIn.nextInt();
		int c = stdIn.nextInt();
		
		
		
		if(a == 5 && b == 5 && c == 7 || b == 5 && c == 5 && a == 7|| c == 5 && a == 5 && b == 7 ) {
			System.out.println("YES");
		}else {
			System.out.println("NO");
		}
		
		
	}

}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1000000007;
int main()
{
    cin.tie(nullptr); ios::sync_with_stdio(false);
    int N, M; cin >> N >> M;
    unordered_set<int> S; for (int i = 0; i < M; i++) { int a; cin >> a; S.insert(a); }
    vector<Int> dp(N+2);
    dp[0] = 1;
    for (int i = 0; i < N; i++) {
        if (!S.count(i+1)) dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        if (!S.count(i+2)) dp[i+2] = (dp[i+2] + dp[i]) % MOD;
    }
    cout << dp[N] << '\n';
    return 0;
}


Measured memory_bytes: 5156
#include<iostream>
using namespace std;
int main(void){
    double xa1,ya1,xa2,ya2,xb1,yb1,xb2,yb2;
    while(cin>>xa1>>ya1>>xa2>>ya2>>xb1>>yb1>>xb2>>yb2){
        xa1<=xb2&&ya1<=yb2&&xb1<=xa2&&yb1<=ya2 ? cout<<"YES"<<endl:cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 1220
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, i;
    cin >> n;
    map <string, ll> m;
    for(i = 0; i < n; i++)
    {
        string temp;
        cin >> temp;
        m[temp]++;
    }
    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;
    return 0;
}

Measured memory_bytes: 3664
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<cstdio>
#include<string.h>
#include<set>
#include<algorithm>

using namespace std;
#define inf 0x3f3f3f3f;
set<int>s;
int gh[1000][1000],w[2000],dis[1000][1000],pre[2000];
bool vis[20000]={0}; 
        

int main()
{
    int i,j,k,l,n,m,r,num;
    int sum;
    int a[110000];
    cin>>n;
    for (i=1;i<=n;i++)
       cin>>a[i];
    a[0]=1;
    num=0;   
    for (i=1;i<=n;i++)
      if (a[i]==i)
      {
         if (a[i-1]==i-1)
         {
            a[i]=i-1;
            a[i-1]=i;
         }
         else
           num++;
      } 
    cout<<num<<endl;                          

    return 0;
}
        
    
    


Measured memory_bytes: 640
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF INT_MAX
#define LLINF LLONG_MAX
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int n;
	cin >> n;
	REP1(k, n){
		ll f = (ll) floor(n/k);
		ans += k * (1 + f) * f / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3624
#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 h, w;
    cin >> h >> w;
    vector<vector<char>> a(h, vector<char>(w));
    rep(i,h)rep(j,w) cin >> a[i][j];
    vector<bool> ver(w, false), hor(h, false);
    rep(i,h){
        bool compress = true;
        rep(j,w){
            if(a[i][j] == '#') compress = false;
        }
        if(compress) hor[i] = true;
    }
    rep(j,w){
        bool compress = true;
        rep(i,h){
            if(a[i][j] == '#') compress = false;
        }
        if(compress) ver[j] = true;
    }
    rep(i,h){
        if(hor[i]) continue;
        rep(j,w){
            if(ver[j]) continue;
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int n; cin >> n;
	vector<int> a(n);
	rep(i,n) cin >> a.at(i);
	ll mny = 1000, keep = 0;
	for(int i = 0; i < n-1; i++){
		if(a.at(i) < a.at(i+1)){
			mny += keep * a.at(i);
			keep = mny / a.at(i);
			mny -= a.at(i) * keep;
		}
		else if(a.at(i) == a.at(i+1)) continue;
		else{
			mny += a.at(i)*keep;
			keep = 0;
		}
		//cout << i << " " << mny << endl;
	}
	cout << keep*a.at(n-1) + mny << endl;
} 


Measured memory_bytes: 3648
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll=long long;

int K;
map<int,map<int, int>> color;
void paint(const vector<vector<int>>& G, int now, int bef){
	int num = (bef==-1?0:color[bef][now]+1)%K;
	for(int next:G[now]){
		if(color[now].find(next)!=color[now].end())continue;
		color[now][next]=color[next][now]=num;
		num=(num+1)%K;
		paint(G, next, now);
	}
}

int main()
{
	int N;
	cin>>N;
	vector<pair<int,int>> inputs;
	vector<vector<int>> G(N);
	rep(i,N-1){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
		inputs.push_back({a,b});
	}

	K=0;
	for(auto& g:G)K=max(K,(int)g.size());
	cout<<K<<endl;
	paint(G,0,-1);
	for(auto& p:inputs){
		cout<<color[p.first][p.second]+1<<endl;
	}

	return 0;
}


Measured memory_bytes: 25588
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ul unsigned long long int
#define ld long double
#define INF 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define FAST_IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int main(){
    FAST_IO;
    ll _=1;
    //cin>>_;
    for(ll ii=1;ii<=_;ii++)
    {
        string s,t;
        cin>>s>>t;
        t.pop_back();
        if(s==t)cout<<"Yes"<<endl;
        else cout<<"No"<<endl;
	}
    return 0;
}


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

struct Variable
{
	int size;
	map < int , int > data;

	Variable(int size) : size(size) {}
	Variable() {}
};

//[s,t)
int expression(string &S, map < char, Variable > &vlist, int s, int t)
{
	int idx;
	if ( isdigit(S[s]) ) return ( stoi(S.substr(s, t - s)) );
	if ( vlist.find(S[s]) == vlist.end() ) return ( -1 );
	if ( (idx = expression(S, vlist, s + 2, t - 1)) == -1 || idx >= vlist[S[s]].size ) return ( -1 );
	if ( vlist[S[s]].data.find(idx) == vlist[S[s]].data.end() ) return ( -1 );
	return ( vlist[S[s]].data[idx] );
}

bool assignment(string &S, map < char, Variable > &vlist, int equalpos)
{
	int idx, value;
	if ( vlist.find(S[0]) == vlist.end() ) return ( true );
	if ( (idx = expression(S, vlist, 2, equalpos - 1)) == -1 || idx >= vlist[S[0]].size ) return ( true );
	if ( (value = expression(S, vlist, equalpos + 1, S.size())) == -1 ) return ( true );
	vlist[S[0]].data[idx] = value;	
	return ( false );
}

int main()
{
	string S;
	map < char, Variable > vlist;
	int flag = 0;
	bool stop = false;
	int row = 1;

	while ( cin >> S ) {
		int equalpos;

		if ( S == "." ) {
			flag++;
			if ( flag == 1 ) {
				vlist.clear();
				if ( !stop ) cout << 0 << endl;
				stop = false, row = 1;
				continue;
			} else {
				break;
			}
		} else {
			flag = 0;
		}
		if ( stop ) continue;

		if ( (equalpos = S.find('=')) == string::npos ) {
			//declaration
			int size = stoi(S.substr(2, S.size() - 3));
			vlist[S[0]] = Variable(size);
		} else {
			//assignment
			if ( assignment(S, vlist, equalpos) ) {
				cout << row << endl;
				stop = true;
			}		
		}
		row++;
	}

	return ( 0 );
}



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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

struct S {
  ll t, d, i;
  bool operator<(const S& s) const {
    if (d != s.d) return d < s.d;
    if (t != s.t) return t < s.t;
    return i < s.i;
  }
};

int main() {
  in(ll, n, k);
  vector<S> s(n);
  rep(i, n) {
    cin >> s[i].t >> s[i].d;
    s[i].i = i;
  }
  sort(all(s), [](const S& a, const S& b) { return a.d > b.d; });
  set<ll> tset;
  ll dsum = 0;
  set<S> rep;
  rep(i, k) {
    dsum += s[i].d;
    if (!tset.insert(s[i].t).second) {
      rep.insert(s[i]);
    }
  }
  auto square = [](ll x) { return x * x; };
  auto score = [&]() { return dsum + square(tset.size()); };
  ll ans = score();
  for (int i = k; i < n; ++i) {
    if (tset.insert(s[i].t).second && !rep.empty()) {
      S replaced = *rep.begin();
      rep.erase(rep.begin());
      dsum -= replaced.d;
      dsum += s[i].d;
      ans = max(ans, score());
    }
  }
  out(ans);
}


Measured memory_bytes: 10652
e=input
a=''
for _ in[0]*int(e()):
 X,z=e(),[]
 for y in e():
  s=i=0
  for k in z:
   t=X.find(y,s)+1
   if t<1:break
   if t<k:z[i]=t
   s=k;i+=1
  else:
   t=X.find(y,s)+1
   if t:z+=[t]
 a+=f'\n{len(z)}'
print(a[1:])


Measured memory_bytes: 5628
#include<stdio.h>

double tanri(int y, double r){
        return 1+y*r/100.0;
}

double fukuri(int y, double r){
        double ret=1;
        int i;
        for(i=0; i<y; i++) ret *= 1+r/100.0;
        return ret;
}

int main(){
        while(1){
                int n, y;
                scanf("%d", &n);
                if(n==0) break;
                scanf("%d", &y);

                double mxget=0;
                int i, mxidx;
                for(i=0; i<n; i++){
                        int b, r, t;
                        double get;
                        scanf("%d %d %d", &b, &r, &t);
                        if(t==1) get = tanri(y, r);
                        else get = fukuri(y, r);

                        if(mxget<=get){
                                mxget = get;
                                mxidx = b;
                        }
                }
                printf("%d\n", mxidx);
        }
        return 0;
}


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

int main(){
    int n;
    cin >> n;
    vector<int>a(n-1);
    for(int i=0;i<n-1;i++){
        cin >> a[i];
    }
    vector<int>ans(n,0);
    for(int i=0;i<n-1;i++){
        
        ans[a[i]-1]++;
        
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4840
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

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

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

    return 0;
}


Measured memory_bytes: 3636
import std.stdio;
import std.algorithm;
import std.range;
import std.array;
import std.string;
import std.conv;

void main(){
	int[] inputs = readln.chomp.split.map!(to!int).array;
	auto n = inputs[0];
	auto a = inputs[1];
	auto b = inputs[2];
	
	auto answer = min(n * a, b);
	writeln(answer);
}

Measured memory_bytes: 256
import bisect

n = int(input())
tops = list(map(int, input().split()))
mids = list(map(int, input().split()))
bottoms = list(map(int, input().split()))

tops.sort()
bottoms.sort()

nos_sets = 0

for m in mids:
    t = bisect.bisect_left(tops, m)
    b = n - bisect.bisect_right(bottoms, m)
    nos_sets += t * b

print(nos_sets)

Measured memory_bytes: 22720
#include <iostream>
#include <string>
#include <algorithm>
#include <utility> 
#include <unordered_set>
#include <vector>
#include <list> 
#include <string>
#include <iterator> 
#include <deque>
#include <array>
#include <forward_list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <climits>
#include <bitset>
#include <numeric>
using namespace std;


const long double PI = 3.14159265358979323846264338327950;
const double EPS = 1e-9;
const long long N = 1e9;

template <class T> T gcd(T a, T b) {
	if (b == 0) { return a; }
	return gcd(b, a % b);
}

template <class T> bool isPrime(T x) {
	for (T d = 2; d * d <= x; d++) { if (x % d == 0) return false; }
	return true;
}

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

	string s, t;
	cin >> s >> t;
	sort(s.begin(), s.end());
	sort(t.begin(), t.end(), greater<char>());
	if (s < t) {
		cout << "Yes" << '\n';
	} else {
		cout << "No" << '\n';
	}
}

Measured memory_bytes: 3628
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextString() string {
	if !sc.Scan() {
		panic("failed scan string")
	}
	return sc.Text()
}

func nextInt() int {
	if !sc.Scan() {
		panic("failed scan int")
	}
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

	s := nextString()
	k := nextInt()

	subs := make([]string, k)

	for i := 0; i < len(s); i++ {
		for j := i + 1; j < len(s)+1; j++ {
			sub := s[i:j]

			for l := 0; l < k; l++ {
				if sub == subs[l] {
					// dup
					break
				}
				if subs[l] == "" {
					subs[l] = sub
					break
				}
				if sub < subs[l] {
					if l != k-1 {
						copy(subs[l+1:], subs[l:])
					}
					subs[l] = sub
					break
				}
			}

		}
	}

	fmt.Println(subs[k-1])
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
  ll a, b, x; cin >> a >> b >> x;
  ll n1 = a / x;
  ll n2 = b / x;
  cout << n2 - n1 + (a % x == 0) << endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define mx 1000000007
#define ll long long int

using namespace std;

int n;

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>> n;
    int arr[n+1];
    for(int i=1;i<=n;++i)
        cin>> arr[i] ;
    int dp[n+1]={0};
    dp[n-1]=abs(arr[n-1]-arr[n]);
    for(int i=n-2;i>0;--i)
    	dp[i]=min(abs(arr[i]-arr[i+1])+dp[i+1],abs(arr[i]-arr[i+2])+dp[i+2] );
    cout<< dp[1] ;
	return 0;
}


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

const int MAX = 5001;
const int INF = (1<<20);

int data[MAX],n;


void solve(){
  vector<int> V;
  fill(data,data+MAX,0);
  for(int i = 1; i < n; i++){
    V.push_back((i*i)%n);
  }
  V.push_back(-1);
  V.push_back(INF);
  sort(V.begin(),V.end());
  vector<int> VV;
  int now = -1;
  while(1){
    now = *upper_bound(V.begin(),V.end(),now);
    if(now == INF) break;
    VV.push_back(now);
  }
  for(int i = 0; i < VV.size(); i++)
    for(int j = 0; j < VV.size(); j++){
      int num = VV[i]-VV[j];
      if(num < 0) num += n;
      if(num > (n-1)/2) num = n-num;
      data[num]++;
    }
}

void print(){
  for(int i = 1; i <= (n-1)/2; i++)
    printf("%d\n",data[i]);
}


int main(){
  while(scanf("%d",&n) && n){
    solve();
    print();
  }
  return 0;
}

Measured memory_bytes: 1040
#include <iostream>
#include <vector>
#include <iterator>
#include <algorithm>

int main() {
	std::vector<int> v;
	std::copy( std::istream_iterator<int>(std::cin), std::istream_iterator<int>(), std::back_inserter(v) );
	std::sort( v.begin(), v.end(), std::greater<int>() );
	std::copy( v.begin(), v.begin()+3, std::ostream_iterator<int>(std::cout, "\n" ));
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  while(R n && n) {
    int a[n];
    rep(i,n) R a[i];
    int x;
    R x;
    int l=0,r=n-1,c=0;
    while(l<=r) {
      int m=(l+r)/2;
      c++;
      if(a[m]==x) break;
      else if(a[m]<x) l=m+1;
      else r=m-1;
    }
    pr(c);
  }
}

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  Main();return 0;
}


Measured memory_bytes: 1196
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

vector<int> solve(vector<int> a,vector<int> b){
    string x,y;
    rep(i,a.size()){
        x+='0'+a[i];
    }
    rep(i,b.size()){
        y+='0'+b[i];
    }
    int r=stoi(x)-stoi(y);
    vector<int> ret;
    stringstream ss;
    ss<<r;
    string z=ss.str();
    string t="";
    rep(i,4-z.size())t+="0";
    z=t+z;
    rep(i,z.size())ret.pb(z[i]-'0');
    return ret;
}

int main(){
    string s;
    while(cin>>s){
        if(s=="0000")break;
        int x=0;
        vector<int> c;
        rep(i,s.size())c.pb(s[i]-'0');
        while(1){
            if(c[0]==6&&c[1]==1&&c[2]==7&&c[3]==4){cout<<x<<endl;break;}
            if(c[0]==c[1]&&c[1]==c[2]&&c[2]==c[3]){
                cout<<"NA"<<endl;
                break;
            }
            vector<int> l=c,s=c;
            sort(all(s));
            sort(all(l),greater<int>());
            c=solve(l,s);
            x++;
        }
    }
}

Measured memory_bytes: 1240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
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 (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if (n == i*j){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256