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

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;
typedef pair<pair<double, double >, double > pdd;
typedef pair<double, double > pd;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main(){
    
    ll N, X, Y;
    cin >> N >> X >> Y;

    vector<ll > ans(N, 0);
    for(ll i = 1; i <= N; i++){
        for(ll j = i + 1; j <= N; j++){
            //if(i == j) continue;
            ll t_ans = min(abs(i-j), min(abs(i-X)+abs(j-X), abs(i-X)+abs(j-Y)+1));
            //cout << i << " " << j << " " << t_ans << endl;
            ans[t_ans]++;
        }        
    }

    for(ll i = 1; i <= N-1; i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 384
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

C = [0] * 3

for i in range(3):
    C[i] = list(map(int, input().split()))

for i in range(1, 3):
    x = C[i][0] - C[i - 1][0]
    for j in range(1, 3):
        if C[i][j] - C[i - 1][j] != x:
            print("No")
            exit()

for j in range(1, 3):
    x = C[0][j] - C[0][j - 1]
    for i in range(1, 3):
        if C[i][j] - C[i][j - 1] != x:
            print("No")
            exit()
print("Yes")




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

int main() {
    int h, n, sum = 0;
    cin >> h >> n;
    for (int i=0; i<n; i++) {
        int num; cin >> num;
        sum += num;
    }
    if (sum >= h) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  vector<int> b = p;
  sort(b.begin(), b.end());
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] != b[i]) { cnt++; }
  }
  cout << (cnt == 2 || cnt == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
while True:
    m,n=map(int,input().split())
    if m==n==0:break
    
    cnt=0
    for i in range(1,m+1):
        for j in range(i,m+1):
            for k in range(j,m+1):
                if i+j+k==n and not(i==j or j== k or k==i):
                    cnt+=1
    print(cnt)
    


Measured memory_bytes: 5596
while input = STDIN.gets
   coins = input.split

   c1   = coins[0].to_i
   c5   = coins[1].to_i * 5
   c10  = coins[2].to_i * 10
   c50  = coins[3].to_i * 50
   c100 = coins[4].to_i * 100
   c500 = coins[5].to_i * 500

   goukei = c1 + c5 + c10 + c50 + c100 + c500

   if goukei >= 1000
     print "1\n"
   else
     print "0\n"
   end
end

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

int main() {
  int n; cin>>n;
  bool can=false;
  for(int i=1;i<=9;i++) {
    for(int j=1;j<=9;j++) {
      if(i*j==n) can=true;
    }
  }
  if(can) cout<<"Yes\n";
  else cout<<"No\n";
}


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

char a[50][50+1],b[50][50+1];

bool search(int i,int j,int m){
    for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
            if(a[i+k][j+l]!=b[k][l])return false;
            if(k==m-1&&l==m-1)return true;
        }
    }
}
int main(){
    int n,m;  cin>>n>>m;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<m;i++)cin>>b[i];
    for(int i=0;i<=n-m;i++)for(int j=0;j<=n-m;j++)if(search(i,j,m)){cout<<"Yes"<<endl;return 0;}
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;


int main() {
  string str;
  while(getline(cin,str)) {
    replace(str.begin(), str.end(), ',', ' ');
    stringstream ss;
    ss << str;
    int num;
    double w, h;
    ss >> num >> w >> h;
    if(w/(h*h) >= 25.0) cout << num << endl;
  }
  return 0;
}

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

typedef long long ll;
#define PB push_back


int n; 
int x[10], y[10];


double distance(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

int fact(int k) {
	if (k == 1) return 1;
	return k * fact(k - 1);
}
 
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) cin >> x[i] >> y[i];
	double sum = 0.0;
	vector<int> permutation;
	for (int i = 0; i < n; ++i) {
		permutation.PB(i);
	}
	do {
		for (int i = 0; i < n - 1; ++i) {
			sum += distance(permutation[i], permutation[i+1]);
		}
	} while (next_permutation(permutation.begin(),permutation.end()));
	cout << fixed << setprecision(10) << sum / fact(n);
}


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int inf = 1e9;

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    int n,m;
    while (cin >> n >> m) {
        vector<PII> A;
        FOR(i,0,m) {
            int a,b; cin >> a >> b;
            A.push_back(PII(a,0));
            A.push_back(PII(b,1));
        }
        sort(ALL(A));
        int cnt = 0, ans = 0, lft = inf;
        FOR_ALL(a,A) {
            const int x = a->first;
            const int t = a->second;
            if (t == 0)
                cnt++;
            if (cnt >= m)
                lft = min(lft,x);
            if (t) {
                if (cnt-1 < m) {
                    ans += max(0,x-lft+1);
                    lft = inf;
                }
                cnt--;
            }
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
   	#endif
    string a,b;
    cin>>a>>b;
    int n=stoi(a+b);
    cout<<((floor(sqrt(n))==ceil(sqrt(n)))?"Yes":"No");
   	return 0;
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<" ";}
#define dumpl(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

//?????¨??°?????? O(f(N+M)) f????????§??????????????°?????°??§??????N
class BipartiteMatching {
public:
	int n;
	vector<vector<int>> g;
	vector<int> match;
	BipartiteMatching(int n) : n(n), g(n), match(n), used(n) {}
	void add_edge(int u, int v) {
		g[u].emplace_back(v);
		g[v].emplace_back(u);
	}
	//?????§??????????????°
	int maximum_matching() {
		int ret = 0;
		fill(match.begin(), match.end(), -1);
		for (int v = 0; v < n; v++) {
			if (match[v] == -1) {
				fill(used.begin(), used.end(), false);
				if (dfs(v)) ret++;
			}
		}
		return ret;
	}
private:
	vector<int> used;
	bool dfs(int v) {
		used[v] = true;
		for (int u : g[v]) {
			int w = match[u];
			if (w == -1 || (!used[w] && dfs(w))) {
				match[v] = u;
				match[u] = v;
				return true;
			}
		}
		return false;
	}
};
//?????§??¬?´???°
int gcd(int x, int y) { return y ? gcd(y, x%y) : x; }
signed main() {
	for (int m, n; cin >> m >> n&&m;) {
		vector<int> b(m); rep(i, 0, m) { cin >> b[i]; }
		vector<int> r(n); rep(i, 0, n) { cin >> r[i]; }
		BipartiteMatching bm(m + n);
		rep(i, 0, m)rep(j, 0, n) {
			if (gcd(b[i], r[j]) == 1)continue;
			bm.add_edge(i, m + j);
		}
		int ans = bm.maximum_matching();
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4404
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define per(i, a, b) for (auto i = (b) - 1; i >= (a); --i)
#define trav(x, v) for (auto &x : v)

#define sz(x) int((x).size())
#define eb(x...) emplace_back(x)

using ll = int64_t;

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

constexpr ll inf = 2e18;
constexpr int M = 1e9 + 7;

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

	int h, w; cin >> h >> w;
	char g[h][w];
	int dp[h + 1][w + 1];
	rep(i, 0, h) rep(j, 0, w) cin >> g[i][j];
	rep(i, 0, h) dp[i + 1][0] = 0;
	rep(j, 0, w) dp[0][j + 1] = 0;
	dp[0][1] = 1;
	rep(i, 0, h)
		rep(j, 0, w)
			dp[i + 1][j + 1] = g[i][j] != '#' ? (dp[i + 1][j] + dp[i][j + 1]) % M : 0;
	cout << dp[h][w];
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 bool primecheck(ll n){//sosuu
    if(n < 2) return false;
    else{
        for(int i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}
int  main(){
int x;
cin >> x;
while(1){
    bool ans = primecheck(x);
    if(ans){cout << x << endl; break;}
    x++;
}
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    k: i32,
    s: chars,
  }
  let mut unhappy = 1;
  for i in 1 .. n {
    if s[i-1] != s[i] {
      unhappy += 1;
    }
  }
  let unhappy = cmp::max(1, unhappy - 2 * k);

  puts!("{}\n", n as i32 - unhappy);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main(void)
{
    int a,b,c,d;
    
    scanf("%d",&a);
    b=a/3600;
    c=a%3600/60;
    d=a%60;
    printf("%d:%d:%d\n",b,c,d);
    return(0);
    
}


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

//freopen("file_name.in", "r", stdin);
//freopen("file_name.out", "w", stdout);

#define fr(i,n) for(int i=0;i<n;i++)
#define frr(i,a,b) for(int i =a;i<=b;i++)

typedef long long ll;

#define eb emplace_back

#define all(v) (v).begin(),(v).end()

#define fi first
#define se second
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

//-DBL_MAX
//__builtin_popcountll(ll x) - __builtin_popcount(int x)

#define prin(a) cout << #a << " = " << (a) << endl
#define prinv(v) {cout << #v << " = "; for(auto it : v) cout << it << " "; cout << endl;}
#define ppal(a)  cout << #a << endl

const int N = 19;
const ll MOD = 1e9+7, INF = LLONG_MAX/2;

ll soma(ll a, ll b){
    return a+b;
}

int true_mask(int mask, vector<int> &v){
    int ans = 0;
    fr(i,v.size()) if(mask&(1<<i)) ans += (1<<v[i]);
    return ans;
}  

ll g[N][N]; 

ll val[1<<N], dp[(1<<N)];

int n;

int main(){
    cin >> n;
    fr(i,n) fr(j,n) scanf("%lld", g[i]+j);
    
    fr(i,(1<<n)) dp[i] = -INF;
    dp[0] = 0;
    
    fr(mask,(1<<n)){
        ll cur = 0;
        fr(i,n) fr(j,n) if( (mask&(1<<i)) and (mask&(1<<j))) cur = soma(cur,g[i][j]);
        val[mask] = cur;
    }
    
    fr(mask_tot,(1<<n)){
        vector<int> can_take;
        fr(i,n) if(mask_tot&(1<<i)) can_take.eb(i);
        vector<int> vmask(1);
        fr(itake,can_take.size()){
            int tam = vmask.size();
            fr(imask,tam) vmask.eb((1<<can_take[itake])|vmask[imask]);
        }
        frr(imask,1,(int)vmask.size()-1) dp[mask_tot] = max(dp[mask_tot],soma(dp[mask_tot^vmask[imask]],val[vmask[imask]]));
    }
    
    //fr(mask,(1<<n)) prin(dp[mask]);
    
    cout << dp[(1<<n)-1]/2 << endl;
	
	return 0;
}


Measured memory_bytes: 3196
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

using namespace std;

bool batch(string str){
  string str1 = str.substr(0, str.size()/2);
  string str2 = str.substr((str.size()+1)/2);
  reverse(str2.begin(), str2.end());
  if(equal(str1.begin(), str1.end(), str2.begin())){
    return true;
  }
  return false;
}

int main(){
  string S;
  cin >> S;
  
  //cout << S << endl;
  
  string ans;
  string str1 = S.substr(0, S.size()/2);
  string str2 = S.substr((S.size()+1)/2);
  
  //cout << str1 << endl;
  
  if(batch(S) && batch(str1) && batch(str2)){
    ans = "Yes";
  }else{
    ans = "No";
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
cum = [1]*2 + [2]*(N-1)
for i in range(2,N//2+1):
    for j in range(2*i,N+1,i):
        cum[j] += 1
ans = 0
for i in range(1,N+1):
    ans += i*cum[i]
print(ans)

Measured memory_bytes: 229688
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお


int dp[5010][5010];
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n; cin >> n;
	string s; cin >> s;

	for(int i = n-1; i >= 0; --i) {
		for(int j = n-1; j >= 0; --j) {
			if(s[i] != s[j]) dp[i+1][j+1]+1;
			else dp[i][j] = dp[i+1][j+1]+1;
		}
	}
	int ans = 0;
	rep(i,n) {
		rep(j,n) {
			if(i >= j) continue;
			int now = min(dp[i][j], j-i);
			ans = max(ans,now);
		}
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int X, A, B;
  cin >> X >> A >> B;
  
  if (A >= B)
    cout << "delicious" << endl;
  else if (B - A <= X)
    cout << "safe" << endl;
  else
    cout << "dangerous" << endl;
}

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



int main() {
	int n;
	cin >> n;
	int ans = 0;
	for(int i=0; i<n; i++) {
		int num;
		cin >> num;
		if(i % 2 == 0 && num % 2 != 0) {
			ans ++;
		}
	}
	cout << ans;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{

	
		int N;
	cin >> N;
	vec(X);

	fx(N) {
		vecp(X);
	}
	ll ans = LLONG_MAX;
	sorts(X);
	fx(X[N-1]+1) {
		ll sum = 0;
		fy(N) {
			sum += (X[y] - x) * (X[y] - x);
		}
		ans = min(ans, sum);
	}
	ce(ans)
    return 0;
}



Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) {
    if (a >= b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;   
}

int main() {
    int a;
    cin>>a;
    vector<int> vec(a);
    rep(i,a){
        cin>>vec.at(i);
    }
    vector<int> svec(a-1);
    rep(i,a-1){
        svec.at(i)=vec.at(i)-vec.at(i+1);
    }
    int max=-1;
    int count=0;
    rep(i,a-1){
        if(svec.at(i)>=0){
            count++;
            if(count>max){
                max=count;
            }
        }
        else{
            if(count>max){
                max=count;
            }
            count=0;
        }
    }
    if(count==a-1){
        cout<<count<<endl;
    }
    else{
        cout<<max<<endl;
    }

}





Measured memory_bytes: 1024
n = int(input())
x = [[int(x) for x in input().split()] for _ in range(n)]

house0 = [[0 for _ in range(10)] for _ in range(3)]
house1 = [[0 for _ in range(10)] for _ in range(3)]
house2 = [[0 for _ in range(10)] for _ in range(3)]
house3 = [[0 for _ in range(10)] for _ in range(3)]
house = [house0, house1, house2, house3]

for b, f, r, v in x:
    house[b-1][f-1][r-1] += v

for i, item in enumerate(house):
    for row in item:
        print(' ', end='')
        print(*row)
    if i < 3:
        print('#'*20)


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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
using pii = pair<int, int>;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

signed main(){
    int n, a, b;
    cin >> n >> a >> b;
    auto mx = min(a, b);
    auto mn = max(a + b - n, 0);
    cout << mx << " " << mn << nl;
}


Measured memory_bytes: 256
from collections import Counter
while 1:
    n = int(input())
    if n == 0:break
    a = tuple(map(int, input().split()))
    b = [a[i + 1] - a[i] for i in range(n)]
    d = Counter(b).most_common()[0][0]
    for i in range(n):
        if b[i] != d:
            if i < n - 1 and b[i + 1] == d:print(a[i])
            else:print(a[i + 1])
            break


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

namespace CSharpSample01
{
    
    

    class Program
    {

        static int MCXI_Val(char ch)
        {
            int deci = 0;

            switch (ch)
            {
                case 'm':
                    deci = 1000;
                    break;
                case 'c':
                    deci = 100;
                    break;
                case 'x':
                    deci = 10;
                    break;
                case 'i':
                    deci = 1;
                    break;
                default:
                    break;
            }

            return deci;
        }

        static string MCXI_Str(int val)
        {
            string str = "";

            switch (val)
            {
                case 1000:
                    str = "m";
                    break;
                case 100:
                    str = "c";
                    break;
                case 10:
                    str = "x";
                    break;
                case 1:
                    str = "i";
                    break;
                default:
                    break;
            }

            return str;
        }

        static int MCXI_To_Decimal(string mcxi_str)
        {
            int decimal_val = 0;
            int v = 1;

            for(int i = 0; i < mcxi_str.Length; i++)
            {
                if('a' < mcxi_str[i] && mcxi_str[i] < 'z')
                {
                    decimal_val += v * MCXI_Val(mcxi_str[i]);
                    v = 1;
                }
                else
                {
                    v = int.Parse(mcxi_str[i].ToString());
                }
            }

            return decimal_val;
        }

        static string Decimal_To_MCXI(int decimal_val)
        {
            string mcxi_str = "";

            int quotient = 0;

            for(int i = 1000; i >= 1; i /= 10)
            {
                quotient = decimal_val / i;
                decimal_val %= i;
                if (quotient == 1)
                {
                    mcxi_str += MCXI_Str(i);
                }
                else if (quotient >= 2)
                {
                    mcxi_str += quotient.ToString() + MCXI_Str(i);
                }

            }
            
            return mcxi_str;
        }
        
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            
            for(int i = 0; i < n; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int decimal_val = MCXI_To_Decimal(input[0]) + MCXI_To_Decimal(input[1]);

                Console.WriteLine(Decimal_To_MCXI(decimal_val));

            }
            
        }
    }
}


Measured memory_bytes: 15772
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define double long double
#define x first
#define y second



           //       |----|       /\      |    |   -----   |
           //       |   /       /  \     |    |     |     |
           //       |--/       /----\    |----|     |     |
           //       |   \     /      \   |    |     |     |
           //       |    \   /        \  |    |   -----   -------

int n;
double arr[3001];
double cache[3001][3001];
bool vis[3001][3001];
double dp(int pos,int head)
{
	if(pos==n)
	{
		if(head>n-head)
			return 1.0;
		return 0;
	}
	if(vis[pos][head])
		return cache[pos][head];
	vis[pos][head]=true;
	return cache[pos][head]=arr[pos]*dp(pos+1,head+1)+(1-arr[pos])*dp(pos+1,head);
}
int32_t main()
{
    IOS
    cin>>n;
    for(int i=0;i<n;i++)
    	cin>>arr[i];
    cout<<fixed<<setprecision(12)<<dp(0,0);
}

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

using namespace std;

struct Card {
    char suit;
    int value;
};

void printAry(Card src[], Card dst[], int N )
{ 
    if(src == NULL && dst == NULL ) {
        std::cout << "Stable" << std::endl;
        return;
    }
    if(src == NULL || dst == NULL ) {
        std::cout << "Not stable" << std::endl;
        return;
    }

    for( int i = 0; i < N; i++ ) {
        if( src[i].suit != dst[i].suit ) {
            std::cout << "Not stable" << std::endl;
            return;
        }
        if( src[i].value != dst[i].value ) {
            std::cout << "Not stable" << std::endl;
            return;
        }
    }

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

void printData(Card data[], int dataNum ) {
    for( int i = 0; i < dataNum; i++ ){
        if( i != 0 ) {
            std::cout << " ";
        }
        std::cout << data[i].suit << data[i].value;
    }
    std::cout << std::endl;
}

void bubbleSort(Card data[], int dataCnt ) {
    int swCnt = 0;
    for(int i = 0; i < dataCnt - 1; i++ ) {
        bool exchanged = false;
        for( int k = dataCnt - 1 - 1; k >= i; k-- ) {
            if( data[k+1].value < data[k].value ) {
                char suit = data[k+1].suit;
                int value = data[k+1].value;
                data[k+1].suit = data[k].suit;
                data[k+1].value = data[k].value;
                data[k].suit = suit;
                data[k].value = value;
                exchanged = true;
                swCnt++;
            }
        }
        if( !exchanged ) {
            break;
        }
    }
}

void selectionSort( Card data[], int dataCnt ) {
    for( int i = 0; i < dataCnt; i++) {
        int minValIndex = i;
        for( int k = i + 1; k < dataCnt; k++ ){
            if( data[minValIndex].value > data[k].value ) {
                minValIndex = k;
            }
        }
        if( i != minValIndex ) {
            Card minValCard = data[minValIndex];
            data[minValIndex] = data[i];
            data[i] = minValCard;
        }
    }
}

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

    Card C1[N], C2[N];
    for( int i = 0; i < N; i++ ) {
        cin >> C1[i].suit >> C1[i].value;
    }

    for( int i = 0; i < N; i++ ) {
        C2[i].suit = C1[i].suit;
        C2[i].value = C1[i].value;
    }

    bubbleSort(C1,N);
    printData(C1,N);
    std::cout << "Stable" << std::endl;

    selectionSort(C2,N);
    printData(C2,N);
    printAry(C1,C2,N);
}


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

using namespace std;

int main(void) {
	int array[32] = { 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 k;
	cin >> k;

	cout << array[k - 1];
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;

public class Main {
	static final int LEFT = 0;
	static final int RIGHT = 1;
	static final double[] eyeTable = { 1.1, 0.6, 0.2 };
	
	static int[][] numEye = new int[2][4];
	
	public static void main(String[] args) throws IOException{
		BufferedReader br = new  BufferedReader(new InputStreamReader(System.in));
		String buf = null;
		while((buf = br.readLine()) != null){
			String[] eye = buf.split(" ");
			String leftEyeClass = judgeEye(Double.parseDouble(eye[LEFT]));
			String rightEyeClass = judgeEye(Double.parseDouble(eye[RIGHT]));
			updateData(leftEyeClass, LEFT);
			updateData(rightEyeClass, RIGHT);
		}
		for(int i = 0; i < numEye[0].length; i++){
			System.out.println(numEye[LEFT][i] + " " + numEye[RIGHT][i]);
		}
	}
	
	private static void updateData(String eye, int side){
		switch(eye.charAt(0)){
		case 'A':
			numEye[side][0]++;
			break;
		case 'B':
			numEye[side][1]++;
			break;
		case 'C':
			numEye[side][2]++;
			break;
		case 'D':
			numEye[side][3]++;
			break;
		default:
			//DO NOTHING
		}
	}
	
	private static String judgeEye(double eye) {
		char eyeClass = 'D';
		for (int i = 0; i < eyeTable.length; i++) {
			if (eye >= eyeTable[i]) {
				eyeClass = (char) ((int) 'A' + i);
				break;
			}
		}
		return String.valueOf(eyeClass);
	}
}

Measured memory_bytes: 16948
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << endl;
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int N;
    cin >> N;

    vll A(N);
    REP(i, N) cin >> A[i];

    vll ans(N);
    ans[0] = 0;
    REP(i, N) {
        ans[0] += (i & 1 ? -1 : 1) * A[i];
    }

    FOR(i, 1, N){
        ans[i] = 2 * A[i - 1] - ans[i - 1];
    }

    REP(i, ans.size()) {
        if (i > 0) cout << " ";
        cout << ans[i];
    }
    print("");
    
}


Measured memory_bytes: 4700
/*#include<bits/stdc++.h>
using namespace std;
int n=0,m=0,e[10001][10001]={0},root=0,num[10001]={0},low[10001]={0},in=0,c=0;
int min(int a,int b)
{
	return a<b?a:b;
}
void dfs(int cur,int father)
{
	int i;
	in;
	num[cur]=in;
	low[cur]=in;
	for(i=1;i<=n;i++)
	{
		if(e[cur][i]==1)
		{
			if(num[i]==0)
			{
				dfs(i,cur);
				low[cur]=min(low[i],low[cur]);
				if(low[i]>num[cur])
					c++;
			}
			else
				if(i!=father)
				{
					low[cur]=min(low[cur],num[i]);
				}
		}
	}
	return ;
}
int main( )
{
	int i,j,x,y;
	cin>>n>>m;
	for(i=1;i<+n;i++)
		for(j=1;j<+n;j++)
			e[i][j]=0;
	for(i=1;i<=m;i++)
	{
		cin>>x>>y;
		e[x][y]=1;
		e[y][x]=1;
	}
	root=1;
	dfs(1,root);
	if(c==0)
		return 0;
	else
		cout<<c<<endl;
	getchar();getchar();
	return 0;
}
*/
#include<bits/stdc++.h>
using namespace std;
int n,m,sum,xi,Map[55][55],visit[55];
int main( )
{
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		visit[a]++;
		visit[b]++;
	Map[a][b]=Map[b][a]=1;
	}
	bool falg=true;
	while(1)
	{
	falg=true;
	for(int i=1;i<=n;i++)
	{
		if(visit[i]==1)
		{
			sum++;
			xi=i;
			falg=false;
			visit[i]--;
			break;
		}
	}
	if(falg)
		break;
	for(int i = 1;i<=n;i++)
	{
		if(Map[xi][i]==1)
		visit[i]--;
	}
	}
	cout<<sum<<endl;
}

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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;

// dp[i][j] := i個目からj個目までが残っている状態での X-Y
lli dp[3001][3001];
int main() {
    lli n;
    cin1(n);
    lli a[n+2] = {0};
    REP(i,0,n) {
        cin >> a[i+1];
    }

    REPE(i,1,n) {
        if ((n-1) % 2 == 0)
            dp[i][i] = a[i];
        else
            dp[i][i] = -a[i];
    }
    REP(i,1,n) {
        REPE(j,1,n-i) {
            // dp[j][j+i] を求める
            if((n-(i+1)) % 2 == 1) {
                dp[j][j+i] = min(dp[j+1][j+i] - a[j], dp[j][j+i-1] - a[j+i]);
            }
            else {
                dp[j][j+i] = max(dp[j+1][j+i] + a[j], dp[j][j+i-1] + a[j+i]);
            }
        }

    }
    //REPE(i,0,n) {
    //    REPE(j,0,n) {
    //        cout3(i, j, dp[i][j]);
    //    }
    //}
    cout << dp[1][n] << endl;
}


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

int main(){
    string S;cin >> S;
    string T;cin >> T;
    if(S[0]==T[2] && S[2]==T[0] && S[1]==T[1]) cout << "YES";
    else cout << "NO";
}

Measured memory_bytes: 256
import Data.Functor((<$>))

main :: IO ()
main = do 
        q  <- (read :: String -> Int).last.words <$> getLine
        xs <- map ((\[n, t] -> (n, (read :: String -> Int) t)).words).lines <$> getContents
        mapM_ (putStrLn.format) $ solve xs [] [] q 0
    where format (n, t) = n ++ (' ' : show t) 

solve                        :: [(String, Int)] -> [(String, Int)] -> [(String, Int)] -> Int -> Int -> [(String, Int)]
solve []            [] zs _ _   = reverse zs
solve []            ys zs q cnt = solve (reverse ys) [] zs q cnt
solve ((n, t) : xs) ys zs q cnt = let t'   = t - q
                                      cnt' = cnt + q
                                      m    = cnt' + t'
                                  in if t' > 0 then solve xs ((n, t') : ys) zs q cnt'
                                               else solve xs ys  ((n, m) : zs) q m

Measured memory_bytes: 35348
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll n,m,x,sum=0,t; cin>>n>>m>>x;
  rep(i,m){
   cin>>t;
    if(t<x) sum++;
    else break;
  }
  cout<<min(sum,m-sum)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>


using namespace std;


int main() {
    int num;
    cin >> num;
    bool output = false;
    int count = 0;
    for (int i = 0; i < num; i++) {
        int a1, a2;
        cin >> a1 >> a2;
        if (a1 == a2) {
            count++;
        }else {
            count = 0;
        }
        if (count == 3) {
            output = true;
        }
        
    }
    if (output) {
        cout << "Yes";
    }
    else {
        cout << "No";
    }

    return 0;
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
bool cmp(ll a,ll b){return a>b;}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
void fl(string name){
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
string s, t;
 
int main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	cin >> s >> t;
	cout << t << s << endl;
	return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define INF 100000005
#define MAX 100001
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);

int a[1000][4];
int b[302];
int main(){
	int x, y, z, n, t;
	while(1){
		scanf("%d%d%d", &x, &y, &z);
		if(!x&&!y&&!z)break;
		scanf("%d", &n);
		fill(b, b+302, 2);
		for(int i = 0;i < n;i++){
			scanf("%d%d%d%d", &a[i][0], &a[i][1], &a[i][2], &a[i][3]);
			if(a[i][3])b[a[i][0]] = b[a[i][1]] = b[a[i][2]] = 1;
		}
		for(int i = 0;i < n;i++){
			t = 0;
			if(a[i][3] == 0){
				rep(j,3)if(b[a[i][j]] == 1)t++;
				if(t == 2)rep(j,3)if(b[a[i][j]]==2)b[a[i][j]] = 0;
			}
		}
		rrep(i,x+y+z)printf("%d\n", b[i]);
	}
	return 0;
}

Measured memory_bytes: 3108
#include <iostream>

using namespace std;

int gcd(int a, int b){
  int mod = !0;
  while(mod != 0 ){
    mod = a % b;
    if (mod > b){
      a = mod;
    } else {
      a = b;
      b = mod;
    }
  }
  return a;
}
int main(int argc, char const *argv[]) {
  int x, y;
  cin >> x >> y;
  cout << gcd(x,y) << endl;
  return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int MOD = 1000000007;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int bin(string s){
    int n = s.size();
    int ans = 1;
    repp(i,n,1){
        if (s[i] == '0') ans = 2 * ans;
        else ans = 2 * ans + 1;
    }
    return ans;
}

int main(){
    int n, m; cin >> n >> m;
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main() {
    int h, w, d, a, q, l, r;
    int px[90010], py[90010], dist[90010] = {};
    cin >> h >> w >> d;
    rep(i, h) {
        rep(j, w) {
            cin >> a;
            px[a] = i;
            py[a] = j;
        }    
    }

    for(int i = d+1; i <= h*w; i++) {
        dist[i] = dist[i-d] + abs(px[i] - px[i-d]) + abs(py[i] - py[i-d]);
    }

    cin >> q;
    while(q--) {
        cin >> l >> r;
        cout << dist[r] - dist[l] << "\n";
    }

    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=(a),_ed=(b);i<=_ed;++i)
#define DREP(i,a,b) for(int i=(a),_ed=(b);i>=_ed;--i)
#define mp(x,y) make_pair((x),(y))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int,int> pii;
inline int read(){
    register int x=0,f=1;register char ch=getchar();
    while(!isdigit(ch)){if(ch=='-')f=0;ch=getchar();}
    while(isdigit(ch)){x=x*10+(ch^'0');ch=getchar();}
    return f?x:-x;
}

const int mod=998244353;
int n,k,fac[500005],ifc[500005];
inline int power(int b,int n){int ans=1;for(;n;n>>=1,b=1ll*b*b%mod)if(n&1)ans=1ll*ans*b%mod;return ans;}
inline int C(int n,int m){return (n<0||m<0||n<m)?0:1ll*fac[n]*ifc[m]%mod*ifc[n-m]%mod;}
inline void inc(int& x,int y){x=x+y<mod?x+y:x+y-mod;}

int main(){
	// freopen("in.in","r",stdin);
	int ___=500001;
	REP(i,fac[0]=1,___)fac[i]=1ll*fac[i-1]*i%mod;
	ifc[___]=power(fac[___],mod-2);
	DREP(i,___,1)ifc[i-1]=1ll*ifc[i]*i%mod;
	n=read(),k=read();
	int ans=0;
	REP(r,1,k){
		int b=k-r;
		if(r<b)continue;
		if(r==b)--b;//////////////////特判特判特判
		if(r>=n+b)inc(ans,C(r+b,r));
		else inc(ans,r>=n?(C(r+b,r)-C(r+b,r+(r-n)+1)+mod)%mod:0);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;

int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if((i < b && j < a) || (b <= i && a <= j)) cout << '0';
            else cout << '1';
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=int(a);i<=int(b);i++)
#define ROF(i,a,b) for(int i=int(b);i>=int(a);i--)
#define pb push_back
#define pq priority_queue
#define ps push
#define x first
#define y second
using namespace std;
int n,in[100010],dp[100010],anw;
int main(){
    cin>>n;
    FOR(i,1,n) cin>>in[i];
    ROF(i,1,n){
        if(i==n);
        else if(in[i]>=in[i+1]) dp[i]=dp[i+1]+1;
        anw=max(anw,dp[i]);
    }
    cout<<anw;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

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

    int N, K;
    cin >> N >> K;
    vector<int> pasta(N + 1, -1);
    rep(i, K) {
        int a, b;
        cin >> a >> b;
        b--;
        pasta[a] = b;
    }

    // dp[i][j][k] = pasta j (0-indexed) at day i (1-indexed), pasta k at day i - 1
    VVV dp(N + 1, VV(3, V(3, 0)));
    dp[0][0][0] = 1;
    const int mod = 10000;
    rep2(i, 1, N + 1) {
        rep(j, 3) {
            if (pasta[i] != -1 && j != pasta[i]) continue;
            rep(k, 3) {
                rep(l, 3) {
                    if (i >= 3 && j == k && k == l) continue;
                    (dp[i][j][k] += dp[i - 1][k][l]) %= mod;
                }
            }
        }
    }

    int ans = 0;
    rep(j, 3) {
        rep(k, 3) {
            (ans += dp[N][j][k]) %= mod;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3200
#include<stdio.h>//////////AOJ0037
                               int
i,j,w[5][5];char*p,b[1<<7];;   int
F(int(v)){scanf("%s",b);for(   p=b
;*p;++p                 ){w[   p-b
+1-v][j   +v]|=((w[p-   b][j   ]|=
(*p==49   )<<3-v)&8>>   v)>>   2;}
return(   j+=v          );/*   */}
main(){   for(   ;4-F   (0);   F(1
));for(   p=b,   i=j=   (*b=   3)^
3;i+=""   "BA"          "BC"   [*b
]-66,j=   (*b)["ABCB"]-66+j,   *++
p="ULDR   "[*b],i+j;)for((*    b+=
1)&=~4;                        !(w
[i][j]&(1<<*b));(*b+=3)&=3);return
!puts(b+1);}/*May2018,tw:@siikya*/



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

#define MOD 1000000007

int main(void){
    int N;
    std::cin >> N;
    std::vector<int> A(N);
    for(int i = 0; i < N; ++i) std::cin >> A[i];

    // 0 = red, 1 = blue, 2 = green
    // how many people
    int colors[3];
    for(int i = 0; i < 2; ++i){
        colors[i] = 0;
    }

    unsigned long long ret = 1;

    for(int i = 0; i < N; ++i){
        int sameColorCount = 0;
        bool alreadyFind = false;
        for(int j = 0; j < 3; ++j){
             if(colors[j] == A[i]){
                 if(!alreadyFind){
                     ++colors[j];
                     alreadyFind = true;
                 }
                 ++sameColorCount;
             }
        }

        ret = ret * sameColorCount % MOD;
    }

    std::cout << ret;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
 
//#define int long long
#define ll long long 
#define f(i,l,n) for(int i=l;i<n;i++)
#define E "\n"
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MAX 1e18
#define float long double
 
const int N=2e5+3;

#define pi 3.141592653590





int32_t main()
{
 
  


	int r;
	cin >> r;
	cout<<fixed<<setprecision(12)<<2*pi*r;
}


Measured memory_bytes: 3812
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;
 
int main()
{
  int n, *x, *y;
  double d_man, d_euc, d_cub, d_che;

  cin >> n;
  x = new int [n];
  y = new int [n];
  
  for(int i=0; i<n; i++){
    cin >> x[i];
  }
  for(int i=0; i<n; i++){
    cin >> y[i];
  }
  
  int dif;
  d_man = d_euc = d_cub = d_che = 0;
  for(int i=0; i<n; i++){
    dif = abs(x[i] - y[i]);
    d_man += dif;
    d_euc += pow(dif, 2.0);
    d_cub += pow(dif, 3.0);
    if(d_che < dif){
      d_che = dif;
    }
  }

  d_euc = sqrt(d_euc);
  d_cub = pow(d_cub, 1./3);
  
  cout << fixed
    << setprecision(5)
      << d_man << endl
        << d_euc << endl
          << d_cub << endl
            << d_che << endl;

  return(0);
}

Measured memory_bytes: 1324
import java.util.Scanner;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int count = 0;
    int sum = 0;
    int[] a = new int[n];
    for(int i = 0;i < n;i++){
      a[i] = sc.nextInt();
      sum += a[i];
    }
    double line  = ((double)sum / (4 * m));
    for(int j = 0;j < n;j++){
      if(a[j] >= line) count++;
    }
    if(m <= count){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23892
#include <stdio.h>
//#include <math.h>


int a[50];

int main(){
	int n,p;
	int i,j,k,l,m;
	int b;
	int ans;
	while(1){
		scanf("%d %d",&n,&p);
		if(n==0&&p==0)break;
		b=1;
		while(b){
			for(i=0; i<n; i++){
				if(p>0){
					p-=1;
					a[i]+=1;
				}
				else{
					for(j=0; j<n; j++){
						if(j!=i&&a[j]!=0)break;
						if(j==n-1){
							b=0;
							ans=i;
							break;
						}
					}
					p+=a[i];
					a[i]=0;
				}
				if(!b)break;
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 600