akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

int N; int A,B,C; vector<int> L;
int DFS(int pos,int la,int lb,int lc){
    if(pos==N){ 
    if(min({la,lb,lc})>0)return abs(A-la)+abs(B-lb)+abs(C-lc)-30;
    else return 1000000000;}
    int ret0=DFS(pos+1,la,lb,lc);
    int ret1=DFS(pos+1,la+L[pos],lb,lc)+10;
    int ret2=DFS(pos+1,la,lb+L[pos],lc)+10;
    int ret3=DFS(pos+1,la,lb,lc+L[pos])+10;
    return min({ret0,ret1,ret2,ret3});
}
main() {
    cin >> N >> A >> B >> C;
    rep(i,N){int a; cin >> a; L.push_back(a);}
    cout << DFS(0,0,0,0) << endl;

    return 0;
}

Measured memory_bytes: 256
/*
ID: computerbox --> Huseyn Hajiyev
LANG: C++
TASK: target_mode_on
*/
#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#define _CRT_SECURE_NO_WARNINGS
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
#define FAST_READ ios_base::sync_with_stdio(0);cin.tie(0);
#define in freopen("input.txt", "r", stdin);
#define out freopen("output.txt", "w", stdout);
#define ll long long
#define debt(x,y)cout<<"#x = "<<(x)<<" and "<<"#y = "<<(y)<<endl;
#define deb(x)cout<<"#x = "<<(x)<<endl;
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define CURTIME() cerr << clock() * 1.0 / CLOCKS_PER_SEC << endl
#define DTIME(ccc) __begin = clock(); ccc; cerr<<"Time of work = "<<(clock()-__begin)/CLOCKS_PER_SEC<<endl;
#define MAXN 2000

using namespace std;

ll k;
string stroka;

int main(){
FAST_READ;
cin>>stroka;
cin>>k;
for(ll i=0;i<min(k,(ll)stroka.size());i++)
{
  if(stroka[i]!='1')
  {
  	cout<<stroka[i]<<endl;
  	return 0;
  }
}
cout<<1<<endl;







return 0;
} 


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
 
#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl
 
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

int main()
{
    int n;
    cin>>n;
    vector<int> dp(3);
    rep(i,0,n)
    {
        vector<int> new_dp(3,0);
        vector<int>c(3);
        rep(j,0,3)
        cin>>c[j];
        rep(k,0,3){
        rep(j,0,3)
        {
            if(k!=j){
                new_dp[j]=max(new_dp[j],dp[k]+c[j]);
            }
        }
        }
    dp=new_dp;
    }   
cout<<max(dp[0],max(dp[1],dp[2]));
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define L_T_S_K ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);  
const int mod = 1e9 + 7;
const int N = 2e5;
int visit[N] , color[N];
std::vector<int> v[N];
bool cycle = false;
int cnt = 0;
void dfs(int src , int col){
  visit[src] = 0;
  color[src] = col;
  cnt++;
  cout << src << " ";
  for(auto x : v[src]){
    if(visit[x] == -1){
      dfs(x , col^1);
    }else if(visit[x] == 0){
      continue;
    }else cycle = true;
  }
  visit[src] = 1;
}

int32_t main(){
 L_T_S_K;
  string s , ss;
  cin >> s >> ss;
  cout << ss + s << " ";
  return 0;
}

Measured memory_bytes: 6400
#include<iostream>
#include<vector>
#include<string>
using namespace std;
int main(){
	const string day[]={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	const int month[]={31,31,29,31,30,31,30,31,31,30,31,30};
	int m,d;
	while(cin>>m>>d,m||d){
		int res=2;
		for(int i=1;i<m;++i){
			res+=month[i%12];
		}
		res+=d;
		cout<<day[res%7]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ll n;
	cin>>n;
	if(n%2==0)
	 {
	 	cout<<n/2<<endl;
	 }
	 else
	 {
	 	cout<<n/2+1<<endl;
	 }
	 return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LL long long
#define REP(i, n) for(int i=0;i<(n);++i)
#define REPA(i, n) for(int i=1;i<(n);++i)
#define lp(i, n) for(int i=-;i<(n);++i)
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9)
#define DEKAI ((int)1e9+7)
#define ALL(x) (x).begin(), (x).end()
#define BIT(x) (1<<(x))
#define foreach(i, n) for(auto &i:(n))
using namespace std;

int num;
int getnum(char c){
    int x = num;
    if(c=='a')return (x/1000)%10;
    if(c=='b')return (x/100)%10;
    if(c=='c')return (x/10)%10;
    if(c=='d')return x%10;
}

PII func(string &str, int place){
    if(str[place]!='[')return PII(getnum(str[place]), place+1);
    ++place;
    PII res=PII(0, 0);
    if(str[place]=='+'){
        ++place;
        res = func(str, place);
        place=res.second;
        PII d = func(str, place);
        res.first|=d.first;
        res.second=d.second;
    }else if(str[place]=='*'){
        ++place;
        res = func(str, place);
        place=res.second;
        PII d = func(str, place);
        res.first&=d.first;
        res.second=d.second;
    }else{
        ++place;
        res = func(str, place);
        place=res.second;
        PII d = func(str, place);
        res.first^=d.first;
        res.second=d.second;
    }
    ++res.second;
    return res;
}

int main(){
    string str;
    while(cin>>str&&str!="."){
        cin >> num;
        int ans = func(str, 0).first;
        int count = 0;
        REP(i, 10000){
            num=i;
            if(func(str, 0).first==ans)++count;
        }
        cout << ans << " " << count << endl;
    }
    return 0;
}



Measured memory_bytes: 3180
/*
    Author: Alam Khan
    AUST CSE 40th Batch

*/

#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

typedef long long ll;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
#define pb     push_back
#define inf     2e18
#define low     -2e18
#define PI        acos(-1.0)
#define endl  "\n"
#define FAST  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
const int sz = 1e5+9;

int main()
{
    ll i,n,t,k,j,x=0,y=0,m,r=0,w=0;
    string str;
    cin>>n>>str;
    bool f = 0;
    ll ans = inf;
    for(i=n-1;i>=0;i--)
    {
        if(str[i]=='R')
        {
            r++;
            f = 1;
        }
        else
        {
            w++;
            if(f)
                y++;
        }
    }
    ans = min(ans,y);
    ans =  min(ans,r);
    ans= min(ans,w);
    for(i=0;i<r;i++)
    {
        if(str[i]=='W')
            x++;
    }
    ans = min(ans,x);
    cout<<ans<<endl;
    return 0;
}



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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define pb push_back
typedef long long ll;
#define int long long
#define ld long double
#define f(i,n) for(ll i=0;i<n;i++)
#define fo(i,a,b) for(ll i=a;i<=b;i++)
#define forr(i,a,b) for(ll i=a;i>=b;i--)
#define ee endl
#define mem(a,b) memset(a,b,sizeof(a))
#define bp __builtin_popcount
#define all(x) (x).begin(),(x).end()
#define s(x) sort(all(x))
#define r(x) reverse(all(x))
#define sz size()
#define ln length()
#define mod 1000000007
#define INF LONG_LONG_MAX
#define MINF LONG_LONG_MIN
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second 
#define mxe(v) *max_element(all(v))
#define vl vector<ll>
#define pll pair<ll,ll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 
#define KHILADI ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))

ll max(ll a , ll b){ if(a>b) return a; else return b;}
ll min(ll a , ll b){ if(a<b) return a; else return b;}

ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}          
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

/*const ll N=2005;
ll dep[N]={0};
bool v[N]={0};
vl adj[N+1];

void dfs(int x)
{
    v[x]=1;
    for(auto i:adj[x])
    {
        if(v[i]==0)
        {
            dep[i]=dep[x]+1;
            dfs(i);
        }
    }
    return;
}*/

void solve()
{
    string a,b;
    cin >> a >> b;
    ll n=a.ln;
    string tmp=b.substr(n,1);
    if(a+tmp == b)
        cout << "Yes";
    else
        cout << "No";
    return;
}

signed main()
{
    KHILADI;
    ll t=1;
    //cin >> t;
    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3644
import java.io.*;
import java.util.*;

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        int w = in.nextInt();
        if (w == 1){
            out.println(s);
            return;
        }
        StringBuilder res = new StringBuilder();
        for (int i = 0; i < s.length(); i+=w) {
            res.append(s.charAt(i));
        }
        out.println(res);
    }


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

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

}


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<<30)-1)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()




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

	int x;
	cin >> x;
	cout << (x >= 30 ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e18
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

const int maxn = 22;
ll dp[1 << maxn];
vl ons[(1 << maxn) + 1];

void solve() {
	ll n;
	cin >> n;
	ll a[n][n];
	rep(i, n) rep(j, n) cin >> a[i][j];

	vl masks[n + 1];
    // clock_t z = clock();

	// rep(mask, 1 << n) {
	// 	rep(j, n) {
	// 		if (mask & (1 << j)) ons[mask].pb(j);
	// 	}
	// }
    // cout << (double)(clock() - z) / CLOCKS_PER_SEC << endl;

	memset(dp, 0, sizeof(dp));
	dp[0] = 1;
	FOR(mask, 1, (1 << n) - 1) {
		ll i = __builtin_popcount(mask);
		dp[mask] = 0;
		rep(j, n) {// for (ll j  0 ons[mask]) {
			if (mask & (1 << j)) 
				if (a[i-1][j]) 
					dp[mask] = (dp[mask] + dp[mask ^ (1 << j)]) % MOD;
		}
	}

	cout << dp[(1 << n) - 1] << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // clock_t z = clock();
    // cin >> t;
    while (t--) {

        solve();
    }
    // cout << (double)(clock() - z) / CLOCKS_PER_SEC << endl;
}


Measured memory_bytes: 131328
#include "bits/stdc++.h"
#define MOD 100000
#define INF 11234567890
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int n, m, s[112345], a[112345];
int pos, ans;

int main()
{
	in >> n >> m;
	rep(i, n - 1) { in >> s[i + 1]; }
	rep(i, m) { in >> a[i]; }

	rep(i, n) { s[i + 1] += s[i]; }
	rep(i, m)
	{
		ans += abs(s[pos + a[i]] - s[pos]);
		pos += a[i];
		ans %= MOD;
	}

	out << ans << std::endl;
	return 0;
}

Measured memory_bytes: 3868
#include <iostream>
#include <cstdio>
#include <queue>

using namespace std;

typedef long long ll;

ll n, base = 1;
ll a[200005];
ll d[1000005];
ll c[1000005];

struct st
{
    ll s, e, x, i;
};

bool operator < (st p, st q)
{
    return p.x > q.x;
}

priority_queue<st> pq;

ll f(ll p, ll q)
{
    if(p % 2 == 0)
    {
        p += base;
        q += base;
        ll re = n;
        while(p < q)
        {
            if(p % 2 == 1)
            {
                if(a[re] > a[c[p]]) re = c[p];
                p++;
            }
            if(q % 2 == 0)
            {
                if(a[re] > a[c[q]]) re = c[q];
                q--;
            }
            p /= 2;
            q /= 2;
        }
        if(p == q)
        {
            if(a[re] > a[c[p]]) re = c[p];
        }
        return re;
    }
    else
    {
        p += base;
        q += base;
        ll re = n;
        while(p < q)
        {
            if(p % 2 == 1)
            {
                if(a[re] > a[d[p]]) re = d[p];
                p++;
            }
            if(q % 2 == 0)
            {
                if(a[re] > a[d[q]]) re = d[q];
                q--;
            }
            p /= 2;
            q /= 2;
        }
        if(p == q)
        {
            if(a[re] > a[d[p]]) re = d[p];
        }
        return re;
    }
}

int main()
{
    scanf("%lld", &n);
    while(base < n) base *= 2;
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
        if(i % 2 == 0) c[i + base] = i, d[i + base] = n;
        else d[i + base] = i, c[i + base] = n;
    }
    a[n] = 4e18;
    for(ll i = base - 1; i >= 1; i--)
    {
        if(a[c[i * 2]] < a[c[i * 2 + 1]]) c[i] = c[i * 2];
        else c[i] = c[i * 2 + 1];
        if(a[d[i * 2]] < a[d[i * 2 + 1]]) d[i] = d[i * 2];
        else d[i] = d[i * 2 + 1];
    }
    ll t = f(0, n - 1);
    pq.push({0, n - 1, a[t], t});
    while(!pq.empty())
    {
        st t1 = pq.top();
        pq.pop();
        printf("%lld ", t1.x);
        ll t2 = f(t1.i + 1, t1.e);
        printf("%lld ", a[t2]);
        if(t1.s <= t1.i - 1)
        {
            ll t3 = f(t1.s, t1.i - 1);
            pq.push({t1.s, t1.i - 1, a[t3], t3});
        }
        if(t1.i + 1 <= t2 - 1)
        {
            ll t4 = f(t1.i + 1, t2 - 1);
            pq.push({t1.i + 1, t2 - 1, a[t4], t4});
        }
        if(t2 + 1 <= t1.e)
        {
            ll t5 = f(t2 + 1, t1.e);
            pq.push({t2 + 1, t1.e, a[t5], t5});
        }
    }
    return 0;
}


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

int a[105], b[105];

int main(){

    int n; cin >> n;
    for(int i = 0; i < n-1; i++)
        cin >> b[i];
    if(n == 2){
        cout << b[0] + b[0] << endl;
        return 0;
    }
    
    a[0] = b[0];
    a[n-1] = b[n-2];
    
    for(int i = 1; i < n-1; i++){
        if(b[i-1] < b[i])
            a[i] = b[i-1];
        else
            a[i] = b[i];
    }
    
    int sum = 0;
    for(int i = 0; i < n; i++)
        sum += a[i];
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
using System;


namespace Sample
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] str = Console.ReadLine().Split(' ');
            int[] a = Array.ConvertAll(str, int.Parse);
            for(int i = 0; i < n - 1; i++)
            {
                a[i + 1] = lcm(a[i],a[i+1]);
            }
            Console.WriteLine(a[n - 1]);
        }

        static int gcd(int a,int b)
        {
            int x = a, y = b, r;
            while(y != 0)
            {
                r = x % y;
                x = y;
                y = r;
            }
            return x;
        }

        static int lcm(int a, int b)
        {
            return (a * b) / gcd(a, b);
        }
    }
}

Measured memory_bytes: 9156
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int ceil_ten(int x) {
    if (x % 10 == 0) return x;
    else return x + (10 - x % 10);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<int> a(5);
    rep(i, 5) cin >> a[i];
    int ans = INF;

    rep(last, 5) {
        int sum = 0;

        rep(i, 5) {
            if (i == last) sum += a[i];
            else sum += ceil_ten(a[i]);
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include "stdio.h"

int main() {
  int N;
  scanf("%d", &N);
  int weight[100] = {};
  int min = 100000;
  int temp[100] = {};
  temp[0] = 10000;

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

  for(int j = 1; j < N; j++){
    int S_1 = 0;
    int S_2 = 0;
    //printf("S1 %d\n", S_1);

    for(int k = 0; k < j; k++){
      S_1 += weight[k];
      //printf("S1 %d\n", S_1);
    }
    for(int l = N - 1; l >= j; l--){
      S_2 += weight[l];
      //printf("S2 %d\n", S_2);
    }
    temp[j] = abs(S_1 - S_2);

    //printf(" temp %d\n", temp[j]);

    if(temp[j]< temp[j -1]){
      min = temp[j];
    }
  }
  printf("%d", min);

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
//小数点以下　cout << fixed << setprecision(10) << num << endl;
//桁数はlog10(mid)でやれ　log(mid)/log(10)はWA
//long*long<0で判定するな
//開区間と閉区間
//アルファベットが何番目かは x=s[i]-'a'
//bfsはmain()内で　rep(i,h)rep(j,w)rep(i,4)でバグ
//切り上げ：(a+(b-1))/b
//32bit以上は 1ull<<j]

int main(){
    int n;
    cin >> n;
    int a[3*n];
    ll x[3*n],y[3*n];
    priority_queue<int,vector<int>,greater<int>> l;
    priority_queue<int> r;
    x[n-1]=y[2*n]=0;
    rep(i,3*n){
        cin >> a[i];
        if(i<n){
            x[n-1]+=a[i];
            l.push(a[i]);
        }
        else{
            if(l.top()<a[i]){
                x[i]=x[i-1]-l.top()+a[i];
                l.pop(); l.push(a[i]);
            }
            else x[i]=x[i-1];
        }
    }
    for(int i=3*n-1;i>=0;i--){
        if(i>=2*n){
            y[2*n]+=a[i];
            r.push(a[i]);
        }
        else{
            if(r.top()>a[i]){
                y[i]=y[i+1]-r.top()+a[i];
                r.pop(); r.push(a[i]);
            }
            else y[i]=y[i+1];
        }
    }
    ll ans=x[n-1]-y[n];
    for(int i=n-1;i<2*n;i++){
        ans=max(ans,x[i]-y[i+1]);
    }
    cout << ans << endl;

}


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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis,dis;

vector<vi> graph;
vector<vector<pair<li,li>>> wgraph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    wgraph.resize(n);
    dis.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
        dis[i]=0;
    }
}

void dfs(li u)
{
    vis[u]=1;
    dis[u]=0;

    for(li v:graph[u])
    {
        if(!vis[v])
        {
            dfs(v);
        }
        
        dis[u]=max(dis[u],dis[v]+1);
    }
}

int main()
{    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li n,m;

    cin>>n>>m;

    init(n+1);

    vi indeg(n+1);

    f(i,0,m-1)
    {
        li u,v;

        cin>>u>>v;

        graph[u].PB(v);
        // graph[v].PB(u);

        indeg[v]++;
    }

    f(i,1,n)
    {
        if(!indeg[i])
        {
            dfs(i);
        }
    }

    li ans=0;

    f(i,1,n)
    {
        ans=max(ans,dis[i]);
    }

    cout<<ans;

    return 0;
}

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

int main() {
    int H, W; cin >> H >> W;
    vector<vector<char>> map(H+2, vector<char>(W+2, '#'));
    int cnt = 0;
    for(int i=1; i<H+1; i++){
        for(int j=1; j<W+1; j++){
            cin >> map.at(i).at(j);
            if(map.at(i).at(j) == '.') cnt++;
        }
    }

    vector<vector<int>> dist(H+2, vector<int>(W+2, -1));
    dist.at(1).at(1) = 0;
    
    queue<int> quex;
    queue<int> quey;
    quex.push(1);
    quey.push(1);
    while(!quex.empty() && !quey.empty()){
        int x, y;
        x = quex.front();
        y = quey.front();
        quex.pop();
        quey.pop();

        if(dist.at(y+1).at(x) == -1 && map.at(y+1).at(x) != '#'){
            quex.push(x);
            quey.push(y+1);
            dist.at(y+1).at(x) = dist.at(y).at(x) + 1;
        }

        if(dist.at(y).at(x+1) == -1 && map.at(y).at(x+1) != '#'){
            quex.push(x+1);
            quey.push(y);
            dist.at(y).at(x+1) = dist.at(y).at(x) + 1;
        }

        if(dist.at(y-1).at(x) == -1 && map.at(y-1).at(x) != '#'){
            quex.push(x);
            quey.push(y-1);
            dist.at(y-1).at(x) = dist.at(y).at(x) + 1;
        }

        if(dist.at(y).at(x-1) == -1 && map.at(y).at(x-1) != '#'){
            quex.push(x-1);
            quey.push(y);
            dist.at(y).at(x-1) = dist.at(y).at(x) + 1;
        }
    }

    if(dist.at(H).at(W) == -1){
        cout << -1 << endl;
        return 0;
    }

    cout << cnt - dist.at(H).at(W) - 1<< endl;

}

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

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

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

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  int n; cin>>n;
  vi s(100005);
  rep(i,n){
    int a; cin>>a;
    s[a]++;
  }
  int cnt=0;
  rep(i,100005){
    if(s[i]>1) cnt+=s[i]-1;
  }
  int ans=n-cnt;
  if(cnt%2) ans--;
  cout<<ans<<endl;
}


Measured memory_bytes: 640
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,K;
    cin >> N >> K;
    ll A[200010];
    rep(i,0,N) cin >> A[i];
    sort(A, A+N);
    ll zero = 0;
    rep(i,0,N){
        if(A[i] == 0) zero++;
    }
    vector<ll> plus, minus;
    rep(i,0,N){
        if(A[i] > 0) plus.push_back(A[i]);
        else if(A[i] < 0) minus.push_back(A[i]);
    }
    ll zero_cnt = N*(N-1)/2 - (N-zero) * (N-zero-1) / 2;
    ll lv = -1e18+1, rv = 1e18+1;
    while(rv - lv > 1){
        ll mid = (rv + lv) / 2;
        bool ok = true;
        ll res = 0;
        ll res_tmp = 0;
        rep(i,0,plus.size()){
            ll v = plus[i];
            ll lv1 = i, rv1 = plus.size();
            while(rv1 - lv1 > 1){
                ll mid1 = (lv1 + rv1) / 2;
                if(v * plus[mid1] <= mid){
                    lv1 = mid1;
                }else{
                    rv1 = mid1;
                }
            }
            res += lv1 - i;
            lv1 = -1, rv1 = minus.size();
            while(rv1 - lv1 > 1){
                ll mid1 = (rv1 + lv1) / 2;
                if(v * minus[mid1] <= mid){
                    lv1 = mid1;
                }else{
                    rv1 = mid1;
                }
            }

            res_tmp += lv1+1;
            // if(mid == -7) print(lv1);
            // print(res);
        }
        reverse(plus.begin(), plus.end());
        reverse(minus.begin(), minus.end());
        // if(mid == 6) print(res);
        // print("===", res);
    
        rep(i,0,minus.size()){
            ll v = minus[i];
            ll lv1 = i, rv1 = minus.size();
            while(rv1 - lv1 > 1){
                ll mid1 = (lv1 + rv1) / 2;
                if(v * minus[mid1] <= mid){
                    lv1 = mid1;
                }else{
                    rv1 = mid1;
                }
            }
            res += lv1 - i;
            lv1 = -1, rv1 = plus.size();
            while(rv1 - lv1 > 1){
                ll mid1 = (rv1 + lv1) / 2;
                if(v * plus[mid1] <= mid){
                    lv1 = mid1;
                }else{
                    rv1 = mid1;
                }
            }
            res_tmp += rv1;
        }
        reverse(plus.begin(), plus.end());
        reverse(minus.begin(), minus.end());
        // if(mid == 6) print(res);
        // print(res);
        // if(mid == -7) print(res);

        res += res_tmp/2;
        if(mid >= 0) res += zero_cnt;
        // print(mid, res);



        if(res >= K){
            ok = true;
        }else{
            ok = false;
        }

        if(ok){
            rv = mid;
        }else{
            lv = mid;
        }
    }
    print(rv);

    

}

Measured memory_bytes: 4084
#include<stdio.h>
#include<math.h>
int main(){
    double a, b, h, m;
    scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
    double ans = M_PI * (m / 30 - (h * 60 + m) / 360);
    printf("%.10f\n",sqrt(a * a + b * b - a * b * cos(ans) * 2));
    return 0;
}

Measured memory_bytes: 2604
/* kadai6_1
   reo012 */

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

#define SIZE 110

int main(void){
    char word[SIZE];    //単語入る配列word用意
    int length;    //単語の文字数length用意
    scanf("%s", word);    //単語入力
    length = (int)strlen(word);    //単語の文字数取得
    putchar(word[0]);    //始めの文字出力（改行なし）
    printf("%d", length-2);    //最初と最後の文字を除いた文字数出力（改行なし）
    putchar(word[length-1]);    //最後の文字出力（改行なし）
    printf("\n");    //改行
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<numeric>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
//scanf("%d", &a); '\n'; cout << fixed << setprecision(10);

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, r;
	cin >> n >> r;
	if (n >= 10) cout << r;
	else cout << 100 * (10 - n) + r;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

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

  int a;
  string s;
  while(cin >> a >> s){
    cout << (a >= 3200 ? s : "red") << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h> 
#include <stdio.h>
#include <queue>
#include <utility>//pair
#include <cmath>//abs()
using namespace std;
#define MAX 200000
#define rep(i, n) for(int i = 0;i < n;i++)
#define in(n) scanf("%d",&n);
#define out(n) printf("%d\n",n);
#define in2(n,k) scanf("%d%d",&n,&k);

int main(){
    int w,a,b,ans;
    cin>>w>>a>>b;
    if(a<b)ans=b-w-a;
    else if(b<a)ans=a-w-b;
    else ans=0;
    if(ans<0)cout<<0<<endl;
    else cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$sc = new Scanner();
$n = $sc->nextInt();
$m = $sc->nextInt();

if($n == $m) {
    out::println('Yes');
} else if($n > $m) {
    out::println('No');
} else {
    out::println('No');
}


?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

void solve() {
  int N; cin >> N;
  string name;
  unordered_map<char, ll> initial;
  rep(i,N) {
    cin >> name;
    ++initial[name[0]];
  }
  
  string MARCH = "MARCH";
  ll ans = 0;
  for (int i=0; i<3; ++i) {
    char x = MARCH[i];
    for (int j=i+1; j<4; ++j) {
      char y = MARCH[j];
      for (int k=j+1; k<5; ++k) {
        char z = MARCH[k];
        ans += initial[x] * initial[y] * initial[z];
      }
    }
  }

  cout << ans << endl;
  return;
}

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


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		for(;;){
			int N=cin.nextInt();
			if(N==0)break;
			Team[] t=new Team[N];
			int team=0;
			Map<Integer, Integer>map=new HashMap<Integer,Integer>();
			for(int i=0;i<N;i++){
				int a=cin.nextInt();
				int b=cin.nextInt();
				int c=cin.nextInt();
				int d=cin.nextInt();
				t[i]=new Team(a,b,c,d);
				if(!map.containsKey(b)){
					map.put(b, 0);
				}
			}
			Arrays.sort(t);

			
			
			for(int i=0;i<N;i++){
				int belong=t[i].belong;
//				System.out.println(map.get(belong));
				if(team<10){
					if(map.get(belong)<3){
						t[i].okay=true;
						map.put(belong, map.get(belong)+1);
						team++;
					}
				}
				else if(team<20){
					if(map.get(belong)<2){
						t[i].okay=true;
						map.put(belong, map.get(belong)+1);
						team++;
					}
				}
				else if(team<26){
					if(map.get(belong)<1){
						t[i].okay=true;
						map.put(belong, map.get(belong)+1);
						team++;
					}
				}
			}
			for(int i=0;i<N;i++){
				if(t[i].okay)
					System.out.println(t[i].id);
			}
		}
	}
	static class Team implements Comparable<Team>{
		int id, belong, solve, pena;
		boolean okay;
		Team(int a,int b,int c,int d){
			id=a;
			belong=b;
			solve=c;
			pena=d;
			okay=false;
		}
		public int compareTo(Team t){
			if(solve==t.solve){
				if(pena==t.pena){
					return id-t.id;
				}
				return pena-t.pena;
			}
			return t.solve-solve;
		}
	}
}

Measured memory_bytes: 21056
#include <boost/multiprecision/cpp_int.hpp> 
#include <bits/stdc++.h>
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define w while
#define ll long long
#define ul ull64_t
#define f(i,a,n) for(auto i=a;i<n;i++)
#define in(k,a) for(auto k:a)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define el endl

using namespace boost::multiprecision;
using namespace std;

typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef vector<ll> vi;
typedef unordered_map<ll,ll> map1;
const ll MOD = 2019; 
int main()
{   
	SPEED
	// insert your code here... 3456
	string str;cin>>str;
	int n = str.length();
	map1 cnt_suf;
	cnt_suf[0] = 1;
	int suf = 0, ct = 0, power_of_ten = 1;
	for(int i = n-1;i>=0 ;i-- ){
		int digit = str[i] - '0';
		suf = (suf + digit * power_of_ten) % MOD;
		power_of_ten = 10*power_of_ten % MOD;
		ct += cnt_suf[suf];
		cnt_suf[suf]++;
	}
	cout<<ct;
	return 0;
}


Measured memory_bytes: 3696
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int N;
  cin >> N;

  int sum = 0;
  vector<int> A(N+1);
  for (int &a:A) {
    cin >> a;
    sum += a;
  }

  if (N == 0 && A[0] == 1) {
    cout << 1 << endl;
    return;
  }

  if (A[0]) {
    cout << -1 << endl;
    return;
  }

  int ans = 1;
  int oya = 1;
  for (int d = 1; d <= N; d++) {
    if (oya * 2 < A[d]) {
      cout << -1 << endl;
      return;
    }

    ans += A[d];
    ans += min(oya * 2 - A[d], sum-A[d]);
    oya = min(oya * 2 - A[d], sum-A[d]);
    sum -= A[d];
  }

  cout << ans << endl;
}

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


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;

#define MAX 1000000005

int main(){
  int h,w,n; cin >> h >> w >> n;
  vi a(n);
  rep(i,n)
    cin >> a[i];
  
  int ans[100][100];
  
  int index = 0;
  rep(i,h)
    rep(j,w){
      if(i%2 == 0){
        ans[i][j] = index +1;
      }else{
        ans[i][w-j-1] = index +1;
      }
      a[index]--;
      if(a[index] == 0)
        index++;
    }
  rep(i,h)
    rep(j,w)
      if(j != w-1)
        cout << ans[i][j] <<" ";
      else
        cout << ans[i][j] << endl;
}

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

int main(void)
{
    int a,b,c,temp=0;
    cin >> a>> b>> c;
    temp=a;
    a=b;
    b=temp;
    temp=a;
    a=c;
    c=temp;
    cout << a <<" "<< b <<" "<< c;



    return 0;

}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int x = stdIn.nextInt();
		int y = 0;
		int max = Integer.MIN_VALUE;
		
		if(x==1) {
			System.out.println(1);
			return;
		}
		
		for(int i = 1; i < x; i++) {
			for(int j = 2; j < 15; j++) {
				if(Math.pow(i,j) <= x && max < Math.pow(i, j)) {
					max = (int)Math.pow(i, j);
				}
			}
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 21844
/*by freesteed*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define pb push_back
#define fill(x,c) memset(x,c,sizeof(x))
#define fi first
#define se second
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define caset int ___T; cin>>___T; for(int cs=1;cs<=___T;cs++)
#define get_be(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
//get_be biger & equal
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
const ll mod=1e9+7;
const ll oo=1e9+10;
const int Max = 1e6+10;
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
//ll a[Max];
ll n,ans;
int A[20];
int x[20][20];
int y[20][20];
int count(int x){
	if(x==0)return 0;
	return count(x>>1)+(x&1);
}
void solve(){
	cin>>n;
	rep(i,1,n+1){
		cin>>A[i];
		rep(j,1,A[i]+1){
			cin>>x[i][j]>>y[i][j];
		}
	}
	for(int bits=1;bits<(1<<n);bits++){
		int ok = 1;
		for(int i=1;i<=n;i++){
			if(bits&(1<<(i-1))){
				for(int j=1;j<=A[i];j++){
//					if((bits&(1<<(x[i][j]-1)?1:0))^y[i][j]){
//						ok = 0;
//					}
					if(bits>>(x[i][j]-1)&1^y[i][j])ok = 0;
				}
			}
		}
		if(ok)ans = max(ans,(ll)count(bits));
	}
	cout<<ans;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//caset{
		solve();
	//}
  	return 0;
}





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

using namespace std;

typedef long long  ll;

inline bool isOperator(char c) {
    return (c == '+') || (c == '-') || (c == '*') || (c == '/');
}

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

    string s;
    getline(cin, s);
    s += " ";
    const int n = s.size();
    int idx = 0;
    stack<int> st;

    while (idx < n) {
        int nxt_idx = idx + 1;
        while (nxt_idx < n && s[nxt_idx] != ' ')
            ++nxt_idx;

        if (nxt_idx - idx == 1 && isOperator(s[idx])) {
            int a = st.top(); st.pop();
            int b = st.top(); st.pop();

            if (s[idx] == '+')
                st.push(b + a);
            else if (s[idx] == '-')
                st.push(b - a);
            else if (s[idx] == '*')
                st.push(b * a);
            else if (s[idx] == '/')
                st.push(b / a);
        }
        else {
            int elem = stoi(s.substr(idx, nxt_idx - idx));
            st.push(elem);
        }

        idx = nxt_idx + 1;
    }

    cout << st.top() << endl;

    return 0;
}

Measured memory_bytes: 1208
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
using namespace std;
int main(void)
{
    int a,b,c,d;
    int t[105];
    while(cin>>a>>b>>c>>d)
    {
        memset(t,0,sizeof(t));
        int mac=max(b,d);
        int mi=min(a,c);
        for(int i=a;i<b;i++)
            t[i]++;
        for(int i=c;i<d;i++)
            t[i]++;
        int tot=0;
        for(int i=mi;i<=mac;i++)
            if(t[i]==2) tot++;
        printf("%d\n",tot);
    }
    return 0;
}


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

struct Node{
	vector<int> arr;
	int step;
};
const int tx[]={1,0,-1,0};
const int ty[]={0,1,0,-1};
vector<int> start,end;
queue<Node> sq;
set<int> pan;

void input()
{
	int tmp;
	for(int i=0;i!=3;++i)
		for(int j=0;j!=3;++j)
		{
			cin>>tmp;
			start.push_back(tmp);
		}
	for(int i=0;i!=8;++i)
		end.push_back(i+1);
	end.push_back(0);
}

Node makenod(vector<int> tmp,int step)
{
	Node res;
	res.arr=tmp;
	res.step=step;
	return res;
}

int vton(vector<int> tmp)
{
	int res=0;
	for(int i=0;i!=9;++i)
		res=res*10+tmp[i];
	return res;
}

/*
void print(vector<int> tmp)
{
	for(int i=1;i!=10;++i)
	{
		cout<<tmp[i-1]<<' ';
		if(i%3==0)	cout<<endl;
	}
	cout<<endl;
}
*/
int main()
{
	input();

	sq.push(makenod(start,0));
	pan.insert(vton(start));

	int ans;
	while(!sq.empty())
	{
		Node now=sq.front();	sq.pop();

		//print(now.arr);

		if(now.arr==end)
		{
			ans=now.step;
			break;
		}

		int ith;
		for(int i=0;i!=9;++i)
			if(now.arr[i]==0)
			{
				ith=i;
				break;
			}
		int x=ith/3,y=ith%3;

		for(int i=0;i!=4;++i)
		{
			int nx=x+tx[i],ny=y+ty[i];
			if(nx>=0 && nx<3 && ny>=0 && ny<3)
			{
				swap(now.arr[nx*3+ny],now.arr[ith]);
				int num=vton(now.arr);
				if(pan.count(num)==0)
				{
					sq.push(makenod(now.arr,now.step+1));
					pan.insert(num);
				}
				swap(now.arr[nx*3+ny],now.arr[ith]);
			}
		}
	}

	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 12280
#include <cstdio>
#include <cstring>

#define mx 200005
char S[mx],T[mx];

int main(){
    scanf("%s",S);
    scanf("%s",T);

    int ans=0;
    for(int i=0;i<strlen(S);i++)
        ans+=(S[i]!=T[i]);
    printf("%d\n",ans);
}


Measured memory_bytes: 2084
#include <stdio.h>
#include <iostream>

using namespace std;

int main() {
	double a,b,c,d,e,f;
	double x,y;

	while (cin >> a >> b >> c >> d >> e >> f) {

		y = (c * d - a * f) / (b * d - a * e);
		x = (c * e - b * f) / (a * e - b * d);

		if (x == -0) {
			x = 0;
		}

		if (y == -0) {
			y = 0;
		}

		printf("%.3f %.3f\n", x , y);
	}

	return 0;
}

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

using namespace std;

#define FOR(i, a, n) for(int i = a; i < n; ++i)
#define ll long long

bool checkPalindrome(string s) {

	FOR(i, 0, s.size()) {
		if (s[i] != s[s.size()-1-i])
			return false;
	}
	return true;
}

int main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif

  	string s; cin >> s;
  	int n = s.size();

  	if (checkPalindrome(s)) {
  		if (checkPalindrome(s.substr(0, (n - 1) / 2))) {
  			if (checkPalindrome(s.substr(((n + 3) / 2)- 1))) {
  				printf("Yes\n");
  			}
  			else
  				printf("No\n");
  		}
  		else
  			printf("No\n");
  	}
  	else
  		printf("No\n");


	return 0;
}


// g++ -std=c++11 -o solve solve.cpp
// ./solve < input.txt


Measured memory_bytes: 256