akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)(?´????????`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi v(n);
	REP(i, n)cin >> v[i];
	int ans = -1;
	REP(i, n) {
		REP(j, n) {
			if (i == j)continue;
			int k = v[i] * v[j], c = ceil(log10(k) + EPS);
			vi tmp(c);
			int a = k;
			REP(s, c) {
				tmp[s] = k % 10;
				k /= 10;
			}
			int flag = 1;

			REP(s, c - 1) {
				if (tmp[s]-1!=tmp[s+1])flag = 0;
			}
			if (flag)ans = max(ans, a);
		}
	}
	cout << ans << endl;
	return 0;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string s;
  cin >> s;
  
  ll k;
  cin >> k;
  
  vector<string> v;
  REP(i, s.size()){
    //need until k words
    for(int j = 1; j <= k; j++)
        v.push_back(s.substr(i, j));
  }
  sort(v.begin(), v.end());
  unique(v.begin(), v.end());
  //v.erase(unique(v.begin(), v.end()), v.end());
  cout << v[k-1] << endl;
  
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(int i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(int i=(a);i<(n);i++)cout<<(arr)[i]<<' ';

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}

int main(){
	fast;
	ll n, k;
	cin>>n>>k;
	ll d;
	map<ll, ll> m;
	forn(i, 0, k){
		cin>>d;
		m[d]++;
	}
	ll ans;
	forn(i, n, n+100000){
		ll x = i, f = 1;
		while(x){
			if(m[x%10]>0){
				f = 0;
				break;
			}
			x/=10;
		}
		if(f == 1){
			ans = i;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
#define INF __INT32_MAX__

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

    vector<vector<int>> scnt(N);
    rep(i, N) {
        string S;
        cin >> S;

        vi sv(26, 0);

        rep(j, S.size()) {
            int x = S.at(j) - 'a';
            sv[x]++;
        }
        scnt[i] = sv;
    }

    string res;
    rep(i, 26) {
        int cmin = INF;
        rep(j, N) {
            cmin = min(cmin, scnt[j][i]);
        }

        rep(j, cmin) {
            res += (i + 'a');
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3480
#include<cstdio>
#include<iostream>
#define LL long long
using namespace std;
int main()
{
    LL n, k, x, y, ans = 0;
    cin>>n;
    cin>>k;
    cin>>x;
    cin>>y;
    if(n <= k){
        ans = n*x;
        cout<<ans;
    }
    else {
        ans += k*x;
        ans += (n-k)*y;
        cout<<ans;
    }


    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<array>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	vector<int> v = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int n; cin >> n; cout << v[n - 1] << endl;
	return 0;
}

/*


*/

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdlib>  
#include<cmath>   
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include<map>
#include<algorithm>
#include<functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<list>
#include<deque>
#include<climits>
#include<typeinfo>
#include<utility>
#define LEN 100005
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(ll i=0;i<n;i++)
#define For(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
using ll = long long;
double pi() { return 3.14; }
int sum(int a, int b) { return a + b; }
int mul(int a, int b) { return a * b; }
ll LGCD(ll x, ll y) { if (x % y == 0) return y;else return LGCD(y, x % y); }
ll LLCM(ll x, ll y) { return x * y / LGCD(x, y); }

int GCD(int x, int y) { if (x % y == 0) return y;else return GCD(y, x % y); }
int LCM(int x, int y) { return x * y / GCD(x, y); }
ll dpc[10000][10000];

//void nCr(ll n, ll r) {
//	ll ans = 1;
//	for (int i = n; i > n - r; --i) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1; ++i) {
//		ans = ans / i;
//	}
//	printf("%d",ans);
//}

ll combination(ll n, ll r) {
	if (n == r) { return dpc[n][n] = 1; }
	else if (r == 0) { return dpc[n][0] = 1; }
	else if (r == 1) { return dpc[n][1] = n; }
	else if (dpc[n][r]) { return dpc[n][r]; }
	else { return dpc[n][r] = combination(n - 1, r - 1) + combination(n - 1, r); }
}

//cout << fixed << setprecision(10)



int main() {
	
	int n, m;
	cin >> n >> m;
	vector<int>h(n);
	for (int i = 0;i < n;i++) {
		cin >> h[i];
	}
	vector<int>a(m);
	vector<int>b(m);
	for (int i = 0;i < m;i++) {
		cin >> a[i] >> b[i];
		a[i] = a[i] - 1;
		b[i] = b[i] - 1;
	}
	vector<int>good(n);
	for (int i = 0;i < n;i++) {
		good[i] = 1;
	}
	for (int i = 0;i < m;i++) {
		if (h[a[i]] > h[b[i]])good[b[i]] = 0;
		else if (h[a[i]] < h[b[i]])good[a[i]] = 0;
		else {
			good[a[i]] = 0;
			good[b[i]] = 0;
		}
	}

	int ans = 0;
	for (int i = 0;i < n;i++) {
		if (good[i] == 1)ans++;
	}

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


Measured memory_bytes: 4844
#include<bits/stdc++.h>
using namespace std;
#define yes "Yes"
#define no "No"

string solve(int A, int B, string S) {
  bool answer = true;
  if ((A>=1) && (B<=5) && (S[A]=='-')) {
    for (int i=0; i<(A+B+1); i++) 
  	  if ((('0'>S[i]) || (S[i]>'9')) && (i!=A))
  		answer &= false;
  } else
    answer = false;
  
  return (answer) ? yes : no;
}

int main() {
  int A, B;
  string S;
  cin >> A >> B >> S;
  cout << solve(A, B, S) << endl;
}


Measured memory_bytes: 256
# Union-Findデータ構造
class UnionFind:
    def __init__(self, numV):
        self.pars = list(range(numV))
        self.ranks = [0] * numV
    def find(self, x):
        if self.pars[x] == x: return x
        else:
            self.pars[x] = self.find(self.pars[x])
            return self.pars[x]
    def union(self, x, y):
        x, y = self.find(x), self.find(y)
        if x == y: return
        if self.ranks[x] < self.ranks[y]:
            self.pars[x] = y
        else:
            self.pars[y] = x
            if self.ranks[x] == self.ranks[y]:
                self.ranks[x] += 1
    def same(self, x, y):
        return self.find(x) == self.find(y)

def conv(i, j):
    return (i-1)*W + j-1

H, W = map(int, input().split())
Sss = ['_' + input() + '_' for _ in range(H)]
Sss = ['_' * (W + 2)] + Sss + ['_' * (W + 2)]

N = H * W
UF = UnionFind(N)
for i in range(1, H+1):
    for j in range(1, W+1):
        revS = '.' if Sss[i][j] == '#' else '#'
        for di, dj in [(-1,0), (1,0), (0,-1), (0,1)]:
            if Sss[i+di][j+dj] == revS:
                UF.union(conv(i, j), conv(i+di, j+dj))

numBs, numWs = [0]*N, [0]*N
for i in range(1, H+1):
    for j in range(1, W+1):
        no = UF.find(conv(i, j))
        if Sss[i][j] == '#':
            numBs[no] += 1
        else:
            numWs[no] += 1

ans = 0
for numB, numW in zip(numBs, numWs):
    ans += numB * numW
print(ans)


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

int main() {
  int n,ans = 0;
  cin >> n;
  n *= 2;
  vector<int>l(n);
  rep(i,0,n) cin >> l[i];
  sort(l.begin(),l.end());
  for(int i = 0;i < n;i += 2) ans += l[i];
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

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

    if((n%500)<=a){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22732
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long valid(long long n) {
	int geko = 0;
	while (n != 0) {
		if (n % 10 == 3) geko |= 1;
		if (n % 10 == 5) geko |= 2;
		if (n % 10 == 7) geko |= 4;
		n /= 10;
	}
	if (geko == 7) return 1;
	return 0;
}
long long gogo[1000] = {};
int main() {
	int n;
	cin >> n;
	for (int i = 2; i <= n; ++i) {
		int now = i;
		for (int q = 2; q <= sqrt(i); ++q) {
			if (now % q == 0) {
				gogo[q]++;
				now /= q;
				q--;
			}
		}
		if (now != 1) gogo[now]++;
	}
	long long dp[10000] = {};
	dp[1] = 1;
	for (int i = 2; i <= n; ++i) {
		for (int q = 75; q >= 0; --q) {
			for (int j = 1; j <= gogo[i]; ++j) {
				dp[q * (j + 1)] += dp[q];
			}
		}
	}
	cout << dp[75] << endl;
	return 0;
}

Measured memory_bytes: 1016
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k,a,i;
    cin>>n>>k;
    for(i=0;i<n;i++)
        cin>>a;
    if(n==k)
        cout<<"1"<<endl;
    else
        cout<<((n-1)%(k-1)==0?(n-1)/(k-1):(n-1)/(k-1)+1)<<endl;
}


Measured memory_bytes: 3616
use std::cmp::*;
use std::io::*;

mod disjoint_set {
    pub struct DisjointSet {
        parent: Vec<usize>,
        size: Vec<usize>,
    }
    impl DisjointSet {
        pub fn new(n: usize) -> DisjointSet {
            DisjointSet {
                parent: (0..n).collect(),
                size: vec![1; n],
            }
        }
        pub fn root(&mut self, x: usize) -> usize {
            if x == self.parent[x] {
                x
            } else {
                let tmp = self.parent[x];
                self.parent[x] = self.root(tmp);
                self.parent[x]
            }
        }
        pub fn merge(&mut self, x: usize, y: usize) {
            let x = self.root(x);
            let y = self.root(y);
            if x == y {
                return;
            }
            if self.size[x] > self.size[y] {
                self.size[x] += self.size[y];
                self.parent[y] = x;
            } else {
                self.size[y] += self.size[x];
                self.parent[x] = y;
            }
        }
    }
}

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let m: usize = itr.next().unwrap().parse().unwrap();

    let mut ds = disjoint_set::DisjointSet::new(n);
    for _ in 0..m {
        let x: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let y: usize = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let z: usize = itr.next().unwrap().parse().unwrap();
        ds.merge(x, y);
    }
    let mut ans = 0;
    let mut used = vec![false; n];
    for i in 0..n {
        if !used[ds.root(i)] {
            ans += 1;
            used[ds.root(i)] = true;
        }
    }
    println!("{}", ans);
}


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

void Main()
{
	int H, W, h, w; cin >> H >> W >> h >> w;
	int res = W * H;
	res -= (h * W);
	res -= (w * H);
	res += (h * w);
	cout << res << endl;
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}


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

int main(){
    long long A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    if(X < Y){
        swap(X,Y);
        swap(A,B);
    }
    long long min = 2*C*X;
    if(min > A*(X-Y)+2*C*Y) min = A*(X-Y)+2*C*Y;
    if(min > A*X+B*Y) min = A*X+B*Y;
    cout << min << endl;
    system("pause");
    return 0;
}

Measured memory_bytes: 504
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(), (a).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;

// --------------------------------------------------------------------------------

void solve()
{
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> a;
    a.push_back(x);
    set<ll> s;
    int id = -1, id2 = -1;
    int r = -1;
    for (int i = 1;; i++)
    {
        ll tmp = a[i - 1] % m * a[i - 1];
        tmp %= m;
        a.push_back(tmp);
        if (s.count(a[i]))
        {
            id = find(all(a), a[i]) - a.begin();
            id2 = i;
            r = id2 - id;
            break;
        }
        else
            s.insert(a[i]);
    }
    // rep(i, a.size()) cout << a[i] << endl;
    ll wanum = (n - id) / r;
    ll wamod = (n - id) % r;
    ll wan = 0;
    for (int i = id; i < id2; i++)
    {
        wan += a[i];
        // wan %= m;
    }
    ll wam = 0;
    for (int i = id; i < id + wamod; i++)
    {
        wam += a[i];
        // wam %= m;
    }
    ll ans = 0;
    rep(i, id)
    {
        ans += a[i];
        // ans %= m;
    }
    wan *= wanum;
    ans += wan;
    // ans %= m;
    ans += wam;
    // ans %= m;
    cout << ans << endl;
}

// --------------------------------------------------------------------------------

int main()
{
    // srand((unsigned)time(NULL));
    // int bt = clock();
    solve();
    // double et = 1.0 * (clock() - bt) / CLOCKS_PER_SEC;
    // printf("Execution Time: %.4lf sec\n", et);
    return 0;
}

Measured memory_bytes: 5996
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef double ld;
typedef long double lld;
//#define LOCAL_DEFINE 0
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define pb push_back
#define mp make_pair
#define pi pair<int,int>
#define pl pair<ll,ll>
template<class T> T umax(T a,T b) {return (a>b?a:b);}
template<class T> T umin(T a,T b) {return (a<b?a:b);}
template<class T,class P> T umax(T a,P b) {return (a>b?a:b);}
template<class T,class P> T umin(T a,P b) {return (a<b?a:b);}


const ll mod = 1e9+7;

ll power(ll a,ll b) {
    ll res = 1;
    while(b) {
        if(b&1) res = (res*a)%mod;
        a = (a*a)%mod;
        b >>= 1;
    }
    return res;
}

int X[] = {0,1,0,-1};
int Y[] = {1,0,-1,0};

int main() {
#ifdef LOCAL_DEFINE
    freopen("CCL.in","r",stdin);
    freopen("ans.txt","w",stdout);
#endif
    ios::sync_with_stdio(false);
    // logic
    int n,x;
    cin >> n;
    vector<pair<int,int> > a(n);
    vector<int> b(n);
    for(int i=0;i<n;i++) {
        cin >> x;
        b[i] = x;
        a[i] = mp(x,i);
    }
    sort(a.begin(),a.end());
    vector<int> idx(n);
    for(int i=0;i<n;i++) {
        idx[i] = a[i].second;
    }
    vector<int> res(n);
    for(int i=0;i<n;i++) {
        int l = i-1;
        int r = i+1;
        int lcnt = l+1;
        int rcnt = n-r;
        if(lcnt == 0) {
             res[idx[i]] = b[idx[(n-1+r)/2]];
        }
        else if(rcnt == 0) {
            res[idx[i]] = b[idx[l/2]];
        }
        else {
            if(lcnt%2==0) {
                res[idx[i]] = (lcnt<rcnt) ? b[idx[n-1-(lcnt+rcnt)/2]] : b[idx[(lcnt+rcnt)/2]];
            }
            else {
                res[idx[i]] =  (lcnt<rcnt) ? b[idx[n-1-(lcnt+rcnt)/2]] : b[idx[(lcnt+rcnt)/2]];
            }
        }
    }
    rep(i,n) cout << res[i] << endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 6144
///
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Jan 21 21:28:54 2018
//
package main

import "fmt"

type pos struct {
	x int
	y int
}

func abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func main() {
	var N int
	fmt.Scan(&N)

	time := 0
	p := pos{0, 0}
	for i := 0; i < N; i++ {
		var t, x, y int
		fmt.Scan(&t, &x, &y)
		dist := abs(p.x-x) + abs(p.y-y)
		tdiff := t - time
		if tdiff < dist {
			fmt.Println("No")
			return
		}

		if (tdiff-dist)%2 != 0 {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <algorithm>
#include <unordered_map>

#define rep(i, a, b) for (ll i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef unordered_map<string, ll> u_map;

// input
void input() {}
template <class Head, class... Tail>
void input(Head &&a, Tail &&... b)
{
    cin >> a;
    input(forward<Tail>(b)...);
}

template <class V>
void input(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &i) { input(i); });
}

// output
template <class V>
void output(vector<V> &v)
{
    for_each(v.begin(), v.end(), [](auto &x) { cout << x << " "; });
    cout << endl;
}

// math functions
ll mpow(ll a, ll n, ll p)
{
    ll x = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            x = a * x % p;
        }
        a = a * a % p;
        n >>= 1;
    }

    return x;
}

ll mfact(ll n, ll p)
{
    ll res = 1;
    for (ll i = 2; i <= n; i++)
    {
        res = res * i % p;
    }
    return res;
}

ll mcomb(ll n, ll r, ll p)
{
    if (n == 0 && r == 0)
    {
        return 1;
    }
    if (n < r || n < 0 || r < 0)
    {
        return 0;
    }

    ll a = mfact(n, p);
    ll b = mfact(n - r, p);
    ll c = mfact(r, p);
    return (((a * mpow(b, p - 2, p)) % p) * mpow(c, p - 2, p)) % p;
}

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

ll lcm(ll a, ll b)
{
    return a * b / gcd(a, b);
}

int main()
{
    int N, X, Y;
    input(N, X, Y);

    int res[N + 1];
    rep(i, 0, N + 1)
    {
        res[i] = 0;
    }

    int dist[N + 1][N + 1];
    rep(i, 0, N + 1)
    {
        rep(j, 0, N + 1)
        {
            dist[i][j] = -1;
        }
    }

    rep(i, 1, N)
    {
        rep(j, i + 1, N + 1)
        {
            dist[i][j] = min(abs(j - i), abs(X - i) + abs(Y - j) + 1);
            res[dist[i][j]]++;
        }
    }

    rep(k, 1, N)
    {
        cout << res[k] << endl;
    }

    return 0;
}


Measured memory_bytes: 15872
def run(a, b):
    h1 = 0
    h2 = 0
    for i in range(1, 1000):
        h1 += i-1
        h2 += i
        if (h1 - a) == (h2 - b):
            return h1 - a


def main():
    a, b = map(int, input().split())
    print(run(a, b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int D = s.nextInt();
        int T = s.nextInt();
        int S = s.nextInt();
        if(D/S > T) System.out.println("No");
        else if(D/S == T && D%S != 0) System.out.println("No");
        else System.out.println("Yes");
    }
}

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

int main() {
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double dis = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
	printf("%.8f\n", sqrt(dis));
}


Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(auto i = (a); i < (b); i++)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = ~(1<<31);
#define fs first
#define sc second
#define pb push_back

const double EPS = 1e-9;
const double pi = acos(-1);
typedef unsigned long long ull;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
template <class T> T smod(T a, T b) {
    return (a % b + b) % b;
}


int n;
double memo[410][410][410];
double dp(int p1, int p2, int p3) {
    int bad = n-p1-p2-p3;
    if(memo[p1][p2][p3] > -0.5) return memo[p1][p2][p3];
    if(bad == n) {
        return 0;
    } else {
        double s = 1;
        if(p1 != 0) s += dp(p1-1,p2,p3) * double(p1)/double(n);
        if(p2 != 0) s += dp(p1+1,p2-1,p3) * double(p2)/double(n);
        if(p3 != 0) s += dp(p1,p2+1,p3-1) * double(p3)/double(n);
        return memo[p1][p2][p3] = s / double(1 - double(bad)/double(n));
    }
}

int main() {
    cin.sync_with_stdio(false);
    cin >> n;
    vi A(3,0);
    rep(i,0,n) {
        int x;
        cin >> x;
        x--;
        A[x]++;
    }
    rep(i,0,410) rep(j,0,410) rep(k,0,410) memo[i][j][k] = -1;
    cout << setprecision(10) << fixed << dp(A[0],A[1],A[2]) << endl;
    return 0;
}


Measured memory_bytes: 538752
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int x;
		String str = "";
		for (int i = 1; i <= n; i++) {
			x = i;
			if (x % 3 == 0) {
				str += " " + x;
			} else {
				while (x != 0) {
					if (x % 10 == 3) {
						str += " " + i;
						break;
					}
					x /= 10;
				}
			}
		}
		System.out.println(str);
	}

}

Measured memory_bytes: 184596
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

int main(){
  int n,t,l,b;
  while(cin>>n>>t>>l>>b, n){
    vector<int> type(n+1,0);
    rep(i,l){ // lose
      int d;
      cin>>d;
      type[d] = 1;
    }
    rep(i,b){ // back
      int d;
      cin>>d;
      type[d] = 2;
    }

    vector<vector<double>> dp(t+2, vector<double>(n+1, 0));
    // dp[t][p]: turn, position
    dp[0][0] = 1;

    rep(i,t){
      rep(j,n) if(dp[i][j]>0){
        repl(k,1,7){
          int nj = j+k;
          if(nj>n) nj = n - (nj-n);
          int ni = i+1;
          if(type[nj]==1) ni++;
          else if(type[nj]==2) nj=0;
          dp[ni][nj] += dp[i][j]/6.0;
        }
      }
      dp[i+1][n] += dp[i][n];
//      dbg(dp[i+1]);
    }

    printf("%.6f\n", dp[t][n]);

  }
  return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return ('0' <= c && c <= '9')?(c - '0'):-1;}


// TODO: write
int main() {
  string s;cin>>s;
  int n = s.size() / 2;
  int ans = INF;
  for(int i = n;i < s.size();++i){
    char c = s[i];
    int longest = 0;
    int cnt = 0;
    rep(j,s.size()){
      cnt++;
      if(s[j] == c){
        chmax(longest,cnt-1);
        cnt = 0;
      }
    }
    chmax(longest,cnt);
    chmin(ans,longest);
  }
  print(ans);
  return 0;
}



Measured memory_bytes: 256
n = int(input())
A = [int(x) for x in input().split()]

B = [0] * n
C = [0] * 10001

for a in A:
    C[a] += 1

j = 0
for i in range(10001):
    for c in range(C[i]):
        B[j] = i
        j += 1

print(' '.join([str(x) for x in B]))



Measured memory_bytes: 241736
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
int MAX = 1000000000;
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int s;
    cin >> s;
    int x2, x3, y2, y3;
    int s1;
    //s1 = abs(x2*y3-y2*x3)

    //cout << 0 << " " << 0 << " " << s << " " <<0 << " " <<0 << " " <<1 << endl;
    int flag = 0;
    for (x2 = 1; x2 <= MAX; x2++)
    {
        if (s % x2 == 0)
        {
            y3 = s / x2;
            if (y3 > MAX)
            {
                flag = 1;
                break;
            }
            else
            {
                x3 = 0;
                y2 = 0;
                break;
            }
        }
        else
        {
            x3 = s % x2;
            y2 = 1;
            y3 = (s - x3) / x2;
            if (y3 > MAX)
            {
                flag = 1;
                break;
            }
            else
            {
                break;
            }
        }
    }
    if (flag == 1)
    {
        for (x2 = MAX; x2 >= 1; x2--)
        {
            if (s % x2 == 0)
            {
                y3 = s / x2;
                if (y3 > MAX)
                {
                    continue;
                }
                else
                {
                    x3 = 0;
                    y2 = 0;
                    break;
                }
            }
            else
            {
                x3 = x2 - (s % x2);
                y2 = 1;
                y3 = (s + x3) / x2;
                if (y3 > MAX)
                {
                    continue;
                }
                else
                {
                    break;
                }
            }
        }
    }
    cout << 0 << " " << 0 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
}

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

#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << ", " << #y << "=" << y << endl

void solve() {
  string s;
  cin >> s;
  ll sm = 0;
  for (int i = 0; i < s.size(); i++) {
    sm += s[i] - '0';
  }
  if (sm % 9 == 0) {
    cout << "Yes\n";
  } else {
    cout << "No\n";
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ll test = 1;
  // cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}


Measured memory_bytes: 3740
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll i,j,k,n,t;
    cin>>t>>n;
    if(t<=8&&n<=8)
    cout<<"Yay!"<<endl;
    else
    cout<<":("<<endl;
	return 0;
}

Measured memory_bytes: 256
ro = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    ro[b - 1][f - 1][r - 1] += v
    

for i in range(4):
    for j in range(3):
        for k in range(10):
            
            print("",ro[i][j][k],end="")
        print()
    if i != 3 :    
        print("#"*20)
    
        


    
        


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

using namespace std;

#define SIZE 100

int main(){
    int i, j, k, flag;
    string s, p;
    cin >> s;
    cin >> p;
    flag = 0;

    for(i = 0; i < s.length(); i++){
        for(j = 0; j < p.length(); j++){
            
            if((i + j) >= s.length()){
                k = (i + j) - s.length();
            }else{
                k = i + j;
            }
            
//            cout << "s[k]:" << s[k] << " p[j]:" << p[j] << " flag:" << flag << endl;            
            
            if(s[k] != p[j]){
                break;    
            }else if(j == p.length() -1){
                flag =1;
            }
        }
    }
    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;    
    }
    return 0;
}

Measured memory_bytes: 1184
"TLE"

N, K = map(int, input().split())

A_list = list(map(int, input().split()))

A_dir_list = []
A_visit_list = [-1 for i in range(N)]
dir = 0

while True:
    A_dir_list.append(dir)
    A_visit_list[dir] = 1
    if A_visit_list[A_list[dir]-1] == -1: 
        dir = A_list[dir]-1
    else:
        cycle_pos = A_dir_list.index(A_list[dir]-1)
        break

if K < cycle_pos:
    print(A_dir_list[K]+1)

else:
    cnt = (K-cycle_pos)%(len(A_dir_list)-cycle_pos)
    print(A_dir_list[cnt+cycle_pos]+1)


Measured memory_bytes: 32368
using System;
using System.Collections.Generic;
using System.Linq;

public class AtCoder_159_D
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var dic = new Dictionary<int, int>();
        var nC2 = new long[n + 1];
        nC2[0] = 0;
        nC2[1] = 0;
        nC2[2] = 1;
        for (int i = 3; i < n + 1; i++)
        {
            nC2[i] = nC2[i - 1] * i / (i - 2);
        }

        for (int i = 0; i < n; i++)
        {
            var num = line1[i];
            if (dic.ContainsKey(num))
            {
                dic[num]++;
            }
            else
            {
                dic.Add(num, 1);
            }
        }

        long total = 0;
        foreach (var val in dic.Values)
        {
            total += nC2[val];
        }

        for (int i = 0; i < n; i++)
        {
            var num = line1[i];
            Console.WriteLine(total - nC2[dic[num]] + nC2[dic[num] - 1]);
        }
    }
}


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

int main() {
    int n,w;
    cin >> n >> w;
    vector<long long int> weight(n), value(n);
    for(int i=0; i<n; i++)
    {
        cin >> weight[i] >> value[i];
    }
    vector<long long int> dp(100001,w+1);
    dp[0] = 0;
    for(int i=0; i<n; i++)
    {
        long long int val = value[i];
        for(int j=100000; j-val >= 0; j--)
        {
            dp[j] = min(dp[j],dp[j-val]+weight[i]);
        }
    }
    int ans = 0;
    for(int i=0; i<=100000; i++)
    {
        if(dp[i] <= w)ans = i;
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){
  char mozi[1001], order[8], re[1001];
  int cnt=0;
  int i,j, st, ed;

  scanf("%s\n%d", mozi, &cnt);
  for(i=0;i<cnt;i++){
    scanf("%s %d %d", order, &st, &ed);
    if(order[2]=='p'){ // replace
      scanf("%s", re);
      for(j=0;j<ed-st+1;j++)   mozi[st+j] = re[j];
    }else if(order[2]=='v'){ // reverse
      for(j=0;j<ed-st+1;j++)   re[ed-st-j] = mozi[st+j];
      for(j=0;j<ed-st+1;j++)   mozi[st+j] = re[j];
    }else if(order[2]=='i') {// print
      for(j=st;j<=ed;j++)      printf("%c", mozi[j]);
      printf("\n");
    }
  }
  return 0;
}



Measured memory_bytes: 2000
sx,sy,tx,ty = map(int,input().split())
#print(sx,sy,tx,ty)
diffx = tx-sx
diffy = ty-sy
#print(diffx,diffy)
st = ''
for i in range(2):
    if i == 0:
        st = st + 'U'*diffy+'R'*diffx+'D'*diffy+'L'*diffx
    if i ==1:
        st = st + 'L'+'U'*(diffy+1)+'R'*(diffx+1)+'D'+'R'+'D'*(diffy+1)+'L'*(diffx+1)+'U'
print(st)

Measured memory_bytes: 9076
// ░░░░░░░░( •̪●)░░░░░░░░░░░░░░░░░░░░░░░░
// ░░░░░░███████ ]▄▄▄▄▄▄▄▄▃░░░▃░░░░ ▃░
// ▂▄▅█████████▅▄▃▂░░░░░░░░░░░░░░░░░
// [███████████████████].░░░░░░░░░░░░░░
// ◥⊙▲⊙▲⊙▲⊙▲⊙▲⊙▲⊙◤...░░░░░░░░░░░░

//PointBlank's code (⌐■_■)

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
 
ll power(ll x, ll y); 
#define repp(I, A, B) for(int I = A; I <= B; I++)
#define rep(I, A, B) for(int I = A; I < B; I++)
#define rrep(I, B, A) for(int I = B; I >= A; I--)
#define pb emplace_back
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define LB lower_bound
#define UB upper_bound
#define MP make_pair
#define mem(A, B) memset(A, B, sizeof(A));
#define mem0(A) memset(A, 0, sizeof(A));
#define quickio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define bitcount(n) __builtin_popcountll(n)
#define in_edges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B), v[B].pb(A);}
#define in_dedges(M) repp(I, 1, M){int A, B; cin >> A >> B; v[A].pb(B);}
#define in_wedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C), v[B].pb(A, C);}
#define in_dwedges(M) repp(I, 1, M){int A, B, C; cin >> A >> B >> C; v[A].pb(B, C);}
#define endl "\n"

const ll MOD = 1000000007;
const ll INF = 1e18;
vector<ll> f[1000006];
int m[1000006];

int main() //PointBlank's code ¯\_(ツ)_/¯
{
    rep(i, 2, 1000006){
        if(f[i].size() == 0){
            f[i].pb(i);
            for(auto j = 2*i; j < 1000006; j+=i){
                f[j].pb(i);
            }
        }
    }
    quickio
    ll n;
    cin >> n;
    vector<ll> v(n);
    for(auto &i : v) cin >> i;
    sort(all(v));

    bool flag = 1;
    for(auto x : v){
        for(auto j : f[x]) m[j]++;
    }

    rep(i, 2, 1000006) if(m[i] > 1) flag = 0;

    if(flag){
        cout << "pairwise coprime";
        exit(0);
    }

    ll gcd = v[0];
    for(auto i : v) gcd = __gcd(gcd, i);

    if(gcd == 1){
        cout << "setwise coprime";
    }else{
        cout << "not coprime";
    }

}

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

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main() {
  int w;
  string s;
  cin >> s >> w;
  for (int i = 0; i < s.size(); i += w) {
    cout << s[i];
  }
  cout << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int m, n;
	int[][] a;
	boolean[][] visited;

	void run(){
		for(;;){
			m=sc.nextInt();
			n=sc.nextInt();
			if((m|n)==0){
				break;
			}
			a=new int[n][m];
			for(int j=0; j<n; j++){
				for(int i=0; i<m; i++){
					a[j][i]=sc.nextInt();
				}
			}
			solve();
		}
	}

	void solve(){
		visited=new boolean[n][m];
		int ans=0;
		for(int j=0; j<n; j++){
			for(int i=0; i<m; i++){
				// debug(i, j, rec(j, i));
				ans=max(ans, rec(j, i));
			}
		}
		println(ans+"");
	}

	int rec(int x, int y){
		if(x<0||x>=m||y<0||y>=n){
			return 0;
		}
		if(a[y][x]==0){
			return 0;
		}
		if(visited[y][x]){
			return 0;
		}
		visited[y][x]=true;

		int res=0;
		int[] dx={0, 0, -1, 1};
		int[] dy={-1, 1, 0, 0};
		for(int i=0; i<4; i++){
			res=max(res, rec(x+dx[i], y+dy[i])+1);
		}
		visited[y][x]=false;

		return res;
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include <iostream>
#include <map>

using namespace std;

int main() {
    int s, ans = 1;
    cin >> s;
    map<int, int> m;
    m[s] = 1;
    while (true) {
        ++ans;
        if (s % 2) s = s * 3 + 1;
        else s /= 2;
        if (m[s]) {
            cout << ans << endl;
            return 0;
        } else m[s] = 1;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define abs(a,b)( a - b > 0 ? a - b : b - a)
using namespace std;



/*
5
2 2 2 10 10
*/


int main()
{
int n;
cin >> n;
vector < long long int> a(n);

for (int i=0; i<n; i++) cin >> a[i];


long long int rs=0,ls=0;
int l = -1, r = n;
while (l+1<r)
   {

    if (rs>=ls)
        {   l++;
            ls+=a[l];
        }
    else
        {   r--;
            rs+=a[r];
        }


        
   }










cout << abs(ls,rs);





}


Measured memory_bytes: 1792
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

int main()
{
    int n;
    int r;
    cin>>n;
    cin>>r;
    if(n>=10){
        cout<<r;
        return 0;
    }
    int internalRating=(r+100*(10-n));
    cout<<internalRating;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    
    if (A == 1) {
      A = 14;
    }
    
    if (B == 1) {
      B = 14;
    }

    if (A == B) {
      System.out.println("Draw");
    } else if (A < B) {
      System.out.println("Bob");
    } else {
      System.out.println("Alice");
    }

  }
}

Measured memory_bytes: 23252
<?php
    // get input from stdin
    // $input = readline("Please input the number N: ");
    $input = readline();
    // Validate the input. 
    if(!is_numeric($input) || (int)$input < 1 || 100 < (int)$input) {
        throw new \Exception("Invalid input, please input between 1 and 100.", 1);
    }
    $input = (int)$input;
    
    // when value is odd <= please write. @dungnq-0076 
    if (($input % 2) != 0) {
        $prob = round((ceil($input / 2) / $input), 9); // <= this answer not 4, > 6 10^(-6)
        print_r($prob);
    }

    // // when value is even
    if(($input % 2) == 0) {
        echo(floatval(0.5));
    }
?>


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  ll N, K; cin >> N >> K;
  vector<ll> A(N), F(N);

  for (ll i = 0; i < N; i++) cin >> A[i];
  for (ll i = 0; i < N; i++) cin >> F[i];

  sort(A.begin(), A.end());
  sort(F.begin(), F.end(), greater<ll>());

  ll left = 0, right = static_cast<ll>(10e12);

  while (left < right) {
    ll mid = (left + right) / 2;

    ll x = K;
    ll ok = true;
    for (ll i = 0; i < N && ok; i++) {
      if (mid < A[i] * F[i]) {
        ll d = A[i] - mid / F[i];

        if (d <= x) {
          x -= d;
        } else {
          ok = false;
        }
      }
    }

    if (ok) {
      right = mid;
    } else {
      left = mid + 1;
    }
  }

  cout << left << endl;
}


Measured memory_bytes: 6428
#include <string>
#include <string.h>
#include <iostream>

using namespace std;

int main()
{
	int N, B[4]; string S;

	memset(B, 0, sizeof(B));

	while (cin >> N >> S)
	{
		if (S == ",A")
		{
			B[0] += 1;
		}
		else if (S == ",B")
		{
			B[1] += 1;
		}
		else if (S == ",AB")
		{
			B[2] += 1;
		}
		else if (S == ",O")
		{
			B[3] += 1;
		}
	}

	cout << B[0] << endl << B[1] << endl << B[2] << endl << B[3] << endl;

	return 0;
}

Measured memory_bytes: 1204
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define MAX_N 500000
vector<int>X[MAX_N]; queue<int>Q;
int COLOR[MAX_N], N, M, Q1, A, B;
int main() {
	cin >> N >> M;
	for (int i = 0; i < M; i++) { cin >> A >> B; X[A].push_back(B); X[B].push_back(A); }
	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (COLOR[i] == 0) {
			Q.push(i); cnt++; COLOR[i] = cnt;
			while (!Q.empty()) {
				int a = Q.front(); Q.pop();
				for (int j = 0; j < X[a].size(); j++) {
					int to = X[a][j];
					if (COLOR[to] == 0) {
						COLOR[to] = cnt;
						Q.push(to);
					}
				}
			}
		}
	}
	cin >> Q1;
	for (int i = 0; i < Q1; i++) {
		cin >> A >> B;
		if (COLOR[A] == COLOR[B]) {
			cout << "yes" << endl;
		}
		else {
			cout << "no" << endl;
		}
	}
	return 0;
}

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

template<typename T,typename F>
struct SegmentTree {
private:
    int n;
    vector<T> node;
    T id;
    F f;
public:
    SegmentTree(vector<T> v,F func,T identity):id(identity),f(func) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1,id);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = f(node[2*i+1],node[2*i+2]);
    }

    void update(int x,T val) {
        x += (n-1);
        node[x] = val;
        while (x > 0) {
            x = (x-1)/2;
            node[x] = f(node[2*x+1],node[2*x+2]);
        }
    }

    T getval(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (r <= a || b <= l) return id;
        if (a <= l && r <= b) return node[k];
        return f(getval(a,b,2*k+1,l,(l+r)/2),getval(a,b,2*k+2,(l+r)/2,r));
    }
};

int main() {
    int n,q;
    cin >> n >> q;
    auto f = [&](int a,int b)->int{return min(a,b);};
    SegmentTree<int,decltype(f)> seg(vector<int>(n,INT_MAX),f,INT_MAX);
    for (int i = 0;i < q;++i) {
        int c,x,y;
        cin >> c >> x >> y;
        if (c) cout << seg.getval(x,y+1) << endl;
        else seg.update(x,y);
    }
    return 0;
}


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

int main(){
  int n;
  cin>>n;
  int ans = 0;
  for(int i=1;i<=n;i++){
    int cnt = 0;
    int z = i;
    while(z!=0){
      z/=10;
      cnt++;
    }
    if (cnt%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256