akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
from functools import reduce
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # greatest common divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # least common multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))
# n = II()
# dp = [INF] * n
# h = LI()
# dp[0], dp[1] = 0, abs(h[1] - h[0])
# for i in range(2, n):
    # dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]), dp[i])
    # dp[i] = min(dp[i-2] + abs(h[i]-h[i-2]), dp[i])
# P(dp[n-1])


a = IS()
b = IS()
c = IS()
d = IS()
e = IS()
ryo = [a, b, c, d, e]
ryo = sorted(ryo, key=lambda x:x[-1])[::-1]
least = '10'
for i in ryo:
    if int(least) >= int(i[-1]) and int(i[-1]) != 0:
        least = i[-1]
if least == '10':
    least = '0'
for i in range(len(ryo)):
    if ryo[i][-1] == least:
        number = ryo.pop(i)
        break
for i in range(len(ryo)):
    for j in range(0,140,10):
        if int(ryo[i]) <= j:
            ryo[i] = j
            break
print(sum(ryo) +int(number))


Measured memory_bytes: 5508
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for(int i = 1, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define PRINT(A) std::cout << (#A) << ":" << (A) << std::endl;
using namespace std;

typedef long long int ll;
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  string s;
  cin >> s;
  char ppc = ' ';
  char pc = ' ';
  int i = 1;
  for(char c : s) {
    if(c == pc) {
      cout << i - 1 << " " << i << endl;
      return 0;
    }
    if(c == ppc) {
      cout << i - 2 << " " << i << endl;
      return 0;
    }
    ppc = pc;
    pc = c;
    i++;
  }
  cout << "-1 -1" << endl;
  return 0;
}


Measured memory_bytes: 512
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans =0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if X -500*a -100*b -50*c ==0:
                ans +=1
               # print(a,b,c)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h> 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main(){
  int t=0;
  int n;
  cin>>n;
  string s;
  cin>>s;
  rep(i,1000){
    int a=i/100,b=(i/10)%10,c=i%10;
    bool r=true,p=false,q=false;
    rep(j,n){
      if(r&&s[j]-'0'==a){r=false;p=true;j++;}
      if(p&&s[j]-'0'==b){p=false;q=true;j++;}
      if(q&&s[j]-'0'==c){t++;break;}}
  }
  cout<<t<<endl;
}

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


void solve(long long A, long long B){
    for (int i = 1; i <= 1100; i++) {
        if (floor(i * 0.08) == A && floor(i * 0.1) == B) {
            cout << i << endl;
            return;
        }
    }

    cout << -1 << endl;
}

// 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)
int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
while True:
    try:
        a=list(input())
        b=list(input())
        a=[i for i in a if i!=' ']
        b=[j for j in b if j!=' ']
        hit=blow=0
        for i in range(4):
            for j in range(4):
                if a[i]==b[j]:
                    if i==j:
                        hit+=1
                    else:
                        blow+=1
        print(hit,blow)
    except EOFError:
        break


Measured memory_bytes: 5564
n=int(input())

xl=[]
yl=[]
hl=[]



for i in range(n):
    xx,yy,hh=list(map(int,input().split()))
    xl.append(xx)
    yl.append(yy)
    hl.append(hh)

for cx in range(0,101):
    for cy in range(0,101):
        ok=True
        for i in range(n):
            x=xl[i]
            y=yl[i]
            h=hl[i]
            if h!=0:
                high = h + abs(x - cx) + abs(y - cy)
                break

        for i in range(n):
            x=xl[i]
            y=yl[i]
            h=hl[i]
            oh=max(high-abs(x-cx)-abs(y-cy),0)
            if h!=oh:
                ok=False
                break
        if ok:
            print(cx,cy,high)
            exit()

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

namespace ITP1_8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                if (input == "0")
                {
                    return;
                }

                var sum = 0;
                foreach (var n in input) 
                {
                    sum += int.Parse(n.ToString());
                }
                Console.WriteLine(sum);
            }
        }
    }
}

Measured memory_bytes: 19996
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	ll A, B, C, ans;

	cin >> A >> B >> C;

	if (A + B >= C - 1) ans = B + C;
	else ans = B + (A + B + 1);

	cout << ans << endl;

	return 0;
}


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

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

  if (a > 9 || a < 1 || b > 9 || b < 1) {
	cout << -1 << endl;
  } else {
	cout << a * b << endl;
  }

  
  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N; cin >> N;
    cout << (double)((N + 1) / 2) / N << "\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>

#define div1 1000000007

using namespace std;

int main(void)
{
    long long N, K, H[200001], i, ans=0;

    cin >> N >> K;

    for(i=1; i<=N; i++){
        cin >> H[i];
    }

    sort(H+1, H+N+1);
    reverse(H+1, H+N+1);

    if(N <= K){
        cout << 0 << endl;
    }

    else{
        for(i=K+1; i<=N; i++){
            ans += H[i];
        }

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 1792
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int H[] = new int[N];
		int COUNT[] = new int[N];
		Arrays.fill(COUNT, 0);
		int A = 0;
		int B = 0;
		for(int i=0; i<N; i++) {
			H[i] = sc.nextInt();
		}
		int count = 0;
		
		for(int i=0; i<M; i++) {
			A = sc.nextInt();
			B = sc.nextInt();
			if(H[A-1]<H[B-1]) {
				COUNT[A-1]=2;
				if(COUNT[B-1]!=2) {
					COUNT[B-1]=1;
				}
			}else if(H[A-1]>H[B-1]) {
				if(COUNT[A-1]!=2) {
					COUNT[A-1]=1;
				}
				COUNT[B-1]=2;
			}else if(H[A-1]==H[B-1]) {
				COUNT[A-1]=2;
				COUNT[B-1]=2;
			}
		}
		for(int i=0; i<N; i++) {
			if(COUNT[i]==1 || COUNT[i]==0) {
				count++;
			}
		}
		
		System.out.print(count);
	}
}

Measured memory_bytes: 60324
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int i = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int i = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int i = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int i = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define debug(x) cerr << #x << ':' << x << '\n'
#define Pi 3.1415926535
#define MOD 1000000007
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << '\n';}
void no(){cout << "No" << '\n';}

int solve(){
    int n; cin >> n;
    ll ans = 0;
    for(int a = 1; a < n ; ++a){
        for(int b = 1; a*b < n ; ++b){
            ++ans;
        }
    }

    cout << ans << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 3656
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    s = input().strip()
    k = int(input().strip())
    ans = []
    for i, c in enumerate(s):
        if i == len(s)-1:
            ans.append(chr(ord('a') + (ord(c) + k % 26 - ord('a')) % 26))
            break
        d = (ord('z') - ord(c) + 1) % 26
        if d <= k:
            k -= d
            ans.append('a')
        else:
            ans.append(c)
    print(''.join(ans))


if __name__ == '__main__':
    main()


Measured memory_bytes: 46576
#include<cstdio>
#include<algorithm>
int s[10000], t[500];
int main() {
	int n, q, i, j, count = 0;
	scanf("%d", &n);
	for (i = 0; i < n; i++)scanf("%d", &s[i]);
	std::sort(s, s + n);
	scanf("%d", &q);
	for (i = 0; i < q; i++)scanf("%d", &t[i]);
	std::sort(t, t + q);
	i = 0;
	j = 0;
	while (i < n&&j < q) {
		if (s[i] == t[j]) {
			count++;
			i++;
			j++;
		}
		else if (s[i] > t[j]) j++;
		else i++;
	}
	printf("%d\n", count);
	return 0;
}


Measured memory_bytes: 2800
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int N;
ll ps[1<<16];
ll js[1<<16];

int main(){

  while(cin>>N&&N){
    for(int i=0;i<N;i++)cin>>ps[i];
    for(int i=0;i<N-1;i++)cin>>js[i];
    sort(ps,ps+N);
    sort(js,js+N-1);
    ll sum=0;
    for(int i=0;i<N;i++)sum+=ps[i];
    for(int i=0;i<N-1;i++)sum+=js[i];
    ll res=0;
    for(int i=0;i<N;i++){
      res=max(res,sum*(i+1));
      sum-=js[i];
    }
    cout<<res<<endl;
  }
  

  return 0;
}

Measured memory_bytes: 2208
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;
#define RET(ans) {cout<<ans<<endl;return 0;} 

    // 二次元ベクターの基本
    /*
    vector<vector<int>> dp; // 宣言
    dp.resize(n); // 1次元めの要素数決定
    dp[i].push_back(int); // プッシュバック
    rep(i,n){
        sort(dp[i].begin(),dp[i].end()); // 二次元めを昇順ソート
    }
    */

    // 整数スキャン（複数）
    /*
    int x,y,z;
    scanf("%d%d%d",&x,&y,&z);

    // n個の整数のスキャン
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // 文字列スキャン
    /*
    string s; cin >> s;
    */

    // n個の文字列スキャン
    /*
    vector<string> slist;
    rep(i,n){
        string s; cin >> s;
        slist.push_back(s);
    }
    */

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

    int a[4] = {};
    rep(i,s.size()){
        if(s[i]=='N')a[0]=1;
        if(s[i]=='W')a[1]=1;
        if(s[i]=='S')a[2]=1;
        if(s[i]=='E')a[3]=1;
    }

    if((a[0]+a[2])%2==0&&(a[1]+a[3])%2==0)yn;

    return 0;
}
 
 


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
    int N, K, Q;

    cin >> N >> K >> Q;

    int ans_count[N + 1];
    int anser;

    for(int i = 1; i < N + 1; i++) {
        ans_count[i] = 0;
    }

    for(int i = 0; i < Q; i++) {
        cin >> anser;
        ans_count[anser]++;
    }

    for(int i = 1; i < N + 1; i++) {
        if(K - Q + ans_count[i] > 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
using namespace std;
int a[6]={1,2,3,4,5,6},b[6];
int main(){
	while(true){
		a[0]=1;a[1]=2;a[2]=3;a[3]=4;a[4]=5;a[5]=6;
		int n;cin>>n;int cnt=1;if(n==0)break;
		for(int i=0;i<n;i++){
			string S;cin>>S;
			for(int i=0;i<6;i++)b[i]=a[i];
			if(S=="North"){a[0]=b[1];a[1]=b[5];a[2]=b[2];a[3]=b[3];a[4]=b[0];a[5]=b[4];}
			if(S=="South"){a[0]=b[4];a[1]=b[0];a[2]=b[2];a[3]=b[3];a[4]=b[5];a[5]=b[1];}
			if(S=="East"){a[0]=b[3];a[1]=b[1];a[2]=b[0];a[3]=b[5];a[4]=b[4];a[5]=b[2];}
			if(S=="West"){a[0]=b[2];a[1]=b[1];a[2]=b[5];a[3]=b[0];a[4]=b[4];a[5]=b[3];}
			if(S=="Right"){a[0]=b[0];a[1]=b[2];a[2]=b[4];a[3]=b[1];a[4]=b[3];a[5]=b[5];}
			if(S=="Left"){a[0]=b[0];a[1]=b[3];a[2]=b[1];a[3]=b[4];a[4]=b[2];a[5]=b[5];}
			cnt+=a[0];
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 3128
#include<iostream>
#include<map>

#define ALP 26 //????£??????°????????§

using namespace std;

typedef struct{
	char index; //????£????
	int mat[2]; //???????\¨??°[0]??????????????§???????\¨??°[1]
}calset;

int main() {
	int n;
	char c;
	char gomi; //???????????¨
	calset cal[ALP] = {0}; //?????????????????????

	int tmp0, tmpj;
	int max0, max1;
	max0 = max1 = 0;

	while (1) {
		cin >> n;
		if (n == 0) break;

		for (int i = 0; i < n; i++) {
			cin >> c;
			for (int j = 0; j < ALP; j++) {
				if (cal[j].index == 0) { //??°??????????£??????????
					cal[j].index = c;
					cal[j].mat[0]++;
					break;
				}
				else if (cal[j].index == c) { //???????\¨??°????????±??´??°
					cal[j].mat[0]++;
					break;
				}
			}
			//mat[1]????????±??´??°&mat[0]????????§???????±???????
			for (int j = 0; j < ALP; j++) {
				tmp0 = cal[j].mat[0];
				cal[j].mat[1] = tmp0 + (n - i - 1);

				if (max0 < tmp0) {
					max0 = tmp0;
					tmpj = j;
				}
			}
			//mat[0]????????§???????£??????\?????§mat[1]????????§??¨????????????????±???????
			for (int j = 0; j < ALP; j++) {
				if (j == tmpj) continue;
				if (max1 < cal[j].mat[1]) {
					max1 = cal[j].mat[1];
				}
			}
			if (max0 > max1) { //???????\¨??¨?????????????????????tmpj??????????\¨??°???????????????????¢?
				cout << cal[tmpj].index << " " << (i + 1) << endl;

				for (int j = n; j > (i + 1); j--) {
					cin >> gomi; //??\????????????
				}
				break; //?¬??????\??????
			}

			if (i == (n - 1)) { //???????????§?±???????????????£?????´???
				cout << "TIE" << endl;
			}
			//?????????
			max0 = max1 = 0;
		}
		//???????????????????????´??????????????????
		max0 = max1 = 0;
		for (int i = 0; i < ALP; i++) {
			cal[i] = { 0 }; //????????????????????????
		}
	}
}

Measured memory_bytes: 3016
x,y = map(int,input().split())

ans_x = 0
ans_y = 0

if x == 1:
    ans_x = 300000
elif x == 2:
    ans_x = 200000
elif x == 3:
    ans_x = 100000
    
if y == 1:
    ans_y = 300000
elif y == 2:
    ans_y = 200000
elif y == 3:
    ans_y = 100000
    
if ans_x + ans_y == 600000:
    print(600000+400000)
else:
    print(ans_x+ans_y)

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

int main(){
    int A, B, C, D, E;
    cin >> A >> B >> C >> D >> E;

    int sum = 0;
    int max_differential = 0;

    const int p[5] = {A , B, C, D, E};
    int differential[5] = {};
    int duty = 0;
    int enter = 0;

    for(int i = 0; i < 5; i++){
        int timer = 0;
        while(timer < p[i]){
            timer = timer + 10;
        }
        differential[i] = timer - p[i];
        if(max_differential < differential[i]){
            max_differential = differential[i];
            enter = p[i];
        }
    }

   // enter = max_differential;
    //cout << "代入" << enter << endl;
    //cout << max_differential << endl;
    const int add = 1;
    for(int i = 1; i < 10; i++){
        if(enter % 10 != 0){
          enter = enter + add;
        }else{
            break;
        }
    }
  //  cout << "enter" << enter << endl;

    sum = differential[0] + p[0] +
          differential[1] + p[1] +
          differential[2] + p[2] +
          differential[3] + p[3] +
          differential[4] + p[4] -
          max_differential;

    cout << sum << endl;

   /* cout << differential[0] + p[0]<< endl;
    cout << differential[1] + p[1]<< endl;
    cout << differential[2] + p[2]<< endl;
    cout << differential[3] + p[3]<< endl;
    cout << differential[4] + p[4]<< endl;
    cout << max_differential << endl;
*/
    //cout << duty << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
void print(int a[],int n)
{
	int i;
	for(i=0;i<n-1;i++)
	{
		cout<<a[i]<<' ';
	}
	cout<<a[n-1]<<endl;
 } 
int main()
{
	int n,i,j,tag,k;
	int *p;
	cin>>n;
	p = new int [n];
	for(i=0;i<n;i++)
	cin>>p[i];
	print(p,n);
	for(i=1;i<n;i++)
	{
		tag = p[i];
		j=i-1;
		while(j >= 0 && p[j] > tag )
		{
			p[j+1] = p[j];
			j--;
		}
		p[j+1] = tag;
		print(p,n);
	}
	delete [] p;
	return 0;
 } 


Measured memory_bytes: 3092
import sys
from math import factorial

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    string_type = {}
    for s in inputs:
        count = {}
        s_list = list(s)
        s_list.sort()
        for c in s_list:
            if c in count:
                count[c] += 1
            else:
                count[c] = 1
        key = ""
        for k in count.keys():
            key += "{}{}".format(k, count[k])
        if key in string_type:
            string_type[key] += 1
        else:
            string_type[key] = 1

    comb_count = 0
    for v in string_type.values():
        if v != 1:
            if v == 2:
                comb_count += 1
            else:
                comb_count += factorial(v) // factorial(v-2) // factorial(2)
    return comb_count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)


Measured memory_bytes: 25612
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
n, x = map(int, input().split())
a = input().split()
b = list(map(int, a))
b.append(x)
b.sort()
if len(b) == 2:
    print(b[1] - b[0])
    exit(0)
c = [abs(a - x) for a in b]


def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a


ans = c[0]
for i in range(len(c)):
    ans = gcd(c[i], ans)
print(ans)


Measured memory_bytes: 18140
import java.util.Scanner;

//Walking in the Hospital
public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			int n = sc.nextInt();
			if(n==0)break;
			int max = 0;
			int p = 0;
			while(n--!=0){
				int x = sc.nextInt();
				int d = sc.nextInt()+sc.nextInt();
				if(max<d){
					max = d;
					p = x;
				}
			}
			System.out.println(p+" "+max);
		}
	}
}

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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */
void solve() {
    vl arr{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    ll k;
    cin >> k;
    cout << arr[k - 1] << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


Measured memory_bytes: 256
s = input()
n = int(s)

m = []

y = n
while y > 0:
    z = y % 10
    m.append(z)
    y = int(y / 10)
    
p = m[len(m) - 1]


max_num = 0
for i in range(len(m)):
    max_num = max(max_num, m[i])

if p < max_num:
    p += 1


for i in range(len(m)):
    m[i] = p
    print(m[i], end='')

print('')

Measured memory_bytes: 9056
//panasonic2020_b.cpp
//Sat Mar 14 20:55:51 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	ll ans = h*w;

	if (h==1 || w==1){
		cout << 1 << endl;
		return 0;
	}

	if (ans%2==0){
		cout << ans/2 << endl;
	}else {
		cout << ans/2+1 << endl;
	}


}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner in=new Scanner(System.in);
        int N=in.nextInt();
        int A=in.nextInt();
        int B=in.nextInt();
        int Y=N*A;
        if((Y==B)||(Y>B)){
            System.out.println(B);
        }
        if(Y<B){
            System.out.println(Y);
        }
    }
}

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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    ll f1=0,f2=0,f3=0;
    FOR(i,0,n){
      ll in;
      cin>>in;
      if(in<=a){
        f1++;
      }
      else if(in<=b){
        f2++;
      }
      else{
        f3++;
      }
    }
    ll res=min(f1,f2);
    cout<<min(res,f3)<<endl;
}


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

int main()
{
	int N, M;
	cin >> N>> M;
	vector<pair<int,int>> ab(M);
	for (int i = 0; i < M; i++)
	{
		int a, b;
		cin >> a >> b;
		ab[i] = make_pair(a, b);
	}
	int output = 0;

	for (int i = 0; i < M; i++)
	{
		vector<int> visited(N+1);
		visited[ab[i].first] = 1;
		for (int count = 0; count < M;count++)
		{
			for (int j = 0; j < M; j++)
			{
				if (j == i)continue;
				if (visited[ab[j].first] == 1)
				{
					visited[ab[j].second] = 1;
				}
				if (visited[ab[j].second] == 1)
				{
					visited[ab[j].first] = 1;
				}

			}
		}
		if (visited[ab[i].second] != 0)
		{
			output++;
		}
		
	}

	cout << M-output << endl;
	return 0;
}


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

class Main {
    public static void main(final String[] args) throws Exception {

        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in));) {
            List<String> inputString = Arrays.asList(br.readLine().split(""));
            int start = 0;
            int end = 0;
            
            for (int i = 0; i < inputString.size(); i++) {
                if (inputString.get(i).equals("A")) {
                    start = i;
                    break;
                }
            }

            for (int j = inputString.size() - 1; j > start; j--) {
                if (inputString.get(j).equals("Z")) {
                    end = j;
                    break;
                }
            }

            int ans = end - start + 1;
            System.out.println(ans);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 37988
#include <bits/stdc++.h>
#define __ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i,a,b) for(int i = a; i <= b; i++)
#define LOG1(x1,x2) cout << x1 << ": " << x2 << endl;
#define LOG2(x1,x2,y1,y2) cout << x1 << ": " << x2 << " , " << y1 << ": " << y2 << endl;
#define LOG3(x1,x2,y1,y2,z1,z2) cout << x1 << ": " << x2 << " , " << y1 << ": " << y2 << " , " << z1 << ": " << z2 << endl;
typedef long long ll;
typedef double db;
const int N = 1e5+100;
const int M = 1e5+100;
const ll mod = 1e9+7;
const db EPS = 1e-9;
using namespace std;

char s[N];
ll dp[N][15];

int main()
{
	scanf("%s",s+1);
	int len = strlen(s+1);
	dp[0][0] = 1;
	rep(i,1,len){
		if(s[i] == '?'){
			rep(j,0,9){
				rep(k,0,12)
					dp[i][(k*10+j)%13] = (dp[i][(k*10+j)%13]+dp[i-1][k])%mod;
			}
		}
		else{
			ll tp = s[i]-'0';
			rep(j,0,12){
				dp[i][(j*10+tp)%13] = (dp[i][(j*10+tp)%13]+dp[i-1][j])%mod;
			}
		}
	}
	printf("%lld\n",dp[len][5]);
	return 0;
}

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

int main() {
    int ans = 0;
    char s[5];

    for(int i = 0; i < 4; i++) {
        cin >> s[i];
        if (s[i] == '+') {
            ans++;
        } else {
            ans--;
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

var scan *bufio.Scanner
var writer io.Writer

func init() {
	scan = bufio.NewScanner(os.Stdin)
	writer = os.Stdout
	scan.Split(bufio.ScanWords)
}

func main() {
	solve()
}

func solve() {
	s := nextWord()
	l := "L"[0]
	r := "R"[0]
	//	u := "U"[0]
	//	d := "D"[0]
	res := "Yes"
	for i := 0; i < len(s); i++ {
		if i%2 == 0 && s[i] == l {
			res = "No"
			break
		}
		if i%2 == 1 && s[i] == r {
			res = "No"
			break
		}
	}
	fmt.Fprint(writer, res)
}

func nextWord() string {
	scan.Scan()
	str := scan.Text()
	return str
}

func nextInt() int {
	i, e := strconv.Atoi(nextWord())
	if e != nil {
		panic(e)
	}
	return i
}


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

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

    int h, w;
    cin >> h >> w;

    char a[h][w];
    rep(i, h) rep(j, w) cin >> a[i][j];

    char res[h][w];
    int h_con = 0;
    int w_con = 0;

    //horizontal axis
    rep(i, h){
        bool drop_flg = true;
        rep(j, w){
            if(a[i][j]=='.') drop_flg = (drop_flg && true);
            else drop_flg = false;
        }
        if(drop_flg) {
            ++h_con;
            if(i != h-1) rep(j, w) res[i][j] = a[i+1][j];
        }
        else rep(j, w) res[i-h_con][j] = a[i][j];
    }

    char res2[h][w];
    //vertical axis
    rep(j, w){
        bool drop_flg = true;
        rep(i, h-h_con){
            if(res[i][j]=='.') drop_flg = (drop_flg && true);
            else drop_flg = false;
        }
        if(drop_flg) {
            ++w_con;
            if(j != w-1) rep(i, h-h_con) res2[i][j] = res[i][j+1];
        }
        else rep(i, h-h_con) res2[i][j-w_con] = res[i][j];
    }


    rep(i, h-h_con){
        rep(j, w-w_con) cout << res2[i][j];
        cout << endl;
    }
}

Measured memory_bytes: 256
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>
# include <iomanip>
# include <string>

# define FILE
# define x first
# define y second
using namespace std;


int n, m, l,q;
int cnt[400][400], fuel[400][400];
vector < pair < int, int > > gr[400];

void dijk( int v ){
    set < pair < int, pair < int, int > > > st;
    for( int i = 1; i <= n; i ++ )
        cnt[v][i] = 1e9;
    st.insert( make_pair( 0, make_pair( -l, v ) ) );
    cnt[v][v] = 0;
    fuel[v][v] = l;
    while( st.empty() == false ){
        auto p = *st.begin();
        st.erase( p );
        int u = p.second.second;
        int f = -p.second.first;
        int c = p.first;
        for( auto to: gr[u] ){
            int cc = c, ff = f;
            if( to.first > f ){
                cc++;
                ff = l-to.first;
            }else{
                ff -= to.first;
            }
            if( cnt[v][to.second] > cc ||( cnt[v][to.second] == cc && fuel[v][to.second] < ff ) ){
                st.erase( make_pair( cnt[v][to.second], make_pair( -fuel[v][to.second], to.second )) );
                cnt[v][to.second] = cc;
                fuel[v][to.second] = ff;
                st.insert( make_pair( cnt[v][to.second], make_pair( -fuel[v][to.second], to.second )) );
            }
        }
    }
}

int main()
{
    # ifdef FILEs
        freopen( "travel.in", "r", stdin );
        freopen( "travel.out", "w", stdout );
    # endif // FILE

    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );

    cin >> n >> m >> l;
    for( int i = 1; i <= m; i ++ ){
        int a, b, c;
        cin >> a >> b >> c;
        if( c > l ) continue;
        gr[a].push_back( make_pair( c,b ) );
        gr[b].push_back( make_pair( c,a ) );
    }
    for( int i = 1; i <= n; i ++ ){
        dijk( i );
    }
    cin >> q;
    while( q -- ){
        int a, b;
        cin >> a >> b;
        if( cnt[a][b] == 1e9 ){
            cout << -1 << endl;
        }else
        cout << cnt[a][b] << endl;
    }




    # ifdef FILEs
        cout << endl << "------------------------";
        cout << endl << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s. |";
        cout << endl << "------------------------";
    # endif
    return 0;
}




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

string func(long long N) {
  if (N == 0) return "";
  N--;
  return func(N / 26) + string(1, 'a' + (N % 26));
}

int main() {
  long long N; cin >> N;
  cout << func(N) << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(x) x.begin(), x.end()
#define mod 1000000007
typedef long long ll;

int main() {
    ll n;
    cin >> n;
    vector<ll> vec(n);
    rep(i, n) cin >> vec[i];
    ll x;
    x = vec[0];
    for(int i=1; i<n; i++){
        x ^= vec[i];
    }
    for(int i=0; i<n; i++){
        ll ans = x ^ vec[i];
        cout << ans << " ";
    } 
    return 0;
}

Measured memory_bytes: 4832
#include <iostream>
using namespace std;
int main(void){
    long long q,h,s,d,n;
    cin>>q>>h>>s>>d>>n;
    s=min(s,min(4*q,2*h));
    if(2*s>d){
        cout<<n/2*d+n%2*s<<endl;
    }else{
        cout<<n*s<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
using namespace std;


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

	int ans = 0;
	REP(_i, n)
	{
		int a; cin >> a;
		if (a >= k) ++ans;
	}

	cout << ans << endl;
}


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

int main() {
  int a; //wa
  int ans; 
  int g; //wa
  /*
  gokei = 2017g + 2002a
  2017g = gokei - 2002a
  
  (2032ans + 2002a) / 2 = a2017g
  2032ans = (a2017g *2 - 2002a)
  */
  
  cin >> a;
  cin >> g;
  ans = g * 2 - a; 
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <limits.h>
using namespace std;
void hoge(int*,int);
int main(){
	int h,n;
	int *a;
	int *b;
	int *hp;
	cin >> h >> n;
	a = new int[n];
	b = new int[n];
	hp = new int[h + 1];
	for(int i = 0;i < n;i++){
		cin >> a[i] >> b[i];
	}
	for(int i = 0;i <= h;i++){
		hp[i] = INT_MAX/2;
	}
	hp[0] = 0;
	for(int i = 0;i < h;i++){
		for(int j = 0;j < n;j++){
			int indi = i + a[j];
			if(indi > h){
				indi = h;
			}
			hoge(hp + indi,hp[i] + b[j]);
		}
	}
	cout << hp[h];
	return 0;
}

void hoge(int *p,int cost){
	if(cost < *p){
		*p = cost;
		return;
	}
	return;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#pragma comment(linker, "/STACK: 20000000005")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2,fma")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const int N = 2005, MOD = 1e9 + 7;

int n, m;
char ch[N][N];
int dp1[N][N];
int dp2[N][N];
int dp3[N][N];
int dp4[N][N];
int ans;

main()
{
    //freopen ("in.in", "r", stdin);freopen ("out.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    string S;
    for (int i = 1; i <= n; i++){
        cin >> S;
        for (int j = 1; j <= m; j++){
            ch[i][j] = S[j - 1];
            /*ch[i][j] = getchar();
            while (ch[i][j] != '.' && ch[i][j] != '#')
                ch[i][j] = getchar();*/
        }
    }
    for (int i = 0; i <= n + 1; i++)
        for (int j = 0; j <= m + 1; j++){
            dp1[i][j] = -1;
            dp2[i][j] = -1;
            dp3[i][j] = -1;
            dp4[i][j] = -1;
        }
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++){
            if (ch[i][j] == '#')
                continue;
            dp1[i][j] = dp1[i - 1][j] + 1;
            dp2[i][j] = dp2[i][j - 1] + 1;
        }
    int pas;
    for (int i = n; i >= 1; i--)
        for (int j = m; j >= 1; j--){
            if (ch[i][j] == '#')
                continue;
            dp3[i][j] = dp3[i + 1][j] + 1;
            dp4[i][j] = dp4[i][j + 1] + 1;
            pas = 1 + dp1[i][j] + dp2[i][j] + dp3[i][j] + dp4[i][j];
            ans = max (ans, pas);
        }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 66944
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPR(i,j) for(int i=j;i>=0;i--)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    llint c[5] = {0};
    int N;
    cin >> N;
    vector<string> A(N);
    REP(i,N) {
        cin >> A[i];
        if(A[i][0]=='M'){c[0] ++;}
        if(A[i][0]=='A'){c[1] ++;}
        if(A[i][0]=='R'){c[2] ++;}
        if(A[i][0]=='C'){c[3] ++;}
        if(A[i][0]=='H'){c[4] ++;}
    }
    llint S;
    S=0;
    REP(i,3){
        REP(j,3-i){
            REP(k,3-i-j){
                S += c[i]*c[i+j+1]*c[i+j+1+k+1];
            }
        }
    }
    cout << S <<"\n";
    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include<algorithm>
#include<sstream>
#include<iomanip>


using namespace std;

typedef long long ll;

const ll MOD_CONST = 1000000007;
const ll BIG_NUM = 1000000000000000000;



int main() {
	int n, h;
	cin >> n >> h;
	priority_queue<int> throwSword;
	
	int maxA = 0;
	

	for (int i = 0;i < n;i++) {
		int a, b;
		cin >> a >> b;

		throwSword.push(b);
		if (maxA < a  ) {
			maxA = a;
			
		}
		
	}
	int cnt = 0;
	
	while (!throwSword.empty()) {
		int b = throwSword.top();
		throwSword.pop();
		
		
		if (b <= maxA) {
			
			break;
		}
		else {
			h -= b;
			cnt++;
		}
		if (h <= 0) {
			break;
		}
	}

	
	if (h > 0) {
		cnt += (h / maxA);
		if (h%maxA != 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 892
n,c,k=map(int,input().split())
t=[]
for i in range(n):
  t.append(int(input()))
t.sort()
num=0
pas=0
end=-1
for i in range(n):
  if(end<t[i]):
    num+=1
    end=t[i]+k
    pas=1
    if(pas==c):
      end=-1
  else:
    pas+=1
    if(pas==c):
      end=-1
  
print(num)

Measured memory_bytes: 7384
#include <iostream>

using namespace std;
typedef long long ll;

int main(){
    ll n;
    cin >> n;
    bool yes = true;
    ll t = 0, x = 0, y = 0;
    for(int i = 0; i < n; ++i){
        ll nt, nx, ny;
        cin >> nt >> nx >> ny;
        const ll dt = nt - t;
        const ll dist = abs(nx - x) + abs(ny - y);
        if(dist > dt || (dt - dist) % 2 != 0){
            yes = false;
        }
        t = nt; x = nx; y = ny;
    }
    if(yes){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> v(100010);
vector<int> even(100010, 0);
vector<int> odd(100010, 0);

int main() {
    int a, b;
    cin >> n;
    for(int i = 0; i < n; ++i) {
        if(i % 2 == 0) {
            cin >> a;
            even.at(a)++;
        }else {
            cin >> b;
            odd.at(b)++;
        }
    }

    int evenmax = max_element(even.begin(), even.end()) - even.begin();
    int oddmax = max_element(odd.begin(), odd.end()) - odd.begin();
    if(evenmax != oddmax) {
        cout << n - even.at(evenmax) - odd.at(oddmax) << endl;
        return 0;
    }

    int evenmax2 = even.at(evenmax);
    int oddmax2 = odd.at(oddmax);
    even.at(evenmax) = odd.at(oddmax) = 0;
    evenmax = max_element(even.begin(), even.end()) - even.begin();
    oddmax = max_element(odd.begin(), odd.end()) - odd.begin();
    cout << n - max(even.at(evenmax) + oddmax2, odd.at(oddmax) + evenmax2) << endl;
}

Measured memory_bytes: 1408
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,K=MI()
    A=LI()
    
    ng=0
    ok=10**9
    
    def f(x):
        temp=0#切る回数
        for i in range(N):
            temp+=(A[i]-0.1)//x
        
        return temp<=K
    
    while ok-ng>1:
        med=(ok+ng)//2
        if f(med):
            ok=med
        else:
            ng=med
               
    print(ok)
    

main()


Measured memory_bytes: 91928
class UnionFind:
   def __init__(self,n):
       self.parent = [-1 for i in range(n)]

   def find(self, x):
       if self.parent[x] < 0:
           return x

       else:
           self.parent[x] = self.find(self.parent[x])
           return self.parent[x]

   def union(self, x, y):
       x, y = self.find(x), self.find(y)
       if (x == y):
           pass
       else:
           self.parent[x] = self.parent[y]
           self.parent[y] = x

   def isgroup(self, x, y):
       return True if self.find(x) == self.find(y) else False


n, m = map(int, input().split())
p = list(map(int, input().split()))

uf = UnionFind(n+1)

for i in range(m):
    x, y = map(int, input().split())
    uf.union(x, y)

count = 0
for i in range(n):
    count += 1 if uf.isgroup(i+1, p[i]) else 0

print(count)

Measured memory_bytes: 14452
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;

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

    int A, B;
    cin >> A >> B;

    int ans = -1;
    for (int i = 1; i <= 10000; ++i) {
        if (i * 8 / 100 == A && i / 10 == B) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import reduce
import math
import itertools
import heapq
#import numpy as np
import bisect
import sys
#import sympy
sys.setrecursionlimit(10**6)


def bfs(s, n, node):
    # 頂点が探索済みかどうかのチェック配列
    check = [False for _ in range(n)]
    check[s] = True
    # 次見る頂点を格納するキュー
    queue = deque([s])
    visited_num = 1

    # 問題固有の配列
    #color_check=[[True for _ in range(l)] for _ in range(n)]
    color = [-1 for _ in range(n)]
    color[s] = 0

    while visited_num < n:
        # グラフが全連結ではない場合
        if len(queue) == 0:
            # 空配列を返す
            # 現状までの計算済み配列を返してもいいと思う
            return color

        now_vertex = queue.popleft()
        # インデックスがない場合は
        for next_vertex in node[now_vertex]:

            if check[next_vertex] == True:
                continue

            queue.append(next_vertex)
            check[next_vertex] = True

            # 問題固有の計算
            color[next_vertex] = color[now_vertex]+1
            visited_num += 1

    return color


mod = 10**9+7
# n=int(input())
# n,m=list(map(int,input().split()))
# a=list(map(int,input().split()))
def ceil(x, y): return (x+y-1)//y
def input_list(): return list(map(int, input().split()))


def cal(x, y, z): return x**2+y**2+z**2+x*y+y*z+x*z


n = int(input())
ans = [0 for _ in range(n)]
for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            tmp = cal(x, y, z)
            if tmp <= n:
                ans[tmp-1] += 1

for i in ans:
    print(i)


Measured memory_bytes: 9664