akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
int cmpfunc (const void * a, const void * b) {
   return ( *(int*)a - *(int*)b );
}


int main(void){
        int i,j,a[50],n,b[50],k=0,t=0,s=0;

        scanf("%d",&n);

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

        qsort(b, n, sizeof(int), cmpfunc);

        for(i=0;i<n;i++){
            if(b[i]!=a[i]){
                s++;
            }
        }

        if(s==0 || s==2){
            printf("YES");
        }
        else{
            printf("NO");
        }

        return 0;
}


Measured memory_bytes: 1688
from collections import deque
#入力
h,w = map(int, input().split())
w = w + 2
maze = [list('#' * (w))]
for i in range(h):
    maze.append(list('#' + input() + '#')) #迷路の読み込み
maze.append(list('#' * (w)))
h = h + 2
                
distance = [[float('inf')] * w for i in range(h)] #まずは無限大の距離と仮定

que = deque() #座標と距離を保存
que.append((1,1,0)) #スタートの座標と距離を入力

move = [(1,0),(-1,0),(0,1),(0,-1)]

while que:
    i,j,k = que.popleft() #先頭を取得
    for di,dj in move:
        if maze[i+di][j+dj] == '.' and distance[i+di][j+dj] > k+1:
            #迷路の道で，今までの距離が今出した距離より長いなら
            distance[i+di][j+dj] = k+1 #より短い今の距離に更新し
            que.append((i+di,j+dj,k+1)) #queの末尾に追加

#初期の道のカウント
road = 0
for i in range(h):
    for j in range(w):
        if maze[i][j] == '.':
            road = road + 1

if distance[h-2][w-2] != float('inf'):
    minimum_distance = distance[h-2][w-2]
else:
    minimum_distance = road

print(road - minimum_distance - 1)

Measured memory_bytes: 3316
using System;


namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            int n=0;
            String[] s = Console.ReadLine().Split(' ');
            int a = int.Parse(s[0]);
            int b = int.Parse(s[1]);
            int c = int.Parse(s[2]);

            while (true)
            {
                if (c % a == 0)
                {
                    n++;
                }
                if (a == b) break;
                a++;
            }

            Console.WriteLine(n);
        }
    }
}

Measured memory_bytes: 9204
X,K,D=map(int,input().split())
zettaitix = abs(X)
if zettaitix >= K*D:
    kotae = abs(zettaitix-(K*D))
elif zettaitix < K*D:
    kai, mod = divmod(zettaitix, D)
    ds = kai*D
    if (K-kai)%2==0:
        kotae = abs(zettaitix-ds)
    elif (K-kai)%2!=0:
        kotae = abs(zettaitix-ds-D)
print(kotae)

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

int main(){
  int N,W;
  cin >> N >> W;
  vector<vector<ll>> M(N+1,vector<ll>(W+1,0));
  ll w,v;
  for(int i=1;i<=N;i++){
    cin >> w >> v;
    for(int j=0;j<=W;j++){
      if(0<=j-w){
        M[i][j]=max(M[i-1][j-w]+v,M[i-1][j]);
      }else{
        M[i][j]=M[i-1][j];
      }
    }
  }
  cout << M[N][W] << endl;
}

Measured memory_bytes: 80256
# coding: utf-8
import time
import re
import math
import fractions
 
def main():
    A,B,C,D=map(int,input().split())
    N=B-A+1
    sc=hoge(A,C)-A+1
    if sc<=N:
        ccount=(N+C-sc)//C
    else:
       ccount=0
 
    sd=hoge(A,D)-A+1
    if sd<=N:
        dcount=(N+D-sd)//D
    else:
       dcount=0
 
    CD=C * D // fractions.gcd(C, D)
    scd=hoge(A,CD)-A+1
    if scd<=N:
        cdcount=(N+CD-scd)//CD
    else:
       cdcount=0
    print(N-(ccount+dcount-cdcount))
 
 
def hoge(a,b):
    if a%b==0:
        return (a//b)*b
    else:
        #print("({} // {} +1)*{} {}".format(a,b,b,(a//b+1)*b))
        return (a//b+1)*b
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B

Measured memory_bytes: 5076
import heapq

n, m = map(int, input().split())
lst = [[] for i in range(m)]
for i in range(n):
  a, b = map(int, input().split())
  if a <= m:
    lst[a-1].append(b)
q = []
res = 0
for i in range(m):
  while lst[i]:
    b = lst[i].pop()
    heapq.heappush(q, -b)
  if len(q) > 0:
    b = heapq.heappop(q)
    b = -b
    res += b
print(res)

Measured memory_bytes: 18244
#include <stdio.h>
#include <inttypes.h>

int N, M;
int32_t a[64], b[64];
int32_t c[64], d[64];

int main(void) {
	int i, j;
	if (scanf("%d%d", &N, &M) != 2) return 1;
	for (i = 0 ; i < N; i++) {
		if (scanf("%" SCNd32 "%" SCNd32, &a[i], &b[i]) != 2) return 1;
	}
	for (i = 0 ; i < M; i++) {
		if (scanf("%" SCNd32 "%" SCNd32, &c[i], &d[i]) != 2) return 1;
	}
	for (i = 0; i < N; i++) {
		int32_t minScore = 0;
		int minIndex = 0;
		for (j = 0; j < M; j++) {
			int32_t score = 0;
			score += a[i] >= c[j] ? a[i] - c[j] : c[j] - a[i];
			score += b[i] >= d[j] ? b[i] - d[j] : d[j] - b[i];
			if (j == 0 || score < minScore) {
				minScore = score;
				minIndex = j;
			}
		}
		printf("%d\n", minIndex + 1);
	}
	return 0;
}


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

void solve(){
    ll N, M; cin >> N >> M;
    vector<pair<ll, ll>> ab(M);
    for (ll i = 0; i < M; ++i){
        ll a, b; 
        scanf("%lld", &a);
        scanf(" %lld", &b);
        --a; --b;
        ab[i].first = a;
        ab[i].second = b;
    }
    sort(ab.begin(), ab.end(),
         [](const pair<ll ,ll>& x, const pair<ll, ll>& y){return x.second < y.second;});
    
    float right = -1;
    ll ans = 0;
    for (ll i = 0; i < M; ++i){
        if (right < ab[i].first) {
            ans++;
            right = ab[i].second - 0.1;
        }
    }
    printf("%lld\n", ans);


}
int main(void){
    //////////////////////////

    solve();

    //////////////////////////
    return 0;
}

Measured memory_bytes: 1792
N, M = map(int,input().split())
dp = [0 for k in range(N+1)]
MOD = 10**9+7

if M == 0:
    if N == 1:
        print(1)
        exit(0)
    dp[0] = 1
    dp[1] = 1
    dp[2] = 1
    for k in range(2,N+1):
        dp[k] = dp[k-1] + dp[k-2]
        dp[k] %= MOD
    print(dp[N])
else:
    A = [int(input()) for k in range(M)]
    dp[0] = 1
    dp[1] = 1
    dp[2] = 1
    if N == 1:
        if M == 1:
            print(0)
        exit(0)
    else:
        t = 0
        if A[0] == 1:
            t += 1
            dp[1] = 0
        for k in range(2,N+1):
            if t < len(A) and A[t] == k:
                dp[k] = 0
                t += 1
            else:
                dp[k] = dp[k-1] + dp[k-2]
                dp[k] %= MOD
        print(dp[N])


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

using namespace std;

int main() {

	long n;
	cin >> n;

	vector<long> a(n + 1), b(n + 1), c(n);

	for (long i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (long i = 1; i <= n; i++) {
		cin >> b[i];
	}
	for (long i = 1; i < n; i++) {
		cin >> c[i];
	}

	long counter=0;
	for (long i = 1; i <= n; i++) {
		counter += b[a[i]];
		if (i != 1) {
			if (a[i] - 1 == a[i - 1]) {
				counter += c[a[i - 1]];
			}
		}

	}
	cout << counter << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000007
//S.size()

using namespace std;


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;



int main(void){
  int a,b; cin>>a>>b;
  int c = b - a;
  int sum = 0,num;
  int dp[1000];
  dp[0] = 0;
  for(int i = 1;i < 1000;i++){
    sum += i;
    dp[i] = sum;
    if(dp[i] - dp[i - 1] == c)num = i;
  }
  cout<<dp[num] - b;
}


Measured memory_bytes: 256
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
#define MP  make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i != (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i != (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n, k;
    cin >> n >> k;
    vector<LL> v(n);
    for(int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    LL ans = 0;
    for(int i = 0; i < n - k; ++i)
    {
        ans += v[i];
    }
    cout << ans << '\n';
}


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

using namespace std;
using ll = long long;

vector<int> v;
ll calc(ll num){
    if(num == 0){
        return 0;
    }
    num--;
    v.push_back(num % 26);
    return calc(num / 26);
}
int main(){
    ll n;
    cin >> n;
    calc(n);
    string ans;
    for(int i = v.size()-1; i >= 0; i--){
        char c = 'a';
        c += v[i];
        ans.push_back(c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
while n = gets.chomp.to_i
  break if n == 0

  sales = {}

  n.times do
    i, p, q = gets.chomp.split.map(&:to_i)
    value = sales[i]
    sales[i] = 0 if value.nil?
    sales[i] += p * q
  end

  if sales.select { |key, value| value >= 1_000_000 }.any?
    sales.each do |key, value|
      puts key if value >= 1_000_000
    end
  else
    puts 'NA'
  end

end

Measured memory_bytes: 8912
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<numeric>
#include<algorithm>
#include<tuple>
#include<cmath>
#include <iomanip>

typedef unsigned long long ull;
typedef long long ll;

ll DENOM = 1000000000LL + 7LL;
ll D2 = 998244353LL;
using namespace std;

ll n, m, k;

int main(){
    cin >> n >> m;
    vector<ll> h(n);
    for (int i=0; i<n; ++i) cin >> h[i];
    map<ll, set<ll> > rt;
    for(int i=0; i<m; ++i){
        ll a,b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        rt[a].insert(b);
        rt[b].insert(a);
    }
    ll ctr = n;
    for(int i=0; i<n; ++i){
        for (auto it = rt[i].begin(); it != rt[i].end(); ++it){
            if (h[i] <= h[*it]){
                ctr--;
                break;
            }
        }
    }
    cout << ctr << endl;

    return 0;
}

Measured memory_bytes: 20704
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc,char *argv[]){
	int a,b;
	scanf("%d %d", &a, &b);
	if(a < b){
		for(int i = 0;i < b;i++){
			printf("%d",a);
		}
		printf("\n");
	}else{
		for(int j = 0;j < a; j++){
			printf("%d",b);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 128
N = int(input())
B = [int(i) for i in input().split(" ")]

A = [0] * N
for i in range(1, N-1):
    A[i] = min(B[i-1], B[i])
A[0] = max(B[0], A[1])
A[N-1] = max(A[N-2], B[N-2])
print(sum(A))

Measured memory_bytes: 38256
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)
#define RFOR(i,s,n) for(int i=(int)(n)-1,i##_len=(int)(s);i>=i##_len;i--)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define MOD 1000000007

typedef long long ll;
typedef unsigned long long ull;

int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};
//今回の変数
int b[100000];
int l[100000];
int u[100000];
ll d[100000];
ll idx[100000];
ll sum;

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int  a, int  b) {
	return (a) > (b) ? (a) : (b);
}
ll Minl(ll a, ll b) {
	return (a)<(b) ? (a) : (b);
}
ll Maxl(ll a, ll b) {
	return (a)>(b) ? (a) : (b);
}

int main() {
	int p,q,r;
	scanf("%d%d%d", &p, &q,&r);

	int max = Max(p, Max(q, r));

	PRINTD(p+q+r-max);
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 100001
using namespace std;
typedef long long ll;

ll prime[MAX_N];         
bool is_prime[MAX_N + 1];
ll like[MAX_N];          

int sieve(int n) {
  int p = 0;
  for (int i = 0; i <= n; i++) {
    is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
  }
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime[p++] = i;
      for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
  }
  return p;
}

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

    ll Q;
    cin >> Q;

    ll l[Q], r[Q];
    for (int i = 0; i < Q; i++) cin >> l[i] >> r[i];

    sieve(MAX_N);

    fill(like, like + MAX_N, 0);
    
    for (int i = 1; i < MAX_N; i++) {
      if (i % 2 == 0) {
	like[i] = like[i-1];
	continue;
      }
      
      if (is_prime[i] && is_prime[(int)((i+1)/2)]) like[i] = like[i-1] + 1;
      else like[i] = like[i-1];
    }
    
    for (int i = 0; i < Q; i++) cout << like[r[i]] - like[l[i]-1] << endl;
    return 0;
}


Measured memory_bytes: 3200
N, M = map(int, input().split())
S = [tuple(map(int, input().split()))[1:] for _ in range(M)]
P = tuple(map(int, input().split()))

ans = 0
for state in range(1 << N):
    for m in range(M):
        count = 0
        for s in S[m]:
            if state & (1 << (s - 1)):
                count += 1
        if count % 2 != P[m]:
            break
    else:
        ans += 1
print(ans)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
     int ac=0,tle=0,wa=0,re=0;

    string s;
    cin.ignore();
    for(int i=0;i<n;i++)
    {
    getline(cin,s);


    if(s=="AC")
    {
        ac++;
    }
    else if(s=="TLE")
    {
        tle++;
    }
    else if(s=="WA")
    {
        wa++;
    }
    else if(s=="RE")
    {
        re++;

    }
    }
      cout<<"AC "<<"x "<<ac<<endl;
    cout<<"WA "<<"x "<<wa<<endl;
    cout<<"TLE "<<"x "<<tle<<endl;
    cout<<"RE "<<"x "<<re<<endl;
    return 0;
}


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

int main(void) {
int n, m, x, i;
int cost1 = 0;
int cost2 = 0;

std::cin >> n >> m >> x;

for (i = 0; i < m; i++) {
  int a;
  std::cin >> a;
  if (a > x) {
    cost1++;
  } else{
    cost2++;
  }
}

if (cost1 <= cost2) {
  std::cout << cost1 << '\n';
} else {
  std::cout << cost2 << '\n';
}
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(int i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(int i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<int,int>;
using PP=pair<int,P>;
using Pl=pair<ll,ll>;
using PPl=pair<ll,Pl>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
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(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n,m,q;
    cin>>n>>m>>q;
    vvi sum(n,vi(n));
    REP(i,m){
        int l,r;
        cin>>l>>r;
        l--;r--;
        sum[l][r]++;
    }
    REP(i,n){
        REP(j,n-1){
            sum[i][j+1]+=sum[i][j];
        }
    }
    REP(i,n-1){
        REP(j,n){
            sum[i+1][j]+=sum[i][j];
        }
    }
    REP(i,q){
        int l,r;
        cin>>l>>r;
        l--;r--;
        cout<<sum[r][r]-(l?sum[l-1][r]:0)-(l?sum[r][l-1]:0)+(l?sum[l-1][l-1]:0)<<endl;
    }
    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    ll n, c, k;
    cin >> n >> c >> k;
    vector<pair<ll, ll>> T;
    rep(i, n) {
        int t;
        cin >> t;
        T.push_back(make_pair(t, t+k));
    }
    sort(T.begin(), T.end());
    ll ans = 0;
    ll l = 0;
    ll r = 30000000000;
    ll count = 0;
    rep(i, n) {
        l = max(l, T[i].first);
        r = min(r, T[i].second);
        if (l > r) {
            ans++;
            l = T[i].first;
            r = T[i].second;
            count = 0;
        }
        else if (count == c) {
            ans++;
            count = 0;
            l = T[i].first;
            r = T[i].second;
        }
        if (i == n-1) {
            ans++;
        }
        count++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 2420
n = int(input())
a = list(map(int,input().split()))
b = list(map(abs,a))
fu = 0
wa = sum(b)
for N in range(n):
    if a[N] < 0:
        fu += 1
if fu % 2 == 0:
    print(wa)
else:
    print(wa - min(b) * 2)

Measured memory_bytes: 14332
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
// #define double long double
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   2005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15
char a[N][N];
int l[N][N],r[N][N],u[N][N],d[N][N];
signed main(){
  fast;
  int n,m,ans=0,x;
  cin>>n>>m;
  for(int i=0;i<n;i++){
  	 for(int j=0;j<m;j++)
  	 	cin>>a[i][j];
  }
  for(int i=0;i<n;i++){
  	x=0;
  	for(int j=0;j<m;j++){
       if(a[i][j]=='.') l[i][j]=x , x++;
       else l[i][j]=-1, x=0;
  	}
  }
  for(int i=0;i<n;i++){
  	x=0;
  	for(int j=m-1;j>=0;j--){
       if(a[i][j]=='.') r[i][j]=x , x++;
       else r[i][j]=-1, x=0;
  	}
  }
  for(int j=0;j<m;j++){
  	x=0;
  	for(int i=0;i<n;i++){
       if(a[i][j]=='.') u[i][j]=x , x++;
       else u[i][j]=-1, x=0;
  	}
  }
  for(int j=0;j<m;j++){
  	x=0;
  	for(int i=n-1;i>=0;i--){
       if(a[i][j]=='.') d[i][j]=x , x++;
       else d[i][j]=-1, x=0;
  	}
  }

  for(int i=0;i<n;i++)
  	for(int j=0;j<m;j++)
  		if(a[i][j]=='.') ans=max(ans,1+l[i][j]+r[i][j]+u[i][j]+d[i][j]);


  cout<<ans<<endl;
}
  


Measured memory_bytes: 129792
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

class Data
{
public:
    int y, x, b;
    vector<int> history;
    Data(int y0, int x0, int b0, int k)
    {
        y = y0;
        x = x0;
        b = b0;
        history.clear();
        for(int i=0; i<5; ++i){
            history.push_back(k % 4);
            k /= 4;
        }
    }
    bool move(int d)
    {
        int y2 = y;
        int x2 = x;
        y += dy[d];
        x += dx[d];
        b -= d / 2;

        bool ret = false;
        for(int i=4; i>=0; --i){
            y2 -= dy[history[i]];
            x2 -= dx[history[i]];
            if(y2 == y && x2 == x)
                ret = true;
        }

        history.erase(history.begin());
        history.push_back(d);

        return ret;
    }
    int toInt(){
        int ret = 0;
        for(int i=4; i>=0; --i){
            ret *= 4;
            ret += history[i];
        }
        return y + 50 * (x + 50 * (b + 4 * ret));
    }
};

int main()
{
    int h, w, n;
    cin >> h >> w >> n;

    vector<string> s(h);
    for(int i=0; i<h; ++i)
        cin >> s[i];

    vector<int> dp(50*50*4*1024, -1);
    dp[Data(0, 0, n, 0).toInt()] = 0;

    for(int b=n; b>=0; --b){
        for(int y=0; y<h; ++y){
            for(int x=0; x<w; ++x){
                for(int k=0; k<1024; ++k){
                    Data d(y, x, b, k);
                    int from = d.toInt();
                    if(dp[from] == -1)
                        continue;

                    for(int i=0; i<4; ++i){
                        Data d2 = d;
                        bool use = d2.move(i);
                        if(d2.y < 0 || d2.y >= h || d2.x < 0 || d2.x >= w || s[d2.y][d2.x] == '#' || d2.b < 0)
                            continue;

                        int next = dp[from];
                        if(!use && isdigit(s[d2.y][d2.x]))
                            next += s[d2.y][d2.x] - '0';

                        int to = d2.toInt();
                        dp[to] = max(dp[to], next);
                    }
                }
            }
        }
    }

    int ret = 0;
    for(int i=0; i<=n; ++i){
        for(int j=0; j<1024; ++j){
            ret = max(ret, dp[Data(h-1, w-1, i, j).toInt()]);
        }
    }
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 41228
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

int main(void) {
  string s;
  cin >> s;
  if(s[0] == 'S') {
    cout << "Cloudy" << endl;
  } else if(s[0] == 'C') {
    cout << "Rainy" << endl;
  } else {
    cout << "Sunny" << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    string s;
    cin >> s;
    int cnt[26] = {};
    rep(i, s.size())
    {
        if (cnt[s[i] - 'a'] != 0)
        {
            cout << "no" << endl;
            return 0;
        }
        cnt[s[i] - 'a']++;
    }
    cout << "yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
vector<int> dx= {1, 0, -1, 0};
vector<int> dy = {0, 1, 0, -1};
const int INF=100000000;

int main(){
    int n;
    cin>>n;
    bool ok =true;
    for(int i=0 ; i<n; i++){
        int tmp;
        cin>>tmp;
        if(tmp%2==0){
            if(tmp%3!=0&&tmp%5!=0){
                ok = false;
            }
        }
    }
    cout<<(ok? "APPROVED":"DENIED");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <list>
#include <utility>
#include <tuple>
#include <cstdio>
#include <set>
#include <queue>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
const long long INF = 1LL << 60;
typedef long long ll;
int main() {
    int N,M;
    cin >> N >> M;
    vector<int> AC(N+1,0);
    vector<int> WA(N+1,0);
    for(int i=0;i<M;i++){
        int p;
        string S;
        cin >> p;
        if(AC[p]==1){
            cin >> S;
        }
        else if(AC[p]==0){
            cin >> S;
            if(S=="AC"){
                AC[p]=1;
            }
            else if(S=="WA"){
                WA[p]++;
            }
        }
    }
    int accnt=0;
    int penalty=0;
    for(int i=1;i<=N;i++){
        accnt+= AC[i];
        if(AC[i]>0){
            penalty+= WA[i];
        }
    }
    cout << accnt << " " << penalty << endl;
    
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(c-a<=d && a-c<=d)
    cout<<"Yes"<<endl;
  else if(a-b<=d && b-a<=d && c-b<=d && b-c<=d)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return(0);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e5+10;
vector<pair<int,int>>g[maxn];
vector<int>clr(maxn);
int n,m;
void dfs(int u,int p,int c){
	for(auto [v,i]:g[u]){
		if( v != p ){
			++c;
			c %=m;
			clr[i] = c;
			dfs(v,u,c);
		}
	}
}
int32_t main(){
	IOS
	cin>>n;
	for(int i=1;i<n;i++){
		int u,v;cin>>u>>v;
		g[u].push_back({v,i});
		g[v].push_back({u,i});
	}
	m = 0;
	for(int i=1;i<=n;i++){
		m=max(m,(int)g[i].size());
	}
	dfs(1,0,-1);
	cout << m << endl;
	for(int i=1;i<n;i++){
		cout << clr[i]+1 << " ";
	}
	cout<< endl;


}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 12080
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
typedef long long ll;
using namespace std;
ll a[200000+50]={0};
int main ()
{
	ll n,i;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	if(a[0]!=0)
	{
		cout<<"-1"<<endl;
		return 0;
	}
	for(i=1;i<n;i++)
	{
		if(a[i]-a[i-1]>1&&a[i]!=1)
		{
			cout<<"-1"<<endl;
			return 0;
		}
	}
	ll ans=0;
	for(i=1;i<n;i++)
	{
		if(a[i-1]<a[i])
			ans+=1;
		else
			ans+=a[i];
	}
	cout<<ans<<endl;
	return 0;
 } 

Measured memory_bytes: 1792
N, M = map(int, input().split())
colors = ['R'] + ['W'] * (N-1)
counts = [1]*N

def receive(color, id):
    counts[id] += 1
    if colors[id] == 'E':
        colors[id] = color
    elif color != colors[id]:
        colors[id] = 'M'

def send(id):
    color = colors[id]
    counts[id] -= 1
    if counts[id] == 0:
        colors[id] = 'E'
    return color

for i in range(M):
    x, y = map(int, input().split())
    c = send(x-1)
    receive(c, y-1)

print(sum([1 for c in colors if c == 'R' or c == 'M']))



Measured memory_bytes: 5348
X,Y,Z,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))
A.sort()
B.sort()
C.sort()
AB=[]
for a in A:
  for b in B:
    AB.append(-(a+b))
import heapq
heapq.heapify(AB)
ABC=[]
for _ in range(min(K,len(AB))):
  ab=heapq.heappop(AB)
  for c in C:
    heapq.heappush(ABC,ab-c)
for i in range(K):
  print(-heapq.heappop(ABC))
  

Measured memory_bytes: 162084
//#pragma comment(linker,"/STACK:102400000,102400000")
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define PI 3.14159265357979823846
#define MEM(a,b) memset((a),(b),sizeof(a))
#define mod(x) ((x)%MOD)
using namespace std;

const int N = 1e2 + 10, INF = 0x3f3f3f3f , MOD = 1e9 + 7;
const int Move[4][2] = {-1,0,1,0,0,1,0,-1};
const int Move_[8][2] = {-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};
ll a[N];
ll gcd(ll a,ll b){
    return !b?a:gcd(b,a%b);
}
int main(){
//	freopen("C:\\Users\\wz\\Desktop\\in.txt","r",stdin);
//	freopen("C:\\Users\\wz\\Desktop\\out.txt","w",stdout);
	ios_base::sync_with_stdio(0);
    int t;cin>>t;
    for(int i = 0;i < t;i++)cin>>a[i];
    ll ans = a[0];
    for(int i = 1; i < t;i++){
        ans = ans/gcd(ans,a[i])*a[i];
    }
    cout<<ans<<endl;
	return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> T(N);
  
  int sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    sum += T[i];
  }
  
  int M;
  cin >> M;
  
  for (int i = 0; i < M; i++) {
    int P, X;
    cin >> P >> X;

    P--;
    cout << sum - T[P] + X << endl; 
  }
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1<<30;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
vector<set<int> > pls;
int main(){
  int n;  cin >> n;
  string s; cin >> s;
  int Q;  cin >> Q;
  pls.assign(26, set<int>({inf}));
  rep(i,0,n) pls[s[i] - 'a'].insert(i);
  while(Q--){
    int type; cin >> type;
    if(type==1){
      int ind;  char nc;  cin >> ind >> nc;
      --ind;
      auto pc = s[ind];
      s[ind] = nc;
      pls[pc - 'a'].erase(ind);
      pls[nc - 'a'].insert(ind);
    }else{
      int l,r;  cin >> l >> r;
      --l;
      int res = 0;
      for(int c=0 ; c<26 ; c++){
        if(pls[c].empty()) continue;
        int lid = *pls[c].lower_bound(l);
        int rid = *pls[c].lower_bound(r);
        if(rid>lid) res++;
      }
      cout << res << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 24196
package main
import (
    "fmt"
)
    
func main(){
    var N, ans int
    fmt.Scan(&N)
    for i, div, mod:=3, N/3, N%3;div>1;i+=2{
        div, mod = N/i, N%i
        if mod == 0 {
            continue
        }
        if (mod-div)%div==0{
            ans += i+(mod-div)/div
        }
        i+=mod/div-1
    }
    fmt.Println(ans)
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<long long int> A(N);
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    
    sort(A.begin(), A.end());
    long long int ans[2];
    ans[0] = A[A.size()-1];
    int index=lower_bound(A.begin(), A.end(), ans[0]/2)-A.begin();
    if((double)ans[0]/2 == (double)A[index]) cout << ans[0] << " " << A[index] << endl;
    else if(index==0) {
        cout << ans[0] << " " << A[index] << endl;
    } else if(abs((double)A[index]-(double)ans[0]/2) < abs((double)A[index-1]-(double)ans[0]/2)) {
        cout << ans[0] << " " << A[index] << endl;
    } else {
        cout << ans[0] << " " << A[index-1] << endl;
    }

    return 0;
    
}

Measured memory_bytes: 1024
S = input()
T = input()

s = len(S)
t = len(T)
num = s - t + 1

ans = 10000
for i in range(num):
    S_tmp = S[i:i+t]
    tmp_ans = 0
    for j, k in zip(S_tmp, T):
        if j!=k:
            tmp_ans += 1
    
    ans = min(ans, tmp_ans)

print(ans)

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

const int N = 305;
typedef long long LL;

int n;
LL a[N], x, k;

int main() {
	cin>>n;
	for(int i = 1; i <= n; i++)
		cin>>a[i];
	for(int i = 3; i <= n; i++)
		x = x^a[i];
	k = a[1] + a[2] - x;
	if(k%2 == 1 || k < 0) {
		cout<<-1<<endl;
		return 0;
	}
	k /= 2;
	if(k > a[1]) {
		cout<<-1<<endl;
		return 0;
	}
	for(int i = 50; i >= 0; i--) 
		if(x&(1ll<<i) && k + (1ll<<i) <= a[1]) k += 1ll<<i;
	if(a[1] - k < 0 || a[1] - k > a[1] - 1|| (k^(a[1] + a[2] - k)) != x) {
		cout<<-1<<endl;
		return 0;
	}
	cout<<a[1] - k<<endl; 
	return 0;
}

Measured memory_bytes: 3596
#include "bits/stdc++.h"

using namespace std;


#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()

#define int long long

#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second

template <typename T>
void print(T x)
{
	std::cout << x <<" " ;
}


template <typename T>
void println(T x)
{
	std::cout << x << "\n";
}


signed main(void) {
	int N;
	cin >> N;
	vector<int>H;
	H.resize(N);
	int ans = 0;
	rep(i, N) {
		cin >> H[i];
	}
	int min = pow(10,9);

	rrep(i, N) {
		if (min >= H[i])min = H[i];
		else if (min == H[i] - 1)min = H[i] - 1;
		else {
			ans = 1;
			break;
		}
	}
	if (ans == 1)print("No");
	else print("Yes");

}

Measured memory_bytes: 1024
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.array;

  int n;
  rd(n);
  auto a = readln.split
    .to!(int[])
    .map!((e) => (e + 1))
    .array;

  int M = 100000 + 5;
  auto map = new int[](M);
  foreach (e; a) {
    for (int d = -1; d <= 1; d++) {
      map[e + d]++;
    }
  }
  writeln(reduce!(max)(map));
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


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

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

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

void Calc(double ys[2][210], pair<double, double> vys[410], int n) {
  REP(i, 210) {
    ys[0][i] = 1e+100;
    ys[1][i] = -1e+100;
  }
  REP(i, n) {
    int px = vys[i].first;
    int nx = vys[i + 1].first;
    double py = vys[i].second;
    double ny = vys[i + 1].second;
    if (px > nx) { swap(px, nx); swap(py, ny); }
    if (px == nx) { continue; }
    FOREQ(x, px, nx) {
      double d1 = abs(x - px);
      double d2 = abs(nx - x);
      double y = (py * d2 + ny * d1) / (d1 + d2);
      ys[0][x + 100] = min(ys[0][x + 100], y);
      ys[1][x + 100] = max(ys[1][x + 100], y);
    }
  }
}

double CalcVolume(int x, double py, double ny, double pz, double nz) {
  double f1 = py * pz;
  double f2 = (py + ny) / 2.0 * (pz + nz) / 2.0;
  double f3 = ny * nz;
  double ret = (f1 + 4 * f2 + f3) / 6.0;
  return ret;
}

pair<double, double> vys[410];
pair<double, double> vzs[410];
int n, m;
double ys[2][210];
double zs[2][210];

int main() {
  while (scanf("%d %d", &m, &n), n|m) {
    MEMSET(vys, 0);
    MEMSET(vzs, 0);
    REP(i, m) {
      int x, y;
      scanf("%d %d", &x, &y);
      vys[i + m] = vys[i] = make_pair(x, y);
    }
    REP(i, n) {
      int x, z;
      scanf("%d %d", &x, &z);
      vzs[i + n] = vzs[i] = make_pair(x, z);
    }
    Calc(ys, vys, m);
    Calc(zs, vzs, n);
    double ans = 0.0;
    for (double x = 0; x <= 200; x += 1) {
      int px = x;
      int nx = x + 1;
      if (ys[0][px] > ys[1][px] ||
          ys[0][nx] > ys[1][nx] ||
          zs[0][px] > zs[1][px] ||
          zs[0][nx] > zs[1][nx]) { continue; }
      ans += CalcVolume(x - 100,
                        ys[1][px] - ys[0][px], ys[1][nx] - ys[0][nx],
                        zs[1][px] - zs[0][px], zs[1][nx] - zs[0][nx]);
    }
    printf("%.8f\n", ans);
  }
}

Measured memory_bytes: 0
#include<queue>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[51],b[51];
int main()
{
	cin>>a>>b;
	int k=strlen(a)-1;
	for (int i=0;i<k;i++)
		cout<<a[i]<<b[i];
	cout<<a[k];
	if (b[k]) cout<<b[k];
	return 0;
}


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

int main(void)
{
	int weight[10000];
	int treasure, temp, max, mem;
	int num, limit, remember[10000], count;
	int i, j;
	
	count = 1;
	while (1){
		scanf("%d", &limit);
		
		if (!limit) break;
		
		scanf("%d", &num);
		memset(weight, -1, sizeof(weight));
		weight[0]=0;
		for (i = 0; i < num; i++){
			scanf("%d%*c%d", &treasure, &temp);
			
			//if (treasure > weight[temp])  weight[temp] = treasure;
			
			memset(remember, 0, sizeof(remember));
			//remember[temp] = 1;
			for (j = limit; j >=0; j--){
				if ( weight[j]!=-1 && weight[j] + treasure > weight[j + temp] ){
					weight[j + temp] = weight[j] + treasure;
				}
			}
		}
		
		max = mem = 0;
		for (j = 0; j <= limit; j++){//printf("%d\n",weight[j]);
			if (weight[j] > max){
				max = weight[j];
				mem = j;
			}
		}
		printf("Case %d:\n%d\n%d\n", count, max, mem);
		count++;
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <queue>
#include <sstream>
#include <algorithm>
#include <bitset>
#include <limits>
#include <map>
#include <set>
#include <iomanip>
#include <cmath>
 
using namespace std;
 
typedef long long int ll;
typedef std::numeric_limits<double> dbl;
const long long int LL_INF=1LL<<60;
 
vector<string> split(const string& input, char delimiter)
{
    stringstream stream(input);
    
    string field;
    vector<string> result;
    while (getline(stream, field, delimiter)) {
        result.push_back(field);
    }
    return result;
}
 
//#define DEBUG
 
ll A, B, M, N, D, K, L, Q, W, H, T, X, Y, S;
 
int main()
{
    cin >> N;
    set<ll> s;
    for (int i = 0; i < N; ++i) {
        ll o; cin >> o;
        if (s.count(o))
            s.erase(o);
        else
            s.insert(o);
    }
    cout << s.size() << endl;
 
    return 0;
}

Measured memory_bytes: 4864
n = int(input())
hurui = [1]*(n+1)
hurui[0] = 0
hurui[1] = 0
sq = int(n**(1/2))+3

for i in range(2,sq):
    for j in range(2,n//i+1):
        hurui[j*i] = 0
p = []

for i in range(n+1):
    if hurui[i]:
        p.append(i)

cnt = {pi:0 for pi in p}

for pi in p:
    tmp = n
    while tmp>0:
        tmp //= pi
        cnt[pi] += tmp
      
cnt2 = {2:0, 4:0, 14:0, 24:0,74:0}

for key in cnt:
    if cnt[key] >= 2:
        cnt2[2]+=1
    if cnt[key] >= 4:
        cnt2[4]+=1
    if cnt[key] >= 14:
        cnt2[14]+=1
    if cnt[key] >= 24:
        cnt2[24]+=1
    if cnt[key] >= 74:
        cnt2[74]+=1

ans = 0

ans += (cnt2[2]-1)*cnt2[24]
ans += (cnt2[4]-1)*cnt2[14]
ans += (cnt2[2]-2)*cnt2[4]*(cnt2[4]-1)//2
ans += cnt2[74]
print(ans)
        

Measured memory_bytes: 38384
#include<stdio.h>
#define MAX 100005
#define NIL -1

struct Node{
  int parent,left,right;
};
struct Node T[MAX];
int n,D[MAX];

void print(int u){
  int i,c;
  printf("node %d: ",u);
  printf("parent = %d, ",T[u].parent);
  printf("depth = %d, ",D[u]);

  if(T[u].parent==NIL)printf("root, ");
  else if(T[u].left==NIL)printf("leaf, ");
  else printf("internal node, ");
  printf("[");
  for(i=0,c=T[u].left;c!=NIL;i++,c=T[c].right){
    if(i) printf(", ");
    printf("%d",c);
  }
  printf("]\n");
}
  /* while(c!=NIL){
    printf("%d",c);
    c=T[c].right;
    }*/

int getdepth(int u,int p){
  D[u]=p;
  if(T[u].right!=NIL) getdepth(T[u].right,p);
  if(T[u].left!=NIL) getdepth(T[u].left,p+1);
}

int main(){
  int i,v,l,r,root,d,c,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    T[i].parent=T[i].left=T[i].right=NIL;
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&v,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      if(j==0){
	T[v].left=c;
      }
      else T[l].right=c;
      l=c;
      T[c].parent=v;
    }
  }
  for(i=0;i<n;i++){
    if(T[i].parent==NIL)r=i;
  }
  
  getdepth(r,0);

  for(i=0;i<n;i++) print(i);

  return 0;
}

 



Measured memory_bytes: 7264
#include<bits/stdc++.h>
using namespace std;
#define LL long long
int main()
{
    LL r,n,m;
    int i;
    scanf("%lld %d %lld",&r,&m,&n);
    for(i=1;i<=10;i++)
    {
        n=r*n-m;
        printf("%lld\n",n);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define print(x) cout << (x) << endl;
#define printa(x, n) for(ll i = 0; i < n; i++) {cout << (x[i]) << " ";} cout << endl;
using namespace std;
using ll = long long;

int main(void) {
    string s;
    cin >> s;
    int n = s.size();
    rep (i, n) cout <<'x';
    cout <<  endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    cout << ((n-1+(k-1)-1))/(k-1) << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long 
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=3005;
const int MOD=998244353;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,S,A[MAXN];
int dp[MAXN][MAXN][3];

main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>S;
	FOR(i,1,N)cin>>A[i];
	dp[0][0][0]=1;
	FOR(i,1,N)FOR(j,0,S){
		(dp[i][j][0]+=dp[i-1][j][0])%=MOD;
		(dp[i][j][1]+=dp[i-1][j][0]+dp[i-1][j][1])%=MOD;
		(dp[i][j][2]+=dp[i-1][j][0]+dp[i-1][j][1]+dp[i-1][j][2])%=MOD;
		if(A[i]<=j) {
			(dp[i][j][1]+=dp[i-1][j-A[i]][0]+dp[i-1][j-A[i]][1])%=MOD;
			(dp[i][j][2]+=dp[i-1][j-A[i]][0]+dp[i-1][j-A[i]][1])%=MOD;
		}
	}
	cout<<dp[N][S][2];	
}


Measured memory_bytes: 211584
#include <cmath>
#include <cstdio>
#include <vector>
#include <map>
#include <queue>
#include <list>
#include <iostream>
#include <algorithm>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

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

  int k,a,b;
  cin >> k >> a >> b;
  if (a / k < b / k || a % k == 0 || b % k == 0) cout << "OK" << endl;
  else cout << "NG" << endl;
} 

Measured memory_bytes: 3652
parseInt(x) = parse(Int,x)

parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    N = parseInt(readline())
    min_score = 10^18
    min_ = -1
    for i in 1:N
        a,b = parsed_data = readline() |> split |> parseMap
        if b<min_score
            min_score = b
            min_ = a
        end
        
  end
  println(min_score+min_)
end

main()


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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<ll> v(n);
    for(auto& i : v) cin >> i;

    vector<int> cnt(60, 0);
    ll ans = 0;

    REP(i, n){
        REP(j, 60){
            int bit = ((v[i] >> j) & 1);
            if(i > 0){
                ans += ((1LL << j) % MOD) * ((cnt[j]*(1 - bit) + (i - cnt[j])*bit)) % MOD;
                ans %= MOD;
            }
            cnt[j] += bit;
        }
    }

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


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
string N;
cin >> N;
if (N.size() == 3) {
    if (N.at(2) == '3') {
        cout << "bon" << endl;
        } else if (N.at(2) == '0' || N.at(2) == '1' || N.at(2) == '6' || N.at(2) == '8' ) {
        cout << "pon" << endl;
    } else {
        cout << "hon"<< endl;
    }
}else if (N.size() == 2) {
    if (N.at(1) == '3') {
        cout << "bon" << endl;
        } else if (N.at(1) == '0' || N.at(1) == '1' || N.at(1) == '6' || N.at(1) == '8' ) {
        cout << "pon" << endl;
    } else {
        cout << "hon"<< endl;
    }
} else {
    if (N.at(0) == '3') cout << "bon" << endl;
    else if (N.at(0) == '0' || N.at(0) == '1' || N.at(0) == '6' || N.at(0) == '8') {
        cout << "pon" << endl;
    } else cout << "hon"<< endl;
}



return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<queue>
#include<algorithm>
#include<numeric>
#include<string>
#include<map>

using namespace std;
using int_greater_PQ = priority_queue<int,vector<int>,greater<int>>;

int main() 
{
    int A,P;
    cin>>A>>P;

    P+=(A*3);

    cout<<P/2<<endl;

    return 0;
}

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

char Z[1000];

int main()
{
	cin >> Z;
	int len = strlen(Z);
	int ans = 0;
	for (; (ans < len) && (Z[ans] != 'C'); ++ans);
	for (; (ans < len) && (Z[ans] != 'F'); ++ans);
	cout << ((ans == len) ? "No" : "Yes") << endl;
	return 0;
}

Measured memory_bytes: 256
import math
N,K=map(int,input().split())
KAKURITU=0
for arufa in range(1,N+1):
  x=math.log(K/arufa,2)
  x=math.ceil(x)
  if x>=1:
    KAKURITU+=(1/N)*(1/2)**x
  else:KAKURITU+=(1/N)
print(KAKURITU)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
   int n, w;
   cin >> n >> w;
   ll wt[n], v[n];
   for(int i = 0;i < n;++i) cin >> wt[i] >> v[i];
   ll dp[w + 1];
   memset(dp, 0, sizeof(dp));
   for(int i = 0; i < n;++i){
       for(int j = w - wt[i]; j >= 0; --j){
            dp[j + wt[i]] = max(dp[j] + v[i], dp[j + wt[i]]);
       }
   }
   cout << dp[w] << endl;
   return 0;
}

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

const int Maxv=1000005;
struct edge{
	int next,to,w;
}e[Maxv];
int head[Maxv],cnt=0;

void add_edge(int x,int y,int w){
	cnt++;
	e[cnt].to=y;
	e[cnt].next=head[x];
	e[cnt].w=w;
	head[x]=cnt;
}

int ans[Maxv];
void dfs(int v,int f){
	int y,w,i;
	for(i=head[v];i!=-1;i=e[i].next){
		y=e[i].to;
		w=e[i].w%2;
		if(y!=f){
			ans[y]=ans[v]^w;
			dfs(y,v);
		}
	}
}
int main()
{
	memset(head,-1,sizeof(head));
	int n,i,j,x,y,w;
	cin>>n;
	for(i=1;i<n;i++){
		cin>>x>>y>>w;
		add_edge(x,y,w);
		add_edge(y,x,w);
	}
	
	dfs(1,0);
	
	for(i=1;i<=n;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 11264