akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char ch[111];
int i,j,k,n;
int main(){
	scanf("%s",ch);n=strlen(ch);
	for (i=k=0;i<n-1;i++)
	 if (ch[i]=='A'&&ch[i+1]=='C') k=1;
	puts(k?"Yes":"No");
	return 0;
}

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

#ifdef LOCAL
#include<debug.h>
#else
#define db(...) 21
#endif

#define debug(x) cout << #x << " = " << x << endl;
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define FOR(it, b, e) for (typeof(b) it = (b); it != (e); ++it)
#define MSET(c, v) memset(c, v, sizeof(c))

const int INF = 0x3F3F3F3F; 
const int NEGINF = 0xC0C0C0C0;
const int NULO = -1;
const double EPS = 1e-10;
const ll mod = 998244353;

inline int cmp(double x, double y = 0) 
{  
  if(fabs(x - y) < EPS)
    return 0;
  return x > y ? 1 : -1;
}

ll exp(ll a, ll b)
{
  ll ans = 1;
  while(b)
  {
    if(b & 1)
      ans = (ans * a) % mod;
    a = (a * a) % mod;
    b >>= 1;
  }
  return ans;
}

const int maxn = 2e5 + 10;

string s[maxn];

int main()
{
  int n;
  ios::sync_with_stdio(false);
  map<char, int>mapa;
  cin >> n >> mapa['A'] >> mapa['B'] >> mapa['C'];
  vector<char>ops;
  for(int i = 0; i < n; i++)
  {
    cin >> s[i];
  }

  for(int i = 0; i < n ; i++)
  {
    char a = s[i][0];
    char b = s[i][1];
    if(mapa[a] == 0 && mapa[b] == 0)
    {
      cout << "No\n";
      return 0;
    }
    if(mapa[a] > mapa[b])
      swap(a, b);
    
    if(mapa[a] == 1 && mapa[b] == 1 && i != n-1)
    {
      char nA = s[i + 1][0];
      char nB = s[i + 1][1];
      if(a != nA && a != nB)
        swap(a, b);
    }
    mapa[a]++;
    mapa[b]--;
    ops.push_back(a);
    if(mapa[b] < 0)
    {
      cout << "No\n";
      return 0;
    }
  }

  cout << "Yes\n";
  for(const auto &c : ops)
  {
    cout << c << endl;
  }

  return 0;
}

Measured memory_bytes: 10004
<?php
fscanf(STDIN, "%d", $N);
$a = explode(" ", trim(fgets(STDIN)));
$direction = 0;
$ans = 0;
for ($i = 1; $i < $N; $i++) {
    if ($a[$i-1] === $a[$i]) {
        continue;
    } else {
        $tmp = $a[$i-1] > $a[$i] ? 1 : -1;
        if ($direction === 0) {
            $direction = $tmp;
        } else {
            if ($direction !== $tmp) {
                $direction = 0;
                $ans++;
            }            
        }
    }
}
echo $ans + 1;


Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
char c;
bool ans[20];
int cnt;
int main() {
    c = getchar();
    while (c != '0' && c != '1' && c != 'B')  c = getchar();
    while (c == '0' || c == '1' || c == 'B') {
        if (c == '0') {
            ans[++cnt] = 0;
        } else if (c == '1') {
            ans[++cnt] = 1;
        } else {
            if (cnt) {
                --cnt;
            }
        }
        c = getchar();
    }
    for (int i = 1; i <= cnt; ++i) {
        cout << ans[i];
    }
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int c1, c5, c10, c50, c100, c500,money=0;
    cin >> c1 >> c5 >> c10 >> c50 >> c100 >> c500;
    money = 500 * c500 + 100 * c100 + 50 * c50 + 10 * c10 + 5 * c5 + 1 * c1;
    if (money >= 1000) {
        cout << 1 << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;
using ll = long long;

constexpr int MOD = 1000000007;

class mint {
  int n;
public:
  mint(int n_ = 0) : n(n_) {}
  explicit operator int() { return n; }
  friend mint operator-(mint a) { return -a.n + MOD * (a.n != 0); }
  friend mint operator+(mint a, mint b) { int x = a.n + b.n; return x - (x >= MOD) * MOD; }
  friend mint operator-(mint a, mint b) { int x = a.n - b.n; return x + (x < 0) * MOD; }
  friend mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
  friend mint &operator+=(mint &a, mint b) { return a = a + b; }
  friend mint &operator-=(mint &a, mint b) { return a = a - b; }
  friend mint &operator*=(mint &a, mint b) { return a = a * b; }
  friend bool operator==(mint a, mint b) { return a.n == b.n; }
  friend bool operator!=(mint a, mint b) { return a.n != b.n; }
  friend istream &operator>>(istream &i, mint &a) { return i >> a.n; }
  friend ostream &operator<<(ostream &o, mint a) { return o << a.n; }
};
mint operator "" _m(unsigned long long n) { return n; }

mint dp[61][2][2][2][2];

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  ll L, R; cin >> L >> R;
  dp[0][0][0][0][0] = 1;
  rep(i, 60) rep(j, 2) rep(k, 2) rep(l, 2) rep(m, 2) {
    int x = L >> 59 - i & 1;
    int y = R >> 59 - i & 1;
    int low = j ? 0 : x;
    int high = k ? 1 : y;
    for (int d = low; d <= high; d++) {
      for (int e = low; e <= high; e++) {
        if (!l && d > e) continue;
        if (!m && (d ^ e)) continue;
        if (d == 1 && e == 0) continue;
        dp[i+1][j || d > low][k || e < high][l || d < e][m || d] += dp[i][j][k][l][m];
      }
    }
  }
  mint ans;
  rep(j, 2) rep(k, 2) rep(l, 2) rep(m, 2) ans += dp[60][j][k][l][m];
  cout << ans << endl;
}

Measured memory_bytes: 256
//   Rishabh Agarwal
#include <bits/stdc++.h>
#define F first
#define S second
#define MAX 10000003
using namespace std;

typedef long long int ll;
const ll mod = 1e18;
const ll INF= 1e18;
long double PI=3.1415926;

ll power(ll a,ll b){
    if(b==0){
        return 1;
    }
    ll temp=power(a,b/2)%mod;
    if(b%2==0){
        return (temp*temp)%mod;
    }
    else{
        return ((a*temp)%mod*temp)%mod;
    }
}

ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 

vector<ll>v;
vector<ll>::iterator it;
map<ll,ll>mp;

void primeFactors(ll n)  
{  
    // Print the number of 2s that divide n  
    while (n % 2 == 0)  
    {  
        //cout << 2 << " ";  
        mp[2]++;
        n = n/2;  
    }  
  
    // n must be odd at this point. So we can skip  
    // one element (Note i = i +2)  
    for (ll i = 3; i <= sqrt(n); i = i + 2)  
    {  
        // While i divides n, print i and divide n  
        while (n % i == 0)  
        {  
            //cout << i << " ";  
            mp[i]++;
            n = n/i;  
        }  
    }  
  
    // This condition is to handle the case when n  
    // is a prime number greater than 2  
    if (n > 2){ 
        mp[n]++; 
        //cout << n << " "; 
    } 
}  

ll max(ll a, ll b) { return (a > b)? a : b; } 
  
ll knapSack(ll sum, ll wt[], ll val[], ll n,ll W) 
{ 
   ll i, w; 
   ll K[n+1][sum+1]; 
   //memset(K,INF,sizeof(K));
   for (i = 0; i <= n; i++) 
   { 
       for (w = 0; w <= sum; w++) 
       { 
           K[i][w]=INF;
           if (w==0) 
               K[i][w] = 0; 
           else if(i==0)
                continue;
           else if (val[i-1] <= w) 
                 K[i][w] = min(wt[i-1] + K[i-1][w-val[i-1]],  K[i-1][w]); 
           else
                 K[i][w] = K[i-1][w]; 

         //cout<<K[i][w]<<" ";
       } 
       //cout<<"\n";
   }
   for(ll x=sum; x>=0; x--){
       if(K[n][x]<=W)
            return x;
   } 
}  

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t;
    //cin>>t;
    t=1;
    //ll c=1;
    while(t--){
        ll n,w;
        cin>>n>>w;
        ll we[n],va[n];
        ll sum=0;
        for(ll x=0; x<n; x++){
            cin>>we[x]>>va[x];
            sum=sum+va[x];
        }
        cout<<knapSack(sum,we,va,n,w)<<"\n";
        mp.clear();  
        v.clear();
        //cout<<"Case #"<<c<<": "<<ans<<"\n";
        //c++;
    }
    return 0;
}

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

#define IOS                               \
	ios_base::sync_with_stdio(false); \
	cin.tie(0);                       \
	cout.tie(0);                      \
	cin.exceptions(cin.failbit);
#define int long long int //Comment when Unnecessary
#define ll long long
#define sz(a) (int)((a).size())
#define all(a) a.begin(), a.end()
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto &a : x)
#define pii pair<int, int>
#define vi vector<int>
#define F first
#define S second
#define endl "\n" // Remove on Interactive

const int N = 300009;
const int mod = 1000000007;

int t, n, m;
string s;

int32_t main()
{
	IOS;

	cin >> n >> s;

	int ans = 0;
	int r = 0, g = 0, b = 0;
	rep(i, 0, n)
	{
		if (s[i] == 'B')
		{
			ans += (r * g);
			b++;
		}
		else if (s[i] == 'R')
		{
			ans += (b * g);
			r++;
		}
		else if (s[i] == 'G')
		{
			ans += (r * b);
			g++;
		}
	}

	rep(i, 1, n + 1)
	{
		rep(j, 0, n)
		{
			if ((j + (2 * i)) >= n)
				break;
			int ye = 0;
			rep(k, 0, 3)
			{
				if ((s[j + k * i] == 'R'))
				{
					ye ^= 1;
				}
				else if ((s[j + k * i] == 'G'))
				{
					ye ^= 2;
				}
				else
				{
					ye ^= 4;
				}
			}
			if (ye == 7)
			{
				ans--;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
string s;
ll b;
ll p,m;
ll ans[200005];
int main(void){
    cin>>n>>s;
    if(s=="1"){
        cout<<0<<endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        if(s[i]=='1') b++;
    }
    ll k=1,l=1;
    for(int i=0;i<n;i++){
        p=(p+(s[n-1-i]-'0')*k)%(b+1);
        if(b!=1){
            m=(m+(s[n-1-i]-'0')*l)%(b-1);
            l=(l*2)%(b-1);
        }
        k=(k*2)%(b+1);
    }
    //cout<<p<<" "<<m<<endl;
    k=1,l=1;
    ll c;
    for(int i=n-1;i>=0;i--){
        c=1;
        if(s[i]=='0'){
            ll t=(p+k)%(b+1);
            //cout<<i<<" "<<t<<endl;
            while(t!=0){
                ll a=0;
                ll co=t;
                while(co>0){
                    a+=(co%2);
                    co=co/2;
                }
                t=t%a;
                c++;
            }
        }else{
            if(b==1){
                ans[i]=0;
                continue;
            }
            ll T=(m-l)%(b-1);
            //cout<<i<<" "<<T<<endl;
            if(T<0){
                T+=(b-1);
            }
            while(T!=0){
                ll A=0;
                ll CO=T;
                while(CO>0){
                    A+=(CO%2);
                    CO=CO/2;
                }
                T=T%A;
                c++;
            }
        }
        ans[i]=c;
        k=(k*2)%(b+1);
        if(b!=1){
            l=(l*2)%(b-1);
        }
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<endl;
    }
    
}


Measured memory_bytes: 5276
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,q,color[N],dis[N],v[N],d[N],c[N];
vector<int> e[N];
queue<int> Q;
void check(int v,int d){
	if (dis[v]>=d) return;
	dis[v]=d;Q.push(v);
}
void bfs(int v,int d,int c){
	check(v,d);
	while (!Q.empty()){
		int v=Q.front();Q.pop();
		if (!color[v]) color[v]=c;
		for (int i=0;i<e[v].size();i++) check(e[v][i],dis[v]-1);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	scanf("%d",&q);
	for (int i=1;i<=q;i++) scanf("%d%d%d",&v[i],&d[i],&c[i]);
	for (int i=1;i<=n;i++) dis[i]=-1;
	for (int i=q;i;i--) bfs(v[i],d[i],c[i]);
	for (int i=1;i<=n;i++) printf("%d\n",color[i]);
	return 0;
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
int main(void){
    string S;
    cin >> S;
    int N = S.size();
    vector<pair<int,int>> V(N),W(N);
    bool f = false;
    int j = 0;
    W[0].first = 0;
    for(int i = 1; i < N; i++){
        if(f == true && S[i] == 'R'){
            W[j].second = i-1;
            j++;
            W[j].first = i;
            f = false;
        }
        if(S[i] == 'L' && S[i-1] == 'R'){
            V[j].first = i;
            V[j].second = i-1;
            f = true;
        }
    }
    W[j].second = N-1;
    vector<int> A(N);
    for(int k = 0; k <= j; k++){
        for(int x = W[k].first; x <= W[k].second; x++){
            if(x <= V[k].first){
                if((V[k].first-x)%2 == 0) A[V[k].first]++;
                else A[V[k].second]++;
            }
            else if(x >= V[k].second){
                if((V[k].second-x)%2 == 0) A[V[k].second]++;
                else A[V[k].first]++;
            }
        }
    }
    for(int i = 0; i < N; i++) cout << A[i] << " ";
    cout << endl;
}
   

Measured memory_bytes: 2688
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    int ans = 700;
    imfor(i, s.size()) {
        if (s[i] == 'o') {
            ans += 100;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <math.h>
#include <vector>
#include <list>

using namespace std;
int n;
list<int> adj[101];
int d[101] = {};
int f[101] = {};

void DFS(int v)
{
    static int num = 1;
    d[v] = num++;
    while (!adj[v].empty())
    {
        if (d[adj[v].front()] == 0)
            DFS(adj[v].front());
        adj[v].pop_front();
    }
    f[v] = num++;
}

void print()
{
    for (int i = 1; i <= n; i++)
    {
        printf("%d %d %d\n", i, d[i], f[i]);
    }
}

int main()
{
    int u, k, v;
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> u >> k;
        while (k > 0)
        {
            cin >> v;
            adj[u].push_back(v);
            k--;
        }
    }
    for (int i = 1; i <= n; i++)
        if (d[i] == 0)
            DFS(i);

    print();

    return 0;
}


Measured memory_bytes: 3232
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>


using namespace std;

void Solution()
{
    int n;
    
    cin>>n;
    
    cin.ignore(); // or use cin.get(); ignore() can be used as when you want to input data and segment them by "enter key", if no "ignore()", then it can be seen as the whole data
    
    string str;
    
    while (n--)
    {
        getline(cin, str);
        
        for (int i = 0; i < (int)str.size(); i ++ ) //because size() returned "unsigned int" type, so need to cast to "int"
        {
            if ("Hoshino" == str.substr(i, 7))
            {
                i += 6;
                cout<<"Hoshina";
            }
            else
            {
                cout<<str[i];
            }
        }
        
        cout<<endl;
    }
    
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
int n,k;
string s;
vector<string>can;
int main(){
	ios::sync_with_stdio(false);
	cin >> n >> k;
	char c='z';
	cin >> s;
	for(auto cur:s){
		c=min(c,cur);
	}
	if(k>13){
		for(int i=1; i<=n ;i++){
			cout << c;
		}
		cout << endl;
		return 0;
	}
	string t=s;reverse(t.begin(),t.end());
	string u=s+t;
	if(k==1){
		for(int i=n-1; i<2*n ;i++){
			can.push_back(u.substr(i-n+1,n));
		}
	}
	else{
		for(int i=n; i<2*n ;i++){
			if(u[i]==c) can.push_back(u.substr(i-n+1,n));
		}
		for(int i=2; i<=k ;i++){
			for(auto &cur:can){
				t=cur;
				reverse(t.begin(),t.end());
				u=cur+t;
				int ptr=n;
				while(ptr<2*n && u[ptr]==c) ptr++;
				cur=u.substr(ptr-n,n);
			}
		}
		for(auto& cur:can) reverse(cur.begin(),cur.end());
	}
	string ans=can[0];
	for(auto cur:can) ans=min(ans,cur);
	cout << ans << endl;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N) {
    switch (N%10) {
        case 2:
        case 4:
        case 5:
        case 7:
        case 9:
        cout << "hon" << endl;
        break;
        case 0:
        case 1:
        case 6:
        case 8:
        cout << "pon" << endl;
        break;
        case 3:
        cout << "bon" << endl;
        break;
    }
}

int main() {
    long long N;
    scanf("%lld", &N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
typedef double db;
mt19937 mrand(random_device{}()); 
const ll mod=998244353;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

const int N=201000;
int n,a[N],b[N],u,v;
VI e[N];
ll ret[N];

void dfs(int u,int f) {
	for (auto v:e[u]) {
		if (v==f) continue;
		dfs(v,u);
		a[u]+=a[v];
		b[u]+=b[v];
	}
}

void dfs2(int u,int f) {
	for (auto v:e[u]) {
		if (v==f) continue;
		ret[v]=ret[u]+a[v]-b[v];
		dfs2(v,u);
	}
}

int main() {
	scanf("%d",&n);
	rep(i,1,n) {
		scanf("%d%d",&u,&v);
		e[u].pb(v);
		e[v].pb(u);
	}
	rep(i,1,n+1) scanf("%d",a+i);
	rep(i,1,n+1) scanf("%d",b+i);
	dfs(1,0);
	dfs2(1,0);
	ll x=*min_element(ret+1,ret+n+1);
	ll ans=0;
	rep(i,1,n+1) ans+=ret[i]-x;
	printf("%lld\n",ans);
}



Measured memory_bytes: 18448
import java.util.*;
import java.util.Collections;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    StringBuilder A = new StringBuilder();
    A.append(S.charAt(0));
    A.append(S.length() - 2);
    A.append(S.charAt(S.length() - 1));
    System.out.println(A);
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int get() { int r; cin >> r; return r; }
int n;
string s[1010];
bool b[2000];
signed main() {
	while (cin >> n, n) {
		for0(i, 1500)b[i] = 0;
		for1(i, n)cin >> s[i];
		for (int i = n; i >= 1; i--) {
			int j;
			for (j = 0; s[i][j] == '.'; j++) {
				if (s[i][j + 1] != '.') {
					s[i][j] = '+';
					b[j] = 1;
				}
				else s[i][j] = (b[j] ? '|' : ' ');
			}
			for (; j <= 1500; j++)b[j] = 0;
		}
		for1(i, n)cout << s[i] << endl;
	}
}


Measured memory_bytes: 3780
// Aizu 0267 Triangle of Blocks
// 2017.9.8 bal4u@uu

#include <stdio.h>
#include <math.h>

int b[1503], n;

int isTriNum(int k)
{
	int t = 8*k + 1;
	int x = (int)sqrt(t);
	return (x & 1) && x*x == t;
}

int main()
{
	int i, k, a, sum, ans;

	while (scanf("%d", &n) && n) {
		for (sum = 0, i = 1; i <= n; i++) scanf("%d", &a), b[i] = a, sum += a;
		if (!isTriNum(sum)) { puts("-1"); continue; }
		ans = 0; while (1) {
			if (ans > 10000) { puts("-1"); break; }
			for (i = 1; i <= n; i++) { if (b[i] != i) break; }
			if (i > n) { printf("%d\n", ans); break; }
			for (k = 1, i = 1; i <= n; i++) {
				if (b[i] > 1) b[k++] = b[i]-1;
			}
			b[k] = n, n = k, ans++;
		}
	}
	return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <complex>
#include <iomanip>
using namespace std;
typedef complex<double> P;
typedef vector<P> vec;
const double EPS = 1e-10;
//二つのスカラーが等しいか
#define EQ(a, b) (abs((a) - (b)) < EPS)
//二つのベクトルが等しいか
#define EQV(a, b) (EQ((a), real(), (b).real()) && EQ((a), imag(), (b).imag()))
#define curr(P, i) P[i]
#define next(P, i) P[(i + 1) % P.size()]
#define prev(P, i) P[(i - 1 + P.size()) % P.size()]

double dot(P a, P b)
{
    return real(a) * real(b) + imag(a) * imag(b);
}

double cross(P a, P b)
{
    return real(a) * imag(b) - imag(a) * real(b);
}

int is_orthogonal(P a1, P a2, P b1, P b2)
{
    return EQ(dot(a1 - a2, b1 - b2), 0.0);
}
int is_parallel(P a1, P a2, P b1, P b2)
{
    return EQ(cross(a1 - a2, b1 - b2), 0.0);
}

int ccw(P a, P b, P c)
{
    b -= a;
    c -= a;
    if (cross(b, c) > 0)
        return 1;
    if (cross(b, c) < 0)
        return -1;
    if (dot(b, c) < 0) // c--a--b on line
        return 2;
    if (norm(b) < norm(c)) //a--b--c on line or a==b
        return -2;
    return 0; // a--c--b on line a==c or b==c
}

int is_intersected_ls(P a1, P a2, P b1, P b2)
{
    return ccw(a1, a2, b1) * ccw(a1, a2, b2) <= 0 &&
           ccw(b1, b2, a1) * ccw(b1, b2, a2) <= 0;
}

double Area(vec &g)
{
    double A = 0;
    for (int i = 0; i < (int)g.size(); ++i)
    {
        A += cross(curr(g, i), next(g, i));
    }
    return A / 2.0;
}

bool is_Convex(const vec &g)
{
    for (int i = 0; i < (int)g.size(); ++i)
    {
        if (ccw(prev(g, i), curr(g, i), next(g, i)) == -1)
            return false;
    }
    return true;
}
int main(void)
{
    int N;
    cin >> N;
    vec v;
    for (int i = 0; i < N; ++i)
    {
        double x, y;
        cin >> x >> y;
        P c = {x, y};
        v.push_back(c);
    }
    if (is_Convex(v))
        cout << "1" << endl;
    else
        cout << "0" << endl;
}


Measured memory_bytes: 3292
#include <stdio.h>
int main(void)
{
    int n;
    scanf("%d",&n);
    int s[n];
    for(int p=1;p<n+1;p++)
    {
        scanf("%d",&s[p]);
    }
    int sum =0;
    for(int q=1;q<n+1;q++)
    {
        sum +=s[q];
        if(s[q]%10==0)
          s[q]*=100;
    }
    int pow;
    for(int r=1;r<n+1;r++)
    {
        for(int t=1;t<n+1;t++)
        {
            if(s[r]<s[t])
            {
                pow=s[r];
                s[r]=s[t];
                s[t]=pow;
            }
        }
    }
    if(sum%10!=0)
      printf("%d",sum);
    else if(sum%10==0)
    {
        if(s[1]<=100)
        {
            printf("%d",sum-s[1]);
        }
        else
        {
            printf("0");
        }
    }
}


Measured memory_bytes: 128
#include <stdio.h>
int main (void) {
  int height[10];
  int i, j;
  int x;

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

  for (i=0;i<9;i++) {
    for (j=i;j<=9;j++) {
      if (height[i] <= height[j]) {
        x = height[i];
        height[i] = height[j];
        height[j] = x;
      }
    }
  }

  for (i=0;i<3;i++) {
    printf("%d\n", height[i]);
  }

  return 0;
}

Measured memory_bytes: 600
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N, M, X;
	List<Tuple> list;
	int[] A;
	int sum = 0;

	static class Tuple {
		int C;
		int[] A;
		int maxA;

		Tuple(String line) {
			String[] tokens = line.split(" ");
			C = Integer.parseInt(tokens[0]);
			A = new int[tokens.length - 1];
			maxA = 0;
			for (int i = 1; i < tokens.length; ++i) {
				A[i - 1] = Integer.parseInt(tokens[i]);
				maxA = Math.max(maxA, A[i - 1]);
			}
		}

		double getKosupa() {
			return (double) maxA / (double) C;
		}
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		N = Integer.parseInt(tokens[0]);
		M = Integer.parseInt(tokens[1]);
		X = Integer.parseInt(tokens[2]);
		list = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			list.add(new Tuple(in.readLine()));
		}
		Collections.sort(list, new Comparator<Tuple>() {
			@Override
			public int compare(Tuple o1, Tuple o2) {
				return -1 * Double.compare(o1.getKosupa(), o2.getKosupa());
			}
		});
		A = new int[M];
		Arrays.fill(A, 0);
	}

	int eval(Tuple tuple, int prev) {
		// まず足す必要があるか評価
		boolean result = true;
		for (int i = 0; i < M; ++i) {
			if (A[i] < X) {
				result = false;
				break;
			}
		}
		if (result) {
			return prev;
		}

		// Aに足していく．全部がX以上になればtrueを返す
		for (int i = 0; i < M; ++i) {
			A[i] += tuple.A[i];
		}
		return prev + tuple.C;
	}

	int eval(int pattern) {
		int sum = 0;
		int[] a = new int[M];
		Arrays.fill(a, 0);
		for (int i = 0; i < N; ++i) {
			if ((pattern & 1) > 0) {
				for (int j = 0; j < M; ++j) {
					a[j] += list.get(i).A[j];
				}
				sum += list.get(i).C;
			}
			pattern = pattern >> 1;
		}
		for (int i = 0; i < M; ++i) {
			if (a[i] < X) {
				return -1;
			}
		}
		return sum;

	}

	void calc() {
		sum = Integer.MAX_VALUE / 2;
		for (int i = 0; i < Math.pow(2.0, (double) N); ++i) {
			int s = eval(i);
			if (s >= 0) {
				sum = Math.min(s, sum);
			}
		}
		if (sum >= Integer.MAX_VALUE / 2 - 1) {
			sum = -1;
		}
	}

	void showResult() {
		System.out.println(sum);
	}

}


Measured memory_bytes: 33944
#include <cstdio>

using namespace std;

int main(void){
  bool flg = true;
  char str[16], *p;
  int a,b;
  
  scanf("%d%d", &a, &b);
  scanf("%s", str);
  
  p = str;
  for (int i=0; i<a; i++){
    flg &= (*p>='0' && *p <='9');
    p++;
  }
  flg &= (*p++ == '-');
  for (int i=0; i<b; i++){
    flg &= (*p>='0' && *p <='9');
    p++;
  }
  puts(flg?"Yes":"No");
  
  return 0;
}

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

#define REP(i,n) for(int i = 0;i < n;i++)
#define REPR(i,n) for(int i = n-1;i >= 0;i--)
#define FOR(i,m,n) for(int i = m;i < n;i++)
#define INF 2e9
#define ALL(v) v.begin(),v.end()
#define ll long long
#define GREATER greater<int>()

using namespace std;

string pop_back(string s){
    string t = s.substr(0,s.size()-1);
    return t;
}

int gcd(int max,int min){
    
    if(max<min){
        int tmp=max;
        max=min;
        min=tmp;
    }

    if(max%min==0)return min;
    else return gcd(min,max%min);

}

int main(void){

    string s;
    cin>>s;
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    int Ccounter=0;
    for(int i=1;i<s.size();i++){
        if(i>1&&s[i]=='C')Ccounter++;
        if(!(i<s.size()-1&&i>1&&s[i]=='C')&&!(s[i]>='a'&&s[i]<='z')){
            cout<<"WA"<<endl;
            return 0;
        }
        if(Ccounter>1){
            cout<<"WA"<<endl;
            return 0;
        }
    }
    if(Ccounter==1){
        cout<<"AC"<<endl;
    }
    else cout<<"WA"<<endl;

    return 0;
}




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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  rep(i, N){
    cin >> X.at(i);
  }
  int min = -1, result;
  for(int i = 1;i <= 100;i++){
    result = 0;
    rep(j, N){
      result += (X.at(j) - i) * (X.at(j) - i);
    }
    if(min == -1) min = result;
    if(min > result) min = result;
  }
  cout << min << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <iostream>
#include <cmath>
#include <vector>
#include <stack>
#include <algorithm>

using namespace std;

int main(void) {
	int N, K;
	int cnt = 1;
	cin >> N >> K;

	N -= K;
	cnt += N / (K - 1);
	if (N % (K - 1) != 0) {
		cnt++;
	}
	
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;
using ld = long double;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

void solve(string S) {
  S[3] = '8';
  cout << S << endl;
}

int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


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

int main() {
	int N;
  std::cin >> N;
  int N_original;
 	int quotient = 0;
  int remainder = 0;
  int sum_number = 0;


  N_original = N;

  while(N > 9){
    quotient = N / 10;
    remainder = N % 10;
    sum_number += remainder;
    N = quotient;
  }

  sum_number += N;

  if(N_original % sum_number == 0){
    std::cout << "Yes" << '\n';
  }else{
  	std::cout << "No" << '\n';
  }

  return 0;

}


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

#define int long long

int w, h;
int field[51][51];

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

void dfs(int x, int y) {
    field[x][y] = 0;
    for(int i=0; i<8; ++i) {
        int nx = x + dx[i];
        int ny = y + dy[i];
        if(nx>=0&&nx<h&&ny>=0&&ny<w&&field[nx][ny]==1) dfs(nx, ny);
    }
}

signed main()
{
    while(cin>>w>>h, w) {
        for(int i=0; i<h; ++i)
            for(int j=0; j<w; ++j) field[i][j] = 0;
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                cin >> field[i][j];
            }
        }

        int ans = 0;
        for(int i=0; i<h; ++i) {
            for(int j=0; j<w; ++j) {
                if(field[i][j]==1) {
                    ans++;
                    dfs(i, j);
                }
            }
        }

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

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

int main() {
	int A, B, C;
	cin >> A >> B >> C;
	if (A != B && B != C && C != A) {
		cout << "No" << endl;
	}
	else if (A == B && B == C) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;
#[allow(dead_code)]
const MOD:i64 = 1e9 as i64 + 7;


#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{a:i64, b:i64};
    let mn = min(a,b);
    let mx = max(a,b);

    for _i in 0..mx {
        print!("{}", mn);
    }
    println!("");

}

Measured memory_bytes: 4352
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] num = new int[N];
        Arrays.fill(num, 1);
        boolean[] red = new boolean[N];
        red[0] = true;
        for (int i = 0; i < M; i++) {
            int x = sc.nextInt()-1;
            int y = sc.nextInt()-1;
            num[x]--;
            num[y]++;
            // move
            if (red[x]) {
                red[y] = true;
            }
            // clear
            if (num[x] == 0) {
                red[x] = false;
            }
        }

        int ans = 0;
        for (int i = 0; i < N; i++) {
            if (red[i]) {
                ans++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 64772
icase=0
if icase==0:
    n,m=map(int,input().split())
#    ki,aset=int(input()),set(map(int,input().split()))
    lista=list(map(int,input().split()))
    ki=lista[0]
    aset=set(lista[1:])
    for i in range(1,n):
        lista=list(map(int,input().split()))
        ki=lista[0]
        a=set(lista[1:])
        aset=aset & a
    print(len(aset))

Measured memory_bytes: 3064
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 X=sc.nextInt();
		int a=0;
		for(int i=0;i<=C;i++) {
			for(int k=0;k<=B;k++) {
				for(int m=0;m<=A;m++) {
					if(i*50+k*100+m*500==X) {
						a=a+1;
					}
				}
			}
		}
		System.out.println(a);
	}
}

Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

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

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int N = in.nextInt();
			int M = in.nextInt();
			Integer[] a = new Integer[N];
			Integer[] b = new Integer[N];
			for(int i = 0; i < N; i++) {
				a[i] = in.nextInt();
				b[i] = in.nextInt();
			}
			Arrays.sort(a, Comparator.reverseOrder());
			Arrays.sort(b, Comparator.reverseOrder());
			int count = 0;
			for(int i = 0; i < N; i++) {
				if(b[i] <= a[0]) {
					break;
				}
				count++;
				M -= b[i];
				if(M <= 0) {
					break;
				}
			}
			while(M > 0) {
				M -= a[0];
				count++;
			}
			out.println(count);
			}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

Measured memory_bytes: 47200
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int main()
{
	int a;
	cin>>a;
	char s[101],t[101];
	scanf("%s%s",&s,&t);
	for(int i=0;i<a;i++)
		cout<<s[i]<<t[i];
	return 0;
}

Measured memory_bytes: 256
# 昇順とはなにか
# 頭から舐めていって、今の最大値より小さな値が出てこないこと
# 制約: 必ず1, 2, 3, 4, 5のような連続した要素からなっている
# 比較すればよい

n = readline.strip.to_i
ps = readline.strip.split.map(&:to_i)
ar = (1.upto n).to_a
count = ps.zip(ar).select do |a, b|
  a != b
end.size

if count == 0 || count == 2
  puts "YES"
else
  puts "NO"
end


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

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

typedef long long ll;
#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 vi vector<int>
#define vii vector< vector<int> >

int N;
double P[3100];
double dp[3100][3100];

int main() {

	cin >> N;
	rep1(i, N + 1) cin >> P[i];

	dp[0][0] = 1;

	rep1(x, N + 1) {
		rep(y, x + 1) {
			dp[x][y] = dp[x - 1][y] * (1 - P[x]);
			if (x != 0) dp[x][y] += dp[x - 1][y - 1] * P[x];
		}
	}

	double ans = 0;
	rep(i, N + 1) {
		if (i > N - i) ans += dp[N][i];
	}
	printf("%.15lf", ans);

}


Measured memory_bytes: 72448
a, b, k = map(int, input().split())
n = []
for i in range(k):
    if a + i > b:
        break
    n.append(a + i)
for j in range(k):
    if b - k + 1 + j < a:
        break
    if n.count(b - k + 1 + j) <= 0:
        n.append(b - k + 1 + j)
[print(num) for num in n]

Measured memory_bytes: 9072
import sys
sys.setrecursionlimit(100000000)
def input():
    return sys.stdin.readline()[:-1]
from bisect import *
from collections import *
from heapq import *
from math import *

S = input()
N = len(S)
lst = []
for i in range(N-1):
    if S[i:i+2] == "RL":
        lst.append(i)
# print(lst)
l = len(lst)
ans = [0]*N
for i in range(N):
    if S[i] == 'L':
        k = lst[bisect_left(lst, i)-1]
    else:
        k = lst[bisect_left(lst, i)]
    if (i-k)%2:
        ans[k+1] += 1
    else:
        ans[k] += 1
print(*ans)

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

int main( )
{
    int n, i, j, k;
    vector< pair<int, int> > v;
    cin >> n;
    for (i = 1; i <= n; i++) {
        cin >> j;
        v.push_back(make_pair(j, i));
    }
    sort(v.begin(), v.end());
    for (i = 0; i < n; i++) {
        if (i != 0) cout << ' ';
        cout << v[i].second;
    }
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1780
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
ll binpow(ll a,ll b,ll mod)
{
	ll ans=1;
	while(b)
	{
		if(b&1)
			ans=(ans*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}
void solve()
{
   ll n;
   cin>>n;
    ll ans=binpow(10,n,hell);
    ans=(ans+binpow(8,n,hell))%hell;
    ans=(ans-binpow(9,n,hell)+hell)%hell;
    ans=(ans-binpow(9,n,hell)+hell)%hell;
    cout<<ans;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

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

int n;
vector<int> h;

int main(){
	cin >> n;
  	for(int i=0;i<n;i++){
      	int x;
      	cin >>x;
    	h.push_back(x);
    }
  
  	int ans=0;
  	int active=0;
  	for(int i=0;i<n;i++){
    	if(active>=h[i]){
        	active=h[i];
        }else{
        	ans+=h[i]-active;
          	active =h[i];
       	}
    }
  cout <<ans <<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	ll n;
	long double a[110];
	cin>>n>>a[0];
	for(int i=1;i<n;i++){
		cin>>a[i];
		a[i]=a[i-1]*a[i]/(a[i-1]+a[i]);
	}
	cout<<fixed<<setprecision(10)<<a[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int num, length[200], i, j, temp, sum= 0;

	scanf("%d", &num);
	num*= 2;

	for(i= 0; i< num; i++)
		scanf("%d", &length[i]);

	for(i= 0; i< num- 1; i++)
	{
		for(j= 0; j< num- i- 1; j++)
		{
			if(length[j]> length[j+ 1])
			{
				temp= length[j];
				length[j]= length[j+ 1];
				length[j+ 1]= temp;
			}
		}
	}

	for(i= 0; i< num; i+= 2)
		sum+= length[i];

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

	return 0;
}

Measured memory_bytes: 128
def main():
  n,m=map(int,input().split())
  inf=10**9
  dp=[inf]*(1<<n)
  dp[0]=0
  for i in range(m):
    a,b=map(int,input().split())
    t=sum([1<<(int(x)-1) for x in input().split()])
    for s in range(1<<n):
      dp[t|s]=dp[t|s] if dp[t|s]<=dp[s]+a else dp[s]+a
  print(-1 if dp[-1]==inf else dp[-1])
  
  
if __name__=='__main__':
  main()


Measured memory_bytes: 9240
S = input()
T = input()
lenS = len(S)
lenT = len(T)
flag = False
ans = list(S)

for i in range(lenS-lenT, -1, -1):
    for j in range(lenT):
        if S[i+j] != T[j] and S[i+j] != '?':
            break
    else:
        flag = True
        break

if flag:
    for k in range(lenT):
        ans[i+k] = T[k]
    
    for k in range(lenS):
        if ans[k] == '?':
            ans[k] = 'a'
    print("".join(ans))
            
else:
    print("UNRESTORABLE")

Measured memory_bytes: 3064
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <vector>
#include <random>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;

int main () {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int64_t a, b, c, k;
    cin >> a >> b >> c >> k;
    cout << (k%2==0 ? a-b : b-a) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long X = sc.nextLong();
        long Y = sc.nextLong();
        long ans = 1;
        while(X*2<=Y){
            ans += 1;
            X = X*2;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define _K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ld long double
#define ll long long
#define ull unsigned ll
#define pb push_back
#define eps 1e-7
#define pi acos(-1)
#define F first
#define S second
#define X real()
#define Y imag()
#define cross(a,b) (conj(a)*(b)).X
#define dot(a,b) (conj(a)*(b)).Y
const int mod = 1e9+7 ;
typedef complex <ld> point ;
typedef vector <point> polygon ;
typedef tuple <int , int , int> line ;
//====================================
ld ans [3005][3005] , p [3005] ;
int main()
{
	_K
	ll n ;
	cin >> n ;
	for (int i = 1 ; i <= n ; cin >> p[i++]) ;
	for(int i = 1 ;  i < n  ; i++)
	{
		for (int j =0 ;  j  < n ; j++)
		{
			ans[i][j] = 0;
		}
	}
	ans[0][1] = 1 - p[1] ;
	ans[1][1] = p[1] ;
	for (int i = 0 ; i <= n ; i++)
	{
		for (int j = 2 ; j <= n ; j++)
		{
			if (i > j)
				ans[i][j] = 0 ;
			else
			{
				ans[i][j] = ans[i][j-1] * (1 - p[j]) ;
				if (i)
					ans[i][j] += ans[i-1][j-1] * p[j] ;
			}
		}
	}
	ld val =0 ;
	for (int i = ceil(n*1.0/2) ; i <= n ; i++)
		val += ans [i][n] ;
	cout << setprecision(10) << fixed << val ;
	return 0;
}

//string s , t ;
//	cin >> s >> t ;
//	for (int i = 0 ; i < s.size() ; i++)
//	{
//		for (int j = 0 ; j < t.size() ; j++)
//		{
//			if (s[i] == t[j])
//			{
//				if (i && j)
//					ans[i][j] = ans[i-1][j-1] + 1 ;
//				else
//					ans[i][j] = 1 ;
//			}
//			else
//			{
//				if (i)
//					ans[i][j] = max (ans[i-1][j] , ans[i][j]) ;
//				if (j)
//					ans[i][j] = max (ans[i][j-1] , ans[i][j]) ;
//			}
//		}
//	}
//	cout << ans[s.size()-1][t.size()-1] ;

//ll n , e4ta = 1 ;
//	cin >> n ;
//	ll a[n] , ans[n] ;
//	for (int i = 0 ; i < n ; cin >> a[i++]) ;
//	for (int i = 0 ; i < n ; i++)
//	{
//		ans[i] = 1 ;
//		for (int j = 0 ; j <= i-1 ; j++)
//		{
//			if (a[j] < a[i])
//				ans[i] = max(ans[j]+1 , ans[i]) ;
//		}
//		e4ta = max(e4ta , ans[i]) ;
//	}
//	cout << e4ta ;


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

int main(){
	int n;
	cin>>n;
	vector<int> a(n);
	rep(i,n) cin>>a[i];
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			int d=abs(a[i]-a[j]);
			if(ans<d) ans = d;
		}
	}
	cout<<ans<<endl;
	return 0;		
}

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

int get(int x) {
	
	int res = 1;
	for(int i = 2 ; i * i <= x ; ++ i) {
		int cnt = 0;
		if(x % i == 0) {
			while(x % i == 0) x /= i, ++ cnt;
			res *= cnt + 1;
		}
	}
	if(x > 1) res *= 2;
	return res;
}

int main() {
	int n;
	scanf("%d", &n);
	int ans = 0;
	for(int i = 1 ; i <= n ; i += 2) {
		int x = get(i);
		if(x == 8) ++ ans;
//		cout << "get(i) 
//		 >> 
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
io = STDIN
$n,m=io.gets.split.map(&:to_i)
$hash=Hash.new{|h,k|h[k]=[]}
m.times do
  a,b=io.gets.split.map(&:to_i)
  $hash[a]<<b
end
puts $hash[1].any?{|x|$hash[x].include?($n)} ? "POSSIBLE" : "IMPOSSIBLE"


Measured memory_bytes: 24572
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        if (S.charAt(S.length()-1) == 's') {
            System.out.println(S+"es");
        } else {
            System.out.println(S+"s");
        }
    }
}


Measured memory_bytes: 38412
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    if(n % 2 != 0)
    {
      cout << "No" << endl;
      return 0;
    }
    for(int i = 0; i < n/2; i++)
    {
        if(s[i+n/2] != s[i])
        {
            cout << "No" << endl;
            return 0;

        }
    }
    cout << "Yes" << endl;
}




Measured memory_bytes: 256
#!/usr/bin/env python

h, w = map(int, input().split())
s = ['' for _ in range(h+2)]
for i in range(1, h+1):
    s[i] = input()
for i in range(w):
    s[0] += '.' 
    s[h+1] += '.' 
for i in range(h+2):
    s[i] = ('.'+s[i]+'.')

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
            if s[i][j-1] == '#' or s[i][j+1] == '#' or s[i-1][j] == '#' or s[i+1][j] == '#' :
                continue
            else:
                print('No')
                exit()
        else:
            continue

print('Yes')


Measured memory_bytes: 9124
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int cnt = 0;
  rep(i,n){
    int p;
    cin >> p;
    if(p!=i+1) ++cnt;
  }
  cout << (cnt<=2?"YES":"NO") << endl;
}


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

int main(){
   ll x;
   cin >> x; 
   ll tmp = 100;
   ll ans = 0;
    while(tmp < x) {
        tmp += (tmp /100); 
        ans++;
    }
    cout << ans << endl; 
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
long long N,K;
int main(){
    cin>>N>>K;
    long long A[N];
    for(int i=0;i<N;i++)cin>>A[i];
    for(int i=K;i<N;i++)cout<<((double)A[i]/A[i-K]>1LL?"Yes":"No")<<endl;
    return 0;
}

Measured memory_bytes: 5164