akhauriyash/Code-Regression huggingface dataset:
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <limits.h>
#include <assert.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <bitset>
#include <vector>
using namespace std;

#define LL long long

#define fi first
#define se second
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(a,b) (((a)+(b))>>1)
#define maxx(a,b) ((a)<(b)?(b):(a))
#define minx(a,b) ((a)<(b)?(a):(b))
#define absx(a) ((a)<0?-(a):(a))
#define mk(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define itr iterator
#define lowbit(x) ((x)&-(x))

typedef unsigned LL ULL;
typedef unsigned uint;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<LL,LL> pLL;

template< typename T > inline void read(T &x) {
    static bool fr_f; static char fr_ch;
    fr_f=0; x=0; fr_ch=getchar();
    while(fr_ch<'0' || '9'<fr_ch) {if(fr_ch=='-') fr_f=1; fr_ch=getchar();}
    while('0'<=fr_ch && fr_ch<='9') {x=(x<<1)+(x<<3)+fr_ch-'0'; fr_ch=getchar();}
    if(fr_f) x=-x;
}

template< typename T > inline void Max (T &a, T b) {if(a<b) a=b;}
template< typename T > inline void Min (T &a, T b) {if(b<a) a=b;}
template< typename T > inline void Swap(T &a, T &b) {T c=a;a=b;b=c;}
template< typename T > inline T Abs(T a) {if(a<0) return -a; else return a;}

const double   pi = acos(-1.0) ;
const int     MOD = (int)1e9+7 ;
const int     INF = (int)0x3f3f3f3f ;
const LL     LINF = (LL)INF<<32|INF ;
const int    SINF = (uint)(-1)>>1 ;
const LL    SLINF = (ULL)(-1)>>1 ;
const double DINF = 1e50 ;
const double  eps = 1e-5 ;
const int    maxn = (int) 2e5+20 ;
const int    maxm = (int) 1e6+20 ;
const int    maxk = (int) 1000+20 ;

inline int sig(double x) {return x<-eps?-1:x>eps;}
inline LL fp(LL a,LL n,LL p) {LL res=1; for(;n;n>>=1,a=a*a%p) if(n&1) res=res*a%p; return res;}
template<typename T>inline T gcd(T a,T b) {for(T c;b;c=a%b,a=b,b=c); return a;}

//--------------------start--------------------

int n;
int a[maxn];
int x[maxn];

void work()
{
    read(n);
    for(int i=1;i<=n;i++) read(a[i]);

    LL ans = 0;
    int wall = 0;
    for(int i=n;i>=1;i--)
    {
        if(a[i] - i >= 0)
        {
            puts("-1");
            return ;
        }

        if(wall < a[i])
        {
            ans += a[i];
            wall = a[i];
        }

        if(wall > a[i])
        {
            puts("-1");
            return ;
        }
        wall--;
    }

    cout <<ans <<endl;
}

//---------------------end---------------------

int main()
{
#ifdef yukihana0416
freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
#endif // yukihana0416
    work();
    return 0;
}


Measured memory_bytes: 1024
/* In the name of Allah */
#include<bits/stdc++.h>
using namespace std;

const int N = 3e3 + 5;
double p[N], dp[N][N] = {1};
int n;

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

	cin >> n;
	for (int i = 0; i < n; i++) {
		double p;
		cin >> p;
		dp[i + 1][0] = dp[i][0];
		for (int j = 1; j <= i + 1; j++)
			dp[i + 1][j] = p * dp[i][j - 1] + (1 - p) * dp[i][j];
	}
	cout << fixed << setprecision(10) << dp[n][n + 1 >> 1] << endl;

	return 0;
}



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

namespace Min__Max_and_Sum
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = int.Parse(Console.ReadLine());
            string[] strs = Console.ReadLine().Split(' ');
            long[] longArr = new long[strs.Length];
            for (int i = 0; i < strs.Length; i++)
            {
                longArr[i] = int.Parse(strs[i]);
            }

            long min = longArr.Min();
            long max = longArr.Max();
            long sum = longArr.Sum();

            Console.WriteLine(min + " " + max + " " + sum);
        }
    }
}



Measured memory_bytes: 18316
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < n; ++i) 
#define REP(i,k,n) for (int i = k; i <= n; ++i) 
#define REPR(i,k,n) for (int i = k; i >= n; --i)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define debug1(a) cout<<" a : "<<a<<"\n"
#define debug2(a,b) cout<<" a : "<<a<<" b : "<<b<<"\n"
#define debug3(a,b,c) cout<<" a : "<<a<<" b : "<<b<<" c : "<<c<<"\n"

signed main()
{
	int n,w;
	cin>>n>>w;
	pair <int,int> a[n+1];
	rep(i,n)
	{
		cin>>a[i+1].S>>a[i+1].F;
	}
	sort(a,a+n+1);
	int dp[n+1][(int)1e5+1];
	fill(dp[0],dp[0]+(int)1e5+1,1e9+5);
	rep(i,n+1) dp[i][0]=0;
	REP(i,1,n)
	{
		REP(j,1,(int)1e5)
		{
			if (j<a[i].F)
			dp[i][j]=dp[i-1][j];
			else
			dp[i][j]=min(dp[i-1][j],dp[i-1][j-a[i].F]+a[i].S);
		}
	}
	// rep(i,n+1)
	// {
	// 	rep(j,20) cout<<dp[i][j]<<" ";
	// 	cout<<"\n";
	// }
	int ans=0;
	REP(i,1,n)
	{
		REP(j,1,(int)1e5)
		{
			if (dp[i][j]<=w)
			{
				ans=max(ans,j);
			}
		}
	}
	cout<<ans;
   return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int64_t A,B,r,x,tmp;
  cin>>A>>B;
  x=A*B;
  if(A<B){tmp=A;A=B;B=tmp;}
  r=A%B;
  while(r!=0){A=B;B=r;r=A%B;}
  cout<<x/B<<endl;
}

Measured memory_bytes: 256
n = int(input())
l =[[0]*2 for i in range(n)]
checker = 0
a_ = 0
for i in range(n):
    a,b = map(int, input().split())
    l[i][1] = a
    l[i][0] = b

l = sorted(l)

for i in range(n):
    a_ = a_ + l[i][1]
    if a_ > l[i][0]:
        checker = 1
        break

if checker == 1:
    print('No')
else:
    print('Yes') 

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

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

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

  int n, x;
  cin >> n >> x;
  vector<int> c(n);
  rep(i, n) cin >> c[i];
  c.push_back(x);
  sort(c.begin(), c.end());

  vector<int> d(n);
  rep(i, n) {
    d[i] = c[i+1] - c[i];
  }
  int min_num = 1001001001;
  int ans = min_num;
  if(d.size() == 1) {
    ans = d[0];
  }
  for(int i = 1; i < n; ++i) {
    ans = min(ans, gcd(d[0], d[i]));
  }

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

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

int main(){
    string s;
    cin >> s;
    bool c[26] = {false};
    rep(i, s.size()){
        c[s[i]-'a'] = true;
    }
    rep(i, 26){
        if(!c[i]){
            cout << (char)('a'+i) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

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

const int MAXN = 100005;
char str[MAXN];

int main()
{
	scanf("%s", str+1);
	int n = strlen(str+1), ans = n;
	for (int i = 1; i < n; i++)
		if (str[i] != str[i+1])
			ans = min(ans, max(i, n-i));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(){
    int sum=0,n;
    string s;
    while(1){
        cin>>s;
        if(s=="0"){
            break;
        }
        for(int i=0;i<s.size();i++){
            n=s[i]-'0';
            sum=sum+n;
        }
        cout<<sum<<endl;
        sum=0;
    }
    return 0;
}


Measured memory_bytes: 3232
#include <bits/stdc++.h>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, a, n) &((x)[a]), &((x)[n])
#define ADD(a, b) ((((a+MOD)%MOD)+((b+MOD)%MOD))%MOD)
#define MUL(a, b) ((((a)%MOD)*((b)%MOD))%MOD)
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define pf push_front
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define EPS (1e-20)
#define INF INT_MAX
#define INFLL LLONG_MAX
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using MCI = std::map<char, int>;
using VPII = std::vector<PII>;
using namespace std;


int N, M, Q;
int acc[510][510];


void makeAcc(){
	repe(i, 1, N)
		repe(j, 1, N) acc[i][j] += acc[i][j-1];
}


signed main(){
	cin >> N >> M >> Q;
	rep(i, 0, M){
		int L, R;
		cin >> L >> R;
		acc[L][R]++;
	}
	
	makeAcc();

	rep(i, 0, Q){
		int ans = 0;
		int p, q;
		cin >> p >> q;
		repe(i, p, q) ans += (acc[i][q]-acc[i][p-1]);
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

int main(void)
{
    string s;

    cin >> s;

    if(s == "Sunny") cout << "Cloudy" << endl;
    if(s == "Cloudy") cout << "Rainy" << endl;
    if(s == "Rainy") cout << "Sunny" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

const int primemax = 500000;
bool prime[primemax];

void init() {
    for (int i = 0; i < primemax; i++) {
        prime[i] = true;
    }
    prime[0] = prime[1] = false;
    for (int i = 2; i * i < primemax; i++) {
        if (prime[i]) {
            for (int j = i * 2; j < primemax; j += i) {
                prime[j] = false;
            }
        }
    }
}

int main() {
    init();
    int n;
    while(1) {
        cin >> n;
        if (n == 0)break;
        int res = 0;
        int i = 2;
        while (n > 0) {
            if (prime[i]) {
                n--;
                res += i;
            }
            i++;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main(){

    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
    }
    int L = vec[0];
    int R = vec[0];

    for(int i = 0; i < N; i++){
        L = min(L, vec[i]);
        R = max(R, vec[i]);
    }
    int ans = 10e9;
    for(int i = L; i <= R; i++){
        int cost = 0;
        for(int j = 0; j < N; j++) cost +=(vec[j]-i)*(vec[j]-i);
        ans = min(ans, cost);
    }

    cout <<ans <<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
  int n,q;
  int tmp;
  int cnt = 0;
  std::cin >> n;
  int s[n];
  for(int i=0;i<n;i++){
    std::cin >> s[i];
  }
  std::cin >> q;
  int t[q];
  for(int i=0;i<q;i++){
    std::cin >> t[i];
  }
  for(int i=0;i<q;i++){
    tmp = t[i];
    for(int j=0;j<n;j++){
      if(s[j]==tmp){
	      cnt++;
	      break;
      }
    }
  }
  std::cout << cnt << "\n";
  return 0;
}



Measured memory_bytes: 3108
import java.util.*

fun main() = abc167c()

@OptIn(ExperimentalStdlibApi::class)
fun abc167c() {
    val (n, m, x) = readLine()!!.split(' ').map { it.toLong() }
    val books = (1..n).map {
        val map = readLine()!!.split(' ').map { it.toLong() }
        map[0] to map.drop(1)
    }

    var answer = Long.MAX_VALUE

    for (i in 0L until (1L shl n.toInt())) {
        val bitSet = BitSet.valueOf(longArrayOf(i))
        val filtered = books.filterIndexed { index, pair -> bitSet[index] }

        val sum = LongArray(m.toInt())
        filtered.forEach { it.second.forEachIndexed { index, l -> sum[index] += l } }

        if (sum.all { it >= x }) {
            answer = Math.min(answer, filtered.map { it.first }.sum())
        }
    }

    if (answer == Long.MAX_VALUE) answer = -1

    println(answer)
}



Measured memory_bytes: 43380
#include <cstdio>
#include <cstring>
#pragma warning(disable : 4996)
#define rng(x, y) (0 <= x && x < W && 0 <= y && y < H)
int H, W, n, gx, gy, x[12][12], d[4] = { 1, 0, -1, 0 };
inline int solve(int sx, int sy, int depth) {
	if (depth == n) {
		if (sx == gx || sy == gy) return 1;
		return 0;
	}
	int ret = 0;
	for (int i = 0; i < 4; i++) {
		int tx = sx + d[i], ty = sy + d[i ^ 1];
		while (rng(tx, ty)) {
			if (x[ty][tx] == 1) {
				x[ty][tx] = 0;
				ret += solve(tx, ty, depth + 1);
				x[ty][tx] = 1;
				break;
			}
			tx += d[i];
			ty += d[i ^ 1];
		}
	}
	return ret;
}
int main() {
	while (scanf("%d%d", &W, &H), W | H) {
		n = 0;
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) scanf("%d", &x[i][j]);
		}
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if (x[i][j] == 1) n++;
				if (x[i][j] == 2) gx = j, gy = i;
			}
		}
		printf("%d\n", solve(gx, gy, 0));
	}
	return 0;
}

Measured memory_bytes: 2712
#include<stdio.h>
int main()
{
  int a[1000][3],i,n,j,t,b;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<3;j++){
      scanf("%d",&a[i][j]);
    }

    for(b=0;b<2;b++){
      for(j=2;j>b;j--){
	if(a[i][j]<a[i][j-1]){
	  t=a[i][j];
	  a[i][j]=a[i][j-1];
	  a[i][j-1]=t;
	}
      }
    }

    if((a[i][2]*a[i][2])==(a[i][0]*a[i][0])+(a[i][1]*a[i][1])){
      printf("YES\n");
      }
    else{
      printf("NO\n");
	}
  }
  return 0;
}

Measured memory_bytes: 592
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main = do
  [n,c] <- fmap (map read . words) getLine
  text <- B.getContents
  let xs = map ((\(x:v:_)-> x`seq`v`seq`(x,v)) . map readI . B.words) (B.lines text)
  print (solve c xs)


-- for fast read
readI :: B.ByteString -> Int
readI s = case B.readInt s of Just (n,_) -> n


-- MaxState, CurrentState, CurrentX
type State = (Int, (Int, Int))

solve :: Int -> [(Int,Int)] -> Int
solve c xs =
  solveTurn roundR roundL
  where
    roundR = scanl f (0,(0,0)) xs
    roundL = scanr (flip f) (0,(0,0)) [(c-x,v)|(x,v)<-xs]

    f (m,(s,y)) (x,v) = let s' = s-(x-y)+v in (max m s', (s', x))

solveTurn :: [State] -> [State] -> Int
solveTurn ss1 ss2 =
  foldl' f 0 (zip ss1 ss2)
  where
    f a (((m1,(s1,x1))),((m2,(s2,x2)))) = max a $! max (s1+m2-x1) $! (s2+m1-x2)


Measured memory_bytes: 60796
#include<iostream>
using namespace std;
int main () {
	int a,b;
	cin>>a>>b;
	if (a>0) cout<<"Positive";
	else if (b>=0) cout<<"Zero";
	else if ((a%2)^(b%2)) cout<<"Positive";
	else cout<<"Negative";
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
// std::cout << std::setprecision(2) << 3.141; // "3.1"
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

static const int giga = pow(10,9);
// double pi = 3.141592653589793238463;

int main(void){
  int a;
  cin >> a;
  string s;
  cin >> s;
  if(a >= 3200){
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
    if(y==0)
        return x;
    else
        return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
        if(m%2)
            r=(r*n)%p;
        n=(n*n)%p;
        m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}
int32_t main()
{
   IOS;
  /* #ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/	
   int n;
   cin>>n;
   int ans=0;
   int a[n];
   for(int i=0;i<n;i++)
   {
        cin>>a[i];
   }
   for(int i=0;i<n-1;i++)
   {
        if(a[i]==a[i+1])
        {
                a[i+1]=10000;
                ans++;
        }
   }
   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 All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int d[1005][1005] = {0};  
int main()
{
  int h, w; cin >> h >> w;
  queue<pair<int, int>> q;
  rep(i, h) rep(j, w){
    char c; cin >> c;
    if(c == '#'){
      q.push(P(j, i));
      d[i][j] = 0;
    }
    else d[i][j] = -1;
  }
  int ans = 0;
  int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};
  while(!q.empty()){
    P a = q.front(); q.pop();
    int x = a.first, y = a.second;
    for(int i = 0; i < 4; i++){
      int nx = x+dx[i], ny = y+dy[i];
      if(0 <= nx && nx < w && 0 <= ny && ny < h){
        if(d[ny][nx] == -1){
          d[ny][nx] = d[y][x]+1;
          q.push(P(nx, ny));
        }
      }
    }
  }
  rep(i, h) rep(j, w) ans = max(ans, d[i][j]);
  cout << ans << endl;
  system("pause");
}

Measured memory_bytes: 12560
def main(n, a):
    count = 9 ** 10

    for a in a:
        c = 0
        while a % 2 == 0:
            a /= 2
            c += 1
        if c < count:
            count = c

    print(count)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)


Measured memory_bytes: 2940
#include <iostream>
#include <unordered_map>
#include <string>

#define ll long long
#define mp make_pair

using namespace std;

int main()
{
    ll ac{}, wa{}, tle{}, re{};

    ll n;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        string s;
        cin >> s;
        
        if(s == "AC")
            ac++;
        if(s == "WA")
            wa++;
        if(s == "TLE")
            tle++;
        if(s == "RE")
            re++;
    }

    cout << "AC x " << ac << "\n";
    cout << "WA x " << wa << "\n";
    cout << "TLE x " << tle << "\n";
    cout << "RE x " << re << "\n";
}


Measured memory_bytes: 3224
#include<stdio.h>
int main(){
int a[100][100],b[100][100],i,j,k,n,m,l;
long long int c[100][100]={0};
scanf("%d%d%d",&n,&m,&l);

for(i=0;i<n;i++){
for(j=0;j<m;j++){
scanf(" %d",&a[i][j]);
}
}


for(j=0;j<m;j++){
for(k=0;k<l;k++){
scanf(" %d",&b[j][k]);
}
}

for(i=0;i<n;i++){
for(k=0;k<l;k++){
for(j=0;j<m;j++){
c[i][k]+=a[i][j]*b[j][k];
}
}
}

for(i=0;i<n;i++){
for(k=0;k<l;k++){
	
	printf("%lld",c[i][k]);
	if(k!=l-1)printf(" ");
}
printf("\n");
}

return 0;
}

Measured memory_bytes: 768
#include <cstdio>

#define max(a, b) ((a) > (b) ? a : b)

int main()
{
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf("%d\n", a + b + c - max(a, max(b, c)));
  return 0;
}


Measured memory_bytes: 128
package main

import (
	"fmt"
)

func max(nums ...int) int {
	max := nums[0]
	for _, v := range nums {
		if max < v {
			max = v
		}
	}
	return max
}

func main() {
	var a, b int
	fmt.Scan(&a, &b)

	fmt.Println(max(a+b, a-b, a*b))
}


Measured memory_bytes: 512
from collections import defaultdict
import sys
import math
from datetime import datetime
import re
import math
def sol(N, S):

    radar = 1
    contigious = []
    for n in S:
        if n == radar:
            contigious.append(n)
            radar += 1
    if len(contigious) > 0:
        return len(S) - len(contigious)
    else:
        return '-1'







do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    # n = int(parsed_lines[0][0])
    # k = int(parsed_lines[0][1])
    S = parsed_lines[0][0]
    return S


if not do_submit:
    S = input_parse("""
    1905
    """)
    print(sol(S))

    S = input_parse("""
    0112
    """)
    print(sol(S))

    S = input_parse("""
    1700
    """)
    print(sol(S))

    S = input_parse("""
    0000
    """)
    print(sol(S))

    S = input_parse("""
    1001
    """)
    print(sol(S))



else:
    n = int(input())
    S = list(map(int, input().split()))
    #S = input()
    print(sol(n, S))

    # S = input().strip()
    # print(sol(S))


Measured memory_bytes: 26216
def solve(s: str) -> str:
    counts = {}
    for c in s:
        if not c in counts:
            counts[c] = 0
        counts[c] += 1

    for n in counts.values():
        if n % 2 == 1:
            return 'No'
    else:
        return 'Yes'

s = input()
print(solve(s))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long  
#define pb push_back
#define mk make_pair
#define mod 998244353
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define all(x) x.begin(),x.end()
vector<ll> v;
ll fun(ll i,ll j,ll val)
{
   if(i==0)
   {
       if(j==0)
       {v.pb(val);v.pb(val+1);}
       else if(j==9)
       {v.pb(val+9);v.pb(val+8);}
       else 
       {
           v.pb(val+j);
           v.pb(val+j+1);
           v.pb(val+j-1);
       }
   }
   else
   {
       if(j==0)
       {
           fun(i-1,0,val);
           val=val+pow(10,i);
           fun(i-1,1,val);
       }
       else if(j==9)
       {
           ll v1=val+9*pow(10,i);
           fun(i-1,9,v1);
           v1=val+8*pow(10,i);
           fun(i-1,8,v1);
       }
       else
       {
            ll v1=val+j*pow(10,i);
           fun(i-1,j,v1);
           v1=val+(j+1)*pow(10,i);
           fun(i-1,j+1,v1);
           v1=val+(j-1)*pow(10,i);
           fun(i-1,j-1,v1);
       }
   }
}
int main()
{
    ios::sync_with_stdio(0) ;
    cin.tie(0); 
   
    for(ll i=1;i<=11;i++)
    {
        if(i<10)
        v.pb(i);
    }
    
    
    
    ll k;
    cin>>k;
    for(int i=1;i<=11;i++)
    {
        for(int j=1;j<=9;j++)
        {
        ll val=pow(10,i);
        val*=j;
       fun(i-1,j,val);}
    }
    sort(v.begin(),v.end());
    
    cout<<v[k-1]<<endl;
    return 0;
}
//make all values ll


Measured memory_bytes: 18920
# coding: utf-8
# Your code here!

def reverse(s, i, j):
    tmp = ''
    for i in range(j, i-1, -1):
        tmp += s[i]
    return s[:i] + tmp + s[j+1:]

def pprint(s, i, j):
    print(s[i:j+1])

def replace(s, i, j, r):
    tmp = s[:i] + r + s[j+1:]
    return tmp

word = input()
# word = 'abcde'
loop = int(input())
# loop = 3
# arr = [
#     'replace 1 3 xyz',
#     'reverse 0 2',
#     'print 1 4',
#     ]

for i in range(loop):
    line = input().split()
    # line = arr[i].split()
    # print(word)
    if line[0] == 'replace':
        word = replace(word, int(line[1]), int(line[2]),line[3])
    elif line[0] == 'reverse':
        word = reverse(word, int(line[1]), int(line[2]))
    elif line[0] == 'print':
        pprint(word, int(line[1]), int(line[2]))
    
    
    



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

#define rep(inc, bgn, end) for(int inc=bgn; inc<(end); ++inc)

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

   int n500 = x / 500; 
   int n5   = (x % 500) / 5;
   cout << n500 * 1000 + n5 * 5 << endl;
} 

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	string s;
	cin >> n >> s;
	int r = 0, cnt = 0;
	rep (i, n) if (s[i] == 'R') r++;
	rep (i, r) {
	  if (s[i] == 'R') cnt++;
	}
	cout << r - cnt << endl;
    
    return 0;
}



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

signed main(){
  string S,T;
  cin>>S>>T;
  int ans=0;
  rep(i,S.size()){
    if(S[i]!=T[i])ans+=1;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int main()
{
    int n;
    cin >> n;
    cout << n * (n + 1) / 2;
    return 0;
}

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

int main(){
    int N;
    cin >> N;
    vector<int>v(N);
    for(int i = 0; i < N; i++){
        cin >> v.at(i);
    }
    sort(v.begin(), v.end());
    int min = v.at(0);
    int max = v.at(N-1);
    cout << max - min << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;

int main() {
  int a, b, c; cin >> a >> b >> c;
  cout << min(c, b/a) << endl;

  return 0;
}







//EOF


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long sum = 0;
		for (long i = 1; i * i < n; i++) {
			if (n % i == 0 && i < n / i - 1) {
				sum += n / i - 1;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 25172
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) {
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  string S; cin>>S;
  int ans = 0;
  if(S == "RRR") ans = 3;
  else if(S == "RRS") ans = 2;
  else if(S == "SRR") ans = 2;
  else if(S == "RSR") ans = 1;
  else if(S == "RSS") ans = 1;
  else if(S == "SRS") ans = 1;
  else if(S == "SSR") ans = 1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3228
//
// Created by Debajyoti Dasgupta on 11-04-2020.
//
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define fr(i, n) for(int i=0;i<n;i++)
#define frr(i, n) for(int i=n;i>=0;i--)
#define fra(i, a, n) for(int i=a;i<n;i++)
#define frra(i, a, n) for(int i=a;i>=n;i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define endl '\n'
 
typedef pair<int, int> pii;
typedef map<int, int> mii;
typedef set<int> si;
typedef unordered_map<int, int> uii;
typedef unordered_set<int> usi;
typedef vector<int> vi;
 
const int mod = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int inf = LONG_LONG_MAX;
 
using point = pair<pii, pii>;
 
void solve() {
    //CODE BEGIN
    int n;
    cin >> n;
    if (n % 10 == 7) {
        cout << "Yes\n";
        return;
    }
    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes\n";
        return;
    }
    n /= 10;
    if (n % 10 == 7) {
        cout << "Yes\n";
        return;
    }
    cout << "No\n";
 
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
//    cin >> t;
    for (int i = 0; i < t; ++i) {
//        cout << "Case #" << i + 1 << ": " << endl;
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#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);
  vector<int> b(n);
  for(int i = 0; i < n; i++)
    b.at(a.at(i)-1) = i+1;
  for(int i : b)
    cout << i << " ";
  cout << endl;
}



Measured memory_bytes: 1664
import java.util.*;
import java.util.LinkedList;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	private int[] visited;
	private int[] distance;
	//adjacency list of edges
	public Graph() { totalVertex = 0; }
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		visited = new int[totalVertex];
		distance = new int[totalVertex];
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	
	public void BFS(int s) {
	    LinkedList<Integer> toVisit = new LinkedList<Integer>();
	    toVisit.add(s);
	    for(int i=0; i<totalVertex; i++) {
	    	distance[i] = -1;
	    }
	    visited[s] = 1;
	    distance[s] = 0;
	    while(toVisit.size() > 0) {
	        //first-in, first-visit; if queue is used, use its dequeue() function
	        int v = toVisit.remove(0); 
	        //setVisited(v);
	        visited[v]=1;
	        List<Integer> neighbors = adjList.get(v);//getNeighbors(v);
	        for(int i = 0; i < neighbors.size(); i ++) {
	            int v1 = neighbors.get(i);
	            if(visited[v1] == 0) {
	                toVisit.add(v1);
	                visited[v1] = 1;
	                distance[v1] = distance[v] + 1;
	            }
	            //System.out.println(s + " " + distance[v1]);
	            }
	        }
	    for(int i=0; i<totalVertex; i++) {
	    	System.out.println(i+1 + " " + distance[i]);
	    }
	}
}
public class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.BFS(0);
	}
}


Measured memory_bytes: 28280
/*
#pragma GCC optimize(2)
#pragma GCC optimize(3,"Ofast","inline")
*/
#include<bits/stdc++.h>
#define ALL(x) (x).begin(),(x).end()
#define ll long long
#define db double
#define ull unsigned long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
const int M = 1e9+7;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}

int a[maxn];
ll suf[maxn];
int main()
{
    fastio();
    int n; cin>>n;
    rep(i,1,n) cin>>a[i];
    ll ans = 0;
    per(i,n,1){
        suf[i] = (suf[i+1] + a[i])%M;
        ans = (ans + a[i] * suf[i+1])%M;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 5996
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
#define F(i,N) for(int i=0;i<N;i++)
int main(){
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, L; cin >> N >> L;
    string S[100]; F(i,N) cin >> S[i];
    sort(S, S+N);
    F(i,N) cout << S[i];
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
	return 0;
}

Measured memory_bytes: 256
//#include<bits/stdc++.h>	// 全てのヘッダーファイルをinclude
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<set>
#include<map>
#include<utility>	// 値入れ替えの関数 wrap
#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++)
const int MOD{ int(1e9 + 7) };	// int 1000000007
const int inf{ int(1e9) };	// inf = 1000000000 // 1e9 はdouble型
using namespace std;
typedef long long ll;

// 最大公約数（ユークリッドの互除法）
int GCD(int x, int y) {
	if (x > y) {
		swap(x, y);
	}
	int r = y % x;
	while (r != 0) {
		y = x;
		x = r;
		r = y % x;
	}
	return x;
}

// 最小公倍数
int LCM(int x, int y) {
	ll gcd = GCD(x, y);
	return x * y / gcd;
}

// 素数判定(素数ならtrue,合成数ならfalse)
bool IsPrime(int num) {
	if (num < 2) return false; // 0,1
	else if (num == 2) return true;	// 2
	else if (num % 2 == 0) return false; // 偶数

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false; // 割り切れたら素数ではない
	}
	return true; // 全部通ったら素数
}

int main(void) {

	char s[4];
	cin >> s[0] >> s[1] >> s[2] >> s[3];

	int temp;
	for (int i = 0; i < 4; i++) {
		for (int j = 4 - 1; j > i; j--) {
			if (s[j] < s[j - 1]) {
				temp = s[j];
				s[j] = s[j - 1];
				s[j - 1] = temp;
			}
		}
	}

	if (s[0] == s[1] && s[2] == s[3] && s[0] != s[2])
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{
   ll x,coin;
   cin>>x;

   coin = (x / 500) * 1000;

   x -= (x/500)*500;

   coin += ((x / 5)*5);

   cout<<coin<<endl;

}

int main()
{
    IOS;
    ll tc = 1;
    while(tc--)
    {
        solve();
    }


return 0;
}



Measured memory_bytes: 3548
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

struct Status {
  int use;
  int pnum[20];
  bool operator<(const Status &rhs) const {
    if (use != rhs.use) { return use < rhs.use; }
    return memcmp(pnum, rhs.pnum, sizeof(pnum)) < 0;
  }
};

int h, w;
int n;
int pnum[20];
int px[20];
int py[20];
char bomb[15][15];
char field[20][20];
map<Status, int> memo;
int dx[9] = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };
int dy[9] = { -1, -1, -1, 0, 0, 0, 1, 1, 1 };

int calc(int depth, Status &status);
int NextState(int depth, Status &status, int cnt) {
  if (cnt == 9) {
    if (status.pnum[depth] != 0) { return 1 << 30; }
    status.use ^= 1 << depth;
    int ret = calc(depth + 1, status);
    status.use ^= 1 << depth;
    return ret;
  }
  int x = px[depth] + dx[cnt];
  int y = py[depth] + dy[cnt];
  if (x < 0 || x >= w || y < 0 || y >= h || field[y][x] == '.' || bomb[y][x] != 0) { return NextState(depth, status, cnt + 1); }

  int ret = 1 << 30;
  bomb[y][x] = 1;
  ret = min(ret, NextState(depth, status, cnt + 1));
  bool ng = false;
  REP(i, n) {
    if (abs(x - px[i]) > 1 || abs(y - py[i]) > 1) { continue; }
    status.pnum[i]--;
    if (status.pnum[i] < 0) { ng = true; }
  }
  if (!ng) {
    ret = min(ret, NextState(depth, status, cnt + 1) + 1);
  }
  REP(i, n) {
    if (abs(x - px[i]) > 1 || abs(y - py[i]) > 1) { continue; }
    status.pnum[i]++;
  }
  bomb[y][x] = 0;
  return ret;
}

int calc(int depth, Status &status) {
  if (depth == n) { return 0; }
  if (memo.count(status)) { return memo[status]; }
  int ret = NextState(depth, status, 0);
  return memo[status] = ret;
}

int main() {
  while (scanf("%d %d", &h, &w), h|w) {
    memo.clear();
    REP(y, h) {
      scanf("%s", field[y]);
    }
    n = 0;
    REP(y, h) {
      REP(x, w) {
        if (isdigit(field[y][x])) {
          pnum[n] = field[y][x] - '0';
          px[n] = x;
          py[n] = y;
          n++;
        }
      }
    }
    Status status;
    status.use = 0;
    memcpy(status.pnum, pnum, sizeof(pnum));
    //MEMSET(status.bomb, 0);
    int ans = calc(0, status);
    printf("%d\n", ans);
  }
}

Measured memory_bytes: 1144
import sys
for line in sys.stdin.readlines():
  l = [int(i) for i in line.replace('\n','')]
  while len(l) >1:
    m = []
    for i in range(len(l)-1):
      m.append((l[i]+l[i+1])%10)
    l = list(m)
  print(l[0])

Measured memory_bytes: 7636
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define ll long long
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define fr first
#define sc second
#define sz(x) (ll)((x).size())
#define endl "\n"
#define vc vector
#define pb push_back
#define pii pair<ll,ll>
#define psi pair<string,ll>
#define msi map<string,ll>
#define mii map<ll,ll>
#define mp  make_pair
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PI 3.14159265
#define mem(x,val) memset(x,val,sizeof(x))
#define r0 return 
const long long INF=1e13;
template<typename T1,typename T2>istream& operator>>(istream& in,pair<T1,T2> &a){in>>a.fr>>a.sc;return in;}
template<typename T1,typename T2>ostream& operator<<(ostream& out,pair<T1,T2> a){out<<a.fr<<" "<<a.sc;return out;}
template<typename T,typename T1>T amax(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T amin(T &a,T1 b){if(b<a)a=b;return a;}
#define dbgv(container) {cerr << #container << " : \n"; int cnt = 0; for (auto& x: container) cerr << #container << "[" << cnt++ << "] = " << x << '\n';} 
#define dbgvv(container) {cerr << #container << " : \n"; int c1=0,c2=0; for (auto& x : container){c2 = 0; for (auto& y : x) {cerr << #container << "[" << c1 << "][" << c2++ << "] = " << y << '\n';}c1++;}}
#define dbg(...)__f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

//code begins here
ll w,h,dp[1005][1005];
char a[1005][1005];
ll calc(ll i,ll j)
{
	if(i==h-1&&j==w-1) return 1;
	if(dp[i][j]!=-1) return dp[i][j];
	ll ans=0;
	if(i<h-1&&a[i+1][j]=='.') (ans+=calc(i+1,j))%=M;
	if(j<w-1&&a[i][j+1]=='.') (ans+=calc(i,j+1))%=M;
	return dp[i][j]=ans;
}
void solve()
{
 	cin>>h>>w;
 	mem(dp,-1);
 	rep(i,0,h) rep(j,0,w) cin>>a[i][j];
 	cout<<calc(0,0);
}
signed main()
{
	fast
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 9216
S = input()
s = S[0]
score = int(S[0])
def rec(n, s, score):
    if n == 1:
        if score == 7:
            print(s + "=7")
            exit()
            
    else:
        rec(n-1, s+"+"+S[-n+1], score+int(S[-n+1]))
        rec(n-1, s+"-"+S[-n+1], score-int(S[-n+1]))
    
print(rec(len(S), s, score))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
#define _USE_MATH_DEFINES
#include <math.h>
 
using namespace std;
 
using LL = long long;
using VLL = std::vector<LL>;
using VVLL = std::vector<VLL>;
using VVVLL = std::vector<VVLL>;
using LD = long double;
using VLD = std::vector<LD>;
using VVLD = std::vector<VLD>;
using VVVLD = std::vector<VVLD>;
 
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }

//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
//template<class T=LL> inline vector<T> cinv(LL N){ vector<T> v(N); REP(i, N)cin>>v[i]; return move(v);}
#define REP(i,n) for(LL (i)=0;(i)<(n);(i)++)
#define ALL(v) v.begin(), v.end()
#define PRINTLN(v) {LL i=0; for(auto (a): v ){   cerr <<i << " : "<<  a << endl; i++;}}
#define PRINTSP(v) for(auto (a): v ) {cerr << a << " ";} cerr << endl
#define cmax(a,b) {if(a<b){a=b;}}
#define cmin(a,b) {if(a>b){a=b;}}
#define EACH(a,A) for(auto a: A)
//#define cmax(a,b) a = (a>b ? a:b)
//#define cmin(a,b) a = (a<b ? a:b) 
//cin,cout高速化のおまじない＋桁数指定
inline VLL cinvll(LL N){
  VLL A(N);
  REP(i,N){
    cin >> A[i];
  }
  return move(A);
}
struct Fast{
	Fast(){
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(std::numeric_limits<double>::max_digits10);
	}
} fast;



void func(){
  string S;
  cin >> S;
  VLL C(3);
  for(LL i=0;i<S.length();++i){
    if(S[i]=='a'){
      C[0]++;
    }
    else if(S[i]=='b'){
      C[1]++;
    }
    else if(S[i]=='c'){
      C[2]++;
    }
  }
  LL num_min = *min_element(ALL(C));
  LL num_max = *max_element(ALL(C));

  //PRINTSP(C);
  if((num_max-num_min)<=1 ){
    cout <<"YES";
  }
  else{
    cout <<"NO";
  }
} 

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long b[200000];
	long long n;
	cin >> n;
	for(int i = 1;i <= n;i++)
		{
			cin >> b[i];
		}
	for(int i = n;i>0;i-=2)
		{
			cout << b[i] << " ";
		}
	long long r = n % 2;
	for(int i = (r!= 0) + 1;i <= n;i += 2)
		{
			cout << b[i] << " ";
		}
	cout << endl;
	return 0;
} 

Measured memory_bytes: 3712
#pragma comment(linker, "/STACK:102400000,102400000")
#include <iostream>
#include <string>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <ctime>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>
#include <cmath>
#include <assert.h>
#include <iomanip>
#include <bitset>
using namespace std;
#define vi vector<int>
#define pii pair<int,int>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define SZ(x) (int)x.size()
#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 pi acos(-1)
#define mod 1000000007
#define inf 1000000007
#define ll long long
#define ull unsigned long long
#define DBG(x) cerr<<(#x)<<"="<<x<<"\n";
#define N 100010
#define _DEBUG
template <class U,class T> void Max(U &x, T y){if(x<y)x=y;}
template <class U,class T> void Min(U &x, T y){if(x>y)x=y;}
template <class T> void add(int &a,T b){a=(a+b)%mod;}
inline int gcd(int a,int b){return b==0?a:gcd(b,a%b);}
inline ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}

int pow(int a,int b){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%mod;
        a=1LL*a*a%mod;b>>=1;
    }
    return ans;
}
int pow(int a,int b,int c){
    int ans=1;
    while(b){
        if(b&1)ans=1LL*ans*a%c;
        a=1LL*a*a%c;b>>=1;
    }
    return ans;
}


int a[101];
int main(){
    //srand(time(NULL)+clock());
    int T,ca=0,k,i,j,m=0,n,K;
    //double start=clock();
    scanf("%d",&n);
    rep(i,1,n+1)scanf("%d",&a[i]);
    vi ans;
    per(i,1,n+1){
        int mx=0,cnt;
        rep(j,1,i+1){
            if(a[j]>mx)mx=a[j],cnt=1;
            else if(a[j]==mx)cnt++;
        }
        if(mx==i){
            if(cnt>1||a[i]!=i){puts("-1");return 0;}
            ans.pb(i);
        }
        else{
            K=-1;
            per(j,1,i+1)if(j==a[j]){
                K=j;break;
            }
            if(K==-1){puts("-1");return 0;}
            ans.pb(K);
            rep(j,K,i)a[j]=a[j+1];
        }
    }
    per(i,1,n+1)printf("%d\n",ans[i-1]);
    //cerr<<(1.*clock()-start)/CLOCKS_PER_SEC<<"\n";
}



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

char map[9][9];

void bomb( int x, int y ){
	map[x][y] = '0';
	for( int dy=1; dy<=3; dy++ ){
		if( y-dy >= 1 ){
			if( map[x][y-dy] == '1' ){
				bomb( x, y-dy );
			}
		}
		if( y+dy <= 8 ){
			if( map[x][y+dy] == '1' ){
				bomb( x, y+dy );
			}
		}
	}
	for( int dx=1; dx<=3; dx++ ){
		if( x-dx >= 1 ){
			if( map[x-dx][y] == '1' ){
				bomb( x-dx, y );
			}
		}
		if( x+dx <= 8 ){
			if( map[x+dx][y] == '1' ){
				bomb( x+dx, y );
			}
		}
	}
	return;
}

int main(){
	int n;
	string line;
	getline( cin, line );
	sscanf( line.c_str(), "%d", &n );
	
	for( int i=1; i<=n; i++ ){
		getline( cin, line );
		for( int y=1; y<=8; y++ ){
			getline( cin, line );
			for( int x=1; x<=8; x++ )
				map[x][y] = line[x-1];
		}
		int bx, by;
		getline( cin, line );
		sscanf( line.c_str(), "%d", &bx );
		getline( cin, line );
		sscanf( line.c_str(), "%d", &by );
		bomb( bx, by );
		cout << "Data " << i << ":" << endl;
		for( int y=1; y<=8; y++ ){
			for( int x=1; x<=8; x++ ){
				cout << map[x][y];
			}
			cout << endl;
		}
	}
	return 0;
}

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

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

typedef long long ll;

int main() {
  
  int N;
  while(cin >> N && N) {
    vector<int> in(N);
    rep(i, N) cin >> in[i];
    vector<int> v(N);
    int mx = -1<<29;
    rep(i, N) {
      if(i-1 >= 0 && v[i-1] >= 0) {
	v[i] = v[i-1] + in[i];
      }
      else {
	v[i] = in[i];
      }
      if(mx < v[i]) { mx = v[i]; }
    }
    cout << mx << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1216