akhauriyash/Code-Regression huggingface dataset:
N, *AS = $stdin.read.split.map(&:to_i)
AS.sort!
AS.reverse!

x, y =
  AS.lazy
    .chunk{|a| a}
    .select{|a, as| as.size >= 2}
    .flat_map{|a, as|
      if as.size >= 4
        [a, a]
      else
        [a]
      end
    }.first(2)

p(x && y ? x*y : 0)


Measured memory_bytes: 11880
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long a, b, k;
  cin >> a >> b >> k;
  if (k>a+b) {
    cout << "0 0" << endl;
    return 0;
  }
  if (k<a) {
    cout << a-k << " " << b << endl;
    return 0;
  }
  cout << "0 " << b-(k-a) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
using namespace std;
#define INF 999999999
#define lint long long
#define rep(i, n) for(int i = 1; i <= (int)(n); i++)
#define rep0(i, n) for(int i = 0; i < (int)(n); i++)
int gcd(int a,int b){return b?gcd(b,a%b):a;}


int main(){
    lint A, P;
    cin >> A >> P;
    cout << (3 * A + P) / 2; 
    return 0;
}

Measured memory_bytes: 764
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func readInt() -> Int {
    return Int(readLine()!)!
}

func readDoubles () -> [Double] {
    return readLine()!.split(separator: " ").map { Double($0)! }
}

func readDouble() -> Double{
    return Double(readLine()!)!
}
///最大公約数を返す
func gcd(_ m:Int, _ n:Int) -> Int {
    if n == 0 {return m}
    return gcd(n, m % n)
}
///最小公倍数を返す
func lcm(_ m:Int, _ n:Int) -> Int {
    return m * n / gcd(m, n)
}

///素数判定(試し割り)
func isPrime(_ x:Int) -> Bool {
    if x <= 1 || x % 2 == 0 { return false }
    if x == 2 { return true }
    for i in stride(from: 3, to: Int(ceil(sqrt(Double(x)))), by: 2){
        if x % i == 0 {
            return false
        }
    }
    return true
}

//https://program-life.com/669
///実行速度の計測
func exectionTime(action: () -> Void) {
    let startDate = Date()
    action()
    let endDate = Date()
    print(endDate.timeIntervalSince(startDate))
}

// https://melheaven.hatenadiary.jp/entry/atcoder144
///約数の配列を返す
func makeDivisors(_ n:Int) -> [Int] {
    var divisors = [Int]()
    for i in 1..<Int(pow(Double(n), 0.5)) + 1 {
        if n % i == 0{
            divisors.append(i + n / i)
        }
    }
    
    return divisors
}

//https://riptutorial.com/ja/swift/example/14738/インデックスを知らずに配列から要素を削除する
extension Array where Element: Equatable {
    
    mutating func remove(_ element: Element) {
        _ = index(of: element).flatMap {
            self.remove(at: $0)
        }
    }
}

func binarySearch(rifgt:Int, key:Int, ary:[String]) -> Int{
    var left = 0
    var right = rifgt
    
    while abs(right - left) > 1 {
        let mid = left + (right - left) / 2
        
        if Int(ary[mid])! < key {
            left = mid
            
        } else {
            right = mid
        }
    }
    return left
}

func arrangement (prev:String, ary:[String], returnVal:[String]) -> [String] {
    var returnVal = returnVal
    if ary.count == 0 {
        returnVal.append(prev)
        return returnVal
    }
    
    for s in ary {
        let wprev = prev + s
        var wary = ary
        wary.remove(s)
        returnVal = arrangement(prev: wprev, ary: wary, returnVal: returnVal)
    }
    return returnVal
}

func main() {
    let nm = readInts()
    let (n, m) = (nm[0], nm[1])
    var left = 0
    var right = Int.max
    
    for i in 0..<m {
        let lr = readInts()
        let (l, r) = (lr[0], lr[1])
        
        left = max(left, l)
        right = min(right, r)
    }
    print(max(right - left + 1, 0))
}
main()


Measured memory_bytes: 13540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    ll N;
    cin >> N;
    ll sum = 0;
    for (ll i = 1; i * i < N; i++) {
        if (N % i == 0 && N / (N / i - 1) == N % (N / i - 1)) {
            sum += N / i - 1;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
/*||>>>> Praveen Ojha <<<<>>>> 22 June 2019 <<<<>>>> 18:08:00 <<<<||*/
// #pragma GCC optimize("Ofast") //(Very Fast but Inaccurate)
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //(Small operations in many loops)
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int lc=a/c,rc=b/c,led=a/d,rid=b/d;
	if(a%c!=0)
		lc++;
	if(a%d!=0)
		led++;
	int lm=(int)(c*d)/__gcd(c,d);
	int le=a/lm,ri=b/lm;
	if(a%lm!=0)
	le++;
	// int cnt1=0;
	// for(int i=a;i<=b;i++){
	// 	if(i%c!=0 && i%d!=0)
	// 		cnt1++;
	// }
	// debug()<< imie(b-a+1) imie(rc-lc+1) imie(rid-led+1) imie(ri-le+1); 
	int val=max(0LL,(b-a+1)-(rc-lc+1)-(rid-led+1)+(ri-le+1));
		// debug()<< imie(cnt1) imie(val);
	cout<<val<<"\n";
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fname "NAME"
#define ll long long
#define ui unsigned int
#define ull unsigned long long
#define bug(x) cerr << (#x) << " = " << (x) << endl;
#define REP0(i, n) for(int i = 0, _n = (n); i < _n; ++i)
#define REP1(i, n) for(int i = 1, _n = (n); i <= _n; ++i)
#define REPB0(i, n) for(int i = (n) - 1; i >= 0; --i)
#define REPB1(i, n) for(int i = (n); i > 0; --i)
#define FOR(i, a, b) for(int i = (a), _b = (b); i <= _b; ++i)
#define FORB(i, a, b) for(int i = (a), _b = (b); i >= _b; --i)
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define X first
#define Y second

using namespace std;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef pair<double, double> dd;
typedef pair<float, float> ff;

int main()
{
	if (fopen(fname".INP", "r")) {
		freopen(fname".INP", "r", stdin);
		freopen(fname".OUT", "w", stdout);
	}
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	int n;
	cin >> n;
	vector<double> arr(n);
	REP0(i, n) cin >> arr[i];
	sort(arr.begin(), arr.end());
	double res = (arr[0] + arr[1]) / 2;
	FOR(i, 2, n - 1) res = (res + arr[i]) / 2;
	cout << fixed << setprecision(8) << res;
	return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
  readLine()
  val array = readLine()
    ?.split("\\s+".toRegex())
    ?.map(String::toInt)
    ?.toIntArray()
    ?: intArrayOf()
  var cnt = 0
  for (i in 0 until array.size - 1) {
    var min = i
    for (j in i + 1 until array.size) {
      if (array[min] > array[j]) {
        min = j
      }
    }
    if (min != i) {
      array.swap(i, min)
      cnt++
    }
  }
  println(array.joinToString(" "))
  println(cnt)
}

fun IntArray.swap(i: Int, j: Int) {
  val tmp = this[i]
  this[i] = this[j]
  this[j] = tmp
}




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

/*
|i-j| == hi + hj != 0 ... i != j
j<i ; i - hi == j + hj
*/
     
int main() {
  int n=0, x=0;
  long long ans=0;
  cin >> n;
  vector<int> vec(n);
  map<int, int> map;
  rep (i, n) {
    cin >> x;
    vec.at(i) = x;
    if (i+1-x > 0) {
      if (!map.count(i+1-x)) map[i+1-x] = 0;
      map.at(i+1-x) += 1;  
    }
  }
  
  rep (i, n){
    if (map.count(i+1+vec.at(i))) ans += map.at(i+1+vec.at(i));
  }
    
  cout << ans << endl;
}

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

int main()
{
	string s;
	cin >> s;
	if(s=="ABC") cout << "ARC";
	if(s=="ARC") cout << "ABC";

	//////////////////////////////////
	//--------end--------
	//
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
  string S; cin >> S;
  int N = S.size();
  
  int count = 0;
  for (int i = 0; i < N / 2; i++) {
    if (S[i] != S[N-1-i]) count++;
  }

  cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	ll a, b, c;
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		cout << 0 << endl;
		return 0;
	}

	cout << min(b * c, min(a * c, a * b)) << endl;
	return 0;
}

Measured memory_bytes: 256
s = input()

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

for i, c in enumerate(s):
    if i & 1 == 0 and c not in odd:
        print('No')
        exit()
    if i & 1 == 1 and c not in even:
        print('No')
        exit()
print('Yes')


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

int main() {
	int n;
	cin >> n;
	vector<long long> dp(64, 1);
	vector<long long> me(64);
	dp[27] = 0;dp[30] = 0;dp[54] = 0;
	for (int i = 3;i < n;i++) {
		for (int j = 0;j < 64;j++)
			me[j] = dp[j];
		for (int j = 0;j < 4;j++) {
			for (int k = 0;k < 4;k++) {
				for (int l = 0;l < 4;l++) {
					//cout << j * 16 + 4 * k + l << endl;
					dp[j * 16 + 4 * k + l] = (me[0 + j * 4 + k] + me[16 + j * 4 + k] + me[32 + j * 4 + k] + me[48 + j * 4 + k])%1000000007;
				}
			}
		}
		//for (int i = 0;i < 64;i++)
			//cout << me[i] << endl;
		dp[27] = 0;dp[30] = 0;dp[54] = 0;
		dp[50] -= me[28];dp[58] -= me[30];dp[62] -= me[31];
		dp[14] -= me[19];dp[46] -= me[27];
		for (int j = 0;j < 64;j++) {
			dp[j] = (dp[j]+ 1000000007)%1000000007;
		}
	}
	long long ans = 0;
	for (int i = 0;i < 64;i++)
		ans = (ans + dp[i]) % 1000000007;
	cout << ans << endl;
	//for (int i = 0;i < 64;i++)
		//cout << dp[i] << endl;
}

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

int main() {
    int x;
    cin >> x;
    int a, b;
    a = x / 500;
    x -= 500 * a;
    b = x / 5;
    cout << 1000 * a + 5 * b << endl;
    return 0;
}

Measured memory_bytes: 256
//Relive your past life.
//Face your demons.
//The past is never dead,it is not even past.
//The memories are not only the key to the past but...also to the future.
//coded in Rusty Lake
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define ll   long long
#define pb   push_back
#define mp   make_pair
#define orz  1000000007
using namespace std;
int n,m,x[100005],y[100005],res;
bool ans[405][405],ok,b[405];
int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;++i)scanf("%d%d",x+i,y+i);
    for(int i=1;i<=n;++i){
        ans[i][i]=1,ok=1;
        for(int j=m;j;--j){
            if(ans[i][x[j]]&&ans[i][y[j]])ok=0;
            else if(ans[i][x[j]])ans[i][y[j]]=1;
            else if(ans[i][y[j]])ans[i][x[j]]=1;
        }
        if(!ok)b[i]=1;
    }
    for(int i=1;i<=n;++i){
        if(b[i]) continue;
        for(int j=i+1;j<=n;++j){
            if(b[j]) continue;
            ok=1;
            for(int k=1;k<=n;++k)if(ans[i][k]&&ans[j][k])k=n+1,ok=0;
            if(ok)++res;
        }
    }
    printf("%d\n",res);
    //system("pause");
    return 0;
}


Measured memory_bytes: 1152
// Aizu Vol-0 0068: Enclose Pins with a Rubber Band
// 2017.8.10

#include <stdio.h>
#include <math.h>

typedef double data;

#define SIZE  105
#define EPS   1e-8

int size;
data x[SIZE], y[SIZE];

int convexHull(int pn, data *x, data *y);
data distance(data x1, data y1, data x2, data y2);
double theta(data x1, data y1, data x2, data y2);

int main(void)
{
	int i, vsize;

	while (1) {
		scanf("%d", &size); if (!size) break;
		for (i = 0; i < size; i++) scanf("%lf,%lf", x + i, y + i);
		vsize = convexHull(size, x, y);
		printf("%d\n", size - vsize);
	}
	return 0;
}

int convexHull(int pn, data *x, data *y)
{
	int i, j;
	int min;
	double minang, nowang;
	data dist;

	min = 0;
	for (i = 1; i < pn; i++) {
		if (y[i] < y[min]) min = i;
		else if (y[i] == y[min] && x[i] < x[min]) min = i;
	}

	minang = 0;
	x[pn] = x[min], y[pn] = y[min];
	for (j = 0; j < pn; j++) {
		data tx, ty;
		if (j != min) {
			tx = x[j], x[j] = x[min], x[min] = tx;
			ty = y[j], y[j] = y[min], y[min] = ty;
		}
		dist = 0x7ffffff;
		min = pn; nowang = minang; minang = 360;
		for (i = j + 1; i <= pn; i++) {
			data d = distance(x[j], y[j], x[i], y[i]);
			double rad = theta(x[j], y[j], x[i], y[i]);
			if (d == 0) continue;
			if (rad < nowang) continue;
			if (rad > nowang + EPS) {
				if (rad + EPS < minang) {
					dist = d;
					minang = rad;
					min = i;
				}
				else if (fabs(rad - minang) < EPS && d > EPS && d > dist) {
					dist = d;
					minang = rad;
					min = i;
				}
			}
			else if (fabs(rad - nowang) < EPS && d > EPS &&
				fabs(rad - minang) > EPS || d > dist) {
				dist = d;
				minang = rad;
				min = i;
			}
		}
		if (min == pn) break;
	}
	return j + 1;
}

data distance(data x1, data y1, data x2, data y2)
{
	data dx = x1 - x2;
	data dy = y1 - y2;
	return dx*dx + dy*dy;
}

double theta(data x1, data y1, data x2, data y2)
{
	data dx, dy, ax, ay;
	double t;

	dx = x2 - x1, ax = dx < 0 ? -dx : dx;
	dy = y2 - y1, ay = dy < 0 ? -dy : dy;
	t = (ax + ay == 0) ? 0 : (double)dy / (double)(ax + ay);
	if (dx < 0) t = 2 - t;
	else if (dy < 0) t = 4 + t;
	return t * 90.0;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
        int i,j,wide,height;
        int h[10000],w[10000];
        i = 1;
        while(1){
                scanf("%d %d",&h[i],&w[i]);
                if(h[i] == 0 && w[i] == 0){
                        break;
                }
                i++;
        }
        for(j = 1;j < i;j++){
                for(height = 1;height <= h[j];height++){
                        for(wide = 1;wide <= w[j];wide++){
                                printf("#");
                        }
                        printf("\n");
                }
                printf("\n");
        }
        return 0;
}

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

typedef long long ll;

typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;

#define all(x) (x).begin(), (x).end()
#define MOD 1000000007
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define fore(i, l, r) for (int i = int(l); i < int(r); ++i)
 
template<class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
    return out <<  "(" << a.first << ", " << a.second << ")";
}
 
template<class A> ostream& operator << (ostream& out, const vector<A> &a) {			
    out << "[";
    for (auto it = a.begin(); it != a.end(); ++it) {
        if (it != a.begin())
            out << ", ";
        out << *it;
    }
    return out << "]";
}

void solve(){
    ll n;
    cin >> n;
    map<int,int> st;
    for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                st[(i*i + j*j+ k*k + i*j+ j*k + i*k)]++;
            }
        }
    }
    for(int i=1;i<=n;i++){
        cout<<st[i]<<"\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
   // cin >> t;
    while(t--){
        solve();
    }

	return 0;
}


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

int main() {
 ll n,a,b; cin >> n >> a >> b;
  
  ll mod = n / (a+b);
  ll count = (a+b) * mod;
  ll ans = a * mod;
 
  while(count < n) {
 	if(n-count > a) {
     ans += a;
    } else {
     ans += n-count;
     break;
    }
	count += a;
    
    if(n-count > b) {
      ans += b;
    } else {
      break;
    }
    count += b;
  }
  
  cout << ans << endl;
  
  return 0;
}
  

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

string a;

bool dfs(int dep, int val, string s) {
	if (dep == 4) {
		if (val == 7) { cout << s << "=7" << endl; return true; }
		return false;
	}
	if (dfs(dep + 1, val + (a[dep] - '0'), s + "+" + a[dep])) return true;
	return dfs(dep + 1, val - (a[dep] - '0'), s + "-" + a[dep]);
}

int main() {
	cin >> a;
	string initS; initS += a[0];
	dfs(1, a[0] - '0', initS);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
  int n;
  cin >> n;
  vector<P> ab(n), sum(n);
  for(int i=0; i<n; ++i){
    cin >> ab[i].first >> ab[i].second;
    sum[i].first = ab[i].first + ab[i].second;
    sum[i].second = i;
  }
  sort(sum.begin(),sum.end());
  reverse(sum.begin(),sum.end());
  ll ans = 0;
  for(int i=0; i<n; ++i){
    int x = sum[i].second;
    if(i%2 == 0){
      ans += ab[x].first;
    }else{
      ans -= ab[x].second;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4844
/*input
1000 1 1000
*/

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

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

    int ans = (n+x-1)/x*t;
    cout << ans << endl;
}

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

using ll = long long;

const int mod = 1e9 + 7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    int n = S.size();
    int ans = 0;
    for (int i = 0; i < n / 2; i++) {
        if (S[i] != S[n - i - 1])
            ans++;
    }
    cout << ans << endl;
}

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

using namespace std;
int main()
{
    long long a,b,c,d;
    long long i = 0;
    long long mod = 1000000007;
    
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;

    bool aa = false;
    while(true){
        c = c-b;
        if(c<=0){
            break;
        }
        a = a-d;
        if(a<=0){
            aa = true;
            break;
        }
    }

    if(aa == true){
        cout << "No";
    }
    else{
        cout << "Yes";
    }

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#ifdef BUG
    #include "debug.hpp"
#else
    #define DEBUG(var)
#endif

using namespace std;
template< class T1, class T2 > inline istream &
operator>>( istream & fin, pair< T1, T2 > & pr )
{ fin >> pr.first >> pr.second; return fin; }
template< class T0, class T1, class T2 > inline istream &
operator>>( istream & fin, tuple< T0, T1, T2 > & t )
{ fin >> get<0>(t) >> get<1>(t) >> get<2>(t); return fin; }
template< class T > inline istream &
operator>>( istream & fin, vector< T > & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class T, size_t n> inline istream &
operator>>( istream & fin, array<T, n> & a ) {
for(auto & u: a) fin >> u; return fin; }
template<class FwdIter> inline auto
dump(FwdIter first, FwdIter last, const char * dlm = " ") -> void {
typedef typename iterator_traits<FwdIter>::value_type value_type;
copy(first, last, ostream_iterator<value_type>(cout, dlm)); }
template<typename T> vector<T> & operator--(vector<T> & a)
{ for(auto & i: a) --i; return a; }
/* @@@ ----------------------------------- */

int64_t
solve(const size_t i,
      const size_t j,
      const size_t k,
      const vector<vector<size_t>> & a,
      const vector<vector<size_t>> & idx,
      vector<vector<vector<int64_t>>> & cache)
{
  const int64_t mod = 1000000007;
  const auto n = cache.size() - 1;

  auto & ref = cache[i][min(j, n)][min(k, n)];
  if(ref != -1) return ref;

  for(const auto ii: idx[i])
  {
    const auto & r = a[ii];
    if(r[2] == 1 && r[0] < j + 1)
      return ref = 0;

    if(r[2] == 2 && (j + 1 <= r[0] || r[0] < k + 1))
      return ref = 0;

    if(r[2] == 3 && k + 1 <= r[0])
      return ref = 0;
  }

  if(i == n)
    return ref = 1;

  // same as i - 1
  ref = solve(i + 1, j, k, a, idx, cache);

  // different from i - 1, same as j
  ref += solve(i + 1, i - 1, k, a, idx, cache);
  ref %= mod;

  // different from i - 1 and j (same as k)
  ref += solve(i + 1, i - 1, j, a, idx, cache);
  ref %= mod;

  return ref;
}


int main(const int argc, char * argv [])
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  size_t n, m;
  cin >> n >> m;
  vector<vector<size_t>> a(m, vector<size_t>(3));
  cin >> a;

  for(auto & r: a)
    -- r[0];

  vector<vector<size_t>> idx(n + 1);
  for(size_t i = 0; i < a.size(); ++i)
    idx[a[i][1]].push_back(i);

  vector<vector<vector<int64_t>>>
    cache(n + 1, vector<vector<int64_t>>(n + 1, vector<int64_t>(n + 1, -1)));

  cout << solve(0, -1, -1, a, idx, cache);

  return EXIT_SUCCESS;
}



Measured memory_bytes: 217088
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<cmath>
 
#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)
 
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e10
 
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; }
typedef long long ll;
typedef std::pair<ll, ll> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
 
using namespace std;

 
int main()
{
  	ll N;
	ll dp[105][5][5][5];
	ll mod;
    mod = pow(10, 9) + 7;
    cin >> N;

    rep(i, 105){
        rep(j, 4){
            rep(k, 4){
                rep(l, 4){
                    dp[i][j][k][l] = 0;
                }
            }
        }
    }

    dp[0][3][3][3] = 1;

    reps(i, N){
        rep(j, 4){
            rep(k, 4){
                rep(l, 4){
                    dp[i][j][k][l] = (dp[i-1][k][l][0] + dp[i-1][k][l][1] + dp[i-1][k][l][2] + dp[i-1][k][l][3])%mod;
                    dp[i][1][2][l] = (dp[i-1][2][l][1] + dp[i-1][2][l][2] + dp[i-1][2][l][3])%mod;
                }
                dp[i][1][k][2] = (dp[i-1][k][2][1] + dp[i-1][k][2][2] + dp[i-1][k][2][3])%mod;
            }
        }

        dp[i][1][2][0] = 0;
        dp[i][1][0][2] = 0;
        dp[i][2][1][0] = 0;
    }

    ll ans;
    rep(i, 4){
        rep(j, 4){
            rep(k, 4){
                ans += dp[N][i][j][k];
            }
        }
    }

    cout << ans%mod << endl;
 
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N; cin >> N;
    vector<int> as1(N), as2(N);
    for (auto &ai : as1) cin >> ai;
    for (auto &ai : as2) cin >> ai;
    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        int tmp = 0;
        for (int j = 0; j <= i; ++j) tmp += as1[j];
        for (int j = i; j < N; ++j) tmp += as2[j];
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    cin>>n;
    int ans=n%10;
    
    if(ans==2 || ans==4 || ans==5 || ans==7 || ans==9)
        cout<<"hon\n";
    else if(ans==0 || ans==1 || ans==6 || ans==8)
        cout<<"pon\n";
    else if(ans==3)
        cout<<"bon\n";
        
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
}



Measured memory_bytes: 256
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        char[] s = Console.ReadLine().ToCharArray();
        int ans = 0;
        int x = 0;
        for (int i = 0; i < n; i++)
        {
            if(s[i] == 'I')
            {
                x++;
                ans = Math.Max(ans,x);
            }
            else
                x--;
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
int A,B,C;
bool check(int a,int b,int c){
	return a==b;
}
int main(){
	cin >> A >> B >> C;
	if(check(A,B,C)&&check(B,C,A)&&check(C,A,B))cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| min!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(z) = it.next() {
            Some(it.fold(z, |x, y| max!(x, y)))
        } else {
            None
        }
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}


macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.cin();
    let mut k = 1;
    let mut base = 1;
    let mut ans = 0;
    for _ in 0..10 {
        if n < 10 * base {
            if k % 2 == 1 {
                ans += n - base + 1;
            }
            break
        } else {
            if k % 2 == 1 {
                ans += 9 * base;
            }
            k += 1;
            base *= 10;
        }
    }
    put!(ans);
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
}


Measured memory_bytes: 4352
from string import ascii_lowercase


def ex_gcd(a, b, y0=0, y1=1):
    s, r = a // b, a % b
    return ex_gcd(b, r, y1, y0 - s * y1) if r else y1


def decrypt(c, a_rev, b):
    return chr(a_rev * (ord(c) - 97 - b) % 26 + 97) if c in ascii_lowercase else c


decrypt_that = {}
decrypt_this = {}

for a in (1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25):
    for b in range(26):
        _t, _h, _a, _i, _s = map(lambda c: chr((a * c + b) % 26 + 97), (19, 7, 0, 8, 18))
        decrypt_that[''.join((_t, _h, _a, _t))] = (a, b)
        decrypt_this[''.join((_t, _h, _i, _s))] = (a, b)

n = int(input())
while n:
    line = input()
    word4 = {w for w in line.split() if len(w) == 4}
    a, b = 0, 0
    for word in word4:
        if word in decrypt_that:
            a, b = decrypt_that[word]
            break
        if word in decrypt_this:
            a, b = decrypt_this[word]
            break
    a_rev = ex_gcd(26, a)
    print(''.join(decrypt(c, a_rev, b) for c in line))

    n -= 1

Measured memory_bytes: 8264
/*Arnab's Code
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define vll vector<ll>
#define vii vector<int>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define take(a,n) for(ll i=0;i<n;i++)cin>>a[i]
#define takes(a,n,st) for(ll i=st;i<n+st;i++)cin>>a[i]
ll sum(ll a[],ll n,ll s){ for(ll i=0;i<n;i++)s+=a[i]; return s;}
#define mod 1000000009
ll power(ll x, ll y, ll p)  {  
    ll 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;  
}
void solve(){
	ll n,d,tot,i,x,y,z;
	cin>>n>>d;
	tot=0;
	for(i=0;i<n;i++){
		cin>>x>>y;
		z=(x*x + y*y);
		if(d*d >= z)
			tot++;
	}
	cout<<tot;
	return;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ll t,T;
//	cin>>T;
	T=1;
	for(t=1;t<=T;t++){
//		cout<<"Case #"<<t<<": ";
		solve();
	}
	return 0;
}

Measured memory_bytes: 3648
a,b,k = map(int, input().split())

for i in range(k):
    if(i%2==0):
        if(a%2!=0):
            a -= 1
        b = b+ a/2
        a = a/2
    else:
        if(b%2!=0):
            b -= 1
        a = a + b/2
        b = b/2

print("{} {}".format(int(a), int(b)))

Measured memory_bytes: 3060
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
#include <map>
#include <bitset>
using namespace std;
typedef long long int lli;
int main(void)
{
    int N;
    char s;
    cin >> s;
    if (s >= 65 && s <= 90)
    {
        cout << "A" << endl;
    }
    else
    {
        cout << "a" << endl;
    }
    return 0;
}


Measured memory_bytes: 3560
n, p = [int(i) for i in input().split()]
if n >= 40:
    print(1)
    exit()

num = int(p ** (1 / n)) + 1
for i in range(num):
    pp = p
    dv = num - i
    if pp % (dv ** n) == 0:
        ans = dv
        break
print(ans)

Measured memory_bytes: 3060
s = input()
prev = s[0]
cnt = 1
ans = 0
for i in range(1, 4):
    if prev == s[i]:
        cnt += 1
    else:
        prev = s[i]
        ans = max(ans, cnt)
        cnt = 1
ans = max(ans, cnt)
if ans >= 3:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 8844
#include <bits/stdc++.h>
using namespace std;
#define watch(x) cout << (#x) << " is " << (x) << '\n'
#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 mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pi;
typedef double db;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a; }
//head


bool is_palindrome(string s){
    int n = s.size();
    for (int i = 0; i < n/2; i++){
        if (s[i] != s[n-i-1]) return false;
    }
    return true;
}

void solve(){
    string s;
    cin >> s;
    int n = s.size();
    if (is_palindrome(s) && is_palindrome(s.substr(0, n/2)) && is_palindrome(s.substr(n/2+1, n/2))){
        cout << "Yes\n";

    }
    else cout << "No\n";
}

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

    //int t; cin >> t; while (t--)
        solve();
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
static const int divide = 1000000000 + 7;

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

	long long ans=0;
	long long mini = 0;
	long long maxi = 0;
	for (int i=1; i<k; i++)
	{
		mini += (i-1) % divide;
		maxi += (n - i + 1) % divide;
	}
	for (int i=k; i<n+2; i++)
	{
		mini += (i-1) % divide;
		maxi += (n - i + 1) % divide;
		// cout << mini << " " << maxi << endl;
		if (mini <= maxi)
		{
			ans += (maxi - mini+1) % (1000000000 + 7);
			ans %= divide;
			// cout << ans << endl;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll ,P> P3;
typedef pair<P ,P> PP;
const ll MOD = ll(1e9+7);
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e4 + 5);
const double EPS = 1e-6;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int r=0, b=0;
    int n;
    cin >> n;
    string s;
    cin >> s;
    REP(i,n){
        if(s[i]=='R')r++;
        else b++;
    }
    cout << (r>b?"Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 384
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int main(){
	string a,str;
	while(getline(cin,str)){
		stack<double> st;
		stringstream ss;
		ss<<str;
		while(ss>>a){
			double b,c;
			if(a=="+"||a=="-"||a=="*"||a=="/"){
				c=st.top(),st.pop();
				b=st.top(),st.pop();
				if(a=="+")st.push(b+c);
				else if(a=="-")st.push(b-c);
				else if(a=="*")st.push(b*c);
				else st.push(b/c);
			}
			else st.push(atof(a.c_str()));
		}
		printf("%.6f\n",st.top());
	}
}

Measured memory_bytes: 1280
class Coord
  attr_accessor :x, :y
  def initialize(__x, __y)
    @x = __x
    @y = __y
  end
  
  def +(coord)
    Coord.new(@x + coord.x, @y + coord.y)
  end
  
  def zero?
    @x == 0 && @y == 0
  end
  
  def to_s
    "#{@x} #{@y}"
  end
end

class MagicalTile
  attr_accessor :moved
  
  def initialize(tile_symbol)
    @vector = Coord.new(0, 0)
    @moved = false
    case tile_symbol
    when "<"
      @vector.x = -1
    when ">"
      @vector.x = 1
    when "^"
      @vector.y = -1
    when "v"
      @vector.y = 1
    end
  end
  
  def move(current_pos)
    unless @moved
      @moved = true
      current_pos + @vector
    end
  end
  
  def stop?
    @vector.zero?
  end
end

class MagicalFloor
  def initialize(__width, __height)
    @width = __width
    @height = __height
    @tiles = Array.new(@height) do
      input_line(gets.strip)
    end
  end
  
  def input_line(line)
    line.each_char.map{ |c| MagicalTile.new(c) }
  end
  
  def run
    pos = Coord.new(0, 0)
    until tile(pos).stop?
      next_pos = tile(pos).move(pos)
      return "LOOP" unless next_pos
      pos = next_pos
    end
    pos.to_s
  end
  
  def tile(pos)
    @tiles[pos.y][pos.x]
  end
end

def input_floor_size
  gets.strip.split.map(&:to_i)
end

floors = []
while true
  height, width = input_floor_size
  break if width == 0 && height == 0
  floors << MagicalFloor.new(width, height)
end

puts floors.map(&:run).join("\n")

Measured memory_bytes: 9644
n, y = map(int, input().split())

def main():
    if (5000*n) == y:
        print('{} {} {}'.format(0, n, 0))
        return
    if (10000*n) == y:
        print('{} {} {}'.format(n, 0, 0))
        return
    for i in range(n):
        for j in range(n-i):
            k = n - (i+j)
            if (10000*i + 5000*j + 1000*k) == y:
                print('{} {} {}'.format(i, j, k))
                return
    print('-1 -1 -1')

main()


Measured memory_bytes: 39280
#include<bits/stdc++.h>
using namespace std;
inline int read(){
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
int main()
{
    puts(read()>read()*read()?"No":"Yes");
    return 0;
}

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

int main () {
    
    int x[10010];
    int numberOfInput = 0;
    for (int i = 0; i < 10010; i++) {
        cin >> x[i];
        if (x[i] == 0) {
            break;
        }
        numberOfInput++;
    }
    
    for (int i = 0; i < numberOfInput; i++) {
        cout << "Case " << i+1 << ": " << x[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3044
import java.util.*;

public class Main
{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
        int l = scan.nextInt();
        int n = scan.nextInt();
        if (l % 2 != n % 2){
            System.out.println("IMPOSSIBLE");
        }
        else {
            System.out.println(((l + n) / 2));
        }
    }
}

Measured memory_bytes: 21844
# ALDS_1_A.

def intinput():
    a = input().split()
    for i in range(len(a)):
        a[i] = int(a[i])
    return a

def show(a):
    # 配列aの中身を出力する。
    _str = ""
    for i in range(len(a) - 1): _str += str(a[i]) + " "
    _str += str(a[len(a) - 1])
    print(_str)

def main():
    n = int(input())
    a = intinput()
    # a[0]から順に、挿入していく。
    for i in range(n):
        # a[i]を順次前の数とswapしていき、
        # 前の数の方が大きくなかったら止める。
        cur = i
        while cur > 0:
            if a[cur - 1] > a[cur]:
                a[cur - 1], a[cur] = a[cur], a[cur - 1]
            else: break
            cur -= 1
        show(a)

if __name__ == "__main__":
    main()


Measured memory_bytes: 5596
def main():
    n = int(input())
    if n % 2 != 0:
        print('No')
        exit()
    s = [v for v in input()]
    t = n//2
    if s[0:t] == s[t:]:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <algorithm>
#include <numeric>
#include <utility>
#include <random>
#include <chrono>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

using namespace std;

using LL = long long;
using ULL = unsigned long long;
using PII = pair<int, int>;
using PIL = pair<int, LL>;
using PLL = pair<LL, LL>;
// const int mod = 1e9 + 7;
// const int mod = 998244353;

inline void quickread() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}


inline void work() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n), b(m);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < m; ++i) cin >> b[i];
    vector<LL> p(m + 1, 0);
    for (int i = 1; i <= m; ++i) p[i] = p[i - 1] + b[i - 1];
    int res = 0;
    LL sum = 0;
    for (int i = 0; i <= n; ++i) {
        if (sum > k) break;
        auto it = upper_bound(p.begin(), p.end(), k - sum);
        int cur = it - p.begin() - 1;
        res = max(res, cur + i);
        sum += a[i];
    }
    cout << res;
}

int main() {
    // freopen(".txt", "r", stdin);
    quickread();
    work();
    return 0;
}

Measured memory_bytes: 6312
n = int(input())
m = list(map(int,input().split()))
minm,maxm,summ = m[0],m[0],0
for x in range(n):
    if m[x] < minm:
        minm = m[x]
    elif m[x] > maxm:
        maxm = m[x]
    summ = summ + m[x]
print(minm,maxm,summ)


Measured memory_bytes: 6596
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
L = getList()

cnt = 0
for i in range(N):
    for j in range(i + 1, N):
        for l in range(j + 1, N):
            if L[i] != L[j] and L[j] != L[l] and L[l] != L[i] and (L[i] + L[j] + L[l]) - 2 * max(L[i], L[j], L[l]) > 0:
                cnt += 1
print(cnt)

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

#define Int register int
#define MAXN 100005

int n;
int a[MAXN];

bool cmp (int a,int b){return a > b;}

int read ()
{
	int x = 0;char c = getchar();int f = 1;
	while (c < '0' || c > '9'){if (c == '-') f = -f;c = getchar();}
	while (c >= '0' && c <= '9'){x = (x << 3) + (x << 1) + c - '0';c = getchar();}
	return x * f;
}

void write (int x)
{
	if (x < 0){x = -x;putchar ('-');}
	if (x > 9) write (x / 10);
	putchar (x % 10 + '0');
}

signed main()
{
	n = read ();
	for (Int i = 1;i <= n;++ i) a[i] = read ();
	sort (a + 1,a + n + 1,cmp);
	for (Int i = 1;i <= n;++ i)
		if (i + 1 > a[i + 1])
		{
			int j = 0;
			for (;a[i + j + 1] == i;++ j);
			if (((i - a[i]) & 1) || (j & 1)) puts ("First");
			else puts ("Second");
			return 0;
		}
	return 0;
}

Measured memory_bytes: 768
#include<iostream>
#include<vector>
#include<string>

const std::string ABC = "ABC";

int main(){
    int N;
    std::cin >> N;
    std::string S;
    std::cin >> S;
    auto iter = S.find(ABC, 0);
    int cnt = 0;
    while(iter != std::string::npos){
        cnt++;
        iter = S.find(ABC, iter + 1);
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
using ll = long long;
int MOD = 1e9 + 7;
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin >> vec[i];
    }
    sort(vec.begin(), vec.end());
    int Max=vec[n-1];
    cout << Max << " ";
    int x = vec[lower_bound(vec.begin(), vec.end(), Max / 2) - vec.begin()];
    int y = vec[lower_bound(vec.begin(), vec.end(), Max / 2) - vec.begin() - 1];
        if (abs(x - (float)Max / 2) <= abs(y - (float)Max / 2))
        {
            if(x==Max){
                cout << y << endl;
                return 0;
            }
            cout << x << endl;
        }
        else
        {
            cout << y << endl;
        }
}


Measured memory_bytes: 640