akhauriyash/Code-Regression huggingface dataset:
def comb(N):
    for i in range(N+1):
        for j in range(i+1):
            if j == 0 or j == i :
                dp[i][j] = 1
            else:
                dp[i][j] = dp[i-1][j-1] + dp[i-1][j]

def main():
    global dp,N
    N, A, B = map(int, input().split())
    v = [int(i) for i in input().split()]
    v.sort(reverse=True)
    dp = [[0 for i in range(N+1)] for j in range(N+1)]
    ans = 0
    for i in range(A):
        ans += v[i]
    ans /= A
    a = 0
    b = 0
    for i in range(N):
        if v[A-1] == v[i]:
            a += 1
            if i < A :
                b += 1
    ans_2 = 0
    comb(N)
    if v[A-1] == v[0]:
        for i in range(A,B+1):
            ans_2 += dp[a][i]
    else:
        ans_2 += dp[a][b]
    print(ans,ans_2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<stdio.h>

int main(void)
{
int n,m,x,tmp;
int i,j;
int x0=0,xn=0;
scanf("%d",&n);
scanf("%d",&m);
scanf("%d",&x);
for(i=0;i<m;i++)
{scanf("%d",&tmp);
if(tmp<x)
{x0+=1;}
else
{xn+=1;}
}
if(x0<xn)
{printf("%d",x0);}
else
{printf("%d",xn);}
return 0;}

Measured memory_bytes: 128
from random import randint
n, a, b, c = map(int, input().split())
S = []
for i in range(n):
    s = input()
    S.append(s)
ans = []
for i in range(n):
    c0 = S[i]
    if c0 == 'AB':
        if a == b == 0:
            print('No')
            exit(0)
        elif a < b or (a == b and i != n - 1 and 'A' in S[i+1]):
            ans.append('A')
            a += 1
            b -= 1
        else:
            ans.append('B')
            a -= 1
            b += 1
    elif c0 == 'BC':
        if c == b == 0:
            print('No')
            exit(0)
        elif c < b or (c == b and i != n - 1 and 'C' in S[i+1]):
            ans.append('C')
            c += 1
            b -= 1
        else:
            ans.append('B')
            c -= 1
            b += 1
    else:
        if c == a == 0:
            print('No')
            exit(0)
        elif c < a or (c == a and i != n - 1 and 'C' in S[i+1]):
            ans.append('C')
            c += 1
            a -= 1
        else:
            ans.append('A')
            c -= 1
            a += 1
print('Yes')
print('\n'.join(ans))
exit(0)

Measured memory_bytes: 17760
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

ll gcd(ll n, ll m) { return n ? gcd(m % n, n) : m; }
int main() {

  ll a, b;
  cin >> a >> b;
  ll g = gcd(a, b);
  vector<ll> p;
  while (g != 1) {
    bool flg = true;
    FOR(i, 2, (ll)sqrt(g) + 1) {
      if (g % i == 0) {
        p.push_back(i);
        g = g / i;
        flg = false;
        break;
      }
    }
    if (flg) {
      p.push_back(g);
      break;
    }
  }

  sort(p.begin(), p.end());
  p.erase(unique(p.begin(), p.end()), p.end());

  cout << p.size() + 1 << endl;
}


Measured memory_bytes: 256
/**
 *		author:  zvm
 *		created: 26.09.2020 17:35:19
**/

#include <bits/stdc++.h>

using namespace std ;

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

	int k ;
	cin >> k ;
	
	for( int i = 0 ; i < k ; ++i ) {
		cout << "ACL" ;
	}

	cout << endl ;
}


Measured memory_bytes: 3640
#!/usr/bin/env python3
import sys
import numpy as np
import math

def solve(N: int, X: "List[int]"):
    place = np.mean(X)
    place = round(place)
    result = 0
    for i in range(N):
        result += (X[i]-place) ** 2
    print(int(result))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, X)

if __name__ == '__main__':
    main()


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

using namespace std;

int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

int inf=1e9;

int main()
{
    ios::sync_with_stdio(false);
    //freopen("inp.in","r",stdin);
    //freopen("outp.out","w",stdout);
    int N, M;
    cin >> N >> M;
    string s;
    cin >> s;
    vector<int> gaNaar(N+1,-1);
    priority_queue< pair<int, int>, vector< pair<int, int> >, greater< pair<int, int> > > pq;
    pq.push(make_pair(0,N));
    for(int i=N-1; i>=0; i--)
    {
        int antwoord=inf;
        int naarWie=-1;
        if(s[i]=='0')
        {
            while(!pq.empty())
            {
                pair<int, int> pa=pq.top();
                int aantal_beurten=pa.first;
                int wie=pa.second;
                if((i+M)<wie)
                {
                    pq.pop();
                    continue;
                }
                antwoord=min(inf,aantal_beurten+1);
                naarWie=wie;
                break;
            }
        }
        if(antwoord>=inf) naarWie=-1;
        gaNaar[i]=naarWie;
        pq.push(make_pair(antwoord,i));
    }
    if(gaNaar[0]==-1)
    {
        cout << -1 << endl;
    }
    else
    {
        int now=0;
        vector<int> v;
        while(now!=N)
        {
            int newNow=gaNaar[now];
            v.push_back(newNow-now);
            now=newNow;
        }
        for(int i=0; i<v.size(); i++)
        {
            if(i != 0) cout << " ";
            cout << v[i];
        }
        cout << endl;
    }
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N;

int latte[222222];

signed main(){
    cin>>N;
    int s=0;
    rep(i,N){
        int a,b;
        cin>>a;
        s+=a;
        latte[s%86400+1]++;
        latte[s%86400+86400+1]++;
        cin>>b;
        s+=b;
    }

    rep(i,222222-1)latte[i+1]+=latte[i];
    int ans=0;
    rep(i,86400){
        chmax(ans,latte[i+10800+1]-latte[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fo(i,n) for(ll i=0;i<n;i++)
#define fok(i,k,n) for(ll i=k;i<n;i++)
#define ci(x) cin>>x
#define ci2(x,y) cin>>x>>y
#define co(x) cout<<x<<"\n"
#define co2(x,y) cout<<x<<" "<<y<<"\n"
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define deb1(x) cout<<#x<<" "<<x<<endl
#define deb2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n"
#define deb3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pll;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pll>		vpll;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;
const int mod = 1000000007;	
int gcd(int a, int b){ if(a==0) return b; return gcd(b%a, a);}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	//ci(t);
	while(t--){
		int s,w;
		ci2(s,w);
		if(w>=s) co("unsafe");
		else co("safe");			
	}
	return 0;
}



Measured memory_bytes: 3656
### constant

WL_TABLE = [
  [3, 3, 3],    # GCP: 000
  [3, 3, 3],    # GCP: 100
  [3, 3, 3],    # GCP: 010
  [1, 2, 0],    # GCP: 110
  [3, 3, 3],    # GCP: 001
  [2, 0, 1],    # GCP: 101
  [0, 1, 2],    # GCP: 011
  [3, 3, 3],    # GCP: 111
]

### main

while true
  k = gets.strip.to_i
  break if k == 0

  members = [k - 1]

  4.times.each do
    members << (gets.strip.to_i - 1)
  end

  wl = 0
  for h in members
    wl |= 1 << h
  end

  wlt = WL_TABLE[wl]

  for h in members
    puts wlt[h]
  end
end

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

$is_right = false;

for($i=0;$i<=(int)$Y/10000;$i++){
  for($j=0;$j<=$N-$i;$j++){
    $rest = $N-$i-$j;
    if(10000*$i+5000*$j+1000*$rest == $Y){
      echo "$i $j $rest";
      $is_right = true;
      break 2;
    }
  }
}

if(!$is_right){
  echo "-1 -1 -1";
}


Measured memory_bytes: 3828
using System;
class Program{
    static void Main(){
        // Your code here!
        string[] input = Console.ReadLine().Split(' ');
        string x = input[0];
        string y = input[1];
        int xNum = StringToNumber(x);
        int yNum = StringToNumber(y);
        if(xNum > yNum){
            Console.WriteLine(">");
        }else if(xNum == yNum){
            Console.WriteLine("=");
        }else{
            Console.WriteLine("<");
        }
    }
    
    static int StringToNumber(string str){
        switch(str){
            case "A":
                return 0;
            case "B":
                return 1;
            case "C":
                return 2;
            case "D":
                return 3;
            case "E":
                return 4;
            case "F":
                return 5;
            default:
                return -1;
        }
    }
}


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

int main() {
    int ma = 0, temp, sum = 0;
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> temp;
        sum += temp;
        ma = max(ma, temp);
    }
    
    sum -= ma / 2;
    
    cout << sum << '\n';
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(ALL(a), greater<int>());
    a.push_back(0);

    int x = 0;
    while(a[x + 1] > x + 1)
        x++;

    int y = lower_bound(ALL(a), x, greater<int>()) - a.begin() - x;
    int z = a[x] - x;

    cout << (y % 2 && z % 2 ? "Second\n" : "First\n");

    return 0;
}

Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long


int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    char c;
    cin >> c;
    if('A' <= c && c <= 'Z') cout << "A\n";
    else cout << "a\n";
}


Measured memory_bytes: 3588
#include <math.h>
#include <ctype.h>
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, n) for (int i = a; i < n; i++)
#define REP(i, n) for(int i = 0; i < n; i++)

long long gcd(long long x, long long y){
    if(x % y == 0) return y;
    else return gcd(y, x % y);
}

long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}

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

    long long tmp, ans = 1;
    REP(i, n){
        cin >> tmp;
        ans = lcm(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}

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

int main() {
	char n[4];
	bool cnt = false;
	cin >> n[0] >> n[1] >> n[2] >> n[3];

	for (int i = 0; i < 3; i++) {
		if ((n[1] == n[2]) && (n[0] == n[1] || n[2] == n[3])) {
			cnt = true;
		}
	}

	if (cnt) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

int n, a[10005];

/*int f(int m) {
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += m % a[i];
	}
	return ans;
} */
int main(){
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int max = 0;
	for (int i = 0; i < n; i++) {
		max += a[i]-1;
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 256
from functools import lru_cache
cc = [["." for i in range(8)] for j in range(8)]

@lru_cache(maxsize=None)     
def dia(s,a,b):
    d = []
    for i in range(8):
        for j in range(8):
            try:
                if j + (a - i) == b: 
                    d.append(s[i][j])
                if j -  (a - i) == b:
                    d.append(s[i][j])
                if j + (i - a) == b: 
                    d.append(s[i][j])
                if j -  (i - a) == b:
                    d.append(s[i][j])
            except IndexError: continue
    print(d)
    return d


def check(cc,a,b):
    ss = list(zip(*cc))
    if 'Q' in cc[a]: return False
    if 'Q' in ss[b]: return False
    d = []
    for i in range(8):
        for j in range(8):
            try:
                if j + (a - i) == b: 
                    d.append(cc[i][j])
                if j -  (a - i) == b:
                    d.append(cc[i][j])
                if j + (i - a) == b: 
                    d.append(cc[i][j])
                if j -  (i - a) == b:
                    d.append(cc[i][j])
            except IndexError: continue
    if 'Q' in d: return False
    return True

def chess(s,queen):
    if queen == 8:
        return s
    for i in range(8):
        for j in range(8):
            if check(s,i,j):
                sol = s
                sol[i][j] = 'Q'
                if chess(sol,queen+1) != [[]]:
                    return sol
                else: sol[i][j] = "."
    return [[]]


k = int(input())
for i in range(k):
    a, b = input().split()
    cc[int(a)][int(b)] = 'Q'
ans = chess(cc,k)
print('\n'.join(list(map(lambda x: ''.join(x),ans))) )


Measured memory_bytes: 6312
import java.util.Scanner;

public class Main {
	static String[] Lb;
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
        Scanner in = new Scanner(System.in);
        String line = in.nextLine();
        String[] L = line.split(" ");

       System.out.println(isWinA(L[0], L[1]));
	}

	private static String isWinA(String A,String B){
		int a =Integer.parseInt(A);
		int b = Integer.parseInt(B);
		if(a != 1 && b != 1){
			if(Integer.parseInt(A) > Integer.parseInt(B)){
				return "Alice";
			}else if(Integer.parseInt(A) == Integer.parseInt(B)){
				return "Draw";
			}else{
				return "Bob";
			}
		}else{
			if( a == 1 && b == 1){
				return "Draw";
			}else{
				if(a == 1){
					return "Alice";
				}
				if(b == 1){
					return "Bob";
				}
			}
			return "";
		}
	}
}

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

const int mxN=101, mxSum=1e5+1;
ll n, W, w[mxN], v[mxN], dp[mxSum];

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> W;
    for (int i=0; i<n; ++i)
        cin >> w[i] >> v[i];
    memset(dp, 0x3f, sizeof(dp));
    dp[0]=0;
    for (int i=0; i<n; ++i)
        for (int j=mxSum-1; j>=0; --j)
            if (j-v[i]>=0)
                dp[j]=min(dp[j], dp[j-v[i]]+w[i]);
    for (int i=mxSum-1; i>=0; --i)
        if (dp[i]<=W) {
            cout << i << '\n';
            break;
        }
}


Measured memory_bytes: 4396
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

N=intput()
A=[list() for _ in range(N)]
for i in range(N):
    a=intput()
    for _ in range(a):
        A[i].append(lint())
ans=0
for c in product('01',repeat=N):
    tmp=True
    for i in range(N):
        if c[i]=='1':
            for x,y in A[i]:
                if c[x-1]!=str(y):
                    tmp=False
                    break
        if not tmp:
            break
    if tmp:
        ans=max(ans,c.count('1'))
print(ans)

Measured memory_bytes: 74988
#include<iostream>
main(){int n,m,i,a,c[1000001];for(std::string s;std::cin>>n>>m>>s,n;printf("%d\n",a))for(a=0,i=m;--i;a+=c[i]>=n)c[i]=s.substr(i,3)=="IOI"?c[i+2]+1:0;}

Measured memory_bytes: 5952
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    cout << (n - 1) / (2 * d + 1) + 1 << '\n';
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  // greedy
  int N, K;
  cin >> N >> K;
  int R, S, P;
  cin >> R >> S >> P;
  map<char, char> win{{'r', 'p'}, {'s', 'r'}, {'p', 's'}};
  map<char, int> score{{'r', R}, {'s', S}, {'p', P}};
  string T;
  cin >> T;
  char result[N];
  int ans = 0;
  rep(i, N) {
    char t = T[i];
    char w = win[t];
    if (i >= K && (result[i-K] == w)) {
      result[i] = 'a';
      continue;
    }
    ans += score[w];
    result[i] = w;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3824
def dfs(i, f):
    if i == n - 1:
        return sum(list(map(int, f.split("+"))))
    return dfs(i + 1, f + s[i + 1]) + dfs(i + 1, f + "+" + s[i + 1])
s = input()
n = len(s)
print(dfs(0, s[0]))

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

int main() {
  int64_t n, k, s = 0;
  cin >> n >> k;
  vector<int64_t> v(n);
  rep(i, n) cin >> v[i];
  sort(v.begin(), v.end());
  if(k < n){
    rep(i, n-k) s += v[i];
  }
  cout << s << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;


int main()
{
	int n;
	cin >> n;
	int s = 0;

	vector<int> a(n);

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

	for (int i = 0; i < n; i++) {
		cout << (s ^ a[i]) << " ";
	}

	cout << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

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

Measured memory_bytes: 3604
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < S.length(); i++) {
			sb.append("x");
		}
		System.out.println(sb.toString());
	}
}

Measured memory_bytes: 24020
#今回は行列を使用します。
#行列演算に完全勝利したコード
n = int(input())
dp = [[0, 0, 0] for i in range(n)]
h = [list(map(int, input().split())) for i in range(n)]
#print(h)
#print(dp)
for j in range(3):
    dp[0][j] = h[0][j]
for i in range(1,n):
    dp[i][0] = h[i][0]+max(dp[i-1][1], dp[i-1][2])
    dp[i][1] = h[i][1]+max(dp[i-1][2], dp[i-1][0])
    dp[i][2] = h[i][2]+max(dp[i-1][0], dp[i-1][1])
print(max(dp[-1]))


Measured memory_bytes: 74020
import sys
from bisect import bisect_right
n = int(input())
data = [n*(n+1)//2 for n in range(1,40)]
cnt2 = 0
while n % 2 == 0:
    cnt2 += 1
    n //= 2
ans = bisect_right(data,cnt2)
if n == 1:
    print(ans)
    sys.exit()
for i in range(3,int(n**(0.5))+1,2):
    cnt = 0
    while n % i == 0:
        cnt += 1
        n //= i
    ans += bisect_right(data,cnt)
    if n == 1:
        break
else:
    ans += 1
print(ans)

Measured memory_bytes: 9412
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
//#define int long long
#define str string
#define rep(i,j) for(int i=0;i<(int)(j);i++)
typedef long long ll;
typedef long double ld;
const long long linf = 4523372036854775807;
const int inf = 1500000000;
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	int from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	int x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
int ari(int a, int b, int c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
int fact(int i) {
	ll sum = 1;
	for (int j = 2; j <= i; j++)
		sum = (sum* j) % Mod;
	return sum;
}//階乗(正）
 //---------------------------------------------------
 //+++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	a += b;
	b = c + d;
	if (a > b) cout << "Left\n";
	else if (a == b) cout << "Balanced\n";
	else cout << "Right\n";
	getchar(); getchar();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    t=1;
     while(t--){
        int n,k;
        cin>>n>>k;
        vector<int> arr(n);
        for(int i=0;i<n;i++){
        	cin>>arr[i];
		}
		sort(arr.begin(),arr.end());
		int sum=0;
		for(int i=0;i<k;i++){
			sum+=arr[i];
		}
		cout<<sum<<"\n";
	 }
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <utility>
#define maxn 1005
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[maxn];
void print(){
	for(int i=1;i<=n;i++){
		printf("%d%c",a[i],i == n ? '\n':' ');
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	print();
	for(int i=1;i<n;i++){
		int v = a[i+1];
		int j = i;
		while(j > 0 && a[j] > v){
			a[j + 1] = a[j];
			j--;
		}
		a[++j] = v;
		print();
	}
	return 0;
}



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

int main() {
    long long K,i, X=7, ans=-1;
    cin >> K;
    for(i=1; i<=K; i++){
        if(X%K == 0){
            ans = i;
            break;
        }
        X = (10*X + 7)%K;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
 
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-funroll-loops")
#pragma GCC target("avx,sse4")
 
#define mms(a,n) memset(a,0,sizeof((a)[0])*(n))
#define mmp(a,b,n) memcpy(a,b,sizeof((b)[0])*(n))
#define lowbit(x) ((x)&-(x))
#define pb push_back
#define fi first
#define se second
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define fo(i,l,r) for(register int i=l,_lim_=r;i<=_lim_;i++)
#define fd(i,r,l) for(register int i=r,_lim_=l;i>=_lim_;i--)
#define fos(i,l,r,d) for(register int i=l,_lim_=r;i<=r;i+=d)
#define fol(i,l,r) for(register ll i=l,_lim_=r;i<=_lim_;i++)
#define fdl(i,r,l) for(register ll i=r,_lim_=l;i>=_lim_;i--)
#define fosl(i,l,r,d) for(register ll i=l,_lim_=r;i<=r;i+=d)
#define Clear(a) memset(a,0,sizeof(a))
#define Copy(a,b) memcpy(a,b,sizeof(b))
#define ALL(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())

using namespace std;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ldb;
typedef double db;
typedef pair<int,int> pi;
typedef vector<int> VI;
typedef vector<VI> VII;

const int N=1000005,P=998244353;

int fpow(int a,int t){
	static int r;
	for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;
	return r;
}

int n,m,k,fac[N],ifac[N],ret;
int C(int n,int m){return n<m||m<0?0:(ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}
int G(int x,int y){return C(x,(x+y)/2);}
int S(int x,int y,int z){return z>=0?0:(G(x,y)-G(x,2*z-y)+P)%P;}

int main(){
	scanf("%d%d",&n,&k);
	m=k<<1;
	fac[0]=1;
	fo(i,1,m)fac[i]=(ll)fac[i-1]*i%P;
	ifac[m]=fpow(fac[m],P-2);
	fd(i,m,1)ifac[i-1]=(ll)ifac[i]*i%P;
	fo(red,1,k){
		int blue=k-red;
		if(red<blue)continue;
		if(red==blue)ret=(ret+S(k-1,1,-k/2+n-1))%P;
		if(red>blue)ret=(ret+S(red+blue,red-blue,n-red-1))%P;
	}
	printf("%d\n",ret);
	return 0;
}

Measured memory_bytes: 8064
#if __has_include("debug.h")
    #include "debug.h"
#else  
#include <bits/stdc++.h>
using namespace std;
#define d(...) 2;
#endif

#define int long long int
#define ld long double

#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"      

#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ff first
#define ss second
#define eps 1e-10
#define PI acos(-1LL)

#define gcd(a,b)            __gcd((a),(b))
#define lcm(a,b)            ((a*b)/gcd(a,b))

void solve();

int32_t main()
{
    #ifdef DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
    #endif 

    fast
    
    int t = 1;
	// cin>>t;
	
	while(t--)
	    solve();
	return 0;  
}

void solve()
{
	int i,j;
	string s;
	cin>>s;

	vector<string>v{"MON","TUE","WED","THU","FRI","SAT","SUN"};

	int cnt=0;

	while(1)
	{
		for(i=0;i<v.size();i++)
		{
			if(v[i]==s)
			{
				j=(i+1)%7;
				cnt++;
				while(v[j]!="SUN")
				{
					cnt++;
						j=(j+1)%7;
				}
				cout<<cnt<<endl;
				return;
			}
		}
	}

}

Measured memory_bytes: 3564
N, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
r = 0
(N - 1).times do |i|
  d = [0, a[i] + a[i + 1] - x].max
  r += d
  a[i + 1] = [0, a[i + 1] - d].max
end
puts r


Measured memory_bytes: 11140
#include <iostream>
#include <vector>

using namespace std;
int main(int argc, char ** argv)
{
  int n, x, y;
  cin >> n >> x >> y;
  vector<int> cs = vector<int>(n, 0);

  for (int i = 1; i <= n; i++) {
    for (int j = i + 1; j <= n; j++) {
      int d = min(abs(j - i), abs(x - i) + 1 + abs(j - y));
      cs[d]++;
    }
  } 
  

  for (int i = 1; i < n; i++) {
    cout << cs[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, P = map(int, input().split())

S = input()

ans = 0
if P == 2 or P == 5:
    for i, s in enumerate(S):
        if int(s) % P == 0:
            ans += i + 1
else:
    counts = [0] * P
    h = 0
    d = 1
    for s in reversed(S):
        m = int(s) * d % P
        h = (h + m) % P
        counts[h] += 1
        d = (d * 10) % P
        ans = counts[0]
    for i in counts:
        ans += (i*(i-1))//2

print(ans)


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    string s;
    cin >> s;
    int count = 0;
    int num = 0;
    while(1){
        char tes = s[num];
        if(num==s.size()-1)break;
        num++;
        while(num<s.size()-1&&tes==s[num]){
            num++;
        }
        if(tes!=s[num])count++;
    }
    COUT(count);
    return 0;
}


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

ll a, b, c, d;

inline void solve(int T) {

    cin >> a >> b >> c >> d;
    ll ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);
    cout << ans;
}
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0);
    // cout.tie(0);

    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
 
    int T = 1;
    // cin >> T;
    rep(i, 1, T) solve(i);
    
    // system("pause");
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string>
#include <stdlib.h>
#include <vector>
#include <math.h>
#include <map>
#include <set>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int a[n];int sum=0;
    for (int i = 0; i < n; ++i)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    int count=0;
    for (int i = 0; i < n; ++i)
    {
        if (a[i]*4*k>=sum)
        {
            //cout<<a[i]<<" ";
            count++;
        }
    }
    if (count<k)
    {
        cout<<"No";
    }
    else
        cout<<"Yes";
}

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

int main() {
  int64_t N, K;
  cin >> N >> K;
  N = N % K;
  if (2 * N - K <= 0) {
    cout << N << endl;
  }
  else {
    cout << K - N << endl;
  }
}

Measured memory_bytes: 3612
num = 1
x = True
lists =[]
lists.append(int(input()))
while x:
    if lists[num-1]%2==0:
        a = lists[num-1]//2
        if a in lists:
            print(num+1)
            x = False
        else:
            num +=1
            lists.append(a)
    else:
        a = lists[num-1]*3+1
        if a in lists:
            print(num+1)
            x = False
        else:
            num +=1
            lists.append(a)

Measured memory_bytes: 3064
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|i| i.parse().ok().unwrap())
        .collect()
}

fn main() {
    let input = read_vec::<usize>();
    let h = input[0];
    let w = input[1];

    if h == 1 || w == 1 {
        println!("1");
    } else {
        println!("{}", (h * w + 1) / 2);
    }
}

Measured memory_bytes: 4352
N, M = map(int, input().split())
H = list(map(int, input().split()))

competitor_H = {}

for m in range(M):
    A, B = map(int, input().split())
    
    if A-1 not in competitor_H.keys():
        competitor_H[A-1] = []
    competitor_H[A-1].append(H[B-1])
    
    if B-1 not in competitor_H.keys():
        competitor_H[B-1] = []
    competitor_H[B-1].append(H[A-1])

countGood = 0
for i in range(N):
    if i not in competitor_H.keys():
        countGood += 1
    elif H[i] > max(competitor_H[i]):
        countGood += 1
print(countGood)

Measured memory_bytes: 27848
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl;
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   " << endl;
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}
 

int main(){
  ll X;
  cin >> X;


  // //A^5 - B^5 = (A-B)^5 + 5AB(A-B)^3 + 5{(AB)^2}(A-B)
  // const ll SIZE = 1000;
  // for(ll A=-SIZE; A<=SIZE; A++){
  //   for(ll B=-SIZE; B<=SIZE; B++){
  //     ll ko1 = (A-B)*(A-B)*(A-B)*(A-B)*(A-B);
  //     ll ko2 = 5 * A * B * (A-B)*(A-B)*(A-B);
  //     ll ko3 = 5 * A*A*B*B * (A-B);
  //     if(ko1+ko2+ko3 == X){
  //       cout << A << " " << B << endl;
  //       return 0;
  //     }
  //   }
  // }
  // cout << " Nothing!!" << endl;
  // return 0;

  //以下の解法だと X=3とかで答えが出なかった
  const ll SIZE = 1000;
  for(ll A=-SIZE; A<=SIZE; A++){
    for(ll B=-SIZE; B<=SIZE; B++){
      if(A*A*A*A*A == B*B*B*B*B + X){
        cout << A << " " << B << endl;
        return 0;
      }
    }

  }
  cout << " Nothing!!" << endl;
  return 0;

    
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;



int main(){
  int n,k;
  double data,ans=0;
  scanf("%d%d",&n,&k);
 
  
  rep(i,n){
    double sum = 1.0/n;
    data = i;
    while(data<k){
    data *= 2;
    sum /= 2;
    }
    ans += sum;
  }
  	cout << fixed << setprecision(10);
    cout << ans;
}
    

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

int main(){
  ll a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  
  ll less = min(x, y);
  ll ans = 0;
  ans += min(a + b, c * 2) * less;
  if (x > y){
    ans += min(a, c * 2) * (x - y);
  }
  else if (x < y){
    ans += min(b, c * 2) * (y - x);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
long long dis[100005];
long long vis[100005];
long long y[100005];
long long z[100005];
int main()
{
    long long C,N,form=0;
    long long you=0,temp=0,zuo=0,ymax=0,zmax=0;
    scanf("%lld %lld",&N,&C);
    for(int i=1;i<=N;i++)
    {
        scanf("%lld %lld",&dis[i],&vis[i]);
        temp=vis[i]+temp-dis[i]+form;
        form=dis[i];
        if(ymax<temp-dis[i])
            ymax=temp-dis[i];
        y[i+1]=ymax;
        if(you<temp)
            you=temp;
    }
    y[1]=0;
    temp=0;
    form=C;
    for(int i=N;i>0;i--)
    {
        temp=vis[i]+temp-(form-dis[i]);
        if(zmax<temp-(C-dis[i]))
            zmax=temp-(C-dis[i]);
            z[i-1]=zmax;
        if(zuo<temp+y[i])
            zuo=temp+y[i];
        form=dis[i];
    }
    z[N]=0;
    temp=0;
    form=0;
    for(int i=1;i<=N;i++)
    {
        temp=vis[i]+temp-dis[i]+form;
        form=dis[i];
        if(you<temp+z[i])
            you=temp+z[i];
    }
    if(zuo>you)
        printf("%lld\n",zuo);
    else
        printf("%lld\n",you);
    return 0;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline ll read(){
	ll x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(ll a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(ll a){write(a); puts("");}
inline void wri(ll a){write(a); putchar(' ');}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1000005,mod=1000000007;
int n,ans,f[N];
ll fac[N],ni[N];
inline ll p(int a,int b){
	return fac[a]*ni[a-b]%mod;
}
inline int ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
int main(){
	n=read();
	for(int i=fac[0]=1;i<=n;i++)fac[i]=fac[i-1]*i%mod; ni[n]=ksm(fac[n],mod-2);
	for(int i=n;i;i--)ni[i-1]=ni[i]*i%mod;
	for(int i=(n+1)/2;i<n;i++){
		f[i]=p(i-1,n-1-i)*fac[i]%mod;
		ans=(ans+(ll)(f[i]-f[i-1])*i)%mod;
	}
	cout<<(ans+mod)%mod<<endl;
}


Measured memory_bytes: 19712
A,B,K = [int(i) for i in input().split(" ")]

def check(A,B,K):
    if A > 0:
        if A > K:
            A-=K
            K = 0
        else:
            result = K-A
            A = 0
            K = result
    if B > 0:
        if B > K:
            B-=K
        else:
            B = 0
    return "{0} {1}".format(A,B)

print(check(A,B,K))

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

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

  int N; cin >> N;
  vector<int> D(N);
  for (int i = 0; i < N; i++) cin >> D[i];
  
  sort(D.begin(), D.end());
  int d1 = D[N / 2 - 1], d2 = D[N / 2 - 0];
  int ans = d2 - d1;
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 640
#define rep(i,n) for (int i=0;i<(n);i++)
#define repr(i,n) for (int i=(n)-1;i>=0;i--)

#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define pic pair<int,char>
#define pci pair<char,int>
#define vs vector<string>
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vc vector<char>

#define all(a) (a).begin(),(a).end()
#define range(a,i) (a).begin(),(a).begin()+i

#define sint(a) int a; scanf("%d",&a);
#define sint2(a,b) int a,b; scanf("%d %d",&a,&b);
#define sint3(a,b,c) int a,b,c; scanf("%d %d %d",&a,&b,&c);
#define sint4(a,b,c,d) int a,b,c,d; scanf("%d %d %d %d",&a,&b,&c,&d);
#define sint5(a,b,c,d,e) int a,b,c,d,e; scanf("%d %d %d %d %d",&a,&b,&c,&d,&e);
#define sll(a) ll a; scanf("%lld",&a);
#define sll2(a,b) ll a,b; scanf("%lld %lld",&a,&b);
#define sll3(a,b,c) ll a,b,c; scanf("%lld %lld %lld",&a,&b,&c);
#define sll4(a,b,c,d) ll a,b,c,d; scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
#define sll5(a,b,c,d,e) ll a,b,c,d,e; scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e);
#define svi(v,n) vector<int> v(n); rep(i,n) scanf("%d", &v[i]);
#define svll(v,n) vector<ll> v(n); rep(i,n) scanf("%lld", &v[i]);
#define sdouble(x) double x; scanf("%lf",&x);
#define svd(v,n) vector<double> v(n); rep(i,n) scanf("%lf", &v[i]);
#define schar(x) char x; scanf(" %c", &x);
#define sstring(x) string x; cin >> x;

#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#endif

#ifdef _MSC_VER
#define DEBUG
#endif

#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <numeric>
#include <climits>
#include <set>
#include <map>

using namespace std;





int main(int argc, char** argv) {
	sll3(N, A, B);
	ll D = B - A;
	if (D < 0) {
		printf("0\n");
		return 0;
	}
	if (N == 1) {
		printf(A == B ? "1\n" : "0\n");
		return 0;
	}
	ll ans = D*(N - 1) - D + 1;
	printf("%lld", ans);
	return 0;
}

Measured memory_bytes: 256
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

sys.setrecursionlimit(10**9)

n,m = map(int, input().split())
G = [[] for i in range(n)]

in_ = set()
for i in range(m):
    a,b = map(int, input().split())
    a,b = a-1,b-1
    G[a].append(b)
    in_.add(b)

dist = [-1]*n

from collections import deque
def dfs(cur):
    if dist[cur] != -1:
        return dist[cur]
    r = 0
    for to in G[cur]:
        r = max(r, dfs(to)+1)
    dist[cur] = r
    return r

for i in range(n):
    if i in in_:
        continue
    dfs(i)

ans = max(dist)

print(ans)

Measured memory_bytes: 111672
(t,),*A=$<.map &:split
p=*0..t.to_i
f=->a{a!=p[a]?p[a]=f[p[a]]:a}
p A.transpose.sum([]){|a|i=0
(x,i),*y=a.map{[_1.to_i,i+=1]}.sort
y.map{[-x+x=_1,i,i=_2]}}.sort.sum{(a=f[_2])!=(b=f[_3])?(p[b]=a
_1):0}

Measured memory_bytes: 54364
#include<stdio.h>

int main(void){

	int H,W;
	int i,j;


	while(1){
		scanf("%d %d",&H,&W);
		if(H==0 &&W==0)break;

		for(i=0;i<H;i++){
			if(i%2==0){
				for(j=0;j<W;j++){
					if(j%2==0){
						printf("#");
					}
					else{
						printf(".");
					}
				}
			}
			else{
				for(j=0;j<W;j++){
					if(j%2==0){
						printf(".");
					}
					else{
						printf("#");
					}	
				}
			}
			printf("\n");
			if(i==H-1)printf("\n");
		}
	}
	return 0;
}
		

Measured memory_bytes: 572
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 100005
int N,M;
priority_queue<int> pq;
vector<int> cn[MXN];

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

    cin>>N>>M;
    int ai,bi;
    int ans=0;
    int now=0;
    FOR(i,1,N)
    {
        cin>>ai>>bi;
        cn[ai].pb(bi);
    }
    FORD(i,M-1,0)
    {
        int df = M-i;
        for( int ci : cn[df] )pq.push(ci);
        if( pq.empty() )continue;
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<'\n';

    return 0;
}



Measured memory_bytes: 5632
use std::io::*;
use std::str::FromStr;
use std::collections::HashSet;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut set: HashSet<String> = HashSet::with_capacity(n);

    for _ in 0..n {
        let s: String = read();
        set.insert(s);
    }

    println!("{}", set.len());
}


Measured memory_bytes: 14736
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, ans = 1;
	string s;
	cin >> n >> s;
	for (int i = 1; i < s.length(); i++){
		if (s[i-1] != s[i]) ans++;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			// 基本情報入力
			int N = scanner.nextInt();
			int T = scanner.nextInt();
			int heikinKion = scanner.nextInt();

			// ループしつつ、平均気温と、計算結果の絶対値差を記録する
			Map<Integer,Double> map = new HashMap<Integer, Double>();
			for (int i = 1; i <= N; i++) {
				map.put(i, Math.abs(heikinKion - (T - scanner.nextInt() * 0.006)));
			}

			// sort
			 List<Entry<Integer, Double>> list_entries = new ArrayList<Entry<Integer, Double>>(map.entrySet());
			Collections.sort(list_entries, new Comparator<Entry<Integer, Double>>(){
				@Override
				public int compare(Entry<Integer, Double> o1, Entry<Integer, Double> o2) {
					return o1.getValue().compareTo(o2.getValue());
				}
			});
			System.out.println(list_entries.get(0).getKey());

		}
	}
}

Measured memory_bytes: 24812
from collections import deque
import sys
input = sys.stdin.readline

h, w = map(int, input().split())
field = []
todo = deque([])

for y in range(h):
    text = input()
    field.append(text)
    for x in range(w):
        if text[x] == '#':
            todo.append([y, x])

dy = [1, -1, 0, 0]
dx = [0, 0, 1, -1]

seen = [[None] * w for _ in range(h)]

for y, x in todo:
    seen[y][x] = 0

while todo:
    y, x = todo.popleft()

    for i in range(4):
        ny, nx = y + dy[i], x + dx[i]

        if ny < 0 or h <= ny or nx < 0 or w <= nx:
            continue
        elif seen[ny][nx] is not None:
            continue
        else:
            seen[ny][nx] = seen[y][x] + 1
            todo.append([ny, nx])

    if not todo:
        print(seen[y][x])


Measured memory_bytes: 140508
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const ll m = 1234567;
const long double pi = 3.141592653589793;
int main() {
	int a, b, t;
	cin >> a >> b >> t;
	cout << t / a * b << endl;
	return 0;
}

Measured memory_bytes: 3592