akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define p push
#define p1 pop
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define pi pair<ll,ll>
#define e 1000000007
using namespace std;
ll dp[100002],arr[100002];
ll solve(ll n,ll k)
{
    dp[1]=0;
    for(int i=2;i<=n;++i)
    {
        ll ans=10000000000000000;
        for(int j=max(ll(1),i-k);j<=i-1;++j)
            ans=min(ans,abs(arr[i]-arr[j])+dp[j]);
        dp[i]=ans;
    }
    return dp[n];
}
int main()
{
    ll n,k;cin>>n>>k;
    for(int i=1;i<=n;++i)
        cin>>arr[i];
    cout<<solve(n,k);
}

Measured memory_bytes: 1792
if __name__ == "__main__":
    shuffle_cards_collection = []

    while True:
        cards = input()

        if cards == '-':
            break

        shuffle_times = int(input())

        hs = []

        for _ in range(shuffle_times):
            h = int(input())
            hs.append(h)

        for h in hs:
            cards = cards[h:] + cards[:h]

        shuffle_cards_collection.append(cards)

    for shuffle_cards in shuffle_cards_collection:
        print(shuffle_cards)


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

#define LL long long
#define ULL unsigned long long
LL INF=10000000000001LL;

typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define READ 		freopen("in.txt","r",stdin)
#define WRITE  		freopen("out.txt","w",stdout)
#define BOOST		ios_base::sync_with_stdio(false)
#define sf 			scanf
#define pf 			printf
#define F  			first
#define S  			second
#define pb 			push_back
#define NL			pf("\n")
#define ALL(v)		v.begin(),v.end()
#define si(x)		sf("%d",&x);
#define sii(x,y)	sf("%d%d",&x,&y);
#define siii(x,y,z)	sf("%d%d%d",&x,&y,&z);
#define sl(x)		sf("%lld",&x);
#define sll(x,y)	sf("%lld%lld",&x,&y);
#define slll(x,y,z)	sf("%lld%lld%lld",&x,&y,&z);
#define clr(x,y) 	memset(x,y,sizeof (x) )
#define ch 			printf("Came Here!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n")
#define SV(v)		sort(v.begin(),v.end())
#define SVR(v,cmp)	sort(v.begin(),v.end(),cmp)
#define FOR(i,n)	for(int i=0;i<n;i++)
#define cnd			tree[idx]
#define lc			tree[idx*2]
#define rc			tree[idx*2+1]
#define lnd 		(2*idx),(b),((b+e)/2)
#define rnd 		((2*idx)+1),(((b+e)/2)+1),(e)
// graph direction array [4]
//LL X[4]={0,0,1,-1};
//LL Y[4]={1,-1,0,0};
// graph direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Bishop direction array [8]
//int X[8]={0,0,1,-1,-1,1,1,-1};
//int Y[8]={1,-1,0,0,-1,-1,1,1};
// Knight Direction Array
//int KX[8] = {1,1,2,2,-1,-1,-2,-2};
//int KY[8] = {2,-2,1,-1,2,-2,1,-1};

bool Check(int N,int pos){return (bool)(N & (1<<pos));} // check bit
int Set(int N,int pos){	return N=N | (1<<pos);}// set bit

LL mod=1000000007;
LL modMul(LL a, LL b){

	return (a%mod * b%mod)%mod;
//    LL ans = 0;
//    a = a % mod;
//    while (b > 0){
//        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
//        a = (a%mod * 2%mod) % mod;
//        b /= 2;
//    }
//    return ans % mod;
}

LL powerMod(LL a,LL b){
	if(b==0)return 1%mod;
	LL x=powerMod(a,b/2);
	x = (x%mod*x%mod)%mod;
//	x = modMul( x,x )%mod;
	if(b%2==1){
		x = (x%mod*a%mod)%mod;
//		x = modMul(x,a)%mod;
	}
	return x%mod;
}

LL lcm( LL a,LL b ){
	LL g = __gcd(a,b);
	return (a*b)/g;
}

const int mx = 10009;
// ----------------------------------------------
// ----------------------------------------------


int main(){
//  READ;
//  WRITE;
//  BOOST;
    LL t,n,m,k,c,u,v;

    cin>>n>>m;
    cout<<(n+(m/2))<<endl;


    return 0;
}




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

int main() {
	// your code goes here
	string t;
	cin>>t;
	if(t[t.size()-1]=='s')
	   t=t+"es";
	else
	   t=t+"s";
	cout<<t<<endl;   
	return 0;
}



Measured memory_bytes: 3624
#include<stdio.h>

#define N 100
#define W 0
#define G 1
#define B 2

int n, m[N][N], color[N], d[N], f[N], t;

void dfs_visit(int u){
  int v;
  color[u] = G;
  d[u] = ++t;
  for(v = 0 ; v < n ; v++){
    if(m[u][v] == 0) continue;
    if(color[v] == W){
      dfs_visit(v);
    }
  }
  color[u] = B;
  f[u] = ++t;
}

void dfs(){
  int u;
  for(u = 0 ; u < n ; u++) color[u] = W;
  t = 0;

  for(u = 0 ; u < n ; u++){
    if(color[u] == W) dfs_visit(u);
  }
  for(u = 0 ; u < n ; u++){
    printf("%d %d %d\n", u + 1, d[u], f[u]);
  }
}


int main(){
  int u, v, k, i, j;

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

  for(i = 0 ; i < n ; i++){
    scanf("%d %d", &u, &k);
    u--;
    for(j = 0 ; j < k ; j++){
      scanf("%d", &v);
      v--;
      m[u][v]  = 1;
    }
  }

  dfs();

  return 0;
}


Measured memory_bytes: 2108
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(int i=m;i<n;i++)
#define fore(i,a) for(auto i:a)
#define ll long long
using namespace std;
int N;
int mini;
int c=0;
int main(){
    cin>>N;
    mini=N+1;
    rep(i,0,N){
        int x;
        cin>>x;
        if(mini>x){
            mini=x;
            c++;
        }
    }
    puts(c);
}

Measured memory_bytes: 256
// AOJ 1201: Lattice Practices
// 2017.12.17 bal4u@uu

#include <stdio.h>
#include <string.h>

char a[10][6], b[10][6];
char *h[5], *v[5];
int same[10];
int ans;
void vset(int k, int s);

int check(int j)
{
	int i, k;
	for (k = 0; k <= j; k++) for (i = 0; i <= j; i++) if (h[i][k] == v[k][i]) return 0;
	return 1;
}

void hset(int k, int s)
{
	int i, bit;

	if (k == 5) { ans++; return; }
	for (bit = 1, i = 0; i < 10; i++, bit <<= 1) {
		if (s & bit) continue;
		h[k] = a[i];
		vset(k, s | bit);
		if (same[i]) continue;
		h[k] = b[i];
		vset(k, s | bit);
	}
}

void vset(int k, int s)
{
	int i, bit;

	for (bit = 1, i = 0; i < 10; i++, bit <<= 1) {
		if (s & bit) continue;
		v[k] = a[i];
		if (check(k)) hset(k+1, s | bit);
		if (same[i]) continue;
		v[k] = b[i];
		if (check(k)) hset(k+1, s | bit);
	}
}

int main()
{
	int i, j;

	while(scanf("%s", a[0]) && a[0][0] != 'E') {
		for (i = 1; i < 10; i++) scanf("%s", a[i]);
		for (i = 0; i < 10; i++) {
			for (j = 0; j < 5; j++) b[i][j] = a[i][4-j];
			same[i] = (memcmp(a[i], b[i], 5) == 0);
		}
		ans = 0;
		hset(0, 0);
		printf("%d\n", ans >> 3);
	}
	return 0;
}

Measured memory_bytes: 1684
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const double EPS = 1e-9;

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

  int n;
  string s;
  cin>>n>>s;
  int x = 0;
  int mx = 0;
  rep(i,n) {
    if(s[i] == 'I') {
      x++;
    } else {
      x--;
    }
    mx = max(mx, x);
  }
  cout  << mx << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#define int long long
#define INF 1e+9
using namespace std;

signed main(){
	int n,ma = 1;
	cin >> n;
	for(int i = 1;i <= (int)sqrt((double)n);i++){
		if(n % i == 0) ma = i;
	}
	n /= ma;
	int cnt = 0;
	while(n){
		n /= 10;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
use std::*;

fn read<T: str::FromStr>() -> T {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim().parse().ok().unwrap()
}

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

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

fn main() {
    let s: String = read();
    let mut count = 0;
    let mut max = 0;
    let acgt = "ACGT";

    for c in s.chars() {
        if acgt.contains(c) {
            count += 1;
            max = cmp::max(count, max);
        } else {
            count = 0
        }
    }

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


Measured memory_bytes: 4352
#!/usr/bin/env python3
import sys, math, itertools, heapq, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans = count = 0

r=int(input())
print(3*(r**2))

Measured memory_bytes: 38384
from collections import deque

H, W = map(int, input().split())
matrix = [input() for _ in range(H)]
(sy, sx) = (0, 0)
(gy, gx) = (H - 1, W - 1)

dist = [[None for _ in range(W)] for _ in range(H)]

q = deque([(sy, sx)])
dist[sy][sx] = 1

count_dots = 0
for i in range(H):
    count_dots += matrix[i].count(".")

while q:
    cy, cx = q.popleft()
    if (cy, cx) == (gy, gx):
        break

    for (dy, dx) in ((0, 1), (1, 0), (0, -1), (-1, 0)):
        ny, nx = cy + dy, cx + dx

        if 0 <= nx < W and 0 <= ny < H and matrix[ny][nx] == ".":
            if dist[ny][nx] is None:
                q.append((ny, nx))
                dist[ny][nx] = dist[cy][cx] + 1

if dist[gy][gx] is None:
    print(-1)
    exit()

print(count_dots - dist[gy][gx])

Measured memory_bytes: 3316
from collections import defaultdict

N = int(input())
b = 10**9
A = [int(round(float(input())*b)) for i in range(N)]
dic = defaultdict(int)
for a in A:
    c2, c5 = 0, 0
    while a % 2 == 0 and c2 < 18:
        c2 += 1
        a //= 2
    while a % 5 == 0 and c5 < 18: 
        c5 += 1
        a //= 5
    dic[(c2, c5)] += 1
ans = 0
for i in range(50):
    for j in range(25):
        for k in range(50):
            for l in range(25):
                if i+k >= 18 and j+l >= 18:
                    if i == k and j == l:
                        ans += dic[(i, j)] * (dic[(i, j)] - 1)
                    else:
                        ans += dic[(i, j)] * dic[(k, l)]
print(ans//2)


Measured memory_bytes: 88768
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int n,sum;
	scanf("%d",&n);
	sum=0;
	for(int i=1;i<=n;i++) sum=sum+i;
	printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 128
N,M=map(int,input().split())
L=[0]*M
R=[0]*M
for i in range(0,M):
    L[i],R[i]=map(int,input().split())
a=0
b=0
f=0
for i in range(0,M):
    if i==0:
        a=L[i]
        b=R[i]
    else:
        if b<L[i] or a>R[i]:
            print(0)
            f=1
            break
        elif b>=R[i]>=a>=L[i]:
            b=R[i]
        elif b>=R[i]>=L[i]>=a:
            a=L[i]
            b=R[i]
        elif R[i]>=b>=L[i]>=a:
            a=L[i]

if f==0:
    print(b-a+1)

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

int main()
{
  int N;
  cin >> N;
  vector<int> time(N + 1);
  vector<string> title(N);
  time[0] = 0;
  rep(i, N)
  {
    string s;
    int t;
    cin >> s >> t;
    title[i] = s;
    time[i + 1] = time[i] + t;
  }
  string X;
  cin >> X;
  int count = 0;
  rep(i, N)
  {
    if (title[i] == X)
      count = i;
  }
  cout << time[N] - time[count+1] << endl;
  return 0;
}

Measured memory_bytes: 256
def ri(): return int(input())
def rli(): return list(map(int, input().split()))
def ris(): return list(input())
def pli(a): return "".join(list(map(str, a)))

N, M = rli()
keiro = [[False for i in range(2)] for j in range(N+1)]
for i in range(M):
    a, b = rli()
    if(b == 1 or b == N):
        keiro[a][1 if b == 1 else 0] = True
    elif(a == 1 or a == N):
        keiro[b][1 if a == 1 else 0] = True

flag = False
for i in range(2, N):
    if(keiro[i][1] and keiro[i][0]):
        flag = True
if(flag):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

Measured memory_bytes: 28788
from collections import Counter
while True:
    W, D = map(int, input().split())
    if not (W | D):
        break
    hw = [int(x) for x in input().split()]
    hd = [int(x) for x in input().split()]
    print(sum(hw) + sum(hd) - sum(k * v for k, v in (Counter(hw) & Counter(hd)).items()))

Measured memory_bytes: 7880
<?php
fscanf(STDIN, '%d %d', $n, $m);
for ($i  = 0; $i < $n; $i++) $a[] = array_map('intval', explode(' ', trim(fgets(STDIN))));
$f = array_fill(1, $m, true);
for ($i = 0; $i < $n; $i++) {
    $k[$i] = $a[$i][0];
    $a[$i] = array_slice($a[$i], 1);
    for ($j = 1; $j <= $m; $j++) {
        if (!in_array($j, $a[$i])) $f[$j] = false;
    }
}
$cnt = 0;
for ($i = 1; $i <= $m; $i++) {
    if ($f[$i]) $cnt++;
}
echo $cnt . PHP_EOL;

Measured memory_bytes: 4604
import java.io.*;
import java.util.*;
public class Main{
  public static void main(String[]args){
  Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=new int[n];
  	for(int i=0;i<n;i++)a[i]=sc.nextInt();
    Arrays.sort(a);
    double value=a[0];
    for(int i=0;i<n;i++){
   	value=(value+a[i])/2;
    }
    System.out.println(value);
  }
}

Measured memory_bytes: 21972
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		if(S.length() > 9) {
			System.out.println("NO");
			System.exit(0);
		}
		String[] w = {"KIH", "B", "R"};
		for(int i = 0; i < 2; i++) {
			for(int j = 0; j < 2; j++) {
				for(int k = 0; k < 2; k++) {
					for(int l = 0; l < 2; l++) {
						String s = "";
						if(i == 1) s += "A";
						s += w[0];
						if(j == 1) s += "A";
						s += w[1];
						if(k == 1) s += "A";
						s += w[2];
						if(l == 1) s += "A";
						if(S.equals(s)) {
							System.out.println("YES");
							System.exit(0);
						}
					}
				}
			}
		}
		System.out.println("NO");
	}
}

Measured memory_bytes: 23764
#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;

using ll = long long;
using P = pair<int,int>;
using Pl = pair<int,ll>;

const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N = 2003;
const ll lmod = 1e9+7;

bitset<MAX_N * MAX_N> dp;
int a[MAX_N];

int main(){
  int N; cin >> N ;
  rep(i,N) scanf("%d",a+i);
  int _sum = 0;
  rep(i,N) _sum += a[i];
  dp[0] = 1; 
  rep(i,N) dp |= (dp << a[i]);
  REP(i,(_sum+1)/2,_sum+1){
    if(dp[i]){
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 1664
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <cmath>
#include <climits>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <array>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define io() ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define fi first
#define se second
#define IN(i,l,r) (l<i&&i<r)
#define LINR(i,l,r) (l<=i&&i<=r)
#define LIN(i,l,r) (l<=i&&i<r)
#define INR(i,l,r) (l<i&&i<=r)
#define v(T) vector<T>
#define p(T, N) pair<T, N>
#define tp(A, B, C) tuple<A, B, C>
#define ii p(int, int)
#define vi v(int)
#define vii v(p(int, int))
#define vvi v(v(int))
#define vl v(long long)
#define vll v(p(long long, long long))
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define qsort(a) sort(all(a))
#define qsortd(a) sort(all(a), greater<>())
#define qsortf(a, f) sort(all(a), f)
#define qsortsi(v) sort(v.begin(), v.end(), [](pair<int, int> aoeui, pair<int, int> boeui){return aoeui.se < boeui.se;})
#define pb(n) push_back(n)
#define eb(n) emplace_back(n)
#define pp(a, b) emplace_back(make_pair(a, b))
#define pt(a, b, c) emplace_back(make_tuple(a, b, c))
#define elif else if
#define fori(i, n) for(ll i = 0; i < n; i++)
#define foris(i, a, b) for(ll i = a; i < b; i++)
#define forise(i, a, b) for(ll i = a; i <= b; i++)
#define ford(i, n) for(ll i = n; i >= 0; i--)
#define fords(i, a, b) for(ll i = a; i >= b; i--)
#define fordse(i, a, b) for(ll i = a; i > b; i--)
#define fora(i, a) for (auto &i: a)
#define rev(a) reverse(a.begin(), a.end())
#define revf(a, b, c) (reverse(a.begin() + b, a.begin() + c))
#define digits(i) (int)((log(i)/(log(10))+1)
#define umap unordered_map
#define uset unordered_set
#define nl '\n'
#define fileio(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
const int mod = 1000000007;

int r;

int main() {
  io();
  
  cin >> r;
  cout << r * r;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdint>
#include <algorithm>
#include <iostream>
#include <list>
#include <vector>
#include <string>

int main()
{
    int32_t n;
    std::cin >> n;

    int32_t min;
    int32_t cnt = 1;

    std::cin >> min;

    for ( int _i = 1; _i < n; _i++ ) {
        int32_t p;
        std::cin >> p;
        if ( min >= p ) {
            cnt++;
            min = p;
        }
        if ( min == 1 ) break;
    }

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


Measured memory_bytes: 888
#input
r_1, c_1, r_2, c_2 = map(int, input().split())

#output
mod = 10**9 + 7

n_ = 2*10**6 + 1
fun = [1]*(n_+1)
for i in range(1,n_+1):
    fun[i] = fun[i-1]*i%mod
rev = [1]*(n_+1)
rev[n_] = pow(fun[n_],mod-2,mod)
for i in range(n_-1,0,-1):
    rev[i] = rev[i+1]*(i+1)%mod
def cmb(n,r):
    if n <= 0 or r < 0 or r > n: return 0
    return fun[n]*rev[r]%mod*rev[n-r]%mod

answer = 0
for j in range(c_1, c_2+1):
    answer += cmb(r_2+j+1, j+1) % mod - cmb(r_1+j, j+1) % mod

print(answer % mod)

Measured memory_bytes: 71900
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nm = ReadIntArray();
            var n = nm[0];
            var m = nm[1];
            var abs = new Tuple<int, int>[n];
            for (int i = 0; i < n; i++)
            {
                var ab = ReadIntArray();
                abs[i] = Tuple.Create(ab[0], ab[1]);
            }
            var cds = new Tuple<int, int>[m];
            for (int i = 0; i < m; i++)
            {
                var cd = ReadIntArray();
                cds[i] = Tuple.Create(cd[0], cd[1]);
            }

            for (int i = 0; i < n; i++)
            {
                var distance = int.MaxValue;
                var checkpoint = -1;
                for (int j = 0; j < m; j++)
                {
                    if (ChangeMin(ref distance, Math.Abs(abs[i].Item1 - cds[j].Item1) + Math.Abs(abs[i].Item2 - cds[j].Item2)))
                    {
                        checkpoint = j;
                    }
                }
                Console.WriteLine($"{checkpoint + 1}");
            }

        }
        public static bool ChangeMin(ref int lhs, int rhs)
        {
            if (lhs > rhs)
            {
                lhs = rhs;
                return true;
            }
            else
            {
                return false;
            }
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s,t;
    cin >> s >> t;
    vector <vector<long long>> dp(s.length()+1,vector<long long>(t.length()+1,0));
    for(long long i = 0; i < s.length(); i++){
        for(long long j = 0; j < t.length(); j++){
            if(s[i]==t[j]){
                dp[i+1][j+1]=max(dp[i][j]+1,dp[i+1][j+1]);
            }
            dp[i+1][j+1]=max(dp[i+1][j],dp[i+1][j+1]);
            dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j+1]);
        }
    }
    //cout << dp[s.size()][t.size()] << endl;
    #if 0
    for(long long i = 0; i < dp.size(); i++){
        for(long long j = 0; j < dp[i].size(); j++){
            cout << dp[i][j] << " ";
        }
        cout << endl;
    }
    #endif
    string ans = "";
    long long current = dp[s.size()][t.size()];
    for(long long i = dp.size()-1; i > 0; i--){
        for(long long j = dp[0].size()-1; j > 0; j--){
            if(dp[i][j]==current){
                if(dp[i][j]==dp[i-1][j-1]+1){
                    if(dp[i][j]==dp[i-1][j])continue;
                    if(dp[i][j]==dp[i][j-1])continue;
                    //cout << i << " " << j << endl;
                    ans+=s[i-1];
                    current--;
                    break;
                }
            }
        }
    }
    for(long long i = ans.length()-1; i >= 0; i--){
        cout << ans[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 73688
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define lf else if

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int top=1e7+19;
const int N=top+19;
const int M=10000;
const int oo=(1<<30)-1;

struct Edge{
	int y,f,nxt;
} E[M];

int vis[N],pri[N],A[N];
int x[M],y[M],las[M],dis[M];
int n,cnt,S,T,ans,res;

void Add_Edge(int x,int y,int f){
	E[cnt]=(Edge){y,f,las[x]};las[x]=cnt++;
	E[cnt]=(Edge){x,0,las[y]};las[y]=cnt++;
}
bool bfs(){
	static int Q[M];
	memset(dis,-1,sizeof(dis));
	dis[S]=1;
	int f=1,w=0;Q[1]=S;
	while (f>w){
		int x=Q[++w];
		for (int i=las[x],y;~i;i=E[i].nxt)
			if (E[i].f&&dis[y=E[i].y]==-1){
				dis[y]=dis[x]+1;
				Q[++f]=y;
			}
	}
	return dis[T]!=-1;
}
int dinic(int x,int flow){
	if (x==T||!flow) return flow;
	int res=0;
	for (int i=las[x],y;~i;i=E[i].nxt)
		if (E[i].f&&dis[y=E[i].y]==dis[x]+1){
			int tmp=dinic(y,min(flow,E[i].f));
			E[i].f-=tmp,E[i^1].f+=tmp,flow-=tmp,res+=tmp;
		}
	if (!res) dis[x]=-1;
	return res;
}

void Init(){
	vis[1]=1;
	For(i,2,top+1){
		if (!vis[i]) pri[++*pri]=i;
		for (int j=1;j<=*pri&&pri[j]*i<=top;j++){
			vis[pri[j]*i]=1;
			if (i%pri[j]==0) break;
		}
	}
}

int main(){
	memset(las,-1,sizeof(las));
	Init();
	n=IN();
	For(i,1,n+1) A[IN()]=1;
	for (int i=top;i;i--) A[i]^=A[i-1];
	For(i,1,top+1) if (A[i]){
		if (i&1) x[++*x]=i;else y[++*y]=i;
	}
	S=*x+*y+1,T=S+1;
	For(i,1,*x+1) Add_Edge(S,i,1);
	For(i,1,*y+1) Add_Edge(i+*x,T,1);
	For(i,1,*x+1) For(j,1,*y+1){
		if (!vis[abs(x[i]-y[j])]) Add_Edge(i,j+*x,1);
	}
	while (bfs()) ans+=dinic(S,oo);
	res=ans;
	if ((*x-ans)&1){
		res+=3;
		res+=(*x-ans-1)+(*y-ans-1);
	} else{
		res+=(*x-ans)+(*y-ans);
	}
	printf("%d\n",res);
}

Measured memory_bytes: 82816
#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, m, k;
const int N = 3000;
int cache[N][N][4];
int a[N][N];
int dp(int i, int j, int last)
{
    if (i == n || j == m)
        return 0;
    int &ans = cache[i][j][last];
    if (ans != -1)
        return ans;
    if (last == 3)
    {
        ans = dp(i + 1, j, 0);
    }
    else
        ans = max({ans, a[i][j] + dp(i + 1, j, 0), dp(i, j + 1, last), a[i][j] + dp(i, j + 1, last + 1)});
    return ans;
}
int32_t main()
{
    cin >> n >> m >> k;
    for (int i = 0; i < k; i++)
    {
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        a[x][y] = c;
    }
    memset(cache, -1, sizeof(cache));
    cout << dp(0, 0, 0);

    return 0;
}

Measured memory_bytes: 355820
x = input()
y = input()

def levenshtein_distance(x, y):
    lx = len(x); ly = len(y)
    dp = [[0 for i in range(ly + 1)] for j in range(lx + 1)]
    
    for i in range(lx + 1):
        dp[i][0] = i
    for j in range(1, ly + 1):
        dp[0][j] = j
        
    for i in range(1, lx + 1):
        for j in range(1, ly + 1):
            if x[i - 1] == y[j - 1]:
                cost = 0
            else:
                cost = 1
                
            dp[i ][j] = min(dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost)
    
    return dp[lx][ly]
    
print(levenshtein_distance(x, y))


Measured memory_bytes: 44012
def run(n, x, a):
    a = sorted(a)
    cnt = 0
    for i in range(n):
        x -= a[i]
        if x >= 0:
            cnt += 1
    if x > 0:
        cnt -= 1
    return cnt


def main():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    print(run(n, x, a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    int n, q;
    cin >> n >> q;
    vector<int> s(n);
    vector<int> t(n);
    vector<int> x(n);
    for(int i = 0; i < n; i++)
    {
        cin >> s[i] >> t[i] >> x[i];
    }
    vector<int> d(q);
    for(int i = 0; i < q; i++)
    {
        cin >> d[i];
    }

    vector<int> ans(q);
    int INF = 1e9+7;
    for(int i = 0; i < q; i++)
    {
        ans[i] = INF;
    }
    using P = pair<int, int>;
    using PP = pair<int, P>;
    priority_queue<PP, vector<PP>, greater<PP>> que;
    for(int i = 0; i < n; i++)
    {
        int cand = x[i];
        int ss = s[i] - cand;
        int ts = t[i] - cand;
        // [start, end)
        int start = lower_bound(d.begin(), d.end(), ss) - d.begin();
        int end = lower_bound(d.begin(), d.end(), ts) - d.begin();
        que.push(PP(cand, P(start, end-1)));
        //for(int j = start; j <= end-1; j++)
        //{
        //    ans[j] = min(ans[j], cand);
        //}
    }
    set<int> ss;
    for(int i = 0; i < q; i++)
    {
        ss.insert(i);
    }
    while(!que.empty())
    {
        PP pp = que.top();
        que.pop();
        P p = pp.second;
        int cand = pp.first;
        int start = p.first;
        int end = p.second;
        auto itr = ss.lower_bound(start);
        while(itr != ss.end() && *itr <= end)
        {
            ans[*itr] = cand;
            itr = ss.erase(itr);
        }
    }
    for(int i = 0; i < q; i++)
    {
        if(ans[i] == INF)
        {
            cout << -1 << endl;
        }
        else
        {
            cout << ans[i] << endl;
        }
    }
}



Measured memory_bytes: 17460
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    string alphabets = "abcdefghijklmnopqrstuvwxyz";
    char c; cin >> c; bool sol = true;
    for (int i = 0; i < 26; i++)
    {
        if (alphabets[i] == c)
        {
            cout << 'a' << endl; sol = false;
            break;
        }
    }
    if (sol)
        cout << 'A' << endl;
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;

bitset<2100000> b;

int main() {
    ll N;
    cin >> N;
    ll sum = 0;
    b = 1;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        b |= b << a;
        sum += a;
    }
    ll ans = (sum + 1) / 2;
    while (true) {
        if (b[ans]) {
            cout << ans << endl;
            break;
        }
        ans++;
    }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
#define MOD 1000000007

int main() {
	ll N;
	string S;
	cin >> N;
	cin >> S;
	vector<ll> A(N * 2, 1), B = A;
	for (int i = 0;i < N * 2;i++) {
		if (i % 2) {
			if (S[i] == 'B')
				A[i] = -1;
		}
		else if (S[i] == 'W')
				A[i] = -1;
	}
	for (int i = 1;i < 2 * N;i++) {
		if (A[i] == -1)
			B[i] = A[i - 1];
		A[i] += A[i - 1];
		if (A[i] < 0) {
			B[0] = 0;
			break;
		}
	}
	if (A[2 * N - 1])B[0] = 0;
	if (A[0] < 0)B[0] = 0;
	ll ans = 1;
	for (ll i : B) {
		ans *= i;
		ans %= MOD;
	}
	ll kaij = 1;
	for (ll i = 1;i <= N;i++)(kaij *= i) %= MOD;
	cout << ans * kaij%MOD << endl;
}

Measured memory_bytes: 3716
import math
A, B, H, M = map(int, input().split())

H = (60 * H + M) * (360 / (60 * 12))
M = M * 6
ang = abs(H - M)  
rad = math.radians(ang)

C = A ** 2 + B ** 2 - 2 * A * B * math.cos(rad)
print(C ** 0.5)

Measured memory_bytes: 9512
x,y = map(int, input().split())
a = [0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1]
if a[x] == a[y]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+5, mod = 1e9+7;
int zrb(int a, int b) { return(1LL*a*b%mod); }
int  jm(int a, int b) { int tmp = (a+b)%mod; while(tmp<0) tmp+=mod; return(tmp); }
int  pw(int a, int b) { int rt = 1; for(;b;b>>=1) { if(b&1) rt=zrb(rt, a); a=zrb(a, a); } return(rt); }
int fac[N], inv[N], n, m, a, b, rt;
int C(int n, int r) { return(zrb(fac[n], zrb(inv[r], inv[n-r]))); }
int main(){
    fac[0] = 1;
    for(int i=1;i<N;i++) fac[i] = zrb(fac[i-1], i);
    inv[N-1] = pw(fac[N-1], mod-2);
    for(int i=N-2;~i;i--) inv[i] = zrb(inv[i+1], i+1);
    scanf("%d %d %d %d", &n, &m, &a, &b);
    rt = C(n+m-2, n-1);
    for(int i=n;n-i<a;i--){
        int aa = n-i+1, bb = m-b;
        int tmp = zrb(C(i+b-2, b-1), C(aa+bb-2, aa-1));
        rt = jm(rt, -tmp);
    }
    printf("%d", rt);
}

Measured memory_bytes: 1792
#pragma region Header
#ifdef DEBUG
#include "debug.hpp"
#else
#define NDEBUG
#define debug(...)
#define IFD(...)
#endif
#include <utility>
#include <cstdint>
#include <cmath>
#include <cassert>
#include <vector>
#include <array>
#include <deque>
#include <queue>
#include <stack>
#include <tuple>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#include <functional>
#include <algorithm>
#include <numeric>
#include <stdexcept>
#include <iostream>
#include <iomanip>
using namespace std;
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
#define rep(i, n) for (int i = 0; i < static_cast<int>(n); ++i)
#define repd(i, n) for (int i = static_cast<int>(n) - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = static_cast<int>(a); i <= static_cast<int>(b); ++i)
#define FORD(i, b, a) for (int i = static_cast<int>(b); i >= static_cast<int>(a); --i)
template <typename T>
int SZ(T const &x)
{
    return static_cast<int>(x.size());
}
template <class T>
bool chmax(T &a, T const &b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
bool chmin(T &a, T const &b)
{
    if (b < a)
    {
        a = b;
        return true;
    }
    return false;
}
#pragma endregion

struct dpdata
{
    int a, b, c;

    int size()
    {
        return a;
    }
};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    string s, t;
    cin >> s >> t;

    vector dp(s.size() + 1, vector<dpdata>(t.size() + 1, {0, -1, -1}));
    // dp[i][0], dp[0][j] = "";
    FOR(i, 1, s.size())
    {
        FOR(j, 1, t.size())
        {
            if (dp[i][j].size() < dp[i - 1][j].size())
            {
                dp[i][j] = dp[i - 1][j];
            }
            if (dp[i][j].size() < dp[i][j - 1].size())
            {
                dp[i][j] = dp[i][j - 1];
            }
            if (s[i - 1] == t[j - 1] and dp[i][j].size() < dp[i - 1][j - 1].size() + 1)
            {
                dp[i][j] = {dp[i - 1][j - 1].size() + 1, i - 1, j - 1};
            }
        }
    }

    string ans;
    {
        auto [a, i, j] = dp[s.size()][t.size()];
        while (i != -1 and j != -1)
        {
            ans += s[i];
            auto [aa, ii, jj] = dp[i][j];
            a = aa;
            i = ii;
            j = jj;
        }
        reverse(ans.begin(), ans.end());
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 109072
#include <iostream>
#include <set>
#include <algorithm>

using namespace std;

int main(){
    int N;
    int idx[200000];
    set<int> st;
    cin >> N;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        idx[a-1] = i;
    }
    long ans = 0;
    for(int i = 0; i < N; i++){
        st.insert(idx[i]);
        auto j = st.find(idx[i]);
        int lower, upper;
        if(j == st.begin()){
            //cout << 'H' <<endl;
            lower = -1;
        }
        else lower = *(--j);
        j = st.find(idx[i]);
        if(++j == st.end()) upper = N;
        else upper = *j;
        //cout << lower << ' ' << idx[i] << ' ' << upper << endl;
        ans += (long)(upper-idx[i])*(long)(idx[i]-lower)*(long)(i+1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 10368
from sys import stdin
from itertools import product


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N,A,B,C = list(map(int,_in[0].split(' ')))  # type:list(int)
    l_arr = []
    for i in range(N):
        _ = int(_in[i+1])  # type:int
        l_arr.append(_)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = float('inf')
    cand_arr = list(product([0,1,2,3],repeat=N))
    for cand in cand_arr:
        length = [0,0,0,0]
        if (1 in cand) and (2 in cand) and (3 in cand):
            for i,_len in zip(cand,l_arr):
                length[i] += _len
            _cnt = abs(A-length[1])+abs(B-length[2])+abs(C-length[3])+\
                   10*(N-cand.count(0)-3)
            cnt = min(cnt,_cnt)
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 51252
N = int(input())
A = list(map(int, input().split()))
B = [0 for i in range(N)]
for i in range(N):
    B[A[i]-1] += 1
s = sum([B[i]*(B[i]-1)/2 for i in range(N)])
for i in range(N):
    print(int(s-B[A[i]-1]*(B[A[i]-1]-1)/2+(B[A[i]-1]-1)*(B[A[i]-1]-2)/2))

Measured memory_bytes: 26140
import sys
input = sys.stdin.buffer.readline

n = int(input())
A = list(map(int, input().split()))
L = [(a, i+1) for i, a in enumerate(A)]
L.sort(reverse=True)
dp = [[-1]*(n+1) for _ in range(n+1)]
dp[0][0] = 0
for i in range(n+1):
  for j in range(n+1-i):
    a, idx = L[i+j-1]
    if i:
      dp[i][j] = max(dp[i][j], dp[i-1][j]+a*(idx-i))
    if j:
      dp[i][j] = max(dp[i][j], dp[i][j-1]+a*(n+1-j-idx))
ans = 0
for i in range(n+1):
  ans = max(ans, dp[i][n-i])
print(ans)

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

int main()
{
    int X;
    cin >> X;

    double ans = 0;
    int n = pow(X, 0.5);

    for (int b = n; b >= 1; b--) {
        if (b == 1) {
            ans = max(ans, 1.0);
            break;
        }
        int p = 2;
        while (pow(b, p) <= X) {
            ans = max(ans, pow(b, p));
            p++;
        }
    }

    cout << (int)ans << endl;

    return 0;
}

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

int main() {
  string s;
  cin>>s;
  int n=s.size();
  vector<char>vec;
  
  for(int i=0;i<n;i++){
    if(i%2==0){
      vec.push_back(s[i]);
    }
  }
  for(int i=0;i<vec.size();i++){
    cout<<vec[i];
  }
  cout<<endl;
}


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

int main() {
  int A,B; cin >>A >>B;
  string S; cin >>S;
  rep(i,0,S.size()) {
    if (i!=A and '0'<=S[i] and S[i]<='9') continue;
    else if (i==A and S[i]=='-') continue;
    else {cout <<"No" <<endl; return 0;}
  }
  cout <<"Yes" <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, start, end) for(int i = start; i < (int)(end); ++i)
int a[200010];
int main(){
    int n;
    cin >> n;
    rep(i,0,n) cin >> a[i];
    int ans;
    int now = 1;
    rep(i,0,n){
        if(now == a[i]){
            now++;
        }else{
            ans++;
        }
    }
    if(now == 1) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

const double g=9.8;
int Height(double v);

int main(){
	double v;	
	
	while( cin>>v ){
		cout<<Height(v)<<endl;
	}
	return 0;
}

int Height(double v){
	int floor;
	for( floor=0;sqrt(2*g*floor*5)<v;floor++ );
	return floor+1;
}

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

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;

string S;

int main(){
    cin >> S;
    int c_r = 0,c_b = 0;
    for(int i=0;i<S.size();i++){
        if(S[i] == '0') c_r++;
        else c_b++;
    } 
    cout << 2*min(c_r,c_b) << endl;
    return 0;

}

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

const int N = 1e5 + 5;

int n, a, ans;
int cnt[N];

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		scanf("%d", &a);
		cnt[a]++;
		cnt[a - 1]++;
		cnt[a + 1]++;
	}
	for(int i = 0; i < N; ++i) {
		ans = max(ans, cnt[i]);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 640
import java.io.*;
import java.util.*;
public class Main{
   public static void main(String[] args) throws IOException{
   BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
   int[] kazu = new int[10];
   for(int a = 0; a <= 9; a++){
   kazu[a] = Integer.parseInt(br.readLine());
   }
   int n = 10;
   int kari;
   for(int b = 0; b <= n-2; b++){
   int x = b;
   for(int c = b+1; c <= n-1; c++){
   if(kazu[x] < kazu[c]){
   x = c;
   }
   }
   if(x != b){
   kari = kazu[x];
   kazu[x] = kazu[b];
   kazu[b] = kari;
   }
   }
   for(int d = 0; d <= 2; d++){
   System.out.println(kazu[d]);
   }
   }
}
   

Measured memory_bytes: 24200
#include<bits/stdc++.h>
using namespace std;
int main()
{
		int arr[]={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 k;
		cin>>k;
		k--;
		cout<<arr[k];
		
}


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

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

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

	while(true){
	
		int n,m; cin >> n >> m;
		if(n == 0) break;

		P site[105];
		for (int i = 0;i < m;i++){
			site[i] = P(0, i+1);
		}

		for (int i = 0;i < n;i++){
			for (int j = 0;j < m;j++){
				int tmp; cin >> tmp;
				if(!tmp) site[j].first++;
			}
		}

		sort(site,site+m);

		for (int i = 0;i < m;i++){
			cout << site[i].second << (i == m-1 ? "\n" : " " );
		}
	
	}

	return 0;

}


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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll N, k;
vector<int> A[1010101];
int C[2][101010];

void dfs(int x, int c, bool b) {
    if (C[b][x] > 0)return;
    C[b][x] = c;
    for (int to:A[x]) {
        dfs(to, c + 1, b);
    }
}

int main() {
    cin >> N;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        A[a].push_back(b);
        A[b].push_back(a);
    }
    dfs(1, 1, 0);
    dfs(N, 1, 1);
    int f = 0, s = 0;
    REP(i, N) {
        if (C[0][i + 1] <= C[1][i + 1])f++;
        else s++;
    }

    cout << (f > s ? "Fennec" : "Snuke") << endl;
    return 0;
}


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

int main(){
    int a,b,c,k=1;
    cin >> a >> b >> c;
    for(int i=a;i<100000;i+=a){
        if(i%b == c){
            cout << "YES" << "\n";
            k=0;
            break;
        }
    }
    if(k==1)cout << "NO" << "\n";
    return 0;
}

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

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

    int n = s.length();

    if(s[n - 1] == '3'){
        cout << "bon" << endl;
    }else if(s[n - 1] == '0' || s[n - 1] == '1' || s[n - 1] == '6' || s[n - 1] == '8'){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;


int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int n;
	cin >> n;

	vector<Int> time(5);
	Int mint = INF;//最小運搬人数
	Int minc = 0;//最小の都市番号
	Int res = 0;
	for (Int i = 0; i < 5; i++) {
		cin >> res;
		if (res <= mint) {
			mint = res;
			minc = i;
		}

	}

	Int ans = 5;
	if (mint < n) {
		ans += (n + (mint - 1)) / mint-1;
	}

	printf("%lld\n", ans);
}

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

int main(){
    int a,b;
    cin >> a>> b;
    if(a == 1 || b== 1){
        if(a==1 && b!=1) cout<<"Alice"<<endl;
        else if(a!=1 && b==1) cout<<"Bob"<<endl;
        else cout<<"Draw"<<endl;

        return 0;
    }

    if(a>b) cout<<"Alice"<<endl;
    else if(b>a) cout<<"Bob"<<endl;
    else cout<<"Draw"<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String str = input.readLine( );

		String before = str;
		String after = "";
		int diff = 0;

		while(before.length() > 0){
			after = before.replace(String.valueOf(before.charAt(0)), "");
			diff = before.length() - after.length();
			if(diff%2 != 0){
				System.out.println("No");
				System.exit(0);
			}
			before = after;
		}

		System.out.println("Yes");

	}

}


Measured memory_bytes: 21460
A = list(input())
B = list(input())
C = list(input())
n = A[0]
del A[0]
while True:
    if n == "a":
        if A == []:
            print("A")
            break
        n = A[0]
        del A[0]
    elif n == "b":
        if B == []:
            print("B")
            break
        n = B[0]
        del B[0]
    else:
        if C == []:
            print("C")
            break
        n = C[0]
        del C[0]
        


Measured memory_bytes: 61928
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if(a == b || b == c || c == a)
		{
			if( a == b && b == c)
			{
				System.out.println(1);
			}else
			{
				System.out.println(2);
			}
			
		}else
		{
			System.out.println(3);
		}
		
		
		
	}

}


Measured memory_bytes: 22740
n,m = map(int, input().split())
h = list(map(int, input().split()))
goods = [1]*n
for _ in range(m):
    a,b = map(int, input().split())
    if h[a-1] > h[b-1]:
        goods[b-1] = 0
    elif h[a-1] < h[b-1]:
        goods[a-1] = 0
    elif h[a-1] == h[b-1]:
        goods[a-1] = 0
        goods[b-1] = 0
print(sum(goods))

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

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

int main()
{
    cout << fixed << setprecision(15);
    ll N, T;
    cin >> N >> T;

    vector<ll> t(N);

    REP(i, N){
        cin >> t[i];
    }

    ll ans = 0;

    REP(i, N-1){
        ans += min(T, t[i+1]-t[i]);
    }
    ans += T;

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

Measured memory_bytes: 4656
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
		cout<<"Yes"<<endl;
		return 0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn=512345;
int n,nxt[maxn],pre[maxn];
char s[maxn];
int main()
{
    scanf("%s",s+1);
    n=strlen(s+1);
    for (int i=2;i<=n;++i) {
        int j=nxt[i-1];
        while (j&&s[i]!=s[j+1])
            j=nxt[j];
        nxt[i]=j+(s[i]==s[j+1]);
    }
    reverse(s+1,s+1+n);
    for (int i=2;i<=n;++i) {
        int j=pre[i-1];
        while (j&&s[i]!=s[j+1])
            j=pre[j];
        pre[i]=j+(s[i]==s[j+1]);
    }
    if (!nxt[n]||n%(n-nxt[n])) return 0*puts("1\n1");
    int res=0;
    for (int i=1;i<n;++i)
        if ((!nxt[i]||i%(i-nxt[i]))&&(!pre[n-i]||(n-i)%(n-i-pre[n-i]))) ++res;
    printf("%d\n%d\n",n/(n-nxt[n])==n?n:2,max(1,res));
    return 0;
}


Measured memory_bytes: 8228
def main():
    n = int(input().strip())
    s = input().strip()

    right_e = len([x for x in s if x == 'E'])
    left_w = 0

    m = right_e - 1 if s[0] == 'E' else right_e
    
    for i in range(1, len(s)):
        if s[i-1] == 'E':
            right_e -= 1
        else:
            left_w += 1

        if s[i] == 'E':
            m = min(m, right_e - 1 + left_w)
        else:
            m = min(m, right_e + left_w)


    print(m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5784