akhauriyash/Code-Regression huggingface dataset:
N = int(input())
MOD = 10**9 + 7


N0 = 9 ** N % MOD
N9 = 9 ** N % MOD
NA = 10 ** N % MOD
NB = 8 ** N % MOD

ans = ( NA - (N0 + N9 - NB) ) % MOD
print(ans)

Measured memory_bytes: 86992
<?php
fscanf(STDIN, "%d %d", $N, $D);

$ans = 0;

for ($i = 0; $i < $N; $i++) {
    $X[$i] = explode(" ", trim(fgets(STDIN)));
}
for ($i = 0; $i < $N - 1; $i++) {
    for ($j = $i + 1; $j < $N; $j++) {
        $diff = 0;
        foreach ($X[$i] as $k => $z) {
            $diff += pow($X[$i][$k] - $X[$j][$k], 2);
        }
        $diff_int = sqrt($diff);
        if ($diff_int == intval($diff_int)) {
            $ans++;
        }
    }
}

echo $ans;


Measured memory_bytes: 4856
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    int N, K; cin >> N >> K;

    int cur = 1;
    for (int i = 0; i < N; i++) {
        if (cur > K) {
            cur += K;
        } else {
            cur *= 2;
        }
    }

    cout << cur << endl;
    return 0;
}


Measured memory_bytes: 256
S = input()
ans = 1000
c = 0
for i in range(len(S) - 2):
    x = int(S[i])
    y = int(S[i+1])
    z = int(S[i+2])
    xyz = 100*x+10*y+z
    c = 753 - xyz
    c = max(c,-c)
    ans = min(c,ans)

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
using namespace std;

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

  string s;
  ll k;
  cin >> s >> k;

  rep(i, s.size()) {
    if(s[i] == 'a') continue;

    int tmp = s[i]-'a';
    if(26-tmp <= k) {
      k -= 26-tmp;
      s[i] = 'a';
    }
  }
  s[s.size()-1] = (char)((s[s.size()-1]-'a'+k)%26+'a');

  cout << s << '\n';
  return 0;
}


Measured memory_bytes: 592
a,x=map(int,raw_input().split())
l=map(int,raw_input().split())
k=0
for i in range(1,a):
    b=l[i-1]
    c=l[i]
    d=b+c
    if(d>x):
        e=d-x
        k=k+e
        if(c>=e):
            f=c-e
            l[i]=f
        else:
            f=0
            g=b-(e-c)
            l[i]=f
            l[i-1]=g
print k
            

    



Measured memory_bytes: 11316
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for _ in range(D)]

last=[0]*26
ans=0

for d in range(1,D+1):
    choice=int(input())
    ans+=s[d-1][choice-1]
    last[choice-1]=d
    for i in range(26):
        ans-=c[i]*(d-last[i])
    print(ans)

Measured memory_bytes: 9212
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define INF 999999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

void visit(Graph &h, int v, int s, int r,
  vector<int> &no, vector< vector<int> > &comp,
  vector<int> &prev, vector< vector<int> > &next, vector<Weight> &mcost,
  vector<int> &mark, Weight &cost, bool &found) {
  const int n = h.size();
  if (mark[v]) {
    vector<int> temp = no;
    found = true;
    do {
      cost += mcost[v];
      v = prev[v];
      if (v != s) {
        while (comp[v].size() > 0) {
          no[comp[v].back()] = s;
          comp[s].push_back(comp[v].back());
          comp[v].pop_back();
        }
      }
    } while (v != s);
    FOR(j,comp[s]) if (*j != r) FOR(e,h[*j])
      if (no[e->src] != s) e->weight -= mcost[ temp[*j] ];
  }
  mark[v] = true;
  FOR(i,next[v]) if (no[*i] != no[v] && prev[no[*i]] == v)
    if (!mark[no[*i]] || *i == s)
      visit(h, *i, s, r, no, comp, prev, next, mcost, mark, cost, found);
}
Weight minimumSpanningArborescence(const Graph &g, int r) {
  const int n = g.size();
  Graph h(n);
  REP(u,n) FOR(e,g[u]) h[e->dst].push_back(*e);

  vector<int> no(n);
  vector< vector<int> > comp(n);
  REP(u, n) comp[u].push_back(no[u] = u);

  for (Weight cost = 0; ;) {
    vector<int> prev(n, -1);
    vector<Weight> mcost(n, INF);

    REP(j,n) if (j != r) FOR(e,h[j])
      if (no[e->src] != no[j])
        if (e->weight < mcost[ no[j] ])
          mcost[ no[j] ] = e->weight, prev[ no[j] ] = no[e->src];

    vector< vector<int> > next(n);
    REP(u,n) if (prev[u] >= 0)
      next[ prev[u] ].push_back(u);

    bool stop = true;
    vector<int> mark(n);
    REP(u,n) if (u != r && !mark[u] && !comp[u].empty()) {
      bool found = false;
      visit(h, u, u, r, no, comp, prev, next, mcost, mark, cost, found);
      if (found) stop = false;
    }
    if (stop) {
      REP(u,n) if (prev[u] >= 0) cost += mcost[u];
      return cost;
    }
  }
}

int main(){
	int V,E,r,s,t,w;
	scanf("%d%d%d",&V,&E,&r);
	Graph g(V);
	for(;E--;)scanf("%d%d%d",&s,&t,&w),g[s].push_back(Edge(s,t,w));
	printf("%d\n",minimumSpanningArborescence(g,r));
}

Measured memory_bytes: 1100
def a(t,i):
    if i==l:
        if eval(t)==7:
            print(t+'=7')
            exit()
        return
    a(t+'+'+s[i+1],i+1)
    a(t+'-'+s[i+1],i+1)

s = input()
l = len(s)-1
a(s[0],0)

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

void solver() {
  long long h, a;
  cin >> h >> a;

  long long sumS = 0;
  for (int i = 0; i < a; i++) {
    long long s;
    cin >> s;

    sumS += s;
  }

  if (h <= sumS) cout << "Yes\n";
  else cout << "No\n";
}

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


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    n, q = MI()
    S = input()
    ats = [0] * n
    cnt = 0
    for i in range(n-1):
        j = i + 2
        s = S[i:j]
        # print(s)
        if s == 'AC':
            cnt += 1
        ats[i+1] = cnt
    # print(ats)
    for _ in range(q):
        l, r = MI1()
        # print(S[l:r+1])
        print(ats[r] - ats[l])


if __name__ == '__main__':
    solve()


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

int main() { 
    ll N, K;
    cin >> N >> K;
    N = N % K;
    bool check = true;
    while(check){
        if(abs(N-K)<N){
          N = abs(N - K);
        }
        else
          check = false;
    }
    cout << N << endl;
    return 0;
}

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

int n,ans2,id;
double ans,bmi,w,h;

double EPS = 1e10;

int main(){
  while(cin>>n&&n){
    ans=9999.9;
    for(int i=0;i<n;i++){
      cin>>id>>h>>w;
      bmi=abs( w/((h/100.0)*(h/100.0)) -22.0);
      if(bmi<ans){
	ans=bmi;ans2=id;
      }else if(bmi - EPS <ans && id<ans2){
	ans2=id;
      }
    }
    cout<<ans2<<endl;
  }
  return 0;
}

Measured memory_bytes: 1228
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        int ans = 0;
        for (int i = 0; i < s.length()-2; i++) {
            if(s.substring(i, i+3).equals("ABC")) ans++;
        }
        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(a==b){
        cout<<"Draw"<<endl;
        goto exit;
    }
    if(a==1){
        cout<<"Alice"<<endl;
        goto exit;
    }
    if(b==1){
        cout<<"Bob"<<endl;
        goto exit;
    }
    if(a<b)cout<<"Bob"<<endl;
    else cout<<"Alice"<<endl;
    






exit:;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    n=int(input())
    A=list(map(int,input().split()))
    #1個がi個，2個がj個，3個がk個
    dp=[[[0.0]*(n+1) for j in range(n+1)]for i in range(n+1)]
    max_i,max_j=A.count(1),A.count(2)
    max_k=n-max_i-max_j
    for k in range(max_k+1):
        for j in range(max_j+max_k+1):
            for i in range(min(max_i+max_j+max_k+1,n-(j+k)+1)):
                if i+j+k==0:continue
                res=n
                if i>0:res+=dp[i-1][j][k]*i
                if j>0:res+=dp[i+1][j-1][k]*j
                if k>0:res+=dp[i][j+1][k-1]*k
                res/=i+j+k
                dp[i][j][k]=res
    print(dp[max_i][max_j][max_k])

if __name__=='__main__':
    main()

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

int main(){
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> walk;

    int now = n;
    while(now > m){
        for(int i = m; i > 0; i--){
            if (s[now-i] == '0'){
                now = now-i;
                walk.push_back(i);
                break;
            }
            if (i == 1){
                cout << -1 << endl;
                return 0;
            }
        } 
    }
    walk.push_back(now);
    for(int i = walk.size()-1; i >= 0; i--){
        cout << walk[i];
        if (i > 0)cout << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3440
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> P;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t,u;
ll d[100000],dp[100][100];

int main(){
  string ans = "";
  cin >> s >> t >> u;
  ans += toupper(s[0]);
  ans += toupper(t[0]);
  ans += toupper(u[0]);
  print(ans);
  return 0;
}

Measured memory_bytes: 256
def int_list(sepalate=" "): return list(map(int, input().split(sepalate)))


def solve1(n, k, x):
    ans = 0

    for i in range(n):
        ans += min(abs(k-x[i]), x[i]) * 2

    return ans


n = int(input())
k = int(input())
x = int_list()
print(solve1(n, k, x))


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

int X, Y, S;

// 税抜価格から税込価格を計算する関数                                           
int tax(int p,int x) {
  int ans;
  ans = x*(100 + p) / 100;
  return ans;
}

//全ての税抜価格の組み合わせから、和がSとなるものを探す                         
int solve() {
  int ma = 0;
  for (int i = 1; i < 1000; i++) {
    for (int j = 1; j < 1000; j++) {
      if (tax(X,i) + tax(X,j) == S) {
        ma = max( tax(Y,i) + tax(Y,j) , ma);
      }
      if (tax(X,i) + tax(X,j) > S) {
        break;
      }
    }
  }
  return ma;
}

int main() {
  while (cin >> X >> Y >> S && X > 0 ) {
    cout << solve() << endl;
  }
}

//Tax Rate Changed の解、約15分ほど                                             
//教卓から見て右中央                                                            
//授業用テキストを参考にしました。 


Measured memory_bytes: 3084
# B
S = input()

n = len(S)
flg = True 
if S != S[::-1]:
    flg = False
s2 = S[:int((n-1)/2)]
if s2 != s2[::-1]:
    flg = False
s3 = S[int((n+3)/2):n-1]
if s3 != s3[::-1]:
    flg = False

if flg:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}


int main(){
    int N; cin >> N;
    int mn = MM;
    for (int i = 1; i < N/2 + 1; i++){
        int num = N-i, num2 = i;
        int sum = 0;
        while (num > 0){
            sum += num % 10;
            num /= 10;
        }
        while (num2 > 0){
            sum += num2 % 10;
            num2 /= 10;
        }
        mn = min(mn,sum);
    }
    cout << mn << endl;
}




Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
#define mt(a) memset(a,0,sizeof(a))
#define ll long long
const ll INF = 0x3f3f3f3f;
using namespace std;
int main (void)
{
	ll n,m;//除了最外层以外 都会被翻过来 因为是9
	cin>>n>>m;
	cout<<(ll) abs((n-2)*(m-2))<<endl;
	return 0;
}

Measured memory_bytes: 256
import * as fs from 'fs';

namespace AtCoder.abc158 {
    export class Program {
        /**
         * ABA
         * Yes
         */
        static main(inp: string) {

            if (inp === 'AAA' || inp === 'BBB') {
                console.log('No');
            } else {
                console.log('Yes');
            }

        }
    }
}

AtCoder.abc158.Program.main(fs.readFileSync('/dev/stdin','utf8').trim());

Measured memory_bytes: 7372
#include<iostream>
#include<cstdio>

using namespace std;

typedef long long ll;

ll p,q,a,n,ans;
int vn;

void dfs(ll depth, ll nume, ll deno, ll product, ll vi){
    if(product > a || nume*q > p*deno) return;
    if(nume*q == p*deno){
        ans++;
        return;
    }
    if(depth == n) return;
    for(ll i=min(vi, a/product);i>=1;i--) dfs(depth+1, nume*i+deno, deno * i, product*i, i);
}

int main(){
    while(scanf("%lld%lld%lld%lld", &p, &q, &a, &n) && p){
        ans = 0LL;
        dfs(0LL, 0LL, 1LL, 1LL, a);
        printf("%lld\n", ans);
    }
}


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

#define reps(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   reps(i,0,n)
#define all(x) (x).begin(),(x).end()
#define INF (2000000000)
#define MOD (1000000007)
#define PI (acos(-1))


int main(){
  string s;
  cin >> s;
  int asum[200010];
  asum[0] = 0;
  reps(i,1,s.size()){
    if(s[i-1] == 'A')asum[i] = asum[i-1]+1;
    if(s[i-1] == 'B'){
      if(s[i] != 'C')asum[i] = 0;
      else asum[i] = asum[i-1];
    }
    if(s[i-1] == 'C'){
      if(i==1){
        asum[i]=0;
        continue;
      }
      if(s[i-2] != 'B')asum[i] = 0;
      else asum[i] = asum[i-1];
    }
  }

  ll ans = 0;
  rep(i,s.size()-1){
    if(s[i] == 'B' && s[i+1] == 'C'){
      ans += asum[i+1];
    }
  }
  cout << ans << endl;
}

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

struct Point{
    int x;
    int y;
};

int main(){
    Point p1,p2;    cin>>p1.x>>p1.y>>p2.x>>p2.y;
    
    int xlength=p2.x - p1.x;
    int ylength=p2.y - p1.y;
    
    Point p3;
    p3.x = p2.x - ylength;
    p3.y = p2.y + xlength;

    Point p4;
    p4.x = p1.x - ylength;
    p4.y = p1.y + xlength;

    cout<<p3.x<<" "<<p3.y<<" "<<p4.x<<" "<<p4.y<<endl;

    return 0;
}


Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

bingos = [
    [(0,0), (0,1), (0,2)],
    [(1,0), (1,1), (1,2)],
    [(2,0), (2,1), (2,2)],
    [(0,0), (1,0), (2,0)],
    [(0,1), (1,1), (2,1)],
    [(0,2), (1,2), (2,2)],
    [(0,0), (1,1), (2,2)],
    [(2,0), (1,1), (0,2)],
]

ans = 'No'
for bingo in bingos:
    for bp in bingo:
        i, j = bp
        if a[i][j] not in b:
            break
    else:
        ans = 'Yes'
        break
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=1;i<=n;i++)
using namespace std;

int main(){
    long long N,M,A,sum = 0;

    cin >> N >> M;

    rep(i,M){
        cin >> A;
        sum += A;
    }
    if( N < sum ){
cout << -1;
    }else{
cout << N - sum;
    }
    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;
vector<vector<vector<int>>> dp(62,vector<vector<int>>(50,vector<int>(50,0)));
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      int n,k;
      cin>>n>>k;
      for(int i=0;i<n;i++){
            for(int j=0;j<n;j++){
                  int x;
                  cin>>x;
                  if(x==1)
                  dp[0][i][j]=1;
            }
      }
      if(k==0){
            cout<<0;
            return 0;
      }
      for(int i=1;i<62;i++){
            for(int x=0;x<n;x++){
                  for(int y=0;y<n;y++){
                        for(int j=0;j<n;j++){
                              dp[i][x][j]=(dp[i][x][j]+dp[i-1][x][y]*dp[i-1][y][j]%modulo)%modulo;
                        }
                  }
            }
      }
      vector<vector<int>>val(n,vector<int>(n,0));
      val=dp[(int)log2(k&-k)];
      k-=k&-k;
      while(k>0){
            vector<vector<int>>temp(n,vector<int>(n,0));
            for(int x=0;x<n;x++){
                  for(int y=0;y<n;y++){
                        for(int j=0;j<n;j++){
                              temp[x][j]=(temp[x][j]+val[x][y]*dp[(int)log2(k&-k)][y][j]%modulo)%modulo;
                        }
                  }
            }
            val=temp;
            k-=k&-k;
      }
      int cnt=0;
      for(int i=0;i<n;i++){
            for(int j=0;j<n;j++)cnt=(cnt+val[i][j])%modulo;
      }
      cout<<cnt;
}


Measured memory_bytes: 1664
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <random>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

int main(){
	ll n ; cin >> n; 
	ll ans = 0 ;
	for(int i=1;i<=n;i++){
		for(int j=1;i*j<n;j++){
			ans++ ;
		}
	}
	cout << ans << endl ;
}

Measured memory_bytes: 3624
a = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
s = input()
for i in a:
    if i not in s:
        print(i)
        break
else:
    print('None')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll mod=1e9+7;
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];
    }
  }
  ll dp[h][w];
  int k=1;
  for(int i=0;i<w;i++)
  {
    if(a[0][i]=='#')
    {
      k=0;
    }
    dp[0][i]=k;
  }
  k=1;
  for(int i=0;i<h;i++)
  {
    if(a[i][0]=='#')
    {
      k=0;
    }
    dp[i][0]=k;
  }
  for(int i=1;i<h;i++)
  {
    for(int j=1;j<w;j++)
    {
      if(a[i][j]=='#')
      {
        dp[i][j]=0;
      }
      else
      {
        dp[i][j]=((dp[i-1][j])%mod+(dp[i][j-1])%mod)%mod;
    //    cout<<dp[i][j]<<" ";
      }

    }
//    cout<<endl;

  }
  dp[h-1][w-1]=dp[h-1][w-1]%mod;
  cout<<dp[h-1][w-1]<<endl;
}


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

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

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    int A, B; cin >> A >> B;
    if(A != 1 && B != 1) cout << 1 << endl;
    else if(A != 2 && B != 2) cout << 2 << endl;
    else cout << 3 << endl;
    return 0;
}

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

namespace ConsoleApplication27 {
    class Program {
        static void Main(string[] args) {
            string[] str  = Console.ReadLine().Split();
            int a = int.Parse(str[0]);
            int b = int.Parse(str[2]);
            int result = 0;
            if (str[1] == "+") {
               result = a + b;
            }
            else {
                result = a - b;
            }


            Console.WriteLine(result);

        }

        private static int Method(string[] str) {//

          
            int result = 0;


            return result;
        }
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << endl;
}
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...);
}

#define pb             push_back
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define rep(i, n)  	   for (int i = 0; i < n; ++i)
#define irep(i, a, b)  for (int i = a; i <= b; ++i)
#define repr(i, a, b)  for (int i = a; i >= b; --i)
#define iter(it, x)    for (auto it = x.begin(); it != x.end(); ++it)

using ll = long long;
using P = pair<int,int>;
using vi = vector<int>;
const char nl = '\n';
const int inf = 2e9;
const ll INF = (ll)2e18;
const ll mod = 1e9 + 7;
const int N = 2e6 + 15;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	sort(all(a));
	reverse(all(a));
	ll ans = 0;
	ans += a[0];
	for (int i = 2; i < n; ++i) {
		ans += a[i / 2];
	}
	cout << ans << nl;
    return 0;
}


Measured memory_bytes: 4780
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
    ll l,r,d; cin >> l >> r >> d;
    ll ans = r/d-(l-1)/d;
    cout << ans << endl;
}

Measured memory_bytes: 3632
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimise ("ofast")
#pragma GCC optimise("unroll-loops")

using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000000000000000;
const ll LOG = 25;

int n, x, ans[N];

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> x;
	n = 2 * n - 1;
	if (x == n || x == 1) return cout << "No\n", 0;
	cout << "Yes\n";
	if (x == 2){
		ans[n / 2 + 1] = 2;
		ans[n / 2] = 3;
		ans[n / 2 + 2] = 1;
		int pnt = 4;
		for (int i = 1; i <= n; i++){
			if (i == (n / 2 + 1) || i == (n / 2) || i == (n / 2 + 2)) continue;
			ans[i] = pnt++;
		}
		for (int i = 1; i <=n; i++) cout << ans[i] << '\n';
		return 0;
	}
	ans[n / 2 + 1] = x;
	ans[n / 2] = 1;
	ans[n / 2 + 2] = n;
	ans[n / 2 + 3] = 2;
	int pnt = 3;
	for (int i = 1; i <= n; i++){
		if (i == (n / 2 + 1) || i == (n / 2) || i == (n / 2 + 2) || i == (n / 2 + 3)) continue;
		if(pnt == x) pnt++;
		ans[i] = pnt++;
	}
	for (int i = 1; i <= n; i++) cout << ans[i] << '\n';






	return 0;
}


Measured memory_bytes: 2304
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
double d[2][20][20];
bool flag[2][20][20];
vector<int>ok[20][20];
int N;
double R,t;
int x[20],y[20];
double dis[20][20];
double calc(int X,int Y)
{
	return atan2(Y,X);
}
main()
{
	cin>>N>>R>>t;
	t=t/180*M_PI;
	for(int i=0;i<N;i++)
	{
		cin>>x[i]>>y[i];
	}
	for(int i=0;i<N;i++)for(int j=0;j<N;j++)
	{
		dis[i][j]=hypot(x[i]-x[j],y[i]-y[j]);
		if(i==j)continue;
		for(int k=0;k<N;k++)
		{
			if(j==k)continue;
			double A=calc(x[j]-x[i],y[j]-y[i]),B=calc(x[k]-x[j],y[k]-y[j]);
			double dif=B-A;
			if(dif<0)dif+=2*M_PI;
			if(dif>M_PI)dif=2*M_PI-dif;
			if(dif<t)ok[i][j].push_back(k);
		}
	}
	int ans=0;
	bool f=false;
	for(int i=1;i<N;i++)
	{
		if(dis[0][i]<R)
		{
			d[0][0][i]=R-dis[0][i];
			flag[0][0][i]=true;
			f=true;
		}
	}
	for(int w=0;f;w=!w)
	{
		ans++;
		f=false;
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)d[!w][i][j]=flag[!w][i][j]=0;
		for(int i=0;i<N;i++)for(int j=0;j<N;j++)
		{
			if(!flag[w][i][j])continue;
			for(int k:ok[i][j])
			{
				double nxt=d[w][i][j]-dis[j][k];
				if(nxt>0)
				{
					flag[!w][j][k]=true;
					f=true;
					d[!w][j][k]=max(d[!w][j][k],nxt);
				}
			}
		}
	}
	cout<<ans<<endl;
}



Measured memory_bytes: 3556
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include <set>
#include <queue>
#include <iomanip>

typedef long long ll;

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

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

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[510][510];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}


int main() {
	ll m;
	cin >> n >> m;
	map<ll,ll,greater<ll>> a;
	vector<P> bc(m);
	ll p = -1;
	rep(i, n) {
		ll tmp;
		cin >> tmp;
		chmax(p, tmp);
		++a[tmp];
	}
	rep(i, m) {
		cin >> bc[i].first >> bc[i].second;
		chmax(p, bc[i].second);
	}
	rep(i, m) {
		a[bc[i].second] += bc[i].first;
	}
	ll res = 0;
	ll cnt = 0;
	for (auto i = a.begin(); i!=a.end(); ++i) {
		if (cnt + i->second<= n) {
			cnt += i->second;
			res += i->second * i->first;
		}
		else {
			res += (n - cnt) * i->first;
			cnt = n;
		}
		if (cnt >= n)break;
	}
	cout << res << endl;
}

Measured memory_bytes: 15360
#include <bits/stdc++.h> // only for GCC

using namespace std;

int main(){
    double a, l, x;
    while(cin >> a >> l >> x){
        double b = sqrt(abs(pow(l, 2)-pow(a/2, 2)));
        double ans = a*b/2;
        double d = sqrt(pow((l+x)/2, 2)-pow(l/2, 2));
        ans += l*d;
        printf("%lf\n", ans);
    }
}

Measured memory_bytes: 1232
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
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; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};


bool isPrime(long long x)
{
    for(int i = 2; i < sqrt(x); i++ )
    {
        if ( x % i == 0 )
        {
            return false;
        }
    }

    return true;
}

int main()
{
    int x;
    cin >> x;
    int MAX = 1000000009;

    REP(i,x,MAX+1)
    {
        if(isPrime(i))
        {
            cout << i << endl;
            return 0;
        }
    }
    
    return 0;
}

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

// const long long MOD = 1000000007;
const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

const int MOD = 1000000007;

class mint
{
  ll x;

public:
  mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
  mint operator-() const
  {
    return mint(-x);
  }

  mint &operator+=(const mint &a)
  {
    if ((x += a.x) >= MOD)
      x -= MOD;
    return *this;
  }

  mint &operator-=(const mint &a)
  {
    if ((x += MOD - a.x) >= MOD)
      x -= MOD;
    return *this;
  }

  mint &operator*=(const mint &a)
  {
    (x *= a.x) %= MOD;
    return *this;
  }

  mint operator+(const mint &a)
  {
    mint res(*this);
    return res += a;
  }

  mint operator-(const mint &a)
  {
    mint res(*this);
    return res -= a;
  }

  mint operator*(const mint &a)
  {
    mint res(*this);
    return res *= a;
  }

  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(MOD - 2);
  }

  mint &operator/=(const mint &a)
  {
    return (*this) *= a.inv();
  }

  mint operator/(const mint &a)
  {
    mint res(*this);
    return res /= a;
  }

  friend ostream &operator<<(ostream &os, const mint &m)
  {
    os << m.x;
    return os;
  }
};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  vector<ll> A(N);
  for (auto &it : A)
    cin >> it;
  vector<int> used(N, 0);
  mint ans = 1;
  for (int i = 0; i < N; i++)
  {
    if (A[i] == 0)
    {
      ans *= 3 - used[A[i]];
      used[A[i]]++;
    }
    else
    {
      ans *= used[A[i] - 1] - used[A[i]];
      used[A[i]]++;
    }
  }
  cout << ans << endl;
  return 0;
}

// 何回使ったかを格納する配列を用意する．A[i]が0の時は3 - used[Ai]でそれ以外の時は，基本的にはA[i] - 1が出た数だけ，左側にはA[i]人被っている色が存在しているが，A[i]が出た数だけ3色のうち色が使われている．したがってこの時使える色の個数はused[A[i] - 1] - used[A[i]]となる．全部掛け合わせていく．


Measured memory_bytes: 1408
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String T=sc.next();
		sc.close();
		String[] a = T.split("");
	
		for(int i=0;i<T.length();i++){
			if(a[i].equals("?")) {
					a[i]="D";
			}
		}
		for(int i=0;i<T.length();i++)
			System.out.print(a[i]);
	}
}


Measured memory_bytes: 68728
'''
.append(要素) リストに要素を追加
.extend(リスト) リストを連結する
.insert(場所,要素) 指定した場所に要素追加
del 配列名[場所]
-1で末尾で末尾から一つ前

sort()
sorted(reverse=true)

配列の初期化
配列名=[a]*n+[b]*m

Decimal()
'''

from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
from functools import reduce
from operator import mul
from collections import Counter
import itertools
import fractions


N = int(stdin.readline().rstrip())
S = stdin.readline().rstrip()
r = S.count('R')
g = S.count('G')
b = S.count('B')
t = r * g * b
for el in range(N):
    end = N - 1 - el
    tt = min([el, end])
    for el2 in range(1, tt+1):
        if S[el - el2] != S[el] and S[el + el2] != S[el] and S[el - el2] != S[el + el2]:
            t -= 1
print(t)


Measured memory_bytes: 73520
n = int(input())
red = []
for i in range(n):
    a, b = map(int, input().split())
    red.append((a, b))

blue = []
for i in range(n):
    c, d = map(int, input().split())
    blue.append((c, d))

red = sorted(red, key=lambda x: x[1])
blue.sort()

count = 0
while len(blue) >= 1:
    c, d = blue.pop(0)
    tmp = []
    r = []
    while len(red) >= 1:
        a, b = red.pop()
        if a < c and b < d:
            r.append((a, b))
        else:
            tmp.append((a, b))
    if len(r) >= 1:
        count += 1
        r = sorted(r, key=lambda x:x[1])
        r.pop()
        tmp.extend(r)
    red.extend(tmp)
print(count)


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

min_char = "abcdefghij"

def dtype_tree(tree, max, num):
    for i in range(max+1):
        tgt_tree = [i]
        if num > 0:
            new_max = max
            if new_max < i+1:
                new_max = i+1
            new_tree = dtype_tree([], new_max, num-1)
            tgt_tree.append(new_tree)

        if tree == None:
            tree = tgt_tree
        else:
            tree.append(tgt_tree)
    return tree

def print_tree(tree, prefix):
    new_prefix = prefix
    if len(tree) == 1:
        print(prefix + min_char[tree[0]])
    else:
        for elem in tree:
            if type(elem) != list:
                new_prefix += min_char[elem]
#                print(new_prefix)
            else:
                print_tree(elem, new_prefix)

    return


def abc_XXX(num):
    tree = dtype_tree(None, 0, num-1)
#    print(tree)
    print_tree(tree, "")
    return

###
# main
if(__name__ == '__main__'):
    # input
    n = int(input())
    
    abc_XXX(n)
    
    # output

# else:
    # do nothing


Measured memory_bytes: 21932
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long int LL;
typedef vector<int> ivec;
typedef vector<string> svec;

const int MOD=1000000007;

int a[100010];
int main(){
	LL n;
	LL kane=100;
	int ans=0;
	cin>>n;
	
	while(kane<n)
	{
		kane=kane*1.01,ans++;
	}
	cout<<ans<<endl;
	return 0;
}

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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void uniq(vector<int> &vec){sort(vec.begin(), vec.end());vec.erase(unique(vec.begin(), vec.end()), vec.end());}
void start(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);}

const int MAX=100100;
int n,m;
VVi connect(MAX,Vi());
int dp[MAX];

int solve(int v) {
    if (dp[v] != -1) return dp[v];
    
    int ret = 0;
    REP(i,0,connect[v].size()){
        chmax(ret, solve(connect[v][i]) + 1);
    }
    dp[v]=ret;
    return ret;
}


signed main() {
    // 入力受け取り
    cin>>n>>m;
    REP(i,0,m){
        int x,y;
        cin>>x>>y;
        --x;
        --y;
        connect[x].pb(y);
    }
    REP(i,0,n) dp[i]=-1;
    
    int ans=0;
    REP(i,0,n) chmax(ans,solve(i));
    cout<<ans<<endl;
}


Measured memory_bytes: 8576
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

int main(){
    ll x,y;
    cin>>x>>y;
    
    ll p = y/x;
    
    int sum = 0;
    while(p){
        sum++;
        p/=2;
    }
    cout<<sum<<endl;
}


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

const ll MOD = 1e9 + 7;

map<long long, int> prime_factor(long long n){
    map< long long, int> ret;

    for(long long i = 2; i * i <= n; i++){
        while(n % i == 0){
            ret[i]++;
            n /= i;
        }
    }

    if( n != 1) ret[n] = 1;
    return ret;
}

int main(){
    ll N; cin >> N;
    
    unordered_map< long long, int> ret;

    for(int x = 2; x <= N; x++){
        int t = x;
        for(long long i = 2; i * i <= t; i++){
            while(t % i == 0){
                ret[i]++;
                t /= i;
            }
        }

        if( t != 1) ret[t]++;
    }
    ll ans = 1;

    for(auto e: ret){
        //cout << e.first << endl;
        ans *= (e.second + 1);
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)
    val S = sc.next
    var blackFirst = 0
    var whiteFirst = 0
    for (i <- 0 until S.length) {
      if (i % 2 == 0) {
        if (S(i) == '1') {
          blackFirst += 1
        } else {
          whiteFirst += 1
        }
      } else {
        if (S(i) == '0') {
          blackFirst += 1
        } else {
          whiteFirst += 1
        }
      }
    }
    val result = Math.min(blackFirst, whiteFirst)
    println(result)
  }
}


Measured memory_bytes: 31044
import java.util.*;
public class Main{
  public static void main(String[] args){
  	Scanner in = new Scanner(System.in);
        long n = in.nextLong();
        String s = "";
        while(n > 0) {
            long mod = n%26;
            if(mod != 0) {
                char c = (char) (96 + mod);
                s = c + s;
                n = n/26;
            } else {
                s = 'z' + s;
                n = n/26;
                n--;
            }
        }
        System.out.println(s);

    
  }
}


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

int main() {
  int64_t x,a,b,ans=0;
  cin>>x;
  a=x/500;
  a*=1000;
  b=x%500;
  b/=5;
  b*=5;
  ans=a+b;
  cout<<ans<<endl;
}

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


int main() {
    int a,b;
    cin>>a>>b;

    if(a%2==1 && b%2==1)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rg register
#define ll long long
using namespace std;
const int N=2e5+5,Inf=1e9+7;
inline ll read(){
	rg ll x=0; rg char c=getchar();
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+c-'0',c=getchar();
	return x; 
}
struct Bag{
	ll ballx,bally;
	inline bool operator < (const Bag &bg) const{ return ballx<bg.ballx; }
}bag[N];
ll x[N],y[N],mx[N],mn[N],n,cnt,ans=Inf,amax,amin=Inf,bmax,bmin=Inf;
int main(){
	n=read();
	for(rg int i=1;i<=n;++i){
		bag[i].ballx=read(); bag[i].bally=read(); 
		if(bag[i].ballx>bag[i].bally) swap(bag[i].ballx,bag[i].bally);
		amin=min(amin,bag[i].bally); amax=max(amax,bag[i].bally);
		bmin=min(bmin,bag[i].ballx); bmax=max(bmax,bag[i].ballx);
	}
	cnt=(amax-amin)*(bmax-bmin); sort(bag+1,bag+n+1); mn[1]=mx[1]=bag[1].bally;
	for(rg int i=2;i<n;++i){
		mn[i]=min(mn[i-1],bag[i].bally); mx[i]=max(mx[i-1],bag[i].bally);
		ans=min(ans,max(mx[i],bag[n].ballx)-min(mn[i],bag[i+1].ballx));
	}
	return printf("%lld\n",min(ans*(amax-bmin),cnt))&0;
}

Measured memory_bytes: 7552
import java.util.*;

public class Main {
	//static_val
	static int N, K;
	static int[] A;
	static int[][][] check;

	public static void main(String[] args){

		int ans = 0;
		Scanner scanner = new Scanner(System.in);

		N = scanner.nextInt();
		K = scanner.nextInt();
		A = new int[N+1];//A[?????????????±??????£???????????\]?????????????????????0,1,2
		Arrays.fill(A, -1);//??????A?????????
		
		for(;K!=0;K--){
			A[scanner.nextInt()]=scanner.nextInt()-1;
		}
		check = new int[N+1][3][3];
		for(int i=0;i<check.length;i++){
			for(int j=0;j<check[i].length;j++){
				Arrays.fill(check[i][j], -1);//1?¬?????????§???????????????????????????
			}
		}
		//		Arrays.fill(check, -1);//Arrays.fill?????????????¬???????????????????????????????
		for(int i=0;i<3;i++){
			for(int j=1;j<3;j++){
				ans+=count_pasta(1, i, j);
//				System.out.println("ans="+ans);
			}
		}
		System.out.println(ans%10000);
	}

	public static int count_pasta(int v, int s, int c){//v=???????????\??° s= c=
		//System.out.println("v="+v+"s="+s+"c="+c);
		if(A[v]!=-1&&A[v]!=s)return 0;
		
		if(v==N)return c==1?1:0;//
		
		if(check[v][s][c]!=-1)return check[v][s][c];//?????§??????????????????
		
		int ans = 0;
		
		if(c==1){
			for(int j=0;j<3;j++){
				if(s==j)continue;
				ans = (ans+count_pasta(v+1, j, 1)+count_pasta(v+1, j, 2))%10000;//????????????????????°????????????
			}
		}
		else ans = count_pasta(v+1, s, 1);
		check[v][s][c] = ans;
//		System.out.println("ans="+ans);

		return ans;
		
	}
}

Measured memory_bytes: 19728
#include<bits/stdc++.h>
using namespace std;
int main(){
	int long long x,y;cin>>x>>y;
	int long long p=y/x;
	int long long ans=0;
	for(int i=0;p>1;i++){
		p/=2;ans++;
	}
	ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	int n;
	cin >> n;

	vector<long long> a(n), b(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}

	long long presses = 0;
	for (int i = n - 1; i >= 0; --i) {
		a[i] += presses;
		if (!a[i]) {
			continue;
		}
		
		long long needed;
		if (a[i] && a[i] % b[i] == 0) {
			needed = 0;
		} else {
			needed = ((a[i] / b[i]) + 1) * b[i] - a[i];
		}

		presses += needed;
	}

	cout << presses << "\n";

	return 0;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int N,M;
    ll A[100001]={0,},sum=0,ans=0;
    cin >> N >> M;
    REP(i,0,N){
        cin>>A[i];
    }
    unordered_map<ll, ll> mp;
    mp[0]=1;
    REP(i,0,N){
        sum+=A[i];
        ans+=mp[sum%M];
        mp[sum%M]++;
    }
    cout<<ans;
    // 4 1 5
    // logMA[i]
    // 0 1 1
    // 0 1 2
    return 0;
}

Measured memory_bytes: 4492
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// g++ -o a a.cpp -Wall -lm -std=c++17
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
    ll n,m;cin>>n>>m;
    UnionFind U(n);
    rep(i,m){
        ll a,b,z;cin>>a>>b>>z;
        a--;b--;
        U.merge(a,b);
    }
    set<ll>st;
    rep(i,n)st.insert(U.root(i));
    cout<<st.size()<<endl;
}

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

int main() {
  int N;
  cin>>N;
  vector<double>A(N);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
  }
  sort(A.begin(),A.end());
  for(int i=1;i<N;i++){
    A.at(0)=100000*(A.at(0)+A.at(i))/2*0.00001;
  }
  cout<<A.at(0)<< endl;
}



Measured memory_bytes: 256