akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();
    let a: u32 = read();
    let b: u32 = read();

    let mut ans = 0;

    for v in 1..n+1 {
        let c_10000 = v / 10000;
        let c_1000  = (v - (10000 * c_10000)) / 1000;
        let c_100   = (v - (10000 * c_10000) - (1000 * c_1000)) / 100;
        let c_10    = (v - (10000 * c_10000) - (1000 * c_1000) - (100 * c_100)) / 10;
        let c_1     = (v - (10000 * c_10000) - (1000 * c_1000) - (100 * c_100) - (10 * c_10)) / 1;
        let c = c_10000 + c_1000 + c_100 + c_10 + c_1;

        if a <= c && c <= b {
            ans += v;
        }
    }

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


Measured memory_bytes: 4352
a = list(map(int, input().split()))
for i in range(a[0]):
    for j in range(a[1]):
        if i<a[3] :
            if j<a[2] :print(0,end="")
            else :print(1,end="")
        else :
            if j<a[2] :print(1,end="")
            else :print(0,end="")
    print("")


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int main2() {
  int N; scanf("%d", &N);
  char s[128];

  int c[128]; CLR(c, 0);
  REP(i, N) {
    scanf("%s", s);
    c[s[0]]++;
  }

  ll a[5] = { c['M'], c['A'], c['R'], c['C'], c['H'] };
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j+1; k < 5; k++) {
        ans += a[i] * a[j] * a[k];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;
int n,a,b,ans,p,v[10002],v1[10002],pw[200002];
char s[200002];
signed main(){
	scanf("%lld%lld%s",&n,&p,s+1);
	v[0]=1;
	if(p==2){
		for(re int i=1;i<=n;++i){
			if((s[i]-'0')&1)continue;
			ans+=i;
		}
		printf("%lld",ans);
	}
	else if(p==5){
		for(re int i=1;i<=n;++i){
			if((s[i]-'0')%5)continue;
			ans+=i;
		}
		printf("%lld",ans);
	}
	else{
		pw[0]=1;
	for(re int i=1;i<=n;++i)pw[i]=pw[i-1]*10%p;
	for(re int i=n;i;--i){
		a+=(s[i]-48)*pw[n-i];
		a%=p;
		ans+=v[a];
		++v[a];
	}
	printf("%lld",ans);	}
}



Measured memory_bytes: 2048
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

// 非常時
fn read_line() -> String{ let mut s = String::new(); std::io::stdin().read_line(&mut s).unwrap(); s.trim().to_string() }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
fn main(){
    input!(N:i32,a:[f64;N]);
    let mean = a.iter().sum::<f64>() as f64/N as f64;
    let mut ans = 0;
    let mut minv = 1000000000_f64;
    for i in 0..N{
        if (a[i as usize]-mean).abs() < minv{
            minv = (a[i as usize]-mean).abs();
            ans = i;
        }
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;

int len(int x)
{
	int ret = 1;
	while (x != 0){
		x /= 10;
		ret *= 10;
	}
	return (ret);
}

int main()
{
	int n;
	static int mini[1000000];
	vector<int> v;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++){
		scanf("%d", mini + i);
	}
	
	sort(mini, mini + n);
	
	for (int i = 0; i < min(n, 20); i++)
		for (int j = 0; j < min(n, 20); j++)
			if (i != j) v.push_back(mini[i] * len(mini[j]) + mini[j]);
	
	sort(v.begin(), v.end());
	printf("%d\n", v[2]);
	
	return (0);
}

Measured memory_bytes: 1080
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
bool card[2][201],w;
int n,x,t,h;
int main()
{
while(1){
	w=0;
	scanf("%d",&n);
	if(!n) return 0;
	fill(card[0],card[0]+201,0);
	fill(card[1],card[1]+201,0);
	t=n;
	h=n;
	for(int i=0;i<n;i++){
		scanf("%d",&x);
		card[0][x]=1;
	}
	for(int i=1;i<=2*n;i++){
		if(!card[0][i]) card[1][i]=1;
	}
	while(1){
		for(int i=1;i<=2*n;i++){
			if(card[w][i]){
				card[w][i]=0;
				if(!w) t--;
				else h--;
				w=!w;
				if(!t||!h) {printf("%d\n%d\n",h,t); goto re;}
			}
		}
		w=!w;
	}
	re: ;
}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> x, y, h;
	for(int i = 0; i < n; i++){
		int X, Y, H;
		cin >> X >> Y >> H;
		if(H >= 1){
			x.push_back(X);
			y.push_back(Y);
			h.push_back(H);
		}
	}
	if(x.size() == 1){
		cout << x[0] << " " << y[0] << " " << h[0] << endl;
		return 0;
	}
	for(int i = 0; i <= 100; i++){
		for(int j = 0; j <= 100; j++){
			bool check = true;
			long long H = h[0] + abs(x[0] - i) + abs(y[0] - j);
			for(int k = 1; k < x.size(); k++){
				if(h[k] >= 1){
					if(H != h[k] + abs(x[k] - i) + abs(y[k] - j)){
						check = false;
					}
				}
			}
			if(check){
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,int> P;

int main() {
    int A,B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int s[1234567];

int main() {
  int c = getchar();
  int n = 0;
  while (c <= 32) c = getchar();
  while (c > 32) {
    s[n++] = c - 'a';
    c = getchar();
  }
  int k;
  scanf("%d", &k);
  for (int i = 0; i < n; i++) {
    if (s[i] > 0 && 26 - s[i] <= k) {
      k -= 26 - s[i];
      s[i] = 0;
    }
  }
  s[n - 1] = (s[n - 1] + k) % 26;
  for (int i = 0; i < n; i++) putchar(s[i] + 'a');
  puts("");
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<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; }

lli n;

int main(void){
  cin >> n;
  vector<vector<lli>> c(n, vector<lli>(2));
  lli zn, zx, wn, wx;
  zn = wn = 1e18;
  zx = wx = -1e18;
  rep(i, n){
    lli x, y;
    cin >> x >> y;
    chmin(zn, x+y);
    chmax(zx, x+y);
    chmin(wn, x-y);
    chmax(wx, x-y);
  }
  lli ans = max(zx-zn, wx-wn);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14332
#!/usr/bin/env python3
import sys


def solve(X: int):
    y = 100
    ans = 0
    while y < X:
        y = (101 * y) // 100
        ans += 1
    print(ans)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9148
n = gets.chomp.to_i 
inter = gets.chomp.split(" ").map(&:to_i)
ans = Array.new(n+1,0)
table = {}
list = []
x = 1
inter.each do |d|
  list.push(d)
  if(table[d] == nil)
    table[d] = [x] 
  else
    table[d] = table[d].push(x)
  end
  x += 1
end
w = 0
list.uniq!
list.sort!{|a,b| b <=> a}
now = 99999999
len = list.size
len.times do |d|
  if table[list[d]][0] <= now
    now = table[list[d]][0]
  end
  w += table[list[d]].size
  mino = (d >= len - 1)? 0 : list[d+1]
  ans[now] += (list[d] - mino)*w
end
ans.delete_at(0)
puts ans

Measured memory_bytes: 33016
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        long N =sc.nextLong();
        long x=0;
        int i=1;
        while(x<=N){
            x=i*i;
            i++;
            
        }
        System.out.println((i-2)*(i-2));
        
    }
}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int N; cin >> N;
	vector <int> L(N);
	for (auto &i : L) cin >> i;
	int cnt = 0;	
	sort(L.begin(), L.end());
	for (int i = 0; i < N; ++i){
		for (int j = i; j < N; ++j){
			for (int k = j; k < N; ++k){
				if (L[i] + L[j] > L[k] && L[i] != L[j] && L[j] != L[k]) ++cnt;
			}
		}
	}
	cout << cnt << "\n";
	return 0;
}


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

int main(){
  int k, s, ans = 0;
  cin >> k >> s;
  
  for ( int i = 0; i <= k; i++ ){
    for ( int j = 0; j <= k; j++ ){
      if ( s - i - j >= 0 && s - i - j <= k){
        ans ++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <vector>
#include <bitset>
#include <set>
#include <unordered_set>
#include <cmath>
#include <complex>
#include <deque>
#include <iterator>
#include <numeric>
#include <map>
#include <unordered_map>
#include <queue>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <limits>
#include <iomanip>
#include <functional>
#include <cassert>
using namespace std;

using ll=long long;
template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
using vll = V<ll>;
using vvll = V<vll>;
#define rep(i, k, n) for (ll i=k; i<(ll)n; ++i)
#define REP(i, n) rep(i, 0, n)
#define ALL(v) v.begin(),v.end()
template < class T > inline bool chmax(T& a, T b) {if (a < b) { a=b; return true; } return false; }
template < class T > inline bool chmin(T& a, T b) {if (a > b) { a=b; return true; } return false; }
#define DEBUG_VLL(vec) REP(sz, vec.size()) std::cerr<<vec[sz]<<(sz==vec.size()-1?'\n':' ');

const long long MOD = 1000000007;
const long long HIGHINF = (long long)1e18;
const int INF = (int)1e9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c, d; cin >> a >> b >> c >> d;
    while (true) {
        c -= b;
        if (c <= 0) {
            cout << "Yes\n";
            return 0;
        }
        a -= d;
        if (a <= 0) {
            cout << "No\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3612
def gcd(a, b):
    if a == 0 or b == 0:
        return 0
    while b != 0:
        a, b = b, a%b
    return a

while True:
    try:
        a, b = map(int, input().split())
    except EOFError:
        break
    else:
        g = gcd(a,b)
        print(g, a*b//g)

Measured memory_bytes: 7604
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int n,m;
    cin>>n>>m;
    int num=n;
    int a[m+2]={0};
    while(n--)
    {
        int k;
        cin>>k;
        while(k--){
            int ind;
            cin>>ind;
            a[ind]++;
        }
    }
    int cnt=0;
    for(int i=1; i<=m; i++)
        if(a[i]==num)cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <climits>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

  int answer = INT_MAX;
  rep(i, N) {
    int a;
    cin >> a;
    int count = 0;
    while (a % 2 == 0) {
      count++;
      a /= 2;
    }
    answer = min(answer, count);
  }
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
class ABC065
{
    static void Main(string[] args)
    {
        int buttonCount = int.Parse(Console.ReadLine());
        int[] cache = new int[buttonCount];
        int currentNumber = 0;
        int tryCount = 0;
        for(int i=0; i<buttonCount; i++){
            cache[i] = int.Parse(Console.ReadLine());
        }
        while(currentNumber != 1){
            currentNumber = cache[currentNumber] - 1;
            tryCount++;
            if(tryCount > buttonCount){
                break;
            }
        }
        if(currentNumber == 1){
            Console.WriteLine(tryCount.ToString());
        }else{
            Console.WriteLine(-1);
        }
    }
}

Measured memory_bytes: 15328
#include <iostream>
#include <functional>
#include <queue>
using namespace std;

const int INF = 10000000;

typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef priority_queue<PP, vector<PP>, greater<PP> > Q;

int C, N, M, S, D;
int m[100][100];
int u[11][100];

bool input() {
  cin >> C >> N >> M >> S >> D;
  if (!C && !N && !M && !S && !D) {
    return false;
  }
  --S, --D;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      m[i][j] = INF;
    }
    m[i][i] = 0;
  }
  for (int i = 0; i < M; ++i) {
    int a, b, f;
    cin >> a >> b >> f;
    --a, --b;
    m[a][b] = f;
    m[b][a] = f;
  }
  return true;
}

void solve() {
  for (int k = 0; k <= C; ++k) {
    for (int i = 0; i < N; ++i) {
      u[k][i] = INF;
    }
  }
  Q q;
  q.push(PP(0, P(0, S)));
  int ans = INF;
  while (!q.empty()) {
    PP pp = q.top();
    q.pop();
    int f = pp.first;
    P p = pp.second;
    int k = p.first;
    int l = p.second;
    if (l == D) {
      ans = f;
      break;
    }
    if (u[k][l] != INF) {
      continue;
    }
    u[k][l] = f;
    for (int i = 0; i < N; ++i) {
      if (l == i || m[l][i] == INF) {
        continue;
      }
      q.push(PP(f + m[l][i], P(k, i)));
      if (k < C) {
        q.push(PP(f + m[l][i]/2, P(k + 1, i)));
      }
    }
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3144
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vll(v) sort((v).begin(), (v).end(), greater<long long>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

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;}
const int IINF=(1<<30);
const ll LLINF = 1LL<<60;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  ll n, m; cin >> n >> m;
  if(n < m/2){
    cout << n + (m - n*2)/4 << endl;
  }else{
    cout << m/2 << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
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;}
using namespace std;
int main(){
  int n,r;
  cin>>n>>r;
  if(n>=10)cout<<r;
  else cout<<r+100*(10-n);
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

		// argumentの取得
		Scanner s = new Scanner(System.in);

		int N = s.nextInt();
        int K = s.nextInt();
      
        // 回答
        int answer = K;
      
		for (int i=1; i < N; i++){
          answer *= (K - 1);
        }
      
        System.out.println(answer);
	
	} 
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> t, ll score, ll &highest, int &nday, int &ncontest){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        nday=day;
        ncontest=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M2=0;
vector<pair<int,int>> m2(D);
vector<int> a(26);
rep(i, 26){
    a[i]=0;
}
int M=0;
rep(i, D){
}
vector<int> t(D);

int m=0;
ll score=0;
rep(i, D){
    M=0;
    rep(j, 26){
        if(s[i].at(j)+c[j]*(i+1-a[j])>M){
            M2=M;
            M=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=m;
            m=j;
        }else if(s[i].at(j)+c[j]*(i+1-a[j])>M2){
            M2=s[i].at(j)+c[j]*(i+1-a[j]);
            m2[i].second=j;
        }
    }
    m2[i].first=M-M2;
    score+=M;
    a[m]=i+1;
    t[i]=m;
}
sort(m2.begin(), m2.end());
ll highest;
highest=score;
int nday=-1;
int ncontest=-1;
rep(i, D){
    calculate(c, s, m2[i].second, i, t, score, highest, nday, ncontest);
}
rep(i, D){
    if(nday==-1){
    cout<<t[i]+1<<endl;
    }else{
        if(i==nday){
            cout<<ncontest+1<<endl;
        }else{
            cout<<t[i]+1<<endl;
        }
    }
}
}

Measured memory_bytes: 3748
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main() {
  std::ios::sync_with_stdio(false);

  int N, K;
  cin >> N >> K;

  set<int> dislike;
  for (int i = 0; i < K; ++i) {
    int tmp;
    cin >> tmp;
    dislike.insert(tmp);
  }

  vector<int> numbers;
  for (int i = 0; i < 10; ++i) {
    if (dislike.find(i) != dislike.end()) continue;
    numbers.push_back(i);
  }

  string Ns = to_string(N);
  string ans = "";
  for (int k = 0; k < Ns.size(); ++k) {
    for (int i = 0; i < numbers.size(); ++i) {
      if (Ns[k] - '0' == numbers[i]) {
        ans += to_string(numbers[i]);
        goto CONT;
      }
      if (Ns[k] - '0' < numbers[i]) {
        ans += to_string(numbers[i]);
        ++k;
        while (k < Ns.size()) {
          ans += to_string(numbers[0]);
          ++k;
        }
        goto DONE;
      }
    }
    ans += to_string(numbers[0]);
    CONT:
      (void)0;
  }
  if (ans == Ns) goto DONE;

BACKTRACK:
  for (int k = Ns.size() - 1; k >= 0; --k) {
    for (int i = 0; i < numbers.size(); ++i) {
      if (Ns[k] - '0' < numbers[i]) {
        ans[k] = numbers[i] + '0';
        goto DONE;
      }
    }
    ans[k] = numbers[0] + '0';
  }
  if (ans < Ns) {
    if (numbers[0] > 0) { 
      ans = to_string(numbers[0]) + ans;
    } else {
      ans = to_string(numbers[1]) + ans;
    }
  }

DONE:
  cout << ans << endl;
}


Measured memory_bytes: 256
function Main(input){
	input = input.split(" ").map(a=>~~a);
  return input[0] * input[1] - input[0] - input[1] + 1;
}

// If you are interested in the algorithms I used, 
// there is no need to read down from this line.

((b,c,d)=>"undefined"!=typeof require?console.log(Main(require("fs").readFileSync("/dev/stdin","utf8"))):[b=b.split("\n").slice(1,-1).join("\n"),c=function(){try{return Main(b)}catch(f){return f.stack||f.message}}(),d=typeof c,"string"==d||(c=JSON.stringify(c)),$("<form>").append([[10,b],0,[1,d],0,[10,c]].map(f=>$(f?"<textarea>":"<br>",f&&{rows:f[0],cols:40,text:f[1]}))).appendTo("body")])(`
5 7
`);

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

using namespace std;
using ll = long long;
using v1 = vector<int>;
using vl = vector<long long>;
using v2 = vector<vector<int>>;
using v3 = vector<vector<char>>;

vl a(1001, 0);
ll MAX = 1e9 + 7;

void cal(int x){
	for(int i = 2; i*i <= x; i++){
		ll c = 0;
		while(x%i == 0){
			x /= i;
			c++;
		}
		a[i] += c;
	}
	if(x != 1) a[x] += 1;
}

int main(){
	int n;
	cin >> n;
	for(int i = 2; i <=n; i++){
		cal(i);
	}
	ll ans = 1;
	for(int i = 2; i <= n; i++){
		if(a[i] != 0){
			ans *= (a[i]+1);
			if(ans >= MAX) ans%=MAX;
		}
	}
	cout << ans << endl;
}


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

using namespace std;

#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define mp make_pair
#define endl '\n'
#define f first
#define s second

#ifdef SEREZHKA
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;
    
    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;
    
    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(4e2) + 17;

int n;
int a[MAXN];

bool read() {
    if (!(cin >> n))
        return false;

    forn (i, n)
        cin >> a[i];

    return true;
}

int f(int x) {
    int res = 0;

    forn (i, n)
        res += (a[i] - x) * (a[i] - x);

    return res;
}

void solve() {
    int ans = INF;

    for (int x = -100; x <= 100; ++x)
        ans = min(ans, f(x));

    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    while (read())
        solve();
    
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#include<string>
#include<queue>
#include<iomanip>
#include<bitset>
#include<math.h>
#include<stack>
#include<set>
using namespace std;
#define int long long
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie();
	cout.tie();
	int n, x, y;
	cin >> n >> x >> y;
	x--; y--;
	queue<int> q;
	vector<bool> used(n, 0);
	vector<int> t1(n);
	vector<int> t2(n);
	used[x] = 1;
	q.push(x);
	while (!q.empty()) {
		int a = q.front();
		q.pop();
		vector<int> g;
		g.push_back(a - 1);
		g.push_back(a + 1);
		if (a == x) {
			g.push_back(y);
		}
		if (a == y) {
			g.push_back(x);
		}
		for (int i = 0; i < g.size(); i++) {
			int to = g[i];
			if (to >= 0 && to < n) {
				if (!used[to]) {
					used[to] = 1;
					q.push(to);
					t1[to] = t1[a] + 1;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		used[i] = 0;
	}
	used[y] = 1;
	q.push(y);
	while (!q.empty()) {
		int a = q.front();
		q.pop();
		vector<int> g;
		g.push_back(a - 1);
		g.push_back(a + 1);
		if (a == x) {
			g.push_back(y);
		}
		if (a == y) {
			g.push_back(x);
		}
		for (int i = 0; i < g.size(); i++) {
			int to = g[i];
			if (to >= 0 && to < n) {
				if (!used[to]) {
					used[to] = 1;
					q.push(to);
					t2[to] = t2[a] + 1;
				}
			}
		}
	}
	vector<int> r(n);
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			r[min(j - i, min(t1[i] + t1[j], t2[i] + t2[j]))]++;
		}
	}
	for (int i = 1; i < n; i++) {
		cout << r[i] << endl;
	}
}
	

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

#define LL long long

const int maxN = 505;

int n;
LL f[maxN + 1][maxN + 1], A[maxN + 1][maxN + 1], s1[maxN + 1][maxN + 1], s2[maxN + 1][maxN + 1];

inline LL read()
{
	LL num = 0, f = 1;
	char ch = getchar();
	while( !isdigit( ch ) ) { if(ch == '-') f = -1; ch = getchar(); }
	while( isdigit( ch ) ) num = (num << 3) + (num << 1) + (ch ^ 48), ch = getchar();
	return num * f;
}

inline LL query(int xu, int yu, int xd, int yd, LL sum[maxN + 1][maxN + 1])
{
	return sum[xd][yd] - sum[xu - 1][yd] - sum[xd][yu - 1] + sum[xu - 1][yu - 1];
}

int main()
{

	n = read();
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= n; j++)
		{
			if(i != j) A[i][j] = read();
			s1[i][j] = s1[i - 1][j] + s1[i][j - 1] - s1[i - 1][j - 1];
			s2[i][j] = s2[i - 1][j] + s2[i][j - 1] - s2[i - 1][j - 1];
			if(i < j) s1[i][j] += A[i][j];
			if(i > j) s2[i][j] += A[i][j];
		}
	
	for(int i = 1; i <= n - 1; i++)
	{
		f[i][0] = query(1, 1, i + 1, i, s2);
		for(int j = 0; j < i; j++)
		{
			f[i][i] = max(f[i][i], f[i - 1][j] + query(i + 1, j + 1, i + 1, i, s2) + query(1, i + 1, i, i + 1, s1));
			for(int k = 0; k < j; k++)
				f[i][j] = max(f[i][j], f[j - 1][k] + query(j + 1, k + 1, i + 1, i, s2) + query(1, j + 1, j, i + 1, s1));
		}
	}

	LL ans = 0;
	for(int i = 0; i <= n - 1; i++) ans = max(ans, f[n - 1][i]);
	printf("%lld", s1[n][n] + s2[n][n] - ans);

	return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;

typedef long long ll;
// const int INF = 1e8;
const ll INF = 1LL << 60;
typedef pair<int, int> P;

ll N;

int main() {
    cin >> N;
    if (N % 2 == 1) N++;
    cout << N / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int l;cin >> l;
  double ll = l;
  ll *= l;
  ll *= l;
  cout << ll/27 << endl; 
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  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;

int main() {
    int n; cin >> n;
    map<int, int> mp;
    rep(i,n) {
        int a; cin >> a;
        mp[a] += i+1;
    }

    for (auto x : mp) {
        cout << x.second << " ";
    }
    cout << endl;
    return 0;
}

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

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

int leftMove(set<int> A, int X) {
  int cost = 0;
  for(int i = X; i > 0; i--) {
    if(A.find(i) != A.end()) cost++;
  }
  return cost;
}

int rightMove(set<int> A, int N, int X) {
  int cost = 0;
  for(int i = X; i < N; i++) {
    if(A.find(i) != A.end()) cost++;
  }
  return cost;
}

int MIN(int a, int b) {
  return a > b ? b : a;
}

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

  int N, M, X;
  cin >> N >> M >> X;
  set<int> A;
  rep(i, M) {
    int a;
    cin >> a;
    A.insert(a);
  }

  int min = MIN(leftMove(A, X), rightMove(A, N, X));
  cout << min << endl;

  return 0;
}


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

int ans=0;

void merge(int A[],int left,int mid,int right){
  int n1=mid-left;
  int n2=right-mid;
  int L[n1+1],R[n2+1];
  for(int i=0;i<n1;i++){
    L[i]=A[left+i];
  }
  for(int i=0;i<n2;i++){
    R[i]=A[mid+i];
  }
  L[n1]=R[n2]=1000000000;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    if(L[i]<=R[j]){
      A[k]=L[i];
      i++;
    }else{
      A[k]=R[j];
      j++;
    }
    ans++;
  }
}

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

int main(){
  int n;
  int A[500010];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  mergeSort(A,0,n);
  for(int i=0;i<n;i++){
    if(i<n-1) cout<<A[i]<<" ";
    else cout<<A[i]<<endl;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 6992
from sys import stdin


def main():
    N, *S = [i.strip() for i in stdin.readlines()]
    N = int(N)
    judge = ["AC", "WA", "TLE", "RE"]
    mul = " x "
    C = [0] * len(judge)
    for Si in S:
        C[judge.index(Si)] += 1
    print("\n".join([judge[i] + mul + str(C[i]) for i in range(len(judge))]))
    return


main()


Measured memory_bytes: 23200
fun main(args: Array<String>) {
    val n = readInputLine().toInt()
    
    val hList = readInputLine().split(" ").map { it.toInt() }.toList()
    
    var max = hList[0]
    
    var ans = 1
    
    for (h in hList.drop(1)) {
        if (h >= max) {
            ans++
            max = h
        }
    }
    
    println(ans)
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37752
//#include<bits\stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 1000000000
#define ldb long double
#define pb push_back
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define gc(a) scanf("%s",a+1)
#define rep(p,n,i) for(RE ll i=p;i<=n;++i)
#define go(x) for(ll i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE ll i=n;i>=p;--i)
#define pii pair<ll,ll> 
#define mk make_pair
#define RE register
#define P 1000000007
#define S second
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define ull unsigned long long
#define mod 998244353
using namespace std;
char buf[1<<15],*fs,*ft;
inline char getc()
{
    return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline ll read()
{
    register ll x=0,f=1;register char ch=getc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getc();}
    return x*f;
}
const ll MAXN=200005;
ll n;
ll a[MAXN];
ll f[MAXN][3];//f[i][j]前表示前i个数用掉j个空隙的最大值.
signed main()
{
	//freopen("1.in","r",stdin);
	get(n);
	rep(1,n,i)get(a[i]);
	memset(f,0xcf,sizeof(f));
	f[0][0]=0;f[1][0]=a[1];
	rep(2,n,i)
	{
		f[i][0]=f[i-2][0]+a[i];
		if(i>=3)f[i][1]=max(f[i-3][0]+a[i],f[i-2][1]+a[i]);
		if(i>=4)f[i][2]=max(f[i-4][0]+a[i],max(f[i-3][1]+a[i],f[i-2][2]+a[i]));
	}
	if(n&1)putl(max(max(f[n][1],f[n][2]),max(f[n-2][0],max(f[n-1][0],f[n-1][1]))));
	else putl(max(f[n][1],max(f[n][0],f[n-1][0])));
	return 0;
}


Measured memory_bytes: 10044
#include<bits/stdc++.h>
#define N 2005
#define P 1000000007
#define debug(x) cout<<#x<<":"<<x<<endl;
using namespace std;
int n,k;
long long C[N][N];
int main(){
	scanf("%d%d",&n,&k);
	C[0][0]=1ll;
	for(int i=0;i<=2000;i++){
		C[i][0]=1ll;
		for(int j=1;j<=i;j++)C[i][j]=C[i-1][j]+C[i-1][j-1],C[i][j]%=P;
	}
	for(int i=1;i<=k;i++){printf("%lld\n",C[k-1][i-1]*C[n-k+1][i]%P);}
	return 0;
}


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

#define ll long long
#define mp make_pair

using namespace std;

int main()
{
  string s;
  cin >> s;
  int r = 0;
  int tmp = 0;

  for(auto& x : s)
  {
    if(x == 'R'){
        tmp++;
        r = max(tmp, r);
    }
    else
    {
        tmp = 0;
    }
  }
  cout << r << '\n';
}


Measured memory_bytes: 3624
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <limits.h>
#include <cmath>
#include <queue>
#include <map>
#include <iomanip>
#include <random>
#include <fstream>
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.14159265358979323846
#define MOD 1000000007
using namespace std;
using ll = long long;

const int MAX = 1000000;

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;
  }
}

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

ll gcd(ll a, ll b)
{
  ll r;
  while ((r = a % b))
  {
    a = b;
    b = r;
  }
  return b;
}

template <class T> struct cord{
  T x,y;
};

template <class T> double dist(cord<T> a, cord<T> b){
  T dx=a.x-b.x;
  T dy=a.y-b.y;
  return sqrt(dx*dx+dy*dy);
}

int main()
{

  //cout << fixed << setprecision(10);
  
  int a,b,c,d; cin >> a >> b >> c >> d;
  if (a+b>c+d){cout << "Left";}
  else if (a+b==c+d){cout << "Balanced";}
  else {cout << "Right";}

  return 0;
}


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


int main() {

  string n ; cin >> n ; 
  int m = stoi(n);
  
  int sum = 0 ;
  for ( char c : n )
    sum += (int)c - (int)'0';
  
  m % sum == 0 ? cout << "Yes" : cout << "No"  ;



}

Measured memory_bytes: 256
n=int(input())
ans=[[None]*101 for _ in range(101)] 
a=[[0]*3 for _ in range(n)] 

for i in range(n):
    a[i][0],a[i][1],a[i][2]=map(int,input().split())
a=sorted(a,key=lambda x: x[2],reverse=True)

for i in range(n):
    for cx in range(101):
        for cy in range(101):
            height=a[i][2]+abs(a[i][0]-cx)+abs(a[i][1]-cy)
            if a[i][2]>0:
                if ans[cx][cy]==None or ans[cx][cy]==height:
                    ans[cx][cy]=height
                else:
                    ans[cx][cy]=-1
            else:
                if ans[cx][cy]!=None:
                    if ans[cx][cy]>abs(a[i][0]-cx)+abs(a[i][1]-cy):
                        ans[cx][cy]=-1
                else:
                    ans[a[i][0]][a[i][1]]=-1
        

for cx in range(101):
    for cy in range(101):
        if ans[cx][cy]!=-1:
            if ans[cx][cy]==None: 
                ans[cx][cy]=1
            print(cx,cy,ans[cx][cy])

Measured memory_bytes: 3444
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll N, Q;
  cin >> N >> Q;
  vector<vector<ll>> G(N);
  ll a, b;
  for (int i = 0; i < N - 1; i++) {
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  ll p, x;
  vector<ll> cnt_action(N, 0);
  for (int i = 0; i < Q; i++) {
    cin >> p >> x;
    p--;
    cnt_action[p] += x;
  }
  deque<pair<ll, ll>> q;
  ll cur_node, cur_add;
  vector<ll> score(N, 0);
  q.push_back({0, 0});
  vector<bool> memo(N, false);
  while (!q.empty()) {
    cur_node = q.front().first;
    cur_add = q.front().second;
    q.pop_front();
    if (memo[cur_node]) continue;
    cur_add += cnt_action[cur_node];
    score[cur_node] += cur_add;
    for (auto node : G[cur_node]) {
      q.push_back({node, cur_add});
    }
    memo[cur_node] = true;
  }
  for (int i = 0; i < N; i++) {
    cout << score[i] << " ";
  }

  return 0;
}

Measured memory_bytes: 21232
#include<iostream>

int main(){

    while(true){
        size_t n, x;
        std::cin >> n >> x;

        if(n == 0 && x == 0) break;

        size_t cnt = 0;

        for(size_t i = 1; i <= n - 2; i++){
            for(size_t j = i + 1; j <= n - 1; j++){
                for(size_t k = j + 1; k <= n; k++){
                    if(i + j + k == x) cnt++;
                }
            }
        }

        std::cout << cnt << std::endl;
    }

    return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define ll long long
#define ldb long double 
#define db double
#define str string
 
#define fr first
#define se second
#define lb lower_bound 
#define ub upper_bound 
#define pb push_back
#define mpr make_pair
 
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pdb pair<db,db>
#define pldb pair<ldb,ldb>
 
#define vi vector<int>
#define vll vector<ll>
#define vdb vector<db>
#define vldb vector<ldb>
#define vpi vector< pi >
#define vpll vector< pll >
 
#define mi map<int,int>
#define mll map<ll,ll>
#define mdb map<db,db>
#define mldb map<ldb,ldb>
 
 
#define forr(a,b) for (int i = (a); i < (b); ++i)
#define rrof(a,b) for (int i = (b)-1; i >= (a); --i)
 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
 
const int md = 1e9+7;
const int MX = 2e5+5;
const ll INF = 1e18; 
const ldb PI = 4*atan((ldb)1);
 
ll power(ll a,ll n)
{
 ll res=1;
 while(n)
{
 if(n%2)
  res*=a;
  a*=a;
  n/=2;
}
return res;
}
 
ll abst(ll a)
{
 return ((a<0)?(-1*a):(a));
}
 
int main()
{
   str s;
   cin>>s;
   int n=s.size();
   for(int i=0;i<n;i++)
    cout<<"x";
    return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}


fn main () {
    input! {
        s : chars,
        t : chars,
    }
    let mut x = s;
    let mut y = t;
    x.sort();
    y.sort();
    y.reverse();
    if x < y {
        println!("Yes");
    }
    else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <queue>
#include <stack>
#include <utility>
#include <cmath>
using namespace std;

int main(){
  int h, w, d; cin >> h >> w >> d;
  pair<int, int>  dis[d][h*w/d+1];
  int diss[d][h*w/d+1];

  int a;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> a;

      dis[a%d][(a-a%d)/d] = make_pair(j, i);//x座標、y座標でペア
    }
  }

  int q; cin >> q;
  int l, r;

  for(int i=0; i<d; i++){
    diss[i][0] = 0;
    for(int j=1; j<h*w/d+1; j++){
      diss[i][j] = diss[i][j-1] + abs(dis[i][j].first-dis[i][j-1].first)
              + abs(dis[i][j].second-dis[i][j-1].second);
    }
  }


  for(int i=0; i<q; i++){
    cin >> l >> r;
    cout << diss[l%d][(r-r%d)/d] - diss[l%d][(l-l%d)/d] << endl;
  }

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
// e.g. sort(all(a), [](int a1, int a2) { return a1 < a2; });
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,m;
  cin >> n >> m;
  // 偶数x偶数のパターン数
  int guusuu = ((n>1) ? (n*(n-1))/2 : 0);
  // 奇数x奇数のパターン数
  int kisuu = ((m>1) ? (m*(m-1))/2 : 0);
  cout << guusuu + kisuu << endl;

  return 0;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).expect("");
    let mut iter = s.trim().split_whitespace();
    
    let n: usize = iter.next().unwrap().parse().unwrap();
    let m: usize = iter.next().unwrap().parse().unwrap();

    let mut v = input(n, m);

    for i in 0..n {
        v[i][m] = v[i].iter().sum();
    }

    for j in 0..m+1 {
        v[n][j] = v.iter().map(|x| x[j]).sum();
    }

    for i in 0..n+1 {
        for j in 0..m+1 {
            if j < m {
                print!("{} ", v[i][j]);
            } else {
                println!("{}", v[i][j]);
            }
        }
    }
}

fn input(n: usize, m: usize) -> Vec<Vec<i32>> {
    let mut v: Vec<Vec<i32>> = vec![];
    
    for i in 0..n {
        let mut s = String::new();
        io::stdin().read_line(&mut s).expect("");
        let mut iter = s.trim().split_whitespace();

        let mut x: Vec<i32> = vec![];
        for _ in 0..m {
            x.push(iter.next().unwrap().parse().unwrap());
        }
        x.push(0);

        v.push(x);
    }
    v.push(vec![0; m+1]);

    v
}



Measured memory_bytes: 5052
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#ifdef LOCAL
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#else
#define eprintf(...) 42
#endif
#define y0 y12345
#define y1 y54321
typedef unsigned long ul;
typedef long long ll;
//typedef pair<int, int> mpair;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b;return 1;}return 0;}
using namespace std;
int n,m;
ul w[101], v[101];
ul dt[101][100001];
ul dp(int p, int nw){
	ul res = 0;
	if(dt[p][nw] != -1){return dt[p][nw];}
	if(p==n){
		res = 0;
	}else if(w[p] + nw > m){
		res = dp(p+1, nw);
	} else{
		res = max(dp(p+1, nw),v[p] + dp(p+1, nw+w[p]));
	}
	return dt[p][nw] = res;
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
   	cin>>n>>m;
	memset(dt, -1, sizeof(dt));
	rep(i, n){
		cin>>w[i]>>v[i];
	}
	cout << dp(0, 0) << endl;
	return 0;
}


Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007;
using ll = long long;
using namespace std;

int main(){
	int n; cin >> n;
	vector<int> a(n);
	for( auto &k : a ) cin >> k;
	int cnt = 0;
	for( int i = 1; i < n-1; ++i ){
		if( ( a[i-1] < a[i] && a[i] < a[i+1] ) || ( a[i-1] > a[i] && a[i] > a[i+1] ) ) ++cnt;
	}
	cout << cnt<< endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  vector<vector<int>> grid(h,vector<int>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(i<b&&j<a) grid[i][j]=0;
      if(i<b&&j>=a) grid[i][j]=1;
      if(i>=b&&j<a) grid[i][j]=1;
      if(i>=b&&j>=a) grid[i][j]=0;
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<grid[i][j];
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 5120
/*
 * 2304.cc: Reverse Roads
 */

#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 */

const int MAX_N = 300;
const int MAX_M = 1000;

const int INF = 1 << 30;

/* typedef */

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

pii es[MAX_M];
vpii nbrs[MAX_N];
int minfs[MAX_N], flows[MAX_N][MAX_N], prvs[MAX_N];

/* subroutines */

int maxflow(int st, int gl) {
  memset(flows, 0, sizeof(flows));
  int max_flow = 0;

  for (;;) {
    //printf("max_flow = %d, limit = %d\n", max_flow, limit);

    memset(prvs, -1, sizeof(prvs));
    prvs[st] = st;
    minfs[st] = INF;

    queue<int> q;
    q.push(st);

    while (! q.empty()) {
      int ui = q.front(); q.pop();

      if (ui == gl) break;
      vpii& nbru = nbrs[ui];
      for (vpii::iterator vit = nbru.begin(); vit != nbru.end(); vit++) {
        int vi = vit->first;
        int vc = vit->second - flows[ui][vi];
        if (prvs[vi] < 0 && vc > 0) {
          prvs[vi] = ui;
          minfs[vi] = (minfs[ui] < vc) ? minfs[ui] : vc;
          q.push(vi);
        }
      }
    }

    if (prvs[gl] < 0) break;

    int min_flow = minfs[gl];
    for (int j = gl; j != st;) {
      int i = prvs[j];
      flows[i][j] += min_flow;
      flows[j][i] -= min_flow;
      j = i;
    }

    max_flow += min_flow;
  }

  return max_flow;
}

/* main */

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

  for (int i = 0; i < m; i++) {
    int xi, yi;
    cin >> xi >> yi;
    xi--, yi--;
    nbrs[xi].push_back(pii(yi, 1));
    nbrs[yi].push_back(pii(xi, 1));

    es[i] = pii(xi, yi);
  }

  int st, gl;
  cin >> st >> gl;
  st--, gl--;

  int mf = maxflow(st, gl);

  vi vs;
  for (int i = 0; i < m; i++)
    if (flows[es[i].first][es[i].second] < 0) vs.push_back(i);

  printf("%d\n", mf);
  printf("%lu\n", vs.size());
  for (int i = 0; i < vs.size(); i++) printf("%d\n", vs[i] + 1);
  return 0;
}

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

int main(){
    int n, i, buf, c = 0;
    cin >> n;
    int a[n+1];
    memset(a, 0, sizeof(int)*(n+1));
    for(i=0; i<n; i++){
        cin >> buf;
        if(buf > n){
            c++;
        }else{
            a[buf]++;
        }
    }
    for(i=1; i<=n; i++){
        if(a[i] < i){
            c += a[i];
        }else if(a[i] > i){
            c += a[i] - i;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 640