akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if (a >= 13) {
          System.out.println(b);
        } else if (a >= 6) {
          System.out.println(b/2);
        } else {
          System.out.println(0);
        }
	}
}

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

typedef long long ll;
#define rep(i,n) for(i=0;i<n;++i)
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define mp make_pair
#define pb push_back
#define fi first
#define sc second

int main(int argc, char const *argv[]) {
  map<char,string> m;
  m[' '] ="101";
  m['\'']="000000";
  m[','] ="000011";
  m['-'] ="10010001";
  m['.'] ="010001";
  m['?'] ="000001";
  m['A'] ="100101";
  m['B'] ="10011010";
  m['C'] ="0101";
  m['D'] ="0001";
  m['E'] ="110";
  m['F'] ="01001";
  m['G'] ="10011011";
  m['H'] ="010000";
  m['I'] ="0111";
  m['J'] ="10011000";
  m['K'] ="0110";
  m['L'] ="00100";
  m['M'] ="10011001";
  m['N'] ="10011110";
  m['O'] ="00101";
  m['P'] ="111";
  m['Q'] ="10011111";
  m['R'] ="1000";
  m['S'] ="00110";
  m['T'] ="00111";
  m['U'] ="10011100";
  m['V'] ="10011101";
  m['W'] ="000010";
  m['X'] ="10010010";
  m['Y'] ="10010011";
  m['Z'] ="10010000";

  int i;
  string s;
  string al="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  while (getline(cin,s)){
    string ans="";

    string a="";
    rep(i,s.size()) a+=m[s[i]];

    int tmp=a.size()%5;
    if(tmp!=0){
      rep(i,5-tmp) a+="0";
    }

    //cout << a << endl;

    for(int j=0; j<a.size(); j+=5){
      //5???????????¨????????????
      string b=a.substr(j,5);
      if(b=="11010") ans+=" ";
      else if(b=="11011") ans+=".";
      else if(b=="11100") ans+=",";
      else if(b=="11101") ans+="-";
      else if(b=="11110") ans+="'";
      else if(b=="11111") ans+="?";
      else{
        int val=0;
        for(int k=0; k<5; ++k){
          val+=(b[k]-'0')*pow(2,4-k);
        }
        ans+=al[val];
      }

    }

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

Measured memory_bytes: 1240
#include <iostream>
#include <algorithm>
#include <string.h>
#include <map>
#define FOR(i,s,e) for(int i=(s);i<=(e);i++)
#define FORD(i,s,e) for(int i=(s);i>=(e);i--)
#define eb emplace_back
#define MAXN 1000009
#define MOD 1000000007
#define mp(x, y) make_pair(x,y)
#define all(v) (v).begin(),(v).end()
#define pb(x) push_back(x)
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second

using namespace std;

typedef unsigned long long LLU;
typedef long double LD;
typedef pair<int,int> PII;
const bool print=false;
typedef long long ll;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n;
int len;
int a[MAXN];
int b[MAXN];
int c[MAXN];
map<int, int> mp;
int main()
{
    //~ freopen("file.in", "r", stdin);
    scanf("%d", &n);
    for(int i = 1; i <= n; i ++)
		scanf("%d", a + i);
	for(int i = n; i > 0; i --){
		b[i] = mp[a[i] + 1];
		mp[a[i]] = i;
		c[i] = c[b[i]] + 1;
		if(c[i] > c[len])
			len = i;
    }
    printf("%d\n", n - c[len]);
//    while(len > 0)
//    	printf("%d ", len),
//        len = b[len];
}


Measured memory_bytes: 18560
//保留所有权利。
#include<iostream>
#include<stdio.h>//printするよ
#include<vector>
#include<algorithm>//辞書順はnext_permutationだよ
#include<set>
#include<string>
#include<sstream>
#include<string.h>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<utility>//swapで数値交換するよ
//END OF LIBRARIES.
#define rt "\n"//改行を最速化させるよ
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(v) for (int i = 0; i < (v).size(); i++) { cin >> (v)[i]; }
#define sort(s) sort(s.begin(),s.end())
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define cncn int cnt=0
#define smsm int sum=0
#define str srting
#define v vector
#define please return
#define AC 0//おまじないだよ
#define Rapid cin.tie(0);ios::sync_with_stdio(false)
//END OF DEFINE.
using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vcha;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;
//printf("%02d:%02d:%02d\n", h, m, s);・・・2文字は埋める・h、m、ｓ
//END OF TYPEDEF.

//最大公約数（GCD）を求めるよ
//最小公倍数（LCM）は＜＜　A × B ÷ GCD　 ＞＞で求まるよ

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

//for A以上B未満でI探索 for (int I = A; i <= B; i++)
//string s = to_string(i);
int a = 0, b = 0, c = 0, x = 0, y = 0, z = 0, n = 0, sum = 0;
string s = ""; asas; cncn;

int main(void) {
	cin >> a >> b;
	cin >> x >> y;
	sum = a * b - x * b - y * a;
	sum += x * y;
	cout << sum << rt;
	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);
int main()
{
    int a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;
    int k;
    cin >> k;
    if (e - a > k)
        cout << ":(" << endl;
    else
        cout << "Yay!" << endl;
    return 0;
}


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

using namespace std;

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

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)
#define ff first
#define ss second

using ll = int64_t;

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

using pll = pair<ll, ll>;

const int N = 3001;
int a[N];
pll dp[N][N];

pll f(int l, int r) {
	if (l > r) return {0, 0};
	auto &x = dp[l][r];
	if (x == pll(-1, -1)) {
		auto tl = f(l + 1, r); swap(tl.ff, tl.ss);
		auto tr = f(l, r - 1); swap(tr.ff, tr.ss);
		tl.ff += a[l]; tr.ff += a[r];
		x = (tl.ff - tl.ss > tr.ff - tr.ss ? tl : tr);
	}
	return x;
}

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

	int n; cin >> n;
	rep(i, 0, n) cin >> a[i];
	rep(i, 0, n) rep(j, 0, n) dp[i][j] = {-1, -1};
	auto tmp = f(0, n - 1);
	cout << tmp.ff - tmp.ss;
}

Measured memory_bytes: 141312
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <iostream>
#include <utility>
#include <vector>
using namespace std;

constexpr long long mod = 1000000007;

typedef pair<long long, long long> result; // true, false
#define T first
#define F second

struct parse_t {
	char c;
	result value;
	parse_t(char c_ = '#', const result &value_ = result()):c(c_), value(value_) {}
};

template<class T>
T take_back(vector<T> &vec) {
	const T res = vec.back();
	vec.pop_back();
	return res;
}

void push_value(vector<parse_t> &sta, result value) {
	while(!sta.empty() && sta.back().c == '~') {
		sta.pop_back();
		swap(value.T, value.F);
	}
	sta.emplace_back('v', value);
}

result calculate_binary_operator(char ope, const result &a, const result &b) {
	switch(ope) {
	case '|': return result((a.T * (b.T + b.F) + a.F * b.T) % mod, a.F * b.F % mod);
	case '&': return result(a.T * b.T % mod, (a.F * (b.T + b.F) + a.T * b.F) % mod);
	default : assert(false);
	}
}

void evaluate_binary_operator(vector<parse_t> &sta) {
	const result b = take_back(sta).value;
	const char ope = take_back(sta).c;
	const result a = take_back(sta).value;
	push_value(sta, calculate_binary_operator(ope, a, b));
}

result parse(const string &expression) {
	vector<parse_t> sta;
	sta.reserve(1000000);

	int priority[256] = {};
	priority['|'] = 2;
	priority['&'] = 3;
	priority['('] = 100;
	priority[')'] = 1;

	for(auto it = expression.cbegin(); it != expression.cend();) {
		if(*it == 'x') {
			++it; // x
			while(isdigit(*it)) ++it;
			push_value(sta, result(1, 1));
		}
		else if(*it == '~') {
			sta.emplace_back('~');
			++it;
		}
		else {
			while(sta.size() >= 3 && sta[sta.size() - 2].c != '('
				  && priority[sta[sta.size() - 2].c] >= priority[*it]) {
				evaluate_binary_operator(sta);
			}

			if(*it == ')') {
				const auto tmp = take_back(sta);
				sta.pop_back(); // (
				push_value(sta, tmp.value);
			}
			else {
				sta.emplace_back(*it);
			}

			++it;
		}
	}

	while(sta.size() >= 3) evaluate_binary_operator(sta);
	return sta.back().value;
}

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

	string expression;
	cin >> expression;
	cout << parse(expression).T << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 15912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(true) {
        int W, H, t, p;
        cin >> W >> H >> t >> p;
        if(W == 0) break;
        int Prev[40][40];
        int Next[40][40];
        for(int i = 0; i < 40; i++) {
            for(int j = 0; j < 40; j++) {
                Prev[i][j] = 0;
                Next[i][j] = 0;
            }
        }
        for(int h = 1; h <= H; h++ ){
            for(int w = 1; w <= W; w++) Prev[h][w] = 1;
        }
        while(t--) {
            for(int i = 0; i < 40; i++) {
                for(int j = 0; j < 40; j++) Next[i][j] = 0;
            }
            int d, c;
            cin >> d >> c;
            for(int h = 1; h <= H; h++) {
                for(int w = 1; w <= W; w++) {
                    if(d == 1) {
                        if(w <= c) Next[h][c - w + 1] += Prev[h][w];
                        else Next[h][w-c] += Prev[h][w];
                    }
                    if(d == 2) {
                        if(h <= c) Next[c - h + 1][w] += Prev[h][w];
                        else Next[h-c][w] += Prev[h][w];
                    }
                }
            }
            swap(Prev, Next);
        }
        //int ans = 0;
        while(p--) {
            int x, y;
            cin >> x >> y;
            cout << Prev[y+1][x+1] << endl;
        }
       // cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3140
/*
 *Author - Bhanu Pratap
 */
#include <bits/stdc++.h>
#define endl '\n'
#define all(c) c.begin(), c.end()
 
using namespace std;
 
typedef long long int ll;
typedef long double ld;
 
const ll mod = 1e9 + 7;
const ld PI = 3.141592653589793;

void solve () {
	int n;
	string s;
	cin>>n>>s;
	if (n>=3200) cout<<s;
	else cout<<"red";
}
main(){
    
    solve();
    return 0;
    }


Measured memory_bytes: 256
def count(X,n):
    l = []
    for i in range(n):
        l.append((X+1)//(2**(i+1))*2**i + max(0,(X+1)%(2**(i+1))-2**i))
    return l

A,B = map(int,input().split())
n = len(bin(B)[2:])
la = count(A-1,n)
lb = count(B,n)

xor = ''
for a,b in zip(la[::-1],lb[::-1]):
    if (b-a)%2 == 0:
        xor += '0'
    else:
        xor += '1'

print(int(xor,2))

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val t = s.map { it }.toTypedArray()

    for (v in 'a'..'z') {
        if (v !in s) {
            println(s + v)
            return
        }
    }
    if (!nextPermutation(t)) {
        println(-1)
    } else {
        var i = 0
        while (s[i] == t[i]) {
            print(s[i])
            i++
        }
        println(t[i])
    }
}

fun nextPermutation(t: Array<Char>): Boolean {
    val n = t.size
    var i = n - 2

    while (i >= 0 && t[i] >= t[i + 1]) {
        i--
    }
    if (i == -1) {
        return false
    }

    var j = i + 1
    while (j < n && t[j] > t[i]) {
        j++
    }
    j -= 1
    var tmp = t[i]
    t[i] = t[j]
    t[j] = tmp

    var left = i + 1
    var right = n - 1

    while (left < right) {
        tmp = t[left]
        t[left] = t[right]
        t[right] = tmp
        left++
        right--
    }
    return true
}


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

int main(){
  int n,count=0;
  cin >> n;
  vector<int> v(n+2,0);
  r(i,n)cin >> v.at(i+1);
  r(i,n+1){
    if(v.at(i)>v.at(i+1))count+=v.at(i)-v.at(i+1);
  }
  cout << count <<endl;
}


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

int main() {
	int N, M, A;
	cin >> N;
	vector<int> X(1 + N), a(2020);
	for (int i = 1; i <= N; ++i) {
		cin >> X[i];
		a[X[i]] = i;
	}
	cin >> M;
	for (int i = 0; i < M; ++i) {
		cin >> A;
		if (0 == a[1 + X[A]] && 2019 != X[A]) {
			a[X[A]] = 0;
			++X[A];
			a[X[A]] = A;
		}
	}
	for (int i = 1; i <= N; ++i) cout << X[i] << endl;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			int c = scanner.nextInt();
			boolean result = false;
			for (int i = a; i < lcm(a, b); i += a) {
				if (c == i % b) {
					result = true;
					break;
				}
			}
			System.out.println(result ? "YES" : "NO");
		}
	}

	/**
	 * @param a
	 * @param b
	 * @return aとbの最小公倍数
	 */
	private static int lcm(int a, int b) {
		int temp;
		long c = a;
		c *= b;
		while ((temp = a % b) != 0) {
			a = b;
			b = temp;
		}
		return (int) (c / b);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
#include <functional>
#include <map>
#include <string>
using namespace std;
#define INF 1000000000;
#define MOD 1000000007;
typedef long long int ll;
int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<int> >vec(m);
    for(int i=0;i<m;i++){
        int k;
        cin>>k;
        vec[i].resize(k);
        for(int j=0;j<k;j++){
            cin>>vec[i][j];
            vec[i][j]--;
        }
    }
    vector<int>p(m);

    for(int i=0;i<m;i++)cin>>p[i];
    int ans=0;
    for(int i=0;i<(1<<n);i++){
        bool ok=true;
        for(int j=0;j<m;j++){
            int c=0;
            for(int id:vec[j]){
                if((i>>id) & 1)c++;
            }
            c%=2;
            if(c!=p[j])ok=false;
        }
        if(ok)ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long N;
  cin >> N;
  long long S = 0;
  long long a = 1;
  
  while(S < N){
    S += pow(26,a);
    a++;
  }

  a--;  
  vector<int> ans(a);
  
  for(int i = 0; i < a; i++){
    ans.at(i) = N%26;
    if(N%26 == 0){
      N--;
    }
    N = N/26;
  }
  vector<char> num = {'z','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
   
  for(int i = 0; i < a; i++){
    if(ans.at(i) == 0){
      ans.at(i) = 26;
    }
  }
  for(int i = 0; i < a; i++){
    cout << num.at(ans.at(a-i-1));
  }
}
  
    
  

Measured memory_bytes: 4136
# GrahamScan
module GrahamScan
  def self.calc(data)
    points = data.map do |data|
      Point.new(data)
    end

    # sort by lower y-cordinate
    points.sort! do |a, b|
      if a.y == b.y
        a.x <=> b.x
      else
        a.y <=> b.y
      end
    end

    # sort by polar angle with respect to base of points[0]
    points[1...points.size] = points[1...points.size].sort! do |a, b|
      -ccw(points[0], a, b)
    end

    hull = []
    hull << points[0]
    hull << points[1]
    hull << points[2]

    for i in 3...points.size
      top = hull.pop

      while ccw(hull.last, top, points[i]) != 1
        top = hull.pop
      end
      hull << top
      hull << points[i]
    end

    hull
  end

  def self.ccw(p1, p2, p3)
    dx1 = p2.x - p1.x
    dy1 = p2.y - p1.y
    dx2 = p3.x - p1.x
    dy2 = p3.y - p1.y

    cross_product = dx1 * dy2 - dy1 * dx2

    if cross_product < 0
      return -1
    elsif cross_product > 0
      return 1
    else
      return 0
    end
  end

  # Point
  class Point
    attr_reader :x, :y

    def initialize(data)
      @x, @y = data
    end
  end
end

while line = gets
  n = line.chomp.to_i
  break if n == 0

  data = []
  n.times do
    data << gets.chomp.split(',').map(&:to_f)
  end

  hull = GrahamScan.calc(data)
  puts n - hull.size
end

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

int main(){
    int n,k;
    cin >> n >> k;
    
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    
    int ans = 0;
    rep(i,n){
        if(h[i]>=k) ans++;
    }
    cout << ans;
    
}


Measured memory_bytes: 640
n,m=map(int,input().split())
edge=[list(map(int,input().split())) for i in range(m)]
ans=0
rout=[[0 for i in range(n)]]
rout[0][0]=1
for i in range(2,n+1):
  rout2=[]
  for j in range(len(rout)):
    for k in range(n):
      if rout[j][k]==0:
        r=rout[j][:]
        r[k]=i
        rout2.append(r)
  rout=rout2
for r in rout:
  lim=0
  while lim<n-1:
    if [r[lim],r[lim+1]] in edge or [r[lim+1],r[lim]] in edge:
      lim+=1
    else:
      lim=0
      break
  if lim:
    ans+=1
print(ans)

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


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        long n = long.Parse(Console.ReadLine());
        //long[] n = Console.ReadLine().Split().Select(long.Parse).ToArray();

        long a = 0;
        var dic = new Dictionary<long, long>();
        while (a < 1000)
        {
            dic.Add(a * a * a * a * a, a);
            if (!dic.ContainsKey(a * a * a * a * a * -1))
            {
                dic.Add(a * a * a * a * a * -1, a * -1);
            }
            a++;
        }

        long ansa = 0;
        long ansb = 0;
        for (long i = 0; i < dic.Count / 2; i++)
        {

            var tmp = i * i * i * i * i - n;
            if (dic.ContainsKey(tmp))
            {
                ansa = i;
                ansb = dic[tmp];
                break;
            }

            tmp = i * i * i * i * i * -1 - n;
            if (dic.ContainsKey(tmp))
            {
                ansa = i * -1;
                ansb = dic[tmp];
                break;
            }

            tmp = i * i * i * i * i + n;
            if (dic.ContainsKey(tmp))
            {
                ansa = i;
                ansb = dic[tmp];
                break;
            }

            tmp = i * i * i * i * i * -1 + n;
            if (dic.ContainsKey(tmp))
            {
                ansa = i * -1;
                ansb = dic[tmp];
                break;
            }
        }

        // 出力
        Console.WriteLine("{0} {1}", ansa, ansb);
    }
}

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

using ll = long long;
using pii = pair<ll, ll>;
using vi = vector<ll>;
using vvi = vector<vi>;

template <class T>
using max_heap = priority_queue<T>;
template <class T>
using min_heap = priority_queue<T, vector<T>, greater<T>>;

template <class T, class U>
void chmax(T &a, U b) {
    if (a < b) a = b;
}
template <class T, class U>
void chmin(T &a, U b) {
    if (b < a) a = b;
}

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define debug(x) cerr << #x << ": " << x << endl;
#define int ll

const ll mod = 1e9 + 7;
const ll inf = (1LL << 50);

void solve(long long N, long long K) {
    int ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
}
signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    long long N;
    scanf("%lld", &N);
    long long K;
    scanf("%lld", &K);
    solve(N, K);
    return 0;
}


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

ll f(ll head, ll tail, ll N)
{
    ll res = 0;
    for (ll i = 1; i <= N; i++) {
        ll h;
        if (i < 10) {
            h = i;
        } else if (i < 100) {
            h = i / 10;
        } else if (i < 1000) {
            h = i / 100;
        } else if (i < 10000) {
            h = i / 1000;
        } else if (i < 100000) {
            h = i / 10000;
        } else {
            h = i / 100000;
        }
        ll t = i % 10;
        if (head == h && tail == t) {
            res++;
        }
    }

    return res;
}

void main_()
{
    ll N;
    cin >> N;

    ll ans = 0;
    for (int i = 1; i < 10; ++i) {
        for (int j = 1; j < 10; ++j) {
            ans += f(i, j, N) * f(j, i, N);
        }
    }

    cout << ans << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


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

int main()
{
    int N; cin >> N;
    string S1,S2;
    int n,m;
    for (int i=0;i<N;i++)
    {
        cin >> S1 >> S2;
        n=S1.size();m=S2.size();
        vector<vector<int>> dp(n+1,vector<int> (m+1,0));
        for (int i=1;i<n+1;i++)
        {
            for (int j=1;j<m+1;j++)
            {
                if (S1[i-1]==S2[j-1])
                {
                    dp[i][j]=max({dp[i-1][j],dp[i][j-1],dp[i-1][j-1]+1});
                }
                else
                {
                    dp[i][j]=max({dp[i-1][j],dp[i][j-1]});
                }
                
            }
        }
        cout << dp[n][m] << endl;
    }
    return 0;
}


Measured memory_bytes: 6928
import heapq
import collections
N, M = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]
table = collections.defaultdict(list)
for a, b in AB:
    table[a].append(b)

job = []
ans = 0
heapq.heapify(job)
for i in range(M):
    for x in table[i+1]:
        heapq.heappush(job, -1 * x)
    if job:
        ans -= heapq.heappop(job)

print(ans)


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  char c;
  char base[26] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
  bool data[26] = { false,};
  while (cin >> c) {
    data[c - 'a'] = true;
  }
  string ans = "None";
  for (int i = 0; i < 26; i++) {
    if (data[i] == false) {
      ans = base[i];
      break;
    }
  }
  cout << ans << '\n';
}


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

int main(){
   
    int N,G;
    cin>>N>>G;
    vector<int> P(N),C(N),A(N);
    for(int i=0;i<N;i++){
        cin>>P[i]>>C[i];
        A[i]=P[i]*100*(i+1)+C[i];
    }
    int ans=2000;
    for(int bit=0;bit<(1<<N);bit++){
        int B=0,D=0;
        for(int i=0;i<N;i++){
            if(bit&(1<<i)){
                B+=A[i];
                D+=P[i];
        }
        }
        if(B>=G) ans=min(ans,D);
        else{
            int E=G-B;
            int F=10000;
        for(int i=N-1;i>=0;i--){
            if(!(bit&(1<<i))){
                if(E<=100*(i+1)*P[i]) F=min((E+100*i)/(100*(i+1)),F);
            }
        }
                                          ans=min(ans,D+F);
}
    }
                                          cout<<ans<<endl;
                                          }


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

int main(){
    int H, W, N;
    cin >> H >> W >> N;
    vector<int> a(N);
    rep(i, N) {
        int input;
        cin >> input;
        input--;
        a[i] = input;
    }
    int ans[H][W] = {0};
    int now_h = 0, now_w = 0, now_col = 0;
    rep(i, H*W) {
        if (a[now_col]<0) now_col++;
        a[now_col]--;
        ans[now_h][now_w] = now_col+1;
        if (now_w==W-1 && now_h%2==0 && i!=0) {
            now_h++;
        } else if (now_w==0 && now_h%2!=0) {
            now_h++;
        } else if (now_h%2==0) {
            now_w++;
        } else {
            now_w--;
        }
    }
    rep(i, H) {
        rep(j, W) {
        cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 384
n = list(map(int, input().split()))
n.sort()
if (sum(n) - max(n)) % 2 == 0:
    print((n[-1] - n[0] + n[-1] - n[1])//2)
else:
    print((n[-1] - n[0] + n[-1] - n[1] + 3)//2)

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

using namespace std;

int N, R, p, c, i, j;

int main()
{
   while ( cin >> N >> R && N >0 )
   {
      int A[N];
      for ( i = 0; i < N; i++)
         {
            A[i] = N - i;
         }
      for ( j = 0; j<R; j++)
         {
            cin >> p >> c;
            rotate(A,A+(p-1),A+(p+c-1));
         }
      cout << A[0] <<endl;
   }
}

Measured memory_bytes: 1184
h,w=map(int,input().split())
bd = [list("."+input()+".") for i in range(h)]
bd.insert(0,["."]*(w+2))
bd.append(["."]*(w+2))
stack=[(1,1)]
while(stack):
  i,j=stack.pop()
  if i == h and j == w:
    bd[i][j]="."
    break
  if bd[i+1][j] == bd[i][j+1]:
    print("Impossible")
    exit()
  if bd[i-1][j] == "#" or bd[i][j-1] == "#":
    print("Impossible")
    exit()
  if bd[i+1][j] == "#":
    stack.append((i+1,j))
  if bd[i][j+1] == "#":
    stack.append((i,j+1))
  bd[i][j] = "."
if bd == [["." for i in range(w+2)] for j in range(h+2)]:
  print("Possible")
else:
  print("Impossible")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<ll> A;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N;
    A = fetch_vec<ll>(N);
    sort(A.begin(),A.end());
}

int solve(){
    ll n= *(--A.end());
    ll k=0;
    for (int i = 0; i < N; i++)
    {
        ll ktmp = min(n-A[i],A[i]);
        k = max(k,ktmp);
    }
    if(!binary_search(A.begin(),A.end(),k)) k = n-k;
    cout << n << " " << k << endl;
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
using namespace std;
typedef long long ll;
#include<iostream>
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}

ll MOD = 1000000007;
int main() {
	string S;
	cin >> S;
	ll w;
	cin >> w;
	for (ll i = 0; i < S.size(); i+=w) {
		cout << S[i];
}
}

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

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

long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}

int N;
#define MAXN 200000
int a[MAXN];
int main(){
    cin >> N;
    rep(i,N)cin >> a[i];
    int count = 1;
    for(int i=0;i<N;i++){
        if(a[i]==count){
            count++;
        }
    }
    if(count==1)cout << -1 << endl;
    else cout << N-count+1 << endl;
    return 0;
}

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

int main(){
	char left[]={'q','w','e','r','t','a','s','d','f','g','z','x','c','v','b'};
	string s;
	while(cin>>s, s!="#"){
		char prev,now;		int ans=0;

		prev=now='R';
		for(int j=0;j<15;j++){
			if(s[0]==left[j]){
				prev=now='L';
				break;
			}
		}

		for(int i=1;i<s.length();i++){
			for(int j=0;j<15;j++){
				if(s[i]==left[j]){
					now='L';
					break;
				}else now='R';
			}
			if(prev != now){
				ans++;
			}
			prev=now;
		}
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mod 1000000007
#define mp make_pair
typedef long long ll;
void read(ll &x)
{
	scanf("%lld",&x);
}
void print(ll x)
{
	printf("%lld ",x);
}
void println(double x)
{
	printf("%.9f\n",x);
}

#define F first
#define S second
ll n;
ll p[200200];
vector<pair<ll, pair<ll, ll > > > edges;

inline int get(int v)
{
	if(p[v] == v) return v;
	return p[v] = get(p[v]);
}
pair<ll, pair<ll, ll > > a[200200];

inline bool cmp(pair<ll, pair<ll, ll> > a, pair<ll, pair<ll, ll > > b)
{
	if(a.S.F != b.S.F)
		return a.S.F < b.S.F;
	return a.F < b.F;
}
int main()
{
	cin>>n;
	for(int i = 1; i <= n; ++i)
	{
		read(a[i].F);
		read(a[i].S.F);
		a[i].S.S = i;
	}
	sort(a + 1, a + n + 1);
	for(int i = 1; i <= n; ++i)
	{
		for(int j = max(i - 4ll, 1ll); j <= min(n, i + 4ll); ++j)
		{
			ll dist = min(abs(a[i].F - a[j].F), abs(a[i].S.F - a[j].S.F));
			edges.pb(mp(dist, mp(a[i].S.S, a[j].S.S)));
		}
	}
	sort(a + 1, a + n + 1, cmp);
	for(int i = 1; i <= n; ++i)
	{
		for(int j = max(i - 4ll, 1ll); j <= min(n, i + 4ll); ++j)
		{
			ll dist = min(abs(a[i].F - a[j].F), abs(a[i].S.F - a[j].S.F));
			edges.pb(mp(dist, mp(a[i].S.S, a[j].S.S)));
		}
	}
	for(int i = 1; i <= n; ++i)
		p[i] = i;
	ll ans = 0;
	sort(edges.begin(), edges.end());
	for(int i = 0; i < edges.size(); ++i)
	{
		int v = edges[i].S.F, u = edges[i].S.S;
		int cost = edges[i].F;
		v = get(v);
		u = get(u);
		if(u == v) continue;
	//	cerr<<u<<' '<<v<<' '<<cost<<endl;
		p[u] = v;
		ans += cost;
	}
//	for(int i = 1; i <= n; ++i)
//		cerr<<p[i]<<' ';
//	cerr<<endl;
	cout << ans;
}

Measured memory_bytes: 57444
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int n=s.size();
    for(int i=0;i<n;i++){
        for(int k=0;k<n;k++){
            if(s[i]=='C'&&s[k]=='F'&&i<k){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll f(ll b,ll n){
	if(n<b) return n;
	else return f(b,n/b)+n%b; 
}
ll n,s,sn,ans=LONG_LONG_MAX;
int main(){
	scanf("%lld%lld",&n,&s); sn=sqrt(n)+1;
	if(s>n){printf("-1"); return 0;}
	if(s==n){printf("%lld",n+1); return 0;}
	for(ll i=2;i<=sn;i++) if(f(i,n)==s){printf("%lld",i); return 0;}
	for(ll i=1;i<=sn;i++)
		if((n-s)%i==0){
			ll b=(n-s)/i+1;
			if(f(b,n)==s) ans=min(ans,b);
		}
	if(ans==LONG_LONG_MAX) printf("-1");
	else printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int main() {
  ll n; cin >> n;
  int digit, min_d = 20;
  for(ll i = 1; i*i <= n; i++) {
    if(n % i == 0) {
      digit = 0;
      int num = max(i, n/i);
      while(num != 0) {
        num /= 10;
        digit++;
      }
    }
    min_d = min(min_d, digit);
  }
  cout << min_d << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ll long long
#define P pair<int,int>
#define fast_io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
const int INF = 2002002002;
const ll LLINF = 9009009009009009009;
using namespace std;

int main() {
    fast_io
    int n;
    cin >> n;
    vector<int> a(n);
    vector<bool> ok(n, true);
    rep(i,n) cin >> a[i];
    sort(a.begin(), a.end());
    if (a[0] == 1) {
        if (a[1] == 1) {cout << 0 << endl; return 0;}
        else {cout << 1 << endl; return 0;}
    }
    rep(i,n) {
        // 割られている
        if (!ok[i]) continue;
        // もしまだ割られていない
        if (ok[i]) {
            if (i < n-1) {
                if (a[i] == a[i+1]) ok[i] = false;
            }
            // 割る数
            int div = a[i];
            while (div <= a[n-1]) {
                int index = lower_bound(a.begin(), a.end(), div) - a.begin();
                while (a[index] == div) {
                    if (index == i) {index++;continue;}
                    ok[index] = false;
                    index++;
                    if (index > n-1) break;
                }
                div += a[i];
            }
        }
    }
    int count = 0;
    rep(i,n) if (ok[i]) count++;
    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3960
N,M = map(int, input().split())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
mod = 10**9+7

A.sort(reverse=True)
B.sort(reverse=True)
ans = 1
i = 0
j = 0
cnt = 0
num = N*M

if len(set(A)) < N or len(set(B)) < M:
    ans = 0
    num = 0
while num > 0:
    if i < N and j < M:
        if A[i] == B[j] == num:
            cnt += i+j
            i += 1
            j += 1
        elif A[i] == num and B[j] < num:
            cnt += j-1
            i += 1
            ans *= j
        elif A[i] < num and B[j] == num:
            cnt += i-1
            j += 1
            ans *= i
        elif A[i] < num and B[j] < num:
            ans *= cnt
            cnt -= 1
    elif i < N:
        if A[i] == num:
            cnt += M-1
            i += 1
            ans *= M
        else:
            ans *= cnt
            cnt -= 1 
    elif j < M:
        if B[j] == num:
            cnt += N-1
            j += 1
            ans *= N
        else: 
            ans *= cnt
            cnt -= 1
    else:
        ans *= num
    num -= 1
    if ans < 0:
        ans = 0
        break
    ans %= mod

print(ans)

Measured memory_bytes: 3188
#include<stdio.h>
int main()
{
	int a,b,c,d;
	int sum1,sum2;
	while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF)
	{
		sum1=a*b;
		sum2=c*d;
		if(sum1!=sum2)
		{
			if(sum1>sum2)
			{
				printf("%d\n",sum1);
			}
			else
			{
				printf("%d\n",sum2);
			}
		}
		else
			printf("%d\n",sum1);
	}
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N; cin >> N;
    int h[N+1];
    h[N] = INT_MAX;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    int c = 0;
    for(int i = 0; i < N; i++){
        int now = 0;
        for(int j = i; h[j] >= h[j+1]; j++){
            // cout << h[j] << " " << h[j+1] << endl;
            now++;
        }
        c = max(c, now);
        if(c == N-1 - i) break;
    }
    cout << c << endl;
}

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

using namespace std;

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

    string ans = "No";
    if(A == B && A != C){
        ans = "Yes";
    }else if(A ==C && A != B){
        ans = "Yes";
    }else if(B == C && C != A){
        ans = "Yes";
    }

    cout << ans << endl;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int gcd(int a,int b)
{
	if(b==0)
	return a;
	
	return gcd(b,a%b);
}
int power(int x,int y,int p)
{
	int res=1;
	x=x%p;
	while(y>0)
	{
		if(y&1)
		res=(res*x)%p;
		
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}
struct Matrix{ 
	int a[2][2] = {{0,0},{0,0}};
	Matrix operator *(const Matrix& other){
		Matrix product;
		for(int i=0;i<2;i++){
			for(int j=0;j<2;j++){
				for(int k=0;k<2;k++){
						product.a[i][k] =product.a[i][k] + (ll)a[i][j]*other.a[j][k];
				}
			}
		}
		return product;
	}
};
int modInverse(int n,int p)
{
	return power(n,p-2,p);
}
int main() {
	// your code goes here
	 ios_base::sync_with_stdio(0);
	 cin.tie(0);
	 int t;
	 cin>>t;
	 if(t>=30)
	 cout<<"Yes";
	 else
	 cout<<"No";
	 return 0;
}


Measured memory_bytes: 3664
s = list(str(input()))

s_rev = list(reversed(s))
n = len(s_rev)

for i in range(n):
  del s_rev[0]
  if len(s_rev) % 2 == 1:
    continue
  elif s[0:len(s_rev)// 2] != s[(len(s_rev) // 2):len(s_rev)]:
    continue  
  elif len(s_rev) != 0:
    print(len(s_rev))
    break


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
  int64_t N;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(),vec.end());
  bool exist = true;
  
  if(N %2 != 0){
    if(vec.at(0) != 0){
      exist = false;
    }
    for(int i=1; i<N; i++){
      if(vec.at(i) != ((i-1)/2 + 1)*2){
        exist = false;
        break;
      }
    }
  }
  else{
    for(int i=0; i<N; i++){
      if(vec.at(i) != ((i+2)/2)*2 -1){
        exist = false;
        break;
      }
    }
  }
  
  if(exist){
    int64_t ans = 1;
   for(int i=0; i<N/2; i++){
     ans *= 2;
     ans %= 1000000007;
   }
   cout << ans << endl;
  }
  else{
    cout << 0 << endl;
  }
}

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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
#define rep(i,n) for(ll i = 0;i<(ll)n;i++)
using namespace std;
typedef long long ll;
static const int MAX = 50;
static const long long INFTYL = 9223372036854775807;
ll mod = 1000000007;

int main()
{
	ll H, W;
	cin >> H >> W;
	ll N;
	cin >> N;

	ll a[10000];
	rep(i, N) {
		cin >> a[i];
	}

	ll c[100][100];
	rep(i, 100)rep(j, 100) c[i][j] = -1;

	ll currentH = 0;
	ll currentW = 0;
	rep(i, N) {
		rep(j, a[i]) {
			c[currentH][currentW] = i;

			if (currentH % 2 == 0) {
				currentW++;
				if (currentW == W) {
					currentH++;
					currentW--;
				}
			}
			else {
				currentW--;
				if (currentW == -1) {
					currentH++;
					currentW++;
				}
			}
		}
	}

	rep(i, H) {
		rep(j, W) {
			if (c[i][j] != -1) {
				cout << c[i][j] + 1;
			}
			if (j != W - 1) {
				cout << " ";
			}
		}
		cout << endl;
	}
	return 0;
}

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


int main(){
	int N;
	cin>>N;
	
	vector<int> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	
	bool flag = false;
	
	for(int k=0;k<2;k++){
		string S(N,'a');
		S[0] = 'D';
		if(k)S[0]='S';
		int S_cnt = k;
		for(int i=1;i<N;i++){
			int x = a[i]-a[i-1];
			if(x==0)S[i]=S[i-1];
			else if(x==1&&S[i-1]=='S'){
				S[i]='D';
			}
			else if(x==-1&&S[i-1]=='D'){
				S[i]='S';
			}
			else{
				goto Label1;
			}
			if(S[i]=='S')S_cnt++;
		}
		
		for(int i=0;i<N;i++){
			int mini = S_cnt;
			if(S_cnt!=N)mini++;
			if(S[i]=='S')mini--;
			int maxi = N-S_cnt-1;
			if(S[i]=='D')maxi++;
			maxi/=2;maxi+=S_cnt;
			if(a[i]<mini||a[i]>maxi)goto Label1;
			
		}
		flag=true;
		break;
		Label1:;
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <list>

using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define rrep(i,a) for(int i = a; i >= 0; i--)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

/*
// 最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// 最小公倍数
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
*/

// ワーシャルフロイド法でも解けるのか
// 試し書き

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

	int h, w;
	cin >> h >> w;
	vector<vector<int>> c(10, vector<int>(10));
	rep(i, 10) {
		rep(j, 10) {
			cin >> c[i][j];
		}
	}
	vector<vector<int>>a(h, vector<int>(w));
	rep(i, h)rep(j, w) cin >> a[i][j];

	rep(k, 10) {
		rep(i, 10) {
			rep(j, 10) {
				c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
			}
		}
	}

	int ans = 0;

	rep(i, h) {
		rep(j, w) {
			if (a[i][j] == -1) continue;
			ans += c[a[i][j]][1];
		}
	}

	// 計算量はO(HW) or O(100log(HW)) := O(1000) でいいのかな

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#define N 100000
#define NIL -1
int Depth(int );
void display(int );
struct Node {
  int parent;
  int left;
  int right;
};

struct Node T[N];
int n,D[N];

int main()
{
  int a,b,i,j,l,m;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    {
      T[i].parent=NIL;
      T[i].left=NIL;
      T[i].right=NIL;
    }
  
  for(i=0;i<n;i++)
    {
      scanf("%d%d",&l,&m);
      for(j=0;j<m;j++)
	{
	  scanf("%d",&a);
	  if(j==0) T[l].left=a;
	  else T[b].right=a;
	  b=a;
	  T[a].parent=l;
	}
    }
  for(i=0;i<n;i++)
    {
      D[i]=Depth(i);
    }
  for(i=0;i<n;i++)
    {
      display(i);
    }
  return 0;
}

int Depth(int a)
{
  int d=0;
  while(T[a].parent!=-1)
    {
      a=T[a].parent;
      d++;
    }
  return d;
}
void display(int x)
{
  int i,j;
  printf("node %d: parent = %d, depth = %d, ",x,T[x].parent,D[x]);
  if(T[x].parent==-1) printf("root, ");
  else if(T[x].left==-1) printf("leaf, ");
  else printf("internal node, ");

  printf("[");
  for(i=0,j=T[x].left;j!=NIL;i++,j=T[j].right)
    {
      if(i) printf(", ");
      printf("%d",j);
    }
  printf("]\n");
}

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

class Dice{
public:
    int a[6];
    Dice(){}
    void roll_z(){ roll(1, 2, 4, 3);}
    void roll_y(){ roll(0, 2, 5, 3);}
    void roll_x(){ roll(0, 1, 5, 4);}
    void roll(int i, int j, int k, int l){
        int tmp=a[i];
        a[i]=a[j];
        a[j]=a[k];
        a[k]=a[l];
        a[l]=tmp;
    }
};

bool eq(Dice d1, Dice d2){
    for (int i=0; i<6; i++){
        if(d1.a[i]!=d2.a[i]) return false;
    }
    return true;
}

bool equal(Dice d1, Dice d2){
    for(int i=0; i<6; i++){
        for(int j=0; j<4; j++){
            if(eq(d1, d2)) {
                return true;
            }
            d1.roll_z();
        }
        if(i%2==0) {
            d1.roll_y();
        } else {
            d1.roll_x();
        }
    }
    return false;
}



int main(){
    Dice D[100];
    int n;
    int ans = 1;
    cin >> n;
    for(int i=0; i<n; i++) {
        for(int j=0; j<6; j++) {
            cin >> D[i].a[j];
        }
    }
    for(int i=0; i<n-1; i++) {
        for (int j=j+1; j<n; j++) {
            if (equal(D[i], D[j])) {
                ans = 0;
            }
        }
    }
    if (ans == 1) { 
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<char> Vc;
typedef vector<string> Vs;
typedef vector<bool> Vb;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> P;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; }
inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; }
inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;

vector<vector<int>> g;
Vi op, res;
int n, q;

void init()
{
	cin >> n >> q;
	g.resize(n);

	REP(i,  n -1)
	{
		int a, b; cin >> a >> b; --a; --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	op.resize(n, 0);
	REP(_i, q)
	{
		int a, v; cin >> a >> v; --a;
		op[a] += v;
	}

	res.resize(n);
}

void dfs(int v, int par, int val)
{
	//cout << "dfs at " << v << " from " << par << endl;

	val += op[v];
	res[v] = val;

	for (int adj : g[v])
		if (adj != par)
			dfs(adj, v, val);
}

int main()
{
	init();
	dfs(0, -1, 0);

	REP(i, n)
		cout << res[i] << " ";
	cout << endl;
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    
    vector<int> ints;
    for (int i = 0; i < n; i++) {
        int a_n;
        cin >> a_n;
        ints.push_back(a_n);
    }

    bool areAllEven = true;
    int answer = 0;
    while (areAllEven) {
        for (int i = 0; i < n; i++) {
            bool isEven = ints[i] % 2 == 0;
            areAllEven &= isEven;
            if (isEven) {
                ints[i] /= 2;
            } else {
                break;
            }    
        }
        if (areAllEven) {
            answer += 1;
        }
    }
    cout << answer << endl;
}


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

using namespace std;

int main(){
    int a, b; cin >> a >> b;
    if((a+b)%2){
        cout << "IMPOSSIBLE" << endl;
    } else{
        cout << (a+b)/2 << endl;
    }
    return 0;
}



Measured memory_bytes: 256