akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int h,w;
    cin>>h>>w;
    char a[h+2][w+2];
    repi(i,1,h+1){
        repi(j,1,w+1){
            cin>>a[i][j];
        }
    }
    rep(j,w+2){
        a[0][j]='#';
        a[h+1][j]='#';
    }
    rep(i,h+2){
        a[i][0]='#';
        a[i][w+1]='#';
    }
    rep(i,h+2){
        rep(j,w+2){
            cout<<a[i][j];
            if(j==w+1) cout<<endl;
        }
    }
}

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

int main() {
  string s;
  cin >> s;
  cout << s.substr(0, 3) << endl;
  return 0;
}


Measured memory_bytes: 3564
//A.cpp
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

int x[] = {0,-1,0,1};
int y[] = {1,0,-1,0};

int main(){
  int H,W;
  cin >> H >> W;
  string S[H+2];
  S[0] = string(W+2,'.');
  for(int i = 1; i <= H; i++){
    cin >> S[i];
    S[i] = '.' + S[i];
    S[i] += '.';
  }
  S[H+1] = string(W+2,'.');

  bool flag;

  for(int i = 1; i <= H; i++){
    for(int j = 1; j <= W; j++){
      if(S[i][j]=='#'){
        flag = false;
        for(int k = 0; k < 4; k++){
          if(S[i+x[k]][j+y[k]]=='#'){
            flag = true;
            break;
          }
        }
        if(!flag) break;
      }
    }
    if(!flag) break;
  }

  if(flag) printf("Yes\n");
  else printf("No\n");
  return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int x[4],y[4];
  for(int i =0;i<2;i++){
    cin >> x[i] >> y[i];
  }
  int xs=x[1]-x[0];
  int ys=y[1]-y[0];
  x[2]=x[1]-ys;
  y[2]=y[1]+xs;
  x[3]=x[2]-xs;
  y[3]=y[2]-ys;
  for(int i=2;i<4;i++){
    cout << x[i] << " ";
    cout << y[i] << (i==3?"\n":" ");
  }
}


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


Measured memory_bytes: 24532
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())




int n, m;
int a[100000];
int b[100000];

int eflip[100000];
int vflip[100000];


bool visited[100000];
vector<pair<int, int>> edge[100000];
vector<pair<int, int>> tree_edge[100000];



void dfs1(int u) {
	visited[u] = true;
	for (auto p : edge[u]) {
		int v = p.first;
		if (!visited[v]) {
			tree_edge[u].push_back(p);
			dfs1(v);
		}
	}
}



void dfs2(int u) {
	for (auto p: tree_edge[u]) {
		int v = p.first;
		dfs2(v);
	}

	for (auto p : tree_edge[u]) {
		int v = p.first;
		if (vflip[v]) {
			eflip[p.second] ^= 1;
			vflip[u] ^= 1;
			vflip[v] ^= 1;
		}
	}
}



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

	cin >> n >> m;

	rep(i,m) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;

		edge[a[i]].emplace_back(b[i], i);
		edge[b[i]].emplace_back(a[i], i);
	}

	rep(i, m)vflip[a[i]] ^= 1;

	dfs1(0);
	dfs2(0);

	bool ok = true;
	rep(i,n) {
		if (vflip[i] == 1) {
			ok = false;
			break;
		}
	}
	if (ok) {
		rep(i, m) {
			a[i]++;
			b[i]++;
			if (eflip[i]) {
				cout << b[i] << ' ' << a[i] << endl;
			}
			else {
				cout << a[i] << ' ' << b[i] << endl;
			}
		}
	}
	else {
		cout << -1 << endl;
	}




	return 0;
}

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

using namespace std;
int main() {
	int A{ 0 }, B{ 0 };
	cin >> A >> B;
	if (A%3==0 || B%3==0 || (A+B)%3 == 0)
	{
		cout << "Possible";
	}
	else
	{
		cout << "Impossible";
	}
	return 0;
}

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

int arr[MAX];
int mmin[MAX];
int mmax[MAX];
int mystk[MAX];

int main(void)
{
	int N, K;
	cin >> N >> K;
	for (int i = 0; i < N; i++) cin >> arr[i];
	int rdptr = 0;
	int wrptr = 0;
	for (int i = 0; i < N; i++)
	{
		while (rdptr > wrptr && mystk[rdptr - 1] > arr[i]) rdptr--;
		mystk[rdptr++] = arr[i];
		if (i >= K)
		{
			mmin[i - K] = mystk[wrptr];
			if (mystk[wrptr] == arr[i - K]) wrptr++;
		}
	}
	rdptr = 0;
	wrptr = 0;
	for (int i = 0; i < N; i++)
	{
		while (rdptr > wrptr && mystk[rdptr - 1] < arr[i]) rdptr--;
		mystk[rdptr++] = arr[i];
		if (i >= K)
		{
			mmax[i - K] = mystk[wrptr];
			if (mystk[wrptr] == arr[i - K]) wrptr++;
		}
	}
	int ans = N - K + 1;
	for (int i = 0; i < N - K; i++)
	{
		if (mmin[i] == arr[i] && mmax[i] == arr[i + K]) ans--;
	}
	int cnt = -1;
	int cur = 1;
	for (int i = 1; i < N; i++)
	{
		if (arr[i] > arr[i - 1]) cur++;
		else cur = 1;
		if (cur == K) cnt++;
	}
	ans -= max(0, cnt);
	cout << ans << endl;
	return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

int main(){
    int H1, H2, M1, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;

    int ans = (H2 - H1) * 60 + (M2 - M1) - K;
    cout << ans << endl;
}

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

//TO_STRING
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}

string to_string(char ch){
  string s;
  s += ch;
  return s;
}

string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + 
    to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

//DEBUG 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL //compile with -DLOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<pi> vpi;
typedef vector<char> vch;
typedef vector<string> vstr;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
typedef vector<vvi> vvvi;
typedef vector<vch> vvch;
typedef vector<vstr> vvstr;

#define all(x) x.begin(), x.end()
#define pb push_back
#define pf push_front
#define fi first
#define se second  
#define sz(x) ((ll)x.size())



void solve() {
 ll a, b, n;
 cin >> a >> b >> n;
 ll x = min(b - 1, n);
 cout << a * x / b << endl;
}

int main() {
  ios::sync_with_stdio(false);  
  cin.tie(0);cout.tie(0); 
  
  int t = 1;
  for (int tc = 1; tc <= t; tc++) {
  	solve();
  }
}

Measured memory_bytes: 3656
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b, a % b)


def m():
    n, x = map(int, input().split())
    a = list(map(int, input().split()))
    b = [0] * n

    for i in range(n):
        b[i] = abs(x - a[i])

    tmp = b[0]
    for i in range(n):
        tmp = gcd(tmp, b[i])

    return tmp

print(m())

Measured memory_bytes: 14252
#include <cstdio>
#include <string>
#include <iostream>
using namespace std;

int main(){
    string line;
    getline(cin, line); 

    int ans = 0;

    ans += line.find('a');
    ans += line.find('b');
    ans += line.find('c');

    if(ans != 3){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(i, s, t) for(i = s; i <= t; ++i)
#define dep(i, s, t) for(i = s; i >= t; --i)

using namespace std;

typedef long long LL;
const int N = 2e5 + 10;
int n;
LL a[N], ans;

int main() {
	LL i, t = 0;
	scanf("%d", &n);
	rep(i, 1, n) {
		scanf("%lld", &a[i]);
		a[i] += a[i-1];
	}
	sort(a, a+n+1);
	
	rep(i, 0, n)
	if(!i || a[i] != a[i-1]) {
		ans += (t - 1) * t / 2;
		t = 1;
	} else {
		++t;
	}
	if(t) ans += (t - 1) * t / 2;
	printf("%lld\n", ans);
	return 0;
}

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

int main() {
  int N;
  int f = 0;
  cin >> N;
  
  for (int d = 1; d <= N; d*=10){
    f += (N % (d * 10) -f) / d;
  }
  
  if (N % f == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3536
n = int(input())
A = [0]*n
B = [0]*n
dica = {}
dicb = {}
for i in range(n):
    A[i],B[i] = map(int,input().split())
    dica[i] = A[i]
    dicb[i] = B[i]

dicb = sorted(dicb.items(), key = lambda x:x[1])

time = 0
for i in range(n):
    time += dica[dicb[i][0]]
    if time > dicb[i][1]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 157400
n = int(input())
a = list(map(int, input().split()))
l = [0 for i in range(n+1)]

for i in range(n):
  l[a[i]] += 1

cnt = 0

for i in range(len(l)):
  cnt += l[i]*(l[i]-1)//2

for i in range(n):
  ans = cnt
  ans -= l[a[i]]*(l[a[i]]-1)//2
  ans += (l[a[i]]-1)*(l[a[i]]-2)//2
  print(ans)

Measured memory_bytes: 26140
n=int(input())
pri=[1]*(10**7)
ans=[]
for i in range(2,55556):
  if pri[i]>0:
    if i%5==1:
      ans.append(i)
    for k in range(1,55556//i+1):
      pri[i*k]=0
print(' '.join(map(str,ans[:n])))

Measured memory_bytes: 81140
#include<stdio.h>
int main(){
    int n,i;
    int cnt=0;
    scanf("%d",&n);
    int a[n+1];
    for(i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(i=1;i<=n;i+=2){
        if(a[i]%2!=0){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


Measured memory_bytes: 1728
N=int(input())
A=list(map(int,input().split()))
C=[0]*N
for i in range(N):
    C[A[i]-1]+=1
K=0
for i in range(N):
    if(C[i]!=0):
        K+=int(C[i]*(C[i]-1)/2)

for i in range(N):
    ans=K-(C[A[i]-1]-1)
    print(ans)


Measured memory_bytes: 83532
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<deque>

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n,vector<int>(m,l));
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>;
#define pint pair<int,int>;
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

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

	if (a == b && b == c)
	{
		cout << 1 << endl;
	}
	else if (a == b || b == c || a==c)
	{
		cout << 2 << endl;
	}
	else
	{
		cout << 3 << endl;
	}

	

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,N,a,b;
  cin>>N;
  vec color(N,0);
  mat v(N);
  rep1(i,N){
    cin>>a>>b;
    a--;b--;
    v[a].pb(b);
    v[b].pb(a);
  }
  color[0]=1;
  color[N-1]=-1;
  queue<ll> que;
  que.push(0);
  que.push(N-1);
  while(!que.empty()){
    auto x=que.front();que.pop();
    for(auto i:v[x]){
      if(!color[i]){
        color[i]=color[x];
        que.push(i);
      }
    }
  }
  if(accumulate(all(color),0LL)>0){
    cout<<"Fennec"<<endl;
  }else{
    cout<<"Snuke"<<endl;
  }
  return 0;
}


Measured memory_bytes: 7168
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        long[] l = new long[n];
        for (int i = 0; i < n; i++) {
            l[i] = Long.parseLong(scan.next());
        }
        scan.close();

        int ans = 0;

        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                for (int k = j + 1; k < n; k++) {
                    if (l[i] == l[j]) {
                        continue;
                    }
                    if (l[j] == l[k]) {
                        continue;
                    }
                    if (l[k] == l[i]) {
                        continue;
                    }

                    long[] length = { l[i], l[j], l[k] };
                    Arrays.sort(length);
                    if (length[0] + length[1] > length[2]) {
                        ans++;
                    }

                }
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 42624
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    String op = sc.next();
    int B = sc.nextInt();


    System.out.println( "+".equals(op) ? A + B : A - B  );
  }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a%2==0||b%2==0||c%2==0) puts("0");
	else{
		printf("%lld\n",1LL*a*b);
	}
	return 0;
}

Measured memory_bytes: 256
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

const int64_t MAX_R = static_cast<int64_t>(1e9);

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(3
4
3
2
)");
#endif
    int n;
    in >> n;
    vector<int> R;
    for (int i = 0; i < n; ++i) {
        int temp;
        in >> temp;
        R.push_back(temp);
    }

    int min_R = R[0];
    int ans = -static_cast<int>(1e10);
    for (int j = 1; j < n; ++j) {
        ans = max(ans, R[j] - min_R);
        min_R = min(min_R, R[j]);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3916
#include<cstdio>
#include<cstring>
#include<algorithm>

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

using namespace std;

const int INF=1<<30;

int n,w,a[1000];

int sum[1001];

int dp[1000][1000];
int dfs(int i,int j){
	int s=sum[j]-sum[i];

	if(j==n) return max(s-w,0);

	if(dp[i][j]!=-1) return dp[i][j];

	int res=INF;
	// テヲツ板ケティツ。ツ?
	if(i<j){
		res=min(res,dfs(j,j)+abs(s-w));
	}
	// テ、ツサツ甘」ツ?ョティツ。ツ古」ツ?ォティツソツステ・ツ環?
	res=min(res,dfs(i,j+1));
	return dp[i][j]=res;
}

int main(){
	for(int cas=1;scanf("%d%d",&n,&w),n||w;cas++){
		rep(i,n) scanf("%d",a+i);
		rep(i,n) sum[i+1]=sum[i]+a[i];

		memset(dp,-1,sizeof dp);
		printf("Case %d: %d\n",cas,dfs(0,0));
	}

	return 0;
}

Measured memory_bytes: 5072
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits.h>
#include <climits>
#include <map>
#include <unordered_map>
#define _USE_MATH_DEFINES
#include <cmath>
#include <set>
#include <unordered_set>
#include <iterator>
#include <deque>
#include <assert.h>
#include <cstdlib>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
ull min(ull x, ull y){ if (x<y) return x; return y;}
ull max(ull x, ull y){ if (x<y) return y; return x;}
ll min(ll x, ll y){ if (x<y) return x; return y;}
ll max(ll x, ll y){ if (x<y) return y; return x;}
double min(double x, double y){ if (x<y) return x; return y;}
double max(double x, double y){ if (x<y) return y; return x;}
ull gcd(ull x, ull y){
    if (!x) return y;
    if (!y) return x;
    if (x>y) swap(x,y);
    return gcd(x, y%x);
}
ull inv(ull a, ull c){ // a,c are coprime and a<c
    if (a==1){
        return 1;
    }
    return ((c-(c/a))*inv(c%a,c))%c;
}


int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    
    string t;
    cin>>t;
    for (int i = 0; i < t.size(); ++i){
        if (t[i]=='?') t[i]='D';
    }
    cout<<t<<"\n";

    return 0;
}






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

int main(){

    while(1){
        int n; cin >> n;
        if(n == 0) break;
        int ans = 0;


        for(int i = 0; i <= 182; i++){
            for(int j = i; j <= 182; j++){
                for(int k = j; k <= 182; k++){
                    for(int l = k; l <= 182; l++){
                        if((i*i + j*j + k*k + l*l) == n) ans++;
                        if(i*i + j*j + k*k + l*l > n) break;
                    }
                    if(i*i + j+j + 2*k*k > n) break;
                }
                if(i*i + 3*j*j > n) break;
            }
            if(4*i*i > n) break;
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); ++i)

ll gcd(ll x, ll y) {
  if (x > y) swap(x, y);
  while (x) {
    ll z = x;
    x = y%x;
    y = z;
  }
  return y;
}

int main() {

  int N, X, x, ans;
  cin >> N >> X >> x;
  ans = abs(x-X);
  REP (i, N-1) {
    cin >> x;
    ans = gcd(ans, abs(x-X));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main(){
    string s, t;
    cin >> s >> t;
    int a, b, scnt, tcnt;
    cin >> a >> b;
    scnt = a;
    tcnt = b;
    string u;
    cin >> u;
    if(s==u) scnt--;
    if(t==u) tcnt--;
    cout << scnt << " " << tcnt;
    return 0;
}


Measured memory_bytes: 256
from collections import deque
k = int(input())
k -= 1
de = deque([1,2,3,4,5,6,7,8,9])
while k > 0:
    x = de.popleft()
    if x%10==0:
        de.append(10*x)
        de.append(10*x+1)
    else:
        de.append(10*x+x%10-1)
        de.append(10*x+x%10)
        if x%10!=9:
            de.append(10*x+x%10+1)
    k -= 1
print(de.popleft())

Measured memory_bytes: 11900
#include<iostream>

using namespace std;

int main() {
	int r, g, b;
	
	cin >> r >> g >> b;

	int num = r * 100 + g * 10 + b;

	if (num % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;

public class Main {

    public static long knapsack(int N, int W, int[] w, int[] v) {
        long[] dp = new long[W + 1];

        for(int i = 0; i < N; i++) {
            for(int j = W; j >= w[i]; j--) {
                dp[j] = Math.max(dp[j], dp[j - w[i]] + v[i]);
            }
        }
        return dp[W];
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        
        int[] w = new int[N];
        int[] v = new int[N]; 

        for(int i = 0; i < N; i++) {
            w[i] = sc.nextInt();
            v[i] = sc.nextInt();
        }

        System.out.println(knapsack(N, W, w, v));
  }
}


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

bool isprime(int x)
{
    for (int i = 2; i*i <= x; i++) {
        if (x % i == 0) return false;
    }
    return true;
}

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

    while(!isprime(x)) {
        x++;
    }

    cout << x;

    return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<map>

using namespace std;

#define rep(i,N) for(int i=0;i<N;i++) //0から


typedef long long ll;




ll binary_search(vector<ll> a, ll n, ll key){
    ll right = n, left = -1;
    ll md = (right + left) / 2;

    while(right - left > 1){
        if(a[md] <= key){
            right = md;
        }else{
            left = md;
        }
        md = (right + left) / 2;
    }
    if(left == -1) return -1; //無い場合
    return right;
}

vector<ll> prime;
void Prime(ll n){ //線形篩,素数列挙
    vector<ll> p(n,0);
    p[0]=1;
    p[1]=1;
    for(ll i=2;i<n;i++){
        if(p[i]==0){
            prime.push_back(i);
            p[i]=i;
        }
        ll k=prime.size();
        for(ll j=0;j<k && i*prime[j]<n && prime[j]<=p[i];j++){
            p[i*prime[j]]=prime[j];
        }
    }
}

ll gcd(ll a,ll b){
    if(a<b){
        swap(a,b);
    }
    //a>=b
    ll r=a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}

#define MOD ((ll)1e+9 + 7)



//cout<<fixed<<setprecision(10);
int main(){
    ll n;
    cin>>n;
    vector<ll> p(n);
    rep(i,n){
        cin>>p[i];
    }
    int cnt=0;
    rep(i,n){
        if(p[i]!=i+1){
            cnt++;
        }
    }
    if(cnt<=2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }


    return 0;
}



Measured memory_bytes: 3580
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(), b=sc.nextInt(), c=sc.nextInt(), d=sc.nextInt();
        
        System.out.println(a*b > d*c ? a*b : c*d);
    }
}


Measured memory_bytes: 21844
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int main(){
  string A,B,C;
  cin>>A>>B>>C;
  int a=A.size()-1,b=B.size()-1,c=C.size()-1;
  if(A[a]==B[0] && B[b]==C[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
    long long a,b,n,x;
    long long ans1,ans2;
    scanf("%lld %lld %lld",&a,&b,&n);
    ans1=((a*n)/b)-(a*(n/b));
    x=b*(n/b)+(b-1);
    if(x>n) x-=b;
    if(x<0) x=0;
    ans2=((a*x)/b)-(a*(x/b));
    if(ans1>ans2) printf("%lld\n",ans1);
    else printf("%lld\n",ans2);
    return 0;
}


Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,a,b,c,d;
	cin >> N;
	a = N/1000;
    b = (N-a*1000)/100;
    c = (N-a*1000-b*100)/10;
    d = N-a*1000-b*100-c*10;
    if((a==b && b ==c)||(b==c && c ==d)){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int d = sc.nextInt();
		int t = sc.nextInt();
		int s = sc.nextInt();
		int ans = 0;

		if(t*s>=d) {
			System.out.println("Yes");
		}
		else {
			System.out.println("No");
		}

	}
}


Measured memory_bytes: 35728
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N, H;

priority_queue<int> aq;
priority_queue<int> bq;

/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N>>H;
    REP(i,0,N){
        int a, b;
        cin>>a>>b;
        aq.push(a);
        bq.push(b);
    }

    int cnt = 0;
    while(true){
        if(H <= 0) break;
        int at = -1, bt = -1;

        if(!aq.empty()) at = aq.top();
        if(!bq.empty()) bt = bq.top();

        if(at >= bt) {
            cnt += (H + (at - 1)) / at;
            H -= at * ((H + (at - 1)) / at);
        }else{
            bq.pop();
            cnt++;
            H -= bt;
        }
    }

    cout<<cnt<<endl;

    return 0;
}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
using namespace std;
int n, a[1000005], b[1000005], sum[1000005];
long long m;
namespace BIT
{
	long long c[5000005];
	inline int lowbit(int x) { return x & (~x + 1); }
	inline void add(int x, long long val)
	{
		for (int i = x; i < 4 * n; i += lowbit(i))	c[i] += val;
	}
	inline long long sum(int x)
	{
		long long res = 0;
		for (int i = x; i; i -= lowbit(i))	res += c[i];
		return res;
	}
}
bool check(int x)
{
	long long cnt = 0;
	sum[0] = 0;
	for (int i = 1; i <= n; ++i)	sum[i] = sum[i - 1] + (a[i] >= x);
	memset(BIT::c, 0, sizeof(BIT::c));
	for (int i = 0; i <= n; ++i)
	{
		sum[i] = (2 * sum[i] - i) + n + 1;
		cnt += BIT::sum(sum[i]);
		BIT::add(sum[i], 1);
	}
	//printf("%d %lld\n", x, cnt);
	return cnt >= m - m / 2;
}
int main()
{
	scanf("%d", &n);
	m = 1ll * n * (n + 1) / 2;
	for (int i = 1; i <= n; ++i)
	{
		scanf("%d", a + i);
		b[i] = a[i];
	}
	sort(b + 1, b + 1 + n);
	int l = 1, r = n, mid, ans;
	while (l <= r)
	{
		mid = (l + r) >> 1;
		if (check(b[mid]))	l = mid + 1, ans = b[mid];
		else r = mid - 1;
	}
	printf("%d\n", ans);
	return 0;
}

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

int main() {
    int h, w;
    while (cin >> h >> w, h) {
        int ah = 150, aw = 150;
        for (int i = 1; i <= 150; i++) {
            for (int j = i + 1; j <= 150; j++) {
                if (i * i + j * j < h * h + w * w) continue;
                if (i * i + j * j == h * h + w * w && i <= h) continue;
                if (i * i + j * j < ah * ah + aw * aw) {
                    ah = i; aw = j;
                } else if (i < ah) {
                    ah = i; aw = j;
                }
            }
        }
        cout << ah << " " << aw << endl;
    }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,x,y;vector<P> v;
int main(){
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> x >> y;v.push_back({x,y});
    }
    sort(v.begin(),v.end());map<P,ll> m;
    for(int i=0;i<N;i++){
        set<P> s;
        for(int j=i+1;j<N;j++){
            s.insert({v[i].first-v[j].first,v[i].second-v[j].second});
        }
        for(auto &e : s) m[e]++;
    }
    ll max_v = 0;
    for(auto &e : m){
        ll t = e.second;max_v = max(t,max_v);
    }
    cout << N - max_v  << endl;
}

Measured memory_bytes: 384
// URL: https://atcoder.jp/contests/abc135/tasks/abc135_b

import std.algorithm, std.container, std.math, std.range, std.typecons, std.string;

version(unittest) {} else
void main()
{
  int n; io.getV(n);
  int[] p; io.getA(n, p);

  auto r = p.enumerate.count!(t => t[1] != t[0]+1);
  io.putB(r == 0 || r == 2, "YES", "NO");
}

auto io = IO();

struct IO
{
  import std.algorithm, std.conv, std.format, std.meta, std.range, std.stdio, std.traits;

  dchar[] buf;
  auto sp = (new dchar[](0)).splitter;
  int precision = 10;
  string delimiter = " ";

  void nextLine()
  {
    stdin.readln(buf);
    sp = buf.splitter;
  }

  auto get(T)(ref T v)
  {
    if (sp.empty) nextLine();
    v = sp.front.to!T;
    sp.popFront();
  }

  auto getV(T...)(ref T v)
  {
    foreach (ref w; v) get(w);
  }

  auto getA(T)(size_t n, ref T v)
  if (hasAssignableElements!T)
  {
    v = new T(n);
    foreach (ref w; v) get(w);
  }

  auto getC(T...)(size_t n, ref T v)
  if (allSatisfy!(hasAssignableElements, T))
  {
    foreach (ref w; v)
      w = new typeof(w)(n);
    foreach (i; 0..n)
      foreach (ref w; v) get(w[i]);
  }

  auto getM(T)(size_t r, size_t c, ref T v)
  if (hasAssignableElements!T && hasAssignableElements!(ElementType!T))
  {
    v = new T(r);
    foreach (ref w; v) getA(c, w);
  }

  auto putA(T)(T v)
  {
    static if (isInputRange!T && hasLength!T && !isSomeString!T) {
      foreach (i, w; v) {
	putA(w);
	if (i < v.length - 1) write(delimiter);
      }
    } else if (isFloatingPoint!T) {
      writef(format("%%.%df", precision), v);
    } else {
      write(v);
    }
  }

  auto put(T...)(T v)
  {
    foreach (i, w; v) {
      putA(w);
      if (i < v.length - 1) write(delimiter);
    }
    writeln;
  }

  auto putB(S, T)(bool c, S t, T f)
  {
    if (c)
      put(t);
    else
      put(f);
  }

  auto dbg(T...)(T v)
  {
    stderr.writeln(v);
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 9e18;

struct info {
    int s, t, c;
};

signed main() {
    int N, C;
    cin >> N >> C;
    vector<info> program(N);
    for (int i = 0; i < N; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        program[i] = {s, t, c};
    }
    auto sorting = [](info a, info b) {
        return a.s < b.s;
    };
    sort(program.begin(), program.end(), sorting);
    vector<vector<info>> recorder;
    for (auto temp : program) {
        bool addCheck = false;
        for (auto & i : recorder) {
            auto last = *(i.end() - 1);
            if (last.c == temp.c) {
                if (last.t <= temp.s) {
                    i.push_back(temp);
                    addCheck = true;
                    break;
                }
            } else {
                if (last.t < temp.s) {
                    i.push_back(temp);
                    addCheck = true;
                    break;
                }
            }
        }

        if (!addCheck) {
            recorder.push_back({temp});
        }
    }
    cout << recorder.size() << endl;
}


Measured memory_bytes: 7028
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int main(){
	LL A,B,C;
	LL X,Y;
	cin>>A>>B>>C>>X>>Y;
	LL ans=1e18;
	REP(i,100001){
		LL c=i*2*C;
		LL a=max(LL(0),X-i);
		LL b=max(LL(0),Y-i);
		ans=min(ans,c+a*A+b*B);
	}
	cout<<ans<<endl;
	return(0);
}

Measured memory_bytes: 256
#!/usr/bin/env ruby

while (t, h, s = gets.split.map(&:to_i)) != [-1, -1, -1]
  remain = 2 * 3600 - (t * 3600 + h * 60 + s)

  nt = format('%02i', remain/3600)
  nh = format('%02i', (remain%3600)/60)
  ns = format('%02i', remain%60)
  remain *= 3
  tt = format('%02i', remain/3600)
  th = format('%02i', (remain%3600)/60)
  ts = format('%02i', remain%60)
  puts "#{nt}:#{nh}:#{ns}"
  puts "#{tt}:#{th}:#{ts}"
end

Measured memory_bytes: 6884
#include <iostream>
#include <algorithm>
#include <vector>
using namespace  std;
const long long INF = 1<<30;

int LIS(vector<int> &A){
    int N = A.size();
    vector<int> dp(N+2, INF);
    for(int i=0; i<N; i++){
        *upper_bound(dp.begin(), dp.end(), A[i]) = A[i];
    }
    int res = 0;
    for(int i=0; i<N; i++) if(dp[i]!=INF) res++;
    return res;
}
signed main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin>>A[i];
    reverse(A.begin(), A.end());
    cout << LIS(A) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;


int main(){
  int N; cin >> N;
  int A[N]; rep(i,N) cin >> A[i];


  map<ll,int> d;
  ll ans = 0;
  rep(i,N){
    d[A[i]+i+1]++;
    ans += d[-(A[i]-(i+1))];
  }
  cout << ans << endl;
  

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 27048
#include <iostream>
#include <math.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define INF 1e9
#define MOD 1e9 + 7
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()

int main(){
    int a, p;
    cin >> a >> p;
    int ans = 3 * a + p;
    cout << ans/2 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    int N, K, S;
    cin >> N >> K >> S;

    int cnta = K;
    int cntb = N - K;
    while (cnta > 0)
    {
        cout << S << ' ';
        cnta--;
    }
    while (cntb > 0)
    {
        if (S < 1000000000)
        {
            cout << S + 1 << ' ';
        }else
        {
            cout << S - 1 << ' ';
        }
        cntb--;
    }
    
    cout << endl;

    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
using namespace std;
string s;
int n;
vector<int> pos[26];
int dest[200000];
int t[200000];
vector<pair<int , int> > p;
void inc(int l)
{
	for(;l < n; l = l | (l + 1))
		t[l]++;
}
int sum(int l)
{
	int ans = 0;
	for(; l >= 0; l = (l & (l + 1)) - 1)
		ans += t[l];
	return ans;
}
int sum(int l , int r)
{
	return sum(r) - sum(l - 1);
}
int main()
{
	cin >> s;
	n = s.size();
	for(int i = 0; i < n; i++)
	{
		pos[s[i] - 'a'].pb(i);
	}
	int odd = 0;
	for(int i = 0; i < 26; i++)
	{
		if(pos[i].size() % 2)
			odd++;
	}
	if(odd > 1)
	{
		cout << -1;
		return 0;
	}

	for(int i = 0; i < 26; i++)
	{
		int m = pos[i].size();
		for(int j = 0; j < m / 2; j++)
		{
			p.pb(mp(pos[i][j] , pos[i][m - 1 - j]));
		}
		if(m % 2)
		{
			dest[pos[i][m / 2]] = n / 2;
		}
	}
	sort(p.begin() , p.end());
	for(int i = 0; i < n / 2; i++)
	{
		dest[p[i].first] = i;
		dest[p[i].second] = n - i - 1;
	}
	ll ans = 0;
	for(int i = 0; i < n; i++)
	{
		ans += sum(dest[i] , n - 1);
		inc(dest[i]);
	}
	cout << ans;
}


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

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

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

    sort(a, a + n, greater<ll>());

    ll ans = a[0];

    priority_queue<pair<ll, ll> > q;
    q.push(make_pair(a[1], a[0]));
    q.push(make_pair(a[1], a[0]));

    for(int i = 2; i < n; i++){
        pair<ll, ll> p = q.top();
        q.pop();
        ans += p.first;
        pair<ll, ll> b = make_pair(a[i], p.first);
        pair<ll, ll> c = make_pair(a[i], p.second);
        q.push(b);
        q.push(c);
    }

    cout << ans << endl;
}

Measured memory_bytes: 9024
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

H,W = I()
N = i()
a = l()
list = []
for i in range(N):
    for j in range(a[i]):
        list.append(i+1)
ans = [[] for _ in range(H)]
for i in range(H):
    for j in range(W):
        ans[i].append(list.pop(0))
for i in range(H):
    if i%2 == 1:
        print(*ans[i][::-1])
    else:
        print(*ans[i])

Measured memory_bytes: 10484
#![allow(unused_imports, unused_macros, dead_code, bare_trait_objects)]

macro_rules! get{
    ($t:ty) => {
        {
            let cin = stdin();
            let mut cin = cin.lock();
            
            let token =
                cin.by_ref().bytes().map(|c| c.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect::<String>();

            try!(token.parse::<$t>())
        }
    }
}

macro_rules! input{
    ($($id:ident: $t:ty),*) => {
        $(
            let $id = get!($t);
        )*;
    }
}

macro_rules! input_vec{
    ($id:ident: Vec<$t:ty>, $n:expr) => {
        let n = $n;
        let mut $id: Vec<$t> = Vec::with_capacity(n);
        for _ in 0..n {
            let temp = get!($t);
            $id.push(temp);
        }
    }
}

use std::io::{Read,stdin};
use std::str::*;
use std::error::Error;
use std::fmt::Debug;
use std::ops::*;
use std::cmp::*;


fn main(){
    while let Ok(_) = solve() {}
}

fn solve() -> Result<(),Box<std::error::Error>>{
    input!(n: usize);

    let mut a = vec![0; n];
    let mut b = vec![0; n];

    for i in 0..n {
        a[i] = get!(u64);
        b[i] = get!(u64);
    }

    if a == b {
        println!("{}", 0);
    } else {
        let ans = a.iter().sum::<u64>() - (0..n).filter(|&i| a[i] > b[i]).map(|i| b[i]).min().unwrap();
        println!("{}", ans);
    }

    Ok(())
}


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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
	string str;
	cin>>str;
	ll mn = 1e18;
    rep(l,'a','z'+1){
        ll mx = 0;
        ll curr = 0;
        rep(i,0,str.size()){
            if(str[i]==l){
                mx = max(curr,mx);
                curr = 0;
            } else ++curr;
        }
        mx = max(curr,mx);
        mn = min(mn,mx);
    }
    cout<<mn<<endl;
}


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


int main(){
  int n,i;
  cin >> n;
  vector<int> a(n+1);
  for(i=1;i<=n;++i){
    cin >> a[i];
  }
  int ans,k;
  ans=0;
  k=1;
  int ha=0;
  for(i=1;i<=n;++i){
    if(a[i]==k){
      k++;
      ha=1;
    }else{
      ans++;
    }
  }
  if(ha==0){
    ans=-1;
  }

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


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

using namespace std;

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1e9 + 7;

ll modpow(int a, int n)
{
  ll ret = 1, b = a;
  for (; n > 0; n >>= 1) {
    if (n & 1) { ret = (ret * b) % MOD; }
    b = (b * b) % MOD;
  }
  return ret;
}

int main()
{
  int N; scanf("%d", &N);
  vector<int> A(N + 1);
  vector<pair<int, pair<int, int>>> freqs(N + 1, pair<int, pair<int, int>>());
  int pos1 = -1, pos2 = -1;
  for (int i = 0; i <= N; ++i) {
    scanf("%d", &A[i]);
    if (++freqs[A[i]].first == 2) {
      pos1 = freqs[A[i]].second.first;
      pos2 = freqs[A[i]].second.second = i;
    }
    else {
      freqs[A[i]].second.first = i;
    }
  }

  vector<ll> modfact(N + 5, 1), inv_modfact(N + 5, 1);
  for (int i = 2; i <= N + 1; ++i) {
    modfact[i] = (modfact[i - 1] * i) % MOD;
    inv_modfact[i] = modpow(modfact[i], MOD - 2);
  }

  int inner = pos2 - pos1 - 1;
  int total = N + 1;
  printf("%d\n", N);
  for (int len = 2; len <= total; ++len) {
    ll sum = (modfact[N + 1] * inv_modfact[len]) % MOD;
    sum = (sum * inv_modfact[N + 1 - len]) % MOD;
    int n = total - 1 - inner - 1;
    int r = len - 1;
    if (n >= r) {
      // combination(n, r)
      ll val = (modfact[n] * inv_modfact[r]) % MOD;
      val = (val * inv_modfact[n - r]) % MOD;
      // if (sum < val) {
      //   fprintf(stderr, "DEBUG: sum=%lld, val=%lld\n", sum, val);
      // }
      sum = (sum - val + MOD) % MOD;
    }
    printf("%lld\n", sum);
  }
  return 0;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,a[100006],b[100006];
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		b[a[i]]=i;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<b[i]<<" ";
	}
}

Measured memory_bytes: 1536
def solve():
  N = int(input())
  A = [int(input()) for _ in range(N)]
  if N==1:
    if A[0]==0:
      return 0
    return -1
  if A[0]>0 or A[1]>1:
    return -1
  ans = N - A.count(0)
  for i in range(1,N-1):
    if A[i]+1<A[i+1]:
      return -1
    if A[i]>=A[i+1] and A[i+1]>0:
      ans += A[i+1]-1
  return ans
print(solve())

Measured memory_bytes: 88112
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#include <chrono>
#include <random>
#include <time.h>
#include <fstream>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define all(c) begin(c),end(c)
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
#define N 250000
ll MOD=1e9+7;

ll dp[N][13];

main(){
    string s;cin>>s;
    int res[N];
    res[1]=1;
    rep2(i,1,s.size()){
        res[i+1]=res[i]*10%13;
    }
    dp[0][0]=1;
    rep2(i,1,s.size()){
        rep(j,13){
        if(s[i-1]=='?'){
            rep(k,10){
                dp[i][(j+res[s.size()-i+1]*k)%13]=dp[i-1][j]+dp[i][(j+res[s.size()-i+1]*k)%13];
                dp[i][(j+res[s.size()-i+1]*k)%13]%=MOD;
            }
        }
        else{
            int t=int(s[i-1]-'0');
            dp[i][(j+res[s.size()-i+1]*t)%13]+=dp[i-1][j];
            dp[i][(j+res[s.size()-i+1]*t)%13]%=MOD;
        }
        }
    }
    cout<<dp[s.size()][5]<<endl;
}



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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int n = s.length();
  int dp[2][2019];
  memset(dp, 0, sizeof(dp));
  dp[1][s[n-1]-'0'] = 1;
  int curr = 10, ans = dp[1][0];
  for(int i=n-2;i>=0;i--)
  {
    int z = ((s[i]-'0')*curr)%2019;
    for(int j=0;j<2019;j++)
    {
      if(dp[1][j])
      {
        int y = (z+j)%2019;
        dp[0][y] += dp[1][j];
      }
    }
    dp[0][z] += 1;
    curr = (curr*10)%2019;
    ans += dp[0][0];
    for(int i=0;i<2019;i++)
    {
      dp[1][i] = dp[0][i];
      dp[0][i] = 0;
    }
  }
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 3764
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	int a[2];
	vector<bool>can(4,true);
	for(int i = 0;i < 2;i++){
		int x;cin >> x;
		can[x] = false;
	}
	for(int i = 1;i < 4;i++){
		if(can[i]){
			cout << i;
		}
	}
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	char s[5];
	int flag = 0;
	cin >> s;

	for (int i = 1; i < 4; i++){
		if (s[i] == s[i - 1]) {
			flag = 1;
			break;
		}
	}

	if (flag == 1) cout << "Bad" << endl;
	else cout << "Good" << endl;

	return 0;
}

Measured memory_bytes: 256
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
import numpy as np
# import math
a,b,c = map(int, input().split())

# p = list(map(int, input().split()))

ans = 'No'

d = a * b
if (c-a-b) ** 2 > 4 * a*b and c-a-b > 0:
    if (c-a+b) ** 2 > 4 * b*c and c-a+b > 0:
        if (c+a-b) ** 2 > 4 * a*c and c+a-b > 0:
            ans = 'Yes'

print(ans)


# print(1000000000 ** 2)

Measured memory_bytes: 14428