akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    string s;
    cin >> s;
    for (int i = 0; i < a + b + 1; i++)
    {
        if (i == a)
        {
            if (s[i] != '-')
            {
                cout << "No" << endl;
                return 0;
            }
            else
            {
                continue;
            }
        }
        else
        {
            int num = s[i] - '0';
            if (!(0 <= num && num <= 9))
            {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
   
typedef struct{
    int k;
    int l;
    int r;
} Node;
   
void insert(Node*, int, int);
void print1(Node*, int);
void print2(Node*, int);
   
int main()
{
    char s[10];
    Node *t;
    int m;
    int a;
    int i;
   
    scanf("%d", &m);
    t=(Node*)malloc(sizeof(Node)*m);
   
    int count=0;
    for(i=0; i<m; i++){
        scanf("%s", &s);
        if(s[0]=='i'){ scanf("%d", &a); insert(t, count, a); count++; }
        if(s[0]=='p'){
            if(count>0) print1(t, 0);
            printf("\n");
            if(count>0) print2(t, 0);
            printf("\n");
        }
    }
       
    return 0;
   
}
   
void print1(Node *t, int p)
{
    if(t[p].l>=0) print1(t, t[p].l);
    printf(" %d", t[p].k);
    if(t[p].r>=0) print1(t, t[p].r);
}
   
void print2(Node *t, int p)
{
    printf(" %d", t[p].k);
    if(t[p].l>=0) print2(t, t[p].l);
    if(t[p].r>=0) print2(t, t[p].r);
}
   
void insert(Node *t, int count, int z)
{
    int x=0, y;
    if(count<1) x=-1;
   
    t[count].k= z;
    t[count].l = -1;
    t[count].r= -1;
   
    while(x>=0){
        y = x; 
        if(z < t[x].k)
            x = t[x].l; 
        else
            x = t[x].r; 
    }
   
    if(count<1){}
    else if(z < t[y].k){
        t[y].l = count; 
    }
    else {
        t[y].r = count;
    }
}

Measured memory_bytes: 8436
#include<iostream>
#include<cstring>
using namespace std;
#define R 0
#define L 1
int main(){
    string s;
    cin>>s;
    int H[1000000];
    int color=R;
    int k=0,l=0;
    int n=s.length();
    for(int i=0;i<n-1;i++){
        if(color==R){
            if(s[i+1]=='R'){
                k++;
                H[i]=0;
            }
            else{
                H[i]=1+k/2;
                H[i+1]=1+k-k/2;
                k=0;
                color=L;
            }
        }
        else{
            if(s[i+1]=='L'){
                l++;
                s[i+1]=0;
            }
            else{
                H[i-l]+=l/2;
                H[i-l-1]+=l-l/2;
                l=0;
                color=R;
            }
        }
    }
    H[n-1-l]+=l/2;
    H[n-2-l]+=l-l/2;

    for(int i=0;i<n;i++){
        if(i==0) cout<<H[i];
        else cout<<" "<<H[i];
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1024
// Problem : B - ... (Triple Dots)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 100005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub uppper_bound
using namespace std;
void solve()
{
	int k;
	cin >> k;
	string s;
	cin >> s;
	if(s.size() <= k)
	{
		cout << s;
		return;
	}
	else{
		string temp = s.substr(0,k);
		temp+="...";
		cout << temp;
		return;
	}
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}

Measured memory_bytes: 3600
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
signed main()
{
	int H, W, h, w;
	cin >> H >> W >> h >> w;
	int ans = H * W - W * h - H * w + h * w;
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int field[9][9];
char afield[9][19];

void search(int x,int y) {
  bool check=true;
  int temp = field[x][y];

  for(int i=0;i<9;i++) { //tate
    if(field[i][y] == temp && i != x){
      check = false;
    }
  }

  for(int i=0;i<9;i++) { //yoko
    if(field[x][i] == temp && i != y){
      check = false;
    }
  }

  for(int i=(x/3)*3;i<(x/3)*3+3;i++) { // 3*3 square
    for(int j=(y/3)*3;j<(y/3)*3+3;j++) {
      if((field[i][j] == temp) && (i != x) && (j != y)) {
	check = false;
      }
    }
  }

  if(check) {
    afield[x][y] = ' ';
  }
  else {
    afield[x][y] = '*';
  }
}

void solve() {
  for(int i=0;i<9;i++) {
    for(int j=0;j<9;j++) {
      search(i,j);
    }
  }
}

int main() {
  int n;
  string str;
  bool r=false;
  cin >> n;
  while(n--) {
    if(r) cout << endl;
    for(int i=0;i<9;i++) {
      for(int j=0;j<9;j++) {
	cin >> field[i][j];
      }
    }
    solve();
    for(int i=0;i<9;i++) {
      for(int j=0;j<9;j++) {
	cout << afield[i][j] << field[i][j];
      }
      cout << endl;
    }
    r = true;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	int n;
	cin >> n;
	vll v(n);
	for(ll i = 0; i < n; i++)
		cin >> v[i];
	ll x = 0;
	for(ll i = 0; i < n; i++)
		x ^= v[i];
	for(ll i = 0; i < n; i++){
		cout << (v[i] ^ x) << ' ';
	}
	cout << endl;
}

Measured memory_bytes: 4780
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
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; }

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<ll>> next(60, vector<ll>(n)); //ダブリング
  vector<int> prev(200010, -1);
  rep(i, 2) {
    rep(j, n) {
      if (prev[a[j]] != -1)
        next[0][prev[a[j]]%n] = n*i+j-prev[a[j]]+1; //同じ値までの距離+1
      prev[a[j]] = n*i+j; //座標
    }
  }
  for (int i=1; i<60; i++) {
    rep(j, n) {
      next[i][j] = next[i-1][j]+next[i-1][(next[i-1][j]+j)%n];
    }
  }

  ll start = 0, sum = 0;
  while (1) {
    int power = 0;
    rep(i, 60) {
      if (next[i][start]+sum >= n*k) {
        power = i-1;
        break;
      }
    }
    if (power == -1)
      break;
    sum += next[power][start];
    start = sum%n;
  }

  vector<bool> used(200010);
  deque<int> ans;
  for (int i = start; i < n; i++) { //残りの長さはn以下
    if (!used[a[i]]) {
      ans.push_back(a[i]);
      used[a[i]] = true;
    } else {
      while (1) {
        int tmp = ans.back();
        ans.pop_back();
        used[tmp] = false;
        if (tmp == a[i])
          break;
      }
    }
  }
  while (!ans.empty()) {
    printf("%d%c", ans.front(), ans.size()>1?' ':'\n');
    ans.pop_front();
  }
  return 0;
}

Measured memory_bytes: 97764
// teleporter.cpp

#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <unordered_map>
#include <queue>
#include <stack>
#include <cmath>
#include <functional>
#include <deque>
#include <bitset>
#include <climits>
#include <cstdio>
#include <list>
#include <iomanip>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ll long long int

int main() {
	fastIO


	ll n, k;
	cin >> n >> k;
	vector<ll> arr(n + 1);
	vector<ll> vec(n + 1 , -1);

	for (int i = 0 ; i < n ; i++)
	{
		cin >> arr[i];
		arr[i]--;
	}

	//memset(vec, -1, sizeof vec);
	vec[0] = 0;
	ll c = 0 ;
	ll pos = 0;
	while (true)
	{

		c++;
		pos = arr[pos];

		if (c == k)
		{
			cout << pos + 1;
			return 0;

		}


		if (vec[pos] >= 0)
		{
			int p = c - vec[pos];
			int x = (k - c) % p;
			//pos = p;
			for (int i = 0 ; i < x ; i ++)
			{
				pos = arr[pos];

			}
			cout << pos + 1 ;
			return 0;

		}


		vec[pos] = c;


	}



	return 0;
}

Measured memory_bytes: 6260
def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()
    
    array_result.append(data.split(" "))

    flg = 1

    try:

        while flg:

            data = input()

            if(data != ""):
                
                array_result.append(data.split(" "))

            else:

                flg = 0
    finally:

        return array_result

arr_data = getinputdata()
n = int(arr_data[0][0])

maxdata=int(arr_data[1][0])
point=int(arr_data[1][1])


for i in range(1,1+n):
    
    a=int(arr_data[i][0])
    b=int(arr_data[i][1])
    
    if maxdata<a:
        maxdata=a
        point=b
        
print(maxdata+point)
    
    

Measured memory_bytes: 33784
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
const int INF = 1 << 25;
int dp[1001][1001];
int main() {
	string s1, s2;
	cin >> s1 >> s2;
	fill((int*)dp, (int*)(dp + 1001), INF);
	for (int i = 0; i <= s1.size(); i++) dp[i][0] = i;
	for (int i = 0; i <= s2.size(); i++) dp[0][i] = i;
	for (int i = 1; i <= s1.size(); i++) {
		for (int j = 1; j <= s2.size(); j++) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
			dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
			dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1]));
		}
	}
	cout << dp[s1.size()][s2.size()] << endl;
}

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

int main()
{
	int n, m;
	cin >> n >> m;
	long long sum = 0;
	for (int i = 0; i < m; i++)
	{
		int j;
		cin >> j;
		sum += j;
	}
	long long last = n - sum;
	cout << (last >= 0 ? last : -1) << endl;
}

Measured memory_bytes: 3632
#include<cstdio>
#define HH puts("")
#define debug puts("haochiyu!")
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, a, n) for (int i = a; i >= n; --i)
namespace io {
	#define N 207
	#define mt long long
	#define in read()
	#define pc putchar
	#define gc getchar()
	#define outk(a) out(a), pc(' ')
	#define outn(a) out(a), pc('\n')
	inline mt read() {
		mt a = 0; char l = ' ', c = gc;
		while (c < '0' || c > '9') l = c, c = gc;
		while (c >= '0' && c <= '9') a = (a << 3) + (a << 1) + (c ^ 48), c = gc;
		return l == '-' ? -a : a;
	} char F[N];
	inline void out(mt a) {
		if (a == 0) {pc('0'); return;}
		if (a < 0) pc('-');
		mt tmp = a < 0 ? -a : a, cnt = 0;
		while (tmp) F[cnt++] = tmp % 10 + '0', tmp /= 10;
		while (cnt) pc(F[--cnt]); return;
	}
	#undef N
	#undef mt
}
using namespace io;
const int inf = 0x3f3f3f3f;
typedef long long ll;

void judge() {
	freopen(".in", "r", stdin);
	freopen(".out", "w", stdout);
}

int n;

int main() {
//	judge();
	n = (int)in;
	out(n & 1 ? n / 2 : n / 2 - 1);
	return 0;
}




Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define LL long long
struct xx {
	int a,b;
	bool operator < (const xx &_) const {
		return a < _.a;
	}
} A[N];

multiset <int> S;
multiset <int> ::iterator it;
int main() {
	int n,m;
	cin >> n >> m;
	for(int i=1; i<=n; i++) scanf("%d%d",&A[i].a,&A[i].b);
	sort(A+1,A+n+1);
	int ans = 0,now = 1;
	for(int i=m; i>=1; i--) {
		while(now <= n && A[now].a+i-1 <= m) S.insert(A[now].b),now ++;
		if(!S.empty()) {
			it = S.end();
			it --;
			ans +=*it;
			S.erase(it);
		}
	}
	cout<<ans;
	return 0;
}


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


int main()
{
    int i, flag=0;
    char s[4];
    cin >> s;
    for(i = 1;i<4;i++){
        if(s[i] == s[i-1]){
            cout << "Bad" << endl;
            flag = 1;
            break;
        }
    }

    if(flag == 0){
        cout << "Good" << endl;
    }

    return 0;
}

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

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  int N;cin>>N;vi a(N);rep(i,N)cin>>a[i];
  vb b(8);
  int cnt=0;
  rep(i,N){
    if(a[i]>=1  &&  a[i]<400)b[0]=true;
    if(a[i]>=400  &&  a[i]<800)b[1]=true;
    if(a[i]>=800  &&  a[i]<1200)b[2]=true;
    if(a[i]>=1200  &&  a[i]<1600)b[3]=true;
    if(a[i]>=1600  &&  a[i]<2000)b[4]=true;
    if(a[i]>=2000  &&  a[i]<2400)b[5]=true;
    if(a[i]>=2400  &&  a[i]<2800)b[6]=true;
    if(a[i]>=2800  &&  a[i]<3200)b[7]=true;
    if(a[i]>= 3200)cnt++;
  }
  int ma=0;
  rep(i,8){
    if(b[i])ma++;
  }
  cout<<max(ma,1)<<" "<<ma+cnt<<endl;
  
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int h, w, n, sr, sc;
    string s, t;

    cin >> h >> w >> n >> sr >> sc;
    cin >> s >> t;

    t[n - 1] = '@';

    bool res = true;

    P p = {1, w};
    for (int i = n - 1; i >= 0; i--)
    {
        if (t[i] == 'R')
            p.first = max(1, p.first - 1);
        if (t[i] == 'L')
            p.second = min(w, p.second + 1);
        if (s[i] == 'R')
            p.second = max(0, p.second - 1);
        if (s[i] == 'L')
            p.first = min(w + 1, p.first + 1);

        if (p.first > p.second || p.first > w || p.second < 1)
            res = false;

        /*
        REP(j, w)
        cout << (j + 1 == p.first || j + 1 == p.second ? "■" : "□");
        cout << endl;
        */
    }

    if ((sc < p.first || p.second < sc))
        res = false;

    p = {1, h};
    for (int i = n - 1; i >= 0; i--)
    {
        if (t[i] == 'D')
            p.first = max(1, p.first - 1);
        if (t[i] == 'U')
            p.second = min(h, p.second + 1);
        if (s[i] == 'D')
            p.second = max(0, p.second - 1);
        if (s[i] == 'U')
            p.first = min(h + 1, p.first + 1);

        if (p.first > p.second || p.first > h || p.second < 1)
            res = false;

        /*
        REP(j, h)
        cout << (j + 1 == p.first || j + 1 == p.second ? "■" : "□");
        cout << endl;
        */
    }

    if ((sr < p.first || p.second < sr))
        res = false;

    cout << (res ? "YES" : "NO") << endl;

    return 0;
}

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

typedef long long ll;
const int N = 2e5+ 7;
const int inf = 1e9 + 7;
const int mod = 1e9 + 7;
#define fi first
#define se second
#define rep(i,a,n) for(int i = a; i <= n; i++)
#define per(i,a,n) for(int i = n; i >= a; i--)
#define pb push_back
#define mp make_pair
typedef pair<int,int> P;

char s[N];
int main()
{
    scanf("%s",s);
	int n =strlen(s);
	for(int i=0;i<n;i++){
        if(s[i]=='?')
            printf("D");
        else
            printf("%c",s[i]);
	}
    printf("\n");
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int a,b;
    cin>>a>>b;
    cout<<max({a+b,a-b,a*b})<<endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    input()
    s,t=input().split()
    ans=""
    for c0,c1 in zip(s,t):
        ans+=c0
        ans+=c1
    print(ans)
main()

Measured memory_bytes: 3064
#include<stdio.h>
int main(void)
{
	int a, b;

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

	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else if (a == b){
		printf("a == b\n");
	}

	return(0);
}

Measured memory_bytes: 1008
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n,k,x,y;

int main(){
  ll ans=0;
  string s;cin>>s;
  vector<string> as={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  REP(i,7){
    if (s==as[i]){
      cout<<(7-i)<<endl;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        String S= sc.next();
        int result = 0;
        for(int i=0;i<N-2;i++){
            if(S.substring(i,i+3).equals("ABC")){
                result++;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 23892
from sys import stdout
printn = lambda x: stdout.write(str(x))
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 999999999
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)
from collections import defaultdict
n = inn()
h = defaultdict(int)
for i in range(n):
    s = ins()
    h[s] += 1
mx = max(list(h.values()))
ss = []
for s in h:
    if h[s]==mx:
        ss.append(s)
ss.sort()
for s in ss:
    print(s)


Measured memory_bytes: 97240
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;

//#define int long long
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
//constexpr int INF = 1e9;//INT_MAX=(1<<31)-1=2147483647
constexpr ll INF = (ll)1e18;//(1LL<<63)-1=9223372036854775807
constexpr ll MOD = (ll)1e9 + 7;
constexpr double EPS = 1e-9;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
#ifdef LOCAL_ENV
	#define debug(var) std::cout<<#var" = "<<var<<std::endl
#else
	#define debug(var)
#endif
#define p(var) std::cout<<var<<std::endl
#define rep(i, n)   for(ll i=0, i##_length=(n); i< i##_length; ++i)
#define repeq(i, n) for(ll i=1, i##_length=(n); i<=i##_length; ++i)
#define all(a) (a).begin(), (a).end()
#define PI (acos(-1))
template<typename T> inline T power(T x, T n){ return n ? power(x*x%MOD,n/2)*(n%2?x:1)%MOD : 1; }
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a; }
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b; }
template<typename T1, typename T2>inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2>inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
	for (int i = 0, len = v.size(); i < len; ++i){
		s << v[i]; if (i < len - 1) s << "\t";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
	for (int i = 0, len = vv.size(); i < len; ++i){
		s << vv[i] << endl;
	}
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
	s << "{" << endl;
	for (typeof(m.begin()) itr = m.begin(); itr != m.end(); ++itr){
		s << "\t" << (*itr).first << " : " << (*itr).second << endl;
	}
	s << "}" << endl;
	return s;
}

/*-----8<-----8<-----*/

constexpr ll N_MAX = 100000;

ll N;
ll p[N_MAX];

void input() {
	scanf("%lld", &N);
	rep(i, N) scanf("%lld", p + i);
}

void solve() {
	ll ans = 0;

	rep(i,N){
		if(i+1==p[i]){
			ans++;
			if(i<N-1)swap(p[i],p[i+1]);
		}
	}

	printf("%lld\n", ans);
}

signed main() {
	input();
	solve();
	return 0;
}


Measured memory_bytes: 1024
using System;

namespace ABC168A
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] s = new string[]{"pon","pon","hon","bon","hon","hon","pon","hon","pon","hon"};
            Console.WriteLine(s[N % 10]);
        }
    }
}


Measured memory_bytes: 27480
#include <stdio.h>
#include <cmath>
#include <bits/stdc++.h>



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int A, B, C, D; cin >> A >> B >> C >> D;

	int left = A + B;
	int right = C + D;
	string s;
	if(left < right) s = "Right";
	else if(left > right) s = "Left";
	else s = "Balanced";

	cout << s << endl;


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll n;
    ll sum = 0;
    ll yo = 1145148931919810;
    bool po = 0;
    cin >> n;
    for(ll i = 0; i < n; i++){
        ll a, b;
        cin >> a >> b;
        sum += a;
        if(a > b){
            po = 1;
            if(b < yo) yo = b;
        }
    }
    cout << (po ? sum - yo : 0) << endl;
    return 0;
}

Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		
		int n = fs.nextInt();
		int m = fs.nextInt();
		
		City[] cityArr = new City[n];
		int[] groupArr = new int[n];
		
		for(int i = 0; i < n; i++) {
			cityArr[i] = new City(i);
		}
		
		for(int i = 0; i < m; i++) {
			int a = fs.nextInt() - 1;
			int b = fs.nextInt() - 1;
			
			cityArr[a].addLoad(b);
			cityArr[b].addLoad(a);
		}
		
		int groupNum = 0;
		for(int i = 0; i < n; i++) {
			if (groupArr[i] != 0) {
				continue;
			}
			
			if(cityArr[i].load.isEmpty()) {
				continue;
			}
			
			groupNum++;
			
			groupArr[i] = groupNum;
			
			ArrayDeque<Integer> queue = new ArrayDeque<>();
			queue.addAll(cityArr[i].load);
			while(!queue.isEmpty()) {
				int cityId = queue.poll();
				if(groupArr[cityId] != 0) {
					continue;
				}
				
				groupArr[cityId] = groupNum;
				queue.addAll(cityArr[cityId].load);
			}
		}
		for(int i = 0; i < n; i++) {
			if(groupArr[i] == 0) {
				groupNum++;
			}
		}
		System.out.println(groupNum-1);
	}
	
	class City {
		int id;
		HashSet<Integer> load;
		
		City(int id){
			this.id = id;
			this.load = new HashSet<>();
		}
		
		void addLoad(int id) {
			load.add(id);
		}
	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 85744
#include<bits/stdc++.h>
using namespace std;
#define mx 1000000000000000000
#define ll long long int
//ll a[40001000];
//ll number[20],used[20];
int main()
{
   //char s[100],t[100],u[100];
   string s;
   cin>> s;
   for(ll i=0;i<s.size();i++)
   {
       s[i]='x';
   }
   cout << s << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
using ll = long long;
using ui = unsigned int;


int main() {
    ll L, R;
    cin >> L >> R;
    ll MOD = 2019;

    ll res = 1000000000000;
    if (R < MOD) {
        for(ll i = L; i < R; i++) {
                for (ll j = i+1; j <= R; j++) {
                    res = min(res, i*j % MOD);
                }       
        }
    } else if (R >= MOD && L <= MOD) {
        res = 0;
    } else {
        ll tmp = (MOD - (L % MOD));
        if (tmp < R - L) {
            res = 0;
        } else {
            for(ll i = L; i < R; i++) {
                for (ll j = i+1; j <= R; j++) {
                    res = min(res, i*j % MOD);
                }       
            }
        }
    }

    cout << res << "\n";
}

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


//#define int long long 

const int N = 2e6 + 7;

int p[N], f[N];

void add(int x) {
	while(x > 1) {
		int y = p[x];
		while(x % y == 0) x /= y;
		f[y]++;
	}
}


int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	for(int i = 2; i < N; i++) if(!p[i]) {
		for(int j = i; j < N; j += i) {
			p[j] = i;
		}
	}

	int n, g = 0; cin >> n;
	for(int i = 1; i <= n; i++) {
		int x; cin >> x;
		g = __gcd(g, x);
		add(x);
	}

	int mx = *max_element(f, f + N);

	if(mx >= 2) {
		cout << (g == 1 ? "setwise coprime" : "not coprime") << endl;
	} else {
		cout << "pairwise coprime" << endl;
	}
}

Measured memory_bytes: 15356
#include <iostream>
#include <string>

int main() {
  std::string S;
  std::cin >> S;

  std::string str = "abcdefghijklmnopqrstuvwxyz";
  int len = str.length();
  for (int i = 0; i < len; ++i) {
    if ( S.find(str[i]) == std::string::npos ) {
      std::cout << str[i] << std::endl;
      return 0;
    }
  }
  std::cout << "None" << std::endl;

  return 0;
}


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

int main() {
	// your code goes here
	char a[3][3];
	int i,j;
	char b[3];
	for(i=0;i<3;i++)
	{
	    for(j=0;j<3;j++)
	    {
	        cin>>a[i][j];
	        if(i==j)
	        b[i]=a[i][j];
	    }
	    cout<<b[i];
	}
	
	return 0;
}


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

int main() {
  int K, S;
  cin >> K >> S;
  int ans = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = K; j >= 0; j--) {
      int k = S - j - i;
      if (k < 0 || K < k) continue;
      ans++;
    }
  }
  cout << ans << endl;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector <int> a(n);
    for(int i=0;i<n;i++)cin >> a[i];

    vector <int> dp(n);

    dp[0] = 0;
    dp[1] = abs(a[1] - a[0]);

    for(int i=2;i<n;i++)
    {
        dp[i] = min(dp[i-1]+abs(a[i] - a[i-1]),dp[i-2]+abs(a[i] - a[i-2]));
    }

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

Measured memory_bytes: 1024
n = int(input())
a = [[i, int(input())] for i in range(n)]
a.sort(reverse=True, key=lambda x:x[1])
first, second = a[0][1], a[1][1]
a.sort(key=lambda x:x[0])
for i in range(n):
  print(first if a[i][1] != first else second)

Measured memory_bytes: 39700
n = int(input())
lh = list(map(int, input().split()))

ans = 0
for i in range(1, max(lh)+1):
    if lh[0] >= i:
        cnt = 1
    else:
        cnt = 0
    j = 1
    while j < n:
        if lh[j-1] < i and lh[j] >= i:
            cnt += 1
        j += 1
    ans += cnt

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int a, b;
    
    scanf("%d%d", &a, &b);
    
    if (a%3==0||b%3==0||(a+b)%3==0) {
        printf("Possible");
    } else {
        printf("Impossible");
    }
    
    return 0;
}



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

int main(){
  string s;
  cin >> s;
  if(s[5] == '1' || s[6] > '4') puts("TBD");
  else puts("Heisei");
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    int ans = 0;

    while(true) {
      boolean fail = false;
      for(int i = 0; i < n; i++) {
        if(a[i] % 2 == 0) {
          a[i] /= 2;
        }
        else {
          fail = true;
          break;
        }
      }
      if(fail) break;

      ans++;
    }

    System.out.println(ans);

    sc.close();
  }

}


Measured memory_bytes: 23892
#include <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const ll INF=1ll<<50;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

const int mod=10000;

int dp[502][11][500][2][2];

int solve(string s,int D){
	int n=s.size();
	for(int i=0;i<=n;i++) for(int j=0;j<=10;j++) for(int k=0;k<D;k++) for(int l=0;l<2;l++) for(int m=0;m<2;m++) dp[i][j][k][l][m]=0;
	dp[0][10][0][0][0]++;
	for(int i=0;i<n;i++) for(int j=0;j<=10;j++) for(int k=0;k<D;k++) for(int l=0;l<2;l++) for(int m=0;m<2;m++){
		if(j!=10){
			int S=m?0:j+1,T=m?j-1:9;
			if(!l) T=min(T,s[i]-'0');
			for(int d=S;d<T+1;d++) (dp[i+1][d][(10*k+d)%D][l||s[i]-'0'!=d/*d<T*/][!m]+=dp[i][j][k][l][m])%=mod;
		}
		else if(!k&&!l&&!m){
			int lim=(i==0)?s[i]-'0':9;
			for(int d=1;d<lim+1;d++) for(int I=0;I<2;I++) dp[i+1][d][d%D][i||d<lim][I]++;
			dp[i+1][10][0][0][0]++;
		}
	}
	int ans=0;
	for(int i=0;i<10;i++) for(int j=0;j<2;j++) for(int k=0;k<2;k++){
		(ans+=dp[n][i][0][j][k])%=mod;
	}
	int num=9/D;
	if(s.size()==1&&s[0]-'0'<num*D) num=(s[0]-'0')/D;
	return (ans+mod-num)%mod;
}

string Minus(string s){
	if(s.back()>'0') s[s.size()-1]-=1;
	else{
		for(int i=s.size()-1;i>=0;i--) if(s[i]>'0'){
			s[i]-=1;
			for(int j=i+1;j<s.size();j++) s[j]='9';
			break;
		}
	}
	if(s=="0") return s;
	for(int i=0;i<s.size();i++) if(s[i]!='0'){
		s.erase(s.begin(),s.begin()+i);
		break;
	}
	return s;
}

string A,B;
int D;

int main(){
	cin>>A>>B>>D;
	cout<<(solve(B,D)-solve(Minus(A),D)+2*mod)%mod<<endl;
}

Measured memory_bytes: 46132
while True:
    T, P, R = map(int, input().split())
    if T == 0 and P == 0 and R == 0:
        break
    correct = [[0] * (P+1) for _ in range(T+1)]
    wrong = [[0] * (P+1) for _ in range(T+1)]
    penalty = [0] * (T+1)
    for i in range(R):
        data = input().split()
        team = int(data[0])
        prob = int(data[1])
        time = int(data[2])
        if data[3] == 'WRONG':
            wrong[team][prob] += 1
        else:
            if correct[team][prob] == 0:
                correct[team][prob] = 1
                penalty[team] += wrong[team][prob]*1200 + time
    res = []
    for i in range(1,T+1):
        res.append((i, sum(correct[i]), penalty[i]))
        res.sort(key=lambda x:(x[1],-1*x[2],-1*x[0]), reverse=True)
    for i in range(T):
        print(res[i][0],res[i][1],res[i][2])



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

using namespace std;
using namespace std::chrono;

/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
    char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
    vector<char*> v({token});
    while(token = strtok(NULL,", ")) v.push_back(token);
    return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
    debug() << " [" << args.back() << ": " << H << "] ";
    args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------


typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
int mod=1000000007;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    ll x,i,j;
    cin>>x;
    REP(i,-120,120){
        REP(j,-120,120)
            if(pow(i,5)-pow(j,5)==x) {
                cout<<i spa j;
                return 0; 
            }
    }
    //cout<<1 spa 3;
    return 0;
} 


Measured memory_bytes: 4064
N = int(input())
s = input()
cnt = 0
acce = [0]*N
accw = [0]*N
if s[0] == 'E':
	acce[0] = 1
else:
	accw[0] = 1
for i in range(1,N):
	if s[i] == 'E':
		acce[i] = acce[i-1]+1
		accw[i] = accw[i-1]
	else:
		accw[i] = accw[i-1]+1
		acce[i] = acce[i-1]

m = acce[N-1] - acce[0]
for i in range(1,N):		
	if m > (accw[i-1]+(acce[N-1]-acce[i])):
		m = (accw[i-1]+(acce[N-1]-acce[i]))


print(m)
 



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


int main() {
 	int A,B,C,D,E,F;
  cin>>A>>B>>C>>D>>E>>F;
  int X=0,Y=0;
  double ans=0.00;
  for(int a=0;100*A*a<=F;a++){
    for(int b=0;100*B*b<=F-100*A*a;b++){
      for(int c=0;C*c<=F-100*A*a-100*B*b;c++){
        for(int d=0;D*d<=F-100*A*a-100*B*b-C*c;d++){
          int x=100*A*a+100*B*b;
          int y=C*c+D*d;
          if(x+y==0|| 100*y>x*E) continue;
          else if((double)100*y/(x+y)>=ans){//水は０ではない
            X=x; Y=y;
            ans=(double)100*y/(x+y);
          }
        }
      }
    }
  }
  cout<<X+Y<<" "<<Y<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


int main(){

	int N,K;
	scanf("%d %d",&N,&K);

	if(N > K){
		printf("0\n");
	}else{
		printf("1\n");
	}

	return 0;
}



Measured memory_bytes: 3168
n, m, d = map(int, input().split())

# 隣接する要素の期待スコア x (n-1) が答え (それぞれ独立)
# i, j が 1..n を取る時，個数は n * n
# そのうち絶対の差がdになるものは n * 2個？#
#
# n = 2, d = 1
# 1 1 -> 0
# 1 2 -> 1
# 2 1 -> 1
# 2 2 -> 0
# score は 2，期待値は0.5，長さは3なので，0.5 x (3-1) = 1.0
#
# この組が何個あるか，をdとnに依存して正しく求める
#
# n = 10, d = 3
# 1 -> 4
# 2 -> 5
# 3 -> 6
# 4 -> 1, 7
# 5 -> 2, 8
# 6 -> 3, 9
# 7 -> 4, 10
# 8 -> 5
# 9 -> 6
# 10 -> 7

if d == 0:
    fact = 1 / n
else:
    fact = 2 * (n - d) / (n * n)
score = fact * (m - 1)
print("{:.10f}".format(score))

Measured memory_bytes: 38384
N=int(input().strip())
sche=[[int(i) for i in input().split()] for i in range(N)]

counter=0
posnow=[0,0,0]
for i in range(N):
    dt=sche[i][0]-posnow[0]
    dx=sche[i][1]-posnow[1]
    dy=sche[i][2]-posnow[2]
    if (dt-dx-dy)<0 or (dt-dx-dy)%2:
        break
    else:
        posnow=sche[i]
        counter=counter+1
if counter==N:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 21108
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RREP(i,n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

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

const int INF = 1e9;
const int MOD = 1e9+7;

int main(void){
  int n;
  cin >> n;
  vi t(n), x(n), y(n);

  REP(i, n) cin >> t[i] >> x[i] >> y[i];
  int nx = 0, ny = 0, nt = 0;
  int k = 1;
  REP(i, n){
    int a = abs(x[i] - nx) + abs(y[i] - ny);
    int b = t[i] - nt;
    if(!(b >= a && (b - a) % 2 == 0)) k = 0;
    nx = x[i]; ny = y[i]; nt = t[i];
  }
  cout << (k ? "Yes" : "No") << endl;
}

Measured memory_bytes: 1408
al=[chr(ord('a') + i) for i in range(26)]
reval=al[::-1]
s=list(input())
for si in s:
    al.remove(si)

if s==reval:
    print(-1)
elif len(al)!=0:
    print(''.join(s)+al[0])
else:
    k=0
    for i in range(26):
        if ord(s[25-i])>ord(s[24-i]):
            k=i
            break
    al=[chr(ord('a') + i) for i in range(26)]
    for i in range(24-k):
        al.remove(s[i])
    x=''
    for j in al:
        if j>s[24-k]:
            x=j
            break
    print(''.join(s[:24-k])+x)


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(long& x) { if( scanf("%ld", &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      long n, a, b;
      scan(n, a, b);
      long x = a + (n - 1) * b;
      long y = (n - 1) * a + b;
      printf("%ld\n", std::max((long)0, x - y + 1));
   }
};

int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// get a integer
		String s = sc.nextLine();
		
		if (Main.IfgetCF(s))
			System.out.println("Yes");
		else
			System.out.println("No");
		
		sc.close();
	}
	
	static boolean IfgetCF(String str) {
		int C = 0;
		int F = 0;
		
		for (int i = 0; i < str.length(); i++) {
			char ch = str.charAt(i);
			if (ch == 'C' || ch == 'F') {
				if (ch == 'C' && C == 0 && F == 0)
				{
					C++;
				}
				else {
					if (str.charAt(i) == 'F' && C != 0)
						F++;
				}
				
			}
		}
		
		if (C != 0 && F != 0)
			return true;
		else
			return false;
	}
}

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

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

	string s, t; cin >> s;
	t = s;
	reverse(t.begin(), t.end());
	for(int i = 0; i < t.size(); i++){
		if(t[i] == 'b') t[i] = 'd';
		else if(t[i] == 'd') t[i] = 'b';
		else if(t[i] == 'p') t[i] = 'q';
		else t[i] = 'p';
	}	
	if(s == t) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;	
}

Measured memory_bytes: 512
import math
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))
mod = 10**9 + 7 
sys.setrecursionlimit(1000010)


A,B,H,M = nm()
(a, b, h, m)=map(float,(A,B,H,M))

theta = 2.0 * math.pi * ( m /60.0 - (h + m /60.0 )/12.0)
print(math.sqrt( a * a + b * b - 2.0 * a * b * math.cos(theta)))

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

typedef long long int ll;

int main(int argc, char const *argv[])
{
	ll n;
	scanf("%lld",&n);
	ll ans=1000000000000;
	for(ll i=1;i*i<=n;i++)
	{
		if(n%i==0)
		{	
			ll b = n/i;
			ans=min(ans,b-2+i);
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 256