akhauriyash/Code-Regression huggingface dataset:
package main

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

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n-1)

	res := 0
	for i := 0; i < n; i++ {
		a[i] = nextInt()
	}
	for i := 0; i < n; i++ {
		b[i] = nextInt()
		res += b[i]
	}
	for i := 0; i < n-1; i++ {
		c[i] = nextInt()
	}
	for i := 0; i < n-1; i++ {
		if a[i]+1 == a[i+1] {
			res += c[a[i]-1]
		}
	}

	fmt.Fprint(writer, res)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}


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


int main(){
    int n;
    cin >> n;
    int ans[n + 5] = {};
    for(int i=1;i<n;i++){
        int a;
        cin >> a;
        ans[a]++;
    }

    for (int i = 1; i <=n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4408
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
#include <algorithm>

using namespace std;

bool cmp(long long a,long long b)
{
    return a>b;
}
long long a[100010];
int main()
{
    int n;
    long long ar=1,flag=0;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);
    }
    sort(a,a+n,cmp);
    for(int i=0;i<n;i++)
    {
        if(flag>=2) break;
        if(a[i]==a[i+1])
        {
            ar*=a[i];
            flag++;
            i++;
        }
    }
    if(flag==2) cout<<ar;
    else printf("0");
    return 0;
}


Measured memory_bytes: 1024
//atcodeer141
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy"<<endl;
    if(s=="Cloudy")
        cout<<"Rainy"<<endl;
    if(s=="Rainy")
          cout<<"Sunny"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
typedef long long int ll;
#define in(n) ll n;cin>>n;
#define fo(m,n) for(int i=m;i< n;i++)
#define rfo(m,n) for(ll i =n;i>=m;i--)
#define out(n) cout<<n<<endl;
#define max(a,b) ((a>b)?a:b)

int main ()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int t;cin>>t;
    if(t<30){cout<<"No"<<endl;}
    else
    {
        cout<<"Yes"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3632
using System;
using System.Linq;
class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        x = x.OrderBy(i => i).ToArray();
        var check = new int[n];
        if (n % 2 == 0)
        {
            for (int i = 0; i < n; i++) check[i] = (i / 2) * 2 + 1;
        }
        else
        {
            for (int i = 1; i < n; i++) check[i] = ((i - 1) / 2) * 2 + 2;
        }
        long ans = 1;
        for (int i = 0; i < n / 2; i++)
        {
            ans *= 2;
            ans %= 1000000007;
        }
        Console.WriteLine(string.Join("", x) == string.Join("", check) ? ans : 0);
    }
}

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

using namespace std;

int main(void){

    int n;
    cin >> n;
    vector<char> s(n);
    for(int i = 0;i < n;i++) cin >> s[i];

    vector<int> temp(4, 0);

    for(int i = 0;i < n;i++){
        switch(s[i]){
            case 'P':
            temp[0]++;
            break;

            case 'W':
            temp[1]++;
            break;

            case 'G':
            temp[2]++;
            break;

            case 'Y':
            temp[3]++;
            break;
        }
    }

    int ans = 0;

    for(int i = 0;i < 4;i++){
        if(temp[i] != 0) ans++;
    }

    cout << (ans == 3 ? "Three" : "Four") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<queue>
#include<unordered_set>
long long const infty = 0x3fffffffffffff;
struct edge{
    long long weight;
    int to,rev;
};
//隣接リスト表現
class Graph{
protected:
    int numVertex,numEdge;
    std::vector<edge> *adj;
public:
    //---基本---

    //v頂点のグラフを作成する（頂点の番号は0-indexed）
    Graph(int v){
        numVertex=v;
        numEdge=0;
        adj=new std::vector<edge>[v];
    }
    ~Graph(){ delete[] adj; }
    int getNumVertex(){ return numVertex; }
    int getNumEdge(){ return numEdge; }
    void addEdge(int u,int v,long long w=1LL,bool isDirected=false){
        adj[u].push_back({w,v,-1});
        numEdge++;
        if(!isDirected){
            adj[v].push_back({w,u,-1});
            numEdge++;
        }
    }
    //ダイクストラ法（単一頂点を始点とする最短経路）O(E+VlogV)
    void dijkstra(long long l[],int s,int prev[]=NULL){
        for(int i=0;i<numVertex;i++)l[i]=infty;
        if(prev!=NULL)for(int i=0;i<numVertex;i++)prev[i]=-1;
        l[s]=0;
        auto cmp=[](const edge &a,const edge &b)->bool { return a.weight>b.weight; };
        std::priority_queue<edge,std::vector<edge>,decltype(cmp)> pq(cmp);
        pq.push({0,s,-1});
        while(!pq.empty()){
            int u=pq.top().to;
            pq.pop();
            for(auto i=adj[u].begin();i!=adj[u].end();i++){
                int v=(*i).to;
                long long w=(*i).weight;
                if(l[v]>l[u]+w){
                    l[v]=l[u]+w;
                    if(prev!=NULL)prev[v]=u;
                    pq.push({l[v],v,-1});
                }
            }
        }
    }
};
long long w[100000];
int main(){
    int v,e,r;
    scanf("%d%d%d",&v,&e,&r);
    Graph g(v);
    for(int i=0;i<e;i++){
        int s,t,d;
        scanf("%d%d%d",&s,&t,&d);
        g.addEdge(s,t,d,true);
    }
    g.dijkstra(w,r);
    for(int i=0;i<v;i++){
        if(w[i]==infty)printf("INF\n");
        else printf("%lld\n",w[i]);
    }
    return 0;
}


Measured memory_bytes: 19004
import heapq
N, M = map(int, input().split())
w = [[] for i in range(M)]
for i in range(N):
    a, b = map(int, input().split())
    try:
        w[a-1].append(-b)
    except:
        pass
ans = 0
a = []
heapq.heapify(a)
for i in range(M):
    for x in w[i]:
        heapq.heappush(a, x)
    try:
        ans += -heapq.heappop(a)
    except:
        pass
print(ans)

Measured memory_bytes: 17604
from collections import deque
 
if __name__ == "__main__":
    N, q = map(int, input().split())
    links = [[] for _ in range(N)]
    
    for i in range(N - 1):
        a, b = map(int, input().split())
        links[a - 1].append(b - 1)
        links[b - 1].append(a - 1)
    
    ans = [0] * N
    for i in range(q):
        p, x = map(int, input().split())
        ans[p - 1] += x

    deq = deque([0])
    visited = [False] * N
    while deq:
        parent = deq.popleft()
        link = links[parent]
        for v in link:
            if not visited[v]:
                ans[v] += ans[parent]
                deq.append(v)
        visited[parent] = True
    
    print(*ans)

Measured memory_bytes: 56084
#include<stdio.h>
 
int main()
{   
  int x,i,fibo[44];
  scanf("%d",&x);
 
  for(i=0;i<x+1;i++)
    {
      if(i==0) 
	{
	  fibo[i]=1;
	}
      if(i==1)
	{
	  fibo[i]=1;
	}
      if(i>1)
	{
	  fibo[i]=fibo[i-1]+fibo[i-2];
	}
      if(i==x)
	{
	  printf("%d\n", fibo[i]);
	}
    }
  return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
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; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

int main() {
  int N = in();
  set<int> Y;
  vector<int> Z;
  for (int i = 0; i < N; ++i) {
    Z.push_back(in());
    if (i % 2 == 1) {
      Y.insert(Z[i]);
    }
  }
  sort(Z.begin(), Z.end());

  int res = 0;
  for (int i = 0; i < N; i += 2) {
    if (Y.count(Z[i]) > 0) {
      ++res;
    }
  }

  printf("%d\n", res);
  
  return 0;
}


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

ll selfadd(ll a,ll b)
{
	if(a<b)
	return a;
	else return a%b;
}
void solve()
{

	ll	 n,k,count=0;
	
	cin>>n>>k;
	
	ll a[n];
	for(auto &i:a)
	{
		cin>>i;
		if(i>=k)count++;
	}
		
		
		cout<<count;
	
	
	
	
	}
		
		


int main()
{


ios::sync_with_stdio(0); 
	cin.tie(0);

		solve();
	
return 0;

		
	}
	
	
	


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

using namespace std;

long long pangkat(long long a){
   long long b;
   if(a==0)return 1;
   else{
      if(a%2==0){
         b=pangkat(a/2);
         return b*b;
      }
      else{
         return 5*pangkat(a-1);
      }
   }
}
int main(){
   long long a,i,d,e,sisa,tampung,b,c,awal,sama;
   scanf("%lld", &a);
   sama=0;
   tampung=0;
   getchar();
  if(a%2==1){
     tampung=0;
  }
  else{
     for(i=1;i<=25;i++){
        c=pangkat(i)*2;
        d=a/c;
  // cout<<c<<"  ";
        tampung=tampung+d;
       // cout<<c;
     }
  }
  printf("%lld\n", tampung);
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<iomanip>
#include<cstdlib>
#define _t putchar(32)
#define _e putchar(10)
#define inf 2147483647
#define ine -2147483647
#define lb(x) ((x)&(-x))
#define sp(x,y) x^=y^=x^=y
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
bool o;
char ch,SSS[1<<17],*A=SSS,*B=SSS;
inline char gc(){
	return A==B&&(B=(A=SSS)+fread(SSS,1,1<<17,stdin),A==B)?EOF:*A++;
}
template <typename _Tp> inline void rd(_Tp &x);
template <typename _Tq> inline void wr(_Tq x);
template <typename _Tp> inline _Tp mx(_Tp x,_Tp y);
template <typename _Tp> inline _Tp mn(_Tp x,_Tp y);
int n,q;
ll a[5001],s[5001],sum;
int g[5001];
int len,seed,mod,tp;
int main(){
	rd(n),rd(q);
	for(int i=1;i<=n;i++) rd(a[i]);
	while(q--){
		rd(len),rd(seed),rd(mod);
		len--;
		seed%=mod;
		for(int i=1;i<=n;i++){
			s[i]=a[i]%mod;
			if(!s[i]) s[i]=mod;
			s[i]+=s[i-1];
		}
		sum=seed+s[n]*(len/n)+s[len%n];
		wr(len-sum/mod),_e;
	}
}
template <typename _Tp>
    inline void rd(_Tp &x){
    	o=0;
        x=0;
      	while (ch^45&&(ch<48||ch>57)) ch=gc();
      	if(ch==45)o=1,ch=gc();
        while(ch>47&&ch<58){
			x=(x<<1)+(x<<3)+(ch^48);
			ch=gc();
		}
      	if(o) x=-x;
 	}
template <typename _Tp>
    inline void wr(_Tp x){
        if(x<0) x=-x,putchar(45);
        if(x<10){
            putchar(x+48);
            return;
        }
        wr(x/10);
        putchar(x%10+48);
    }
template <typename _Tp>
	inline _Tp mx(_Tp x,_Tp y){
		return x>y?x:y;
	}
template <typename _Tp>
	inline _Tp mn(_Tp x,_Tp y){
		return x<y?x:y;
	}


Measured memory_bytes: 512
x = gets.chomp.to_i

2000.times do |a|
    a = a - 1000
    2000.times do |b|
        b = b - 1000
        if a.pow(5) - b.pow(5) == x
            puts a.to_s + " " + b.to_s
            exit
        end
    end
end


Measured memory_bytes: 14340
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N),C(N,0);
  rep(i,N) cin>>A[i];
  rep(i,N) cin>>B[i];
  rep(i,N-1) cin>>C[i];

  rep(i,N) A[i]--;

  int ans=0;
  rep(i,N) ans+=B[i];
  for(int i=0;i<N-1;i++){
    if(A[i]+1==A[i+1]) ans+=C[A[i]];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

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

  vector<long long> ANS(N, 0);
  for (int i = 1; i < N; i++) ANS[A[i] - 1]++;
  for (int i = 0; i < N; i++) cout << ANS[i] << endl;
}


Measured memory_bytes: 5988
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#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 REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int d;
    cin >> d;
    int ans = 1;
    int dd = d;
    while (dd % 360 != 0) {
        dd += d;
        ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ll)(1e9+7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	ll x1=1, x2=1, x3=1;
	for(int i=0 ; i<n ; ++i){
		x1 *= 10;x2 *= 9;x3 *= 8;
		x1 %= MOD;x2 %= MOD;x3 %= MOD;
	}
	
	x1 -= x2;
	x1 += MOD;
	x1 %= MOD;
	x1 -= x2;
	x1 += MOD;
	x1 %= MOD;
	x1 += x3;
	x1 %= MOD;
	
	cout << x1;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3652
#include<functional>
#include <algorithm>
#include <iostream>
#include <memory.h>
#include <string.h>
#include <string>
#include <math.h>
#include <time.h>
#include <vector>
#include <queue>
#include<stack>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long long ll;
string s, t;
int dp[3003][3003];
int calc(int i, int j) {
	if (i == s.size() || j == t.size())
		return 0;
	int &ret = dp[i][j];
	if (ret != -1)
		return ret;
	if (s[i] == t[j])
		ret = 1 + calc(i + 1, j + 1);
	else
		ret = max(calc(i, j + 1), calc(i + 1, j));
	return ret;
}
void print(int i, int j) {
	if (i == s.size() || j == t.size())
		return;
	if (s[i] == t[j]) {
		cout << s[i];
		print(i + 1, j + 1);
	}
	else if (calc(i, j + 1) > calc(i + 1, j))
		print(i, j + 1);
	else
		print(i + 1, j);
}
int main() {
	//freopen("src.txt", "r", stdin);
	memset(dp, -1, sizeof dp);
	cin >> s >> t;
	print(0, 0);
	cout << endl;
	return 0;
}

Measured memory_bytes: 35840
//   //  /////       ///      
//  //   //  //     // //     
// //    //   //   //   //    
////     //   //  //     //   
// //    //   //  /////////    
//  //   //  //   //     //    
//   //  /////    //     //    

#include <bits/stdc++.h>
using namespace std;
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define iter(it,a,b) for(a::iterator it=b.begin(); it!=b.end();++it)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (binary me 1 kitne hai) (if longlong popcount ll)
#define ln "\n"
#define dbg(x) cerr<<#x<<" = "<<x<<endl
#define dbg2(x,y) cerr<<#x<<" = "<<x<<" & "<<#y<<" = "<<y<<endl;
#define dbgstl32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it<<ln;} cerr<<endl
#define dbgstlp32(v) cerr<<#v<<" = \n"; { int c=0; forstl(it,v) \
cerr<<"    Term "<< ++c <<" = "<<it.fi<<" , "<<it.se<<ln;} cerr<<endl
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(n) n.begin() , n.end() 
#define tfi first.first
#define tse first.second
#define tth second
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
typedef pair< pair<int,int> , int> tri;
typedef vector<bool> vbool;
typedef priority_queue<p32> pq32;
typedef priority_queue<p32, vector<p32>, greater<p32> > pq32l;

#pragma GCC optimize ("-O2")
const ll LIM = 2e5+5;
const ll MOD = 1e9+7;
const ll inf = 1e10;



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

	int n;
	cin >> n;

	ll h[n];

	forn(i,n) cin >> h[i];

	ll dp[n];

	dp[0] = 0;
	dp[1] = abs(h[0]-h[1]);

	forsn(i,2,n){
		dp[i] = min( abs(h[i]-h[i-1]) + dp[i-1], abs(h[i]-h[i-2]) + dp[i-2] );
	}

	cout << dp[n-1];

}


Measured memory_bytes: 1792
#include <stdio.h>

int main (void){
      int st = 0, nd =0 ,rd =0,  tem, i;
       
         for( i =0; i<10; i++){
            scanf("%d",&tem);
             if (  tem >= st){
                   rd = nd;
                   nd = st;
                   st  =  tem;
                    continue ;
                }
             if  ( tem >= nd)    {
                    rd = nd;
                    nd =tem;
                   continue;
                  }
             if ( tem >= rd)    {
                    rd =tem;
                   continue;
              }
          }
                printf("%d\n%d\n%d\n",st,nd,rd);
             return 0;
}
               

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

using namespace std;

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

#define $ system("pause")
#define MOD ll(1e9 + 7)
#define MAXN 3010
#define inf (ll)1e18

template<typename T> inline T smin(T &a, const T &b) { return a > b ? a = b : a; }
template<typename T> inline T smax(T &a, const T &b) { return a < b ? a = b : a; }
inline void add(ll &l, const ll &r) { l = (l + r) % MOD; }
ll gcd(ll v, ll u) { return u ? gcd(u, v % u) : v; }
ll po(ll v, ll u) { return u ? (po(v * v % MOD, u >> 1) * (u & 1 ? v : 1) % MOD) : 1; }

/*
int n, arr[MAXN];
int have[MAXN][20];
int pl[MAXN][20], pr[MAXN][20];
vector<int> p[MAXN];

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	for (int i = 2; i < MAXN; i++)
		if (p[i].empty()) {
			for (int j = i; j < MAXN; j += i)
				p[j].push_back(i);
		}

	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		int local = arr[i];
		for (auto e : p[arr[i]]) {
			int cnt = 0;
			while ((local % e) == 0) {
				cnt++;
				local /= e;
			}
			have[e][cnt]++;
		}
	}
	for (int i = 1; i < MAXN; i++) {
		pr[i][19] = have[i][19];
		for (int j = 18; j; j--) 
			pr[i][j] = pr[i][j + 1] + have[i][j];
		have[i][0] = n - pr[i][1];
		pr[i][0] = n;
		pl[i][0] = have[i][0];
		for (int j = 1; j < 20; j++)
			pl[i][j] = pl[i][j - 1] + have[i][j];

	}
	return 0;
}

*/

int n, arr[MAXN];
vector<int> adj[MAXN];

bool dfs(int v, int p = 0) {
	bool res = false;
	for (auto e : adj[v]) {
		if (e ^ p && arr[e] < arr[v]) {
			res |= !dfs(e, v);
		}
	}
	return res;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	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);
	}
	for (int i = 1; i <= n; i++) {
		if (dfs(i))
			cout << i << ' ';
	}
	//$;
	return 0;
}

Measured memory_bytes: 512
n=int(input())
a=[]
x=[]
for _ in range(n):
    A=int(input())
    X=[list(map(int,input().split())) for _ in range(A)]
    a.append(A)
    x.append(X)
ans=0

for i in range(2**n):
    tmp=[0]*n
    for j in range(n):
        if (i>>j)&1:
            tmp[j]=1
    for k in range(n):
        if a[k]==0:
            continue
        for h in range(a[k]):
            hito=x[k][h][0]-1
            singi=x[k][h][1]
            if tmp[k]==1:
                if tmp[hito]!=singi:
                    break
        else:
            continue
        break
    else:
        ans=max(ans,sum(tmp))

print(ans)




Measured memory_bytes: 9120
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int r, d, x;
	scanf("%d%d%d", &r, &d, &x);

	REP(i, 10) {
		x = r*x - d;
		PRINTD(x);
	}
}


Measured memory_bytes: 128
#include <iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int a[100], ji = 0;
	while (n--)
	{
		cin >> a[ji++];
	}
	int sum = 1;
	int max=a[0];
		for (int j = 1; j < ji; j++)
		{
			if (a[j] >= max)
			{
				sum++;
				max = a[j];
			}
		}
	
	cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
x = int(input())


def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors


for i in make_divisors(x):
    a = 0
    while (a - i) < 0 or a**5 - (a - i)**5 < x:
        a += 1
        if a**5 - (a - i)**5 == x:
            print(a, a - i)
            exit()


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    double a, b;
    cin >> a >> b;
    OP(ceil((a + b) / 2));
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

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

const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,k;
    cin >> a >> b >> k;
    int tmp=0;
    for(int i=min(a,b);i>=1;i--){
        if(a%i==0&&b%i==0){
            tmp++;
        }
        if(tmp==k){
            cout << i << endl;
            return 0;
        }
    }
    return 0;
}

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



int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c;
  cin>>a>>b>>c;
  ll res=0;
   res=c-a+b;
  if(res>0)
  cout<<res<<'\n';
  else
  cout<<"0\n";



  return 0;
}


Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;

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

    int P[100001],Y[100001];
    vector<int> py[100001];

    REP(i,M){
        cin >> P[i] >> Y[i];
        py[P[i]].push_back(Y[i]);
    }

    REP(i,N+1){
        SORT(py[i]);
    }

    REP(i,M){
        cout << setfill('0') << setw(6) << right << P[i];
        cout << setfill('0') << setw(6) << right << int(lower_bound(py[P[i]].begin(), py[P[i]].end(), Y[i])-py[P[i]].begin())+1 << endl;
    }
}


Measured memory_bytes: 7808
import itertools
import math
import collections

def func(x,y,z):
    return x**2+y**2+z**2+x*y+y*z+z*x
 
n = int(input())
 
ans = 0
arr = []
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            ans = func(x,y,z)
            arr.append(ans)
            if ans > n:
                break
 

c = collections.Counter(arr)
for i in range(n):
    print(c[i+1])

Measured memory_bytes: 19824
func readThreeInts(separator: String.Element = " ") -> (a: Int, b: Int, c: Int) {
    let ints = readLine()!.split(separator: separator).map { Int($0)! }
    return (a: ints[0], b: ints[1], c: ints[2])
}

func mainC() {
    let (X, K, D) = readThreeInts()

    // いくら移動しても理論値に到達しない場合
    if abs(X) > abs(K * D) {
        print(abs(X) - abs(K * D))
        return
    }

    var position = X
    for i in 1...K {
        if abs(position - D) < abs(position) {
            position -= D
        } else if abs(position + D) < abs(position) {
            position += D
        } else {
            // 絶対値が大きくなってしまう場合
            let remain = K - i + 1
            // 2の倍数なら+D, -Dをし続けて消化できる
            if remain.isMultiple(of: 2) {
                break
            } else {
                // 2の倍数じゃないならより大きくならない方に移動して終わる
                if position >= 0 {
                    position -= D
                } else if position <= 0 {
                    position += D
                } else {
                    fatalError()
                }

                break
            }
        }
    }

    print(abs(position))
}
mainC()

Measured memory_bytes: 8244
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(int i=1,i##_len=(n); i<=i##_len; ++i)
#define drep(i,n) for(int i=(n)-1; i>=0; --i)
#define srep(i,s,t) for(int i=(s);i<(t);++i)
#define rng(obj) (obj).begin(), (obj).end()
#define maxs(x,y) (x=max((x),(y)))
#define mins(x,y) (x=min((x),(y)))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x=max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T>>
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vp = vector<P>;
template <class T> inline istream& operator>>(istream&i,v(T)&v)
{ rep(j,sz(v))i>>v[j];return i;}
template <class T> string join(const v(T)&v)
{ stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template <class T> inline ostream& operator<<(ostream&o,const v(T)&v)
{ if(sz(v))o<<join(v); return o;}
template <class T1,class T2> inline istream& operator>>(istream&i ,pair<T1,T2>&v)
{ return i>>v.fi>>v.se;}
template <class T1,class T2> inline ostream& operator<<(ostream&o ,pair<T1,T2>&v)
{ return o<<v.fi<<","<<v.se;}
template <class T> inline ll suma(const v(T)& a) 
{ ll res(0); for(auto&& x:a) res += x; return res;}
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const double eps = 1e-10;
const int MX = 200005;
//----------------------------------------------------------------

#define fileio ifstream fio; if(argc>=2){fio.open(argv[1]); std::cin.rdbuf(fio.rdbuf());}
#define fastio ios_base::sync_with_stdio(false);
#define MOD 1000000007
//----------------------------------------------------------------

void Main(){
  int n;
  cin>>n;
  int t0=0,t1=0,x0=0,x1=0,y0=0,y1=0;
  rep(i,n){
    cin>>t1>>x1>>y1;
    int time = (t1-t0);
    int dist = ( abs(x1-x0) + abs(y1-y0) );
    bool f = time>=dist and time%2 == dist%2;
    if(f){
      t0=t1;
      x0=x1;
      y0=y1;
    }else{
      cout<<"No"<<endl;
      return;
    }   
  }
  cout<<"Yes"<<endl;
} int main(int argc,char* argv[]){ 
    fastio; fileio; Main();}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		long n=sc.nextLong();
		String ans="";
		char c[]=new char[12];
		int q=0;
		
		while(n>0) {
			n--;
			c[q++]=(char)(n%26+'a');
			n/=26;
		}
		
		for(int i=q-1;i>=0;i--) {
			System.out.print(c[i]);
		}
		System.out.println();
	}
	
	

}

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

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

	int N, M;
	cin >> N >> M;

	vector<int> l( M );
	for( int i = 0; i < N; ++i ) {
		int K;
		cin >> K;

		for( int j = 0; j < K; ++j ) {
			int A;
			cin >> A;

			l[A-1] += 1;
		}
	}

	int result = 0;
	for( int i = 0; i < M; ++i ) {
		if( l[i] == N ) { result += 1; }
	}

	cout << result << endl;
	return 0;
}


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

namespace ConsoleApp14
{
    class Program
    {
        static void Main(string[] args)
        {
            var solver = new Solver();
            solver.Calc();
        }
    }

    public class Solver
    {
        public class TXY
        {
            public int T;
            public int X;
            public int Y;
        }

        public void Calc()
        {
            var H = long.Parse(Console.ReadLine());
            var i = 0;
            if (H == 1)
            {
                Console.WriteLine(1);
                return;
            }

            var ans = H;
            while (true)
            {

                ans /= 2;
            
                if (ans == 1)
                {
                    break;
                }
                i++;

            }
            long sum = 0;

            for (var j = 0; j <= (i + 1); j++)
            {
                sum += (long)Math.Pow(2, j);
            }
            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 11220
#pragma GCC optimize("O4")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
//#define MOD (ll)(998244353)
#define MOD (ll)(1e9+7)
#define INF (1e17)
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

int gcd(int a,int b) { return b==0?a:gcd(b,a%b); }
int lcm(int a,int b) { return a/gcd(a,b)*b; }
int fpow(int b,int p){
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

inline double dis(pii a,pii b){
	return sqrt((a.F-b.F)*(a.F-b.F)+(a.S-b.S)*(a.S-b.S));
}

int32_t main() {
#ifdef LOCAL_TEST
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\input.in","r",stdin);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\output.out","w",stdout);
	freopen("E:\\Jimmy\\2 Coding\\1 C++\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0);

	//code...
	cout<<fixed<<setprecision(10);
	int n; cin>>n;
	vector<pii> v(n);
	for(auto &i:v) cin>>i.F>>i.S;
	sort(all(v));
	double tot=0;
	int cnt=0;
	do{
		For(i,1,n-1){
			tot+=dis(v[i],v[i-1]);
		}
		cnt++;
	}while(next_permutation(all(v)));
	cout<<tot/cnt<<"\n";
	return 0;
}

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

int main(){
  ll H,W;cin >> H >> W;
  ll ans = 10000000000;
  for(int bit=0;bit<2;bit++){
    if(bit == 1){
      ll tmp = H;
      H = W;
      W = tmp;
    }
    for(ll h=1;h<H;h++){ 
      ll A = h*W;
      ll B = (W/2)*(H-h);
      ll C = H*W - A - B;
      ll D = max(max(A,B),C) - min(min(A,B),C);
      ans = min(ans,D);
      B = (H-h)/2*W;
      C = H*W - A - B;
      D = max(max(A,B),C) - min(min(A,B),C);
      ans = min(ans,D);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int S, W;
        Scanner sc = new Scanner(System.in);
        S = sc.nextInt();
        W = sc.nextInt();
        int check = S > W ? 1 : 0;
        switch (check)
        {
            case 1:
                System.out.println("safe");
                break;
            case 0:
                System.out.println("unsafe");
        }
    }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> H(N);
  for (int i = 0; i < N; i++) cin >> H.at(i);
  vector<int> DP(N, 1e9);
  DP.at(0) = 0;
  for (int i = 0; i < N; i++) {
    for (int k = 1; k <= K; k++) {
      if (i + k >= N) continue;
      DP.at(i + k) = min(DP.at(i + k), DP.at(i) + abs(H.at(i + k) - H.at(i)));
    }
  }
  cout << DP.at(N - 1) << "\n";
}

Measured memory_bytes: 1024
n, m, K = map(int, input().split())
for k in range(n + 1):
    if n - 2 * k != 0 and (K - k * m) % (n - 2 * k) == 0 and 0 <= (K - k * m) / (n - 2 * k) <= m:
        print('Yes')
        exit(0)
else:
    print('No')

Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    for (int center = 0; center < N; center++) {
        set<char> found1;
        set<char> found2;
        for (int pos = 0; pos < center; pos++) {
            found1.insert(S[pos]);
        }
        for (int pos = center; pos < N; pos++) {
            found2.insert(S[pos]);
        }

        int cnt = 0;
        for (int i = 0; i < 26; i++) {
            char c = 'a' + i;
            if (found1.find(c) != found1.end() && found2.find(c) != found2.end()) {
                cnt++;
            }
        }
        chmax(ans, cnt);
    }

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


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	int ans = 0;
	for(int i = 0;i < n-1;i++){
		map<char,int> mp1;
		map<char,int> mp2;
		for(int j = 0;j <= i;j++){
			mp1[s[j]] = 1;
		}
		for(int j = i+1;j <= n-1;j++){
			mp2[s[j]] = 1;
		}
		int cnt = 0;
		for(auto p:mp1){
			if(mp2.count(p.first)) cnt++;
		}
		ans = max(ans,cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,Case[10001],count=0;
  while(1)
  {
    scanf("%d",&Case[count]);
    if(Case[count]==0)
      break;
    count++;
  }
  for(i=0;i<count;i++)
  {
    printf("Case %d: %d\n",i+1,Case[i]);
  }
  return 0;
}



Measured memory_bytes: 2028
#include <bits/stdc++.h>
#define rep(i, N) for (int i = 0; i < (N); i++)
#define swap(a, b) (a += b, b = a - b, a -= b)
using namespace std;
int main()
{
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(B, A * N) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n,q,*t,c,x,y,k,i,j;
	for(cin>>n>>q,t=new int[n],i=0;i<n;++i)t[i]=i;
	for(i=q;cin>>c>>x>>y,i--;){
		if(c)
			cout<<(t[x]-t[y]?0:1)<<endl;
		else
			for(k=t[y],j=0;j<n;++j)if(t[j]==k)t[j]=t[x];
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1001;
const int INF = 1e9 + 7;
char a[N][N];
int dist[N][N];
int n, m;
vector <pair <int, int> > v = {{0, -1}, {0, 1}, {1, 0}, {-1, 0}};
bool check(int i, int j) {
    return 0 <= i && i < n && 0 <= j && j < m;
}   
int bfs() {
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            dist[i][j] = INF;
        }   
    }   
    queue <pair <int, int> > q;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) {
            if (a[i][j] == '#') {
                dist[i][j] = 0;
                q.push({i, j});
            }
        }   
    }   
    int ans = 0;
    while (q.size()) {
        int i = q.front().first, j= q.front().second;
        q.pop();
        ans = max(ans, dist[i][j]);
        for (auto e : v) {
            int x = e.first + i, y = e.second + j;
            if (check(x, y) && dist[i][j] + 1 < dist[x][y]) {
                dist[x][y] = dist[i][j] + 1;
                q.push({x, y});
            }   
        }   
    }   
    return ans;
}   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < m; ++j) cin >> a[i][j];
    }   
    cout << bfs() << '\n';
}

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

int n, ans;
string s, t[101];

int main()
{
    cin >> s >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> t[i];
        t[i] = t[i] + t[i];
        if (t[i].find(s) != string::npos)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#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 pb push_back
#define pcnt __builtin_popcount
#define show(x) cout<<#x<<" = "<<x<<endl;
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define fi first
#define se second
#define rng(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define sz(x) (int)(x).size()
#define mp make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef set<int> si;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll;
typedef set<ll> sl;
typedef __int128_t lll;
typedef pair<lll,lll> plll;
typedef vector<lll> vlll;
template<typename T>string join(vector<T>&v)
{stringstream s;FOR(i,0,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T&v)
{fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0; return gcd(a, b, x, y);}
ll modpow(lll a,lll n,ll m){if(a==0)return a;lll p=1;for(;n>0;n/=2,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
void dout(double d){printf("%.12f\n",d);}

const int iinf = 1e9;
const ll linf = 1e18;
const int mod = 1e9+7;
const double pi = acos(-1);
const double eps = 1e-10;
const int N = 0;
int n, x;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> x;
  int mi = iinf;
  FOR(i, 0, n){
    int m;
    cin >> m;
    x -= m;
    mins(mi, m);
  }
  cout << n + x/mi << endl;
  return 0;
}

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


using namespace std;


#ifdef zxc

#include "debug.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = int64_t;
using ld = long double;
const ld EPS = 1e-8;
const ll MOD = 1e9 + 7;
const ld PI = 3.141592653589793;
const int maxn = 200001;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}


ll a[maxn];
ll dp[maxn];
int k;
vector<int> g[maxn];
int nosex[maxn];
int ans = 0;
bool change[maxn];

void dfs(int v) {
    nosex[v] = 0;
    for (int to:g[v]) {
        dfs(to);
        if (!change[to]) {
            nosex[v] = max(nosex[v], nosex[to]);
        }
    }
    if (nosex[v] == k - 1) {
        if (a[v] != 1)
            change[v] = 1;
    } else {
        nosex[v]++;
    }
    if (v != 1)
        ans += change[v];
}

signed main() {
#ifdef zxc
    mt19937 mt(228);
    freopen("../kolya_input.txt", "r", stdin);
//    freopen("../kolya_input.txt", "w", stdout);
#else
    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
//            freopen("", "r", stdin);
//        freopen("hack.out", "w", stdout);
#endif
    fast_io();
    cout.precision(10);
    cout << fixed;
    auto start = chrono::steady_clock::now();
    int n;
    cin >> n;

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

    if (a[1] != 1) {
        a[1] = 1;
        ++ans;
    }
    for (int i = 2; i <= n; ++i) {
        g[a[i]].push_back(i);
    }
    dfs(1);
    cout << ans;
    auto end = chrono::steady_clock::now();
    debug("time", chrono::duration_cast<chrono::milliseconds>(end - start).count() / 1000.0);

}



Measured memory_bytes: 15744
import java.util.*

fun main(args:Array<String>){
    val n = readLine()!!.toInt()
    val t = LongArray(n)
    for(i in 0 until n){
        val k = readLine()!!.toLong()
        t[i] = k
    }
    var ans = t[0]
    for(i in 0 until n){
        ans = lcm(ans, t[i])
    }
    println(ans)
}

fun gcd(a : Long, b : Long) : Long{
    if(b == 0L) return a
    return gcd(b, a % b)
}

fun lcm(a : Long, b : Long) : Long{
    return a / gcd(a, b) * b
}


Measured memory_bytes: 33816
gets.to_i.times{
    order = gets.chomp.split("").reverse
    str = gets.chomp
    order.each{|messenger|
        case messenger
        when "J"
            str = str[-1] + str[0..-2]
        when "C"
            str = str[1..-1] + str[0]
        when "E"
            if str.length > 1
                l = str.length / 2
                str = str[(-l)..-1] + str[0..(l-1)] if str.length.even?
                str = str[(-l)..-1] + str[-l-1] + str[0..(l-1)] if str.length.odd?
            end
        when "A"
            str = str.reverse
        when "P"
            0.upto(str.length - 1){|i| str[i] = ((str[i].to_i - 1) % 10).to_s if ["0","1","2","3","4","5","6","7","8","9"].include? str[i]}
        when "M"
            0.upto(str.length - 1){|i| str[i] = ((str[i].to_i + 1) % 10).to_s if ["0","1","2","3","4","5","6","7","8","9"].include? str[i]}
        end
    }
    puts str
}


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

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N, M;
	cin >> N >> M;
	vector<vector<pair<int, int>>> data(N, vector<pair<int, int>>());
	for (int i = 0; i < M; i++) {
		int P, Y;
		cin >> P >> Y;
		P--;
		data[P].push_back({Y, i});
	}

	vector<int> prf(M), cty(M);
	for (int i = 0; i < N; i++) {
		sort(data[i].begin(), data[i].end());
		int k = data[i].size();
		for (int j = 0; j < k; j++) {
			prf[data[i][j].second] = i+1;
			cty[data[i][j].second] = j+1;
		}
	}
	
	for (int i = 0; i < M; i++) {
		cout.width(6);
		cout.fill('0');
		cout << prf[i];
		
		cout.width(6);
		cout.fill('0');
		cout << cty[i] << endl;
	}	
}


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

// long long gcd(long long a, long long b){
//     if (a < b){
//         a ^= b;
//         b ^= a;
//         a ^= b;
//     }
//     return b ? gcd(b, a % b) : a;
// }

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

int main(){
    llong n,k,q;
    cin >> n >> k >>q;
    llong a[q],count[100001]={};
    rep(i,q){
        cin >> a[i];
        count[a[i]-1]++;
    }
    rep(i,n){
        if(count[i] > q-k){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


Measured memory_bytes: 2176
using System;
 
namespace Dice
{
    class Program
    {
        private static bool Eql(string[] x, string[] y)
        {
            var g = true;
            for (int o = 0; o < x.Length; o++)
              if (x[o] != y[o]) g = false;
            return g;
        }
 
        private static bool Check(string[] x, string[] y)
        {
            if (Eql(x, y)) return true;
            for (int p = 0; p < 2; p++)
            {
                for(int q = 0; q < 4; q++)
                {
                    string a = x[0], b = x[1], c = x[2], 
                           d = x[3], e = x[4], f = x[5];
                    x = p == 0 ? new string[] { e, a, c, d, f, b } :
                                 new string[] { d, b, a, f, e, c };
                    if (Eql(x, y)) return true;
                    var h = x;
                    for(int r = 0; r < 4; r++)
                    {
                        string i = h[0], j = h[1], k = h[2],
                               l = h[3], m = h[4], n = h[5];
                        h = new string[] { i, k, m, j, l, n };
                        if (Eql(h, y)) return true;
                    }
                }
            }
            return false;
        }
 
        static void Main()
        {
            int s = int.Parse(Console.ReadLine());
            var t = new string[s][];
            for(int u = 0; u < s; u++)
                t[u] = Console.ReadLine().Split(' ');
            for (int v = 0; v < s; v++)
                for (int w = v + 1; w < s; w++)
                    if (Check(t[v], t[w]))
                    {
                        Console.WriteLine("No");
                        return;
                    }
            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 9300