akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

ll dp[110][5][5][5];//1234を使う（最初は0）
int main(){
	dp[0][0][0][0]=1;
	ll n;
	scanf("%lld",&n);
	rep(x,0,n)rep(i,0,5)rep(j,0,5)rep(k,0,5)rep(c,1,5){
		if(!(j==1&&k==2&&c==3||
			 j==1&&k==3&&c==2||
			 j==2&&k==1&&c==3||
			 i==1&&j==2&&c==3||
			 i==1&&k==2&&c==3))dp[x+1][j][k][c]=(dp[x+1][j][k][c]+dp[x][i][j][k])%MOD;
	}
	ll ans=0;
	rep(i,0,5)rep(j,0,5)rep(k,0,5)ans=(ans+dp[n][i][j][k])%MOD;
	printf("%lld",ans);
}

Measured memory_bytes: 256
use proconio::{fastout, input, marker::Usize1};
use std::cmp::Ordering;
use std::collections::BinaryHeap;
#[derive(Copy, Clone, Eq, PartialEq)]
struct State {
    cost: usize,
    pos: usize,
}

impl Ord for State {
    fn cmp(&self, other: &State) -> Ordering {
        other
            .cost
            .cmp(&self.cost)
            .then_with(|| self.pos.cmp(&other.pos))
    }
}

impl PartialOrd for State {
    fn partial_cmp(&self, other: &State) -> Option<Ordering> {
        Some(self.cmp(other))
    }
}
#[derive(Copy, Clone, Eq, PartialEq)]

pub struct Edge {
    to: usize,
    cost: usize,
}

impl Edge {
    fn new(to: usize, cost: usize) -> Edge {
        Edge { to, cost }
    }
}

pub struct AdjList {
    dim: usize,
    list: Vec<Vec<Edge>>,
}

impl AdjList {
    pub fn new(d: usize) -> AdjList {
        AdjList {
            dim: d,
            list: vec![vec![]; d],
        }
    }

    pub fn dim(&self) -> usize {
        self.dim
    }

    pub fn add_edge(&mut self, from: usize, to: usize, cost: usize) {
        self.list.get_mut(from).unwrap().push(Edge::new(to, cost));
    }

    pub fn add_undirected_edge(&mut self, from: usize, to: usize, cost: usize) {
        self.list.get_mut(from).unwrap().push(Edge::new(to, cost));
        self.list.get_mut(to).unwrap().push(Edge::new(from, cost));
    }

    pub fn out_edges(&mut self, vertex: usize) -> Vec<Edge> {
        self.list.get_mut(vertex).unwrap().to_vec()
    }

    pub fn in_edges(&mut self, v: usize) -> Vec<usize> {
        let mut res = vec![];
        for l in 0..self.dim() {
            if let Some(list) = self.list.get(l) {
                if list.contains(&Edge::new(v, 0)) {
                    res.push(l);
                }
            }
        }

        res
    }

    fn shortest_paths(&self, start: usize) -> Vec<usize> {
        let mut dist: Vec<_> = (0..self.list.len())
            .map(|_| 1_000_000_000_000_000_000)
            .collect();
        let mut heap = BinaryHeap::new();
        dist[start] = 0;
        heap.push(State {
            cost: 0,
            pos: start,
        });
        while let Some(State { cost, pos }) = heap.pop() {
            if cost > dist[pos] {
                continue;
            }
            for edge in &self.list[pos] {
                let next = State {
                    cost: cost + edge.cost,
                    pos: edge.to,
                };
                if next.cost < dist[next.pos] {
                    heap.push(next);
                    dist[next.pos] = next.cost;
                }
            }
        }
        dist
    }
}

#[fastout]
fn main() {
    input! {
        n:usize,
    }

    let mut g = AdjList::new(n);
    for i in 0..n - 1 {
        input! {
            u:Usize1,
            v:Usize1,
            w:usize,
        }
        g.add_undirected_edge(u, v, w);
    }

    let dist = g.shortest_paths(0);

    for i in 0..n {
        println!("{}", dist[i] % 2);
    }
}


Measured memory_bytes: 12216
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    long long int n,k;
    cin >> n >> k;
    long long int ans = 0;
    while(pow(k,ans) <= n)
    {
        ans++;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 384
n=int(input())
x= map(int , input().split())
x_list=[int(i) for i in x]
y_list=sorted(x_list)
s=y_list[int(n/2-1)]
b=y_list[int(n/2)]
for i in range(n):
    if x_list[i]<=s:
        print(b)
    else:
        print(s)


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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  vector<int> v(5);
  cin >> v;
  int sum = 0;
  for(auto e:v)sum += e;
  cout << 15 - sum << endl;
  return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int sign(double r){ return (r < -EPS) ? -1 : (r > EPS) ? 1 : 0; }
bool eq(double a, double b){ return abs(b - a) < EPS; }

struct Point{
  double x, y;
  Point() {}
  Point(double x, double y) : x(x), y(y) {}
  Point operator+(const Point& b) const { return Point(x + b.x, y + b.y); }
  Point operator-(const Point& b) const { return Point(x - b.x, y - b.y); }
  Point operator*(const double b) const { return Point(x * b, y * b); }
  Point operator*(const Point& b) const { return Point(x * b.x - y * b.y, x * b.y + y * b.x); }
  Point operator/(const double b) const { return Point(x / b, y / b); }
  bool operator< (const Point& b) const { return x != b.x ? x < b.x : y < b.y; }
  bool operator==(const Point &b) const { return eq(x, b.x) && eq(y, b.y); }
  double dot(const Point &b){ return x * b.x + y * b.y; }
  double cross(const Point &b){ return x * b.y - y * b.x; }
  double norm(){ return x * x + y * y; }
  double arg(){ return atan2(x, y); }
  double abs(){ return sqrt(norm()); }
  Point rotate(double theta){ return Point(cos(theta) * x - sin(theta) * y, sin(theta) * x + cos(theta) * y); }
  Point rotate90(){ return Point(-y, x); }
};

ostream& operator<<(ostream& os, Point& p){ return os<<"("<<p.x<<","<<p.y<<")"; }
istream& operator>>(istream& is, Point& a){ return is>>a.x>>a.y; }
Point polor(double rho, double theta){ return Point(rho * cos(theta), rho * sin(theta)); }

struct Line : public vector<Point> {
  Line(const Point &a, const Point &b) {
    push_back(a); push_back(b);
  }
  Point vector(){
    return back() - front();
  }
};
typedef vector<Point> Polygon;
struct Circle {
  Point p; double r;
  Circle(const Point &p, double r) : p(p), r(r) { }
};

int main(){
  int N;
  cin>>N;
  while(N--){
    Point p[4];
    REP(i, 4) cin>>p[i];
    Line l1(p[0], p[1]);
    Line l2(p[2], p[3]);
    if(eq(l1.vector().cross(l2.vector()), 0)){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1228
#include <stdio.h>

#define TRUE 1
#define FALSE 0

int checkPrime(int x) {
  int i;
  if (x <= 1)
    return FALSE;
  for (i = 2; i * i <= x; i++) {
    if (x % i == 0)
      return FALSE;
  }
  return TRUE;
}

int main() {
  int x;
  int i;

  if (scanf("%d", &x) != 1)
    return -1;
  i = 0;
  while (TRUE) {
    if (checkPrime(x + i)){
      printf("%d\n", x + i);
      return 0;
    }
    i++;
  }

  return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      int a = sc.nextInt();
      int b = sc.nextInt();
      int x1 = 0;
      int x2 = 0;
      int x3 = 0;
      int x4 = 0;
      int x5 = 0;
      int count = 0;
      for(int i = a;i <= b;i++){
      	x5 = i%10;
        x1 = i/10000;
        x2 = (i-x1*10000)/1000;
        x3 = (i-x1*10000-x2*1000)/100;
        x4 = (i-x1*10000-x2*1000-x3*100)/10;
        if(x1==x5&&x2==x4)count++;
      }
      System.out.println(count);
    }
}


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

using namespace std;
typedef long long ll;

int n;
ll a[440];
ll sum[440];
ll dp[440][444];
ll f(int l, int r)
{
    if (l > r) return 1e18;
    if (l == r) return 0;
    ll &ret = dp[l][r];
    if (~ret) return ret;
    ret = 1e18;
    for (int i = l+1 ; i <= r; ++i)
    {
        ret = min(ret, f(l, i-1) + f(i, r));
    }
    return ret += sum[r] - (l ? sum[l-1]: 0);
}

int main()
{
    memset(dp, -1, sizeof dp);
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%lld", &a[i]), sum[i] = a[i] + (i ? sum[i-1] : 0);
    printf("%lld\n", f(0, n-1));

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  ll K;
  cin >> N >> K;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
    A[i]--;
  }
  vl cnt(N,-1);
  int now = 0;
  ll id=0;
  while(cnt[now]<0) {
    cnt[now]=id;
    id++;
    now=A[now];
  }
  int bi = cnt[now];
  if(K<=bi) {
    now=0;
    rep(i,K) {
      now=A[now];
    }
    cout << now+1 << endl;
    return 0;
  }
  now=0;
  rep(i,bi) {
    now=A[now];
  }
  K -= bi;
  K %= (id-bi);
  rep(i,K) {
    now=A[now];
  }
  cout << now+1 << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

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

	int n;
	cin >> n;

	string s;
	cin >> s;

	int ans = 0;
	for(int i = 0; i < n-1; i++){
		set<char> a;
		for(int j = 0; j < i + 1; j++){
			a.insert(s[j]);
		}

		set<char> b;
		for(int j = i + 1; j < n; j++){
			b.insert(s[j]);
		}

		set<char> res;
		set_intersection(a.begin(), a.end(), b.begin(), b.end(), inserter(res, res.end()));
		ans = max(ans, (int)res.size());
	}

	cout << ans << endl;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <utility>

using namespace std;

int main() {
	int n, m, a[10000], b[10000];
	while (cin >> n >> m && n != 0) {
		vector<bool> fri(n + 1);
		fri[1] = true;
		for (int i = 0; i < m; ++i) {
			cin >> a[i] >> b[i];
		}
		
		for (int i = 0; i < 2; ++i) {
			vector<bool> temp = fri;
			for (int j = 0; j < m; ++j) {
				if (fri[a[j]])
					temp[b[j]] = true;
				if (fri[b[j]])
					temp[a[j]] = true;
			}
			fri = temp;
		}

		int ans = 0;
		for (int i = 2; i <= n; ++i) {
			if (fri[i])
				ans++;
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
using namespace std;
int main() {
	string S;
	cin >> S;
	if (S[0] == S[1] && S[2] == S[3] && S[0] != S[2]) { cout << "Yes"; return 0; }
	else if (S[0] == S[2] && S[1] == S[3] && S[0] != S[1]) { cout << "Yes"; return 0; }
	else if (S[0] == S[3] && S[1] == S[2] && S[0] != S[1]) { cout << "Yes"; return 0; }
	else cout << "No";
}

Measured memory_bytes: 256
N, M = map(int, input().rstrip().split())
ab = [list(map(int, input().rstrip().split())) for _ in range(M)]
count = [[0]*N for _ in range(N)]
for road in ab:
    count[road[0]-1][road[1]-1] += 1
    count[road[1]-1][road[0]-1] += 1
for i in range(N):
    print(sum(count[i]))

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

int main() {
  int n;
  cin >> n;
  int count = 0;
  int num = 1;
  for(int i=0; i<n; i++) {
    int a;
    cin >> a;
    if(a == num) {
      num++;
    } else {
      count++;
    }
  }
  if(num == 1) {
    cout << -1 << endl;
  } else {
    cout << count << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin>>n;
    set<int> s;
    REP(i,n){
        int a;cin>>a;
        s.insert(a);
    }
    if(s.size()%2==0) cout<<s.size()-1<<endl;
    else cout<<s.size()<<endl;
}

Measured memory_bytes: 4992
n=int(input())
a=list(map(int,input().split()))
l1=[0]*n
l2=[0]*n
k=0
ans=0
for i in a:
  if k+i<n:
    l1[k+i]+=1
  if k-i>=0:
    l2[k-i]+=1
  k+=1
for i in range(n):
  ans+=l1[i]*l2[i]
print(ans)

Measured memory_bytes: 32236
#include <algorithm>
#include <bitset>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> ss(n);
    for (auto& s : ss) {
        cin >> s;
    }
    sort(begin(ss), end(ss));
    int q;
    cin >> q;
    int ans = 0;
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (binary_search(begin(ss), end(ss), t)) {
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1248
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef tuple<int, int, int, int> T;
T rotate(T x) {
	return make_tuple(get<1>(x), get<2>(x), get<3>(x), get<0>(x));
}
T lex_min(T x) {
	T t = x;
	for (int i = 0; i < 3; i++) {
		x = rotate(x);
		t = min(t, x);
	}
	return t;
}
ll perm(int n, int k) {
	if (n < k) return 0;
	ll ret = 1;
	for (int i = n; i >= n - k + 1; i--) ret *= i;
	return ret;
}
map<T, int> cnt;
int main() {
	int N;
	cin >> N;
	vector<T> tile;
	for (int i = 0; i < N; i++) {
		int C[4];
		for (int j = 0; j < 4; j++) cin >> C[j];
		T x = make_tuple(C[0], C[1], C[2], C[3]);
		x = lex_min(x);
		tile.push_back(x);
		cnt[x]++;
	}
	ll ans = 0;
	for (int i = 0; i < N; i++) for (int j = 0; j < 4; j++) {
		T x = tile[i];
		cnt[x]--;
		for (int k = 0; k < j; k++) x = rotate(x);
		for (int k = i + 1; k < N; k++) for (int l = 0; l < 4; l++) {
			T y = tile[k];
			cnt[y]--;
			for (int m = 0; m < l; m++) y = rotate(y);
			map<T, int> sel;
			T z = make_tuple(get<0>(x), get<3>(x), get<0>(y), get<3>(y));
			z = lex_min(z);
			sel[z]++;
			z = make_tuple(get<3>(x), get<2>(x), get<1>(y), get<0>(y));
			z = lex_min(z);
			sel[z]++;
			z = make_tuple(get<2>(x), get<1>(x), get<2>(y), get<1>(y));
			z = lex_min(z);
			sel[z]++;
			z = make_tuple(get<1>(x), get<0>(x), get<3>(y), get<2>(y));
			z = lex_min(z);
			sel[z]++;
			ll tmp = 1;
			for (auto p : sel) {
				tmp *= perm(cnt[p.first], p.second);
				T t = p.first;
				int n = 1;
				for (int m = 0; m < 3; m++) {
					t = rotate(t);
					if (t == p.first) n++;
				}
				for (int m = 0; m < p.second; m++) tmp *= n;
			}
			ans += tmp;
			y = lex_min(y);
			cnt[y]++;
		}
		x = lex_min(x);
		cnt[x]++;
	}
	cout << ans / 12 << endl;
}

Measured memory_bytes: 80128
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] map = new int[r][c];
		for(int i=0;i<r;i++){
			for(int j=0;j<c;j++){
				int in = sc.nextInt();
				if(in==1) map[i][j] = 1;
				else map[i][j] = -1;
			}
		}
		
		int cnt = 0;
		for(int i=0;i<r;i++){
			int a = 0;
			int b = c-1;
			while(true){
				if(map[i][a]==1){
					cnt++;
					if(i+1<r) map[i+1][a] *= -1;
					if(a+1<c) map[i][a+1] *= -1;
					a++;
				}else{
					if(map[i][b]==1) cnt++;
					if(i+1<r) map[i+1][b] *= -1;
					if(b-1>=0) map[i][b-1] *= -1;
					b--;
				}
				if(b<a) break;
			}
		}
		
		System.out.println(cnt);
	}

	
}

Measured memory_bytes: 30876
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int N, M;
signed main(){
	cin >> N >> M;
	if(N == M) cout << "Yes" << endl;
	else cout << "No" << endl;
}


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

vector<int>graph[200000];

int main() {
	int n, m; cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
	}

	for (int i = 0; i < graph[0].size(); i++) {
		int u = graph[0][i];
		for (int j = 0; j < graph[u].size(); j++) {
			int v = graph[u][j];
			if (v == n - 1) {
				cout << "POSSIBLE" << endl; return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;

	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

#define INF (INT_MAX/2-1)
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

int main(){
  int N,K;
  cin>>N>>K;
  double k=0;
  for(ll i=1;i<=N;i++){
    ll a=i;
    double kakuritu=1./N;
    if(a>=K)k+=kakuritu;
    else{
      int c=0;
      for(;a<K;c++){
        //kakuritu*=0.5;
        a*=2;
        if(a>=K)break;
      }
      k+=kakuritu*1./pow(2,c+1);
    }
  }
  cout<<setprecision(20)<<k<<endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().rstrip().split(' '))
city = [list(map(int, input().rstrip().split(' '))) + [i] for i in range(M)]

city = sorted(city, key=lambda x: x[1])

belongs = [0 for _ in range(N)]

for i, (p, y, n) in enumerate(city):
    belongs[p-1] += 1
    city[i].append(belongs[p-1])
    
city = sorted(city, key=lambda x: x[2])

for p, y, n, n_city in city:
    print('{:06d}{:06d}'.format(p, n_city))

Measured memory_bytes: 33000
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fi first
#define se second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ull unsigned long long
#define ld long double
#define pll pair<long long,long long>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define sqr(x) (x)*(x)
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
using namespace std;
bool cmp(pll a,pll b){
    return a.se>b.se;
}
signed main()
{
    fast_io;
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    ll sum=0;
    ld ans=0;
    for(ll i=0;i<k-1;i++){
        sum+=a[i];
    }
    ll mx=0;
    for(ll i=k-1;i<n;i++){
        sum+=a[i];
        mx=max(mx,sum);
        sum-=a[i-(k-1)];
    }
    cout<<fixed<<setprecision(6)<<(ld)(mx+k)/2.0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 3e5+5;
const int mod = 1e9+7;

LL cnt[64][2];
LL val[64];

LL A[maxn];
int N;

void split(LL num){
    _for(i,0,61){
        if( (num >> i) & 1LL){
            cnt[i][1]++;
        }
        else{
            cnt[i][0]++;
        }
    }
}

int cal(LL num){
    LL ret = 0;
    _for(i,0,61){
        if((num >> i) & 1LL){
            ret =(ret  + ((cnt[i][0]%mod) * (val[i]%mod))%mod)%mod;
        }else{
            ret =(ret  + ((cnt[i][1]%mod) * (val[i]%mod))%mod)%mod;
        }

    }

    return ret;
}


int main()
{
    _for(i,0,64){
        val[i] = (1LL << i);
    }

    cin >> N;
    _for(i,0,N) cin >> A[i];

    LL ans = 0;
    for(int i = N-1;i>=0;i--){
        ans = (ans + cal(A[i]))%mod;
        split(A[i]);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Tue Mar  6 22:15:13 2018
//
package main

import (
	"fmt"
)

var N, M int
var graph [][]bool

func permutations(n int) [][]int {
	if n == 1 {
		return [][]int{{1}}
	}

	ret := [][]int{}
	perm := permutations(n - 1)
	for i := 0; i < len(perm); i++ {
		for j := 0; j <= len(perm[i]); j++ {
			p := make([]int, len(perm[i]))
			copy(p, perm[i])
			ret = append(ret, append(p[:j], append([]int{n}, p[j:]...)...))
		}
	}
	return ret
}

func main() {
	fmt.Scan(&N, &M)

	graph = make([][]bool, N+1)
	for i := 0; i < N+1; i++ {
		graph[i] = make([]bool, N+1)
	}

	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		graph[a][b] = true
		graph[b][a] = true
	}

	count := 0
	for _, val := range permutations(N) {
		if val[0] == 1 {
			invalid := false
			for i := range val {
				if i+1 < len(val) {
					if !graph[val[i]][val[i+1]] {
						invalid = true
					}
				}
			}
			if !invalid {
				count++
			}
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 9728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = 1e9;
    for (int i = 0; i <= x; i++) {
        int k = (x - i) * 2;
        int j = max(y - k / 2, 0);
        ans = min(ans, i * a + j * b + k * c);
    }
    for (int j = 0; j <= y; j++) {
        int k = (y - j) * 2;
        int i = max(x - k / 2, 0);
        ans = min(ans, i * a + j * b + k * c);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);
//#define _GLIBCXX_DEBUG//only for debugging
#include <bits/stdc++.h>
#include <ext/rope>
#define VALHALLA cin.tie(0)->ios_base::sync_with_stdio(false);cout<<fixed<<setprecision(13);
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define debug(x) std::cerr << #x << ": " << (x) << '\n';
#define sz(x) (int)x.size()
#define fast(map_name) map_name.reserve(1024);map_name.max_load_factor(0.25);
using namespace std;
using namespace __gnu_cxx;
typedef long long int ll;
typedef pair<int,int> ii;
typedef complex<double> point;
const double epsilon=1e-9;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int mod=1e9+7;
/* VARIABLE DECLARATION START */
ll dp[3000][51][51];
int arr[100];
/*  FUCNTION TEMPLATE STARTS  HERE */

double dot(point a,point b){ return (conj(a)*b).real() ; }
double cross(point a,point b){ return (conj(a)*b).imag() ; }
double dist(point a, point b){ return abs(a-b); }
struct neal {
static uint64_t splitmix64(uint64_t x)
 {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const
 {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
}
};
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};
bool isprime(ll n) {
    if (n == 2 || n == 3) return true;
    if (n < 2 || n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 6; (i - 1) * (i - 1) <= n; i += 6) {
        if (n % (i - 1) == 0 || n % (i + 1) == 0) {
            return false;
        }
    }
    return true;
}
inline ll exp(ll a, ll b, ll mod) {
    ll n = 1;
    ll p = a;
    while (b > 0) {
        if (b % 2 == 1) {
            n *= p;
            n %= mod;
        }
        p *= p;
        p %= mod;
        b /= 2;
    }
    return n;
}

inline bool comp(double a,double b)
{
  return (fabs(a-b)<epsilon);
}
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
ll solve(int sum,int index,int cnt)
{
  if(sum<0||cnt<0)return 0;
  if(index<0)
  {
    if(sum==0&&cnt==0)return 1;
    else
      return 0;
  }
  if(dp[sum][index][cnt]!=-1)return dp[sum][index][cnt];
  ll ans=0;
  ans=solve(sum-arr[index],index-1,cnt-1)+solve(sum,index-1,cnt);
  return dp[sum][index][cnt]=ans;
}

/*  FUCNTION TEMPLATE ENDS HERE */
int main()
{
   VALHALLA
   int n,a;
   cin>>n>>a;
   for(int i=0;i<n;++i)cin>>arr[i];
    ll ans=0;
   for(int i=1;i<=n;++i)
   {
    memset(dp,-1,sizeof(dp));
    ans+=(solve(i*a,n-1,i));
   }
   cout<<ans<<endl;
}

Measured memory_bytes: 61184
#include <stdio.h>
#include <string.h>

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

    char s[101], p[101];
    scanf("%s%s", s, p);

    int len_s = strlen(s);
    for( i = 0, j = 0, k = i; s[i]; k = ++i, j = 0 ){
        while( s[k] == p[j] ){
            k = (k + 1) % len_s;
            if( p[++j] == '\0' ){ printf("Yes\n"); return 0; }
        }
    }

    printf("No\n");

    return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;
 
const double eps=1e-10;

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


int main()
{
	long long e;
	while(cin>>e,e){
		long long res=10000000;
		for(long long z=0;z*z*z<=e;z++){
			for(long long y=0;z*z*z+y*y<=e;y++){
				long long x=e-z*z*z-y*y;
				res=min(res,x+y+z);
			}
		}
		cout<<res<<endl;
	}

	return 0;
}

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

int main() {
  int n,x,t;
  cin >> n >> x >>t;
  int z;
  
  if((n % x) == 0 ){
    z = (n / x) * t;
  }else{
    z = ((n / x) + 1) * t;
 
  }
     cout << z << endl;
 
}

Measured memory_bytes: 3628
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
void solve(){
    ll n=0,k=0; 
    cin>>n>>k;
    ll c=n/k;
    ll ans=n-c*k;
    cout<<min(ans,abs(ans-k));
}
int main()
{
    fastio;
//    ll t=0;
//    cin>>t;
//    while(t--)
        solve();
    return 0;
}


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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;
 
int main() {
  int d, t, s;
  cin >> d;
  cin >> t;
  cin >> s;
  
  if(d <= t*s){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  
  return 0; 
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<iomanip>
#include<regex>

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

using namespace std;

int main()
{
    long long k,n,tmp,max = 0;
    cin >> k;
    double a,sum;
    a = 1.0 * k/3;
    sum = a*a*a;

    cout << fixed << setprecision(8) << endl;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,n) for(int i = (a); i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define debug_v(v,N) for(int i=0;i<N;i++) { cout << v[i] << " "; } cout << endl;
#define debug_vv(v,H,W) for(int i=0;i<H;i++) { for(int j=0;j<W;j++) { cout << v[i][j] << " "; } cout << endl; }

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

void Main()
{
	int M, D; cin >> M >> D;
	int res = 0;
	REP(i,1,M + 1) {
		REP(j,22,D + 1) {
			int d10 = atoi(to_string(j).substr(0,1).c_str());
			int d1 = atoi(to_string(j).substr(1,1).c_str());
			if (d1 <= 1 || d10 <= 1) continue;
			if (i == d10 * d1) {
				++res;
			}
		}
	}
	cout << res << endl;
}

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


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    if(N*A <= B){
      System.out.println(N*A);
    }else{
      System.out.println(B);
    }
  }
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#include <fstream>
#include <utility>
#include "unistd.h"
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pr;
typedef vector<pr> vpr;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    bool b=1;
    ll n,a;
    cin >> n;
    rep(i,n){
        cin >> a;
        if(a%2) b=0;
    }
    cout << (b?"second\n":"first\n");
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 234567;
char s[MAXN];

int qpow(int x, int p, int P) {
    if (!p) return 1;
    int cur = qpow(x, p / 2, P);
    int ans = (cur * cur) % P;
    if (p % 2) ans = (ans * x) % P;
    return ans;
}

int main() {
    int N, P;
    scanf("%d %d", &N, &P);
    scanf("%s", s);
    map<int, int> mp;
    mp[0] = 1;
    int inv = qpow(10, P - 2, P);
    LL sum = 0, offs = 1, ans = 0;
    for (int i = 0; i < N; i++) {
        int cur = s[i] - '0';
        sum = (sum * 10 + cur) % P;
        int want = (sum * offs) % P;
        ans += mp[want];
        mp[(sum * offs) % P]++;
        offs = (offs * inv) % P;
    }
    if (P == 2 || P == 5) {
        ans = 0;
        for (int i = 0; i < N; i++) {
            if ((s[i] - '0') % P == 0)
                ans += i + 1;
        }
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<unordered_map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<queue>
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
#define mp make_pair
#define pb push_back
 const ll mod = 1000000007;

 int main() {
	int N, D;
	cin >> N >> D;

	vector<vector<int>> P;

	for(int n =0; n < N; n++){
		vector<int> X;
		for(int d=0; d < D; d++){
			int x;
			cin >> x;
			X.push_back(x);
		}
		P.push_back(X);
	}

	int count  = 0;
	for(int i = 0; i < N - 1; i++){
		for(int j = i+1; j < N; j++){
			double s = 0;
			for(int d = 0; d < D; d++){
				s += (P[i][d] - P[j][d]) * (P[i][d] - P[j][d]);
			}
			double rt = sqrt(s);
			if (abs(rt - round(rt)) < 0.000001){
				count++;
			}
		}
	}


	cout << count << endl;

	return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long int ll;
typedef pair<int,int> P;
typedef pair<P,P> PP;
const ll MOD=10000;
const ll INF=1000000010;
const int MAX=100001;
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int main(){
    int a,b;cin>>a>>b;
    bool ff=true;
    int n;cin>>n;
    for(int i=0;i<n;i++){
        int s,f;
        cin>>s>>f;
        if(b<=s||a>=f){
            continue;
        }else{
            ff=false;
        }
    }
    if(ff){
        cout<<0<<endl;
    }else{
        cout<<1<<endl;
    }
    return 0;
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvl vector<vector<ll>>
#define vvi vector<vector<int>>
const int M=100111;
const int inf=1000000007;
const long long INF=1e18;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};
int ddx[8]={1,-1,0,0,1,-1,-1,1},ddy[8]={0,0,1,-1,1,-1,1,-1};


int main() {
	int n;
	ll k,a[M],X=0;
	int num[41]={};
	cin>>n>>k;
	rep(i,0,n){
		cin>>a[i];
		rep(j,0,41)if(a[i]>>j&1)num[j]++;
	}
	if(n%2==0){
		for(int i=40;i>=0;i--){
			if(num[i]<n/2){
				if(pow(2,i)+X<=k)X+=pow(2,i);
			}
		}
	}else{
		for(int i=40;i>=0;i--){
			if(num[i]<=n/2){
				if(pow(2,i)+X<=k)X+=pow(2,i);
			}
		}
	}
	ll ans=0;
	rep(i,0,n)ans+=(X^a[i]);
//	print("X="<<X);
	print(ans);
}

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

const int MOD = 1000000007;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to))
#define sort(a) sort(a.begin(), a.end())
#define reverse(s) reverse(s.begin(), s.end())
#define p(s) cout << (s) << endl

typedef long long ll;
using namespace std;

template<class T>
void load(vector<T> &v, int n) {
  for (int i = 0; i < n; ++i) {
    T t;
    cin >> t;
    v.push_back(t);
  }
}

template<class T>
T max(vector<T> &v) {
  return *max_element(v.begin(), v.end());
}

template<class T>
T min(vector<T> &v) {
  return *min_element(v.begin(), v.end());
}

void py(bool isUpper = false) {
  if (isUpper) {
    p("YES");
  } else {
    p("Yes");
  }
}

void pn(bool isUpper = false) {
  if (isUpper) {
    p("NO");
  } else {
    p("No");
  }
}

int main() {
  int n;
  cin >> n;
  vector<double> v;
  load(v, n);

  int mi = min(v);
  vector<double> w;
  for (int i = 0; i < n; ++i) {
    w.push_back(v[i] - mi);
  }
  sort(w);

  double mean = 0;
  for (int i = 1; i < n; ++i) {
    if (i == 1) {
      mean = (w[i] + w[i - 1]) / 2.0;
    } else {
      mean = (mean + w[i]) / 2.0;
    }
  }
  mean += mi;

  printf("%.6lf", mean);
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define allof(a) a.begin(),a.end()
typedef pair<int, int> pii;
typedef vector< pii > PArray;

int n, m;

void solve() {
	int cnt[110] = { 0 };
	for_(i,0,n) for_(j,0,m) {
		int c; scanf("%d", &c), cnt[j] += c;
	}
	
	PArray vp;
	for_(i,0,m) vp.push_back(pii(cnt[i], -(i + 1)));
	sort(allof(vp));
	
	for_rev(i,m-1,0) {
		if (i > 0) printf("%d ", -vp[i].second);
		else printf("%d\n", -vp[i].second);
	}
}

int main() {
	while (scanf("%d %d", &n, &m), n) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    map<int, int> ma, mb;
    vector<int> cnt[200010];
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]].push_back(i);
        ma[A[i]]++;
    }
    for(int i = 0; i < N; i++) {
        cin >> B[i];
        mb[B[i]]++;
    }
    for(auto v: mb){
        int t = v.second + ma[v.first];
        if(t > N){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    int now = -1, j;
    for(int i = 0; i < N; i++){
        if(now != A[i]) j = 0;
        if(A[i] == B[i]){
            for(; j < N; j++){
                if(A[i] != A[j] && B[j] != A[i]){
                    swap(B[i], B[j]);
                    break;
                }
            }
        }
        now = A[i];
    }
    for(int i = 0; i < N; i++){
        if(i != N - 1) cout << B[i] << ' ';
        else cout << B[i] << endl;
    }
}


Measured memory_bytes: 34408
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define fi first
#define se second
#define ss string
#define ll long long int
#define Endl endl
#define u_b upper_bound
#define rep(i,n)         for(int i=0;i<n;i++)
#define ld long double
#define tc long long t;cin>>t;while(t--)
#define fr(i,a,b)        for(long long int i=a;i<=b;i++)
#define E endl
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define V deque<ll>v;
#define aaste long long int n;cin>>n;long long int a[n];for(long long int i=0;i<n;i++)cin>>a[i];
const ll   mod=            1000000007;
const ll   MOD1=           (int)1e9 + 9;
const ll   MOD2=           998244353;
const ld    pi=             atan2(0, -1);
const ld    eps=            1e-9;
const int   N=                   2e5+5;
 
const int MAXR = 1000005;
ll         tests=          1;
 
using namespace std;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
ll binarySearch(ll l, ll r,ll k)
{
  if (r >= l) {
    ll mid = l + (r - l) / 2;
    if (mid*(mid+1)==k)
      return 1;
    if (mid*(mid+1)>k)
      return binarySearch( l, mid - 1,k);
    return binarySearch(mid + 1, r, k);
  }
  return 0;
}
bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
} 
void swap(ll *p1, ll *p2)
{
   ll temp=*p1;
   *p1=*p2;
   *p2=temp;
}
ll cbratt(ll x)
{
    ll l = 0, r = MAXR;
    while (l != r) {
        ll m = (l + r + 1) / 2;
        if (m * m * m > x)
            r = m - 1;
        else
            l = m;
    }
    return l;
}
int MaxSubArraySumReturn(int a[], int  n) //negative thakle o kaaj korbe in O(n)
{
 
    int sum = 0, best = 0;
   for(ll i=0;i<n;i++)
    {
        sum = max(a[i], a[i] + sum);
        best = max(best, sum);
    }
    return best;
 
}
ll totalDigits(ll n) 
{ 
 
    ll number_of_digits = 0; 
    for (ll i = 1; i <= n; i *= 10) 
        number_of_digits += (n - i + 1); 
  
    return number_of_digits; 
}

int main()
{
  #ifndef ONLINE_JUDGE
    {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        freopen("error.txt", "w", stderr);
    }
#endif
ll n;
cin>>n;
if(n%1000==0)
cout<<0;
else
{
ll t=n/1000;
t=(t+1)*1000;
cout<<t-n;
}
}


Measured memory_bytes: 3636
N, Q = map(int, input().split())
from collections import deque
queue = deque([])

time = 0
for _ in range(N):
    name, t = input().split()
    t = int(t)
    queue.append([name, t])

while queue:
    process = queue.popleft()
    red = min(Q, process[1])
    time += red
    process[1] -= red
    if process[1] == 0:
        print(process[0], time)
    else:
        queue.append(process)



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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
	
	int N;
	string S, T;
	
	cin >> N >> S >> T;
	
	rep(i, N)
	cout << S[i] << T[i];
	
	return 0;
}

Measured memory_bytes: 256
//幅優先探索によるトポロジカルソート
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1 << 29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s) // 幅優先探索
{
    queue<int> q;
    q.push(s);
    while( !q.empty() )
    {
        int u = q.front();
        q.pop();
        out.push_back(u);
        for (int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            indeg[v]--;
            if (indeg[v] == 0 && !V[v])
            {
                V[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort()
{
    for (int i = 0; i < N; i++)
    {
        indeg[i] = 0;
    }

    for (int u = 0; u < N; u++)
    {
        for (int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            indeg[v]++;
        }
    }

    for (int u = 0; u < N; u++)
    {
        if (indeg[u] == 0 && !V[u]) bfs(u);
    }

    for ( list<int>::iterator it = out.begin(); it != out.end(); it++) //Listの要素のポインタを先頭から末尾まで走らせる
    {
        cout << *it << endl;
    }
}

int main()
{
    int s, t, M;

    cin >> N >> M;

    for (int i = 0; i < N; i++) V[i] = false;

    for (int i = 0; i < M; i++)
    {
        cin >> s >> t;
        G[s].push_back(t);
    }

    tsort();

    return 0;
}


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

int a, b;

int main() {
    cin >> a >> b;

    if ((a / 3 > 0 && a % 3 == 0) || (b / 3 > 0 && b % 3 == 0) || ((a + b) / 3 > 0 && (a + b) % 3 == 0)) {
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }

    return 0;
}

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

int main() {
 int N;
 cin >> N;
 vector<int> Cards(N);
  for(int i = 0; i < N; i++){
    cin >> Cards.at(i);
  }
  sort(Cards.begin(),Cards.end());
  reverse(Cards.begin(),Cards.end());
  int Alice, Bob;
  for(int i = 0; i < N; i++){
    Alice = Alice + Cards.at(i);
    i++;
    if(i == N){
      break;
    }
    Bob = Bob + Cards.at(i);
  }
 int diff;
  diff = Alice - Bob;
  cout << diff << endl;
}


Measured memory_bytes: 256
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 110000;

int n,L,T;
ll c;
ll p[maxn];

int main()
{
	scanf("%d%d%d",&n,&L,&T);
	c=0;
	for(int i=1;i<=n;i++)
	{
		int x,w; scanf("%d%d",&x,&w);
		if(w==1) p[i]=((ll)x+T)%L,c+=T/L+(T%L+x>=L?1:0);
		else p[i]=((ll)x-T%L+L)%L,c-=T/L+(x-T%L<0?1:0);
	}
	sort(p+1,p+n+1); c=(c%n+n)%n;
	c++;
	for(int i=c;i<=n;i++) printf("%lld\n",p[i]);
	for(int i=1;i<c;i++) printf("%lld\n",p[i]);
	
	return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    int ans;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        ans += 2 * min(x,K - x);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256