akhauriyash/Code-Regression huggingface dataset:
/*
 * 2570.cc: Shipura
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

typedef long long ll;
const ll MAX_Y = 30;
const ll MOD = 1000000007;

/* typedef */

/* global variables */

/* subroutines */

ll expr(string &s, int &pos);

void sp(string &s, int &pos) {
  while (pos >= 0 && s[pos] == ' ') pos--;
}

ll term(string &s, int &pos) {
  sp(s, pos);
  if (s[pos] == '>') {
    pos--; // '>'
    sp(s, pos);
    ll x = expr(s, pos);
    sp(s, pos);
    pos--; // '<'
    sp(s, pos);
    pos--; // 'S'

    x %= MOD;
    x = x * x % MOD;
    return x;
  }

  ll num = 0, t = 1;
  while (pos >= 0 && s[pos] >= '0' && s[pos] <= '9')
    num += t * (s[pos--] - '0'), t *= 10;
  return num;
}

ll expr(string &s, int &pos) {
  sp(s, pos);
  ll x = term(s, pos);
  sp(s, pos);

  if (pos > 0 && s[pos] == '>' && s[pos - 1] == '>') {
    pos -= 2; // '>>'
    sp(s, pos);
    ll y = x;
    x = expr(s, pos);
    sp(s, pos);

    if (y >= MAX_Y) x = 0;
    else x /= (1 << y);
  }

  return x;
}

/* main */

int main() {
  for (;;) {
    string s;
    getline(cin, s);
    if (s == "#") break;

    int pos = s.size() - 1;
    ll x = expr(s, pos);
    printf("%lld\n", x);
  }

  return 0;
}

Measured memory_bytes: 5496
#include<stdio.h>

int main(void){
    int N,M,K,A;
    int i,j,ans,sum[40];
    for(i=0;i<40;i++){
        sum[i] = 0;
    }
    ans = 0;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++){
        scanf("%d",&K);
        for(j=0;j<K;j++){
            scanf("%d",&A);
            sum[A]++;
        }
    }
    for(i=0;i<40;i++){
        if(sum[i]==N){
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}


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

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

typedef long long ll;

int const MOD = 1e9+7;

string line; string::iterator iter;
inline void debug() { cout << "Remain: \"" <<string(iter, line.end())<<'"' << endl; }

void consume(char e) {
  if(*iter == e) { iter++; }
  else { assert(0); }
}

bool ifconsume(char e) {
  if(*iter == e) { consume(e); return 1; }
  return 0;
}

bool strcons(string s) {
  string::iterator is = s.begin();
  string::iterator tmpiter = iter;
  
  while(is!=s.end() &&
        tmpiter!=line.end() &&
        *is == *tmpiter) { tmpiter++; is++; }

  if(is == s.end()) {
    iter = tmpiter;
    return true;
  }
  return false;
}

ll get_num() {
  ll ret = 0;
  while(isdigit(*iter)) { ret *= 10; ret += (*iter)-'0'; consume(*iter); }
  return ret;
}

ll expr();
ll term() {
  if(isdigit(*iter)) { return get_num(); }
  else if(ifconsume('S')) {
    consume('<');
    ll r = expr(); (r*=r) %= MOD;
    consume('>');
    return r;
  }
  else {
    debug();assert(0&&"term");
  }
}

ll expr() {
  ll t1 = term();
  while(strcons(">>")) {
    if(*iter != 'S' && !isdigit(*iter)) { iter -= 2; break; }
    int k = term();
    while(k--) { t1 >>= 1; if(t1 == 0) break; }
  }
  return t1;
}

int main() {
  for(string s;getline(cin, s);) {
    if(s == "#") break;
    line.clear();
    int sz=s.size(); rep(i,sz) if(s[i]!=' ') { line.push_back(s[i]); }
    iter = line.begin();
    cout << expr() << endl;
  }
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
ll n,k,v[300001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>v[i];
    for(int i=k+1;i<=n;i++)
    {
        if(v[i]>v[i-k])
        {
            cout<<"Yes\n";
        }
        else
            cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 5204
from collections import Counter
from functools import reduce
import bisect
import fractions
import math
import statistics
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]  # LIST INT
def LF(): return [float(x) for x in sys.stdin.readline().split()]  # LIST FLOAT
def LS(): return sys.stdin.readline().split()  # LIST STRING
def MI(): return map(int, sys.stdin.readline().split())  # MAP INT
def II(): return int(sys.stdin.readline())  # INPUT INT
def IS(): return input()  # INPUT STRING
def P(x): return print(x)
def C(x): return Counter(x)
def GCD_LIST(numbers):  # Greatest Common Divisor
    return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers):  # Least Common Multiple
    return reduce(LCM, numbers)
def LCM(m, n):
    return (m * n // fractions.gcd(m, n))


n = II()
v = LI()
c = LI()
xy = [v[i] - c[i] for i in range(n)]
print(sum([ xy[i] for i in range(n) if xy[i] > 0]))


Measured memory_bytes: 5128
def frozen(A, t):
    if A >= B or A >= 0: return A, t
    return frozen(A + 1, t + C)

def normal_temperature(A, t):
    if A >= B: return A, t
    return normal_temperature(A + 1, t + E)

t = 0
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
# 温度が０℃より低い時、温度を１℃上げるのにかかる時間
if A < 0:
    A, t = frozen(A, t)
# 解凍にかかる時間
if A == 0 and A < B:
    t+=D
# 温度が０℃より高い時、温度を１℃上げるのにかかる時間
if A >= 0:
    A, t = normal_temperature(A, t)

print(t)



Measured memory_bytes: 5612
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
vector <int> a;
vector <int> all;
int n,m;



int bainary_search(int i) {
  int L=0;int R = all.size()-1,M;
  
  while(L<R) {
    M = (L+R)/2;
    if(all[i]+all[M] > m) R = M;
    else L = M+1;
  }
  if(L != 0)L--;
  return L;
}

int main() {

  while(1) {
    cin >> n >> m;
    if(n == 0 && m ==0) break;
    a.resize(n);
    for(int i=0;i<n;i++) cin >>a[i];

    a.push_back(0);
    all.clear();
    for(int i=0;i<a.size();i++) 
      for(int j=i;j<a.size();j++)
	all.push_back(a[i]+a[j]);

    sort(all.begin(),all.end());

    int ans = 0;
    int allsize = all.size();
    for(int i=0;i<allsize;i++) {
      if(i!=allsize-1 && all[i] == all[i+1]) continue;
      int res = all[i] + all[bainary_search(i)];
      if(ans < res && res<= m) ans = res;
    }
    cout << ans <<endl;
  }
  return 0;
  
}

Measured memory_bytes: 3176
#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);
  string b;
  cin >> b;
  if(b=="A")
  {
    cout << "T" << endl;
  }
  else if(b=="T")
  {
    cout << "A" << endl;
  }
  else if(b=="C")
  {
    cout << "G" << endl;
  }
  else
  {
    cout << "C" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main ()
{
	long long int a, x;
	scanf ("%lld", &x);
	if (x/11!=0)
		a=(x/11)*2;
	if (x%11<=6&&x%11>0)
		a+=1;
	if (x%11>6)
		a+=2;
	printf ("%lld", a);
	return 0;
}


Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());

        var a = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine()).ToArray();
        string[] h = new[] { "AC", "WA", "TLE", "RE" };

        Console.WriteLine(string.Join("\n", h.Select(x => $"{x} x {a.Count(y => y == x)}")));
    }
}


Measured memory_bytes: 32180
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
const int limit = 100;
const vector<int> cost = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };
string max_num(string s, string t) {
	if (s.size() > t.size()) return s;
	if (s.size() < t.size()) return t;
	return max(s, t);
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for (int i = 0; i < M; ++i) cin >> A[i];
	sort(A.begin(), A.end());
	vector<string> dp(limit + 1);
	for (int i = 1; i <= limit; ++i) {
		for (int j = 0; j < M; ++j) {
			if (i - cost[A[j]] < 0) continue;
			if (i - cost[A[j]] == 0 || !dp[i - cost[A[j]]].empty()) {
				dp[i] = max_num(dp[i], dp[i - cost[A[j]]] + to_string(A[j]));
			}
		}
	}
	int opt = 1 << 30, pos = -1;
	for (int i = 0; i < M; ++i) {
		if (opt >= cost[A[i]]) {
			opt = cost[A[i]];
			pos = A[i];
		}
	}
	string final_ans;
	for (int i = 0; i <= N; i += opt) {
		int rem = N - i;
		if (rem > limit) continue;
		string ans = dp[rem];
		if (rem != 0 && ans.empty()) continue;
		for (int j = 0; j < i; j += opt) ans += to_string(pos);
		sort(ans.begin(), ans.end(), greater<char>());
		final_ans = max_num(final_ans, ans);
	}
	cout << final_ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    string S, T;
    cin >> S >> T;
    for (int i = 0; i < N; ++i) {
        putchar(S[i]);
        putchar(T[i]);
    }
    putchar('\n');
    return 0;
}


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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

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

  if(s.size() < t.size()){
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  for(int i = s.size() - t.size(); i >= 0; i--){
    bool flag = true;
    for(int j = 0; j < t.size(); j++){
      if(s[i+j] != t[j] and s[i+j] != '?'){
        flag = false;
        break;
      }
    }
    if(flag){
      for(int j = 0; j < t.size(); j++){
        s[i+j] = t[j];
      }
      for(int j = 0; j < s.size(); j++){
        if(s[j] == '?'){
          s[j] = 'a';
        }
      }
      cout << s << endl;
      return 0;
    }
  }

  cout << "UNRESTORABLE" << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        double A = sc.nextDouble();
        double B = sc.nextDouble();
        
        if(A > B){
            System.out.println("GREATER");
        } else if(A < B){
            System.out.println("LESS");
        } else {
            System.out.println("EQUAL");
        }
        
        sc.close();
        
    }
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n;
  string s;
  cin>>n>>s;
  if(n%2==1){
    cout<<"No"<<endl;
    return 0;
  }
  string ss=s;
  for(int i=0;i<n/2;i++){
    ss.pop_back();
  }
  if(s.find(ss,n/2)==-1){
    cout<<"No"<<endl;
  }
  else{
    cout<<"Yes"<<endl;
  }
}

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

int main(){

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


for(int i = min(A, B); i > 0 ; i--){ 
int cnt;     
        if(A % i == 0 && B % i == 0) cnt++;
        if (cnt == K) {
            cout <<  i << endl;
            return 0;
        }   
}


}

Measured memory_bytes: 256
#include <stdio.h>

void mergeSort(int *, int, int);
void merge(int *, int, int, int);

int count = 0;
int L[250002],R[250002];
int main(){
  int i,n,right,left = 0;
  int S[500000];

  scanf("%d",&n);
  right = n;
  for(i = 0; i < n; i++){
    scanf("%d",&S[i]);
  }

  mergeSort(S,left,right);
  
  for(i = 0; i < n; i++){
    printf("%d",S[i]);
    if(i == n-1) break;
    printf(" ");
  }

  printf("\n%d\n",count);
  

  return 0;
}

void mergeSort(int *S, int left, int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(S,left,mid);
    mergeSort(S,mid,right);
    merge(S,left,mid,right);
  }
}

void merge(int *S, int left, int mid, int right){
  int i,j,k,n1,n2;
  
  n1 = mid - left;
  n2 = right - mid;

  for(i = 0; i < n1; i++){
    L[i] = S[left+i];
  }

  for(i = 0; i < n2; i++){
    R[i] = S[mid+i];
  }
  L[n1] = 2000000000;
  R[n2] = 2000000000;
  
  i = 0;
  j = 0;

  for(k = left; k < right; k++){
    count++;
    if(L[i] <= R[j]){
      S[k] = L[i];
      i = i + 1;
    }
    else{
      S[k] = R[j];
      j = j + 1;
    }
  }
}



Measured memory_bytes: 5604
x, k, d = map(int, input().split())
abs_x = abs(x)
kd = k * d 
ans = 0
if abs_x > kd:
  ans = abs_x - kd
else:
  div, mod = divmod(abs_x, d)
  ans = abs(mod - (k - div) % 2 * d)

print(ans)

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

#define ll long long
#define pii pair <int, int>

using namespace std;

string s;
int a[500005];

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

    cin >> s;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] == '<')
            a[i + 2] = a[i + 1] + 1;
    }
    /*for (int i = 1; i <= s.length() + 1; ++i)
        cout << a[i] << " ";
    cout << '\n';*/
    for (int i = s.length() - 1; i >= 0; --i) {
        if (s[i] == '>')
            a[i + 1] = max(a[i + 1], a[i + 2] + 1);
    }
    ll rez = 0;
    for (int i = 1; i <= s.length() + 1; ++i)
        rez += a[i];
    return cout << rez, 0;
}


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

int N;

struct V {
  ll x, y;

  V(ll x = 0, ll y = 0): x(x), y(y) {};

  ll r2() const {
    return dot(*this);
  }

  V& operator += (const V &v) {
    x += v.x;
    y += v.y;
    return *this;
  }

  ll cross(const V& that) const {
    return x * that.y - that.x * y;
  }

  ll dot(const V& that) const {
    return x * that.x + y * that.y;
  }

  int orthant() const {
    if(x == 0 && y == 0) return 0;
    if(x > 0 && y >= 0) return 1;
    if(x <= 0 && y > 0) return 2;
    if(x < 0 && y <= 0) return 3;
    return 4;
  }

  bool operator < (const V &that) const {
    int o1 = orthant(), o2 = that.orthant();
    if(o1 != o2) return o1 < o2;
    return cross(that) > 0;
  }
};

vector<V> x;

int main () {
  cin >> N;

  rep(i,N) {
    ll a, b;
    cin >> a >> b;
    x.emplace_back(a, b);
  }

  sort(all(x));

  ll ans = 0;
  rep(i,N) {
    V c(0, 0);
    rep(j,N) {
      c += x[(i+j)%N];
      ans = max(ans, c.r2());
    }
  }

  cout << fixed << setprecision(12) << sqrt(ans) << endl;

  return 0;
}


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

int main()
{
    int h, n;
    cin >> h >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];

    int sum = accumulate(a.begin(), a.end(), 0);

    if (sum >= h) {
        cout << "Yes" << endl;
        return 0;
    } else {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
scanf("%d", &n);
int arr[n];
int ct[n+1];
memset(ct,0,sizeof(ct));
int ans=0;
for (int i=0;i<n;i++) {
scanf("%d", &arr[i]);
if (arr[i]>n) ans+=1;
else ct[arr[i]]++;
}
for (int i=0;i<=n;i++) {
if (ct[i]>=i) ans+=ct[i]-i;
else ans+=ct[i];
}
printf("%d\n", ans);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<vector>
#include<queue>
using namespace std;

int n;
vector<int>g[200001];
int d[200001];
int ans=0,ansd=0;
void dfs(int u,int f){
/*	if(d[u]>ans)ans=d[u],ansd=u;
	for(int i=0;i<g[u].size();i++)
		if(f!=g[u][i]){
			d[g[u][i]]=d[u]+1;
			dfs(g[u][i],u);
		}*/
	for(int i=1;i<=n;i++)d[i]=0;
	queue<int>q;
	q.push(u);
	d[u]=1;
	while(!q.empty()){
		int o=q.front();
		q.pop();
		for(int i=0;i<g[o].size();i++)
			if(!d[g[o][i]]){
				d[g[o][i]]=d[o]+1;
				q.push(g[o][i]);
			}
	}
	ans=0;
	for(int i=1;i<=n;i++)
		if(d[i]>ans)ans=d[i],ansd=i;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int u,v;
		scanf("%d%d",&u,&v);
		g[u].push_back(v);
		g[v].push_back(u);
	}
	d[1]=1;
	dfs(1,0);
	d[ansd]=1;
	ans=0;
	dfs(ansd,0);
	printf(ans%3!=2?"First\n":"Second\n");
}

Measured memory_bytes: 16024
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  map<int, int> m;
  for (int i = 0; i < 4; i++) {
    int t; cin >> t;
    m[t]++;
  }
  if (m[1] && m[9] && m[7] && m[4]) cout << "YES" << '\n';
  else cout << "NO" << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3596
# unionfindぽいけどもっと単純に答えるらしい
# って思ってやったんだけどTLEなるじゃん は？？？？？？？？？？
# なんかリストを作るときに探索して仲間わけしてるからクエリの判定がO(1)で済むっていうやり方をやってるらしい
n, m = gets.chomp.split.map(&:to_i)
arr = Array.new(n).map{[]}
group = Array.new(n, 0) # これで同じグラフに属するか判断するらしい
# ただし判断するときに、0同士は独立した者同士ってことを考慮する
id = 1  # グループ番号
m.times do
  a, b = gets.chomp.split.map(&:to_i)
  arr[a] << b
  arr[b] << a
  # ここで探索して仲間わけするらしい
  # 違ったわ ぜんぶとってから（3WA）
end

# ここで探索して仲間わけ
n.times do |a|
  stack = [a]
  if group[a].zero?
    group[a] = id
  end
  until stack.empty?
    nex = stack.pop
    arr[nex].each do |i|
      if group[i].zero?
        group[i] = id
        stack << i
      end
    end
  end
  id+=1
end

q = gets.chomp.to_i
q.times do
  a, b = gets.chomp.split.map(&:to_i)
  if group[a] == group[b] && group[a] > 0 && group[b] > 0 # 0同士は独立した者同士
    puts "yes"
  else
    puts "no"
  end
end


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

typedef long long ll;

// Vectors
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define print(msg) cout << msg << endl

const int INF = 1e9;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    int sum = 0;
    for (int i = 0; i < sz(s); ++i) {
        sum += (s[i] - 48);
    }
    if (sum % 9 == 0) {
        cout << "Yes"
             << "\n";
    } else {
        cout << "No"
             << "\n";
    }

    return 0;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
typedef long long LL;
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VL vector<long long>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second

using namespace std;

int main(){
	DRIII(h,w,n);
	set<PII> b;
	int bestsol=h;
	REP(i,n){
		DRII(x,y);
		b.insert({y-1,x-1});
	}
	int cmr=0;
	auto it=b.begin();
	REP(col,w){
		//cout<<col<<" "<<cmr<<endl;
		while (it!=b.end() and *it<=PII({col,cmr})) it++;
		if (it==b.end()) break;
		if (it->F==col){
			bestsol=min(bestsol,it->S);
		}
		
		if (col<w-1){
			cmr++;
			while (b.find({col+1,cmr})!=b.end() and cmr<h) cmr++;
		}
		if (cmr>=bestsol) break;
	}
	printf("%d\n",bestsol);
}


Measured memory_bytes: 9600
require 'set'
N = gets.to_i
S = gets.chomp

R = Set.new
G = Set.new
B = Set.new

S.each_char.with_index {|c, i|
  case c
  when 'R'
    R << i
  when 'G'
    G << i
  when 'B'
    B << i
  end
}

a, b, c = [R, G, B].sort_by(&:length)

ans = 0

a.each do |i|
  b.each do |j|
    ans += c.length

    i1, j1 = [i, j].sort
    min = i1 - (j1 - i1)
    med = (i1 + j1).even? ? (i1 + j1) / 2 : -1
    max = j1 + j1 - i1

    if c.include?(min)
      ans -= 1
    end
    if c.include?(med)
      ans -= 1
    end
    if c.include?(max)
      ans -= 1
    end
  end
end

puts ans

Measured memory_bytes: 14540
import itertools
import copy

h, w, k =  map(int, input().split())
c_list = []
ans = 0
for i in range(h):
    c = list(input())
    c_list.append(c)

p_list = list(itertools.product(range(0, 2), repeat = (h + w)))

for i in range(len(p_list)):
    damy = copy.deepcopy(c_list)
    for j in range(h):
        if p_list[i][j] == 1:
            damy[j] = ["."] * w
    for j in range(w):
        if p_list[i][h + j] == 1:
            for l in range(h):
                damy[l][j] = "."
    count = 0
    for j in range(h):
        count += damy[j].count('#')
    if count == k:
        ans += 1

print(ans)


Measured memory_bytes: 9512
/*
 * FileName:     counting_sort
 * CreatedDate:  2020-07-07 16:45:13 +0900
 * LastModified: 2020-07-07 17:10:24 +0900
 */

#include <stdio.h>
#include <stdlib.h>
void counting_sort( int *a, int *b, int n, int k){
    int c[k];
    for(int i=0;i<k;i++){
        c[i]=0;
    }
    for(int i=1; i<n+1; i++){
        c[a[i]]++;
    }
    for(int i=1;i<k;i++){
        c[i] += c[i-1];
    }
    for(int i=n; i>0; i--){
        b[c[a[i]]] = a[i];
        c[a[i]]--;
    }
}
int main(void){
    int n;scanf("%d ", &n);
    int *a = malloc((n+1)*sizeof(int));
    int a_max = 0;
    for(int i=1;i<n+1;i++){
        scanf("%d", a+i);
        if(a_max<a[i]){
            a_max = a[i];
        }
    }
    int *b = malloc((n+1)*sizeof(int));
    counting_sort( a, b, n, a_max+1);
    printf("%d", b[1]);
    for(int i=2; i<n+1; i++){
        printf(" %d", b[i]);
    }
    printf("\n");
    free(a);
    free(b);
    return 0;
}



Measured memory_bytes: 17112
#include <bits/stdc++.h>
#define cin_fit() cin.tie(nullptr);ios::sync_with_stdio(false)
#define rep(i, N) for(int i=0; i<(N); i++)
#define reps(i, N) for(int i=1; i<=(N); i++)
#define rrep(i, N) for(int i=(int)(N)-1; i>=0; i--)
#define rreps(i, N) for(int i=(int)(N); i>=1; i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
using namespace std;
using ll = long long;
using V = vector<ll>;
using P = pair<ll, ll>;
constexpr int inf = 1e9;
constexpr int mod = 1e9+7;
ll gcd(ll a, ll b) { return b? gcd(b, a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a, b)*b;}

ll N, M;
ll k, p, s[15];

int main() {
    cin_fit();
    cin >> N >> M;
    rep(i, M) {
        cin >> k;
        rep(j, k) {
            ll t; cin >> t; t--;
            s[t] |= 1 << i;
        }
    }
    rep(i, M) {
        ll t; cin >> t;
        p |= t << i;
    }

    ll ans = 0;
    rep(i, 1 << N) {
        ll t = 0;
        rep(j, N) {
            if(i >> j & 1) {
                t ^= s[j];
            } 
        }
        if (t == p) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int X[100005];
vector<int> dif;

int main() {
    int N,M,i,cnt;

    scanf("%d%d",&N,&M);

    for (i = 0;i < M;i++)
        scanf("%d",&X[i]);

    sort(X,X + M);

    for (i = 1;i < M;i++)
        dif.push_back(X[i] - X[i - 1]);

    sort(dif.begin(),dif.end());

    cnt = 0;
    for (i = max(0,((int) dif.size()) - N + 1);i < dif.size();i++)
        cnt += dif[i];

    printf("%d\n",X[M - 1] - X[0] - cnt);

    return 0;
}


Measured memory_bytes: 1276
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		for(int i = 0; i<5; i++){
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);
	System.out.println(a[4]+" "+a[3]+" "+a[2]+" "+a[1]+" "+a[0]);
	}

}

Measured memory_bytes: 26380
N, K = map(int, input().split())
A = list(map(int, input().split()))

def f(X):
    return sum([X ^ a for a in A])

bin_K = '{:040b}'.format(K)
bin_A = ['{:040b}'.format(a) for a in A]
counter = [{'0': 0, '1': 0} for i in range(40)]
for ba in bin_A:
    for i in range(40):
        counter[i][ba[i]] += 1

cand = []
for i in range(40):
    if counter[i]['0'] < counter[i]['1']:
        cand.append('0')
    else:
        cand.append('1')

i = 0
for i in range(40):
    if bin_K[i] == '1':
        break

bin_K = bin_K[i:]
cand = cand[i:]
counter = counter[i:]

candidate = [f(0), f(K)]
for i in range(len(cand)):
    if bin_K[i] == '1':
        tmp = cand[i:]
        tmp[0] = '0'
        candidate.append(f(int(bin_K[:i]+''.join(tmp), 2)))

print(max(candidate))

Measured memory_bytes: 21988
#include <bits/stdc++.h>
#define pb push_back
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0)
#define ll long long
#define double long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define rep(i, a, b) for (int i = a; i < b; i++)
#define fr(i, b) for (int i = 0; i < b; i++)
#define cini(t) \
    int t;      \
    cin >> t
#define cinl(t) \
    ll t;       \
    cin >> t
#define cins(s) \
    string s;   \
    cin >> s
using namespace std;
int main()
{
    fast;
    cini(n);
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i] >> c[i];
    }
    int dp[n][3];
    rep(i, 0, n)
    {
        cin >> a[i] >> b[i] >> c[i];
    }

    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];

    rep(i, 1, n)
    {
        dp[i][0] = max(dp[i - 1][1], dp[i - 1][2]) + a[i];
        dp[i][1] = max(dp[i - 1][0], dp[i - 1][2]) + b[i];
        dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]) + c[i];
    }
    int ans = 0;
    rep(i, 0, 3)
    {
        ans = max(ans, dp[n - 1][i]);
    }

    cout << ans;
}

Measured memory_bytes: 2560
while True:
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    n=int(input())
    NG=[list(map(int,input().split())) for _ in range(n)]
    dp=[[0]*(b+1) for _ in range(a+1)]
    for i in range(1,a+1):
        for j in range(1,b+1):
            dp[i][j]=dp[i-1][j]+dp[i][j-1]
            if i==j==1:
                dp[1][1]=1
            if [i,j] in NG:
                dp[i][j]=0
    print(dp[a][b])


Measured memory_bytes: 5600
n, m, s = map(int, input().split())

edges = [[] for _ in range(n)]
for _ in range(m):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    edges[u].append((v, a, b))
    edges[v].append((u, a, b))

banks = tuple(tuple(map(int, input().split())) for _ in range(n))

max_s = 50 * (n-1)

s = min(s, max_s)

import heapq

h = []
dp = [[float('inf')] * (max_s+1) for _ in range(n)]
ans = [float('inf')] * n

heapq.heappush(h, (0, 0, s))
while h:
    time, node, coin = heapq.heappop(h)
    if time >= dp[node][coin]:
        continue
    dp[node][coin] = time
    if time < ans[node]:
        ans[node] = time

    c, d = banks[node]
    if coin < max_s:
        heapq.heappush(h, (time+d, node, min(coin + c, max_s)))

    for n, a, b in edges[node]:
        new_time = time + b
        new_coin = coin - a
        if new_coin < 0 or new_time >= dp[n][new_coin]:
            continue
        heapq.heappush(h, (new_time, n, new_coin))

for a in ans[1:]:
    print(a)


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

const int MOD = 1000000007;
const int INF = 1000000000;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

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

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


int main(){
string S;
cin >> S;
int cnt = 0;
REP(i, S.length()) if(S[i] == '1') cnt++;
print(cnt);

}


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

bool isnum(string a)
{
	return ('0' <= a[0] && a[0] <= '9');
}

int tonum(string a)
{
	int ret = 0;
	rep(i, 0, a.length()) ret = ret * 10 + a[i] - '0';
	return ret;
}

string solve()
{
	int m; cin >> m;
	map<string, set<int>> name;
	rep(i, 0, m)
	{
		string s; cin >> s;
		int lb, ub; cin >> lb >> ub;
		rep(i, lb, ub + 1) name[s].insert(i);
	}

	int n; cin >> n;
	int index = 0;
	stack<string> stk;
	rep(_n, 0, n)
	{
		string s; cin >> s;

		if ((s[0] == '+' || s[0] == '-') || (s[0] == '*' || s[0] == '/'))
		{
			string b = stk.top(); stk.pop();
			string a = stk.top(); stk.pop();

			set<int> aa, bb, cc;

			if (isnum(a))
				aa.insert(tonum(a));
			else
				for (int i : name[a]) aa.insert(i);

			if (isnum(b))
				bb.insert(tonum(b));
			else
				for (int i : name[b]) bb.insert(i);

			if (s[0] == '/')
			{
				for (int i : bb) if (i == 0) return "error";
			}

			for (int aaa : aa) for (int bbb : bb)
			{
				int c;
				switch (s[0])
				{
				case '+': c = (aaa + bbb) % 256; break;
				case '-': c = (aaa - bbb + 256) % 256; break;
				case '*': c = (aaa * bbb) % 256; break;
				case '/': c = (aaa / bbb) % 256; break;
				}
				cc.insert(c);
			}

			string next = "_" + to_string(index);
			index++;
			stk.push(next);
			name[next] = cc;
		}
		else
		{
			stk.push(s);
		}
	}

	return "correct";
}

int main()
{
	cout << solve() << endl;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
#include<functional>
#include<queue>
using namespace std;

const double INF = 1e9;
typedef double Weight;

struct Edge{
  int src,dst;
  Weight weight;
  Edge(int src,int dst,Weight weight) : src(src), dst(dst), weight(weight) {;}
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void dijkstra(const Graph &g,const int s, vector<Weight> &dist, vector<int> &prev) {
  const int n = g.size();
  dist.assign(n, INF);
  dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q;

  for(Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top();
    Q.pop();
    if(prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(Edges::const_iterator it = g[e.dst].begin(); it != g[e.dst].end(); ++it) {
      if(dist[it->dst] > e.weight + it->weight) {
	dist[it->dst] = e.weight + it->weight;
	Q.push(Edge(it->src, it->dst, e.weight + it->weight));
      }
    }
  }
}

int main() {
  int n,m,p,a,b,ts,t,x,y,z;
  vector<int> tickets(8);
  vector<int> prev((1<<8)*30);
  vector<Weight> dist((1<<8)*30);

  while(cin>>n>>m>>p>>a>>b) {
    if(n==0 && m==0 && p==0 && a==0 && b==0) break;
    ts = 1<<n;
    Graph g(ts*m);
    a--,b--;

    tickets.clear();
    for(int i=0; i<n; ++i) {
      cin>>t;
      tickets.push_back(t);
    }

    for(int i=0; i<p; ++i) {
      cin>>x>>y>>z;
      x--,y--;
      for(int j=0; j<ts; ++j) {
	for(int k=0; k<n; ++k) {
	  if((j&(1<<k)) == 0) {
	    g[x*ts+j].push_back( Edge(x*ts+j, y*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	    g[y*ts+j].push_back( Edge(y*ts+j, x*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	  }
	}
      }
    }

    dist.clear();
    prev.clear();
    dijkstra(g, a*ts, dist, prev);

    double minw = INF;
    for(int i=0; i<ts; ++i)
      minw = min(dist[b*ts+i], minw);

    if(minw == INF)
      cout<<"Impossible"<<endl;
    else
      cout<<minw<<endl;
  }
}

Measured memory_bytes: 28000
using System;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        //入力の受け取り
        char[] input = Console.ReadLine().ToCharArray();

        //配列→list
        List<char> numList = new List<char>();
        for(int jj = 0; jj < input.Length; jj++)
        {
            numList.Add(input[jj]);
        }

        //答え用カウンター
        int answer = 0;

        //隣合う0と1を取り除いてカウントしていく
        for(int ii = 0; ii < numList.Count - 1; ii++)
        {
            if(numList[ii] != numList[ii + 1])
            {
                numList.RemoveAt(ii);
                numList.RemoveAt(ii);
                answer = answer + 2;
                if (ii < 2)
                {
                    ii = 0;
                }
                else
                {
                    ii = ii - 2;
                }
            }
        }

        for (int ii = 0; ii < numList.Count - 1; ii++)
        {
            if (numList[ii] != numList[ii + 1])
            {
                numList.RemoveAt(ii);
                numList.RemoveAt(ii);
                answer = answer + 2;
            }
        }

        //回答提出
        Console.WriteLine(answer);

    }
}

Measured memory_bytes: 14048
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 1e-11
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<(n);i++)
#define loop(i,a,n) for(i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

double area(double a,double b,double c){
  double s=(a+b+c)/2;
  return sqrt(s*(s-a)*(s-b)*(s-c));
}

int main(void) {
  int i,j;
  double x1,x2,x3,y1,y2,y3;
  cin>>x1>>y1>>x2>>y2>>x3>>y3;
  double a=hypot(fabs(x1-x2),fabs(y1-y2));
  double b=hypot(fabs(x2-x3),fabs(y2-y3));
  double c=hypot(fabs(x1-x3),fabs(y1-y3));
  double r=2*area(a,b,c)/(a+b+c);

  double m=max(a,max(b,c));

  double ok=0;
  double ng=a+b+c;
  while(abs(ok-ng)>EPS){
    double mid=(ok+ng)/2;
    double x=(r-mid)*m/r;
    if(mid+mid<=x)ok=mid;
    else ng=mid;

  }
  cout<<shosu(15)<<ok<<endl;
}


Measured memory_bytes: 256
A=[]
i=0
for l in range(3):
    A.append(list(map(int,input().split())))
N=int(input())
B = [int(input()) for i in range(N)]
for C in B:
    for a in range(3):
        for b in range(3):
            if C==A[a][b]:
                A[a][b]=-1

for a in range(3):
    for b in range(3):
        if A[0][b]==A[1][b]==A[2][b]==-1:
            print("Yes")
            i=1
            break
        elif A[a][0]==A[a][1]==A[a][2]==-1:
            print("Yes")
            i=1
            break
        elif A[1][1]==A[2][2]==A[0][0]==-1:
            print("Yes")
            i=1
            break
        elif A[0][2]==A[1][1]==A[2][0]==-1:
            print("Yes")
            i=1
            break
    if i==1:
        break
if i==0:
    print("No")

Measured memory_bytes: 9200
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin >>n,n){
    int T[16][17],DP[1<<16];
    for(int i=0; i<n; i++) for(int j=0; j<=n; j++) cin >>T[i][j];
    for(int i=0; i<(1<<16); i++) DP[i] = 1600001;
    DP[0] = 0;
    for(int i=0; i<(1<<n); i++){
      for(int j=0; j<n; j++){
	if(i&(1<<j)) continue;
	int t=T[j][0];
	for(int k=0; k<n; k++) if(i&(1<<k)) t = min(t,T[j][k+1]);
	DP[i|(1<<j)] = min(DP[i|(1<<j)],DP[i]+t);
      }
    }
    cout <<DP[(1<<n)-1]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1416
struct dice{
    int d[6], tmp[6];
};
struct dice dice1;
struct dice dice2;
struct dice dice3[110];
void copy1(int a){
    int i;
    for (i=0;i<6;i++){
        dice3[a].d[i]=dice2.d[i];
        dice3[a].tmp[i]=dice2.tmp[i];
    }
}
void copy2(int a){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=dice3[a].d[i];
        dice2.tmp[i]=dice3[a].tmp[i];
    }
}
void init1(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice1.d[i]=n[i];
    }
}
void init2(int n[6]){
    int i;
    for (i=0;i<6;i++){
        dice2.d[i]=n[i];
    }
}
void throwdice(char c){
    int i;
    for(i=0;i<6;i++){
        dice1.tmp[i]=dice1.d[i];
    }
    if(c=='N'){
        dice1.d[0]=dice1.tmp[1];
        dice1.d[1]=dice1.tmp[5];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[0];
        dice1.d[5]=dice1.tmp[4];
    }
    else if(c=='E'){
        dice1.d[0]=dice1.tmp[3];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[0];
        dice1.d[3]=dice1.tmp[5];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[2];
    }
    else if(c=='W'){
        dice1.d[0]=dice1.tmp[2];
        dice1.d[1]=dice1.tmp[1];
        dice1.d[2]=dice1.tmp[5];
        dice1.d[3]=dice1.tmp[0];
        dice1.d[4]=dice1.tmp[4];
        dice1.d[5]=dice1.tmp[3];
    }
    else if(c=='S'){
        dice1.d[0]=dice1.tmp[4];
        dice1.d[1]=dice1.tmp[0];
        dice1.d[2]=dice1.tmp[2];
        dice1.d[3]=dice1.tmp[3];
        dice1.d[4]=dice1.tmp[5];
        dice1.d[5]=dice1.tmp[1];
    }
    else if(c=='R'){
        dice1.d[0]=dice1.tmp[0];
        dice1.d[1]=dice1.tmp[3];
        dice1.d[2]=dice1.tmp[1];
        dice1.d[3]=dice1.tmp[4];
        dice1.d[4]=dice1.tmp[2];
        dice1.d[5]=dice1.tmp[5];
    }
}
int compare(){
    int i;
    for(i=0;i<6;i++){
        if(dice1.d[i]!=dice2.d[i]){
            return 0;
        }
    }
    return 1;
}
int main()
{
    int n[6];
    int m;
    int i,j,k,l;
    int ok=0;
    scanf("%d",&m);
    for(i=0;i<6;i++){
        scanf("%d",&n[i]);
    }
    init2(n);
    copy1(0);
    for(i=0;i<m-1;i++){
        for(j=0;j<6;j++){
            scanf("%d",&n[j]);
        }
        init1(n);
        for(j=0;j<i+1;j++){
            copy2(j);
            for(k=0;k<4;k++){
                for(l=0;l<4;l++){
                    throwdice('N');
                    throwdice('E');
                    throwdice('S');
                    if(compare()) ok=1;
                }
                throwdice('N');    
            }
            throwdice('E');
            for(k=0;k<2;k++){
                for(l=0;l<4;l++){
                    throwdice('N');
                    throwdice('E');
                    throwdice('S');
                    if(compare()) ok=1;
                }
                throwdice('W');    
                throwdice('W');    
            }
        }
        copy1(i+1);
    }
    if(!ok) puts("Yes");
    else puts("No");
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

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

    string S;
    cin >> S;
    vector<ll> tmp;
    REP(i, S.size()){
    	tmp.push_back(S[i]-'A');
    }
    sort(tmp.begin(),tmp.end());
    if(tmp[0] == tmp[1] && tmp[2] == tmp[3] && tmp[1] != tmp[2]){
    	cout << "Yes" << endl;
    }else{
    	cout << "No" <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
class Proc {
    fun run() {
        val inpt = Reader.readLn()!!.split(" ").map { a-> a.toInt() }
        val ans = Math.min(inpt[0]*inpt[1], inpt[2])
        println(ans)
    }
}

class Reader {
    companion object {
        private var current = -1;
        var inputStrints: List<String>? = null
        fun readLn(): String? {
            current++
            return if(inputStrints == null) {
                readLine()
            } else {
                inputStrints!![current];
            }
        }
    }
}

fun main(args:Array<String>) {
    Proc().run()
}


Measured memory_bytes: 36160
#![allow(unused_imports)]
#![allow(unused_variables)]
use proconio::input;
use proconio::marker::*;
use std::cmp::{min, max};
use std::collections::{HashSet, HashMap, BinaryHeap};

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut sum = a[n - 1];
    let mut ans = 0i64;
    let MOD = 1e9 as i64 + 7;
    for i in (0..n - 1).rev(){
        ans += a[i] * sum;
        ans %= MOD;
        sum += a[i];
        sum %= MOD;
    }
    println!("{}", ans);
}


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

char c[10];

int check(char c[],int a,int b)
{
    int i;
    for(i=0;i<a-1;i++){
        if(!isdigit(c[i])) return 0;
    }
    if(c[a]!='-') return 0;
    for(i=a+1;i<a+b+1;i++){
        if(!isdigit(c[i])) return 0;
    }
    return 1;
}

int main()
{
    int a,b;
    cin>>a>>b>>c;
    if(check(c,a,b)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;

}


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

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

int gcd(int a, int b)
{
    if (!b) {
        return a;
    }

    return gcd(b, a % b);
}

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

template <typename T, T N>
class UnionFind {
    T parent_[N];
    T rank_[N];
    T size_[N];

public:
    UnionFind();
    T Root(T idx);
    bool IsSame(T x, T y);
    void Unite(T x, T y);
    T GetSize(T idx);
};

template <typename T, T N>
UnionFind<T, N>::UnionFind()
{
    for (T i = 0; i < N; i++) {
        parent_[i] = i;
        rank_[i] = 0;
        size_[i] = 1;
    }
}

template <typename T, T N>
T UnionFind<T, N>::Root(T idx)
{
    return parent_[idx] == idx ? idx : parent_[idx] = Root(parent_[idx]);
}

template <typename T, T N>
bool UnionFind<T, N>::IsSame(T x, T y)
{
    return Root(x) == Root(y);
}

template <typename T, T N>
void UnionFind<T, N>::Unite(T x, T y)
{
    x = Root(x);
    y = Root(y);
    if (x == y) {
        return;
    }

    if (rank_[x] < rank_[y]) {
        parent_[x] = y;
        size_[y] += size_[x];
    } else {
        parent_[y] = x;
        size_[x] += size_[y];
        if (rank_[x] == rank_[y]) {
            rank_[x]++;
        }
    }
}

template <typename T, T N>
T UnionFind<T, N>::GetSize(T idx)
{
    return size_[Root(idx)];
}

long long pow_mod(long long n, long long p, long long m)
{
    if (p == 0) {
        return 1;
    }

    if (p % 2 == 0) {
        long long t = pow_mod(n, p / 2, m);
        return t * t % m;
    }
    return n * pow_mod(n, p - 1, m) % mod;
}

long long nCr_mod(long long n, long long r)
{
    long long x = 1;
    for (long long i = n - r + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }

    long long a = 1;
    for (long long i = 1; i <= r; i++) {
        a *= i;
        a %= mod;
    }

    long long y = pow_mod(a, mod - 2, mod) % mod;

    return x * y % mod;
}

int main()
{
    long long x;
    std::cin >> x;

    long long val = 100;
    long long year = 0;
    while (val < x) {
        year++;
        val *= 1.01;
    }

    std::cout << year << std::endl;
}


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

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

int main() {
    int n, m, k, a; cin >> n >> m;
    vector<int> cnt(m);
    rep(i, n){
        cin >> k;
        rep(i, k){
            cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0; rep(i, m) if(cnt[i] == n) ans++;
    cout << ans << endl;
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;

void solve()
{
	int n, k;
	cin >> n >> k;
	vector<bool> s(n, false);

	for(int i = 0; i < k; ++i)
	{
		int d;
		cin >> d;
		for(int j = 0; j < d; ++j)
		{
			int a;
			cin >> a;
			s[a - 1] = true;
		}
	}

	int ans = n;
	for(const auto& v : s)
	{
		ans -= v;
	}

	cout << ans << endl;


}

int main()
{
	fastio;
	solve();

	return 0;
}

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

def main():
	N = int(input())
	S = input().rstrip()
	M = 10**9 + 7
	
	# a     (0)+1
	# ab    (1)+1+1
	# abc   (3)+3+1
	# abca  (7)+1+2+1
	# abcab (11)+1+3+2
	# abcabc (17)+1+4+3
	A = ord("a")
	res = 1
	for i in range(26):
		q = chr(i+A)
		qc = S.count(q)
		res = res * (qc+1) % M
		
	print((res-1) % M)
	
main()


Measured memory_bytes: 3188
/**
 * ??????

???????????´??°a, b, c?????????????????????????????? a < b <
c????????¶????????????????????°"Yes"?????????????????????????????°"No"???????????????????????°?????????????????????????????????

Input
???????????´??°???????????§????????????????????????????????????

Output
Yes?????????No????????????????????????????????????

Constraints
0 ??? a, b, c ??? 100
Sample Input 1
1 3 8
Sample Output 1
Yes
Sample Input 2
3 8 1
Sample Output 2
No

 */

#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  unsigned int a, b, c;
  a = b = c = 0;

  while (true) {
    std::string param;

    getline(std::cin, param);
    std::istringstream iss(param);
    iss >> a >> b >> c;

    if ((a > 100) || (b > 100) || (c > 100)) {
      std::cout << "Error: 0 <= a, b, c <= 100" << std::endl;
    } else {
      break;
    }
  }
  if ((a < b) && (b < c)) {
    std::cout << "Yes" << std::endl;
  } else {
    std::cout << "No" << std::endl;
  }

  return 0;
}

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

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }


int main() {

    int N, res = 0;
    cin >> N;
    vector<int> D;
    forn(i, N) {
        int d; cin >> d;
        D.pb(d);
        res += d * d;
    }
    int sum = 0;
    forn(i, N) {
        forn(j, N) {
            sum += D.at(i) * D.at(j);
        }
    }
    cout << (sum - res) / 2 << endl;
}


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

int main(){
  double x;
  cin >> x;
  
  int count = 1;
 
  while(x > 101){ 
  x /= 1.01;
  x = ceil(x);
  count++;
  }
  
  cout << count << endl;
}


  


Measured memory_bytes: 3716