akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

int N;
vector<int> a;

void input() {
	cin >> N;
	a.resize(N);
	for (int i = 0; i < N; ++i)
		cin >> a[i];
}

void solve() {
	input();
	// 木の直径を求める.
	int d = 0;
	for (auto ai : a)
		d = max(d, ai);
	// 各値がa中に何回出現するかを求める
	map<int, int> cnt;
	for (auto ai : a)
		++cnt[ai];
	// 直径中の頂点をremove
	for (int i = d; i >= (d + 1) / 2; --i) {
		if (d % 2 == 0 && i == d / 2)
			--cnt[i];
		else
			cnt[i] -= 2;
		if (cnt[i] < 0) {
			cout << "Impossible" << endl;
			return;
		}
	}
	for (auto& e : cnt) {
		if (e.second > 0 && e.first <= (d + 1) / 2) {
			cout << "Impossible" << endl;
			return;
		}
	}
	cout << "Possible" << endl;
	return;
}

int main() {
	solve();
}

Measured memory_bytes: 256
if __name__ == '__main__':

	INF = 10**18
	
	n = int(input())
	A = list(map(int,input().split()))

	if 0 in A:
		print(0)
		exit()

	ans = 1
	flg = False

	for i in range(n):
		ans = ans * A[i]
		if ans > INF:
			ans = -1
			break

	print(ans)


Measured memory_bytes: 21576
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=Math.max(a+b, a-b);
		int d=Math.max(c,a*b);
		System.out.println(d);
	}
}


Measured memory_bytes: 23764
import java.util.*;

class Main {
	Scanner sc;
	int N;
	Map<String, Integer> map;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		map = new TreeMap<>();
		int max = -1;
		for (int i = 0; i < N; i++) {
			String s = sc.next();
			int c = map.getOrDefault(s, 0) + 1;
			max = Math.max(max, c);
			map.put(s, c);
		}
		for (String s : map.keySet()) {
			if (map.get(s) == max) System.out.println(s);
		}
	}

	public static void main(String[] args) {
		new Main().calc();
	}
}


Measured memory_bytes: 78116
#include<algorithm>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
//    cout << fixed << setprecision(10);
    int N;
    long long K;
    cin >> N >> K;
    vector<int> A(N);
    map<int, int> paths;
    
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    // 2 3 4 2
    // 0 1 2 3
    // 0 1 2 3
    //   0?0?0?
    int steps = 0;
    int position = 0;
    while (true) {
        int nextPosition = A[position] - 1;
        if (paths[nextPosition] != 0) {
            int mod = steps + 1 - paths[nextPosition];
            K -= paths[nextPosition];
            K %= (long long)mod;
            while ( K > 0 ) {
                nextPosition = A[nextPosition] - 1;
                K--;
            }
            cout << nextPosition + 1;
            return 0;
        } else {
            steps++;
            paths[nextPosition] = steps;
            position = nextPosition;
        }
        if ((long long)steps == K) {
            cout << nextPosition + 1;
            return 0;
        }
    }

    return 0;
}

Measured memory_bytes: 11320
let for_range s e step f =
  let rec loop i =
    if i <= e then begin f i;loop (i + step) end
  in loop s;;

let sieve num =
  let p = Array.make (num+1) 1 in
  let rec loop i m =
    if i*i < num then
      begin
        if p.(i) = 1 then for_range (i*i) num (i*2) (fun x -> p.(x) <- 0);
        loop (i+m) (if m = 2 then 4 else 2)
      end
  in
  p.(0) <- 0; p.(1)<-(0);
  for_range 4 num 2 (fun x -> p.(x) <- 0);
  for_range 9 num 6 (fun x -> p.(x) <- 0);
  loop 5 2;
  for i = 3 to num-1 do
    p.(i) <- p.(i) + p.(i-1);
  done;
  p
;;

let _ =
  let p = sieve 1000000 in
  let rec read () =
    try let n = read_int () in
        Printf.printf "%d\n" p.(n);
        read ()
    with End_of_file -> ()
  in read ()
;;

Measured memory_bytes: 10336
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <map>
using namespace std;
const int maxn=4e6+5;
int tag[maxn];
int b[maxn],c[maxn];
vector<int> adj[maxn];
int n,len,m;
int num[maxn],a[maxn];
int d[maxn];
int s[maxn];
map<int,int> mp[maxn];
vector<pair<int,int> > mem;
inline bool cmp1(pair<int,int> a1,pair<int,int> b1){
	return a1.first<b1.first;
}
inline void dfs(int u){
	for (int i=0;i<adj[u].size();i++){
		int v=adj[u][i];
		s[v]=(s[v]+s[u])%2;
		if (v==5){
			cout<<"%%%%%%%%%%%print cur 5 "<<u<<endl;
		}
		dfs(v);
	}
}
inline void topo(){
	queue<int> q;
	for (int i=1;i<=m;i++){
		if (d[i]==0){
			q.push(i);
		}
	}
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for (int i=0;i<adj[u].size();i++){
			int v=adj[u][i];
			s[v]=(s[v]+s[u])%2;
			d[v]--;
			if (d[v]==0) q.push(v);
		}
	}
}
int main(){
	cin>>n>>m;
	int sm=m;
	for (int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		num[++len]=a[i];
	}
	sort(num+1,num+len+1);
	for (int i=1;i<=n;i++){
		a[i]=lower_bound(num+1,num+len+1,a[i])-num;
		c[a[i]]=b[i];
	}
	for (int i=1;i<=m;i++){
		int l,r;
		scanf("%d%d",&l,&r);
		if (l>num[len]||r<num[1]) continue;
		l=max(l,num[1]);
		r=min(r,num[len]);
		l=lower_bound(num+1,num+len+1,l)-num;
		r=upper_bound(num+1,num+len+1,r)-num-1;
		if (l>r) continue;
		mp[l][r]=i;
	}
	bool flg=1;
	int curans=0;
	for (int i=1;i<=len;i++){
		curans=(curans+tag[i])%2;
		for (map<int,int>::iterator it=mp[i].begin();it!=mp[i].end();it++){
			mem.push_back(make_pair(it->first,it->second));
		}
		int tp=(curans+c[i])%2;
		if (mem.size()==0&&tp==1){
			flg=0;
			break;
		}
		if (mem.size()==0){
			continue;
		}
		sort(mem.begin(),mem.end(),cmp1);
		if (tp==1){
			tag[mem[0].first+1]=(tag[mem[0].first+1]+1)%2;
			curans=(curans+1)%2;
			s[mem[0].second]=1;
		}
		for (int j=1;j<mem.size();j++){
			int r1=mem[j-1].first;
			int r2=mem[j].first;
			if (r1==r2) continue;
			m++;
			mp[r1+1][r2]=m;
			adj[m].push_back(mem[j-1].second);
			adj[m].push_back(mem[j].second);
			d[mem[j-1].second]++;
			d[mem[j].second]++;
		}
		mem.clear();
	}
	if (flg==0){
		cout<<"-1"<<endl;
		return 0;
	}
	topo();
	int cnt=0;
	for (int i=1;i<=sm;i++){
		if (s[i]) cnt++;
	}
	cout<<cnt<<endl;
	for (int i=1;i<=sm;i++){
		if (s[i]) printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 389300
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

    int a, b;
    cin >> a >> b;

    int color[100][100];
    fill(color[0], color[49]+100, 0); // black
    fill(color[50], color[99]+100, 1); // white

    for (int i = 0; i < a-1; i++) {
        color[i/25*2][i%25*2] = 1;
    }

    for (int i = 0; i < b-1; i++) {
        color[99-i/25*2][i%25*2] = 0;
    }

    cout << "100 100\n";
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            if (color[i][j] == 0) {
                cout << '#';
            } else {
                cout << '.';
            }
        }
        cout << "\n";
    }

    return 0;
}

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

int main(){
  int x;
  cin >> x;
  
  int max=1;
  rep(i,x+1){
    rep(b,(x+1)/2){
      for(int p=2;p<10;p++){
        if(i==pow(b,p) && i > max){
          max = i;
        }
      }
    }
  }
  
  cout << max << endl;
  
  return 0;
}


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

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

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second　   //pairの二つ目の要素

int main(){
    double a,b,h,m,hh;
    double pai=acos(-1);
    cin>>a>>b>>h>>m;
    hh=h+m/60;
    double ad=hh/12.*2.*pai;
    double bd=hh*2.*pai;
    double ax,ay,bx,by;
    ax=a*sin(ad);
    bx=b*sin(bd);
    ay=a*cos(ad);
    by=b*cos(bd);
    double ans=sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));
    cout<<std::fixed;
    cout<<setprecision(10)<<ans<<endl;
    return 0;
}

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

int main(){long N, K;
cin >> N >> K;
long i = 1; long cnt = 0;
while(i < K && N > cnt){
    i *= 2;
    cnt++;
}


long ans = i + K * (N - cnt);

cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

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

  if ('a' <= a && a <= 'z') {
    cout << 'a' << endl;
  } else {
    cout << 'A' << endl;
  }
}


Measured memory_bytes: 3616
H, W = map(int, input().split())


def calc(h, w):
    if h % 3 == 0 or w % 3 == 0:
        return 0
    num1, num2 = float("inf"), float("inf")
    for i in range(1, h):
        a = i * w
        b = (h - i) * (w // 2)
        c = (h - i) * (w - w // 2)
        ma = max(a, max(b, c))
        mi = min(a, min(b, c))
        num1 = min(num1, ma - mi)

    for i in range(1, h):
        a = i * w
        p = (h - (h - i) // 2) * w
        q = (h - (h - i + 1) // 2) * w
        mp = max(a, max(p, q))
        mq = min(a, min(p, q))
        num2 = min(num2, mp - mq)

    return min(num1, num2)


print(min(calc(H, W), calc(W, H)))

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
using namespace std;


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

int main(){
    int N, X, T;
    cin >> N >> X >> T;

    if(N%X ==0){
        cout << (N/X)*T << endl;
    }
    else{
        cout << ((N/X)+1)*T << endl;
    }
    return 0;
}

Measured memory_bytes: 3192
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      s: chars,
    }
    for i in 1..s.len() {
        if s[i] == s[i-1] {
            return println!("{} {}", i, i+1);
        }
        if i >= 2 {
            if s[i] == s[i-2] {
                return println!("{} {}", i-1, i+1);
            }
        }
    }
    println!("{} {}", -1, -1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
long long lopow(ll a, long long n) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a ;
        a = a * a ;
        n >>= 1;
    }
    return res;
}

//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;

int main(){
  ll N,M;cin>>N>>M;
  vl A(M),B(M);
  rep(i,M)cin>>A[i]>>B[i];
  vvl u(N+1);
  rep(i,M){
    u[A[i]].push_back(B[i]);
    u[B[i]].push_back(A[i]);
  }
  vl ans(N+1);
  rep(i,N+1){
    ans[i]=0;
  }
  vb seen(N+1);
  rep(i,N+1)seen[i]=false;
  queue<ll> q;
  q.push(1);
  ans[1]=100;
  while(!q.empty()){
    ll qf =q.front();
    q.pop();
    
    if(!seen[qf]){
      rep(j,u[qf].size()){
        if(ans[u[qf][j]]==0){
          ans[u[qf][j]]=qf;
          q.push(u[qf][j]);
        }
      }
    }
   
    seen[qf]=true;
  }
  bool zero=true;
  for(int i=2;i<N;i++){
    if(ans[i]==0)zero =false;
  }
  
  if(zero){
    cout<<"Yes"<<endl;
    for(int i=2;i<N+1;i++)cout<<ans[i]<<endl;
  }
  else cout<<"No"<<endl;
}


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

long long gcd(long long n,long long m){
  if(m==0)return n;
  else return gcd(m,n%m);
}

long long f(long long x,long long n,long long m){
  return x-x/n-x/m+x/(n*m/gcd(n,m));
}

int main() {
  long long a,b;
  long long c,d;
  cin >> a >> b >> c >> d;
  cout << f(b,c,d)-f(a-1,c,d) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int maxtime( int x ){
  return (x + 9) / 10 * 10;
}
int retime( int x ){
  return maxtime(x) - x;
}
int main( void ){
  int time[6];
  int temptime[6];
  int bottomtime;
  int i;
  int sum=0;

  for(i=0;i<5;i++){
    scanf("%d", &time[i]);
  }
  for(i=0;i<5;i++){
    sum += maxtime(time[i]);
  }
  for(i=0;i<5;i++){
    temptime[i] = retime(time[i]);
  }
  bottomtime = temptime[0];
  for(i=0;i<5;i++){
    if(bottomtime<temptime[i]){
      bottomtime = temptime[i];
    }
  }
  sum -= bottomtime;
  printf("%d\n", sum);
  return 0;
}


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

using namespace std;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int ans = 0;
    int cnt = 0;
    for(int i = 0; i < s.length(); i++){
        if(s[i] == 'R'){
            cnt++;
            ans = max(cnt, ans);
        }else{
            cnt = 0;
        }
    }
    cout << ans << endl;
}

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

int n, a[101], c = 0;

int main() {
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	for (int i = 1; i <= n; ++i) {
		if (i % 2 && a[i] % 2)
			++c;
	}

	cout << c << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<math.h>
int main(){
  int x,y;
  scanf("%d",&x);
  int a[x];
  int i,j;
  y=x;
  for(i=0;i<x;i++){
    scanf("%d",&a[i]);
    for(j=2;j<=sqrt(a[i]);++j){
      if(a[i]%j==0){
	y--;
	break;
      }
    }
  }
  printf("%d\n",y);
  return 0;
}



Measured memory_bytes: 2104
module IntMap = Map.Make(struct type t = int let compare = compare end)
let split_string ?(pattern="") = Str.split @@ Str.regexp pattern

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string ~pattern:" " |> List.map int_of_string
let q = Scanf.sscanf (read_line ()) "%d" @@ fun q -> q
let bc = Array.init q @@ fun _ -> Scanf.sscanf (read_line ()) "%d %d" @@ fun b c -> (b, c)

let find i map = try IntMap.find i map with Not_found -> 0

let map = List.fold_left 
    (fun map key -> IntMap.add key (find key map + 1) map)
    IntMap.empty a

let sum = IntMap.fold (fun key value sum -> sum + key * value) map 0

let _ = Array.fold_left (fun (map, sum) (b, c) ->
    let b_cnt = find b map in
    let next = sum + b_cnt * (c - b) in
    Printf.printf "%d\n" next;
    (map |> IntMap.remove b |> IntMap.add c (find c map + b_cnt), next)
  ) (map, sum) bc

Measured memory_bytes: 31444
/*

 ________      
|\   ____\         _____              _          ___   ___   
\ \  \___|_ ___  _|_   _|__ _   _ ___| |_   _   / _  V  _ \ 
 \ \_____  V _ \/ __; |/ _ \ | | / __; | | | | | |_| | |_| |
  \|____|\  \ _/| | | | |_|  |_| \__ \ | |_| | |  _  |  _  |
    ____\_\  \_||_|_| |\___/\__,_|___/_|\__, |0|_| |_|_| |_|
   |\_________\   |_____|               {___/                
   \|_________|                

*/

#include <bits/stdc++.h>
using namespace std;
#define sz(x) (ll)(x).size()
#define trav(x) for(auto& it: x)
#define all(x) x.begin(), x.end()
#define stp fixed<<setprecision(20)
#define tc ll tt; cin>>tt; while(tt--)
#define For(i, st, en) for(ll i=st; i<en; i++)
#define rFor(i, st, en) for(ll i=st; i>=en; i--)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define printv(x) For(i, 0, sz(x)){cout<<x[i]<<" ";} cout<<endl;  
#define print2v(x) For(i, 0, sz(x)){For(j, 0, sz(x[i])){cout<<x[i][j]<<" ";} cout<<endl;}
#define scan2v(x,n,m) For(i, 0, n){vi tp(m,0);For(j, 0, m){cin>>tp[j];}x.pb(tp);}
#define scanv(x,n) For(i, 0, n){cin>>tttt; x.pb(tttt);}
#define ll long long
#define int long long
#define F first
#define S second
#define pb push_back
#define po pop_back
#define mp make_pair
#define ss substr
typedef deque<int> di;
typedef vector<int> vi; 
typedef pair<int, int> pii;
typedef vector<vi> vvi;
typedef vector<pii> vpi;
typedef map <int, int> mii;
typedef priority_queue <int> pq;
#define endl '\n'   
#define MAXN 300005
#define MOD 1000000007  
#define INF 1000000000000000007
#define bitc __builtin_popcountll

int begtime = clock(); ll tttt;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>

#define end_routine() cout << "\n\nTime elapsed: " << (double)(clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n";

void splitx(string s, char c, vector<string> &v){
    int i=0, j;
    while(i<sz(s)){
        j=i; string temp;
        while(j<sz(s) && s[j]!=c){temp+=s[j]; j++;}
        v.pb(temp); i=j+1; }}
struct TreeNode { int val; TreeNode *left; TreeNode *right; 
		TreeNode(int x) : val(x), left(NULL), right(NULL) {} };


signed main()
{   
	int n;cin>>n;
	map<string,int> m;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		m[s]++;
	}
	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;

	
	
   return 0;
}


Measured memory_bytes: 3592
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ld = long double;

char s[30010];
int n;
vector<int> pos[10];

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(6);
	cout << fixed;
	
	cin >> n >> s;
	for (int i = 0; i < n; ++i)
		pos[s[i] - '0'].push_back(i);
	
	int ans = 0;

	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			for (int k = 0; k < 10; ++k) {
				if (pos[i].size() == 0)
					continue;
				int temp, p;
				temp = pos[i][0];
				p = lower_bound(pos[j].begin(), pos[j].end(), temp + 1) - pos[j].begin();
				if (p == pos[j].size())
					continue;
				temp = pos[j][p];
				p = lower_bound(pos[k].begin(), pos[k].end(), temp + 1) - pos[k].begin();
				if (p == pos[k].size())
					continue;
				++ans;
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 512
import itertools
S = input()
for x in itertools.product(["+", "-"],repeat=3):
    res = ""
    for s, p in zip(S, x):
        res += s + p
    res += S[-1]
    if eval(res) == 7:
        ans = res + "=7"
        print(ans)
        exit(0)


Measured memory_bytes: 3060
import sys

def divisor(n):
    i = 1
    l = []
    while i * i <= n:
        if n%i == 0:
            l.append(i)
            l.append(n//i)
        i += 1
    l.sort()
    return l

stdin = sys.stdin

ni = lambda: int(ns())
ns = lambda: stdin.readline()

N = ni()
ans = 0
if N > 1:
    div = divisor(N)
    #print(div, div[len(div)//2 - 1])
    if len(div) > 1:
        i = div[len(div)//2 - 1] - 1
        j = (N // (div[(len(div)//2) - 1]))  - 1
        ans = i + j
    else:
        ans = 1
elif N == 1:
    ans = 0
else:
    ans = 1

print(ans)

Measured memory_bytes: 3276
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

double minkowski(int* x, int* y, int n, int p){
	double d = 0;

	for (int i = 0; i < n; i++){
		d += pow(abs(x[i] - y[i]), p);
	}
	return pow(d, 1 / (double)p);
}

double chebyshev(int* x, int* y, int n){
	double d = -1.0;

	for (int i = 0; i < n; i++){
		if (d < abs(x[i] - y[i])) d = abs(x[i] - y[i]);
	}

	return d;
}

int main() {
	int n;
	int x[100], y[100];

	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> x[i];
	}
	for(int i = 0; i < n; i++){
		cin >> y[i];
	}

	cout << fixed << setprecision(5) << minkowski(x, y, n, 1) << endl;
	cout << fixed << setprecision(5) << minkowski(x, y, n, 2) << endl;
	cout << fixed << setprecision(5) << minkowski(x, y, n, 3) << endl;
	cout << fixed << setprecision(5) << chebyshev(x, y, n) << endl;

	return 0;
}


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

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

    int n; cin >> n;
    vector<li> a(n); for (int i=0; i<n; i++) cin >> a[i];

    vector<li> lm(n,0);
    vector<li> rm(n,0);

    for (int i=1; i<n; i++) lm[i] = max(lm[i-1], a[i-1]);
    for (int i=n-2; i>=0; i--) rm[i] = max(rm[i+1], a[i+1]);

    for (int i=0; i<n; i++) cout << max(rm[i],lm[i]) << "\n";

    return 0;

}

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll a, b, n;
	cin>>a>>b>>n;
	cout<<(a*min(b - 1, n)/b)<<endl;

	return 0;
}

Measured memory_bytes: 3644
n, t = map(int, input().split(" "))
ct = []
for i in range(n):
    c1, t1 = map(int, input().split(" "))
    ct.append((c1, t1))

res = "TLE"
cts = sorted(ct)
for i in cts:
    if i[1] > t:
        pass
    else:
        res = i[0]
        break
print(res)


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

int main(void){
  char s[11],t[11],u[11];
  int a,b;
  
  scanf("%10s %10s", s, t);
  scanf("%d %d", &a, &b);
  scanf("%10s", u);
  
  if(strcmp(s,u) == 0) a--;
  else b--;
  
  printf("%d %d", a, b);
  
  return 0; 
}

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

#define IOS std::cin.tie(0);std::ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>;

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 55;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

//----------------------Global-------------------------//

signed main(){
    IOS;
    CIN(N);
    map<ll,ll> mp;
    ll ans=0;
    RepS(i,1,N){
        CIN(a);
        ans+=mp[i-a];
        mp[i+a]++;
    }
    COUT(ans);

    return 0;
}

Measured memory_bytes: 26212
import java.util.Scanner;

class Main {
    public static void main (String[] args) {
        int num, i=1;
        Scanner sc = new Scanner(System.in);
        while(true) {
            num = sc.nextInt();
            if (num == 0) break;
            System.out.println("Case " + i + ": " + num);
            i++;
        }
    }
}


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

int A[200005];

int main(){
    int N;
    scanf("%d", &N);

    for(int i = 0; i < N; i ++){
        scanf("%d", &A[i]);
    }
    sort(A, A+N, greater<int>());

    long long ans = 0;
    for(int i = 1; i <= N-1; i ++){
        ans += A[i>>1];
    }

    printf("%lld", ans);
    return 0;
}


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

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int i=1;
	while(a>0 && c>0){
	    if(i&1){
	        c-=b;
	    }
	    else{
	        a-=d;
	    }
	    i++;
	}
	if(i%2==0){
	    cout<<"Yes\n";
	}
	else{
	    cout<<"No\n";
	}
	
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a[7]={1,3,5,7,8,10,12};
	int b[4]={4,6,9,11};
	int c[1]={2};
	int x,y,i,j;
	int flag=0;
	cin>>x>>y;
	for(i=0;i<7;i++){
		for(j=i;j<7;j++){
			if(x==a[i]&&y==a[j]){
			flag=1;
			break;
			}
		}		
	}
	for(i=0;i<4;i++){
		for(j=i;j<4;j++){
			if(x==b[i]&&y==b[j]){
			flag=1;
			break;
			}
		}	
	}
	if(flag==1) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
//#include<algorithm>
#include<string>
using namespace std;
int main(){
  string s[100000];
  string a;
  int d[100000];
  int b;
  int count = 0;
  while(cin>>a>>b){
    s[count] = a;
    d[count] = b;
    count++;
  }
  for(int i=0;i<count;i++){
    for(int j=count-2;j>=i;j--){
      if(s[j]>s[j+1]){
	string mem = s[j];
	s[j] = s[j+1];
	s[j+1] = mem;
	int me = d[j];
	d[j] = d[j+1];
	d[j+1] = me;
      }
      else if(s[j]==s[j+1]&&d[j]>d[j+1]){
	string me = s[j];
	s[j] = s[j+1];
	s[j+1] = me;
	int mem = d[j];
	d[j] = d[j+1];
	d[j+1] = mem;
      }
    }
  }
  cout << s[0] << endl << d[0];
  for(int i=1;i<count;i++){
    if(s[i]==s[i-1]) cout << ' ' << d[i];
    else{
      cout << endl;
      cout << s[i] << endl << d[i];
    }
  }
  cout << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int a, b;
  cin >> a >> b;
  int cnt = 0;
  cout  << 100 << " " << 100 << endl;
  for(int i=0; i<49; i++){
    for(int j=0; j<100; j++){
      if(i%2==0 && j%2==0 && cnt<a-1){
        cout << ".";
        cnt++;
      }else{
        cout << "#";
      }
    }
    cout << endl;
  }
  for(int j=0; j<100; j++){
    cout << "#";
  }
  cout << endl;
  for(int j=0; j<100; j++){
    cout << ".";
  }
  cout << endl;
  cnt = 0;
  for(int i=0; i<49; i++){
    for(int j=0; j<100; j++){
      if(i%2==0 && j%2==0 && cnt<b-1){
        cout << "#";
        cnt++;
      }else{
        cout << ".";
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
"use strict"

const arg_str = require('fs').readFileSync('/dev/stdin', 'UTF-8')
const args_lines = arg_str.split('\n')
const N = args_lines[0]
const A = args_lines[1].split(' ')

let result = (new Array(N)).fill(0)

A.forEach((item, index)=>{
    result[item-1] = index
})

console.log(result.map(x=>x+1).join(' '))

Measured memory_bytes: 36452
# coding: utf-8
import re
import bisect
from datetime import datetime as dt
import math
n, k = map(int, raw_input().split())
X = []
i = 1
while i <= n:
    x = max(math.ceil(math.log((float(k) / float(i)), 2)), 0)
    X.append(2 ** (-int(x)))
    i += 1
print sum(X) * n ** (-1)


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n, k;
  cin >> n >> k;
  if ((n - 1) * (n - 2) / 2 < k)
  {
    cout << -1 << endl;
    return 0;
  }
  cout << n - 1 + (n - 1) * (n - 2) / 2 - k << endl;
  for (i64 i = 2; i <= n; i++)
    cout << 1 << " " << i << endl;
  i64 cnt = 0;
  for (i64 i = 2; i <= n; i++)
    for (i64 j = i + 1; j <= n; j++)
    {
      if (cnt == (n - 1) * (n - 2) / 2 - k)
        return 0;
      cout << i << " " << j << endl;
      cnt++;
    }
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
#N, K = map(int, input().split())
# 文字列の入力
#s = input()
#開業されたN個要素を受け付ける
input_list = list(map(int, input().split()))

for i in range(5):
    if input_list[i] == 0:
        print(i+1)


Measured memory_bytes: 9156
n = int(input())
num_l = sorted(map(int, input().split()))

result = 0

def judge(nums, result):
    l = []
    index = 0
    false = 'False'
    for num in nums:
        if num % 2 == 0:
            l.append(num)
            index += 1
            if index == len(nums):
                result += 1
                return l, result
        else:
            return false, result

def divide(nums):
    l = []
    for num in nums:
        a = num / 2
        l.append(a)
    return l


j_l, result = judge(num_l, result)

while True:
    if j_l == 'False':
        print(result)
        break
    else:
        re_l = divide(j_l)
        j_l, result = judge(re_l, result)

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

using namespace std;

int main(void) {
  int h, w;
  cin >> h >> w;

  string s[26][26];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> s[i][j];
    }
  }

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (s[i][j] != "snuke") continue;
      printf("%c%d\n", j + 'A', i + 1);
    }
  }

  return 0;
}

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

int cost[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};

void func(string &a, string b) {
	if (a == "!") a = b;
	else if (a.size() < b.size()) a = b;
	else if (a.size() == b.size() && a < b) a = b;
}

int main() {
	int n, m;
	cin >> n >> m;
	int a[m];
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	string dp[20000];
	for (int i = 0; i < 20000; i++) {
		dp[i] = "!";
	}
	dp[0] = "";
	for (int i = 0; i <= n; i++) {
		if (dp[i] == "!") continue;
		for (int j = 0; j < m; j++) {
			string b = dp[i] + (char)('0' + a[j]);
			func(dp[i + cost[a[j] - 1]], b);
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 45440
#include <bits/stdc++.h>
using namespace std;using ll=int_fast64_t;using ld=long double;using pll=pair<ll,ll>;using pld=pair<ld,ld>;
const ll INF=1LL<<60;void solve();int main(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(10);solve();}
#define fi first
#define se second
#define SELECTOR(_1,_2,_3,_4,SELECT,...) SELECT
#define rep(...) SELECTOR(__VA_ARGS__,_rep2,_rep1,_rep0)(__VA_ARGS__)
#define _rep0(i,n) for(ll i=0;i<n;++i)
#define _rep1(i,k,n) for(ll i=k;i<n;++i)
#define _rep2(i,k,n,d) for(ll i=k;d!=0&&d>0?i<n:i>n;i+=d)
template<class T> vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<class... Ts> auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<class T> inline bool chmax(T &a,const T &b){if(a<b){a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a,const T &b){if(a>b){a=b; return 1;} return 0;}
template<class T> void contout(const T &v){for(auto it=v.begin();it!=v.end();++it,cout<<(it!=v.end()?" ":"\n"))cout<<*it;}

void solve(){
  ll n,k; cin>>n>>k;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  vector<ll> dp(2,0);
  vector<ll> cnt(40);
  rep(d,40)rep(i,n){
    cnt[d]+=(a[i]>>d)&1;
  }

  function<ll(ll,ll,ll)> dfs=[&](ll d,ll v,ll lt){
    if(d<0) return v;
    ll res=-INF;
    if(lt){
      chmax(res,dfs(d-1,v+max(cnt[d],n-cnt[d])*((ll)1<<d),1));
      return res;
    }
    if((k>>d)&1){
      chmax(res,dfs(d-1,v+cnt[d]*((ll)1<<d),1));
      chmax(res,dfs(d-1,v+(n-cnt[d])*((ll)1<<d),0));
    } else {
      chmax(res,dfs(d-1,v+cnt[d]*((ll)1<<d),0));
    }
    return res;
  };
  cout<<dfs(39,0,0)<<"\n";
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N, digit = 0;
	string S = "";
	cin >> N;
	if (N == 0) S = '0';
	else {
		while (N != 0) {
			if (abs(N) % 2 == 1) {
				S += '1';
				N -= pow(-1, digit);
			}
			else S += '0';
			N /= 2;
			digit++;
		}
    }
	reverse(S.begin(), S.end());
	cout << S;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;

int main() {
    ll n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) {
        cin >> a[i];
        --a[i];
    }

    vector<int> per(1);
    vector<bool> flag(n);
    int now = 0;
    int start_t = 0;
    flag[0] = true;
    rep(i, n) {
        now = a[now];
        if (flag[now]) {
            start_t = now;
            break;
        }
        per.push_back(now);
        flag[now] = true;
    }

    int start = 0;
    rep(i, per.size()) {
        if (per[i] == start_t)
            start = i;
    }

    vector<int> roop;
    for (int i = start; i < per.size(); ++i) {
        roop.push_back(per[i]);
    }

    if (k <= start) {
        cout << per[k] + 1 << endl;
    } else {
        k -= start;
        k %= roop.size();
        cout << roop[k] + 1 << endl;
    }

    return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

ll gcd(ll x, ll y)
{
  if (x % y == 0)
  {
    return y;
  }
  return gcd(y, x % y);
}

ll sum(ll i){
  return i / 10000 + i / 1000 % 10 + i / 100 % 10 + i / 10 % 10 + i % 10;
}

int main()
{
  ll N, A, B;
  cin >> N >> A >> B;
  // ll A[N];
  // for (int i = 0; i < N; ++i){
  //   cin >> A[i];
  // }

  ll ans = 0;
  for (int i = 0; i <= N; ++i)
  {
    if (A <= sum(i) && sum(i) <= B)
    {
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
    int n, b, f, r, v, i, j, k, rooms[4][3][10];
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++) {
                rooms[i][j][k] = 0;
            }
        }
    }
    scanf("%d", &n);
    while (n--) {
        scanf("%d%d%d%d", &b, &f, &r, &v);
        rooms[b - 1][f - 1][r - 1] += v;
    }
    for (i = 0; i < 4; i++) {
        for (j = 0; j < 3; j++) {
            for (k = 0; k < 10; k++) {
                printf(" %d", rooms[i][j][k]);
            }
            printf("\n");
        }
        if (i < 3) {
            printf("####################\n");
        }
    }
    return 0;
}

Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : " "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int H,W;
    cin>>H>>W;
    int N;
    cin>>N;
    vector<int> a(N);
    cin>>a;

    vector<vector<int>> c(H,vector<int>(W,-1));
    int w=1;//3
    int y=0,x=0;
    REP(i,N) {
        REP(k,a[i]) {
            c[y][x]=i+1;
            if(w==1 && x==W-1) y++,w=3;
            else if(w==3 && x==0) y++,w=1;
            else x+=DX[w];
        }
    }
    REP(i,H) {
        cout<<c[i]<<endl;
    }
    return 0;
}


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

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    for(int i = 0;i < n;i++){
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());
    for(int i = 0;i < n;i++)cout << s.at(i);
    cout << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n;
		while((n=sc.nextInt())!=0){
			int[] a=new int[n];
			for(int i=0;i<n;i++){
				a[i]=sc.nextInt();
			}
			Arrays.sort(a);
			long sum=0;
			long add=0;
			for(int i=1;i<n;i++){
				add+=a[i-1];
				sum+=add;
			}
			System.out.println(sum);
		}
	}
}

Measured memory_bytes: 45096
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = 1234567;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	ll n,a;
	cin>>n>>a;
	ll x;
	vector<vector<ll>> dp,dp2;
	rep(i,n*50+1){
		dp.push_back(vector<ll>());
		dp2.push_back(vector<ll>());
		rep(j, n+1){
			dp[i].push_back(0);
			dp2[i].push_back(0);
		}
	}
	dp[0][0] = 1;
	dp2[0][1] = 1;
	rep(hoge,n){
		cin>>x;
		reps(i, n*50){
			reps(j, n){
				if(i-x<0) continue;
				dp2[i][j] += dp[i-x][j-1];
			}
		}
		reps(i,n*50){
			reps(j,n){
				dp[i][j] = dp2[i][j];
			}
		}
	}
	ll ans = 0;
	reps(i,n){
		ans += dp[i*a][i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2944
#include<iostream>

using namespace std;

int main(){
	int money,a[4],b[4];
	bool f=false;
	for(;cin>>money,money!=0;){
		if(f)cout<<endl;
		f=true;
		cin >> a[0] >> a[1] >> a[2] >> a[3];
		money=-money+a[0]*10+a[1]*50+a[2]*100+a[3]*500;
		b[3]=money/500;
		money-=b[3]*500;
		b[2]=money/100;
		money-=b[2]*100;
		b[1]=money/50;
		money-=b[1]*50;
		b[0]=money/10;
		if(a[0]>b[0])cout<<"10 "<<a[0]-b[0]<<endl;
		if(a[1]>b[1])cout<<"50 "<<a[1]-b[1]<<endl;
		if(a[2]>b[2])cout<<"100 "<<a[2]-b[2]<<endl;
		if(a[3]>b[3])cout<<"500 "<<a[3]-b[3]<<endl;
	}
	return 0;
}

Measured memory_bytes: 864
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
#include <stack>
#include <map> // pair
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
typedef std::stack<int> IntStack;
typedef std::stack<char> charStack;

using namespace std;
using ll = long long;
typedef pair <ll, ll > pll;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n, m, K;
	ll memo[200005] = {};
	ll memo2[10004] = {};
	string s;
	string s1, s2;
	//IntStack yStack;
	//charStack Stack;
	//vector<pair<int, int> > pairs(a);
	cin >> a;
	for (int i = 0; i < a; i++)
	{
		cin >> b;
		memo[i] = b;
	}
	e = 1;
	ans = memo[0];
	while (e == 1)
	{
		e = 0;
		for (int i = 0; i < a; i++)
		{
			b = memo[i];
			c = max(ans, b);
			d = min(ans, b);
			if (c%d != 0)
			{
				ans = c%d;
				e = 1;
			}
			else
			{
				ans = min(c, d);
			}
		}
	}

	cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

Measured memory_bytes: 1920
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll h,w;
    cin>>h>>w;
    vector<vector<ll>> a(h,vector<ll>(w));
    for(int i=0;i<h;i++){
        for(int t=0;t<w;t++){
            cin>>a[i][t];
            a[i][t]%=2;
        }
    }
    vector<vector<ll>> A;
    for(int i=0;i<h;i++){
        if(i%2==0){
            for(int t=0;t<w;t++){
                if(a[i][t]%2){
                    if(t==w-1){
                        if(i==h-1){continue;}
                        A.push_back({i,t,i+1,t});
                        a[i+1][t]++;
                    }
                    else{
                        A.push_back({i,t,i,t+1});
                        a[i][t+1]++;
                    }
                }
            }
        }
        else{
            for(ll t=w-1;t>=0;t--){
                if(a[i][t]%2){
                    if(t==0){
                        if(i==h-1){continue;}
                        A.push_back({i,t,i+1,t});
                        a[i+1][t]++;
                    }
                    else{
                        A.push_back({i,t,i,t-1});
                        a[i][t-1]++;
                    }
                }
            }
        }
    }
    cout<<A.size()<<endl;
    for(int i=0;i<A.size();i++){
        cout<<A[i][0]+1<<" "<<A[i][1]+1<<" "<<A[i][2]+1<<" "<<A[i][3]+1<<endl;
    }
    
    
    return 0;
}


Measured memory_bytes: 12848