akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
	    // write your code here
        Scanner sc = new Scanner(System.in);

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

        for (int i = 0; i < n; i++) {
            list[i] = sc.nextLong();
        }

        Arrays.sort(list);

        long last = 0;
        long max = 0;
        long nextMax = 0;
        boolean hasMax = false;
        for (int i = n - 1; i >= 0 ; i--) {
            if (last == list[i]) {
                if (hasMax) {
                    nextMax = last;
                    break;
                } else {
                    max = last;
                    last = 0;
                    hasMax = true;
                }
            } else {
                last = list[i];
            }
        }

        System.out.println(max * nextMax);
    }
}

Measured memory_bytes: 48984
n = int(input())
s = input().rstrip()

ans = 0
for i in range(1, n):
    l= {}
    r= {}
    count = 0

    for c in range(0, i):
        l[s[c]] = True

    for c in range(i, n):
        r[s[c]] = True

    for c in l.keys():
        if r.get(c, False):
            count += 1
    ans = max(ans, count)

print(ans)


Measured memory_bytes: 3060
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
from functools import lru_cache
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))

lst=[0]*(k+1)
# for i in range(a[0]):
#     lst[i]=0
# print(lst)
# for i in range(a[0],a[-1]+1):
#     lst[i]=1
# print(lst)

for i in range(k+1):
    flag=1
    for j in range(n):
        if i-a[j]>=0:
            flag=min(flag,lst[i-a[j]])

    if flag==0:
        lst[i]=1
    else:
        lst[i]=0
# print(lst)
if lst[k]==1:
    print("First")
else:
    print("Second")

Measured memory_bytes: 42860
#include<stdio.h>
//大きい順にソート
long long c[1002];
void merge(int i,int j,long long *s){
  if(i!=j){
    merge(i,(i+j)/2,s);
    merge((i+j)/2+1,j,s);
    int a=i,b=(i+j)/2+1;
    int d;
    for(d=i;d<=j;d++){
      if((i+j)/2<a){
        c[d]=s[b];
        b++;
      }
      else if(j<b){
        c[d]=s[a];
        a++;
      }
      else if(s[a]>s[b]){
        c[d]=s[a];
        a++;
      }
      else{
        c[d]=s[b];
        b++;
      }
    }
    for(d=i;d<=j;d++)
      s[d]=c[d];
  }
}

int main(){
  int n,m,i;
  scanf("%d%d",&n,&m);
  long long x[n+1][3],d[n+1],max=0,count=0;
  for(i=0;i<n;i++){
    scanf("%lld%lld%lld",&x[i][0],&x[i][1],&x[i][2]);
    d[i]=x[i][0]+x[i][1]+x[i][2];
  }
  merge(0,n-1,d);
  for(i=0;i<m;i++)
    max+=d[i];
  for(i=n-m;i<n;i++)
    count-=d[i];
  if(count>max)
    max=count;
  for(i=0;i<n;i++)
    d[i]=-x[i][0]+x[i][1]+x[i][2];
  merge(0,n-1,d);
  count=0;
  for(i=0;i<m;i++)
    count+=d[i];
  if(count>max)
    max=count;
  count=0;
  for(i=n-m;i<n;i++)
    count-=d[i];
  if(count>max)
    max=count;
  for(i=0;i<n;i++)
    d[i]=x[i][0]-x[i][1]+x[i][2];
  merge(0,n-1,d);
  count=0;
  for(i=0;i<m;i++)
    count+=d[i];
  if(count>max)
    max=count;
  count=0;
  for(i=n-m;i<n;i++)
    count-=d[i];
  if(count>max)
    max=count;
  for(i=0;i<n;i++)
    d[i]=x[i][0]+x[i][1]-x[i][2];
  merge(0,n-1,d);
  count=0;
  for(i=0;i<m;i++)
    count+=d[i];
  if(count>max)
    max=count;
  count=0;
  for(i=n-m;i<n;i++)
    count-=d[i];
  if(count>max)
    max=count;
  printf("%lld\n",max);
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>

const int maxn=1e6+10;

struct edge{
    int to,next;
}map[maxn];

int n,m,stk[maxn],top,val,ans[maxn],tp,nxt[maxn];
int head[maxn],cnt;
bool vis[maxn],flag,tag[maxn];

inline void add(int x,int y){
    map[++cnt]=(edge){y,head[x]};
    head[x]=cnt;
    return ;
}

void dfs(int x){
    stk[++top]=x,vis[x]=tag[x]=true;
    for(register int i=head[x];i;i=map[i].next){
        int y=map[i].to;
        if(!vis[y]) dfs(y);
        else if(tag[y]){
            val=y,flag=true;
        }
        if(flag) return ;
    }
    top--,vis[x]=false;
    return ;
}

int main(){
    scanf("%d%d",&n,&m);
    for(register int i=1;i<=m;i++){
        int x,y;
        scanf("%d%d",&x,&y);
        add(x,y);
    }
    for(register int i=1;i<=n;i++){
        if(!tag[i]){
            dfs(i);
            if(flag) break ;
        }
    }
    if(!flag){
        printf("-1");
        return 0;
    }
    int pos;
    for(register int i=1;i<=top;i++)
        if(stk[i]==val) pos=i;
    nxt[ stk[top] ]=val;
    for(register int i=pos;i<top;i++)
        nxt[ stk[i] ]=stk[i+1];
    for(register int i=1;i<=n;i++){
        if(!nxt[i]) continue;
        for(register int j=head[i];j;j=map[j].next){
            int y=map[j].to;
            if(!nxt[y]) continue;
            int p=i,q=nxt[i];
            while(q!=y){
                int r=nxt[q];
                nxt[p]=r;
                nxt[q]=0;
                q=r;
            }
        }
    }
    int x;
    for(register int i=1;i<=n;i++)
        if(nxt[i]) x=i;
    int p=x;
    ans[++tp]=p;
    p=nxt[p];
    while(p!=x){
        ans[++tp]=p;
        p=nxt[p];
    }
    std::cout<<tp<<std::endl;
    for(register int i=1;i<=tp;i++){
        std::cout<<ans[i]<<std::endl;
    }
    return 0;
}


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

ll p=1e9+7;

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    bool flag=true;
    if (n%2==1) {
        for (int i=0;i<n;i++) {
            if (a[i]!=int((i+1)/2)*2) flag=false;
        }
    } else {
        for (int i=0;i<n;i++) {
            if (a[i]!=int(i/2)*2+1) flag=false;
        }
    }
    ll ans=1;
    for (int i=0;i<n/2;i++) {
        ans*=2;
        ans=ans%p;
    }
    if (flag) cout << ans << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
struct Edge {
    int to;
};
using Graph = vector<vector<Edge>>;
using ll = long long;
// 深さ優先探索
vector<ll> seen;  // 既に見たことがある頂点か記録
vector<ll> c;
int dfs(const Graph &G, int v, int id = 0) {
    seen[v] = c[id];
    for (auto e : G[v]) {
        if (seen[e.to] == 0) {  // 訪問済みでなければ探索
            id = dfs(G, e.to, id + 1);
        }
    }
    return id;
}

template <class T>
ostream &operator<<(ostream &s, vector<T> vec) {
    for (int i = 0; i < (int)vec.size(); ++i) {
        if (i > 0) {
            s << ' ';
        }
        s << vec[i];
    }
    return s << endl;
}

int main() {
    int V, E;
    cin >> V;
    E = V - 1;
    Graph G(V);
    for (int i = 0; i < E; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back({b});
        G[b].push_back({a});
    }

    seen.resize(V, 0);  // 初期化
    c.resize(V, 0);
    for (int i = 0; i < V; i++) {
        cin >> c.at(i);
    }
    sort(c.begin(), c.end(), greater<ll>());

    dfs(G, 0);
    cout << accumulate(ALL(seen), 0LL) - seen[0] << endl;
    cout << seen;

    return 0;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		TreeSet<Integer> set = new TreeSet<>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
		    set.add(sc.nextInt());
		}
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
		    int x = sc.nextInt();
		    if (set.contains(x)) {
		        set.remove(x);
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int x : set) {
		    sb.append(x).append("\n");
		}
		System.out.print(sb);
	}
}



Measured memory_bytes: 163480
C = [list(map(int, input().split())) for i in range(3)]
X = [[0 for j in range(3)] for i in range(3)]
result = 'Yes'
for i in range(3):
    X[i][0] = C[i][0] - C[i][1]
    X[i][1] = C[i][1] - C[i][2]
    X[i][2] = C[i][2] - C[i][0]
for i in range(3):
    if X[0][i] != X[1][i] or X[0][i] != X[2][i]:
        result = 'No'
        break
for j in range(3):
    X[0][j] = C[0][j] - C[1][j]
    X[1][j] = C[1][j] - C[2][j]
    X[2][j] = C[2][j] - C[0][j]
for j in range(3):
    if X[j][0] != X[j][1] or X[j][0] != X[j][2]:
        result = 'No'
        break
print(result)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define ll long long
#define MOD 1000000007

using namespace std;

ll modinv(ll a, ll m = MOD) {
  ll b = m, u = 1, v = 0;
  while(b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if(u < 0)
    u += m;
  return u;
}

int main() {
  ll h, w, a, b, k[200001], o = 0;
  k[0] = 1;
  for(int i = 1; i < 200001; i++)
    k[i] = k[i - 1] * i % MOD;
  cin >> h >> w >> a >> b;
  ll t = modinv(k[h - a - 1]) * modinv(k[a - 1]) % MOD;
  for(int i = b + 1; i <= w; i++)
    o = (o + t * k[i + h - a - 2] % MOD * k[w + a - i - 1] % MOD *
                 modinv(k[i - 1]) % MOD * modinv(k[w - i]) % MOD) %
        MOD;
  cout << o << endl;
}

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

int main(){
    int N;
    int A[1001];
    bool flag = 0;

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }
    for(int i=0;i<N;i++){
        if(A[i]%2==0){
            if(A[i]%3==0){
                flag = 0;
            }else if(A[i]%5==0){
                flag = 0;
            }else{
                flag = 1;
                break;
            }
        }
    }
    if(flag==0){
        cout << "APPROVED" << endl;
    }else if(flag==1){
        cout << "DENIED" << endl;
    }
    return 0;
}

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

struct Edge {
    ll to, cost;
    Edge(ll to, ll cost) : to(to), cost(cost){}
};

void dijkstra(ll s, ll d[], vector<Edge> g[]){
    priority_queue<P, vector<P>, greater<P> > que;
    d[s] = 0;
    que.push({0, s});

    while (que.size()) {
        P p = que.top(); que.pop();
        ll v = p.second;
        if(d[v] < p.first) continue;

        for(Edge e : g[v]){
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push({d[e.to], e.to});
            }
        }
    }
    return;
}

int main(){
    ll n; cin >> n;
    vector<Edge> g[n];
    rep(i, n-1) {
        ll u, v, w; cin >> u >> v >> w;
        --u; --v;
        g[u].push_back(Edge(v, w));
        g[v].push_back(Edge(u, w));
    }

    ll color[n];
    memset(color, 1, sizeof(color));

    dijkstra(0, color, g);

    rep(i, n) cout << color[i]%2 << endl;

    return 0;
}

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

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " = " << x << endl

using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;

const ld PI = 3.14159265359;

ll MOD = (ll) 10939;
const ll MAXN = (ll) 1e3 + 10;
const int X = 5005;
const ll INF = (ll) INT_MAX >> 2;
const ll LOG = 20;

int p[MAXN], x[MAXN];
vector<int> G[MAXN];
int dp[MAXN][X + 10];
int ndp[X + 10];


int main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin >> n;
	for(int i = 2; i <= n; i++) cin >> p[i];
	for(int i = 1; i <= n; i++) cin >> x[i];
	
	for(int i = 1; i <= n; i++) dp[i][0] = 0;
	for(int i = n; i >= 2; i--){
		memset(ndp, 31, sizeof ndp);
		for(int j = 0; j <= X; j++){
			if(dp[i][j] <= x[i]){
				for(int k = 0; k <= X; k++){
					ndp[min(k + j, X)] = min(ndp[min(k + j, X)], dp[p[i]][k] + x[i]);
					ndp[min(k + x[i], X)] = min(ndp[min(k + x[i], X)], dp[p[i]][k] + j);
				}
				break;
			}
		}
		for(int j = 0; j <= X; j++) dp[p[i]][j] = ndp[j];
	}
	for(int i = 1; i <= X; i++) if(dp[1][i] <= x[1]) return cout << "POSSIBLE", 0;
	cout << "IMPOSSIBLE";
	return 0;
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
#define re return
#define pb push_back
#define po pop_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define si size
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define pi 3.14159265359
#define er erase
#define in insert
#define em empty
#define ft front
#define fo(i,n) for(i = 0; i < n; i++)
#define ro(i,n) for(i = n - 1; i >= 0; i--)
#define fr(i,j,n) for(i = j; i < n; i++)
#define rf(i,j,n) for(i=n-1;i>=j;i--)
typedef std::vector<int> vi;
typedef std::vector<vi> vvi;
typedef std::pair<int,int> ii;
typedef std::vector<ii> vii;
typedef std::vector<std::string> vs;
typedef double dl;
typedef long double ld;
typedef long long ll;
typedef std::pair<ll, ll> pll;
typedef std::vector<ll> vll;
#define filename ""
using namespace std;

int main()
{
    /*
	freopen(filename".in","r",stdin);
	freopen(filename".out","w",stdout);
	*/
	/*
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	*/
    int a,b;
    cin>>a>>b;
    int c=b;
    int q=0;
    do
    {
        q++;
        c/=10;
    }while(c);
    int i;
    fo(i,q)
    {
        a*=10;
    }
        a+=b;
    fo(i,a)
    {
        if (i*i==a)
        {
            cout<<"Yes\n";
            re 0;
        }
    }
    cout<<"No\n";
    re 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int N;
  cin>>N;
  
  vector<int> V(N);
  for(int i=0;i<N;i++){
    cin>>V[i];
  }
  
  vector<int> C(N);
  for(int i=0;i<N;i++){
    cin>>C[i];
  }
   
  int ans=0;
  
  
  for(int i=0;i<N;i++){
    if(V[i]>C[i]){
      ans+=(V[i]-C[i]);
    }
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define pii pair<int,int>
const long long MOD=1e9+7;

int main() {
  int n,r;
  cin>>n>>r;
  if(n>=10) cout<<r<<endl;
  else cout<<r+100*(10-n)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,n) for(ll i=0;i<n;i++)
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    ll n;
    cin>>n;
    ll a[n],i,q,s=0;
    map<ll,ll> c;
    forn(i,n){
        cin>>a[i];
        s+=a[i];
        c[a[i]]++;
    }
    cin>>q;
    while(q--){
        ll b,cc;
        cin>>b>>cc;
        s=s-(b*c[b])+cc*c[b];
        c[cc]+=c[b];
        c[b]=0;
        cout<<s<<endl;
    }
}

Measured memory_bytes: 10188
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = int.Parse(input[1]);
//        int c = int.Parse(input[2]);
//        int d = int.Parse(input[3]);*/
//        string temp = ReadLine();
//        int a = int.Parse(ReadLine());
//        int b = int.Parse(ReadLine());
//        int c = int.Parse(ReadLine());
//        int d = int.Parse(ReadLine());
//        string a = ReadLine();
//        string b = ReadLine();
//        string c = ReadLine();
//        string ko = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        string[] gazo1 = new string[a];
        string[] gazo2 = new string[b];
        for(int i=0;i<a;i++){
            gazo1[i] = ReadLine();
        }
        for(int i=0;i<b;i++){
            gazo2[i] = ReadLine();
        }
        int count = 0;
        for(int i=0;i<a-b+1;i++){
            for(int j=0;j<a-b+1;j++){
                if(gazo2[0][0] == gazo1[i][j]){
                    count = 0;
                    for(int k=0;k<b;k++){
                        for(int l=0;l<b;l++){
                            if(gazo2[k][l] == gazo1[i+k][j+l]){
                                count++;
                            }
                        }
                    }
                    if(count == b*b){
                        break;
                    }
                }
            }
            if(count == b*b){
                break;
            }
        }
        if(count == b*b){
            WriteLine("Yes");
        }else{
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<fstream>
#include<algorithm>
using namespace std;
using ll = long long;

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

Measured memory_bytes: 256
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		if (a == 0) return;
		int geko = b * c;
		geko -= a;
		geko = max(geko, 0LL);
		cout << (geko + d-1) / d << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<double> v(n);
	for(int i = 0; i < n; i++){
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	double ans = 0;
	for(int i = 1; i < n; i++){
		v[i] = 0.5*(v[i] + v[i-1]);
	}
	cout<<v[n-1]<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int K, X;
    cin >> K >> X;

    bool f = false;
    FOR(i, max(-1000000, X - K + 1), min(1000001, X + K)) {
        if (f) cout << " ";
        cout << i;
        f = true;
    }

    cout << endl;
}


Measured memory_bytes: 3596
S = input()
S = S + '0'
mod = 2019
p = [0] * mod
r = 0
d = 1
for s in reversed(S):
  t = int(s)%mod
  r += t*d
  r %= mod
  d = d*10%mod
  p[r] += 1

print(sum([i*(i-1)//2 for i in p]))

Measured memory_bytes: 9196
// problem: "https://atcoder.jp/contests/abc146/tasks/abc146_d"

#include<bits/stdc++.h>
#define Pair pair<int,int>

using namespace std;

map<Pair,int> minColors(vector<int>G[],int n)
{
    queue<Pair>Q;
    Q.push(Pair(1,0));
    vector<bool>Vis(n+1,0);
    Vis[1] = 1;
    map<Pair,int>M;

    while(!Q.empty())
    {
        Pair p = Q.front();
        Q.pop();

        int i,c;
        c = 1;

        for(i=0;i!=G[p.first].size();i++)
        {
            if(c == p.second)
                c++;

            if(Vis[G[p.first][i]] == 0)
            {
                Vis[G[p.first][i]] = 1;
                Q.push(Pair(G[p.first][i],c));
                M.insert({Pair(p.first,G[p.first][i]),c});
                c++;
            }
        }
    }

    return M;
}

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

    vector<Pair>Edges;
    vector<int>G[n+1];
    int i,x,y;

    for(i=0;i!=n-1;i++)
    {
        cin>>x>>y;

        G[x].push_back(y);
        G[y].push_back(x);

        Edges.push_back(Pair(x,y));
    }

    map<Pair,int>M = minColors(G,n);       // define
    int m = 0;

    for(auto it=M.begin();it!=M.end();it++)
        m = max(m,it->second);

    cout<<m<<'\n';

    for(i=0;i!=n-1;i++)
    {
        Pair p = Edges[i];

        if(M.count(p))
            cout<<M[p]<<'\n';
        else
            cout<<M[Pair(p.second,p.first)]<<'\n';
    }

    return 0;
}


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

#define int long long

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int n, mx = -1, res = 0;
	cin >> n;

	vector<int> a(n);
	unordered_map<int, int> f;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		++f[a[i]];
		mx = max(mx, a[i]);
	}

	sort(a.begin(), a.end());		

	vector<int> dp(mx + 1);
	for (int i = 0; i < n; ++i) {
		if (dp[a[i]] == 0) {
			if (f[a[i]] > 1)
				dp[a[i]] = 1;
			
			for (int j = 2; a[i] * j <= mx; ++j)
				dp[a[i] * j] = 1;
		}
	}

	for (int i = 0; i < n; ++i) {
		// cout << dp[a[i]] << ' ';
		if (dp[a[i]] == 0)
			++res;
	}

	cout << res;

	return 0;
}

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

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

	int c = 0;
	for (int i = n; i >= 1; i--) {
		if (static_cast<int>(log10(i) + 1) % 2 != 0) {
			c++;
		}
	}

	cout << c << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <math.h>

typedef long long ll;
typedef long double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const int inf = 2e9;
const ll N = 2e5+1;
const ll mod = 1e9+7;

vector<int>adj[N];
int arr[N];
int ans[N];

void dfs(int node,int par,vector<int>&lis){


    // calculate for this
    int pos = lower_bound(lis.begin(),lis.end(),arr[node])-lis.begin();
    int ele = lis[pos];
    lis[pos] = arr[node];
    ans[node] = max(pos,ans[par]);

    for(int nxt: adj[node]){
        if(nxt!=par){
            dfs(nxt,node,lis);
        }
    }

    lis[pos] = ele;
}

int main(){

    FASTIO;
    PRECISION;

    int n;
    cin>>n;

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

    for(int i=1;i<n;i++){
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    vector<int>lis(n+1,inf);
    lis[0] = -inf;
    dfs(1,0,lis);

    for(int i=1;i<=n;i++){
        cout<<ans[i]<<"\n";
    }
}


Measured memory_bytes: 30896
# Problem C - Not so Diverse

from collections import Counter

# input
N, K = map(int, input().split())
a_nums = list(map(int, input().split()))

# initialization
a_sets = set(a_nums)
a_len = len(a_sets)

# output
if a_len-K<=0:
    print(0)
else:
    # 色を変える必要がある場合
    a_counter = Counter(a_nums)
    a_counter = a_counter.most_common()[::-1]

    # count
    ans = 0
    for i in range(a_len - K):
        ans += a_counter[i][1]
    print(ans)


Measured memory_bytes: 110792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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 ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }


struct RollingHash{
    int n;
    ll mod1 = 1e9 + 7, mod2 = 1e9 + 9;
    ll base1 = 1007, base2 = 1009;
    VL hash1, hash2, pow1, pow2;

    void init(string s){
        n = s.length();
        hash1.assign(n+1, 0);
        hash2.assign(n+1, 0);
        pow1.assign(n+1, 1);
        pow2.assign(n+1, 1);
        REP(i,n){
            hash1[i+1] = (hash1[i] * base1 + s[i]) % mod1;
            hash2[i+1] = (hash2[i] * base2 + s[i]) % mod2;
            pow1[i+1] = (pow1[i] * base1) % mod1;
            pow2[i+1] = (pow2[i] * base2) % mod2;
        }
    }

    // [l, r)
    PL hash(int l, int r){
        ll h1 = ((hash1[r] - hash1[l] * pow1[r-l]) % mod1 + mod1) % mod1;
        ll h2 = ((hash2[r] - hash2[l] * pow2[r-l]) % mod2 + mod2) % mod2;
        return PL(h1, h2);
    }

    bool match(int l1, int r1, int l2, int r2){
        if (r1 > n || r2 > n) return false;
        return hash(l1, r1) == hash(l2, r2);
    }

    bool match(int l1, int l2, int k){
        return match(l1, l1 + k, l2, l2 + k);
    }

    int lcp(int l1, int l2){
        int ok = 0, ng = n;
        while (ng - ok > 1){
            int m = (ok + ng) / 2;
            if (match(l1, l2, m)) ok = m;
            else ng = m;
        }
        return ok;
    }
};

int main() {
    int n;
    string s;
    cin >> n >> s;
    RollingHash rh;
    rh.init(s);
    int ok = 0, ng = n / 2 + 1;
    while (ng - ok > 1){
        int len = (ok + ng) / 2;
        set<PL> st;
        bool found = false;
        FOR(i,len,n-len){
            st.insert(rh.hash(i - len, i));
            if (st.count(rh.hash(i, i + len))){
                found = true;
                break;
            }
        }
        if (found) ok = len;
        else ng = len;
    }
    cout << ok << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  if(strcmp(s.c_str(), "2019/04/30") <= 0){
    cout << "Heisei" << endl;
  } else{
    cout << "TBD" << endl;
  }
  return 0;
}


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

int main()
{
  int H,W,K;
  std::cin>>H>>W>>K;
  
  std::vector<std::vector<char>> c(H,std::vector<char>(W,0));
  int blackCount=0;
  std::vector<int> hBlackCount(H,0);
  std::vector<int> vBlackCount(W,0);
  for(int i=0;i!=H;i++)
  {
    for(int j=0;j!=W;j++)
    {
      std::cin>>c[i][j];
      if(c[i][j]=='#')
      {
        blackCount++;
        hBlackCount[i]++;
        vBlackCount[j]++;
      }
    }
  }
  
  int result=0;
  for(int hBit=0;hBit!=1<<H;hBit++)
  {
    std::vector<int> horizontal;
    for(int i=0;i!=H;i++)
    {
      if(hBit&(1<<i))
      {
        horizontal.push_back(i);
      }
    }
    
    int black=blackCount;
    for(auto e:horizontal)
      black-=hBlackCount[e];
    
    for(int vBit=0;vBit!=1<<W;vBit++)
    {
      std::vector<int> vertical;
      for(int j=0;j!=W;j++)
      {
        if(vBit&(1<<j))
        {
          vertical.push_back(j);
        }
      }
      
      int black2=black;
      for(auto e:vertical)
      {
        black2-=vBlackCount[e];
        
        for(auto e2:horizontal)
        {
          if(c[e2][e]=='#')
          {
            black2++;
          }
        }
      }
      
      if(black2==K)
      {
        result++;
      }
    }
  }
  
  std::cout<<result<<std::endl;
  
  return 0;
}

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


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


Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    map<int, int> mp;
    set<int> st;
    rep(i, N) {
        mp[A[i]]++;
        st.insert(A[i]);
    }
    int ans = 0;
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        if (mp[*itr] % 2 == 1) ans++;
        //cout << *itr << endl;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;
int main()
{
    char S[3];
    cin >> S;
    int count = 0;
    int MAX = 0;
    for (int i = 0; i<3;i++)
    {   
        if(S[i] == 'R')
            count++;
            if(count>MAX)
                MAX = count;
        if(S[i] == 'S')
            count = 0;
    }
    cout << MAX;
    return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
        using namespace std;
        #define tani_nachi_ke  ios_base::sync_with_stdio(false); cin.tie(NULL);
        #define M_PI 3.14159265358979323846
        #define data data_
        #define ff first
        #define ss second
        #define pb push_back
        #define ld long double
        #define int long long
        #define print(t) cout << "Case #" << t << ": ";
        int32_t main()
        {
            tani_nachi_ke  
            
            int n,x,t;
            cin >> n >> x >> t;
            cout << (n+x-1)/x * t << endl;




           return 0;
        }
          

Measured memory_bytes: 3644
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

k = int(input())

ans = list(range(1, 10))
d = 10
prev = ['0'] + list(map(str, ans))
while len(ans) <= k:
    _next = []
    for v in prev:
        if v[0] == '0':
            _next.append('0' + v)
            _next.append('1' + v)
            ans.append(int('1' + v))
            continue
        if v[0] == '1':
            _next.append('0' + v)
            _next.append('1' + v)
            ans.append(int('1' + v))
            _next.append('2' + v)
            ans.append(int('2' + v))
            continue
        if v[0] == '9':
            _next.append('8' + v)
            ans.append(int('8' + v))
            _next.append('9' + v)
            ans.append(int('9' + v))
            continue
        i = int(v[0])
        s1 = str(i - 1)
        s2 = str(i)
        s3 = str(i + 1)
        _next.append(s1 + v)
        ans.append(int(s1 + v))
        _next.append(s2 + v)
        ans.append(int(s2 + v))
        _next.append(s3 + v)
        ans.append(int(s3 + v))
    prev = _next

print(sorted(ans)[k-1])

Measured memory_bytes: 73816
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define INF 1000000007

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N, H, W;
    cin >> N >> H >> W;
    int ans = 0;
    rep(i, N)
    {
        int x, y;
        cin >> x >> y;
        if (x >= H && y >= W)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#define rep(i,n) for (int i = 0; i < (n);i++)
typedef long long ll;
using namespace std;
/*#include<boost/range/adaptors.hpp>

namespace adaptor = boost::adaptors;*/


void Main()
{
	int n;cin >> n;
    vector<int> a(n);
    rep(i,n) cin >>a.at(i);
    int pre = -999;
    rep(i,n) {
        if (pre <= a.at(i)-1){
            pre = a.at(i) -1;
        }else if (pre <= a.at(i)){
            pre = a.at(i);
        }else{
            puts("No");return ;
        }
    }
    puts("Yes");
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}

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

int main() {
    long long N;
    cin >> N;
    int b;
    int temp = 10;
    
    for (long long i = 1; i <= sqrt(N); i++) {
        b = N / i;
        if (i * b == N) {
            int ans = 1;
            while (b >= 10) {
                b /= 10;
                ans ++;
            }
            if(ans < temp) {
                temp = ans;
            }
        }
    }

    
    cout << temp << endl;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

bool chpal(string s){
	int n=sz(s);
	rep(i,n/2) if(s[i]!=s[n-1-i]) return false;
	return true;
}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >>s;
	int n=sz(s);
	if(!chpal(s)){puts("No"); return 0;}
	int p1=(n-1)/2;
	if(!chpal(s.substr(0, p1))){puts("No"); return 0;}
	p1 = (n+3)/2;
	if(!chpal(s.substr(p1-1))){puts("No"); return 0;}
	puts("Yes");
	return 0;


}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <climits>
#include <string>
int main() {
	long long int n; std::cin >> n;
	auto sqrt = std::sqrt(n);
	long long int sum = 0;
	for (auto q = 1; q < sqrt; ++q) {
		if (n % q == 0) {
			auto m = n / q - 1;
			if (m > q) {
				sum += m;
			}
		}
	}
	std::cout << sum << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int is_prime(int x)
{
	if(x == 1) { return 0; }
	if(x == 2) { return 1; }

	if(x % 2 == 0)
	{
		return 0;
	}
	
	for(int i = 3; i * i <= x; i += 2)
	{
		if(x % i == 0)
		{
			return 0;
		}
	}

	return 1;
}

int main()
{
	int n, r, d;
	int rmin = +2000000000;
	int dmax = -1000000000;
	
	scanf("%d", &n);
	for(int i = 0; i < n; ++i)
	{
		scanf("%d", &r);
		d = r - rmin;
		rmin = r < rmin ? r : rmin;
		dmax = d > dmax ? d : dmax; 
	}
	printf("%d\n", dmax);
}



Measured memory_bytes: 2088
#include <iostream>

int main()
{
	int a, b, c[1000], d[1000], min = 1000000, k = 0, m = 0,sum = 0;
	std::cin >> a >> b;
	for(int i = 0; i < a; i++)
	{
		std::cin >> c[i];	
		k += c[i];
		if(min > c[i])
		{
			min = c[i];
		}
	}
	b = b - k;
	

	if(min < b)
	{
		m = b / min;
		sum = a + m;
	}else{
		sum = a;
	}
	std::cout << sum << std::endl;
}

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

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

struct fast_io {
	fast_io(){
		std::cin.tie(nullptr);
		std::ios::sync_with_stdio(false);
	};
} fio;

signed main(){
	cout<<fixed<<setprecision(10);
	
	int A, B;
	
	cin>>A>>B;
	
	for(int i = 1; i < 100000; i++){
		int a = i * 8 /100;
		int b = i * 10 /100;
		
		if(a == A && b == B) {
			cout<<i<<endl;
			return 0;
		}
	}
	
	cout<<-1<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<map>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=200003;
int n,k;
double p[N],ans,tmp;
int main() {
	cin>>n>>k;
	for(int i=1;i<=n;i++) {
		cin>>p[i];
		p[i]=(p[i]+1)/2;
	}
	for(int i=1;i<k;i++)
		tmp+=p[i];
	for(int i=k;i<=n;i++) {
		tmp+=p[i],tmp-=p[i-k];
		ans=max(ans,tmp);
	}
	printf("%.12lf\n",ans);
	return 0;
}

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

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


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

using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(){
    long long int A,B;
    cin >> A >> B;
    long long int C;
    if(A == 1 && B == 2){
        cout << 3;
    }
    if(A == 1 && B == 3){
        cout << 2;
    }
    if(A == 2 && B == 1){
        cout << 3;
    }      
    if(A == 2 && B == 3){
        cout << 1;
    }  
    if(A == 3 && B == 1){
        cout << 2;
    }  
    
    if(A == 3 && B == 2){
        cout << 1;
    }  
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<pair<int, int> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < n; i++) {
    cout << v[i].first << " " << v[i].second << endl;
  }
}


Measured memory_bytes: 3624
n, l = list(map(int, input().split()))
t_a = int(l * n + n * (n - 1) / 2)
if l >= 0:
    print(t_a - l)
elif 0 > l and l + n - 1 > 0:
    print(t_a)
else:
    print(t_a - (l + n - 1))


Measured memory_bytes: 2940
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n  , M[N][N];
int color[N] , d[N] , f[N] , tt;

void dfs_visit( int u ){
	
	int v;
	color[u] = GRAY;
	d[u] = ++tt;

	for( v = 0; v < n; v++ ){
		
		if( M[u][v] == 0 ){
			continue;
		}
		if( color[v] == WHITE ){
			dfs_visit(v);
		}
	}
	
	color[u] = BLACK;
	f[u] = ++tt;
}

void dfs(){
	
	int u;
	
	for( u = 0; u < n; u++ ){
		color[u] = WHITE;
	}
	tt= 0;
		
	for( u = 0; u < n; u++ ){
		if( color[u] == WHITE ){
			dfs_visit(u);
		}
	}
	for( u = 0; u < n; u++ ){
		printf( "%d %d %d\n" , u+1 , d[u] , f[u] );
	}
}

int main( void ){
	
	int u , v , k , i , j;
	
	scanf( "%d" ,&n );
	
	for( i = 0; i < n; i++ ){
		for( j = 0; j < n; j++ ){
			M[i][j] = 0;
		}
	}
	
	for( i = 0; i < n; i++ ){
		scanf( "%d %d" , &u , &k );
		u--;
		for( j = 0; j < k; j++ ){
			scanf( "%d" , &v );
			v--;
			M[u][v] = 1;
		}
	}
	
	dfs();
	
	return 0;
	
}


Measured memory_bytes: 2108
class Button
  attr_accessor :lx, :ly, :rx, :ry, :link
  def initialize(a, b, c, d, l)
    @lx, @ly, @rx, @ry, @link = a.to_i, b.to_i, c.to_i, d.to_i, l.to_s
  end
  def clicked?(x, y)
    x, y = x.to_i, y.to_i
    return false if x < lx || rx < x
    return false if y < ly || ry < y
    true
  end
end

class Page
  attr_accessor :button
  def initialize(b = Array.new)
    @button = b
  end
  def add(b)
    @button.push(b)
  end
end

until (n = gets.to_i).zero? do
  w, h = gets.split.map(&:to_i)

  buffer = Array.new
  pointer = 0
  page = Hash.new
  n.times do
    name, b = gets.split
    buffer.push(name) if buffer.empty?
    page[name] = Page.new
    b.to_i.times do
      page[name].add(Button.new(*gets.split))
    end
  end

  m = gets.to_i
  m.times do
    command, x, y = gets.split
    case command
      when "click"
        page[buffer[pointer]].button.each do |b|
          next unless b.clicked?(x, y)
          pointer += 1
          buffer = buffer.first(pointer).push(b.link)
          break
        end
      when "back"
        pointer -= 1 if pointer > 0
      when "forward"
        pointer += 1 if pointer < buffer.size - 1
      when "show"
        puts buffer[pointer]
    end
  end
end

Measured memory_bytes: 10560
import sys

if __name__ == '__main__':
    input = sys.stdin.readline
    n = int(input())
    s = list(input())
    s.remove('\n')
    r = 0
    g = 0
    b = 0
    for i in s:
        if i == "R":
            r += 1
        elif i == "G":
            g += 1
        else:
            b += 1
    ans = r * g * b
    for i in range(n):
        for j in range(i, n):
            out = j * 2 - i
            if out >= n:
                continue
            if len({s[i], s[j], s[out]}) == 3:
                ans -= 1
    print(ans)


Measured memory_bytes: 68588
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,m,x;
  cin >> n >> m >> x;
  vector<int>a(m),cnt(n+1,0);
  for(int i=0; i<m; i++){
    cin >> a.at(i);
    cnt.at(a.at(i))++;
  }
  int right=0,left=0;
  for(int i=x; i<=n; i++){
    right+=cnt.at(i);
  }
  for(int i=x; i>=0; i--){
    left+=cnt.at(i);
  }
  if(right>left){
    cout << left << endl;
  }
  else{
    cout << right << endl;
  }
}


Measured memory_bytes: 256
import os
import sys
from collections import deque

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353

S = sys.stdin.buffer.readline().decode().rstrip()
Q = int(sys.stdin.buffer.readline())
queries = [sys.stdin.buffer.readline().decode().rstrip() for _ in range(Q)]

S = deque(list(S))
even = True
for query in queries:
    if query[0] == '1':
        even = not even
    else:
        _, f, c = query.split()
        if f == '1':
            if even:
                S.appendleft(c)
            else:
                S.append(c)
        else:
            if even:
                S.append(c)
            else:
                S.appendleft(c)

if not even:
    S.reverse()
ans = ''.join(S)
print(ans)


Measured memory_bytes: 21156
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char s;
  cin >> s;
  string vowelStr = "aiueo";
  int compare = count(vowelStr.cbegin(), vowelStr.cend(), s);
  if(0 == compare)
  {
     cout << "consonant" << endl;
  }else
  {
     cout << "vowel" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define REP(i,n) for(int i=0; i<n;i++)
int main(){
    int i,n,k,s=1;
    cin >> n >> k;
    REP(i,n) cin >> i;
    for(i=0;s < n;i++) s += (k-1);
    cout << i << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,i,j,k,u,l1,l2,l3;
	scanf("%d%d",&n,&m);
	l1=min(m/1000,n);
	l2=min(m/5000,n);
	l3=min(m/10000,n);
	for(i=0;i<=l1;i++)
	{
		for(j=0;j<=l2;j++)
		{
			k=n-i-j;
			if(k>l3||k<0)
				continue;
			if(i*1000+j*5000+k*10000==m)
			{
				printf("%d %d %d",k,j,i);
				return 0;
			}
		}
	}
	printf("-1 -1 -1");
	return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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

int main() {
	llong W,H,x,y;
    string S;
    llong ans=0;
    cin >>S;

    if(S[0]==S[1] || S[1]==S[2] || S[2]==S[3]){
        cout << "Bad" <<endl;
    }else{
        cout << "Good" << endl;
    }

    return 0;
    




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

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

  int n = s.size(), ans = 0;
  rep(i, n - 1) {
    if (s[i] != s[i + 1]) ans++;
  }
  cout << ans << endl;


  
  return 0;
}

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

int main(){
    ll n; cin >> n;
    ll sum=0, tmp=n;
    while(0<tmp){
        sum += tmp%10;
        tmp /= 10;
    }
    string ans="No";
    if(n%sum==0) ans="Yes";
    cout << ans << endl;
    

}



Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int x,y,n;
  scanf("%d%d",&x,&y);
  for(n=0;n<=x;n++){
    if((4*x-y)==2*n){
      printf("Yes\n");
      return 0;
    }


  }
printf("No\n");
  return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
#define int long long
signed main() {
	int n, k;
	cin >> n >> k;
	pair<int, int> P[n];
	for (int i = 0; i < n; i++) {
		cin >> P[i].first >> P[i].second;
	}
	sort(P, P + n);
	int sum = 0, i = -1;
	while (sum < k) {
		sum += P[++i].second;
	}
	cout << P[i].first << endl;
	return 0;
}

Measured memory_bytes: 1792