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("filed 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 h:usize = read();
    let w:usize = read();
    let grid:Vec<Vec<char>> = (0..h).map(|_| read::<String>().chars().collect::<Vec<char>>()).collect();
    let mut ans = vec![vec![true; w]; h];
    for i in 0..w {
        let mut cnt = 0;
        for j in 0..h {
            if grid[j][i] == '.' {
                cnt += 1;
            }
        }
        if cnt == h {
            for j in 0..h {
                ans[j][i] = false;
            }
        }
    }
    for v in 0..h {
        if !grid[v].contains(&'#') {
            ans[v] = vec![false; w];
        }
    }
    for i in 0..h {
        for j in 0..w {
            if ans[i][j] {
                print!("{}", grid[i][j]);
            }
        }
        println!("");
    }
}


Measured memory_bytes: 2196
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const int INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n],b[n],c[n];
    rep(i,n) cin >> a[i];
    rep(i,n) cin >> b[i];
    rep(i,n) cin >> c[i];
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    ll ans = 0;
    rep(i,n){
        ans += (lower_bound(a,a+n,b[i])-a)*(n-(upper_bound(c,c+n,b[i])-c));
    }
    PRINT(ans);
}


Measured memory_bytes: 1408
import math
A, B, C, D = map(int, input().split())

# for文は間に合わないので、包除原理を使え！

# CでもDでも割り切れない =
# 全体(a) - Cで割り切れる(b) + Dで割り切れる(c)
# + CでもDでも割り切れる(d)

# Cで割り切れる個数 =
# B以下の数でCで割り切れる個数 - (A−1)以下の数でCで割り切れる個数

lcm = C*D // math.gcd(C, D)
a = B - A + 1
b = B // C - (A-1) // C
c = B // D - (A-1) // D
d = B // lcm - (A-1) // lcm
 
print(a-b-c+d)

Measured memory_bytes: 9120
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//const ll MOD = 998244353;

ll dp[2][50];

// 整数を2進法表記した文字列（0埋めしてk桁にする）を返す
string tobin(ll n, ll k) {
	string out = "";
	ll len = 1;
	ll div = 1;
	while (1) {
		if (n / div < 2) {
			break;
		}
		len++;
		div *= 2;
	}
	for (ll i = 0; i < len; i++) {
		if (n / div >= 1) {
			out = out + "1";
			n -= div;
		}
		else {
			out = out + "0";
		}
		div /= 2;
	}
	if (out.length() <= k) {
		out = string(k - out.length(), '0') + out;
	}

	return out;
}


int main() {
	ll strlen = 50;
	ll N, K;
	ll i, j;
	cin >> N >> K;
	string sK = tobin(K, strlen);
	vector<string> A;
	for (i = 0; i < N; i++) {
		ll a;
		cin >> a;
		A.push_back(tobin(a, strlen));
	}

	dp[0][0] = 0;
	dp[1][0] = -1;

	for (i = 1; i <= strlen; i++) {
		ll n_0 = 0;
		for (j = 0; j < N; j++) {
			if (A[j][i - 1] == '0') {
				n_0++;
			}
		}
		ll n_1 = N - n_0;

		if (sK[i - 1] == '0') {
			dp[0][i] = dp[0][i - 1] + (ll)pow(2, strlen - i) * n_1;
			if (dp[1][i - 1] == -1) {
				dp[1][i] = -1;
			}
			else {
				dp[1][i] = dp[1][i - 1] + (ll)pow(2, strlen - i) * max(n_0, n_1);
			}
		}
		else {
			dp[0][i] = dp[0][i - 1] + (ll)pow(2, strlen - i) * n_0;
			if (dp[1][i - 1] == -1) {
				dp[1][i] = (ll)pow(2, strlen - i) * n_1;
			}
			else {
				dp[1][i] = max(dp[0][i - 1] + (ll)pow(2, strlen - i) * n_1, dp[1][i - 1] + (ll)pow(2, strlen - i) * max(n_0, n_1));
			}
		}

	}
	cout << max(dp[0][strlen], dp[1][strlen]) << endl;

	return 0;
}


Measured memory_bytes: 13488
//***Little by little one travels far***
 
#include<bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define endl "\n"
 
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef long double ld;
 
template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

int main()
{
    ll r;
    cin>>r;
    cout<<r*r;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;

int main() {
  ll N;
  cin>>N;
  ll A[N];
  rep(i,N){cin>>A[i];A[i]=-1ll*A[i];}
  multiset<ll>ma;
  ma.insert(2ll);
  ma.insert(-100000000000ll);
  ll ans=0ll;
  rep(i,N){
    auto t=ma.upper_bound(A[i]);
    if(*t==2){ma.insert(A[i]);ans++;continue;}
    else{
      ma.erase(t);
      ma.insert(A[i]);
    }
  }
  cout<<ans;
}


Measured memory_bytes: 8936
#include<stdio.h>
int main(){
    int a;
    scanf("%d",&a);
    if(0<a && a<10){
        printf("%d",a);
    }
    else if(9<a && a<100 ){
        printf("9");
    }
    else if(99<a && a<1000){
        printf("%d", (a-90));
    }
    else if(999<a && a<10000){
        printf("909");
    }
    else if(9999<a && a<100000){
        printf("%d",(a-9090));
    }
    else if(a==100000){
        printf("90909");
    }
    return 0;
}

Measured memory_bytes: 128
N=int(input())
alist=list(map(int,input().split()))

min_answer=float("inf")
for i in range(min(alist),max(alist)+1):
  answer=0
  for a in alist:
    answer+=(a-i)**2
    
  min_answer=min(answer,min_answer)
print(min_answer)

Measured memory_bytes: 3060
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;
ll a[500050];
int main()
{
    ll n,i,j;
    scanf("%lld",&n);
    for(i=0;i<n;i++)
        scanf("%lld",&a[i]);
    ll ci=0;
    ll k=a[0];
    for(i=0;i<n;i++)
    {
        if(a[i]<=k)
            ci+=k-a[i];
        else
            k=a[i];
    }
    printf("%lld\n",ci);
    return 0;
}


Measured memory_bytes: 5384
import std.algorithm;
import std.range;
import std.stdio;
import std.math;
import std.array;
import std.string;
import std.conv;

/// 数列の読み込み
auto readNums(T = int)() {
	return readln().chomp.split.map!(to!T).array;
}

/// 数の読み込み
auto readNum(T = int)() {
	return readNums!T.front;
}

/// 指定行数読み込み
auto readRows(size_t rows) {
	return generate(() => readln().chomp).take(rows).array;
}

auto maxElement(R)(R r) {
    return r.reduce!((a, b) => max(a, b));
}

void main() {
    const nums = readNums();
    immutable k = readNum();
    immutable nmax = nums.maxElement;
    writefln("%d", nums.sum - nmax + (nmax << k));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define lli long long int
#define rep(i,n) for(lli i=0; i<n; i++)
#define loop(i, j, n) for(lli i=j; i<n; i++)
#define Max(a, b) ((a) > (b) ? (a) : (b))
#define Min(a, b) ((a) < (b) ? (a) : (b))
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const double PI = acos(-1);
//Function
lli combi(lli n, lli r){
	if(r==0 || r==n) return 1;
	else return combi(n-1,r) + combi(n-1,r-1);
}
lli sigma1(lli n){return n*(n+1)/2;}
lli sigma2(lli s, lli n){return sigma1(n) - sigma1(s -1);}
using namespace std;
// }}} End Header

int main() {
	int n;
	cin >> n;
	vector<vector<int>> a(2, vector<int>(n));
	rep(i,2){
		rep(j,n){
			cin >> a[i][j];
		}
	}
	int max  = 0;
	rep(i,n){
		int sum = 0;
		rep(j,i+1) sum += a[0][j];
		loop(k, i, n) sum+= a[1][k];
		max =Max(max, sum);
	}
	cout << max << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 200000 + 5;
ll tot, t, k; // 1 ~ tot
ll ch[maxn][2], key[maxn], pri[maxn], sz[maxn], h[maxn];
void update(ll u) {
	sz[u] = sz[ch[u][0]] + sz[ch[u][1]] + 1;
	h[u] = h[ch[u][0]]+h[ch[u][1]]+key[u];
}
void rotate(ll &u, ll d /* 0 or 1 */) {
	ll v = ch[u][d^1];
	ch[u][d^1] = ch[v][d];
	ch[v][d] = u;
	update(u);
	update(v);
	u = v;
}
void insert(ll &u, ll k) {
	if (u == 0) {
		u = ++tot;
		key[u] = k, pri[u] = rand(), sz[u]=1, h[u]=k;
		return;
	}
	int d = (k > key[u]);
	insert(ch[u][d], k);
	update(u); 
	if (pri[ch[u][d]] < pri[u]) rotate(u, d ^ 1);
}
/*void erase(ll &u,ll x) {
	if (u == 0) return;
	if (key[u] == x) {
		if (!ch[u][0]) u = ch[u][1];
		else if (!ch[u][1]) u = ch[u][0];
		else {
			int d = (pri[ch[u][0]] < pri[ch[u][1]]);
			rotate(u, d);
			erase(ch[u][d], x);
		}
	} else {
		int d = (x > key[u]);
		erase(ch[u][d], x);
	}
	if (u) update(u);
}*/
ll Rank(ll u,ll x) {
	if(!u) return 0;
	if(x <= key[u]) return Rank(ch[u][0],x);
	else return sz[ch[u][0]] + 1 + Rank(ch[u][1],x);
}
ll zhui(ll u, ll x){
	if(!u) return 0;
	if (x == sz[u]) return h[u];
	else if (x <= sz[ch[u][0]]) return zhui(ch[u][0], x);
	else return h[ch[u][0]]+zhui(ch[u][1], x - sz[ch[u][0]] - 1)+key[u];
}
ll select(ll u,ll x) {
	if (x == sz[ch[u][0]] + 1) return key[u];
	else if (x <= sz[ch[u][0]]) return select(ch[u][0], x);
	else return select(ch[u][1], x - sz[ch[u][0]] - 1);
}
/*void dfs(ll u) {
	if (ch[u][0]) dfs(ch[u][0]);
	//cout << key[u] << " ";
	if (ch[u][1]) dfs(ch[u][1]);
}*/
ll f, a, b, chang, sum, num;
int main() {
	srand(233);
	ll root = 0;
	cin>>t;
	for(int i=1;i<=t;i++){
		scanf("%lld", &f);
		if(f==1) {
			scanf("%lld%lld", &a, &b);
			sum+=a, num++;
			insert(root, a);
			chang+=b;
		}
		if(f==2) {
			ll p=select(root, (num+1)/2);
			ll q=chang+p*Rank(root, p)-zhui(root, Rank(root, p))+sum-zhui(root,Rank(root, p))-p*(num-Rank(root, p));
			printf("%lld %lld\n", p, q);
		}
		/*if(k==1) insert(root, x);
		if(k==2) erase(root, x);
		if(k==3) cout<<Rank(root, x)+1<<endl;
		if(k==4) cout<<select(root, x)<<endl;
		if(k==5) cout<<select(root, Rank(root, x))<<endl;
		if(k==6) cout<<select(root, Rank(root, x+1)+1)<<endl;*/
 	}
	return 0;
}

Measured memory_bytes: 10240
import java.lang.*;
import java.io.*;
import java.util.*;


public class Main {
	
	public static void main(String[] args) throws java.lang.Exception {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(in, out);
		out.close();
	}
}

class TaskA {
	
	
	public void solve(InputReader in, PrintWriter out) {
		String s = in.next();
		int len = s.length();
		int posa = -1, posz = 0;
		
		for (int i=0; i<len; ++i) {
			if (posa<0 && s.charAt(i)=='A')
				posa = i;
			if (s.charAt(i) == 'Z')
				posz = i;
		}
		
		int ans = posz - posa + 1;
		out.println(ans);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;
	
	
	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream), 32768);
		tokenizer = null;
	}
	
	public String next() {
		while (tokenizer==null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	
	public int nextInt() {
		return Integer.parseInt(next());
	}
	
	public long nextLong() {
		return Long.parseLong(next());
	}
	
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 27092
n, m = map(int,input().split())
a = list(input().split() for i in range(m))

wa = [0]*n
ac = [0]*n

for b in a:
  p = int(b[0]) - 1
  if ac[p] == 1:
    next
  else:
    if b[1] == 'AC':
      ac[p] = 1
    else:
      wa[p] += 1
wa = [ac[i]*wa[i] for i in range(n)]
print('{} {}'.format(sum(ac),sum(wa)))

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

using namespace std;
#define PROBLEM "A"
int like[100000];

int main(){

	#ifdef DBG
	freopen("problem" PROBLEM ".in", "r", stdin);
	freopen("problem" PROBLEM ".out", "w", stdout);
	#endif

	memset(like, 0, sizeof(like));
	int N, M;
	cin >> N >> M;
	for(auto i = 0 ; i < N ; i++){

		int K = 0;
		cin >> K;
		int trash;
		for(auto j = 1 ; j <= K ; j++){

			cin >> trash;
			like[trash]++;
		}
	}

	int count = 0;
	for(int i = 1 ; i <= M ; i++){

		if(like[i] == N){

			count++; 
		}
	}
	cout << count << endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    for(int i=0; i<n; i++){
      a[i] = Integer.parseInt(sc.next());
    }

    long sum = 0;
    
    for(int i = 1; i<n; i++){
      int dif = a[i-1] - a[i];
      if(dif > 0){
        sum += dif;
        a[i] += dif;
      }
    }

    System.out.println(sum);
   
    sc.close();
    return;
  }
  
}


Measured memory_bytes: 60128
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

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

  int n;
  cin >> n;
  bool v[4][14];
  rep(i, 0, 4) rep(j, 0, 14) v[i][j] = true;

  rep(i, 0, n) {
    char c;
    int x;
    cin >> c >> x;
    if (c == 'S')
      v[0][x] = false;
    else if (c == 'H')
      v[1][x] = false;
    else if (c == 'C')
      v[2][x] = false;
    else if (c == 'D')
      v[3][x] = false;
  }

  rep(i, 0, 4) {
    rep(j, 1, 14) {
      if (v[i][j]) {
        if (i == 0)
          cout << "S ";
        else if (i == 1)
          cout << "H ";
        else if (i == 2)
          cout << "C ";
        else if (i == 3)
          cout << "D ";
        cout << j << endl;
      }
    }
  }
}



Measured memory_bytes: 3132
#include<iostream>

using namespace std;

int main()
{
    int a[101][101],b[101],c[101];

    int n,m;

    cin>>n>>m;

    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cin>>a[i][j];
        }
    }

    for(int i=0;i<m;i++)
    {
        cin>>b[i];
    }

    for(int i=0;i<n;i++)
    {
        c[i]=0;
        for(int j=0;j<m;j++)
        {
            c[i]+=a[i][j]*b[j];
        }
        cout<<c[i]<<endl;
    }


    return 0;
}



Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define pb push_back
#define int long long int
const int mod=1e9+7;
using namespace std;

signed main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("input.txt", "r", stdin);
    int d, t,s; cin>>d>>t>>s;
    int x=d/s;
    //cout<<x<<endl;
    if(x < t){
        cout<<"Yes"<<endl;
    }
    else if(x == t and d%s==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n;
    cin >> n;

    map<string, ll> res;
    rep(i,n){
        string s;
        cin >> s;
        sort(all(s));
        res[s]++;
    }

    ll ans = 0;
    for(auto i: res){
        if(i.second != 1){
            ll tmp = i.second * (i.second - 1) / 2;
            ans += tmp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 11136
#include<stdio.h>
int main(){
    int num[101],i,n;

    scanf("%d",&n);
    for( i = 0; i < n; i++ ){
        scanf("%d",&num[i]);
    }
    for( i = n-1; i >= 0; i-- ){
        if( i == n-1 ){
            printf("%d",num[i]);
        }
        else{
            printf(" %d",num[i]);
        }
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#define mxN 15
using namespace std;

int n, m, x, c[mxN], a[mxN][mxN], s[mxN], ans;

void solve(int d, int t) {
	if (d >= n) {
		bool works = true;
		for (int i=0; i<m; i++) {
			// cout << s[i] << ' ';
			if (s[i] < x) {
				works = false;
				break;
			}
		}
		// cout << "\n";
		if (works) {
			if (ans == -1) {
				ans = t;
			}
			else {
				ans = min(ans, t);
			}
		}
		return;
	}

	for (int i=0; i<m; i++) s[i] += a[d][i];
	solve(d + 1, t + c[d]);
	for (int i=0; i<m; i++) s[i] -= a[d][i];

	solve(d + 1, t);
}

int main() {
	cin >> n >> m >> x;
	for (int i=0; i<n; i++) {
		cin >> c[i];
		for (int j=0; j<m; j++) {
			cin >> a[i][j];
		}
	}

	ans = -1;
	solve(0, 0);
	cout << ans << "\n";
}

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

int main(){
  int N, M;
  cin >> N;
  vector<string> s(N);
  for(int i = 0; i < N; i++){
    cin >> s[i];
  }
  cin >> M;
  vector<string> t(M);
  for(int i = 0; i < M; i++){
    cin >> t[i];
  }
  
  int ten = 0;
  int max = 0;
  for(int i = 0; i < N; i++){
    for(int k = 0; k < N; k++){
      if(i != k && s[i] == s[k]){
        ten ++;
      }
    }
    for(int k = 0; k < M; k++){
      if(s[i] == t[k]){
        ten --;
      }
    }
    if(max < ten){
      max = ten;
    }
    ten = 1;
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
main()
{
	cin>>n;
	vector<int>a(n);
	for(int i=0;i<n;i++)cin>>a[i];
	reverse(a.begin(),a.end());
	vector<int>table(n,0);
	vector<long long>sum(n,0);
	for(int i=0;i<n;i++)
	{
		int L=-1,R=n-1;
		while(R-L>1)
		{
			int M=(L+R)/2;
			if(table[M]<=a[i])R=M;
			else L=M;
		}
		sum[R]=a[i]+(R>0?sum[R-1]:0);
		table[R]=a[i];
	}
	int id=n-1;
	while(id>=0&&sum[id]==0)id--;
	cout<<(id<0?0:sum[id])<<endl;
}



Measured memory_bytes: 4400
from sys import stdin
import bisect
N = int(stdin.readline().rstrip())
A = [int(x) for x in stdin.readline().rstrip().split()]
B = [int(x) for x in stdin.readline().rstrip().split()]
C = [int(x) for x in stdin.readline().rstrip().split()]
A.sort()
B.sort()
C.sort()

ans = 0

for b in B:
    a = bisect.bisect_left(A,b)
    c = N - bisect.bisect_right(C,b)
    ans += (a*c)
print(ans)

Measured memory_bytes: 23232
#include <bits/stdc++.h>
using namespace std;
const int BASE = 1e9 + 7;

int main()
{
  int n, k, a[2000];
  long long internal = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
    for (int j = 0; j < i; j++)
      internal += a[j] > a[i];
  }

  long long ans = internal * k % BASE;
  for (int i = 0; i < n; i++)
  {
    long long external = 0;
    for (int j = 0; j < n; j++)
      external += a[i] > a[j];
    ans = (ans + (k - 1LL) * k / 2 % BASE * external) % BASE;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i,no;
    int v[3];

    scanf("%d",&no);

    for (i = 0; i < 3; i++){
        v[2 - i] = no % 10;
        no /= 10; 
    }

    for (i = 0; i < 3; i++){
        printf("%d",(v[i] == 1) ? 9:1);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 128
/*C - Next Prime*/
#include <bits/stdc++.h>

#define MAX_N 1000000

using namespace std;
using Number = long long;

Number factor[MAX_N];
vector<bool> isNotPrime(MAX_N);
vector<Number> primes;

inline void createSieve()
{
	for (Number p = 2; p < MAX_N; ++p)
	{
		if (not isNotPrime[p])
		{	
			factor[p] = p;
			primes.push_back(p);
		}

		for (int j = 0; j < primes.size() and p * primes[j] < MAX_N and primes[j] <= factor[p]; ++j)
		{
			factor[p * primes[j]] = primes[j];
			isNotPrime[p * primes[j]] = true;
		}
	}

	return;
}

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

	createSieve();

	Number num;

	cin >> num;
	for (Number prime : primes)
		if( prime  >= num){
			cout << prime;
			break;
		}

	return 0;
}

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

using namespace std;

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

    int h, w;

    cin >> h >> w;
    vector<string> c(h);
    for (int i = 0; i < h; ++i)
        cin >> c[i];

    for (int i = 0; i < 2 * h; ++i) {
        for (int j = 0; j < w; ++j)
            cout << c[i / 2][j];
        cout << '\n';
    }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
 
 
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n%2==1){
        cout<<"No"<<endl;
        return 0;
    } 
    if(s.substr(0,n/2)==s.substr(n/2,n/2)) cout<<"Yes"<<endl;
    else  cout<<"No"<<endl;
    //cout<<s.substr(0,n/2)<<" "<<s.substr(n/2,n/2)<<endl;
}

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

int main() {
  int A, B;
  std::string x(1, ' ');
  scanf("%d", &A);
  scanf("%s", &x[0], x.size());
  scanf("%d", &B);
  if (x[0] == '+')
    printf("%d", A + B);
  else
    printf("%d", A - B);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define RFOR(i,a,b) for(int i=(b-1); i>=(a); i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define pb push_back
using ll = long long;
using D = double;
using LD = long double;
using P = pair<int, int>;
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; }

int main(){
    ll a,b,c,k; cin >> a >> b >> c >> k;
    ll ans = 0;
    if(k <= a) ans = k;
    else if(k <= a+b) ans = a;
    else ans = a-(k-a-b);
    cout << ans << endl;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ls( s) (s&(-s))
#define ll long long
const int N = 3000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const int mod =    1e9+7;
int a,b,c;
int main()
{ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

cin>>a>>b>>c;
if(a+b+c>=22)
cout<<"bust";
else
cout<<"win";


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	if (S[K - 1] == 'A') S[K - 1] = 'a';
	if (S[K - 1] == 'B') S[K - 1] = 'b';
	if (S[K - 1] == 'C') S[K - 1] = 'c';
	
	cout << S << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
set<string>s;
string p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,x;
    cin>>n>>m>>l>>r;
    for(i=1; ; i++)
    {
        if(i%2==1)
        {
            l-=m;
        }
        else
        {
            n-=r;
        }
        if(l<=0)
        {
            cout<<"Yes\n";
            break;
        }
        if(n<=0)
        {
            cout<<"No\n";
            break;
        }
    }
    return 0;
}


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

int	main() {
	int	N;
	long	M;
	cin >>N >>M;
	vector<long> A(N+1);
	A.at(0)=0;
	for (int i=1; i<=N; i++) cin >>A.at(i);
	for (int i=1; i<=N; i++) A.at(i)=(A.at(i)+A.at(i-1))%M;
	sort(A.begin(), A.end());
	vector<vector<long>> B(0);
	B.push_back({0, 1});
	for (int i=1; i<=N; i++)
		if (A.at(i)==A.at(i-1)) B.back().at(1)++;
		else B.push_back({A.at(i), 1});
	long S =0;
	for (int i=0; i<B.size(); i++) S += B.at(i).at(1)*(B.at(i).at(1)-1)/2;
	cout << S << endl;
	return 0;
}



Measured memory_bytes: 4532
#include <stdio.h>

int main(){
	int data[3];
	int temp;
	scanf("%d %d %d", &data[0], &data[1], &data[2]);
	
	for(int i=0; i< 3; i++){
		for(int j=i+1; j< 3; j++){
			if(data[i] > data[j]){
				temp = data[i];
				data[i] = data[j];
				data[j] = temp;
			}
		}
	}

	printf("%d %d %d\n", data[0], data[1], data[2]);

	return 0;

}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>0;(i)--)
#define rrep(i,n,m) for(int (i)=(n);(i)<(m);(i)++)
#define rrepr(i,n,m) for(int (i)=(n);(i)>(m);(i)--)
#define SORT(s) sort((s).begin(),(s).end())
#define SORTR(s,t) sort((s).begin(),(s).end(),greater<t>())

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

const int INF = 1000000000;
const ll LINF = 1000000000000000000ll;
const double PI = acos(-1.0);
const double EPS = 1e-10;

const ll MOD = 1000000007ll;
const int MAX=510000;

int N; vi A; vi B;
void input()
{
    cin>>N;
    rep(i,N+1){
        int a; cin>>a; A.emplace_back(a);
    }
    rep(i,N){
        int b; cin>>b; B.emplace_back(b);
    }
    return;
}

void solve()
{
    ll ans=0;
    for(int i=N-1;i>=0;--i){
        if(A[i+1]<B[i]){
            ans+=(ll)A[i+1]+(ll)min(A[i],B[i]-A[i+1]);
            A[i]=max(0,A[i]+A[i+1]-B[i]);
            A[i+1]=0;
        }
        else{
            ans+=B[i];
            A[i+1]-=B[i];
        }
    }
    cout<<ans<<endl;
    return;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 1400
#include<cstdio>
using namespace std;
int c=0;
int main()
{
    long long x,y,tmp;
    scanf("%lld %lld",&x,&y);
    tmp=x;
    while(tmp<=y)
    {
        c++;
        tmp*=2;
    }
    printf("%d",c);
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		sc.close();

		int ans = (A * 3 + B) / 2;
		System.out.println(ans);

	}

}


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


int main(){
    int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n = 35;
    cin >> n;
    cout << A[n-1];
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int c=0;
        for(int i=1; i<S.length(); i++){
            if(S.charAt(i)!=S.charAt(i-1))c++;
        }
        System.out.println(c);
    }
}

Measured memory_bytes: 13456
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0);
#define END return EXIT_SUCCESS;
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR((I),0,(N))
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP((I),(N)) cin>>V[I]
#define INS2(I,N,V1,V2) REP((I),(N)) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP((I),(N)) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<(P)<<endl
#define OUT2(P1,P2) cout<<(P1)<<" "<<(P2)<<endl
#define OUT3(P1,P2,P3) cout<<(P1)<<" "<<(P2)<<" "<<(P3)<<endl
#define OUTS(I,N,V) REP((I),(N)) cout<<(V[i])<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
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;}
template<class T>inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T>inline T lcm(T a,T b){return a*b/gcd(b,a%b);}
int N,i,sum,max_L;
vector<int> L;
inline void solve(){
  IN(N);
  L.resize(N);
  REP(i,N){
    IN(L[i]);
    sum+=L[i];
    chmax(max_L,L[i]);
  }
  sum-=max_L;
  if(max_L<sum)OUT("Yes");
  else OUT("No");
}

int main(int argc,char**argv){
  BEGIN
  solve();
  END
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,a,b,c;
    cin>>n;
    while(cin>>a>>b>>c){
        if(b+c>a) return cout<<"No"<<endl,0;
        if((b+c)%2==0 && a%2) return cout<<"No"<<endl,0;
        if((b+c)%2 && a%2==0) return cout<<"No"<<endl,0;
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define brep(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<n;i++)
#define cY cout<<"Yes"<<endl
#define cN cout<<"No"<<endl
#define ll long long

int main(void){
    int n,m;
    cin >> n >> m;
    vector<tuple<int,int,int>>a;
    int p[m],y[m];
    rep(i,m){
        cin >> p[i] >> y[i];
        a.emplace_back(y[i],p[i],i);
    }
    sort(a.begin(),a.end());
    int ct[n+1];
    rep(i,n+1)ct[i]=1;
    rep(i,m){
       y[get<2>(a[i])] =ct[get<1>(a[i])];
       ct[get<1>(a[i])]++;
    }
    rep(i,m){
        int keta = log10(p[i])+1;
        rep(i,6-keta)cout << "0";
        cout << p[i];
        keta = log10(y[i])+1;
        rep(i,6-keta)cout << "0";
        cout << y[i] << endl;
    }
    return 0;
}

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

int main(){
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=K; i<N; i++) cout << (A[i-K] < A[i] ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 4048
#include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
    while(1){
        int H,W;
        cin >> H >>W;
         
        if(H==0 && W==0)break;
        for(int y=0;y<H;y++){
            for(int x=0;x<W;x++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
     
    return 0;
}

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

int main() {
    int n, a;
    cin >> n;
    vector<int> b(100002, 0);
    for (int i = 0; i < n; i++) {
        cin >> a;
        b[a]++, b[a+1]++, b[a+2]++;
    }
    int ans = 0;
    for (int i = 0; i < 100002; i++)
        ans = max(ans, b[i]);
    cout << ans << endl;
}

Measured memory_bytes: 3792
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }

signed main(void) {
  int n, k, q; cin >> n >> k >> q;
  vector<int> p(n);
  for (int i = 0; i < q; ++i) {
    int a; cin >> a;
    ++p[a - 1];
  }

  for (int i = 0; i < n; ++i) {
    int s = k - (q - p[i]);
    if (s > 0) cout << "Yes";
    else cout << "No";
    cout << endl;
  }
  
}


Measured memory_bytes: 1408
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e5+20
#define INF 1e18+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
typedef pair<LL,LL> pii;
const int delta=(int)1e9+7;
LL n,k,ans=-1,a,b;pii x[70]; 
int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>n>>k;
	for(int i=0;i<n;++i) cin>>x[i].F>>x[i].S;
	sort(x,x+n);
	for(int i=0;i<n;++i){
		for(int j=i;j<n;++j){
			a=x[j].F-x[i].F;
			vector<int>y; y.clear();
			for(int l=i;l<=j;++l){
				y.pb(x[l].S);
			}
			if(y.size()<k) continue;
			sort(y.begin(),y.end());
			b=INF;
			for(int l=k-1;l<y.size();++l){
				b=min(b,(LL)(y[l]-y[l-k+1]));
			}
			//cout<<a<<" "<<b<<" "<<a*b<<endl;
			if(ans==-1) ans=a*b;
			ans=min(ans,a*b);
		}
	}
	cout<<ans;
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <cstring>
#include <map>
using namespace std;

int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};

struct State {
    int dis;
    int x,y,turn;
    State(int x,int y,int turn,int dis) : x(x), y(y), turn(turn) , dis(dis) {;}
};

map<char,int> idx;
int memo[1<<8][30][30];

int bfs(vector<string> &mp) {
    const int h = mp.size();
    const int w = mp[0].length();

    int nx,ny,gx,gy;

    for(int i=0; i<(1<<8); ++i)
        for(int j=0; j<30; ++j)
            for(int k=0; k<30; ++k)
                memo[i][j][k] = -1;

    for(int i=0; i<h; ++i) {
        for(int j=0; j<w; ++j) {
            if(mp[i][j] == '@') {
                nx = j; ny = i;
                mp[i][j] = '.';
            } else if(mp[i][j] == '<') {
                gx = j; gy = i;
                mp[i][j] = '.';
            }
        }
    }

    queue<State> Q;
    Q.push(State(nx,ny,0,0));

    while(!Q.empty()) {
        State st = Q.front(); Q.pop();
        int x = st.x, y = st.y;
        if(x == gx && y == gy) return st.turn;

        if(memo[st.dis][x][y] != -1) continue;
        memo[st.dis][x][y] = st.turn;

        for(int dir = 0; dir<4; ++dir) {
            int nx = x + dx[dir], ny = y + dy[dir];
            if(nx < 0 || nx >= w || ny < 0 || ny > h-1 || mp[ny][nx] == '#')
                continue;
            if(isupper(mp[ny][nx]) && (st.dis>>(idx[mp[ny][nx]]))%2 == 0)
                continue;

            State ns(nx,ny,st.turn+1,st.dis);

            if(islower(mp[ny][nx])) {
                if(!(idx.find(toupper(mp[ny][nx])) == idx.end()))
                    ns.dis ^= (1<<idx[toupper(mp[ny][nx])]);

//                cout<<"new dis "<<ns.dis<<" push "<<idx[toupper(mp[ny][nx])]<<endl;
                Q.push(ns);
            }else{
                Q.push(ns);
            }
        }
    }

    return -1;
}

int main() {
    int W,H;
    while(cin>>W>>H, W|H) {
        idx.clear();
        vector<string> mp;
        string s;
        for(int i=0; i<H; ++i) {
            cin>>s;
            mp.push_back(s);
        }

        int nc = 0;
        for(int i=0; i<H; ++i)
            for(int j=0; j<mp[i].length(); ++j)
                if(isupper(mp[i][j]) && idx.find(mp[i][j]) == idx.end())
                    idx[mp[i][j]] = nc++;


        cout<<bfs(mp)<<endl;
    }
}

Measured memory_bytes: 2276
# 愚直にやってもどうせ間に合う


n = int(input())


def keta(x):
    k = 0
    while x > 0:
        x //= 10
        k += 1
    return k


ans = 0
for i in range(n, 0, -1):
    if keta(i) % 2 == 1:
        ans += 1


print(ans)


Measured memory_bytes: 2940
#include <stdio.h>

int main(void){

  int x1,y1,x2,y2;
  scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
  int x3,y3,x4,y4;
  int vec_x = x2-x1;
  int vec_y = y2-y1;
  x3 = x2-vec_y;
  y3 = y2+vec_x;
  x4 = x1-vec_y;
  y4 = y1+vec_x;
  printf("%d %d %d %d\n", x3, y3, x4, y4);

  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cstring>
#include <iostream>

using namespace std;

int votes[100];

bool less_than(int i, int j) {
  return votes[i] > votes[j];
}

int main() {
  for (;;) {
    int n, m;
    cin >> n >> m;
    if (!n && !m) return 0;
    int results[n];
    memset(votes, 0, sizeof votes);
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) {
        bool f;
        cin >> f;
        if (f) votes[j]++;
      }
    for (int i = 0; i < m; i++)
      results[i] = i;
    stable_sort(results, results+m, less_than);
    for (int i = 0; i < m; i++) {
      cout << results[i] + 1;
      if (i != m-1) cout << ' ';
    }
    cout << endl;
  }
}

Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1000005;
int n,q,k;
char s[N];
int tot[N];
void solve(){
	cin >> k;
	LL v1=0,v2=0;
	LL ans=0;
	for (int i=1;i<=n;i++){
		if (i-k>0&&s[i-k]=='D')
			v2-=tot[i-1]-tot[i-k],v1--;
		if (s[i]=='D')
			v1++;
		if (s[i]=='M')
			v2+=v1;
		if (s[i]=='C')
			ans+=v2;
	}
	cout << ans << endl;
}
int main(){
	cin >> n;
	scanf("%s",s+1);
	for (int i=1;i<=n;i++)
		tot[i]=tot[i-1]+(s[i]=='M');
	cin >> q;
	while (q--)
		solve();
	return 0;
}


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

void solve(int n, int w, vector<int> v){
    int bars[12] = {};
    int max_v = *max_element(v.begin(), v.end());
    int n_bar = ceil((double)max_v / (double)w) + (max_v % w == 0);
    double delta_ink = 1.0 / (double)(n_bar - 1);

    for(int i=0;i<n;i++){
        bars[v[i] / w]++;
    }
    int max_h = *max_element(bars, bars+n_bar);

    double ans = 0.01;
    double ink = 1.0;
    for(int i=0;i<n_bar;i++){
        ans += ((double)bars[i] / (double)max_h) * ink;
        ink -= delta_ink;
    }
    cout << fixed << setprecision(6) << ans << endl;
    return;
}

int main(){
    while(true){
        int n, w;
        vector<int> v;
        cin >> n >> w;
        if(!(n || w)) break;

        for(int i=0;i<n;i++){
            int tmp;
            cin >> tmp;
            v.push_back(tmp);
        }
        solve(n, w, v);
    }
    return 0;
}


Measured memory_bytes: 3124
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	K, D := sc.nextStr(), sc.nextInt()
	var dp [10005][105][2]int
	n := len(K)
	dp[0][0][0] = 1
	for i := 0; i < n; i++ {
		d := int(K[i] - '0')
		for j := 0; j < D; j++ {
			for x := 0; x < 10; x++ {
				if x == d {
					dp[i+1][(j+x)%D][0] += dp[i][j][0]
					dp[i+1][(j+x)%D][0] %= MOD
				} else if x < d {
					dp[i+1][(j+x)%D][1] += dp[i][j][0]
					dp[i+1][(j+x)%D][1] %= MOD
				}
				dp[i+1][(j+x)%D][1] += dp[i][j][1]
				dp[i+1][(j+x)%D][1] %= MOD
			}
		}
	}
	// 0は除く
	fmt.Fprintln(wtr, (dp[n][0][0]+dp[n][0][1]-1+MOD)%MOD)
}


Measured memory_bytes: 17664
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()
  val x = sc.nextInt()
  val t = sc.nextInt()
  
  var tmp = n / x
  if (n % x != 0) tmp++

  println(tmp * t)

}


Measured memory_bytes: 36416
// #include <bits/stdc++.h>
#include <cstdio>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

using i32 = int;
using i64 = long long;

#define REP(i, stop) FOR(i, 0, stop)
#define FOR(i, start, stop) for (int i = start, i##_len = stop; i < i##_len; ++i)
#define RREP(i, n) for (int i = n; i-- > 0;)
#define ALL(v) (v).begin(), (v).end()

template<typename T>
T read() {
  T a = 0;
  for(;;) {
    char c = getchar();
    if ('0' <= c && c <= '9') {
      a = a * 10 + c - 48;
    } else {
      return a;
    }
  }
}

signed main() {
//  i32 x, y, z, k;
//  scanf("%d%d%d%d", &x, &y, &z, &k);
  i32 x = read<i32>(),
      y = read<i32>(),
      z = read<i32>(),
      k = read<i32>();
  vector<i64> A(x), B(y), C(z);
//  REP(i, x) scanf("%lld", &A[i]);
//  REP(i, y) scanf("%lld", &B[i]);
//  REP(i, z) scanf("%lld", &C[i]);
  REP(i, x) A[i] = read<i64>();
  REP(i, y) B[i] = read<i64>();
  REP(i, z) C[i] = read<i64>();
  sort(ALL(A), greater<i64>());
  sort(ALL(B), greater<i64>());
  sort(ALL(C), greater<i64>());
  using T = tuple<i32, i32, i32>;
  using P = pair<i64, T>;
  priority_queue<P> Q;
  Q.push({A[0] + B[0] + C[0], make_tuple(0, 0, 0)});
  set<T> S;
  S.insert(make_tuple(0, 0, 0));
  REP(_, k) {
    i64 p = Q.top().first;
    i32 u, v, w;
    tie(u, v, w) = Q.top().second;
    Q.pop();
    printf("%lld\n", p);
    auto u1 = make_tuple(u + 1, v, w);
    auto v1 = make_tuple(u, v + 1, w);
    auto w1 = make_tuple(u, v, w + 1);
    if (u + 1 < x && !S.count(u1)) { S.insert(u1); Q.push({A[u + 1] + B[v] + C[w], u1}); }
    if (v + 1 < y && !S.count(v1)) { S.insert(v1); Q.push({A[u] + B[v + 1] + C[w], v1}); }
    if (w + 1 < z && !S.count(w1)) { S.insert(w1); Q.push({A[u] + B[v] + C[w + 1], w1}); }
  }
}

Measured memory_bytes: 896
n = int(input())
li = list(map(int,input().split()))
flag = True
last = 0
for i,l in enumerate(li):
    #print(last,l)
    if i == 0:
        last = l-1
    if last > l:
        flag = False
        break
    elif last == l:
        last = l
    else:
        last = l-1
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14352
import sys

N = int(sys.stdin.readline().strip())
T = list(map(int, sys.stdin.readline().strip().split()))
A = list(map(int, sys.stdin.readline().strip().split()))

# i番目の山が取りうる高さの下限、上限
cand = [[1, float("inf")] for _ in range(N)]

l_max = 0
for i in range(N):
    if l_max < T[i]:
        l_max = T[i]
        if cand[i][0] > T[i] or cand[i][1] < T[i]:
            # print("here1", cand[i][0], cand[i][1], T[i])
            print(0)
            sys.exit()
        else:
            cand[i] = [T[i], T[i]]

    else:
        cand[i][1] = min(cand[i][1], T[i])

r_max = 0
for i in range(N-1, -1, -1):
    if r_max < A[i]:
        r_max = A[i]
        if cand[i][0] > A[i] or cand[i][1] < A[i]:
            # print("here2", cand[i][0], cand[i][1], A[i])
            print(0)
            sys.exit()
        else:
            cand[i] = [A[i], A[i]]
    else:
        cand[i][1] = min(cand[i][1], A[i])

# print(l_max, r_max)
if l_max != r_max:
    print(0)
else:
    ans = 1
    for h_min, h_max in cand:
        ans *= (h_max - h_min + 1)
        ans %= 10**9 + 7

print(ans)

Measured memory_bytes: 89160
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <sstream>
#include <cstdlib>
using namespace std;
int main(){
	string str;
	int x,y;
	stack<int> st;
	while(cin>>str){
		if(str=="+"){
			x=st.top();
			st.pop();
			y=st.top();
			st.pop();
			st.push(y+x);
		}else if(str=="-"){
			x=st.top();
			st.pop();
			y=st.top();
			st.pop();
			st.push(y-x);
		}else if(str=="*"){
			x=st.top();
			st.pop();
			y=st.top();
			st.pop();
			st.push(y*x);
		}else{
			int k=atoi(str.c_str());
			st.push(k);
		}
	}
	cout<<st.top()<<endl;
	return 0;
}

Measured memory_bytes: 3160
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      //split??????????????§????????????????§£????????£??\
        String[] lines = sc.nextLine().split(" ");
        int num1 = Integer.parseInt(lines[0]);
        int num2 = Integer.parseInt(lines[1]);
        int num3 = Integer.parseInt(lines[2]);
        //???????????£??\??????result?????£?¨????
        String result;

        //???????????????????????????????????£??\???
        if(num1 < num2 && num2 < num3){
            result = "Yes";
        } else {
            result = "No";
        }

        //???????????¨???
        System.out.println(result);

    }
}

Measured memory_bytes: 26208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; 
const int INF = 0x3f3f3f3f;
const int mod = 1e9+7;
const int N = 100000 + 5;

int main()
{
	int n,m;
	cin >> n >> m;
	if(n == m)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256