akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
typedef __int128_t lll;
using namespace std;

int main(int argc, char const *argv[]) {
  vvl d = vv(3, 3, 0, ll);
  re(i, 3) re(j, 3) std::cin >> d[i][j];
  ll n;std::cin >> n;
  re(i, n){
    ll b;std::cin >> b;
    re(j, 3) re(k, 3) if(d[j][k]==b) d[j][k] = -1;
  }
  bool flag = false;
  re(i, 3){
    if(d[i][0]==-1&&d[i][1]==-1&&d[i][2]==-1) flag = true;
    if(d[0][i]==-1&&d[1][i]==-1&&d[2][i]==-1) flag = true;
  }
  if(d[0][0]==-1&&d[1][1]==-1&&d[2][2]==-1) flag = true;
  if(d[0][2]==-1&&d[1][1]==-1&&d[2][0]==-1) flag = true;
  std::cout << (!flag?"No":"Yes") << '\n';
  return 0;
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> w(n,0);
    vector<int> e(n,0);
    for (int i = 0; i < n-1; i++)
    {
        w[i+1] = w[i];
        if (s[i]=='W')
        {
            w[i+1] = w[i+1]+1;
        }
    }
    for (int i = n-1; i > 0; i--)
    {
        e[i-1] = e[i];
        if (s[i] == 'E')
        {
            e[i-1] = e[i-1]+1;
        }
    }
    int ans = INF;
    //for (auto &&i : e)cout << i;
    //cout << endl;
    //for (auto &&i : w)cout << i;
    //cout << endl;
    

    rep(i,n)
    {
       ans = min(ans, e[i]+w[i]); 
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REP(a, b, m) for (ll a = (ll)(b); a < (ll)(m); a++)

int main()
{
    ll n;
    cin >> n;
    vector<string> v(n);
    ll ans = 0;
    rep(i, n)
    {
        cin >> v[i];
        sort(v[i].begin(), v[i].end());
    }
    sort(v.begin(), v.end());
    ll memo = 0;
    rep(i, n)
    {

        if (i == 0)
        {
            memo++;
        }
        else if (v[i] == v[i - 1])
        {
            memo++;
        }
        else
        {
            ans += memo * (memo - 1) / 2;
            memo = 1;
        }
        if (i == n - 1)
        {
            ans += memo * (memo - 1) / 2;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 7296
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    vite;
    lli a;
    cin >> a;
    cout << a + a * a + a * a * a;
    return 0;
}

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

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

    ll n;
    cin >> n;

    vector<ll> a(n), b(n);
    rep(i, n) cin >> a[i] >> b[i];

    ll res = 0;
    ll cnt = 0;
    for(int i = n-1; i >=0; --i){
        a[i] += cnt;
        if(b[i] == 1 || a[i]%b[i]==0) continue;

        // while(a[i]%b[i]){
        //     ++a[i];
        //     ++res;
        //     ++cnt;
        // }

        ll tmp = b[i] - a[i]%b[i];
        a[i] += tmp;
        cnt += tmp;
        res += tmp;
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {
static class UnionFind {
    List<Integer> Parent;
    UnionFind(int N) {
        Parent = new ArrayList<Integer>();
        Integer[] values = new Integer[N];
        Arrays.fill(values, -1);
        Parent.addAll(Arrays.asList(values));
    }
    int root(int A) {
        if (Parent.get(A) < 0)
            return A;
        int root = root(Parent.get(A));
        Parent.set(A, root);
        return root;
    }
    int size(int A) {
        return -Parent.get(root(A));
    }

    boolean connect(int A, int B) {
        A = root(A);
        B = root(B);
        if (A == B) {
            return false;
        }

        if (size(A) < size(B)) {
            int temp = A;
            A = B;
            B = temp;
        }

        Parent.set(A, Parent.get(A) + Parent.get(B));
        Parent.set(B, A);

        return true;
    }
}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int M = Integer.parseInt(sc.next());
        int[] p = new int[N];
        for (int i=0;i<N;i++) {
            p[i] = Integer.parseInt(sc.next());
        }
        UnionFind uf = new UnionFind(N);
        for (int i=0;i<M;i++) {
            int a = Integer.parseInt(sc.next())-1;
            int b = Integer.parseInt(sc.next())-1;
            uf.connect(a, b);
        }
        int ans = 0;
        for (int i=0;i<N;i++) {
            if (uf.root(p[i]-1)==uf.root(i)) {
                ans++;
            }
        }
        System.out.println(ans);
    }

    public static int kyotsu(ArrayList<Integer> a, ArrayList<Integer> b) {
        int ans = 0;
        int j=0;
        for (int i=0;i<a.size();i++) {
            if (a.get(i)==b.get(j)) {
                ans++;
                j++;
                if (j==b.size()) {
                    break;
                }
            } else if (a.get(i)<b.get(j)) {
                continue;
            } else if (a.get(i)>b.get(j)) {
                i--;
                j++;
                if (j==b.size()) {
                    break;
                }
            }
        }
        return ans;
    }
}

Measured memory_bytes: 61052
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
#define		CH		ch=(getchar())
#define		N		600005
#define		INF		0x3f3f3f3f

inline		int		IN(){
	int x=0,f=1;char ch;
	for (CH;ch>'9'||ch<'0';CH) if (ch=='-') f=-1;
	for (;ch>='0'&&ch<='9';CH) (x*=10)+=ch-'0';
	return x*f;
}

int i,j,k,l,n,m,f[N],Way[N*5],r,Now,Son[N],Link[N],Next[N],Len,x,y;

inline	void	Spfa(int x){
	l=r=1;Way[r]=x;
	for (;l<=r;l++){
		for (Now=Son[Way[l]];Now;Now=Next[Now])
			if (f[Link[Now]]>f[Way[l]]+1){
				f[Link[Now]]=f[Way[l]]+1;
				r++;Way[r]=Link[Now];
			}
	}
}

inline	void	Add(int x,int y){Next[++Len]=Son[x];Son[x]=Len;Link[Len]=y;}

int main(){
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++){
		scanf("%d%d",&x,&y);
		Add(x,y);Add(y,x);
	}
	for (i=1;i<=n;i++) f[i]=INF;
	f[1]=0;
	Spfa(1);
	if (f[n]==2) puts("POSSIBLE");
		else puts("IMPOSSIBLE");
}


Measured memory_bytes: 9856
#include <iostream>
#include <vector>
#include <queue>
#include<map>
#include<algorithm>
#include<set>
#include<iomanip>
#include<string>
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1; i<=n;i++)
#define rrep(i,n) for(int i = n-1;i >=0;i--)
#define ALL(a) a.begin(),a.end()
#define PI  acos(-1)
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
int dx[4] = { 0,0,1,-1 }, dy[4] = { 1,-1,0,0 }, sum = 0, h, w;
int main() {
    int k,cnt =1; cin >> k; vector<int> a(k, 0);
    ll sum = 7;
    while (1) {
        if (sum % k == 0) {
            cout << cnt << endl;
            break;
        }
        if (a[sum%k]) {
            cout << -1 << endl;
            break;
        }a[sum%k] = 1;
        sum = sum * 10 + 7;
        sum %= k; cnt++;
    }
}

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

#define IL inline 
#define int long long

IL int read() {
	char ch = getchar(); int u = 0, f = 1;
	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
	while (isdigit(ch)) { u = (u << 1) + (u << 3) + ch - 48; ch = getchar(); }
	return u * f; 
}

const int maxn = 2e5 + 10;
int n, L, Q;
int x[maxn], go[maxn][20];

IL void Pre() {
	int ipos = 1;
	for (int i = 1; i <= n; ++i) {
		while (ipos <= n && x[ipos] - x[i] <= L) ipos++;
		go[i][0] = ipos - 1;
	}
	for (int i = 1; i < 20; ++i) {
		for (int j = 1; j <= n; ++j) 
			go[j][i] = go[go[j][i - 1]][i - 1];
	}
}

signed main() {
#ifdef Edgration
	freopen("1.in", "r", stdin);
#endif
	n = read();
	for (int i = 1; i <= n; ++i) x[i] = read();
	L = read();
	Pre();
	Q = read();
	while (Q--) {
		int a = read(), b = read();
		if (a == b) { cout << "0\n"; continue; }
		if (a > b) swap(a, b);
		int ans = 0;
		for (int i = 19; ~i; --i) {
			int V = go[a][i];
			if (V == 0ll) continue;
			if (V < b) {
				a = V; 
				ans |= (1 << i);
			}
		}
		printf("%lld\n", ans + 1);
	}
	return 0;
}

Measured memory_bytes: 19200
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
a = l()

a.sort(reverse=True)
b = -1

for i in a:
    if i==b:
        if ans != 0:
            ans *= i
            break
        else:
            ans = i
            b = -1
            continue
    b = i
print(ans)




Measured memory_bytes: 22052
import sys

input = sys.stdin.readline


class DoublyLinkedNode(object):
    def __init__(self, front, data, back):
        self.front = front
        self.data = data
        self.back = back


class DoublyLinkedList(object):
    def __init__(self):
        self.first_node = None
        self.last_node = None

    def insert(self, data):
        if self.first_node is None:
            self.first_node = DoublyLinkedNode(None, data, None)
            self.last_node = self.first_node
        else:
            second_node = self.first_node
            self.first_node = DoublyLinkedNode(None, data, second_node)
            second_node.front = self.first_node

    def delete(self, data):
        node = self.first_node
        while node:
            if node.data == data:
                if node == self.first_node:
                    self.delete_first()
                    break
                elif node == self.last_node:
                    self.delete_last()
                    break
                else:
                    node.front.back = node.back
                    node.back.front = node.front
                    break
            else:
                node = node.back

    def delete_first(self):
        if self.first_node.back is None:
            self.__init__()
        else:
            self.first_node = self.first_node.back
            self.first_node.front = None

    def delete_last(self):
        if self.last_node.front is None:
            self.__init__()
        else:
            self.last_node = self.last_node.front
            self.last_node.back = None

    def show_all(self):
        data_list = []
        node = self.first_node
        while node:
            data_list.append(node.data)
            node = node.back
        print(" ".join(map(str, data_list)))


def main():
    n = int(input())
    link = DoublyLinkedList()
    for _ in range(n):
        command = input().rstrip()
        if command == "deleteFirst":
            link.delete_first()
        elif command == "deleteLast":
            link.delete_last()
        else:
            command = command.split()
            command, data = command[0], int(command[1])
            if command == "insert":
                link.insert(data)
            elif command == "delete":
                link.delete(data)
            else:
                raise ValueError
    link.show_all()


if __name__ == "__main__":
    main()



Measured memory_bytes: 203852
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

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

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

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

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

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

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

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll N,K,M=0,x,ans=0;
  cin>>N>>K;
  while(N--){
    cin>>x;
    M=max(M,x);
    ans=gcd(ans,x);
  }
  if(M>=K&&K%ans==0){
    cout<<"POSSIBLE"<<endl;
  }else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 384
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;
ll n,cnt;
ll a[10000];
vector<P> G;

ll solve(ll x){//G[x]???????????¨????????£???
	ll res=0;
	ll l=x,r=x;
	ll now;
	while(l>0&&G[l-1].first==G[x].first||G[l-1].second==0) l--;
	while(r<n-1&&G[r+1].first==G[x].first||G[r+1].second==0) r++;
	for(ll i=l;i<=r;i++) res+=G[i].second;
	if(res<=3) return 0;
	l--;
	r++;
	while(1){
		if(l<0||n<=r||G[r].first!=G[l].first) return res;
		cnt=G[r].second+G[l].second;
		if(cnt<=3) return res;
		res+=cnt;
		l--;
		r++;
	}
}


ll prev,ans=0;
int main()
{while(1){
	scanf("%lld",&n);
	if(!n) return 0;
	ans=0;
	G.clear();
	for(ll i=0;i<n;i++){
		scanf("%lld",&a[i]);
		if(i>0&&a[i]==a[i-1]){
			G[G.size()-1].second++;
		}
		else{
			G.push_back(P(a[i],1));
		}
	}
	ll N=G.size();
	for(ll i=0;i<N-1;i++){
		prev=G[i].first;
		G[i].second++;
		G[i+1].second--;
		ans=max(ans,solve(i));
		G[i].second-=2;
		G[i+1].second+=2;
		ans=max(ans,solve(i+1));
		G[i].second++;
		G[i+1].second--;
	}
	printf("%lld\n",n-ans);
}}

Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int main()
{
    int N, K;
    double ans = 0.0;
    cin >> N >> K;
    for (int i = 1; i <= N; i++)
    {
        if (i > K)
        {
            ans += 1;
        }
        else
        {
            double mark = (double)K / (double)i;
            int n = ceil(log2(mark));
            ans += pow(0.5, n);
        }
    }
    cout << setprecision(10) << ans / (double)N;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 650055;
const int K = 700 ;
int a[N], p1[N], p2[N], d[N], n;
vector < pair < int, int > > t;
string calc(string s){
        string ans = "";
        int cnt1 = 0;
        int cnt2 = 0;
        int n = s.length() / 2;
        for (int i = 1; i <= n + n; i++){
            if (s[i - 1] == 'a'){
                cnt1++;
                cnt2 = 0;
                for (int j = 1; j <= n + n; j++){
                    if (s[j - 1] == 'b') cnt2++;
                    if (cnt2 == cnt1){
                        d[i] = j;
                        break;
                    }
                }
            }
        }
        int c = 1;
        while (c <= n + n){
            ans += "ab";
            c = d[c];
            while(s[c - 1] == 'b') c++;
        }
    return ans;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n;
    string s;
    cin >> s;
    for (int i = 1; i <= n + n; i++){
        if (s[i - 1] == 'a') a[i] = -1; else a[i] = 1;
    }
    int x = 0;
    int l = 1;
    int q = 0;
    for (int i = 1; i <= n + n; i++){
        x += a[i];
        if (x == 0){
            if (a[l] == 1) q = 1;
            t.pb({l, i});
            l = i + 1;
        }
    }
    int c = 0;
    if (q == 0){
        cout << calc(s);
        return 0;
    }
    vector < string > v;
    for (auto i: t){
        string res = "";
        string cur = s.substr(i.F - 1, i.S - i.F + 1);
        if (a[i.F] == -1){
            res = calc(cur);
            v.pb(res);
            continue;
        }
        int cnt1 = 0;
        int cnt2 = 0;
        for (int j = 0; j < cur.length(); j++){
            if (cur[j] == 'a'){
                cnt2++;
                p2[j] = p1[cnt2];
            } else{
                cnt1++;
                p1[cnt1] = j;
            }
        }
        for (int j = 0; j < cur.length(); j++){
            if (cur[j] == 'a') continue;
            string x = "";
            for (int l = j; l < cur.length(); l++){
                if (cur[l] == 'b') x += "b"; else
                if (cur[l] == 'a' && p2[l] >= j) x += "a";
            }
            res = max(res, x);
        }
        v.pb(res);
    }
    string ans = "";
    for (int j = v.size() - 1; j >= 0; j--){
        ans = max(ans, v[j] + ans);
    }
    cout << ans;
}


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


int main(){
	int t;
	cin>>t;
	while(t--){
		int n,a,b;
		int up=0,down=0;
		cin>>n;
		cin>>a;
		for(int i=1;i<n;i++){
			cin>>b;
			if(a<b){
				up=max(up,b-a);
			}else{
				down=max(down,a-b);
			}
			a=b;
		}
		cout<<up<<' '<<down<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define cst(x) cout<<fixed<<setprecision(x)
#define pi 3.14159265359
#define mod 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;


int main(){

    int h,w,n; cin >> h >> w >> n;
    vector<int> a(n);
    rep(i,n) cin >> a.at(i);
    Graph G(h,vector<int>(w));

    int cnt = 0;
    int height = 0;

    rep(i,n){
        rep(j,a.at(i)){
            G.at(height).at(cnt) = i+1;
            cnt++;
            if(cnt == w){
                cnt = 0;
                height++;
            }
        }
    }
    rep(i,h){
        if(i%2 == 1){
            reverse(all(G.at(i)));
        }
    }
    rep(i,h){
        rep(j,w){
            cout << G.at(i).at(j);
            if(j != w-1) cout << ' ';
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#pragma once
#include <algorithm>
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
using namespace std;
long long int N;
long long int A[100001];
long long int B[100001];
long long int amari[100001];
long long int result=0;



int main(){
	scanf("%lld",&N);
	for(int i=0;i<N;i++){
		scanf("%lld%lld",&A[i],&B[i]);
		amari[i]=A[i]%B[i];
	}

	for(int i=N-1;i>=0;i--){
		if((result+amari[i])%B[i]!=0){
			result+=B[i]-(result+amari[i])%B[i];
		}
	}



	printf("%lld\n",result);

return 0;
}

Measured memory_bytes: 2560
//creator :Harjot Singh	

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define vi vector<int> 
#define vll vector<long long > 
#define for(i,a,b) for(int i=a;i<=b;i++)
#define vii vector<int,int> 
#define ll long long 
const int mod=1e9+7;
int main()
{
     int n,k;

     cin>>n>>k;

     ll arr[n+1];
     for(i,0,n)
     	cin>>arr[i];

     ll dp[n+1][k+1];
     
     for(i,0,k)
     	dp[1][i]=i>arr[0]?0:1;

     for(i,2,n)
     {
     	for(j,0,k)
     	{
     		if(j==0)
     			dp[i][j]=dp[i-1][j];
     		else
     		dp[i][j]=(mod+dp[i][j-1]+dp[i-1][j]-(j-1-arr[i-1]>=0? dp[i-1][j-1-arr[i-1]]:0))%mod;

     	}
     }

     cout<<dp[n][k];


   

	return 0;
}


Measured memory_bytes: 78336
H=int(input())+1
A=[0]+list(map(int,input().split()))
def h(i):
 l=2*i;r=l+1
 g=l if l<H and A[i]<A[l]else i
 if r<H and A[g]<A[r]:g=r
 if g>i:A[i],A[g]=A[g],A[i];h(g)
for i in range(H//2,0,-1):h(i)
print(' '+' '.join(map(str,A[1:])))


Measured memory_bytes: 64896
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

const int N = 2001;

int ps[3][N + 1][N + 1];

int a[N][N];
int v[3][N][N];

void init() {
	for (int t = 0; t < 3; t++) {
		for (int i = 1; i <= N; i++) {
			for (int j = 1; j <= N; j++) {
				ps[t][i][j] = ps[t][i - 1][j] + ps[t][i][j - 1] - ps[t][i - 1][j - 1] + v[t][i - 1][j - 1];
			}
		}
	}
}

int s(int t, int i1, int j1, int i2, int j2) {
	return ps[t][i2][j2] - ps[t][i1][j2] - ps[t][i2][j1] + ps[t][i1][j1];
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	
	
	int n, m, q;
	cin >> n >> m >> q;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		for (int j = 0; j < m; j++) {
			a[i][j] = (s[j] - '0');
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			v[0][i][j] = a[i][j];
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (a[i][j] && a[i - 1][j]) v[1][i][j] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 1; j < m; j++) {
			if (a[i][j] && a[i][j - 1]) v[2][i][j] = 1;
		}
	}
	init();
	while (q--) {
		int i1, j1, i2, j2;
		cin >> i1 >> j1 >> i2 >> j2;
		i1--;
		j1--;
		int ans = s(0, i1, j1, i2, j2);
		ans -= s(1, i1 + 1, j1, i2, j2);
		ans -= s(2, i1, j1 + 1, i2, j2);
		cout << ans << '\n';
	}
}

Measured memory_bytes: 112708
#include <iostream>

using namespace std;

int main()
{
long long s,j,n,d,a,x,y,z;
cin>>s>>j>>n>>d>>a;
x=s*8;
y=j*4;
z=n*2;
if(x<=y && x<=d && x<=z){
    cout<<x*a/2<<endl;}
else
if(y<x && y<=d && y<=z){
    cout<<y*a/2<<endl;}
else
if(z<y && z<x && z<=d){
    cout<<z*a/2<<endl;}
else
if(d<y && d<z && d<x){
if(a%2==1)
{
    if(x<=z && x<=y)
    cout<<d*(a/2)+x/2<<endl;
    if(y<=z && y<x)
    cout<<d*(a/2)+y/2<<endl;
    if(z<x && z<y)
    cout<<d*(a/2)+z/2<<endl;
}
else
cout<<d*(a/2);
}
   return 0;
}


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

int main() {
    string s; cin >> s;
    int n = s.size();
    for (int i=2; i<n; i += 2) {
        string s1, s2;
        s1 = s.substr(0, (n-i)/2);
        s2 = s.substr((n-i)/2, (n-i)/2);
        if (s1 == s2) {
            cout << n-i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

const int N=2000005;
const int mod=1000000007;

int n,m,ans,sum;
int fac[N],inv[N];
char s[N];

int quickpow(int x,int y){
	int s=1;
	for (;y;y>>=1,x=1ll*x*x%mod)
		if (y&1) s=1ll*s*x%mod;
	return s;
}

void init(int l){
	fac[0]=inv[0]=1;
	for (int i=1;i<=l;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[l]=quickpow(fac[l],mod-2);
	for (int i=l-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}

int C(int n,int m){
	if (n<m) return 0;
	return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;
}

int main(){
	scanf("%d",&n);
	scanf("%s",s);
	m=strlen(s);
	init(n+m);
	ans=0;
	sum=1;
	for (int i=1;i<=n+m&&n+m-i-m+1>=0;i++){
		(ans+=1ll*sum*quickpow(25,n+m-i-(m-1))%mod*C(n+m-i,m-1)%mod)%=mod;
		sum=1ll*sum*26%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 20416
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int B[110];
    rep(i, N - 1) cin >> B[i];
    int ans = B[0] + B[N - 2];
    rep(i, N - 2) ans += min(B[i + 1], B[i]);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
import sys
sys.setrecursionlimit(500*500)

N = int(input())
edges = [list(map(int,input().split())) for _ in range(N-1)]
A  = [[] for j in range(N+1)]

for edge in edges:
  A[edge[0]].append([edge[1],edge[2]])
  A[edge[1]].append([edge[0],edge[2]])
  
depth = [-1]*(N+1)
depth[1] = 0

def dfs(A,s):
  for v in A[s]:
    if depth[v[0]] == -1:
      depth[v[0]] = depth[s] + v[1]
      dfs(A,v[0])
dfs(A,1)


for d in depth[1:]:
  if d % 2 == 0:
    print(0)
  else:
    print(1)



Measured memory_bytes: 102104
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
main(){
    char A,B;
    scanf("%c%*c%c",&A,&B);
    if(A=='H' && B=='H')cout << "H" << endl;
    if(A=='D' && B=='H')cout << "D" << endl;
    if(A=='H' && B=='D')cout << "D" << endl;
    if(A=='D' && B=='D')cout << "H" << endl;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
//#include<bits/extc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
using namespace std;
//using namespace __gnu_pbds;
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vector<ll>>;
//using oset = tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll mod = 17*7*(1<<23) + 1;
#define maxq(x, y) (x = max(x, y))
int ans = 0, dp[200100][2];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	s = " " + s;
	for(int i = 1; i < s.size(); i++) {
		dp[i][0] = dp[i-1][1]+1;
		dp[i][1] = i>1?dp[i-2][0]+1:0;
		if(s[i]!=s[i-1]) {
			dp[i][0] = max(dp[i][0], dp[i-1][0]+1);
		}
		if(i>3&&(s[i]!=s[i-2]||s[i-1]!=s[i-3])) {
			dp[i][1] = max(dp[i][1], dp[i-2][1]+1);
		}
	}
	cout << max(dp[s.size()-1][0], dp[s.size()-1][1]);
}


Measured memory_bytes: 2128
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
int main(void){
    int X;
    cin >> X;
    bool f= false;
    rep2(A,-120,121){
        rep2(B,-120,121){
            if(X==(A*A*A*A*A-B*B*B*B*B)){
                cout << A << " " << B << endl;
                f=true;
                break;
            }
        }
        if(f){
            break;
        }
    }
    return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/
	
	int n;
	cin >> n;

	out(180 + 180 * (n - 3));

	return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
out = 0
for i in range(n):
    if x-a[i] < 0:
        print(out)
        exit()
    else:
        x -= a[i]
        out += 1
if x > 0:
    print(out-1)
else:
    print(out)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N,M,K;
  cin>>N>>M>>K;
  vector<int>A(N+1);
  vector<int>B(M);
  for(int i=1;i<=N;i++){
    cin>>A[i];
  }
  for(int i=0;i<M;i++){
    cin>>B[i];
  }

  vector<int64_t>table(M);
  table[0]=B[0];
  for(int i=0;i<M;i++){
    if(i>0){table[i]+=table[i-1]+B[i];}
    //cout<<table[i]<<endl;
  }
  int64_t suma=0;
  int ans=0;
  for(int i=0;i<=N;i++){
    suma+=A[i];
    int64_t x=K-suma;
    if(suma>K){continue;}
    int b=upper_bound(table.begin(),table.end(),x)-table.begin();
    ans=max(ans,i+b);//cout<<suma<<endl;cout<<b<<endl;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6368
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#define int long long
#define mod(int)(1000000007)
using namespace std;
const int INF = 1000000000000;
int cnt[3456][3456], test[345678][2];
signed main() {
	int n, m, q, l, r, a, b; cin >> n >> m >> q;
	for (int h = 0; h < m; h++) {
		cin >> l >> r; cnt[l][r]++;
	}
	for (int h = 1; h <= n; h++) {
		for (int i = 1; i <= n; i++) {
			cnt[h][i] += cnt[h - 1][i] + cnt[h][i - 1] - cnt[h - 1][i - 1];
		}
	}
	
	for (int h = 0; h < q; h++) {
		cin >> a >> b;
		cout << cnt[b][b] - cnt[a - 1][b] - cnt[b][a - 1] + cnt[a - 1][a - 1] << endl;
	}
	return 0;
}

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

int main() {
    string n;
    cin >> n;
    while (true) {
        if (n[0] == n[1] && n[1] == n[2])
            break;
        n = to_string(stoi(n) + 1);
    }
    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let ans = (a+b) % 24;
    println!("{}", ans);
}

// 以下関数

use std::io::*;
use std::str::FromStr;
pub fn read<T: FromStr>() -> T {
    let stdin = 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")
}

pub const MOD: u64 = 10e9 as u64 + 7;

pub fn is_prime(n: i32) -> bool {
    if n < 2 {
        return false;
    } else if n == 2 {
        return true;
    }
    let mut i = 2;
    while i * i < n {
        if n % i == 0 {
            return false;
        } else {
            i += 1;
            continue;
        }
    }
    true
}

pub fn lcm(mut n: i32, mut m: i32) -> i32 {
    n = if n > m { m } else { n };
    m = if n > m { n } else { m };
    let mut i = n;
    while i % m != 0 {
        i += n;
    }
    i
}

pub fn abs(n: i32) -> i32 {
    if n >= 0 {
        n
    } else {
        -n
    }
}

pub fn max(n: i32, m: i32) -> i32 {
    if n >= m {
        n
    } else {
        m
    }
}

pub fn min(n: i32, m: i32) -> i32 {
    if n <= m {
        n
    } else {
        m
    }
}

Measured memory_bytes: 4352
void main()
{
    long n = readln.chomp.to!long;
    long[] a = readln.split.to!(long[]);
    long[] b = readln.split.to!(long[]);
    long[] c = readln.split.to!(long[]);

    a.sort!"a < b";
    c.sort!"a < b";
    auto aa = a.assumeSorted;
    auto ca = c.assumeSorted;
    long result;
    foreach (x; b)
    {
        long aal = aa.lowerBound(x).length;
        long cal = ca.upperBound(x).length;
        result += aal * cal;
    }

    result.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 12872
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;


int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(12);

    int n;
    cin >> n;
    vector<int> A(3 * n, 0);
    for (int i = 0; i < 3 * n; ++i) {
        cin >> A[i];
        --A[i];
    }

    const int INF = 1 << 20;
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, -INF));
    
    auto update = [&](int i, int j, int v) {
        vector<int> X{i, j, n};
        for (int i = 0; i < 3; ++i) {
            for (int j = 0; j < 3; ++j) {
                if (i == j && X[i] != n) {
                    continue;
                }
                dp[X[i]][X[j]] = max(dp[X[i]][X[j]], v);
            }
        }
    };

    update(A[0], A[1], 0);

    int base = 0;
    for (int i = 2; i + 3 <= 3 * n; i += 3) {
        vector<int> B{A[i], A[i + 1], A[i + 2]};
        vector<vector<int>> DP{dp[A[i]], dp[A[i + 1]], dp[A[i + 2]]};
        auto dpn = dp[n];

        if (A[i] == A[i + 1] && A[i + 1] == A[i + 2]) {
            ++base;
            for (int i = 0; i <= n; ++i) {
                for (int j = 0; j < 3; ++j) {
                    DP[j][i] -= 1;
                }
                dpn[i] -= 1;
            }
        }

        for (int _ = 0; _ < 3; ++_) {
            {
                //[i, j, a, b, c] - [j, a, b] = [i, c]
                for (int i = 0; i <= n; ++i) {
                    int mx = dpn[i];
                    if (B[0] == B[1]) {
                        mx = max(mx, DP[0][i] + 1);
                    } 
                    update(i, B[2], mx);
                }
            }

            {
                //[i, j, a, b, c] - [i, j, a] = [b, c]
                int mx = dpn[n];
                mx = max(mx, DP[0][B[0]] + 1);
                update(B[1], B[2], mx);
            }
            rotate(B.begin(), B.begin() + 1, B.end());
            rotate(DP.begin(), DP.begin() + 1, DP.end());
        }
    }

    int res = 0;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= n; ++j) {
            int ans = dp[i][j];
            if (i == j && A.back() == i) {
                ++ans;
            }
            res = max(res, ans);
        }
    }

    res += base;

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 19044
a = int(input())
num = [int(a) for a in input().split()]
counter = 0
while True:
    b = list(map(lambda x: x % 2, num))
    if b.count(0) == a:
        num = list(map(lambda x: x>>1, num))
        counter += 1
    else:
        print(counter)
        break


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

using ll = long long;

/*
given weights and values array, each i-th means it weights[i] and values[i] 

find the maximum with given W 

3 8
3 30
4 50
5 60
dp[i][w] = i-th means consider up to i, w means the weight it used 
1. add it (if w >= weights[i])
dp[i][w] = dp[i-1][w-weights[i]] + values[i]
2. ignore it 
dp[i][w] = dp[i-1][w]

dp[c] = minimum weight to get to c.
ans = max(c in dp[c] that dp[c] > -1)

*/

int main() {
    const int INF = 1e9+7;
    int n;
    int W;
    int ans = 0;
    scanf("%d%d", &n, &W);
    
    vector<int> weights(n);
    vector<int> values(n);
    ll sum_value = 0;
    for (int i = 0; i < n; i++) {
        scanf("%d%d", &weights[i], &values[i]);
        sum_value += values[i];
    }
    
    vector<int> dp(sum_value+1, INF);
    
    dp[0] = 0;
    
    for (int i = 0; i < n; i++) {
        for (int j = sum_value-values[i]; j >= 0; j--) {
            int new_weight = weights[i] + dp[j];
            int new_value = values[i] + j;
            dp[new_value] = min(dp[new_value], new_weight);
            if (new_weight <= W) {
                ans = max(ans, new_value);    
            }
        }
    }
    
    
    
    
    /*
    //vector<ll> dp(100001);
    unordered_map<ll, ll> dp;
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        int weight;
        int value;
        vector<pair<ll, ll>> to_add;
        scanf("%d%d", &weight, &value);
        for (const auto& any : dp) {
            ll new_value = any.first + value;    
            ll new_weight = any.second + weight;
            if (new_weight <= W) {
                if (dp.find(new_value) == dp.end()) {
                    to_add.push_back({new_value, new_weight});
                }
                else {
                    dp[new_value] = min(dp[new_value], new_weight);        
                }
                ans = max(ans, new_value);
            }
        }
        while (!to_add.empty()) {
            pair<int, int> p = to_add.back();
            to_add.pop_back();
            dp[p.first] = p.second;
        }
        
    }
    
    
    //vector<ll> dp(W+1);
    unordered_map<ll, ll> dp;
    
    for (int i = 1; i <= n; i++) {
        int weight;
        int value;
        scanf("%d%d", &weight, &value);
        for (int w = W; w >= weight; w--) {
            if (w >= weight) {
                dp[w] = max(dp[w], dp[w-weight]+value); // add
                ans = max(ans, dp[w]);
            }
        }
    }
    */
    
    printf("%d", ans);
    
	return 0;
}






Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main(){
    long long int x,c=0;
    cin>>x;
    if(x==2)
    {
        cout<<x<<endl;

    }
    else{while(1){
    for (int i=2;i<=sqrt(x);i++)
    {
        if(x%i==0){c++;
        break;}
    }
    if(c==0)
    {
        cout<<x<<endl;
        break;
    }
    else{x++;
    c=0;
    }
}}
    return 0;

}



Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main(void){
  int n;
  long h, w, a, b, counter = 0;
  cin >> n >> h>> w;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    if(h <= a && w <= b)  counter++;
  }
  cout << counter << endl;
  return 0;
}


Measured memory_bytes: 256
A, B = [int(_) for _ in input().split()]
cards = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 1]
print("Alice" if cards.index(A) > cards.index(B) else "Bob" if cards.index(A) < cards.index(B) else "Draw")


Measured memory_bytes: 3064
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Maybe

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntListN n = map readInt <$> replicateM (fromIntegral n) BS.getLine

simulate :: [Int] -> Int -> Int -> Int
simulate [] c n
  | odd n = 1
  | otherwise = 0
simulate (a : as) c n
  | c == 0 = simulate as a 1
  | c == a = simulate as c (n + 1)
  | odd n = 1 + simulate as a 1
  | otherwise = simulate as a 1

main = do
  n <- getInt
  as <- getIntListN n
  let as' = sort as
  print $ simulate as' 0 0


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

#define rep(i,n) for(i=0;i<(n);i++)
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define ROF(i,a,b) for(i=(a);i>(b);i--)
#define all(a) (a).begin(),(a).end()
typedef vector<int> vi;
typedef vector< vi > vii;
typedef vector<string> vs;
typedef pair<int,int> pii;

main(){
  int n;
  cin >> n;
  cout << (int) sqrt(n) * (int) sqrt(n) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  
  int a=-1,b=-1,c=-1,d=-1,e=-1,f=-1;
  int min,ans=0,i;
  
  //入力
  scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
  while(1){
    
    //全て0なら入力を終わる
    if(a==0 && b==0 && c==0 && d==0 && e==0 && f==0)  break;
    
    //足し算
    a+=d; b+=e; c+=f;

    for(i=0;i<=2;i++){
      if(a>=i && b>=i && c>=i){
	//printf("ans=%d %d\n",ans,(a-i)/3 + (b-i)/3 + (c-i)/3 + i);
	if(ans < (a-i)/3+(b-i)/3+(c-i)/3 + i) ans=(a-i)/3+(b-i)/3+(c-i)/3 + i;
      }
    }
    printf("%d\n",ans);
    ans=0;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f); 
  }
  return 0;
}

Measured memory_bytes: 600
#include<algorithm>
#include<set>
#include<vector>

class BipartiteGraph {
 public:
  BipartiteGraph(const int x, const int y) :size_x_(x), size_y_(y), edge_(x + y) {}

  void insert(const int vx, const int vy) {edge_[vx].insert(size_x_ + vy);}

  int matching() const {
    std::vector<int> match_to(edge_.size(), -1);
    int count = 0;
    for(int i = 0; i < size_x_; ++i) {
      std::vector<bool> visited(edge_.size(), false);
      if(FordFullkerson(i, match_to, visited)) ++count;
    }
    return count;
  }

 private:
  bool FordFullkerson(int from, std::vector<int>& match_to, std::vector<bool>& visited) const {
    if(from == -1) return true;
    if(visited[from]) return false;
    visited[from] = true;
    for(const auto& to: edge_[from]) {
      if(!FordFullkerson(match_to[to], match_to, visited)) continue;
      match_to[from] = to;
      match_to[to] = from;
      return true;
    }
    return false;
  }

  std::vector<std::set<int>> edge_;
  int size_x_, size_y_;
};
#include<bits/stdc++.h>
using namespace std;
struct Point {int x, y;};
int main() {
  int N;
  cin >> N;
  vector<Point> R(N), B(N);
  for(auto& i: R) cin >> i.x >> i.y;
  for(auto& i: B) cin >> i.x >> i.y;
  BipartiteGraph G(N, N);
  for(auto i=0; i<N; ++i) for(auto j=0; j<N; ++j) {
    auto r=R[i];
    auto b=B[j];
    if(r.x<b.x && r.y<b.y) G.insert(i, j);
  }
  cout << G.matching() << endl;
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<int> h(N);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    cin >> h[i];
    if (h[i] >= K) ans++;
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 640
#include <stdio.h>

int insertSort(int*, int);

int main()
{
	int arr[100];
	int num = 0, temp = 0, re = 0;
	
	scanf(" %d", &num);

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

	re = insertSort(arr, num);

	for (int i = 0; i < num; i++)
	{
		printf("%d", arr[i]);
		if (i < num - 1) printf(" ");
	}
	printf("\n");
	printf("%d\n", re);

	return 0;
}

int insertSort(int arr[], int num)
{
	int cnt = 0, min = 0, temp = 0;
	for(int i = 0; i < num; i++)
	{
		min = i;
		for (int j = i; j < num; j++)
		{
			if (arr[j] < arr[min])
			{
				min = j;
			}
		}
		if (i != min) cnt++;
		temp = arr[i];
		arr[i] = arr[min];
		arr[min] = temp;
	}

	return cnt;
}




Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////

int n, k;vector<int>g[55];
int dp[100][55][55];
int ans[100][55][55];
signed main(){
  cin>>n>>k;
  rep(i,n)rep(j,n){
    cin>>dp[0][i][j];
  }
  repd(i,1,63){
    rep(from, n){
      rep(to, n){
        rep(via, n){
          dp[i][from][to] = ((dp[i][from][to]) + (dp[i-1][from][via] * dp[i-1][via][to])%MOD)%MOD;
        }
      }
    }
  }
  vector<int> vec;
  rep(i,63)if(k&(1LL<<i))vec.push_back(i);
  rep(i,n)rep(j,n)ans[0][i][j] = dp[vec[0]][i][j];
  repd(i,1,vec.size()){
    rep(from, n){
      rep(to, n){
        rep(via, n){
          ans[i][from][to] = ((ans[i][from][to]) + (ans[i-1][from][via] * dp[vec[i]][via][to])%MOD)%MOD;
        }
      }
    }
  }
  int sum = 0;
  rep(i,n)rep(j,n)sum = (sum + ans[vec.size()-1][i][j])%MOD;
  cout << sum << endl;
}


Measured memory_bytes: 3712
#include <stdio.h>

int main(void) {
  int x, y;
  scanf ("%d %d", &x, &y);
  while (!(x == 0 && y == 0)) {
    if(x < y) printf ("%d %d\n", x, y);
    else printf ("%d %d\n", y, x);
    scanf ("%d %d", &x, &y);
  }
  return 0;
}


Measured memory_bytes: 2044