akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
    #define pb push_back
    #define tam 320000
    #define se second
    #define fi first
    #define pitem item*
    #define forr(i,p,n) for(int i=p;i<n;i++)
    using namespace std;
    typedef long long ll;
    const ll MOD=1000000007 ;
    ll mult(ll a,ll b, ll p=MOD){return ((a%p)*(b%p))%p;}
    ll add(ll a, ll b, ll p=MOD){return (a%p + b%p)%p;}
    typedef pair<int,int> ii;
    typedef vector<vector<int> > vvi;
    typedef  double lld;

    int main()
    {
        ios::sync_with_stdio(false);cin.tie(0);
        ll num;
        cin>>num;
        ll tot=ll(num/11)*2;
        if (num%11==0)
        {
            cout<<tot<<endl;
            return 0;
        }
        if (num%11>=7)
            tot+=2;
        else
            tot++;
        cout<<tot<<endl;
        
    }

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

#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
 
////////////////////////////////////////////////////////////////////

const int N = 25e3 + 5, K = 4e2 + 5;

int n, m, k, A[N], DP[N][K], PS[N][K], C[N][K], PC[N][K], CNT[K], F[K];

int Power(int a, int b) {
	int res = 1;
	for (; b; b >>= 1, a = 1LL * a * a % MOD) if (b & 1) res = 1LL * res * a % MOD;
	return res;
}

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	mt19937 Rnd(time(0));
	
	F[0] = 1;
	for (int i = 1; i < K; i++) F[i] = 1LL * i * F[i - 1] % MOD;
	
	cin >> n >> k >> m;
	int ans = 1LL * (n - m + 1) * Power(k, n - m) % MOD;
	int inv = Power(F[k], MOD - 2);
	for (int i = 0; i < m; i++) cin >> A[i];

	for (int i = 0; i < m; i++) {
		memset(CNT, 0, sizeof CNT);
		int j = i;
		while (j < m && CNT[A[j]] == 0) CNT[A[j++]]++;
		if (j - i == k) die(ans);
	}
	memset(CNT, 0, sizeof CNT);
	int l = 0;
	while (l < m && CNT[A[l]] == 0) CNT[A[l++]]++;
	memset(CNT, 0, sizeof CNT);
	int r = 0;
	while (r < m && CNT[A[m - 1 - r]] == 0) CNT[A[m - 1 - r++]]++;
	bool dup = !(l == m && r == m);	

	PS[0][0] = DP[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < k && j <= i; j++) {
			DP[i][j] = (1LL * DP[i - 1][j - 1] * (k - j + 1) % MOD + PS[i - 1][j]) % MOD;
		}
		for (int j = k - 1; j >= 1; j--) PS[i][j] = (PS[i][j + 1] + DP[i][j]) % MOD;
	}
	if (dup) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < k && j <= i; j++) C[i][j] = (1LL * C[i - 1][j - 1] * (k - j + 1) % MOD + PC[i - 1][j]) % MOD;
			if (i >= m) C[i][r] = (C[i][r] + 1LL * PS[i - m + l][l] * (1LL * F[k - l] * inv % MOD) % MOD) % MOD;
			for (int j = k - 1; j >= 1; j--) PC[i][j] = (PC[i][j + 1] + C[i][j]) % MOD;
		}
	} else {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j < k && j <= i; j++) {
				C[i][j] = (1LL * C[i - 1][j - 1] * (k - j + 1) % MOD + PC[i - 1][j]) % MOD;
				if (j >= m) C[i][j] = (C[i][j] + 1LL * DP[i][j] * (1LL * F[k - m] * inv % MOD) % MOD) % MOD;
			}
			for (int j = k - 1; j >= 1; j--) PC[i][j] = (PC[i][j + 1] + C[i][j]) % MOD;
		}
	}
	cout << (ans - PC[n][1] + MOD) % MOD << endl;

	return 0;
}


Measured memory_bytes: 161928
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int d[3][3];
int a[3],b[3];
bool chk(){
  REP(i,3)REP(j,3){
    if( a[i]+b[j] != d[i][j] ) return false;
  }
  return true;
}
int main(){
  IOS();
  REP(i,3)REP(j,3) cin>>d[i][j];
  REP(j,3) b[j] = d[0][j];
  a[0] = 0;
  REP1(i,2){
    a[i] = d[i][0]-b[0];
  }
  if( chk() ) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 256
// Nguyen Anh Tu
#include <bits/stdc++.h>
#define FOR(x,a,b) for(int x=a;x<=b;x++)
#define FORD(x,a,b) for(int x=a;x>=b;x--)
#define maxn 100005
#define maxc 1000000007
#define MOD 1000000007
#define reset(x,y) memset(x,y,sizeof(x))
#define task ""
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
#define bit(p,x) ((x>>p) & 1)
#define remain(a,b) (a+b >= MOD) ? (a+b - MOD) : (a+b)

using namespace std;
ll n,a,b;
int main()
{
   ios_base::sync_with_stdio(NULL);
   cin.tie(NULL);
   cout.tie(NULL);
    cin >> n >> a >> b;
    if(a == 0) return cout << 0,0;
    ll ans = n %(a + b);
    cout << min(a,ans) + a * (n/(a + b));
}


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

using namespace std;

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

	int n = b - a;
	int high = (n*(n + 1)) / 2 - b;

	cout << high;

	char qq;
	cin >> qq;
	return 0;
}

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

using namespace std;

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

  int answer = 1;
  int maxCount = 0;

  for (int i = N; i > 0; i--) {
    int n = i;
    int count = 0;

    while (n % 2 == 0) {
      n /= 2;
      count += 1;
    }

    if (count > maxCount) {
      answer = i;
      maxCount = count;
    }
  }

  cout << answer << endl;
}


Measured memory_bytes: 256
import math
import copy
import numpy as np

MOD = 998244353

n = int(input())
xxs = []
total = 0
for _ in range(n):
    t = int(input())
    xxs.append(t)
    total += t

xs = np.array(xxs)
dp = np.array([[0] * (total+1) for _ in range(n)])

dp[0][0] = 2
dp[0][xs[0]] = 1

curtotal = xs[0]
for i in range(1,n): # length of
    s = xs[i]
    curtotal += s
    dp[i] = (dp[i-1] * 2)
    dp[i][s:] += dp[i-1][:-s]
    dp[i] %= MOD

#print(dp)

plus = 0
if total % 2 == 0:
    dp2 = np.array([0] * (total // 2 + 1))
    dp2[0] = 1
    curtotal = 0
    for i in range(n):
        s = xs[i]
        curtotal += s
        prev = copy.copy(dp2)
        dp2[s:] += prev[:-s]
        dp2 %= MOD
    plus = dp2[total//2]

#print(dp2)
minus = 0
for i in range(math.ceil(total/2), total+1):
    minus = (minus + dp[n-1][i]) % MOD


#print(3**n, minus, plus)
print(((3**n)%MOD - minus*3 + plus*3) % MOD)


Measured memory_bytes: 433852
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <set>

using namespace std;

int H, W;
string S[2020];
set<int> V[2020], Y[2020];

int main(void) {

	cin >> H >> W;

	for (int i = 0; i <= W + 1; i++) {
		S[0] += "#";
		S[H + 1] += "#";
	}

	string  tmp;
	for (int i = 1; i <= H; i++) {
		cin >> tmp;
		S[i] = "#" + tmp + "#";
	}

	/*for (int i = 0; i <= H + 1; i++) {
		cout << S[i] << endl;
	}*/

	for (int i = 1; i <= H; i++) {
		for (int j = 0; j <= W + 1; j++) {
			if (S[i][j] == '#') { V[i].insert(j); }
		}
	}

	for (int j = 1; j <= W; j++) {
		for (int i = 0; i <= H + 1; i++) {
			if (S[i][j] == '#') { Y[j].insert(i); }
		}
	}

	long long int ans = 0;

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (S[i][j] == '#') { continue; }
			//==============
			V[i].insert(j);
			auto it1 = V[i].find(j);
			it1--;
			auto it2 = V[i].find(j);
			it2++;
			V[i].erase(j);
			//===============

			Y[j].insert(i);
			auto itt1 = Y[j].find(i);
			itt1--;
			auto itt2 = Y[j].find(i);
			itt2++;
			Y[j].erase(i);
			//=============

			long long int num = (*it2) - (*it1) - 1 + (*itt2) - (*itt1) - 1 - 1;
			/*cout << "i= " << i << "  j= " << j << endl;
			cout << *it1 << " " << *it2 << endl;
			cout << *itt1 << "  " << *itt2 << endl;
			cout<<"num = " << num << endl;*/
			ans = max(ans, num);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 383744
#include <string>
#include <queue>
#include <stdio.h>
#include <iostream>
using namespace std;

int main(){
    int n,q;
    cin >> n >> q;
    queue<string> S;
    queue<int> Q;
    for(int i = 0; i < n; i++){
        string name;
        int time;
        cin >> name >> time;
        S.push(name);
        Q.push(time);
    }
    int timesum = 0;
    while(!S.empty()){
        if(Q.front() - q > 0){
            timesum += q;
            S.push(S.front());
            S.pop();
            Q.push(Q.front() - q);
            Q.pop();
        }else{
            timesum += Q.front();
            printf("%s %d\n", S.front().c_str(), timesum);
            S.pop();
            Q.pop();
        }
    }
}

Measured memory_bytes: 5656
io = STDIN
a,b,q=io.gets.split.map(&:to_i)
A=[-Float::INFINITY]+a.times.map{io.gets.to_i}+[Float::INFINITY]
B=[-Float::INFINITY]+b.times.map{io.gets.to_i}+[Float::INFINITY]
def judge(x,a1,a2,b1,b2)
  [(x-a1)*2+(b2-x),
   (x-a1)+(b2-x)*2,
   (x-b1)*2+(a2-x),
   (x-b1)+(a2-x)*2,
   [a2,b2].max-x,
   x-[a1,b1].min].min
end
def calc(x)
  ai=A.bsearch_index{|i|i>x}
  bi=B.bsearch_index{|i|i>x}
  judge(x,A[ai-1],A[ai],B[bi-1],B[bi])
end
q.times do
  x=io.gets.to_i
  p calc(x)
end


Measured memory_bytes: 7932
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    string s1,s2,s3;
    cin>>s1>>s2>>s3;
    map<char,int>m;
    int ans=0;
    int i;
    for(i=0;i<n;i++)
    {
        m.clear();
        m[s1[i]]++;
        m[s2[i]]++;
        m[s3[i]]++;
        int g=max(m[s1[i]],m[s2[i]]);
        ans+=3-g;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

int main()
{
    ll n;
    cin>>n;
    ll mod=9*n;
    ll p=1;
    for(int i=1;i<=1e7;i++){
        p=p*10;
        ll sum=(p-1)*7;
        if(sum%mod==0){
            cout<<i<<endl;
            return 0;
        }
        p=p%mod;
    }
    cout<<-1<<endl;

    return 0;
}




Measured memory_bytes: 3636
s = int(input())
dp =[0]*2001
dp[0] = dp[1] = dp[2] = 0
dp[3] = dp[4] = dp[5] = 1
dp[6] = dp[3]+1
for i in range(7,s+1):
    dp[i] = dp[i-1]+dp[i-3]
print(dp[s] % (10**9+7))

Measured memory_bytes: 9160
#include <iostream>
#include <set>

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

int main() {
  int n;
  std::cin >> n;
  std::set<std::string> all;

  all.clear();
  std::string s;
  rep(i, n) {
    std::cin >> s;
    all.insert(s);
  }

  std::cout << all.size() << '\n';
  return 0;
}


Measured memory_bytes: 19224
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//






int main(void) {
    
    int A, B; cin >> A >> B;
    int ans = 0;
    while (ans * (A - 1) < B - 1) ++ans;
    out(ans);

    
    return 0;
}






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

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    int h, a, ans = 0;
    cin >> h >> a;
    ans = (h + a - 1) / a;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;

public class Main
{
  public static void main
  (
    String[] args
  )
  {
    BufferedReader in_stream;
    String         in_str;
    String[]       in_str_split;

    int   in_N;
    int[] in_d;

    int                cnt;
    ArrayList<Integer> kind;
    HashSet<Integer>   unique;


    try
    {
      in_stream    = new BufferedReader(new InputStreamReader(System.in));
      in_str       = new String(in_stream.readLine());
      in_str_split = in_str.split(" ");

      in_N = Integer.parseInt(in_str_split[0]);

      in_d = new int[in_N];
      kind = new ArrayList<Integer>();
      for(cnt=0; cnt<in_N; cnt++)
      {
        in_str       = new String(in_stream.readLine());
        in_str_split = in_str.split(" ");
        kind.add(Integer.valueOf(in_str_split[0]));
      }

      unique = new HashSet<Integer>(kind);


      UtilLog.ans_ln("" + unique.size());
    }
    catch(Exception e)
    {
      e.printStackTrace();
    }
  }



}


class UtilLog
{
  private static boolean is_debug_mode = false;



  public static void ans_ln
  (
    String i_message
  )
  {
    System.out.println(i_message);
  }



  public static void ans_f
  (
    String i_message
  )
  {
    System.out.printf(i_message);
  }



  public static void inf_ln
  (
    String i_message
  )
  {
    StackTraceElement[] stack;


    if(is_debug_mode)
    {
    stack = new Throwable().getStackTrace();

    System.out.println
      (
        String.format
          (
            "[inf][%s:%s():%5d]",
            stack[1].getClassName(),
            stack[1].getMethodName(),
            stack[1].getLineNumber(),
            i_message
          )
      );
    }
  }
}


Measured memory_bytes: 21332
#include <stdio.h>
#define REP(i, a, b) for(int i = a; i < b; i++)

long long int compare(const void* a, const void* b) {
    return *(long long int*)b - *(long long int*)a;
}

int main(void) {
    char a[3][4];
    REP(i, 0, 3) {
        scanf("%s", a[i]);
    }
    printf("%c%c%c\n", a[0][0], a[1][1], a[2][2]);
    return 0;
}

Measured memory_bytes: 128
import java.io.IOException;
import java.util.Scanner;

public class Main{
	public static void main (String[] args){
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		
		if (a < b){
			System.out.println("a < b");
		}else if(a == b){
			System.out.println("a == b");
		}else{
			System.out.println("a > b");
		}
		
	}
}

Measured memory_bytes: 26108
#include<bits/stdc++.h>
using namespace std;
#define debug(x)        cout<<#x<<" :"<<x<<endl;
#define ff              first
#define ss              second
#define ar              array
#define int             long long
#define ld              long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define f(i,n)          for(int i=0;i<n;i++)
#define MOD             1000000007
#define pi              3.14159265
#define umii            unordered_map<int,int>
#define umci            unordered_map<char,int>
#define umsi            unordered_map<string,int>

void k_007()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#ifndef ONLINE_JUDGE
  freopen("ip1.txt", "r", stdin);
  freopen("op1.txt", "w", stdout);
#endif
}

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b)
{
  return (a.second < b.second);
}
int gcd(int a, int b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
int prime(int n) {
  int flag = 1;
  for (int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {flag = 0; break;}
  }
  return flag;
}
int power(int x, int y)
{
  if (y == 0)
    return 1;
  else if (y % 2 == 0)
    return ((power(x, y / 2) % MOD) * ( power(x, y / 2) % MOD)) % MOD;
  else
    return ((x % MOD) * (power(x, y / 2) % MOD) * (power(x, y / 2) % MOD)) % MOD;
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}

int32_t main()
{
  k_007();
  int n, m;
  cin >> n >> m;
  int a[m];
  int busy = 0;
  f(i, m)
  {
    cin >> a[i];
    busy += a[i];
  }

  if (busy > n)
  {
    cout << -1 << endl;
    return 0;
  }

  cout << n - busy << endl;

}


Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
using ll = long long;

int main() {
	ll n;
	cin >> n;
	set<string> ss;
	rep(i, n) {
		string s;
		cin >> s;
		ss.insert(s);
	}
	cout << ss.size() << endl;
	return 0;
}


Measured memory_bytes: 19180
#include <iostream>
#include <string>

using lli=long long;
const int mod=1000000007;

int main(){
  int N;
  std::cin >> N;

  std::string S1,S2;
  std::cin >> S1 >> S2;

  lli ans = 0;
  bool prev_v = false;
  for(int i = 0; i < N; i++){
    if(S1[i] == S2[i]){
      if(i == 0) ans = 3;
      else if(prev_v) ans *= 2;
      prev_v = true;
    }else{
      if(i == 0) ans = 6;
      else if(prev_v) ans *= 2;
      else ans *= 3;
      prev_v = false;
      i++;
    }
    ans %= mod;
  }
  std::cout << ans << std::endl;

  return 0;
}



Measured memory_bytes: 256
classes = {
  'light fly' => 48,
  'fly' => 51,
  'bantam' => 54,
  'feather' => 57,
  'light' => 60,
  'light welter' => 64,
  'welter' => 69,
  'light middle' => 75,
  'middle' => 81,
  'light heavy' => 91,
  'heavy' => Float::INFINITY
}

while line = gets
  weight = line.chomp.to_f
  classes.each do |key, value|
    if weight <= value
       puts key
      break
    end
  end
end

Measured memory_bytes: 8596
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define MP make_pair
typedef long long ll;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

/*** chmax, chmin ***/
// a < b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b; 
		return true;
	}
	return false;
}
// a > b ならば a を b で更新
// 更新されたら true を返す
template <typename T>
bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b; 
		return true;
	}
	return false;
}
/*** chmax, chmin ここまで ***/

int h, w;
queue<pii> q;
int seen[1001][1001];
int cnt[1001][1001];

void bfs(int x, int y, vvi &data){
	int dx[] = {0,0,1,-1};
  	int dy[] = {1,-1,0,0};

  	seen[x][y] = 1;
    rep(i,4){
    	int tempx = x+dx[i];
      	int tempy = y+dy[i];
      	if(tempx >= 0 && tempx < h && tempy >= 0 && tempy < w &&
            data[tempx][tempy] == 0 && seen[tempx][tempy] == 0){
        	q.push(MP(tempx,tempy));
        	seen[tempx][tempy] = 1;
            cnt[tempx][tempy] = cnt[x][y]+1;
        } 
    }
  	return;
}

void Main()
{
  	cin >> h >> w;
  	vector<string> A(h);
	vvi data(h, vector<int>(w,0));
  	rep(i,h) {
      	cin >> A[i];
      	rep(j,w){
      		if(A[i][j] == '#') {
              	data[i][j] = 1;
              	q.push(MP(i,j));
              	cnt[i][j] = 0;
            }
        }
    }
  	int ans;

  	while(!q.empty()){
    	int i = q.front().first;
      	int j = q.front().second;
      	q.pop();
      	bfs(i,j,data);
    }
  	  
  	int mx = 0;
  	rep(i,h){
    	rep(j,w){
        	chmax(mx,cnt[i][j]);
        }
    }
  
  	cout << mx << endl;  	
	return;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}


Measured memory_bytes: 21264
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <iostream>

using namespace std;
typedef long long ll;

int mo[5]={0,1,0,-1,0};
int ans,n,X1[1000],X2[1000],Y1[1000],Y2[1000],mm[2010][2010]={0};

void calc(int w,int h){
    
    for(int i=0;i<2010;i++)
        for(int j=0;j<2010;j++)
            mm[i][j]=0;
    
    ans=0;
    
    vector<int> x,y;
    map<int,int> mx,my;
    
    scanf("%d",&n);
    
    for(int i=0;i<n;i++){
        scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
        
        x.push_back(X1[i]);
        x.push_back(X2[i]);
        y.push_back(Y1[i]);
        y.push_back(Y2[i]);
    }
    
    x.push_back(0);
    x.push_back(w);
    y.push_back(0);
    y.push_back(h);
    
    sort(x.begin(),x.end());
    sort(y.begin(),y.end());
    x.erase(unique(x.begin(),x.end()),x.end());
    y.erase(unique(y.begin(),y.end()),y.end());
    
    for(int i=0;i<x.size();i++){
        mx[x[i]]=i;
    }
    for(int i=0;i<y.size();i++){
        my[y[i]]=i;
    }
    
    for(int i=0;i<n;i++){
        mm[my[Y1[i]]][mx[X1[i]]]++;
        mm[my[Y1[i]]][mx[X2[i]]]--;
        mm[my[Y2[i]]][mx[X1[i]]]--;
        mm[my[Y2[i]]][mx[X2[i]]]++;
    }
    
    for(int i=0;i<y.size();i++){
        for(int j=0;j<x.size();j++){
            mm[i][j+1]+=mm[i][j];
        }
    }
    
    for(int i=0;i<x.size();i++){
        for(int j=0;j<y.size();j++){
            mm[j+1][i]+=mm[j][i];
        }
    }
    
    
    for(int i=0;i<y.size()-1;i++){
        for(int j=0;j<x.size()-1;j++){
            if(mm[i][j]>0) continue;
            
            queue<pair<int,int> > q;
            q.push(make_pair(i,j));
            mm[i][j]=1;
            ans++;
            
            while(!q.empty()){
                pair<int,int> p = q.front();
                q.pop();
                
                for(int k=0;k<4;k++){
                    if(0<=p.first+mo[k] && p.first+mo[k]<y.size()-1 && 0<=p.second+mo[k+1] && p.second+mo[k+1]<x.size()-1){
                        if(mm[p.first+mo[k]][p.second+mo[k+1]]==0){
                            q.push(make_pair(p.first+mo[k],p.second+mo[k+1]));
                            mm[p.first+mo[k]][p.second+mo[k+1]]=1;
                        }
                    }
                }
            }
        }
    }
    
    printf("%d\n",ans);
    
    return;
}

int main(){
    int w,h;
    
    while(1){
        scanf("%d%d",&w,&h);
        if(w==0) break;
        calc(w,h);
    }
    
    return 0;
}

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

/* */

int main(){
    // 入力スタンダード
    int n;
    cin >> n ;

    ll sum=0;
    for(int i=1; i<n+1; i++){
        if(!(i%3==0 || i%5==0)){
            sum += i;
        }
    }
    cout << sum <<endl;

    return 0;
}

Measured memory_bytes: 3568
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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

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

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int A, B, X;

int main() {
  cin >> A >> B >> X;
  if (A <= X && X <= A + B)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}

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

int main () {
  int a , b ;
  cin >> a >> b ;
  
  if(a*b==15) {
    cout << "*" << endl ;
  } else if (a+b == 15 ) {
    cout << "+" << endl ;
  } else {
    cout << 'x' << endl ;
  }
}

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

int main()
{
    int a, b;
    cin >> a >> b;
    int sum = a + b;
    int mul = a * b;
    int sub = a - b;
    int Max = sum;
    Max = max(Max, mul);
    Max = max(Max, sub);
    cout << Max << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 *
 *   Author     : Amit Kumar
 *   Date    	: June 4 2019
 * 
 */

#include <bits/stdc++.h>

//#define FAST_INPUT_OUTPUT
//#define MORE_THAN_ONE_TESTCASE // COMMENT IT

#define vi vector<int>
#define vl vector<long long>
#define mii map<int , int>
#define mll map<long long , long long>
#define msi map<string , i>
#define msl map<string , long long>
#define umii unordered_map<int,int>
#define umll unordered_map<long long ,long long>
#define umsi unordered_map<string , int>
#define umsl map<string , long long> 
#define si set<int>
#define sl set<long long>
#define pii pair<int , int >
#define psi pair<string,int>
#define psl pair<string , long > 
#define pll pair<long long , long long>
#define vpii vector<pii>
#define vpll vector<pll>
#define vpsi vector<psi>
#define vpsl vector<psl>
#define pqi priority_queue<int>
#define pql priority_queue<long long>
#define ub upper_bound
#define lb lower_bound
#define bint long long int
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define iv(v) for(auto &i:v){cin>>i;}
#define ov(v) for(auto i:v){cout<<i<<" ";}cout<<endl;
#define ovn(v) for(auto i:v){cout<<i<<endl;}
#define euv(v) for(auto i:v){cerr<<i<<" ";}cerr<<endl;
#define eovn(v) for(auto i:v){cerr<<i<<endl;}
#define os(s) for(auto itr:s){cout<<itr<<" ";}cout<<endl;
#define osn(s) for(auto itr:s){cout<<itr<<endl;}
#define eos(s) for(auto itr:s){cerr<<itr<<" ";}cerr<<endl;
#define eosn(s) for(auto itr:s){cerr<<itr<<endl;}
#define rep(x) for(auto i=0 ; i<(x); ++i)
#define _rep(a,b) for(auto i=(a); i<(b); ++i)
#define endl '\n'
using namespace std;




auto SOLUTION_FUNCTION( void ) ->void {

    // your solution goes here 

    bint x , y , z ;
    bint K ;

    cin>>x>>y>>z>>K;

    vl a(x);
    iv(a);
    vl b(y);
    iv(b);
    vl c(z);
    iv(c);

    sort(all(a),greater<bint>());
    sort(all(b),greater<bint>());
    sort(all(c),greater<bint>());


    vl ans;

    for(int i=0; i<x; ++i){
        for(int j=0; j<y; ++j){
            for(int k=0; k<z; ++k){
                if((i+1) * (j+1)* (k+1)<=K){
                    ans.pb(a[i]+b[j]+c[k]);
                }else{
                    break;
                }
            }
        }
    }


    sort(all(ans),greater<bint>());

    rep(K){
        cout<<ans[i]<<endl;
    }

    return ;
}




int main(void){
#ifdef FAST_INPUT_OUTPUT
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout<<setprecision(10);
    cout<<fixed;
    cout<<boolalpha;
#endif
#ifdef MY_LOCAL_PROJECT
    freopen("din","r",stdin);
    freopen("dout","w",stdout);
#endif
    int testcase = 1;


#ifdef MORE_THAN_ONE_TESTCASE
    cin>>testcase;
#endif
    
    while(testcase--){
        SOLUTION_FUNCTION();
    }

#ifdef MY_LOCAL_PROJECT
    cout<<"Time : "<<1.0*(double)clock()/CLOCKS_PER_SEC<<endl;
#endif
    return 0;
}


Measured memory_bytes: 1404
<?php
	fscanf(STDIN, "%d", $X);

	for ($i = $X; $i < $X*2; $i++) {
      
      $isPrime = true;
      for ($j = 2; $j < $i; $j++) {
        if ($i % $j === 0) {
          $isPrime = false;
          break;
        }
      }
      if ($isPrime) {
        echo ($i);
       	break;
      }
    }
?>


Measured memory_bytes: 4604
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
  
use std::collections::VecDeque;
fn main() {
    input!{
        n:usize,
        m:usize,
        uv: [[usize1;2];m],
        st: [usize1;2]
    }
    // 0-indexed
    let mut graph = vec![vec![];n];
    let s = st[0];
    let t = st[1];
    for i in 0..m{
        graph[uv[i][0]].push(uv[i][1]);
    }
    // println!("{:?}", graph);
    let mut done = vec![vec![false;3];n];
    let mut dist = vec![vec![None;3];n];
    dist[s][0] = Some(0);
    let mut que = VecDeque::<(usize, usize)>::new();
    que.push_back((s,0));
    while let Some((g, r)) = que.pop_front() {
        let parity = r%3;
        if done[g][parity] {
            continue;
        }
        done[g][parity] = true;
        dist[g][parity] = Some(r);
        for i in 0..graph[g].len() {
            let f = graph[g][i];
            let par = r+1;
            que.push_back((f, par));
        }
    }
    match dist[t][0] {
        None => println!("-1"),
        Some(d) => println!("{}", d/3),
    }
}

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

using namespace std;

const double EPS = 1e-8;

int sign(double x){
    if(x > EPS) return 1;
    if(x < -EPS) return -1;
    return 0;
}
typedef complex<double> Point;
typedef vector<Point> Polygon;
struct Line : public vector<Point> {
    Line(const Point& a, const Point& b) {
        push_back(a); push_back(b);
    }
    Point vector() const {
        return back() - front();
    }
};
double dot(Point a, Point b){
    return real(conj(a) * b);
}
double cross(Point a, Point b){
    return imag(conj(a) * b);
}
int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if (cross(b, c) > EPS)   return +1; // 反時計回り
    if (cross(b, c) < -EPS)   return -1; // 時計回り
    if (dot(b, c) < 0)     return +2; // c--a--b の順番で一直線上
    if (norm(b) < norm(c)) return -2; // a--b--c の順番で一直線上
    return 0;                         // 点が線分ab上にある
}
Point crosspointLL(Line l, Line m){
    double A = cross(l.vector(), m.vector());
    double B = cross(l.vector(), l[1] - m[0]);
    if(sign(A) == 0 && sign(B) == 0) return m[0]; // 二直線が重なっている
    if(sign(A) == 0) assert(false); // 直線が交わらない
    return m[0] + m.vector() * B / A;
}

inline Point curr(const Polygon& P, int k){ return P[k]; }
inline Point next(const Polygon& P, int k){ return P[(k + 1) % P.size()]; }
Polygon convex_cut(const Polygon& P, Line l){
    Polygon Q;
    for(int i = 0; i < P.size(); i++){
        Point A = curr(P, i), B = next(P, i);
        if(ccw(l[0], l[1], A) != -1) Q.push_back(A); //Aが直線lの右側でない
        if(ccw(l[0], l[1], A) * ccw(l[0], l[1], B) < 0)
            Q.push_back(crosspointLL(l, Line(A, B)));
    }
    return Q;
}

Point rotate(Point a, double b){
    return a * polar(1.0, b);
}

int main(){
    int N;
    while(cin >> N && N){
        Polygon P;
        REP(i, N){
            double x, y;
            cin >> x >> y;
            P.push_back(Point(x, y));
        }
        double lb = 0, ub = 100000;
        REP(iter, 100){
            double len = (lb + ub) / 2;
            Polygon Q = P;
            REP(i, N){
                Line l(curr(P, i), next(P, i));
                Line l2(l[0] + polar(len, arg(l.vector()) + M_PI/2), l[1] + polar(len, arg(l.vector()) + M_PI/2));
                Q = convex_cut(Q, l2);
            }
            if(Q.empty()){
                ub = len;
            }else{
                lb = len;
            }
        }
        printf("%.12f\n", lb);
    }
    return 0;
}

Measured memory_bytes: 1336
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007

char S[10];
signed main(){
    scanf("%s",&S);
    if(S[2]==S[3]&&S[4]==S[5]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
int main()
{
    string s;
    cin >> s;
    int size = s.size();
    int sum = 0;
    for (int i = 0; i < s.length(); i++) 
	{
        if (s[i] == 'S') 
		{
                sum++;
        }
        if (s[i] == 'T') 
		{
            if (sum > 0) 
			{
                sum--;
                size -= 2;
            }
        }
    }
    cout << size << endl;
    return 0;
}

Measured memory_bytes: 640
n=int(input())
ei="$abcdefghijklmnopqrstuvwxyz"
fla=[]
flaa=[0]
ans=""
cnt=2

for i in range(1,20):
    fla.append(26**i)
    flaa.append(flaa[i-1]+26**i)
for i in range(20):
    if n<=flaa[i]:
        k=i
        break
# print(flaa,k)
if k==1:
    print(ei[n])
    exit()

b=n-flaa[k-1]
# print(b)
while len(ans)!=k-1:
    for i in range(1,27):
        if fla[k-cnt]*i>=b:
            ans+=str(ei[i])
            b-=fla[k-cnt]*(i-1)
            cnt+=1
            # print(b)
            break
ans+=str(ei[b])

print(ans)


Measured memory_bytes: 61792
#include <stdio.h>

int main(void){
  int n, m, i, j;
  scanf("%d %d", &n, &m);
  int r[2][m];
  for(i = 0; i < m; i++) scanf("%d %d", &r[0][i], &r[1][i]);
  int ans[n];
  int num;
  for(j = 0; j < n; j++){
    num = 0;
    for(i = 0; i < m; i++){
      if(r[0][i] == j + 1 || r[1][i] == j + 1) num++;
    }
    ans[j] = num;
  }
  for(i = 0; i < n; i++) printf("%d\n", ans[i]);
  return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------

using pii = pair<int, int>;
int n;
int rui[11111];

int main() {
   iota(rui, rui+1111, 0);
   repp (i, 1, 1111) rui[i] += rui[i-1];

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

      int cnt = 0;
      for (int i = 1; i <= n; i++) {
         for (int j = i; j <= n; j++) {
            if (j-i < 1) continue;
            int sum = rui[j] - rui[i-1];
            if (sum == n) {
               cnt++;
            }
         }
      }
      cout << cnt << endl;
   }

   return 0;
}


Measured memory_bytes: 2992
i;double a,b,c,d,e,f,k;main(){for(i=0;~scanf("%lf",&f);){if(++i%6==0)k=(c*d-a*f)/(b*d-e*a),printf("%.3lf %.3lf\n",(c-(b*k))/a,k);a=b,b=c,c=d,d=e,e=f;}}

Measured memory_bytes: 1856
#include <stdio.h>

#define MAX 100000
typedef long long llong;
int n, k;
llong T[MAX];

int check(llong P) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong s = 0;
		while (s + T[i] <= P) {
			s += T[i];
			i++;
			if (i == n) return n;
		}
	}
	return i;
}

llong solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n) right = mid;
		else left = mid;
	}
	return right;
}

int main() {
	int i;
	llong ans;
	scanf("%d %d", &n, &k);
	for (i = 0; i < n; i++) scanf("%d", &T[i]);
	ans = solve();
	printf("%lld\n", ans);
	return 0;
}


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


long long int calc_val(char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}

long long int dp[10000001][2];
//ピッタリ払うときの最小
//1余分に払うときの最小

int main(void){
    string n;
    int tmp;
    cin >>n;

    tmp = calc_val( n[0] );

    dp[0][0] += tmp;
    dp[0][1] += 1+ (10-tmp);
       //cout << dp[0][0] << " " << dp[0][1] << endl;


    for(int i=1; i<n.size();i++){
        tmp = calc_val( n[i] );
        //ピッタリ払うときの最小
        dp[i][0] += min( dp[i-1][0] + tmp ,
                         dp[i-1][1] + tmp );
        //1余分に払うときの最小
        dp[i][1] += min( 
                    ( dp[i-1][0] + 1 + (10-tmp) ) , 
                    ( dp[i-1][1] - 1 + (10-tmp) )
                    );
       //cout << dp[i][0] << " " << dp[i][1] << endl;
    }

    cout << min(dp[n.size()-1][0],dp[n.size()-1][1]) << endl;

    return 0;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1e9 + 7

using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(void)
{
    int a, b;
    cin >> a >> b;
    cout << (a - 1) * (b - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
from itertools import permutations

def warshall_floyd(A, INF=10**20):
    d = [[INF for i in range(len(A))] for j in range(len(A))]
    for i in range(len(A)):
        d[i][i] = 0
        for j in A[i].keys():
          d[i][j] = A[i][j]

    for k in range(len(A)):
        for i in range(len(A)):
            for j in range(len(A)):
                d[i][j] = min(d[i][j], d[i][k]+d[k][j])
    
    return d
  
N,M,R=map(int,input().split())
r = list(map(int,input().split()))
r2 = []
for i in range(len(r)):
  r2.append(r[i]-1)
r = r2
G=[{} for _ in range(N)]
for i in range(M):
  a,b,c=map(int,input().split())
  a -= 1
  b -= 1
  G[a][b] = G[b][a] = c

d = warshall_floyd(G)

if R==2:
  print(d[r[0]][r[1]])
  exit()
  
ans = 10**20
for p in permutations(r):
  dist=0
  for i in range(R-1):
    dist += d[p[i]][p[i+1]]
  ans = min(ans,dist)
  
print(ans)

Measured memory_bytes: 78268
// C - Numbers on a Circle
#include <bits/stdc++.h>
 
using namespace std;
 
int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
 
	int n;
	cin >> n;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];
	set<pair<int, int>, greater<pair<int, int> > > s;
	for (int i = 0; i < n; i++) s.insert(make_pair(b[i], i));
 
	long long ans = 0;
	while (!s.empty()) {
		int i = s.begin()->second;
		s.erase(s.begin());
		int d = b[i] - a[i], t = b[(i + 1) % n] + b[(i - 1 + n) % n];
		if (d != 0 && d < t) {
			ans = -1;
			break;
		}
		ans += d / t;
		b[i] -= d / t * t;
		if (b[i] != a[i]) s.insert(make_pair(b[i], i));
	}
 
	cout << ans << endl;
 
	return 0;
}

Measured memory_bytes: 13312
#include<cctype>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cmath>
#include<cassert>
#include<algorithm>
#include<numeric>
#include<vector>
#include<string>
#include<map>
#include<unordered_map>
#include<queue>
#include<tuple>
using namespace std;
typedef long long int lnt;
typedef unsigned long long int unt;
typedef unsigned ust;
typedef double dou;
typedef pair<int,int> P;
#define FZ(i,n)       for(int i=0;i<(n);++i)
#define FB(i,n)       for(int i=(n)-1;i>=0;--i)
#define FV(i,st,ed)   for(int i=st;i<(ed);++i)
#define FC(i,n)       for(int i=n;i;--i)
#define FZU(i,n)      for(ust i=0;i!=(n);++i)
#define FVU(i,st,ed)  for(ust i=st;i<(ed);++i)
#define FCU(i,n)      for(ust i=n;i;--i)
#define SZ(x)         ((int)x.size())
#define ALL(x)        std::begin(x),std::end(x)
#define likely(x)     __builtin_expect(!!(x), 1)
#define unlikely(x)   __builtin_expect(!!(x), 0)

#define RI(x) scanf("%d",&(x))
#define RII(x,y) scanf("%d %d",&(x),&(y))
#define RS(x) scanf("%s",x)
#define RI64(x) scanf("%I64d",&(x))
#define RII64(x,y) scanf("%I64d%I64d",&(x),&(y))

#define FIR first
#define SEC second
#define pritnf printf
constexpr ust N = 100514u;
P a[N];
bool sol(){
    int k,n;
    if(RII(k,n)==EOF)return 0;
    FZ(i,n){
        RI(a[i].FIR);
        a[i].SEC = i;
    }
    make_heap(a,a+n);
    int ans = 0, last = -1;
    for(;n;){
        auto w = a[0]; pop_heap(a,a+n); n--;
        if(w.SEC==last){
            if(n){
                auto x = a[0]; pop_heap(a,a+n); n--;
                last = x.SEC;
                if(x.FIR!=1){
                    x.FIR--;
                    a[n++] = x;
                    push_heap(a,a+n);
                }
                a[n++] = w;
                push_heap(a,a+n);
            }else{
                last = w.SEC;
                ans++;
                if(w.FIR!=1){
                    w.FIR--;
                    a[n++] = w;
                    push_heap(a,a+n);
                }
            }
        }else{
            last = w.SEC;
            if(w.FIR!=1){
                w.FIR--;
                a[n++] = w;
                push_heap(a,a+n);
            }
        }
    }
    printf("%d\n",ans);
    return 1;
}
int main(){
    while(sol());
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int N, A[50];
int calc(int i,int M)
{
  if(M==0) return 1;
  if(i>=N) return 0;
  int answer = calc(i+1, M) || calc(i+1, M - A[i]);
  return answer;
}

int main()
{
  //input
  int M, q, ornot;
  scanf("%d", &N);
  for(int i=0; i<N; i++) scanf("%d", &A[i]);
  scanf("%d", &q);
  for(int i=0; i<q; i++)
  {
    scanf("%d", &M);
    if(calc(0, M) == 1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}



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

int main(){
   ll x,k,d;
   cin >> x >> k >> d;
   ll ans=x;
   if(x<0){
      ans = -x;
   }
   
   if(ans/d>=k){
      ans -= k*d;
   }else{
      if((k-(ans/d))%2==0){
         ans = ans%d;
      }else{
         ans = d - ans%d; 
      }
   }
   cout << ans << endl;
   return 0;  
}

Measured memory_bytes: 3620
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn set_mark(a: &mut Vec<Vec<u32>>, b: u32){
    for i in 0..3{
        for j in 0..3{
            if a[i][j] == b{
                a[i][j] = 0;
                return;
            }
        }
    }
}

fn is_bingo(a: &Vec<Vec<u32>>) -> bool{
    if a[0][0] == 0 && a[1][1] == 0 && a[2][2] == 0{
        return true;
    }

    if a[0][2] == 0 && a[1][1] == 0 && a[2][0] == 0{
        return true;
    }

    for i in 0..3{
        let mut bflag = true;
        for j in 0..3{
            if a[i][j] != 0{
                bflag = false;
            }
        }
        if bflag{
            return true;
        }
    }

    for i in 0..3{
        let mut bflag = true;
        for j in 0..3{
            if a[j][i] != 0{
                bflag = false;
            }
        }
        if bflag{
            return true;
        }
    }

    return false;
}

fn main(){
    let mut a: Vec<Vec<u32>> = vec![];

    for _ in 0..3{
        a.push(read_as_vec());
    }

    let n : usize = read_as_vec()[0];


    for _ in 0..n{
        let b: u32 = read_as_vec()[0];
        set_mark(&mut a, b);
    }

    if is_bingo(&a){
        println!("Yes");
    }else{
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) { a = b; return 1; }
  return 0; }
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) { a = b; return 1; }
  return 0; }

int main(void){
  int n; cin >> n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  rep(i,n){
    string s;
    cin >> s;
    if(s == "AC") ac++;
    else if(s == "WA") wa++;
    else if(s == "TLE") tle++;
    else re++;
  }
  cout << "AC x " << ac << endl;
  cout << "WA x " << wa << endl;
  cout << "TLE x " << tle << endl;
  cout << "RE x " << re << endl;
  return 0;
}


Measured memory_bytes: 3624