akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
int player,rounds,i,j,k;
cin>>player>>rounds;
int target[rounds],forecast[player],sum[player];
for(i=0;i<player;i++)sum[i]=0;
for(i=0;i<rounds;i++)cin>>target[i];
for(i=0;i<rounds;i++){
    for(k=0;k<player;k++)cin>>forecast[k];
for(j=0;j<player;j++){
if(target[i]==forecast[j])sum[j]++;else sum[target[i]-1]++;
}
}
for(i=0;i<player;i++)cout<<sum[i]<<endl;
return 0;
}

Measured memory_bytes: 1160
a = int(input())
b = list(map(int,input().split()))
bmax = 0
ans = 0
for i in range(a):
    if i == 0:
        bmax = b[i]
    else:
        if bmax < b[i]:
            bmax = b[i]
        elif bmax > b[i]:
            ans += bmax - b[i]
print(str(ans))

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
#define leftunique(a) {sort((a).begin(),(a).end());(a).erase(unique((a).begin(),(a).end()),(a).end());}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
static const ll INF = 1LL << 60;
//Write From this Line

ll h, w;
vector<string> field(2010);
vector<vector<pair<ll,ll>>> light(2010,vector<pair<ll,ll>>(2010));
bool check_left(ll y, ll x) {
	if(x == 0) return true;
	if(field[y][x-1] == '#') return true;
	else return false;
}
bool check_upper(ll y, ll x) {
	if(y == 0) return true;
	if(field[y-1][x] == '#') return true;
	else return false;
}
ll count_right_light(ll y, ll x,ll limit) {
	ll ret = 0;
	while(1){
		if(x >= limit) break;
		if(field[y][x] == '.') ret++;
		else break;
		++x;
	}
	return ret;
}
ll count_down_light(ll y, ll x,ll limit) {
	ll ret = 0;
	while(1){
		if(y >= limit) break;
		if(field[y][x] == '.') ret++;
		else break;
		++y;
	}
	return ret;
}
int main()
{
	// Lamp
	cin >> h >> w;
	rep(i,h) cin >> field[i];

	ll ans = 0;
	rep(i,h){
		rep(j,w){
			// 0行目か0列目なら、その行,列を探索
			// 左が壁ならその行を探索、上が壁ならその列を探索
			if(field[i][j] == '#') continue;
			if(check_left(i,j)){
				// jよりも右に何個照らせるところがあるか数える
				light[i][j].first =count_right_light(i,j,w);
			} else {
				light[i][j].first = light[i][j-1].first;
			}
			if(check_upper(i,j)){
				light[i][j].second =count_down_light(i,j,h);
			} else {
				light[i][j].second = light[i-1][j].second;
			}
			chmax(ans,light[i][j].first+light[i][j].second-1);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 67584
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long int
#define pb push_back
#define mk make_pair
#define flp(i, k, n) for(int i=k; i<n; i++)
#define rev(i, k) for(int i=k; i>=0; i--)
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
int dx[4] = {-1,1,0,0};
int dy[4] = {0,0,-1,1};

int32_t main(void)
{
    int r;
    cin>>r;
    r*=2;
    cout<<(double)(r)*(double)(3.14)<<"\n";
    return 0;
}


Measured memory_bytes: 3776
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <bitset>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
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; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<int> ans;
    if(n==0)ans.pb(0);
    while(n != 0){
        int r = abs(n) % 2;
        if(r == 1)n--;
        ans.pb(r);
        n /= -2;
    }
    reverse(all(ans));
    for(auto x : ans) cout << x;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mii map <int, int>
#define mll map <ll, ll>
#define pii pair <int, int>
#define pll pair <ll, ll>
#define vi vector <int>
#define vd vector <double>
#define vll vector <ll>
#define fi first
#define se second
#define si set <int>
#define sll set <ll>
#define spii set <pii>
#define vs vector <string>
#define vpii vector <pair <int,int> >
#define vpll vector <pair <long long,long long> >
#define vvi vector <vector <int> >
#define vvpii vector <vector <pii > >
#define forn(i, n) for (int i = 0; i < (n); i++)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define for1(i, n) for (int i = 1; i < (n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()


using namespace std;
const ll INFLL = 1e18;
const int MAXN = 1e6+100;
const ll INF = 1e9;
const ll mod1=1e9+7;
const ll mod2=2e9+11;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
    freopen("a.in","r",stdin);
    #endif
    ll h;
    ll a;
    cin>>h>>a;
    cout<<(h+a-1)/(a);



}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll k,x;
    cin>>k>>x;
    if(k*500>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN = 1e5 + 10;
int N, M, A[MAXN];

int main()
{
	scanf("%d %d", &N, &M);
	for (int i = 1; i <= M; i ++) scanf("%d", &A[i]);
	int Odd = 0;
	for (int i = 1; i <= M; i ++)
		Odd += A[i] & 1;
	if (Odd >= 3) return puts("Impossible"), 0;
	if (M == 1)
	{
		if (A[1] == 1) return printf("1\n1\n1\n"), 0;
		printf("%d\n", N);
		printf("2\n1 %d\n", N - 1); return 0;
	}
	else if (M == 2)
	{
		if (A[1] == A[2] && A[1] == 1)
		{
			printf("1 1\n 1\n 2");
			return 0;
		}
	}
	Odd = 0;
	for (int i = 1; i <= M; i ++)
	{
		if (A[i] & 1)
		{
			if (!Odd) swap(A[i], A[1]);
			else {swap(A[i], A[M]); break;}
			++ Odd;
		}
	}
	for (int i = 1; i <= M; i ++)
		printf("%d ", A[i]);
	puts("");
	vector<int> ans(0);
	for (int i = 1; i <= M; i ++)
	{
		if (i == 1 && A[i] > 1)
			ans.push_back(A[i] - 1);
		if (i == M) ans.push_back(A[i] + 1);
		else if (i >= 2) ans.push_back(A[i]);
	}
	printf("%d\n", ans.size());
	for (int cur : ans)
		printf("%d ", cur);
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
char s[100010],t[100010];
int lens,lent;
set<int>h[300];
int preidx=1
,ans;
bool fstrun;
signed main(){
	cin>>(s+1)>>(t+1);
	lens=strlen(s+1);
	lent=strlen(t+1);
	for(int i=1;i<=lens;i++)h[s[i]].insert(i);
	for(int i=1;i<=lent;i++)
		if(h[t[i]].empty()){
			puts("-1");
			return 0;
		}
	for(int i=1;i<=lent;i++){
		bool flg=0;
		auto it=h[t[i]].upper_bound(preidx);
		if(fstrun==0)it=h[t[i]].begin(),fstrun=1;
		if(it==h[t[i]].end())it=h[t[i]].begin(),flg=1;
		if(flg)ans+=(lens-preidx)+(*it);
		else ans+=((*it)-preidx);
//		cout<<preidx<<' '<<flg<<endl;
		preidx=*it;
//		cout<<ans<<' '<<*it<<endl;
	}
	cout<<ans+1<<endl;
	return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define maxn 100050 
#define modu 1000000007
using namespace std;
typedef long long LL;

int n;
LL a[maxn];

LL F[maxn]={1},S[maxn];

LL inv(LL a)
{
	LL ans=1;
	for (int k=modu-2;k;k>>=1)
	{
		if (k&1)
			ans=ans*a%modu;
		a=a*a%modu;
	}
	return ans;
}

int main()
{
//	freopen("c.in","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<=n;++i)
		scanf("%lld",&a[i]);
	
	for (int i=1;i<=n;++i)
		F[i]=F[i-1]*i%modu;
	for (int i=1;i<=n;++i)
		S[i]=F[n]*inv(i)%modu;
	for (int i=1;i<=n;++i)
		S[i]+=S[i-1],S[i]%=modu;
		
	LL ans=0;
	for (int i=1;i<=n;++i)
		ans+=(S[i]+S[n-i+1]-F[n]+modu)*a[i],ans%=modu;
	cout<<ans<<endl;
	return 0;
} 

Measured memory_bytes: 2560
module Main where

import Control.Applicative
import Numeric

main :: IO ()
main = loop

loop :: IO ()
loop = do
  { [h, w] <- getInts
  ; if h == 0 && w == 0 then done
    else do
      {putStrLn $ unlines $ checkerboard h w
      ;loop
      }
  }

firstLine :: Int -> String
firstLine n = take n (cycle "#.")

secondLine :: Int -> String
secondLine n = take n (cycle ".#")

checkerboard :: Int -> Int -> [String]
checkerboard h w = take h (cycle [firstLine w, secondLine w])
      
--

getInts :: IO [Int]
getInts = map read . words <$> getLine

putInts :: [Int] -> IO ()
putInts = putStrLn . unwords . map show

getDoubles :: IO [Double]
getDoubles = map read . words  <$> getLine

putDoubles :: [Double] -> IO ()
putDoubles = putStrLn . unwords . map showDouble

showDouble :: Double -> String
showDouble d = showFFloat Nothing d ""

done :: IO ()
done = return ()



Measured memory_bytes: 4240
//============================================================================
// Name        : AOJ.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <algorithm>

using namespace std;

int w,h,n;
int d[100001]={};

int main() {
	int E,Y;
	cin>>E>>Y;
	if(E==0){
		if(Y>=1868&&Y<=1911)cout<<"M"<<Y-1867<<endl;
		if(Y>=1912&&Y<=1925)cout<<"T"<<Y-1911<<endl;
		if(Y>=1926&&Y<=1988)cout<<"S"<<Y-1925<<endl;
		if(Y>=1989&&Y<=2016)cout<<"H"<<Y-1988<<endl;
	}else if(E==1){
		cout<<Y+1867<<endl;
	}else if(E==2){
		cout<<Y+1911<<endl;
	}else if(E==3){
		cout<<Y+1925<<endl;
	}else if(E==4){
		cout<<Y+1988<<endl;
	}
	return 0;
}

Measured memory_bytes: 3120
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range (a+1):
    for j in range (b+1):
        for k in range (c+1):
            if 500*i + 100*j + 50*k == x:
                ans += 1
print(ans)

Measured memory_bytes: 9216
// ABC171.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


// A ///////////////////////////////////

//#include <iostream>
//
//using namespace std;
//
//int main()
//{
//	char input;
//
//	cin >> input;
//
//	if (input >= 65 && input <= 90) {
//		cout << 'A';
//	}
//
//	if (input >= 97 && input <= 122) {
//		cout << 'a';
//	}
//
//	return 0;
//}


// B ///////////////////////////////////

#include <iostream>

using namespace std;

int main()
{
	//変数の宣言
	int N, K; //売られている果物の種類、実際に買う種類数
	int price[1000]; //各種果物の値段;
	int minRanking[1000] = { 0 };
	int min1, min2, min3, minTemp = 1001, minFruit;
	int minSum = 0;

	//入力の格納
	cin >> N >> K;
	for (int i = 1; i <= N; i++) {
		cin >> price[i - 1];
	}

	//最安ランキングの作成(K回行う)
	for (int j = 1; j <= K; j++) {
		minTemp = 1001;
		for (int i = 1; i <= N; i++) {
			if (price[i - 1] < minTemp) {
				minTemp = price[i - 1];
				minFruit = i - 1;
			}
		}
		minRanking[j - 1] = minTemp;
		price[minFruit] = 1001;
	}
	
	//合算と出力

	for (int i = 1; i <= K; i++) {
		minSum += minRanking[i - 1];
	}

	cout << minSum;

	return 0;

	//test

	/*int test1[100];

	for (int i = 1; i <= 3; i++) {
		cin >> test1[i - 1];
	}

	for (int i = 1; i <= 3; i++) {
		cout << test1[i - 1] << "\n";
	}

	return 0;*/

}


Measured memory_bytes: 3116
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <queue>
#include <stack>
#include <string.h>
#include <list>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define all(a)  (a).begin(), (a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define rep(i,n) for(int i = 0; i < n; i++)
#define repR(i,n) for(int i = n-1; i >= 0; i--)
#define FOR(i,m,n) for(int i = m; i < n; i++)
#define PB push_back
#define MP make_pair
#define EPS (1e-7)
#define INF (1e12)
#define PI (acos(-1))

int main(){
    int n;
    cin >> n;
    vector<ll> X(n),Y(n);
    rep(i,n){
        cin >> X[i];
        Y[i] = X[i];
    }
    sort(all(Y));
    int l = n/2 - 1, r = n/2;
    rep(i,n){
        if(X[i] <= Y[l]) cout << Y[r] << endl;
        else cout << Y[l] << endl;
    }
    return 0;
}

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

class dice {
    int dice[6];
    string state;
public:
    void input() {
        for(int i=0; i<6; ++i) cin >> dice[i];
    }
    void move() {
        cin >> state;
        for(int i=0; i<state.length(); ++i) {
            switch(state[i]) {
                case 'N':
                    swap(dice[0], dice[1]);
                    swap(dice[1], dice[5]);
                    swap(dice[5], dice[4]);
                    break;
                case 'S':
                    swap(dice[0], dice[4]);
                    swap(dice[4], dice[5]);
                    swap(dice[5], dice[1]);
                    break;
                case 'E':
                    swap(dice[0], dice[3]);
                    swap(dice[3], dice[5]);
                    swap(dice[5], dice[2]);
                    break;
                case 'W':
                    swap(dice[0], dice[2]);
                    swap(dice[2], dice[5]);
                    swap(dice[5], dice[3]);
                    break;
                default:
                    break;
            }
        }
    }
    void output() {
        cout << dice[0] << endl;
    }
};

int main() {
    dice d;

    d.input();
    d.move();
    d.output();

    return 0;
}

Measured memory_bytes: 3188
#include<iostream>
        #include<string>
        #include<algorithm>
        #include<vector>
        #include<iomanip>
        #include<math.h>
        #include<complex>
        #include<queue>
        #include<deque>
        #include<stack>
        #include<map>
        #include<set>
        #include<bitset>
        using namespace std;
        #define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
        #define rep(i,n) REP(i,0,n)
        typedef long long ll;
        typedef pair<int,int> pint;
        typedef pair<ll,int> pli;
        typedef pair<ll,ll> pll;
        const int inf=1e9+7;
        const ll longinf=1LL<<60 ;
        const ll mod=1e9+7 ;
            using namespace std;
     
            int main(){
              ll n;
              cin >> n;
              ll a[n+1];
              rep(i,n) cin >> a[i];
              sort(a,a+n);
              pll x;
              ll ans=a[n-1]-a[0];
              x.first=a[0];
              x.second=a[n-1];
              pll kouho,kouho2;
              kouho.first=a[1];
              kouho.second=1;
                kouho2.first=a[n-2];
                kouho2.second=n-2;
              for(int i=1;i<n-1;i++){
                ll le1=abs(x.first-kouho.first);
                ll le2=abs(x.first-kouho2.first);
                ll ri1=abs(x.second-kouho.first);
                ll ri2=abs(x.second-kouho2.first);
               if(le1>=le2 && le1>=ri1 && le1>=ri2){
                 ans+=le1;
                x.first=kouho.first;
                  kouho.first=a[kouho.second+1];
                   kouho.second++;
               }
                else if(le2>=le1 && le2>=ri1 && le2>=ri2){
                 ans+=le2;
                  x.first=kouho2.first;
                  kouho2.first=a[kouho2.second-1];
                    kouho2.second--;
                }
                else if(ri1>=le1 && ri1>=le2 && ri1>=ri2){
                 ans+=ri1;
                  x.second=kouho.first;
                   kouho.first=a[kouho.second+1]; 
                  kouho.second++;
                }
                else if(ri2>=le1 && ri2>=le2 && ri2>=ri1){
                 ans+=ri2;
                  x.second=kouho2.first;
                  kouho2.first=a[kouho2.second-1];
                    kouho2.second--;
                }
              }
              cout << ans << endl;
              return 0;}

Measured memory_bytes: 1024
#include <stdio.h>
#include <iostream>
using namespace std;

int main(void)
{		
	int n;
	int house[4][3][10] = {0};
	cin >> n;
	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		cin >> b >> f >> r >> v;
		house[b-1][f-1][r-1] += v;
	}
	
	for (int b = 0; b < 4; b++) {
		for (int f = 0; f < 3; f++) {
			for (int r = 0; r < 10; r++) {
				cout << " " << house[b][f][r];
			}
			cout << "\n";
		}
		if (b < 3) {
			cout << "####################\n";
		}
	}
	
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ITER(c) __typeof((c).begin())
#define each(c, it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define ALL(c) c.begin(), c.end()
#define mp make_pair
#define pb push_back
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define S first
#define I second

using namespace std; 

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

const int INF = 1 << 24;
 
int main(void){
    vector<psi> t;
    for(psi in; cin >> in.S >> in.I; t.pb(in));
   
    sort(ALL(t));

    string pre;
    each(t, it){
        if(it->S != pre) cout << (it != t.begin() ? "\n":"") << it->S << endl;
        cout << (pre == it->S ? " ":"") << it->I;
        pre = it->S;
    }
    cout << endl;
 
    return 0;
}

Measured memory_bytes: 1232
#include<iostream>
#include<cstdio>
#include<vector>
#include<string.h>
#include<vector>
using namespace std;

unsigned long long  i,j=0,k,h,w,a,b,c,d,x,y,z,ret=0;
int main(void){

  const char key[]="keyence";
 
  
  char s[101];
  cin>>s;
  if(strstr(s,key))ret=1;
  if(s[0]=='k'&&s[strlen(s)-1]=='e'){
    for(i=0;i<strlen(key);i++){
      if(s[i]!=key[i])break;
    }
    for(j=strlen(s)-1,k=0;k<strlen(key)-i;k++){
      if(s[j-k]!=key[strlen(key)-k-1])break;
    }
  }
  if(i+k==strlen(key))ret=1;
   cout<<(ret?"YES":"NO");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        for(int i = 1 ; num!=0 ; i++){
            System.out.println("Case "+i+": "+num);
            num=sc.nextInt();
        }
    }
}


Measured memory_bytes: 43360
#include <stdio.h>		// standard input output
#include <iostream>		// input output stream, cin cout( console in console out)
#include <cmath>		// circle math ( sin, con, sinh
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>		// input output manipulation

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


int main() {
  int N; // 変数の宣言
  cin >> N; // 標準入力
  vector<int> a(N),b(N),c(N);
  rep(i,N){
    cin >> a.at(i) >> b.at(i) >> c.at(i);
      }

  vector<int> A_r(N),B_r(N),C_r(N);
  A_r.at(0) = a.at(0);
  B_r.at(0) = b.at(0);
  C_r.at(0) = c.at(0);
  for(int i=1;i<N;i++){
    A_r.at(i)= max(B_r.at(i-1)+a.at(i),C_r.at(i-1)+a.at(i));
    B_r.at(i)= max(A_r.at(i-1)+b.at(i),C_r.at(i-1)+b.at(i));
    C_r.at(i)= max(A_r.at(i-1)+c.at(i),B_r.at(i-1)+c.at(i));
  }
  
  cout << max(max(A_r.at(N-1),B_r.at(N-1)),C_r.at(N-1)) << endl; // 標準出力
}



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

using namespace std;

int main() {
    int a, b, c, d, l, r;
    string ans;
    cin >> a >> b >> c >> d;
    l = a + b;
    r = c + d;

    if (l > r) {
        ans = "Left";
    }
    else if (l == r) {
        ans = "Balanced";
    }
    else {
        ans = "Right";
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		int n, i, j, factorial,k;
		String str;

		try (Scanner sc = new Scanner(System.in)) {
			n = sc.nextInt();
			factorial = (int) (Math.pow(2, n));
			k = sc.nextInt();
			int[] b = new int[k];
			int[] a = new int[n];
			for(i = 0; i < k; i++) {
				b[i] = sc.nextInt();
			}
			for(i = 0; i < factorial; i++) {
				str = Integer.toBinaryString(i);

				for(j = 0; j < str.length(); j++) {
					a[j] = Character.getNumericValue(str.charAt(str.length() - j - 1));
				}
				boolean bool = false;
				for(j = 0; j < k; j++) {
					if(a[b[j]] == 0) {
						bool = true;
					}
				}
				if(bool) continue;
				System.out.print(i + ":");
				for(j = 0; j < str.length(); j++) {
					if(a[j] == 1) {
						System.out.print(" " + j);
					}
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 67424
#include <iostream>
#include <cstdio>
#include <complex>
#include <cmath>
#include <vector>
#include <algorithm>
#define double long double
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;
typedef complex<double> Point;

//円と円の交点. 接する場合も空のvectorを返す. この誤魔化しは, 解heightを少し小さくすれば解消できるのでOK.
vector<Point> kouten_CC(Point c1, double r1, Point c2, double r2) {
	Point r = c2 - c1;
	if (norm(r) >= (r1 + r2) * (r1 + r2)) { return vector<Point>(); }
	if (min(r1, r2) + abs(r) <= max(r1, r2)) { return vector<Point>(); }
	double theta = acos((norm(r) + r1 * r1 - r2 * r2) / (2 * r1 * abs(r)));
	Point R = (r1 / abs(r)) * r;
	Point res1 = R * exp(Point(0, 1) * theta);
	Point res2 = R * exp(Point(0, 1) * (-theta));
	vector<Point> ret;
	ret.push_back(c1 + res1);
	ret.push_back(c1 + res2);
	return ret;
}

int n;
double x[10], y[10], l[10];

bool check(double h) {
	double r[10];
	int i, j, k;
	
	rep(i, n) r[i] = sqrt(l[i] * l[i] - h * h);
	
	//cout << endl;
	//cout << "h = " << h << endl;
	//rep(i, n) cout << "r[" << i << "] = " << r[i] << endl;
	
	vector<Point> ps;
	rep(i, n) {
		ps.push_back(Point(x[i], y[i]));
		for (j = i + 1; j < n; j++) {
			ps.push_back((Point(x[i], y[i]) + Point(x[j], y[j])) * (double)0.5);
			vector<Point> p = kouten_CC(Point(x[i], y[i]), r[i], Point(x[j], y[j]), r[j]);
			rep(k, p.size()) {
				ps.push_back(p[k]);
				//cout << p[k] << endl;
			}
			if (p.size() == 2) {
				ps.push_back((p[0] + p[1]) * (double)0.5);
			}
		}
	}
	
	//交点ps[i]が全ての円に含まれるか判定.
	//誤差が無い場合、円jが交点ps[i]をギリギリ含むことがある。
	//誤差が無い場合、解hを小さくすることで誤魔化すのは難しい。(交点しか見ないため）
	//そこで、円jを少しだけ大きくしておいて判定する。
	double EPS = 1e-11;
	rep(i, n) r[i] += EPS;
	rep(i, ps.size()) {
		int cnt = 0;
		rep(j, n) {
			Point diff = Point(x[j], y[j]) - ps[i];
			if (abs(diff) <= r[j]) cnt++;
		}
		if (cnt == n) return true;
	}
	return false;
}

int main() {
	while (cin >> n) {
		if (!n) break;
		int i;
		double minL = 114514;
		rep(i, n) {
			cin >> x[i] >> y[i] >> l[i];
			minL = min(minL, l[i]);
		}
		
		double st = 0, ed = minL, mid;
		rep(i, 100) {
			mid = (st + ed) / 2;
			if (check(mid)) st = mid;
			else ed = mid;
		}
		printf("%.14Lf\n", st);
	}
	return 0;
}


Measured memory_bytes: 3576
N,M,Q = gets.split.map &:to_i
$ABCD = Q.times.map{ gets.split.map(&:to_i)}

def dfs(ary)
    if ary.size == N+1 then
        return $ABCD.map{|a,b,c,d| ary[b]-ary[a]==c ? d : 0 }.sum
    end

    ((ary.last)..M).map{|i| dfs(ary + [i])}.max
end

p dfs([1])

Measured memory_bytes: 14724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner s = new Scanner(System.in);
		int k = s.nextInt();

		String str = "ACL";

		for(int i=0; i<k; i++) {
			System.out.print(str);
		}


	}

}

Measured memory_bytes: 35800
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
char a[55],b[55],c[110];
int main()
{
    scanf("%s",a);
    scanf("%s",b);
   int h1=strlen(a);
   int h2=strlen(b);
   int g=0;
   for(int i=0;i<h1;i++)
   {
       c[g]=a[i];
       c[++g]=b[i];
       g++;

   }
   puts(c);
   return 0;

}


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

#define CEIL(a,b) ((a) / (b) + ((a) % (b) == 0 ? 0 : 1))

using namespace std;
using ll = long long;
using pii = pair<int, int>;

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'000'000'001;
constexpr ll LLINF = 4'000'000'000'000'000'001;
// constexpr int INF = 2147483647; // 2 * 1e9
// constexpr ll LLINF = 9223372036854775807; // 9 * 1e18

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    cout << double(CEIL(n,2)) / n << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int digit(int n){
  int ret=n%10;
  n/=10;
  while(n){
    ret+=n%10;
    n/=10;
  }
  return ret;
}
int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(a<=digit(i)&&digit(i)<=b){ans+=i;}
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
n,m,p=map(int,input().split())
data=[list(map(int,input().split())) for i in range(m)]
inf=float("inf")
dist=[-inf]*(n+1)
dist[1]=0
for i in range(n-1):
    for a,b,c in data:
        if dist[a]!=-inf:
            dist[b]=max(dist[b],dist[a]+c-p)
lst=[]
for a,b,c in data:
    if dist[b]<dist[a]+c-p:
        lst.append(b)

tag=[[] for i in range(n+1)]
for a,b,c in data:
    tag[a].append(b)
flag=[0]*(n+1)
for u in lst:
    if flag[u]==0:
        flag[u]=1
        que=[u]
        while que:
            h=que.pop()
            for v in tag[h]:
                if flag[v]==0:
                    que.append(v)
                    flag[v]=1
if flag[n]==1:
    print(-1)
else:
    print(max(0,dist[n]))

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

int main() {
  int N;
  cin >> N;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if (N == i*j){
        cout << "Yes" << endl;
        return 0;
      }
    }   
  } 
  cout << "No";
}


Measured memory_bytes: 3552
#include<stdio.h>
int main()
{
    char s[100];
    scanf("%s",s);
    int i=0,l=0,c=0,d=1;
    while(s[i]!='\0')
    {
        if(s[i]=='C')
            c++;
        if(s[i]>'Z')
        l++;
        i++;
    }
    if(s[0]!='A' || s[1]=='C' || c!=1 || s[i-1]=='C' || l!=i-2)
        d=0;
    if(d==0)
        printf("WA\n");
    else printf("AC\n");

}


Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A.Train
{
    class Program
    {
        static void Main(string[] args)
        {
            var NI =  Console.ReadLine().Split(null).Select(int.Parse).ToArray();

            int ans = NI[0] - NI[1] + 1;

            Console.WriteLine(ans);
        }
    }
}

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#define showvv(v)
#endif

using namespace std;

#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((int)(x).size())
#define pb push_back
#define fst first
#define snd second

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

#define MAX 100000

int main(){
  int n,C; cin >> n >> C;
  vvi a(2*MAX+2, vi(C));
  int s,t,c;
  rep(i,n){
    cin >> s >> t >> c;
    a[2*s-1][c-1]++;
    a[2*t+1][c-1]--;
  }
  ll ans = 0;
  rep(i,2*MAX+1){
    ll tmp = 0;
    rep(j,C){
      a[i+1][j] += a[i][j];
      if(a[i][j]) tmp++;
    }
    ans = max(ans,tmp);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 29952
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();
            int x = sc.nextInt();
            if(n ==0 && x == 0) break;
            int sum = 0;
            for(int i = 1; i <= n - 2; i++){
                for(int j = i + 1; j <= n - 1; j++){
                    for(int k = j + 1; k <= n; k++){
                        if(i + j + k == x){
                            sum++;    
                        }
                    }
                }
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 26424
#include<iostream>
using namespace std;
int main() {

	//B
	int x, y;
	cin >> x >> y;
	if ((y % 2 == 0) && (y - 2 * x >= 0) && (4 * x - y >= 0)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;

	//A
	/*int n;
	int i;
	for (i = 0; i < 4; i++) {
		cin >> n;
		if (n == 0)cout << i + 1 << endl;
	}
	return 0;
	*/
}

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

int main() {
  string S;
  cin>>S;
  if(S.at(2)==S.at(3)){
    if(S.at(4)==S.at(5)){
      cout<<"Yes"<<endl;
    }
    else{
      cout<<"No"<<endl;
    }
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  string o,e;
  cin>>o>>e;
  int a=min(o.size(),e.size());
  for(int i=0;i<a;i++){
    cout<<o.at(i)<<e.at(i);
  }
  if(o.size()==e.size()){
    cout<<endl;
  }
  else if(o.size()<e.size()){
    cout<<e.at(e.size()-1)<<endl;
  }
  else{
    cout<<o.at(o.size()-1)<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(void)
{
    int num[4],n=0,sum=0,i,j;
    while(n<4)
    {
        num[n++]=getchar()-'0';
    }
    for(i=0;i<8;i++)
    {
        sum=num[0];
        for(j=0;j<3;j++)
        {
            if(((i>>j)&1)==1) sum+=num[j+1];
            else sum-=num[j+1];
        }
        if(sum==7)
        {
            for(j=0;j<3;j++)
            {
                printf("%d",num[j]);
                if(((i>>j)&1)==1) printf("+");
                else printf("-");
            }
            printf("%d=7",num[3]);
            break;
        }
    }
    return 0;
}




Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>
#include <numeric>
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; }

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


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

	int kkt = 1;
	while (kkt--) {
		string s; cin >> s;
		int cnt = 0;
		ll res = 0;
		for (int i = 0; i < s.size(); i++) {
			if (s[i] == '(') cnt++;
			if (s[i] == '*') res = cnt;
			if (s[i] == ')') cnt--;
		}
		cout << res << endl;
	}
	return 0;

}



Measured memory_bytes: 3232
/*****************************************************/
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>

using namespace std;

#define   offcin        ios::sync_with_stdio(false)
#define   DEBUG         freopen("#.txt", "r", stdin)
#define   sigma_size    26
#define   lson          l,m,v<<1
#define   rson          m+1,r,v<<1|1
#define   slch          v<<1
#define   srch          v<<1|1
#define   ll            long long
#define   ull           unsigned long long
#define   lowbit(x)     (x&-x)

const int    INF    = 0x3f3f3f3f;
const ll     INFF   = 1e18;
const double pi     = acos(-1.0);
const double inf    = 1e18;
const double eps    = 1e-9;
const ll     mod    = 1e9+7;
const int    maxmat = 10;
const ull    BASE   = 133333331;

/*****************************************************/
inline void RI(int &x) {
      char c;
      while((c=getchar())<'0' || c>'9');
      x=c-'0';
      while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
}
inline ll bits(ll x) {
      return !x ? x : bits(x - lowbit(x)) + 1;
}
/*****************************************************/

int cnt(int x) {
    int ans = 0;
    while (x) {
        ans ++;
        x /= 10;
    }
    return ans;
}

int main(int argc, char const *argv[]) {
    long long N; 
    cin>>N;
    int ans = INF;
    int s = sqrt(N);
    for (int x = s; x >= 1; x --) if (N % x == 0){
        int y = N / x;
        ans = max(cnt(x), cnt(y));
        break;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import sys


def parse(file):
    n = int(file.readline())
    vs = map(int, file.readline().split())
    cs = map(int, file.readline().split())
    return n, vs, cs


def main(n, vs, cs):
    ans = 0
    for v, c in zip(vs, cs):
        if v - c > 0:
            ans += v - c
    return ans


if __name__ == '__main__':
    print(main(*parse(sys.stdin)))

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e10;

///////////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int n;cin >> n;
    vector<int>a(n+1); a[0] = 0;
    rep(n){int x;cin>>x;a[i+1]=x;}
    a.pb(0);
    long long s = 0;
    vector<int>d(n+1); rep(n+1){d[i]=abs(a[i+1]-a[i]); s+=d[i];}
    vector<int>d2(n); rep(n) d2[i]=abs(a[i+2]-a[i]);
    for(int i = 1;i <= n;i++){
        cout << s - d[i-1] - d[i] + d2[i-1] << endl; 
    }
    return 0;
}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  string s;
  cin >> s;
  int g = 0, p = 0;
  for (auto c : s) {
    if (c == 'g') g++;
    else p++;
  }

  cout << ((g - p) >> 1) << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 3704
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math

# NO, PAY-PAY
#import numpy as np
#import statistics
#from statistics import mean, median,variance,stdev

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    x,y = map(str, input().split())
    
    if x < y:
        print("<")
    elif x > y:
        print(">")
    else:
        print("=")
            	
if __name__ == "__main__":
	main()


Measured memory_bytes: 38256
#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.at(i);
  int cnt = 10000;
  for (int i = 1; i < N; i++) {
    if (A.at(i-1) == A.at(i)) {
      A.at(i) = cnt;
      cnt--;
    }
  }
  cout << 10000 - cnt << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n;
    cin >> n;
    vl a(n);
    ll sum = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
    }
    ll onetime = n * (n + 1) / 2;
    if (sum % onetime != 0) {
        cout << "NO"
             << "\n";
        return 0;
    }
    ll k = sum / onetime;
    vl diff(n);
    diff[0] = a[0] - a[n - 1] - k;
    for (int i = 1; i < n; ++i) {
        diff[i] = a[i] - a[i - 1] - k;
    }
    ll x = 0;
    for (int i = 0; i < n; ++i) {
        if (diff[i] > 0 || abs(diff[i]) % n != 0) {
            cout << "NO"
                 << "\n";
            return 0;
        }
        x += abs(diff[i]) / n;
    }
    assert(x == k);
    cout << "YES"
         << "\n";
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <string>
#include <bitset>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <sstream>
#include <fstream>
#include <string.h>

#define X first
#define Y second
#define MP make_pair
#define FOR(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
const int MAX = 101;

template<class T, class U>
void convert(T &t, U &u){
    stringstream ss;
    ss << t;
    ss >> u;
}

bool mark[101][101];
char tb[101][101];

void dfs(int x, int y, pair<int, int> &last){
	if(mark[y][x]) return;
	if(tb[y][x]=='.'){
		last.first  = x;
		last.second = y;
		return;
	}
	mark[y][x] = true;
	if(tb[y][x]=='^'){
		dfs(x, y-1, last);
	}else if(tb[y][x]=='>'){
		dfs(x+1, y, last);
	}else if(tb[y][x]=='v'){
		dfs(x, y+1, last);
	}else if(tb[y][x]=='<'){
		dfs(x-1, y, last);
	}
	return;
}

int main(){
	int w, h;
	while(cin >> h >> w && w|h){
		memset(mark, false, sizeof(mark));
		memset(tb, ' ', sizeof(tb));
		FOR(i, h){
			string tmp;
			cin >> tmp;
			FOR(j, w){
				tb[i][j] = tmp[j];
			}
		}

		pair<int, int> last(-1, -1);
		dfs(0, 0, last);

		if(last.first==-1&&last.second==-1){
			cout << "LOOP" << endl;
		}else{
			cout << last.first << " " << last.second << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
import std.stdio;
import std.algorithm;
import std.math;
import std.conv;
import std.string;

T readNum(T)(){
  return readStr.to!T;
}

T[] readNums(T)(){
  return readStr.split.to!(T[]);
}

string readStr(){
  return readln.chomp;
}

void main(){
  auto n = readNum!int;
  auto p = readNums!int;
  int ret;

  foreach(i; 1 .. n-1){
    auto s = p[i-1 .. i+2];

    if((s[0] < s[1] && s[1] <= s[2]) ||
       (s[0] >= s[1] && s[1] > s[2])){
      ret++;
    }
  }

  writeln(ret);
}


Measured memory_bytes: 256
if __FILE__==$0
	inf=Float::INFINITY
	readln_i=lambda{||gets.chomp.split(" ").map(&:to_i)}
	read_i=lambda{fp.gets.chomp.to_i}
	n,a,b=readln_i[]
	
	mn=a*(n-1)+b;
	mx=a+(n-1)*b;
	p (mx-mn)+1>0 ? (mx-mn)+1 : 0
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
typedef long long ll;
#define mx 400
#define pb push_back
ll mod = 1e9 + 7;
using namespace std;
ll arr[mx + 3];
ll dp[mx + 3][mx + 3];
ll inf = 1e18;
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		for (int j = i; j <= n; ++j)
			dp[i][j] = inf;

	for (int i = 1; i <= n; ++i)
		cin >> arr[i], arr[i] += arr[i - 1];

	for (int r = 1; r <= n; ++r)
		for (int l = r; l > 0; --l)
			if (l == r)
				dp[l][r] = 0;
			else
				for (int i = l; i < r; ++i)
					dp[l][r] = min(dp[l][r], dp[l][i] + dp[i + 1][r] + arr[r] - arr[l - 1]);

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

Measured memory_bytes: 1536
H, W, N = map(int, raw_input().split())
sr, sc = map(int, raw_input().split())
sr -= 1
sc -= 1
S = raw_input()
T = raw_input()

L = [-1]*N
R = [W]*N
U = [-1]*N
D = [H]*N

if S[-1]=="L":
  L[-1] = 0
if S[-1]=="R":
  R[-1] = W-1
if S[-1]=="U":
  U[-1] = 0
if S[-1]=="D":
  D[-1] = H-1

ans = "YES"

for i in range(N-1)[::-1]:
  L[i] = L[i+1]
  R[i] = R[i+1]
  U[i] = U[i+1]
  D[i] = D[i+1]
  if S[i]=="L" and (T[i]!="R" or L[i]<0):
    L[i] += 1
  if S[i]!="L" and T[i]=="R":
    L[i] = max(L[i]-1, -1)
  if S[i]=="R" and (T[i]!="L" or R[i]>=W):
    R[i] -= 1
  if S[i]!="R" and T[i]=="L":
    R[i] = min(R[i]+1, W)
  if S[i]=="U" and (T[i]!="D" or U[i]<0):
    U[i] += 1
  if S[i]!="U" and T[i]=="D":
    U[i] = max(U[i]-1, -1)
  if S[i]=="D" and (T[i]!="U" or D[i]>=H):
    D[i] -= 1
  if S[i]!="D" and T[i]=="U":
    D[i] = min(D[i]+1, H)
  if L[i]+1>=R[i] or U[i]+1>=D[i]:
    ans = "NO"

if sr<=U[0] or D[0]<=sr or sc<=L[0] or R[0]<=sc:
  ans = "NO"
print ans


Measured memory_bytes: 19424
import math
n = int(input())
pf_list = []

min_digit = float('inf')
for i in range(1, int(math.sqrt(n))+1):
  if n % i == 0:
    a = len(str(int(i)))
    b = len(str(int(n/i)))
    tmp_list = [a, b]
    tmp_list = list(map(int, tmp_list))
    if min_digit > max(tmp_list):
      min_digit = max(tmp_list)

print(min_digit)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i < n; i++)
#define rep3(i, x, n) for(int i = x; i > n; i--)
long long MOD = 1e9+7;
long long INF = 1e15;
typedef pair<long long, long long> P;
typedef long long ll;

int main(){
    long long N, Q;
    cin >> N >> Q;
    vector<P> vec;
    rep(i, N){
        ll S, T, X;
        cin >> S >> T >> X;
        vec.push_back(P(S-X, -X));
        vec.push_back(P(T-1-X, X));
    }
    rep(i, Q){
        ll D;
        cin >> D;
        vec.push_back(P(D, 0));
    }
    sort(vec.begin(), vec.end());
    set<ll> s;
    rep(i, vec.size()){
        P p = vec[i];
        if(p.second < 0) s.insert(-p.second);
        else if(p.second > 0) s.erase(p.second);
        else{
            if(s.size() == 0) cout << -1 << endl;
            else cout << *s.begin() << endl;
        }
    }
}

Measured memory_bytes: 21988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 100005
const ll MOD = 1000000007;

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

	ll n;
	cin>>n;
	map<string,int> m;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
	}

	cout<< "AC x " << m["AC"] << "\n";
	cout<< "WA x " << m["WA"] << "\n";
	cout<< "TLE x " << m["TLE"] << "\n";
	cout<< "RE x " << m["RE"] << "\n";
	
}

Measured memory_bytes: 3664
N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(M)]

ans = [0]*N
for road in ab:
  ans[road[0] - 1] += 1
  ans[road[1] - 1] += 1
  
for a in ans:
  print(a, end='\n') 

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 200005
using namespace std;
typedef long long ll;
const int mod=1e9+7;
struct P{
	int x,v,l,r,id;
}a[N];
struct trie{
	ll sum,add;
	trie(){
		add=1;
	}
}t[N<<2];
int n,f[N];
void add(int &a,int b){a=a+b>=mod?a+b-mod:a+b;}
bool cmp(P a,P b){
	return a.v<b.v;
}
bool cmp1(P a,P b){
	return a.x<b.x;
}
bool cmp2(P a,P b){
	return a.l<b.l;
}
void pwd(int k,int l,int r){
	if(l==r) return;
	l=k<<1;r=k<<1|1;
	if(t[k].add!=1){
		t[l].add=t[l].add*t[k].add%mod;
		t[r].add=t[r].add*t[k].add%mod;
		t[l].sum=t[l].sum*t[k].add%mod;
		t[r].sum=t[r].sum*t[k].add%mod;
		t[k].add=1;
	}
}
void update(int k,int l,int r,int L,int R,int val){
	if(L>R) return;
	pwd(k,l,r);
	if(L<=l&&R>=r){
		if(val==-2) t[k].sum=t[k].sum*2%mod,t[k].add=t[k].add*2%mod;
		else t[k].sum=(t[k].sum+val)%mod;
		return;
	}
	int mid=l+r>>1;
	if(L<=mid) update(k<<1,l,mid,L,R,val);
	if(R>mid) update(k<<1|1,mid+1,r,L,R,val);
	t[k].sum=(t[k<<1].sum+t[k<<1|1].sum)%mod;
}
ll query(int k,int l,int r,int L,int R){
	pwd(k,l,r);
	if(L<=l&&R>=r) return t[k].sum;
	int mid=l+r>>1;ll ans=0;
	if(L<=mid) ans=query(k<<1,l,mid,L,R);
	if(R>mid) ans=(ans+query(k<<1|1,mid+1,r,L,R))%mod;
	return ans;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].x,&a[i].v);
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++) a[i].id=i;
	sort(a+1,a+n+1,cmp1);
	for(int i=1,mx=0;i<=n;i++){
		mx=max(mx,a[i].id);
		a[i].r=mx;
	}
	for(int i=n,mn=1e9;i;i--){
		mn=min(mn,a[i].id);
		a[i].l=mn;
	}
	for(int i=1;i<=n;i++) a[i].l++,a[i].r++;
	sort(a+1,a+n+1,cmp2);
	n++;
	update(1,1,n,1,1,1);
	for(int i=1;i<n;i++){
		ll sum=query(1,1,n,a[i].l-1,a[i].r);
		update(1,1,n,a[i].r,a[i].r,sum);
		update(1,1,n,a[i].r+1,n,-2);
	}
	printf("%lld",query(1,1,n,n,n));
	return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  int N = S.size();
  
  int num01 = 0;
  int num10 = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) {
      if (S[i] == '0') {
        num10++;
      } else {
        num01++;
      }
    } else {
      if (S[i] == '1') {
        num10++;
      } else {
        num01++;
      }
    }
  }
  
  cout << min(num10, num01) << endl;
}

Measured memory_bytes: 512