akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
int n, m;
long long dp[305][305][305];
int l, r2, x;
bool f[305][305][305];
long long DP(int r, int g, int b);
int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> l >> r2 >> x;
		if (x == 1) {
			for (int k = l; k < r2; k++) for (int j = 0; j <r2 ;j++) {
				f[r2][k][j] = true;
				dp[r2][k][j] = 0;
				f[k][r2][j] = true;
				dp[k][r2][j] = 0;
				f[k][j][r2] = true;
				dp[k][j][r2] = 0;
				f[r2][j][k] = true;
				dp[r2][j][k] = 0;
				f[j][r2][k] = true;
				dp[j][r2][k] = 0;
				f[j][k][r2] = true;
				dp[j][k][r2] = 0;
			}
		}
		else if (x == 2) {
			for (int k = l; k < r2; k++) for (int j = l; j < r2; j++) {
				f[r2][k][j] = true;
				dp[r2][k][j] = 0;
				f[k][r2][j] = true;
				dp[k][r2][j] = 0;
				f[k][j][r2] = true;
				dp[k][j][r2] = 0;
			}
			for(int k=0;k<l;k++)for(int j=0;j<l;j++){
				f[r2][j][k] = true;
				dp[r2][j][k] = 0;
				f[j][r2][k] = true;
				dp[j][r2][k] = 0;
				f[j][k][r2] = true;
				dp[j][k][r2] = 0;
			}
		}
		else if (x == 3) {
			for (int k = 0; k < l; k++) for (int j = 0; j < r2; j++) {
				f[r2][k][j] = true;
				dp[r2][k][j] = 0;
				f[k][r2][j] = true;
				dp[k][r2][j] = 0;
				f[k][j][r2] = true;
				dp[k][j][r2] = 0;
				f[r2][j][k] = true;
				dp[r2][j][k] = 0;
				f[j][r2][k] = true;
				dp[j][r2][k] = 0;
				f[j][k][r2] = true;
				dp[j][k][r2] = 0;
			}
		}
	}
	cout << DP(0, 0, 0) << endl;
	return 0;
}
long long DP(int r,int g,int b) {
 
if (!f[r][g][b]) {
	f[r][g][b] = true;
	int k = max({ r,g,b });
		if (k == n ) { dp[r][g][b] = 1; return 1; }
		dp[r][g][b] = (DP(k + 1, g, b) + DP(r, k + 1, b) + DP(r, g, k + 1))%1000000007;
		
	}
	return dp[r][g][b];
}


Measured memory_bytes: 248064
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

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

    int N;
    cin >> N;
    vector<vector<int>> dp(210, vector<int>(210, -1));
    auto MemoRec = [&](auto&& self, int w, int b) -> int {
        if(dp[w][b] != -1)  return dp[w][b];
        set<int> Grundy;
        if(w > 0)   Grundy.emplace(self(self, w - 1, b));
        if(b > 0)   Grundy.emplace(self(self, w + 1, b - 1));
        for(int i = 1; i <= w; ++i){
            if(b - i < 0)   break;
            Grundy.emplace(self(self, w, b - i));
        }
        int res = 0;
        while(Grundy.count(res))    ++res;
        return dp[w][b] = res;
    };
    int Nim = 0;
    for(int i = 0; i < N; ++i){
        int w, b;
        cin >> w >> b;
        Nim ^= MemoRec(MemoRec, w, b);
    }
    cout << (Nim == 0) << endl;
}


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

int32_t main()
{
    int n,a,b;
    cin>>n>>a>>b;
    
    // n = n - a;
    int p = n/(a+b);
    
    int rem = n - p*(a+b);
    
    int res = p*a ;
    
    if(rem > a)
        res+=a;
    else
        res+=rem;
        
        cout<<res<<endl;
    
        
}

Measured memory_bytes: 256
n,m=[int(i) for i in input().split()]
hoge=[tuple([int(i) for i in input().split()]) for j in range(n)]
hoge.sort()
ans=0
for i in range(len(hoge)):
    if hoge[i][1]>m:
        ans+=hoge[i][0]*m
        break
    else:
        ans+=hoge[i][0]*hoge[i][1]
        m-=hoge[i][1]
print(ans)

Measured memory_bytes: 16984
# -*- coding: utf-8 -*-
def inpl(): return list(map(int, input().split()))

def make(N):
    if N%2:
        L = [N + (N//2)**2 - n**2 + 2*n - 1 for n in range(1, N//2+2)]
        L = L[1::][::-1] + L
        return L
    else:
        L = [N + N*(N-2)//4 -n**2 + n for n in range(1, N//2+1)]
        L = L[::-1] + L
        return L

N, M = inpl()

X = inpl()
Y = inpl()

A = make(N-1)
B = make(M-1)

Sx = 0
Sy = 0

for i, a in enumerate(A):
    Sx += a * (X[i+1] - X[i])

for j, b in enumerate(B):
    Sy += b * (Y[j+1] - Y[j])

print((Sx*Sy)%(10**9 + 7))

Measured memory_bytes: 18624
package main

import (
	"fmt"
	"sort"
)

type Store struct {
	A int
	B int
}

type Stores []Store

func (s Stores) Len() int {
	return len(s)
}

func (s Stores) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s Stores) Less(i, j int) bool {
	return s[i].A < s[j].A
}

func main() {
	var n int
	var m int
	fmt.Scan(&n)
	fmt.Scan(&m)

	stores := make(Stores, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&stores[i].A)
		fmt.Scan(&stores[i].B)
	}

	sort.Sort(stores)

	sum := 0
	cansmax := m

	for i := 0; i < n; i++ {
		if cansmax >= stores[i].B {
			sum += stores[i].A * stores[i].B
			cansmax -= stores[i].B
		} else {
			sum += stores[i].A * cansmax
			cansmax = 0
		}
		if cansmax == 0 {
			break
		}
	}

	fmt.Println(sum)
}


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

using namespace std;

double dp[3009][3009];
double a[3009];

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

  dp[0][0]=1;

  for(int i=1;i<=n;i++){
    for(int j=0;j<=i;j++){
        if(j) dp[i][j]+=dp[i-1][j-1]*a[i-1];
        dp[i][j]+=dp[i-1][j]*(1-a[i-1]);
    }
  }
  double ans=0;
  for(int i=0;i<=n;i++){
    if(i>n-i) ans+=dp[n][i];
  }
  printf("%.12f\n",ans );
  return 0;
}


Measured memory_bytes: 69120
n = int(input())
As = list(map(int, input().split()))
    
def f(m):
    debug = m
    for a in As:
        i = m // a
        m = i * a
    return m

# 二部探索?
l = 1
r = 10**20
while r-l > 1:
    m = (r+l)//2
    if f(m) <= 1: l = m
    else: r = m
ans1 = r
l = 1
r = 10**20
while r-l > 1:
    m = (r+l)//2
    if f(m) <= 2: l= m
    else: r = m
ans2 = l

if ans1 > ans2:
    print(-1)
else:
    print(ans1,ans2)

Measured memory_bytes: 20492
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> a[i][j];
    }
  }
  vector<bool> row(h, false);
  vector<bool> col(w, false);
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (a[i][j] == '#') {
        row[i] = col[j] = true;
      }
    }
  }
  for (int i = 0; i < h; ++i) {
    if (row[i]) {
      for (int j = 0; j < w; ++j) {
        if (col[j]) {
          cout << a[i][j];
        }
      }
      cout << "\n";
    }
  }
  return 0;
}

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

#define IOS  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int  long long

string s, t;
int cache[3005][3005];

int dp(int i, int j)
{
    if(i < 0 || j < 0) return 0;
    int &ans = cache[i][j];
    if(ans != -1) return ans;
    if(s[i] == t[j]) ans = 1 + dp(i - 1, j - 1);
    else ans = max(dp(i - 1, j), dp(i, j - 1));
    return ans;
}

int32_t main()
{   
    IOS
    cin >> s >> t;
    memset(cache, -1, sizeof(cache));
    int f = dp(s.size() - 1, t.size() - 1);
    // cout << f << endl;
    string ans;
    int i = s.size() - 1, j = t.size() - 1;
    while(i >= 0 && j >= 0)
    {
        if(s[i] == t[j]) ans += s[i], i--, j--;
        else 
        {
            if(i - 1 >= 0 && j - 1 >= 0) 
            {
                if(cache[i - 1][j] > cache[i][j - 1]) i--;
                else j--;
            }
            else if(i - 1 >= 0) i--; 
            else if(j - 1 >= 0) j--;
            else break;
        } 
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 74460
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　RedcoderになるためAtCoderを巡る旅をしてます。

　　　 　＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　   ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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;
}

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

    double H, A; cin >> H >> A;
    COUT(ceil(H / A));
}


Measured memory_bytes: 256
function Main(input) {
    const S = input;
    var countA = 0;
    var countB = 0;
    var prevA = 0;
    var P = ["0", "1"];
    Array.prototype.forEach.call(S, function(s) {
        if(P[prevA] == s) {
            countA++;
        } else {
            countB++;
        }
        prevA = (prevA + 1) % 2;
    });

    console.log(Math.min(countA, countB));
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 7500
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> x(N);
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  ll ans = INF;
  for (int i = K - 1; i < N; i++) {
    ll cand1 = abs(x[i - K + 1]) + abs(x[i] - x[i - K + 1]);
    ll cand2 = abs(x[i]) + abs(x[i] - x[i - K + 1]);
    ans = min({ans, cand1, cand2});
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4024
#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

typedef long long ll;

int n;
ll a[100000];

ll solve(ll t){
	ll res = 0, sum = 0;
	for(int i = 0; i < n; i++, t = -t){
		sum += a[i];
		if(sum * t > 0) continue;
		res += abs(sum - t);
		sum += t * abs(sum - t);
	}
	return res;
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	ll res = solve(1);
	res = min(res, solve(-1));
	printf("%lld\n", res);
	return 0;
}

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


int main(void){
    int n;
    long long k;
    cin >> n >> k;
    map<int,long long> m;
    
    for (int i = 0; i < n; i++) {
        int a,b;
        cin >> a >> b;
        m[a] += b;
    }
    
    long long sum = 0;
    for(auto p : m) {
        sum += p.second;
        if(sum >= k) {
            cout << p.first << endl;
            break;
        }
    }
}


Measured memory_bytes: 4224
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    if ((N + 1) / 2 >= K) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
n=int(input())
s=input()
a=[0]
for i in range(n):
	a.append(a[i]+(s[i]=='W'))
p=n
for i in range(n):
	j=a[i]
	k=n-i-(a[-1]-a[i+1])-1
	#print(i,j,k)
	p=min(p,j+k)
print(p)

Measured memory_bytes: 15520
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <bitset>
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)

using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

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

    ll i,j,h;

    ll A,B,C,X,Y;
    vector<vector <char> > a(1, vector<char>(2));
    ll ans = 0;
  
    cin >> A>>B>>C>>X>>Y;

    ll min_=min(X,Y);

    vector<ll> n(2), m(2);
    n[0]=A;
    n[1]=B;
    ll x;

    if(X>Y)x=A;
    else x=B;

    if(A+B>2*C){
        ans += 2*C*min_;
        if(x>2*C)ans += 2*C*(max(X,Y)-min_);
        else ans += x*(max(X,Y)-min_);
    }else{
        ans += A*X+B*Y;
    }


  
    cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 3220
#include <stdio.h>

int main(){
int W;
int H;
int x;
int y;
int r;
scanf("%d %d %d %d %d\n",&W,&H,&x,&y,&r);
if(0<=x-r && x+r<=W && 0<=y-r && y+r<=H){
printf("Yes\n");
}
else{
printf("No\n");
}
}



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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    map<int,int> m;

    int n;
    cin>>n;

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

    for(int i=1;i<n;i++) {
        int num;
        cin>>num;
        m[num]++;
    }

    map<int,int>::iterator it;
    for(it=m.begin();it!=m.end();it++) {
        cout<<it->second<<endl;
    }


}




Measured memory_bytes: 13044
"use strict";
new Promise(resolve => {
  resolve(require("fs").readFileSync("/dev/stdin", "utf8").split(/\s/));
}).then(input => {
  const [a, b, c, d] = input.map(x => Number(x));
  const A2B = Math.abs(b - a);
  const B2C = Math.abs(c - b);
  const A2C = Math.abs(c - a);
  const ans = ((A2B <= d && B2C <= d) || A2C <= d) ? "Yes" : "No";
  console.log(ans);
});


Measured memory_bytes: 7372
S=lambda:input()
I=lambda:int(input())
L=lambda:list(map(int,input().split()))
LS=lambda:list(map(str,input().split()))

n=I()
a=L()
ans=0
for i in range(n):
    if i+1&1 and a[i]&1:
        ans+=1
print(ans)

Measured memory_bytes: 9188
n, k = list(map(int, input().split()))
m = 998244353

s = []
for i in range(k):
    l, r = list(map(int, input().split()))
    s.append((l, r))

dp = [0] * n
dp[0] = 1
totals = [0] * n
totals[0] = 1

for i in range(1, n):
    thisTotal = 0
    for l, r in s:
        indL = i-l
        if indL >= 0:
            indR = max(0, i-r)

            thisTotal += totals[indL] - totals[indR-1]

    dp[i] = (thisTotal%m)
    totals[i] = (totals[i-1] + thisTotal)%m

print(dp[n-1])

Measured memory_bytes: 24800
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define INF (1<<30)-1
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

inline int isPrime(ll n){
  for(ll i = 2; i*i <= n; i++) if(n % i == 0) return 0;
  return 1;
}

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  ll a,b; cin >> a >> b;

  ll gcd = __gcd(a,b);
  int ans = 0;
  for(ll i = 1; i*i <= gcd; i++){
    if(gcd % i == 0){
      ans += isPrime(i);
      if(i != gcd/i) ans += isPrime(gcd/i);
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 3648
//coded b vishal mourya - the legendary coder
#include<bits/stdc++.h>
#define ll long long int
#define vec vector<ll>
#define f(a,b) for(ll i = a ; i < b ; i++ )
#define fj(a,b) for(ll j = a ; j < b ; j++ )
#define fk(a,b) for(ll k = a ; k < b ; k++ )
#define fasthoja ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;

int main(void){
    fasthoja;
    
    ll n,m; cin >> n >> m;
    ll cac = 0, cwa = 0, cwat = 0;
    ll ans = 0;
    vec hero(n+1,0);
    vec cnt(n+1,0);
    hero[0] = 1;
    
    for( int i = 1 ; i <= m ; i++) {
        ll p1; cin >> p1;
        string st; cin >> st;
        
        // if( cac == n ) break;
        
        if( st == "WA" && hero[p1] == 0 ){
            //  cwat++;
            cnt[p1]++;
        }
        
        if( st == "AC" &&  hero[p1] != 1 ) {
            cac++;
            // if( cwa != 0 ) {
                
                hero[p1] = 1; //solved
                cwa += cnt[p1];
                // cwat = 0;
                
            // }
        }
        
        
    
    }
    
    cout << cac << " " << cwa << "\n";
    
 return 0;
}


Measured memory_bytes: 4752
L=[0]*120
n = int(input())
i = 0
while i < n:
    b, f, r, v = map(int, input().split(' '))
    p = (r - 1) + (f - 1) * 10 + (b - 1) * 30
    L[p] += v
    i += 1
ans = ''
ans += ' ' + ' '.join(map(str, L[0:10].copy())) + '\n'
q = 1
while q < 12:
    if q % 3 == 0:
        ans += '#' * 20 + '\n'
    ans += ' ' + ' '.join(map(str, L[q*10:(q+1)*10].copy())) + '\n'
    q += 1
print(ans[:-1])


Measured memory_bytes: 5608
/*
 * Author : Sadi
 * Mon 29/06/2020
 * 21:06:45.95
 */
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int k;
    cin >> k;
    if(k & 1) {
        cout << k / 2 * (k / 2 + 1) << endl;
    }
    else {
        cout << k / 2 * k / 2 << endl;
    }

    return 0;
}


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

#define ll              long long int
#define ull             unsigned long long int
#define pii             pair < int, int>
#define pll             pair < ll, ll>
#define sc              scanf
#define scin(x)         sc("%d",&(x))
#define scln(x)         sc("%lld",&(x))
#define pf              printf
#define NL              pf("\n")
#define ms(a,b)         memset(a,b,sizeof(a))
#define pb(a)           push_back(a)
#define mp              make_pair
#define db              double
#define EPS             10E-10
#define ff              first
#define ss              second
#define sqr(x)          (x)*(x)
#define vi              vector< int >
#define vl              vector< ll >
#define vii             vector<vector< int > >
#define vll             vector<vector< ll > >
#define DBG             pf("HI\n")
#define MOD             1000000007
#define CIN             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define RUN_CASE(t,T)   for(__typeof(t) t=1;t<=T;t++)
#define CASE(t)         printf("Case %d: ",t)
#define CASEL(t)        printf("Case %d:\n",t)
#define intlimit        2147483648
#define longlimit       9223372036854775808
#define infinity        (1<<28)
#define gcd(a, b)       __gcd(a,b)
#define lcm(a, b)       ((a)*(b)/gcd(a,b))
#define mx              1234567899
#define PI              2*acos(0.0)
#define rep(i,a,b)      for(ll i=a; i<=b; i++)
#define rev(i,a,b)      for(ll i=a; i>=b; i--)
#define file            freopen("E:\\file.txt", "r", stdin);ios_base::sync_with_stdio(false); cin.tie(NULL);
#define all(x)            x.begin(),x.end()
using namespace std;

///--------------Graph Moves--------------------------------------
///const int fx[] = {+1,-1,+0,+0};
///const int fy[] = {+0,+0,+1,-1};
///const int fx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's move
///const int fy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int fx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's move
///const int fy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's move
///---------------------------------------------------------------

long long BigMod(long long int a, long long int b, int M) { /// a function to determine a^b(mod M)
    long long remainder, answer = 1;                            /// set two variables for remainder and answer
    remainder = a%M;                                         /// setting remainder as
    while(b!=0)                                                     ///  loop occurs until b is not equal to 0
    {
        if(b%2==1) answer = (answer*remainder)%M;                  /// checking if b is odd
                /// taking the present remainder in the answer if b is odd
        remainder = (remainder*remainder)%M;    /// making remainder double on each turn of the loop
        b/=2;                                  /// reducing b by dividing it by 2 in every turn,
    }
    return answer;
}
bool cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n;
    cin >> n;
    int a[n+3];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
    }
    int ans = a[0];
    for(int i=1;i<n;i++)
    {
        ans = gcd(a[i],ans);
    }
    cout <<ans;
    return 0;
}



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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

bool memo[1001];

void solve(long long X){
    memo[1] = true;
    REP2(i, 2, 1000) {
        int tmp = i * i;
        while(tmp <= 1000) {
            memo[tmp] = true;
            tmp *= i;
        }
    }

    RREP(i, X) {
        if(memo[i]) {
            cout << i << endl;
            return;
        }
    }
}

int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


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

#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{
    gearup;
    ll n; cin >> n;
    vl a(n);
    rep(i,n)cin>>a[i];
    ll now = 1000;
    
    //先読みする
    for(int i=0;i<n-1;i++){
        if(a[i] < a[i+1]){
            ll rot = now/a[i];
            now += rot*(a[i+1] - a[i]);
        }
    }
    out(now);
}

Measured memory_bytes: 3560
#include <cmath>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;


int main()
{
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	bool ans = (a*100 + b*10 + c)%4;
	if(ans) printf("NO\n");
	else printf("YES\n");	
	return 0;
}

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

const ll big=1e18;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll ans=1;
    rep(i,n){
        cin>>a[i];
        if(a[i]==0){
            cout<<0<<endl;
            return 0;
        }
    }
    rep(i,n){
        if(ans>big/a[i]+1){
            cout<<-1<<endl;
            return 0;
        }
        ans*=a[i];
        if(ans>big){
            cout<<-1<<endl;
            return 0;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3972
N = int(input())
S = list(input())

acc = [0]
acc2 = [0]
for s in S:
    if s == ".":
        acc.append(acc[-1] + 1)
        acc2.append(acc2[-1])
    else:
        acc.append(acc[-1])
        acc2.append(acc2[-1] + 1)
acc.pop(0)

ans = float("inf")

for i in range(N):
    s = S[i]
    tmp = acc[-1] - acc[i]
    tmp2 = acc2[i]
    ans = min(ans , tmp + tmp2)
print(ans)


Measured memory_bytes: 14184
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, n) for(int i = 1; i < n; i++)
#define P pair<int, int>
typedef long long ll;
const ll mod = 1e9+7;

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

//繰り返し自乗法による累乗計算
//a**n
ll pow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = pow(a, n/2);
    return res * res;
  }
  return a * pow(a, n-1);
}
//繰り返し自乗法によるmod累乗計算
//a**n (mod)
ll modpow(ll a, ll n){
  if(n == 0) return 1;
  if(n%2 == 0){
    ll res = modpow(a, n/2);
    return res * res % mod;
  }
  return a * modpow(a, n-1) % mod;
}
//組み合わせ
//nCa
ll com(ll n, ll a){
  ll x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  ll res = x / y;
  return res;
}
//組み合わせ(mod)
//nCa (mod)
ll modcom(ll n, ll a){
  ll x = 1, y = 1;
  rep(i, a){
    x = x * (n-i) % mod;
    y = y * (i+1) % mod;
  }
  ll ans = x * modpow(y, mod-2) % mod;
  return ans;
}
//gcd 最大公約数
ll gcd(int x, int y){
  if(x % y == 1) return y;
  return gcd(y, x%y);
}
//lcm 最小公倍数
ll lcm(int x, int y){
  return x * y / gcd(x, y);
}
// n個の最大公約数
ll ngcd(vector<int> a){
  int res;
  res = a[0];
  for(int i=1; i<a.size() && res!=1; i++){
    res = gcd(res, a[i]);
  }
  return res;
}
// n個の最小公倍数
ll nlcm(vector<int> a){
  int res;
  res = a[0];
  REP(i, a.size()){
    res = lcm(res, a[i]);
  }
  return res;
}
// 素数判定
bool isprime(int x){
  int i;
  if(x < 2) return false;
  else if(x == 2) return true;
  if(x % 2 == 0) return false;
  for(i = 3; i*i <= x; i += 2){
    if(x % i == 0) return false;
  }
  return true;
}
// 桁和
int digsum(int x){
  int res = 0;
  while(x > 0){
    res += x % 10;
    x /= 10;
  }
  return res;
}


int main(){
  int n, m, X, Y;
  cin >> n >> m >> X >> Y;
  vector<int> x(n), y(m);
  rep(i,n) cin >> x[i];
  rep(i,m) cin >> y[i];
  sort(x.rbegin(), x.rend());
  sort(y.begin(), y.end());
  for(int i = X+1; i < Y; i++){
    if(i > x[0] && i <= y[0]){
      cout << "No War" << endl;
      return 0;
    }
  }
  cout << "War" << endl;
}






Measured memory_bytes: 256
s = input()
t = input()
l_s = len(s)
l_t = len(t)

s2 = s + s
l_s2 = len(s2)

next_idx = [[l_s2] * 26 for i in range(l_s2)]

for i in reversed(range(1, l_s2)):
    for j in range(26):
        next_idx[i-1][j] = next_idx[i][j]
    next_idx[i-1][ord(s2[i]) - ord("a")] = i

cur_idx = 0
for i in range(l_t):
    if i == 0:
        flg = False
        for j in range(l_s):
            if t[i] == s[j]:
                cur_idx += j
                flg = True
                break
        if flg:
            continue
        else:
            print("-1")
            exit()

    else:
        idx = next_idx[cur_idx%l_s][ord(t[i]) - ord("a")]

    if idx == l_s2:
        print("-1")
        exit()

    cur_idx += idx - (cur_idx % l_s)
    
print(cur_idx+1)

Measured memory_bytes: 133376
#include <bits/stdc++.h>
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N, R;
  cin >> N >> R;
  if (N>10){
    cout << R << endl;
  }else{
    cout << R+(10-N)*100 << endl;
  }
  
}

Measured memory_bytes: 256
/**
 *    Author:  "Robin Singh" !!!
 *    BrainyIsTheNewSexy     (CodeForces)
 *    rob_in_1               (Other OJs)
**/
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define mp make_pair
#define szz(v) ((int)(v).size())  
#define fr(i, j, k) for(int i = j; i < k; i++)     
#define bk(i, j, k) for(int i = j-1; i >= k; i--)
#define frit(it, a) for(__typeof((a).begin()) it = a.begin(); it != a.end(); ++it)
#define mem(ptr)  memset(ptr, 0, sizeof ptr)
#define str string 
#define rtn return 
#define nl "\n"
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector <int> vi;
typedef vector <long long> vll;
typedef vector < pair<int,int> > vpii;
typedef vector < pair<ll, ll> > vpll;
const long long mod = 1e9+7;
const long double eps = 1e-9;
const long long INF = (1LL<<61);
const int inf = (1<<30);
const int nn = 1e6;
//---------------------------------------------*DEBUGGING*--------------------------------------------------------->]
#define dbg( args...) { vector<string> _v = split( #args, ','); err( _v.begin(), args); cerr << '\n'; }
vector<string> split( const string& s, char c) { vector<string> v; stringstream ss( s); string x; 
while ( getline( ss, x, c)) v.emplace_back(x); return move(v); }
void err( vector<string>::iterator it) { } 
template<typename T, typename... Args>
void err( vector<string>::iterator it, T a, Args... args) {
    cerr << it -> substr( ( *it)[0] == ' ', it -> length()) << " = " << a << '\t'; err( ++it, args...); }
//----------------------------------------------------------------------------------------------------------------->]
//*****************************************!Template Ends Here!*****************************************************]

ll fac[nn];
void init(){
    fac[0] = 1;
    for(int i=1; i<nn; i++)
        fac[i] = fac[i-1] * i % mod;
}

ll expo(ll n, ll r){
    n %= mod;
    ll res = 1;
    while(r){
        if(r & 1) res = (res * n) % mod;
        n = (n * n) % mod;
        r >>= 1;
    }
    return res;
}

ll ncr(ll n, ll r){
    if(n < r || r < 0) return 0;
    if(n==r || r==0) return 1;
    return (fac[n] * expo(fac[r], mod-2) % mod * expo(fac[n-r], mod-2) % mod);
}

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    init();
    ll n, m;
    cin >> n >> m;
    ll ans = 1;
    for(ll i=2; i*i <= m; i++){
        int c = 0;
        while(m % i == 0){
            c++;
            m /= i;
        }
        if(c) ans = ans * ncr(c+n-1, n-1) % mod;     // distribute all power among n length
    }
   
    if(m > 1) ans = (ans * n) % mod;                  // if prime
    cout << ans;
    return 0;
}

//->INTUITIONS are not to be ignored. They represent data processed too fast for the conscious mind to comprehend !!

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

using namespace std;

typedef long long ll;

int MOD;

ll pow_mod(ll x,int k) {
  ll ans=1;
  while (k) {
  	if (k&1) ans=ans*x%MOD;
  	x=x*x%MOD;
  	k>>=1;
  }
  return ans;
}

inline void update(int &x,ll y) {
  x=(x+y)%MOD;
}

ll powd[105][10005],facd[105],facv[105];

void pre(int n,int m,int k) {
  for(int i=0;i<=k;i++) {
  	powd[i][0]=1;
  	for(int j=1;j<=n*m;j++) powd[i][j]=powd[i][j-1]*i%MOD;
  }
  facd[0]=1;
  for(int i=1;i<=max(n,m);i++) facd[i]=facd[i-1]*i%MOD;
  facv[max(n,m)]=pow_mod(facd[max(n,m)],MOD-2);
  for(int i=max(n,m)-1;i>=0;i--) facv[i]=facv[i+1]*(i+1)%MOD;
}

int f[2][105][105];
ll trans[105][105];

int main() {
  int n,m,K;
  scanf("%d%d%d%d",&n,&m,&K,&MOD);
  pre(n,m,K);
  int cur=0;
  f[0][0][0]=1;
  for(int i=1;i<=K;i++) {
  	cur^=1;
  	memset(f[cur],0,sizeof(f[cur]));
  	for(int j=0;j<=n;j++)
  	  for(int k=0;k<=m;k++) trans[j][k]=facv[j]*powd[i][j*(m-k)]%MOD*powd[K-i+1][j*k]%MOD;
  	for(int j=0;j<=n;j++)
  	for(int k=0;k<=m;k++)
  	for(int l=0;l<=j;l++)
  	    update(f[cur][j][k],f[cur^1][j-l][k]*trans[l][k]);
  	cur^=1;
  	memset(f[cur],0,sizeof(f[cur]));
  	for(int j=0;j<=m;j++)
  	  for(int k=0;k<=n;k++) trans[j][k]=facv[j]*powd[i][j*(n-k)]%MOD*powd[K-i+1][j*k]%MOD;
  	for(int j=0;j<=n;j++)
  	for(int k=0;k<=m;k++)
  	for(int l=0;l<=k;l++)
  	    update(f[cur][j][k],f[cur^1][j][k-l]*trans[l][j]);
  	cur^=1;
  	memset(f[cur],0,sizeof(f[cur]));
  	for(int j=0;j<=n;j++)
  	  for(int k=0;k<=m;k++) trans[j][k]=facv[j]*powd[i][j*(m-k)]%MOD*powd[K-i][j*k]%MOD*((j&1)?MOD-1:1)%MOD;
  	for(int j=0;j<=n;j++)
  	for(int k=0;k<=m;k++)
  	for(int l=0;l<=j;l++)
  	    update(f[cur][j][k],f[cur^1][j-l][k]*trans[l][k]);
  	cur^=1;
  	memset(f[cur],0,sizeof(f[cur]));
  	for(int j=0;j<=m;j++)
  	  for(int k=0;k<=n;k++) trans[j][k]=facv[j]*powd[i][j*(n-k)]%MOD*powd[K-i][j*k]%MOD*((j&1)?MOD-1:1)%MOD;
  	for(int j=0;j<=n;j++)
  	for(int k=0;k<=m;k++)
  	for(int l=0;l<=k;l++)
  	    update(f[cur][j][k],f[cur^1][j][k-l]*trans[l][j]);
  }
  printf("%lld\n",f[cur][n][m]*facd[n]%MOD*facd[m]%MOD);
  return 0;
}

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

typedef long long ll;

int main()
{
    string s;
    cin >> s;

    while(true){
        bool flag = false;
        int n = s.size();
        if(s.size() >= 7){
            if(s.substr(n-7) == "dreamer"){
                s.erase(n-7);
                flag = true;
            }else if (s.substr(n-6) == "eraser"){
                s.erase(n-6);
                flag = true;
            }else if(s.substr(n-5) == "erase"){
                s.erase(n-5);
                flag = true;
            }else if(s.substr(n-5) == "dream"){
                s.erase(n-5);
                flag = true;
            }
            if(!flag){
                cout << "NO" << endl;
                break;
            }
        }

        if(s.size() != 0 && s.size() <= 4){
            cout << "NO" << endl;
            break;
        }
        if(s.size() == 0){
            cout << "YES" << endl;
            break;
        }
        if(s.size() == 6){
            if(s == "eraser"){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
            break;
        }
        if(s.size() == 5){
            if(s == "erase" || s == "dream"){
                cout << "YES" << endl;
            }else{
                cout << "NO" << endl;
            }
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(container) container.begin(), container.end()
#define Cin(T, x) T x; cin >> x;
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i];
#define Cout(val) cout << (val) << "\n";
using namespace std;
using ll = long long;

int main(void){
    Cin(int, a);
    Cin(int, b);
    Cout(max(max(a+b, a-b), a*b));
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdlib.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N, M;
    cin >> N >> M;
    if(N >= M){
        cout << 0 << endl;
        return 0;
    }
    vector<int> X(M);
    REP(i,M) cin >> X[i];
    sort(X.begin(), X.end());
    vector<int> step;
    FOR(i, 1, M) step.push_back(X[i] - X[i-1]);
    sort(step.begin(), step.end());
    reverse(step.begin(), step.end());
    REP(i,N-1) step[i] = 0;

    sort(step.begin(), step.end());
    reverse(step.begin(), step.end());    
    int ans = 0;
    REP(i,M){
        int elem = step[i];
        if(elem==0) break;
        ans += elem;
    }

    cout << ans << endl;

    return 0;
}

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

int main()
{
  vector<int64_t> C(26, 0);
  int H, W;
  cin >> H >> W;
  char c;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      cin >> c;
      int idx = c - 'a';
      C[idx]++;
    }
  }
  int fs = (H / 2) * (W / 2), ts = 0, os = 0;
  if (H % 2)
    ts += W / 2;
  if (W % 2)
    ts += H / 2;
  if (H % 2 && W % 2)
    os++;
  for (int i = 0; i < 26; i++)
  {
    while (C[i] >= 4 && fs > 0)
    {
      C[i] -= 4;
      fs--;
    }
    while (C[i] >= 2 && ts > 0)
    {
      C[i] -= 2;
      ts--;
    }
    if (C[i] == 1 && os > 0)
    {
      C[i]--;
      os--;
    }
  }
  cout << ((fs == 0 && ts == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main()
{
    char s[10+1]={}, t[10+1]={}, u[10+1]={};
    int a, b;
    
    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);
    /*比較処理及び演算処理.開始*/
    if(strcmp(u,s) == 0)    a--;
    else if(strcmp(u,t) == 0)   b--;
    /*比較処理及び演算処理.終了*/
    printf("%d %d \n",a,b);
    
    return 0;
}

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

int main(void){

  char c;
  cin>>c;

  switch (c) {
    case 'a':cout<<"vowel"<<endl; break;
    case 'e':cout<<"vowel"<<endl;break;
    case 'i':cout<<"vowel"<<endl;break;
    case 'o':cout<<"vowel"<<endl;break;
    case 'u':cout<<"vowel"<<endl;break;
    default:cout<<"consonant"<<endl;break;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  cin >> a;
  vector<vector<int>> v(a);
  vector<string> z(a);
  for(int i = 0;i < a;i++){
    cin >> z.at(i);
    for(int j = 0;j < 10;j++){
      v.at(i).push_back(z.at(i).at(j));
    }
    sort(v.at(i).begin(),v.at(i).end());
  }
  sort(v.begin(),v.end());
  long long c = 1;
  long long d = 0;
  for(int i = 0;i < a-1;i++){
    if(v.at(i)==v.at(i+1))c++;
    else{d+=(c*(c-1))/2;
         c=1;}
    
  }
  d+=(c*(c-1))/2;
  cout << d << endl;
  }

Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>

using ll = long long;
const ll inf = 1001001001;

int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans;

    rep(i, 0, tx-sx)ans += 'R';
    rep(i, 0, ty-sy)ans += 'U';
    rep(i, 0, tx-sx)ans += 'L';
    rep(i, 0, ty-sy)ans += 'D';

    ans += 'D';
    rep(i, 0, tx-sx)ans += 'R';
    ans += 'R';
    rep(i, 0, ty-sy)ans += 'U';
    ans += 'U';
    ans += 'L';
    ans += 'U';
    rep(i, 0, tx-sx)ans += 'L';
    ans += 'L';
    rep(i, 0, ty-sy)ans += 'D';
    ans += 'D';
    ans += 'R';

    cout << ans << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		StringTokenizer st = new StringTokenizer(br.readLine());
		
		long a = Long.parseLong(st.nextToken());
		double b = Double.parseDouble(st.nextToken());
		
		long c = (long)(b * 100.0 + 0.5);
		long res = a * c / 100;
		System.out.println(res);
	}

}

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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb puah_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

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

int main(){
    int n; cin >> n;
    vector<int> lis(n+1);
    REP(i, 0, n){cin >> lis[i+1];}
    int ans = 0;
    REP(i, 1, n+1){
        if(lis[lis[i]] == i){
            ans++;
        }
    }
    cout << ans/2 << endl;
}

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


int main(){
  long long i, N, D, X, Y, cnt=0;
  cin>>N>>D;
  D*=D;
  for(i=0; i<N; i++){
    cin>>X>>Y;
    if(X*X+Y*Y<=D) cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

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

int main(){
    char b;
    cin >> b;
    switch(b){
        case 'A':
        cout << 'T' << endl;
        break;
        case 'T':
        cout << 'A' << endl;
        break;
        case 'G':
        cout << 'C' << endl;
        break;
        case 'C':
        cout << 'G' << endl;
        break;
    }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication50
{
    class Program
    {
        static void Main()
        {
            string a = Console.ReadLine();
            for (int c = 0; c < a.Length;c++ )
            {
                if (a[c] == 'a' && a[c + 1] == 'p' && a[c + 2] == 'p' && a[c + 3] == 'l' && a[c + 4] == 'e')
                {
                    Console.Write("peach"); c += 4;
                }
                else if (a[c] == 'p' && a[c + 1] == 'e' && a[c + 2] == 'a' && a[c + 3] == 'c' && a[c + 4] == 'h')
                {
                    Console.Write("apple"); c += 4;
               }
                else Console.Write(a[c]);
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 8824
#include <bits/stdc++.h>
using namespace std;
int n, a[3000005];

int main(){
	cin >> n;
	for(int i = 1; i <= 142; i++)
		for(int j = 1; j <= 142; j++)
			for(int k = 1; k <= 142; k++)
				a[i * i + j * j + k * k + i * j + j * k + k * i]++;
	for(int i = 1; i <= n; i++)
		printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 4228
func gcd(x: Int, _ y: Int) -> Int {
    return y>0 ? gcd(y, x%y) : x
}
let N = Int(readLine()!)!
let A = readLine()!.characters.split(" ").map{Int(String($0))!}
var L = [0]
var R = [0]
for i in 0..<N {
    L += [gcd(L[i], A[i])]
    R += [gcd(R[i], A[N-i-1])]
}
print((0..<N).map{gcd(L[$0], R[N-$0-1])}.maxElement()!)

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

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n=s.length(),num1=0,num2=0;
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='0')
                num1++;
        }
        else
        {
            if(s[i]=='1')
                num1++;
        }
    }
    for(int i=0;i<n;i++)
    {
        if(i%2==0)
        {
            if(s[i]=='1')
                num2++;
        }
        else
        {
            if(s[i]=='0')
                num2++;
        }
    }
    if(num1>num2)
        cout << num2 << endl;
    else
        cout << num1 << endl;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int N;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++)cin>>a[i];
  int min=10000000;
  for(int j=-100;j<=100;j++){
    int total=0;
    for(int i=0;i<N;i++)
      total+=(a[i]-j)*(a[i]-j);
    if(total<min)min=total;
  }
  cout<<min<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll          long long
#define pb          push_back
#define INF         9223372036854775807
#define    endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define lower(u)    transform(u.begin(), u.end(), u.begin(), ::tolower);//convert string u to lowercase;
#define upper(u)    transform(u.begin(), u.end(), u.begin(), ::toupper);
using namespace std;

using namespace __gnu_pbds; 
  
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define N  100005

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int TESTS=1;
//    cin>>TESTS;
    while(TESTS--)
    {
        ll n;
        cin>>n;
        vi v;
        v.pb(0);
        rep(i,0,n)
        {
            ll x;
            cin>>x;
            v.pb(x);
        }        
        map<ll,ll>lol;
        ll ans=0;
        lol[n-v[n]]++;
        for(ll i=n-1;i>=1;i--)
        {
            ans+=lol[v[i]+i];
            lol[i-v[i]]++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 27396