akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <cmath>
using namespace std;
int in()
{
	int x;
	cin>>x;
	return x;
}
vector<int> h,w;
int mp[1500001]={};
int main ()
{
	int n,m;
	while(cin>>n>>m&&n&&m)
	{
		
		int ans=0;
		h.push_back(0);
		w.push_back(0);
		for(int i=0;i<n;i++)h.push_back(in());
		for(int i=0;i<m;i++)w.push_back(in());
		for(int i=1;i<=n;i++)h[i]+=h[i-1];
		for(int l=1;l<=m;l++)w[l]+=w[l-1];
		for(int i=0;i<n;i++)
		{
			for(int l=i+1;l<=n;l++)
			{
				mp[h[l]-h[i]]++;
			}
		}
		for(int i=0;i<m;i++)
		{
			for(int l=i+1;l<=m;l++)
			{
				if(mp[w[l]-w[i]]!=0)
				{
					ans+=mp[w[l]-w[i]];
					//cout<<i<<" "<<l<<endl;;
				}
			}
		}
		h.clear();
		w.clear();
		for(int i=0;i<1500001;i++)mp[i]=0;
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 7100
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=998244353;
const ll MAX=300000;

int main(){
    int n;
    cin>>n;
    vector<int>a(n),b(n),c(n);
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n)cin>>b[i];
    rep(i,n)cin>>c[i];
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(c.begin(),c.end());
    ll ans=0;
    rep(i,n){
        int ia=lower_bound(a.begin(),a.end(),b[i])-a.begin();
        if(ia==0)continue;
        ia--;
        int ic=upper_bound(c.begin(),c.end(),b[i])-c.begin();
        if(ic==c.size())continue;
        ans+=(ia+1)*(c.size()-ic);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1536
sa=list(input())
sb=list(input())
sc=list(input())

t="a"
sa_c=0
sb_c=0
sc_c=0

while 1:
    #print(t,sa_c,sb_c,sc_c)
    if t=="a":
        if len(sa)<=sa_c:
            print("A")
            exit()
            
        t=sa[sa_c]
        sa_c+=1
        
    elif t=="b":
        if len(sb)<=sb_c:
            print("B")
            exit()
        
        t=sb[sb_c]
        sb_c+=1
        
    else:
        if len(sc)<=sc_c:
            print("C")
            exit()
        
        t=sc[sc_c]
        sc_c+=1    
        

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

int main() {
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  for(int i = a; i <= b; i++) {
    int l1 = i % 10;
    int l2 = i / 10 % 10;
    int f1 = i / 10000 % 10;
    int f2 = i / 1000 % 10;
    if(l1 == f1 && l2 == f2) cnt++;
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#include <cmath>
#include <iomanip>
#include <queue>
#include <map>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
static const double pi = 3.141592653589793;

int main()
{
    ll a, b;

    cin >> a >> b;
    cout << a * b << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

class Main{
	static int n;
	static long ans = 1000000000;
	static int[] memo;
	static int[] dp;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long ans = 0;
		if(c-a >= 0){
			ans += a;
			c -= a;
			if(b - c < 0){
				ans += 2*b+1;
			}else{
				ans += c+ b;
			}
		}else{
			ans += c + b;
		}
		System.out.println(ans);
	}
}







class Pair implements Comparable{
	int from;		//p
	int end;		//y
	int num;
	int bango;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}


Measured memory_bytes: 22612
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K =Integer.parseInt(sc.next());
        int gcd1,gcd2 ;
        long sum = 0;
        for(int i=1;i<=K;i++){
            for(int j=1;j<=K;j++){
                for(int k=1;k<=K;k++){
                    gcd1 = gcd(j,i);
                    gcd2 = gcd(k,gcd1);
                    sum+=gcd2;
                }
            }
        }
        System.out.println(sum);
    }

    public static int gcd(int a,int b){
        if(b == 0){
            return a;
        }else{
            return gcd(b,a%b);
        }
    }
}

Measured memory_bytes: 27180
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <utility>
#include <set>
#include <map>
using namespace std;

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

vector<int> res[4];
int w, n, W;
int ans;
void solve(ll i, ll j, ll k)
{
  ll tot = (i+j+k)*w+j+2*k;
  if (tot > W)
    return;
  ll left = W-tot;
  ll l = min((ll)res[3].size()-1, left/(w+3));
  ans = max(ans, res[0][i]+res[1][j]+res[2][k]+res[3][l]);
}
int main()
{
  scanf("%d %d", &n, &W);
  int a, b;
  scanf("%d %d", &a, &b);
  w = a;
  res[0].push_back(b);
  for (int i = 1; i < n; ++i)
    {
      scanf("%d %d", &a, &b);
      res[a-w].push_back(b);
    }
  for (int i = 0; i < 4; ++i)
    {
      sort(res[i].begin(), res[i].end());
      res[i].push_back(0);
      reverse(res[i].begin(), res[i].end());
      for (int j = 1; j < res[i].size(); ++j)
	res[i][j] += res[i][j-1];
    }
  ans = 0;
  for (int i = 0; i < res[0].size(); ++i)
    {
      for (int j = 0; j < res[1].size(); ++j)
	{
	  for (int k = 0; k < res[2].size(); ++k)
	    {
	      solve(i, j, k);
	    }
	}
    }
  printf("%d\n", ans);
}


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

using namespace std;

typedef long long ll;

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

int n, pi[MAX_N * MAX_N], dist[MAX_N * MAX_N], idx[MAX_N][MAX_N];
int ptot, xi[MAX_N * MAX_N], yi[MAX_N * MAX_N], rem[MAX_N * MAX_N];

void dfs(int u)
{
    for (int d = 0; d < 4; d++)
    {
        int dstx = xi[u] + dx[d], dsty = yi[u] + dy[d];
        int nd = dist[u] + 1 - rem[idx[dstx][dsty]];
        if (dist[idx[dstx][dsty]] > nd)
            dist[idx[dstx][dsty]] = nd, dfs(idx[dstx][dsty]);
    }
}

int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n * n; i++)
        scanf("%d", &pi[i]);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
        {
            idx[i][j] = ++ptot, xi[ptot] = i, yi[ptot] = j;
            dist[ptot] = min(min(n - i + 1, i), min(n - j + 1, j));
        }
    int ans = 0;
    for (int i = 1; i <= n * n; i++)
    {
        int u = pi[i];
        ans += dist[u] - 1, rem[u] = 1;
        for (int d = 0; d < 4; d++)
        {
            int dstx = xi[u] + dx[d], dsty = yi[u] + dy[d];
            dist[u] = min(dist[idx[dstx][dsty]], dist[u]);
        }
        dfs(idx[xi[u]][yi[u]]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 25032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		int max = a;
		int r = 10 * a + b + c;
		if (b > max){
			max = b;
			r = 10 * b + a + c;
		}
		if (c > max){
			max = c;
			r = 10 * c + a + b;
		}
		System.out.println(r);

	}

}

Measured memory_bytes: 25300
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long int
#define mod 1000000007
#define string_mod 2549536629329_base_255
#define pb push_back
#define F first
#define S second
#define ff first
#define endl "\n"
#define ss second
#define all(v) v.begin(), v.end()
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int power(int x, unsigned int y, int p)
{
  int res = 1;
  x = x % p;
  while (y > 0)
  {

    if (y & 1)
      res = (res * x) % p;

    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
int32_t main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  tc = 1;
  //cin>>tc;
  while(tc--){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#include <list>
#include <set>
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
using namespace std;
using ll = long long;
const int INF = 1e9 + 1;
ll MOD = 1e9+7;
ll dx[9] = {-1, -1, -1, 0, 0, 0, 1, 1, 1};
ll dy[9] = {-1,  0,  1,-1, 0, 1,-1, 0, 1};

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

    string A,B;
    cin >> A >> B;
    REP(i,A.length()){
        cout << A[i];
        if(i < B.length()){
            cout << B[i];
        }
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<complex>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

typedef double Real;
typedef complex<Real> Point;

bool cmp(const Point &p1,const Point &p2){
	return p1.real()<p2.real();
}

Real sx[110],sy[110];
Real nx[110],ny[110];
int N,M;

Point ns[110];

vector<int> vec;

void init(){
	vec.clear();
}

void rot(){
	for(int i=1;i<M;i++){
		sx[i]-=sx[0];
		sy[i]-=sy[0];
	}
	for(int i=0;i<N;i++){
		nx[i]-=sx[0];
		ny[i]-=sy[0];
	}
	sx[0]=0,sy[0]=0;
	Point coe=Point(cos(1),sin(1));
//	Point coe=1;
	for(int i=1;i<M;i++){
		Point tmp=Point(sx[i],sy[i]);
		tmp*=coe;
		sx[i]=tmp.real();
		sy[i]=tmp.imag();
	}
	for(int i=0;i<N;i++){
		Point tmp=Point(nx[i],ny[i]);
		tmp*=coe;
		nx[i]=tmp.real();
		ny[i]=tmp.imag();
	}
	for(int i=0;i<N;i++){
		ns[i]=Point(nx[i],ny[i]);
	}
	sort(ns,ns+N,cmp);
	for(int i=0;i<N;i++){
		nx[i]=ns[i].real();
		ny[i]=ns[i].imag();
	}
}

void calc(Real sx,Real sy,Real tx,Real ty){
//	printf("%f %f %f %f\n",sx,sy,tx,ty);
	if(sx<tx){
		for(int i=0;i<N;i++){
			if(sx<nx[i]&&nx[i]<tx){
				Real r=(nx[i]-sx)/(tx-sx);
				Real dy=(ty-sy)*r;
				Real y=sy+dy;
				int id;
				if(y<ny[i]) id=i*2;
				else id=i*2+1;
//				printf("id=%d\n",id);
				if(vec.size()==0||vec.back()!=id) vec.push_back(id);
				else vec.pop_back();
			}
		}
	}else{
		for(int i=N-1;i>=0;i--){
			if(tx<nx[i]&&nx[i]<sx){
				Real r=(nx[i]-sx)/(tx-sx);
				Real dy=(ty-sy)*r;
				Real y=sy+dy;
				int id;
				if(y<ny[i]) id=i*2;
				else id=i*2+1;
//				printf("id=%d\n",id);
				if(vec.size()==0||vec.back()!=id) vec.push_back(id);
				else vec.pop_back();
			}
		}
	}
}

Real dp[10100];

Point ps[10100];
bool dirs[10100];

Real solve(){
	init();
	rot();
	for(int i=0;i<M-1;i++){
		calc(sx[i],sy[i],sx[i+1],sy[i+1]);
	}
	if(vec.size()==0){
		Real dx=sx[0]-sx[M-1],dy=sy[0]-sy[M-1];
		return sqrt(dx*dx+dy*dy);
	}
	ps[0]=Point(sx[0],sy[0]);
	for(int i=0;i<vec.size();i++){
		ps[i+1]=ns[vec[i]/2];
		dirs[i+1]=vec[i]%2==1;
	}
	ps[vec.size()+1]=Point(sx[M-1],sy[M-1]);
	dp[0]=0;
//	for(int i=0;i<vec.size()+2;i++){
//		printf("%f %f %c\n",ps[i].real(),ps[i].imag(),dirs[i]?'u':'d');
//	}
	for(int i=1;i<vec.size()+2;i++){
		dp[i]=dp[i-1]+abs(ps[i]-ps[i-1]);
		for(int j=i-2;j>=0;j--){
			if(dp[i]<dp[j]+abs(ps[i]-ps[j])) continue;
			if(abs(ps[j]-ps[j+1])<(1e-8)) break;
			bool ok=true;
			for(int k=j+1;k<i;k++){
				Real x1=ps[j].real(),y1_=ps[j].imag();
				Real x2=ps[i].real(),y2_=ps[i].imag();
				Real x=ps[k].real();
				Real r=(x-x1)/(x2-x1);
				Real y=y1_+(y2_-y1_)*r;
				bool flg=ps[k].imag()<y;
				if(dirs[k]!=flg){
					ok=false;
					break;
				}
			}
			if(ok){
				dp[i]=dp[j]+abs(ps[i]-ps[j]);
			}
		}
	}
//	for(int i=0;i<vec.size()+2;i++){
//		printf("%f ",dp[i]);
//	}
//	printf("\n");
	return dp[vec.size()+1];
}

void input(){
	scanf("%d%d",&M,&N);
	if(M==0&&N==0) exit(0);
	for(int i=0;i<M;i++){
		scanf("%lf%lf",sx+i,sy+i);
	}
	for(int i=0;i<N;i++){
		scanf("%lf%lf",nx+i,ny+i);
	}
}

int main(){
	while(true){
		input();
		Real ans=solve();
		printf("%f\n",ans);
	}
	return 0;
}

Measured memory_bytes: 1352
#include <iostream>
#include <cmath>

#define N_MAX 1000

using namespace std;

int main(){
    int N, T, A;
    int H[N_MAX];
    double min = 100000;
    int index;
    cin >> N;
    cin >> T >> A;
    for(int i = 0; i < N; i++){
        cin >> H[i];
    }
    for(int i = 0; i < N; i++){
        if(abs((double)T - 0.006*(double)H[i] - (double)A) < min){
            index = i+1;
            min = abs((double)T - 0.006*(double)H[i] - (double)A);
        }
    }
    cout << index << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
lis = []
for i in range(n):
    lis.append(str(input()))
for k in range(n):
    for h in range(m):
        if lis[k][h] == "#":
            key = 0
            try:
                if lis[k][h+1] == "#":key = 1
            except:
                key = 0
            if key == 0:
                try:
                    if lis[k][h-1] == "#":key = 1
                except:
                    key = 0
                if key == 0:
                    try:
                        if lis[k+1][h] == "#":key = 1
                    except:
                        key = 0
                    if key == 0:
                        try:
                            if lis[k-1][h] == "#":key = 1
                        except:
                            key = 0
                        if key == 0:
                            print("No")
                            exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

#define fi first
#define se second
#define vi vector<int>
#define vpi vector<pair<int,int>>
#define vll vector<ll>
#define vpll vector<pair<ll,ll>>
#define endl '\n'

#define si(v) int((v).size())
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i) 
#define rep2(i, n, m) for (ll i = n; i <= (ll)(m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (ll)(m); --i)

template<class T, class U> void chmax(T &a, U b) { if (a < b) a = b; }
template<class T, class U> void chmin(T &a, U b) { if (a > b) a = b; }

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

constexpr ll MOD = 1000000007;

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

  int d; cin >> d;
  
  string ans = "Christmas";
  rep(i, 25 - d) ans += " Eve";

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
//#define int long long
#define loop(i, a, b) for(int i = a; i < b; i++)
#define rep(i, a) loop(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int MOD = 1e9 + 7, INF = 1e9;
using vi = vector <int>;
using vvi = vector <vi>;
//g++ -std==c++14

struct edge{int u, v, cost;};

bool comp(const edge& e1, const edge& e2){return e1.cost < e2.cost;}

int tree[100010];
int root(int x){return tree[x] == x ? x : tree[x] = root(tree[x]);}
void unite(int a , int b){tree[root(a)] = root(b);}

edge es[1000100];
int V, E;

int kruskal(){
    sort(es, es + E, comp);
    rep(i, V)tree[i] = i;
    int res = 0;
    rep(i, E){
        edge e = es[i];
        if(root(e.u) != root(e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

struct point{int x, y, index;};
bool sort_x(const point& point1, const point& point2){return point1.x < point2.x;}
bool sort_y(const point& point1, const point& point2){return point1.y < point2.y;}

signed main(){
    cin >> V;
    point x_y[V];
    rep(i, V){
        cin >> x_y[i].x >> x_y[i].y;
        x_y[i].index = i;
    }
    int koko = 0;

    sort(x_y, x_y + V, sort_x);
    rep(i, V - 1){
        es[koko].u = x_y[i].index;
        es[koko].v = x_y[i + 1].index;
        es[koko].cost = min(abs(x_y[i].x - x_y[i + 1].x),abs(x_y[i].y - x_y[i + 1].y));
        koko++;
    }

    sort(x_y, x_y + V, sort_y);
    rep(i, V - 1){
        es[koko].u = x_y[i].index;
        es[koko].v = x_y[i + 1].index;
        es[koko].cost = min(abs(x_y[i].x - x_y[i + 1].x),abs(x_y[i].y - x_y[i + 1].y));
        koko++;
    }

    E = koko;

    cout << kruskal() << endl;

}


Measured memory_bytes: 5888
import sys
f = sys.stdin

sentences = f.readline().split()

for i in range(len(sentences)):
    if 'apple' in sentences[i]:
        sentences[i] = sentences[i].replace('apple', 'peach')
    elif 'peach' in sentences[i]:
        sentences[i] = sentences[i].replace('peach', 'apple')
print(' '.join(sentences))

Measured memory_bytes: 6724
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
a = 0

while a <= A and a * 500 <= X:
	b = 0
	while b <= B and a * 500 + b * 100 <= X:
		if (X - 500 * a - 100 * b) // 50 <= C:
			ans += 1
		b += 1
	a += 1

print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pi acos(-1)
#define mod 1000000007
using namespace std;

int dp[3001][3001];
string a, b;

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

    cin >> a >> b;
    int n = a.length(), m = b.length();
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[i] == b[j]){
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            dp[i+1][j+1] = max(dp[i + 1][j + 1], max(dp[i + 1][j], dp[i][j + 1]));
        }
    }
    string ans = "";
    while(n > 0 && m > 0){
        if(a[n-1] == b[m-1]){
            ans += a[n-1];
            n--;
            m--;
        }else if(dp[n-1][m] > dp[n][m-1]){
            n--;
        }else{
            m--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans;
    return 0;
}


Measured memory_bytes: 35456
parseline(str=readline()) = parse.(Int, split(str))
function SemiCommonMultiple()
    N, M = parseline()
    A = parseline()
    a = div.(A, 2)
    temp = a
    zero = zeros(Int, N)
    while temp≠zero
        temp_ = temp.%2
        if 0 in temp_
            temp_==zero && (temp = div.(temp, 2); continue)
            return println(0)
        else
            break
        end
    end
    X = lcm(big.(a))
    println(X>M ? 0 : (M - X)÷2X + 1)
end
SemiCommonMultiple()

Measured memory_bytes: 241196
#!/usr/bin/env python3

import math
import sys

n = int(sys.stdin.readline().strip())
f_list = []
for _ in range(n - 1):
    c, s, f = sys.stdin.readline().strip().split(" ")
    c = int(c)
    s = int(s)
    f = int(f)
    f_list = [c + math.ceil((max(_f, s)) / f) * f for _f in f_list]
    f_list.append(c + s)
f_list.append(0)
for _f in f_list:
    print(_f)

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

#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pi acos(-1)
#define MAXS 1e(18)
#define MOD 1000000007
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;



int main()
{

    _fastIO;

    int n;

    while(cin>>n){
        string a,b,c;
        cin>>a>>b;
        for(int i=0; i<n; i++){
            c.push_back(a[i]);
            c.push_back(b[i]);
        }
        cout<<c<<endl;
    }

    return 0;
}


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

#define N 101

int top,S[N];

int pop(){

  if(top == 0){
    fprintf(stderr,"アンダーフロー\n");
    exit(2);
  }

  return S[top--];

}

void push(int x){

  if(top == 100){
    fprintf(stderr,"オーバーフロー\n");
    exit(1);
  }

  S[++top] = x;

}


int main(){

  int n,a,b,status;

  char A[1000000];

  S[top] = NULL;

  while((status = scanf("%s",&A)) != EOF){
    
    if(A[0] == 42 || A[0] == 43 || A[0] == 45){
      
      switch(A[0]){
	
      case 42:
	b = pop();
	a = pop();
	push(a * b);
	break;

      case 43:
	b = pop();
	a = pop();
	push(a + b);
	break;

      case 45:
	b = pop();
	a = pop();
	push(a - b);
	break;
	
      }
      
    }
    
    else{
      push(atoi(A));
    }
    
  }

  printf("%d\n",S[top]);

  return 0;
}





Measured memory_bytes: 2140
import heapq as hq
N = int(input())
V = [int(i) for i in input().split()]
hq.heapify(V)
for i in range(N-1):
    a = hq.heappop(V)
    b = hq.heappop(V)
    hq.heappush(V,(a+b)/2)
print(V[0])

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <math.h>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
#include <set>
#include <list>
#include <string>
#include <memory.h>
#include <bitset>
#include <stack>
#include <assert.h>
#include <ctime>
#include <unordered_set>
using namespace std;
#define ll long long
#define ppi pair<int, int>
#define mp make_pair
const int N = 2e5 + 1111 , BN = 3e7 + 11, K = 20;
const int mod = 1e9 + 7;
int dp[N], dp2[N];
int get(int idx)
{
	if (idx < 0)return 0;
	else return dp2[idx];
}
int main()
{
#ifndef ONLINE_JUDGE
	//freopen("inp.txt", "r", stdin);
#endif
	int n, k, c;
	string x;
	cin >> n >> k >> c >> x;
	for (int i = n - 1; i >= 0; i--)
	{
		if (x[i] == 'x') dp[i] = dp[i + 1];
		else dp[i] = max(dp[i + c + 1] + 1, dp[i + 1]);
	}
	for (int i = 0; i < n; i++)
	{
		if (x[i] == 'x') dp2[i] = get(i - 1);
		else dp2[i] = max(get(i - c - 1) + 1, get(i - 1));
	}
	for (int i =0 ; i < n ; i++)
	{
		if (get(i - 1) + dp[i + 1] == k - 1)
		{
			printf("%d\n", i + 1);
		}
	}
}


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

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll long long
using namespace std;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

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

  vector<int> A(N);
  vector<int> P(N);
  vector<int> Q(N);
  loop(0, N, i) A[i] = i+1;
  loop(0, N, i) cin >> P[i];
  loop(0, N, i) cin >> Q[i];

  int count = 1;
  int a = -1;
  int b = -1;
  do {
    bool pok = true;
    bool qok = true;
    loop(0, N, i) {
      if (A[i] != P[i]) pok = false;
      if (A[i] != Q[i]) qok = false;
    }
    if (pok) a = count;
    if (qok) b = count;
    count++;

  } while(next_permutation(A.begin(), A.end()));
  print(abs(a-b));
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;

vector<int> vs;
int dp[200000];
signed main(){
	vs.pb(1);
	int tmp = 6;
	rep(i,100000){
		if(tmp > 100000)break;
		vs.pb(tmp);
		tmp *= 6;
	}
	tmp = 9;
	rep(i,100000){
		if(tmp > 100000)break;
		vs.pb(tmp);
		tmp *= 9;
	}
	ZIP(vs);
	
	int n, ans = 0;
	scanf("%lld", &n);
	fill(dp, dp+200000, inf);
	dp[0] = 0;
	rrep(i,n){
		rep(j,vs.size()){
			if(i-vs[j] < 0)continue;
			dp[i] = min(dp[i], dp[i-vs[j]]+1);
		}
	}
	printf("%lld\n", dp[n]);
	return 0;
}







Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2255&lang=jp
// reference : http://rokugats-pc.hateblo.jp/entry/2015/06/20/163726
typedef long long ll;
#define INF 1<<30

map<string, set<int>> memo;
bool n_only(string& str) {
	for (auto s : str) if (s < '0' || s > '9') return false;
	return true;
}
string::iterator p_end_pos(string::iterator s) {
	int p = 1;
	for (auto it = s + 1;;it++) {
		if (*it == '(')p++; if (*it == ')')p--;
		if (p == 0)return it;
	}
}

set<int> rec(string str) {
	if (memo.count(str)) return memo[str];
	if (n_only(str))return memo[str] = set<int>{ stoi(str) };
	if (str[0] == '(' && p_end_pos(str.begin()) == str.end() - 1) {
		return memo[str] = rec(string(str.begin() + 1, str.end() - 1));
	}
	set<int> ret;
	for (auto it = str.begin(); it != str.end();it++) {
		if (*it == '(') it = p_end_pos(it);
		char op = *it;
		if (op == '+') {
			set<int> L = rec(string(str.begin(), it));
			set<int> R = rec(string(it + 1, str.end()));
			for (auto l : L)for (auto r : R) {
				ret.insert(l + r);
			}
		}
		else if (op == '-') {
			set<int> L = rec(string(str.begin(), it));
			set<int> R = rec(string(it + 1, str.end()));
			for (auto l : L)for (auto r : R) {
				ret.insert(l - r);
			}
		}
		else if (op == '*') {
			set<int> L = rec(string(str.begin(), it));
			set<int> R = rec(string(it + 1, str.end()));
			for (auto l : L)for (auto r : R) {
				ret.insert(l * r);
			}
		}
		else if (op == '/') {
			set<int> L = rec(string(str.begin(), it));
			set<int> R = rec(string(it + 1, str.end()));
			for (auto l : L)for (auto r : R) {
				if (r == 0)continue;
				ret.insert(l / r);
			}
		}
	}
	return memo[str] = ret;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	string str;
	while (cin >> str) {
		if (str == "#")break;
		cout << rec(str).size() << endl;
	}
	return 0;
}

Measured memory_bytes: 3760
#include <stdio.h>
int main(void)
{

int A, B;

scanf("%d %d", &A, &B);

if((A + B) % 3 == 0 || A % 3 == 0 || B % 3 == 0) {
printf("Possible\n");
}else { 
printf("Impossible\n");
}

    return 0;

}


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


void cc_env(){
	#ifndef ONLINE_JUDGE
		freopen("input", "r", stdin);
		freopen("output", "w", stdout);
		// 
	#endif
}



void self_max(ll &a, ll b){
	a = max(a, b);
}


int main(){
	// cc_env();
	// input part;
	int N, W, w, v;
	cin>>N>>W;

	// maintaining output array
	vector<ll> dp(W+1, 0);
	for(int i=0;i<N;i++){
		cin>>w>>v;

		// processing
		for(int weight_already = W-w; weight_already >=0; --weight_already){
			// cout<<dp[weight_already+w]<<" "<<dp[weight_already]+v<<endl;
			self_max(dp[weight_already+w], dp[weight_already]+v);
		}

		// for(int i=0;i<dp.size();i++)
		// 	cout<<dp[i]<<" ";
		// cout<<endl;

	}
	// find max among weight array
	ll maxVal = *max_element(dp.begin(), dp.end());
	cout<<maxVal<<endl;
	return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#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, k;
	cin >> n >> k;
	string s;
	cin >> s;
	s.at(k-1) = s.at(k-1) - 'A' + 'a';
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
const int MAX = 500050;
typedef pair<int, int>P;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


signed main() {
	int N, M, K; cin >> N >> M >> K;
	COMinit();
	ll res = 0;
	REP(d, N) {
		int c = M * M % MOD;
		c *= (N - d); c %= MOD;
		c *= d; c %= MOD;
		res += c; res %= MOD;
	}
	REP(d, M) {
		int c = N * N % MOD;
		c *= (M - d); c %= MOD;
		c *= d; c %= MOD;
		res += c; res %= MOD;
	}
	res *= COM(N * M - 2, K - 2);
	res %= MOD;
	print(res);
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
    string s;
    cin >> s;
    bool ans = true;
    rep(i, s.length()) {
        if (i % 2 == 1 && s[i] == 'R') ans = false;
        if (i % 2 == 0 && s[i] == 'L') ans = false;
    }


    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    EACH(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
    REP(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
    REP(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}

int sign(int x) {
    return x < 0 ? -1 : x > 0 ? 1 : 0;
}
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int L; cin >> L;
    int N; cin >> N;
    ll m = 0;
    REP(i, N) {
        int x, w; cin >> x >> w;
        m += x * w;
    }
    if (m == 0) {
        cout << 0 << endl;
    }
    else {
        cout << 1 << endl;
        cout << sign(-m) << " " << abs(m) << endl;
    }
    // m = -m;
    // ll rest = m;
    // vector<P> ans;
    // RFOR(i, 2, L+1) {
    //     if (abs(rest) / i) {
    //         P p = {sign(m)*i, abs(rest)/i};
    //         ans.pb(p);
    //         rest -= p.first * p.second;
    //     }
    // }
    // if (rest) {
    //     ans.pb({sign(m), rest});
    // }
    // cout << ans.size() << endl;
    // REP(i, ans.size()) {
    //     cout << ans[i].first << " " << ans[i].second << endl;
    // }
}

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

int main(){

        string s;
        cin >> s;
        rep(i,s.length()-1){
                if(s[i]==s[i+1]) {
                        cout << i+1 << " " << i+2 << endl;
                        return 0;
                }
        }
        rep(i,s.length()-2){
                if(s[i]==s[i+2]) {
                        cout << i+1 << " " << i+3 << endl;
                        return 0;
                }
        }

        cout << "-1 -1" << endl;
        return 0;
}


Measured memory_bytes: 512
using System;
using System.IO;
using System.Linq;

namespace At{
    class agc008 {
        static string[] splits;
        static int current = 0;

        static int nextint(){
            if(splits == null || splits.Length == current){
                splits = Console.ReadLine().Split(' ').ToArray();
            }
            
            int n = int.Parse(splits[current]);
            current++;
            return n;
        }

        static long[] ints(){
            return Console.ReadLine().Split(' ').Select(a => long.Parse(a)).ToArray();
        }

        static void Main(){
            int n = nextint();
            int k = nextint();

            long[] arr = ints();
            long total_plus = 0;
            long total_minus = 0;

            long[] plusto = new long[n];
            long[] minusto = new long[n];

            for(int i = 0; i <n ; i++){
                if(arr[i] > 0){
                    total_plus += arr[i];
                }
                else {
                    total_minus += arr[i];
                }
                plusto[i] = total_plus;
                minusto[i] = total_minus;
            }

            long blackout;
            long whiteout;
            
            long tmpmax = total_plus + minusto[k-1];

            // Console.WriteLine("Black");
            for(int i = 1; i < n - k + 1; i++){
                blackout = total_plus + minusto[i+k-1] - minusto[i-1];
                tmpmax = Math.Max(tmpmax,blackout);
                // Console.WriteLine(i + " ~ " + (i+k-1) +" " + blackout);
            }

            // Console.WriteLine("White");
            tmpmax = Math.Max(tmpmax, total_plus - plusto[k-1]);
            for(int i = 1; i < n - k + 1; i++){
                whiteout = total_plus - plusto[i+k-1] + plusto[i-1];
                tmpmax = Math.Max(tmpmax,whiteout);
                // Console.WriteLine(i + " ~ " + (i+k-1) +" " + whiteout);
            }

            Console.WriteLine(tmpmax);
        }
    }
}



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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int f(int a) {
  return (a * a + 4) / 8;
}

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

  string s; cin >> s;
  string ans;
  for(int i=0;i<SZ(s);i+=2) {
    ans.push_back(s[i]);
  }
  cout << ans << endl;

}


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

void b_toll_gates(void) {
	int n, m, x;
	int a[110] = { 0 };
	cin >> n >> m >> x;
	int aa;
	for (int i = 1; i <= m; i++) {
		cin >> aa;
		a[aa]++;
	}

	int cost_l = 0, cost_r = 0;

	for (int i = x; i >= 0; i--) {
		cost_l += a[i];
	}
	for (int i = x; i <= n; i++) {
		cost_r += a[i];
	}

	int min = cost_l;
	if (min > cost_r) {
		min = cost_r;
	}
	cout << min << endl;

}

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

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int value = 700;
  if(S.at(0)== 'o'){
    value += 100;
  }
  if(S.at(1) == 'o'){
    value += 100;
  }
  if(S.at(2) == 'o'){
    value += 100;
  }
  cout << value << endl;
}

Measured memory_bytes: 3572
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#define INF 1e16
#define N 2003
using namespace std;

int n, num[N];
int tot = 0, fir[N], nxt[N << 1], to[N << 1], val[N << 1];
long long res, f[N], g[N];
char s[N + 10];

inline void addEdge(int u, int v) {
    nxt[++tot] = fir[u], fir[u] = tot, to[tot] = v;
}

void dfs(int u, int p) {
    int cnt = 0;
    for (int i = fir[u], v; i; i = nxt[i]) {
        v = to[i]; if (v == p) continue;
        ++cnt, dfs(v, u);
        num[u] += num[v];
        g[u] += g[v];
    }
    if (cnt >= 1) {
        f[u] = g[u] % 2;
        for (int i = fir[u], v; i; i = nxt[i]) {
            v = to[i]; if (v == p) continue;
            f[u] = max(f[u], f[v] + g[v] - g[u]);
        }
    } else f[u] = g[u];
    if (!p) return ;
    if (s[u] == '1') ++num[u];
    f[u] += num[u], g[u] += num[u];
    res += num[u];
}

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    cin >> n;
    scanf("%s", s + 1);
    for (int i = 1, u, v; i < n; ++i) {
        scanf("%d%d", &u, &v);
        addEdge(u, v), addEdge(v, u);
    }
    long long ans = INF;
    for (int i = 1; i <= n; ++i) {
        memset(f, 0, sizeof f);
        memset(g, 0, sizeof g);
        memset(num, 0, sizeof num);
        res = 0;
        dfs(i, 0);
        if (f[i] == 0)
            ans = min(ans, res / 2);
    }
    printf("%lld\n", ans == INF ? -1 : ans);
    return 0;
}


Measured memory_bytes: 512
N,K = map(int,input().split())
if K%2:
    tmp = len(range(K,N+1,K))
    print(tmp**3)
else:
    tmp = len(range(K//2,N+1,K))
    tmp2 = len(range(K,N+1,K))
    print(tmp**3+tmp2**3)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,a,b,h[100000];
int T(int t){
  int need=0;
  for(int i=0;i<n;i++){
    int ex=h[i]-b*t;
    if(ex>0){
      need+=ex/(a-b);
      if(ex%(a-b)!=0)need++;
    }
  }
  if(need>t)return 0;
  else return 1;
}

signed main(){
  cin>>n>>a>>b;
  for(int i=0;i<n;i++)cin>>h[i];
  
  int l=-1,r=1e9,m;
  while(r-l>1){
    m=(l+r)/2;
    if(T(m))r=m;
    else l=m;
  }
  cout<<r<<endl;
  
  return 0;
}


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

int main(){
  int n,counter=0;
  char s[300100];
  int e[300100],w[300100];
  cin >> n;
  cin >> s[0];
  if(s[0]=='E')e[0]++;
  else w[0]++;
  for(int i=1;i<n;i++){
    cin >> s[i];
    if(s[i]=='E')e[i]+=e[i-1]+1;
    else e[i]=e[i-1];
    w[i]=i+1-e[i];
    //cout << "E["<< i << "]:" << e[i] <<  " "  << "W["<< i << "]:"  <<w[i] << endl;
  }
  int ans = 10000000;
  //リーダーが左端
  ans=min(ans,e[n-1]-e[0]);
  //cout << "位置" << 0 << " における向く人数 : " << e[n-1]-e[0] << endl;
  for(int i=1;i<n;i++){
    int res=w[i-1]+e[n-1]-e[i];
  //  cout << "位置" << i << " における向く人数 : " << res << endl;
    ans=min(ans,res);
  }
  cout << ans <<endl;
}


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

using namespace std;

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

#define INF (1<<(4*4-1))
#define MOD 1000000007


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

   int N,K;
   cin>>N>>K;
   vector<int>h(N);
   for(int i=0;i<N;i++)cin>>h[i];

   vector<ll>dp(N,1<<30);
   dp[0] = 0;
   for(int i=0;i<N;i++){
      for(int j=1;j<=K;j++){
         if(i-j<0)break;
         dp[i] = min(dp[i],dp[i-j]+abs(h[i]-h[i-j]));
      }
   }

   cout<<dp[N-1]<<endl;
   return 0;
}


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

int main() {
    int n,m,a,b,sum = 0;
    cin >> n >> m;
    vector<int> hi(n);
    vector<int> s(n);
    vector<int> an(n);
    for(int i = 0 ; i < n ; ++i){
        cin >> hi.at(i);
    }
    for(int i = 0 ; i < m ; ++i){
        cin >> a >> b ;
        if(a == b){
            continue;
        }
        s.at(a-1)++;
        s.at(b-1)++;
        if(hi.at(a-1) < hi.at(b-1)){
            an.at(b-1)++;
        }
        else if(hi.at(a-1) > hi.at(b-1)){
            an.at(a-1)++;
        }
    }
    for(int i = 0 ; i < n ; ++i){
        if(an.at(i) == s.at(i)){
            sum++;
        }
        }
    
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 4488
#include <bits/stdc++.h>
#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 rrep(i,n) for(int i=((int)(n)-1);i>=0;(i)--)
#define rrep1(i,n) for(int i=((int)(n));i>0;(i)--)
#define sz(c) ((int)(c).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> P;
typedef pair<int, pair<int, int> > PP;
//const int MAX=;

string S;
void input(){
	cin>>S;
	char x=S[0];
	if(x=='S')cout<<"Cloudy";
	if(x=='C')cout<<"Rainy";
	if(x=='R')cout<<"Sunny";
}

void solve(){

}

void output(){
  
}

int main(){
  input();
  solve();
  output();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n"
//#pragma GCC optimize(2)
using namespace std;
const int N=1e3+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
int n,m,a,b;
char p[N][N];
int main(){
	cin>>n>>m>>a>>b;
	FOR(i,1,n)FOR(j,1,m)p[i][j]='.';
	for(int i=1;m&1&&i<n&&b>0;i+=2)
		p[i][m]='^',p[i+1][m]='v',b--;
	if(b&1&&n&1&&m>=3&&n>=3){
			if(m%2==0)
				p[n-1][m]='^',p[n][m]='v',b--;
			else p[n-1][m-2]='^',p[n][m-2]='v',b--;
		
	}
	FOR(i,1,n-1)
		for(int j=1;j<=m-(m&1)&&b>0;j++)
			if(p[i][j]=='.'&&p[i+1][j]=='.')
				p[i][j]='^',p[i+1][j]='v',b--;
	if(b){
		cout<<"NO"<<endl;return 0;
	}
	FOR(i,1,n)
		for(int j=1;j<m&&a>0;j++)
			if(p[i][j]=='.'&&p[i][j+1]=='.')
				p[i][j]='<',p[i][j+1]='>',a--;
	if(a){
		cout<<"NO"<<endl;return 0;
	}
	cout<<"YES\n";
	FOR(i,1,n){
		FOR(j,1,m)cout<<p[i][j];
		cout<<endl;
	}
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int A,B,C,X;
    cin>>A>>B>>C>>X;
    int ans = 0;
    REP(i,A+1) {
        REP(j,B+1) {
            REP(k,C+1) {
                int n = 500 * i + 100 * j + 50 * k;
                if (X == n) ans++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
#define D()
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素


int main(){
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	REP(i,m){
		cin >> a[i];
	}

	REP(i,m){
		n -= a[i];
	}
	if(n>=0){
		cout << n << endl;
	}
	else{
	cout << -1 << endl;
	}
}



Measured memory_bytes: 3632
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(x...) cerr << __LINE__ << ": " << #x << " = "; DBG::_print(x)
#else
#define DEBUG(x...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

const int MOD = 1e9 + 7;
llong sum1toN(llong N) {
   return N*(N+1)/2;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);
   cout.precision(10);
   cout << fixed;

   int N, K;
   cin >> N >> K;

   llong res = 0;
   FOR(k, K, N+1) {
      llong lo = sum1toN(k-1);
      llong hi = sum1toN(N) - sum1toN(N-k);
   // cerr << k << ": " << lo << " to " << hi << endl;
      res = (res + (hi - lo + 1) + MOD) % MOD;
   }
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
deque<int>q;
int main()
{
	ios::sync_with_stdio(0);
	int n;cin>>n;int p=0;
	int x;cin>>x;q.push_back(x);
	for(int i=2;i<=n;i++){
		cin>>x;
		if(p==0)q.push_back(x);
		else q.push_front(x);
		p^=1;
	}
	if(p==0){
		for(int i=1;i<=n;i++){
			cout<<q.front()<<' ';q.pop_front();
		}
	}else{
		for(int i=1;i<=n;i++){
			cout<<q.back()<<' ';q.pop_back();
		}
	}
}

Measured memory_bytes: 3072
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

int main(){
  string s;
  cin>>s;
  if( (s.size() + ((int)(s[0]==s[s.size()-1])))%2 == 1 ){
    cout<<"First"<<endl;
  }
  else{
    cout<<"Second"<<endl;
  }
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

int n, m;

void bfs(int st_n, int st_c, vector<vector<pair<int, int>>> &pass, vector<pair<int, vector<int>>> &route, vector<vector<int>> &id)
{
  queue<pair<int, int>> que; // first: current_node, second: current_cost
  que.push(make_pair(st_n, st_c));

  while (!que.empty()) {
    pair<int, int> front = que.front();
    que.pop();

    rep (i, 0, pass[front.first].size()) {
      pair<int, int> tmp = pass[front.first][i];

      if (front.second + tmp.second < route[tmp.first].first) {
        route[tmp.first].first = front.second + tmp.second;
        route[tmp.first].second = route[front.first].second;
        route[tmp.first].second.push_back(id[front.first][i]);
        que.push(make_pair(tmp.first, route[tmp.first].first));
      }
    }
  }
}

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

  cin >> n >> m;

  vector<vector<pair<int, int>>> pass(n);
  vector<vector<int>> id(n);
  rep (i, 0, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    pass[a].push_back(make_pair(b, c));
    pass[b].push_back(make_pair(a, c));
    id[a].push_back(i);
    id[b].push_back(i);
  }

  vector<vector<pair<int, vector<int>>>> route(n, vector<pair<int, vector<int>>>(n));
  rep (i, 0, n) {
    rep (j, 0, n) {
      if (i == j)
        route[i][j].first = 0;
      else
        route[i][j].first = INF;
    }
  }

  rep (i, 0, n) {
      bfs(i, 0, pass, route[i], id);
  }

  set<int> s;
  rep (i, 0, n) {
    rep (j, 0, n) {
      for (int tmp : route[i][j].second)
        s.insert(tmp);
    }
  }

  cout << m - s.size() << endl;
	return 0;
}


Measured memory_bytes: 3200