akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char a[1000];
	int x=0,y=0,i;
	gets(a);
	for(i=0;i<strlen(a);i++)
	{
		if(a[i]=='C') x++;
		if(a[i]=='F')
		{
			if(x!=0) y++;
		}
	}
	if(x>=1&&y>=1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
    final double EPS = 1.0e-10;

    void run() {
        int MAX = 30001;
        boolean isPrime[] = new boolean[MAX];
        List<Integer> primes = new ArrayList<Integer>();
        Arrays.fill(isPrime, true);
        isPrime[0] = isPrime[1] = false;
        for (int i = 2; i < MAX; i++) {
            if (isPrime[i]) {
                primes.add(i);
                for (int j = i + i; j < MAX; j += i) {
                    isPrime[j] = false;
                }
            }
        }
        Scanner sc = new Scanner(System.in);
        while (true) {
            int T = sc.nextInt();
            if (T == 0)
                break;
            int ans = 0;
            Set<String> set = new HashSet<String>();
            for (int i = 0; i < primes.size(); i++) {
                int a = primes.get(i);
                if (a >= T)
                    break;
                for (int j = i; j < primes.size(); j++) {
                    int b = primes.get(j);
                    int c = T - a - b;
                    if (c < 0)
                        break;
                    if (a + b > c && c > Math.abs(b - a))
                        if (isPrime[c]) {
                            int[] ary = { a, b, c };
                            Arrays.sort(ary);
                            String str = Arrays.toString(ary);
                            if (set.contains(str))
                                continue;
                            set.add(str);
                            // System.out.println(a + " " + b + " " + c);
                            ans++;
                        }
                }
            }
            System.out.println(ans);
        }
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 24000
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int LL;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



int main(){fastio
    ll a,b,c;cin>>a>>b>>c;
    cout<<max(0,c-(a-b))<<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
//const int mod = ;

vi p;

int getp(int v) {
  if (p[v] == v) return v;
  return p[v] = getp(p[v]);
}

void join(int a, int b) {
  a = getp(a);
  b = getp(b);
  if (a == b) return;
  if (rand() % 2) swap(a, b);
  p[a] = b;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  int n, m;
  cin >> n >> m;
  p.resize(n);
  vi a(n);
  for (int i = 0; i < n; ++i) p[i] = i;
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < m; ++i) {
    int a, b;
    cin >> a >> b;
    join(a, b);
  }
  vvi v(n);
  for (int i = 0; i < n; ++i) v[getp(i)].push_back(a[i]);
  int comp = 0;
  ll res = 0;
  vi ts;
  for (int i = 0; i < n; ++i) {
    if (!v[i].empty()) {
      ++comp;
      sort(v[i].begin(), v[i].end());
      res += v[i][0];
      for (int j = 1; j < v[i].size(); ++j) ts.push_back(v[i][j]);
    }
  }
  if (comp == 1) {
    cout << 0 << endl;
  } else {
    int need = comp - 2;
    sort(ts.begin(), ts.end());
    if (need > ts.size()) {
      cout << "Impossible\n";
    } else {
      for (int i = 0; i < need; ++i) res += ts[i];
      cout << res << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 6528
using System;
class program {
static void Main(string[] args){
  program p = new program();
  p.Run();
}
  void Run(){
  string[] inp = Console.ReadLine().Split();
  int ab = int.Parse(inp[0]);
   int bc = int.Parse(inp[1]);
  int ans = (int)(ab*bc/2);
  Console.WriteLine(ans.ToString());
   }
  }

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, A;
  cin >> N;
  vector<int> Z(0,0);
  for(int i=0; i<N; i++){
    cin >> A;
    Z.push_back(A);
  }
  vector<int> X(1,Z[0]), Y(1,Z[N-1]);
  int b=Z[0];
  for(int i=1; i<N-1; i++){
    int a=Z[i], c=a%b;
    while(c!=0){
      a=b;
      b=c;
      c=a%b;
    }
    X.push_back(b);
  }
  b=Z[N-1];
  for(int i=N-2; i>0; i--){
    int a=Z[i], c=a%b;
    while(c!=0){
      a=b;
      b=c;
      c=a%b;
    }
    Y.push_back(b);    
  }
  int ans=Y[N-2];
  for(int i=0; i<N-2; i++){
    int a=X[i], b=Y[N-i-3], c=a%b;
    while(c!=0){
      a=b;
      b=c;
      c=a%b;
    }
    ans=max(ans, b); 
  }
  ans=max(ans, X[N-2]);
  cout << ans << endl;
}

Measured memory_bytes: 1784
from itertools import product

n = int(input())
al = []

for _ in range(n):
    curr_al = []
    a = int(input())
    for i in range(a):
        x,y = map(int, input().split())
        curr_al.append((x,y))
    al.append(curr_al)


pattern = 2
ite = product(range(pattern),repeat=n)
ans = 0
for it in ite:
    a_01_l = list(it)
    curr_ans = a_01_l.count(1)
    # print('-----')
    # print(a_01_l)
    for i, curr_it in enumerate(it):
        if curr_it == 1:
            check = True
            for a in al[i]:
                if a_01_l[a[0]-1] != a[1]:
                    check = False
            if not check:
                break
    else:
        # print('ok')
        ans = max(curr_ans,ans)

print(ans)


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

using namespace std;
typedef long long ll;

ll n,arr[3003],mem[3][3005][3005];

ll dp(ll p, ll i1, ll i2){
    if(i1>i2){
        return 0;
    }
    if(mem[p][i1][i2]!=-1)return mem[p][i1][i2];
    if(p==0){
        ll o1=dp(1,i1+1,i2)+arr[i1];
        ll o2=dp(1,i1,i2-1)+arr[i2];
        return mem[p][i1][i2]=max(o1,o2);
    }
    else{
        ll o1=dp(0,i1+1,i2)-arr[i1];
        ll o2=dp(0,i1,i2-1)-arr[i2];
        return mem[p][i1][i2]=min(o1,o2);
    }
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);cout.tie(nullptr);
    cin>>n;
    for(ll i=0;i<n;i++)cin>>arr[i];
    memset(mem,-1,sizeof(mem));
    cout<<dp(0,0,n-1);
}

Measured memory_bytes: 212096
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	ll n,m,i,j;
	cin>>n>>m;
	ll a[m+1],sum=0;
	for(i=0;i<m;i++)
		cin>>a[i],sum+=a[i];
	if(sum>n)cout<<"-1";else cout<<n-sum;
	return 0;
}

Measured memory_bytes: 3728
#include <bits/stdc++.h>
using namespace std;
const int64_t INF=9999999999999999;

int main() {
   int64_t N;
   cin>>N;
   int64_t ans=INF;
   for(int64_t i=1;i<=sqrt(N);i++){
      if(N%i==0){ans=min(ans,i-1+N/i-1);}
   }
   cout<<ans<<endl;
return 0;}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;


int main() {
    
    int K = 0;
    cin >> K;
    for (int i = 0; i < K; i++) {
        cout << "ACL";
    }
    

    return 0;
}

Measured memory_bytes: 3040
#define _USE_MATH_DEFINES

#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

int main(){
	
	int N;
	cin >> N;
	
	if((N % 1000) % 111 == 0 || (N / 10) % 111 == 0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

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

int main(){

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

    int n,a,c=0;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a;
        c+=(i&1)&&(a&1);
    }
    cout<<c<<endl;

    return 0;
}

Measured memory_bytes: 3604
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

P, Q, R = rl()

print(min(P+Q, Q+R, R+P))


Measured memory_bytes: 68480
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int c[3][3], a[3], b[3];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,3)rep(j,3) cin >> c[i][j];
    for(int i = 0; i <= 100; i++){
        rep(j,3){
            a[j] = -1;
            b[j] = -1;
        }
        a[0] = i;
        bool ok = true;
        rep(j,3){
            b[j] = c[0][j] - a[0];
        }
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        rep(j,3){
            if(c[1][j] != a[1] + b[j]) ok = false;
            if(c[2][j] != a[2] + b[j]) ok = false;
        }
        if(ok){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main
  n = gets.chop.to_i
  bs = gets.chop.split.map(&:to_i)
  ans = 0
  if n == 2
    puts (bs[0] * 2)
   else
     ans += bs[0]
     0.upto(n - 3) do |i|
       b1 = bs[i]
       b2 = bs[i+1]
       ans += [b1, b2].min
     end
     ans += bs[n-2]
     puts ans
  end
end

if __FILE__ == $0
  main
end



Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s,ans;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    rep(i,Size(s)){
        if(s[i]=='B'){
            if(Size(ans)==0)continue;
            ans.erase(Size(ans)-1);
        }
        else{
            ans+=s[i];
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 384
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

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

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn=5e2+10, lg=22, mod=1e9+7, inf=1e18;

ll n,ans[maxn*maxn],a[maxn],f[maxn];
bool cmp(int x,int y){return a[x]<a[y];}

int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	
	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>a[i];
		f[i]=i;
	}
	sort(f+1,f+n+1,cmp);
	ll k=1;
	for(int i=1;i<=n;i++){
		ans[a[f[i]]]=f[i];
		for(int j=1;j<f[i];j++){
			while(ans[k]) k++;
			if(k>a[f[i]]) return cout<<"No", 0;
			ans[k]=f[i];
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n-f[i];j++){
			while(ans[k]) k++;
			if(k<a[f[i]]) return cout<<"No", 0;
			ans[k]=f[i];
		}
	cout<<"Yes"<<endl;
	for(int i=1;i<=n*n;i++) cout<<ans[i]<<' ';
	return 0;
}


















Measured memory_bytes: 3200
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T, class U> inline void chmax(T &a, const U &b) { if ((a) < (b)) (a) = (b); }
template <class T, class U> inline void chmin(T &a, const U &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#include <atcoder/math>
using namespace atcoder;

int solve() {
    ll n;cin>>n;

    ll ans = INF;
    for(ll i=1; i*i<=2*n; i++){
        if (2*n % i != 0) continue;

        {
            ll d1 = i;
            ll d2 = (2*n)/i;
            auto [y, z] = crt({0, d2-1}, {d1, d2});
            if (y == 0 || z == 0){
            }
            else{
                dump(d1, d2, y, z);
                chmin(ans, y);
            }
        }
        {
            ll d2 = i;
            ll d1 = (2*n)/i;
            auto [y, z] = crt({0, d2-1}, {d1, d2});
            if (y == 0 || z == 0){
            }
            else{
                dump(d1, d2, y, z);
                chmin(ans, y);
            }
        }
    }
    cout << ans << endl;

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


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

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; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	
	string s;
	
	cin>>N>>s;
	
	for(int i = 0; i < s.size(); i++){
		int x = s[i] - 'A' + N;
		x %= 26;
		cout<<((char)(x+'A'));
	}
	cout<<endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef pair<int,int> pii;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
template<class Type> void join(const Type &a){for(auto elem:a)cout<<elem<<' ';cout<<endl;}

int main(){
	string w[]={"Sunny","Cloudy","Rainy","Sunny"};
	
	string s;
	cin>>s;
	REP(i,3){
		if(s==w[i]){
			cout<<w[i+1]<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
(N, ) = [int(n) for n in input().split()]
A = {'AC':0, 'WA':0, 'TLE':0, 'RE':0}

for _ in range(N):
    A[input()] += 1

for k in ['AC', 'WA', 'TLE', 'RE']:
    print('{} x {}'.format(k, A[k]))


Measured memory_bytes: 9176
import heapq

N, M = map(int, input().split())
A = [-int(x) for x in input().split()]
heapq.heapify(A)

for _ in range(M):
    tmin = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmin//2))

print(-sum(A))

Measured memory_bytes: 72216
#include <iostream>
#include <string>
std::string s;
char x;
int f(int a,int b,int c){
	char i=s[a];
	x=((i!='s'&&i==s[b]&&i==s[c])?i:0);
	return x;
}
int main(){
	int i,j;
	while(getline(std::cin,s)){
		x=(f(0,4,8)||f(2,4,6))?s[4]:0;
		if(!x){
			for(i=0;i<3;i++){
				f(i,i+3,i+6);
				if(x)break;
				j=i*3;
				f(j,j+1,j+2);
				if(x)break;
			}
			if(!x)x='d';
		}
		std::cout<<x<<"\n";
	}
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define modulo 100000
#define mod(mod_x) ((((long long)mod_x)+modulo)%modulo)
#define Inf 1000000000

int dijkstra(vector<vector<pair<int,int>>> &E,int start,int goal){
	priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>> ,greater<pair<int,pair<int,int>>>> P;
	vector<int> dis(E.size(),Inf);
	dis[start]=0;
	for(int i=0;i<E[start].size();i++){
		P.push(make_pair(E[start][i].first,make_pair(start,E[start][i].second)));
	}
	
	while(P.size()!=0){
		pair<int,pair<int,int>> X;
		X=P.top();
		P.pop();
		int cost = X.first;
		int from = X.second.first;
		int to = X.second.second;
		if(dis[to]==Inf){
			dis[to] = cost;
			for(int i=0;i<E[to].size();i++){
				P.push(make_pair(E[to][i].first+dis[to],make_pair(to,E[to][i].second)));
			}
		}
	}
	
	return dis[goal];
	
}

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<pair<int,int>>> E(3*N,vector<pair<int,int>> (0));
	
	for(int i=0;i<M;i++){
		int a,b;
		cin>>a>>b;
		a--;b--;
		E[a].push_back(make_pair(1,b+N));
		E[a+N].push_back(make_pair(1,b+2*N));
		E[a+2*N].push_back(make_pair(1,b));
	}
	
	int S,T;
	cin>>S>>T;
	S--;T--;
	
	int a = dijkstra(E,S,T);
	if(a==Inf){
		cout<<-1<<endl;
	}
	else{
		cout<<a/3<<endl;
	}
	
	
	
	
	return 0;
}


Measured memory_bytes: 17792
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>

using namespace std;

int main() {
  int d[5];
  for (int i = 0; i < 5; i++) cin >> d[i];
  
  int max_diff = 0;
  int sum = 0;
  for (int i = 0; i < 5; i++) {
    int diff = 10 - d[i] % 10;
    if (diff < 10 && max_diff < diff) {
      max_diff = diff;
    }
    sum += (diff == 10 ? 0 : diff) + d[i];
  }
  
  cout << (sum - max_diff) << "\n";
}

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

using std::swap;
typedef long long LL;

const int N=1e5+10;

struct Edge{int to,next;} way[N<<2];
int n,m,num[N],tot,son[N],f[N][20],dep[N];
LL p,q,cnt;
bool vis[N];

void Build(int a,int b) { way[++tot]=(Edge){b,num[a]}; num[a]=tot; }

void Init() {
	int u,v;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i) {
		scanf("%d%d",&u,&v);
		Build(u,v);
		Build(v,u);
	}
}

int LCA(int x,int y) {
	if (dep[x]>dep[y]) swap(x,y);
	for (int i=19;i>=0;--i) if (dep[x]<=dep[f[y][i]]) y=f[y][i];
	for (int i=19;i>=0;--i) 
		if (f[x][i]!=f[y][i]) {
			x=f[x][i];
			y=f[y][i];
		}
	if (x!=y) x=f[x][0],y=f[y][0];
	return x;
}

bool Dfs(int x,int fa) {
	vis[x]=1; f[x][0]=fa; son[x]=1; dep[x]=dep[fa]+1;
	for (int i=1;i<20;++i) f[x][i]=f[f[x][i-1]][i-1];
	bool ret=0;
	for (int i=num[x];i;i=way[i].next) {
		int v=way[i].to;
		if (v==fa) continue;
		if (!vis[v]) ret|=Dfs(v,x),son[x]+=son[v];
		else {
			int lca=LCA(v,x),len=dep[x]+dep[v]-(dep[lca]<<1)+1;
			if (len&1) ret|=1;
		}
	}
	return ret;
}

void Solve() {
	p=q=cnt=0;
	for (int i=1;i<=n;++i) if (!vis[i]) {
		bool fl=Dfs(i,0);
		if (son[i]==1) cnt++;
		else if (!fl) q++;
		else p++;
	}
	printf("%lld\n",1ll*n*n-1ll*(n-cnt)*(n-cnt)+q*q*2+p*p+p*q*2);
}

int main() {
	Init();
	Solve();
	return 0;
}

Measured memory_bytes: 16128
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

//Seishun 18 Kippu
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			int m = sc.nextInt();
			if((n|m)==0)break;
			Map<String, Integer> ref = new HashMap<String, Integer>();
			int id = 0;
			int s = id; ref.put(sc.next(), id++);
			int p = id; ref.put(sc.next(), id++);
			int g = id; ref.put(sc.next(), id++);
			int[][] e = new int[n][n];
			for(int[]a:e)Arrays.fill(a, 1<<29);
			while(m--!=0){
				String A = sc.next();
				String B = sc.next();
				int a = -1, b = -1;
				if(ref.containsKey(A))a = ref.get(A);
				else {
					a = id; ref.put(A, id++);
				}
				if(ref.containsKey(B))b = ref.get(B);
				else{
					b = id; ref.put(B, id++);
				}
				int d = sc.nextInt(), t = sc.nextInt();
				e[a][b] = e[b][a] = d/40+t;
			}
			for(int k=0;k<n;k++)for(int i=0;i<n;i++)for(int j=0;j<n;j++)e[i][j] = Math.min(e[i][j], e[i][k]+e[k][j]);
			System.out.println(e[s][p]+e[p][g]);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 16000
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n,a; cin >> n >> a;
  if(n%500 <= a) cout << "Yes" << endl;
  else cout << "No" << endl;
} 

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

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

map<ll, ll> factorize(ll n){
    map<ll, ll> mp;
    ll sq = sqrt(n);
    FOR(i, 2, sq+1){
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
    }
    // 残り
    if(n!=1){
        mp[n]++;
    }
    return mp;
}

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

    // input
    ll N;
    cin >> N;

    vector<ll> P;

    auto mp = factorize(N);
    for(auto p : mp){
        ll v = p.first;
        ll count = p.second;
        // p2(v, count);

        FOR(i, 0, count){
            P.push_back(v);
        }
    }

    map<pair<ll, ll>, bool> done;
    ll sum = 0;
    // vprint(P);
    ll L = P.size();
    FOR(i, 0, 1<<L){
        ll a = 1;
        ll b = 1;
        FOR(j, 0, L){
            if(i>>j&1){
                a *= P[j];
            }else{
                b *= P[j];
            }
        }

        if(a-b>=2 && !done[make_pair(a, b)]){
            sum += a-1;
            done[make_pair(a, b)] = true;
        }
        // cout << "a " << a << " b " << b << endl;
    }

    p(sum);



    
    return 0;
}

Measured memory_bytes: 512
N = int(input())
S = input()
dp = [[0]*N for i in range(N)]
pm = 0
ans = 0
for i in range(N-1,0,-1):
  for j in range(i-1,-1,-1):
    if S[i]==S[j]:
      if i<N-1:
        dp[i][j] = min(dp[i+1][j+1]+1, i-j)
      else:
        dp[i][j] = 1
    else:
      dp[i][j] = 0
    if dp[i][j]>ans:
      ans = dp[i][j]
print(ans)

Measured memory_bytes: 229896
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int n,x[30],y[30],r[30],c[30],cover[30];
char dp[1<<24];
vector<pii> same_col;

int rec(int bit){
  if(dp[bit])return dp[bit];

  int res = 0;
  for(int i=0;i<(int)same_col.size();i++){
    const int a = same_col[i].first, b = same_col[i].second;
    if( (~bit)&(1<<a) && (~bit)&(1<<b) ){
      if( (~bit)&cover[a] || (~bit)&cover[b])continue;
      res = max(res, rec(bit | (1<<a) | (1<<b))+2);
    }
  }
  return dp[bit]=res;
}
  
int main(){
  while(cin >> n, n){
    for(int i=0;i<n;i++)cin >> x[i] >> y[i] >> r[i] >> c[i];

    same_col.clear();
    for(int i=0;i<n;i++){
      cover[i] = 0;
      for(int j=0;j<i;j++){
	if( (x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) < (r[i]+r[j])*(r[i]+r[j]) ){
	  cover[i] |= 1<<j;
	}
	if(c[i] == c[j])same_col.push_back(pii(i,j));
      }
    }

    memset(dp,0,sizeof(dp));
    cout << rec(0) << endl;
  }	  
}

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

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> A(N);
	
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
		// 入力値から-1することで、配列のindexとして利用
		A[i]--;
	}
	
	vector<int> answer(N);
	// 逆順列の計算
	for (int i = 0; i <  N; i++)
	{
		// i番目の生徒はA[i]番目に教室に来た
		answer[A[i]] = i;
	}
	
	// 出力
	for (int i = 0; i < N; i++)
	{
		// i番目 + 1で、答えの出力に変換
		cout << answer[i] + 1 << " ";
	}
	cout << endl;
	
	return 0;
}


Measured memory_bytes: 1536
import numpy as np
N, M, C = map(int, input().split())
B = np.array(list(map(int, input().split())))
count = []
A = [count.append(0) for _ in range(N) if sum(
    B * np.array(list(map(int, input().split())))) + C > 0]
print(len(count))


Measured memory_bytes: 12480
#include<stdio.h>
typedef long long int lli;
int main() {
  char s[6];
  scanf("%s", &s);
 
  if(s[2]==s[3] && s[4]==s[5]){
      printf("Yes\n");
  }
  else{
      printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1632
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second


namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int a, b, t;
	cin >> a >> b >> t;
	int time = 0;
	int ans=0;
	while (time <= t) {
		time += a;
		if (time <= t) {
			ans += b;
		}
	}
	cout << ans << endl;
}


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

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    int T[N], departure = -1, people = 0, ans = 0;
    rep(i, N) {
        cin >> T[i];
    }
    sort(T, T + N);
    // C人まで乗れる，K越えるとだめ
    rep(i, N) {
        //cout << i << ": " << departure << " " << people << " " << ans << endl;
        if (T[i] > departure || people >= C) {
            departure = T[i] + K;
            people = 1;
            ans++;
        } else {
            people++;
        }
        //cout << i << ": " << departure << " " << people << " " << ans << endl;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int blood[110];

int main() {
	int n,k;
	while(n=in(),k=in()){
		int i,j;
		for(i=0;i<k;i++){
			cin>>blood[i];
		}
		for(j=0;j<n;j++){
			for(i=0;i<k;i++){
				blood[i]-=in();
			}
		}
		for(i=0;i<k;i++){
			if(blood[i]<0)break;
		}
		cout<<(i==k?"Yes":"No")<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define eb emplace_back
#define sz(V) ((int)(V).size())
using namespace std;
typedef long long ll;

const int MAXN = 200055;

int A[MAXN], B[30];

ll Ans;
int N;

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

	cin >> N;
	for(int s = 1, i = 1, c = 0; i <= N; i++) {
		cin >> A[i];
		for(int j = 0; j < 20; j++)
			if((A[i] & (1<<j)) && 2 == ++B[j])
				c++;
		for(; c; s++) for(int j = 0; j < 20; j++)
			if((A[s] & (1<<j)) && 1 == --B[j])
				c--;
		Ans += i-s+1;
	}

	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(void)
{
	int H,W,a,b,c;
	while(1){
	scanf("%d %d",&H,&W);
	if(H==0 && W==0){break;}
	for(a=1;a<=H;a++){
	for(b=1;b<=W;b++){
	printf("#");
	}
	printf("\n");
	}
	printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
#include <cctype>
#define ll long long
#define PI 3.14159265358979323846
using namespace std;
const int maxn = 1e6+7;

int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(c<=b){
		int start=max(a,c);
		int end=min(b,d);
		if(end-start>0){
			cout<<end-start<<endl;
		}
		else{
			cout<<0<<endl;
		}
	}
	else{
		cout<<0<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

using T = tuple<double, int, int>;

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int l = 0, r = INF;
  while (r-l > 1) {
    int mid = (l+r)/2;
    ll num = 0;
    rep(i, n)
      num += (a[i]+mid-1)/mid-1;
    if (num <= k)
      r = mid;
    else
      l = mid;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 3856
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    vector<ll> a(n), sum(n);
    rep(i,n) cin >> a[i];
    sort(all(a));
    sum[0] = a[0];
    rep(i,n-1) sum[i+1] = sum[i] + a[i+1];

    int ans = 1;
    for(int i = n-1; i > 0; i--){
        if (a[i] > 2 * sum[i-1]) break;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n, l;
int x[MAXN];

void read()
{
    cin >> n;
    for(int i = 0; i < n; i++)
        cin >> x[i];
    cin >> l;
}

int nxt[MAXN][20];

void solve()
{
    x[n] = (int)2e9 + 42;
    for(int i = 0; i < 20; i++) nxt[n][0] = n;
    for(int i = n - 1; i >= 0; i--)
    {
        nxt[i][0] = nxt[i + 1][0];
        while(x[nxt[i][0]] - x[i] > l) nxt[i][0]--;
        for(int l = 1; l < 20; l++) nxt[i][l] = nxt[nxt[i][l - 1]][l - 1];
    }

    int q;
    cin >> q;
    while(q--)
    {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if(a > b) swap(a, b);

        int answer = (a == b) ? -1 : 0;
        for(int l = 19; l >= 0; l--)
            if(x[nxt[a][l]] < x[b])
                answer += (1 << l), a = nxt[a][l];

        cout << answer + 1 << endl;
    }
}

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

	read();
	solve();
	return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vec a = ivec(n);
    map<int, int> mp;
    repall (x, a)
        mp[x]++;
    repall (p, mp) {
        if (p.second > 1) {
            print("NO");
            return 0;
        }
    }
    print("YES");

    return 0;
}


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

const int MaxN = 200005;

int n;
long long k;
int a[MaxN], depth[MaxN];

int main()
{
    cin >> n >> k;
    rep(i,1,n)
    {
        cin >> a[i];
        depth[i] = -1;
    }
    depth[1] = 0;
    int Count = 0, x = 1;
    while (depth[a[x]] == -1)
    {
        x = a[x];
        Count++;
        k--;
        if (k == 0)
        {
            cout << x;
            return 0;
        }
        depth[x] = Count;
    }
    x = a[x];
    Count++;
    k--;
    k = k % (Count - depth[x]);
    while (k > 0)
    {
        k--;
        x = a[x];
    }
    cout << x;
    return 0;
}


Measured memory_bytes: 5200
#include <bits/stdc++.h>
#define eb emplace_back
#define pb pop_back
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define sz(x) (int)x.size()
#define mp make_pair
#define pii pair<int,int>
#define vi vector<int>
#define itn int
#define vpii vector<pii>
#define pdd pair<double,double>
#define vll vector<ll>

typedef long long ll;

using namespace std;

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (i & 1) cnt++;
	}
	cout << fixed << setprecision(100) << (double)cnt / n;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;
using ll = long long;

using Pair = pair<int, int>;

int main() {
    int n, m;
    cin >> n;
    vector<string> strs;
    map<string, int> s;
    string str;
    for (auto i = 0; i < n; i++) {
        cin >> str;
        ++s[str];
        strs.push_back(str);
    }
    cin >> m;
    for (auto i = 0; i < m; i++) {
        cin >> str;
        --s[str];
    }
    int ans = 0;
    for (auto &c: strs) {
        ans = max(s[c], ans);
    }
    cout << ans;
}





Measured memory_bytes: 256
N, K = map(int, input().split())
*p, = map(int, input().split())

s = 0
for i in range(K):
    s += p[i]
ans = (K+s)/2

for i in range(K, N):
    s += p[i]
    s -= p[i-K]
    ans = max(ans, (K+s)/2)

print(ans)

Measured memory_bytes: 25060
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if x in a and y in a:
    print('Yes')
elif x in b and y in b:
    print('Yes')
elif x in c and y in c:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int l,r,d;
	cin>>l>>r>>d;
	cout<<(r/d)-((l-1)/d)<<"\n";
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 




////////////////////////////////////////////////////////

ll cnt1[61];

int main() {
    ll n; cin >> n;
    rep(i, 0, n){
        ll a; cin >> a;
        bitset<60> s(a);
        rep(i, 0, 60){
            if(s.test(i)) cnt1[i]++;
        }
    }
    ll kake = 1;
    ll ans = 0;
    rep(i, 0, 60){
        ans += ((cnt1[i]*(n-cnt1[i])%MOD)*((1LL<<i)%MOD))%MOD;
        ans %= MOD;
        kake *= 2;
        kake %= MOD;
    }
    co(ans);

    return 0;
}


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

int popcoun(int x)
{
  return __builtin_popcount(x);
}

int mod(int x)
{
  if (x == 0) return 0;
  return mod(x % popcoun(x)) + 1;
}


int main()
{
  int n;
  cin >> n;
 int a[200001],ans[200001];

  for (int i = 1; i <= n; i++)
  {
     char s;
     cin>>s;
     a[i]=s-'0';
  }
  int popcount = 0;
  for (int i = 1; i <= n; i++) popcount+=a[i];
  for (int c = 0; c < 2; c++)
    {
    int npc = popcount;
    if (c == 0)  npc++;
    else npc--;
    if (npc == 0)  continue;

    int r0 = 0;
    for (int i = 1; i <= n; i++)
    {
      int sum = r0 * 2 + a[i];
      r0 = sum % npc;
    }

    int k = 1;
    for (int i = n; i > 0; i--)
    {
        if (a[i] == c)
      {
        int r = r0;
        if (c == 0)
        {
          r = (r + k) % npc;
        }
        else
        {
          r = (r - k + npc) % npc;
        }
        ans[i] = mod(r) + 1;
      }

      k = (k * 2) % npc;
    }
  }

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


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

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int cnt =0;
    for(int i=0; i<=N-3; i++){
        if(s.substr(i, 3) == "ABC") cnt++;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int time;
    int seconds;
    int minutes;
    int hours;

    cin>>time;
    seconds=time%60;
    minutes=(time/60)%60;
    hours=(time/60)/60;
    cout<<hours<<":"<<minutes<<":"<<seconds<<endl;
    return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
const ll mod = 998244353;
const double PI = acos(-1);
const double eps = 1e-7;
int a,b,x;
int main() 
{
	cin>>a>>b>>x;
	double area=x*1.0/a;
	double s1=a*0.5*b;
//	cout<<area<<" "<<s1<<endl;
	if(area<=s1)
	{
		area*=2;
		area/=b;
		double zz=b/area;
		printf("%.7f\n",atan(zz)*1.0*180/PI);	
	}
	else
	{
		area=a*b*1.0-area;
		area*=2;
		area/=a;
		double zz=area/a;
		printf("%.7f\n",atan(zz)*1.0*180/PI);
	}
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int a, b, n;
  while (~scanf("%d%d%d", &a, &b, &n)) {
    int s = 0;
    for (a = (a % b) * 10; a && n; n--) {
      s += (a - (a % b)) / b;
      a = a % b * 10;
    }
    printf("%d\n", s);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    int ans = 1;
    for (int i = 2; i * i <= n; i++)
    {
        if(i*i<=n){
            ans = i * i;
        }
    }
    cout << ans << endl;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> vec;
  for (int i = 0; i < N; i++) {
    int tmp;
    cin >> tmp;
    vec.push_back(tmp);
  }
  sort(vec.begin(), vec.end());

  int ans = INT_MAX;
  for (int i = K - 1; i < N; i++) {
    int hmin = vec[i - K + 1];
    int hmax = vec[i];
    int diff = hmax - hmin;
    ans = min(ans, diff);
  }

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

Measured memory_bytes: 892
N = gets.to_i
N.times do
  a = gets.split(" ").map(&:to_i)
  b, c = 0, 0
  f = 0
  a.each do |n|
    if n > b
      b = n
    elsif n > c
      c = n
    else
      f = 1
    end
  end
  puts %w{YES NO}[f]
end

Measured memory_bytes: 6096
#include<stdio.h>

int main() {
    int seconds, h, m, s;
    scanf("%d", &seconds);
    h = seconds / 3600;
    m = (seconds-3600*h) / 60;
    s = seconds - 3600*h - 60*m;
    printf("%d:%d:%d\n", h, m ,s);
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;


int main(){
    int ans=0;
    int n;cin >>n;
    for (int i = 1; i*i<=n; ++i) ans=i*i;
    cout <<ans <<endl;
    return 0;
}

Measured memory_bytes: 3556
n = gets.to_i
adj = {}
(n - 1).times do
  a, b = gets.split(' ').map(&:to_i)
  adj[a] ||= {}
  adj[a][b] = 1
  adj[b] ||= {}
  adj[b][a] = 1
end
c = gets.split(' ').map(&:to_i).sort
sum = c[0...(n - 1)].inject(:+)

d = (0..n).map { nil }
v = (0..n).map { false }

s = [1]
v[1] = true
while !(s.empty?) do
  i = s.pop
  d[i] = c.pop
  adj[i].each_key do |j|
    unless v[j]
      v[j] = true
      s.push(j)
    end
  end
end

puts sum
puts d[1..n].join(' ')


Measured memory_bytes: 6648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    cin >> s;
    int n = s.size();

    vector<int> ans(n);
    
    int cnteven = 0, cntodd = 0;
    int posR, posL;
    rep(i, n) {

        if(i%2 == 0) {
            cnteven++;
        }
        else {
            cntodd++;
        }

        if(i < n-1 && s[i] == 'R' && s[i+1] == 'L') {
            posR = i;
            posL = i+1;
        }

        if( (i == n-1) ||  (i < n-1 && s[i] == 'L' && s[i+1] == 'R') ) {
            if(posR%2 == 0) {
                ans[posR] = cnteven;
                ans[posL] = cntodd;
            }
            else {
                ans[posR] = cntodd;
                ans[posL] = cnteven;
            }
            cntodd = 0;
            cnteven = 0;
        }

    }

    rep(i, n) {
        cout << ans[i] << " ";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 1024