akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const ll INF = (1LL << 31) - 1;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



int main() {

	
	ll s;
	cin >> s;
	ll a = 1000000000;
	ll b = 1LL;

	ll d = ceil(s / (double)a);
	ll c = a * d - s;

	cout << "0 0 1000000000 1 " << c << " " << d << endl;



	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
int r[100005],X,K,Q,a,b,c,d;
void calc(int v){
	c+=v;
	if (a>X-c) a=b=X-c;
		else b=b>X-c?X-c:b;
	if (b<-c) a=b=-c;
		else a=a<-c?-c:a;
}
int main(){
	scanf("%d%d",&X,&K);
	for (int i=1;i<=K;i++) scanf("%d",&r[i]);
	a=0;b=X;c=d=0;
	scanf("%d",&Q);
	for (int i=1,j=1,k=-1;i<=Q;i++){
		int t,x;
		scanf("%d%d",&t,&x);
		for (;j<=K && r[j]<=t;d=r[j++],k=-k) calc(k*(r[j]-d));
		calc(k*(t-d));d=t;
		if (x<a) printf("%d\n",a+c);
			else if (x<=b) printf("%d\n",x+c);
				else printf("%d\n",b+c);
	}
}

Measured memory_bytes: 1536
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    int n;
    cin>>n;
    int c=0;
    int a[10000];
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n;i++){
        for(int j=a[i];j>0;j/=2){
            if(j%2==0)c++;
            else goto loop;
        }
        loop:;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <string>

using namespace std;

const int maxn = 1e5 + 10;

stack<bool> s;

string a;

int main() {
    int ans = 0;
    cin >> a;
    int n = a.size();
    for (int i = 0; i < n; i++) {
        if (s.empty()) s.push(a[i] - '0');
        else if (a[i] - '0' != s.top()) {
            s.pop();
            ans += 2;
        }
        else s.push(a[i] - '0');
    }
    cout << ans;
    return 0;
}

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

int main(){
    int n; cin >> n;
    vector<int> d(n); rep(i,n) cin >> d.at(i);

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

    cout << d.at((d.size()-1)/2+1) - d.at((d.size()-1)/2) << endl;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

const int maxn = 1000000 + 20;

bool prime[maxn];

bool isprime(int n)
{
    int t = sqrt(n);
    for(int i = 2; i <= t; i++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    return true;
}

int presum[maxn];

void init()
{
    memset(prime, true, sizeof(prime));
    prime[0] = false;
    prime[1] = false;
    for(int i = 2; i < maxn; i++)
    {
        if(!prime[i])
        {
            continue;
        }
        if(isprime(i))
        {
            for(int j = 2; j * i < maxn; j++)
            {
                prime[j * i] = false;
            }
        }
        else
        {
            prime[i] = false;
        }
    }
    for(int i = 1; i < maxn; i++)
    {
        presum[i] = presum[i-1] + (prime[i] && prime[(i+1)/2]);
    }
}

int getsum(int l, int r)
{
    return presum[r] - presum[l - 1];
}

int main()
{
    init();
    int T;
    cin >> T;
    while(T--)
    {
        int l, r;
        scanf("%d%d", &l, &r);
        cout << getsum(l, r) << endl;
    }
    return 0;
}


Measured memory_bytes: 5504
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  char c;
  cin >> c;

  if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

ll n;
vector<ll> v;
void fact(ll x)
{
    v.clear();
    for(ll i = 1; i*i<=x; i++) if(x%i == 0) v.pb(i);
    if(v[v.size()-1] * v[v.size()-1] == x)
    {
        int sz = v.size();
        for(int i = sz-2; i>=0; i--) v.pb(x / v[i]);
    }
    else
    {
        int sz = v.size();
        for(int i = sz-1; i>=0; i--) v.pb(x / v[i]);
    }
}
unordered_set<ll> m;


int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n;
    fact(n);
    for(int i = 1; i<v.size(); i++)
    {
        ll cur = n;
        while(cur % v[i] == 0) cur /= v[i];
        if(cur % v[i] == 1) m.insert(v[i]);
    }
    fact(n-1);
    for(int i = 1; i<v.size(); i++)
    {
        m.insert(v[i]);
    }
    cout << m.size() << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;
char heya[22][22];
char vis[22][22];
int H,W;

int solve(int x,int y){
  if(y<0||y>=W) return 0;
  if(x<0||x>=H) return 0;
  if(heya[x][y]!='.') return 0;
  if(vis[x][y]==1) return 0;
  vis[x][y]=1;
  int res=1;
  res+=solve(x+1,y);
  res+=solve(x-1,y);
  res+=solve(x,y+1);
  res+=solve(x,y-1);
  return res;
}

int main(void){
  int i,j;
  int sx,sy;
  while(cin>>W>>H,W||H){
    sx=sy=0;
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
        cin>>heya[i][j];
        vis[i][j]=0;
        if(heya[i][j]=='@'){
          sx=i;sy=j;
          heya[i][j]='.';
        }
      }
    }
    cout<<solve(sx,sy)<<endl;
  }
  return 0;
}

Measured memory_bytes: 3040
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

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



	int H, W;
	cin >> H >> W;

	string S[51];
	int A[52][52] = {};
	rep1(i, H) {
		cin >> S[i];
		rep1(ii, W) {
			if (S[i][ii - 1] == '#') A[i][ii] = 1;
		}
	}

	rep1(i, H) {
		rep1(ii, W) {
			if (S[i][ii - 1] == '.') {
				int kazu = A[i + 1][ii] + A[i - 1][ii];
				kazu += A[i + 1][ii - 1] + A[i - 1][ii - 1];
				kazu += A[i + 1][ii + 1] + A[i - 1][ii + 1];
				kazu += A[i][ii + 1] + A[i][ii - 1];
				S[i][ii - 1] = to_string(kazu)[0];
			}
		}
	}
	rep1(i, H) co(S[i]);

	Would you please return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#define rep(i,j,k) for (i=j;i<=k;i++)
using namespace std;
const int N=2e5+5;
int n,m,i,j,x,y,wh,ans,a[N],h[N],cnt[N];
int main()
{
//	freopen("spell.in","r",stdin);
//	freopen("spell.out","w",stdout);
	scanf("%d%d",&n,&m);
	rep(i,1,n) {
		scanf("%d",&a[i]);
		h[a[i]]++;
	}
	rep(i,1,n)
		rep(j,0,h[i]-1) if (i-j>0) cnt[i-j]++;
	rep(i,1,n)
		if (cnt[i]) ans++;
	rep(i,1,m)
	{
		scanf("%d%d",&x,&y);
		wh=a[x]-h[a[x]]+1; if (wh>0) {cnt[wh]--; if (!cnt[wh]) ans--; } h[a[x]]--;
		h[y]++; wh=y-h[y]+1; if (wh>0) { cnt[wh]++; if (cnt[wh]==1) ans++; }
		a[x]=y;
		printf("%d\n",n-ans); 
	}
	return 0;
}

Measured memory_bytes: 3712
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let a :i32 = read(); //500
    let b :i32 = read(); //100
    let c :i32 = read(); //50
    let x :i32 = read(); //合計
    let mut ans = 0;
    for i in 0..a + 1{
        for j in 0..b + 1 {
            for k in 0..c + 1  {
                if i * 500 + j * 100 + k * 50 == x {
                    ans += 1;
                }
            }
        }
    }
    println!("{}",ans);
}

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

int N, M;
map<string, int> mp;

main()
{
    cin >> N;
    string input;
    for (int i = 0; i < N; i++) {
        cin >> input;
        mp[input]++;
    }
    cin >> M;
    for (int i = 0; i < M; i++) {
        cin >> input;
        mp[input]--;
    }
    
    int max = 0;
    map<string, int>::iterator it;
    for (it = mp.begin(); it != mp.end(); it++) {
        if (max < it->second) {
            max = it->second;
        }
    }
    cout << max << endl;
}

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

int N,M,C;
int* B;
int A(0);
int ans(0);

int main(){
  cin >> N >> M >> C;
  B = new int(M);
  for(int i = 0;i<M;++i){
   cin >> B[i];
  }
  for(int i = 0;i<N;++i){
    for(int j = 0;j<M;++j){
      int tmp;
      cin >> tmp;
      A += tmp * B[j];
    }
    if((A + C) > 0)++ans;
    A = 0;
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

int main()
{
    int n,x;
    int a[1010];
    cin>>n>>x;
    int s1=0,s2=0,s=0;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        s1+=a[i];
    }
    sort(a,a+n);
    s2=x-s1;
    s=s2/a[0]+n;


    cout <<s<< endl;
    return 0;
}


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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    string s_dash, t; cin >> s_dash >> t;
    vs s;
    for(int i = 0; i < SIZE(s_dash)-SIZE(t)+1; i++) {
        string str;
        rep(i,s_dash.size()) str.push_back((s_dash[i]!='?' ? s_dash[i] : 'a'));
        bool can = true;
        for(int j = 0; j < t.size(); j++){
            if(s_dash[i+j]!='?' && s_dash[i+j]!=t[j]) can = false;
            else str[i+j] = t[j];
        }
        if(can) s.push_back(str);
    }
    sort(all(s));
    cout << (s.size()!=0 ? s[0] : "UNRESTORABLE") << '\n';
}


Measured memory_bytes: 256
import java.util.*;
    public class Main{//Main
          public static void main(String[] args){
             Scanner scanner = new Scanner(System.in);
              int A = scanner.nextInt();
              int B = scanner.nextInt();
              int C = scanner.nextInt();
              if(A==B){
                             if(B==C) System.out.println("No");
                             else System.out.println("Yes");
               }
              else if(A==C){
                             if(B==C) System.out.println("No");
                             else System.out.println("Yes");
               }
              else if(B==C){
                             if(A==C) System.out.println("No");
                             else System.out.println("Yes");
               }
              else System.out.println("No");
}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,i,N,K,t;
  cin>>N>>K;
  t=1;
  for(i=0; i<N; i++){
    a=2*t;
    b=t+K;
    if(a>b){
      t=b;
    }
    else{
      t=a;
    }
  }
  cout<<t<<endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;
constexpr int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

int main(){
    ios::sync_with_stdio(false); cin.tie(nullptr);
    //cout << fixed << setprecision(6);
    int x; cin >> x;

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

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define ll  long long int
#define pb push_back
#define ff first
#define ss second
#define vi vector<int>
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i :c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
#define er(x) cout << x << " "
#define err(x,y) cout << x << " "<<y
const int MOD = 1e9+7;
const int N = 3500;
using namespace std;
clock_t time_p=clock();
void dem()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int main()
{
    fast_io();
    int n ;
    cin >> n ;
    vector<int>vec ( n );
    for ( int &x: vec )cin >> x ;
    sort(all(vec));

    int x = vec[ n / 2 - 1 ] ;
    auto lb = lower_bound(all(vec),  x ) - vec.begin();
    while ( lb+1 < n &  vec[lb] == vec[lb+1] )++lb ;
    if ( lb+1 == n - lb -1  )
        cout << vec[lb+1] - vec[lb];
    else
        cout << "0";

 // 1 4 4 6 7 9
 // 1 4 4 5 5 9 14

    return 0 ;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,l,r) for(ll i=(l);i<(r);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
int cmp(const void *a, const void *b);
//your code here!

int main(void){
    char mm;
    ll A, B;
    scanf("%lld %c %lld", &A, &mm, &B);
    if(mm=='+')printf("%lld\n", A+B);
    else printf("%lld\n", A-B);
    return 0;
}

int cmp(const void *a, const void *b){
    ll A=*(ll *)a, B=*(ll *)b;
    if(A==B)return 0;
    else return A>B ? 1:-1;//昇順ソート
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())

using namespace std;
typedef long long  ll;

int main(){
    ios::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);
    int n;
    cin >> n;
    vector<int> v(n) , c(n);
    for(int &x : v)
        cin >> x;
    for(int &x : c)
        cin >> x;

    int ans = -inf;
    for(int i = 0 ; i < (1 << n) ; ++i){
        int msk = i;
        int X = 0 , Y = 0;
        for(int j = 0 ; j < n ; ++j){
            if(msk & (1 << j)){
                X += v[j];
                Y += c[j];
            }
        }
        ans = max(ans , X - Y);
    }

    cout << ans << "\n";
 }


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

namespace AtCoder.Abc
{
    class Q082A
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数配列の入力
            var inputIntArray = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();

            int a = inputIntArray[0];
            int b = inputIntArray[1];

            Console.WriteLine(Math.Ceiling((decimal)(a + b)/2));

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

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

int cnt;

void dfs(int n, int k, int s) {
    if (k == 0 && s == 0) {
        cnt++;
        return;
    }
    if (n <= 0 || k <= 0 || s <= 0) {
        return;
    }

    dfs(n - 1, k - 1, s - n);
    dfs(n - 1, k, s);
}

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

    int n, k, s;
    while (cin >> n >> k >> s, n) {
        cnt = 0;
        dfs(n, k, s);
        cout << cnt << endl;
    }

}

Measured memory_bytes: 2992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define vi vector<int>
#define vvi vector<vector<int>>
#define pii pair<int,int>
#define vs vector<string>
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define ld long double
#define mod 10000000007
#define PI 3.141592653589793238
#define phi 1.638
#define eps 1e-9
using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main() 
{ 
    fastio
    int k, n;
    cin>>k>>n;

    vector<int> vec(n);
    for(auto& it : vec) cin>>it;

    int ans = 1e9;
    for(int i = 1; i<n-1; ++i)
    {
        int a1 = abs(k+vec[i-1]-vec[i]);
        int a2 = abs(k-vec[i+1]+(vec[i]));
        ans = min({ans, a1, a2});
    }

    ans = min(ans, vec[n-1]-vec[0]);
    ans = min(ans, vec[n-1]+vec[n-2]);

    cout<<ans<<endl;
} 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<ctype.h>
# define pb push_back
#define fst first
#define sec second
#define For(i,a,b) for(int i=a;i<b;i++)
#define ll long long int
#define ull unsigned long long int
#define mod 1000000007
#define fo(i,n) for(ll i=0;i<n;i++)
#define endl "\n"
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define fo1(i,n) for(ll i=1;i<=n;i++)
#define boolsize 1000001
#define pi pair<ll,ll>
#define vi vector<ll>
#define vii vector<pi>
using namespace std;
template<typename T>
void showvector(vector <T> v)
{
    for(T x:v)
        cout<<x<<" ";
    cout<<endl;

}
template<typename T>
void showvector1(vector <T> v)
{
    ll n=v.size();
    fo1(i,n-1)
        cout<<v[i]<<endl;

}
template<typename T>
void showset(set <T> s)
{
    for(T x: s)
        cout<<x<<" ";
    cout<<endl;
}
template<class T>
void showvectorpair(vector<T> v)
{
    for(auto it=v.begin();it!=v.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T,typename P>
void showmap(map <T,P> m)
{
    for(auto it=m.begin();it!=m.end();it++)
        cout<<it->first<<" "<<it->second<<endl;
    cout<<endl;
}
template<typename T>
bool comp(T a,T b)
{
    return (a>b);
}
template<class T>
bool comppair(T a,T b)
{
    if(a.first==b.first)
        return(a.second>b.second);
    return (a.first>b.first);
}
bool sameparity(ll a,ll b)
{
    return (a%2==b%2);
}
bool difparity(ll a,ll b)
{
    return !(a%2==b%2);
}
bool isprime(ll x)
{   if(x<=1)
     return false;
    for(ll i=2;i<=sqrt(x);i++)
    {
        if(x%i==0)
            return false;
    }
    return true;
}
bool iseven(ll x)
{
    return !(x%2);
}
bool isodd(ll x)
{
    return (x%2);
}
/// check for test case before submitting
void vfun()
{
    ll n,k;
    cin>>n;
    vector <ll> v(n);
    fo(i,n)
    cin>>v[i];

}
void check(string s,ll pos,ll sum,vector <char > v)
{

    if(pos==4 && sum==7)
    {
        v.pb('=');
        if(v[0]=='-')
            cout<<v[0];
        fo(i,4)
        {
            cout<<s[i]<<v[i+1];
        }
        cout<<"7";
        exit(0);
    }
    else if(pos==4)
        return ;
    v.pb('+');
    check(s,pos+1,sum+(s[pos]-'0'),v);
    v.pop_back();
    v.pb('-');
    check(s,pos+1,sum-(s[pos]-'0'),v);

}
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("inputh.txt", "r", stdin);
    freopen("outputh.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0); ///cant use scanf, printf
    cin.tie(0);cout.tie(0); /// no longer auto flush cout before each cin, remove for interactive
    //cout << fixed << setprecision(11); /// no scientific output
    ll test=1;
   // cin>>test;
    while(test--)
    {

            string s;
            cin>>s;
            vector <char> v;
            check(s,0,0,v);
//         if(vfun())
//            cout<<"YES\n";
//         else
//            cout<<"NO\n";
    }
}
///before sub
/// check for value of zero and single input in array
///loop vars,1LL in mult, equal, one, bounds, int v ll, endl, finish taking inputs
/// check whether test cases are given or not





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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  vector<vector<int>> a(3, vector<int>(3));
  for (auto&& v : a) {
    for (auto&& e : v) {
      cin >> e;
    }
  }
  vector<vector<int>> c(3, vector<int>(3));
  int n;
  cin >> n;
  while (n--) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; ++i) {
      for (int j = 0; j < 3; ++j) {
        if (a[i][j] == b) {
          c[i][j] = 1;
        }
      }
    }
  }
  for (int i = 0; i < 3; ++i) {
    if (c[i][0] + c[i][1] + c[i][2] == 3) {
      cout << "Yes\n";
      exit(0);
    }
  }
  for (int j = 0; j < 3; ++j) {
    if (c[0][j] + c[1][j] + c[2][j] == 3) {
      cout << "Yes\n";
      exit(0);
    }
  }
  if (max(c[0][0] + c[1][1] + c[2][2], c[0][2] + c[1][1] + c[2][0]) == 3) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}


Measured memory_bytes: 256
n=int(input())
t=[int(j) for j in input().split()]
a=[int(j) for j in input().split()]
tmp=0
l=[]
for i in t:
    if tmp<i:
        l.append(-i)
        tmp=i
    else:
        l.append(i)
tmp=0
ans=1
mod=10**9+7
for i in range(n)[::-1]:
    if tmp<a[i]:
        tmp=a[i]
        if l[i]<a[i]:
            if l[i]>0 or -l[i]!=a[i]:
                print(0)
                exit()
    else:
        if l[i]>0:
            ans=(ans*min(a[i],l[i]))%mod
print(ans)

Measured memory_bytes: 19648
import java.util.Scanner;

public class Main {

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

		int[] alpha = new int[27];//0-26
		for (int syoki = 0; syoki < 27; syoki++) {
			alpha[syoki] = 0;
		}

		/*文字と数値一覧表
		 * A===10===a
		 * B===11===b
		 * !
		 * !
		 * !
		 * Z===35==z
		 * alpha[0]=a--->Character.getNumericValue('A')-10;
		 * alpha[1]=b--->Character.getNumericValue('B')-10;
		 */

		//個数のカウント
		for (; sc.hasNextLine();) {
			int sum = 0;
			char[] swap = sc.nextLine().toCharArray();//char型の配列に格納する

			for (int i = 0; i < swap.length; i++) {
				if (swap[i] != ' ') {
					int a = Character.getNumericValue(swap[i]);
					//  System.out.println("aは"+a);
					//  System.out.println("a:" + a);
					if (a >= 10 && a < 37) {
						alpha[a - 10]++;
					} else {
						//break;
					}
				}
			}
		}
		//A~Zの個数を出力
		char L00 = 'a';
		for (int L01 = 0, i = 0; L01 <= ('z' - 'a'); L01++, i++) {
			System.out.print(L00++);
			System.out.println(" : " + alpha[i]);
		}

	}

}



Measured memory_bytes: 25844
import heapq
v = []
n = int(input())
v_0 = list(map(int,input().split()))
for u in v_0:
    heapq.heappush(v,u)
max = heapq.heappop(v)*((1/2)**(n-1))
while v:
    max += heapq.heappop(v)*((1/2)**(n-1))
    n -= 1
print(max)


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

#define pb push_back
#define ff first
#define ss second

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

const int MAXN = 1000 + 17, inf = 1e9 + 17;

int n, m, dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}, d[MAXN][MAXN], ans;
char a[MAXN][MAXN];
queue<pii> q;
bool mark[MAXN][MAXN];

bool isval(int i, int j) { return !mark[i][j] && 1 <= i && i <= n && 1 <= j && j <= m; }

void bfs() {
	while (q.size()) {
		pii u = q.front();
		q.pop();
		for (auto i : {0, 1, 2, 3})
			if (isval(u.ff + dx[i], u.ss + dy[i])) {
				mark[u.ff + dx[i]][u.ss + dy[i]] = true;
				d[u.ff + dx[i]][u.ss + dy[i]] = d[u.ff][u.ss] + 1;
				q.push({u.ff + dx[i], u.ss + dy[i]});
			}
	}
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	for (int i = 0; i < MAXN; i++)
		for (int j = 0; j < MAXN; j++)
			d[i][j] = inf;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++) {
			cin >> a[i][j];
			if (a[i][j] == '#')
				q.push({i, j}), mark[i][j] = true, d[i][j] = 0;
		}
	bfs();
	for (int i = 1; i <= n; i++)
		for (int j = 1; j <= m; j++)
			ans = max(ans, d[i][j]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 14480
import java.util.Scanner

import scala.io.StdIn._

object Main extends App {

  val Array(n,m) = readLine().split(" ").map(_.toInt)
  val A = readLine().split(" ").map(_.toInt)

  def solve() = {
    Math.max(n-A.sum, -1)
  }


  println(solve())

}



Measured memory_bytes: 55352
#include<stdio.h>

int binarySearch(int A[],int n,int key)
{
	int left=0;
	int right=n;
	int mid=0;
	while(left<right)
	{
		mid = (left+right)/2;
		if(A[mid]==key) return 1;
		else if(key < A[mid]) right = mid;
		else left=mid+1;
	}
	return 0;
}

int main(void)
{
	int n=0,q=0,i=0,key=0,count=0;
	scanf("%d", &n);
	int S[n];
	for(i=0; i<n; i++)
	{
		scanf("%d", &S[i]);
	}
	scanf("%d", &q);
	int T[q];
	for(i=0; i<q; i++){
		scanf("%d", &key);
		count = count + binarySearch(S, n, key);
	}
	printf("%d\n",count);
	return 0;
}




Measured memory_bytes: 2132
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}

int main(){
    vector<int> a(5);
    rep(i,5) cin >> a[i];
    int k; cin >> k;
    if(a[4]-a[0]>k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
a = [int(i) for i in input().split()]

ng, ok = -1, sum(a)

while ok - ng > 1 :
    m = (ok + ng) // 2
    
    for i in range(-N, 1) :
        if m + i <= ng :
            continue
            
        c = 0
        for j in range(N) :
            c += (a[j] + m + i - N) // (N + 1) + 1
        if c <= m + i :
            ok = m + i
            break
    else :
        ng = m
        
print(ok)

Measured memory_bytes: 39920
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll a[100];

int main()
{
    int n,a,b,c,d;
    cin>>n;
    a=(n/1000)%10;
    b=(n/100)%10;
    c=(n/10)%10;
    d=n%10;
    if(a+b+c+d==7)//1
        cout<<a<<"+"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else
    if(a+b+c-d==7)//2
        cout<<a<<"+"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else
    if(a+b-c+d==7)//3
        cout<<a<<"+"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else
    if(a-b+c+d==7)//4
        cout<<a<<"-"<<b<<"+"<<c<<"+"<<d<<"=7"<<endl;
    else
    if(a+b-c-d==7)//5
        cout<<a<<"+"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    else
    if(a-b-c+d==7)//6
        cout<<a<<"-"<<b<<"-"<<c<<"+"<<d<<"=7"<<endl;
    else
    if(a-b+c-d==7)//7
        cout<<a<<"-"<<b<<"+"<<c<<"-"<<d<<"=7"<<endl;
    else
    if(a-b-c-d==7)//8
        cout<<a<<"-"<<b<<"-"<<c<<"-"<<d<<"=7"<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()

const ll mod = 1000000000 + 7;
const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

int x, a, b;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> x >> a >> b;
    if (abs(x - a) < abs(x - b)) {
        cout << 'A' << endl;
    }
    else cout << 'B' << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    long long ans = 1;

    for (int i = 1; i <= N; ++i){
        ans = ans * i % (long long) (1e9 + 7);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long 
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define Time (double)clock()/CLOCKS_PER_SEC
const int N = 1e6 + 7, MOD = 1000 * 1000 * 1000 + 7;
int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }
int n, t[N], f[N];
int C(int n, int k) { 
    if (n < k) return 0;
    return dv(f[n], mod(f[k] * f[n - k])); 
}
int get(int k) { return mod(C(k - 1, n - 1 - k) * mod(f[k] * f[n - 1 - k])); }   
signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    f[0] = 1;
    for (int i = 1; i < N; ++i) f[i] = mod(f[i - 1] * i);
    cin >> n;
    if (n <= 2) {
        cout << "1\n";
        exit(0);
    }   
    int p = 0, ans = 0;
    for (int i = 1; i < n; ++i) {
        t[i] = mod(get(i) - p);
        p = mod(p + t[i]);
        ans = mod(ans + t[i] * i);
    }   
    cout << ans << '\n';
}

Measured memory_bytes: 15872
import java.io.*;

class Main{
	public static void main(String []args)throws IOException{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      	String S = br.readLine();
      	String T = br.readLine();
      	if(S.equals(T.substring(0, T.length() - 1)))
           System.out.println("Yes");
       	else
           System.out.println("No");
    }
}

Measured memory_bytes: 25360
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(a) a.begin(),a.end()
#define ld long double
#define ub upper_bound
#define lb lower_bound
#define pii pair<int,int>
using namespace std;
signed main(){
    fast;
    int x;
    cin>>x;
    int ans = (int)1000*(x/(int)500);
    x-=((x/(int)500)*(int)500);
    ans+=(int)5*(x/(int)5);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int res = Math.max(0, b + c - a);

        System.out.println(res);


    }
}


Measured memory_bytes: 23124
import java.util.Scanner;

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

        String s = sc.next();
        String t = sc.next();

        if (t.matches(s + ".")) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}

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

int main() {
    string s; cin >> s;
    vector<string> ans;
    string c = "abcdefghijklmnopqrstuvwxyz";
    set<char> se;
    rep(i,26) se.insert(c[i]);
    rep(i,s.size()) se.erase(s[i]);
    if (s.size() <= 25) ans.push_back(s + *se.begin());
    string ss = s;
    if (next_permutation(ss.begin(), ss.end())) {
        ans.push_back(ss);
    }
    for (int i=s.size()-1; i>=0; i--) {
        se.insert(s[i]);
        auto it = se.upper_bound(s[i]);
        if (it != se.end()) {
            ans.push_back(s.substr(0,i) + *it);
        }
    }
    sort(ans.begin(), ans.end());
    //rep(i,ans.size()) cout << ans[i] << endl;
    if (ans.size() == 0) cout << -1 << endl;
    else cout << ans.front() << endl;
}

Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

    private static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(final String[] args) throws IOException {
        FastReader in = new FastReader();
        PrintWriter out = new PrintWriter(System.out, true);

        int n = in.nextInt();
        int k = in.nextInt();
        int[] p = new int[n];
        String[] tokens = in.nextLine().split(" ");
        for (int i = 0; i < n; i++) {
            p[i] = Integer.parseInt(tokens[i]);
        }

        Arrays.sort(p);

        int price = 0;
        for (int i = 0; i < k; i++) {
            price += p[i];
        }

        out.println(price);
    }
}


Measured memory_bytes: 33124
import math
a, b, h, m = map(int, input().split())
h_v = (h + m/60)* 30
m_v = m * 6
k = abs(h_v-m_v)
if k > 180:
	k = 360 - k
r = 0
if k == 0:
	r = a - b
else:
	radian = math.radians(k)
	r2 = a**2 + b**2 - (2 * a * b * math.cos(radian))
	r = r2**0.5
print(r)

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

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

  int ans = 0;
  if (s == "SSS") {
    ans = 0;
  } else if (s == "RSS") {
    ans = 1;
  } else if (s == "SRS") {
    ans = 1;
  } else if (s == "RRS") {
    ans = 2;
  } else if (s == "SSR") {
    ans = 1;
  } else if (s == "RSR") {
    ans = 1;
  } else if (s == "SRR") {
    ans = 2;
  } else if (s == "RRR") {
    ans = 3;
  }

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


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
using namespace std;
int main()
{
	map<char, int> m[100];
	int n, ans=0,i;
	string a, b, c;
	cin >> n;
	cin >> a >> b >> c;
	for (int i = 0; i < n; i++) {
		m[i][a[i]]++;
		m[i][b[i]]++;
		m[i][c[i]]++;
		int aa = 0;
		for (pair<char,int> c : m[i]) {
			if (aa < c.second)
				aa = c.second;
		}
		ans += 3 - aa;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
    ll n;
    cin >> n;
    vector<ll> s(n);
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        if (i == 0)
            s[i] = a;
        else
            s[i] = s[i - 1] + a;
    }
    ll ld = 0, rd = s[n - 1];
    ll d = rd - ld;
    for (int i = 0; i < n; i++) {
        ld = s[i];
        rd = s[n - 1] - s[i];
        d = min(d, abs(rd - ld));
    }
    cout << d << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll H, W, A, B;
  cin >> H >> W >> A >> B;
  string S1 = "";
  string S2 = "";
  for(int i = 0; i < A; i++){
    S1 += '1';
    S2 += '0';
  }
  for(int i = 0; i < W-A; i++){
    S1 += '0';
    S2 += '1';
  }
  for(int i = 0; i < H; i++){
    if(i < B) cout << S1 << endl;
    else cout << S2 << endl;
  }
}

Measured memory_bytes: 1280
n = int(input())
s = input()

l = 0
r = 1
ans = 0
# 順番に見ていく

while r < n:
  if s[l:r] in s[r:]:
    ans = max(ans, r - l)
    r += 1
  else:
    l += 1
  if l == r:
    l += 1
    r += 2
print(ans)


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

#define all(a) a.begin(), a.end()
#define ff first
#define ss second
#define pb push_back

using ll = long long;
using pii = pair<int, int>;

template<typename T> using V = vector<T>;

const int MAX_N = 1e5 + 5;
vector<int> adj[3 * MAX_N];
bool visit[3 * MAX_N];
int dist[3 * MAX_N];

inline void make_edge(int u, int v) {
	adj[u].pb(v);
}

int main() {
	ios::sync_with_stdio(false);cin.tie(nullptr);
	int N, M; cin >> N >> M;
	for (int i = 0; i < M; ++i) {
		int u, v; cin >> u >> v;
		make_edge(3 * u, 3 * v + 1);
		make_edge(3 * u + 1, 3 * v + 2);
		make_edge(3 * u + 2, 3 * v);
	}
	int S, T; cin >> S >> T;
	S *= 3; T *= 3;
	queue<int> Q;
	dist[S] = 0;
	Q.push(S);
	while(!Q.empty()) {
		int cur = Q.front();
		Q.pop();
		for (auto nxt : adj[cur]) {
			if(!visit[nxt]) {
				visit[nxt] = true;
				Q.push(nxt);
				dist[nxt] = dist[cur] + 1;
			}
		}
	}
	cout << (visit[T] ? (dist[T] / 3) : -1) << '\n';
	return 0;
}

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

using namespace std;

using ll = long long;

#define ALL(A) A.begin(),A.end()

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

    if(N%10==3) cout << "bon" << endl;
    else if(N%10==0 || N%10==1 || N%10==6 || N%10==8) cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}

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

using namespace std;
 
#define ll long long
#define endl '\n'
#define mod 1000000007


void solve(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int rr = 0,w = 0;
	int cnt = 0;
	for(int i = 0;i<n;i++){
		if(s[i] == 'R'){
			rr ++;
		}else{
			w++;
		}
	}
	int l = 0;
	int r = n-1;
	while(l < r){
		if(s[l] == 'W' && s[r] == 'R'){
			cnt++;
			swap(s[l],s[r]);
			l++;
			r--;
		}else if(s[l] == 'W' && s[r] == 'W'){
			r--;
		}else if(s[l] == 'R' && s[r] == 'W'){
			l++;
			r--;
		}else{
			l++;
		}
	}
	cout<<min(cnt,min(rr,w));
}
 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	while(t--)
    	solve();
	return 0;
}


Measured memory_bytes: 3796
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please

int A[52][52];
int B[52][52];
vector<pair<int,int>> que;

void keisan(int d) {
	vector<pair<int, int>> que2;
	for (pair<int,int> P : que) {
		int x = P.first;
		int y = P.second;
		if (B[x][y] == 0 && A[x][y]) {
			B[x][y] = d;
			que2.push_back(make_pair(x - 1, y));
			que2.push_back(make_pair(x + 1, y));
			que2.push_back(make_pair(x, y - 1));
			que2.push_back(make_pair(x, y + 1));
		}
	}
	que.clear();
	for (pair<int, int> P : que2) que.push_back(P);
}

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

	int H, W;
	cin >> H >> W;
	int white = 0;
	rep1(i, H) {
		string S;
		cin >> S;
		rep1(ii, W) {
			if (S[ii - 1] == '.') {
				A[i][ii] = 1;
				white++;
			}
		}
	}

	que.push_back(make_pair(1, 1));
	rep1(i, 2500) keisan(i);
	
	if (B[H][W] == 0) co(-1);
	else co(white - B[H][W]);
	Would you please return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<set>
#include<queue>
#include<algorithm>
#include<stack>
#include<cstdlib>
#include<cctype>
using namespace std;
#define ll long long
typedef pair<int,int>P;
const int len=2e5+5;
int arr[len];
int num[len];
int main()
{
	string str;
	int a;
	cin>>str>>a;
	for(int i=0;i<str.size();++i)
		if(i%a==0)cout<<str[i];
	puts("");
}

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

#include <bits/stdc++.h>

using namespace std;

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

void d_err() {
    cerr << endl;
}

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

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

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

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

ll ans = 0;
vector<ll> a(55), b(55), c(55), d(55);

int N, M, Q;

void rec(vector<int> &cur) {
    if (cur.size() == N) {
        ll tmp = 0;
        REP(i, Q) {
            if (cur[b[i]] - cur[a[i]] == c[i]) tmp += d[i];
        }

        ans = max(ans, tmp);
    } else {
        int st = 1;
        if (!cur.empty()) st = cur.back();
        for (int i = st; i <= M; ++i) {
            cur.pb(i);
            rec(cur);
            cur.pop_back();
        }
    }
}

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

    cin >> N >> M >> Q;

    REP(i, Q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }

    vector<int> v;
    rec(v);

    cout << ans << endl;


}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <numeric>
 
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

 
void inputArray(int * p, int a){
    rep(i, a){
        cin >> p[i];
    }
};
 
int main(int argc, const char * argv[]) {
 
    // source code
    // char s[4];
    int A, P;
    cin >> A >> P;
 
    P += A * 3;
 
    cout << P / 2 <<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;

int main() {
    int64_t H, W; cin >> H >> W;
    if(H == 1 || W == 1) {
        cout << 1 << '\n';
        return 0;
    }
    int64_t h = (H + 1) / 2;
    int64_t w = (W + 1) / 2;
    int64_t ans = h * w;
    h = H - h, w = W - w;
    ans += h * w;
    cout << ans << '\n';
    return 0;
}


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

#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define ALL( a )        (a).begin(), (a).end()             

int main() {
	int n; cin >> n;
	int dp[50];
	dp[0] = dp[1] = 1;

	FOR( i, 2, n + 1 ) dp[i] = dp[i - 1] + dp[i - 2];

	cout << dp[n] << endl;
}


Measured memory_bytes: 3120
#include<iostream>
using namespace std;
int main()
{
  int N,X,T;
  cin>>N;
  cin>>X;
  cin>>T;

  int sum =0;
    int time= 0;
  while(N > sum)
  {
    sum += X;
	time+= T;
  }
  cout<<time<<endl;
}


Measured memory_bytes: 3588
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(void)
{
  int n,tmp[200002];
  for(int i=0;i<200001;i++){
    tmp[i]=0;
    //tmp1[i]=0;
  }
  scanf("%d",&n);
  int a[n];
  long long ans[n],total=0;
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
    tmp[a[i]]++;
    //if(tmp[a[i]]>=2) tmp1[i]+=tmp[i]-1;
    total+=tmp[a[i]]-1;
  }
  for(int i=0;i<n;i++){
    ans[i]=total-(tmp[a[i]]-1);
    printf("%lld\n",ans[i]);
  }
  return 0;
}

Measured memory_bytes: 5632
#include <iostream>
using namespace std;
int main(void){
    int x, y;
    
    while(true){
        cin >> x;
        cin >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x < y){
            cout << x << " " << y << endl;
        }
        else{
            cout << y << " " << x << endl;
        }
    }
}



Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main (){
  string s,t;
  cin >> s>>t;
  
  vector<int> start(26,-1);
  vector<int> goal(26,-1);
  
  for(int i=0;i<s.size();i++){
   int a = s[i]-'a';
    int b = t[i] -'a';
  
  
     if(start[a] != -1 || goal[b] != -1){
       if(start[a] != b || goal[b] != a){
         cout << "No" << endl;
         
         return 0;
       }
     }
       start[a] = b;
       goal[b] =a;
  }
  
  cout << "Yes" << endl;
}
     
  
  
  


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

int main(){
	int n; cin >> n;
	vector<int> x(n),y(n);
	for(int i=0;i<n;i++) {
		cin >> x[i];
		y[i]=x[i];
	}
	sort(y.begin(),y.end());
	for(int i=0;i<n;i++) {
		if(x[i]<=y[n/2-1]) cout << y[n/2];
		else cout << y[n/2-1];
		cout << endl;
	}
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  //A＋B＞C＋Dの時左に傾く
  //A＋B＝C＋Dの時釣り合う
  //A＋B＜C＋Dの時右に傾く
  if (A + B > C + D) {
    cout << "Left" << endl;
  } else if (A + B == C + D) {
    cout << "Balanced" << endl;
  } else {
    cout << "Right" << endl;
  }
}


Measured memory_bytes: 256