akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    ull n,m;
    cin >> n >> m;

    ull ans = n*m;
    ans = (ans+1)/2;

    if(n == 1 || m == 1) ans = 1;
    cout << ans << "\n";
    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


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

int main()
{
    int height;
    vector<int> top3;

    while (cin >> height) {
        for (auto it = top3.begin(); it != top3.end(); it++) {
            if (height > *it) {
                it = top3.insert(it, height);
                break;
            }
        }
        if (top3.size() > 3)
            top3.pop_back();
        else if (top3.size() < 3)
            top3.push_back(height);
    }
    
    for (auto h: top3)
        cout << h << endl;

    return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>
int insertionSort(int *,int,int);
int main (){
    int n,x[1000000],i,j,cnt=0,m,g[100];
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&x[i]);
    }
    j=0;
    for(i=1;i<=n;i=3*i+1){
        g[j]=i;
        j++;
        cnt++;
    }
    m=cnt;
    cnt=0;
    for(i=1;i<=m;i++){
        cnt=insertionSort(x,n,g[m-i]);
    }
    printf("%d\n",m);
    for(i=1;i<=m;i++){
        if(i-1){
            printf(" ");
        }
        printf("%d",g[m-i]);
    }
    printf("\n");
    printf("%d\n",cnt);
    for(i=0;i<n;i++){
        printf("%d\n",x[i]);
    }
    return 0;

}

int insertionSort(int *x,int n,int g){
    int i,v,j;
    static int cnt;
    for(i=g;i<n;i++){
        v=x[i];
        j=i-g;
        while((j>=0) && (x[j]>v)){
            x[j+g]=x[j];
            j=j-g;
            cnt++;
        }
        x[j+g]=v;
    }
    return cnt;
}




Measured memory_bytes: 5600
#include<iostream>
using namespace std;
int main()
{
    long long h,a,t=0,n;
    cin>>h>>n;
    while(n--)
    {
        cin>>a;
        t+=a;
    }
    if(h<=t)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ut i=(a);i<(ut)(b);i++)
#define REP(i,b) FOR(i,0,b)
#define ALL(c) c.begin(),c.end()
#define PB push_back
#define cat //cout << __LINE__ << endl;
using namespace std;
typedef long long LL;
typedef double ld;
typedef LL ut;
typedef vector<ut> VI;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<ut,VI> PQ;
const ut INF=1LL<<30;
const int SIZE=2001;
int main(){
	int T,N,D;
	cin >> T;

	REP(i,T){
		cin >> N >> D;
		N--;
		if(N&1) cout << 127*(N+1)-D << endl;
		else    cout << 127*N+D << endl;
	}
	return 0;
}

Measured memory_bytes: 256
from collections import deque

n=int(input())
a=[0]+list(map(int, input().split()))

b=deque()

for i in range(1, n+1):
    if n%2==i%2:
        b.appendleft(a[i])
    else:
        b.append(a[i])

ans=[]

for elem in b:
    ans.append(elem)

print(*ans)

Measured memory_bytes: 32332
#include <bits/stdc++.h>
using namespace std;
 
#define int  long long
const int MOD = 1e9 + 7;

struct node{
  int x, id;	
};

bool cmp(node a, node b){
   return a.x < b. x;	
}

void solve(){
	int n;
	cin >> n;
	vector<node> v(n);
	for (int i = 0; i < n; i++){
	   int val;
	   cin >> val;
	   v[i].x = val;
	   v[i].id = i + 1; 	
	}
   sort(v.begin(), v.end(), cmp);
   for (auto it : v)
     cout << it.id << " ";
}

int32_t main(){
     ios_base::sync_with_stdio(false);
     cin.tie(nullptr);
     solve();	
}


Measured memory_bytes: 2432
#include <iostream>
#include <string.h>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	string s;
	cin>>s;
	int ls=s.size();
	s[5]=' ';
	s[13]=' ';
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
max_a = max(a for a, _ in ab)
dp = [10 ** 18 for _ in range(h + max_a)]

dp[0] = 0
for i in range(1, h + max_a):
    dp[i] = min(dp[i-a] + b for a, b in ab)
print(min(dp[h:]))


Measured memory_bytes: 3832
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pie (3.141592653589)
using namespace std;

const int N = 2e5 + 10;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout << fixed;
	cout.precision(10);
	
	int n;
	cin >> n;
	cout << 1 - n;
	
	return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <tuple>
#include <map>
#include <queue>
#include <set>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int i = 0; i < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back

int main()
{
    string s;
    cin >> s;
    if(s == "SUN"){
        cout << 7 << endl;
    }
    else if(s == "MON"){
        cout << 6 << endl;
    }
    else if(s == "TUE"){
        cout << 5 << endl;
    }
    else if(s == "WED"){
        cout << 4 << endl;
    }
    else if(s == "THU"){
        cout << 3 << endl;
    }
    else if(s == "FRI"){
        cout << 2 << endl;
    }
    else if(s == "SAT"){
        cout << 1 << endl;
    }
}

Measured memory_bytes: 256
from sys import stdin
f_i = stdin

N = int(f_i.readline())

adj = [[] for i in range(N)]
for i in range(N - 1):
    A, B = map(int, f_i.readline().split())
    A -= 1
    B -= 1
    adj[A].append(B)
    adj[B].append(A)

mod = 10 ** 9 + 7

pow2 = [1] * (N + 1)
for i, j in zip(range(N), range(1, N + 1)):
    pow2[j] = pow2[i] * 2 % mod

from sys import setrecursionlimit
setrecursionlimit(10 ** 6)

ans = 0

def dfs(node, parent):
    global ans
    cnt = 1
    
    for child in adj[node]:
        if child != parent:
            cnt += dfs(child, node)
    
    ans += (pow2[cnt] - 1) * (pow2[N-cnt] - 1)
    ans %= mod
    
    return cnt

dfs(0, None)

ans = (ans - N * pow2[N-1] + pow2[N] - 1) % mod
ans = ans * pow(pow2[N], mod - 2, mod) % mod

print(ans)

Measured memory_bytes: 174356
#include <iostream>
#include <set>
#include <vector>
#include <iomanip>
#include <numeric>
#include <cfenv>
#include <cmath>
typedef long long int ll;

using namespace std;

void dfs(vector<int> A, int &ans, int N, int M, int Q, vector<vector<ll>> qs)
{

    if (A.size() > 0)
    {

        if (A.size() == N)
        {


           
            for(int j=0 ; j<N;j++){


            }

            int count = 0;

            for (int i = 0; i < qs.size(); i++)
            {

                

                int qd = A[qs[i][1]-1] - A[qs[i][0]-1];

                

                if (qd == qs[i][2])
                {

                    count += qs[i][3];
                }
            }

            ans = max(ans, count);

          

            return;
        }

        else
        {

            A.push_back(A.back());


            while (M >= A.back())
            {

               
                dfs(A, ans, N, M, Q, qs);
                A.back()++;
            }
        }
    }
    
}

int main()
{

    int N, M, Q;

    cin >> N >> M >> Q;

    vector<vector<ll>> qs(Q, vector<ll>(4, 0));

    for (int i = 0; i < Q; i++)
    {

        cin >> qs[i][0] >> qs[i][1] >> qs[i][2] >> qs[i][3];
    }

    int maxc = 0;

    vector<int> A(1);



        int l = 1;

        while (M >= l)
        {

            A[0] =l;

            dfs(A, maxc, N, M, Q, qs);
            l++;
        }
    


    cout << maxc << endl;

    return 0;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back

using namespace std;

#define DEBUG_IS_VALID

#ifdef DEBUG_IS_VALID
#define DEB 1 
#else
#define DEB 0
#endif
#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline void chmax(T& a,T const& b){a=max(a,b);}
template<class T> inline void chmin(T& a,T const& b){a=min(a,b);}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<60; 

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N,M; cin >> N >> M;
  vvl x(N,vl(3));
  rep(i,N) cin >> x[i][0] >> x[i][1] >> x[i][2];
  vi ind(N); iota(ind.begin(),ind.end(),0);
  function<ll(vi&)> cnt = [&](vi& index){
    ll c1,c2,c3; c1 = c2 = c3 = 0;
    rep(i,M){
      c1 += x[index[i]][0]; c2 += x[index[i]][1]; c3 += x[index[i]][2];
    }
    ll res = abs(c1)+abs(c2)+abs(c3);
    c1 = c2 = c3 = 0;
    RREP(i,N-1,N-M){
      c1 += x[index[i]][0]; c2 += x[index[i]][1]; c3 += x[index[i]][2];
    }
    chmax(res,abs(c1)+abs(c2)+abs(c3));
    return res;
  };
  function<ll(int,int,int)> solve = [&](int a,int b,int c){
    ll res = -LINF;
    sort(ind.begin(),ind.end(),[&](int l,int r){
      return a*x[l][0]+b*x[l][1]+c*x[l][2]<a*x[r][0]+b*x[r][1]+c*x[r][2];
    });
    chmax(res,cnt(ind));
    return res;
  };
  ll ans = -LINF;
  rep(s,1<<3){
    ll res = solve((s&1)?1:(-1),((s>>1)&1)?1:(-1),((s>>2)&1)?1:(-1));
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
using namespace std;

int main(){
  int n;
  bool notfirst = false;
  while(cin >> n && n){
    if(notfirst){
      cout << "\n";
    }
    else{
      notfirst = true;
    }
    vector<pair<int, pair<int, string> > > v(n);
    for(int i = 0; i < n; i++){
      string team;
      int w, l, d;
      cin >> team >> w >> l >> d;
      v[i] = make_pair(-(w * 3 + d), make_pair(i, team));
    }
    sort(v.begin(), v.end());
    for(int i = 0; i < n; i++){
      cout << v[i].second.second << "," << -v[i].first << "\n";
    }
  }
  return 0;
}

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

signed main(){
	int n,tmp = 1;
	cin >> n;
	for(int i = 1;i <= n;i++) (tmp *= i) %= MOD;
	cout << tmp << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
const int N=2e6+10;
int a[N],d[N],n;
bool check(int m)
{
    for(int i=1;i<n<<1;i++) d[i]=a[i]>m;
    int l=-1,r=-1;
    for(int i=n-1;i;i--)
    {
        if(d[i]^d[i+1]) continue;
        l=i;break;
    }
    for(int i=n+1;i<n<<1;i++)
    {
        if(d[i]^d[i-1]) continue;
        r=i;break;
    }
    if((!~l)&&(!~r)) return d[n]^(n-1&1);
    if(!~l) return d[r];
    if(!~r) return d[l];
    return n-l>r-n?d[r]:d[l];
}
int main()
{
    scanf("%d",&n);
    for(int i=1;i<n<<1;i++) scanf("%d",a+i);
    int l=1,r=(n<<1)-1;
    while(l<r)
    {
        int mid=l+r>>1;
        if(check(mid))
            l=mid+1;
        else
            r=mid;
    }
    printf("%d\n",l);
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int n;
    scanInt(n);
    bool flag = false;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            if (i * j == n) flag = true;
    }}
    if (flag) printYes();
    else printNo();
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

std::vector<std::string> split(std::string str, string del) {
    int first = 0;
    int last = str.find_first_of(del);
 
    std::vector<std::string> result;
 
    while (first < str.size()) {
        std::string subStr(str, first, last - first);
 
        result.push_back(subStr);
 
        first = last + 1;
        last = str.find_first_of(del, first);
 
        if (last == std::string::npos) {
            last = str.size();
        }
    }
 
    return result;
}

int main() {
  int N, M;
  int ans = 0;
  string s = "1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51"; 

  cin >> N;

  vector<string> sp(s.length());
  sp = split(s, ", ");
  // int spn = sp.size();
  // for(int i = 0; i<spn; i+=2 ){
  //   cout << i << " = " << sp[i] << ", ";
  // }

  cout << sp[(N-1)*2] << endl;

}


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

int main(){
  int n;
  cin >> n;
  vector <string> s(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i);
  }
  
  // 重複要素削除
  sort(s.begin(), s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  
  cout << s.size() << endl;
  
  return 0;
}

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

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

    string s,t;
    cin >> s;
    cin >> t;

    for(int i=0;i<n;i++){
        cout << s[i];
        cout << t[i];
    }

    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,from,n) for(int i = from; i < n; i++)
#define mreps(i,from,n) for(int i = from; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll MOD = 1000000007;
int INF = 1001001001;

void solve()
{
    int n; cin >> n;
    vector<double> a(n);
    double ave = 0;
    rep(i, n) {cin >> a[i];ave += a[i];}
    ave /= n;
    int ans = 0;
    double diff = 1000;
    rep(i, n)
    {
        if(chmin(diff,abs(ave-a[i])))
        {
            ans = i;
        }
    }
    cout << ans << endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	long a,b,c,tmp,r,i;
	scanf("%ld %ld",&a,&b);
	c=a*b;
	if(a<b) {
		tmp=a;
		a=b;
		b=tmp;
	}
	r=a%b;
	while(r!=0) {
		a=b;
		b=r;
		r=a%b;
	}
	printf("%ld",c/b);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
double p[3000];
double dp[3000][3000];
double ans=0;
double f(int x,int y)
{ 
  if(x==n)
    {
      if(y>(n-y))
        return 1;
      return 0;
    }
  if(dp[x][y]!=-1)
    return dp[x][y];
  dp[x][y]=f(x+1,y+1)*p[x]+f(x+1,y)*(1-p[x]);
  return dp[x][y]; 
}
int32_t main()
{  
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>p[i];
  for(int i=0;i<3000;i++)
    for(int j=0;j<3000;j++)
      dp[i][j]=-1;
  cout<<setprecision(10)<<f(0,0);
}


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

int main(){

	int height[10];

	for(int i=0;i<10;i++){
		cin >> height[i];

	}

		for (int j=0;j<10;j++){
			for (int k=0;k<10;k++){
				if (height[j]<height[k]){
					int tmp;
					tmp=height[j];
					height[j]=height[k];
					height[k]=tmp;
				}
			}
		}

		for(int m=9;m>6;m--){
			cout<<height[m]<<endl;
		}



    return 0;
}

Measured memory_bytes: 1160
import heapq

N,K = map(int,input().split(' '))
pn = list(map(int,input().split(' ')))
#Sn = [0] * N
#Sn[0] = pn[0]
#for i in range(1,len(pn)):
#    Sn[i] = Sn[i-1] + pn[i]
kakuritsu = [0] * N 
num_list = [0] * 1001
num_list[0] = 0
for i in range(1,1001):
    num_list[i] = num_list[i-1] + i

for i in range(N):
    if i != 0:
        kakuritsu[i] = kakuritsu[i-1] + ( num_list[pn[i]] / pn[i] )
    else:
        kakuritsu[i] = num_list[pn[i]] / pn[i]

max_sn = [0] * N

for i in range(N-K+1):
    if i != 0:
        max_sn[i] = ( kakuritsu[i-1+K] - kakuritsu[i-1]   ) * (-1)
    else:
        max_sn[i] = kakuritsu[i-1+K] * (-1)

heapq.heapify(max_sn)
print(heapq.heappop(max_sn) * (-1))

Measured memory_bytes: 92808
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		Map<String, Integer> map = new HashMap<String, Integer>();
		for(int i = 0; i < N; i++) {
			map.merge(sc.next(), 1, (v1, v2) -> (v1 + v2));
		}
		int M = sc.nextInt();
		for(int i = 0; i < M; i++) {
			String t = sc.next();
			if(map.containsKey(t)) {
				map.put(t, map.get(t) - 1);
			}
		}
		sc.close();
		int max = 0;
		for(String k : map.keySet()) {
			max = Math.max(max, map.get(k));
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 28620
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if (a<=b*c)
		cout<<"Yes";
	else
		cout<<"No";
	re 0;
}


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

typedef pair <int, int> pii;

const int MAXN = 2e5 + 5;

int N;
int a[MAXN];
unordered_map <int, int> num;
set <pii> inter;
	
bool check(int k) {
	num.clear();
	inter.clear();
	
	for (int i = 1; i < N; i++) {
		if (a[i] > a[i - 1])
			continue;
			
		int j = a[i];
		if (!inter.empty()) {
			auto it = inter.lower_bound({j + 1, j + 1});
			if (it != inter.begin() && (--it) -> second >= j)
				for (; j >= it -> first && num[j] == k - 1; j--)
					num[j] = 0;
			else	
				num[j] = 0;
		}
		else
			num[j] = 0;
			
		if (!j)
			return false;
		num[j]++;
			
		while (!inter.empty() && inter.rbegin() -> first > j)
			inter.erase(*inter.rbegin());
		
		if (!inter.empty() && inter.rbegin() -> second >= j - 1) {
			pii tmp = *inter.rbegin();
			inter.erase(tmp);
			inter.insert({tmp.first, j});
		}
		else 
			inter.insert({j, j});
	}
	
	return true;
}

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++)
		scanf("%d", a + i);
	
	bool inc = true;
	for (int i = 1; i < N; i++)
		inc &= a[i] > a[i - 1];
	
	if (inc) {
		puts("1");
		return 0;
	}
		
	int lo = 2, hi = N;
	while (lo < hi) {
		int mid = (lo + hi) / 2;
		if (check(mid))
			hi = mid;
		else
			lo = mid + 1;
	}
	
	printf("%d\n", lo);
	
	return 0;
}

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

int main() {
    int D, N;
    cin >> D >> N;
    int cnt = 0;
    for (int i = 1; i < 1e9; i++) {
        int n = i;
        int tmp = 0;
        while (n % 100 == 0) {
            tmp++;
            n /= 100;
        }
        if (tmp == D) {
            cnt++;
        }
        if (cnt == N) {
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
using namespace std;
typedef long long ll;
typedef vector<int> poly;
#define pb push_back
const int rlen=1<<18|1;
char buf[rlen],*ib=buf,*ob=buf;
#define gc() (((ib==ob)&&(ob=(ib=buf)+fread(buf,1,rlen,stdin)),ib==ob)?-1:*ib++)
inline int read() {
  int ans=0;
  char ch=gc();
  while(!isdigit(ch)) ch=gc();
  while(isdigit(ch)) ans=((ans<<2)+ans<<1)+(ch^48),ch=gc();
  return ans;
}
namespace modular {
  const int mod=998244353;
  inline int add(int a,int b) { return a+b<mod?a+b:a+b-mod; }
  inline int dec(int a,int b) { return a<b?a-b+mod:a-b; }
  inline int mul(int a,int b) { return (ll)a*b%mod; }
  inline void Add(int&a,int b) { a=a+b<mod?a+b:a+b-mod; }
  inline void Dec(int&a,int b) { a=a<b?a-b+mod:a-b; }
  inline void Mul(int&a,int b) { a=(ll)a*b%mod; }
  inline int ksm(int a,int p) { int ret=1;for(;p;p>>=1,Mul(a,a)) (p&1)&&(Mul(ret,a),1);return ret; }
  inline int Inv(int a) { return ksm(a,mod-2); }
}
using namespace modular;
ll n,a,b;
int main() {
  #ifdef ldxcaicai
  freopen("lx.in","r",stdin);
  #endif
  cin>>n>>a>>b;
  ll t=a<b?b-a:a-b;
  if(!(t&1)) cout<<t/2;
  else cout<<min(min(a,b)-1,n-max(a,b))+1+(t-1)/2;
  return 0;
}

Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 20

# 0<= L < R <= 2*10^9 
L, R = [int(x) for x in stdin.readline().rstrip().split()]
MODN = 2019

#if R < 2019:
#    print(L*R)
#    exit()

ans = INF
for i in range(L, L + 2019 + 3):
    if i > R:
        break
    for j in range(i+1, L + 2019 + 3):
        if j > R:
            break

        tmp = (i * j) % MODN
        ans = min(ans, tmp)

print(ans)



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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int, int> pii;
const int mod = (int)1e9 +7;

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	ll n,a,b;
	cin >>n >>a >>b;
	VI x(n);
	rep(i,n) cin >> x[i];
	ll ans =0;
	rep(i,n-1){
		ll ky=x[i+1]-x[i];
		if( a*ky > b) ans +=b;
		else ans += a*ky;
	}
	cout << ans <<endl;
	return 0;

}


Measured memory_bytes: 640
#include <iostream>
#define N 20
using namespace std;
int n,k,s,C;
void Ess(int,int,int);
int main(){
  bool r;
  while(1){
    cin >> n >> k >> s;
    if(n==0&&k==0&&s==0) break;
    C=0;
    Ess(0,0,0);
    cout << C << endl;
  }
  return 0;
}
void Ess(int x,int sum,int cnt){
  if(n==x){
    if(cnt==k&&sum==s) C++;
    return ;
  }
  Ess(x+1,sum,cnt);
  Ess(x+1,sum+x+1,cnt+1);
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(){

  int a,b,r;

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

  if(a<b){

    r=a;
    a=b;
    b=r;

}

  while(1){

    r=a%b;
    if(r==0) break;
    a=b;
    b=r;

}

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

  return 0;

}

Measured memory_bytes: 1024
<?php
  
$a = fgets(STDIN);
$a = explode(" ", $a);
$k = intval($a[0]);
$s = intval($a[1]);

$count = 0;
$z = 0;
for($x = 0; $x <= $k; $x++){
  for($y = 0; $y <= $k; $y++){
    $z = $s - ($x + $y);
    if($z >= 0 && $z <= $k){
      $count++;
    }
  }
}
echo $count;
?>

Measured memory_bytes: 3576
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
	int j=0;
	string str;
	char ans[20];
	cin >> str;
	for(int i=str.size()-1;i>=0;i--){
		ans[j] = str[i];
		j++;
	}
	ans[j] = '\0';
	cout << ans << endl;
	return 0;
}

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

int main(){
    string S;
    cin >> S;
    int s = 0;
    int ans = 0;
    for(int i = 0; i < S.size();i++){
        if(S[i] == 'S'){
            s++;
        }else if(S[i] == 'T'){
            if(s > 0){
                ans++;
                s--;
            }
        }
        //cout << ans << endl;
    }
    cout <<S.size() - ans*2 << endl;
    
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for( int i = 0 ; i < n ; i++ )
typedef long long ll ;
int main() {
int N , M ;
cin >> N >> M ;
vector<ll> A(N) ;
vector<ll> B(N) ;
int count = 0 ;
ll sum = 0 ;
rep(i,N) cin >> A.at(i)  >> B.at(i) ;
map<ll,ll> score ;
rep(i,N) score[A.at(i)] += B.at(i) ;
for(auto p : score ) {
auto key = p.first ;
auto value = p.second;
  //cout << key <<endl ;
  //cout << value <<endl ;
for(int j = 0; j < value ; j++ ){
sum += key ;
  count++  ;
if( count == M ){
  cout << sum << endl;
  return 0 ; 
}
		}
	}
}

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

void Main()
{
    long n, k;
    cin >> n >> k;

    long num = 0;
    long a = 0, b = 0;
    for (int i = 0; i < k-1; i++)
    {
        a += i;
        b += n - i;
    }
    for (int i = k; i <= n+1; i++)
    {
        a += i - 1;
        b += n+1 - i;
        num = (num + (b-a+1)) % (1000000000LL + 7);
    }

    cout << num << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}

int main() {
  string a,b;
  cin>>a>>b;
  cout<<b<<a;
}

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

int main()
{
  // input the data
  int N,M;
  cin >> N >> M;

  vector<int> s(M);
  vector<int> c(M);
  for(int i=0; i<M; i++){
    cin >> s.at(i) >> c.at(i);
  }
  
  string r(N+1,'0');
  r.at(0)='1';
  int max=stoi(r);
  int min;
  if(N==1){
    min=0;
  }
  else{
    r.pop_back();
    min=stoi(r);
  }
  
  // check the numbers
  for(int i=min; i<max; i++){
    string str=to_string(i);
    bool b=true;
    for(int j=0; j<M; j++){
      if( str.at(s.at(j)-1) != '0'+c.at(j)) b=false;
    }
    if (b==true){
      cout<<i<<endl;
      return 0;
    }
  }
  
  cout << -1 << endl;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pdl = pair<double,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr ll inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

ll numofbits5(long bits)
{
  bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
  bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
  bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
  bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
  return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}
vector<string> f;
vector<ll> w,s;
int n;
ll sumW;
double g = inf;
vector<int> ans;
void rdp(int st,int k,vector<vector<pdl>> &dp,vector<int> v){
  int bfr = st & ~(1 <<k);
  ll W = dp[st][k].se ;
  W -= w[k];
  v.push_back(k);
  if(bfr == 0){
    ans = v;
    return ;
  }
  ll G = dp[st][k].fi ;
  REP(i,0,n){
    if(bfr & (1 << i) && G - numofbits5(st) * w[k] == dp[bfr][i].fi){
      rdp(bfr,i,dp,v);
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  while(cin>>n&&n){
    f.clear(); f.resize(n); w.clear(); w.resize(n); s.clear(); s.resize(n);
    sumW =0;
    rep(i,n){
      cin >> f[i] >> w[i] >> s[i];
      sumW += w[i];
    }
    vector<vector<pdl>> dp(1 << n,vector<pdl>(n,mp(inf,1)));
    rep(i,n){
      if(sumW - w[i] <= s[i]){
        dp[1 << i][i] = mp(w[i],w[i]);
      }
    }
    rep(i,1 << n){
      rep(j,n){
        if((i & (1 << j)) == 0 || dp[i][j].fi == inf) continue;
        rep(k,n){
          if(i & (1 << k)) continue;
          int nxt = i | (1 << k);
          double G = dp[i][j].fi + (numofbits5(nxt)) * w[k];
          ll W = dp[i][j].se + w[k];
          if(1.0 * G / W < 1.0 * dp[nxt][k].fi / dp[nxt][k].se && sumW - W <= s[k]){
            dp[nxt][k] = mp(G,W);
          }
        }
      }
    }
    int st = (1 << n) -1;
    double ansg = inf;
    int suf = -1;
    REP(i,0,n){
      if(1.0 * dp[st][i].fi / dp[st][i].se < ansg){
        ansg = 1.0 * dp[st][i].fi / dp[st][i].se ;
        suf = i;
      }
    }
    vector<int> v(0);
    rdp(st,suf,dp,v);
    reverse(all(ans));
    rep(i,ans.size()){
      cout << f[ans[i]] << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3288
#include<iostream>
#include<vector>
using namespace std;
#define int long long
#define V vector
#define vel V<int>
#define rep(i,n) for(int i=0;i<n;i++)
#define mkp make_pair
#define pin pair<int,int>
pin solve(V<pin>& ab, int ex) {
	if (!ex) { return mkp(1, 0); }
	V<V<pin>> qab(2);
	for (pin x : ab) {
		qab[x.second & 1].push_back(mkp(x.first / 2, x.second / 2));
		if (x.first & 1) { qab[(x.second + 1) & 1].push_back(mkp(x.first / 2, (x.second + 1) / 2)); }
	}
	V<vel> c(2, vel(2));
	rep(i, 2) {
		for (pin x : qab[i]) {
			int qc = (2 * x.first + x.second) % 3;
			if ((qc + 1) % 2) { c[i][0] ^= 1; }
			if (qc) { c[i][1] ^= 1; }
		}
	}
	rep(i, 2) {
		if (!c[1 - i][0] && !c[1 - i][1]) {
			pin ans = solve(qab[i], ex - 1);
			ans.first *= 2; ans.second *= 2; ans.second += i;
			return ans;
		}
	}
	for (pin& v : ab) { v.first++; }
	pin ans = solve(ab, ex); ans.first--;
	return ans;
}
signed main() {
	long long inf = 1e17;
	int n; scanf("%lld", &n);
	V<pin> ab(n);
	rep(i, n) {
		long long a, b; scanf("%lld", &a); scanf("%lld", &b);
		ab[i] = { a + inf,b + inf };
	}
	pin ret = solve(ab, 60);
	cout << ret.first - inf << " " << ret.second - inf;
}

Measured memory_bytes: 11504
s = 0
mn = 10
for i in range(5):
  a = int(input())
  q, mod = divmod(a, 10)
  if mod == 0:
    s += a
  else:
    s += a - mod + 10
    mn = min(mn, mod)
if mn != 10:
  print(s + mn - 10)
else:
  print(s)

Measured memory_bytes: 2940
"""
Writer: SPD_9X2
https://atcoder.jp/contests/agc043/tasks/agc043_b

まず、1度計算して 0,1,2の問題にしてよい

1が含まれているとき、答えが2にならない証明
途中経過に2が含まれていないと、2にはならない
→1が含まれているかつ、偶数がある場合、次は必ず1が含まれる
→偶数が消えない場合、最後まで1が残る
→最後まで2が消えない場合、最後は1になってしまうので×
よって、答えが2になるのは0,2のみのとき
→この時は2で割っておいて、最後に2を掛ければよい
"""
N = int(input())

div2_num = [0]
for i in range(1,N+1):

    cnt = 0
    while i % 2 == 0:
        cnt += 1
        i //= 2
    div2_num.append(div2_num[-1] + cnt)

#print (div2_num)

def EO_nCr(n,r): #nCr%2を返す

    if div2_num[n] - (div2_num[n-r] + div2_num[r]) > 0:
        return 0
    else:
        return 1



A = list(map(int,list(input())))
#print (A)

a = []

for i in range(N-1):
    a.append(abs(A[i]-A[i+1]))



if 1 not in a:
    for i in range(N-1):
        a[i] = a[i] // 2
    lastk = 2
else:
    lastk = 1


ans = 0

for i in range(N-1):

    ans ^= (a[i]%2) * EO_nCr(N-2,i)

    #print (N-2,i,EO_nCr(N-2,i))

print (ans * lastk)



Measured memory_bytes: 139928
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] floors = new int[N+1];
		boolean[] results = new boolean[N+1];
		for(int i=1;i<=N;i++){
			floors[i] = sc.nextInt();
			results[i] = true;
		}
		int floor =1;
		int count = 0;
		while(true){
			if(floor == 2){
				System.out.println(count);
				return;
			} else if(!results[floor]){
				System.out.println(-1);
				return;
			} else {
				results[floor] = false;
				floor = floors[floor];
				count++;
			}
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r;
	cin >> r;
	if(r < 1200) cout << "ABC" << endl;
	else if (r < 2800) cout << "ARC" << endl;
	else cout << "AGC" << endl;
}


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

const int nm = 2e5;
int n, q, w, h, c[nm - 1], r[nm - 1];
ll ans;

int main() {
	cin >> n >> q;
	w = n - 1;
	h = n - 1;
	ans = (ll) (n - 2) * (n - 2);

	for (int i = 0; i < q; ++i) {
		int a, x;
		cin >> a >> x;
		--x;
		if (a == 1) {
			if (x < w) {
				ans -= h - 1;
				for (int i = x + 1; i < w; ++i)
					c[i] = h - 1;
				w = x;
			} else {
				ans -= c[x];
			}
		} else {
			if (x < h) {
				ans -= w - 1;
				for (int i = x + 1; i < h; ++i)
					r[i] = w - 1;
				h = x;
			} else {
				ans -= r[x];
			}
		}
	}

	cout << ans << endl;
}


Measured memory_bytes: 5144
fun main(args: Array<String>) {
    val (h, w, m) = readIntList()

    val hc = IntArray(h)
    val wc = IntArray(w)

    val tar = mutableSetOf<Pair<Int, Int>>()
    repeat(m) {
        val (hh, ww) = readIntList().map { it - 1 }
        tar.add(hh to ww)
        hc[hh]++
        wc[ww]++
    }

    val hMax = hc.max()!!
    val wMax = wc.max()!!

    val lsH = hc.withIndex().filter { it.value == hMax }.map { it.index }
    val lsW = wc.withIndex().filter { it.value == wMax }.map { it.index }

    val ans = hMax + wMax
    lsH.forEach { i ->
        lsW.forEach { j ->
            if (!tar.contains(i to j)) {
                println(ans)
                return
            }
        }
    }
    println(ans - 1)
}

// read
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

Measured memory_bytes: 114764
#include <iostream>
#include <utility>

using namespace std;

typedef unsigned long long BigInt;

BigInt gcd(BigInt a, BigInt b) {
  if (a < b) {
    swap(a, b);
  }
  while (b > 0) {
    a %= b;
    swap(a, b);
  }
  return a;
}

BigInt lcm(BigInt a, BigInt b) {
  return a * b / gcd(a, b);
}

int main() {
  int n;
  BigInt dh, vh;
  BigInt d[10], v[10];
  while (true) {
    cin >> n;
    if (n == 0) {
      return 0;
    }
    for (int i = 0; i < n; ++i) {
      cin >> d[i] >> v[i];
    }
    dh = d[0];
    vh = v[0];
    for (int i = 1; i < n; ++i) {
      BigInt y = lcm(v[i] * dh, vh * d[i]);
      BigInt kh = y / (v[i] * dh);
      BigInt z = gcd(dh * kh, vh);
      dh = dh * kh / z;
      vh /= z;
    }
    for (int i = 0; i < n; ++i) {
      cout << dh * v[i] / (d[i] * vh) << endl;
    }
  }
}

Measured memory_bytes: 1160
// 模擬国内予選 2014 A 踏み台昇降
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            int n = sc.nextInt();
            if (n == 0) {
                break;
            }
            
            int ans = 0;
            boolean isUp = false;
            boolean isDown = false;
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                if (s.charAt(1) == 'u') {
                    if (isUp) {
                        ans++;
                        isUp = false;
                    } else if (isDown) {
                        isDown = false;
                    } else {
                        isUp = true;
                    }
                } else {
                    if (isUp) {
                        isUp = false;
                    } else if (isDown) {
                        ans++;
                        isDown = false;
                    } else {
                        isDown = true;
                    }
                }
            }
            System.out.println(ans);
        }
    }
}

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

int n,m,flag=1;
string u;
map<string,int>mp;

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u;
    mp[u]=1;
  }
  
  cin>>m;
  for(int i=0;i<m;i++){
    cin>>u;
    if(mp.count(u)){
      if(flag){cout<<"Opened by "<<u<<endl;flag=0;}
      else{cout<<"Closed by "<<u<<endl;flag=1;}
    }
    else cout<<"Unknown "<<u<<endl;
  }
}

Measured memory_bytes: 1236
// https://atcoder.jp/contests/abc132/tasks/abc132_a

#include <stdio.h>
#define forn(i,L,R) for (int i = L; i < R; i++)
#define getString(x) scanf("%s", x)

int main(){
    char x[5];
    getString(x);
    char a, b;
    int aCnt = 0, bCnt = 0;
    a = x[0];
    forn(i, 1, 4){
        if (x[i] != a){
            b = x[i];
            break;
        }
    }
    forn(i, 0, 4){
        if (x[i] == a) aCnt++;
        else if (x[i] == b) bCnt++;
    }
    
    if (aCnt == 2 && bCnt == 2) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int GCD(int a,int b)
{
  return (b?GCD(b,a%b):a);
}
int main()
{
  long long A,B;
  cin>>A>>B;
  cout<<A*B/GCD(A,B);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <fstream>
#include <queue>
#include <deque>
#include <numeric>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long LL;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef vector< LL > vl;
typedef vector< vl > vvl;
typedef vector< bool > vb;
typedef pair <int, int> ii;
#define tr(c,it) for(decltype(c.begin()) it = c.begin(); it != c.end(); it++)
#define rep(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define repr(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define pb push_back
#define mp make_pair
#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define in(a,b) ( (b).find(a) != (b).end())


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

	int n;
	cin >> n;

	vvi abc(3, vi(n));
	rep(j, n) 
		rep(i, 3) 
			cin >> abc[i][j];

	vvi m(3, vi(n));
	rep(i, 3) m[i][0] = abc[i][0];

	repr(i, 1, n) {
		m[0][i] = abc[0][i] + max(m[1][i-1], m[2][i-1]);
		m[1][i] = abc[1][i] + max(m[0][i-1], m[2][i-1]);
		m[2][i] = abc[2][i] + max(m[1][i-1], m[0][i-1]);
	}

	cout << max({m[0][n-1], m[1][n-1], m[2][n-1]});
}


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <iostream>
#include <tuple>
#include <cmath>
#include <string>

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

bool f(int m){
    return 1<=m and m<=12;
}

int main()
{
    string s;
    cin >> s;
    int p1 = stoi(s.substr(0,2));
    int p2 = stoi(s.substr(2,2));
    if(f(p1) && f(p2)){ cout << "AMBIGUOUS" << endl;}
    else if(f(p1)){cout << "MMYY"<<endl; }
    else if(f(p2)){cout << "YYMM" << endl;}
    else{cout << "NA"<<endl;}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <utility>
#include <cstdio>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n, m) for (int i = n; i >= m; i--)

template <class T>
bool contain(const std::string &s, const T &v)
{
    return s.find(v) != std::string::npos;
}

int func(int n){
    if(n%2==0){
        return n/2;
    }else{
        return 3*n+1;
    }
}

int main()
{
    int n,h[105]={},ans=0;
    cin>>n;
    rep(i,n)cin>>h[i];

    rep(i,n){
        if(h[i]>h[i+1]){
            ans += h[i] - h[i+1];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rf(i,a,b) for(ll i=a;i>=b;i--)
#define sf(i,s) for(ll i=0;s[i]!='\0';i++)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define inf 1e18
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tr(v,i) for(typeof(v).begin() i = v.begin(); i != v.end(); i++)
#define pre(v,x) (v.find(x) != v.end())
#define vpre(v,x) (find(all(v),x) != v.end())
#define gcd(x,y) __gcd(x,y)
#define bc(x) __builtin_popcountll(x)
//cin.ignore(1, '\n');
ll power(ll a, ll b)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a % mod;
    else
    {
        ll t = power(a, b / 2);
        if (b % 2 == 0)
            return ((t % mod) * (t % mod)) % mod;
        else
            return ((((t % mod) * (t % mod)) % mod) * ((a % mod) % mod)) % mod;
    }
}
ll par[200001],R[200001];
ll find1(ll x)
{
    if(par[x]<0)
    return x;
    else return par[x]=find1(par[x]);
}
void union1(ll x,ll y)
{
    x=find1(x);
    y=find1(y);
    if(x==y)
    return;
    if(R[x]>=R[y])
    {
        par[x]+=par[y];
        par[y]=x;
        R[x]+=R[y];
    }
    else
    {
         par[y]+=par[x];
        par[x]=y;
        R[y]+=R[x];
    }
    
}
void solve()
{
  ll n,i,m,x,y;
  cin>>n>>m;
  f(i,0,n+1)
  {
      par[i]=-1;
      R[i]=1;
  }
  f(i,0,m)
  {
      cin>>x>>y;
      union1(x,y);
  }
  ll ans=-1;
  f(i,1,n+1)
  {
      if(par[i]<0)
      {
        par[i]=abs(par[i]);
        ans=max(ans,par[i]);
      }
  }
  cout<<ans<<"\n";
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t = 1;
   // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}


Measured memory_bytes: 6740
n = int(input())
s = input()

count_e = [0] * n
count_w = [0] * n
for i in range(n):
    if i == 0:
        if s[i] == 'E':
            count_e[i] = 1
        else:
            count_w[i] = 1
        continue
    if s[i] == 'E':
        count_e[i] = count_e[i-1] + 1
        count_w[i] = count_w[i-1]
    else:
        count_e[i] = count_e[i-1]
        count_w[i] = count_w[i-1] + 1

ans = 10 ** 9
for i in range(n):
    if s[i] == 'E':
        e = count_e[-1] - count_e[i]
        w = count_w[i]
    else:
        e = count_e[-1] - count_e[i]
        w = count_w[i] - 1
    ans = min(ans,e+w)
print(ans)

Measured memory_bytes: 17652
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int N = Integer.parseInt(S[0]);
    int K = Integer.parseInt(S[1]);
    
    int[] nums = new int[N];
    for(int i = 0; i < N; i++){
      nums[i] = Integer.parseInt(sc.next());
    }
    
    double[] p = new double[1001];
    for(int i = 1; i < 1001; i++){
      p[i] = (i+1)/2.0;
    }
    
    double max = 0;
    double now = 0;
    for(int i = 0; i < N; i++){
      if(i < K){
        now += p[nums[i]];
      }else{
        now += p[nums[i]];
        now -= p[nums[i-K]];
      }
      max = Math.max(max, now);
    }
    System.out.println(max);
  }
}

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

int main(){

  int i,j,N,tmp,b,flag = 1,cnt=0;

  scanf("%d",&N);

  int A[N];

  if(N<1 && N>100) exit(1);

  for(i=0; i<N; i++){
    scanf("%d",&A[i]);
    if(A[i]<0||A[i]>100) exit(2);
  }

  while(flag){
    flag = 0;
    for(j=N-1; j>0; j--){
      if(A[j] < A[j-1]){
        tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        flag = 1;
        cnt++;
      }
    }
  }

  for(i=0; i<N; i++){
    if(i!=0) printf(" %d",A[i]);
    else printf("%d",A[i]);
  }
  
  printf("\n%d\n",cnt);
  
  return 0;
}


Measured memory_bytes: 2108
#n = int(input())
n,m = map(int,input().split())
h_L = list(map(int,input().split()))

def check(origin,target):
    return origin > target

dic = {}
for i in range(n):
    dic[i] = []

for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1

    tmp = check(h_L[a],h_L[b])
    dic[a].append(tmp)
    tmp = check(h_L[b],h_L[a])
    dic[b].append(tmp)

#print(dic)

ans = 0
for k,v in dic.items():
    try:
        if v[0] and len(set(v)) ==1:
            ans += 1
    except:
        ans += 1
print(ans)

Measured memory_bytes: 31644