akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(){
	char a;
	int b;
	while(true) {
		b=0;
		while(true) {
			a = cin.get();
			if ( a == '\n' ) break;
			b+=a-'0';
		}
		if ( b == 0 ) break;
		cout << b << endl;
	}
    return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    ll n; cin >> n;
    ll aux, w[200010];
    memset(w, 0, sizeof w);
    for(int i = 0; i < n - 1; i++){
        cin >> aux;
        w[aux]++;
    }
    for(int i = 1; i <= n; i++)
        cout << w[i] << "\n";
    return 0;
}


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

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  string s;
  cin >> s;
  REP(i, s.size()) { cout << 'x'; }
  cout << endl;
}

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

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

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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

void solve() {
  int n, m, x;
  vi c;
  mat A;

  cin >> n >> m >> x;
  int test[n][n];

  rep(i, 0, n) {
    int f;
    cin >> f;
    c.push_back(f);
    A.push_back(vi(0));

    rep(j, 0, m) {
      int s;
      cin >> s;
      A[i].push_back(s);
    }
  }

  int ans = INF;
  for (int bit = 0; bit < (1 << n); ++bit) {
    vi S;
    for (int i = 0; i < n; ++i) {
      if (bit & (1 << i)) {
        S.push_back(i);
      }
    }

    int cost = 0;
    rep(j, 0, S.size()) { cost += c[S[j]]; }
    if (cost > ans) {
      continue;
    }

    vi rikai(m);
    bool flag = true;
    rep(j, 0, S.size()) {
      rep(k, 0, m) { rikai[k] += A[S[j]][k]; }
    }

    rep(j, 0, rikai.size()) {
      if (rikai[j] < x) {
        flag = false;
      }
    }

    if (flag == true) {
      ans = cost;
    }
  }

  if (ans == INF) {
    cout << -1;
  } else {
    cout << ans;
  }
  cout << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
static const int N = 100;

int main(){
    int M[N][N];
    int n, u, k, v;
    
    cin >> n;
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M[i][j] = 0;
        }
    }
    
    for(int i=0; i<n; i++){
        cin >> u >> k;
        u--;
        for(int j=0; j<k; j++){
            cin >> v;
            v--;
            M[u][v] = 1;
        }
    }
    
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j) cout << " ";
            cout << M[i][j];
        }
        cout << endl;
    }
    
    return 0;
}


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

int main()
{
    int N;
    cin >> N;
    int a[110];
    for (int i = 0; i < N; i++) {
        a[i] = i;
    }

    int ans = 1;
    int num = 0;

    for (int i = 1; i <= N; i++) {
        bool can = true;
        int count = 0;
        int x = i;
        while (can) {
            if (x % 2) {
                can = false;
                break;
            }
            x /= 2;
            count++;
        }
        if (count > num) {
            ans = i;
        }
        num = max(num, count);
    }

    cout << ans << endl;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int N, M; cin >> N >> M;
  vector<int> a(M), b(M); REP(i, M) cin >> a[i] >> b[i];
  vector<vector<ll>> node(N + 1);
  REP(i, M) {
    node[a[i]].push_back(b[i]);
    node[b[i]].push_back(a[i]);
  }
  string ans = "IMPOSSIBLE";
  for(int i = 0; i < node[1].size(); ++i) {
    if(vector_finder(node[node[1][i]], N)) ans = "POSSIBLE";
  }
  cout << ans << endl;
}


Measured memory_bytes: 14312
#include<stdio.h>
#define M 250
int pa(int);
int left(int);
int right(int);
int main(){
  int s[M+1],i,H;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&s[i]);
  }
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,s[i]);
    if (pa(i) >= 1)printf("parent key = %d, ", s[pa(i)]);
    if (left(i) <= H)printf("left key = %d, ", s[left(i)]);
    if (right(i) <= H)printf("right key = %d, ", s[right(i)]);
    printf("\n");
  }
  return 0;
}
int pa(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}
int right(int i){
  return 2*i+1;
}



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D ;
  int L = A + B;
  int R = C + D;

  if (L == R) {
    cout << "Balanced"  << endl;
  }

  else if (L > R) {
    cout << "Left"  << endl;
  }

  else if (L < R) {
    cout << "Right"  << endl;
  }

}

Measured memory_bytes: 3608
n, y = gets.split.map(&:to_i)
(0..n).each do |i|
  (0..n-i).each do |j|
    k = n - i - j
    if 10000*i + 5000*j + 1000*k == y
      puts "#{i} #{j} #{k}"
      return
    end
  end
end
puts '-1 -1 -1'

Measured memory_bytes: 14364
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+7;
int a[5];
int main(){
    for(int i=0;i<3;i++) cin>>a[i];
    sort(a,a+3);
    if(a[0]+a[1]==a[2]) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int const INF = 1e9+5;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int> V(N), S(N+1, 0);
  for(int i = 0; i < N; ++i) std::cin >> V[i];
  for(int i = 0; i < N; ++i) S[i+1] = S[i] + V[i];
  int ans = 0;
  auto calc = [&](int nt, int np)->int {
    std::vector<int> v(V.begin(), V.begin()+nt);
    std::sort(v.begin(), v.end());
    int st = S[nt], sd = 0, cnt = 0;
    std::map<int,int> dis, keep;
    for(int vv: v) {
      if(vv >= 0) break;
      if(++cnt > np) ++keep[vv];
      else {
        sd += vv;
        ++dis[vv];
      }
    }
    if(cnt > np) cnt = np;
    int res = st - sd;
    for(int i = 0; i < nt; ++i) {
      // remove V[nt-1-i]
      int tgt = V[nt-1-i];
      st -= tgt;
      if(keep.count(tgt) > 0) { // if in keep
        if(--keep[tgt] == 0) keep.erase(tgt);
      } else if(dis.count(tgt) > 0) { // if only in dis
        sd -= tgt;
        if(--dis[tgt] == 0) dis.erase(tgt);
        if(--cnt < np && keep.size() > 0) { // move one from keep
          ++cnt;
          tgt = keep.begin()->first;
          sd += tgt;
          ++dis[tgt];
          if(--keep[tgt] == 0) keep.erase(tgt); 
        }
      }
      // add V[N-1-i] 
      tgt = V[N-1-i];
      st += tgt;
      if(tgt < 0) {
        sd += tgt;
        ++dis[tgt];
        if(++cnt > np) {
          --cnt;
          // move one to keep
          tgt = dis.rbegin()->first;
          sd -= tgt;
          if(--dis[tgt] == 0) dis.erase(tgt);
          ++keep[tgt];
        }
      }
      res = std::max(res, st - sd);
    }
    return res;
  };
  for(int i = 0; i <= std::min(N, K); ++i) {
    // take i jems, then put <=j jems back
    int j = std::min(K-i, i);
    ans = std::max(ans, calc(i, j));
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		char c[] = scan.next().toCharArray();
		if(c[0] == c[1] && c[1] == c[2]) {
			System.out.println("No");
		}else {
			System.out.println("Yes");
		}

	}

}

Measured memory_bytes: 21844
use std::io::*;
use std::str::FromStr;
use std::num::*;

fn main() {
    let mut b: String = read();
    let mut ans: String = "".to_string();
    let mut anssub: String = "".to_string();
    let mut cnt: i64 = 0;
    let mut max: i64 = 0;
    for i in b.as_str().chars(){
        if i.to_string() == "A" || i.to_string() == "T" || i.to_string() == "C" || i.to_string() == "G" {
            anssub.push_str(&i.to_string());
            cnt+=1;
            if cnt>max {
                ans = anssub.to_string();
                max = cnt;
            }
        }else{
            anssub = "".to_string();
            cnt = 0;
        }
    }
    println!("{}", ans.len());
}
fn read<T: FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

Measured memory_bytes: 4352
#include<stdio.h>
int main(){
  int n,m,xmax,ymin,i;
  scanf("%d%d%d%d",&n,&m,&xmax,&ymin);
  int a;
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(a>xmax)
      xmax=a;
  }
  for(i=0;i<m;i++){
    scanf("%d",&a);
    if(a<ymin)
      ymin=a;
  }
  if(xmax<ymin)
    puts("No War");
  else
    puts("War");
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <unordered_map>

using namespace std;

int main()
{
    unordered_map<char, bool> m;
    string l = "qwertasdfgzxcvb";
    string r = "yuiophjklnm";
    for (auto&& i : l) {
        m[i] = false;
    }
    for (auto&& i : r) {
        m[i] = true;
    }
    while (true) {
        string s;
        cin >> s;
        if (s == "#") {
            return 0;
        }

        bool state = m[s[0]];
        int count = 0;
        for (int i = 1; i < s.size(); ++i) {
            bool newState = m[s[i]];
            if (state != newState) {
                state = newState;
                count += 1;
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define mod 1000000007
#define pi acos(-1.0)
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main(int argc, char const *argv[])
{
   FastIO;
   ll n;
   cin>>n;
   ll sum = 0;
   for(int i=1;i<=n;i++)
   {
       if((i%3!=0 || i%5!=0) && i%3!=0 && i%5!=0)
       {
           //cout<<i<<endl;
           sum+=i;
       }

   }
   cout<<sum<<endl;
}


Measured memory_bytes: 3664
import sys
s =input()
n = len(s)
hn = int((n-1)/2)
qn = int((n+1)/4)
for i in range(qn):
  if s[i] == s[hn-i-1] and s[-i-1] == s[i-hn] and s[i] == s[-i-1]:
    pass
  else:
    print("No")
    sys.exit()
print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define range(i, l, r) for(long long int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (long long int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

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

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    os << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        os << ", " << *it;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    os << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        os << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint X; cin >> X;
    lint num_500 = X / 500;
    lint num_5 = (X - num_500 * 500) / 5;
    cout << num_500 * 1000 + num_5 * 5 << "\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n, m, q;
    cin >> n >> m >> q;
    int a[q], b[q], c[q],d[q];
    long i, j, k;
    for(i=0; i<q; i++){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    int p[n];
    for(i=0;i<n;i++){
        p[i]=1;
    }
    long score_max=0;
    for(i=0;i<10000000000;i++){
        long score=0;
        for(j=0; j<q;j++){
            if(p[b[j]-1] - p[a[j]-1] == c[j]) score += d[j];
        }
        if(score_max<score)score_max=score;
        p[n-1]++;
        for(j=n-1;j>=1;j--){
            if(p[j]>m){
                p[j-1]++;
                for(k=j;k<n;k++){
                    p[k]=p[j-1];
                }
            }
        }
        if(p[0]>m)break;
    }
    cout << score_max << endl;
    return 0;
}

Measured memory_bytes: 3620
s = input()

d = dict()
for i in range(len(s)):
    c = s[i]
    if d.__contains__(c):
        d[c].append(i)
    else:
        d[c]=[]
        d[c].append(i)
for c in d.keys():
    for i in range(len(d[c])-1):
        if d[c][i+1]-d[c][i]<3:
            print(d[c][i]+1,d[c][i+1]+1)
            exit(0)
print(-1,-1)


Measured memory_bytes: 7412
H, W, K = map(int, input().split())
S = [list(input()) for i in range(H)]

fans = 10 ** 5
for i in range(1 << (H-1)):
    slc = []
    scnt = 1
    ans = 0
    switch = 1
    for j in range(H-1):
        if (i >> j) % 2 == 1:
            slc.append(j+1)
            scnt += 1
            ans += 1
    slc.append(H)
    stock = [0] * scnt 
    for j in range(W):
        kari = [0] * scnt
        ss = slc[0]
        idx = 0
        for k in range(H):
            if ss == k:
                idx += 1
                ss = slc[idx]
            if S[k][j] == "1":
                kari[idx] += 1
            if kari[idx] > K:
                switch = 0
                break
        if switch == 0:
            break
        for k in range(scnt):
            if stock[k] + kari[k] <= K:
                stock[k] += kari[k]
            else:
                stock = kari
                ans += 1
                break
    if switch == 1:
        fans = min(fans, ans)

print(fans)

Measured memory_bytes: 46812
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int main()
{
	int n;
	int num=0;
	scanf("%d",&n);
	int u=n;
	int sum=0;
	int o=1;
	int x=1;
	while(n)
	{
		num++;
		n/=10;
	}
	if(num%2==0)
	{
		for(int i=1;i<=num;i++)
		{
			o=o*10;
			if(i%2==1)sum+=o-x;
			x*=10;
		}
		printf("%d\n",sum);
	}
	else {
		for(int i=1;i<num;i++)
		{
			o=o*10;
			if(i%2==1)
			sum+=o-x;
			x=x*10;
		}
		sum+=u-o+1;
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(NULL);
inline void IO() {
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
}

int main(int argc, char const *argv[])
{
	//IO();
	FAST_IO
	
	string s, t; cin >> s >> t;
	int count = 0;
	for(int i=0 ; i < s.size() ; i++) {
		if(s[i] != t[i]) ++count;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(b<c||d<a){
		cout<<0<<endl;
	}
	else{
		cout<<min(b,d)-max(a,c)<<endl;
	}
	return 0;
}



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

int main() {
	bool valid = true;
	int n;cin >>n;
	for(int i=0;i<n;++i){
		int a;cin>>a;
		if(a%2==0){
			if(a%3!=0&&a%5!=0){
				valid = false;
				break;
			}
		}
	}
	if(valid){
		cout << "APPROVED" << endl;
	} else {
		cout << "DENIED" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b;

    scanf("%d %d",&a,&b);
    if(a==1){
        a=14;
    }
    if(b==1){
        b=14;
    }

    if(a>b){
        printf("Alice");
    }
    else if(a<b){   
        printf("Bob");
         
    }

    else
    {
        printf("Draw");
    }
    
    
    return 0;
}

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


int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;
    for(int i = 0; flag; i++){
        flag = 0;
        for(int j = N - 1; j >= i + 1; j--){
            if(A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(){
    int A[100], N, sw;
    cin >> N;
    for(int i=0; i<N; i++) cin >> A[i];

    sw = bubbleSort(A, N);

    for(int i=0; i<N; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;

    cout << sw << endl;

    return 0;
}



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

int main() {
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < s.size(); i++) {
    if (s.at(i) == 'o') c++;
  }
  cout << 700 + c * 100 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <iomanip>

using namespace std;

int main(){
    int n;
    double sum = 0.0;
    cin >> n;

    for(int i = 0;i < n;i++){
        double num;
        string s;
        cin >> num >> s;

        if(s == "JPY")
            sum += num;
        else 
            sum += num*380000.0;
    }

    cout << setprecision(14) << sum << endl;


    return 0;
}

Measured memory_bytes: 256
n,a,b=input().split()
n,a,b=int(n),int(a),int(b)
m=len(str(n))
'''
c=0
if n==10**4 and A==1:
    c=1
k=len(str(n))
for i in range(k):
'''
c=0
for i in range(n):
    #map関数はクソ便利
     if a <= sum(list(map(int, str(i+1)))) <= b:
         c+=i+1

print(c)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, a, n) for (long long i = (a); i < (long long)(n); ++i)
#define REPC(i, a, n) for (long long i = (a); i <= (long long)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
void show(int H, int W, VEC<VEC<int>>&A){
  REP(i,0,H){
    REP(j,0,W){
      cout<<A[i][j]<<" ";
    }
    cout<<endl;
  }
  cerr<<endl;

}

int main() {
  int H, W, K;
  cin >> H >> W >> K;
  VEC<string> S(H);
  REP(i, 0, H) cin >> S[i];
  auto A=MATINIT(int, H, W, 0);
  int k = 1;
  REP(i,0,H){
    REP(j,0,W){
      if(S[i][j]=='#'){
        A[i][j]=k;
        k++;
      }
    }
  }
  // show(H,W,A);

  REP(i,0,H){
    REP(j,1,W){
      int prev = A[i][j-1];
      if(prev!=0 && A[i][j]==0)A[i][j]=prev;
    }
    for(int j=W-2;j>=0;j--){
      int prev = A[i][j+1];
      if(prev!=0 && A[i][j]==0)A[i][j]=prev;
    }
  }
  // show(H,W,A);

  REP(j,0,W){
    REP(i,1,H){
      int prev = A[i-1][j];
      if(prev!=0 && A[i][j]==0)A[i][j]=prev;
    }
    for(int i=H-2;i>=0;i--){
      int prev = A[i+1][j];
      if(prev!=0 && A[i][j]==0)A[i][j]=prev;
    }
  }
  show(H,W,A);

  return 0;
}


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

using namespace std;

int const maxn = 101010;

vector<int> v[maxn];
int dp[maxn], g[maxn];

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

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;

        v[x].push_back(y);
        g[y]++;
    }

    vector<int> tsort;
    for (int i = 1; i <= n; i++) {
        if (g[i] == 0) {
            tsort.push_back(i);
        }
    }

    for (int i = 0; i < (int)tsort.size(); i++) {
        int at = tsort[i];
        for (int u : v[at]) {
            g[u]--;

            if (g[u] == 0) {
                tsort.push_back(u);
            }
        }
    }

    for (int i = n-1; i >= 0; i--) {
        int at = tsort[i];
        for (int u : v[at]) {
            dp[at] = max(dp[at], dp[u] + 1);
        }
    }

    int ans = *max_element(dp+1, dp+n+1);

    cout << ans << "\n";
}

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



int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  rep(i,N){
      cin >> S[i];
  }
  sort(S.begin(),S.end());
  S.push_back("##");

  vector<pair<int,string>> p;
  int c = 1;
  rep(i,N){
      if(S[i] == S[i+1]){
          c++;
      }
      if(S[i] != S[i+1]){
         p.push_back(make_pair(c,S[i]));
         c = 1;
      }
  }
  sort(p.begin(),p.end());

  int num = p[p.size()-1].first;
  //reverse(p.begin(),p.end());

  rep(i,p.size()){
      if(p[i].first == num) cout << p[i].second << endl;
  }
}


Measured memory_bytes: 21092
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>

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

int main()
{
  int n;
  cin >> n;
  int p;
  int cnt = 0;
  rep(i, n)
  {
    cin >> p;
    if(p-1 != i) ++ cnt;
  }
  if(cnt > 2)
    cout << "NO" << endl;
  else
    cout << "YES" << 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);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        UnionFindTree uft = new UnionFindTree(n);
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            uft.unite(a, b);
        }
        uft.calc();
        for (int i = 0; i < k; i++) {
            int a = sc.nextInt() - 1;
            int b = sc.nextInt() - 1;
            uft.dislike(a, b);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            if (i != 0) {
                sb.append(" ");
            }
            sb.append(uft.ans[i]);
        }
		System.out.println(sb);
   }
    
    static class UnionFindTree {
        int[] parents;
        int[] counts;
        int[] friends;
        int[] ans;
        
        public UnionFindTree(int size) {
            parents = new int[size];
            counts = new int[size];
            friends = new int[size];
            ans = new int[size];
            for (int i = 0; i < size; i++) {
                parents[i] = i;
                counts[i] = 1;
            }
        }
        
        public int find(int x) {
            if (parents[x] == x) {
                return x;
            } else {
                return parents[x] = find(parents[x]);
            }
        }
        
        public boolean same(int x, int y) {
            return find(x) == find(y);
        }
        
        public void unite(int x, int y) {
            friends[x]++;
            friends[y]++;
            int xx = find(x);
            int yy = find(y);
            if (xx == yy) {
                return;
            }
            parents[xx] = yy;
            counts[yy] += counts[xx];
        }
        
        public void calc() {
            for (int i = 0; i < counts.length; i++) {
                ans[i] = counts[find(i)] - 1 - friends[i];
            }
        }
        
        public void dislike(int x, int y) {
            if (same(x, y)) {
                ans[x]--;
                ans[y]--;
            }
        }
    }

}


Measured memory_bytes: 95344
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  int now = 1;
  REP(i, N){
    if(A[i] == now) now++;
  }

  if(now == 1) N = -1;
  cout << N-now+1 << "\n";

  return 0;
}

Measured memory_bytes: 1792
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <utility>

#define reps(i,f,n) for(ll i=f; i<ll(n); ++i)
#define rep(i,n) reps(i,0,n)

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pii;

const char* color = "RYGB";

signed main()
{
    int h, w, d;
    cin >> h >> w >> d;
    
    if(d%2 == 1){
        rep(i, h){
            rep(j, w) cout << color[(i+j)%4];
            cout << endl;
        }
    }
    else{
        vector<string> S(h, string(w, ' '));
        
        rep(i, h) rep(j, w){
            S[i][j] = color[(((i + j) / d) % 2) * 2 + (((i - j + w*10 + h*10) / d) % 2)];
        }
        
        /*
        for(int k=0; k<h+w-1; k+=2){
            rep(j, w){
                int i = k - j;
                if(i < 0 || h <= i) continue;
                S[i][j] = color[((k / d) % 2) * 2 + (((j + k/2) / (d/2)) % 2)];
            }
        }
        */
        
        rep(i, h){
            cout << S[i] << endl;
        }
    }
}


Measured memory_bytes: 768
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

ll f(ll mid,ll A,ll B,ll N){
  // if(mid<0 or N<mid)return false;
  return (A*mid)/B-A*(mid/B);
}

bool solve(){
  ll A,B,N;cin>>A>>B>>N;
  
  // rep(i,100)cout<<i<<" "<<f(i,A,B,N)<<endl;
  cout<<f(min(N,B-1),A,B,N)<<endl;
  return false;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout<<fixed<<setprecision(30);
    solve();
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf=0x3f3f3f3f;
const int N=2e5+20;
int mn[2][N][30],n,a[2][N],pos[N];
void init(int v)
{
	for(int i=0;i<n;i++)
		mn[v][i][0]=a[v][i];
	for(int j=1;(1<<j)<=n;j++)
		for(int i=0;(i+(1<<j)-1)<n;i++)
			mn[v][i][j]=min(mn[v][i][j-1],mn[v][i+(1<<(j-1))][j-1]);
}
int rmq(int l,int r,int v)
{
	int k=0;
	while((1<<(k+1))<=r-l+1)
		k++;
	return min(mn[v][l][k],mn[v][r-(1<<k)+1][k]);
}
struct node{
	int x,l,r;
	bool operator < (const node &t)const{
		return x>t.x;
	}
};
int main()
{
	int x;
	while(cin>>n)
	{
		for(int i=0;i<n;i++)
		{
			scanf("%d",&x);
			pos[x]=i;
			a[i&1][i]=x;
			a[(i&1)^1][i]=inf;
		}
		init(0),init(1);
		priority_queue<node> q;
		x=rmq(0,n-1,0);
		q.push({x,0,n-1});
		while(!q.empty())
		{
			node x=q.top();
			q.pop();
			int v1=x.x,v2=rmq(pos[x.x]+1,x.r,(pos[x.x]&1)^1);
			printf("%d %d ",v1,v2);
			v1=pos[v1],v2=pos[v2];
			if(x.l!=v1)
				q.push({rmq(x.l,v1-1,x.l&1),x.l,v1-1});
			if(v1+1!=v2)
				q.push({rmq(v1+1,v2-1,(v1+1)&1),v1+1,v2-1});
			if(v2!=x.r)
				q.push({rmq(v2+1,x.r,(v2+1)&1),v2+1,x.r});
		}
		printf("\n");
	}
	return 0;
 
} 

Measured memory_bytes: 51320
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int A, B;
	cin >> A >> B;
	int p;
	int C1 = 0;
	int C2 = 0;
	int C3 = 0;
	for (int i = 0; i < N; i++) {
		cin >> p;
		if (p <= A)C1++;
		else if (p > B)C3++;
		else C2++;
	}
	cout << min(C1, min(C2, C3)) << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC48 D

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
n = len(s)
if s[0] == s[-1]:
    if n % 2:
        print('Second')
    else:
        print('First')
else:
    if n % 2:
        print('First')
    else:
        print('Second')


Measured memory_bytes: 39152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define all(a) (a).begin(),(a).end()
#define bit(k) (1LL<<(k))

int main(void){
    int n,K;
    cin >> n >> K;
    vector<ll> a(n), sum(n+1);
    rep(i,n) cin>>a[i];
    rep(i,n) sum[i+1] += sum[i] + a[i];
    vector<ll> btf;
    rep1(r,n)rep(l,r){
        btf.push_back(sum[r]-sum[l]);
    }

    ll res = 0;
    for (int k = 60; k >= 0; k--) {
        sort(all(btf), greater<ll>());
        vector<ll> tmp;
        if (btf[K-1] & bit(k)) {
            res |= bit(k);
            for (ll b : btf) {
                if (b & bit(k)) {
                    tmp.push_back(b & (bit(k)-1));
                }
            }
        } else {
            for (ll b : btf) {
                tmp.push_back(b & (bit(k)-1));
            }
        }
        btf = tmp;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 12440
#include<bits/stdc++.h>
using namespace std;
#define fastio() ios::sync_with_stdio(0),cin.tie(0);
int main()
{
	int N, T, c, t, res = 1e9;
	cin >> N >> T;
	while (N--)
	{
		cin >> c >> t;
		if (t <= T)res = min(res, c);
	}
	res == 1e9 ? cout << "TLE" : cout << res;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 int main() {
   vector<char>moji(110);
   vector<char>mojim(110);
   string s;
   cin >> s;
   int mcount=0;
   int ucount=0;
   int fcount=0;
   int flag=0;
   int dlag=0;
   int count=0;
  	for(int i=0;i<s.size();i++){
      moji.at(i) = s.at(i);
    }
  	for(int i=0;i<s.size();i++){
     if(moji.at(i)==moji.at(s.size()-1-i))fcount++;
   }
     
   for(int i=0;i<(s.size()-1)/2;i++){
     if(moji.at((s.size()-1)/2-1-i) ==  moji.at(i)) mcount++;
   }  
      if(mcount==(s.size()-1)/2) flag=1;
//	cout << mcount <<endl;

   for(int i=(s.size()-1)/2+1;i<s.size();i++){
     if(moji.at(s.size()-1-count) ==  moji.at(i)) {
       ucount++;
     }
     count++;
   }  
      if(ucount==(s.size()-1)/2) dlag=1;
   
//	cout << ucount <<endl;  
      
   if(fcount==s.size() && flag==1 && dlag==1) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
 }
//mcount>0 && ucount>0 && 


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

class Program
{
    static void Main()
    {
        var s = Enumerable.Range(1, 9).SelectMany(x => Enumerable.Range(1, 9).Select(y => x * y)).Distinct();
        var n = int.Parse(Console.ReadLine());
        Console.WriteLine(s.Contains(n) ? "Yes" : "No");
    }
}

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

// ループによる最大公約数
long long gcd(long long x, long long y) {
  long long r;
  if(x < y) swap(x, y);
  
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

// gcdを利用した最小公倍数
long long lcm(long long x, long long y) {
  return x / gcd(x, y) * y;
}

int main() {
  long long n, i;
  cin >> n;
  
  vector<long long> t(n);
  for(i = 0; i < n; i++){
    cin >> t.at(i);
  }
  
  long long a = t.at(0);
  for(i = 1; i < n; i++){
    a = lcm(a, t.at(i));
  }
  
  cout << a << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stack>
#include<cstdlib>

int main(){
	std::stack<int>s;
	std::string str;
	while(std::cin>>str){
		if(str=="+"){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(a+b);
		}
		else if(str=="-"){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(b-a);
		}
		else if(str=="*"){
			int a=s.top();
			s.pop();
			int b=s.top();
			s.pop();
			s.push(a*b);
		}
		else s.push(atoi(str.c_str()));
	}
	std::cout<<s.top()<<std::endl;
	return 0;
}

Measured memory_bytes: 1200
from collections import deque

N, Q = map(int, input().split())

G=[[] for i in range(N)]
A =[0]*N

for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

for i in range(Q):
    p, x = map(int, input().split())
    A[p-1] += x

queue = deque([0])
visited= [0]*N
while queue:
    a = queue.popleft()
    visited[0] = 1
    for i in G[a]:
        if visited[i] == 0:
            A[i] += A[a]
            visited[a] = 1
            queue.append(i)

print(*A)


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

using std::string;

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

    int pnt_t = 0, pnt_h = 0;
    string card_t, card_h;
    while (cards_num--) {
        std::cin >> card_t >> card_h;

        if (card_t > card_h) {
            pnt_t += 3;
        } else if (card_t < card_h) {
            pnt_h += 3;
        } else {
            pnt_t++;
            pnt_h++;
        }
    }

    std::cout << pnt_t << " " << pnt_h << std::endl;

    return 0;
}

Measured memory_bytes: 1212
s=input()
if s=='SUN':
    print(7)
elif s=='MON':
    print(6)
elif s=='TUE':
    print(5)
elif s=='WED':
    print(4)
elif s=='THU':
    print(3)
elif s=='FRI':
    print(2)
elif s=='SAT':
    print(1)

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

void solve() {
    string N;
    cin >> N;
    bool ok = false;
    for (int i = 0; i < 3; ++i) {
        ok = N[i] == '7';
        if (ok) break;
    }
    cout << (ok ? "Yes" : "No") << endl;
}

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


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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int n,q,a[500010],num[500010],ans[500010];
vector <pair <pii,int> > v[2000];

bool cmp(pair <pii,int> x,pair <pii,int> y)
{
	return x.fi.se<y.fi.se;	
} 

int main()
{
	cin>>n>>q;
	rep(i,n) scanf("%d",&a[i]);
	int x,y;
	rep(i,q)
	{
		scanf("%d%d",&x,&y);
		x--;
		y--;
		v[x/600].pb(mpr(mpr(x,y),i));
	}
	rep(i,(q-1)/600+1)
	{
		if(v[i].empty()) continue;
		sort(v[i].begin(),v[i].end(),cmp);
		memset(num,0,sizeof(num));
		int lb=v[i][0].fi.fi,ub=v[i][0].fi.se,cur=0;
		for(int j=lb;j<=ub;j++)
		{
			num[a[j]]++;
			if(num[a[j]]==1) cur++;
		}
		ans[v[i][0].se]=cur;
		for(int j=1;j<v[i].size();j++)
		{
			while(ub<v[i][j].fi.se)
			{
				ub++;
				num[a[ub]]++;
				if(num[a[ub]]==1) cur++;
			}
			while(lb<v[i][j].fi.fi)
			{
				num[a[lb]]--;
				if(num[a[lb]]==0) cur--;
				lb++;
			}
			while(lb>v[i][j].fi.fi)
			{
				lb--;
				num[a[lb]]++;
				if(num[a[lb]]==1) cur++;
			}
			ans[v[i][j].se]=cur;
		}
	}
	rep(i,q) printf("%d\n",ans[i]);
	return 0;
}

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

int main(void)
{
	int N,K;

	while(cin >> N >> K, N | K){
		int blood[100000] = {};
		bool f = true;

		for(int i = 0; i < K; i++)
			cin >> blood[i];

		int drain;
		for(int i = 0; i < N; i++){
			for(int j = 0; j < K; j++){
				cin >> drain;
				blood[j] -= drain;
				
				if(blood[j] < 0)
					f = false;
			}
		}

		if(f)
			cout << "Yes\n";
		else
			cout << "No\n";
	}

	return 0;
}

Measured memory_bytes: 1516
using System;

class AOJ
{
  static void Main(string[] args)
  {
    string s;

    while ((s = Console.ReadLine()) != null)
    {
      var z = Array.ConvertAll(s.Split(' '), int.Parse);

      double a = z[0], b = z[1], c = z[2], d = z[3], e = z[4], f = z[5];

      double x = (e * c - b * f) / (e * a - b * d);
      double y = (c * d - a * f) / (b * d - e * a);

      if (x == -0.0) x = 0;
      if (y == -0.0) y = 0;

      Console.WriteLine("{0:F3} {1:F3}", x, y);
    }
  }
}

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

int isCat(string& s, int i){
    if(s[i]!='m') return -1;
    i++;
    if(s[i]!='e'){
        i = isCat(s, i);
        if(i==-1 || s[i]!='e') return -1;
    }
    i++;
    if(s[i]!='w'){
        i = isCat(s,i);
        if(i==-1 || s[i]!='w') return -1;
    }
    i++;
    return i;
}

int main(){
    string s;
    cin >> s;
    s += "0";
    if(isCat(s, 0) == (int)s.length()-1){
        cout << "Cat" << endl;
    }else{
        cout << "Rabbit" << endl;
    }
    return 0;
}

Measured memory_bytes: 3196
#include <stdio.h>

int main(void) {
  long long int x = 0, k = 0, d = 0;

  scanf("%lld %lld %lld", &x, &k, &d);

  if (x < 0)x *= -1;

  if (d > x/k) {
      k = (k - x / d)%2;
      x %= d;
  }
  else {
      x -= k*d;
      k = 0;
  }
  if (k) {
      x -= d;
      x *= -1;
  }

  printf("%lld\n", x);

  return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define MAX 510000
#define Rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep(i, n) for(ll i = 1; i <= (ll)(n); i++)

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

//cout << fixed << setprecision(10);//
//最小公倍数//
ll gcd(ll x, ll y) {
	if (x == 0) return y;
	return gcd(y%x, x);
}
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

//べき//
ll squ(ll n, ll p, ll m){
	if(p==0) return 1;
	if(p%2==0){
		ll t=squ(n, p/2, m);
		return t*t%m;
	}
	return n*squ(n,p-1,m);
	
}


//逆元mod(mを法とするaの逆元)//
long long modinv(long long a, long long m) {
	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;
}

//Cmonp//
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

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

//nが大

ll com(ll n,ll m){
    if(n<m || n<=0 ||m<0){
		return 0;
	}
	if( m==0 || n==m){
		return 1;
	}
	
	ll k=1;
	for(ll i=1;i<=m;i++){
       k*=(n-i+1); 
	   k%=MOD;
	   k*=modinv(i,MOD);
	   k%=MOD;
	}

	return k;
}


////////////////////////////////////////////////////////////////////


int main() {
ll n;
ll ma,mb;
cin>>n;
cin>>ma>>mb;

ll med[n+1][3];
for(ll i=0;i<=n;i++){
for(int j=0;j<=2;j++){
	if(i==0){med[i][j]=0;
	continue;}
	cin>>med[i][j];
}
}

ll ans=1000000;
ll dp[401][401][n+1];

for(int k=0;k<=n;k++){
	
	ll p=med[k][0];
		ll q=med[k][1];
		ll val=med[k][2];
	
for(ll i=0;i<=400;i++){
for(ll j=0;j<=400;j++){

if(i==0 && j==0 ){dp[i][j][k]=0;
continue;}
if(k==0){dp[i][j][k]=1000000;
continue;}
if(i>=p && j>=q){
	dp[i][j][k]=min(dp[i-p][j-q][k-1]+val,dp[i][j][k-1]);
	continue;
}
dp[i][j][k]=dp[i][j][k-1];

}

}
}


for(ll i=1;i<=400;i++){
for(ll j=1;j<=400;j++){
if(i/ma==j/mb && i%ma==0 && j%mb==0){
	ans=min(ans,dp[i][j][n]);
	
}
}
}



if(ans==1000000){cout<<-1<<endl;}
else {cout<<ans<<endl;}
return 0;


}




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

int main() {
    int n,m;
    cin >> n >> m;
    int ans=0;
    int a[m];
    for(int i=0;i<m;i++){
        a[i]=0;
    }
    int k,l;
    for(int i=0;i<n;i++){
        cin >> k;
        for(int j=0;j<k;j++){
            cin >> l;
            a[l-1]++;
        }
    }
    for(int i=0;i<m;i++){
        if(a[i]==n) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int sx, sy, tx, ty, px, py;
    cin >> sx >> sy >> tx >> ty;
    px = sx;
    py = sy;
    REP(i,tx-sx)cout << 'R';
    REP(i,ty-sy)cout << 'U';
    REP(i,tx-sx)cout << 'L';
    REP(i,ty-sy+1)cout << 'D';
    REP(i,tx-sx+1)cout << 'R';
    REP(i,ty-sy+1)cout << 'U';
    cout << 'L';
    cout << 'U';
    REP(i,tx-sx+1)cout << 'L';
    REP(i,ty-sy+1)cout << 'D';
    cout << 'R' << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define A_MAX 1000000
 
using namespace std;
 
int scanint() { 
	char c = getchar_unlocked();
    int x = 0;
    for(; (c<48)||(c>57);c = getchar_unlocked());
    for(; (c>47)&&(c<58);c = getchar_unlocked())
        x = (x << 3) + (x << 1) + c - 48;
    return x;
} 
 
int min_factor[A_MAX + 1];
int q[A_MAX + 1];
int a[A_MAX + 1];
int primes[] = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
 
int main() {
 
    for (int i = 2; i <= A_MAX; ++i) {
        if (!min_factor[i]) {
            min_factor[i] = i;
        }
        int j = 0;
        for (int p = primes[0]; ; p = primes[++j]) {
            int n = i * p;
            if (n > A_MAX) {
                break;
            }
            min_factor[n] = p;
            if (p == min_factor[i]) {
                q[n] = q[i];
                break;
            } else {
                q[n] = i;
            }
        }
    }
 
    int N = scanint();
    for (int i = 0; i < N; ++i) {
        ++a[scanint()];
    }
 
    bool is_pairwise_coprime = true;
    for (int n = A_MAX; n > 1; --n) {
        int an = a[n];
        if (an) {
            if (an > 1) {
                if (an == N) {
                    printf("not coprime\n");
                    return 0;
                }
                is_pairwise_coprime = false;
            }
            a[min_factor[n]] += an;
            a[q[n]] += an;
        }
    }
    if (is_pairwise_coprime) {
        printf("pairwise coprime\n");
    } else {
        printf("setwise coprime\n");
    }

    return 0;
}

Measured memory_bytes: 15320