akhauriyash/Code-Regression huggingface dataset:
D, G = [int(_) for _ in input().split()]
PC = [tuple(int(_) for _ in input().split()) for i in range(D)]

from itertools import product

def calc(D, G, PC, es):
    r = 0
    k = None
    result = 0
    for i, e, pc in zip(range(D), es, PC):
        if e:
            r += (i+1) * 100 * pc[0] + pc[1]
            result += pc[0]
        else:
            k = i
    if r >= G:
        return result, r
    if not k is None:
        d = (k+1)*100
        p = PC[k][0]
        if r + d * (p - 1) >= G:
            n = (G - r + d - 1) // d
            result += n
            r += n * d
            return result, r
    return None, None

result = 10**20

for es in product((0, 1), repeat=D):
    r, score = calc(D, G, PC, es)
    #print(D, G, PC, es, r, score)
    if not r is None:
        result = min(result, r)

print(result)


Measured memory_bytes: 3064
/*
このコード、と～おれ!
Be accepted!
  ∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	
	ll n, a[100001], b[100000], amount = 0;
	scanf("%lld", &n);
	rep(i, n + 1)scanf("%lld", &a[i]);
	rep(i, n)scanf("%lld", &b[i]);

	repr(i, n - 1) {
		if (b[i] >= a[i + 1]) {
			b[i] -= a[i + 1];
			amount += a[i + 1];
			a[i + 1] = 0;
		}
		else {
			a[i + 1] -= b[i];
			amount += b[i];
			b[i] = 0;
		}
		if (b[i] >= a[i]) {
			b[i] -= a[i];
			amount += a[i];
			a[i] = 0;
		}
		else {
			a[i] -= b[i];
			amount += b[i];
			b[i] = 0;
		}
	}

	printf("%lld\n", amount);
	return 0;
}


Measured memory_bytes: 1664
while True:
    a,b = map(int,input().split())
    if a==0 and b == 0:break
    for i in range(a):
        for j in range(b):
            
            if (i+j)%2 == 0:
                print('#',end = "")
            else:
                print('.',end = "")
        print()    
    print()
            


Measured memory_bytes: 7008
package main

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


var sc = bufio.NewScanner(os.Stdin)
func nextInt() int {
    sc.Scan()
    i, e := strconv.Atoi(sc.Text())
    if e != nil {
        panic(e)
    }
    return i
}

func main() {
  sc.Split(bufio.ScanWords)
  n := nextInt()
  m := nextInt()
  if m == 0 {
    if n == 1 {
      fmt.Println(0)
    } else {
      fmt.Println(int(math.Pow(10, float64(n-1))))
    }
    return
  }
  var cex map[int]bool = map[int]bool{}
  var cs map[int]int = map[int]int{}
  for i := 0; i < m; i++ {
    s := nextInt()
    c := nextInt()
    if n != 1 && s == 1 && c == 0 {
      fmt.Println(-1)
      return
    }
    if cex[s] && cs[s] != c {
      fmt.Println(-1)
      return
    }
    cex[s] = true
    cs[s] = c
  }
  ans := 0
  min := 5
  for s, c := range cs {
    if s < min {
      min = s
    }
    ans += c * int(math.Pow(10, float64(n - s)))
  }
  if min != 1 {
    ans += int(math.Pow(10, float64(n-1)))
  }
  fmt.Println(ans)
}


Measured memory_bytes: 640
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

C = collections.Counter()
n = int(input())
C0 = 10**2+10
for i in range(1,C0):
  for j in range(1,C0):
    for k in range(1,C0):
      C[i**2+j**2+k**2+i*j+j*k+k*i] += 1
for i in range(1,n+1):
  print(C[i])

Measured memory_bytes: 75152
K = int(input())
L = [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]
print(L[K-1])


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

int  main()
{
	long n; cin >> n;
	vector <long> a(n);
	vector <long> b(1000001, 0);
	set <long> st;
	long mx = 0;
	rep(i, n)
	{
		cin >> a[i];
		mx = max(a[i], mx);
	}
	rep(i, n)
	{
		for (int j = a[i]; j <= mx; j += a[i])
			b[j]++;
	}
	long ans = 0;
	rep(i, n)
	{
		if (b[a[i]] <= 1)
		{
			ans++;
		}
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 12632
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int d(int, int);
int dd(int, int);

int main(){
  int a, b;
  while(cin >> a >> b)
  {
    printf("%d %d\n", d(a, b), dd(a, b));
  }
  return 0;
}

int d(int a, int b)
{
  if(a == 0)
    return b;
  if(b == 0)
    return a;
  if(a > b)
  {
    return d(b, a % b);
  }
  else
    return d(a, b % a);
}

int dd(int a, int b)
{
  return a  / d(a, b) * b;
}

Measured memory_bytes: 1144
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
struct Edge {
  ll to;
  ll cost;
};
int main() {
  ll X, N;
  cin >> X >> N;
  map<int, int> fb{};
  REP(i, N) {
    int a;
    cin >> a;
    fb[a] = 1;
  }
  ll mn=INF,ID=0;
  for (int i = -200; i <= 200; i++) {
    if (fb[i] == 1) continue;
    if(abs(i-X)<mn){
      mn = abs(i - X);
      ID = i;
    }
  }
  cout << ID << endl;
}

Measured memory_bytes: 3648
#include <iostream>
using namespace std;
int main () {

	int n, t, x, y;
	cin >> n;
	int v = 0, p1 = 0, p2 = 0;
	for (int i = 0; i < n; i ++) {
		cin >> t >> x >> y;
		if (t-v < abs(p1 - x)+abs(p2 - y) ) {
			cout << "No";
			return 0;
		}
		if ((t-v) % 2 != (abs(p1 - x)+abs(p2 - y)) % 2 ) {
			cout << "No";
			return 0;
		}
	}
	cout << "Yes";

	return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<queue>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 1000010
int arr[1000]={0};
int main(){
    int n;
    cin >>n;
    //cout<<n<<endl;
    for(int i=1;i<=n;i++){
        cin >>arr[i];
    }
    vector<int>v;
    for(int i=1;i<=n;i++){
        if(arr[i]>i)
        return cout<<-1<<endl,0;
        int k = arr[i];
        v.insert(v.begin()+k-1,k);
    }
    for(auto it = v.begin();it!=v.end();it++){
        cout<<*it<<endl;
    }

    return 0;
}



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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    while (true) {
        cin >> N;
        if (N == 0) break;
        vector<int> eratosutenesu;
        int furui = int(sqrt(2 * N));
        for (int i = 2; i <= furui; i++) {
            bool f = true;
            for (auto e : eratosutenesu) {
                if (i % e == 0) f = false;
            }
            if (f) eratosutenesu.push_back(i);
        }
        int ans = 0;
        for (int i = N + 1; i <= 2 * N; i++) {
            bool f = true;
            for (auto e : eratosutenesu) {
                if (i % e == 0) f = false;
            }
            if (f) ans++;
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <map>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<ll> Vec;
typedef vector<Vec> Mat;
const ll MOD = 1000000009LL;
Mat mul(const Mat& m1, const Mat& m2){
    int N = m1.size();
    int M = m2[0].size();
    int K = m1[0].size();
    Mat res(N, Vec(M, 0));
    for(int i = 0; i < N; i++){
        for(int k = 0; k < K; k++){
            for(int j = 0; j < M; j++){
                res[i][j] = (res[i][j] + m1[i][k] * m2[k][j]) % MOD;
            }
        }
    }
    return res;
}
Mat pow(Mat m, ll p){
    int N = m.size();
    Mat res(N, Vec(N, 0));
    for(int i = 0; i < N; i++) res[i][i] = 1;
    while(p > 0){
        if(p & 1) res = mul(res, m);
        m = mul(m, m);
        p >>= 1;
    }
    return res;
}
Mat make_mat(ll W, ll H){
    Mat m(W, Vec(W, 0));
    for(int i = 0; i < W; i++){
        for(int j = 0; j < W; j++){
            if(abs(i - j) <= 1) m[i][j] = 1;
        }
    }
    return pow(m, H);
}
Vec mul(const Vec& v, const Mat& m){
    int N = v.size();
    Vec res(N, 0);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            res[j] = (res[j] + v[i] * m[i][j]) % MOD;
        }
    }
    return res;
}
int main(){
    ll W, H, N;
    int casenum = 1;
    while(cin >> W >> H >> N && W){
        map<ll, vector<ll> > obs_dict;
        obs_dict[0] = vector<ll>();
        obs_dict[H - 1] = vector<ll>();
        while(N--){
            ll x, y;
            cin >> x >> y;
            obs_dict[y - 1].push_back(x - 1);
        }
        ll curr = 0;
        Vec v(W, 0);
        v[0] = 1;
        for(auto& kv : obs_dict){
            ll next = kv.first;
            vector<ll>& bad = kv.second;
            v = mul(v, make_mat(W, next - curr));
            for(auto bi : bad) v[bi] = 0;
            curr = next;
        }
        printf("Case %d: %lld\n", casenum++, v[W - 1]);
    }
}

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

int main(){
	 int a,b;
	 cin>>a>>b;
	 if (a>=13) cout<<b<<endl;
       else if(a>=6 && a<=12) cout<<b/2<<endl;
       else cout<<"0"<<endl;

	 	 return 0;
 }


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
    int n;
    char s[100100];

    while(~scanf("%s",s))
    {
        n = strlen(s);
        if(s[0] == s[n-1])
        {
            if(n%2 == 0) printf("First\n");
            else printf("Second\n");
        }
        else
        {
            if(n%2 == 0) printf("Second\n");
            else printf("First\n");
        }
    }
    return 0;
}





Measured memory_bytes: 384
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int N, K, ans = 0; cin >> N >> K;
    vector<int> A(N+1, 0);
    rep (i, 0, N) {
        int a; cin >> a;
        A.at(a)++;
    }
    sort(A.begin(), A.end());

    for (int j = 0; j < A.size() - K; j++) {
        ans += A.at(j);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int X; cin >> X;
    int A, B; cin >> A >> B;

    if (A >= B) {
        cout << "delicious" << endl;
    } else if (X - (B - A) >= 0) {
        cout << "safe" << endl;
    } else {
        cout << "dangerous" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3580
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int b, c;
            String[] str = Console.ReadLine().Split(' ');
            b = int.Parse(str[0]);  
            c = int.Parse(str[1]);
            String[] str2 = Console.ReadLine().Split(' ');
            int[] aa = new int[b];
            for (int i = 0; i < b; i++)
            {
                aa[i] = int.Parse(str2[i]);
            }
            int bb = b - c;
            int vv = bb / (c - 1) ;
            if (bb % (c - 1) > 0) vv++;

            Console.WriteLine(++vv);

        }
    }
}


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

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

    for(int i=1; i<n; i++) {
        string a = s.substr(0,i);
        string b = s.substr(i,n-i);
        int count = 0;
        for(char c = 'a'; c <= 'z'; c++) {
            if(a.find(c) != string::npos && b.find(c)!= string::npos) count++;
        }
        max_count = max(count, max_count);
    }
    cout << max_count << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
using namespace std;

typedef long long ll;
typedef pair<int, int> p;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9

int num[100000];

int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		num[tmp]++;
	}
	bool flag = true;
	if (N % 2 == 1) {
		// 入力が正しいかチェック
		if (num[0] != 1) flag = false;
		for (int i = 2; i < N && flag == true; i += 2) {
			if (num[i] != 2) flag = false;
		}
		if (!flag) cout << 0 << endl;
		else {
			ll ans = 1;
			for (int i = 0; i < N / 2; i++) ans = (ans * 2 % modulo);
			cout << ans << endl;
		}
	}
	else {
		for (int i = 1; i < N && flag == true; i += 2) {
			if (num[i] != 2) flag = false;
		}

		if (!flag) cout << 0 << endl;
		else {
			ll ans = 1;
			for (int i = 0; i < N / 2; i++) ans = (ans * 2 % modulo);
			cout << ans << endl;
		}
	}


	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,i;
  string u[100];
  long double x[100],ans=0;
  cin>>n;
  for(i=0;i<n;i++){
	cin>>x[i]>>u[i];
  }
  
  for(i=0;i<n;i++){
    if(u[i]=="JPY"){
      ans+=x[i];
    }else{
	  ans+=x[i]*380000.0;
    }
  }
  
  cout<<ans<<endl;
		
  
  
}


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

using namespace std;

class SegTree
{
public:
    SegTree(int size)
        : count_(4 * size + 4, 0), maxes_(4 * size + 4, 0), size_(size) {}

    void Add(int num) { Update(0, 0, size_ - 1, num, 1); }
    void Remove(int num) { Update(0, 0, size_ - 1, num, -1); }

    int GetSmaller(int num) const { return Get(0, 0, size_ - 1, num - 1); }

private:
    void Update(int node, int left, int right, int num, int mod);
    int Get(int node, int left, int right, int limit) const;

    int LeftSon(int node) const { return 2 * node + 1; }
    int RightSon(int node) const { return 2 * node + 2; }

    vector<int> count_;
    vector<int> maxes_;
    int size_;
};

void SegTree::Update(int node, int left, int right, int num, int mod)
{
    if (left == right) {
        count_[node] += mod;
        maxes_[node] = (count_[node] > 0 ? num : -1);
        return;
    }

    int mid = left + (right - left) / 2;
    if (num <= mid) {
        Update(LeftSon(node), left, mid, num, mod);
    } else {
        Update(RightSon(node), mid + 1, right, num, mod);
    }
    maxes_[node] = max(maxes_[LeftSon(node)], maxes_[RightSon(node)]);
}

int SegTree::Get(int node, int left, int right, int num) const
{
    if (left > num) {
        return -1;
    }
    if (right <= num) {
        return maxes_[node];
    }

    int mid = left + (right - left) / 2;
    int res = Get(LeftSon(node), left, mid, num);

    if (num > mid) {
        res = max(res, Get(RightSon(node), mid + 1, right, num));
    }
    return res;
}

int Find(const vector<int> &sorted, int val)
{
    int pos = -1;
    int pow = (1 << 25);

    while (pow > 0) {
        int next_pos = pos + pow;
        pow >>= 1;

        if (next_pos < (int)sorted.size() && sorted[next_pos] <= val) {
            pos = next_pos;
        }
    }
    return pos;
}

int Normalise(vector<int> &vec)
{
    vector<int> sorted(vec.begin(), vec.end());
    sort(sorted.begin(), sorted.end());

    int index = 0;
    for (size_t i = 0; i < sorted.size(); i += 1) {
        if (i == 0 || sorted[i] != sorted[i - 1]) {
            sorted[index] = sorted[i];
            index += 1;
        }
    }
    sorted.resize(index);

    for (auto &num : vec) {
        num = Find(sorted, num);
    }
    return sorted.size();
}

bool Valid(vector<int> &vec, int n)
{
    int distinct = Normalise(vec);
    sort(vec.begin(), vec.end(), greater<int>());

    SegTree tree(distinct);
    for (size_t i = 1; i < vec.size(); i += 1) {
        tree.Add(vec[i]);
    }

    vector<int> slimes{vec[0]};
    while (slimes.size() < vec.size()) {
        int size = slimes.size();
        for (int i = 0; i < size; i += 1) {
            int next = tree.GetSmaller(slimes[i]);
            if (next < 0) {
                return false;
            }

            slimes.push_back(next);
            tree.Remove(next);
        }
    }
    return true;
}

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

    vector<int> vec(1 << n);
    for (auto &num : vec) {
        cin >> num;
    }

    auto res = Valid(vec, n);
    cout << (res ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 11516
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   int n , m;
   cin >> n >> m;
   string s = string(n , 'c');
   while(m--){
      int x , c;
      cin >> x >> c;
      x--;
      char tp = (char)c + '0';
      if(s[x] != 'c' && s[x] != tp){
         cout << "-1\n";
         return 0;
      }
      s[x] = tp;
   }
   if(n == 1){
      if(s[0] == 'c')
         s[0] = '0';
      cout << s << "\n";
      return 0;
   }
   bool l = false;
   for(int i = 0 ;  i < n ; ++i){
      if(i){
         if(s[i] == 'c')
            s[i] = '0';
      }
      else{
         if(s[i] == '0'){
            cout << "-1\n";
            return 0;
         }
         if(s[i] == 'c')s[i] = '1';
      }
   }
   cout << s << endl;
}

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

// #define fi first
// #define se second
#define rep(i, n) for (ll i=0;i<(n); i++)
#define ALL(v) (v).begin(), (v).end()
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
#define WHITE 0  // 未訪問
#define BLACK 1  // 訪問ずみ

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 (a>b) { a=b; return 1; } return 0; }

using namespace std;
typedef long long ll;
typedef pair<ll, ll> pi;

const ll M=1000000007ll;
const ll MOD=1000000007ll;
const ll MAX=100000001ll;
const int N=100000;
//const ll M = 1000000000+7;

ll cnt = 0; 

struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n, -1){}
  int root(int x) {
    if(d[x]<0) return x;
    return d[x] = root(d[x]);
  }
  bool unite(int x, int y){
    x = root(x); y=root(y);
    if(x==y) return false;
    if (d[x]>d[y]) swap(x, y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) {return root(x)==root(y);}
  int size(int x) {return -d[root(x)];}
  int factor_size() {
    int ans=0;
    rep(i,d.size()){
      if (d[i]<0) {ans++;}
    }
    return ans;
  }
  
};
  
int main(){ 
  int n,m,k,s,t;
  cin >> n>>m;

  int graph[n][n];

  rep(i,n) rep(j,n) graph[i][j] = 0;
  
  UnionFind u(n);

  vector<pi> P;
  
  rep(i, m){
    cin >> s >> t;
    s--;t--;
    graph[min(s,t)][max(s,t)] = 1;
    P.push_back(make_pair(min(s,t), max(s,t)));
  }

  UnionFind uf(n);
  rep(j, n) for(k=j;k<n;k++) {
    if(graph[j][k]==1) uf.unite(j, k);
  }

  int ref = uf.factor_size();

  int ans = 0;
  rep(i, m){
    s = P[i].first;
    t = P[i].second;
    graph[s][t] = 0;

    UnionFind u(n);
    rep(j, n) for(k=j;k<n;k++) {
      if(graph[j][k]==1) u.unite(j, k);
    }
    if (u.factor_size()>ref) ans++;
    graph[s][t] = 1;

  }
  
  cout << ans <<endl;
  
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>
#include<vector>
#include<map>

using namespace std;
static const int MAX = 101;

vector<string> getList(string line){
  vector<string> l;
  string str = "";
  for ( int i = 0; i < line.size(); i++ ){
    if ( line[i] == '.' || line[i] == ',' ){
      l.push_back(str);
      str = "";
    } else str += line[i];
  }
  return l;
}

vector<string> M[MAX];
bool vis[MAX];

void rec(int p, map<string, int> P, set<string> &U, set<string> G, vector<string> V){
  vis[p] = true;
  for ( int i = 0; i < V.size(); i++ ){
    string name = V[i];
    if ( G.find(name) != G.end() ){
      int t = P[name];
      if ( !vis[t] ) rec(t, P, U, G, M[t]);
    } else {
      U.insert(name);
    }
  }
}

void solve(int n){
  string line;
  set<string> G;
  map<string, int> P;

  for ( int i = 0; i < n; i++ ) {
    cin >> line;
    int p = 0;
    string gname = "";
    while( line[p] != ':' ) { gname += line[p++]; }
    P[gname] = i;
    M[i] = getList(line.substr(p+1));
    G.insert(gname);
  }

  set<string> U;
  for ( int i = 0; i < n; i++ ) vis[i] = false;
  rec(0, P, U, G, M[0]);
  cout << U.size() << endl;
}

main(){
  int n;
  while( cin >> n, n) solve(n);
}

Measured memory_bytes: 2436
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
typedef complex<double> P;
static const double EPS = 1e-8;
static const int INF = (int)1e8;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) for (int i=0; i<(int)(n); ++i)
#define FOREQ(i,k,n) for (int i=(k); i<=(int)(n); ++i)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define FIND(m,w) ((m).find(w)!=(m).end())
struct Edge{
  int e;
  int c;
  Edge(int e,int c): e(e),c(c){}
};
bool used[11][11];
vector<Edge> edge[11];
int maxcost;
vector<int> ans,tmp;
void dfs(int u,int c){
  tmp.push_back(u);

  bool unmovable = true;
  REP(i,edge[u].size()){
    int v = edge[u][i].e;
    if(!used[u][v]){
      unmovable = false;
      used[u][v] = used[v][u] = true;
      dfs(v, c + edge[u][i].c);
      used[u][v] = used[v][u] = false;
    }
  }
  if(unmovable){
    if(maxcost < c || (maxcost==c&&ans>tmp)){
      maxcost = c;
      ans = tmp;
    }
  }

  tmp.pop_back();
}

int main(void){
  int ns,nl;
  while(cin>>ns>>nl,ns){
    maxcost = -1;
    ans.clear();
    tmp.clear();
    REP(i,11)edge[i].clear();

    REP(i,nl){
      int s1,s2,d;
      cin>>s1>>s2>>d;
      edge[s1].push_back(Edge(s2,d));
      edge[s2].push_back(Edge(s1,d));
    }

    for(int i=1; i<=ns; i++){
      memset(used,0,sizeof(used));
      dfs(i,0);
    }

    cout<<maxcost<<endl;
    REP(i,ans.size()){
      if(i) cout<<" ";
      cout<<ans[i];
    }
    cout<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int N, M;
    cin >> N >> M;
    int H,A,B;
    vector<vector<int>> hedge(N);
    for(int i=0; i<N; i++){
        cin >> H;
        hedge.at(i).push_back(H);
    }
    for(int i=0; i<M; i++){
        cin >> A >> B;
        hedge.at(A-1).push_back(B-1);
        hedge.at(B-1).push_back(A-1);
    }
//    sort(hedge.begin(), hedge.end(), greater<int>());
    vector<int> flag(N,1);
    int index;
    for (int i=0; i<N; i++){
        if (flag.at(i)==0) continue;
        for (int j=1; j<hedge.at(i).size(); j++){
            index = hedge.at(i).at(j);
            if (hedge.at(i).at(0) > hedge.at(index).at(0) ){
                flag.at(index) = 0;
            }
            else{
                flag.at(i) = 0;
                break;
            }
        }
    }
    int cnt = 0;
    for (int i=0; i<N; i++) cnt += flag.at(i);
    cout << cnt << endl;
}

Measured memory_bytes: 9860
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	long long n,res=0,x,y;
	long double d;
	cin>>n>>d;
	for(long long i=1;i<=n;i++)
	{
		cin>>x>>y;
		long double xxi=x*x;
		long double yxi=y*y;
		long double	can=sqrt(xxi+yxi);
		//cout<<can<<endl;
		if(can<=d)	res++;
	}
	cout<<res;
	return 0;
}

Measured memory_bytes: 3788
#include <stdio.h>
int gcd(int x,int y){
  int z;
  z=x%y;
  while(z!=0){
    x=y;
    y=z;
    z=x%y;
  }
  return y;
}
int main(void){
  int a,b,c;
  int k;
  int i;
  long int total=0;
  scanf("%d",&k);
  for(a=1;a<=k;a++){
    for(b=1;b<=k;b++){
      for(c=1;c<=k;c++){
        total+=gcd(gcd(a,b),c);
      }
    }
  }
  printf("%d",total);
  return 0;
}


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

using ll = long long;

#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 ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

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

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);

  int n; std::cin >> n;
  int cnt = 0;
  rep(i, n) {
    int a; std::cin >> a;
    while (a % 2 == 0) a /= 2, cnt++;
  }
  std::cout << cnt << "\n";
}


Measured memory_bytes: 256
implicit none
integer:: n,a,b,keta,d,total
integer:: i,j
character(5):: s
 
read(*,*) n,a,b
 
total=0
do i=1,n
write(s,'(i0)') i
 
keta=0
do j=1,len(s)
if(s(j:j)/='')then
read(s(j:j),*) d
keta=keta+d
endif
end do
 
if(keta >= a .and. keta <=b)then
total=total+i
endif
 
end do
 
write(*,*) total
 
end

Measured memory_bytes: 2932
import bisect
n,q=map(int,input().split())
s=input()
lr=[[int(i) for i in input().split()] for j in range(q)]

li=[0]*(n-1)
check=0
for i in range(n-1):
    if s[i]=='A' and s[i+1]=='C':
        check+=1
    li[i]=check
for l,r in lr:
    if l>=2:
        print(li[r-2]-li[l-2])
    else:
        print(li[r-2])

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

int main(void)
{
  int n; cin >> n;
  set<string> s1;
  for(int i = 0; i < n; i++)
  {
   	string s; cin >> s;
    s1.insert(s);
  }
  cout << s1.size() << '\n';
  return 0;
}

Measured memory_bytes: 19136
#[allow(unused_imports)] use proconio::{input, marker::{Bytes, Chars, Usize1, Isize1}};
#[allow(unused_imports)] use std::cmp::{min, max};
#[allow(unused_imports)] use superslice::Ext as _;

const MAX: usize = 200000;
const MOD: usize = 1000000007;

fn com_init( fac: &mut [usize], finv: &mut [usize] )
{
	let mut inv = [0usize; MAX];
	fac[0] = 1;
	fac[1] = 1;
	finv[0] = 1;
	finv[1] = 1;
	inv[1] = 1;
	for i in 2..MAX {
		fac[i] = fac[i-1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD /i) % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}

}

fn com( n: usize, k: usize, fac: &[usize], finv: &[usize] ) -> usize {
	if n < k {
		return 0;
	}
	return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

#[proconio::fastout]
fn main() {
	input! {
		h: usize,
		w: usize,
		a: usize,
		b: usize,
	}

	// C(n,r)前処理
	let mut fac = [0usize; MAX];
	let mut finv = [0usize; MAX];
	com_init(&mut fac, &mut finv );

	// 必ず通るマス (H-A-1, B～W-1)
	let mut ans = 0;
	for i in b..w {
		// (0, 0)->(H-A-1, W-i-1)の経路
		let a1 = com(h-a-1+i, i, &fac, &finv);
		// そこから->(H-1, W-1)の経路
		let a2 = com(a+w-1-i-1, w-1-i, &fac, &finv);
		ans += a1 * a2 % MOD;
		ans %= MOD;
	}

	println!("{}", ans);
}



Measured memory_bytes: 6856
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<cstdlib>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i,k) for(int i=0;i<k;i++)
ll n, m[22][22] = {}, i, j, k,h, o, l=0, z, sam = 0, p, q;
ll a[200005] = {} , inf = 1000000000000;
ll b[100005] = {};

string s[22];
ll t[100005], xx[100005];
char ss,st;
const int MAX =100005;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
	cin >> n >> k;
	rep(i, n)cin >> a[i];
	sort(a, a + n);
	z = n - k;
	if (z <= 0) {
		cout << 0;
		return 0;
	}
	rep(i, z) sam+= a[i];

	cout << sam;
	return 0;
}

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

static const int MAX = 200000;

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

  int maxv = -2000000000;;
  int minv = R[0];
  for(int i=1;i<n;i++)
  {
    maxv = max(maxv,R[i]-minv);
    minv = min(minv,R[i]);
  }
  cout << maxv << endl;
}


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

int main() {
int n,ans=0,s; cin>>n;
  s=n;
  for(int i=0;i<10;i++)
  {
    ans+=s%10;
    s/=10;
   
  }
  
  if(n%ans==0)
  {
    cout<<"Yes"<<endl;
  }
  else
  {
    cout<<"No"<<endl;
  }
}





Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCorder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());

            var list = new List<KeyValuePair<int, int>>();

            for (int i = 0; i < n; i++)
            {
                var input = Console.ReadLine().Split(' ');
                list.Add(new KeyValuePair<int, int>(int.Parse(input[0]), int.Parse(input[1])));
            }

            var sum = 0;
            foreach (var item in list.OrderBy(t => t.Value))
            {
                sum += item.Key;
                if (sum > item.Value)
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 24108
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

#define rep(i, n) for(int i = 0; i < n; i ++)
#define ALL(T) T.begin(), T.end()
#define mp make_pair
#define pb push_back

using namespace std;

typedef pair<int, int> pii;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;

const int INF = 1 << 24;
const string B[4] = {"A", "B", "AB", "O"};

int main(void){
    map<string, int> cnt;
    int n; char c;
    for(string b; cin >> n >> c >> b;) cnt[b] ++;
    rep(i, 4) cout << cnt[B[i]] << endl; 

    return 0;
}

Measured memory_bytes: 1216
n = list(map(int, input().split()))
x1 = 0
x9 = 0
x7 = 0
x4 = 0

for i in range(4):
  if n[i] == 1:
    x1 += 1
  if n[i] == 9:
    x9 += 1
  if n[i] == 7:
    x7 += 1
  if n[i] == 4:
    x4 += 1

if min(x1, x9, x7, x4) == 1:
  print("YES")
else:
  print("NO")

Measured memory_bytes: 3064
while True:
    N, M = map(int, raw_input().split())
    if (N, M) == (0, 0): break
    fert = [map(float, raw_input().split()) for _ in range(N)]
    dp = [[0]*N for _ in range(M)]
    for i in range(N): dp[0][i] = 1.0
    for i in range(M-1):
        for j in range(N):
            dp[i+1][j] = max([dp[i][k]*fert[k][j] for k in range(N)])
    print('{:.2f}'.format(max(dp[M-1])))

Measured memory_bytes: 4748
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  int N;
  cin >> N;
  if(N==3||N==5||N==7)
  {
    cout << "YES" << endl;
  }
  else
  {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 3604
import java.util.Scanner;

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

		for(int i=0; i<N; i++) {
			an[i]=sc.nextInt();
		}
		StringBuilder sb=new StringBuilder();

		if(N%2==0) {
			for(int i=N-1; i>=0; i-=2) {
				sb.append(an[i]);
				sb.append(" ");
			}
			for(int i=0; i<N; i+=2) {
				sb.append(an[i]);
				sb.append(" ");
			}
			String a=new String(sb);
			a=a.substring(0, a.length()-1);
			System.out.println(a);
		}

		if(N%2==1) {
			for(int i=N-1; i>=0; i-=2) {
				sb.append(an[i]);
				sb.append(" ");
			}
			for(int i=1; i<N; i+=2) {
				sb.append(an[i]);
				sb.append(" ");
			}
			String a=new String(sb);
			a=a.substring(0, a.length()-1);
			System.out.println(a);
		}
	}
}

Measured memory_bytes: 77516
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int T = sc.nextInt();
    int min = Integer.MAX_VALUE;
    for (int i = 0; i < N; i++) {
      int cost = sc.nextInt();
      int time = sc.nextInt();
      if (T >= time) {
        min = Math.min(cost, min);
      }
    }
    if (min == 2147483647) {
      System.out.println("TLE");
    } else {
      System.out.println(min);
    }
  }
}


Measured memory_bytes: 21972
#include <stdio.h>
#include <stdlib.h>

struct point
{
    int x, y;
};

typedef struct point * P;

int compare(const void *, const void *);
void sort(P [], int);
void pri(P [], int);

int main(void)
{
    int i, n;
    P p, A[100000];

    scanf("%d", &n);
    p = (P) malloc(sizeof(struct point) * n);

    for (i = 0; i < n; i++) {
        A[i] = p + i;
        scanf("%d %d", &(A[i]->x), &(A[i]->y));
    }

    qsort(p, n, sizeof(P), compare);
    pri(A, n);
    return 0;
}

int compare(const void *a, const void *b)
{
    P pa, pb;
    pa = (struct point *) a;
    pb = (P) b;
    return pa->x == pb->x ? pa->y - pb->y : pa->x - pb->x;
}

void sort(P A[], int N)
{
    int i, j;
    P tmp;
    
    for (i = 1; i < N; i++) {
        tmp = A[i];
        for (j = i - 1; j >= 0 && compare(A[j], tmp) > 0; j--)
            A[j + 1] = A[j];
        A[j + 1] = tmp;
    }
}


void pri(P A[], int N)
{
    int i;
    
    for (i = 0; i < N; i++) {
        printf("%d %d\n", A[i]->x, A[i]->y);
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef vector<double> Vector;
typedef vector<vector<ll>> DVector;

#define fi          first
#define se          second
#define pb          push_back
#define INF         INT_MAX/3
#define bcnt        __builtin_popcount
#define all(x)      (x).begin(),(x).end()
#define dbg(x)      cout<<#x"="<<x<<endl
#define ub(x,y)     upper_bound(all(x),y)
#define lb(x,y)     lower_bound(all(x),y)
#define uni(x)      x.erase(unique(all(x)),x.end())
#define rep(i,n)    repl(i,0,n-1)
#define repl(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);i++)
#define mmax(x,y)   (x>y?x:y)
#define mmin(x,y)   (x<y?x:y)
#define maxch(x,y)  x=mmax(x,y)
#define minch(x,y)  x=mmin(x,y)
#define exist(x,y)  (find(all(x),y)!=x.end())
#define each(itr,v) for(auto itr:v)
#define usort(x)    sort(all(x))
#define dsort(x)    sort(all(x),greater<int>())
#define mkp(x,y)    make_pair(x,y)

double per(int water, int suger){
  return double(suger*100)/double(water+suger);
}

int main(){
  cin.sync_with_stdio(false);
  int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  int mw=-INF,ms=0;
  rep(i,30)rep(j,30)rep(k,3000){
    if(i == 0 && j == 0 )break;
    int water = (a * i + b * j) * 100;
    int suger = c*k + mmax(0, mmin((((water/100)*e-c*k)/d)*d,((f-water-c*k)/d)*d));
    if(water+suger > f || suger > (water/100)*e)continue;
    if(per(mw,ms)<per(water,suger)){
      mw = water;
      ms = suger;
    }
  }
  if( mw==-INF )mw =100*a;
  cout << mw+ms << " " << ms << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using tii = tuple<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define INF 1E9
#define LINF 1E18*5
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

class compare {
public:
	bool operator()(tuple<int, int> a, tuple<int, int> b) {
		return (get<1>(a) < get<1>(b));
	}
};

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	ll ans = 0;
	cin >> n;
	multiset<ll> s;
	vl v(n), pw;
	rep(i, n) {
		cin >> v[i];
		s.insert(v[i]);
	}
	ll tmp = 1;
	rep(i, 31) {
		tmp *= 2;
		pw.push_back(tmp);
	}
	while (!s.empty()) {
		auto ritr = s.end();
		ritr--;
		ll tmp = *ritr;
		s.erase(ritr);
		ll rtmp = *upper_bound(all(pw), tmp) - tmp;
		//cout << tmp << " " << rtmp << endl;
		auto itr = s.find(rtmp);
		if (itr != s.end()) {
			s.erase(itr);
			ans++;
		}
	}
	cout << ans << endl;
}



Measured memory_bytes: 11264
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,n) for(int i=(1);i<=(n);i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 200005;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Test.insert(x)late ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}

/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));
    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
    int n,m;
    cin>>n>>m;
    int a=1<<m;
    int b=100*(n-m)+1900*m;
    cout<<a*b;

    return 0;
}


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

// for flow algorithm
struct EdgeF{
  int to, cap, rev;
  EdgeF(int to_=0, int cap_ = 0, int rev_ = 0)
	:to(to_), cap(cap_), rev(rev_){}
};
using GraphF = vector<vector<EdgeF>>;

// add edge with (from -> to, capacity)
void add_edge(GraphF& G, int from, int to, int cap){
  G[from].emplace_back(to, cap, G[to].size());
  G[to].emplace_back(from, 0, G[from].size()-1);
}


// Ford-Fulkerson
// O(FE) where F := max flow of graph
// find increase path
int max_flow(GraphF& G, int s, int t){
  const int V = G.size();
  vector<bool> used(V);

  function<int(int,int,int)> dfs = [&](int v, int t, int f){
	if(v == t) return f;
	used[v] = true;
	for(auto& e: G[v]){
	  if(!used[e.to] && e.cap > 0){
		int d = dfs(e.to, t, min(f, e.cap));
		if(d > 0){
		  e.cap -= d;
		  G[e.to][e.rev].cap += d;
		  return d;
		}
	  }
	}
	return 0;
  };

  int flow = 0;
  while(true){
	fill(used.begin(), used.end(), false);
	int f = dfs(s, t, INF);
	if(f == 0) return flow;
	flow += f;
  }
}


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

  int V, E;
  cin >> V >> E;
  GraphF G(V);
  REP(i,E){
	int u, v, c;
	cin >> u >> v >> c;
	add_edge(G, u, v, c);
  }
  cout << max_flow(G, 0, V-1) << endl;

  return 0;
}

Measured memory_bytes: 3216
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cstdlib>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <vector>
#include <iterator>
#define ll long long
#define Lu unsigned long long
const int maxn = 60;
const int mod = 1e9 +7;

using namespace std;

Lu dp[maxn];
char mp[2][maxn];

int main()
{
    int N;
    scanf("%d",&N);
    for(int i=0;i<2;i++)
        for(int j = 0 ;j < N ;++j)
        scanf(" %c",&mp[i][j]);
    if(mp[0][0]==mp[1][0])
        dp[0] = 3;
    else
        dp[0] = 6;

    for(int i=1;i<N;i++)
    {
        if(mp[0][i]==mp[0][i-1]&&mp[1][i]==mp[1][i-1])
            dp[i] = dp[i-1]%mod;
        else
        {
            if(mp[0][i-1]==mp[1][i-1]&&mp[0][i]!=mp[1][i])
                dp[i] = (dp[i-1]*2)%mod;
            if(mp[0][i-1]==mp[1][i-1]&&mp[0][i]==mp[1][i])
                dp[i] = (dp[i-1]*2)%mod;
            if(mp[0][i-1]!=mp[1][i-1]&&mp[0][i]==mp[1][i])
                dp[i] = dp[i-1]%mod;
            if(mp[0][i-1]!=mp[1][i-1]&&mp[0][i]!=mp[1][i])
                dp[i] = (dp[i-1]*3)%mod;
        }
    }
    printf("%llu\n",dp[N-1]);
    return 0;
}


Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 1))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

;; Hauptteil

(deftype uint nil `(integer 0 ,(expt 10 9)))

(defun %solve (vertical-list prev-vertical-p res)
  (if (null vertical-list)
      res
      (let ((vertical-p (car vertical-list)))
        (%solve (cdr vertical-list)
                vertical-p
                (if prev-vertical-p
                    (+ res res)
                    (if vertical-p
                        res
                        (* 3 res)))))))
(defun solve (vertical-list)
  (%solve (cdr vertical-list)
          (car vertical-list)
          (if (car vertical-list) 3 6)))

(defun main ()
  (let* ((n (read))
         (str1 (read-line))
         (str2 (read-line))
         (vertical-list
           (loop for i below n
                 collect (or (>= (1+ i) n)
                             (if (char= (aref str1 i) (aref str1 (1+ i)))
                                 (progn (incf i) nil)
                                 t)))))
    (declare (ignore str2))
    (println (mod (solve vertical-list) 1000000007))))

#-swank(main)


Measured memory_bytes: 8932
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
  
  int A,B,C,K;
  cin>>A>>B>>C>>K;
  
  int check=0;
  
    while(A>=B){
      B*=2;
      check++;
    }
  
  if(C*pow(2,K-check)>B){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 4032
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#define MOD 1000000007
using namespace std;
int main()
{
	long long int n, k;
	cin >> n >> k;

	if (n >= k) {
		n = n % k;
	}
	if (n = min(n, abs(n - k)));
	cout << n << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<sstream>
#include<algorithm>
#include <vector>
#include <cassert>
#include<cmath>
#include <cstdio>
using namespace std;

int main() {
	int i, j;
	int N;
	cin >> N;
	int sum = 0;
	int M;
	M = N;
while (M > 0) {
	sum += M % 10;
	M /= 10;
	}

if (N%sum == 0) {
	cout << "Yes" << endl;
}
else {
	cout << "No" << endl;
}



}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int X, Y;
  cin >> X >> Y;
  int ans = 0;

  switch (X) {
  case 3:
    ans += 100000;
    break;
  case 2:
    ans += 200000;
    break;
  case 1:
    ans += 300000;
    break;
  default: {
  }
  }

  switch (Y) {
  case 3:
    ans += 100000;
    break;
  case 2:
    ans += 200000;
    break;
  case 1:
    ans += 300000;
    break;
  default: {
  }
  }

  if (X == 1 && Y == 1) {
    ans += 400000;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>

int n,a[105],Ans;

int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;++i)scanf("%d",&a[i]);
    for(int i=1,j;i<=n;i=j+1)
    {
        for(j=i;j<=n&&a[j+1]==a[i];++j);
        Ans+=(j-i+1)>>1;
    }
    printf("%d\n",Ans);
    return 0;
}

Measured memory_bytes: 128