akhauriyash/Code-Regression huggingface dataset:
// VALUE THE SACRIFICES..
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
#define int long long
#define out_of_reach ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,n) for(i=0; i < n; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define mod 1000000007
int par[150001],siize[1000005];
// -----------------------------------------------------------------
signed  main()
{
    int t;
    int n;
    cin>>n;
    int ans = (n/500)*1000;
    n = n%500;
    ans += (n/5)*5;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main()
{
	char str[6];
	int l,i,flag=0;
	
	scanf("%s",str);
	
	l=strlen(str);
	
	for(i=0;i<l-1;i++)
	{
		if(str[i]=='A'&&str[i+1]=='C')
	{
		flag=1;
		break;
	}
	}
	if(flag==1)
	{
		printf("Yes");
	}
	else
	printf("No");
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
ll h,n;
cin>>h>>n;
while(n--)
{
	ll x;
	cin>>x;
	h-=x;
}
if(h<=0)
{
	ol("Yes");
}
else
{
	ol("No");
}
return 0;
}



Measured memory_bytes: 256
#include <cstdio>

int n, A[1000010];

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

int main()
{
    #ifdef LOCAL
        freopen("E:\\Temp\\input.txt", "r", stdin);
        freopen("E:\\Temp\\output.txt", "w", stdout);
    #endif

    int i, q, key, sum = 0;
    scanf("%d", &n);
    for(i=0; i<n; ++i) scanf("%d", &A[i]);
    scanf("%d", &q);

    for(i=0; i<q; ++i) {
        scanf("%d", &key);
        if(binarySearch(key)) ++sum;
    }
    printf("%d\n", sum);

    return 0;
}

Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int N; cin >> N; 
	vector<int> d(N); rep(i, 0, N) { cin >> d[i]; }
	string s = "";
	rep(i, 0, N) 
		s += to_string(d[i]);
	rep(i, 0, INF) {
		if (s.find(to_string(i)) == string::npos) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3260
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) S[i] = 'x';
	cout << S << endl;
	return 0;
}

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

int main(){
  int n;cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int ans=0;
  for(int i=1;i<n-1;i++){
    if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1])) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<utility>
#include<cstring>
#include<stack>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define REP(i,n) for(int i=0;i<(int)(n);i++)
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
using namespace std;
int main()
{
  double sum,res=0,p,ruiseki=1;
  int i,N,M;
  scanf("%d %d",&N,&M);
  p = pow(1.000/2.000,M);
  sum = p;
  for(i=1;i<=10000;i++){
    res += (double)(i)*((1900.000)*(double)(M) + (double)(N-M)*(100.000))*(sum);
    ruiseki *= 1-p;
    sum = ruiseki*p;
  }
  printf("%d\n",(int)(res + 0.001));
  return 0;
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
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);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int64 A, V, B, W, T;
  cin >> A >> V >> B >> W >> T;
  if(A < B) {
    int64 X = A + V * T;
    int64 Y = B + W * T;
    if(X >= Y) cout << "YES\n";
    else cout << "NO\n";
  } else {
    // A >= B
    int64 X = A - V * T;
    int64 Y = B - W * T;
    if(X <= Y) cout << "YES\n";
    else cout << "NO\n";
  }
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;

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

int n,w,h;
int x[101];
int xi[101];

int main(void){
	scanf("%d%d%d",&n,&h,&w);
	for(int i=0;i<n;i++){
		scanf("%d",&x[i]);
	}
	for(int i=0;i<n;i++){
		xi[i]=i*w;
		if(i%2==0){
			xi[i]+=x[i];
		}else{
			xi[i]-=x[i];
		}
	}
	int ans=0;
	xi[n]=(n*w);
	sort(xi,xi+n);
	for(int i=0;i<n;i++){
		ans+=max(0,xi[i+1]-xi[i]-w);
	}
	ans+=xi[0];
	printf("%d\n",ans*h);
	return 0;
}

Measured memory_bytes: 3268
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template <class c
#define ris return *this
#define dor > debug &operator<<
#define eni(x)                                                                    \
    sim > typename enable_if<sizeof dud<c>(0) x 1, debug &>::type operator<<(c i) \
    {
sim > struct rge
{
    c b, e;
};
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c *x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug
{
#ifdef LOCAL
    ~debug()
    {
        cerr << endl;
    }
    eni(!=) cerr << boolalpha << i;
    ris;
} eni(==) ris << range(begin(i), end(i));
}
sim, class b dor(pair<b, c> d)
{
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d)
{
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
        *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
#else
    sim dor(const c &)
    {
        ris;
    }
#endif
}
;
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);
#define endl '\n'
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 10;
ll n;
ll arr[100005];
ll dp[100005];
ll dfs(int i)
{
    if(i==n-1)
    return 0;
    if(i>=n)
    return 1e18;
    if(dp[i]!=-1)
    return dp[i];
    ll c1=dfs(i+1)+abs(arr[i]-arr[i+1]);
    ll c2=1e18;
    if(i+2<n)
    c2=dfs(i+2)+abs(arr[i]-arr[i+2]);
    ll ans=min(c1,c2);
    return dp[i]=ans;
}
int main()
{
    fastio
    memset(dp,-1,sizeof dp);
cin>>n;
for(ll i=0;i<n;i++)
{
    cin>>arr[i];
}

cout<<dfs(0)<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
int main(){
    int a,b,c;cin>>a>>b>>c;
    vector<int>v;
    v.pb(a);
    v.pb(b);
    v.pb(c);
    sort(v.begin(),v.end());
    cout<<v[0]+v[1]<<"\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n, k;
	cin >> n >> k;
	int x; 
	int sum = 0;
	for (int i=0;i<n; i++){
		cin >> x;
		if (x > k-x) sum += (k-x)*2;
		else sum += x*2;
	}
	cout << sum<<endl;
}

Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

template <class T, class F>
T UpperBound(T i0, T i1, F f) {
    while (i0 < i1) {
        T i = (i0 + i1) / 2;
        if (f(i)) i0 = i + 1; else i1 = i;
    }
    return i0;
}

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

    int n;
    ll m;
    cin >> n >> m;

    m = (ll)n * n - m;

    vector<int> a(n);
    vector<ll> s(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i];
    }

    ll r = 0;

    auto t = UpperBound<int>(a[0] * 2 - 1, a.back() * 2 + 1, [&](auto t) {
        ll sum = 0, k = 0;
        int j = n;
        for (int i = 0; i < n; i++) {
            while (j > 0 && a[i] + a[j - 1] > t) j--;
            sum += s[j] + (ll)j * a[i];
            k += j;
        }
        if (k > m) {
            r = max(r, sum - t * (k - m));
        }
        return k <= m;
    });

    cout << 2 * n * s[n] - r << endl;

    return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define p5(i) i*i*i*i*i
using namespace std;
int n,a[100005];
int m;
vector<int> g[100005];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;++i) cin>>a[i];

     while(m--)
     {
         int u,v;
         cin>>u>>v;
         g[u].push_back(a[v]);
         g[v].push_back(a[u]);
     }
     int r=n;

     for(int i=1;i<=n;++i)
     {
         for(auto x : g[i]) if(x>=a[i])
         {
             r--;
             break;
         }
     }
     cout<<r;

}


Measured memory_bytes: 9092
#include<iostream>
#include <math.h>
using namespace std;

int N;

int main(){
    cin >> N;

    int X = double(N) / 1.08;

    int X1 = floor(X * 1.08);

    if (X1 == N){
        // cout << N << endl;
        cout << X << endl;
        // cout << X1 << endl;
        return 0;
    }
    else{
        X++;
        X1 = floor(X * 1.08);
        if (X1 == N)
        {
            cout << X << endl;
            // cout << X1 << endl;
            return 0;
        }
        else{
            // cout << X << endl;
            // cout << X1 << endl;
            cout << ":(" << endl;
        }
    }
}

Measured memory_bytes: 3576
#include<iostream>
#include<string.h>
using namespace std;
 
int D[2][6];
void spin(int n,char c)
{
  if(c=='E'){
    swap(D[n][0],D[n][3]);swap(D[n][3],D[n][5]);swap(D[n][5],D[n][2]);
  }
  else if(c=='W'){
    swap(D[n][0],D[n][2]);swap(D[n][2],D[n][5]);swap(D[n][5],D[n][3]);
  }
  else if(c=='S'){
    swap(D[n][0],D[n][1]);swap(D[n][0],D[n][4]);swap(D[n][4],D[n][5]);
  } 
  else if(c=='N'){
    swap(D[n][0],D[n][1]);swap(D[n][1],D[n][5]);swap(D[n][5],D[n][4]);
  }
}
int main()
{
  char SWS[10]={"SSSSWSSSS"};
  for(int i=0;i<6;i++)cin>>D[0][i];
  for(int i=0;i<6;i++)cin>>D[1][i];
  for(int i=0;i<10;i++){
    if(D[0][1]==D[1][1])break;
    spin(1,SWS[i]);
  }
  if(D[0][1]!=D[1][1] || D[0][4]!=D[1][4])cout<<"No"<<endl;
  else{
    for(int i=0;i<4;i++){
      if(D[0][0]==D[1][0] &&D[0][2]==D[1][2] &&D[0][3]==D[1][3] &&D[0][5]==D[1][5]){
    cout<<"Yes"<<endl;
    break;
      }
      spin(1,'W');
      if(i==3)cout<<"No"<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3112
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int k,n;
    cin>>k>>n;
    k*=500;
    if(k>=n) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}



Measured memory_bytes: 3612
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;
 
ll gcd(ll a, ll b){
if(a<b){return gcd(b,a);}
else if(a%b){return gcd(b,a%b);}
else{return b;}
}
int main(){
ll a,b,c;
cin>>a>>b>>c;
if(a==5&&b==5&&c==7)cout<<"YES"<<endl;
else if(a==5&&b==7&&c==5)cout<<"YES"<<endl;
else if(a==7&&b==5&&c==5)cout<<"YES"<<endl;
else
cout<<"NO"<<endl;

    }



Measured memory_bytes: 256
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

# N =I()
N,M= LI()
#AB = [LI() for _ in range(N)]
#A,B = zip(*AB)
#Ap = np.array(A)
#C = np.zeros(N + 1)

ans = False
if N==M:
    ans = True
if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 27056
import fractions


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

gcd_L=[]
gcd_R=[]

L=a[0]
for i in range(n):

    L=fractions.gcd(L,a[i])
    gcd_L.append(L)

R=a[n-1]
for i in range(n):

    R=fractions.gcd(R,a[n-i-1])
    gcd_R.append(R)


# print(gcd_L)
# print(gcd_R)

ans=gcd_R[n-2]

for i in range(1,n-1):
    ans = max(ans,fractions.gcd(gcd_L[i-1],gcd_R[n-i-2]))


ans= max(ans,gcd_L[n-2])

print(ans)


Measured memory_bytes: 16612
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  string s;
  int k;
  cin>>s>>k;
  if(s[0]!='1') cout<<s[0]<<endl;
  else {
    bool res=true;
    char ans;
    for(int i=0;i<s.size();i++){
      if(s[i]!='1'){
        if(i>=k){
          break;
        }
        res=false;
        ans=s[i];
        break;
      }
    }
    if(!res) cout<<ans<<endl;
    else cout<<1<<endl;
  }
  return 0;
}


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

int main(){
 long long N,d,p,ans,k;
cin>>N;
  ans=0;
vector<long long>a(N),b(N),c(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
    for(int i=0;i<N;i++){
    cin>>b[i];
      ans+=b[i];
  }
    for(int i=0;i<N;i++){
    cin>>c[i];
  }
  for(int i=0;i<N-1;i++){
if(a[i]+1==a[i+1]){
  ans+=c[a[i]-1];
  }
  }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

const int MAX_L = 1000001;
const int MAX_SQRT_B = 1000001;
bool is_prime_array[MAX_L];
bool is_prime_small[MAX_SQRT_B];

map<ll, ll> prime_factor(ll n) {
	map<ll, ll> res;
	for(int i = 2; i * i <= n; i++) {
		while(n % i == 0) {
			++res[i];
			n /= i;
		}
	}
	if(n != 1) res[n] = 1;
	return res;
}

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

	int N;
	cin >> N;
	int a[101];
	memset(a, 0, sizeof(a));

	rep(i, 2, N + 1) {
		map<ll, ll> m = prime_factor(i);
		for(map<ll, ll>::iterator it = m.begin(); it != m.end(); it++) {
			a[it->first] += it->second;
		}
	}

	int cnt[101];
	memset(cnt, 0, sizeof(cnt));
	rep(i, 0, 101) {
		if(a[i] >= 2) cnt[2]++;
		if(a[i] >= 4) cnt[4]++;
		if(a[i] >= 14) cnt[14]++;
		if(a[i] >= 24) cnt[24]++;
		if(a[i] >= 74) cnt[74]++;
	}

	ll rsl = cnt[74] + cnt[24] * (cnt[2] - 1) + cnt[14] * (cnt[4] - 1) + (cnt[4] * (cnt[4] - 1)) / 2 * (cnt[2] - cnt[4]) + (cnt[4] * (cnt[4] - 1)) / 2 * (cnt[4] - 2);

	cout << rsl << endl;

}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define N_MAX 100
#define W_MAX 2000

int Adj[N_MAX][N_MAX] = {};

int color[N_MAX] = {};

int sum_mst_path = 0;
int n;

int prim(void);

int main(){
    int i, j;

    cin >> n;
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            cin >> Adj[i][j];
        }
    }

    color[0] = 1;
    while ( prim() );

    cout << sum_mst_path << endl;

    return 0;
}

//[?????????
//0 : MST????§???????????????????
//1 : ???????????????????????????
int prim(void) {
    int i, j, min, next_node;

    min = W_MAX + 1;
    next_node = N_MAX + 1;

    //?¢????node???????????????????¢????node??????????????§???????°??????¢???path?????¢?´¢
    for (i = 0; i < n; i++) {
        if (color[i] != 1)
            continue;

        for (j = 0; j < n; j++) {
            if (color[j] != 0)
                continue;

            if (Adj[i][j] != -1 && Adj[i][j] < min) {
                min = Adj[i][j];
                next_node = j;
            }
        }
    }

    if (next_node == N_MAX + 1) //??????????¢??????????
        return 0;

    //next_node????¢????
    color[next_node] = 1;
    sum_mst_path += min;

    return 1;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define si(n) scanf("%d",&n);
#define PI acos(-1.0)
#define sl(n) scanf("%lld",&n);
#define sf(n) scanf("%lf",&n);
#define ss(n) scanf("%s",n);
#define for0(i,n) for(ll i=0;i<n;i++)
#define for1(i,n) for(ll i=1;i<=n;i++)
#define forc(i,j,n) for(ll i=j;i<n;i++)
#define pb push_back
#define sor(n) sort(n.begin(),n.end())
#define sorcmp(n) sort(n.begin(),n.end(),cmp)
#define rev(n) reverse(n.begin(),n.end())
#define pi(x)  printf("%d",x);
#define pl(x)  printf("%lld",x);
#define pf(x)  printf("%.10lf",x);
#define ps(x)  printf("%s",x);
#define en() printf("\n");
#define random_shuffle(r...)random_shuffle(r,[](int _){return rand()%_;})
#define SQR(a) (a)*(a)
#define sp(x) fixed<<setprecision(x)
#define mod 1000000007
#define endl '\n'
#define pii pair<int,int>
#define pll pair<ll,ll>
#define bug cout<<"Here"<<endl
void fastio(){ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
template <typename T> T POW(T B,T P){ if(P==0) return 1; if(P&1) return B*POW(B,P-1);  else return SQR(POW(B,P/2));}
ll powmod(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%mod;a = a*a%mod;b >>= 1;}return ans;}

int main(){
fastio();



            int arr[5];
  int indx;
  for(int i=0;i<5;i++)
  {
    cin>>arr[i];
    if(arr[i]==0) indx=i+1;
  }
  
  cout<<indx<<endl;




return 0;
}




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

int main()
{
    vector<int>v(3);
    for(int i=0;i<3;i++) cin>>v[i];
    sort(v.begin(),v.end());

    int res=v[2]*10+v[1]+v[0];
    cout<<res<<endl;
    return 0;
}


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

int main(){
  int a,b;
  cin >> a >> b;
  cout << a*b << ' ' <<  2*a+2*b << endl;
  return 0;
}




Measured memory_bytes: 3136
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>

namespace adaptor = boost::adaptors;
using index_t = std::size_t;

void Main()
{
	int M, D;
	std::cin >> M >> D;
	int count = 0;
	for (int i : boost::irange(4, std::max(4, M + 1)))
	{
		for (int d0 : boost::irange(2, 10))
		{
			for (int d1 : boost::irange(2, 10))
			{
				if (10 * d1 + d0 <= D && d1 * d0 == i)
				{
					++count;
				}
			}
		}
	}
	std::cout << count << std::endl;
}

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

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double EPS = 1e-8;

int main(){
  int sum = 0;
  for(int i=0;i<10;i++){
    int tmp;
    scanf("%d",&tmp);
    sum += tmp;
  }
  printf("%d\n",sum);
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

int main() {
	string source;
	string target;
	cin >> target;
	for (int i = 0; i < target.length(); i++) {
		target[i] = tolower(target[i]);
	}
	int sum = 0;
	while (cin>>source && source != "END_OF_TEXT") {
		for (int i = 0; i < source.length(); i++) {
			source[i] = tolower(source[i]);
		}
		if (source==target) {
			sum++;
		}
	}
	cout << sum << endl;
	return 0;
}

/*
int main() {
	string source;
	string target;
	cin >> target;
	int targetLen = target.length();
	int sum = 0;
	cin.ignore();
	//getline(cin,source);
	while (getline(cin,source)&&source!="END_OF_TEXT") {
		//search for words
		bool wordMissed = false;
		for (int i = 0; i < source.length()-targetLen+2; i++) {
			if (source[i] == ' ') {
				wordMissed = false;
				continue;
			}
			for (int j = 0; j < target.length()&&!wordMissed; j++) {
				if (tolower(source[i + j]) == tolower(target[j]) &&j==targetLen-1) {
					if (i+j== source.length() -1||source[i+j+1]==' ') {
						sum++;
					}
					
				}else if (tolower(source[i + j]) == tolower(target[j]) ) {
					continue;
				}
				else
				{
					wordMissed = true;
					break;
				}
				//if()

			}
			//getline(cin,source);
		}
		
		
	}

	cout << sum<<endl;

	return 0;
}
*/

Measured memory_bytes: 3052
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_5_B&lang=ja

    #include <stdio.h>
    
    int main(void){
        int w,h,i,j;
        while(1){
            scanf("%d %d",&w,&h);
            if(w == 0 && h == 0){
                break;
            }else{
                for(i=0;i<w;i++){
                    for(j=0;j<h;j++){
                        if((i == 0 || i == w - 1) ||
                           (j == 0 || j == h - 1)){
                                printf("#");
                           }else{
                                printf(".");
                           }
                    }
                    printf("\n");
                }
                printf("\n");
            }
        }

        return 0;
    }


Measured memory_bytes: 2024
#include<stdio.h>

int main(void)
{
  int a, b, c, d, x;

     scanf("%d%d%d", &a, &b, &c);

     x = b / a;

        if(x <= c)
          printf("%d\n", x);

        else
          printf("%d\n", c);


return 0;
}


Measured memory_bytes: 128
//AtCoder ABC046 C - AtCoDeerくんと選挙速報 / AtCoDeer and Election Report
#include <bits/stdc++.h>
using namespace std;
using lli=int64_t;

int main() {
#if LOCAL&0
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    int N;
    cin>>N;
    lli a=0,b=0;
    cin>>a>>b;

    auto get_rate = [](lli c,lli n){
        lli r=c/n;
        while(c > n*r){
            ++r;
        }
        return r;
    };

    for(int i=1;i<N;++i){
        lli aa,bb;
        cin>>aa>>bb;
        lli r=max(get_rate(a,aa),get_rate(b,bb));
        a=aa*r;
        b=bb*r;
    }
    cout<<a+b<<endl;
    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


void dice_north(int d[], int b[])	//北側に回転
{
	int i;

	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[1];
	d[1] = b[5];
	d[2] = b[2];
	d[3] = b[3];
	d[4] = b[0];
	d[5] = b[4];
}

void dice_south(int d[], int b[])
{
	int i;

	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[4];
	d[1] = b[0];
	d[2] = b[2];
	d[3] = b[3];
	d[4] = b[5];
	d[5] = b[1];
}

void dice_east(int d[], int b[])
{
	int i;

	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[3];
	d[1] = b[1];
	d[2] = b[0];
	d[3] = b[5];
	d[4] = b[4];
	d[5] = b[2];
}

void dice_west(int d[], int b[])
{
	int i;

	for (i = 0; i < 6; i++) {
		b[i] = d[i];
	}
	d[0] = b[2];
	d[1] = b[1];
	d[2] = b[5];
	d[3] = b[0];
	d[4] = b[4];
	d[5] = b[3];
}

int main(void)
{
	int dice[5] = { 0 };
	int box[5] = { 0 };
	int i;
	char kaiten[101] = { "\0" };

	for (i = 0; i < 6; i++) {
		scanf("%d", &dice[i]);
	}

	scanf("%s", kaiten);

	i = 0;
	while (kaiten[i]) {
		if (kaiten[i] == 'N')
			dice_north(dice, box);
		else if (kaiten[i] == 'S')
			dice_south(dice, box);
		else if (kaiten[i] == 'W')
			dice_west(dice, box);
		else if (kaiten[i] == 'E')
			dice_east(dice, box);
		i++;
	}

	printf("%d\n", dice[0]);

	

	//scanf("%d", &i);
	return 0;
}


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

int main() {
  long long t1, t2, a1, a2, b1, b2;
  cin>>t1>>t2>>a1>>a2>>b1>>b2;
  long long dist_a_t1 = t1 * a1;
  long long dist_a_t2 = t1 * a1 + t2 * a2;
  long long dist_b_t1 = t1 * b1;
  long long dist_b_t2 = t1 * b1 + t2 * b2;
  if (dist_a_t2 == dist_b_t2) {
    cout<<"infinity"<<endl;
    return 0;
  }
  if (dist_a_t1 < dist_b_t1 && dist_a_t2 < dist_b_t2) {
    cout<<0<<endl;
    return 0;
  }
  if (dist_a_t1 == dist_b_t1 && dist_a_t2 < dist_b_t2) {
    cout<<1<<endl;
    return 0;
  }
  if (dist_b_t1 < dist_a_t1 && dist_b_t2 < dist_a_t2) {
    cout<<0<<endl;
    return 0;
  }
  if (dist_b_t1 == dist_a_t1 && dist_b_t2 < dist_a_t2) {
    cout<<1<<endl;
    return 0;
  }
  long long k;
  if (dist_b_t1 > dist_a_t1) {
    k = (dist_b_t1 - dist_a_t1 - 1) / (dist_a_t2 - dist_b_t2) + 1;
  } else {
    k = (dist_a_t1 - dist_b_t1 - 1) / (dist_b_t2 - dist_a_t2) + 1;
  }
  long long ans = 2 * k - 1;
  if ((dist_b_t1 - dist_a_t1) % (dist_a_t2 - dist_b_t2) == 0) {
    ++ans;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

void output(int H[3][10]){
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			printf(" %d",H[i][j]);
		}
		printf("\n");
	}
}


int main(){
	int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,h_num,f_num,r_num,div_num;
	for(int i = 0; i < 3; i++){
		for(int j = 0; j < 10; j++){
			H1[i][j] = H2[i][j] = H3[i][j] = H4[i][j] = 0;
		}
	}
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d %d %d %d",&h_num,&f_num,&r_num,&div_num);
		switch(h_num){
		case 1:
			H1[f_num-1][r_num-1] += div_num;
			break;
		case 2:
			H2[f_num-1][r_num-1] += div_num;
			break;
		case 3:
			H3[f_num-1][r_num-1] += div_num;
			break;
		case 4:
			H4[f_num-1][r_num-1] += div_num;
			break;
		}
	}

	output(H1);
	printf("####################\n");
	output(H2);
	printf("####################\n");
	output(H3);
	printf("####################\n");
	output(H4);

}


Measured memory_bytes: 2756
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)    cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
//----------------------------------------------------------------
int main(void) {
  ll n;
  cin >> n;

  ll ans=0;
  rep(i,n){
    if((i+1)%3!=0 && (i+1)%5!=0) ans+=(i+1);
  }

  prt(ans);

}


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

int main() {
  int N = 0, Alice = 0, Bob = 0;
  cin >> N;
  
  vector<int> a(N);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N - 1; j++) {
      if (a.at(N - j - 1) > a.at(N - j - 2)) {
        int tmp = a.at(N - j - 2);
        a.at(N - j - 2) = a.at(N - j - 1);
        a.at(N - j - 1) = tmp;
      }
    }
  }
  
  for (int i = 0; i < N; i++) {
    if ((i + 2) % 2 == 0) {
      Alice += a.at(i);
    } else {
      Bob += a.at(i);
    }
  }
  
  cout << Alice - Bob << endl;
}


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

int main(){
	int a, b;
	char op;
//cin >> a >> op >> b;//★コメントにしました。入力１行目を読み捨てています。
		while(true){
			cin >> a >> op >> b;
				if(op == '?')
					break;
			int sum = 0;
				switch(op){
					case '+':
					sum = a + b;
					break;
					case '-':
					sum = a - b;
					break;
					case '*':
					sum = a * b;
					break;
					case '/':
					sum = a / b;
					break;
					case '?':
					break;
				}
			cout << sum << endl;
		}

return 0;
}


Measured memory_bytes: 3092
#include<stdio.h>
int main(void){
	int Height, Width;
	int i, j;
	do{
		scanf("%d%d",&Height,&Width);
		if(Height==0&&Width==0)break;
		for(i=0;i<Height;i++){
			for(j=0;j<Width;j++){
				if((i==0)||(i==Height-1))
				putchar('#');
				else if((j==0)||(j==Width-1))
				putchar('#');
				else
				putchar('.');
			}
			putchar('\n');
		}
		putchar('\n');
	}while(1);
}

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

int main() {
  string s;
  cin >> s;
  int k = s.length(), ch = 0;
  for ( int i = 0; i < k; i++ ) {
    if ( s[i] == 'o' ) { ch++; }
  }
  if ( (15-k)+ch >= 8 ) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  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);
		String S = sc.next();
		sc.close();
		int count = 0;

		for(int i = 0; i < 4; i++) {
			String syb = S.substring(i, i + 1);
			if(syb.equals("+")) {
				count++;
			}else {
				count--;
			}
		}
		System.out.println(count);

	}
}

Measured memory_bytes: 21844
from enum import Enum

class Point():
    def __init__(self, arg_x, arg_y):
        self.x = arg_x
        self.y = arg_y

def calc_len(a, b):
    from math import sqrt
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y))

x1, y1, x2, y2 = map(float, input().split())

p1 = Point(x1, y1)
p2 = Point(x2, y2)

print("%.10f"%calc_len(p1, p2))



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

#define REP(i, n) for(decltype(n) i = 0; i < n; i++)

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (ll)1e18 + 1;

class CombinationCalculator {
    using ull = unsigned long long;
public:
    /**
     *  組み合わせの数を求めるクラス
     *  @n_max: $ {}_n C_r $ における $ {}_n $ の最大値
     *  @mod:   組み合わせの数に対して取るMODの値
     */
    explicit CombinationCalculator(const ull& n_max,
                                   const ull& mod = (int)1e9 + 7):
        m_((mod != 0) ? mod : std::numeric_limits<uint>::max()),
        fact_(n_max + 1, 0),
        inv_fact_(n_max + 1, 0),
        inv_(n_max + 1, 0) {
        std::fill(fact_.begin(), fact_.begin() + 2, 1);
        std::fill(inv_fact_.begin(), inv_fact_.begin() + 2, 1);
        std::fill(inv_.begin(), inv_.begin() + 2, 1);
        for(ull i = 2; i <= n_max; i++) {
            fact_[i]     = (fact_[i - 1] * i) % m_;
            inv_[i]      = m_ - inv_[m_ % i] * (m_ / i) % m_;
            inv_fact_[i] = inv_fact_[i - 1] * inv_[i] % m_;
        }
    }

    /**
     *  $ {}_n C_r $ を求める
     *  @n:      $ {}_n $ の値
     *  @k:      $ {}_r $ の値
     *  @Return: $ {}_n C_r $
     */
    ull run(const ull& n,
            const ull& r) {
        if(n < r) {
            return 0;
        }
        else {
            return fact_[n] * (inv_fact_[r] * inv_fact_[n - r] % m_) % m_;
        }
    }

private:
    ull m_;
    std::vector<ull> fact_;
    std::vector<ull> inv_fact_;
    std::vector<ull> inv_;
};

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

    int H, W, A, B;
    std::cin >> H >> W >> A >> B;

    CombinationCalculator comb(H - 1 + W - 1, MOD);
    auto ans = 0LL;
    REP(i, W - B) {
        auto a = comb.run((H - A - 1) + (B + i), B + i);
        auto b = comb.run((A - 1) + (W - B - i - 1), W - B - i - 1);
        ans += a * b;
        ans %= MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    char a[5];
    cin>>a;
    if(a[0]==a[1] &&a[1]==a[2] || a[1]==a[2] && a[2]==a[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    rep(i, n) cin >> a[i] >> b[i];
    vector<int> c(m);
    vector<int> d(m);
    rep(i, m) cin >> c[i] >> d[i];
    rep(i, n) {
        int ans = 0;
        int dis = 1000000000000000;
        rep(j, m) {
            if (chmin(dis, abs(a[i] - c[j]) + abs(b[i] - d[j])))
                ans = j;
        }
        cout << ans + 1 << endl;
    }
}

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

using namespace std;
pair<double, vector<int> > dp[15][1 << 15];
int iton[15];
int x[15];
int w[15];
int n;

#define INF 1e+20

pair<double, vector<int> > solve(int state, int pos, int weight){
    if(dp[pos][state].first != INF) return dp[pos][state];
    pair<double, vector<int> > ret(0, vector<int>()),tmp;
    ret.second.push_back(iton[pos]);

    if(state == (1<<n)-1) return ret;

    ret.first = INF;
    for(int i=0;i<n;i++){
        if((state & (1 << i)) == 0){
            tmp = solve(state|(1<<i),i,weight+w[i]);
            tmp.first += abs(x[pos] - x[i]) / (2000.0 / (70+weight));
            if(ret.first > tmp.first){
                ret = tmp;
            }
        }
    }

    ret.second.push_back(iton[pos]);
    return dp[pos][state] = ret;
}

int main(){
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> iton[i] >> x[i] >> w[i];
        w[i] *= 20;
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<(1<<n);j++){
            dp[i][j] = pair<double, vector<int> >(INF,vector<int>());
        }
    }

    pair<double, vector<int> > ret(INF, vector<int>()), tmp;
    for(int i=0;i<n;i++){
        tmp = solve(1 << i, i, w[i]);
        if(tmp.first < ret.first){
            ret = tmp;
        }
    }
    reverse(ret.second.begin(), ret.second.end());

    for(int i=0;i<ret.second.size()-1;i++){
        cout << ret.second[i] << " ";
    }
    cout << ret.second.back() << endl;
    return 0;
}

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

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

	int res = 0;
	for (int i = 1; i < N; i++){
		if (p[i] == i){
			int tmp = p[i];
			p[i] = p[i+1];
			p[i+1] = tmp;
			res++;
		}
	}
	if (p[N] == N) res++;

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define pf push_front
#define pii pair <int, int>
#define all(vv) (vv).begin(), (vv).end()
#define time cerr << '\n' << (double)clock()/CLOCKS_PER_SEC << '\n'; return 0;
#define get(vv, times) for(int ii = 0; ii < times; ++ii) {int jj; cin >> jj; (vv).pb(jj);}

int n;
map <string, int> mp;
priority_queue <string, vector <string>, greater <string> > pq;

int32_t main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int i = 0; i < n; ++i) {
		string x; cin >> x;
		++mp[x];
	}
	int mx = -1e18l;
	for(auto it:mp) {
		mx = max(it.second, mx);
	}
	for(auto it:mp) {
		if (it.second == mx) {
			pq.push(it.first);
		}
	}
	int a = pq.size();
	for(int i = 0; i < a; ++i) {
		cout << pq.top() << '\n';
		pq.pop();
	}
	time
}

Measured memory_bytes: 27256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

  int n, a[110];
  cin >> n;
  for(int i=0; i<n; i++){
    cin >> a[i];
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0){
        cout << "DENIED" << endl;
        return 0;
      }
    }
  }
  cout << "APPROVED" << endl;

	return 0;
}

Measured memory_bytes: 256
/**
    * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0003
    */
  object Main {
    def main(args: Array[String]): Unit = {
      val N = io.StdIn.readInt()
      Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null).take(N)
        .map(_.split(" +").map(_.toInt) match { case Array(a, b, c) => (a, b, c) })
        .map { case (a, b, c) => isRightTriangle(a, b, c) }
        .map(if (_) "YES" else "NO")
        .foreach(println)
    }
  
    def isRightTriangle(x: Int, y: Int, z: Int): Boolean = {
      val (a, b, c) = Seq(x, y, z).sorted match {
        case Seq(_a, _b, _c) => (_a, _b, _c)
      }
      math.pow(a.toDouble, 2) + math.pow(b.toDouble, 2) == math.pow(c.toDouble, 2)
    }
  
  }

Measured memory_bytes: 47604
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstdlib>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define MOD 1000000007

using namespace std;

typedef long long int ll;

const ll INF=(ll)1e18;

int main(){
  ll N, K;
  cin >> N >> K;

  int a[2005];
  REP(i,N)cin >> a[i];

  ll t = 0;
  REP(i,N)FOR(j,i+1,N){
    if(a[i] > a[j])t+=1;
  }
  ll s = 0;
  REP(i,N)REP(j,N){
    if(a[i] > a[j])s+=1;
  }
  t %= MOD;
  s %= MOD;


  cout << ((t * K) % MOD +  (((K * (K-1) / 2) % MOD) * s )) % MOD << endl;

}



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 k = sc.nextInt();
        String s = sc.next();
        String ans = s;
        if(s.length() > k) {
            ans = s.substring(0, k) + "...";
        }
        // 出力
        System.out.println(ans);
    }
}


Measured memory_bytes: 38668
n,a,b= map(int, input().split())

if (b-a)%2==0:
    print((b-a)//2)

elif b-a==1:
    print(min(b-1,n-a))

else:
    x=-(-(b-a)//2)
    print(min(x+a-1,x+n-b))

Measured memory_bytes: 38384
#include <stdio.h>
#include <vector>
#include <stack>
#include <functional>
#include <numeric>
#include <complex>
#include <queue>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <assert.h>
#include <cstring>
#include <sstream>
#include <string>
#include <algorithm>
#include <iostream>
 
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define X first
#define Y second
#define pb(x) push_back(x)
#define FOR(k, n) for (int k = 0; k < n; k++)
#define FORN(k, s, n) for (int k = s; k < n; k++)
#define debug(x) printf("x = %d\n", x);
#define debug2(x, y) printf("x = %d, y = %d\n", x, y);
#define debug3(x, y, z) printf("x = %d, y = %d, z = %d\n", x, y, z);
#define debug4(x, y, z, t) printf("x = %d, y = %d, z = %d, t = %d\n", x, y, z, t);
 
#pragma warning(disable : 6031)
#pragma warning(disable : 4101)
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
typedef long double ld;
typedef complex<double> cd;
 
const int INF = 1e9;
const long long LINF = 1e18;
const double PI = acos(-1);
 
// Solution

const int MAXN = 100005;

int n, m, a, b, tot;
vector<int> A[MAXN];
multiset<int, greater<int>> S;

int main() {
    scanf("%d%d", &n, &m);

    for (int i = 0; i < n; i++) {
        scanf("%d%d", &a, &b);
        A[a].push_back(b);
    }

    for (int i = 1; i <= m; i++) {
        for (int k : A[i]) {
            S.insert(k);
        }

        if (!S.empty()) {
            tot += *S.begin();
            S.erase(S.begin());
        }
    }

    printf("%d\n", tot);

    return 0;
}

Measured memory_bytes: 7808
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int k,a,b;
    scanf("%d%d%d",&k,&a,&b);
    int x=a%k;
    if(x==0){
        printf("OK");
    }else{
        a+=(k-x);
        if(a<=b){
            printf("OK");
        }else{
            printf("NG");
        }
    }
    
}

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

using namespace std;

int main()
{
    vector<int>v;
    int i,a;
    for(i=0;i<10;i++)
    {
        cin >> a;
        v.push_back(a);
    }
    sort(v.rbegin(),v.rend());
    for(i=0;i<3;i++)
    {
        cout << v[i] <<endl;
    }
    return 0;
}



Measured memory_bytes: 3168
import java.util.*;
    public class Main {
     
    	public static void main(String[] args) {
    			
    		Scanner scan=new Scanner(System.in);
    		
    		String s1=scan.next().toUpperCase();
    		String s2=scan.next().toUpperCase();
    		String s3=scan.next().toUpperCase();
    		
    		System.out.print(s1.charAt(0));
    		System.out.print(s2.charAt(0));
    		System.out.print(s3.charAt(0));

    		
    	
  
    				
    	}
     
    }

Measured memory_bytes: 21588
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
const int INF = 1e18;

using namespace std;

int calc(int a,int b){
  if(b == 0) return 1;
  if(b%2 == 0){
    int d = calc(a,b/2);
    return (d*d)%MOD;
  }
  return (a*calc(a,b-1))%MOD;
}

int comb(int n,int r){
  int tmp = 1,ttmp = 1;
  for(int i = n;i >= n-r+1;i--) tmp = (tmp*i)%MOD;
  for(int i = 1;i <= r;i++) ttmp = (ttmp*i)%MOD;
  return (tmp*calc(ttmp,MOD-2))%MOD;
}

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

  vector<int> A(N);
  REP(i, N) cin >> A[i];
  vector<int> vec(100);
  REP(i, N){
    vector<int> cnt;
    while(A[i] > 0){
      cnt.push_back(A[i]&1);
      A[i] /= 2;
    }

    REP(i, cnt.size()){
      vec[i] += cnt[i];
    }
  }

  int ans = 0;
  REP(i, 100){
    if(vec[i]){
      int res = N-vec[i];
      res *= vec[i];
      res %= MOD;
      REP(k, i){
        res *= 2;
        res %= MOD;
      }
      ans += res;
    }
    ans %= MOD;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 2560
s = input()
n = len(s)
ans = 0

for i in range(n):
    if i % 2 == 0:
        if s[i] != 'L':
            ans += 1
    else:
        if s[i] != 'R':
            ans += 1
            
if ans == n:
    print('Yes')
else:
    print('No')

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

int p;
int up,uq,dp,dq;

void sternBrocot(int n,int pl=0,int ql=1,int pr=1,int qr=0) {
    int pm = pl + pr,qm = ql + qr;
    if(pm > n || qm > n) return;

    if(pm > sqrt(p)*qm) {
        if(up*qm - pm*uq > 0) {
            up = pm, uq = qm;
        }
        sternBrocot(n, pl, ql, pm, qm);
    }else{
        if(pm*dq - dp*qm > 0) {
            dp = pm, dq = qm;
        }
        sternBrocot(n, pm, qm, pr, qr);
    }
}

int main() {
    int n;
    while(cin>>p>>n, p|n) {
        up = p, uq = 1, dp = 0, dq = 1;
        sternBrocot(n);

        cout<<up<<"/"<<uq<<" "<<dp<<"/"<<dq<<endl;
    }
}

Measured memory_bytes: 0