akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin>>s;
	if(s[s.length()-1]=='s')
	cout<<s<<"es"<<endl;
	else
	cout<<s<<"s"<<endl;
	return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<string>
#include<set>

const long long int MOD=1e9+7;

using namespace std;
int n, q, check[200009];
long long c[200009], ans[200009];
vector<int> v[200009];

int main(){
    cin >> n >> q;
    c[0]=0;ans[0]=0;
    for(int i=0;i<n-1;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        v[a].push_back(b);
        v[b].push_back(a);
        c[i+1]=0;
        ans[i+1]=0;
    }
    for(int i=0;i<q;i++){
        int p, x;
        cin >> p >> x;
        p--;
        c[p]+=x;
    }
    queue<pair<long long , long long >> Q;
    Q.push(make_pair(0, 0));
    while(!Q.empty()){
        long long root=Q.front().first,cur=Q.front().second;
        Q.pop();
        check[root] = 1;
        cur += c[root];
        ans[root]=cur;
        for(int i=0;i<v[root].size();i++){
            if(check[v[root][i]]==0){
                Q.push(make_pair(v[root][i], cur));
            }
        }
    }
    for(int i=0;i<n;i++){
        cout << ans[i] << ' ';
    }
    cout << endl;
}



Measured memory_bytes: 21108
#include<iostream>
#include<stdio.h>
#include<math.h>

using namespace std;

int main()
{
    int N, a, b, c, d, Answer,x,pattern;

    cin >> N;

    a = N / 1000;
    b = (N - a * 1000) / 100;
    c = (N - a * 1000 - b * 100) / 10;
    d = N - a * 1000 - b * 100 - c * 10;

    for (x = 1; x < 9; x++)
    {
        switch (x)
        {
        case 1:
            Answer = a + b + c + d;
            pattern = 1;
            break;
        case 2:
            Answer = a + b + c - d;
            pattern = 2;
            break;
        case 3:
            Answer = a + b - c + d;
            pattern = 3;
            break;
        case 4:
            Answer = a - b + c + d;
            pattern = 4;
            break;
        case 5:
            Answer = a + b - c - d;
            pattern = 5;
            break;
        case 6:
            Answer = a - b + c - d;
            pattern = 6;
            break;
        case 7:
            Answer = a - b - c + d;
            pattern = 7;
            break;
        case 8:
            Answer = a - b - c - d;
            pattern = 8;
            break;
        default:
            break;
        }
        
        if (Answer == 7)
        {
            break;
        }
    }

    if (pattern == 1)
    {
        cout  << a << "+" << b << "+" << c << "+" << d << "=" << Answer << "\n" << endl;
    }
    else if (pattern == 2)
    {
        cout  << a << "+" << b << "+" << c << "-" << d << "=" << Answer << "\n" << endl;
    }
    else if (pattern == 3)
    {
        cout << a << "+" << b << "-" << c << "+" << d << "=" << Answer << "\n" << endl;
    }
    else if (pattern == 4)
    {
        cout << a << "-" << b << "+" << c << "+" << d << "=" << Answer << "\n" << endl;
    }
    else if (pattern == 5)
    {
        cout << a << "+" << b << "-" << c << "-" << d << "=" << Answer << "\n" << endl;
    }
    else if (pattern == 6)
    {
        cout << a << "-" << b << "+" << c << "-" << d << "=" << Answer << "\n" << endl;
    }
    else if (pattern == 7)
    {
        cout << a << "-" << b << "-" << c << "+" << d << "=" << Answer << "\n" << endl;
    }
    else if (pattern == 8)
    {
        cout << a << "-" << b << "-" << c << "-" << d << "=" << Answer << "\n" << endl;
    }

}

Measured memory_bytes: 888
#include <cstdio>
#include <cstring>
#include <algorithm>
int pri[33] = {0, 2, 3, 5, 7, 11, 13, 17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
int num[34];
int n, cnt = 25, ans = 0;
int main(){
	scanf("%d", &n);
	for(int i = 2; i <= n; i++){
		int k = i;
		for(int j = 1; j <= cnt; j++)
			while(k % pri[j] == 0) k /= pri[j], num[j]++;
	}
	for(int i = 1; i <= cnt; i++) if(num[i] >= 74) ans++;
	int a = 0, b = 0;
	for(int i = 1; i <= cnt; i++){
		if(num[i] >= 24) a++;
		if(num[i] >= 2 && num[i] < 24) b++;
	}
	ans += a * (a - 1)+ b * a;
	a = 0, b = 0;
	for(int i = 1; i <= cnt; i++){
		if(num[i] >= 14) a++;
		if(num[i] >= 4 && num[i] < 14) b++;
	}
	ans += a * (a - 1) + b * a;
	a = 0, b = 0;
	for(int i = 1; i <= cnt; i++){
		if(num[i] >= 4) a++;
		if(num[i] >= 2 && num[i] < 4) b++;
	}
	ans += a * (a - 1) * (a - 2) / 2 + a * (a - 1) / 2 * b;
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define PB push_back
#define MP make_pair
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)

int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> a(n), b(m), asum(n + 1), bsum(m + 1);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> b[i];
  }

  asum[0] = bsum[0] = 0;
  for (int i = 1; i < n + 1; i++)
  {
    asum[i] = asum[i - 1] + a[i - 1];
  }
  for (int i = 1; i < m + 1; i++)
  {
    bsum[i] = bsum[i - 1] + b[i - 1];
  }

  int ans = 0, j = m;

  for (int i = 0; i < n + 1; i++)
  {
    if (asum[i] > k)
      break;
    while (bsum[j] > k - asum[i])
    {
      j--;
    }
    ans = max(ans, (i + j));
  }

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


Measured memory_bytes: 9604
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;                                                                                                
int main(){                                                                                                  
    long long n, h, i;
    long long t = 0;   
    cin >> n >> h;
    vector <long long> a(n + 1);
    vector <long long> b(n + 1);
    for( i = 0 ; i < n ; i = i + 1 ){
         cin >> a.at(i) >> b.at(i);
    }
    sort( a.rbegin(), a.rend() );
    sort( b.rbegin(), b.rend() );
    for( i = 0 ; i < n ; i = i + 1 ){
        if( 0 < h && b.at(i) > a.at(0) ){
            h -= b.at(i);
            t += 1;
        }
        if( 0 >= h ){
            cout << t << endl;
            return 0;
        }
    }
    if( h % a.at(0) == 0 ){
        t += h / a.at(0);
    }
    else t += ( h / a.at(0) ) + 1;        
    cout << t << endl;
    return 0;
}

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

using namespace std;

int main(){
  string x;
  int y;
  cin >> x;
  y = stoi(x);
  if(y / 100 == 0 && y % 100 == 0){
    cout << "NA" << endl;
  }
  else if(y / 100 <= 12 &&  (y % 100) <= 12 && y / 100 != 0 && y % 100 != 0) {
    cout << "AMBIGUOUS" << endl;
  }
  else if(y / 100 <= 12 && y / 100 != 0){
    cout << "MMYY" << endl;
  }
  else if((y % 100) <= 12 && y % 100 != 0){
    cout << "YYMM" << endl;
  }
  else{
    cout << "NA" << endl;
  }

  return 0;
}


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

using namespace std;

template<typename T>
class Dijkstra {
public:
  int n;
  T INF = numeric_limits<T>::max();
  vector< vector< pair<int,T> > > g;
  
  Dijkstra(int _n) : n(_n) {
    g.resize(n);
  }

  void add_edge(int u, int v, T w) {
    assert(0 <= u && u < n && 0 <= v && v < n);
    assert(w >= 0);
    g[u].emplace_back(v, w);
  }

  vector<T> short_path(int s) {
    vector<T> dis(n, INF);
    set< pair<T,int> > bag;
    bag.insert(make_pair(0, s));
    while (bag.size()) {
      int u, v;
      T w, cost;
      tie(cost, u) = *bag.begin();
      bag.erase(bag.begin());
      if (dis[u] > cost) {
        dis[u] = cost;
        for (auto i : g[u]) {
          tie(v, w) = i;
          bag.insert(make_pair(w + cost, v));
        }
      }
    }
    return dis;
  }
};

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

  int n, m;
  cin >> n >> m;
  Dijkstra<long long> g(n);
  for (int i = 0; i < n - 1; i++) {
    g.add_edge(i + 1, i, 0);
  }

  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--;
    g.add_edge(u, v, w);
  }

  long long ans = g.short_path(0)[n - 1];
  cout << (ans == g.INF ? -1 : ans) << '\n';
  return 0;
}
 


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

string s;

int main(){
	cin >> s;
	sort(ALL(s));
	bool f = true;
	rep(i,s.size()-1){
		if(s[i] == s[i+1])f = false;
	}
	if(f)cout << "yes" << endl;
	else cout << "no" << endl; 
}

Measured memory_bytes: 256
using	System;

class Program
{
	public static void Main()
	{
		int a,b,c;

		for(a=1;a<=9;a++)
		{
			for(b=1;b<=9;b++)
			{
				c = a*b;

				Console.WriteLine("{0}x{1}={2}",a,b,c);
			}
		}
	}
}

Measured memory_bytes: 9088
n=int(input())
m=len(str(n))
k=int(input())
def c(n,m):
    import math
    if n-m<0 or m<=0:
        return 0
    return(math.factorial(n)//math.factorial(n-m)//math.factorial(m))
def f(m,k):
    return c(m,k)*9**(k)
#ans=f(m-1,k)
#ans+=f(m-1,k-1)*(int(str(n)[0])-1)

def slove(n,k):
    if k==0:
        return 0
    m=len(str(n))
    t=0
    t+=f(m-1,k)
    t+=f(m-1,k-1)*(int(str(n)[0])-1)
    if k==1:
        t+=int(str(n)[0])
    if n>9:
        t+=slove(int(str(n)[1:]),k-1)
    else:
        if k==1:
            return n
    return t

print(slove(n,k))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define infi 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////
	int c[1000001];

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	int ans=0;
	int a[n+1];
	for(int i=1;i<=n;++i){
		cin>>a[i];
		c[a[i]]++;
	}
	for(int i=1;i<=n;++i){
		c[a[i]]--;
		int fl=1;
		for(int j=1;j*j<=a[i];++j){
			if(a[i]%j==0){
				if(c[j]||c[a[i]/j]){
					fl=0;
				}
			}
		}
		ans+=fl;
		c[a[i]]++;
	}
	cout<<ans;
	#ifdef ANIKET_GOYAL
		// cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

Measured memory_bytes: 12916
while true
  n = gets.to_i
  break if n==0

  s = 2*n
  x = 2  
  ptn = 0
  while x<=n
    if s%x == 0
      y = s/x
      l2 = y-x+1
      ptn += 1 if l2>0 && l2%2==0
    end
    x += 1
  end

  puts ptn
end

Measured memory_bytes: 8660
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
using pint = pair<int,int>;
using vec = vector<int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
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; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
const int mod = 1000000007;
struct mint {
    int64_t x;
    mint(int64_t x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(int64_t t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    //for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    ll n;cin>>n;
    vec h(n);
    rep(i,n) cin>>h[i];
    vll dp(n+1,INF);
    dp[0]=0;
    rep(i,n){
        chmin(dp[i+1],dp[i]+abs(h[i+1]-h[i]));
        if(i+2<n)chmin(dp[i+2],dp[i]+abs(h[i+2]-h[i]));
    }

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

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

using namespace std;

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

	if (b < a)
	{
		cout << "GREATER" << endl;
	}
	else if (b == a)
	{
		cout << "EQUAL" << endl;
	}
	else
	{
		cout << "LESS" << endl;
	}
}


Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 03/14/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll a,b,c; cin>>a>>b>>c;
  ll l = 4*a*b;
  ll r = (c-a-b)*(c-a-b);
  bool ans = (c-a-b)>0 and l<r;
  cout << (ans ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
using lint=long long;
using lubl=long double;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    lint n,k,c;std::cin>>n>>k>>c;
    std::string s;std::cin>>s;
    if(c==0){
        if(k<std::count(ALL(s),'o'))return 0;
        for(lint i=0;i<n;i++){
            if(s.at(i)!='o')continue;
            std::cout<<i+1<<'\n';
        }
        return 0;
    }
    std::vector<std::vector<lint>>a(2,std::vector<lint>(n));
    for(lint i=0;i<2;i++){
        auto&&v=a.at(i);
        lint prv=-c-1;
        for(lint j=0;j<n;j++){
            v.at(j)=j?v.at(j-1):0;
            if(c+1<=j-prv&&s.at(j)=='o'){
                v.at(j)++;
                prv=j;
            }
        }
        std::reverse(ALL(s));
    }
    std::reverse(ALL(a.at(1)));
    std::vector<lint>ness(n+1);
    for(lint i=-c;i<n;i++){
        if(k<=(0<=i?a.at(0).at(i):0ll)+(i+c+1<n?a.at(1).at(i+c+1):0ll)){
            ness.at(std::max(0ll,i+1))++;
            ness.at(std::min(n,i+c+1))--;
        }
    }
    std::partial_sum(ALL(ness),ness.begin());
    for(lint i=0;i<n;i++){
        if(s.at(i)=='o'&&!ness.at(i)){
            std::cout<<i+1<<'\n';
        }
    }
}


Measured memory_bytes: 5268
//#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;
}
int32_t main()
{
    IOS

	int k;
	cin>>k;
	map<int,int> m;
	int c=0;
	int rem=0;
	while(1)
	{
		if(m[rem])
		{
			cout<<-1;
			return 0;
			break;
		}
		m[rem]=1;
		rem=(rem*10+7)%k;
		c++;
		if(rem==0)
			break;
	}
	cout<<c;

}



Measured memory_bytes: 66088
def gcd(x, y):
	if y == 0: return x
	else: return gcd(y, x%y)

A, B, K = map(int, raw_input().split())

g = gcd(A, B)
cnt = 1

while cnt != K:
	g -= 1
	if A % g == 0 and B % g == 0:
		cnt += 1

print g

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long N,K;
  cin>>N>>K;
  long long ans=1;
  while(1){
  N=N/K;
    if(N==0)break;
    ans++;
    
  }
  cout<<ans<<endl;
  
  return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        long a[] = new long[6];
        long min = 0;
        long sum = 0;

        for (int i = 0; i < 6; i++) {
            a[i] = scan.nextLong();
        }

        min = a[0];


        for(int i = 1; i < 6 ; i++){
            if((a[i] <= min) ){
                min = a[i];
            }
        }

        sum = 5 + ((a[0] + min - 1)/min) -1 ;
        System.out.println(sum);

    }
}

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

using namespace std;

string s[] = {"Sunny", "Cloudy", "Rainy"};

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

	string x;
	cin >> x;
	int cnt = 0;
	for(int i = 0; i < 3; i++) {
		if(s[i] == x) cnt = i;
	}
	cout << s[++cnt % 3] << "\n";

	return 0;
}


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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define COUNT(i, n) for(int i = 1; i <= n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
 
using namespace std; 

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string Q[2] = {"JOI", "IOI"};

int main(void){
    size_t ind;
    for(string in; cin >> in;)
        rep(i, 2){
            int cnt = 0;
            for(; ~(ind = in.find(Q[i])); cnt++) in[ind] = '.';
            cout << cnt << endl;
        }

    return 0;
}

Measured memory_bytes: 1208
n = int(input())
seq = []
maxi = 0
secondmax = 0
double = 0
for i in range(n):
    num = int(input())
    seq.append(num)
    if num > maxi:
        secondmax = maxi
        maxi = num
        double = 0
    elif num == maxi:
        double += 1
    elif secondmax < num < maxi:
        secondmax = num

for i in range(n):
    if seq[i] == maxi and double != 0:
        print(maxi)
    elif seq[i] == maxi and double == 0:
        print(secondmax)
    else:
        print(maxi)

Measured memory_bytes: 13204
k = int(input())
s = list(input())
an_lis = []
if len(s) <= k:
    ans = "".join(s)
    print(ans)
else:
    for i in range(k):
        an_lis.append(s[i])
    an_lis.append("...")
    ans = "".join(an_lis)
    print(ans)


Measured memory_bytes: 61936
import java.util.Scanner;

class Main{
  static final int M = 1046527;

  static long getKey(String str){
    long key = 0;
    int p = 1;
    for(int i = 0; i < str.length(); i++){
      switch(str.charAt(i)){
        case 'A' : {key += (1 * p);} break;
        case 'C' : {key += (2 * p);} break;
        case 'G' : {key += (3 * p);} break;
        case 'T' : {key += (4 * p);} break;
      }
      p *= 5;
    }
    return key;
  }

  static int h1(long key){
    return (int)(key % M);
  }

  static int h2(long key){
    return (int)(1 + (key % (M - 1)));
  }

  static int h(String str, int i){
    return (h1(getKey(str)) + i * h2(getKey(str))) % M;
  }

  static void insert(String[] s, String str){
    int i = 0;
    while(true){
      int j = h(str, i);
      if(s[j] == null){
        s[j] = str;
        return;
      }
      else
        i++;
    }
  }

  static boolean find(String[] s, String str){
    int i = 0;
    while(true){
      int j = h(str, i);
      if(s[j] == null || i > M)
        return false;
      else if(s[j].equals(str))
        return true;
      else
        i++;
    }
  }

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

    int n = stdIn.nextInt();
    boolean[] ans = new boolean[n];
    int find_count = 0;

    for(int i = 0; i < n; i++){
      String order = stdIn.next();
      String str = stdIn.next();
      if(order.charAt(0) == 'i')
        insert(s, str);
      else{
        ans[find_count++] = find(s, str);
      }
    }

    for(int i = 0; i < find_count ; i++){
      if(ans[i])
        System.out.println("yes");
      else
        System.out.println("no");
    }

  }
}

Measured memory_bytes: 257632
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}

inline int mini(int a,int b,int c,int d)
{
    return min(a,min(b,min(c,d)));
}
 main()

{
    fast
    int q,h,s,d;
    cin>>q>>h>>s>>d;
    int n;
    cin>>n;
    int yo=n/2;
    int x=q*8;
    int y=h*4;
    int z=s*2;
    int mn=mini(x,y,z,d);
    int ses=mn*yo;
    n=n%2;
    x=q*4;
    y=h*2;
    z=s;
    mn=min(x,min(y,z));
    ses+=(mn*n);
    cout<<ses<<endl;
    return 0;

}





































Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstring>
#include <cassert>
#include <unordered_set>
using namespace std;
#define rep(i,a,n) for (int i=a;i<(int)(n);i++)
#define per(i,a,n) for (int i=(n)-1;i>=(int)(a);i--)
template<typename T> ostream& operator<<(ostream& s, vector<T> t) {rep(i, 0, t.size()) s << (i ? " " : "") << t[i]; return s;}
template<typename T> istream& operator>>(istream& s, vector<T> &t) {rep(i, 0, t.size()) s >> t[i]; return s;}
template<typename T, typename U> ostream& operator<<(ostream& s, pair<T, U> t) {s << "(" << t.first << "," << t.second << ")"; return s;}
template<typename T, typename U> istream& operator>>(istream& s, pair<T, U> &t) {s >> t.first >> t.second; return s;}
typedef long long ll;

string alphabet = "abcdefghijklmnopqrstuvwxyz";

int main() {
    set<char> letters(alphabet.begin(), alphabet.end());

    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.size();
    vector<int> lens(n+1);
    lens[n] = 1;
    set<char> avail = letters;
    per(i,0,n) {
        lens[i] = lens[i+1];
        avail.erase(s[i]);
        if(avail.empty()) {
            lens[i]++;
            avail = letters;
        }
    }

    string res = "a";
    avail = letters;
    rep(i, 0, n) {
        avail.erase(s[i]);
        // cout << s[i] << " " << lens[i] << " " << res << endl;
        if(s[i] == res.back()) {
            if(res.size() + lens[i+1] <= lens[0]) {
                // cout << "y " << i << endl;
                res += "a";
                avail = letters;
                // for(auto x : avail) cout << x << " "; cout << endl;
            } else {
                assert(!avail.empty());
                res.back() = *avail.begin();
            }
        }
    }
    cout << res << endl;
}


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

int main(void) {
int h, w, i, j = 0;
char str1[51][51];
int hoge = 0;
std::cin >> h >> w;

for (i = 0; i < h; i++) {
  for (j = 0; j < w; j++) {
    std::cin >> str1[i][j];
  }
}

for (i = 0; i < h; i++) {
  for (j = 0; j < w; j++) {
    hoge = 0;
    if (str1[i][j] == '#') {

      if (str1[i + 1][j] == '.') {
        hoge++;
        }
      if (str1[i - 1][j] == '.') {
        hoge++;
        }
        if (str1[i][j + 1] == '.') {
          hoge++;
        }
        if (str1[i][j - 1] == '.') {
          hoge++;
        }
        if (hoge == 4) {
          std::cout << "No" << '\n';
          return 0;
        }

      }
    }
  }
std::cout << "Yes" << '\n';
return 0;
}


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

int n;
vector<int> out[200010];
int in[200010];
int cycle[200010];
int grundy[200010];
int st = -1;
const int CYCLE = 42;

int dfs(int x) {
	cycle[x] = 1;
	for(int i : out[x]) {
		if(cycle[i] == 1) {
			st = i;
			cycle[x] = CYCLE;
			return CYCLE;
		}
		else if(cycle[i] == 0) {
			if(dfs(i) == CYCLE) {
				cycle[x] = CYCLE;
				if(x == st) return 0;
				else return CYCLE;
			}
		}
	}
	cycle[x] = 2;
	return 0;
}

int getgrundy(int x) {
	set<int> s;
	for(int i : out[x])
		if(cycle[i] != CYCLE)
			s.insert(getgrundy(i));
	int ans = 0;
	auto it = s.begin();
	while(it != s.end()) {
		if(*it == ans) {
			++ans;
			++it;
		}
		else return grundy[x] = ans;
	}
	return grundy[x] = ans;
}

bool chk(int x, int val, int res) {
	if(x == st) return res == val;
	int nxt = -1;
	for(int i : out[x]) {
		if(cycle[i] == CYCLE) {
			nxt = i;
		}
	}
	return chk(nxt, grundy[nxt] + (grundy[nxt] == val), res);
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	memset(cycle, 0, sizeof cycle);
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		--x;
		out[x].push_back(i);
		in[i] = x;
		if(x < i and in[x] == i) {
			st = i;
			cycle[x] = cycle[i] = CYCLE;
		}
	}
	for(int i = 0; st == -1 and i < n; ++i) if(cycle[i] == 0) dfs(i);
	for(int i = 0; i < n; ++i) if(cycle[i] == CYCLE) getgrundy(i);
	int nxt;
	for(int i : out[st]) {
		if(cycle[i] == CYCLE) {
			nxt = i;
		}
	}
	if(st == nxt or chk(nxt, grundy[nxt] + (grundy[st] == grundy[nxt]), grundy[st])) cout << "POSSIBLE" << endl;
	else if (chk(nxt, grundy[nxt] + ((grundy[st] + 1) == grundy[nxt]), grundy[st] + 1)) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;

}


Measured memory_bytes: 20352
n = input()
p = list(map(int, input().split()))
result = 0
i = 1
for index, v in enumerate(p):
    if index != i:
        continue
    else:
        if len(p) >= index+2:
            a = p[index-1]
            b = p[index]
            c = p[index+1]
            if (a > b and b > c) or (b > a and c > b):
                result += 1
    i += 1
print(result)


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

int cnt[300];

main(){
  
  string A;
  
  cin>>A;

  int ans=1;
  
  for(int i=0;i<A.size();i++){
    
    cnt[A[i]]++;
    
    ans+=(i+1)-cnt[A[i]];
    
  }

  cout<<ans<<endl;
  
}


Measured memory_bytes: 640
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename M>
void warshallFloyd(M &m, const int &n) {
  rep(k, n) rep(i, n) rep(j, n) cmin(m[i][j], m[i][k] + m[k][j]);
}

void solve() {
  int n;
  while (cin >> n, n) {
    vvi t(10, vi(10));
    rep(i, 10) rep(j, 10) t[i][j] = i == j ? 0 : INF;
    set<int> s;
    rep(i, n) {
      int a, b, c;
      cin >> a >> b >> c;
      s.insert(a), s.insert(b);
      t[a][b] = t[b][a] = c;
    }
    vi v(s.size());
    copy(all(s), v.begin());
    warshallFloyd(t, 10);
    int ms = INF, mp;
    rep(i, 10) {
      int s = 0;
      for (int j : v) s += t[i][j];
      if (cmin(ms, s)) mp = i;
    }
    cout << mp << ' ' << ms << endl;
  }
}

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

int main(){
	long long a,b;
	cin >> a >> b;
	if( a <= 0 and b >= 0 ){
		cout << "Zero" << endl;
	}else if( a > 0 ){
		cout << "Positive" << endl;
	}else{
		int x = abs(b - a) + 1;
		if( x % 2 ) cout << "Negative" << endl;
		else cout << "Positive" << endl;
	}
}

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

int main(){
	string s;
	cin >> s;
	int count = 0;
	char now = s[0];
	for(int i = 1; i< s.size(); i++) {
		if(s[i] == now)
			continue;
		now = s[i];
		count++;
	}
	cout << count << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	string s;
	cin >> s;
	int n = s.length();
	int a[n + 1];
	for(int i = 1;i <= n;i++)
		a[i] = s[i - 1] - '0';
	int prev = 0;
	for(int i = 1;i <= n;i++)
		prev = (prev + a[i]) % 9;
	if(prev)
		cout << "No";
	else
		cout << "Yes";
	return 0;
}

Measured memory_bytes: 4488
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
int main() {
    ll n;
    cin >> n;

    vl d(n);
    rep(i, n) {
        cin >> d[i];
    }
    sort(all(d));

    out(d[n/2] - d[n/2 - 1]);
    re0;
}

Measured memory_bytes: 1024
import itertools
N, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]

def f(y, z):
    return abs(y - z) ** 2
ans = 0
B = tuple(itertools.combinations(A, 2))
for i in range(len(B)):
    accum = 0
    for j in range(D):
        accum += f(B[i][0][j], B[i][1][j])
    if (accum ** 0.5).is_integer():
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LL long long
#define MAXN 200005
#define LL long long
using namespace std;

LL n, ans, a[MAXN];

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

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
int N;
vector<int> route;
vector<vector<int>> graph(1e5+1);
vector<bool>    used(1e5+1, false);

bool dfs(int v){
    if(v == N){
        route.emplace_back(v);
        return true;
    }
    used[v] = true;
    for(auto& itr : graph[v]){
        if(!used[itr] && dfs(itr)){
            route.emplace_back(v);
            return true;
        }
    }
    return false;
}
int main(){
    cin >> N;
    for(int i = 0;i < N-1;i++){
        int ai, bi;
        cin >> ai >> bi;
        graph[ai].emplace_back(bi);
        graph[bi].emplace_back(ai);
    }
    dfs(1);
    reverse(route.begin(), route.end());
    int id = (route.size()-1)/2;
    int a = route[id];
    int b = route[id+1];
    for(int i = 0;i < graph[a].size();i++) if(graph[a][i] == b)  graph[a].erase(graph[a].begin()+i);
    for(int i = 0;i < graph[b].size();i++) if(graph[b][i] == a)  graph[b].erase(graph[b].begin()+i);
    for(int i = 1;i <= N;i++)   used[i] = false;
    queue<int>  que;
    que.push(1);
    int count = 0;
    while(!que.empty()){
        int v = que.front();
        que.pop();
        if(used[v]) continue;
        used[v] = true;
        count++;
        for(auto itr : graph[v])    que.emplace(itr);
    }
    if(count*2 > N) cout << "Fennec" << endl;
    else    cout << "Snuke" << endl;
}

Measured memory_bytes: 11004
package main

import "fmt"

func main() {
	var n, sum int
	fmt.Scan(&n)

	p := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&p[i])
	}

	for i := 1; i < n-1; i++ {
		p1 := p[i-1]
		p2 := p[i]
		p3 := p[i+1]
		if p1 < p2 && p2 < p3 || p1 > p2 && p2 > p3 {
			sum++
		}
	}

	fmt.Println(sum)
}


Measured memory_bytes: 512
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors
  
x = int(input())
lis = make_divisors(x)
flg = False

for i in range(0, len(lis)):

  for j in range(-1000,1000):
    if (j+lis[i])**5 -j**5 ==x:
      ans = str(j+lis[i])+' '+str(j)
      #flg = False
      break


if flg:
  for i in range(0, len(lis)):
    for j in range(-1000,1000):
      if (j+lis[i])**5 -j**5 ==x:
        ans = str(j+lis[i])+' '+str(j)
        break

  
print(ans)

Measured memory_bytes: 9492
n = int(input())
d = list(map(int, input().split()))
d.sort()
ans = min(d)
for i in range(n):
    if i % 2 == 0:
        d[i] = 24-d[i]


for i in range(n):
    for j in range(n):
        if i != j:
            ans = min(ans, abs(d[i]-d[j]))

print(ans)


Measured memory_bytes: 38768
#include <bits/stdc++.h>
    using namespace std;
    #define endl "\n"
    #define fi first
    #define se second
    #define pb push_back
    #define ll long long
    #define ld long double
    #define pii pair<ll,ll>
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define For(i,n) for(ll i=0;i<n;i++)
    #define what(x) cerr << #x << " is " << x << endl;
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;
    
/*.....................................................................................................................*/

    const ll man=(ll)2e5+5,mod=(ll)1e9+7;
    ll add(ll x,ll y) {return (x+y)%mod;}
    ll mult(ll x, ll y){return ((x%mod )* (y%mod)) % mod;}
    long long binpow(long long x, long long p) 
    {
        if (p == 0) {return 1;}
    	if (p == 2 || (p & 1)) {return mult(x, binpow(x, p - 1));}
    	return binpow(binpow(x, p / 2), 2);
    }
    ll modinv(ll a) {return binpow(a,mod-2);}
    double pi=3.141592653589793238462641;
    ll dx[4]={1,-1,0,0},dy[4]={0,0,1,-1};

/*........................................................................................................................*/

signed main()
{
    fast;
    read(a);
    cout<<a*(1+a+a*a)<<endl;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;

	vector<bool> a(1000000001, 0);
	int aa;
	int total = 0;
	for (int i = 0; i < n; i++) {
		cin >> aa;
		if (a[aa] == 1) { a[aa] = 0; total--; }
		else { a[aa] = 1; total++; }
	}
	
	cout << total << endl;
}

Measured memory_bytes: 122368
#include<bits/stdc++.h>
#define ll long long int

using namespace std;
int main()
{
  ll n;
  cin>>n;
  if(n%1000 == 0)
    cout<<"0\n";
  else
    cout<<1000*(n/1000 + 1) - n<<'\n';
  return 0;
}


Measured memory_bytes: 3580
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  long long sum = 0;
  for (int i = 1; i <= n; ++i) {
    if ((i % 3) == 0 ||
        (i % 5) == 0)
      continue;
    sum += i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define ll long long
#define WEIGHTSUM weight + i
#define VALUESUM maxValue[i] + value
using namespace std;
ll maxValue[100005];

int main() {
    ll n, w, weight, value;

    cin >> n >> w;
    for (int i = 1; i <= n; i++) {
        cin >> weight >> value;

        for (int i = w; i >= 0; i--)
            if (WEIGHTSUM <= w) {
                maxValue[WEIGHTSUM] = max(maxValue[WEIGHTSUM], VALUESUM);
                maxValue[w] = max(maxValue[w], VALUESUM);
            }
    }

    cout << maxValue[w];

    return 0;
}


Measured memory_bytes: 4372
n = int(input())
a = list(map(int , input().split()))
# count = 0 if 1 in a else -1
# i = 1
# while i in a:
#   ind = a.index(i)
#   count += ind
#   a = a[ind + 1:]
#   i += 1
# print(count)

ans = []
i = 1
for j in range(n):
  if i == a[j]:
    i += 1
    ans.append(i)

print(n - len(ans) if 1 in a else -1)

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

int num[101];

int count;
void push(int n){
	num[count++]=n;
}

int pop(){
	return num[--count];
}

void calc(char c){
	int a,b;
	a=pop();
	b=pop();
	if(c=='+'){
		push(b+a);
	}else if(c=='-'){
		push(b-a);
	}else{
		push(b*a);
	
	}

}
int main(){
	char c[400];
	int i=0,a,b,flag=0;
	fgets(c,400,stdin);
	count=0;
	int len=strlen(c);

	char x[20];	
	int j=0,m;

	for(i=0;i<len;i++){
		if(c[i]=='+' || c[i]=='-' || c[i]=='*'){
			calc(c[i]);
			flag=1;
		}else if(c[i]<='9' && '0'<=c[i]){
			flag=0;
			x[j]=c[i];
			j++;
		}else if(c[i]==' ' && flag==0){
			push(atoi(x));
			memset(x,' ', 20);
			j=0;
		}
	}	
	
		printf("%d\n", num[0]);
	
	return 0;
}

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

int n; 
set<int> k;
multiset<int> ans1, ans2;

int main(){
	scanf("%d", &n);
	for(int i=0;i<n;i++){
		int tmp; scanf("%d", &tmp);
		ans1.insert(tmp);
	}
	int a = *ans1.begin(), b = *ans1.rbegin();
	for(int i=0;i<n;i++){
		if(i%3==0) ans2.insert(a);
		else if(i%3==1) ans2.insert(b);
		else ans2.insert(a^b);
	}
	if(equal(ans1.begin(), ans1.end(), ans2.begin(), ans2.end())){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = INT64_MAX;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;
using Vi = vector<long long int>;
typedef pair<int, int> P; typedef pair<ll, ll> PLL;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i=0;i<N;i++)
auto max(auto x,auto y){if(x>y){return x;}else{return y;}}
auto min(auto x,auto y){if(x>y){return y;}else{return x;}}
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
typedef vector<vector<ll> > matrix;
void princ(auto x){cout<<x<<" ";}; void print(auto x){cout<<x<<"\n";};
///////////////////////////////////////////////////////////////////////////////////

long double l;

int main(){
    std::cout<<std::fixed<<std::setprecision(10);
    cin>>l;
    double r = l/3.0;
    if(floor(r)==r){
        ll rr = (int)r;
        print(rr*rr*rr);
    }else{
        print(r*r*r);
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int cmp_int(const void *a,const void *b){
  return -(*(int*)a - *(int*)b);
}
int N;
int a[100000];
int main(){
  int i,j;
  int x,y;
  int t;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&a[i]);
  qsort(a,N,sizeof(int),cmp_int);
  
  i=0;
  while(i<N-1 && i+1<a[i+1])i++;
  t=i;
  while(i<N-1 && t<a[i+1]){j++;i++;}
  x=a[t]-t-1;
  y=j;
  //printf("i=%d x=%d y=%d\n",t,x,y);
  if(x%2==0 && y%2==0)printf("Second\n");
  else printf("First\n");
  return 0;
}


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

using ll = long long;

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

    ll a, b;
    cin >> a >> b;

    ll res = 0;
    ll div = 2;
    while (div / 2 <= b) {
        ll a_res = (a / div) * (div / 2);
        ll a_rem = (a % div) - (div / 2);
        if (a_rem > 0){
            a_res += a_rem;
        }
        ll b_res = ((b + 1) / div) * (div / 2);
        ll b_rem = ((b + 1) % div) - (div / 2);
        if (b_rem > 0){
            b_res += b_rem;
        }
        if ((b_res - a_res) % 2 == 1){
            res += div / 2;
        }
        div *= 2;
    }

    cout << res << '\n';

    return 0;
}


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

long modpow(long a, long n, long mod) {
    long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long modinv(long a, long mod) {
    return modpow(a, mod - 2, mod);
}

int main()
{
    int N;
    int A[105];
    cin >> N;
    REP(i, N)
        cin >> A[i];
    bool ans = true;
    REP(i, N){
        if(A[i] % 2 == 0){
            if(A[i] % 3 != 0 && A[i] % 5 != 0)
                ans = false;
        }
    }
    if(ans)
        cout << "APPROVED" << endl;
    else
        cout << "DENIED" << endl;
    return 0;
    
}



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

using namespace std;

int main(){
    int n;
    long long x,t,ans=0;
    scanf("%d %lld",&n,&x);
    vector<long long> a(n);
    for (auto&e:a) scanf("%lld",&e);
    for (int i=1;i<n;i++) {
        if (a[i]+a[i-1]>x) {
            t=a[i]+a[i-1]-x;
            ans+=t;
            a[i]=a[i]-t<0?0:a[i]-t;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=1e6;
vector<int>a(N);
vector<int>b(N);
int n;

int func(vector<int>vx,vector<int>a)
{
    int cnt=0;
    
    do
    {
        cnt++;
        if(a==vx) return cnt;
    }while(next_permutation(a.begin(),a.end()));
    
    return -1;
}

int32_t main()
{
   cin>>n; a.resize(n); b.resize(n);
   vector<int>c;  for(int i=1;i<=n;i++) c.push_back(i);
   for(int i=0;i<n;i++) cin>>a[i];
   for(int i=0;i<n;i++) cin>>b[i];
   cout<<abs(func(a,c)-func(b,c));
   return 0;
}

                        
           
                            

Measured memory_bytes: 15872
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<int(n);i++)
#define FOR(i,n,m) for(int i=n;i<int(m);i++)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
using namespace std;
 
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
 
int vx[]={0,0,-1,1};
int vy[]={1,-1,0,0};
int dx[]={1,0,-1,1,-1,1,0,-1};
int dy[]={1,1,1,0,0,-1,-1,-1};
 
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	
 
const ll mod=1e9+7;
const int INF=INT_MAX/2;

int main(){
	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;
}

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

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
#        for line in sys.stdin:
#            lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    s = lines[0]

    return (s, )


def solve(s, ):

    result = 'Yes'
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
                pass
            else:
                result = 'No'

        if i % 2 == 1:
            if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
                pass
            else:
                result = 'No'


    return result


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()
	

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

using namespace std;

#define pii pair<int,int>
#define point pair<double,double>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI acos(-1)
#define MOD 1e9+7

int main()
{
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
    {
        if(s[i]!=s[s.size()-1-i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
    
	return 0;
}

Measured memory_bytes: 256