akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

char str[200005];
char qq[200005][2];

int main(int argc, char* argv[])
{
    long n, q;
    scanf("%ld%ld\n", &n, &q);
    scanf("%s", str);

    long i;
    for(i=0; i<q; i++) {
        char str0[5]={0};
        scanf("%s", str0);
        qq[i][0]=str0[0];
        scanf("%s", str0);
        qq[i][1]=str0[0];
    }

    long curr0=0, curr1=0;
    {
        long r=n, l=-1;
        while( r-l>1 ) {
            long m=(l+r)/2;
            long curr=m;
            long fail=0;
            for(i=0; i<q; i++) {
                if(str[curr]==qq[i][0] && qq[i][1]=='R') {
                    curr++;
                    if(curr==n) {
                        break;
                    }
                }
                else if(str[curr]==qq[i][0] && qq[i][1]=='L') {
                    curr--;
                    if(curr==-1) {
                        fail=1;
                        break;
                    }
                }
            }
            if(i==q) {
                fail=1;
            }
            if( fail ) {
                l=m;
            }
            else {
                r=m;
            }
        }
        curr0 = r;
    }

    {
        long r=n, l=-1;
        while( r-l>1 ) {
            long m=(l+r)/2;
            long curr=m;
            long fail=0;
            for(i=0; i<q; i++) {
                if(str[curr]==qq[i][0] && qq[i][1]=='R') {
                    curr++;
                    if(curr==n) {
                        fail=1;
                        break;
                    }
                }
                else if(str[curr]==qq[i][0] && qq[i][1]=='L') {
                    curr--;
                    if(curr==-1) {
                        break;
                    }
                }
            }
            if(i==q) {
                fail=1;
            }
            if( fail ) {
                r=m;
            }
            else {
                l=m;
            }
        }
        curr1 = l;
    }

    printf("%ld\n", MAX(curr0-curr1-1, 0));
    return 0;
}


Measured memory_bytes: 768
def tentousu(a):
  ans=0
  for i in range(len(a)):
    for j in range(i+1,len(a)):
      if a[i]>a[j]:ans+=1
  return ans
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(1,n,2):a[i],b[i]=b[i],a[i]
ans=inf=float('inf')
for i in range(2**n):
  s=bin(i)[2:].zfill(n)
  if s.count("0")!=n//2:continue
  if s.count("1")!=n//2 and s.count("1")!=n//2+1:continue
  ac=[]
  bc=[]
  for j in range(n):
    if s[j]=="1":ac.append((a[j],j))
    else:bc.append((b[j],j))
  ac.sort()
  bc.sort()
  x=[]
  for j in range(n):
    if j%2:x.append(bc[j//2])
    else:x.append(ac[j//2])
  f=False
  for j in range(1,n):
    if x[j-1][0]>x[j][0]:f=True
  if f:continue
  m=[]
  for j in range(n):m.append(x[j][1])
  ans=min(ans,tentousu(m))
if ans==inf:ans=-1
print(ans)


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

int main()
{
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  rep(i, N)
  {
    cin >> S[i];
  }
  sort(S.begin(), S.end());
  string ans;
  rep(i, N)
  {
    ans += S[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
a,b=map(int,input().split())
c=[i for i in input()]
#print(c)
if "-" in c:
	d=0
	e=0
	for i in range(len(c)):
		if c[i] != "-":
			d=d+1
		else:
			break
	for i in range(len(c)):
		if c[-i-1] != "-":
			e=e+1
		else:
			break
	if d==a and e==b:
		print("Yes")
	else:
		print("No")
else:
	print("No")


Measured memory_bytes: 3060
def f(i, j)
  return i * i + j * j
end

loop do
  h, w = gets.chomp.split.map(&:to_i)

  if h == 0 && w == 0
    break
  end

  ans_h = 200
  ans_w = 200
  
  for i in h..150
    for j in 1..150
      if i >= j
        next
      end
      d = f(i, j)
      if d == f(h, w) && i != h && i < ans_h
        ans_h = i
        ans_w = j
      end
    end
  end

  if ans_h == 200 && ans_w == 200
    for i in 1..150
      for j in 1..150
        if i >= j
          next
        end
        d = f(i, j)
        if d > f(h, w) && (d < f(ans_h, ans_w) || (d == f(ans_h, ans_w) && i < ans_h))
          ans_h = i
          ans_w = j
        end
      end
    end
  end
  
  puts "#{ans_h} #{ans_w}"
end

Measured memory_bytes: 6116
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x;
    cin >> x;
    if(x%11<=6 && x%11!=0){
        cout << (x/11)*2+1 << endl;
    }
    else if(x%11==0){
        cout << x/11*2 << endl;
    }
    else{
        cout << (x/11)*2+2 << endl;
    }
}


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

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

using ll = long long;
using lb = long double;
using P = pair<string,string>;
using graph = vector<vector<ll>>;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll INF = 1LL<<60;
const ll mod = 1000000007LL;

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<string> v(H);
  rep(i,H) cin>>v[i];
  rep(i,W+2) cout<<'#';
  cout<<endl;
  rep(i,H){
    cout<<'#';
    cout<<v[i];
    cout<<'#'<<endl;
  }
  rep(i,W+2) cout<<'#';
  cout<<endl;
}

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

using ll = long long int;

int n;
ll s[100], t[100], l[100], r[100];

ll gcd(ll p, ll q){
    if(q==0) return p;
    else return gcd(q, p%q);
}

ll lcm(ll p, ll q){
    return p/gcd(p,q)*q;
}

ll rec(int id){
    if(id == -1) return 1;
    ll wl = rec(l[id]), wr = rec(r[id]);
    ll m = lcm(wl*s[id], wr*t[id]);
    return m/s[id]+m/t[id];
}

bool solve(){
    cin >> n;
    if(n == 0) return false;
    int cnt[100]{};
    for(int i=0;i<n;i++){
        cin >> s[i] >> t[i] >> l[i] >> r[i];
        l[i]--; r[i]--;
        if(l[i]>=0) cnt[l[i]]++;
        if(r[i]>=0) cnt[r[i]]++;
    }
    for(int i=0;i<n;i++){
        if(cnt[i]==0){
            cout << rec(i) << endl;
            break;
        }
    }
    return true;
}

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



Measured memory_bytes: 3120
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <cmath>
#include <set>
#include <bitset>
#include <limits>

using namespace std;

#define ll long long

int main(void){
    int r, g, b;

    cin >> r >> g >> b;

    int k;
    cin >> k;

    while(r >= g){
        g = g*2;
        k = k-1;
    }

    while(g >= b){
        b = b*2;
        k = k-1;
    }

    if(r < g && g < b && k > -1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
using namespace std;
int main(){
    int d,c=0,a=1,z=0;
    string s;
    cin >> s;
    if(s[0]=='A'){
        a=0;
    }
    d=s.size();
    for(int i=2;i<d-1;i++){
        if(s[i]=='C'){
            z++;
        }
    }

    for(int i=0;i<d;i++){
       if(s[i]>='a'&&s[i]<='z'){
        c++;
        }
    }
        
    if(a==0&&z==1&&c==d-2){
        cout <<"AC" << endl;
    }else{
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FASTIO ios_base::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
int A[(int)1e5][3];
bool visited[(int)1e5][3];
ll dp[(int)1e5][3];
int N;
#define Max(a,b,c) max(max(a,b),c)
ll go(int option , int day){
    if(day == N-1) return A[day][option];

    if(visited[day][option]) return dp[day][option];

    visited[day][option] = 1;

    ll ans = A[day][option];
    if(option == 0){
        ans += max(go(1,day+1) , go(2,day+1));
    }
    else  if(option == 1){
        ans += max(go(0,day+1) , go(2,day+1));
    }
    else{
         ans += max(go(0,day+1) , go(1,day+1));
    }
    dp[day][option] = ans;
    return ans;
}
int main(){
    FASTIO;
    cin>>N;
    for(int i = 0; i< N; i++){
        cin>>A[i][0]>>A[i][1]>>A[i][2];
    }
    ll max_happiness = Max(go(0,0) , go(1,0), go(2,0));
    cout<<max_happiness;
}


Measured memory_bytes: 8704
# coding: utf8

from functools import reduce

def gcda(x, y):
    while y:
        x, y = y, x % y
    return x

def gcd(*numbers):
    return reduce(gcda, numbers)


def read_int_n():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n, x = read_int_n()
    y = read_int_n()
    y.append(x)

    y.sort()
    w = [y[i] - y[i-1] for i in range(1, len(y))]
    print(gcd(*w))


Measured memory_bytes: 14748
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#include <vector>
#include <iostream>
#include <string.h>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <string>
using namespace std;

typedef double LD;
typedef long long LL;
typedef pair<int, int> PII;
#define MP make_pair
#define PB push_back
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LL MOD = 1000000007;
const int INF = 1e9;
const LL LINF = 1LL * INF * INF;
const int MAXN = 3007;
const LD EPS = 1e-7;

int A[MAXN];
vector <int> G[MAXN];
bool used[MAXN], W[MAXN];

void dfs(int v)
{
	used[v] = true;
	REP(i, SZ(G[v]))
	{
		int to = G[v][i];
		if (!used[to])
		{
			dfs(to);
			if (A[to] < A[v] && !W[to])
				W[v] = true;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	int n;
	cin >> n;
	REP(i, n)
		cin >> A[i];
	REP(i, n - 1)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	REP(i, n)
	{
		memset(used, 0, MAXN);
		dfs(i);
		if (W[i])
			cout << i + 1 << ' ';
	}
	//cout << endl; system("pause");
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=1e5+2;

int main()
{
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    cout<<(n>=30?"Yes":"No");


    
}

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

using namespace std;

int main() {

    int N;

    cin>>N;

    vector<int> dollars;

    for(int i=0; i<N; i++) {
        int temp;
        cin>>temp;
        dollars.push_back(temp);
    }

    float y = 0.0; 
    int ans = 0;
    y = accumulate(dollars.begin(), dollars.end(), y) / dollars.size();
    y = round(y);

    for(int x: dollars) {
        ans += pow(x - y, 2);

    }

    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10000000)
MOD = 1001
INF = 10 ** 15

class UnionFind():
    def __init__(self,n):
        self.n = n
        self.parents = [-1]*n

    def find(self,x): #根を見つける、繋ぎ直す
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    
    def unite(self,x,y): #x,yの含むグループを併合する
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return
        
        if self.parents[x] > self.parents[y]:
            x,y = y,x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def same(self,x,y):#xとyが同じグループにいるか判定
        return self.find(x) == self.find(y)
    
    def members(self,x):#xと同じグループのメンバーを列挙
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    
    def size(self,x):#xが属するグループのメンバーの数
        return -self.parents[self.find(x)]
    
    def roots(self):#ufの根を列挙
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):#グループの数を数える
        return len(self.roots())

def solve(V,d,fib):
    uf  = UnionFind(V)
    for i in range(V):
        for j in range(i + 1,V):
            if abs(fib[i] - fib[j]) < d:
                uf.unite(i,j)
    ans = uf.group_count()
    print(ans)

def main():
    fib = [0] * 1005
    fib[0] = 2; fib[1] = 3
    for i in range(2,1005):
        fib[i] = fib[i - 1] + fib[i - 2]
        fib[i] %= MOD
    
    while True:
        try:
            V,d = map(int,input().split())
            solve(V,d,fib)
        except:
            return
if __name__ == '__main__':
    main()


Measured memory_bytes: 5628
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  //b
  int a[3][3];
  for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) cin >> a[i][j];
  int res[3][3] = {};
  int n;
  cin >> n;
  while (n--) {
    int b;
    cin >> b;
    for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++) if (a[i][j] == b) res[i][j] = 1;
  }
  bool ok = false;
  for (int i = 0; i < 3; i++) {
    bool f = true;
    for (int j = 0; j < 3; j++) f &= res[i][j];
    ok |= f;
  }
  for (int i = 0; i < 3; i++) {
    bool f = true;
    for (int j = 0; j < 3; j++) f &= res[j][i];
    ok |= f;
  }
  ok |= (res[0][0] && res[1][1] && res[2][2]);
  ok |= (res[0][2] && res[1][1] && res[2][0]);
  cout << (ok ? "Yes\n" : "No\n");
  return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N; ll A[int(1e5+5)];
vector <Pll> ans;

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

  ll M = 0;
  if (A[N-1] < 0){
    M = A[N-1];
    for (int i = 0; i < N - 1; i++){
      ans.push_back({M, A[i]});
      M -= A[i];
    }
  }else if (A[0] > 0){
    M = A[0];
    for (int i = 1; i < N - 1; i++){
      ans.push_back({M, A[i]});
      M -= A[i];
    }
    ans.push_back({A[N-1], M});
    M = A[N-1] - M;
  }else{
    M = A[0];
    for (int i = 1; i < N - 1; i++){
      if (A[i] < 0){
        ans.push_back({A[N-1], A[i]});
        A[N-1] -= A[i];
      }else{
        ans.push_back({M, A[i]});
        M -= A[i];
      }
    }
    ans.push_back({A[N-1], M});
    M = A[N - 1] - M;

  }

  cout << M << endl;
  for (int i = 0; i < N - 1; i++){
    cout << ans[i].fi << " " << ans[i].se << endl;
  }

  return 0;
}


Measured memory_bytes: 6136
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n,x,t = map(int,input().split())
    a = n//x
    if n%x != 0:
        a+=1
    print(a*t)

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

int divide_2(int number, int count){
    if(number % 2 == 0){
        return divide_2(number/2, count+1);
    }else{
        return count;
    }
}

int main(){

    int N;

    cin >> N;

    int a[N];

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

    int total = 0;

    for(int i=0; i<N; i++){
        total = divide_2(a[i], total);
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 256
import copy
h,w,k=[int(i) for i in input().split()]
c=[]
for i in range(h):
    c.append(list(input()))

def x(i,j,c):
    r=0
    if i<h:
        r+=x(i+1,j,copy.deepcopy(c))
        _c=copy.deepcopy(c)
        _c[i]=["r" for a in range(w)]
        r+=x(i+1,j,_c)
    elif j<w:
        r+=x(i,j+1,copy.deepcopy(c))
        _c=copy.deepcopy(c)
        for a in range(h):
            _c[a][j]="r"
        r+=x(i,j+1,_c)
    else:
        count=0
        for a in range(h):
            for b in range(w):
                if c[a][b]=="#":
                    count+=1
        if count==k:
            r=1
    return r
print(x(0,0,c))


Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
using namespace std;
// 型シノニム
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
// 定数
constexpr ll INF   = 1e16;
constexpr ll INM   = 114514;
constexpr ll MOD   = 1e9 + 7;
constexpr ld EPS   = 1e-12;
constexpr ll dx[4] = {1, 0, -1, 0};
constexpr ll dy[4] = {0, 1, 0, -1};
// 便利関数
void IOS() { ios::sync_with_stdio(false), cin.tie(0); }
template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <class T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T>
bool chmin(T &a, const T &b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll mod) {
	if (a > 0) return a % mod;
	if (a % mod == 0) return 0;
	ll x = -a / mod + 1;
	a += x * mod;
	return a % mod;
}
ll powm(ll a, ll b, ll m) {
	if (b == 0) {
		return 1;
	} else if (b % 2 == 0) {
		ll d = powm(a, b / 2, m);
		return (d * d) % m;
	} else {
		return (powm(a, b - 1, m) * a) % m;
	}
}

// 本体
char g[7][7];
char ng[7][7];
int main() {
	IOS();
	ll h, w, k;
	cin >> h >> w >> k;
	for (int i = 0; i < h;i++) {
		for (int j = 0; j < w;j++) {
			cin >> g[i][j];
		}
	}
	ll ans = 0;
	for (int i = 0; i < (1 << h);i++) {
		for (int j = 0; j < (1 << w);j++) {
			for (int i2 = 0; i2 < h;i2++) {
				if((i >> i2) & 1){
					for (int j2 = 0; j2 < w;j2++) {
						ng[i2][j2] = 'r';
					}
				}else {
					for (int j2 = 0; j2 < w;j2++) {
						ng[i2][j2] = g[i2][j2];
					}
				}
			}
			for (int j2 = 0; j2 < w;j2++) {
				if((j >> j2) & 1){
					for (int i2 = 0; i2 < h;i2++) {
						ng[i2][j2] = 'r';
					}
				}
			}
			ll cnt = 0;
			for (int i2 = 0; i2 < h;i2++) {
				for (int j2 = 0; j2 < w;j2++) {
					if (ng[i2][j2] == '#') cnt++;
				}
			}
			if (cnt == k) ans++;
		}
	}
	dump(ans);
}


Measured memory_bytes: 3652
# 高橋君の夏休みが N 日間
# 夏休みの宿題が M個出されており、i 番目の宿題をやるには　A i日間かかる
# 条件　複数の宿題を同じ日にはできない。
# また宿題をやる日は遊べない。
# 夏休み中に全ての宿題を終わらせるとき、最大何日遊ぶことができるか。
# 終わらない時は-1

N, M = map(int, input().split())
A = list(map(int, input().split()))

# 宿題にかかる合計日数
play_day = N - sum(A)

if play_day < 0:
    print("-1")
else:
    print(play_day)

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

bool g[1000][1000];
bool visited[1000];

vector<int> extract_cycle(vector<int>& path) {
	if (path.size() <= 1) {
		return vector<int>();
	}

	int v = path[path.size() - 1];
	for (int i = path.size() - 2; i >= 0; --i) {
		if (g[v][path[i]]) {
			vector<int> cycle(path.size() - i);
			copy(path.begin() + i, path.end(), cycle.begin());

			return cycle;
		}
	}

	return vector<int>();
}

vector<int> find_cycle(int n, int start, vector<int>& path) {
	visited[start] = true;
	path.push_back(start);

	vector<int> cycle = extract_cycle(path);
	if (!cycle.empty()) {
		return cycle;
	}
	
	for (int dest = 0; dest < n; ++dest) {
		if (g[start][dest] && !visited[dest]) {
			vector<int> cycle = find_cycle(n, dest, path);
			if (!cycle.empty()) {
				return cycle;
			}
		}
	}

	path.pop_back();

	return vector<int>();
}

int main() {
	memset(g, false, sizeof(g));

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; ++i) {
		int a, b;
		cin >> a >> b;
		g[a - 1][b - 1] = true;
	}

	vector<int> res;

	for (int i = 0; i < n; ++i) {
		memset(visited, false, sizeof(visited));
		vector<int> p;
		vector<int> cycle = find_cycle(n, i, p);

		if (!cycle.empty()) {
			res = cycle;
		}
	}

	if (res.empty()) {
		cout << -1;
		return 0;
	}

	cout << res.size() << endl;
	for (int c : res) {
		cout << c + 1 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 1408
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const int MOD = 1000000007;
const ll INF=2e18;
const int MAX = 20000;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll N,M,K,C;
ll a,b,c,d;
string s;
int main(){
    COMinit();
    cin>>N>>K;
    ll ans=0;
    for(int i=1;i<=K;i++){
        ll tmp=COM(N-K+1,i);
        //cout<<tmp<<endl;
        tmp*=COM(K-1,i-1)%MOD;
        cout<< tmp%MOD<<endl;
    }
    
    return 0;
}


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

static const int N = 100;

int main(){
    int n, p[N + 1], m[N + 1][N + 1];
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> p[i - 1] >> p[i];
    }
    for(int i = 1; i <= n; i++){
        m[i][i] = 0;
    }
    for(int l = 2; l <= n; l++){
        for(int i = 1; i <= n - l + 1; i++){
            int j = i + l - 1;
            m[i][j] = (1 << 21);
            for(int k = i; k <= j - 1; k++){
                m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
            }
        }
    }
    cout << m[1][n] << endl;
    
    return 0;
}


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

int main() {
  int N, K, S = 1;
  cin >> N;
  cin >> K;
  
  for (int i = 0; i < N; i++) {
    if (S > K) {
      S += K;
    }else{
      S *= 2;
    }
  }
  cout << S << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)


 int main(){
     double K,maxDist;
     long N;
     double A[200100];
     cin >>K >> N;

     rep(i,N) cin >> A[i];
     A[N]=A[0]+K;
     maxDist = 0;

     rep(i,N+1){
         if(A[i+1]-A[i] > maxDist){
             maxDist = A[i+1]-A[i];
         }
     }
     cout << K-maxDist << endl;
     return 0;
 }


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string.h>
#define rep(i, n) for(int i = 0; i<(n); i++)
using namespace std;
typedef long long ll;
static const int MAX = 200000; 
//pi = 3.14159265358979323846

int main() {

    int a, b, x, y;
    cin >> a >> b >> x >> y;
    printf("%lf %d\n", double(a) * double(b) / 2, x + x == a && y + y == b);

}




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

int main(){
  int N;
  cin >> N;
  int a[N];
  for(int i=0;i<N;i++){
    cin >> a[i];
  }
  int ans=-1;
  for(int i=-100;i<=100;i++){
    int c=0;
    for(int j=0;j<N;j++){
      c+=(i-a[j])*(i-a[j]);
    }
    ans=ans!=-1?min(ans,c):c;
  }
  cout << ans << endl;
}

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

#define MOD (1000000007ULL)

using namespace std;

int main(void){
    int N;
    cin >> N;
    vector<unsigned long long> A(N);
    vector<unsigned long long> bc(60, 0);
    for(int i = 0; i < N; i++){
        cin >> A[i];
        unsigned long long B = A[i];
        for(int j = 0; B > 0; j++){
            if(B % 2 == 1) bc[j]++;
            B /= 2;
        }
    }
    
    unsigned long long ans = 0;
    for(int i = 0; i < N; i++){
        unsigned long long d = 1;
        for(int j = 0; j < 60; j++){
            if(A[i] & d){
                // unsigned long long c = ((d % MOD) * (N - bc[j] - 1)) % MOD;
                // ans += c;
                // ans %= MOD;
            }else{
                unsigned long long c = ((d % MOD) * bc[j]) % MOD;
                ans += c;
                ans %= MOD;
            }
            d *= 2;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 2560
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val N = sc.nextInt
    val xu = Array.fill(N)(sc.next, sc.next)

    xu.map {
      case (x, "JPY") => x.toInt
      case (x, _) => x.toDouble * 380000
    }.sum.toString
  }
}


Measured memory_bytes: 25756
#include<iostream>
#include<set>
#include <bitset>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include <cstdio>
#include<algorithm>
#include <sstream>
#include<string>
#include<string.h>
#include <cmath>
#include <iomanip>
#include <string>
#include<list>
#include <limits>
#include <numeric>
#include <type_traits>
#define int long long
#define ll long long
#define mod  1000000007
#define inf 1e17
#define rep(i,j,n) for(int i=j;i<n;i++)
#define P pair<int,int>
#define ps push_back
double pi = 3.141592653589793;
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
//ここから始めよう
int p[214514],q[214514],c[214151];
vector<P> G[614514];
int lastid=0;
map<P,int> sid;
int getid(int v,int c){
    P p(v,c);
    if(sid.find(p)!=sid.end())return sid[p];
    return sid[p]=lastid++;
}
void addedge(int p,int q,int c){
    int v=getid(p,c);int u=getid(q,c);
    G[v].ps(P(u,0));
    G[u].ps(P(v,0));
}
signed main(){
    int n,m;cin>>n>>m;
    rep(i,0,m){
        cin>>p[i]>>q[i]>>c[i];
        p[i]--;q[i]--;
        addedge(p[i],q[i],c[i]);
    }
    rep(i,0,m){
        G[getid(p[i],c[i])].ps(P(lastid+p[i],1));
        G[getid(q[i],c[i])].ps(P(lastid+q[i],1));
        G[lastid+p[i]].ps(P(getid(p[i],c[i]),1));
        G[lastid+q[i]].ps(P(getid(q[i],c[i]),1));
    }
    vector<int> d(lastid+n,mod);d[lastid]=0;
    priority_queue<P> que;
    que.push(P(0,lastid));
    while(!que.empty()){
        auto p=que.top();que.pop();
        int u=p.second,dist=-p.first;
        if(dist>d[u])continue;
        for(auto e:G[u]){
            int v=e.first,c=e.second;
            if(d[v]>d[u]+c){
                d[v]=d[u]+c;
                que.push(P(-d[v],v));
            }
        }
    }int ans=d[lastid+n-1];
    if(ans==mod)ans=-1;
    else ans/=2;
    cout<<ans<<endl;return 0;
}

Measured memory_bytes: 82544
let rec for_fold a b v f = if a >= b then v else for_fold (a+1) b (f v a) f
let () =
  Scanf.scanf "%d %d" @@ fun n m ->
  let a = Array.init n (fun _ -> Array.init m (fun _ -> Scanf.scanf " %d" pred)) in
  let held = Array.make m true in
  for_fold 0 m n (fun c _ ->
    let counts = Array.make m 0 in
    for i = 0 to n-1 do
      let k = for_fold 0 m (-1) (fun k j ->
        if k >= 0 then k
        else if held.(a.(i).(j)) then a.(i).(j) else -1) in
      counts.(k) <- counts.(k) + 1;
    done;
    let k = for_fold 0 m 0 (fun k i ->
      if not held.(k) then i
      else if not held.(i) then k
      else if counts.(k) > counts.(i) then k else i)
    in
    held.(k) <- false;
    min c counts.(k)
  ) |> Printf.printf "%d\n"

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

int main(){
  int n;
  cin >> n;
  int h[100];
  int max;
  cin >> max;
  int ct = 1;
  for(int i=1;i<n;i++){
    cin >> h[i];
    if(h[i]>=max){
      ct++;
      max = h[i];
    }
  }
  cout << ct << endl;


}


Measured memory_bytes: 256
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	ll h;
	cin >> h;
	ll ans = 0LL;
	ll cnt = 0LL;
	ll sub = 1LL;
	while(h>=1LL){
		ans += sub;
		sub *= 2;
		h /= 2;
	}
	cout << ans << '\n';
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int ans=1;
  for(int i=1;i<N;i++){
    if(i*i<=N&&(i+1)*(i+1)>N){
      ans=i;
      break;
    }
  }
  cout<<ans*ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k;
int ans;
int main(){
	scanf("%d%d",&n,&k);
	if(k==1){
		printf("0\n");
		return 0;
	}
	ans=n-k+1;
	printf("%d\n",ans-1);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> a(q), p(n, k);
  rep(i, q){
    cin >> a.at(i);
    p.at(a.at(i)-1)++;
  }
  rep(i, n) {
    if(p.at(i) <= q) cout << "No" << endl;
    else cout << "Yes" << endl;
  }
}


Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
struct Point { ld a; ld b; ld c; };
struct Line { Point x; Point y; };
bool eq(ld a, ld b) {
	return(abs(a - b) < eps);
}
ld norm(Point x,Point y) {
	return sqrt(pow(y.a-x.a,2) + pow(y.b-x.b,2) + pow(y.c-x.c,2));
}
Point dif(Point x, Point y) {
	return Point{ y.a - x.a,y.b - x.b,y.c - x.c };
}
ld proi(Line l,Line m) {
	Point a = dif(l.x,l.y);
	Point b = dif(m.x, m.y);
	return a.a*b.a + a.b*b.b + a.c*b.c;
}
Point dra(Point a, Point b, Point c) {
	Point res;
	ld h = proi({ a,b }, { a,c })/norm(a,b);
	res = Point{ h*(b.a - a.a) / norm(a,b) + a.a,h*(b.b - a.b) / norm(a,b) + a.b,h*(b.c - a.c) / norm(a,b) + a.c };
	if (eq(proi({ a,res }, { c,res }), 0)) {
		return res;
	}
	res = Point{ (h)*(a.a - b.a) / norm(a,b) + a.a,((h)*(a.b - b.b) / norm(a.b) + a.b),((h)*(a.c - b.c) / norm(a,b) + a.c) };
	cout<< res.a << " " << res.b << " " << res.c << endl;
	return res;
}
bool across(Line l, Point x,ld r) {
	Point w =dra(l.x, l.y, x);
	bool f = false; bool g = false;
	if (eq(norm(l.x, w) + norm(w, l.y), norm(l.x, l.y))) {
		f = true;
	}
	if (norm(w, x) < r + eps) {
		g = true;
	}
	if (f&&g)return true;
	else return false;
}
int main() {
	int n, q;
	cin >> n >> q;
	Point a[50]; ld r[50]; ll cost[50];
	rep(i, n) {
		ld x, y, z;
		cin >> x >> y >> z >> r[i] >> cost[i];
		a[i] = { x,y,z };
	}
	rep(i, q) {
		ld x, y, z,x1,y1,z1;
		cin >> x >> y >> z;
		Point s = { x,y,z };
		cin >> x1 >> y1 >> z1;
		Point t = { x1,y1,z1 };
		Line l = { s,t };
		ll sum = 0;
		rep(j, n) {
			if (across(l, a[j], r[j])) {
				sum += cost[j];
			}
		}
		cout << sum << endl;
	}
	return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long double LD; 
typedef long long ll; 
#define int ll 
#define ff(i,a,b) for (int i = a; i < b; i++) 
#define bf(i,a,b) for (int i = a; i >= b; i--) 
#define all(v) v.begin(),v.end() 
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define F first 
#define S second
#define pb push_back
#define mp make_pair
#define lb lower_bound   
#define ub upper_bound
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define one cout<<"-1"<<endl
#define pi 3.141592653589793238
#define intmx INT_MAX 
#define intmi INT_MIN
const int MOD=1e9+7;
int mod(int x){
    return ((x%MOD + MOD)%MOD);
}
int add(int a,int b){
    return mod(mod(a)+mod(b));
}
int mul(int a,int b){
    return mod(mod(a)*mod(b));
}
void solve(){
   int n;
   cin>>n;
   string s;
   cin>>s;
   int cnt=0;
   ff(i,0,s.size()){
       if(s[i]=='W')
       cnt++;
   }
   int j=s.size()-1;
   int ans=0;
   while(cnt){
       if(s[j]=='R'){
           ans++;
       }
       cnt--;
       j--;
   }
   cout<<ans<<endl;
}
signed main() {
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

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

using namespace std;
using ll = long long;
int main() {
    char c;
    cin>>c;
    if(c == 'A') cout << 'T' << endl;
    else if(c == 'T') cout << 'A' <<endl;
    else if(c== 'C') cout << 'G' <<endl;
    else cout << 'C' <<endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
 
using namespace std;
 
 
int main() {
	int a, b, c;
	cin >> a;
	if (a == 1) {
		cout << "Hello World" << endl;
	}
	else {
		cin >> b>>c;
		cout<<b + c << endl;
	}
 
 
 
	return 0;
}

Measured memory_bytes: 256
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
# def LF(): return [float(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n,k=LI()
  s=S()
  ans=0
  x=s[0]
  cnt=0
  for y in s[1:]:
    if x==y:
      cnt+=1
    else:
      ans+=cnt
      cnt=0
    x=y
  ans+=cnt

  ans=min(n-1,ans+2*k)

  return ans

# main()
print(main())


Measured memory_bytes: 10820
#include <bits/stdc++.h>
#define ll long long
#define ar array
#define nl '\n'
#define AC ios_base::sync_with_stdio(0); cin.tie(NULL);
using namespace std;
const int M = 1e9+7;
const int N = 2*1e5;


int main(){
    AC
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    int turn = 1;
    while(a>0 && c>0){
        if(turn){
            c-=b;
            turn=0;
        }
        else{
            a-=d;
            turn=1;
        }
    }
    if(a>0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
}

Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
	public static void Main()
	{
		var n = int.Parse(ReadLine());
		var a = ReadLine().Split().Select(int.Parse).ToArray();
		var b = new int[100000];
		for(int i = 0; i < n; i++)
		{
			b[a[i]]++;
		}
		var max = 0;
		for(int i = 2; i < 100000; i++)
		{
			max = Max(max, b[i - 2] + b[i - 1] + b[i]);
		}
		WriteLine(max);
	}
}


Measured memory_bytes: 26884
import sys
#import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

#最小値と最大値の絶対値がどちらが大きいか
N = ir()
A = lr()
if abs(max(A)) >= abs(min(A)):
    i = A.index(max(A))
    print(2*(N-1))
    print(i+1, 2)
    print(i+1, 2)
    for i in range(2, N):
        print(i, i+1)
        print(i, i+1)
else:
    i = A.index(min(A))
    print(2*(N-1))
    print(i+1, N-1)
    print(i+1, N-1)
    for i in range(2, N):
        print(N-i+1, N-i)
        print(N-i+1, N-i)

# 50

Measured memory_bytes: 3064
'''
Created on 2020/08/29

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  S=pin()[:-1]
  T=pin()[:-1]
  t=len(T)
  ans=len(T)
  for i in range(len(S)-t+1):
    u=S[i:i+t]
    cnt=0
    for j in range(t):
      if u[j]!=T[j]:
        cnt+=1
    ans=min(ans,cnt)
  print(ans)
  return 
main()

Measured memory_bytes: 9124
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
long long a[100000];
int main()
{
	int n;
	scanf("%ld",&n);
	a[0] = 2;
	a[1] = 1;
	for(int i = 2; i <= n; i++)
	{
		a[i]=a[i-1]+a[i-2];
	}
	printf("%lld\n",a[n]);
	return 0;
}

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

int h,w;
int di[4]={1,0,-1,0},dj[4]={0,1,0,-1};
char g[55][55];
bool ans=true;
void p(int i,int j,bool d);

int main(void){
  int i,j;
  cin >> h >> w;
  for (i=0;i<h;i++) for (j=0;j<w;j++) cin >> g[i][j];
  for (i=0;i<h&&ans;i++) for (j=0;j<w&&ans;j++) if (g[i][j]=='#') p(i,j,true);
  if (ans) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

void p(int i,int j,bool d){
  if (!ans) return;
  int ni,nj,count=0;
  g[i][j]='.';
  for (int k=0;k<4;k++){
    ni=i+di[k];
    nj=j+dj[k];
    if (ni>=0&&ni<h&&nj>=0&&nj<w&&g[ni][nj]=='#') p(ni,nj,false);
    else if (d) count++;
  }
  if (count==4) ans=false;
  return;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {

    Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {

        int n = sc.nextInt();
        int one = 0;
        int two = 0;
        int three = 0;

        double[][][] dp = new double[n+2][n+2][n+2];

        for (int i=0; i<n; i++) {
            int t = sc.nextInt();
            if (t == 1) one++;
            if (t == 2) two++;
            if (t == 3) three++;
        }

        for (int i=0; i<=n; i++) {
            for (int j=0; j<=n; j++) {
                for (int k=0; k<=n; k++) {
                    if (i == 0 && j == 0 && k == 0) continue;
                    double sum = i + j + k, p = n / sum;
                    if (0 < k) dp[k][j][i] += dp[k-1][j][i] * k / sum;
                    if (0 < j) dp[k][j][i] += dp[k+1][j-1][i] * j / sum;
                    if (0 < i) dp[k][j][i] += dp[k][j+1][i-1] * i / sum;
                    dp[k][j][i] += p;
//                    dp[i][j][k] += n;
//                    dp[i][j][k] /= (double) (i + j + k);
                }
            }
        }

//        for (int i=0; i<=n; i++) {
//            for (int j=0; j<n; j++) {
//                for (int k=0; k<n; k++) {
//                    if (i == 0 && j == 0 && k == 0) continue;
//                    double sum = i + j + k, p = n / sum;
//                    if (0 < i) dp[i][j][k] += dp[i-1][j+1][k] * i / sum;
//                    if (0 < j) dp[i][j][k] += dp[i][j-1][k+1] * j / sum;
//                    if (0 < k) dp[i][j][k] += dp[i][j][k-1] * k / sum;
//                    dp[i][j][k] += p;
//                }
//            }
//        }




//        System.out.println(res);

//        System.out.println(dp[three][two][one]);
        System.out.println(dp[one][two][three]);



    }

}



Measured memory_bytes: 305744
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

string as,bs,cs;
int al,bl,cl;
int at=-1,bt=-1,ct=-1;
char flag='a';

inline void solve(){
    for( ; ; ){
        if(at>=al){
            puts("A");
            break;
        }
        if(bt>=bl){
            puts("B");
            break;
        }
        if(ct>=cl){
            puts("C");
            break;
        }
        if(flag=='a'){
            at++;
            flag=as[at];
        }
        if(flag=='b'){
            bt++;
            flag=bs[bt];
        }
        if(flag=='c'){
            ct++;
            flag=cs[ct];
        }
    }
}

int main(){
    cin>>as>>bs>>cs;
    al=as.size();
    bl=bs.size();
    cl=cs.size();
    solve();
    return 0;
}

Measured memory_bytes: 764
using System;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] oppai = Console.ReadLine().Split(' ');
            int a = int.Parse(oppai[0]);
            int b = int.Parse(oppai[1]);
            if (a < b)
            {
                Console.WriteLine("a < b");
            }
            else
            {
                if (a > b)
                {
                    Console.WriteLine("a > b");
                }
                else
                {
                    Console.WriteLine("a == b");
                }
            }
        }
    }
}

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

int digitSum(int n)
{
    if(n < 10) 
    { 
        return n; 
    }
    return digitSum(n / 10) + n % 10; 
}


int main()
{
    int n, a, b, tmp, res = 0;
    cin >> n >> a >> b;

    for(int i = 1; i <= n; ++i)
    {
        tmp = digitSum(i);
        if(tmp >= a && tmp <= b)
        {
            res += i;
        }
    }

    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var (H, W) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var a = Enumerable.Range(0, H).Select(i => ReadLine().Split(' ').Select(int.Parse).ToArray()).ToArray();

        var moveList = new List<((int y, int x) from, (int y, int x) to)>();

        void MoveAWhenFromAIsOdd((int y, int x) from, (int y, int x) to)
        {
            if (a[from.y][from.x] % 2 == 1)
            {
                a[from.y][from.x]--;
                a[to.y][to.x]++;

                moveList.Add((from, to));
            }
        }

        for (int i = 0; i < H; i++)
        {
            if(i % 2 == 0)
            {
                for (int j = 0; j < W; j++)
                {
                    if(j < W - 1)
                        MoveAWhenFromAIsOdd((i, j), (i, j + 1));
                    else if (i < H - 1)
                        MoveAWhenFromAIsOdd((i, j), (i + 1, j));
                }
            }
            else
            {
                for (int j = W - 1; j >= 0; j--)
                {
                    if(0 < j)
                        MoveAWhenFromAIsOdd((i, j), (i, j - 1));
                    else if (i < H - 1)
                        MoveAWhenFromAIsOdd((i, j), (i + 1, j));
                }
            }
        }

        WriteLine(moveList.Count);
        foreach (var (from, to) in moveList)
            WriteLine($"{from.y + 1} {from.x + 1} {to.y + 1} {to.x + 1}");
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


Measured memory_bytes: 52448
import java.util.*;
public class Main
{
	static	double EPS=1e-2;
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		for(;;)
		{
			Point p1=new Point(in.nextDouble(), in.nextDouble()); 
			Point p2=new Point(in.nextDouble(), in.nextDouble()); 
			if(p1.x==0&&p1.y==0&&p2.x==0&&p2.y==0)
				return;
			Point p3=new Point(in.nextDouble(), in.nextDouble()); 
			Point p4=new Point(in.nextDouble(), in.nextDouble()); 
			Point p5=new Point(in.nextDouble(), in.nextDouble()); 
			Point p6=new Point(in.nextDouble(), in.nextDouble());
			boolean judge=true;
			if(!lineCross(p1, p2, p3, p4))
				judge=false;
			if(!lineCross(p3, p4, p5, p6))
				judge=false;
			if(!lineCross(p5, p6, p1, p2))
				judge=false;

			if(judge)
			{
				double a1=slanting(p1, p2);
				double a2=slanting(p3, p4);
				double x1=(a1*p1.x-p1.y-a2*p3.x+p3.y)/(a1-a2);
				if(a1==-1.123)
					x1=p1.x;
				else if(a2==-1.123)
					x1=p3.x;
				double y1=(p2.y-p1.y)/(p2.x-p1.x)*(x1-p1.x)+p1.y;
				if(a1==-1.123)
					y1=(p4.y-p3.y)/(p4.x-p3.x)*(x1-p3.x)+p3.y;

				a1=slanting(p3, p4);
				a2=slanting(p5, p6);
				double x2=(a1*p3.x-p3.y-a2*p5.x+p5.y)/(a1-a2);
				if(a1==-1.123)
					x2=p3.x;
				else if(a2==-1.123)
					x2=p5.x;
				double y2=(p4.y-p3.y)/(p4.x-p3.x)*(x2-p3.x)+p3.y;
				if(a1==-1.123)
					y2=(p5.y-p6.y)/(p5.x-p6.x)*(x2-p5.x)+p5.y;

				a1=slanting(p5, p6);
				a2=slanting(p1, p2);
				double x3=(a1*p5.x-p5.y-a2*p1.x+p1.y)/(a1-a2);
				if(a1==-1.123)
					x3=p5.x;
				else if(a2==-1.123)
					x3=p1.x;
				double y3=(p6.y-p5.y)/(p6.x-p5.x)*(x3-p5.x)+p5.y;
				if(a1==-1.123)
					y3=(p2.y-p1.y)/(p2.x-p1.x)*(x3-p1.x)+p1.y;

				double a=x2-x1;
				double b=y2-y1;
				double c=x3-x1;
				double d=y3-y1;
				double S=Math.abs(a*d-b*c)/2;
				if(S<EPS)
					System.out.println("kyo");
				else if(S<100000)
					System.out.println("syo-kichi");
				else if(S<1000000)
					System.out.println("kichi");
				else if(S<1900000)
					System.out.println("chu-kichi");
				else 
					System.out.println("dai-kichi");			
			}
			else
				System.out.println("kyo");
		}
	}

	static boolean lineCross(Point p1,Point p2,Point p3,Point p4)
	{
		double jc1=(p1.x-p2.x)*(p3.y-p1.y)+(p1.y-p2.y)*(p1.x-p3.x);
		double jd1=(p1.x-p2.x)*(p4.y-p1.y)+(p1.y-p2.y)*(p1.x-p4.x);
		double jc2=(p3.x-p4.x)*(p1.y-p3.y)+(p3.y-p4.y)*(p3.x-p1.x);
		double jd2=(p3.x-p4.x)*(p2.y-p3.y)+(p3.y-p4.y)*(p3.x-p2.x);
		return jc1*jd1<=0 && jc2*jd2<=0;
	}

	static double slanting(Point p1,Point p2)
	{
		if(Math.abs(p1.x-p2.x)<EPS)
			return -1.123;
		else
			return (p1.y-p2.y)/(p1.x-p2.x);
	}
}
class Point
{
	double x;
	double y;
	Point(double x,double y)
	{
		this.x=x;
		this.y=y;
	}
}

Measured memory_bytes: 23164