akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

int main() {
    int n=0, q=0;
    string s;
    int ans;

    cin>>n>>q;

    vi l, r;
    l.resize(q);
    r.resize(q);
    
    cin>>s;

    REP(i,q)
    {
        l[i] = 0; r[i] = 0;
        cin>>l[i]>>r[i];
    }

    int cnt[q], found = 0;
    cnt[0] = 0;
    REP(i,n-1)
    {
        if (s[i] == 'A' && s[i+1] == 'C')
            found++;

        cnt[i+1] = found;

        //DEBUG(cnt[i+1]);
    }


    REP(j,q)
    {
        cout << cnt[r[j]-1] - cnt[l[j]-1] << endl;
    }

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m=1e32,s,p,j,i,a[500];
    cin>>n;
    for(i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(i=a[0];i<=a[n-1];i++)
    {
        s=0;
        for(j=0;j<n;j++)
        {
            p=(a[j]-i);
            s+=(p*p);
        }
        if(s<m)m=s;
    }
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 256
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

def main():
    n = ii()
    d = li()
    d = sorted(d)
    print(d[n//2]-d[n//2-1])


main()




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

int main() {
    string s;
    cin >> s;
    for(int i=0;i<4;i++) cout << s.at(i);
    cout<< " ";
    for(int i=4;i<s.size();i++) cout << s.at(i);
    cout << endl;
}

Measured memory_bytes: 256
// Problem : D - Powerful Discount Tickets
// Contest : AtCoder - AtCoder Beginner Contest 141
// URL : https://atcoder.jp/contests/abc141/tasks/abc141_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n,m;
	cin>>n>>m;
	vi a(n);
	map<ll,ll> map;
	loop(i,n)
	{
		cin>>a[i];
		map[a[i]]++;
	}
	while(m--)
	{
		auto i=map.rbegin();
		i->s--;
		map[i->f/2]++;
		if(i->s==0)
		{
			map.erase(i->f);
		}
	}
	ll ans=0;
	trav(i,map)
	ans+=i.f*i.s;
	cout<<ans;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 9828
#include <stdio.h>
int main()
{
    long long n,m,num;
    while(scanf("%lld%lld",&n,&m)!=EOF)
    {

        num=0;
        if(n>m/2)
        {
            printf("%lld\n",m/2);
        }
        else if(n==m/2)
            printf("%lld",n);
        else
        {
            num=n;
            m=m-2*n;
            num+=m/4;
            printf("%lld\n",num);
        }
    return 0;
}
}

Measured memory_bytes: 128
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	as := make([]int, n)
	for i := range as {
		fmt.Scan(&as[i])
	}

	var ans int
	for i, a := range as {
		if (i+1)%2 == 1 && a%2 == 1 {
			ans++
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1768
#include <bits/stdc++.h>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

constexpr ll MOD = 998244353;

int main() {
  ll n,x;
  cin>>n>>x;
  ll p2 = 1;
  while (p2 <= x) p2 *= 2;
  vector<vecll> dp(p2,vecll(x+1, 0));
  dp[0][0] = 1;
  REP(i,n) {
    vector<vecll> psum(dp);
    REP(j,p2) {
      partial_sum(ALL(dp[j]),begin(psum[j]));
      REP(k,x+1) psum[j][k] %= MOD;
    }
    vector<vecll> tmp(p2,vecll(x+1, 0));
    REP(x1,x+1)REP(y,p2) {
      tmp[y][x1] += psum[y^x1][x1];
      tmp[y][x1] %= MOD;
    }
    swap(dp, tmp);
  }
  vector<vecll> psum(dp);
  REP(j,p2) {
    partial_sum(ALL(dp[j]),begin(psum[j]));
    REP(k,x+1) psum[j][k] %= MOD;
  }
  cout<<psum[x][x]<<endl;
  return 0;
}



Measured memory_bytes: 8960
n, m = map(int, input().split())
cnt = [[] for _ in range(n + 1)]
for i in range(m):
    p, y = map(int, input().split())
    cnt[p].append((y, i))
buf = [None] * m
for p, l in enumerate(cnt):
    if not l:
        continue
    l.sort()
    for j, (y, i) in enumerate(l):
        buf[i] = '{:06d}{:06d}'.format(p, j + 1)
print('\n'.join(buf))

Measured memory_bytes: 38376
A,B,C,D=map(int, input().split())
import fractions
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数

if (B-(A+(C-A%C)%C))<0:
    cs=0
else:
    cs=(B-(A+(C-A%C)%C))//C+1
if (B-(A+(D-A%D)%D))<0:
    ds=0
else:
    ds=(B-(A+(D-A%D)%D))//D+1
E=lcm(C,D)
if (B-(A+((E)-A%(E))%(E)))<0:
    cds=0
else:
    cds=(B-(A+((E)-A%(E))%(E)))//(E)+1

#print(cs, ds, cds)
print(B-A+1-(cs+ds-cds))

Measured memory_bytes: 5048
#include <bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep_i(i, n) for (int i = 0; i < (n); ++i)
#define rep_ll(i, n) for (long long i = 0; i < (n); ++i)
#define r_rep_i(i, start, end) for (int i = (start); i < (end); ++i)
#define r_rep_ll(i, start, end) for (long long i = (start); i < (end); ++i)
#define debug_vi(v) copy((v).begin(), (v).end(), ostream_iterator<int>(cout, " "));
#define debug_vll(v) copy((v).begin(), (v).end(), ostream_iterator<long long>(cout, " "));
#define debug_vd(v) copy((v).begin(), (v).end(), ostream_iterator<double>(cout, " "));
#define sort_v(v) sort((v).begin(), (v).end()); //昇順
#define d_sort_vi(v) sort((v).begin(), (v).end(), greater<int>()); //降
#define d_sort_vd(v) sort((v).begin(), (v).end(), greater<double>()); //昇順
#define say(t) cout << (t) << endl;
#define sum_vi(v) accumulate((v).begin(), (v).end(), 0);
#define sum_vll(v)accumulate((v).begin(), (v).end(), 0LL);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(0);
  int n; cin >> n;
  string s;
  cin >> s;
  int c = 0;
  for (int i = 0; i < s.length() - 2; i++){
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C'){
      c += 1;
    }
  }
  say(c);
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    int N = S.size(), res = 0;
    REP(i, N) {
        if (i % 2 == S[i] - '0') {
            res++;
        }
    }
    cout << min(res, N - res) << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <iostream>
typedef unsigned long ul;
using namespace std;

int main() {
	int n;
	cin >> n;
	cout << 180 * (n-2) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
#define lp(var,start,end) for (ll var = start; var <end ; ++var)
#define rlp(var,start,end) for(ll var = start; var>=end ; var--)
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL)
#define ll long long int
#define ld long double
#define fi first 
#define se second 
#define mp make_pair
#define pb push_back
#define ull unsigned long long int
#define vll vector<ll>
#define vld vector<ld>
#define pll pair<ll,ll> 
#define pld pair<ld,ld> 
#define vpll vector<pll>
#define vpld vector<pld>
#define all(X) X.begin(),X.end()
#define mo 1000000007
ll gcd(ll a ,ll b){if(a%b==0)return b;return gcd(b,a%b);}
ll poww(ll a,ll n){if(n==0)return 1;ll p=poww(a,n/2);p=(p*p)%mo;if(n%2)p=(a*p)%mo;return p;}
////////////////////////////////////////////////////

void solve()
{
	ll n, k; cin>>n>>k; 
	n = n%k; 
	cout<<min(n,k-n)<<endl; 
}

int main()
{ ios; 

 int t; t=1;
 while(t--)
	solve(); 
	return 0 ; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>


int main(int argc, const char * argv[]) {
	
	double a,b,c;
	
	scanf("%lf %lf %lf",&a,&b,&c);
	
	double s = a * b * sin(c/180 * M_PI) / 2;
	
	double l = a + b + sqrt(a*a + b*b - 2*a*b*cos(c/180 * M_PI));
	
	double h = b * sin(c/180 * M_PI);
	
	printf("%f\n",s);
	printf("%f\n",l);
	printf("%f\n",h);
	
	return 0;
	
}

Measured memory_bytes: 672
// C - Skip
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

ll gcd(ll a, ll b){return b? gcd(b, a%b): a;}

int main(){
	int N,X; cin>>N>>X;
	vl XX(N); rpz(i, N) cin>>XX[i];
	ll g = abs(XX[0] - X);
	rp(i, 1, N) g = gcd(g, abs(XX[i] - X));
	cout<< g <<endl;
}

Measured memory_bytes: 1024
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/05/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<int> h(n); for(auto& v : h) cin>>v;
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(h[1]-h[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min(
        dp[i-2] + abs(h[i]-h[i-2]),
        dp[i-1] + abs(h[i]-h[i-1])
        );
  }
  cout << dp[n-1] << endl;

  return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n;cin>>n;
  while(n!=0)
  {
    int now=1000;
    now-=n;
    int ans=0;
    while(now>=500)
    {
      now-=500;
      ans++;
    }
    while(now>=100)
    {
      now-=100;
      ans++;
    }
    while(now>=50)
    {
      now-=50;
      ans++;
    }
    while(now>=10)
    {
      now-=10;
      ans++;
    }
    while(now>=5)
    {
      now-=5;
      ans++;
    }
    while(now>=1)
    {
      now--;
      ans++;
    }
    cout<<ans<<endl;
    cin>>n;
  }
}


Measured memory_bytes: 3092
#include <iostream>
#include <vector>
#include <algorithm>

typedef long long ll;

ll solve(std::vector<ll> &a)
{
    ll ans = 1;

    const int n = a.size();

    ll r = 0, g = 0, b = 0;

    for (int i = 0; i < n; i++) {
        int c = a[i];
        if (r == c && g == c && b == c) {ans *= 3; r++;} else
        if (r == c && g == c          ) {ans *= 2; r++;} else
        if (r == c &&           b == c) {ans *= 2; r++;} else
        if (          g == c && b == c) {ans *= 2; g++;} else
        if (r == c                    ) {ans *= 1; r++;} else
        if (          g == c          ) {ans *= 1; g++;} else
        if (                    b == c) {ans *= 1; b++;} else
        {
            return 0;
        }
        ans %= 1000000007;
    }

    return ans;
}

int main(int argc, char *argv[])
{
    ll n;
    std::vector<ll> a;
    ll ans;

    std::cin >> n;

    a.resize(n);

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

    ans = solve(a);

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 1024
import sys
import math
import collections
from collections import deque
#x = int(input())
n, x, y = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

ans = [0 for i in range(n-1)]
for i in range(1, n):
    for j in range(i+1, n+1):
        ans[(min((j-i), abs(x-i)+1+abs(y-j)))-1] += 1

for i in range(n-1):
    print(ans[i])


                

            
                
                


Measured memory_bytes: 3820
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  (n : a : b : _) <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    comb = modComb n
  print . (`mod` modulus) $ modExp 2 n - 1 - comb a - comb b

modExp :: Integral a => Int -> a -> Int
modExp = exp' 1
  where
    exp' z _ 0 = z
    exp' z w y = exp' z' w' y'
      where
        y' = y `div` 2
        w' = w * w `mod` modulus
        z' | even y    = z
           | otherwise = (z * w) `mod` modulus

modInv :: Int -> Int
modInv = (invs VU.!)
  where
    invs :: VU.Vector Int
    invs = VU.constructN (succ $ 2 * 10 ^ 5) rec
      where
        rec v = case VU.length v of
          0 -> 0
          1 -> 1
          l -> let (q, r) = modulus `divMod` l in (modulus - (v VU.! r) * q) `mod` modulus

modComb :: Int -> Int -> Int
modComb n = (combs VU.!)
  where
    combs = VU.unfoldrN (succ $ 2 * 10 ^ 5) next (0, 0)
      where
        next (0, _) = Just (1, (1, 1))
        next (k, x) = let x' = (((x * (n - k + 1)) `mod` modulus) * modInv k) `mod` modulus in Just (x', (succ k, x'))

modulus :: Int
modulus = 10 ^ 9 + 7

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


Measured memory_bytes: 5116
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sca = new Scanner(System.in);
		List<Integer> abc = new ArrayList<Integer>();
		for(int i = 0;i < 5;i++) abc.add(sca.nextInt());
		int min = abc.get(0),index = 0,time = 0;
		for(int i = 0;i < 5;i++) {
			if(min > abc.get(i) % 10 && abc.get(i)%10 != 0) {
				min = abc.get(i) % 10;
				index = i;
			}
		}
		for(int i = 0;i < 5;i++) {
			if(i != index) {
				if(abc.get(i)%10 != 0) time += abc.get(i) + (10 - (abc.get(i)%10));
				else time += abc.get(i);
			}
		}
		time += abc.get(index);
		System.out.println(time);
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long

int main() {
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	double x;
	cin >> x;
	cout << fixed << setprecision(15) << x * x * x / 27;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void){
    long i, j, n;
    int *a;

    while(1){
        scanf("%ld", &n);
        if (n == 0){
            break;
        }
        a = malloc((2*n+1) * sizeof(int));

        if (a == NULL){
            printf("Insufficient memory.\n");
            exit(1);
        }

        for (i = 2; i <= 2*n; i++){
            a[i] = 1;
        }

        for (i = 2; i <= 2*n; i++){
            if (a[i] == 1){
                for (j = i; i * j <= 2*n; j++){
                    a[i*j] = 0;
                }
            }
        }

        long count = 0;
        for (i = n+1; i <= 2*n; i++){
            if (a[i] == 1){
                count++;
            }
        }
        printf("%ld\n", count);

        free(a);

    }

    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<int, int>;

int main() {
  ll x, k, d;
  cin >> x >> k >> d;

  ll ans = x;
  ll t = abs(x) / d;
  if (k <= t) {
    if (x >= 0) ans -= k*d;
    else ans += k*d;
  } else {
    if (x >= 0) ans -= t*d;
    else ans += t*d;
    if ((k-t)%2==1) {
      if (x >= 0) ans -= d;
      else ans += d;
    }
  }
  if (ans < 0) ans = -ans;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <memory>
#include <complex>
#include <numeric>
#include <cstdio>
#include <iomanip>
#include <random>

#define REP(i,m,n) for(int i=int(m);i<int(n);i++)
#define RREP(i,m,n) for(int i=int(n)-1;i>=int(m);--i)
#define EACH(i,c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
//#define int long long

#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR 
#endif
using namespace std;

using UI = unsigned int;
using UL = unsigned long;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VS = vector<string>;
using PII = pair<int,int>;
using VP = vector<PII>;
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; }

constexpr double EPS = 1e-10;
//constexpr double PI  = acos(-1.0);
//constexpr int INF = INT_MAX;
constexpr int MOD = 1'000'000'007;
//inline void modAdd(LL &l, LL &r) {l = (l + r) % MOD;}

template<class T> inline T sqr(T x) {return x*x;}

void solve() {
    int n,m;
    cin >> n >> m;
    cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

signed main() {
    solve();
    
    return 0;
}

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

int main() {
  int a,x;
  cin >> x >> a;
  if(x<a){
    cout << 0 <<endl;
  }else{
    cout << 10 <<endl;
  }
  return 0;
}

Measured memory_bytes: 256
X, K, D = map(int,input().split())

l = X - K * D
r = X + K * D


if l >= 0:
    print(l)
elif r <= 0:
    print(-r)
else:
    X = abs(X)
    k = X // D
    if (K - k) % 2 == 0:
        print(X - X // D * D)
    else:
        print(-(X - (X // D + 1) * D))

Measured memory_bytes: 9196
import math
a, b, h, m = map(int,input().split())

long = (h * 60 + m) / 2
mini = 6 * m
ans = pow(a, 2) + pow(b, 2) - 2 * a * b * math.cos(abs(long - mini)/180 * math.pi)
print(ans ** 0.5)

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

constexpr ll MOD = 1'000'000'007;
int N, M;
int S[2100], T[2100];
ll dp[2100][2100];

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

    std::cin >> N >> M;

    for(int i=0;i<N;++i){
        std::cin >> S[i];
    }

    for(int i=0;i<M;++i){
        std::cin >> T[i];
    }

    for(int i=N-1;i>=0;--i){
        for(int j=M-1;j>=0;--j){
            dp[i][j] = (dp[i+1][j] + dp[i][j+1] + MOD - dp[i+1][j+1]) % MOD;
            
            if(S[i] == T[j]){
                dp[i][j] = (dp[i][j] + dp[i+1][j+1] + 1) % MOD;
            }
        }
    }

    // for(int i=0;i<=N;++i){
    //     for(int j=0;j<=M;++j){
    //         std::cout << dp[i][j] << " ";
    //     }
    //     std::cout << std::endl;
    // }

    ll res = (dp[0][0] + 1) % MOD;
    std::cout << res << std::endl;
}


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

#define pb            push_back
#define mp            make_pair
#define ins           insert
#define endl          '\n'
#define all(x)        x.begin(),x.end()
#define debug(X)      { cerr<<endl<<(#X)<<" = "<<(X)<<endl; }
//#define cerr if(0)cerr

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;


int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    ll h,n,a,m=-1,ta=0;
    cin>>h>>n;
    while (n--) {
        cin>>a;
        ta+=a;
    }
    cout<<(ta>=h?"Yes":"No")<<endl;
}



Measured memory_bytes: 256
import numpy as np

N, K = [int(x) for x in input().split()]

L = np.arange(N)
L += 1

count = np.sum(L >= K)
times = 1

prob = times * count

while count < N:
  times += 1
  old_count = count
  L *= 2
  count = np.sum(L >= K)
  prob += (count - old_count)*(0.5)**(times-1)
prob /= N
print(prob)

Measured memory_bytes: 21504
A, B, C = list(map(int, input().split()))
K = int(input())

ans = 'No'
for i in range(K):
  if A < B < C:
    break
  
  if A >= B:
    B = 2 * B
  elif B >= C:
    C = 2 * C

if A < B < C: 
  ans = 'Yes'


  
print(ans)

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
//ALLAH is one
int main()
{
    ll n,i,j,t;
    char ch;
    cin>>ch;
    if(ch=='A')
        cout<<"T\n";
    if(ch=='T')
        cout<<"A\n";
    if(ch=='C')
        cout<<"G\n";
    if(ch=='G')
        cout<<"C\n";

    return 0;
}



Measured memory_bytes: 3512
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cassert>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
int N;

struct P
{
  int x,y,type;
  P(int x = -1,int y = -1,int type = -1):x(x),y(y),type(type){}
};
int SMLx[3][12] = {{0,0,1,-1},{1,2,2,2,1,1,0,0},{0,0,0,0,1,1,1,2,-1,-1,-1,-2}};
int SMLy[3][12] = {{1,2,1,1},{0,0,1,2,1,2,1,2},{1,2,3,4,1,2,3,2,1,2,3,2}};
int SML[] = {4,8,12};
bool F;
int Cx[] = {0,1,0};
int Cy[] = {1,1,2};

void print(const VVI& G)
{
  cout << "print---" << endl;
  for(int i=0;i<10;i++)
    {
      for(int j=0;j<10;j++)
	{
	  cout << G[i][j] << " ";
	}
      cout << endl;
    }
  cout << endl;
}

bool check(VVI& G,int x,int y,int type)
{
  G[y][x]--;
  for(int i=0;i<SML[type];i++)
    {
      int nx = x + SMLx[type][i];
      int ny = y + SMLy[type][i];
      if(!(0 <= nx && nx < 10 && 0 <= ny && ny < 10) || G[ny][nx] <= 0)
	{
	  G[y][x]++;
	  for(int j=i-1;j>=0;j--)
	    {
	      nx = x + SMLx[type][j];
	      ny = y + SMLy[type][j];
	      G[ny][nx]++;
	    }
	  return false;
	}
      G[ny][nx]--;
    }
  return true;
}

void draw(VVI& G,int x,int y,int type)
{
  G[y][x]++;
  for(int i=0;i<SML[type];i++)
    {
      int nx = x + SMLx[type][i];
      int ny = y + SMLy[type][i];
      if(!(0 <= nx && nx < 10 && 0 <= ny && ny < 10))
	assert(false);	 	
      G[ny][nx]++;
    }
}


void dfs(VVI& G,int x,int y,int cnt,vector<P> perm)
{
  if(cnt > N)
    return;
    if(F)
    return;
      
  perm.push_back(P(-1,-1,-1));
  for(int i=y;i<10;i++)
    for(int j= (i == y?x:0);j<10;j++)
      if(G[i][j] >= 1)
	{
	  bool found = false;
	  for(int k=0;k<3;k++)
	    {
	      if(!check(G,j,i,k))
		continue;
	      perm[perm.size()-1] = P(j+Cx[k],i+Cy[k],k+1);
	      dfs(G,j,i,cnt+1,perm);
	      draw(G,j,i,k);
	    }
	  return;
	}


  if(cnt == N  && !F)
    {
      for(int i=0;i<N;i++)
	{
	  cout << perm[i].x << " " << perm[i].y << " " << perm[i].type << endl; 
	}      
      assert(!F);
      F = true;
    }
}

int main()
{
  F = false;
  cin >> N;
  assert(N <= 12);
  VVI G(10,VI(10));

  for(int i=0;i<10;i++)
    for(int j=0;j<10;j++)
      cin >> G[i][j];
  dfs(G,0,0,0,vector<P>());
  assert(F);
  return 0;
}

/*
-- output --
3 2 1
8 4 2
1 1 2
5 2 3
8 1 2
1 4 2
3 6 3
6 6 3
1 8 2

-- input --
9
1 1 1 0 0 1 0 1 1 1
1 1 1 1 1 1 1 1 1 1
1 1 2 2 2 1 1 2 1 1
1 1 1 1 1 1 1 1 1 1
1 1 1 1 0 1 1 1 1 1
1 1 2 1 1 1 1 2 1 1
0 1 1 1 2 2 1 1 1 0
1 1 2 1 1 1 1 1 0 0
1 1 1 1 0 0 1 0 0 0
1 1 1 0 0 0 0 0 0 0

*/

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

const int INF = 1e+9;

int main() {
	int n, a, bp, p, kogen = 0, bonti = 0, sanpuku = 0, mine = 0, kuboti = 0;
	cin >> n;
	cin >> bp >> p;
	if(n == 1 || n == 2){
		for(int i = 0; i < 5; ++i){
			if(i)
				cout << " ";
			cout << "0";
		}
		cout << endl;
		return 0;
	}
	bool flag = false;
	for(int i = 2; i < n; ++i){
		scanf("%d", &a);
		if(p == a && bp != p){
			flag = true;
			continue;
		}
		if(flag){
			if(bp < p && p > a)
				kogen++;
			else if(bp > p && p < a)
				bonti++;
			else
				sanpuku++;
			flag = false;
		}
		else if(bp > p && p < a)
			kuboti++;
		else if(bp < p && p > a)
			mine++;
		bp = p;
		p = a;
	}
	cout << kogen << " " << bonti << " " << sanpuku << " " << mine << " " << kuboti << endl;
	return 0;
}


Measured memory_bytes: 1248
#include <bits/stdc++.h>
#define long long long
#define ull unsigned long long
#define up(i,a,b) for (int i=a; i<=b; i++)
#define down(i,a,b) for (int i=a; i>=b; i--)
#define endl '\n'
#define pb push_back
#define X first
#define Y second
#define II pair<int, int>
#define III pair<int, pair<int, int> >
#define V vector
#define debug(X) cerr<< #X << " = " <<X << endl
#define debug2(X,Y) cerr<< #X << " = " <<X << ","<<#Y<<" = "<<Y<<endl
#define show(X,a,b) {cerr << #X << " = "; up(__,a,b) cerr << X[__] << ' '; cerr << endl;}
#define gc getchar
#define pc putchar

using namespace std;

inline void read(int &x)
{
    register int c = gc();
    x = 0;
    int neg = 0;
    for (;((c<48 || c>57) && c != '-') ;c = gc());
    if(c=='-') {neg=1;c=gc();}
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(neg) x=-x;
}
inline void writeln(int x){

         char buffor[21];
         register int i=0;
         int neg=0; if (x<0) {neg=1; x= -x;}
         do{
               buffor[i++]=(x%10)+'0';
               x/=10;
            } while(x);
           i--;
           if (neg) pc('-');
           while(i>=0) pc(buffor[i--]);
           pc('\n');
       }
int n,cnt[4];
void input()
{
    cin>>n;
    up(i,1,n)
    {
    	int a; cin>>a;
    	cnt[a% 4]++;
    }
}

void solve()
{

    if (cnt[1]+cnt[3]<= cnt[0] or (cnt[1]+cnt[3]-1== cnt[0] and cnt[2]==0 ) ) cout<<"Yes";
    else cout<<"No";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);// don't use when interactive
    #define TASK "tmp"
    //freopen(TASK".inp","r",stdin);
    //freopen(TASK".out","w",stdout);

    input();
    solve();

    return 0;
}


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

using namespace std;

typedef long long int ll;

int main(){
    int t;
    cin>>t;
    ll sum = 0;
    for(int i = 1;i<=t;i++){
        for(int j =1;j<= t;j++){
            int thisGcd = (i!=j)?__gcd(i, j):i;
            for(int k = 1;k<= t;k++){
                int finGcd = (k!=thisGcd)?__gcd(thisGcd, k):k;
                sum+= finGcd;
            }
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<char>v[3];

template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
	vector.erase(vector.begin() + index);
}

int main(){

	string Sa, Sb, Sc;

	cin >> Sa;
	cin >> Sb;
	cin >> Sc;

	for (int i = 0; i < Sa.size(); i++) {
		v[0].push_back(Sa[i]);
	}
	for (int i = 0; i < Sb.size(); i++) {
		v[1].push_back(Sb[i]);
	}
	for (int i = 0; i < Sc.size(); i++) {
		v[2].push_back(Sc[i]);
	}

	int turn = 0;

	while (1) {
		if (v[turn].empty()) { break; }
		char s = v[turn][0];
		remove(v[turn], 0);
		if (s == 'a') { turn = 0; }
		else if (s == 'b') { turn = 1; }
		else { turn = 2; }
	}
	if (turn == 0) { cout << 'A' << endl; }
	else if (turn == 1) { cout << 'B' << endl; }
	else { cout << 'C' << endl; }

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

map<ll, ll> cost;
vector<ll> ans;
Graph graph;

void dfs(ll v, ll from, ll c) {
    ans[v] = c;
    for (ll u: graph[v]) {
        if (u != from) {
            dfs(u, v, c + cost[u]);
        }
    }
}

void Main() {
    ll N, Q;
    cin >> N >> Q;
    graph.resize(N);
    ans.resize(N, 0);
    rep(i, N-1) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    rep(i, Q) {
        ll p, x;
        cin >> p >> x;
        p--;
        cost[p]+=x;
    }
    dfs(0, -1, cost[0]);
    rep(i, N) {
        cout << ans[i] << ' ';
    }
}

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


Measured memory_bytes: 46208
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

void bfs(vector< vector<int> > & edges, int node, vector<int>& state, vector<int>& dist){
    queue<int> Q;
    Q.push(node);
    dist[node] = 0;
    while(!Q.empty()){
        node = Q.front();
        Q.pop();
        if(dist[node] >= 2) break;
        for(int e : edges[node]){
            if(state[e] == 0){
                dist[e] = dist[node] + 1;
                Q.push(e);
            }
        }
        state[node] = 0;
    }
}

int main()
{
    int N, M;
    cin >> N >> M;
    vector< vector<int> > edges(N);
    vector<int> state(N), dist(N, -1);
    int a, b;
    for(int i=0;i<M;++i){
        cin >> a >> b;
        edges[--a].push_back(--b);
        edges[b].push_back(a);
    }

    bfs(edges, 0, state, dist);

    if(dist[N-1] == 2){
        cout << "POSSIBLE" << endl;
    }
    else cout << "IMPOSSIBLE" << endl;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<P> items(N);
    rep(i, N) cin >> items[i].first >> items[i].second;
    ll t = 1, a = 1;
    rep(i, N) {
        P p = items[i];
        ll x = max((t + p.first - 1) / p.first, (a + p.second - 1) / p.second);
        t = p.first * x;
        a = p.second * x;
    }
    cout << t + a << '\n';
}

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


Measured memory_bytes: 256
import sys
input = sys.stdin.readline


N = int(input())
graph = [[] for _ in range(N)]
P = list(map(int, input().split()))
Xs = list(map(int, input().split()))

for i, p in enumerate(P):
    graph[p-1].append(i+1)

stack = [0]
Scores = [[0, 0] for _ in range(N)]
Ind = [0]*N
ok = True
while stack and ok:
    p = stack[-1]
    if Ind[p] == len(graph[p]):
        stack.pop()
        Max = Xs[p]
        dp = [False]*(Max+1)
        dp[0] = True
        S = 0
        for ch in graph[p]:
            a, b = Scores[ch]
            S += a+b
            for x in reversed(range(Max+1)):
                dp[x] = (x >= a and dp[x-a]) or (x >= b and dp[x-b])
        to_ret = -1
        for x in reversed(range(Max+1)):
            if dp[x]:
                to_ret = S - x
                break
        if to_ret == -1:
            ok = False
        else:
            Scores[p] = [Max, to_ret]
    else:
        stack.append(graph[p][Ind[p]])
        Ind[p] += 1

print("POSSIBLE" if ok else "IMPOSSIBLE")

Measured memory_bytes: 45276
def find(n, y):
  for i in range(n+1):
    for j in range(n+1-i):
      if 10000 * i + 5000 * j + 1000 * (n - i - j) == y:
        return i, j, n-i-j
  return -1, -1, -1
N, Y = map(int, input().split())
i, j, k = find(N, Y)
print("{} {} {}".format(i, j, k))

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

int main() {
  int N;
  cin >> N;
  int a = N / 100;
  int b = (N / 10) % 10;
  int c = N % 10;
  if (a == 7 || b == 7 || c == 7) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 3612
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=(1LL<<63) - 600;
const ll mod=1e9+7 ;

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

Measured memory_bytes: 256
fn solve() {
    let n: usize = read();
    let mut a: Vec<usize> = (0..n).map(|_| read::<usize>()).collect();
    a.sort();
    let l = n / 2 - 1;
    let r = n / 2;
    println!("{}", a[r] - a[l]);
}

fn main() {
    let stack_size = 104_857_600;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min, Reverse};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1_000_000_007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========


Measured memory_bytes: 2244
//include,using,define等
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>

// ===============================================================
//using系
#pragma region header
using namespace std;
using ll = long long;
using lint = long long;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;
using ui = unsigned int;
using qul = queue<ll>;
using pql = priority_queue<ll>;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#pragma region header
//#define int long long
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i <= n; i++)
#define INF (ll)10000000000000000
#define mod (ll)1000000007
#define P pair<lint,lint>
template <class T>
bool chmax(T& a, const T& b) {
	if (a < b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
template <class T>
bool chmin(T& a, const T& b) {
	if (a > b) {
		a = b;  // aをbで更新
		return true;
	}
	return false;
}
#pragma endregion
#pragma endregion


int main() {
	lint h, w; cin >> h >> w;
	lint n; cin >> n;
	vl a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	lint cnt = 0;
	vector<vector<lint>> d(h, vector<lint>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (i % 2 == 0) {
				if (a[cnt] != 0)
					d[i][j] = cnt + 1, a[cnt]--;
				else {
					cnt++;
					d[i][j] = cnt + 1;
					a[cnt]--;
				}
			}
			else {
				if (a[cnt] != 0)
					d[i][w - j - 1] = cnt + 1, a[cnt]--;
				else {
					cnt++;
					d[i][w - j - 1] = cnt + 1;
					a[cnt]--;
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (j != w - 1)
				cout << d[i][j] << ' ';
			else
				cout << d[i][j] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod =1000000007;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(b>=c-1){cout<<b+c;return 0;}
    else{cout<<2*b+1+min(c-b-1,a);}
}

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

int main(){
    int x; cin >> x;
    if(x==1) cout << 0 << endl;
    if(x==0) cout << 1 << endl;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long int n,d=0;
	cin>>n;
	vector <long long int> v(n);
	for(long long int i=0;i<n;++i)
	{
	    cin>>v[i];
	}
	sort(v.begin(),v.end());
	long long int p=n/2;
	cout<<v[p]-v[p-1];
	
}

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

int main(){
  int n,k;cin>>n>>k;
  int arr[n];
  for(int i=0; i<n; i++)cin>>arr[i];
  sort(arr,arr+n);
  long long ans=0;
  for(int i=0; i<n-k; i++){
  	ans+=arr[i];
  }
  cout<<ans<<endl;
  return 0;
}


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

    ll n;cin>>n;
    string s;
    vector<pair<char,ll>> v(5);
    vector<char> c={'M','A','R','C','H'};
    rep(i,5){
        v[i].first=c[i];
    }
    rep(i,n){
        cin>>s;
        char ini=s[0];
        rep(j,5){
            if(v[j].first==ini){
                v[j].second++;
                break;
            }
        }
    }
    ll sum=0;
    rep(i,3){
        ll a=v[i].second;
        for(int j=i+1;j<4;j++){
            ll b=v[j].second;
            for(int k=j+1;k<5;k++){
                ll c=v[k].second;
                sum+=a*b*c;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

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

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;


//void warshall_floyd(int n){
//    for(int k=0;k<n;k++){
//        for(int i=0;i<n;i++){
//            for(int j=0;j<n;j++){
//                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
//            }
//        }
//    }
//}
//ll calc_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        ++res;
//        N /= 10;
//    }
//    return res;
//}
//ll sum_digit(ll N) {
//    ll res = 0;
//    while (N) {
//        res += N % 10;
//        N /= 10;
//    }
//    return res;
//}

int main() {
    char z; cin >> z;
    isupper(z) ? cout << 'A':cout << 'a';
}




Measured memory_bytes: 3608
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, x;
  cin >> N >> x;
  vector<ll> a(N);
  ll ans = 0;
  ll prev_v;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
    if (a[i] > x) {
      prev_v = a[i];
      a[i] = x;
      ans += prev_v - a[i];
    }
  }
  for (int i = 0; i < N - 1; i++) {
    if (a[i] + a[i + 1] <= x) continue;
    prev_v = a[i + 1];
    a[i + 1] = prev_v - ((a[i] + a[i + 1]) - x);
    ans += prev_v - a[i + 1];
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
    ll n;
    cin >> n;
    string ans = "";
    for(int i = 1; i < log(1000000000000001); i++){
        if(n > pow(26, i)){
            n -= pow(26, i);
        } else {
            n--;
            for(int j = 0; j < i; j++){
                ans += 'a' + n % 26;
                n /= 26;
            }
            break;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

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

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

    if(s.length() < 26){
        for(int i=0; i<26; i++){
            char c = 'a' + i;
            if(s.find(c) == s.npos){
                s += c;
                cout << s << endl;
                return 0;
            }
        }
    }

    int x = 25;
    set<char> letter = {s[x]};

    while(x > 0 && s[x-1] > s[x]){
        letter.insert(s[x-1]);
        x -= 1;
    }
    x -= 1;
    if(x == -1){
        cout << -1 << endl;
        return 0;
    }

    string ans = s.substr(0,x);
    ans += *letter.lower_bound(s[x]);
    //letter.insert(s[x]);
    //for(char l : letter) ans += l;
    
    cout << ans << endl;
    return 0;
}

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

#define ll long long

using namespace std;

const int N = (int)2e5 + 7;

int n;

struct seg {
	ll tree[4 * N];
	
	seg() {
		memset(tree, 0, sizeof tree);
	}
	
	void upd(int pos, ll val, int v = 1, int l = 1, int r = n) {
		if (l == r) {
			tree[v] = val;
			return ;
		}
		int mid = (l + r) >> 1;
		if (pos <= mid)
			upd(pos, val, v + v, l, mid);
		else
			upd(pos, val, v + v + 1, mid + 1, r);
		tree[v] = max(tree[v + v], tree[v + v + 1]);
	}
	
	ll get(int l, int r, int v = 1, int tl = 1, int tr = n) {
		if (tl > r || tr < l) return 0;
		if (l <= tl && tr <= r) return tree[v];
		int mid = (tl + tr) >> 1;
		return max(get(l, r, v + v, tl, mid), get(l, r, v + v + 1, mid + 1, tr));
	}
};
seg tr;

int h[N], a[N];

main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &h[i]);
	}
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 1; i <= n; i++) {
		ll res;
		res = tr.get(1, h[i]) + a[i];
		tr.upd(h[i], res);
	}
	cout << tr.get(1, n);
}



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

using namespace std;

class Dice
{
public:
    int label[6];

    void in()
    {
        rep(i, 6) scanf("%d", &label[i]);
    }

    void roll(char cmd)
    {
        if (cmd == 'S')
        {
            int tmp = label[0];
            label[0] = label[4];
            label[4] = label[5];
            label[5] = label[1];
            label[1] = tmp;
        }
        else if (cmd == 'N')
        {
            int tmp = label[0];
            label[0] = label[1];
            label[1] = label[5];
            label[5] = label[4];
            label[4] = tmp;
        }
        else if (cmd == 'E')
        {
            int tmp = label[0];
            label[0] = label[3];
            label[3] = label[5];
            label[5] = label[2];
            label[2] = tmp;
        }
        else if (cmd == 'W')
        {
            int tmp = label[0];
            label[0] = label[2];
            label[2] = label[5];
            label[5] = label[3];
            label[3] = tmp;
        }
    }
};

int main()
{
    Dice d;
    d.in();
    string cmd;
    cin >> cmd;
    rep(i, cmd.length()) d.roll(cmd[i]);
    printf("%d\n", d.label[0]);
}



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

using ll = long long;
const ll MOD = 998244353;

int main() {
    int N;
    cin >> N;
    ll ans = 1, MOD = 1e9 + 7;
    for (int i = 1; i <= N; i++) {
        ans = (ans * i) % MOD;
    }
    cout << ans << endl;
}

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

int main() {
  int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >> y2;
  int x3, y3, x4, y4;
  int xdif = x2 - x1;
  int ydif = y2 - y1;
  x3 = x2 - ydif;
  y3 = y2 + xdif;
  x4 = x3 - xdif;
  y4 = y3 - ydif;
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long x, k, d, zahyou, move;
    cin >> x >> k >> d;
    if((abs(x)+d-1)/d<k){
    //座標の符号が途中で変化する場合
    zahyou = x%d;
    move = k-abs(x)/d;
    if(move%2!=0 && x>=0) zahyou -= d;
    else if(move%2!=0 && x<0) zahyou+=d;
    cout << abs(zahyou) <<endl;
    return 0;
    }
    else{
    //最後まで座標の符号が変化しない場合
    if(x>0) zahyou = x-(k*d);
    else zahyou = x + (k*d);
    cout << abs(zahyou) <<endl;
    return 0;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
int n,k;
cin >> n >> k >> s;
if(s[k-1]=='A'){
  s[k-1] = 'a';
}
else if(s[k-1]=='B'){
  s[k-1] = 'b';
}
else if(s[k-1]=='C'){
  s[k-1] = 'c';
}
cout << s;
return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int[] h = new int[N];
		for (int i = 0; i < N; i++) {
			h[i] = sc.nextInt();
		}
		
		int operations = 0;
		
		while(true) {
			int start = 0;
			int min = 0;
			int currentOperations = operations;
			for (int i = 0; i < N; i++) {
				if (h[i] > 0) {
					if (min == 0 || h[i] < min) {
						min = h[i];
					}
				} else {
					for (int j = start; j < i; j++) {
						h[j] -= min;
					}
					operations += min;
					start = i+1;
					min = 0;
				}
			}
			for (int j = start; j < N; j++) {
				h[j] -= min;
			}
			operations += min;
			
			if (currentOperations == operations) {
				break;
			}
		}
		
		System.out.println(operations);
	}
}


Measured memory_bytes: 21844