akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;

namespace Frog2
{
	class Program
	{
		static void Main(string[] args)
		{
			var line = Console.ReadLine();
			var lineSplited = line.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);

			var N = int.Parse(lineSplited[0]);
			var K = int.Parse(lineSplited[1]);
			var H = new List<int>();

			var line2 = Console.ReadLine();
			var line2Splited = line2.Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries);
			foreach (var token in line2Splited) {
				H.Add(int.Parse(token));
			}

			var cost = new Cost(N, K, H);
			Console.WriteLine(cost.getCost(N-1));
		}

		class Cost
		{
			List<int> costs;
			int N, K;
			List<int> H;

			public Cost(int N, int K, List<int> H)
			{
				this.K = K;
				this.N = N;
				this.H = H;

				costs = new List<int>();
				for (int i = 0; i < N; i++) {
					costs.Add(int.MaxValue);
				}
			}

			public int getCost(int i)
			{
				if (costs[i] < int.MaxValue) return costs[i];

				if (i == 0) return costs[0] = 0;

				var cost = int.MaxValue;
				
				for (int k = 0; k < K && k < i; k++) {
					var _ = getCost(i - (k + 1)) + Math.Abs(H[i] - H[i - (k + 1)]);
					cost = cost > _ ? _ : cost;
				}

				return costs[i] = cost;
			}
		}
	}
}

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

int main(){
  long long K,ans=0;
  cin >> K;
  
  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        ans += gcd(a,gcd(b,c));
      }
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n,x,cnt=0;
  cin >> n >> x;
  int a[101];
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a,a+n);
  for(int i=0; i<n; i++){
    if(i == n-1 && a[i] < x){
      break;
    }
    if(a[i] <= x){
      x -= a[i];
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iomanip>
#include <iostream>

using namespace std;

int main(int argc, char const *argv[]) {

  int n;
  cin >> n;
  double *p = new double[n];
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }

  double **dp = new double *[n + 1];
  for (int i = 0; i <= n; i++) {
    dp[i] = new double[n + 1];
  }
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      dp[i][j] = 0;
    }
  }

  dp[0][0] = 1.0;
  for (int i = 0; i < n; i++) {
    dp[i + 1][0] = dp[i][0] * (1.0 - p[i]);
    for (int j = 0; j < n; j++) {
      dp[i + 1][j + 1] = dp[i][j + 1] * (1.0 - p[i]) + dp[i][j] * p[i];
    }
  }

  double ans = 0.0;
  for (int i = (n + 1) / 2; i <= n; i++) {
    ans += dp[n][i];
  }

  cout << setprecision(10) << ans << endl;

  for (int i = 0; i <= n; i++) {
    delete[] dp[i];
  }
  delete[] dp;
  return 0;
}


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

int main(void){
  int w,h,f;
  char c;
  cin >> w >> h >> c;
  
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      f=0;
      f |= (j==0 || j==w-1);
      f |= (i==0 || i==h-1)<<1;
      if (i*2+1==h && j*2+1==w) cout << c;
      else cout << ".|-+"[f];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3108
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>inline bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>inline bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
int in(){int a;scanf("%d",&a);return a;}
ll lin(){ll a;scanf("%lld",&a);return a;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int n, m;
string s, t;
int dp[2][2002][2002];
bool S[2002], T[2002];

int rec(int I, int a, int b) // I := ???I????????????, a := s??????????????????, b := t??????????????????
{
    int &res = dp[I][a][b];

    if (~res) return res;

    res = 0;
    
    if (a < m && I != S[a]) {
        chmax(res, 1 + rec(S[a], a + 1, b));
    }

    if (b < n && I != T[b]) {
        chmax(res, 1 + rec(T[b], a, b + 1));
    }

    return res;
}

int main()
{
    m = in(), n = in();
    cin >> s >> t;

    rep(i, m) S[i] = s[i] == 'I';
    rep(i, n) T[i] = t[i] == 'I';

    memset(dp, -1, sizeof dp);

    int ma = 0;

    rep(i, m) rep(j, n) {
        chmax(ma, rec(S[i], i+1, j) + S[i]);
        chmax(ma, rec(T[j], i, j+1) + T[j]);
    }

    printf("%d\n", ma == 0 ? 0 : (ma - (ma % 2 == 0)));
}

Measured memory_bytes: 34964
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repr(i,a,b) for(int i=a,i > b;--i)
#define mm(lamb, tttt) memset(lamb, tttt, sizeof lamb)

#define null NULL
#define eps 0.000000001
#define mod 1000000007
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define sz(V) (ll)V.size()
#define _ <<" "<<

#include <iostream>
#include <fstream>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <iterator>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <limits.h>
#include <iomanip>
#include <cctype>
#include <numeric>
#include <complex>

using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef pair <double, double> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<int> vii;

int h,w,n;
vi a(10004,0);
int board[100][100];

int main(){
	cin>>h>>w>>n;
	rep(i,0,n) cin>>a[i];
	
	int curr_col=0;
	int currcntr=0;
	for(int i=0;i<h;i++){
		if(i%2==0){
			for(int j=0;j<w;j++){
				if(currcntr < a[curr_col]){
					board[i][j]=curr_col;
					currcntr++;
				}
				else{
					curr_col++;
					currcntr=1;
					board[i][j]=curr_col;
				}
			}
		}
		else{
			for(int j=w-1;j>=0;j--){
				if(currcntr < a[curr_col]){
					board[i][j]=curr_col;
					currcntr++;
				}
				else{
					curr_col++;
					currcntr=1;
					board[i][j]=curr_col;
				}
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cout<<++board[i][j]<<" ";
		}cout<<endl;
	}
}


Measured memory_bytes: 384
(defn abc123-A
  "return whether all antennas could talk to each other"
  [xs k]
  (let [min (reduce #(Math/min %1 %2) xs)
        max (reduce #(Math/max %1 %2) xs)]
    (<= (- max min) k)))
(defn main-abc123-A []
  (let [xs (doall (for [_ (range 5)] (read)))
        k (read)]
    (if (abc123-A xs k)
     (println "Yay!")
     (println ":("))))
(main-abc123-A)


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

template <class T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N;
  string S;
  cin >> N >> S;
  int ans = 0;
  int count = 0;
  for(int i = 0; i < N; ++i) {
    if(S[i] == 'I') {
      count++;
    } else if(S[i] == 'D') {
      count--;
    }
    chmax(ans, count);
  }
  cout << ans << endl;

  return 0;
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}

int main() {
	ll i, n, m, k, c = 0, sum = 0;
	c_p_c();
	ll no;

	cin >> n >> m;
	vector<pair<ll,ll>> v;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		ll a,b;
		cin>>a>>b;
		v.pb(make_pair(a,b));
	}
	sort(all(v));
	for (int i = 1; i < n; ++i)
	{
		/* code */
		v[i].S+=v[i-1].S;
	}


	// for(auto it : v)
	// 	cout<<it.F<<" "<<it.S<<endl;


	for (int i = 0; i < n; ++i)
	{
		if(v[i].S>=m)
		{
			cout<<v[i].F<<endl;
			return 0;
		}
	}


	return 0;
}



Measured memory_bytes: 5372
#include <bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
const int maxn=2e5+1;
typedef pair<int,int> pii;

int n,a[maxn],res;
vector<pii>ans;

void solve1(int l,int r){
	while(a[r-1]>0){
		ans.pb(mp(a[l],a[r]));
		a[l]=a[l]-a[r];
		r--;
	}
	int pos=r;r--;
	while(r>=l){
		ans.pb(mp(a[pos],a[r]));
		a[pos]=a[pos]-a[r];
		r--;
	}
	res=a[pos];
}

void NET(){
	res=a[2]-a[1];
	ans.pb(mp(a[2],a[1]));
}

void solve3(){
	ans.pb(mp(a[1],a[2]));
	a[2]=a[1]-a[2];
	solve1(2,n);
}

void solve2(){
	ans.pb(mp(a[n],a[n-1]));
	a[n-1]=a[n]-a[n-1];
	solve1(1,n-1);
}

int main(){
	cin>>n;
	for (int i=1;i<=n;++i)
	cin>>a[i];
	sort(a+1,a+1+n);
	if (n==2) NET();
	else if (a[1]<0&&a[n]>0) solve1(1,n);
	else if (a[n]<=0) solve2();
	else solve3();
	printf("%d\n",res);
	for (auto v:ans)
	printf("%d %d\n",v.fr,v.sc);
} 

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;

ll mod_pow(ll a,ll b){
	a%=mod;
	if(b==0)return 1;
	if(b==1)return a;
	ll res=mod_pow(a,b/2)%mod;
	res*=res; res%=mod;
	if(b%2)res*=a;
	return res%mod;
}


template<typename T>
map<T,ll> factorize(T x){
	map<T,ll> res;
	for(ll i=2;i*i<=x;i++){
		while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	map<int,int> mp;
	int n; cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
		auto m=factorize(a[i]);
		for(auto p:m){
			mp[p.first]=max((int)mp[p.first],(int)p.second);
		}
	}
	ll k=1;
	for(auto p:mp){
		k*=mod_pow(p.first,p.second);
		k%=mod;
	}
	ll ans=k%mod;
	ll cnt=0;
	for(int i=0;i<n;i++){
		(cnt+=mod_pow(a[i],mod-2))%=mod;
	}
	cout << ans*cnt%mod << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) begin(obj), end(obj)
#define RALL(obj) rbegin(obj), rend(obj)
#define fi first
#define se second
using ii = pair<int, int>;
vector<ii> dirs = {
  {1, 0}, {0, 1}, {-1, 0}, {0, -1},  // 4方向
  {1, 1}, {-1, 1}, {-1, -1}, {1, -1},  // 斜め
  {0, 0},  // 自身
};
template <class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }

// debug
template <class T> ostream& operator<<(ostream& s, vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream& s, vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream& s, pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
  #define endl "\n"
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }

struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1000000007;
// *************** TEMPLATE END *************** 

signed main() {
  vector<int> a(5); REP (i, 5) cin >> a[i];
  int k; cin >> k;
  cout << (a.back() - a.front() > k ? ":(" : "Yay!") << endl;
}


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

#define int long long

auto main() -> signed {
    int a, b;
    cin >> a >> b;
    if(a+b<10) cout << a+b << endl;
    else cout << "error" << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv){vprint(v)};

template<typename A, typename B>
struct pair_hash{
    inline size_t operator()(const pair<A, B> &p) const{
        const auto h1 = hash<A>()(p.first);
        const auto h2 = hash<B>()(p.second);
        return h1^(h2<<18);
    }
};

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

    ll N;
    cin >> N;
    vll x(N), y(N);
    rep(i, N) cin >> x[i] >> y[i];

    unordered_map<pair<int, int>, pair<int, int>, pair_hash<int, int>> par;
    rep(i, N) par[{x[i], y[i]}] = {x[i], y[i]};
    function<pair<int, int>(pair<int, int>)> root = [&](pair<int, int> p){
        if(par[p]==p) return p;
        return par[p] = root(par[p]);
    };
    function<void(pair<int, int>, pair<int, int>)> unite = [&](pair<int, int> p1, pair<int, int> p2){
        auto r1 = root(p1);
        auto r2 = root(p2);
        if(r1!=r2) par[r1] = r2;
    };

    vll xs(100001, 0), ys(100001, 0);
    rep(i, N){
        if(xs[x[i]]>0) unite({x[i], xs[x[i]]}, {x[i], y[i]});
        else xs[x[i]] = y[i];
        if(ys[y[i]]>0) unite({ys[y[i]], y[i]}, {x[i], y[i]});
        else ys[y[i]] = x[i];
    }

    ll ans = 0;
    map<pair<ll, ll>, set<pair<ll, ll>>> m;
    for(auto p : par){
        m[root(p.second)].insert(p.first);
    }
    for(auto p : m){
        auto s = p.second;
        unordered_set<ll> xs, ys;
        for(auto t : s){
            xs.insert(t.first);
            ys.insert(t.second);
        }
        ll n = xs.size() * ys.size() - s.size();
        ans += n;
    }
    cout << ans << endl;
}


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

int main(){
    int a,b;
    cin>>a;
    cin>>b;
    if (a>=13){
        cout<<b<<endl;
    }
    else if (a>=6){
         cout<<b/2<<endl;
    }
    else{
        cout<<0<<endl;
    }
return 0;  
}

Measured memory_bytes: 256
#include<algorithm>
#include <iostream>
#include <math.h>
#include <cstdio>
#include <string.h>
using namespace std;
int main(void){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d||(abs(a-b)<=d&&abs(c-b)<=d))cout<<"Yes\n";
	else cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
//const int MODINF = 1000000007;
using namespace std;

int main(){
    int H, W, D, Q;
    cin >> H >> W >> D;
    vector<vector<int>> A(H, vector<int>(W));
    vector<pair<int, int>> pa(W * H);
    rep(i, 0, H){
        rep(j, 0, W){
            cin >> A.at(i).at(j);
            pa.at(A.at(i).at(j) - 1) = make_pair(i, j);
        }
    }
    cin >> Q;
    vector<int> L(Q), R(Q);
    rep(i, 0, Q){
        cin >> L.at(i) >> R.at(i);
    }
    vector<int> S_cost(H * W);
    for (int k = 0; k < D; k++){
        int fin = H * W - k;
        int num = (fin + D - 1) / D;
        S_cost.at(fin - 1) = 0;
        for (int j = 1; j < num; j++){
            int x_1 = pa.at(fin - D * (j - 1) - 1).second;
            int y_1 = pa.at(fin - D * (j - 1) - 1).first;
            int x_0 = pa.at(fin - D * j - 1).second;
            int y_0 = pa.at(fin - D * j - 1).first;
            int cost = abs(x_1 - x_0) +abs(y_1 - y_0);
            S_cost.at(fin - D * j - 1) = S_cost.at(fin - D * (j - 1) - 1) + cost;
        }
    }
    rep(i, 0, Q){
        cout << S_cost.at(L.at(i) - 1) - S_cost.at(R.at(i) - 1) << endl;
    }
}


Measured memory_bytes: 3328
#include <cstdio>
using namespace std;

int main(int argc, char** argv)
{
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i=0; i<m; i++)
	{
		int x;
		scanf("%d", &x);
		if((n -= x) < 0)
		{
			puts("-1");
			return 0;
		}
	}
	printf("%d\n", n);
	return 0;
}

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

int A[101010];

int main() {
    memset(A, 0, sizeof(A));
    REP2(i, 1, 1001) {
        int tmp = i;
        REP2(j, i+1, 1001) {
            tmp += j;
            if (tmp <= 1000) A[tmp] += 1;
        }
    }

    while (1) {
        int N; cin >> N;
        if (N == 0) break;
        cout << A[N] << endl;
    }

    return 0;
}

Measured memory_bytes: 3396
#include<iostream>

class Circle{
public:
	Circle()
		: m_x(0)
		, m_y(0)
		, m_r(0)
	{}
	int m_x;
	int m_y;
	int m_r;
};

int range(int l,int p, int r){
	int a = p - r;
	int b = p + r;
	if (a < 0)
		return 1;
	if (b > l)
		return 1;
	return 0;

}

int main(){
	int h, w;
	Circle c;
	int flag = 0;
	std::cin >> w;
	std::cin >> h;
	std::cin >> c.m_x;
	std::cin >> c.m_y;
	std::cin >> c.m_r;
	if (range(w, c.m_x, c.m_r))
		flag = 1;
	if (range(h, c.m_y, c.m_r))
		flag = 1;
	if (flag == 1)
		std::cout << "No" << '\n';
	else
		std::cout << "Yes" << '\n';

}

Measured memory_bytes: 1124
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
using namespace std;
typedef long long int ll;
static const int MAX_H = 50;
static const int MAX_W = 50;

int H, W;
int map[MAX_H][MAX_W];
int dp[MAX_H + 1][MAX_W + 1];

int main(void){
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			char c;
			cin >> c;
			if(c != '\n') map[i][j] = c - '0';
		}
	}
	dp[0][0] = 0;
	for(int i = 1; i < H; i++) dp[i][0] = dp[i - 1][0] + map[i][0];
	for(int j = 1; j < W; j++) dp[0][j] = dp[0][j - 1] + map[0][j];
	for(int i = 1; i < H; i++){
		for(int j = 1; j < W; j++){
			dp[i][j] = min(dp[i][j - 1], dp[i - 1][j]) + map[i][j];
		}
	}
	cout << dp[H - 1][W - 1] << endl;
	return 0;
}

Measured memory_bytes: 3096
import math
n, d = map(int, input().split())
l = [list(map(int, input().split())) for i in range(n)]
count = 0
for i in range(len(l)):
    for j in range(i+1, len(l)):
        s = 0
        for k in range(d):
            s += (l[i][k] - l[j][k])**2
        s = math.sqrt(s)
        if s.is_integer():
            count += 1
print(count)

Measured memory_bytes: 3064
a=[]
for i in range(3):
  tmp=list(map(int, input().split()))
  a.append(tmp)
import numpy as np
A=np.array(a)

n=int(input())

for i in range(n):
  b=int(input())
  idx=np.where(A==b)
  if idx:
    A[idx]=0

yoko=0 in A.sum(axis=1)
tate=0 in A.sum(axis=0)
naname1=A[0,0]+A[1,1]+A[2,2]
naname2=A[0,2]+A[1,1]+A[2,0]

if yoko or tate or naname1*naname2==0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 12488
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_asc(const void* a, const void* b) {
    return *((size_t*)a) < *((size_t*)b) ? -1 : 1;
}

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_i64_asc(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_i64_desc(const void* a, const void* b) {
    return *((int64_t*)a) > * ((int64_t*)b) ? -1 : 1;
}

int compare_c_asc(const void* a, const void* b) {
    return *((char*)a) < *((char*)b) ? -1 : 1;
}

int compare_c_desc(const void* a, const void* b) {
    return *((char*)a) > * ((char*)b) ? -1 : 1;
}

static size_t powSz(const size_t base, const size_t exp) {
    if (exp == 0) {
        return 1;
    }

    if (exp == 1) {
        return base;
    }

    if (exp % 2 == 0) {
        return powSz(base * base, exp / 2);
    }
    else {
        return base * powSz(base, exp - 1);
    }
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static int64_t a[100000];

int main(void) {
    size_t n;

    scanf("%zu\n", &n);
    for (size_t i = 0; i < n; i++) {
        scanf("%"PRId64, &a[i]);
    }

    size_t cnt[2] = { 0,0 };
    int64_t base[2] = { 1,-1 };
    int64_t sum[2] = { 0,0 };

    for (size_t i = 0; i < n; i++) {
        sum[0] += a[i];
        sum[1] += a[i];

        int64_t additionalMove[2] = { 0,0 };

        if (!((base[0] < 0 && sum[0] < 0) || (0 < base[0] && 0 < sum[0]))) {
            additionalMove[0] = base[0] - sum[0];
        }
        if (!((base[1] < 0 && sum[1] < 0) || (0 < base[1] && 0 < sum[1]))) {
            additionalMove[1] = base[1] - sum[1];
        }

        sum[0] += additionalMove[0];
        sum[1] += additionalMove[1];

        cnt[0] += (size_t)ABS(additionalMove[0]);
        cnt[1] += (size_t)ABS(additionalMove[1]);

        base[0] = -base[0];
        base[1] = -base[1];
    }

    printf("%zu", MIN(cnt[0], cnt[1]));

    return 0;
}


Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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


int main() {
  long n;
  cin >> n;
  long l1, l2;
  l1 = 2;
  l2 = 1;
  long ans = 0;
  if (n == 1) {
    P(1);
    return 0;
  }
  rep (i, n - 1) {
    ans = l1 + l2;
    l1 = l2;
    l2 = ans;
  }
  P(ans);
  return 0;
}

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

#define ll long long
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define pii pair<int, int>

using namespace std;

int solve();

#define TASK ""

int main()
{
    #ifdef DEBUG
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif // DEBUG
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}

const int MAXN = 2001;

bool dp[2001][20001];
int p[2001][20001];

int solve()
{
    int n, s;
    cin >> n >> s;
    dp[0][0] = 1;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= s / 1000; j++)
        {
            if (dp[i - 1][j - 1])
            {
                dp[i][j] = 1;
                p[i][j] = 1;
            }
            if (j >= 5 && dp[i - 1][j - 5])
            {
                dp[i][j] = 1;
                p[i][j] = 5;
            }
            if (j >= 10 && dp[i - 1][j - 10])
            {
                dp[i][j] = 1;
                p[i][j] = 10;
            }
        }
    int cnt1 = 0, cnt2 = 0, cnt3 = 0;
    if (!dp[n][s / 1000])
    {
        cout << -1 << " " << -1 << " " << -1 << endl;
        return 0;
    }
    int cur = s / 1000; int ind = n;
    while (ind != 0)
    {
        if (p[ind][cur] == 1)
            cnt1++;
        if (p[ind][cur] == 5)
            cnt2++;
        if (p[ind][cur] == 10)
            cnt3++;
        cur -= p[ind][cur];
        ind--;
    }
    cout << cnt3 << " " << cnt2 << " " << cnt1 << endl;
}


Measured memory_bytes: 193792
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int N;
    cin >> N;
    
    vector<int> b(N);
    REP(i, N) cin >> b[i];

    stack<int> ans;

    while(b.size() != 0) {
        int tmp = b.size();
        for (int i = b.size()-1; i >= 0; i--) {
            if (b[i] == i+1) {
                ans.push(b[i]);  
                b.erase(b.begin() + i);
                break;
            }
        }
        if (tmp == b.size()) {
            cout << -1 << endl;
            return 0;
        }
    }
    
    for(int i = 0; i < N; i++) {
        cout << ans.top() << endl;
        ans.pop();
    }

    return 0;
}

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

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





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

class abc124_C
{
    static void Main(string[] args)
    {
        var QS = Console.ReadLine();
        var differCount = 0;
        for(var i=0; i<QS.Length; i++) {
            if((i%2==0) == (QS[i] == '0')) {
                differCount++;
            }
        }

        var result = Math.Min(differCount, QS.Length - differCount);
        Console.WriteLine(result);
    }
}

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

using namespace std;

typedef long long ll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main()
{
    ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
    int n,m,k,g[305][305],cnt=0,ans[305][305];
    string str;
    cin>>n>>m>>k;
    for(int i=0;i<n;i++)
    {
        cin>>str;
        for(int j=0;j<m;j++)
            g[i][j]=(str[j]=='#');
    }
    memset(ans,0,sizeof ans);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            if(g[i][j])
            {
                cnt++;
                for(int k=0;k<=j;k++)
                    ans[i][k]=cnt;
                for(int k=j+1;k<m;k++)
                {
                    if(g[i][k])
                        cnt++;
                    ans[i][k]=cnt;
                }
                break;
            }
        }
    }
    for(int i=1;i<n;i++)
        for(int j=0;j<m;j++)
            if(ans[i][j]==0&&ans[i-1][j]!=0)
                ans[i][j]=ans[i-1][j];
    for(int i=n-2;i>=0;i--)
        for(int j=0;j<m;j++)
            if(ans[i][j]==0&&ans[i+1][j]!=0)
                ans[i][j]=ans[i+1][j];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
            cout<<ans[i][j]<<" \n"[j==m-1];
    return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  rep(ki, k) {
    vector<int> b(n + 1);
    rep(i, n) {
      int l = max(0, i - a[i]);
      int r = min(i + a[i] + 1, n);
      b[l]++;
      b[r]--;
    }
    rep(i, n) b[i + 1] += b[i];
    b.pop_back();
    if (a == b) break;
    a = b;
  }
  rep(i, n) cout << a[i] << endl;
  return 0;
}

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

int main() {
string S;
cin>>S;
int c=-1,f=-1;
for(int i=0;i<S.size();i++){
  if(c==-1&&S[i]=='C') c=i;
  if(S[i]=='F') f=i;
}
if(c!=-1&&f!=-1&&c<f) cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 3580
import java.util.Scanner;
class Main{
           public static void main(String args[]){
                 Scanner sc = new Scanner(System.in);
                 String a = sc.next();
                 String b = sc.next();
                 StringBuffer c = new StringBuffer(b);
                 String d = new String(c.reverse());
                 if (a.equals(d)) {
                   System.out.println("YES");
                        }
                 else{
                   System.out.println("NO");
                   }
           }
}


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

#define fi first
#define se second
#define ll long long

const int N = 200200;

using namespace std;

int n;
int a[N];
set < pair < pair < int, int >, int > > s;

bool can(int m)
{
        s.clear();
        s.insert({{1, a[1]}, 1});
        for(int i = 2; i <= n; i++){
                if((--s.end())->fi.se < a[i]){
                        s.insert({{(--s.end())->fi.se + 1, a[i]}, 1});
                        continue;
                }
                while((--s.end())->fi.se > a[i]){
                        if((--s.end())->fi.fi > a[i]){
                                s.erase(--s.end());
                                continue;
                        }
                        auto p = *(--s.end());
                        s.erase(--s.end());
                        p.fi.se = a[i];
                        s.insert(p);
                }
                if((--s.end())->se < m){
                        auto p = *(--s.end());
                        s.erase(--s.end());
                        if(p.fi.fi != p.fi.se){
                                s.insert({{p.fi.fi, p.fi.se - 1}, p.se});
                        }
                        p.fi.fi = p.fi.se;
                        p.se += 1;
                        s.insert(p);
                        continue;
                }
                int L = (--s.end())->fi.fi;
                int R = (--s.end())->fi.se;
                s.erase(--s.end());
                while(!s.empty() && (--s.end())->se == m){
                        L = (--s.end())->fi.fi;
                        s.erase(--s.end());
                }
                if(s.empty()){
                        return false;
                }
                {
                        auto p = *(--s.end());
                        s.erase(--s.end());
                        if(p.fi.fi != p.fi.se){
                                s.insert({{p.fi.fi, p.fi.se - 1}, p.se});
                        }
                        p.fi.fi = p.fi.se;
                        p.se += 1;
                        s.insert(p);
                }
                s.insert({{L, R}, 1});
        }
        return true;
}

int main()
{
        ios_base::sync_with_stdio(0);

        //freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);

        cin >> n;
        int can1 = 1;
        for(int i = 1; i <= n; i++){
                cin >> a[i];
                if(i > 1 && a[i - 1] >= a[i]){
                        can1 = 0;
                }
        }
        if(can1){
                cout << 1 << "\n";
                return 0;
        }
        int l = 2, r = n;
        while(l < r){
                int m = (l + r) / 2;
                if(can(m)){
                        r = m;
                } else{
                        l = m + 1;
                }
        }
        cout << l << "\n";
}


Measured memory_bytes: 8104
#include <bits/stdc++.h>
#define ll long long
#define MAX 105

using namespace std;

ll a[MAX];

int main()
{
//    ios_base::sync_with_stdio(false);
//    cin.tie(0);
	ll n;
	ll i;
	cin >> n;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		if(a[i]%2==0){
			if(a[i]%3==0||a[i]%5==0){
				continue;
			}
			else{
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)

typedef long long int ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef pair<string,string> Pstring;
typedef pair<double,double> Pdouble;



int main() {
  string s;
  cin >> s;
  ll n= s.size();
  string s1 = s.substr(0,(n-1)/2);
  string s2 = s.substr((n+3)/2-1);
  bool flag = true;
  REP(i,s.size()){
    ll id = s.size()-1-i;
    if(s.at(i) != s.at(id)){
      flag = false;
    }
  }
  REP(i,s1.size()){
    ll id = s1.size()-1-i;
    if(s1.at(i) != s1.at(id)){
      flag = false;
    }
  }
  REP(i,s2.size()){
    ll id = s2.size()-1-i;
    if(s2.at(i) != s2.at(id)){
      flag = false;
    }
  }

  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define F first
#define S second
#define int long long
#define mod 1000000007
#define mmod 998244353
#define all(v) v.begin(), v.end()
#define INF LLONG_MAX/3
using namespace std;
int mypow(int a, int b, int c) {
	if (b == 0)return 1;
	if (b % 2)return mypow(a, b - 1, c)*a%c;
	int z = mypow(a, b / 2, c);
	return z * z%c;
}
signed main() {
	double s;
	cin >> s;
	printf("%.100lf", s*s*s / 27);
}


Measured memory_bytes: 256
#include<stdio.h>

 int main(){
     int W,H,x,y,r;
     scanf("%d%d%d%d%d",&W,&H,&x,&y,&r);
     if(x+r<=W && y+r<=H && x-r>=0 && y-r>=0)printf("Yes\n");
     else printf("No\n");
     }


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

#define REP(i, n) for(int i = 0; i < (int)n; ++i)

using namespace std;

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

    int r;
    cin >> r;
    cout << 3 * r * r << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int W[10],K[10];
int wmax,kmax;
int main(){	  
	for(int i=0;i<10;i++)
		std::cin>>W[i];
	for(int i=0;i<10;i++)
		std::cin>>K[i];
	std::sort(W,W+10);
	std::sort(K,K+10);
	wmax=W[9]+W[8]+W[7];
	kmax=K[9]+K[8]+K[7];
	std::cout<<wmax<<" "<<kmax<<std::endl;
}

Measured memory_bytes: 1180
N = int(input())
B = [int(x) for x in input().split()]
ans = [0]*(N)
if N==2:
  print(int(B[0])*2)
  exit()
for i in range(1,N-1):
  ans[i] = min(B[i-1],B[i])
ans[0] = B[0]
ans[N-1] = B[N-2]
print(sum(ans))

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

class Program
{
    static void Main(string[] args)
    {
        var x = sc.ReadLong();
        long ans = 0;
        if (x % 11 == 0)
        {
            ans = x / 11 * 2;
        }
        else
        {
            ans = (x / 11 * 2) + 1;
            if (x % 11 > 6)
            {
                ans++;
            }
        }
        Console.WriteLine(ans);
    }

    static int MOD = (int)1e9 + 7;
    static int INF = (int)1e7 + 1;
    static long LINF = (long)1e13 + 1;
    static Scanner sc = new Scanner();
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }
    public string ReadStr()
    {
        return this.Next();
    }
    public char ReadChar()
    {
        return this.Next()[0];
    }
    public int ReadInt()
    {
        return int.Parse(this.Next());
    }
    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }
    public long ReadLong()
    {
        return long.Parse(this.Next());
    }
    public double ReadDouble()
    {
        return double.Parse(this.Next());
    }
    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }
    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }
    public double[] ReadDoubleArray(int n)
    {
        var array = new double[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadDouble();
        }
        return array;
    }
    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }
    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



Measured memory_bytes: 11220
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut ans = usize::max_value();
    for i in 1..n {
        if i * i > n {
            break;
        }
        if n % i != 0 {
            continue;
        }
        ans = min(ans, i + n / i - 2);
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi(i,a,b) for (int i=a; i<=b; ++i)
#define fid(i,a,b) for (int i=a; i>=b; --i)
#define pp pair<int,int>
#define f first
#define s second
#define DAVu "Grid1"
#define maxn 1005
#define mod 1000000007
using namespace std;
int n, l[maxn][maxn],m, a[maxn][maxn] ;
int main()
{
    ios_base::sync_with_stdio(0) ;
    cin.tie(NULL); cout.tie(NULL) ;
    //freopen(DAVu".inp", "r", stdin) ;
    //freopen(DAVu".out", "w", stdout) ;
    cin >> n >> m ;
    fi(i,1,n)
    fi(j,1,m){
        char st ;
        cin >> st ;
        if(st == '.') a[i][j] = 0 ;
        else a[i][j] = 1 ;
    }
    fi(i,1,n)
    fi(j,1,m)
        if(i == 1 && j == 1) l[i][j] = 1 ;
        else if(a[i][j] == 0) {
            l[i][j] = l[i][j-1]+l[i-1][j] ;
            l[i][j]%=mod ;
        }
    cout << l[n][m]%mod ;
}


Measured memory_bytes: 11424
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = list(map(int, readline().split()))

    for y in x:
        if x.count(y) == 1:
            print(y)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61796
#include "stdio.h"
int main(void)
{
	int num[10000],i,j,k,tmp;
	for(i=0;;i++){
		scanf("%d",&num[i]);
		if(i%2 != 0){
			if(num[i]==0 && num[i-1]==0){
				tmp = i;
				break;
			}
		}
	}
	for(i=0;i<tmp-1;i++){
		for(j=0;j<num[i];j++){
			for(k=0;k<num[i+1];k++){
				if( (j+k)%2 == 0)
					printf("#");
					else
					printf(".");	
			}
			printf("\n");
		}
		printf("\n");
		i++;
	}
	return 0;
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split().Select(i => Convert.ToInt32(i)).ToArray();
            int N = input[0];
            int D = input[1];
            int onePerson = 2 * D + 1;
            int res = (N + onePerson - 1) / onePerson;
            Console.WriteLine(res);
        }
    }
}


Measured memory_bytes: 13268
/*
	@・ω・@ <だれだろうね
*/

/*****/

#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <iomanip>	//cout << fixed << setprecision(桁数);
#include <stdexcept>

//#define int long long

using namespace std;
using ll = long long;
using ld = long double;
using vecll = vector<long long>;
using pll = pair<long long, long long>;
template<class T> using pr = pair<T, T>;
template<class T> using vec = vector<T>;

#define debug(x) (std::cerr << x << "\n")
#define debug_tab(n, x) (std::cerr << strMulti("\t",n) << (x) << "\n")
#define debug_cout(x) (std::cerr << #x << " : " <<  (x) << "\n")
#define debug_tabcout(n, x) (std::cerr << strMulti("\t",n) << #x << " : " <<  (x) << "\n")
#define debug_headcout(h, x) (std::cerr << h << " : " <<  (x) << "\n")
#define debug_tabheadcout(n, h, x) (std::cerr << strMulti("\t",n) << h << " : " <<  (x) << "\n")

#define str(n)	(n.toString())

#define rep(i, n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i, n) for(ll i=(n)-1; i >= 0; --i)
#define rrep1(i, n) for(ll i=(n); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pair(a, b) make_pair(a, b)
constexpr int INF = 2000000100;
constexpr ll MOD = 1000000007;	// 10e9+7
template<class T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> T divup(T a, T b) { if (a % b == 0) { return a / b; } return a / b + 1; }
std::string strMulti(std::string t, int n) { std::string out = ""; for (int i = 0; i < n; i++) { out += t; } return out; }
template<class T> T math_P(T m, T n) { T ret = 1; for (T i = m; i > m - n; i--) { ret *= i; } return ret; }
template<class T> T math_C(T m, T n) { T ret = math_P(m, n); for (T i = 2; i <= n; i++) { ret /= i; } return ret; }
template<class T> bool cmp_2nd(pair<T, T> a, pair<T, T> b) { if (a.second != b.second) { return a.second < b.second; } return a.first < b.first; }
template<class T> T mod_pow(T x, T n, const T& p) { T ret = 1; while (n > 0) { if (n & 1) { (ret *= x) %= p; } (x *= x) %= p; n >>= 1; } return ret; }

/*****/



void Main()
{
	string S;
	cin >> S;

	cout << (S[2] == S[3] && S[4] == S[5] ? "Yes" : "No");
}

/*****/

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

	std::cout << std::fixed << std::setprecision(10);

	/*
	while (true)
	{
		Main();
		cout << endl;
	}
	//*/

	Main();
	cout << /** endl /*/ flush /**/;

	return 0;
}


Measured memory_bytes: 256