akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using graph = vector<vector<int>>;

vector<int> retrograde(const graph& g) { // (0, 1, 2) = (lose, win, draw)
	int n = g.size();
	graph rg(n);
	vector<int> cnt(n), res(n, 2);
	queue<int> q;
	for (int i = 0; i < n; i++) {
		for (int to : g[i]) rg[to].push_back(i);
		cnt[i] = g[i].size();
		if (!cnt[i]) res[i] = 0, q.push(i);
	}
	while (!q.empty()) {
		int v = q.front(); q.pop();
		if (res[v]) {
			for (int to : rg[v]) if (res[to] == 2) {
				--cnt[to];
				if (cnt[to]) continue;
				res[to] = 0;
				q.push(to);
			}
			continue;
		}
		for (int to : rg[v]) if (res[to] == 2) res[to] = 1, q.push(to);
	}
	return res;
}

int main()
{
	ios::sync_with_stdio(false), cin.tie(0);
	int H, W, R, C;
	while (cin >> H >> W >> R >> C, H | W | R | C) {
		int S = (H + 2) * (W + 2);
		graph G(S * 3);
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				G[i * (W + 2) + j + S * 2].push_back(i * (W + 2) + j);
				G[i * (W + 2) + j + S * 2].push_back(i * (W + 2) + j + S);
			}
		}
		for (int t = 0; t <= H * 2; t++) {
			int i = (t + 1) >> 1;
			int s;
			if (t % 2 == 0) {
				for (int j = 1; j <= W; j++) {
					cin >> s;
					if (0 < i) G[i * (W + 2) + j + S * s].push_back((i + 1) * (W + 2) + j + S * 2);
					if (i < H) G[(i + 1) * (W + 2) + j + S * s].push_back(i * (W + 2) + j + S * 2);
				}
			}
			else {
				for (int j = 0; j <= W; j++) {
					cin >> s;
					if (0 < j) G[i * (W + 2) + j + S * s].push_back(i * (W + 2) + (j + 1) + S * 2);
					if (j < W) G[i * (W + 2) + (j + 1) + S * s].push_back(i * (W + 2) + j + S * 2);
				}
			}
		}
		cout << (retrograde(G)[R * (W + 2) + C] == 1 ? "Yes" : "No") << endl;
	}
	return 0;
}



Measured memory_bytes: 91224
#include<stdio.h>
int S[400010];
int T,NAN=2147483647;
int hyoka(int a,int b){return a<b?a:b;}
void sset(int n,int *d){
  int i;
  for(T=1;T<n;T*=2);
  for(i=0;i<n;i++)S[T+i]=d[i];
  for(   ;i<T;i++)S[T+i]=NAN;
  for(i=T-1;i;i--)S[i]=hyoka(S[i*2],S[i*2+1]);
}
void sud(int i,int n){
  S[i+=T]=n;
  while(i/=2)S[i]=hyoka(S[i*2],S[i*2+1]);
}
int sout(int a,int b,int i,int l,int r){
  if(r<=a||b<=l)return NAN;
  if(a<=l&&r<=b)return S[i];
  return hyoka(sout(a,b,i*2,l,(l+r)/2),sout(a,b,i*2+1,(l+r)/2,r));
}
int main(){
  int i,n,m,q,a,b,d[100000];
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)d[i]=NAN;
  sset(n,d);
  while(m--){
    scanf("%d %d %d",&q,&a,&b);
    if(q)printf("%d\n",sout(a,b+1,1,0,T));
    else sud(a,b);
  }
  return 0;
}

Measured memory_bytes: 2016
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		new Main().run();
	}

	private void run() {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			String line = scanner.next();
			if (line.equals("#"))
				break;
			int now = 0;
			for (int i = 0; i < line.length(); i++) {
				int a = line.charAt(i) - '0';
				now = move[now][a];
			}
			System.out.println(now == 5 ? "Yes" : "No");
		}
	}

	int[][] move = { { 1, 2 }, { 6, 3 }, { 1, 6 }, { 4, 5 }, { 5, 2 },
			{ 2, 1 }, { 6, 6 } };
}

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

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

using namespace std;


int main() {

    ll n; cin >> n;
    vector<ll> t(100001),x(100001),y(100001),s(100001);
    bool f = true;

    rep(i,n){
        cin >> t[i] >> x[i] >> y[i];
        s[i] = x[i] + y[i];
    }

    rep(i,n){
        if(i == 0) {
            if (t[i] < s[i]) f = false;
            else if (t[i] > s[i] && (t[i] - s[i]) % 2 == 1) f = false;
        }else{
            if (t[i]-t[i-1]  < abs(s[i]-s[i-1])) f = false;
            else if (t[i]-t[i-1] > abs(s[i]-s[i-1]) && (t[i]-t[i-1] - abs((s[i]-s[i-1]))) % 2 == 1) f = false;
        }
    }

    cout << ((f)?"Yes":"No");


    return 0;
}











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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
	double a,b,x;
    cin>>a>>b>>x;
    x/=a;
    double S=a*b/2;
    double theta;
    if(x>S) theta=atan2(2*(a*b-x),a*a);
    else theta=atan2(b*b,2*x);
    double ans=theta*180/pi;
    printf("%.10lf\n",ans);
	return 0;
}

Measured memory_bytes: 4140
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  string s;
  int k;
  cin >> s >> k;
  vector<string> array;
  rep(i,s.size())FOR(j,i,s.size()){
    string nextS = s.substr(i,j-i+1);
      if(array.size() < 6){
        array.push_back(nextS);
        //descendingSort
        sort(all(array));
        //unique
        array.erase(unique(all(array)),array.end());
      }else if(array[4] > nextS){
        array[5] = nextS;
        //descendingSort
        sort(all(array));
        //unique
        array.erase(unique(all(array)),array.end());
      }
  }
  //rep(i,array.size()) cout << array[i] << endl;
  cout << array[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
import heapq

N, M = map(int, input().split())
a_list = list(map(int, input().split()))

minus_a_list = [-a for a in a_list]
heapq.heapify(minus_a_list)

for _ in range(M):
    value = -(heapq.heappop(minus_a_list))
    heapq.heappush(minus_a_list, -(value//2))

print(-sum(minus_a_list))

Measured memory_bytes: 14188
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
using namespace std;
#define MAXN 500
int w[MAXN]={0,300000,200000,100000};
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	int ans=w[a]+w[b];
	if (a==b&&a==1) ans+=400000;
	printf("%d\n",ans);
	return 0;
}

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

int s[101][10];
int a[101];
int n;

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    for (int i = 0; i <= n; i++) for (int j = 0; j < 10; j++)
        {
            s[i][j] = -1e9;
        }
    s[0][0] = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            s[i + 1][j] = max(s[i + 1][j], s[i][j]);
            if (s[i][j] < 0)
            {
                continue;
            }
            int nj = (j + a[i + 1]) % 10;
            s[i + 1][nj] = max(s[i + 1][nj], s[i][j] + a[i + 1]);
        }
    }
    int ans = 0;
    for (int i = 1; i < 10; i++)
    {
        ans = max(ans, s[n][i]);
    }
    cout << ans << endl;
    return 0;
}


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

#define INF 1e9
#define PI 3.141592653589793238
#define N 1000000010
#define mod 1000000007
#define REP(inc, bgn, end) for(int inc=bgn; inc<end; inc++)
typedef long long ll;

int main() {
    ll sum; cin>>sum;
    ll ary[3000];
    for(int i=0; i<=sum; i++) ary[i]=0;
    ary[0] = 1;
    ary[1] = 0;
    ary[2] = 0;
    ary[3] = 1;
    ary[4] = 1;
    ary[5] = 1;
    for(int i=6; i<=sum; i++){
        for(int j=i-3; j>=0; j--){
            ary[i] += ary[j];
            ary[i] %= mod;
        }
    }

    ll ans = ary[sum];
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3644
object Main extends App {
  var s = io.StdIn.readLine().toInt
  def f(x: Int): Int = if(x % 2 == 0) x / 2 else 3 * x + 1
  var seq = Seq[Int]()
  while (!seq.contains(s)) {
    seq ++= Seq[Int](s)
    s = f(s)
  }
  println(seq.length + 1)
}

Measured memory_bytes: 25404
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		StringTokenizer st = new StringTokenizer(bf.readLine());
 		int n = Integer.parseInt(st.nextToken());
 		int k = Integer.parseInt(st.nextToken());
 		int[] array = new int[n+1];
 		int[] prefix = new int[n+2];
 		prefix[0] = 0;
 		StringTokenizer st1 = new StringTokenizer(bf.readLine());
 		for(int i = 1;i<=n;i++){
 			array[i] = Integer.parseInt(st1.nextToken());
 		}
 		for(int i = 1;i<=n;i++){
 			prefix[i] = array[i]-array[i-1];
 		}
 		for(int i = 0;i<Math.min(k,  100);i++){
 			int[] newarray = new int[n+2];
 			int sum = 0;
 			for(int j = 1;j<=n;j++){
 				sum+=prefix[j];
 				newarray[Math.max(1,j-sum)]++;
 				newarray[Math.min(n+1, j+sum+1)]--;
 			}
 			for(int j = 1;j<=n;j++){
 				prefix[j] = newarray[j]+0;
 			}
 		}
 		int sum = 0;
 		for(int j = 1;j<=n;j++){
 			sum+= prefix[j];
 			out.print(sum + " ");
 		}
		
 		out.close();
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

pair <string, int> p[55];

int main() {
	int n;
	scanf("%d", &n);
	int sum = 0;
	for (int i=0 ; i<n ; i++) {
		cin >>p[i].x>>p[i].y;
	}
	string s;
	cin >>s;
	bool st = false;
	for (int i=0 ; i<n ; i++) {
		if (st) sum += p[i].y;
		if (p[i].x == s) st = true;
	}
	cout <<sum<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<ll> vecll;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < (ll)n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007
#define _SPLIT " "

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T,class ...Args> void read(T& a, Args&... args){cin >> a; read(args...);} 
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << setprecision(12) << a << endl;}
template<class T,class ...Args> void write(T a, Args... args){cout << setprecision(12) << a << _SPLIT; write(args...);}
template<class T> void warr(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll gcd(ll a, ll b){while(true){ll k = a % b;if(k == 0)return b;a = b;b = k;}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}

int main(void)
{
    string s;
    read(s);
    int n=s.size();
    int x1=-1,x2=-1;
    REP(d,1,3){
        REP(i,d,n){
            if(s[i-d]==s[i]){
                x1=i-d+1,x2=i+1;
                break;
            }
        }
        if(x1>=0)break;
    }
    write(x1,x2);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for(int i=0;i<N;i++){
    cin >> p.at(i);
  }
  
  bool icchi = true;
  for(int i=0;i<N;i++){
  	if(i+1 != p.at(i)){
      int a = p.at(p.at(i)-1);
      p.at(p.at(i)-1) = p.at(i);
      p.at(i) = a;
      icchi = false;
    }
    if(icchi == false){
      break;
    }
  }
 
  icchi = true;
  for(int i=0;i<N;i++){
  	if(i+1 != p.at(i)){
      cout << "NO" << endl;
      icchi = false;
    }
    if(icchi == false){
      break;
    }
  }
  if(icchi){
    cout << "YES" << endl;
  }
   
  
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<limits>

using namespace std;

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

  int N, C;
  cin >> N >> C;
  vector<vector<int>> D(C, vector<int>(C));

  for (int i = 0; i < C; ++i) {
    for (int j = 0; j < C; ++j) {
      cin >> D[i][j];
    }
  }

  vector<int> c0(C, 0), c1(C, 0), c2(C, 0);
  int c;
  for (int i = 1; i <= N; ++i) {
    for (int j = 1; j <= N; ++j) {
      cin >> c;
      switch ((i + j) % 3) {
        case 0:
          for (int k = 1; k <= C; ++k) {
            c0[k-1] += D[c-1][k-1];
          }
          break;
        case 1:
          for (int k = 1; k <= C; ++k) {
            c1[k-1] += D[c-1][k-1];
          }
          break;
        case 2:
          for (int k = 1; k <= C; ++k) {
            c2[k-1] += D[c-1][k-1];
          }
          break;
      }
    }
  }

  int minval = numeric_limits<int>::max();
  for (int i = 0; i < C; ++i) {
    for (int j = 0; j < C; ++j) {
      if (i == j) continue;
      for (int k = 0; k < C; ++k) {
        if (i == k || j == k) continue;
        int val = c0[i] + c1[j] + c2[k];
        if (val < minval) minval = val;
      }
    }
  }

  cout << minval << endl;

  return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
k = list(map(int, input().split()))
d = [0]*(m-1)
k.sort()
for i in range(m-1):
    d[i] = abs(k[i]-k[i+1])
d = sorted(d, reverse=True)
res = 0
for i in range(n-1):
    if i==m-1:
        break
    res += d[i]
print(sum(d)-res)


Measured memory_bytes: 13960
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <iterator>
#include <map>
#include <set>
#include <iomanip>
#include <vector>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Graph = vector<vector<int>>;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#define rep(i, N) for(int i = 0; i < N; i++)
#define rep2(i, l, r) for (ll i = (ll)l; i < (ll)(r); i++)
#define INF 1000000000000000000
#define MAX 200001
#define MOD 1000000007

template <typename T > inline string toString(const T &a) {ostringstream oss; oss << a; return oss.str();};

int main(){
    string s,t;
    cin >> s >> t;
    vector<vector<ll>> dp(3001, vector<ll>(3001, 0));
    for(int i = 1; i < s.size() + 1; i++){
        for(int j = 1; j < t.size() + 1; j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = dp[i-1][j-1] + 1;
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    string ans = "";
    int x = s.size();
    int y = t.size();
    while(x > 0 && y > 0){
        if(dp[x][y] == dp[x-1][y]) x--;
        else if(dp[x][y] == dp[x][y-1]) y--;
        else{
            x--;
            y--;
            ans += s[x];
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
}

Measured memory_bytes: 73756
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll A, B, C, K;
  cin >> A >> B >> C >> K;
  for(ll i = 0; i < K; i++) {
    if(A >= B) B *= 2;
    else if(B >= C) C*= 2;
  }
  if((A < B) && (B < C)) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3632
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        FastScanner sc = new FastScanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int a = sc.nextInt();
        int b = sc.nextInt();
        pw.println((a-1)*(b-1));
        pw.flush();
    }

    static class GeekInteger {
        public static void save_sort(int[] array) {
            shuffle(array);
            Arrays.sort(array);
        }
 
        public static int[] shuffle(int[] array) {
            int n = array.length;
            Random random = new Random();
            for (int i = 0, j; i < n; i++) {
                j = i + random.nextInt(n - i);
                int randomElement = array[j];
                array[j] = array[i];
                array[i] = randomElement;
            }
            return array;
        }
 
    }
}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

char s[10010];
bool comb[1<<10][10];

int main(void){
	int n;
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		scanf("%s",s);
		
		memset(comb,false,sizeof(comb));
		bool safe=true;
		
		int mask=0;
		rep(i,n){
			if(s[i]=='u')
				mask=0;
			else{
				int get=s[i]-'0';
				if((mask&(1<<get))==0)
					comb[mask][get]=true;
				else
					safe=false;
				mask|=(1<<get);
			}
		}

		if(safe==false){
			puts("UNSAFE");
			continue;
		}

		rep(mask1,1<<10)rep(get1,10)rep(mask2,1<<10)rep(get2,10){
			if(comb[mask1][get1]==false) continue;
			if(comb[mask2][get2]==false) continue;
			if(mask1&mask2) continue;
			if( (mask2&(1<<get1))!=0 &&  (mask1&(1<<get2))==0) comb[mask1|mask2][get2]=true;
		}

		
		rep(mask1,1<<10)rep(get1,10)rep(mask2,1<<10)rep(get2,10){
			if(comb[mask1][get1]==false) continue;
			if(comb[mask2][get2]==false) continue;
			if(mask1&mask2) continue;
			if( (mask2&(1<<get1))!=0 &&  (mask1&(1<<get2)) !=0){
				safe=false;
				mask1=1<<10,get1=10,mask2=1<<10,get2=10;
			}
		}

		if(safe)
			puts("SAFE");
		else
			puts("UNSAFE");	
	}
	return 0;
}

Measured memory_bytes: 3148
#include<iostream>
#include<vector>
#include<stdio.h>
using namespace std;
int main(){
  int train[10],n,i;
  n = 0;
  int order[100],intrain[10];
  for( i = 1;i <= 10;i++){
    train[i] = i;
  }
  for(i=0;i<100;i++)
    order[i] = 11;
  i = 0;
  while(scanf("%d",&order[i]) != EOF){i++;}
  for(i = 0;order[i] != 11;i++){
    if(order[i] != 0){
      intrain[n] = order[i]; n++;}else if(order[i] == 0){
      n--;      cout << intrain[n] << endl;}
  }
}
 
    

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <vector>

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

std::vector<int> insertion_sort(std::vector<int> A) {
  int key, j;

#if display
  for (int k = 0; k < A.size(); k++) {
    if (k > 0) {
      std::cout << " ";
    }
    std::cout << A[k];
  }
  std::cout << std::endl;
#endif

  for (int i = 1; i < A.size(); i++) {
    key = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > key) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = key;

#if display
    for (int k = 0; k < A.size(); k++) {
      if (k > 0) {
        std::cout << " ";
      }
      std::cout << A[k];
    }
    std::cout << std::endl;
#endif
  }
  return A;
}

int main() {
  int N;
  std::cin >> N;
  std::vector<int> A(N);
  rep(i, N) { std::cin >> A[i]; }
  std::vector<int> AA = insertion_sort(A);
  return 0;
}

Measured memory_bytes: 3072
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int n, x, t;
    cin>>n>>x>>t;
    int d;
    d=n/x;
    if(n%x)d=(n/x)+1;
    cout<<d*t<<endl;

    return 0;
}

Measured memory_bytes: 3648
n = int(input())
a = list(map(int,input().split()))
dic = {} # i + a[i]
ans = 0
for i in range(n):
    if i+a[i] in dic.keys():
        dic[i+a[i]] +=1
    else:
        dic[i+a[i]] = 1
for i in range(n):
    if i - a[i] in dic.keys():
        ans +=dic[i - a[i]]
print(ans)

Measured memory_bytes: 111624
s[50],i,j,p;
main(q){for(;j=i=atoi(gets(s));printf("%d\n",i)){
for(;i;s[j-i--]=strlen(gets(s+j)));
for(q=0;q>0||(j?(p=i++,j=q=6):0);)for(q=6842496>>--j*4&15;q>1;)q-=s[p++];
}}

Measured memory_bytes: 532
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstring>
#include<iostream>
using namespace std;
typedef long long ll;
const int maxn=2e5+5;
char a[maxn];
int n,p,x,base=1;
ll ans,cnt[maxn];
int main(){
    scanf("%d %d %s",&n,&p,a);
    if(p==2||p==5){
        for(int i=0;i<n;i++){
            if((a[i]-'0')%p==0){
                ans=ans+i+1;
            }
        }
    }else{
        cnt[0]=1;//这个特判一下
        for(int i=n-1;i>=0;i--){
            x=(x+(a[i]-'0')*base)%p;
            ans=ans+cnt[x];
            cnt[x]++;
            base=base*10%p;
//            printf("%d %lld\n",x,cnt[x]);
        }
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 512
#pragma region header
#include <bits/stdc++.h>
#define all(a) begin(a), end(a)
#define mp make_pair
#define rep1(i, n) for (decltype(+n) i = 0; i < (n); i++)
#define rrep1(i, n) for (auto i = n - 1; i > static_cast<decltype(i)>(-1); i--)
#define rep2(i, a, b) for (auto i = (a); i < (b); i++)
#define rrep2(i, a, b) for (auto i = b - 1; i >= a; i--)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep2, rep1) (__VA_ARGS__)
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep2, rrep1) (__VA_ARGS__)
#define each(i, a) for (auto &&i : (a))
using namespace std;

using vi = vector<int>;

template <class T>
void COUT(const T &x) { cout << x << endl; }

constexpr int lshift(const int &x) noexcept { return 1ll << x; }

#pragma endregion header

void solve(int N, vi a, vi b) {
  int ans = 0;
  vi t(30, 1);
  rep(i, 29) t[i + 1] = t[i] << 1;
  rrep(k, 29) {
    each(x, a) x %= t[k + 1];
    each(x, b) x %= t[k + 1];
    sort(all(b));
    bool odd = false;
    int t1 = t[k], t2 = t[k] * 2, t3 = t[k] * 3, t4 = t[k] * 4;
    each(x, a) odd ^= ((lower_bound(all(b), t4 - x) - lower_bound(all(b), t3 - x)) ^ (lower_bound(all(b), t2 - x) - lower_bound(all(b), t1 - x))) & 1;
    if(odd) ans += lshift(k);
  }
  COUT(ans);
}


#pragma region main
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(15);

  int N;
  cin >> N;
  vi a(N);
  for(int i = 0 ; i < N ; i++){
    cin >> a[i];
  }
  vi b(N);
  for(int i = 0 ; i < N ; i++){
    cin >> b[i];
  }
  solve(N, move(a), move(b));
}
#pragma endregion main


Measured memory_bytes: 4668
import itertools
for e in iter(input, '0 0'):
    ans = 0
    # print(e.split())
    n = int(e.split()[0])
    x = int(e.split()[1])
    num = [i for i in range(1, n+1)]
    # print(num)
    for v in itertools.combinations(num, 3):
        if sum(v) == x:
            ans += 1
    print(ans)


Measured memory_bytes: 5640
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, n, k) for (int i = n; i < k; i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(24) << fixed << p << endl;
#define vi vector<int>
#define printv(v)                      \
    for (int i = 0; i < v.size(); i++) \
        P(v[i]);
#define printt(a, b) cout << a << " " << b << endl;
#define mp(a, b) make_pair(a, b)
#define pb(a) push_back(a)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};
int MOD = 1e9 + 7;

void solve()
{
    int n, k;
    cin >> n >> k;
    double dn = n, dk = k;
    double t = 0;
    REP(i, 1, min(n, k) + 1)
    {
        int count = 0;
        int ii = i;
        while (ii < k)
        {
            count++;
            ii *= 2;
        }
        t += (double)(1.0 / dn) * pow(0.5, count);
    }
    if (n < k)
    {
        sP(t);
    }
    else
    {
        sP(double((dn - dk) / dn) + t);
    }
}

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


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

char x[200010];
int main()
{
	scanf("%s",x+1);
	int a = strlen(x+1);
	for(int i=1;i<=a;i++) if(x[i]=='?') x[i] = 'D';
	for(int i=1;i<=a;i++) printf("%c",x[i]);
}

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

using namespace std;

const int Inf = 1e9;

int main()
{
    int n, m, k;    cin >> n >> m >> k;

    vector <int> C(n);
    vector <vector <int>> A(n, vector <int> (m));

    for(int i = 0; i < n; i++)
    {
        scanf("%d", &C[i]);
        for(int& x : A[i])  scanf("%d", &x);
    }

    int Ans = Inf;

    for(int Mask = 0; Mask < (1 << n); Mask++)
    {
        int Cost = 0;
        vector <int> B(m);

        for(int i = 0; i < n; i++)
            if(Mask & (1 << i))
                Cost += C[i];

        for(int i = 0; i < n; i++)
            if(Mask & (1 << i))
                for(int j = 0; j < m; j++)
                    B[j] += A[i][j];

        if(*min_element(B.begin(), B.end()) >= k)   Ans = min(Ans, Cost);
    }

    if(Ans == Inf)  Ans = -1;

    cout << Ans << endl;
}


Measured memory_bytes: 3716
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
 * 境界部分には気をつける(そこだけ別で処理するというのもあり)
 * 逆再生することで簡単になることもある
 */
public class Main {
    public Main() {
    }

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

    public void exec() {
        BufferedReader bf = null;
        try{
            bf = new BufferedReader(new InputStreamReader(System.in));
            exec_body(bf);
        } catch (IOException e) {
			e.printStackTrace();
		}
        finally{
            if( bf != null ) {
                try {
					bf.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
            }
        }
    }

    public void exec_body( BufferedReader bf ) throws IOException {
    		bf.readLine();
    		int[] sList = toList(bf.readLine());
    		bf.readLine();
    		int[] tList = toList(bf.readLine());

    		int cnt = 0;
    		for( int tval : tList ) {
    			for( int sval : sList ) {
    				if( tval == sval ) {
    					cnt++;
    					break;
    				}
    			}
    		}

    		System.out.println( cnt );
    }

    public int[] toList( String str ) {
    		String[] vals = str.split(" ");
    		int[] ret = new int[vals.length];
    		for( int i = 0; i < ret.length; i++ ) {
    			ret[i] = Integer.valueOf(vals[i]);
    		}

    		return ret;
    }
}


Measured memory_bytes: 27316
#include<stdio.h>
int main()
{
	int a,b;

	scanf("%d", &a);
	scanf("%d", &b);

	if ((a + b) == 15)
		printf("+\n");
	else if ((a * b) == 15)
		printf("*\n");
	else
		printf("x\n");

	return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main {
	static final long MOD = 1000000007L;

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

	private void solveA() {
		Scanner sc = new Scanner(System.in);
		int five = 0;
		int seven = 0;
		for (int i = 0; i < 3; i++) {
			switch (sc.nextInt()) {
			case 5:
				five++;
				break;
			case 7:
				seven++;
				break;
			default:
			}
		}
		if (five == 2 && seven == 1) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}

	private void solveB() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int L = sc.nextInt();
		List<String> list = new ArrayList<String>();
		for (int i = 0; i < N; i++) {
			list.add(sc.next());
		}
		Collections.sort(list);
		for (String str : list) {
			System.out.print(str);
		}
		System.out.println();
	}

	private void solveC() {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int K = sc.nextInt();
		boolean[] forbid = new boolean[10];
		int[] next = new int[10];
		for (int i = 0; i < 10; i++) {
			forbid[i] = false;
			next[i] = i;
		}
		for (int i = 0; i < K; i++) {
			forbid[sc.nextInt()] = true;
		}
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				if (!forbid[(i + j) % 10]) {
					next[i] = i + j;
					break;
				}
			}
		}

		int L = N.length();
		String answer = "";
		boolean lift = false;
		for (int i = 0; i < N.length(); i++) {
			char c = N.charAt(L - i - 1);
			int ctoi = c - '0' + (lift ? 1 : 0);
			int ni = next[ctoi % 10] % 10;
			if (ctoi == ni) {
				answer = ni + answer;
			} else {
				int AL = answer.length();
				answer = "" + ni;
				for (int j = 0; j < AL; j++) {
					answer = answer + next[0];
				}
			}
			lift = (ctoi >= 10 || next[ctoi] >= 10);
		}
		if (lift) {
			System.out.print("1");
		}
		System.out.println(answer);
	}

	private void solveD() {
		Scanner sc = new Scanner(System.in);
		long H = sc.nextLong();
		long W = sc.nextLong();
		long A = sc.nextLong();
		long B = sc.nextLong();

		long startRowIndex = H - A;
		long startColIndex = B + 1;
		long answer = 0L;
		for (long shiftIndex = 0; startRowIndex - shiftIndex > 0 && startColIndex + shiftIndex <= W; shiftIndex++) {
			answer += pointComb(H, W, H - A - shiftIndex, B + 1 + shiftIndex);
			answer %= MOD;
		}
		System.out.println(answer);
	}

	/**
	 * h行w列の格子について点(r, c)を通る組み合わせを求めます
	 * @param h 格子の行数
	 * @param w 格子の列数
	 * @param r 通る点の行index
	 * @param c 通る点の列index
	 * @return C(r + c - 2, c - 1) * C(h - r + w - c, w - c)
	 */
	private long pointComb(long h, long w, long r, long c) {
		return combination(r + c - 2, c - 1) * combination(h - r + w - c, w - c);
	}

	/**
	 * n個からm個選ぶ組み合わせの数を求めます
	 * @param n 全体の数
	 * @param m 選ぶ数
	 * @return C(n, m)
	 */
	private long combination(long n, long m) {
		if (n / 2 < m) {
			return combination(n , n - m);
		}
		if (m <= 0) {
			return 1;
		}
		return (combination(n, m - 1) * (n - m + 1) / m) % MOD;
	}
}

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

int main(){
    int N, mini, r;
    int maxi = -1000000007;
    cin >> N >> mini;
    for(int i=1; i < N; ++i){
        cin >> r;
        maxi = max(maxi, r - mini);
        mini = min(mini, r);
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 3108
class UnionFind():
  def __init__(self, n):
    self.n = n
    self.parents = [-1] * n

  def find(self, x):
    if self.parents[x] < 0:
      return x
    else:
      self.parents[x] = self.find(self.parents[x])
      return self.parents[x]

  def union(self, x, y):
    x = self.find(x)
    y = self.find(y)

    if x == y:
      return

    if self.parents[x] > self.parents[y]:
      x, y = y, x

    self.parents[x] += self.parents[y]
    self.parents[y] = x

  def size(self, x):
    return -self.parents[self.find(x)]

  def same(self, x, y):
    return self.find(x) == self.find(y)

  def members(self, x):
    root = self.find(x)
    return [i for i in range(self.n) if self.find(i) == root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x < 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    return {r: self.members(r) for r in self.roots()}

  def __str__(self):
    return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
  
N, M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
  a,b = map(lambda x:int(x)-1, input().split())
  uf.union(a,b)
  
rlt = 0
for i in range(N):
  rlt = max(rlt, uf.size(i))
print(rlt)

Measured memory_bytes: 80416
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (int)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


int extend_gcd(int a, int b, int& x, int& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    int x1, y1;
    int d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

int rowNum[]={-1,0,0,1};
int colNum[]={0,-1,1,0};

int main()
{
	fastio
	string a,b;
	cin>>a>>b;

	int ans=0;

	for(int i=0;i<a.size();i++)
	{
		if(a[i]!=b[i])
			ans++;
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 3800
n= int(input())
if n == 1:
    print(1)
    exit(0)
balls = []
pqs = []
for i in range(n):
    x, y = map(int, input().split())
    balls.append((x,y))

for i in range(n):
    for j in range(n):
        pqs.append((balls[i][0] - balls[j][0], balls[i][1] - balls[j][1]))
ans = 1 << 30
for p, q in pqs:
    tmp = 0
    if p == 0 and q == 0:continue
    for x, y in balls:
        prev = (x-p, y-q)
        if prev not in balls:
            tmp += 1
    ans = min(ans, tmp)

print(ans)
    

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

int n,c;
int s[200001][31];

int main(){
	cin>>n>>c;
	int t1,t2,t3;
	for(int i=1; i<200001;i++){
		for(int j=1;j<=30;j++){
			s[i][j]=0;
		}
	}
	for(int i=1;i<=n;i++){
		cin>>t1>>t2>>t3;
		for(int j=t1*2-1;j<t2*2;j++){
			s[j][t3]=1;
		}
	}
	int ans=0;
	for(int i=1;i<200001;i++){
		int tmp=0;
		for(int j=1;j<=30;j++){
			tmp+=s[i][j];
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 24576
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;



class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().calc();
        return 0;
    }
    

    Scanner cin;
    

    void calc()
    {
        cin = new Scanner();
        int H = cin.nextInt();
        int W = cin.nextInt();
        Console.WriteLine(calc(H, W));
    }

    long calc(int H, int W)
    {
        long H3 = H / 3;
        long W3 = W / 3;
        long ans = long.MaxValue;
        for (int i = -10; i < 10; i++)
        {
            long H2 = H3 + i;
            if (H2 <= 0 || H2 >= H) continue;
            ans = Math.Min(ans, calc2(H - H2, W, H2 * W));
        }
        for (int i = -10; i < 10; i++)
        {
            long W2 = W3 + i;
            if (W2 <= 0 || W2 >= W) continue;
            ans = Math.Min(ans, calc2(H, W - W2, H * W2));
        }
        return ans;
    }

    long calc2(long H, long W, long pre)
    {
        long H2 = H / 2;
        long W2 = W / 2;
        long A1 = H2 * W;
        long A2 = H * W - A1;
        long ans1 = calcDiff(A1, A2, pre);
        long B1 = W2 * H;
        long B2 = H * W - B1;
        long ans2 = calcDiff(B1, B2, pre);
        return Math.Min(ans1, ans2);
    }

    long calcDiff(long a, long b, long c)
    {
        long max = Math.Max(a, b);
        max = Math.Max(max, c);
        long min = Math.Min(a, b);
        min = Math.Min(min, c);
        if (min == 0) return long.MaxValue / 2;
        return max - min;
    }
    
}



class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 11092
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);

    if(a+b>=a-b && a+b>=a*b){
        printf("%d\n",a+b);
    }
    else if(a*b>=a+b && a*b>=a-b)
    {
        printf("%d\n",a*b);

    }
    else if(a-b>=a+b && a-b>=a*b)
        {
           printf("%d",a-b);

        }
        return 0;


    }


Measured memory_bytes: 128
#include <iostream>
#include <vector>
using namespace std;
int main(void){
  int n;
  cin >> n;
  
  vector<int>num(n,0);
  for(int i=0;i<n;i++){
    cin >> num[i];
  }
  
  int count = 0;
  for(int i=0;i<n;i++){
    if(i + 1 != num[i])
      count++;
  }
  
  if(count <= 2){
    cout << "YES" << endl;
  }
  else
    cout << "NO" << endl;
  
  return 0;
}

 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.1415926535897932
#define _GLIBCXX_DEBUG
using namespace std;
long long GCD(long long A,long long B){
  if(B==0)return A;
  else return GCD(B,A%B);
}
int main() {
  
  int N;
  cin>>N;
  
  vector<int> A(N-1);
  for(int i=0;i<N-1;i++){
    cin>>A[i];
  }
  
  vector<int> ans(N);
  
  
  for(int i=0;i<N-1;i++){
    ans[A[i]-1]++;
  }
  
  
  for(int i=0;i<N;i++){
    cout<<ans[i]<<endl;
  }
}

Measured memory_bytes: 4844
#include<stdio.h>

int main(){
    int n, k, qtd=0;
    scanf("%d %d", &n, &k);
    while (n>1){
        ++qtd;
        n=n/k;
    }
    if (n==0){
        printf("%d\n", qtd);
    }else{
        printf("%d\n", qtd+1);
    }
    return 0;
}


Measured memory_bytes: 128
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

macro_rules! eprint {
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = write!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! eprintln {
	() => { eprintln!(""); };
	($($t:tt)*) => {{
		use ::std::io::Write;
		let _ = writeln!(::std::io::stderr(), $($t)*);
	}};
}
macro_rules! dbg {
	($v:expr) => {{
		let val = $v;
		eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
		val
	}}
}

macro_rules! mat {
	($($e:expr),*) => { Vec::from(vec![$($e),*]) };
	($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
	($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
	($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
	($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
		$a$([$i])*.$f($($t),*)
	};
	($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
		let t = $e;
		ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
	} };
}

pub fn readln() -> String {
	let mut line = String::new();
	::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
	line
}

macro_rules! read {
	($($t:tt),*; $n:expr) => {{
		let stdin = ::std::io::stdin();
		let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
			let line = line.unwrap();
			let mut it = line.split_whitespace();
			_read!(it; $($t),*)
		}).collect::<Vec<_>>();
		ret
	}};
	($($t:tt),*) => {{
		let line = readln();
		let mut it = line.split_whitespace();
		_read!(it; $($t),*)
	}};
}

macro_rules! _read {
	($it:ident; [char]) => {
		_read!($it; String).chars().collect::<Vec<_>>()
	};
	($it:ident; [u8]) => {
		Vec::from(_read!($it; String).into_bytes())
	};
	($it:ident; usize1) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
	};
	($it:ident; [usize1]) => {
		$it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
	};
	($it:ident; [$t:ty]) => {
		$it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
	};
	($it:ident; $t:ty) => {
		$it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
	};
	($it:ident; $($t:tt),+) => {
		($(_read!($it; $t)),*)
	};
}

pub fn main() {
	let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

pub trait SetMinMax {
	fn setmin(&mut self, v: Self) -> bool;
	fn setmax(&mut self, v: Self) -> bool;
}
impl<T> SetMinMax for T where T: PartialOrd {
	fn setmin(&mut self, v: T) -> bool {
		*self > v && { *self = v; true }
	}
	fn setmax(&mut self, v: T) -> bool {
		*self < v && { *self = v; true }
	}
}

fn solve() {
	let (h,w) = read!(i64,i64);
	if h==1 || w==1{
		println!("1");
		return;
	}
	println!("{}", ((w+1)/2)*((h+1)/2) + (w/2)*(h/2))
}


fn run() {
    solve();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define F first
#define S second
#define P pair<int,int>
#define V vector
#define pb push_back
#define mp make_pair
#define endl "\n"
#define db(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define MOD 1000000007  //1e9+7

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << '\n'; }
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}

void solve()
{
	string s,t; cin>>s>>t;
	cout<<t+s<<endl;
}
	
int32_t main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin>>t;
    //while(t--)
    solve();
    return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    int x[m];
    for(int i = 0; i < m; ++i) cin >> x[i];
    if(n >= m) {
        cout << 0 << '\n';
        return 0;
    }
    sort(x, x+m);
    priority_queue<int> pq;
    for(int i = 0; i < m-1; ++i) {
        pq.push(x[i+1] - x[i]);
    }
    int ans = x[m-1] - x[0];
    while(!pq.empty() && n != 1) {
        int diff = pq.top();
        pq.pop();
        ans -= diff;
        n--;
    }

    cout << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 1276
from itertools import permutations
N = int(input())
x = [0]*N
y = [0]*N
route = list(permutations(range(N)))

for i in range(N):
    x[i], y[i] = map(int, input().split())

ans = 0
for r in route:
    for l in range(len(r)-1):
        tmp = ((x[r[l]] - x[r[l+1]])**2 + (y[r[l]] - y[r[l+1]])**2)**0.5
        ans += tmp

print(ans / len(route))

Measured memory_bytes: 8052
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define r_rep(i, n) for(int i = n; i >= 0; i--)
#define ll long long int
#define pb push_back

const long long INF = 1LL << 60;

int main() {
  ll N, K, ans;
  cin >> N >> K;

  if(N==1){
    print(K);
  } else {
    ans = K * pow(K-1, N-1);
    print(ans);
  }
}


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

int main() {
  long long N;
  cin >> N;
  long long ans = N;
  long long term;
  long long ga,gb,sa,sb,ba,bb;
  cin >> ga >> sa >> ba >> gb >> sb >> bb;
  if (ga >= gb && sa >= sb && ba >= bb) {
    swap(ga,gb);
    swap(sa,sb);
    swap(ba,bb);
  }
  if (ga <= gb && sa <= sb && ba <= bb) {
    for (int i=0; i<=N; i++) {
      for (int j=0; j<=N-i; j++) {
        term = N;
        term += i/ga*(gb-ga);
        term += j/sa*(sb-sa);
        term += (N-i-j)/ba*(bb-ba);
        ans = max(ans,term);
      }
    }
    cout << ans << endl;
    return 0;
  }
  if (ga <= gb && sa >= sb && ba <= bb) {
    swap(sa,ba);
    swap(sb,bb);
  }
  else if (ga >= gb && sa <= sb && ba <= bb) {
    swap(ga,ba);
    swap(gb,bb);
  }
  if (ga <= gb && sa <= sb && ba >= bb) {
    for (int i=0; i<=N; i++) {
      term = N;
      term += i/ga*(gb-ga);
      term += (N-i)/sa*(sb-sa);
      ans = max(ans,term);
    }
    ans += ans/bb*(ba-bb);
    cout << ans << endl;
    return 0;
  }
  long long change;
  long long amari;
  if (ga >= gb && sa <= sb && ba >= bb) {
    swap(ga,sa);
    swap(gb,sb);
  }
  else if (ga >= gb && sa >= sb && ba <= bb) {
    swap(ga,ba);
    swap(gb,bb);
  }
  if (ga <= gb && sa >= sb && ba >= bb) {
    N += N/ga*(gb-ga);
    if (sa * bb < ba * sb) {
      swap(sa,ba);
      swap(sb,bb);
    }
    ans = N;
    for (int i=0; i<=max(N/sb,bb); i++) {
      change = N/sb - i;
      term = N;
      term += change * (sa-sb);
      amari = N - change * sb;
      term += amari/bb*(ba-bb);
      ans = max(ans,term);
    }
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
ll a[20][20];
ll c[20];
ll q[20];
void solve()
{
	ll n,m,z;
	cin>>n>>m>>z;
	for(ll i=0;i<n;i++)
	{
		cin>>c[i];
		for(ll j=0;j<m;j++)
		{
			cin>>a[i][j];
		}
	}
	ll ans=inf;
	for(ll i=0;i<(((ll)1)<<n);i++)
	{
		ll x=i;
		ll cost=0;
		for(ll j=0;j<m;j++)
		{
			q[j]=0;
		}
		for(ll j=0;j<n;j++)
		{
			if(x%2)
			{
				cost+=c[j];
				for(ll k=0;k<m;k++)
				{
					q[k]+=a[j][k];
				}
			}
			x/=2;
		}
		ll b=1;
		for(ll j=0;j<m;j++)
		{
			if(q[j]<z)
				b=0;
		}
		if(b)
			ans=min(ans,cost);
	}
	if(ans==inf)
		cout<<-1;
	else
		cout<<ans;
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    time_taken_start
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
    time_taken_end
}

Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <functional>

int main()
{
    int a;
    std::string s;
    std::cin >> a >> s;
    if(a>=3200){
        std::cout << s << std::endl;
    }else{
        std::cout << "red" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 256
K, A, B = map(int, input().split())
if A > B - 2 or K < A + 1:
    print(1 + K)
else:
    K -= A - 1
    cnt = K // 2 * B - (K // 2 - 1) * A
    if K % 2:
        cnt += 1
    print(cnt)



Measured memory_bytes: 2940