akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
using namespace std;
#define _GLIBCXX_DEBUG
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define vit vector<lint>::iterator
#define all(x) (x).begin(),(x).end()
#define repj(x) for(int j = 0;j < (x);j++)
#define rep(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define mod 1000000007
#define graph_set(n) struct edge{int to,int cost;} vector<edge> G((n))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define range(x,y) ((x) >= 0 && (x) < h && (y) >= 0 && (y) < w)
#define pyes cout << "Yes" << endl
#define pno cout << "No" << endl
#define fin return 0
typedef vector<long long> vi;
typedef vector<pair<long long, long long>> vp;
typedef vector<vector<long long>> vvi;
typedef pair<long long, long long> pi;
typedef long long lint;
typedef long long ll;
lint qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
lint qp(ll a, ll b, int mo) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }
lint gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };
long long INF = (ll)1e19;

int r[100], l[100];
int a, b;

#define MAX 9223372036854775807
/*********************** */
int n;
int F[100][10];
int P[100][11];
int main() {
	cin >> n;
	rep(i,n){
		rep(j,10) cin >> F[i][j];
	}
	rep(i,n)rep(j,11){
		cin >> P[i][j];
	}
	//ll res = 0;
	ll ans = -MAX;
	for(int i = 1;i < (1<<10);i++){
		ll res = 0;
		int x = i;
		rep(k,n){
			int c = 0;
			rep(j,10){
				if(((x >> j) & 1) == 1 && (F[k][j] == 1)) c++;
			}
			res += P[k][c];
		}
		maxs(ans,res);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  int m,f,r;
  cin >> m >> f >> r;
  while(m!=-1 || f!=-1 || r!=-1) {
      if (m==-1 || f==-1) cout << "F" << endl;
      else if (m+f>=80) cout << "A" << endl;
      else if (m+f>=65) cout << "B" << endl;
      else if (m+f>=50) cout << "C" << endl;
      else if (m+f>=30) {
          if (r>=50) cout << "C" << endl;
          else cout << "D" << endl;
      }
      else cout << "F" << endl;
      cin >> m >> f >> r;
  }
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl;
#define fi(v) get<0>(v)
#define se(v) get<1>(v)
#define th(v) get<2>(v)
template <typename T> bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, const T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;

//Dinic法、蟻本そのまま
//最大流(=最小カット)を求めるアルゴリズム
//隣接リスト表現での実装
//計算量はO(|E||V|^2)だが、実際は非常に高速
//Ford-Fulkerson法の上位互換？？

//辺を表す構造体（行き先、容量、逆辺）
struct edge{ll to, cap, rev;};

vector<vector<edge>> G(203, vector<edge>(0));;//$１には最大頂点数+3を入れよう！
ll level[203];//sからの距離
ll iter[203];//どこまで調べ終わったか

//辺を追加する！
//fromからtoへ向かう容量capの辺
void add_edge(ll from, ll to, ll cap){
    G[from].emplace_back(edge{to,cap,(ll)G[to].size()});
    G[to].emplace_back(edge{from,0,(ll)G[from].size()-1});
}

//sからの距離をBFSで計算する
void bfs(ll s){
    memset(level,-1,sizeof(level));
    queue<ll> que;
    level[s]=0;
    que.emplace(s);
    while(!que.empty()){
        ll v=que.front();que.pop();
        for(ll i=0;i<G[v].size();i++){
            edge &e=G[v][i];
            if(e.cap>0&&level[e.to]<0){
                level[e.to]=level[v]+1;
                que.emplace(e.to);
            }
        }
    }
}

//増加パスをdfsで探す！
ll dfs(ll v, ll t, ll f){
    if(v==t)return f;
    for(ll &i=iter[v];i<G[v].size();i++){
        edge &e=G[v][i];
        if(e.cap>0&&level[v]<level[e.to]){
            ll d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                G[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}

//sからdへの最大流を求める
ll max_flow(ll s,ll t){
    ll flow=0;
    for(;;){
        bfs(s);
        if(level[t]<0)return flow;
        memset(iter,0,sizeof(iter));
        ll f;
        while((f=dfs(s,t,INF))>0)flow+=f;
    }
}



int main(){
    ll N;
    cin >> N;
    vector<ll> A(N+1,0);
    vector<ll> B(N+1,0);
    vector<ll> C(N+1,0);
    vector<ll> D(N+1,0);
    for(ll i=1;i<=N;i++)cin>>A[i]>>B[i];
    for(ll i=1;i<=N;i++)cin>>C[i]>>D[i];

    //辺の追加
    for(ll i=1;i<=N;i++)
        for(ll j=1;j<=N;j++)
            if(A[i]<C[j]&&B[i]<D[j])add_edge(i,j+N,1);
    
    for(ll i=1;i<=N;i++)add_edge(0,i,1);
    for(ll i=N+1;i<=2*N;i++)add_edge(i,2*N+1,1);

    print(max_flow(0,2*N+1))

    return 0;
}

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

int main() {
  string S[100];
  int N;
  int type=3;
  cin >> N;
  rep(i,N){
    cin >> S[i];
    if(S[i] == "Y"){
        type=4;
    }
  }
  if (type==3)
    cout << "Three" <<endl;
  if (type==4)
    cout << "Four" <<endl;


}


Measured memory_bytes: 3564
A = []
for i in range(3):
    line = list(map(int, input().split()))
    A.extend(line)
N = int(input())

bingo = [False] * 9

def num_check(num):
    for i in range(9):
        if A[i] == num:
            bingo[i] = True


for _ in range(N):
    num = int(input())
    num_check(num)

bingo_flag = False
# row check
if any([bingo[i] and bingo[i+1] and bingo[i+2] for i in range(0, 9, 3)]):
    bingo_flag = True

# col check
if any([bingo[i] and bingo[i+3] and bingo[i+6] for i in range(3)]):
    bingo_flag = True

# cross check
if (bingo[0] and bingo[4] and bingo[8]) or (bingo[2] and bingo[4] and bingo[6]):
    bingo_flag = True

print("Yes") if bingo_flag else print("No")

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<cstdlib>
#include<cctype>
#include<ctime>

typedef long long LL;
using namespace std;

long long A, B;
int main()
{
	cin >> A >> B;
	for(int i = 1; i <= B; i++)
	{
		if((A * i) % B == 0)
		{
			cout << A * i << endl; 
			break;
		}
	}
	return 0;
}

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

#define pb push_back
#define sz(X) ((int)(X).size())
#define all(X) (X).begin(),(X).end()
#define ll long long
#define pi pair<int,int>
const int N=3e5+5,MOD=1e9+7;

using namespace std;

int n,k;
string a;
int ans;
int main()
{
	//freopen("tst.txt","r",stdin);
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin>>n>>k>>a;
	vector<pi>wa;
	wa.pb({0,0});
	for(int i=0;i<sz(a);i++){
		if(a[i]=='0'){
			int st = i;
			while(a[i]=='0')i++;
			i--;
			wa.pb({st,i});
		}
	}

	if(sz(wa)==1)
		ans=sz(a);

	for(int i=1;i<sz(wa);i++){
		int st = min(wa[i-1].second + 1,wa[i].first),last=n;
		if(i+k<sz(wa)){
			last=wa[i+k].first;
		}
		ans = max(ans,last-st);
	}

	cout<<ans<<"\n";
 
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin,(a).rend()
#define dunk(a) cout << (a) << endl
using namespace std;
typedef long long ll;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string S;
	cin >> S;
	rep(i, S.size()) {
		if (S[i] == ',') cout << ' ';
		else cout << S[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++){
            int a[] = new int[3];
            for (int j = 0; j < 3; j++){
                a[j] = sc.nextInt();
            }
            Arrays.sort(a);
            if (a[0]*a[0] + a[1]*a[1] == a[2]*a[2]){
                System.out.println("YES");
            }else{
                System.out.println("NO");
            }
        }
    }
}

Measured memory_bytes: 23348
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();
		int K=sc.nextInt();
		char[][] c=new char[H][W];

		for(int i=0;i<H;i++) {
			String s=sc.next();
			c[i]=s.toCharArray();
		}

		int answer=0;
		for(int h=0;h<(Math.pow(2, H));h++) {     //行はh通りある
			for(int w=0;w<(Math.pow(2, W));w++) {  //列はw通りある
        int blackcount=0;
				for(int row=0;row<H;row++) {        //＃かどうか確認する行
					for(int col=0;col<W;col++) {      //＃かどうか確認する列
						if(((h>>row & 1)==1) && ((w>>col & 1)==1)) { //行はrow個、列はcol個ずらす
							if (c[row][col] == '#')blackcount++; //＃があった
						}
					}
				}
				if(blackcount==K)answer++;
			}
		}

	    System.out.println(answer);
	}
}


Measured memory_bytes: 35888
n,m = [int(x) for x in input().split()]

a = [[0 for i in range(m)] for j in range(n)]

for i in range(n):
    a[i] = [int(x) for x in input().split()]

b = [[0] for i in range(m)]
for i in range(m):
    b[i][0] = int(input()) 
    

c = [[0] for i in range(n)]
for i in range(n):
    for j in range(m):
        c[i][0] += a[i][j] * b[j][0]
    print(c[i][0])


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

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  bool ok=false;
  for(int i=0;i<=n;++i){
    for(int j=0;j<=m;++j){
      if((i*(m-j)+j*(n-i))==k) ok=true;
    }
  }
  if(ok){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			int[] a = new int[m];
			int[] b = new int[m];
			for(int i=0;i<m;i++){
				a[i] = sc.nextInt();
				b[i] = sc.nextInt();
			}
			
			int max = 0;
			int p = 0;
			int count = 0;
			while(true){
				count++;
				max = 0;
				for(int j=0;j<m;j++){
					if(a[j]<=p+1) max = Math.max(max,b[j]);
				}
				if(max==p){
					System.out.println("Impossible");
					break;
				}else if(max==n){
					System.out.println(count);
					break;
				}
				p = max;
			}

		}
	}	
}

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

int main() {
  string s;
  cin >> s;
  auto sa = atcoder::suffix_array(s);
  auto lcp = atcoder::lcp_array(s, sa);
  ll res = (ll)sa.size() * (sa.size() + 1) / 2;
  for (int i = 0; i < (int)(lcp.size()); i++) res -= lcp[i];
  cout << res << endl; 
  return 0; 
}

Measured memory_bytes: 15580
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d.at(i);
  sort(ALL(d));
  int ans = 1;
  rep2(i, 1, n){
    if(d.at(i) != d.at(i-1)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BichromeCells
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = int.Parse(Console.ReadLine());

            Console.WriteLine(Math.Pow(n, 2) - a);
        }
    }
}

Measured memory_bytes: 13140
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<malloc.h>
#include<math.h>


int my_gets(char *buf,int nBuf,FILE *fp){
    int ch;

    while(--nBuf >0){
        ch=getc(fp);
        if(ch==EOF || ch=='\n')
            break;
        *(buf++)=(char)ch;
    }
    *(buf)='\0';

    return nBuf;
}

void InputIntAry(int *a,int nDigit,int N){      //nDigitは想定される最大桁数
    char *buf,*ptr;

    buf=(char*)malloc( (N*(nDigit+2)) * sizeof(char) );
    my_gets(buf,N*(nDigit+2),stdin);

    ptr=strtok(buf," ");
    while(ptr!=NULL && N-->0){
        *(a++)=atoi(ptr);
        ptr=strtok(NULL," ");
    }
    free(buf);
}


int main(){
    int N,i=0,cnt=0;
    int a[200000]={},b[200000]={};

    scanf("%d%*c",&N);
    InputIntAry(a,1,N);
    i=N;
    for(int j=1; j<= N; j++){
        for(; (i*(j+1))> N; i--){
            int tmp=0;
            for(int k=2; k<=j; k++){
                tmp ^= b[k*i -1];
            }
            b[i -1] = tmp ^ a[i -1];
            //printf("i:%d j:%d a[i-1]:%d b[i-1]:%d\n",i,j,a[i -1],b[i -1]);
            cnt += b[i -1];
        }
    }
    printf("%d\n",cnt);
    int flag=0;
    for(int j=0;j<N;j++){
        if(b[j]){
            if(flag){
                printf(" %d",j+1);
            }
            else{
                printf("%d",j+1);
                flag=1;
            }
        }
    }
    if(flag)
        puts("");
    
    return 0;
}

Measured memory_bytes: 2588
#include <iostream>
#include <vector>

using namespace std;

int main () {
  int n;
  cin >> n;
  vector <pair <int, int>> a(n);
  for (int i = 0; i < n; i++)
    cin >> a[i].first >> a[i].second;
  vector <bool> tf(n);
  for (int i = 0; i < n; i++)
    tf[i] = (a[i].first == a[i].second);
  for (int i = 0; i + 2 < n; i++)
    if (tf[i] && tf[i + 1] && tf[i + 2]) {
      cout << "Yes\n";
      return 0;
    }
  cout << "No\n";
  return 0;
}


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

int main() {
	long long N;
	cin >> N;

	for (int h = 1; h <= 3500; h++) {
		for (int n = h; n <= 3500; n++) {
			long long bumbo = N * h * n;
			long long bunshi = 4ll * h * n - N * n - N * h;
			if (bunshi > 0 && bumbo % bunshi == 0) {
				cout << h << " " << n << " " << bumbo / bunshi << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

        int N = sc.nextInt();
        int K = sc.nextInt();

        System.out.println(solve(N, K));

        sc.close();
    }

    static String solve(int N, int K) {
        if (K > (N - 1) * (N - 2) / 2) {
            return "-1";
        }

        List<String> edges = new ArrayList<>();
        for (int i = 2; i <= N; ++i) {
            edges.add(String.format("%d 1", i));

            for (int j = 2; j < i; ++j) {
                if (K == 0) {
                    edges.add(String.format("%d %d", i, j));
                } else {
                    --K;
                }
            }
        }

        return String.format("%d\n%s", edges.size(), String.join("\n", edges));
    }
}

Measured memory_bytes: 48828
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i = (s);i<(int)(n);i++)

int main(){
    int n;
    cin >> n;
    if(n%1000 != 0)cout << 1000 - n%1000 << endl;
    else cout << 0 << endl;
}

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

using namespace std;
int sumarraybegin(vector<int> &w,int n)
{
  int sum=0; 
  if(n==0)
  {
    sum+=w.at(0);
  }
  else{
    for(int i=0;i<n;i++)
    {
      sum += w.at(i);
    }
  }
  
  return sum;
}
int sumarrayend(vector<int> &w,int n,int b)
{
  int sum=0;
  if(b==0)
  {
    for(int i=n-1;i>b;i--)
    {
      sum += w.at(i);
    }
  }
  else{
    for(int i=n-1;i>=b;i--)
    {
      sum += w.at(i);
    }
  }
  
  return sum;
}
int main()
{
  int n;
  cin >> n;
  vector<int> w(n);
  vector<int> t(n);
  for(int i=0;i<n;i++)
  {
    cin >> w.at(i);
  }
  int s1;
  int s2;
  for(int i=0;i<n;i++)
  {
    s1=sumarraybegin(w,i);
    s2=sumarrayend(w,n,i);
    // cout << s1 << " " << s2 << " ";
    if(s1>s2){
      t.at(i)=s1-s2;
    }
    else{
      t.at(i)=s2-s1;
    }
     // cout << t.at(i) << endl;
  }
  sort(t.begin(),t.end());

  cout << t.at(0) << endl;
  
   
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
int N;
long long L;
int main(){
    cin>>N>>L;
    vector<long long>A;
    vector<pair<LL,LL> >B;
    for(int i=0;i<N;i++)
    {
        long long l,r;
        cin>>l>>r;
        A.push_back(l);
        A.push_back(r);
        B.push_back(make_pair(l,r));
    }
    sort(A.begin(),A.end());
    A.erase(unique(A.begin(),A.end()),A.end());
    sort(B.begin(),B.end());
    long long p=0,q=0;
    int ans=0;
    for(int i=0;i<N;i++)
    {
        q=max(q,B[i].second);
        if(i==N-1||B[i+1].first>p)
        {
            ans++;
            p=q;
            if(p>=L)break;
        }
    }
    cout<<ans<<" ";
    vector<int>S(A.size(),0);
    for(pair<LL,LL>a:B)
    {
        int l,r;
        l=lower_bound(A.begin(),A.end(),a.first)-A.begin();
        r=lower_bound(A.begin(),A.end(),a.second)-A.begin();
        S[l]++;
        S[r]--;
    }
    int T=0,K=2e9;
    for(int i=0;i<A.size();i++)
    {
        T+=S[i];
        if(i+1<A.size())K=min(K,T);
    }
    cout<<N-K+1<<endl;
}



Measured memory_bytes: 10400
var
n,m,i,j,l:longint;
begin
readln(n,m);
for i:=0 to m div 10000 do
  for j:=0 to (m-i*10000) div 5000 do
    begin
      l:=n-i-j;
      if i*10000+j*5000+l*1000=m then
        begin
          writeln(i,' ',j,' ',l);
          halt;
        end;
    end;
writeln('-1 -1 -1');
end.

Measured memory_bytes: 128
n, a, b = gets.chomp.split.map(&:to_i)
towns = gets.chomp.split.map(&:to_i)
distances = []
pos, total = 0, 0

(n-1).times do |i|
  distances[i] = towns[i+1] - towns[i]
end

(n-1).times do |i|
  if a * distances[pos] < b
    total += a * distances[pos]
    pos += 1
  else
    total += b
    pos += 1
  end
end

puts total

Measured memory_bytes: 10324
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int w, h;
bool exist[30][30];

int calc(int x, int y, int low, int high) {
  //cout << x << " " << y << " "<< low << " " << high << endl;
  if (y == h) { return 1; }
  if (x == w + 1) { return 0; }
  if (x == w) {
    int nhigh = high & ~(1 << x);
    return calc(0, y + 1, nhigh, 0);
  }
  if (exist[y][x]) {
    int nhigh = high | (1 << x) | (1 << (x + 1));
    return calc(x + 1, y, low, nhigh);
  }
  int ret = 0;
  int prev = (low >> (x + 1)) & 1;
  int next = (low >> (x + 2)) & 1;
  exist[y][x] = true;
  if (!exist[y][x + 1] && !next) {
    int nhigh = high | (1 << (x + 2));
    exist[y][x + 1] = true;
    ret += calc(x + 2, y, low, nhigh);
    exist[y][x + 1] = false;
  }
  if (!prev && y != h - 1) {
    int nhigh = high & ~(1 << x);
    exist[y + 1][x] = true;
    ret += calc(x + 1, y, low, nhigh);
    exist[y + 1][x] = false;
  }
  exist[y][x] = false;
  return ret;
}

int main() {
  MEMSET(exist, false);
  while (scanf("%d %d", &w, &h), w|h) {
    if (w > h) { swap(w, h); }
    printf("%d\n", calc(0, 0, 0, 0));
  }
}

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

using namespace std;
#define ll long long
#define mod 1000000007

int n1, n2;
string s1, s2;
ll dp[3000][3000];

ll f(ll i, ll j) {
    if (i == n1 || j == n2) {
        return 0;
    }

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

    ll ans;
    if (s1[i] == s2[j]) {
        ans = 1 + f(i + 1, j + 1);
    } else {
        ans = max(f(i + 1, j), f(i, j + 1));
    }

    dp[i][j] = ans;
    return ans;
}

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

    memset(dp, -1, sizeof(dp));

    cin >> s1 >> s2;
    n1 = s1.length(), n2 = s2.length();

    int i = 0, j = 0;
    while (i < n1 && j < n2) {
        if (s1[i] == s2[j]) {
            cout << s1[i];
            i++, j++;
        } else if (f(i + 1, j) > f(i, j + 1)) {
            i++;
        } else {
            j++;
        }
    }
}


Measured memory_bytes: 74144
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    ll n,m;
    cin >> n >> m;
    if (n >= 2 && m >= 2){
        cout << (n-2) * (m-2) << endl;
    } else if (n == 1 || m == 1){
        cout << abs(n * m - 2) << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
	int a[5];
	rep(i,5)cin>>a[i];
	int ans=0;
	rep(i,5){
		if(a[i]%10==0)ans=ans+a[i];
		else ans+=a[i]/10*10+10;
		a[i]=(a[i]-1)%10+1;
	}
	sort(a,a+5);
	ans=ans-10+a[0];
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
def ith(N,i):
    # print(N, i, (N % (10 ** (i+1))) // 10 ** i)
    return (N % (10 ** (i+1))) // 10 ** i
def next(N):
    if N < 10:
        return N+1
    if ith(N,0) == 9:
        up = next(N//10)
        # print(up)
        if ith(up,0) == 0:
            return up * 10 + ith(up,0)
        else:
            return up * 10 + ith(up,0) - 1
    if ith(N,0) == ith(N,1) + 1:
        up = next(N//10)
        if ith(up,0) == 0:
            return up * 10 + ith(up,0)
        else:
            return up * 10 + ith(up,0) - 1
    return N + 1


def main():
    K = int(input())
    ans = 1
    for i in range(K-1):
        ans = next(ans)
    print(ans)
main()

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9,MOD = 1e9+7,ohara = 1e6;
const ll LINF = 1e18;
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrrep(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt=0,ans=0,a,b,c,d,cmp,cmpp,m,h,w,x,y,sum=0,pos,k;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

int main(void){
       cin.tie(0);
    ios::sync_with_stdio(false);
      
    cin>>a>>b>>k;
    rep(i,k){
        if(i%2==0){
            if(a%2==1)a--;
            b+=a/2;
            a/=2;
        }
        else{
            if(b%2==1)b--;
            a+=b/2;
            b/=2;
        }
    }
    cout<<a<<" "<<b<<"\n";
    return 0;
}


Measured memory_bytes: 256
def xor(n1, n2):
  if n2=="0":
    return n1
  elif n2=="1":
    if n1=="1":
      return "0"
    else:
      return "1"
      
def bitxor(n1, n2):
 
  bn1 = bin(n1)[2:]
  bn2 = bin(n2)[2:]
  if n1<n2:
    bn1 = bn1.zfill(len(bn2))
  else:
    bn2 = bn2.zfill(len(bn1))
    
  n3 = [xor(b1,b2) for b1,b2 in zip(bn1, bn2)]
  n3 = "".join(n3)
  return int(n3, 2)
 
 
n = int(input())
a = [int(x) for x in input().split()]
a_unique = list(set(a))
la = len(a)
lau = len(a_unique)

if a_unique==[0]:
  print("Yes")

elif la%3==0 and (0 in a_unique):
  u0 = a.count(0)
  if u0*3!=la:
    print("No")
  else:
    a_unique.remove(0)
    tmp = [(a.count(ai)%2==0) for ai in a_unique]
    if len(tmp)==sum(tmp):
      print("Yes")
    else:
      print("No")

elif la%3==0 and lau==2 and (0 in a_unique):
  u0 = a.count(0)
  if a_unique[0]==0:
    num = a_unique[1]
  else:
    num = a_unique[0]
  u1 = a.count(num)
  if u0*2==u1:
    print("Yes")
elif la%3!=0 or lau!=3:
  print("No")
else:
  u0 = a.count(a_unique[0])
  u1 = a.count(a_unique[1])
  u2 = a.count(a_unique[2])
 
  if (a_unique[2]== bitxor(a_unique[0], a_unique[1])) and (u0==u1 and u1==u2):
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 14212
package main

import (
  "fmt"
)

func main() {
  var A,B,C int
  fmt.Scan(&A)
  fmt.Scan(&B)
  fmt.Scan(&C)
  if C >= A && C <= B {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

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

	int result = 0;
	result += n / 500 * 1000;
	n %= 500;
	result += n / 5 * 5;

	cout << result << endl;
}

Measured memory_bytes: 256
def selectionSort(A, N): # N個の要素を含む0-オリジンの配列A
    counter = 0
    for i in range(0,N):
        minj = i
        for j in range(i,N):
            if A[j] < A[minj]:
                minj = j
        A[i], A[minj] = A[minj], A[i]
        if i != minj:
            counter += 1
    return A, counter

if __name__ == '__main__':
    N = int(input())
    a = list(map(int, input().split()))
    a, num = selectionSort(a, N)
    for i in range(len(a)):
        if i != len(a)-1:
            print(a[i], end=" ")
        else:
            print(a[i])
    print(num)



Measured memory_bytes: 5604
#include <iostream>
using namespace std;
int res[201][201];
int gcd(int a, int b)
{
	if (a >= b)
		return b ? res[b][a % b] : a;
	else
		return a ? res[a][b % a] : b;
}
void culcaluate(int n)
{	
	for (int i = 0; i <= n; i++)
	{
		res[i][0] = i;
	}
	for (int i = 0; i <= n; i++)
	{
		res[0][i] = i;
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			res[i][j] = 1;
		}
	}
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= n; j++)
		{
			res[i][j] = gcd(i, j);
		}
	}
}
int main()
{
	int k;
	long long ans = 0;
	cin >> k;
	culcaluate(k);
	for (int i = 1; i <= k; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			for (int q = 1; q <= k; q++)
			{
				//if (i == j && j == q)
				{
					ans += res[res[i][j]][q];
				}
				/*else
				{
					ans = ans + 3 * res[res[i][j]][q];
				}*/
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    bool yes = true;

    for(int i=0; i< s.size(); ++i){
        if((i+1)%2==1 && s[i] == 'L')
            yes = false;
        if((i+1)%2==0 && s[i] == 'R')
            yes = false;
    }

    if(yes)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define ALL(x) x.begin(),x.end()
#define EPS (1e-8)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

typedef long long ll;
bool LTE(double a,double b) { return equals(a,b) || a < b; }
bool LT(double a,double b) { return !equals(a,b) && a < b; }

void compute() {

}

bool debug = 0;
int main() {
  int n,k;
  cin >> n >> k;
  vector<int> A(n);
  rep(i,n) cin >> A[i];
  int pos = -1;
  rep(i,n) if( A[i] == 1 ) { pos = i; break; }
  int mini = INT_MAX;
  if( n == k ) mini = 1;
  rep(i,n) {
    if( i <= pos ) {
      if( i + k - 1 >= pos ) {
	int L = i;
	int R = n - ( i + k );
	int cost = 1;
	if( 0 <= L && L <= n ) 
	  cost += ceil(L/(double)(k-1));
	if( 0 <= R && R <= n ) 
	cost += ceil(R/(double)(k-1));
	mini = min(mini,cost);
	if( debug ) {
	  cout << i << "-thU : " << L << "," << R << " cost = " << cost << endl;
	}
      }
    } else {
      if( i - k + 1 <= pos ) {
	int L = i - k + 1;
	int R = n - i;
	int cost = 1;
	if( 0 <= L && L <= n ) 
	  cost += ceil(L/(double)(k-1));
	if( 0 <= R && R <= n ) 
	  cost += ceil(R/(double)(k-1));
	mini = min(mini,cost);
	if( debug ) {
	  cout << i << "-thD : " << L << "," << R << " cost = " << cost << endl;
	}
      }
    }
  }
  cout << mini << endl;
  compute();
  return 0;
}


Measured memory_bytes: 640
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<map>
#include<set>
using namespace std;
string s, t;
set<string> S;
 
void Work()
{
    int lens = s.size();
    int lent = t.size();
    for(int i = 0; i < lens; i++)
    {
        if(s[i] == '?' || s[i] == t[0])//如果字符相等
        {
            string tmp = s;              //构造判断子串之前的字符
            for(int j = 0; j < i; j++)
                if(tmp[j] == '?')
                    tmp[j] ='a';    
            bool can = false;
            for(int j = 0; j < lent; j++)    //判断是否为子串
            {
 
                if(tmp[i+j]!= '?' && tmp[i+j] != t[j])  //字符匹配
                    break;
                tmp[i+j] = t[j];
                if(j == lent - 1) can = true;
            }
            if(can)
            {
                for(int j = i + lent; j < lens; j++) if(tmp[j] == '?') tmp[j] = 'a';//处理匹配后的字符
                S.insert(tmp);  //压入容器
            }
        }
    }
    if(S.size() == 0) cout << "UNRESTORABLE" << endl;
    else cout << *S.begin() << endl;
}
int main()
{
    cin >> s >> t;
    Work();
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 3e15
    
const int N=1e5+5;
const int M=1e9+7;
void solve()
{
	int n,k;
	cin>>n>>k;
	int ans=n%k;
	ans=min(ans,abs((n%k)-k));
	cout<<ans;
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}




Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int n=int.Parse(Console.ReadLine());
		int[] a=Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);
		Array.Sort(a);
		long ans=a[1]-a[0];
		if(n!=1){
			int i=2;
			for(;i<=n;i+=2){ans=Math.Min(ans,a[i]-a[i-2]);}
			ans=Math.Min(ans,(12-a[n])+(12-a[n-1]));
			for(i-=3-((n%2)*2);i>1;i-=2){ans=Math.Min(ans,a[i]-a[i-2]);}
		}
		Console.WriteLine(ans);
	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	int cntp = 0;
	int cnt2 = 0;
	int cnt4 = 0;
	rep(i,n) {
		if (v[i] % 4 == 0) cnt4++;
		else if (v[i] % 2 == 0) cnt2++;
		else cntp++;
	}
	if (cnt2 == 0) {
		if (cnt4 == 0) cout << "No" << endl;
		else if (cntp <= cnt4 + 1) cout << "Yes" << endl;
		else cout << "No" << endl;
	} else {
		if (cntp <= cnt4) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
const long long MOD = 1000000007;
const int INF = INT_MAX / 2;
const long double PI = 3.1415926;
#define FOR(i, r, n) for(int i=(ll)(r); i<(ll)(n); i++) 
#define REP(i, n) FOR(i, (0), n)
#define ALL(r) r.begin(), r.end()
#define ll long long int
using namespace std;
string s;
vector<ll> v;
vector<pair<ll, ll>> vp;
vector<vector<ll>> vv(110, vector<ll>(50, 0));
vector<tuple<ll, ll, ll>> vt;
set<ll> st;
map<char, ll> mp;

typedef int Weight;
struct Edge
{
	int from, to; Weight cost;
	bool operator < (const Edge& e) const { return cost < e.cost; }
	bool operator > (const Edge& e) const { return cost > e.cost; }
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
void add_edge(Graph &g, int from, int to, Weight cost)
{
	g[from].push_back(Edge{ from, to, cost });
}

typedef pair<Weight, Edge> P;

int V, limit, nf, E, r, goal;
bool isdone[100005];
vector<Weight> dist(100005, INF);
priority_queue<P, vector<P>, greater<P>> pq;

void dijkstra(Graph &g, int r)
{
	dist[r] = 0;
	isdone[r] = true;
	for (auto e : g[r])
	{
		pq.emplace(e.cost, e);
	}
	while (!pq.empty())
	{
		Edge te = pq.top().second;
		pq.pop();
		if ((dist[te.to] > dist[te.from] + te.cost)&&!isdone[te.to])
		{
			dist[te.to] = dist[te.from] + te.cost;
			isdone[te.to] = true;
			for (auto e : g[te.to])
			{
				pq.emplace(dist[te.to]+e.cost, e);
			}
		}
	}
}

int main()
{
	cin >> V >> E >> r;
	//cin >> V >> limit >> nf >> E >> r >> goal;
	Graph g(V);
	REP(i, E)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		add_edge(g, a, b, c);
	}
	dijkstra(g, r);
	REP(i, V) {
		if (dist[i] == INF) cout << "INF" << endl;
		else cout << dist[i] << endl;
	}
}

Measured memory_bytes: 18744
#include <iostream>
#define int long long
using namespace std;
signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b)swap(a, b);
	if (b > c)swap(b, c);
	if (a > b)swap(a, b);
	cout << a << ' ' << c << endl;
}


Measured memory_bytes: 3108
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll N,K,i,j,ans1;
    cin>>N>>K;
    ll a[N],b[N];
    for(i=0;i<N;i++) cin>>a[i];
    for(i=0;i<N;i++) cin>>b[i];
    // Binary search
    sort(a,a+N); sort(b,b+N,greater<ll>());
    ll l=0,r=1e18;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        ll ans=0;
        for(i=0;i<N;i++)
        {
            if(mid>=a[i]*b[i]) continue;
            else ans+=(a[i]-(mid/b[i]));
        }
        if(ans<=K) { ans1=mid; r=mid-1; }
        else l=mid+1;
    }
    cout<<ans1<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>

typedef long long ll;

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

  ll count = 0;
  for(int i = 1;i <= n;i ++){
    count += n/i;
    if(n%i == 0){
      count--;
    }
  }

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

  
  return 0;
}

Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int A, B, C;
  cin >> A >> B >> C;
  cout << min(B / A, C) << '\n';
  return 0;
}


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

#define ll long long
#define ar array
 
using namespace std;

int somarDigitos(int numero) {
    int soma = 0;

    while (numero != 0) {
        soma   += numero % 10;
        numero  = numero / 10;
    }

    return soma;
}

int main() {
	
	int a,n;
	
	cin >> a;
	
	n = somarDigitos(a);
	
	if(a%n==0){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	
   	return 0;
}
   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline void read(T &x) {
	x = 0; int c = getchar(), f = 1;
	for (; !isdigit(c); c = getchar()) if (c == 45) f = -1;
	for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0');
}
int main() {
	int A, B, C; read(A), read(B), read(C);
	return printf("%d\n", B+min(A+B+1, C)), 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

node_max = [1]
for i in range(1, n+1):
    node_max.append(min(10**18, node_max[i-1]*2-a[i]))

a.reverse()
node_max.reverse()

node_max2 = [a[0]]
node_min2 = [a[0]]

for i in range(n):
    node_max2.append(node_max2[-1]+a[i+1])
    node_min2.append((node_min2[-1]+1)//2+a[i+1])

if node_min2[-1] != 1:
    print(-1)
else:
    ans = 0
    for i in range(n+1):
        ans += min(node_max[i]+a[i], node_max2[i])

    print(ans)


Measured memory_bytes: 685804
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 110;
int n,m,a[N][N],b[N][N],ans1[N][N],cnt,ans2[N][N],c[N];
pa pos[N];
vector<int>v[N][N];

struct _{
	int n, mch[N], vistime[N];
	vector<int>e[N];
	inline void init(int _n){
		n=_n;
		For(i,1,n) e[i].clear(),mch[i]=vistime[i]=0;
	}
	inline void Add(int u,int v){
		e[u].pb(v);
	}
	bool dfs(const int u, const int tag) {
	  if (vistime[u] == tag) return false;
	  vistime[u] = tag;
	  for (auto v : e[u]) if ((mch[v] == 0) || dfs(mch[v], tag)) {
	    mch[v] = u;
	    return true;
	  }
	  return false;
	}
	inline int solve(){
		int ans=0;
		for (int i = 1; i <= n; ++i) if (dfs(i, i)) {
    		++ans;
 		}
 		return ans;
	}
}G;

int main(){
	//freopen("in01.txt","r",stdin);
	n=read(),m=read();
	For(i,1,n) For(j,1,m){
		a[i][j]=read(),b[i][j]=(a[i][j]-1)/m+1;
		v[i][b[i][j]].pb(j);
	}
	For(k,1,m){
		cnt=0,G.init(n);
		For(i,1,n) For(j,1,n) if (!v[i][j].empty()) G.Add(i,j);
		int tmp=G.solve();
		assert(tmp==n);
		For(i,1,n){
			int j=G.mch[i];
			ans1[j][k]=a[j][v[j][i].back()];
			v[j][i].pop_back();
		}
	}
	For(i,1,n){
		For(j,1,m) printf("%d ",ans1[i][j]),assert(ans1[i][j]>0);
		puts("");
	}
	For(j,1,m){
		For(i,1,n) c[i]=ans1[i][j];
		sort(c+1,c+1+n);
		For(i,1,n) ans2[i][j]=c[i];
	}
	For(i,1,n){
		For(j,1,m) printf("%d ",ans2[i][j]),assert(ans2[i][j]>0);
		puts("");
	}
}

Measured memory_bytes: 4464
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    vector<ll> v(n);
    for(auto &x:v)
    {
        cin>>x;
    }
    vector<vector<ll> > dp(n,vector<ll>(n,0));
    for(ll sz=1;sz<=n;sz++)
    {
        ll i=0;
        ll j=sz-1;
        while(j<n)
        {
            if(sz==1)
            {
                dp[i][j]=v[i];
            }
            else if(sz==2)
            {
                dp[i][j] = max(v[i]-v[j],v[j]-v[i]);
            }
            else
            {
                ll x1 = v[i] + min(dp[i+1][j-1]-v[j],dp[i+2][j]-v[i+1]);
                ll x2 = v[j] + min(dp[i][j-2]-v[j-1],dp[i+1][j-1]-v[i]);
                dp[i][j] = max(x1,x2);
            }
            i++;
            j++;
        }
    }
    cout<<dp[0][n-1];
    return 0;
}



Measured memory_bytes: 70784
#include<stdio.h>

int main(){

int N;int A,B,SA=0,SB=0;
while(1){
SA=0,SB=0;

scanf("%d",&N);
if(N==0)break;
for(int i=0;i<N;i++){
scanf("%d %d",&A,&B);
if(A>B)SA=SA+A+B;
else if(B>A)SB=SB+A+B;
else {SA+=A;SB+=B;}
}

printf("%d %d\n",SA,SB);
}
return 0;
}

Measured memory_bytes: 1028
////**********CODED BY :- DURGESH KUMAR***************////
    #include<bits/stdc++.h>
    #define ff double
    #define endl "\n"
    #define ll long long
    #define pb push_back
    #define vi vector<int>
    #define mii map<int,int>
    #define pii pair<int,int>
    #define test ll t;cin>>t;while(t--)
    #define REP(i,n) for(int i=0;i<(n);i++)
    #define FOR(i,a,b) for(int i=(a);i<=(b);i++)
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
    #define M 1000000007
    using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    REP(i,n)
    cin>>arr[i];

    ll brr[n];
    REP(i,n)
    cin>>brr[i];

    ll crr[n];
    REP(i,n-1)
    cin>>crr[i];

    ll ans=0;
    ll prev=arr[0];
    for(int i=0;i<n;i++)
    {
    ans=ans+brr[arr[i]-1];
    if(arr[i]-prev==1)
    {
    if(arr[i]!=1)
    ans=ans+crr[arr[i-1]-1];
    }
    prev=arr[i];
    }

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


Measured memory_bytes: 256
import java.io.*;

public class Main {
    public static void main(String[] args) {
        try {
            int a,b,h,m;
            BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
            String[] temp = in.readLine().split(" ");
            a = Integer.parseInt(temp[0]);
            b = Integer.parseInt(temp[1]);
            h = Integer.parseInt(temp[2]);
            m = Integer.parseInt(temp[3]);
            m += h * 60;
            double c = Math.PI * m / 360;
            double d = Math.PI * m / 30;
            double t = d - c;
            while(t > 0) t -= 2 * Math.PI;
            t = Math.min(-t, 2 * Math.PI + t);
            System.out.print(Math.sqrt(a*a + b*b - 2*a*b*Math.cos(t)));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}


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

using namespace std;

using ll = long long;

constexpr char newl = '\n';

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

    int K;
    cin >> K;

    for (int i = 0; i < K; i++) {
        cout << "ACL";
    }
    cout << newl;

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=20;
const ll S=1<<16;
const ll mod=1e9+7;
ll n,m,a[N],f[N][S],siz[S],fac[S+5],inv[S+5],id[S],ans;
ll C(ll n,ll m){
	if(n<m)return 0;
	return fac[n]*inv[m]%mod*inv[n-m]%mod;
}
signed main(){
	n=read(),m=read();
	for(ll i=1;i<=m;i++)a[i]=read();
	for(ll i=1;i<1<<n;i++)siz[i]=siz[i>>1]+(i&1);
	for(ll i=0;i<n;i++)id[1<<i]=i;
	fac[0]=1;for(ll i=1;i<=S;i++)fac[i]=fac[i-1]*i%mod;
	inv[1]=1;for(ll i=2;i<=S;i++)inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	inv[0]=1;for(ll i=1;i<=S;i++)inv[i]=inv[i-1]*inv[i]%mod;
	f[m+1][0]=1;
	for(ll i=m+1;i>=2;i--)for(ll sta=0;sta<1<<n;sta++)if(f[i][sta]){
		f[i-1][sta]=(f[i-1][sta]+f[i][sta])%mod;
		ll fsta=((1<<n)-1)^sta;
		for(;fsta;){
			ll x=id[fsta&(-fsta)];
			if((1<<n)-a[i-1]+1>=(sta|(1<<x)))f[i-1][sta|(1<<x)]=(f[i-1][sta|(1<<x)]+f[i][sta]*C((1<<n)-a[i-1]-sta,(1<<x)-1)%mod*fac[1<<x]%mod)%mod;
			fsta-=fsta&(-fsta);
		}
	}
	ans=fac[1<<n];for(ll sta=1;sta<1<<n;sta++)ans=(ans+(siz[sta]&1?mod-1:1)*f[1][sta]%mod*fac[(1<<n)-1-sta]%mod*(1<<n)%mod)%mod;
	return cout<<ans,signed();
}
/*
2 1 3
4 3 2 4 6
3 0
3 3 3 4 7
16 16 5489 5490 5491 5492 5493 5494 5495 5497 18993 18995 18997 18999 19000 19001 19002 19003
*/

Measured memory_bytes: 11596
// abc044_c
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B>
bool cmin(A &a, const B &b)
{
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B>
bool cmax(A &a, const B &b)
{
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll solve(vector<ll> &vx, ll offset, ll n, ll sum, vector<vector<vector<ll>>> &memo)
{
  if (offset == vx.size())
  {
    return sum == 0 && n == 0;
  }

  if (sum < 0 || n < 0)
  {
    return 0;
  }

  if (memo[offset][n][sum] == -1)
  {

    memo[offset][n][sum] = solve(vx, offset + 1, n, sum, memo) +
                           solve(vx, offset + 1, n - 1, sum - vx[offset], memo);
  }

  return memo[offset][n][sum];
}

int main()
{
  ll n, a;
  cin >> n >> a;
  vector<ll> vx(n);
  for (auto &x : vx)
  {
    cin >> x;
  }

  vector<vector<vector<ll>>> memo(
      60, vector<vector<ll>>(60, vector<ll>(60 * 60, -1)));
  ll ans = 0;
  for (int i = 1; i <= n; ++i)
  {
    ans += solve(vx, 0, i, a * i, memo);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 106436