akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <queue>
#include <list>
#include <limits>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
const int MOD = 1000000007;

    class Pairs{
        public : ll a;
        ll b;
        void setpairs(ll _a, ll _b){
            a = _a;
            b = _b;
        }
    };

    bool cmp(const Pairs &A, const Pairs &B){
        return (A.a < B.a);
    }


int main(){    
    int N,X,sum = 0,num;
    int sums[100];
    cin >> N >> X;
    for(int i=0;i<N;i++){
        cin >> num;
        sum += num;
        sums[i] = sum; 
    }
    int count = 1;
    for(int i=0;i<N;i++){
        if(X >= sums[i]) count++;
    }
    cout << count;
}

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

using namespace std;

int main() {
	int N;
	string A, B;
	string G = "";
	cin >> N;
	cin >> A >> B;

	for(int i = 0; i < N; i++) {
		G += A.at(i);
		G += B.at(i);
	}
	cout << G << endl;

}

Measured memory_bytes: 256
<?php
/*
    Problem URL : http://agc013.contest.atcoder.jp/tasks/agc013_a

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */


// define('DEBUG', true);
define('DEBUG', false);

ini_set('error_reporting', E_ALL & ~E_NOTICE);

$arr = array();

fscanf(STDIN, "%d %d", $N, $M);
for ($i = 0; $i < $M; $i++) {
    fscanf(STDIN, "%d %d", $a, $b);
    // echo $a . " " . $b . PHP_EOL;
    $arr[$a]++;
    $arr[$b]++;
}

for ($i = 1; $i <= $N; $i++) {
    echo $arr[$i] ?: 0;
    echo PHP_EOL;
}


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

ll n, x, a[100005], ans;

int main() {
    scanf("%lld%lld", &n, &x);
    for (int i = 1; i <= n; i++) scanf("%lld", &a[i]);
    for (int i = 1; i < n; i++) {
        if (a[i] + a[i + 1] > x) {
            int u = a[i] + a[i + 1] - x;
            if (a[i + 1] - u >= 0) a[i + 1] -= u;
            else a[i] -= (u - a[i + 1]), a[i + 1] = 0;
            ans += u;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 1024
A,B,C = map(int,input().split())
if A == 5 and B == 5 and C == 7:
  print('YES')
elif (A == 5 and B == 7 and C == 5):
  print('YES')
elif (A == 7 and B == 5 and C == 5):
  print('YES')
else:print('NO')

Measured memory_bytes: 3060
s=raw_input()
g=p=0
#n,k=map(int,raw_input().split())
#l=map(int,raw_input().split())
ans=chk=0
for i in s:
    if i=='g' and g>p:
        ans+=1
        p+=1
    elif i=='g':
        g+=1
    if i=='p' and g>p:
        p+=1
    elif i=='p':
        g+=1
        ans-=1
print ans

Measured memory_bytes: 2692
#include <iostream>

using namespace std;

int main(){
    string s;
    cin >> s;
    int sum=0;
    for (int i = 0; i < 3; ++i) {
        if(s[i] == 'A') sum++;
    }

    cout << ((sum == 3 || sum==0) ? "No" : "Yes") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main(){
  double t,x;
  cin >> t>>x;
  printf("%.10f\n",t/x);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io std :: ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define M 1000000007
#define int long long
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define nl "\n"
#define yy "YES\n"
#define nn "NO\n"
using namespace std;
signed main()
{
    io;
    int n,m;
    cin>>n>>m;
    cout<<(n*(n-1)/2)+(m*(m-1)/2);
}



Measured memory_bytes: 256
s = input()
ans = 0
l = 0
r = len(s)-1
while l<r:
    if s[l]==s[r]:
        l += 1
        r -= 1
    elif s[l]=='x':
        ans += 1
        l += 1
    elif s[r]=='x':
        ans += 1
        r -= 1
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 3316
//#include <ext/pb_ds/assoc_container.hpp> 
 //#include <ext/pb_ds/tree_policy.hpp>
//#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;

typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e9+7;
ll mod1=1e9+5;
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power(((((a)%mod)*((a)%mod))%mod),b/2)%mod;
    else return (((a)%mod)*(power(((((a)%mod)*((a)%mod))%mod),b/2)%mod))%mod;
}
inline ll inverse(ll a,ll md) {
  a %= md;
  if (a < 0) a += md;
  ll b = md, u = 0, v = 1;
  while (a) {
    ll t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  assert(b == 1);
  if (u < 0) u += md;
  return u;
}
  
  
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
const int ce=1e9+7;
ll fast_mod(ll input)
{
    return input < ce ? input : input%ce;
}
int fre[100001];
int co[11];
int n,k;
int f[100001];
int maxi;
int dp[501][5001];
int solve(int i,int rem)
{
	if(rem==0)
		return 0;
	if(i==maxi)
		return 0;
	int &res=dp[i][rem];
	if(res!=-1)
		return res;
	res=0;
	for(int j=1;j<=min(rem,k);j++)
	{
		res=max(res,co[j]+solve(i+1,rem-j));
	}
	return res;
}
int32_t main()
{
    IOS
      
    
    int n,k;
    cin>>n>>k;
    int a[n+1];
    for(int i=1;i<=n;i++)
    	cin>>a[i];
    sort(a+1,a+n+1);
    int co=0;
    for(int i=1;i<=k;i++)
    	co+=a[i];
    cout<<co;
}       

Measured memory_bytes: 3604
import numpy as np
N = int(input())
a = np.array([list(map(int, input().split()))])
b = np.array([list(map(int, input().split()))])

diff = b - a
limit = np.sum(diff)

minus = -sum(diff[diff < 0])
diffp = diff[0 < diff]
result = minus
for d in diffp:
    div = min(int(d / 2), minus)
    minus -= div
    result = d - div * 2
    if limit < result:
        break

if 0 < minus or limit < result:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 14856
#include <bits/stdc++.h>
#include <stack>
#include <cassert>
#include <set>
#include <queue>
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <map>
#include <cmath>
#include <numeric>

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
const double EPS=1e-6;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define F first
#define S second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int)((a).size())
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) a.rbegin(),a.rend()
#define FLL(a,b) memset((a),b,sizeof(a))
#define CLR(a) FLL(a,0)
#define declare(a,it) __typeof(a) it=(a)
#define FOR(it,a) for(declare(a.begin(),it);it!=a.end();++it)
#define FORR(it,a) for(declare(a.rbegin(),it);it!=a.rend();++it)
template<class T,class U> ostream& operator<< (ostream& o, const pair<T,U>& v){return o << "(" << v.F << ", " << v.S << ")";}
template<class T> ostream& operator<< (ostream& o, const vector<T>& v){o << "{";rep(i,SZ(v)) o << (i?", ":"") << v[i];return o << "}";}
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,-1,1,1,-1};
int s2i(string& a){stringstream ss(a);int r;ss>>r;return r;}
int geti(){int n;scanf("%d", &n);return n;}

int main(int argc, char *argv[])
{
  int n,t;
  cin >> n>> t;
  vector<int> in(n);
  rep(i,n) cin >> in[i];
  sort(ALL(in));
  reverse(ALL(in));
  ll ans = 1;
  const ll mod=1e9+7;
  int s = 0;
  for(int i = 0; i < n; ++i){
    while(s<i && in[s] > in[i]+t) ++s;
    ans=(ans*(i-s+1))%mod;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1532
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cout << #x << " = " << (x) << "\n"
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

int n;
VVI a;
vector<vector<LL> > s;

void solve() {
	LL ans = -INF;
	for ( int i = 1; i <= n; i++ ) {
		for ( int j = 1; j <= n; j++ ) {
			for ( int k = 0; k < i; k++ ) {
				for ( int l = 0; l < j; l++ ) {
					ans = max( ans, s[ i ][ j ] - s[ k ][ j ] - s[ i ][ l ] + s[ k ][ l ] );
				}
			}
		}
	}
	printf( "%lld\n", ans );
}

int main() {
#ifdef WIN32
	printf( "Debug Mode\n" );
#endif
	scanf( "%d\n", &n );
	a.resize( n, VI( n ) );
	s.resize( n + 1, vector<LL>( n + 1, 0 ) );
	for ( int i = 0; i < n; i++ ) {
		for ( int j = 0; j < n; j++ ) {
			scanf( "%d", &a[ i ][ j ] );
			s[ i + 1 ][ j + 1 ] = s[ i + 1 ][ j ] + s[ i ][ j + 1 ] - s[ i ][ j ] + a[ i ][ j ];
		}
	}
	solve();
	return 0;
}

Measured memory_bytes: 1336
import java.util.*;
import java.io.*;
import java.math.*;
public class Main {
    public static void main(String[]args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		int[] l = new int[n];
		for(int i = 0 ; i < n ; i++) l[i] = Integer.parseInt(sc.next());
		Arrays.sort(l);
		int yono = 0;
		for(int i = 0 ; i < n - 1 ; i++) yono += l[i];
		if(yono > l[n - 1]) ou.println("Yes");
		else ou.println("No");
		ou.flush();
	}
}

Measured memory_bytes: 35644
#include <bits/stdc++.h>
#define ll long long
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end))) // rep(i, 1, 5) --> {1,2,3,4} // rep(i, 5, 1) --> {4,3,2,1} // rep(it, end(v), begin(v)) --> *it

using namespace std;

int main()
{
    int k, s;
    cin >> k >> s;
    int res = 0;
    rep(x, 0, k+1)
        rep(y, 0, k+1)
            if (s-x-y >= 0 && s-x-y <= k)
                res++;
    cout << res;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<50)
signed main(){
  int N,M,L; cin>>N>>M>>L;
  if(!(N==300&&M==N*(N-1)/2)){
  vector<vector<pii>> A(N),F(N,vector<pii>(N,mp(INF,L)));
  rep(i,0,M){
    int X,Y,Z; cin>>X>>Y>>Z;
    if(L>=Z){
      A[X-1].pb(mp(Y-1,Z));
      A[Y-1].pb(mp(X-1,Z));
    }
  }
  rep(i,0,N){
    priority_queue<pair<pii,int>,vector<pair<pii,int>>,greater<pair<pii,int>>> Q;
    Q.push(mp(mp(0,0),i));
    F[i][i]=mp(0,0);
    while(Q.size()>0){
      int X=Q.top().second,Y=Q.top().first.first,Z=Q.top().first.second;
      Q.pop();
      rep(j,0,A[X].size()){
        int P=A[X][j].first,R=A[X][j].second;
        int B=Z+R,C=Y;
        if(B>L){
          B=R;
          C++;
        }
        if(F[i][P]>mp(C,B)){
          F[i][P]=mp(C,B);
          Q.push(mp(mp(C,B),P));
        }
      }
    }
  }
  int Q; cin>>Q;
  rep(i,0,Q){
    int X,Y; cin>>X>>Y;
    int ans=F[X-1][Y-1].first;
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
  }
  }
  else{
  vector<vector<pii>> A(N,vector<pii>(N,mp(INF,INF)));
  rep(i,0,M){
    int X,Y,Z; cin>>X>>Y>>Z;
    if(L>=Z){
      A[X-1][Y-1]=mp(0,Z);
      A[Y-1][X-1]=mp(0,Z);
    }
  }
  rep(i,0,N) A[i][i]=mp(0,0);
  rep(i,0,N){
    rep(j,0,N){
      rep(k,0,N){
        int X=A[j][i].first+A[i][k].first,Y=A[j][i].second+A[i][k].second;
        if(Y>L){
          Y-=L;
          X++;
        }
        A[j][k]=min(A[j][k],mp(X,Y));
      }
    }
  }
  int Q; cin>>Q;
  rep(i,0,Q){
    int X,Y; cin>>X>>Y;
    int ans=A[X-1][Y-1].first;
    if(ans==INF) ans=-1;
    cout<<ans<<endl;
  }
  }
  }




Measured memory_bytes: 2816
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<utility>
#define ul unsigned long long int
#define ll long long int
#define MAX 1000000+1
using namespace std;
#define F first
#define S second
#define pi 2*acos(0.0)
#define PB push_back
#define LSTAGE 1



int main()
{

    ll n;
    cin >> n;
    map<ll, bool> v;
    for(ll i=  0; i < n; i++)
    {
        ll r;
        cin >> r;
        if(v.count(r)==0)
        {
            v[r] = false;
        }

        v[r] = (!v[r]);

    }
    map<ll, bool> :: iterator it;
    ll area = 0;
    ll a= 0, b= 0;
    for(it = v.begin(); it!=v.end(); it++)
    {

//        cout << it->F<<endl;
        if(it->S)
            area++;
    }
    cout << area ;




    return 0;
}


Measured memory_bytes: 6528
#include<iostream>
#include<stdio.h>
#include<queue>

using namespace std;
int main() {
	queue<long long> q;
	int K;
	cin >> K;


	for (int i = 1; i < 10; i++) {
		q.push(i);
	}

	long long x = 0;

	for (int i = 0; i < K - 1; i++) {
		x = q.front();
		q.pop();
		
		if (x % 10 != 0) {
		q.push(((10 * x) + (x % 10)) - 1);
		}
		q.push((10 * x) + (x % 10));

		if ((x % 10 != 9)) {
			q.push((10 * x) + (x % 10) + 1);
		}
	}

	cout << q.front() << endl;
	return 0;
}

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

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

    set<string> str_set;
    int len = s.length();
    for(int i=0; i<len; i++) {
        for(int j=1; j<=5; j++) {
            if(i+j > len)
                continue;
            str_set.insert(s.substr(i, j));
    
        }
    }
    auto itr = str_set.begin();
    for(int i=0; i<K-1; i++) {
        itr++;
    }

    cout << *itr << endl;
}

Measured memory_bytes: 1664
#pragma GCC optimize("O3")
    #pragma comment(linker, "/stack:200000000")
    #pragma GCC optimize("Ofast")
    #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include<bits/stdc++.h>
    #define int long long
    # define mo 1000000007
    using namespace std;
    #define goku ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    pair<int,int> a[200005];
    signed main(){
        goku
    int n,d,af;
    cin>>n>>d>>af;
    for(int i=0;i<n;i++)
    {
        cin>>a[i].first>>a[i].second;
    }
    sort(a,a+n);
    queue<pair<int,int>> q;
    q.push({a[0].first,a[0].second});
    int pr=a[0].first;
    int bb=0;
    int i=0;
    while(i<n||!q.empty())
    {
       if((i<n&&a[i].first-pr<=2*d)||q.empty())
       {
           if(q.empty())
            pr=a[i].first;
           q.push({a[i].first,a[i].second+bb});
           i++;
       }
       else
       {

           if(q.size()==1)
           {
               bb = (q.front().second/af)*af;
               if(q.front().second%af!=0)
                bb+=af;
               q.pop();
               continue;
           }

           if(i==n)
           {
               pair<int,int> tt = q.front();
           pr=tt.first;

           while(!q.empty()){
                if(bb>=q.front().second){
                q.pop();
                if(!q.empty())
                pr = q.front().first;
                }
           else{
                tt = q.front();
              q.pop();
                bb = (tt.second/af)*af;
            if(tt.second%af!=0)
               bb+=af;
               if(!q.empty())
               pr=q.front().first;
           }

           }
           }
           else{
           pair<int,int> tt = q.front();
           pr=tt.first;

           while(!q.empty()&&a[i].first-pr>2*d){
                if(bb>=q.front().second){
                q.pop();
                if(!q.empty())
                pr = q.front().first;
                }
           else{
                tt = q.front();
              q.pop();
                bb = (tt.second/af)*af;
            if(tt.second%af!=0)
               bb+=af;
               if(!q.empty())
               pr=q.front().first;
           }

           }

           }

       }

    }
    cout<<bb/af;
       return 0;
    }


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
typedef long long ll;

set<ll> enum_divisors(ll N, ll M){
    set<ll> res;
    for(ll i = 1; i * i <= max(N, M); i++){
        if(N % i == 0 && M % i == 0){
            res.insert(i);
        }
        if(N / i > 0 && M % (N / i) == 0) res.insert(N / i);
        if(M / i > 0 && N % (M / i) == 0) res.insert(M / i);
    }
    return res;
}

bool is_prime(ll N){
    for(ll i = 2; i * i <= N; i++){
        if(N % i == 0) return false;
    }
    return true;
}

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

    set<ll> res = enum_divisors(a, b);
    ll cnt = 0;
    for(auto i = res.begin(); i != res.end(); i++){
        if(is_prime(*i)) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 512
#include<iostream>

using namespace std;

int main()
{
  int N,a[3],i;
  cin >> N;
  for(i=0;i<3;i++){
    a[i] = N%10;
    N = N/10;
  }
  if(a[0]==7 || a[1]==7 || a[2]==7)
  cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main(){
    const double pi=3.1415926535897932384626433832795028841971693;
    double s1,s2,s3,a;
    cin >> s1 >> s2 >> a;
    cout << setprecision(20)<< fixed << (1/2.0)*(s1)*(s2)*(sin(a*pi/180)) << endl;
    s3=sqrt(pow(s1,2)+pow(s2,2)-2*s1*s2*cos(a*pi/180));
    cout << s1+s2+s3 << endl;
    cout << s2*sin(a*pi/180) << endl;
}


Measured memory_bytes: 3452
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int n;
map<int, int> mp;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> n;
  FOR(i, 1, n + 1) {
    int a;
    cin >> a;
    mp[a] = i;
  }

  FOR(i, 1, n + 1) {
    cout << mp[i] << endl;
  }
}


Measured memory_bytes: 5504
N = int(input())
S = input()
L = [0]
R = [0]
for i in range(1, N):
	if S[i-1] == 'W':
		L.append(L[-1]+1)
	else:
		L.append(L[-1])
	if S[-i] == 'E':
		R.append(R[-1]+1)
	else:
		R.append(R[-1])
R.reverse()
min = 5000000000000000
for i in range(0, N):
	if L[i]+R[i] < min:
		min = L[i]+R[i]
print(min)

Measured memory_bytes: 81500
#include <bits/stdc++.h>
#define int long long
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define mod 1000000007
#define lld long double
#define mii map<int, int>
#define mci map<char, int>
#define msi map<string, int>
#define pii pair<int, int>
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rep(i,x,y) for(int i=x; i<y; i++)
#define fill(a,b) memset(a, b, sizeof(a))
#define vi vector<int>
#define setbits(x) __builtin_popcountll(x)
using namespace std;
const long long N=200005, INF=2000000000000000000;
int power(int a, int b, int p)
    {
        if(a==0)
        return 0;
        int res=1;
        a%=p;
        while(b>0)
        {
            if(b&1)
            res=(res*a)%p;
            b>>=1;
            a=(a*a)%p;
        }
        return res;
    }

int32_t main()
{
    IOS;
    int n;
    cin>>n;
    int rem=n%500,h=0;
    h=1000*(n/500);
    h+=5*(rem/5);
    cout<<h;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int N, x=0, i;
  int a[255];
  scanf("%d", &N);
  if(N == 0){
    printf("0");
  }
  while(N!=0){
    a[x] = abs(N) % 2;
    if(N<0 && abs(N)%2 == 1){
      N -= 1;
    }
    N = N / (-2);
    x++;
  }
  for(i=x-1; i>=0; i--){
      printf("%d", a[i]);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


int main() {
    ll L, ans;
    while(cin >> L,L){
        ans = 1;
        for(ll i=2; i*i<=L; i++){
            if(L%i==0){
                ll cnt = 0;
                while(L%i==0){
                    L /= i;
                    cnt++;
                }
                ans *= 2*cnt+1;
            }
        }
        if(L!=1) ans *= 3;
        ans = (ans+1)/2;
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 2988
#include <bits/stdc++.h>
#define N 105
const long long INF = (1LL<<32);
using namespace std;
long long d[N][N];
int main(){
    int n, e;
    scanf("%d %d", &n, &e);
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            d[i][j] = (i == j) ? 0 : INF;
    for(int i = 0; i < e; i++){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        d[a][b] = c;
    }

    for(int k = 0; k < n; k++){
        for(int i = 0; i < n; i++){
            if(d[i][k] == INF) continue;
            for(int j = 0; j < n; j++)
                if(d[k][j] == INF) continue;
                else d[i][j] = min(d[i][j], d[i][k]+d[k][j]);
        }
    }

    int flag = 0;
    for(int i = 0; i < n; i++) if(d[i][i] < 0) flag = 1;
    if(flag) printf("NEGATIVE CYCLE\n");
    else{
        for(int i = 0; i < n; i++){
            for(int j = 0; j < n; j++){
                if(d[i][j] == INF) printf("INF");
                else printf("%lld", d[i][j]);
                if(j == n-1) printf("\n");
                else printf(" ");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint l;
    cin >> l;
    vector<lint> a(l);
    for (int i = 0; i < l; ++i) {
        cin >> a[i];
    }
    vector<vector<lint>> dp(l + 1, vector<lint>(5, inf));
    for (int j = 0; j < 5; ++j) {
        dp[0][j] = 0;
    }
    // dp[0][0] = 0;
    for (int i = 1; i <= l; ++i) {
        chmin(dp[i][0], dp[i - 1][0] + a[i - 1]);
        chmin(dp[i][1], dp[i - 1][1] + (a[i - 1] == 0 ? 2 : (a[i - 1] % 2)));
        chmin(dp[i][2], dp[i - 1][2] + (1 - a[i - 1] % 2));
        chmin(dp[i][3], dp[i - 1][3] + (a[i - 1] == 0 ? 2 : (a[i - 1] % 2)));
        chmin(dp[i][4], dp[i - 1][4] + a[i - 1]);
        for (int j = 1; j < 5; ++j) {
            for (int k = j - 1; k >= 0; --k) {
                chmin(dp[i][j], dp[i][k]);
            }
        }
    }
    cout << dp[l][4] << "\n";
    return 0;
}

Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string yes="yes";
string Yes="Yes";
string YES="YES";
string no="no";
string No="No";
string NO="NO";

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; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
#define case std::cout << "Case #" <<qqq+1<<": "
#define res resize
#define as assign
#define ffor for(;;)
#define ppri(a,b) std::cout << a<<" "<<b << std::endl
#define pppri(a,b,c) std::cout << a<<" "<<b <<" "<< c<<std::endl
#define aall(x,n) (x).begin(),(x).begin()+(n)
 
typedef long long ll;
typedef pair<int,int> P;
//typedef long long T;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
//const int mod = 1000000007ll;
int main(){
    int n;
    std::cin >> n;
    ll ans=0;
    rrep(i,1,n+1){
        if((i%3!=0)&&(i%5!=0))ans=ans+i;
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
string s;
long long ans=0;
long long dfs(int len,long long cur,long long sum){
	if(len==s.size()) {
		return sum;
	}
	int d=s[len]-'0';
	long long res=0;
	if(len+1!= s.size())
		res+=dfs(len+1,cur*10+d,sum);
	res+=dfs(len+1,0,sum+cur*10+d);
	return res;
}
int main(){
	cin>>s;
	cout<<dfs(0,0,0);
}


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

int main()
{
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100005]; 
int gcd1[100005];
int gcd2[100005];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	   scanf("%d",&a[i]);
	
	gcd1[1]=a[1];
	gcd2[n]=a[n];
	for(int i=2;i<=n;++i)
	    gcd1[i]=__gcd(gcd1[i-1],a[i]);//cout<<gcd1[i]<<" ";
	//cout<<endl;
	for(int i=n-1;i>=1;--i)
	    gcd2[i]=__gcd(gcd2[i+1],a[i]);//cout<<gcd2[i]<<" ";
	//cout<<endl;
	gcd1[0]=gcd2[2];
	gcd2[n+1]=gcd1[n-1];
	int ans=0;
	for(int i=1;i<=n;++i)
		ans=max(ans,__gcd(gcd1[i-1],gcd2[i+1]));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5008
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;
using namespace std;

int main() {
    int a,b;
    cin >> a >> b;
    int a1;
    a1 = a+b;
    if(a%3==0 || b%3==0 || a1%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
    int n;
    cin>>n;
    int a;
    cin>>a;
    if(n<a){
        cout<<0<<endl;
    }
    else{
        cout<<10<<endl;
    }
}


Measured memory_bytes: 256
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <memory.h>
#include <ctime>
#include <bitset>
#include <vector>
#include <string>
#include <queue>

using namespace std;

char cc[1000000];

int f1 = 3e5, f2;
bool rev = false;

void solution() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        cc[f1 + i] = s[i];
    }
    f2 = f1 + s.size();
    int q;
    cin >> q;
    int t, f;
    char c;
    while (q--) {
        scanf("%d", &t);
        if (t == 1) {
            rev = !rev;
        } else {
            scanf("%d %c", &f, &c);
            if ((f == 1 && !rev) || (f == 2 && rev)) {
                cc[--f1] = c;
            } else {
                cc[f2++] = c;
            }
        }
    }
    if (!rev) {
        for (int i = f1; i < f2; i++) {
            printf("%c", cc[i]);
        }
    } else {
        for (int i = f2 - 1; i >= f1; i--) {
            printf("%c", cc[i]);
        }
    }
    cout << endl;
}

/*-------------------*/

int main()
{
#ifdef Files
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    /*Test*/
    //freopen("input.txt", "w", stdout);

    double OcZ2X = clock();
#else
    //freopen("joke.in", "r", stdin);
    //freopen("joke.out", "w", stdout);
#endif

/*
　　     　 　          ∧_,,∧　　　
    　            ♪　  (・ω・)　♪
               ＿＿＿＿○＿＿つヾ＿＿＿＿＿
             /δ⊆・⊇ 。/†: :† /δ ⊆・⊇｡ /|
            |￣￣￣￣￣￣￣￣￣￣￣￣￣ | |
            |　　　*/solution();/* 　　| |
            |　　　　　　　　　　　　　 |
*/

#ifdef Time
    double P2HxQ = clock();
    printf("\n*** Total time = %.3f sec ***\n", (P2HxQ - OcZ2X) / CLOCKS_PER_SEC);
#endif
}

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

const int NN=1e5+10;
int a[NN];
int b[NN];
int c[NN];
int Min;
int Min2;
int n;

int gcd(int a,int b)
{
    while(b!=0){
        int temp=a;
        a=b;
        b=temp%b;
    }
    return a;
}

int main(){
    scanf("%d",&n);
    Min=-1;
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
    }
    sort(a,a+n);
    for(int i=1;i<n;i++)
    {
        if(i>0){
            b[i-1]=gcd(a[i],a[0]);
            if(Min==-1){
                Min=i-1;
            }
            else if(b[i-1]<b[Min]){
                Min=i-1;
            }
        }
    }
    if(n==2){
        printf("%d\n",max(a[0],a[1]));
        return 0;
    }
    Min2==-1;
    for(int i=0;i<n;i++)
    {
        c[i]=gcd(a[i],a[1]);
        if(Min2==-1){
            Min2=i;
        }
        else if(c[Min2]>c[i]){
            Min2=i;
        }
    }

        if(Min>0){
            b[Min]=b[Min-1];
        }
        else if(Min+1<n-1){
            b[Min]=b[Min+1];
        }
        else{
            printf("%d\n",b[Min]);
            return 0;
        }
        int temp=-1;
        for(int i=1;i<n-1;i++){
            if(temp==-1){
                temp=gcd(b[i],b[i-1]);
            }
            else{
                temp=gcd(b[i],temp);
                if(temp==1){
                    break;
                }
            }
        }

        if(Min2>0){
            c[Min2]=c[Min2-1];
        }
        else if(Min2+1<n){
            c[Min2]=c[Min2+1];
        }
        else{
            printf("%d\n",c[Min2]);
            return 0;
        }
        int temp2=-1;
        for(int i=1;i<n;i++){
            if(temp2==-1){
                temp2=gcd(c[i],c[i-1]);
            }
            else{
                temp2=gcd(c[i],temp2);
                if(temp2==1){
                    break;
                }
            }
        }
        printf("%d\n",max(temp,temp2));

}


Measured memory_bytes: 1408
#include <stdio.h>  /*入出力*/
#include <stdlib.h> /*標準ライブラリ*/
#include <string.h> /*文字列*/
#include <math.h>   /*計算*/
#include <assert.h> /*確認*/
#include <ctype.h>  /*文字操作*/

#define rep(i, n) for(int  i = 0; i < (n); i++)
#define max(a,b) ((a>b)?a:b)
#define ABS(a) (((a)>(0))?a:-(a))

#define N 3000
void swap(int *a, int *b)
{
  int temp;
  temp = *a;*a = *b;*b = temp;
}

int main(void)
{
  int x;
  int y;
  int sum=0;
  scanf("%d%d", &x,&y);
  if(x == 3)sum += 100000;
  if (x==2) {
    sum+= 200000;
  }
  if(x==1)sum+=300000;
  if(y == 3)sum += 100000;
  if (y==2) {
    sum+= 200000;
  }
  if(y==1)sum+=300000;
  if (x==1 && y==1) {
    sum+= 400000;
  }
  printf("%d\n", sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
	int n,total=0;
	cin>>n;
	int a[n+1],b[n+1],c[n];
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n;i++)  cin>>b[i];
	for (int i=1;i<=n-1;i++)  cin>>c[i];
	for (int i=1;i<=n;i++) total+=b[i];
	for (int i=1;i<=n-1;i++)
	{
		if (a[i+1]-a[i]==1)
		{
			total+=c[a[i]];
		}
	}
	cout<<total<<endl;
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

const int MAX = 1000100;
bool prime[MAX];

void sieve(){
	fill(prime, prime+MAX, true);
	prime[0] = prime[1] = false;

	for(int i=2; i*i < MAX; i++){
		if(!prime[i]) continue;
		for(int j=i*i; j < MAX; j += i) prime[j] = false;
	}
}


int main(){
	int n;
	sieve();
	while(cin >> n){
		for(int i=1; ; i++) if(prime[n-i]){ cout << n-i << " "; break;}
		for(int i=1; ; i++) if(prime[n+i]){ cout << n+i << endl; break;}
	}
}

Measured memory_bytes: 2136
#include <iostream>

using namespace std;

int main() {

    ios::sync_with_stdio(false);

    string a,b;
    cin >> a;

    for(int i = 0; i < a.size(); i++) {
        if(i == 0 || a[i-1] != a[i])
            b.push_back(a[i]);
    }

    cout << b.size()-1;

    return 0;
}


Measured memory_bytes: 592
#include<iostream>
using namespace std;
struct Card{char suit,value;};
void bubble(struct Card A[],int N){
  for(int i=0;i<N;i++){
    for(int j=N-1;j>=i+1;j--){
      if(A[j].value<A[j-1].value){
	Card t=A[j];A[j]=A[j-1];A[j-1]=t;
      }
    }
  }
}
void selection(struct Card A[],int N){
  for(int i=0;i<N;i++){
    int minj=i;
    for(int j=i;j<N;j++){
      if(A[j].value<A[minj].value) minj=j;
    }
    Card t=A[i]; A[i]=A[minj]; A[minj]=t;
  }
}
void print(struct Card A[],int N){
  for(int i=0;i<N;i++){
    if(i>0) cout << " ";
    cout << A[i].suit << A[i].value;
  }
  cout << endl;
}
bool isStable(struct Card C1[],struct Card C2[],int N){
  for(int i=0;i<N;i++){
    if(C1[i].suit != C2[i].suit) return false;
  }
  return true;
}
int main(){
  Card C1[100],C2[100];
  int N;
  char ch;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> C1[i].suit >> C1[i].value;
  }
  for(int i=0;i<N;i++) C2[i] = C1[i];
  bubble(C1,N);
  selection(C2,N);
  print(C1,N);
  cout << "Stable" << endl;
  print(C2,N);
  if(isStable(C1,C2,N)){
    cout << "Stable" << endl;
  } else{
    cout << "Not stable" << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
typedef long long int ll;
#define pb         push_back
#define mp         make_pair
#define F          first
#define S          second
#define fl(i,a,b)  for(ll i=a;i<b;i++)
#define pll        pair<ll,ll>
#define pii        pair<int,int>
#define all(v)     v.begin(),v.end()
#define M          998244353
#define M2         1000000007
#define inf        100000000000000
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

using namespace std;

bool isPrime(ll n)
{
    if(n<=1)
        return false;
    if(n<=3)
        return true;
    if(n%2==0 || n%3==0)
        return false;
    for(ll i=5;i*i<=n;i=i+6)
        if(n%i==0|| n%(i+2)==0)
            return false;
    return true;
}

int main()
{
    off;
    int n,m,x;
    cin>>n>>m>>x;
    int ski[n][m],cost[n];
    fl(i,0,n)
    {
        cin>>cost[i];
        fl(j,0,m)
            cin>>ski[i][j];
    }
    int ans = M2;
    fl(i,0,(1<<n))
    {
        int sk[m],co=0;
        memset(sk,0,sizeof(sk));
        fl(j,0,n)
        {
            if(!(i & (1<<j))) continue;
            fl(k,0,m)
            {
                sk[k]+=ski[j][k];
            }
            co+=cost[j];
        }
        int f=0;
        fl(j,0,m)
        {
            if(sk[j]<x)
            {
                f=1;
                break;
            }
        }
        if(f==0)
            ans = min(ans, co);
    }
    if(ans==M2)
        ans=-1;
    cout<<ans;
}








Measured memory_bytes: 3640
package main

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

const (
	initialBufSize = 1e4
	maxBufSize     = 1e8
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func min(x, y int) int {
	if x > y {
		return y
	} else {
		return x
	}
}

func main() {
	S := next()

	l0, l1 := 0, 0
	for i := 0; i < len(S); i++ {
		if S[i] == '0' {
			l0++
		} else {
			l1++
		}
	}
	fmt.Println(2 * min(l0, l1))
}


Measured memory_bytes: 2136
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
using lint = long long;

template<class T = lint>
struct Edge {
	int to;
	T cost;
	Edge(int to, T cost = 0) : to(to), cost(cost) {}
	bool operator>(const Edge &r) const { return this->cost > r.cost; }
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

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

	int u, v;
	vector<vector<Edge<lint>>> edges(N);
	for (int i = 0; i < M; i++) {
		cin >> u >> v;
		u--, v--;
		edges[u].emplace_back(v);
	}

	int st, go;
	cin >> st >> go;
	st--, go--;

	vector<vector<lint>> cost(N, vector<lint>(3, INF));
	queue<Edge<lint>> que;
	que.emplace(st);
	cost[st][0] = 0;

	while (!que.empty()) {

		Edge<lint> now(que.front().to);
		que.pop();

		for (int i = 0; i < 3; i++) {
			for (const auto &e : edges[now.to]) {
				lint tmp_cost = cost[now.to][i] + 1;
				if (cost[e.to][(i + 1) % 3] > tmp_cost) {
					cost[e.to][(i + 1) % 3] = tmp_cost;
					que.emplace(e.to);
				}
			}
		}
	}

	if (cost[go][0] % 3 == 0) cout << cost[go][0] / 3 << "\n";
	else cout << "-1\n";
	
	return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char a, b, c, d;

  cin >> a >> b >> c >> d;

  if(a == b && b == c){
    cout << "Yes" << endl;
  }
  else if(b == c && c == d){
    cout << "Yes" << endl;
  }
  else if(a == b && b == c && c == d){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<bits/stdc++.h>
#define lli long long int
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define fastio ios_base::sync_with_stdio(false); cout.tie(NULL);
using namespace std;

int main()
{
	fastio;
	int n;
	cin>>n;
	if(n>=30)
		cout<<"Yes";
	else
		cout<<"No";
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <vector>
#include <string.h>

typedef long long ll;
typedef long double lg;

using namespace std;

int main(){

 int a,b;
 cin>>a>>b;

 if(a > 8 || b>8)
    cout<<":("<<endl;
 else
    cout<<"Yay!"<<endl;



return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; ++i)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")

using ll = long long;

using pint = std::pair<int, int>;
using pll = std::pair<ll, ll>;


constexpr int inf = 1e9 + 7;
constexpr ll infll = 1ll << 60ll;
constexpr ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

namespace {
	template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
	template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
	template<typename T> void chadd(T& a, T b) { a = a + b; }

	void Cout(long long x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const T& x, const char* end = "\n") { std::cout << x << end; }
	template <typename T> void Cout(const std::vector<T>& x, const char* sep = " ", const char* end = "\n") { for (std::size_t i = 0, sz = x.size(); i < sz; i++) { std::cout << x[i] << (i == sz - 1 ? end : sep); } }


	// 標準入出力
	struct inp {
		std::size_t sz;
		inp(std::size_t _sz = 1) : sz(_sz) {}
		template <typename T> operator T () const { T a; std::cin >> a; return a; }
		template <typename T> operator std::vector<T>() const { vector<T> a(sz); for (std::size_t i = 0; i < sz; i++) std::cin >> a[i]; return a; }
		template <typename T, typename U> operator std::pair<T, U>() const { T f; U s; std::cin >> f >> s; return std::pair<T, U>(f, s); }
	};

	inp inp1; // input one
}

int main() {

	int h, n;
	cin >> h >> n;
	vector<int> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];

	int max_a = *max_element(allof(a));
	// dp[i] := 敵のHPをi削ったときに消費する魔力の最小値
	vector<int> dp(h + max_a + 1, inf);

	dp[0] = 0;
	rep(i, n) {
		rep(j, h) {
			chmin(dp[j + a[i]], dp[j] + b[i]);
		}
	}

	int ans = inf;
	Rep(i, h, h + max_a + 1) {
		chmin(ans, dp[i]);
	}

	Cout(ans);

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n;
  cin >> n;
  vi p(n);
  rep(i,n) cin >> p[i];
  int ans = 0;
  rep(i,n-1) {
    if (p[i] == i+1) {
      swap(p[i],p[i+1]);
      ans++;
    }
  }
  if (p[n-1] == n) ans++;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    int n,m,x,y; cin >> n >> m >> x >> y;
    vector<int> xx(n),yy(m);
    rep(i,n) cin >> xx[i];
    rep(i,m) cin >> yy[i];
    sort(all(xx));
    sort(all(yy));

    for(int z=x+1; z<=y; z++){
            if(z>xx[n-1] && z<=yy[0]){
                cout << "No War" << endl;
                return 0;
            }
    }

    cout << "War" << endl;
    return 0;
}


Measured memory_bytes: 3572
n=int(input())
A=list(map(int,input().split()))
q=int(input())

C=[0]*(10**5+1)

for a in A:
    C[a]+=1

ans=sum(A)

for i in range(q):
    b,c=map(int,input().split())
    ans+=(c-b)*(C[b])
    C[c]+=C[b]
    C[b]=0
    print(ans)

Measured memory_bytes: 84320
// https://atcoder.jp/contests/abc069/tasks/arc080_a

#include <bits/stdc++.h>
#define REP(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define REPR(i, n) for (int(i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for (int(i) = (m); (i) < (n); i++)
#define INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll N, a, f, o;
string r;

int main()
{
  o = f = 0;
  cin >> N;
  REP(i, N)
  {
    cin >> a;
    if (a % 4 == 0)
      f++;
    else if (a % 2 != 0)
      o++;
  }

  r = min(o, f) == N / 2 || o <= f ? "Yes" : "No";

  cout << r << '\n';

  return 0;
}


Measured memory_bytes: 256