akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace Sample101
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var line = Console.ReadLine().Split(' ').Select(str => int.Parse(str)).ToArray();
                if (line[0] == -1 && line[1] == -1 && line[2] == -1)
                {
                    return;
                }
                
                if (line[0] == -1 || line[1] == -1)
                {
                    Console.WriteLine("F");
                } else if (line[0] + line[1] >= 80)
                {
                    Console.WriteLine("A");
                } else if (line[0] + line[1] >= 65)
                {
                    Console.WriteLine("B");
                } else if (line[0] + line[1] >= 50)
                {
                    Console.WriteLine("C");
                } else if (line[0] + line[1] >= 30)
                {
                    if (line[2] >= 50)
                    {
                        Console.WriteLine("C");
                    } else
                    {
                        Console.WriteLine("D");
                    }
                } else
                {
                    Console.WriteLine("F");
                }
            }
        }
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define show(x) cout << #x << " = " << x ln
#define dbg(x) cout<<#x"="<<x ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a;
deque<int> q;

int main() {
	cin >> n;
	rep(i,n) {
		cin >> a;
		if (i%2==n%2) q.push_front(a);
		else q.push_back(a);
	}
	rep(i,n) {
		cout << q.back() << (i==n-1 ? '\n' : ' ');
		q.pop_back();
 	}
}

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


int main(){
    int64_t n, ans, cons = 1000000007, te = 1, ni = 1 ,ei = 1;
    cin >> n;


    for (int  i = 0 ; i < n; i++){
        te *= 10;
        te %= cons;
        ni *= 9;
        ni %= cons;
        ei *= 8;
        ei %= cons;
    }

    ans = te - 2*ni + ei;
    ans %= cons;
    if (ans < 0) ans += cons;

    cout << ans << endl;

}

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

long long res, minus, n, r, g, b;

std::string s;

int main() {
	std::cin >> n >> s;

	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')r++;
		if (s[i] == 'G')g++;
		if (s[i] == 'B')b++;
	}

	res = r * g * b;

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= (n - i - 1) / 2; j++) {
			if (s[i] != s[i + j] && s[i + j] != s[i + j * 2] && s[i] != s[i + j * 2])
				minus++;
		}
	}

	res -= minus;

	std::cout << res << std::endl;

	return 0;
}

Measured memory_bytes: 3636
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
//typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    while(true){
        int N,R;
        cin>>N;
        if(N==0) return 0;
        cin>>R;
        vector<int> V[51];
        for(int i=N;i>=1;i--) V[0].push_back(i);

        for(int j=0;j<R;j++){
            int p,c;
            cin>>p>>c;
            for(int i=0;i<c;i++){
                int x=i+p-1;
                V[j+1].push_back(V[j][x]);
            }
            for(int i=0;i<N;i++){
                if(i>=p-1 && c+p-2>=i) continue;
                V[j+1].push_back(V[j][i]);
            }
        }
        cout<<V[R][0]<<endl;
    }
}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;




int n, m;
int f[maxn];
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
    cin>>n>>m;
    for (int i=0; i<n; i++) {
	int k;
	cin>>k;
	while (k--) {
	    int x;
	    cin>>x;
	    f[x]++;
	}
    }

    int res = 0;
    for (int i=1; i<=m; i++) {
	res += (f[i]==n);
    }
    out(res);
    
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>//辞書順はnext_permutation
#include<set>
#include<string>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<utility>//swap(数値交換)
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define yes(ans) if(ans)cout<<"yes"<<endl;else cout<<"no"<<endl;
#define Yes(ans) if(ans)cout<<"Yes"<<endl;else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl;else cout<<"NO"<<endl;
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define rt "\n"
#define asas int ans=0
#define please return
#define AC 0

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}


int main(void) {
	llint a, b;
	cin >> a >> b;
	if ((a + b) % 2 != 0) {
		cout << "IMPOSSIBLE" << rt;
		please AC;
	}
	cout << (a + b) / 2 << rt;
	please AC;
}

// abc : 141 , aoj : ITP1_6_D
//sort, abs, swap, reverse, max, min
//__gcd, sbstring, erase, push_back,stoll、stoi

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define LL long long
#define maxn 100005

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n+2];
   int ans=0;
   ans=0;
   for(int i=1;i<=n;i++)
   {
       cin>>a[i];
       if(i%2==1&&a[i]%2==1)
       {
           ans++;
       }
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3632
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace B
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var s = Console.ReadLine();
            var t = Console.ReadLine();
            var answer = false;
            for (var i = 0; i < s.Length; i++)
            {
                var left = s.Substring(i, s.Length - i);
                var right = s.Substring(0, i);
                if (left + right == t) answer = true;
            }
            Console.WriteLine(answer ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n;
	ll a[200001];
	cin >> n;
	a[0]=0;
	lp(n) {
		cin >> a[i + 1];
		a[i + 1] += a[i];
	}
	sort(a, a + n + 1);
	ll cnt, ans;
	ans = 0;
	cnt = 1;
	lp(n) {
		if (a[i] == a[i + 1])cnt++;
		else {
			ans += cnt*(cnt - 1) / 2;
			cnt = 1;
		}
	}
	ans += cnt*(cnt - 1) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>

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

int main()
{
  int n;
  cin >> n;
  string s;
  unordered_map<string, ll> freq;
  ll ans = 0;
  rep(i, n)
  {
    cin >> s;
    sort(s.begin(), s.end());
    freq[s]++;
    ans += freq[s] - 1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 10660
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// #define pair pair<ll,ll> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


const ll mod =1e9+7;




int main(){

    string s;
    cin>>s;
    ll g=0,p=0;
    ll ans=0;
    for(ll i=0;s[i];i++){
        if(g>p){
            p++;
            ans+=(s[i]=='g');
        }
        else{
            g++;
            ans-=(s[i]=='p');
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 512
n,h=map(int,input().split())
ba=[]
m=0
for i in range(n):
    a,b=map(int,input().split())
    m=max(m,a)
    ba.append([b,a])
ba.sort(reverse=True)
count=0
for i in range(n):
    b,a=ba[i]
    if b>m:
        h-=b
        count+=1
        if h<=0:
            print(count)
            break
    else:
        if h%m==0:
            print(count+h//m)
        else:
            print(count+1+h//m)
        break
else:
    if h%m==0:
        print(count+h//m)
    else:
        print(count+1+h//m)

Measured memory_bytes: 63704
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int i = 1;
  while(1){
     if(i%2){
        c-=b;
     }
     else {
        a-=d;
     }
        
     if(c <= 0 && i%2 == 1){
       cout<<"Yes\n";break;
     }
     else if(a <= 0 && i%2 == 0){
       cout<<"No\n";break;
     }
     i++;
  }
    return 0;
  }

Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
long long MOD = 1000000007;
long long Array[300005];

int Process( int N , int bit ){
    int i , Count = 0;

    for( i = 1 ; i <= N ; ++i ){
        if( ( Array[i] >> bit ) & 1LL ) ++Count;
    }

    return Count;
}

long long FindAns( int N ){
    int i , j , Zeros , Ones , Count;
    long long Ans = 0LL , Num;
    bool Set;

    for( i = 0 ; i <= 59 ; ++i ){
        Count = Process( N , i );
        Num = ( 1LL << i ) % MOD;

        for( j = 1 ; j < N ; ++j ){
            if( ( Array[j] >> i ) & 1LL ){ 
                Set = true;
                --Count;
            }
            else Set = false;

            Ones = Count;
            Zeros = N - j - Ones;

            if( Set == true ) Ans = ( Ans + ( ( Num * Zeros ) % MOD ) ) % MOD; 
            else Ans = ( Ans + ( ( Num * Ones ) % MOD ) ) % MOD;
        }
    }

    return Ans;
}

int main(){
    int i , N;
    scanf( "%d" , &N );

    for( i = 1 ; i <= N ; ++i )
        scanf( "%lld" , Array + i );

    printf( "%lld\n" , FindAns( N ) );
    return 0;
}

Measured memory_bytes: 2560
#include <iostream>
 using namespace std;
 int main(){
     int A,B,C;
     cin >>A>>B>>C;
   if(A==B && B==C){
       cout<<"No"<<endl;
     
    }
   else if(A==C||A==B||B==C){
        cout<<"Yes"<<endl;
    }
   else {
        cout<<"No"<<endl;
    }
      
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a;i < b;i++)
#define rrep(i,a,b) for(int i = a;i >= b;i--)
#define all(x) (x).begin(),(x).end()
#define fore(i,a) for(auto &i:a)
#define dbg(x) cerr << #x << ": " << x << endl;
typedef long long ll;
using namespace std;

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




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

int main(){
   cin.tie(0);
   ios::sync_with_stdio(false);
   
   int n,y;
   cin >> n >> y;
   rep(i,0,n + 1) rep(j,0,n + 1 - i){
      int k = n - i - j;
      if(i + j + k != n || k < 0) continue;
      if(10000 * i + 5000 * j + 1000 * k == y){
         cout << i << " " << j << " " << k << endl;
         return 0;
      }
   }

   cout << "-1 -1 -1" << endl;

   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String[] s = S.split("");
		int count = 0;
		for(int i=1; i<s.length; i++) {
		    if(s[i].equals(s[i-1])) {
		        continue;
		    }else {
		        count++;
		    }
		}
		System.out.println(count);
	}
}

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

int main() {
  string A,B;
  cin >> A >> B;
  int A_size = A.size();
  int B_size = B.size();
  if (A_size > B_size) {
    cout << "GREATER" << endl;
  } else if (A_size < B_size) {
    cout << "LESS" << endl;
  } else if (A == B) {
    cout << "EQUAL" << endl;
  } else {
    int a, b;
    for (int i = 0; i < A_size; ++i) {
      a = A[i] - '0';
      b = B[i] - '0';
      if (a != b) {
        break;
      }
    }
    if (a > b) {
      cout << "GREATER" << endl;
    } else if (a < b) {
      cout << "LESS" << endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;
ll arr[111][2];

int main() {
  int l,k;
  cin >> l >> k;
  arr[0][1] = 1LL;
  rep(i,l) {
    rep(j,2) {
      if( arr[i][j] ) {
	int v = ( j + 1 ) & 1;
	if( !v ) arr[i+k][v] += arr[i][j];
	arr[i+1][v] += arr[i][j];
      }
    }
  }
  ll ans = 0;
  REP(i,1,l+1) ans += arr[i][0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
bool isprime(int x){
	for(int i=2; i*i<=x; i++)if(x%i==0)return false;
	return true;
}
int main(){
	long long int res = 1;int n;
	scanf("%d",&n);
	for(int i=2; i<=n; i++)if(isprime(i)){
		int r = 1;
		for(int x=n; x/=i; r+=x);
		res = res * r % 1000000007;
	}
	printf("%d\n",(int)res);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int a,b;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();

		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else if(a==b){
			System.out.println("a == b");
		}
		sc.close();
	}

}

Measured memory_bytes: 26172
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    X = int(input())
    if X>=30:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


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

int main() {
    int N;
    cin >> N;
    vector<long long> A(N), B(N);
    for(int i=0; i<N; ++i) cin >> A[i] >> B[i];

    long long res = 0;
    for(int i=N-1; i>=0; --i) {
        if((A[i] + res) % B[i] == 0) continue;
        res += B[i] - (A[i] + res) % B[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main()
{

    int n, c = 0, i, j;
    cin >> n;
    string s1;
    map<string,int>m;
    for (i = 0; i < n; i++)
    {
        cin >> s1;
       m[s1]++;
    }
    cout<<m.size()<<endl;

    return 0;
}

Measured memory_bytes: 19260
#include <bits/stdc++.h>
#define lol long long
using namespace std;
signed main(){
  string s,t;
  int n,ans=0,co;
  cin>>n>>co;
  if(n<10)
    cout<<co+100*(10-n)<<"\n";
  else cout<<co<<"\n";
  return(0);
}


Measured memory_bytes: 256
import java.io.*;

public class Main {
  public static void main(String... args) {
    BufferedReader br = new BufferedReader(
      new InputStreamReader(System.in));

    try {
      String s = br.readLine();
      if(s.equals("Sunny")) {
        System.out.println("Cloudy");
      } else if(s.equals("Cloudy")) {
        System.out.println("Rainy");
      } else {
        System.out.println("Sunny");
      }
      br.close();
    } catch(IOException e) {
      e.printStackTrace();
    }
  }
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    double a, b, c, s, l, h;
    cin >> a >> b >> c;
    double rad = c * M_PI / 180.0;
    s = (a * b * sin(rad)) / 2;
    l = a + b + sqrt(a* a + b * b - 2 * a * b * cos(rad));
    h = s * 2 / a;
    cout << fixed << setprecision(6) << s << endl;
    cout << fixed << setprecision(6) <<  l << endl;
    cout << fixed << setprecision(6) <<  h << endl;
    return 0;
}


Measured memory_bytes: 3508
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	A, B := float64(scanInt()), float64(scanInt())
	minA := A / 0.08
	maxA := (A + 0.9) / 0.08
	minB := B / 0.1
	maxB := (B + 0.9) / 0.1
	ans := math.Max(minA, minB)
	if ans > math.Min(maxA, maxB) {
		fmt.Println(-1)
	} else {
		fmt.Println(int(ans + .5))
	}
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
//#include <math.h>
#include <algorithm>
#include <vector>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;

ll dp[10005][100];

int main(int argc, char* argv[])
{
    char str[10005]={0};
    scanf("%s", str);
    long d;
    scanf("%ld", &d);

    long len=strlen(str);
    
    long i, j, m;
    dp[0][0]=1;
    for(i=1; i<len; i++) {
        for(j=0; j<=9; j++) {
            for(m=0; m<d; m++) {
                dp[i][m] = (dp[i][m]+dp[i-1][(m+j*d-j)%d]) %MOD;
            }
        }
    }

    ll ans = 0;
    long sum = 0;
    for(i=0; i<len; i++) {
        long curr = str[i]-'0';        
        for(j=0; j<(i==len-1? curr+1: curr); j++) {
            ans = (ans + dp[len-i-1][(11*d-sum-j)%d])%MOD;
        }
        sum = (sum+curr)%d;
    }

    printf("%lld\n", (ans+MOD-1)%MOD);

    return 0;
}


Measured memory_bytes: 7936
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
int main(){
	ll h,w,mod=pow(10,9)+7,n;
	cin>>n;
	vector<long double> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	vector<vector<long double>> p(n+1,vector<long double>(n+1,(long double)0));
	p[0][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=n;j++){
			if(!j)
			p[i][j]=p[i-1][j]*(1-a[i-1]);
			else {
				p[i][j]=p[i-1][j-1]*a[i-1]+p[i-1][j]*(1-a[i-1]);
			}
//			cout<<p[i][j]<<" ";
		}
//		cout<<endl;
	}
	if(n%2)
	cout<<setprecision(20)<<accumulate(p[n].begin()+ceil(n/2.0),p[n].end(),(long double)0)<<endl;
	else 
	cout<<setprecision(20)<<accumulate(p[n].begin()+n/2+1,p[n].end(),(long double)0)<<endl;
}

Measured memory_bytes: 144220
#include "bits/stdc++.h"
using namespace std;
int main(){
    int N,M,i,j,ans=0,tmp;
    string now;
    cin >> N;
    vector<string> s(N);
    for(i=0;i<N;i++) cin >> s.at(i);
    cin >> M;
    vector<string> t(M);
    for(i=0;i<M;i++) cin >> t.at(i);
    for(i=0;i<N;i++){
        now = s.at(i);
        tmp = 0;
        for(j=0;j<N;j++) if(now == s.at(j)) tmp++;
        for(j=0;j<M;j++) if(now == t.at(j)) tmp--;
        ans = max(ans,tmp);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#include<queue>
#define h 1000000007
#define lli long long int
#define pb push_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	double s, v, t;
	cin>>s>>t>>v;
	if((s/v)<=t) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
  return 0;
} 



Measured memory_bytes: 3736
N = int(input())
A = list(map(int, input().split()))

A.append(0)
A.insert(0, 0)

D = []

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

tot = sum(D)

for n in range(N):
    ans = tot - abs(D[n]+D[n+1]) + abs(A[n]-A[n+2])
    print(ans)

Measured memory_bytes: 14176
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<iostream>
using namespace std;

int main()
{
	int N, M, i,D,X, j, k, l, m, n, sum, cnt, flag;
	cin >> N>>D>>X;
	vector<int>A(N);
	for (i = 0; i < N; i++) {
		cin >> A[i];
	}
	sum = X;
	flag = 0;
	cnt = 0;
	for (i = 0; i < N; i++) {
		sum += (D - 1) / A[i] + 1;
	}
	cout<<sum<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = int_fast64_t;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr<<#x<<":"<< (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;
	VAR(int, n, m, x, y);
	VEC(int, p, n);
	VEC(int, q, m);

	sort(ALL(p));
	sort(ALL(q));
	bool ok = false;
	FOR(z, -100, 101) {
		if (!(z > x && z <= y)) continue;
		if (z > p.back() && z <= q[0]) ok = true;
	}

	OUT(ok ? "No War" : "War")BR;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()

using namespace std;

typedef long long ll;
typedef long double ld;

static const long long MOD = 1000000007;
static const long long INF = 1<<31;

ll ans;
map<ll, ll> m;
ll n, a[200005];

int main(void) {
    cin >> n;
    rep(i, 0, n) scanf("%lld", &a[i]);

    rep(i, 0, n) {
        ll t = a[i] - i;
        ans += m[t];
        m[-1*a[i]-i]++;
    }
    

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 27808
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back
#define eb emplace_back
#define mod   998244353
#define PI 2*acos(0.0)
int dirx[] = {1, -1,0, 0}, diry[] = {0, 0, 1, -1};

ll bigmod(ll x, ll p)
{
    ll res = 1;
    while(p)
    {
        if(p&1)
            res = (res*x)%mod;
        x = (x*x)%mod;
        p >>= 1;
    }
    return res;
}

//=============================================ASIFAZAD==============================================//

int32_t main()
{
    io;
    int n, m;
    cin>>n>>m;
    vi val(n), cnt(n);
    for(auto& x: val) cin>>x;

    vector<bool> vis(n);
    vi adj[n];

    while(m--)
    {
        int u,v;
        cin>>u>>v;
        u--;
        v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    int ans = 0;
    for(int i = 0; i< n;i++)
    {
        int j;
        for(j = 0; j < adj[i].size(); j++)
            if(val[adj[i][j]] >= val[i])
                break;
        if(j >= adj[i].size())
            ans++;

    }

    cout<<ans;
    return 0;
}


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

using namespace std;
#define N 100100
#define SIGMA 26

int x, n, i, ok;
int main()
{
    int T = 1;
    //cin >> T;
    for (int tt = 0; tt < T; ++tt){
        cin >> n;
        ok = 1;
        for (i = 0;i < n; ++i){
            cin >> x;
            if (x % 2 == 0 && (x % 3 != 0 && x % 5 != 0))
                ok = 0;
        }
        if (ok)
            cout << "APPROVED";
        else
            cout << "DENIED";
    }
    return 0;
}


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

int main(){
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); cerr.tie(NULL);
    
    string str;
    cin >> str;
    if(str[2] == str[3] and str[4] == str[5]){
        cout << "Yes";
    }
    else cout << "No";
}

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

const int N = 100000;

int partition(int l, int r, int A[]) {
  int i, j, x;

  x = A[r];
  i = l - 1;

  for (j = l; j < r; j++) {
    if (A[j] <= x) {
      i++;
      swap(A[i], A[j]);
    }
  }

  swap(A[i+1], A[r]);

  return i + 1;
}                                

int main() {
  int i, n;
  int A[N];

  cin >> n;
  for (i = 0; i < n; i++) cin >> A[i];

  int q = partition(0, n-1, A);

  for (i = 0; i < n; i++) {
    if (i > 0) cout << " ";
    if (i == q) cout << "[" << A[i] << "]";
    else cout << A[i];
  }
  cout << endl;

  return 0;
}



Measured memory_bytes: 3476
let _ =
	read_line ()
	|> (fun n -> ["a";"i";"u";"e";"o"]
			|> List.map (fun x -> x = n)
			|> List.fold_left (fun x y -> x || y) false)
	|> (fun p ->
		if p
		then print_string "vowel"
		else print_string "consonant"
		)


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,d;
    cin>>n>>d;
    int ans=0;
    long long int x,y;
    for (int i=0;i<n;i++){
        cin>>x>>y;
        if(x*x+y*y<=d*d) ans++;
    }
    cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
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; }

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v){
    for (auto &e : t) fill(e, v);
}

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }

#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }




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

    int N;cin >> N;
    cout << N * N * 3 << endl;
    
    
}


















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,g;cin >> n >> g;
	vector<int> p(n);
	vector<int> c(n);
	rep(i,n) cin >> p.at(i) >> c.at(i);
	int ans=1000000000;
	int cnt=0,sum=0;
	for(int i=0;i<(1<<n);++i){
		cnt=0;
		sum=0;
		rep(j,n){
			if(i&(1<<j)){
				sum+=p.at(j)*(j+1)*100+c.at(j);
				cnt+=p.at(j);
			}
		}
		for(int j=n-1;j>=0;--j){
			if(sum>=g) break;
			if(i&(1<<j)) continue;
			rep(k,p.at(j)){
				if(sum>=g) break;
				sum+=100*(j+1);
				cnt++;
			}
		}
		ans=min(ans,cnt);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define debug cout<<"Debug"<<endl;
#define ll long long 
using namespace std;

ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll quickpow(ll a,ll b)
{
	ll ans=1;
	while(b)
	{
		if(b&1) ans*=a;
		a*=a;b>>=1;
	}
	return ans;
}
set<ll>::iterator it;
int main()
{
	int n;
	cin>>n;
	int ans=0;
	set<ll> se,temp;
	for(int i=1;i<=n;i++)
	{
		int x;cin>>x;
		while(1)
		{
			if(x%2==0 && x!=0)
			{
				ans++;x/=2;
			}
			else break;
		}
	}
	cout<<ans<<endl;
	return 0;	
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int x=0,n,max=0;
    char s[100];
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++){
        if(s[i]=='I') x+=1;
        else x-=1;
        if(max<x) max=x;
    }
    printf("%d",max);
    return 0;
}

Measured memory_bytes: 128
//#pragma comment(linker, "/STACK:102400000,102400000") 
#pragma warning(disable:4996)
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x33ffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e6 + 5;
const ll mod = 1e9 + 7;
const double PI = acos(-1.0);

int n, k;
bool dp[2002][10001];
bool good[2002][10001];
int vis[2002];
string s[2002];
vector <int> which;
vector <int> pos;
vector <int> next_which;
vector <int> next_pos;

char getBest()
{
	char ret = 'z';
	for (int i = 0; i < which.size(); i++)
	{
		ret = min(ret, s[which[i]][pos[i]]);
	}
	return ret;
}

void updateNext(char c, int remain)
{
	mem(vis, 0);
	next_which.clear();
	next_pos.clear();
	int firstFinish = n + 1;
	int rate = which.size() / 4000;
	rate = 0;
	int sz = which.size();
	for (int i = 0; i < sz; i += (rate + 1))
	{
		if (s[which[i]][pos[i]] == c)
		{
			if (pos[i] == s[which[i]].length() - 1)
			{
				firstFinish = min(firstFinish, which[i]);
			}
			else
			{
				vis[which[i]] = 1;
				next_which.push_back(which[i]);
				next_pos.push_back(pos[i] + 1);
			}
		}
	}
	for (int i = firstFinish + 1; i <= n; i++)
	{
		if (vis[i])continue;
		if (good[i][remain])
		{
			next_which.push_back(i);
			next_pos.push_back(0);
		}
	}
	which = next_which;
	pos = next_pos;
}

void solve()
{
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
	{
		cin >> s[i];
	}
	memset(dp, 0, sizeof(dp));
	dp[n + 1][0] = true;
	for (int i = n; i >= 1; i--)
	{
		for (int j = 0; j <= k; j++)
		{
			if (dp[i + 1][j] == true)
			{
				dp[i][j] = true;
			}
			if (j - (int)s[i].length() >= 0 && dp[i + 1][j - (int)s[i].length()])
			{
				dp[i][j] = true;
			}
		}
	}
	memset(good, false, sizeof(good));
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			if (s[i].length() <= j && dp[i + 1][j - (int)s[i].length()])
			{
				good[i][j] = true;
			}
		}
	}
	int remain = k;
	for (int i = 1; i <= n; i++)
	{
		if (good[i][remain])
		{
			which.push_back(i);
			pos.push_back(0);
		}
	}
	string ret;
	for (int i = 1; i <= k; i++)
	{
		char c = getBest();
		remain--;
		updateNext(c, remain);
		ret += c;
	}
	cout << ret << endl;
}

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


Measured memory_bytes: 40704
N, M = map(int, input().split())
lst = [[0, 0], [1, 0]] + [[0, 1] for _ in range(N)]

for _ in range(M):
    x, y = map(int, input().split())
    if lst[x][0] == 0: #赤いボールがないとき
        lst[x][1] -= 1 #白いボールを移動させる
        lst[y][1] += 1
    if lst[x][0] == 1: #赤いボールがあるとき
        if lst[x][1] == 0: #赤いボールしかないとき
            #赤いボールを移動させる
            lst[x][0] -= 1
            if lst[y][0] == 0:
                lst[y][0] = 1
            else:
                lst[y][1] += 1
        else:
            #全体のボールを減らして、x, yともに赤が入っていることとする
            lst[x][1] -= 1
            if lst[y][0] == 0:
                lst[y][0] = 1
            else:
                lst[y][1] += 1
count = 0
for i in lst:
    if i[0] == 1:
        count += 1
print (count)
# print (lst)

Measured memory_bytes: 13940
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<iomanip>
#include<map>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const int z = 1000000007;
long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
int main() {
    int n;
    cin >> n;
    if (n >= 30)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
    
}


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

int main(){
 	int n;
  	cin>>n;
  	if((n/1000==n/100%10)&&(n/1000==n/10%10))
      cout<<"Yes"<<endl;
  	else if((n%10==n/100%10)&&(n%10==n/10%10))
      cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
#define intt long long

int main() {
	intt N; std::cin >> N;
	std::vector<intt> t(N);
	std::vector<intt> x(N);
	std::vector<intt> y(N);
	for (intt i = 0; i < N; ++i)
		std::cin >> t[i] >> x[i] >> y[i];
	intt X = 0;
	intt Y = 0;
	intt T = 0;
	bool flag = true;
	for (intt i = 0; i < N; ++i) {
		X = std::abs(X - x[i]);
		Y = std::abs(Y - y[i]);
		T = t[i] - T;
		if (X + Y > T || (X + Y) % 2 != T % 2)
			flag = false;
	}
	if (flag == true)
		std::cout << "Yes" << std::endl;
	else
		std::cout << "No" << std::endl;

	return 0;
}

Measured memory_bytes: 5632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
//i64 mod = 998244353;
int int_max = 2147483647;
i64 INF = 1e16;
int max_n = 1e5;


int main(int argc, char **argv) {
    string s,t;
    cin >> s >> t;
    i64 min_diff{int_max};
    for (int i=0; i<=s.size()-t.size(); ++i) {
        i64 tmp_diff{0};
        for (int j=0; j<t.size(); ++j) {
            if (s[i+j] != t[j]) ++tmp_diff;
        }
        min_diff=min(min_diff, tmp_diff);
    }

    cout << min_diff << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){
    int N, K;
    long long h;
    cin >> N >> K;
    vector<long> Hs(N, 0);
    for(int i = 0; i < N; i++){
        cin >> h;
        Hs[i] = h;
    }
    sort(Hs.begin(), Hs.end(), greater<long long>());
    int maxH = 0, minH = 0;
    long long ans = 10e9;
    for(int i = 0; i < N-K+1; i++){
        int tmp = Hs[i] - Hs[i+K-1];
        if(tmp < ans) ans = tmp;
    }

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

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=998244353;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,m;
vvi g;
vi a;

int main(){
	cin>>n>>m;
	g=vvi(n);
	a=vi(n);
	for(auto &i:a) cin>>i;
	for(int i=0;i<m;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int res=0;
	for(int i=0;i<n;i++){
		int B=1;
		for(auto v:g[i]) if(a[i]<=a[v]) B=0;
		res+=B;
	}
	cout<<res<<endl;
}

Measured memory_bytes: 8744
def main():
    S = input()
    N = len(S)
    a = S.count("a")
    b = S.count("b")
    c = S.count("c")
    ma = max(a, b, c)
    mi = min(a, b, c)
    if ma - mi > 1:
        print("NO")
    else:
        print("YES")


if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
lines = []
colums = []

while True:
  H,W = map(int,input().split())
  if H == 0 and W == 0:
    break
  lines.append(H)
  colums.append(W)

for H,W in zip(lines,colums):
  for i in range(H):
    if i == 0 or i == H-1:
      for j in range(W):
        print("#",end="")
    else:
      for j in range(W):
        if 0 < j and j < W-1:
          print(".",end="")
        else:
          print("#",end="")
    print("\n",end="")
  print("\n",end="")


Measured memory_bytes: 7020
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll a,b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
int N,K;
cin >> N >> K;
string S;
cin >> S;
int m  =0;//元々のhappyな人の数
int ans = 0;
for(int i = 1;i<N;i++){
    if(S[i-1] == S[i]) m++;
}
string S2;//Sの連続する同じ文字を１個とみなした文字列
S.push_back('1');
for(int i = 0;i<N;i++){
    if(S[i] != S[i+1]){//自分より右側の文字が自分と異なっていればS2に追加
        S2.push_back(S[i]);
    }
}

int p = 0;//maxの反転回数
if(S2.size() %2 != 0){
p = S2.size()/2;
ans = m + min(p,K)*2;
}

if(S2.size()%2 == 0){
p = (S2.size()-2)/2;//末端を除く反転箇所の数
if(K<=p) ans = m + K*2;
else if(K>p) ans = m + p*2 +1;
}

cout << ans << endl;
}

Measured memory_bytes: 640
void main() {
	auto X = rs;
	string res = X[0..1];
	foreach(i; X[1..$]) {
		if(res.length == 0) { res ~= i; continue; }
		auto p = res.back;
		if(p == 'S' && i == 'T') res.popBack;
		else res ~= i;
	}
	res.length.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


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

using namespace std;

typedef long long li;

const int N = 100100;
const int MOD = 1e9 + 7;

li z[20][N];

void init() {
  for (int i = 0; i < N; ++i) {
    z[0][i] = i;
  }
  for (int i = 1; i < 20; ++i) {
    int L = 1 << i;
    if (L >= N)
      break;
    int h = L / 2;
    for (int j = 0; j + L <= N; ++j) {
      z[i][j] = (z[i - 1][j] * z[i - 1][j + h]) % MOD;
    }
  }
}

int Ank2(int n, int k) {
  int fm = n - k + 1, to = n;
  int span = to + 1 - fm;
  int off = fm;
  li res = 1;
  for (int b = 20; b >= 0; --b) {
    int L = (1 << b);
    if (span & L) {
      res = (res * z[b][off]) % MOD;
      off += L;
    }
  }
  return int(res);
}

int main() {
  init();
  int n;
  scanf("%d", &n);
  vector<int> a(n), b(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
    b[i] = (a[i] +  1) / 2;
  }
  int p = 0;
  li cur = 1;
  for (int id = 0; id < n; ++id) {
    p += 1;
    int diff = p - b[id];
    if (diff > 0) {
      cur = (cur * Ank2(p, diff)) % MOD;
      p -= diff;
    }
  }
  cur = (cur * Ank2(p, p)) % MOD;
  printf("%lld\n", cur);
  return 0;
}


Measured memory_bytes: 15360
H, W = map(int, input().split())
h, w = map(int, input().split())

lst = [[0]*W for _ in range(H)]

for i in range(h):
    for j in range(W):
        lst[i][j] = 1
        
for i in range(H):
    for j in range(w):
        lst[i][j] = 1

ans = 0

for i in range(H):
    for j in range(W):
        if lst[i][j] == 0:
            ans += 1
            
print(ans)

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

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    while(cin >> a >> b) {
        if(a % b == 0) {
            cout << -1 << endl;
            return 0;
        }
        ll ans = a;
        while(ans <= 1e18) {
            if(ans % b == 0) ans += a;
            else break;
        }
        cout << ans << endl;
    }
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int n;
    cin>>n;
    vi a(n);
    rep(i,n)cin>>a[i];


    //dp[i]:i日めが始まるタイミングでの所持金(株0)
    vl dp(n+1);
    dp[0]=1000;
    dp[1]=1000;

    //i日めに買ってj日めに売る
    rep(i,n-1){

        ll kabu=dp[i]/a[i];
        ll money=dp[i]%a[i];

        ll m=dp[i];
        repa(j,i+1,n){
            cmax(dp[j+1],max(money+kabu*a[j],m));
            cmax(m,dp[j+1]);
        }
    }

    cout<<dp[n]<<"\n";

    return 0;

}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)

int main(){
  ll i,N,ans=0,a,b,c,d,e;
  cin>>N;
  vec point(N);
  rep(i,N){
    cin>>a;
    point[a-1]=i;
  }
  multiset<ll> se;
  se.insert(point[N-1]);
  se.insert(-1);
  se.insert(N);
  se.insert(-1);
  se.insert(N);

  for(i=N-2;i>=0;i--){
    c=point[i];
    auto p=se.upper_bound(c);
    d=*p;
    p++;
    e=*p;
    p--;p--;
    b=*p;
    p--;
    a=*p;
    se.insert(c);
    ans+=(e-d)*(c-b)*(i+1);
    ans+=(d-c)*(b-a)*(i+1);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 5760
_n, m = gets.split.map(&:to_i)

ken = Hash.new {|hash, key| hash[key] = [] }

data = m.times.map.with_index do |i|
  p, y = gets.split.map(&:to_i)
  ken[p] << [i, y]
  [p, y]
end

ken.each do |p, value|
  value
    .sort_by(&:last)
    .each.with_index(1) {|(data_index, _year), order| data[data_index][1] = order }
end

data.each {|p, o| puts "%06d%06d" % [p, o] }


Measured memory_bytes: 35836
#include <stdio.h>

int main(){
	int x,y,n,i=0;
	while(i==0){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0){break;}
		if(x>y){
			n=x;
			x=y;
			y=n;
		}
		printf("%d %d\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 600