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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    ll sum = 0;
    priority_queue<ll> A;
    cin >> N >> M;
    rep(i, N) {
        ll temp;
        cin >> temp;
        A.push(temp);
    }
    rep(i, M) {
        ll temp = A.top();
        A.pop();
        A.push(temp / 2);
    }
    rep(i, N) {
        ll temp = A.top();
        A.pop();
        sum += temp;
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1400
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		String[] spl = s.split(" ");
		int A = Integer.parseInt(spl[0]);
		int B = Integer.parseInt(spl[1]);
		int T = Integer.parseInt(spl[2]);
		
		int bis = 0;
		
		for(int i = 1;i < T + 1;i++){
			if(A * i < T + 1){
				bis += B;
			}
		}
		System.out.println(bis);

	}

}

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

#define ff first
#define ss second

int main()
{
	ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;

	int total = ((N - 1) * (N - 2)) / 2;
	if (K > total) {
		cout << -1 << endl;
		return 0;
	}

	vector<pair<int, int> > edges;
	for (int i = 2; i <= N; ++i) {
		edges.push_back({1, i});
	}

	for (int i = 2; i < N && total > K; ++i) {
		for (int j = i+1; j <= N && total > K; ++j, --total) {
			edges.push_back({i, j});
		}
	}

	cout << edges.size() << endl;
	for (const auto& p : edges) {
		cout << p.ff << ' ' << p.ss << endl;
	}

	return 0;
}


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


# 約数を列挙 (ex. 6 => [1,2,3,6])
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors


def main():
    N = int(input())
    D = make_divisors(N)
    D.remove(1)
    ans = 0
    for a in D:
        q, r = divmod(N, a-1)
        if q == r:
            ans += a-1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3264
N = gets.to_i

def dfs(s)
  if s.to_i > N
    return 0
  end

  ret = 0
  if s.include?('7') && s.include?('5') && s.include?('3')
    ret += 1
  end

  ret += dfs('7' + s)
  ret += dfs('5' + s)
  ret += dfs('3' + s)

  ret
end

puts dfs('')


Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
    string S;
    cin >> S;
    if(S.size() == 2){
        cout << S <<endl;
    }else if(S.size() == 3){
        reverse(S.begin(), S.end());
        cout << S <<endl;
    }

}

Measured memory_bytes: 256
#include <stdio.h>

void output_array( int* array, int num)
{
	int i;
	for (i = 0; i < num-1; i++)
	{
		printf("%d ", array[i]);
	}
	printf("%d\n", array[i]);
	return;
}


int main(void) 
{
	int N;
	int array[100];
	int i, j;
	int tmp;
	
	scanf("%d", &N);

	for (i = 0; i < N; i++)
	{
		scanf("%d", &array[i]);
	}
	
	output_array(array, N);
	
	for (i = 1; i < N; i++)
	{
		tmp = array[i];
		for (j = i-1; j >= 0 && array[j] > tmp; j--)
		{
			array[j+1] = array[j];
		}
		array[j+1] = tmp;
		output_array(array, N);
	}
	return 0;
}



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

#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i+=a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

int main() {
    int k, X;
    cin >> k >> X;
    if(k*500>=X){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
// Best practice

#include<bits/stdc++.h>

#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define in(x) 		scanf("%d", &x)
#define echo(x)		printf("%d", x)
#define inf 		(int)(1e18)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;

#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}

// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };


// Code from Here -------------------------------------------------------------------------------


signed main() {
	tezz


	int n;
	cin >> n;
	vi a(n);
	unordered_map<int,int> mp;
	set<int> s;
	int maxx=-1;
	for(int i=0; i<n; i++){
		cin >> a[i];
		mp[a[i]]++;
		s.insert(a[i]);
		maxx=max(maxx, a[i]);
	}	
	for(auto it: s){
		if(mp[it]!=0){
			for(int i=2*it; i<=maxx; i+=it){
				mp[i]=0;
			}
		}
		if(mp[it]>1)mp[it]=0;
	}
	int ans=0;
	for(auto it: mp)if(it.y!=0)ans++;
		cout << ans;


	return 0;
}  


Measured memory_bytes: 50952
# coding: utf-8
# Your code here!
import numpy as np
n,m = map(int,input().rstrip().split())
connection_list = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().rstrip().split())
    connection_list[a-1].append(b-1)
    connection_list[b-1].append(a-1)

count = 0
def dfs(g,p,checked):
    global count
    checked[p] = 1
    if checked.all():
        count += 1
        return
    for next in g[p]:
        if checked[next] == 1:
            continue
        dfs(g,next,checked.copy())

checked = np.zeros(n,int)
dfs(connection_list,0,checked)
print(count)

Measured memory_bytes: 13828
#include<iostream>
#include<algorithm>
using namespace std;
struct node{
	int x,y;
}a[100005];
bool cmp(node x,node y){
	return x.x<y.x;
}
int main()
{
	int n,m,i,x,y,maxv=0,minv=100005,sum=1;
	cin>>n>>m;
	for(i=1;i<=m;i++){
		cin>>x>>y;
		a[i].x=x;
		a[i].y=y;
	}
	
	sort(a+1,a+m+1,cmp);
	for(i=1;i<=m;i++){
		maxv=max(maxv,a[i].x);
		minv=min(minv,a[i].y);
		
		if(maxv>=minv){
			sum++;
			maxv=a[i].x;
			minv=a[i].y;
		}
	}
	cout<<sum;
	return 0;
} 

Measured memory_bytes: 1024
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	double calc(int _p, int _a, int _b, int _c, int _d, int _e, int _f, int _s, int _m) {
		double p = (double)_p, a = (double)_a, b = (double)_b, c = (double)_c, d = (double)_d, e = (double)_e, f = (double)_f, s = (double)_s, m = (double)_m;
		double t1 = a+b+c, t2 = d+e;
		return (s*f*m-p)/(t1+t2*m);
	}
	
	void sort(String[] s, double[] d) {
		int n = s.length;
		for (int i = 1; i < n; i++) {
			for (int j = 0; j < n-i; j++) {
				if (d[j] < d[j+1] || (d[j] == d[j+1] && s[j].compareTo(s[j+1]) > 0)) {
					double tempd = d[j];
					d[j] = d[j+1];
					d[j+1] = tempd;
					String temps = s[j];
					s[j] = s[j+1];
					s[j+1] = temps;
				}
			}
		}
	}
	
	void run() {
		int n;
		while (true) {
			n = sc.nextInt();
			if (n == 0) break;
			String[] s = new String[n];
			double[] eff = new double[n];
			for (int i = 0; i < n; i++) {
				s[i] = sc.next(); 
				eff[i] = calc(sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt(),sc.nextInt());
			}
			
			sort(s, eff);
			for (String st : s)
				out.println(st);
			out.println("#");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B){
        cout << C << endl;
    }
    else if (B == C){
        cout << A << endl;
    }
    else{
        cout << B << endl;
    }
}

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

int main() {
  int n,x;
  cin >> n >> x;

  int m,m_min=1e9,m_sum=0;
  for (int i=0; i<n; i++) {
    cin >> m;
    m_sum += m;
    if(m < m_min)
      m_min = m;
  }
  cout << n + (x-m_sum) / m_min << endl;
  return 0;
}

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

using namespace std;

#define  fastio         ios:: sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
#define  randomINIT     mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define  foo(i,a,n)     for(ll i = (a); i <= n; i++)
#define  frr(i,a,n)     for(ll i = (a); i >= n; i--)
#define  fo(i,n)        for(ll i = 0; i < n; i++)
#define  all(x)         (x).begin(),(x).end()
#define  mset(x,val)    memset(x,val,sizeof(x))
#define  newl           cout<<"\n"
#define  pb             push_back
#define  mp             make_pair
#define  s              second
#define  f              first
#define  dline          cerr<<"///REACHED///\n";
#define  deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define  deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define  deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef  long long             ll;
typedef  long double           ld;
typedef  pair<ll,ll>           pll;
typedef  vector<ll>            vll;
typedef  vector<pll>           vpll;

const ll   MOD   =  1e+9+7;
const ll   INF   =  0x7f7f7f7f7f7f7f7f;
const int  INFi  =  0x7f7f7f7f;
const ll   MAXN  =  1e+5+7;

vll adj[MAXN];ll visit[MAXN]={};
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1};
int dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};

//<<-----Declare Variable Here------->>//
int q=1;
ll n,k;
ll a[200005];
ll pre[200005];
//<<-----Implement Functions Here---->>//


//<<-----Start of Main--------------->>//
void MAIN(){
		cin>>n>>k;
		for(ll i=0;i<n;i++)cin>>a[i];

		if(k>500)
		{
			for(ll i=0;i<n;i++)cout<<n<<" ";
			return;
		}
		while(k--)
		{
			for(ll i=0;i<n;i++)pre[i] = 0;
			for(ll i=0;i<n;i++)
			{
				ll d1 = i + a[i];ll d2 = i-a[i];
				d1 = min(d1,n-1);d2 = max(d2,ll(0));
				pre[d2]++;pre[d1+1]--;
			}
			for(ll i=1;i<n;i++)pre[i] += pre[i-1];
			for(ll i=0;i<n;i++)a[i] = pre[i];
		}
		for(ll i=0;i<n;i++)cout<<a[i]<<" ";


}

int main(){
	fastio;randomINIT;

	//cin>>t;
	while(q--){
		MAIN();
	}

   
}

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

int main(){
  int a,b,c,d,e,f,N,i;
  cin >> N;
  for(i=0;i<N;i++){
    cin >> a >> b>>c;
    d=a*a;
    e=b*b;
    f=c*c;
    if(d==e+f||e==d+f||f==d+e){
      cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 2996
object Main extends App {
  val n: Int = io.StdIn.readLine().toInt
  val arr: Vector[Int] = io.StdIn.readLine().split(" ").toVector map(_.toInt)

  def partition(a: Vector[Int], i: Int, p: Int, r:Int): (Vector[Int], Int) = {
    if (i >= r) {val (ap,ar) = (a(p),a(r)); (a.updated(p,ar).updated(r,ap), p)}
    else if (i == p) partition(a, i+1, if (arr(i) <= arr(r)) p+1 else p, r)
    else {
      val ai = a(i)
      val ap = a(p)
      if (ai <= a(r) && ai < ap) partition(a.updated(i,ap).updated(p,ai), i+1, p+1, r)
      else partition(a, i+1, p, r)
    }
  }

  val (pa, i): (Vector[Int], Int) = partition(arr, 0, 0, n-1)
  println(pa.slice(0, i).mkString(" ") + " [" + pa(i) + "] " + pa.slice(i+1, n).mkString(" "))
}

Measured memory_bytes: 145808
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int psize = 1000000;
    vector<int>num(psize+1);//prime is 0
    num[0] = num[1] = 1;
    for(int i = 2;i * i <= psize;i++){
        if(num[i])continue;
        for(int j = i * 2;j <= psize;j += i){
            num[j] = 1;
        }
    }
    vector<int>prime;
    rep(i,0,psize+1){
        if(!num[i])prime.push_back(i);
    }
    
    int N,P;
    cin >> N >> P;
    while(N != -1){
        auto itr = upper_bound(prime.begin(), prime.end(), N);
        auto itr2 = itr;
        int d = distance(prime.begin(), itr);
        multiset<int>st;
        /*          
        rep(i,0,100){
            rep(j,0,100){
                st.insert(*itr + *itr2);
                itr2++;
            }
            itr++;
        }
                  */
        rep(i,0,100){
            rep(j,i,100){
                st.insert(prime[i + d] + prime[j + d]);
            }
        }
        //sort(num.begin(), num.end()); 
        //cout << num[P-1] << endl;
        auto itr3 = st.begin();
        rep(i,0,P-1){
            itr3++;
        }
        cout << *itr3 << endl;
        cin >> N >> P;
    }
    
}


Measured memory_bytes: 7128
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  vector<long> A(N + 1);
  rep (i, N) cin >> A[i+1];
  unordered_set<long> visited;

  long current = 1;
  visited.insert(current);
  long ans = 0;
  while (true) {
    if (current == 2) {
      cout << ans << endl;
      return;
    }
    current = A[current];
    ans++;
    if (visited.count(current)) {
      cout << -1 << endl;
      return;
    }
    visited.insert(current);
  }
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 5156
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 100100100100;
const ll MOD = 1000000007;


ll combination(ll n, ll r){
    if(n < r) return 0;
    if(r == 0||r == n) return 1;
    else if(r == 1) return n;
    return (combination(n - 1, r - 1) + combination(n - 1, r));
}

bool checkKaibun(string str){
    string checkStr = str;
    reverse(checkStr.begin(), checkStr.end());
    if(str == checkStr) return true;
    else return false;
}

int keta(ll num){
    int digits = 0;
    while(num > 0){
        num /= 10;
        digits++;
    }
    return digits;
}


ll mpow(ll x, ll n){//繰り返し二乗法 計算量O(logN)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans * x % MOD;
        x = x * x % MOD;
        n  = n >> 1;
    }
    return ans;
}

int gcd(int a, int b){
    if(a % b == 0) return b;
    else return (gcd(b, a%b));
}



int main(){
    int N;
    cin >> N;
    queue<string> que;
    que.push("a");
    while(!que.empty()){
        string str = que.front(); que.pop();
        if(str.length() == N) cout << str << endl;
        else{
            char mx = 0;
            rep(i, str.length()){
                if(mx < str[i]) mx = str[i];
            }
            mx++;
            for(char c = 'a'; c <= mx; c++){
                que.push(str + c);
            }
        }
    }
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
  #define ll  long long int
  #define N 100000
  #define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
  #define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
  #define po pop_back
  #define pb push_back
  #define lb lower_bound
  #define fi first
  #define se second
  #define debug(x) cout << #x << " = " << x << endl
  #define ub upper_bound
  #define ibs ios_base::sync_with_stdio(false)
  #define cti cin.tie(0)
  #define all(x) x.begin(),x.end()
  #define PI 3.14159265
  #define cot cout.tie(0)
  using namespace std;
   /**
    * @author :: Sawlani
    *
    */
    const ll M=1e9+7;
    int main()
    {
        ll n,k;
        cin >>  n >>  k;
        ll a[n+1];
        f(i,1,n)
        {
            cin >> a[i];
        }

        ll wh[n+1]={0};
         ll pr[n+1]={0};

        f(i,1,n)
        {
            f(j,1,n)
            {
                if(a[i]>a[j]){
                    wh[i]++;
                    if(j>i)
                     pr[i]++;
                }

            }

        }
        ll ans=0;
        ll s=(((k*(k-1))/2))%M;

        f(i,1,n){
        ans=(ans%M+(wh[i]%M*s%M)%M+(pr[i]%M*k%M)%M)%M;

        }

           cout <<  ans <<  endl;


    }


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
import java.math.BigInteger;
public class Main{

  public static void main(String[] args) {
    InputReader in = new InputReader(System.in);
    PrintWriter w = new PrintWriter(System.out);
    long x=in.nextLong();
    long curpos=0;
    long i=0;
    while (curpos<x){
      curpos=curpos+i;
      i++;
    }
    w.println(i-1);
    w.close();
    }

  static class InputReader {

    private final InputStream stream;
    private final byte[] buf = new byte[8192];
    private int curChar, snumChars;
    private SpaceCharFilter filter;

    public InputReader(InputStream stream) {
      this.stream = stream;
    }

    public int snext() {
      if (snumChars == -1)
      throw new InputMismatchException();
      if (curChar >= snumChars) {
        curChar = 0;
        try {
          snumChars = stream.read(buf);
        } catch (IOException e) {
          throw new InputMismatchException();
        }
        if (snumChars <= 0)
        return -1;
      }
      return buf[curChar++];
    }

    public int nextInt() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      int res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

    public long nextLong() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      int sgn = 1;
      if (c == '-') {
        sgn = -1;
        c = snext();
      }
      long res = 0;
      do {
        if (c < '0' || c > '9')
        throw new InputMismatchException();
        res *= 10;
        res += c - '0';
        c = snext();
      } while (!isSpaceChar(c));
      return res * sgn;
    }

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

    public String readString() {
      int c = snext();
      while (isSpaceChar(c)) {
        c = snext();
      }
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isSpaceChar(c));
      return res.toString();
    }

    public String nextLine() {
      int c = snext();
      while (isSpaceChar(c))
      c = snext();
      StringBuilder res = new StringBuilder();
      do {
        res.appendCodePoint(c);
        c = snext();
      } while (!isEndOfLine(c));
      return res.toString();
    }

    public boolean isSpaceChar(int c) {
      if (filter != null)
      return filter.isSpaceChar(c);
      return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

    private boolean isEndOfLine(int c) {
      return c == '\n' || c == '\r' || c == -1;
    }

    public interface SpaceCharFilter {
      public boolean isSpaceChar(int ch);
    }
  }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define INF 1000000000
#define MOD 1000000007

void solve() {
    ll n,a,b;
    cin >> n >> a >> b;
    ll ans = n/(a+b)*a;
    if (n % (a+b)) ans += min(a, n%(a+b));
    cout <<ans << "\n";
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin >> t;
    while (t--)
        solve();
    return 0;
}



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

#define FOR(i,N) for(int i=0;i<N;i++)
#define ROF(i,N) for(int i=N-1;i>=0;i--)
#define ROF1(i,a,b) for(int i=(b);i>=(a);i--)
#define FOR1(i,a,b) for(int i=(a);i<=(b);i++)
#define FORi(i,a,b,c) for(int i=(a);i<=(b);i+=(c))

#define read freopen("IN.txt","r",stdin)
#define write freopen("OT.txt","w",stdout)
#define fastread {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mem(a,b)          memset(a,b,sizeof(a))
#define EPS 1e-9
#define PI              acos(-1.0)
#define INF             2e16

#define ll              long long
#define ull             unsigned long long
#define ft              first
#define sd              second
#define bn              begin
#define en              end
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define pll             pair<LL,LL>
#define all(x) x.begin(), x.end()


#define dbg(args...) {cerr<<"-->";debugger::call(#args,args);cerr<<"\n";}
struct debugger {
    static void call(const char* it) {}
    template<typename T, typename ... aT>
    static void call(const char* it, T a, aT... rest) {
        string b;
        for (; *it&&*it != ','; ++it) if (*it != ' ')b += *it;
        cerr << b << "=" << a << " ";
        call(++it, rest...);
    }
};

int main()
{
     int n,a[30],b[30],c[30],ans=0;
     cin>>n;
     for(int i=1;i<=n;i++)cin>>a[i];
      for(int i=1;i<=n;i++)cin>>b[i];
       for(int i=1;i<=n-1;i++)cin>>c[i];

     for(int i=1;i<=n;i++)
     {
          ans+=b[a[i]];
          if(a[i+1]-a[i]==1){ans+=c[a[i]];}
     }
     cout<<ans<<"\n";
}


Measured memory_bytes: 256
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i==n-1];};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll Q;
    cin >> Q;
    while(Q--){
        ll A, B;
        cin >> A >> B;
        ll lv = 1, rv = max(A,B) * 3;
        if(A == B){
            print(2*(A-1));
            continue;
        }
        while(rv - lv > 1){
            ll mid = (rv + lv) / 2;
            ll a1 = (mid + 1) / 2;
            ll b1 = mid + 1 - a1;
            if(a1 * b1 <= A*B-1){
                lv = mid;
            }else{
                rv = mid;
            }
        }
        print(lv - 1);
    }
    
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
typedef long long LL;

int main() {
  char prev = 'a';
  for (int i = 0; i < 4; ++i) {
    char c; std::cin >> c;
    if (prev == c) {
      std::cout << "Bad" << std::endl;
      return 0;
    }
    prev = c;
  }

  std::cout << "Good" << std::endl;
}


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


ll i,j,h,n,ans;
ll x[10005],y[10005],z[10005];
char s[10];
ll a = 0,b = 0, c=0;

bool solve(){
	cin >> n;
	if(n == 0)return false;
	ll res = n;
	for(i=0;i<26;i++){
		x[i] = 0;
	}
	for(i=0;i<n;i++){
		cin >> s;
		z[i] = s[0] - 'A';
	}
	for(i=0;i<n;i++){
		//cin >> s;
		x[z[i]]++;
		res--;
		for(j=0;j<26;j++){
			y[j] = x[j];
		}
		sort(y,y+26);
		reverse(y,y+26);
		if(y[1] + res >= y[0]){
			//cout << y[1] << " " << y[0] << endl;
			//mada
		}else{
			h = 0;
			ll num = 0;
			for(j=0;j<26;j++){
				if(x[j] > h){
					h = x[j];
					num = j;
				}
			}
			cout << (char)(num + 'A') << " " << i+1 << endl;
			return true;
		}
	}
	cout << "TIE" << endl;
	return true;

}

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


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

int main(){
	int n;
	cin>>n;
	int *data=(int*)malloc(n*sizeof(int));
	int *dp=(int*)malloc(n*sizeof(int));
	dp[0]=0;
	for(int i=0;i<n;i++){
		cin>>data[i];
		if(i==1){
			dp[i]=abs(data[i]-data[i-1]);
		}
		if(i>=2){
			dp[i]=min(dp[i-1]+abs(data[i]-data[i-1]),dp[i-2]+abs(data[i]-data[i-2]));
		}
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1152
n = int(input())
a = [int(i) for i in input().split()]
ans = [0] * n
summ = sum([abs(a[i]-a[i+1]) for i in range(n-1)])
summ += abs(a[0]) + abs(a[-1])
for i in range(1, n-1):
  ans[i] = summ -abs(a[i-1]-a[i])-abs(a[i+1]-a[i])+abs(a[i-1]-a[i+1])
ans[0] = summ - abs(a[0]) -abs(a[0]-a[1]) + abs(a[1])
ans[-1] = summ - abs(a[-1]) -abs(a[-1]-a[-2])+abs(a[-2])
for i in ans:
  print(i)

Measured memory_bytes: 14172
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
const int INF = 1e9;
const vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
int H, W;
vector<vector<char> >  c;

bool inside(int i, int j){
	return (i >= 0 && i < H && j >= 0 && j < W && c[i][j] == '.');
}

int main(){ 
	cin >> H >> W;
	int sx,sy, gx, gy; 
	cin >> sx >> sy >> gx >> gy;
	--sx; --sy; --gx; --gy;

	c.resize(H, vector<char> (W));
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++) cin >> c[i][j];
	}

	vector<vector<int> > dist(H, vector<int> (W, INF));
	dist[sx][sy] = 0;
	deque<P> que;
	que.push_front(P(sx, sy));

	while(que.size()){
	    P p = que.front(); que.pop_front();
		int x = p.first, y = p.second;
		for(int i = x - 2; i <= x + 2; i++){
			for(int j = y - 2; j <= y + 2; j++){
				if(!inside(i, j)) continue;
				int adj = (abs(x - i) + abs(y - j) != 1);
				int d = dist[x][y] + adj;
				if(d < dist[i][j]){
					dist[i][j] = d;
					if(adj) que.push_back(P(i, j));
					else que.push_front(P(i, j));
				}
			}
		}
	}

	int ans = dist[gx][gy];
	if(ans == INF) ans = -1;
	cout << ans << endl;
}



Measured memory_bytes: 8524
n=int(input())
l=list(map(int,input().split()))
ans=[-1]*n
l.reverse()
for i in range(n):
    if i%2==0:
        ans[i//2]=l[i]
    else:
        ans[n-1-((i-1)//2)]=l[i]


for i in range(n-1):
    print(ans[i],end=" ")
print(ans[n-1])

Measured memory_bytes: 26180
nag = int(input())

def dfs(rootlist,deep,n):
    global nag
    if len(rootlist) != nag:
        for i in range(n+1):
            nextroot = rootlist[:]
            nextroot.append(i)
            if i < n:
                dfs(nextroot,deep+1,n)
            else:
                dfs(nextroot,deep+1,n+1)
    else:
        answer = ''
        wordlist = ['a','b','c','d','e','f','g','h','i','j']
        for index in rootlist:
            answer += wordlist[index]
        print(answer)


dfs([0],0,1)


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

int main() {
	long long a,b,c,ans=0,d,e,f;
	cin >> a >> b >> c;
	while(a!=b || b!=c){
		if(a%2 || b%2 || c%2){
			cout << ans; return 0;
		}
		d=(b+c)/2; e=(c+a)/2; f=(a+b)/2;
		a=d; b=e; c=f;
		ans++;
	}
	if(a%2 || b%2 || c%2){
		cout << ans;
	}else{
		cout << -1;
	}
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n;
  int i,j;
  int num;

  cin>>n;

  rep(i,n){

    bool yes=true;
    int max1=0,max2=0;

    rep(j,10){

      scanf("%d",&num);

      if(max1>num && max2>num){
	if(yes)	cout<<"NO"<<endl;
	yes=false;
	continue;
      }
      else if(max1>num)
	max2=num;
      else if(max2>num)
	max1=num;
      else
	max1>max2 ? max1=num : max2=num;

    }//repj
    if(yes)
      cout<<"YES"<<endl;
  }//repi
}

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

using namespace std;
#define ll  long long
#define ld  long double

#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
const int MAXN=1e5 + 5;
string h;
int a,b,k;
ll fastPow(ll x,ll b)
{
    if(b==0)
        return 1;
    else if(!(b & 1))
    {
        return fastPow(x*x,b/2);
    } else
        return x*fastPow(x*x,(b-1)/2);
}
//__builtin_popcount ();
int main() {
    FAST
ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    sort(arr,arr+n);
    ll sum=0;
    for(int i=0;i<n-k;i++)
        sum+=arr[i];
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 1792
fun calcCumulativeSum(list: List<Int>): List<Int> {
    // mutableでないほうがいいかな？Array?List?
    return list.fold(mutableListOf(0)) { acc, value ->
        acc += acc.last() + value
        acc
    }
}

fun sumFromOneTo(last: Int) = last * (last + 1) / 2
fun calcExpectedValueForDice(value: Int) = sumFromOneTo(value) / value.toDouble()
fun calcMaxIndex(list: List<Int>) = list.indices.maxBy { list[it] }!!

fun main(args: Array<String>) {
    val (n, k) = readIntegerList()
    val pList = readIntegerList()

    val cs = calcCumulativeSum(pList)
    (0..(pList.size - k)).map { cs[it + k] - cs[it] }
        .let(::calcMaxIndex)
        .let { it until (it + k) }
        .map { pList[it] }
        .map(::calcExpectedValueForDice)
        .sum()
        .let(::println)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


Measured memory_bytes: 83200
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n, m;
int u[100100], v[100100];
ll s[100100];

int level[100100];
ll val[100100];

struct edge {
    int to;
    ll c;
};

vector<edge> G[100100];

ll solve() {
    for (int i = 0; i < m; i++) {
        G[u[i]].push_back(edge{v[i], s[i]});
        G[v[i]].push_back(edge{u[i], s[i]});
    }

    memset(level, -1, sizeof(level));
    memset(val, -1, sizeof(val));
    ll lb = 1, ub = 1e9;
    queue<int> que;
    que.push(0);
    level[0] = val[0] = 0;
    while (!que.empty()) {
        int w = que.front(); que.pop();
        int l = level[w];
        for (int i = 0; i < G[w].size(); i++) {
            edge e = G[w][i];
            if (level[e.to] >= 0 && level[e.to] < l) continue;
            if (level[e.to] == l) {
                ll x = e.c - val[w] - val[e.to];
                if (abs(x) % 2 > 0) return 0;
                if (!((level[w] % 2 == 0 && x > 0) || (level[w] % 2 == 1 && x < 0))) return 0;
                ll t = abs(x) / 2;
                if (lb <= t && t <= ub) {
                    lb = ub = t;
                } else {
                    return 0;
                }
            } else if (level[e.to] > l) {
                if (val[e.to] != e.c - val[w]) return 0;
            } else {
                que.push(e.to);
                level[e.to] = level[w] + 1;
                val[e.to] = e.c - val[w];
                if (level[e.to] % 2 == 0) {
                    lb = max(lb, 1-val[e.to]);
                } else {
                    ub = min(ub, val[e.to]-1);
                }
                if (lb > ub) return 0;
            }
        }
    }

    return ub - lb + 1;
}

void input() {
    cin >> n >> m;
    for (int i = 0; i < m; i++) {
        cin >> u[i] >> v[i] >> s[i];
        u[i]--; v[i]--;
    }
}

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

    input();
    cout << solve() << endl;
}


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

int main(){
    int h, w; cin >> h >> w;
    vector<string> mine(h+2);
    for (int i=1; i<=h; i++){
        string s; cin>>s;
        s = '.' + s + '.';
        mine[i]=s;
    }
    mine[0] = string(w, '.');
    mine[h+1] = string(w,'.');
    
    for (int i=1; i<=h; i++){
        for (int j=1; j<=w; j++){
            if(mine[i][j]=='#') cout << '#';
            else{
                int num = 0;
                for(int k=-1; k<=1; k++){
                    for(int l=-1; l<=1; l++){
                        if (k==0 && l==0) continue;
                        else num += mine[i+k][j+l]=='#';
                    }
                }
                cout << num;
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 3596
// in the name of Allah

#include <bits/stdc++.h>
using namespace std;

#define endl '\n'
#define pb push_back
#define ll long long
#define double long double
#define sz(x) ((int) (x.size()))

#define fr first
#define se second

#define inf 1e9
#define max_n 3003
#define mod 1000000007

ll add(ll a, ll b) {
	a += b;
	if(a >= mod) return a - mod;
	return a;
}

ll mul(ll a, ll b) {
	a *= b;
	if(a >= mod) return a % mod;
	return a;
}

ll power(ll a, ll b) {
	ll p = 1;
	while(b) {
		if(b&1) p = mul(p, a);
		a = mul(a, a);
		b /= 2;
	}
	return p;
}

const int N = 1234567;

ll F[N];
ll IF[N];

void init() {
	F[0] = 1;
	for(int i=1; i<N; i++) F[i] = mul(F[i-1], i);
	IF[N-1] = power(F[N-1], mod-2);
	for(int i=N-2; i>=0; i--) IF[i] = mul(IF[i+1], i+1);
}

ll ncr(ll x, ll y) {
	if(y > x || y < 0) return 0;
	return mul(F[x], mul(IF[x-y], IF[y]));
}

int n, m, k;
ll dp[max_n][2];
pair <int, int> p[max_n];

ll memo(int idx, int t) {
	// cout << idx << endl;
	if(idx == 0) {
		if(t == 0) return 1;
		return 0;
	}
	if(dp[idx][t] != -1) return dp[idx][t];
	ll res = 0;
	if(t == 0) {
		for(int i=0; i<idx; i++) {
			if(p[i].fr <= p[idx].fr && p[i].se <= p[idx].se)
				res = add(res, mul(memo(i, 1), ncr(p[idx].fr - p[i].fr + p[idx].se - p[i].se, p[idx].fr - p[i].fr)));
		}
	}
	else {
		for(int i=0; i<idx; i++) {
			if(p[i].fr <= p[idx].fr && p[i].se <= p[idx].se)
				res = add(res, mul(memo(i, 0), ncr(p[idx].fr - p[i].fr + p[idx].se - p[i].se, p[idx].fr - p[i].fr)));
		}
	}
	return dp[idx][t] = res;
}

int main() {
	// ll start = clock();
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	init();
	cin >> n >> m >> k;
	for(int i=0; i<k; i++) cin >> p[i].fr >> p[i].se;
	p[k] = {1, 1};
	p[k+1] = {n, m};
	k += 2;
	sort(p, p+k);
	memset(dp, -1, sizeof dp);
	cout << add(memo(k-1, 1), mod - memo(k-1, 0)) << endl;
	// cerr << (clock() - start) / (CLOCKS_PER_SEC*1.0) << endl;
	return 0;
}

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

int main(void)
{
	string str;
	cin >> str;


	string aji = str.substr(0, 1);
	string tya = str.substr(1, 1);
	string ne = str.substr(2, 1);

	int sum = 700;

	if (aji == "o") { sum += 100; }
	if (tya == "o") { sum += 100; }
	if (ne == "o") { sum += 100; }

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};

const int maxn = 2e6+5;
const int maxs = 1e5;
int dub[21][maxn];
int now[maxn];
int ans[maxn];

void solve(){
	string s;
	cin >> s;
	int n = s.length();
	for(int i = 0; i < n; i++){
		now[i] = i;
	}
	for(int i = 0; i < n; i++){
		if(s[i]=='L') dub[0][i]=i-1;
		else dub[0][i]=i+1;
	}
	for(int i = 0; i < 20; i++){
		for(int j = 0; j < n; j++){
			dub[i+1][j] = dub[i][dub[i][j]];
		}
	}
	for(int i = 20; i >= 0; i--){
		if(1LL<<i&maxs){
			for(int j = 0; j < n; j++){
				now[j] = dub[i][now[j]];
			}
		}
	}
	for(int i = 0; i < n; i++){
		ans[now[i]]++;
	}

	for(int i = 0; i < n; i++){
		cout << ans[i] << " ";
	}
	cout << '\n';

}


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

Measured memory_bytes: 56400
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] NK = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		boolean[] SNKs = new boolean[NK[0]];
		for(int i = 0; i < NK[1]; i++) {
			scanner.nextLine();
			int[] Ais = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).map(in -> in - 1).toArray();
			for(int Ai: Ais) {
				SNKs[Ai] = true;
			}
		}
		int count = 0;
		for(boolean SNK: SNKs) {
			if(!SNK) count++;
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 34068
#include <iostream>
#include <string>

using namespace std;

int main()
{
  string S;
  cin >> S;
  bool flg = true;
  for(int i=0;i<S.size()-1;i++)
    if(S[i]==S[i+1])
      flg = false;

  if(flg)
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;    
}


Measured memory_bytes: 256
var line, even, odd, i, res, hw;

// even : #.#.
// odd  : .#.#

even = {1: '#', 2: '#.'};
odd = {1: '.', 2: '.#'};

line = require('fs').readFileSync('/dev/stdin', 'ascii').split("\n");
line.length = line.lastIndexOf('0 0');

res = [];
for (i in line) {
	hw = line[i].split(' ').map(Number);
	res.push(get_area(hw[0], hw[1]));
	res.push("");
}
console.log(res.join('\n'));

function get_area(h, w) {
	var top, bottom;
	if (h >= 3) {
		top = Math.floor(h / 2);
		if (top % 2 === 1) top++;
		bottom = h - top;
		return get_area(top, w) + '\n' + get_area(bottom, w);
	} else if (h == 1) {
		return get_even(w);
	} else if (h == 2) {
		return get_even(w) + '\n' + get_odd(w);
	}
}

function get_even(n) {
	var i, smaller;
	if (n in even) return even[n];
	if (n % 2 === 0) {
		i = n / 2;
		smaller = get_even(i);
		return smaller + ((i % 2 === 0) ? smaller : get_odd(i));
	}
	return get_even(n - 1) + '#';
}

function get_odd(n) {
	var i, smaller;
	if (n in odd) return odd[n];
	if (n % 2 === 0) {
		i = n / 2;
		smaller = get_odd(i);
		return smaller + ((i % 2 === 0) ? smaller : get_even(i));
	}
	return get_odd(n - 1) + '.';
}

Measured memory_bytes: 17896
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;

int const num = 55555;

int main(){
    int n;
    cin>>n;
    bool a[num+1];
    bool ans[num+1];
    for(int i=0;i<=num;i++){
        a[i]=true;
        ans[i]=false;
    }

    for(int i=2;i*i<=num;i++){
        if(a[i] == false) continue;
        for(int j=2;i*j<=num;j++){
            if(a[i*j] == false) continue;
            a[i*j] = false;
        }
    }

    for(int i=2;i<=num;i++){
        if(i % 5 != 1) a[i] = false;
    }

    cout<<2<<" ";
    int i = 3;
    int ansnum = 1;
    while(ansnum < n){
        if(a[i]){
            cout<<i<<" ";
            ansnum++;
        }
        i++;
    }
    cout<<endl;
}

Measured memory_bytes: 256
s=input()
count=1
ans='Yes'
for i in s:
    if count%2==1:
        if i=='R' or i=='U' or i=='D':
            count+=1
            continue
        else:
            ans='No'
            break
    else:
        if i=='L' or i=='U' or i=='D':
            count+=1
            continue
        else:
            ans='No'
            break
print(ans)


Measured memory_bytes: 9032
'use strict';
const main = input => {
  const n = parseInt(input[0]);
  const s = input[1];
  // console.log(n, s);
  // console.log(s.charCodeAt(0));
  // console.log(String.fromCharCode(s.charCodeAt(0)+2));
  let ans = '';
  for(let i=0; i<s.length; i++) {
    if (s.charCodeAt(i)+n > 'Z'.charCodeAt(0)) {
      ans += String.fromCharCode(s.charCodeAt(i)+n-26)
    } else {
      ans += String.fromCharCode(s.charCodeAt(i)+n);
    }
  }
  console.log(ans);
  
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 9420
import itertools

dd = list(map(int,input().split()))
NN = dd[0]
MM = dd[1]
XX = dd[2]
success = 0
min_price = 100000*13
arr = [list(map(int,input().split())) for i in range(NN)]
for i in range(1,NN+1):
    comb = list(itertools.combinations(arr,i))
    for j in range(len(comb)):
        total_price = 0
        total_skill = [0]*MM
        doable = [0]*MM
        for k in range(i):
            total_price = total_price + comb[j][k][0]
            for l in range(MM):
                total_skill[l] = total_skill[l] + comb[j][k][l+1]
                if total_skill[l] >= XX:
                    doable[l] = 1
        if min(doable) == 1:
            success = 1
            if total_price < min_price:
                min_price = total_price
if success == 0:
    print(-1)
else:
    print(min_price)

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

vector<string> v;
string s;

signed main() {

    int n, l;
    cin >> n >> l;

    for ( int i = 0; i < n; i++ ) {
        cin >> s;
        v.push_back(s);
    }

    sort(v.begin(), v.end());

    for ( int i = 0; i < n; i++ ) cout << v[i];
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
from collections import Counter
N = int(input())
A = list(enumerate(list(map(int, input().split()))))
b = Counter([x[0]+x[1]+1 for x in A])
c = Counter([x[0]-x[1]+1 for x in A])
count = 0
for x in b.items():
    count += x[1] * c[x[0]]
print(count)

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

#define REP(i, a, b) for(int i = a; i <= b; ++i)
#define DEC(i, a, b) for(int i = a; i >= b; --i)
#define getmid(l,r) ((l) + ((r) - (l)) / 2)
#define MEM(a,b) memset(a,b,sizeof(a))
#define FI first
#define SE second
#define SZ(x) ((int)(x).size())
#define MP make_pair
#define PB push_back
 
typedef long long ll;
typedef pair<int,int> pii;
const int mod = 1000000007;

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

int main(){
    ios_base::sync_with_stdio(false);
	int a, b;
    cin >> a >> b;
    cout << 1LL * a * b / gcd(a, b) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int n;
int data[100];


int solve() {
  int avg;
  sort(data, data+n);
  avg = 0;
  for(int i = 1; i < n-1; ++i) {
    avg += data[i];
  }
  return avg / (n-2);
}

main() {
  while(( cin >> n ) && n) {
    for(int i = 0; i < n; ++i) {
      cin >> data[i];
    }
    cout << solve() << endl;
  }
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var LN = ReadInts();
            var L = LN[0];
            var N = LN[1];
            var snake = Read();

            BigInteger maru = 0;
            for (int i = 0; i < snake.Length - 1; i++)
            {
                if (snake[i] == 'o' && snake[i + 1] == 'o')
                {
                    maru++;
                }
            }

            BigInteger ans = L + maru * 3;

            for (int i = 1; i < N; i++)
            {
                maru = maru * 2;
                ans += maru * 3;
            }
            WriteLine(ans);
        }
        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}



Measured memory_bytes: 18080
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int N;
	
	cin >> N;

	int a[N];

	int b[3] = {0, 0, 0};

	rep(i, N)
	{
		cin >> a[i];
		if (a[i] & 0x01)
		{
			b[0]++;
		}
		else if (a[i] % 4 == 0)
		{
			b[2]++;
		}
		else if (a[i] % 2 == 0)
		{
			b[1]++;
		}
	}


	if (b[1] == 0)
	{
		if (b[0] <= b[2] + 1)
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	else
	{
		if (b[0] <= b[2])
		{
			cout << "Yes" << endl;
		}
		else
		{
			cout << "No" << endl;
		}
	}
	
	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    string s;
    cin >> n >> s;
    for (char &i : s) {
        i = ((i - 'A') + n) % 26 + 'A';
    }
    cout << s;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
x = list(map(int, input().split()))
ans = 10**9
for i in range(k-1,n):
    if x[i]*x[i-k+1]<0:
        mn = min(abs(x[i-k+1]),abs(x[i]))
        mx = max(abs(x[i-k+1]),abs(x[i]))
        ans = min(ans,2*mn+mx)
    else:
        ans = min(ans, max(abs(x[i-k+1]),abs(x[i])))
print(ans)

Measured memory_bytes: 14384