akhauriyash/Code-Regression huggingface dataset:
turn = int(input())

taro_score = 0
hanako_score = 0 

for i in range(turn):
    tcard,hcard = input().split()
    tcard = str(tcard)
    hcard = str(hcard)
    taro_card = [0]*len(tcard)
    hanako_card = [0]*len(hcard)
    
    
    for j in range(len(tcard)):
        taro_card[j] = ord(tcard[j])
    
    
    for k in range(len(hcard)):
        hanako_card[k] = ord(hcard[k])
        
    if len(tcard) == len(hcard):
    
        for l in range(len(tcard)):
            if taro_card[l] > hanako_card[l]:
                taro_score += 3
                break
            
            elif taro_card[l] < hanako_card[l]:
                hanako_score += 3
                break   
            
            else:
                if l == len(tcard)-1:
                    taro_score += 1
                    hanako_score += 1
                else:
                    continue
    
    elif len(tcard) < len(hcard):
        
        for a in range(len(tcard)):
            if taro_card[a] > hanako_card[a]:
                taro_score += 3
                break
            
            elif taro_card[a] < hanako_card[a]:
                hanako_score += 3
                break
                
            else:
                if a == len(tcard)-1:
                    #taro_score += 3
                    hanako_score += 3
                    
                else:
                    continue
                    
    else:
            
        for b in range(len(hcard)):
            if taro_card[b] > hanako_card[b]:
                taro_score += 3
                break

            elif taro_card[b] < hanako_card[b]:
                hanako_score += 3
                break

            else:
                if b == len(hcard)-1:
                    #hanako_score += 3
                    taro_score += 3

                else:
                    continue
                              
print("%d %d"%(taro_score,hanako_score))


Measured memory_bytes: 5608
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<cassert>
using namespace std;
int inf = 1000000000;

vector<bool> isPrime(int n){
  vector<bool> ret(n+1, true);
  ret[0] = false;
  ret[1] = false;
  for(int i=2; i<=sqrt(n); i++){
    if( !ret[i] ) continue;
    for(int j=i+i; j<n; j+=i){
      ret[j] = false;
    }
  }
  return ret;
}

int main(void) {

  vector<bool> prime = isPrime(1000000);
  int n, p;
  while(cin >> n >> p){
    if( n == -1 && p == -1 ) break;

    int cnt = 0;
    vector<int> a;
    for(int i=n+1; i<=prime.size(); i++){
      if( cnt > 100 ) break;
      if( !prime[i] ) continue;
      cnt++;
      int tmp = 0;
      for(int j=i; j<=prime.size(); j++){
        if( tmp > 100 ) break;
        if( !prime[j] ) continue;
        tmp++;
        a.push_back( i+j );
      }
    }
    sort(a.begin(), a.end());
    cout << a[p-1] << endl;

  }



  return 0;
}


// EOF

Measured memory_bytes: 3156
# coding: utf-8
import string
d = {}
for ch in list(string.ascii_lowercase):
    d[ch] = 0
    
while True:
    try:
        s = list(input().lower())
    except EOFError:
        break
    
    
    for ch in s:
        if ch.isalpha():
            d[ch] += 1
        else:
            pass
    

for k, v in sorted(d.items()):
    print('{} : {}'.format(k, v))



Measured memory_bytes: 6684
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>
#include <random>
#include <cstring>

#define rep(i,n) for(int i=0;i<int(n);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back

using namespace std;
using ll = long long;

const ll mod = 1000000007;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
// bool debug=false;

/*---------------------------------------------------*/

int main() {
    int N;
    int C[51], V[51];
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for(int i = 0; i < N; i++) {
        cin >> C[i];
    }

    int ans = 0;
    for(int mask = 0; mask < (1 << N); mask++) {
        int X = 0, Y = 0;
        for(int i = 0; i < N; i++) {
            if(mask & (1 << i)) {
                X += V[i];
                Y += C[i];
            }
        }
        //cerr << X << " " << Y << endl;
        ans = max(ans, X - Y);
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

int h, n, a, sum = 0;

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	cin >> h >> n;
	for( int i = 1; i <= n; ++i )
	{
		cin >> a;
		sum += a;		
	}
	cout << ( sum >= h ? "Yes" : "No" ) << "\n";	
	return 0;
}

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

int main() {
    int n;
    cin>>n;
    int place[n];
    for(int i=0; i<n; i++) cin>>place[i];

    int spend[100];
    for(int i=0; i<100; i++) {
        int sum = 0;
        for(int j=0; j<n; j++) {
            sum += (place[j]-i-1)*(place[j]-i-1);
        }
        spend[i] = sum;
    }

    int ans = *min_element(spend, spend+100);

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

Measured memory_bytes: 256
s = input()
s_rev = s[::-1]
T_list = ['maerd', 'remaerd', 'esare', 'resare']
 
def mojicut(s, r):
    n = s.replace(r, "", 1)
    return n
 
 
while len(s_rev) > 0:
    s_len = len(s_rev)
    for i in T_list:
        if s_rev.startswith(i):
            s_rev = mojicut(s_rev, i)
            break
    if len(s_rev) == s_len:
        break
 
if len(s_rev) > 0:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3316
#include<iostream>

int main() {
  
  int data[32] = {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};
  
  int n;
  std::cin >> n;
  std::cout << data[n-1] << std::endl;
  return 0;
}

Measured memory_bytes: 256
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define debug(x) cout<<#x<<": "<<x<<" "
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
int main()
{
    IO;
    int n;
    string s;
    cin>>n>>s;
    int i=0,j=n-1;
    int res=0;
    while(i<j)
    {
        if(s[i]=='R'&&s[j]=='W') i++,j--;
        else if(s[i]=='W'&&s[j]=='R') res++,i++,j--;
        else if(s[i]=='W'&&s[j]=='W') j--;
        else i++;
    }
    cout<<res<<endl;
    return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MOD 1000000007
#define INF 100100100

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ll n;
  cin >> n;
  vector<pair<ll, ll>> v(n);
  vector<ll> a(n);
  vector<ll> b(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first;
    v[i].second = i;
    a[i] = i * n;
    b[i] = (n - i) * n;
  }

  for (int i = 0; i < n; i++) {
    a[v[i].first-1] += (i+1);
  }


  for (int i = 0; i < n-1; i++) {
    cout << a[i] << " ";
  }
  cout << a[n-1] << endl;

  for (int i = 0; i < n-1; i++) {
    cout << b[i] << " ";
  }
  cout << b[n-1] << endl;
}


Measured memory_bytes: 1280
n=int(input())
M=float("inf")
w=list(map(int,input().split()))
def check(t,l):
  left=sum(l[:t])
  right=sum(l[t:])
  return max(right,left)-min(right,left)

for i in range(n):
  i += 1
  k=check(i,w)
  if k < M:
    M = k

print(M)

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, LD> PLDLD;
typedef pair<char, char> PCC;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
LL MOD = 1e9+7;
int INF = (1e9) *2+1;
double EPS=1.0e-9;
double PI=atan2(0,-1);


int main()
{
    /*PII e[129];
    
    REP(i,129)
    {
        int tmp=0,ma=0;
        REP(j,128)
        {
            tmp=j+(i^j);
            if(ma<tmp)
            {
                tmp=ma;
                e[i]=PII(j, i^j);
            }
        }
    }
    REP(i,129)
    {
        cout<<i<<" "<<e[i].first<<" "<<e[i].second<<endl;
    }*/
    
    /*0000001 0111100 0111101 0111100*2
    0111100 1100011 1011111 1000011*2
    127*2+1
    1101100 0100110
    400 -254 + 108*/
    int t;
    cin>>t;
    REP(l,t)
    {
        int n,d,ans=0;
        cin>>n>>d;
        if(n%2==1)
        {
            ans=(n-1)*127+d;
        }
        else
        {
            ans=(n-2)*127+d+(d^127)*2;
        }
        cout<<ans<<endl;
    }
}

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


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

    int d_m = n * (n-1) / 2;
    int d_n = m * (m-1) / 2;

    cout << d_m + d_n << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String input = sc.next();
    int i, j, temp;
    int[] number = new int[4];
    String[] mark = new String[3];
    for(i = 0; i < 4; i++) number[i] = input.charAt(i) - '0';
    for(i = 0; i < 2 << 3; i++) {
      temp = number[0];
      for(j = 0; j < 3; j++) {
        if((1 & i >> j) == 1) {
          temp += number[j+1];
          mark[j] = "+";
        } else {
          temp -= number[j+1];
          mark[j] = "-";
        }
      }
      if(temp == 7) {
        for(j = 0; j < 3; j++) {
          System.out.print(number[j] + mark[j]);
        }
        System.out.println(number[j] + "=7");
        break;
      }
    }
  }
}


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

int main(){

    int n;
    cin >> n;
    set<int> s;

    rep(i,n){
        int t;
        cin >> t;
        s.insert(t);
    }

    cout << s.size() << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << (a-c)*(b-d) << endl;
}

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

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

  int tmp;

  for (ll i = 0; i < s.length(); i++)
  {
    tmp = s[i] - 'A';
    tmp = (tmp + n) % 26;
    s[i] = 'A' + tmp;
  }

  cout << s << endl;

  return 0;
}

Measured memory_bytes: 256
object Main extends App {
  val Array(n, a, b) = readLine.split(" ").map(_.toInt)
  
  val elements = for {
    e <- (0 to n).toList
    str = e.toString.split("").filter(_.nonEmpty)
    sum = str.map(_.toInt).sum
    if a <= sum
    if sum <= b
  } yield e
  
  println(elements.sum)
}

Measured memory_bytes: 45776
#include <bits/stdc++.h>
#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(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#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 show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
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; }

int dp[1000005][2];

int main () {
  string s;
  cin >> s;
  reverse(rng(s));
  s += '0';
  int n = s.size();
  rep(i,n+1)rep(j,2) dp[i][j] = INF;
  dp[0][0] = 0;
  rep(i,n)rep(j,2) {
    int x = s[i]-'0';
    x += j; // 繰り下がり (a-1)-n = a-(n+1)
    rep(a,10) {
      int ni = i+1, nj = 0;
      int b = a-x;
      if (b < 0) {
        nj = 1;
        b += 10;
      }
      dp[ni][nj] = min(dp[ni][nj], dp[i][j]+a+b);
    }
  }
  int ans = dp[n][0];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 9220
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n, k;
    cin >> n >> k;
    int pos = -1;
    for(int i = 0; i < n; ++i){
        int foo;
        cin >> foo;
        if(foo == 1)    pos = i;
    }
    int ans = INF;
    for(int i = 0; i <= min(pos, k - 1); ++i){
        int sum = 1;
        sum += ceil((double)(pos - i) / (k - 1));
        int rest = max(0, n - (pos + k - i));
        sum += ceil((double)rest / (k - 1));
        chmin(ans, sum);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
lis = []
for i in range(5):
    lis.append(int(input()))
plus = 0
notdiv = []
for i in range(5):
    if lis[i] % 10 != 0:
        plus += 10 - (lis[i] % 10)
        notdiv.append(lis[i])
if notdiv:
    for i in range(len(notdiv)):
        notdiv[i] %= 10
        notdiv[i] = 10 - notdiv[i]

    notdiv.sort()
    print(sum(lis) + plus - notdiv[-1])
else:
    print(sum(lis) + plus)

Measured memory_bytes: 3064
n = int(input())
*A, = map(int, input().split())

from itertools import product

ans = 0
for P in product(range(3), repeat=n):
    even = 0
    for i in range(n):
        b = A[i] + P[i] - 1
        even |= (b % 2) == 0
    if even:
        ans += 1
print(ans)

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

int main() {
  int A,B,cnt = 0;
  
  cin >> A >> B;
  
  for(int i=A; i<=B; i++){
  int n1,n2,n4,n5;
    n1 = i / 10000;
    n2 = i / 1000 %10;
    n4 = i / 10 % 10;
    n5 = i % 10;
    
    if(n1 == n5&&n2 == n4) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

bool pr[10001];
int a[1300], p=0;

int func(int n, int v)
{
	if(n == 0){
		return 1;
	}
	if(n < 0){
		return 0;
	}
	
	return func(n-a[v-1], v-1);
}

int main()
{
	int n, s, t;
	fill(pr, pr+10001, true);
	
	pr[0] = pr[1] = false;
	for(int i = 2; i <= 10000; i++){
		if(pr[i]){
			a[p++] = i;
			for(int j = 2*i; j <= 10000; j+=i){
				pr[j] = false;
			}
		}
	}
	
	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		s = t = 0;
		for(int i = 0; i < p && a[i] <= n; i++){
			t = i;
		}
		
		for(int i = t; i >= 0; i--){
			s += func(n-a[i], i);
		}
		cout << s << endl;
	}
	
	return 0;
}

Measured memory_bytes: 816
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
static const int giga = pow(10,9);

int main(void){
  int a,b;
  cin >> a >> b;
  cout << (a+b)%24 << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    static readonly int Mod = (int)1e9 + 7;
    static void Add(ref long a, long b) { a = (a + b) % Mod; }

    public void Solve()
    {
        int N = Reader.Int(), C = Reader.Int();
        var A = Reader.IntArray(N);
        var B = Reader.IntArray(N);

        int Bmax = B.Max();
        var powSum = new long[C + 1, Bmax + 1];
        for (int x = 1; x <= Bmax; x++)
            for (long n = 0, p = 1; n <= C; n++, p = p * x % Mod)
                powSum[n, x] = (powSum[n, x - 1] + p) % Mod;

        var dp = new long[C + 1];
        dp[0] = 1;
        for (int i = 0; i < N; i++)
        {
            var nextdp = new long[C + 1];
            for (int add = 0; add <= C; add++)
            {
                long v = (Mod + powSum[add, B[i]] - powSum[add, A[i] - 1]) % Mod;
                for (int sum = 0; sum + add <= C; sum++)
                    Add(ref nextdp[sum + add], dp[sum] * v);
            }
            dp = nextdp;
        }

        Console.WriteLine(dp[C] % Mod);
    }

}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 5336
#include<iostream>
#include<cstdio>
#define INF 1000000
#define NIL -2
#define GRAY -3
#define WHITE -4
#define BRACK -5

using namespace std;

int n;
int M[101][101];
int d[101];//重み
//int p[101];//親
int color[101];
int sum = 0;

void Dijkstra(int u) {
	//cout << u << endl;
	color[u] = BRACK;

	//重みの更新
	for (int i = 0; i < n; i++) {
		if (color[i] != BRACK && M[u][i] != 0) {
			color[i] = GRAY;
			if ((d[u] + M[u][i]) < d[i]) {
				d[i] = d[u] + M[u][i];
			}
		}
	}
	
	int min = -1;
	d[min] = 100000;


	for (int v = 0; v < n; v++) {
		if (color[v] != BRACK) {
			if (d[v] < d[min]) {
				min = v;
			}
			else {
				color[v] = WHITE;
			}
		}
	}

	if (min != -1) {
		Dijkstra(min);
	}
}

int main() {
	cin >> n;
	int v, k, g, weight; //v = 節点番号　g = 次数

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			M[i][j] = 0;
		}
	}

	for (int i = 0; i < n; i++) {
		cin >> v >> g;
		for (int j = 0; j < g; j++) {
			cin >> k;
			cin >> M[i][k];
		}
	}

	for (int i = 1; i <= n; i++) {
		color[i] = WHITE;
	}

	for (int i = 0; i < n; i++) {
		d[i] = INF;
	}

	d[0] = 0;

	//関数
	Dijkstra(0);

	for (int i = 0; i < n; i++) {
		cout << i << " " << d[i] << endl;
	}

	return 0;
}




Measured memory_bytes: 3148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.math.*;
 
public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		int n = Integer.parseInt(br.readLine());
		int[] a = new int [n];
		for(int i = 0; i < n; i++){
			a[i] = Integer.parseInt(br.readLine());
		}
		long cnt = a[0] - 1;
		int max = 2;
		
		for(int i = 1; i < n; i++){
			if(max<a[i]){
				int c = a[i]%max==0 ? (int)Math.floor(a[i]/max)-1 : (int)Math.floor(a[i]/max);
				cnt += c;
				a[i] = 1;
			}
			max = Math.max(a[i]+1,max);
		}
		sb.append(cnt);
		System.out.println(sb);
	}
}

Measured memory_bytes: 18592
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;

ll func(ll a){
    ll ans=0;
    ll x=5;
    a /= 2;
    while(x <= a){
        ans += a / x;
        x *= 5;
    }
    return ans;
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    ll n;
    ll ans = 0;
    cin >> n;
    if(n % 2 == 1){
    }else{
        ans = func(n);
    }
    cout << ans << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <list>
#include <forward_list>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>

using namespace std;

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

  int k;
  cin >> k;
  string s;
  cin >> s;
  
  if (s.length() <= k)
    cout << s << endl;
  else
    cout << s.substr(0, k) << "..." << endl;
  
}

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

using namespace std;

typedef long long ll;

const int MAXN = 5003;
const ll MOD = 1e9+7;
ll fac[5010], fnv[5010];
ll D[5010][5010];
int ni[5010], sz[5010];
int n;
vector<int> lis[5010];

int idfs(int here, int p) {
    sz[here] = 1;
    for (int &there : lis[here]) {
        if (there==p) continue;
        sz[here] += idfs(there,here);
    }
    return sz[here];
}

int cdfs(int here, int p) {
    for (int &there :lis[here]) {
        if (there==p) continue;
        if (sz[there]>n/2) return cdfs(there,here);
    }
    return here;
}

ll power(ll a, ll n) {
    if (!n) return 1;
    ll t = power(a,n/2);
    return t*t%MOD*((n&1)?a:1)%MOD;
}

void init() {
    int i;
    fac[0] = 1;
    for (i=1;i<MAXN;i++) fac[i]=fac[i-1]*i%MOD;
    for (i=0;i<MAXN;i++) fnv[i]=power(fac[i],MOD-2);
}

ll calc(int p) {
    int i, j, k, s = ni[0];
    for (i=0;i<=ni[0];i++) D[0][i] = fnv[ni[0]-i]*fnv[ni[0]-i]%MOD*fnv[i]%MOD;
    for (i=1;i<p;i++) {
        s += ni[i];
        for (j=0;j<=s;j++) {
            D[i][j] = 0;
            for (k=0;k<=min(j,ni[i]);k++) D[i][j] += D[i-1][j-k]*fnv[ni[i]-k]%MOD*fnv[ni[i]-k]%MOD*fnv[k]%MOD;
            D[i][j]%=MOD;
        }
    }
    int q = 1;
    ll res = 0, val = 1;
    for (i=0;i<p;i++) val = val*fac[ni[i]]%MOD*fac[ni[i]]%MOD;
    for (i=0;i<=s;i++,q=-q) {
        res = (res+q*D[p-1][i]*fac[s-i]%MOD)%MOD;
    }
    return (res*val%MOD+MOD)%MOD;
}

int main() {
    scanf("%d",&n);
    int i;

    init();
    for (i=0;i<n-1;i++){
        int a, b;
        scanf("%d%d",&a,&b);--a;--b;
        lis[a].push_back(b);lis[b].push_back(a);
    }
    idfs(0,-1);
    int cen = cdfs(0,-1);
    idfs(cen,-1);
    if (n%2==0) {
        bool flag = 0;
        for (int &there : lis[cen]) {
            if (sz[there]==n/2) {
                flag = 1;
                break;
            }
        }
        if (flag) {
            printf("%lld\n",fac[n/2]*fac[n/2]%MOD);
            return 0;
        }
    }
    int p = 0;
    for (int &there : lis[cen]) ni[p++] = sz[there];
    ni[p++] = 1;
    printf("%lld\n",(calc(p-1)+calc(p))%MOD);

    return 0;
}


Measured memory_bytes: 194688
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<int> a(n + 1);
	rep(i,n){
		int b;cin >> b;
		a.at(b)++;
	}
	int cnt = 0;
	vector<int> b;
	rep(i,n + 1){
		if(a.at(i)){
			cnt++;
			b.pb(a.at(i));
		}
	}
	sort(all(b));
	int ans = 0;
	int j = 0;
	while(cnt > k){
		ans += b.at(j++);
		cnt--;
	}
	cout << ans << endl;
}


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

int main()
{
	int N;
	string S;
	cin >> N >> S;
	int cnt = 1;
	for (int i = 1; i < N; i++) {
		cnt += S[i] != S[i - 1];
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func readInt() int              { return readIntArray()[0] }
func readInt2() (int, int)      { a := readIntArray(); return a[0], a[1] }
func readInt3() (int, int, int) { a := readIntArray(); return a[0], a[1], a[2] }
func readIntArray() []int {
        a := make([]int, 0, 1000)
        sc.Scan()
        for _, v := range strings.Split(sc.Text(), " ") {
                vv, _ := strconv.Atoi(v)
                a = append(a, vv)
        }
        return a
}
func readString() string            { return readStringArray()[0] }
func readString2() (string, string) { a := readStringArray(); return a[0], a[1] }
func readStringArray() []string     { sc.Scan(); return strings.Split(sc.Text(), " ") }

func main() {
        n := readInt()
        s, t := readString2()

        for i := 0; i < n; i++ {
                fmt.Print(string(s[i]))
                fmt.Print(string(t[i]))
        }
}

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

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr ll inf = 2e18;
constexpr int M = 1e9 + 7;

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

	int h, w; cin >> h >> w;
	char g[h][w];
	int dp[h][w];
	rep(i, 0, h) rep(j, 0, w) cin >> g[i][j];
	dp[0][0] = 1;
	rep(i, 1, h)
		dp[i][0] = g[i][0] != '#' ? dp[i - 1][0] : 0;
	rep(j, 1, w)
		dp[0][j] = g[0][j] != '#' ? dp[0][j - 1] : 0;
	rep(i, 1, h)
		rep(j, 1, w)
			dp[i][j] = g[i][j] != '#' ? (dp[i][j - 1] + dp[i - 1][j]) % M : 0;
	cout << dp[h - 1][w - 1];
}

Measured memory_bytes: 5120
#include <iostream>
#include <vector>
#include <cmath>
#include <set>

using namespace std;
int K,N;
set<int> A;

int main()
{
  int i;
  int an, ap, st;
  int dist;
  int maxd=0;

  cin >> K >> N;

  for (i=0; i<N; i++) {
    cin >> an;
    A.insert(an);
  }
  auto it=A.begin();
  ap = *it;
  st = ap;
  it++;
  for (; it != A.end(); it++) {
    an = *it;
    dist = an-ap;
    if (maxd < dist) {
      maxd = dist;
    }
    ap = an;
  }
  dist = K - ap + st;
  if (maxd < dist) {
    maxd = dist;
  }
  printf("%d\n", K - maxd);
  return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define Mod 1000000007

int main() {
    ll x;
    cin>>x;
    ll now=100,ans=0;
    while(now<x){
        ans++;
        now*=1.01;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <map>

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#pragma GCC optimize ("fast-math")

#define AS(a) (sizeof(a)/sizeof(a[0]))
using namespace std;
long long int MOD = 1000000007;
long long int INF = 1000000007;
vector< vector< pair< int, long long int > > >v;
bool ec(int id, long long int* a, bool* b, long long int cs ) {
  a[id] = cs;
  b[id] = true;
  vector <pair<int, long long int> > vv = v[id];
  for(int i = 0; i < vv.size(); i++) {
    if(b[vv[i].first]) continue;
    ec(vv[i].first,a,b,vv[i].second + cs);
  }
}

int main() {
  int N;
  cin >> N;
  int a[N-1],b[N-1],c[N-1];
  for(int i = 0; i < N-1; i++) {
    cin >> a[i] >> b[i] >> c[i];
  }
  int Q,K;
  cin >> Q >> K;
  K--;
  int x[Q],y[Q];
  for(int i = 0; i < Q; i++) {
    cin >> x[i] >> y[i];
    x[i]--;
    y[i]--;
  }
  long long int n_c[N];
  bool visit[N];
  for(int i = 0; i < N; i++) {
    v.push_back(std::vector<pair<int, long long int > >());
  }
  for(int i = 0; i < N-1; i++) {
    v[a[i]-1].push_back(pair<int, long long int >(b[i]-1,c[i]));
    v[b[i]-1].push_back(pair<int, long long int >(a[i]-1,c[i]));
  }
  for(int i = 0; i < N; i++) {
    n_c[i] = 0;
    visit[i] = false;
  }

  ec(K,n_c,visit,0);

  for(int i = 0; i < Q; i++){
    cout << (n_c[x[i]] + n_c[y[i]]) << endl;
  }

}


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

typedef long long ll;
typedef long double ld; 
typedef double db; 
typedef string str; 

typedef pair<int, int> pi;
typedef pair<ll,ll> pl; 
typedef pair<ld,ld> pd; 

typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd; 
typedef vector<str> vs; 
typedef vector<pi> vpi;
typedef vector<pl> vpl; 

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound 
#define ub upper_bound 

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

ll N, K;

namespace Modop {
    ll modAdd(ll a, ll b) {
        return (a + b) % MOD;
    }
    
    ll modSub(ll a, ll b) {
        return (((a - b) % MOD) + MOD) % MOD;
    }
    
    ll modMul(ll a, ll b) {
        return ((a % MOD) * (b % MOD)) % MOD;
    }

    ll modExp(ll base, ll power) {
        if (power == 0) {
            return 1;
        } else {
            ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
            if (power % 2 == 1) cur = cur * base;
            cur = cur % MOD;
            return cur;
        }
    }
    
    ll modInv(ll a) {
        return modExp(a, MOD - 2);
    }
    
    ll modDiv(ll a, ll b) {
        return modMul(a, modInv(b));
    }
}

using namespace Modop;


int main() {
    cin.sync_with_stdio(0); cin.tie(0);
    cin >> N >> K;
    ll dp[K + 1], ans = 0;
    FOR(i, 1, K + 1) dp[i] = modExp(K / i, N);
    ROF(i, 1, K + 1) {
        // cout << dp[i] << "\n";
        for (int j = 2 * i; j < K + 1; j += i) {
            dp[i] -= dp[j];
        }
        ans += modMul(i, dp[i]);
    }
    
    cout << ans % MOD;
    return 0;
    // You should actually read the stuff at the bottom
}

/* Stuff to Look For
 * -----------------
 * Int overflow, array bounds
 * Initializing all variables, avoid weird behavior
 * Edge cases(n = 0, n = 1)
 * Just return 0 after result
 */


Measured memory_bytes: 4400
import string

n = int(input())
num = {k:v for k,v in zip(range(26),string.ascii_lowercase)}
#num[0] = "z"

ans = ""
while True:
    n -= 1
    ans += num[n % 26]
    n //= 26
    if (n == 0): 
        print(ans[::-1])
        exit()

Measured memory_bytes: 9956
#include <iostream>

using namespace std;

int main()
{
    int K;
    int out;

//    cin  >> N >> i;
    cin  >> K;

    if(K % 2 == 0){
        out = (K/2)*(K/2);
    }
    else{
        out = (K/2)*(K/2)+(K/2);
    }

    cout << out << endl;
}



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

int main(){
  int n;
  cin >> n;
  long long int a[n];
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  int lock = 0;
  long long int ans = 0;
  int trigger = 0;
  for(long long int i = 0;i < a[n-1];i++){
    for(int j = 0;j < n;j++){
      if(a[j]%(i+1) != 0){
        lock++;
      }
      if(lock == 2){
        lock = 0;
        break;
      }else if(j == n-1){
        ans = i+1;
        lock = 0;
      }
    }
    for(int j = 0;j < n;j++){
      if(a[j]%(a[n-1]-i) != 0){
        lock++;
      }
      if(lock == 2){
        lock = 0;
        break;
      }else if(j == n-1){
        ans = a[n-1]-i;
        lock = 0;
        trigger = 1;
      }
    }
    if(trigger == 1){
      break;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
#from itertools import permutations

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b: a, b = b, a%b
    return a

def lcm(a: int, b: int):
    return a * b // gcd(a, b)


def main():
    #N = int(input())
    #N,M = map(int, input().split())
    #vP = tuple(map(int, input().split()))
    #vA = set(map(int, input().split()))
    #vA = list(range(1,N+1))

    #print(l, file=sys.stderr)
    #l //= 2
    S = input().rstrip()
    #print(S)
    print(chr(ord(S)+1))
    #print(lcm(N, M))
    #print("Yes" if N<=500*M else "No")
    #print(S.count("ABC"))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
using System;
using System.Linq;

namespace _0018
{
    class Program
    {
        static void Main(string[] args)
        {
            int []a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Array.Sort(a);
            Console.WriteLine(a[4] + " " + a[3] + " " + a[2] + " " + a[1] + " " + a[0]);
Console.ReadLine();      
  }
    }
}

Measured memory_bytes: 9612
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 32;
const int MAX_C = 32;
const int PATTERN = (1 << 16);

int dp[MAX_N + 1][PATTERN];

string disp(int bit){
  stringstream ss;
  //cout <<bit <<endl;
  REP(i, 16){
    ss << (bit & 1);
    bit >>= 1;
  }
  string s = ss.str();
  REVERSE(s);
  return s;
}

int main() {
  int N, C;
  while(cin >>N >>C && N){
    static int a[MAX_N], b[MAX_C];
    REP(i, N){
      a[i] = 0;
      REP(j, 16){
        int tmp; cin >>tmp;
        a[i] = (a[i] << 1);
        a[i] += tmp;
      }
    }
    REP(i, C){
      b[i] = 0;
      REP(j, 16){
        int tmp; cin >>tmp;
        b[i] = (b[i] << 1);
        b[i] += tmp;
      }
    }
    //REP(i, N) cout <<disp(a[i]) <<" "; cout <<endl;
    //REP(i, C) cout <<disp(b[i]) <<" "; cout <<endl;

    //cout <<"----" <<endl;
    int ans = 0;
    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    REP(i, N){
      REP(j, PATTERN){
        if(dp[i][j] == -1) continue;
        //cout <<i <<", " <<disp(j) <<endl;
        int bef_delete = (j | a[i]);
        dp[i + 1][bef_delete] = max(dp[i + 1][bef_delete], dp[i][j]);
        REP(k, C){
          int aft_delete = (~(b[k]) & bef_delete);
          int cnt = __builtin_popcount(b[k] & bef_delete);
          dp[i + 1][aft_delete] = max(dp[i + 1][aft_delete], cnt + dp[i][j]);
          ans = max(ans, dp[i + 1][aft_delete]);
        }
      }
    }
    cout <<ans <<endl;
    
  }
  return 0;
}

Measured memory_bytes: 9628
total = 0
dish = []
for i in range(5):
    dish.append(int(input()))

total = 0
min_val =10
for it in dish:
    total += it
    tmp = it % 10
    
    if tmp == 0:
        continue
        
    if tmp<min_val:
        min_val = tmp
    total += (10-tmp)
print(total - 10 + min_val)

Measured memory_bytes: 3064
s=input()
x=int(s[:2])
y=int(s[2:])
a=b=0
if(y<=12)and(y>=1):
    a=1
if(x<=12)and(x>=1):
    b=1

if(a==1)and(b==1):
    print('AMBIGUOUS')
elif(a==1):
    print('YYMM')
elif(b==1):
    print("MMYY")
else:
    print("NA")
    


Measured memory_bytes: 3316
N,A,B,C,D = map(int,input().split())
S = input()

flg = 0
cnt = 0
S_ac = S[A:C]
S_bd = S[B:D]

if '##' in S_ac or '##' in S_bd:
    flg = 1

if D < C and flg == 0:
    S = S[B-2:D+1]
    if '...' not in S:
        flg = 1

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

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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

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

int main() {
  int A, B;
  cin >> A >> B;
  int ans = 6;
  ans -= A;
  ans -= B;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <numeric>

int main(){
  int N, M;
  std::cin >> N >> M;
  std::vector<int> X(M);
  std::copy_n(std::istream_iterator<int>(std::cin), M , X.begin());
  if(M > N){
    std::vector<int> dif;
    std::sort(X.begin(),X.end());
    for(int i = 0 ; i < M - 1 ; i++ ){
      dif.push_back(X[i+1] - X[i]);
    }
    std::sort(dif.rbegin(),dif.rend());
    long long result = std::accumulate(dif.begin() + N -1 , dif.end(), 0);
    std::cout<<result << std::endl;
    return 0;
  }else{
    std::cout << 0 << std::endl;
    return 0;
  }
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define int long long
#define inf 1e9
#define mod 1000000007

void solve()
{
    int A, B, N;
    cin >> A >> B >> N;

    int ans = 0;
    int low = 1, high = N;
    while (low <= high)
    {
        int mid = (low + high) / 2;
        int exp = ((A * mid) / B) - (A * (mid / B));

        if (ans <= exp)
        {
            low = mid + 1;
        }
        else
        {
            high = mid - 1;
        }
        ans = max(ans, exp);
    }
    cout << ans;
}

int32_t main()
{
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

// increment
#define rep_n(_1, _2, _3, NAME, ...) NAME
#define rep_2(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep_3(i, initial, n) for (int i = (int)(initial); i < (int)(n); ++i)
#define repeat(...) rep_n(__VA_ARGS__, rep_3, rep_2, rep_1)(__VA_ARGS__)
// decrement
#define rep_r_n(_1, _2, _3, NAME, ...) NAME
#define rep_r_2(i, n) for (int i = (int)(n); i > 0; i--)
#define rep_r_3(i, initial, n) for (int i = (int)(initial); i > (int)(n); i--)
#define repeat_r(...) rep_r_n(__VA_ARGS__, rep_r_3, rep_r_2)(__VA_ARGS__)
// define variable
using namespace std;
typedef long long ll;
using mpint = boost::multiprecision::cpp_int; // 多倍長整数（任意精度）
typedef pair<int, int> P;
const double EPS = numeric_limits<double>::epsilon();
// 最大公約数
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; }
// char -> int
int ctoi(char c) { return (int)(c - '0'); }
// 素因数分解
vector< pair<ll, ll> > prime_factorize(ll n) {
	vector< pair<ll, ll> > p;
	for(ll i = 2; i*i <= n; i++) {
		if ((n % i) != 0) continue;
		p.push_back(make_pair(i, 0));
		while((n % i) == 0) {
			n /= i;
			p[i].second += 1;
		}
		p.push_back(make_pair(n, 0));
	}

	if (n != 1) p.push_back(make_pair(n, 1));
	return p;
}

int main() {
	int N;
	cin >> N;
	vector< vector<string> > pattern({
				{"M", "A", "R"},
				{"M", "A", "C"},
				{"M", "A", "H"},
				{"M", "R", "C"},
				{"M", "R", "H"},
				{"M", "C", "H"},
				{"A", "R", "C"},
				{"A", "R", "H"},
				{"A", "C", "H"},
				{"R", "C", "H"}
	});

	map<string, ll> m;

	repeat(i, N) {
		string s = "";
		cin >> s;
		string s1 = s.substr(0, 1);
		m[s1]++;
	}

	ll result = 0;
	repeat(i, pattern.size()) {
		vector<string> p = pattern[i];
		result += m[ p[0] ] * m[ p[1] ] * m[ p[2] ];
	}

	cout << result << endl;	
	return 0;
}


Measured memory_bytes: 384
N,Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        t[i+1] = t[i] + 1
        i += 2
    else:
        t[i+1] = t[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1]-t[l-1])


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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def Yes(): print("Yes"); return
def No(): print("No"); return

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def Base_10_to_n(X, n):
  if X//n:
    return Base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def Base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

A,B,C,X = inputILs(4)
ans = 0
for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        ans += 1
        
print(ans)

Measured memory_bytes: 39664
#include <stdio.h>
#include <iostream>
using namespace std;

int main() {

  int x=0, i=1;

  while(1) {

    cin >> x;

    if(x==0) {

      break;
      
    }

      cout << "Case " << i << ": " << x << endl;

      i++;
    
  }

  return 0;
  
}


Measured memory_bytes: 3068