akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <array>
#include <cassert>

// BEGIN CUT HERE
#ifdef _MSC_VER
#include <agents.h>
#endif
// END CUT HERE 

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define MP make_pair
#define MT make_tuple

using namespace std;

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

string naive(int x, int k){
	string s = "0";
	int i = 1;
	while (s.size() <= x+k) s += to_string(i++);

	return s.substr(x, k);
}

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

	int n, k;
	while (cin >> n >> k, n){
	//k = 10;
	//for (n = 1; n <= 10000; ++n){
		ll cur = 1, len = 1, num = 9;

		while (cur + len * num <= n){
			cur = cur + len*num;
			len++;
			num *= 10;
		}

		ll ub = num, lb = 0;
		while (ub - lb > 1){
			ll mid = (ub + lb) / 2;
			if (cur + mid*len <= n) lb = mid;
			else ub = mid;
		}
		ll id = pow(10, len-1) + lb, pos = cur + len*lb;

		string str;
		for (int x = id; x <= id + 100; ++x) str += to_string(x);

		cout << str.substr(n - pos, k) << endl;
		//assert(str.substr(n - pos, k) == naive(n, k));
	}



	return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N, M;
    cin >> N >> M;
    bool check = true;
    map<ll, ll> count;
    loop(i, M)
    {
        ll x, y;
        cin >> x >> y;
        count[x]++;
        count[y]++;
    }
    loop(i, N)
    {
        if (count[i + 1] % 2 == 1)
            check = false;
    }
    if (check)
        putout("YES");
    else
        putout("NO");
    return 0;
}


Measured memory_bytes: 6528
import math
n, l = map(int, input().split())
fabs_lis = []
true_lis = []
for i in range(n):
    fabs_lis.append(math.fabs(i+l))
    true_lis.append(i+l)
index = fabs_lis.index(min(fabs_lis))
print(sum(true_lis)-true_lis[index])


Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>

using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> score;
	int a;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> a;
		score.emplace_back(a);
		ans += a;
	}
	sort(score.begin(), score.end());
	for (int i = 0; i < n; i++) {
		if (ans % 10 == 0) {
			ans -= score[i];
		}
		else {
			for (int j = i-1; j >= 0; j--) {
				if ((ans + score[j]) % 10 != 0) {
					ans += score[j];
				}
			}
			break;
		}
	}
	cout << ans << endl;
}



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

using namespace std;

int main(void)
{
    int N;
    cin >>N;
    int res = ((N*100-1)/108)+1;
    if(res*108/100==N){
        cout<<res<<endl;
    }
    else{
    cout<<":("<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(a) ((a).begin(), (a).end())
typedef long long ll;
// const long long INF = 1LL << 60;
const int INF = 1010101010;
// using Graph = vector<vector<int>>;
const int MOD = 1000000007;
vector<ll> cnt(1010);
int main() {
  long long n;
  cin >> n;
  for (long long i = 2; i <= n; ++i) {
    long long now = i;
    for (long long j = 2; j <= now; ++j)
      while (now >= 1 && now % j == 0) {
        ++cnt[j];
        now /= j;
      }
  }
  ll ans = 1;
  for (long long i = 0; i <= n; ++i)
    if (cnt[i] != 0) {
      ans *= cnt[i] + 1;
      ans %= 1000000007;
    }
  cout << ans << endl;
  return 0;
}

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

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

void b(int a,int count);

int main(){
  int n;
  cin >> n;
  Rep(i,n){
    string s;
    cin >> s;

    int d=1;
    string pre = s.substr(0,1);
    rep(j,1,s.size()){
      if(pre == s.substr(j,1) ) d++;
      else{
	int num = stoi(pre);
	b(num,d);
	pre = s.substr(j,1);
	d=1; 
      }
    }
    cout << endl;
  }
}

void b(int a,int count){
  if(a == 1){
    if(count%5==1) cout <<".";
    else if(count%5==2) cout <<",";
    else if(count%5==3) cout <<"!";
    else if(count%5==4) cout <<"?";
    else if(count%5==0) cout <<" ";

  }
  else if(a == 2){
    if(count%3==1) cout <<"a";
    else if(count%3==2) cout <<"b";
    else if(count%3==0) cout <<"c";
  }
  else if(a == 3){
    if(count%3==1) cout <<"d";
    else if(count%3==2) cout <<"e";
    else if(count%3==0) cout <<"f";
  }
  else if(a == 4){
    if(count%3==1) cout <<"g";
    else if(count%3==2) cout <<"h";
    else if(count%3==0) cout <<"i";
  }
  else if(a == 5){
    if(count%3==1) cout <<"j";
    else if(count%3==2) cout <<"k";
    else if(count%3==0) cout <<"l";
  }
  else if(a == 6){
    if(count%3==1) cout <<"m";
    else if(count%3==2) cout <<"n";
    else if(count%3==0) cout <<"o";
  }
  else if(a == 7){
    if(count%4==1) cout <<"p";
    else if(count%4==2) cout <<"q";
    else if(count%4==3) cout <<"r";
    else if(count%4==0) cout <<"s";
  }
  else if(a == 8){
    if(count%3==1) cout <<"t";
    else if(count%3==2) cout <<"u";
    else if(count%3==0) cout <<"v";
  }
  else if(a == 9){
    if(count%4==1) cout <<"w";
    else if(count%4==2) cout <<"x";
    else if(count%4==3) cout <<"y";
    else if(count%4==0) cout <<"z";
  }
  return;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <string.h>

int main(int argc, char *argv[])
{
    static char buf[200032];
    char *A, *Z;
    fgets(buf, sizeof(buf), stdin);
    A = strchr(buf, 'A');
    Z = strrchr(buf, 'Z');
    printf("%ld\n", Z-A+1);
    return 0;
}

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

int main() {
	int n,k;
	string s;
	cin >> n >> k >> s;
	for(int i = k - 1;i < k;i++)
	{
		char si;
		si = s.at(i);
		si = si + 32;
		s.at(i) = si;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e10;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n;
  cin >> n;
  vector<int> v(n);
  rep(i, n) cin >> v[i];
  bool f = true;
  rep(i, n - 1) if (v[i] != v[i + 1]) f = false;
  if (f) {
    cout << n / 2 << endl;
    return 0;
  }
  map<int, int> even, odd;
  rep(i, n) {
    if (i % 2 == 0)
      even[v[i]]++;
    else
      odd[v[i]]++;
  }
  vector<pair<int, int>> re, ro;
  for (auto x : even) re.push_back(make_pair(x.second, x.first));
  for (auto x : odd) ro.push_back(make_pair(x.second, x.first));
  sort(all(re));
  reverse(all(re));
  sort(all(ro));
  reverse(all(ro));
  if (re[0].second == ro[0].second) {
    cout << n - re[0].first - max(re[1].first, ro[1].first);
  } else {
    cout << n - re[0].first - ro[0].first << endl;
  }
  return 0;
}


Measured memory_bytes: 9592
import Data.List

winner :: [(Int,Int)] -> (Int,Int)
winner = foldl1' (\w c -> case snd w `compare` snd c of
                             GT -> w
                             LT -> c
                             EQ -> min c w
                )

main = do
    _ <- getLine
    getContents >>= putStrLn . (\(n,f) -> show n ++ " " ++ show f)
        . winner . map ( (\(n:f:_) -> (n,f)) . map read . words) . lines

Measured memory_bytes: 3840
#include<iostream>
#include<stdio.h>
using namespace std;

int main(){

	int a,b;
	cin >> a >> b;

	//cout << (a/b) <<" "<<(a%b)<<" "<<(a/b)<<endl;
	printf("%d %d %.5f\n", (a/b),(a%b),((double)a/b));

	return 0;
}


Measured memory_bytes: 3232
#line 2 "/home/defineprogram/Desktop/Library/template/template.cpp"
#include<bits/stdc++.h>
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define REP(i,n) for(ll i=1;i<n;i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define P pair<ll,ll>
#define len(s) (ll)s.size()
 
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;
}
constexpr ll inf = 3e18;
#line 2 "main.cpp"

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int K;cin>>K;
    rep(i,K)cout<<"ACL";
    cout<<"\n";
}


Measured memory_bytes: 3652
main(){
	int n,s,S,m,M,i;
	for(;scanf("%d",&n),n;){
		S=0;
		M=0;
		m=1000;
		for(i=0;i<n;i++){
			scanf("%d",&s);
			S+=s;
			if(s>M)
				M=s;
			if(s<m)
				m=s;
		}
		printf("%d\n",(S-m-M)/(n-2));
	}
	exit(0);
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dp[5005][5005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	for(int i = n-1; i >= 0; --i){
		for(int j = n-1; j >= 0; --j){
			if(s[i] == s[j]) dp[i][j] = dp[i+1][j+1] + 1;
		}
	}
	int ans = 0;
	for(int i = 0; i < n; ++i){
		for(int j = i+1; j < n; ++j){
			int cmp = min(dp[i][j], j-i);
			chmax(ans, cmp);
		}
	}
	cout << ans << endl;
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n-1; i >= 0; i--)
#define PER(i,n) for(int i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
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(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int n;
  cin >> n;
  vi a(n);
  rep(i,n) {
    cin >> a[i];
    a[i] -= i+1;
  }
  sort(all(a));
  int b = a[n/2];
  ll ans = 0;
  rep(i,n) {
    ans += max(a[i],b) - min(a[i],b);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import std.stdio;
import std.conv, std.array, std.algorithm, std.string;
import std.math, std.random, std.range, std.datetime;
import std.bigint;
import std.container;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

void main(){
	int hh = read.to!int;
	int ww = read.to!int;
	int h = read.to!int;
	int w = read.to!int;
	
	if(hh % h == 0 && ww % w == 0){
		writeln("No");
		return;
		}
	
	writeln("Yes");
	
	const long u = 10000;
	
	long[][] matrix;
	foreach(j; 0 .. hh){
		long[] row;
		foreach(i; 0 .. ww){
			long x = 0;
			if(i % w == w - 1) x += -(w - 1) * u - 1; else x += u;
			if(j % h == h - 1) x += -(h - 1) * u - 1; else x += u;
			row ~= x;
			}
		matrix ~= row;
		}
	
	debug matrix.writeln;
	foreach(row; matrix) writeln(row.map!(to!string).array.join(" "));
	
	}

/*

こんな感じ
（たとえば 11 1 5 1 の場合）

10000 10000 10000 10000 -40001; 10000 10000 10000 10000 -40001; 10000

これだと11が5でわりきれないからOK
※この場合の10000というのは、-1×2周期 よりも十分に大きいようにとる

縦も同様にやってたす


*/

Measured memory_bytes: 8572
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <string>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <bitset>
#include <cmath>
#include <algorithm>
#include <utility>
#include <iterator>
#include <sstream>
#include <fstream>
#include <functional>
#include <ctime>
#include <cassert>
#include <limits>

using namespace std;

#define SyncFalse ios::sync_with_stdio(0); cin.tie(0)
#define MEM(a, v) memset(a, v, sizeof(a))
#define CLRV(a, sz, v) a.clear(); a.resize(sz, v)
#define CLR(a, sz) a.clear(); a.resize(sz)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.end(), a.begin()
#define MP make_pair
#define FI first
#define SE second
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define SZ(a) (int)a.size()
#define LNG(a) (int)a.length()
#define LPI 3.141592653589793238462643383279502884L
#define SI(n) scanf("%d", &n)
#define SL(n) scanf("%lld", &n)
#define SD(n) scanf("%lf", &n)
#define SLD(n) scanf("%llf", &n)
#define SC(n) scanf(" %c", &n)
#define SS(n) scanf("%s", n)
#define FR(i, n) for (int i = 0; i < n; i++)
#define RFR(i, n) for (int i = n - 1; i >= 0; i--)
#define FR1(i, n) for (int i = 1; i <= n; i++)
#define RFR1(i, n) for (int i = n; i >= 1; i--)
#define FOREACH(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define endl '\n'

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<ld> VLD;
typedef vector<double> VD;
typedef vector<bool> VB;
typedef vector<char> VC;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef pair<int, int> PII;
typedef map<int, int> MII;
typedef map<string, int> MSI;
typedef vector<PII> VPII;
typedef vector<VPII> VVPII;

const double PI = acos(-1.0);
const double EPS = numeric_limits<double>::epsilon();
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const int MOD = (int) 1e9 + 7;

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

int main() {
	int a, b, c;
	SI(a), SI(b), SI(c);
	int ans = 0;
	while (ans < 1000000 && a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
		int ta = a, tb = b, tc = c;
		a = tb / 2 + tc / 2;
		b = ta / 2 + tc / 2;
		c = ta / 2 + tb / 2;
		ans++;
	}
	if (ans >= 1000000) {
		printf("-1\n");
	} else {
		printf("%d\n", ans);
	}
	return 0;
}

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

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

    /*
    for(ll i = a; i <= b; i++){
        ans *= i;
    }*/

    if(a > 0 && b > 0){ ans = 1;}
    else if(a <= 0 && b >= 0){
        ans = 0;
    }else if(a < 0 && b < 0){
        if((abs(a) - abs(b) + 1) % 2 == 0){ ans = 1;}
        else{ ans = -1;}
    }else if(a == 0 || b == 0){
        ans = 0;
    }

    if(ans > 0){
        cout << "Positive" << endl;
    }else if(ans < 0){
        cout << "Negative" << endl;
    }else{
        cout << "Zero" << endl;
    }

}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair < int, int > pii;
typedef unsigned long long ull;

const int N = int(5e5) + 5;
const int inf = (int)1e9 + 7;

int n;
deque < int > dq;

int main(){
  scanf("%d", &n);
  for(int i = 1; i <= n; ++i){
    int x;
    scanf("%d", &x);
    if(i % 2){
      dq.push_back(x);
    } else{
      dq.push_front(x);
    }
  }
  if(n % 2){
    reverse(dq.begin(), dq.end());
  }
  for(int i : dq){
    printf("%d ", i);
  }
  return 0;
}


Measured memory_bytes: 2944
a,b,c,d = map(int, input().split())
ans = [c-a,c-b,b-a]
for i in range(len(ans)):
    if ans[i]<0:
        ans[i]=ans[i]*-1
if ans[0]<=d or ans[1]<=d and ans[2]<=d:
    print("Yes")
else:
    print("No")


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

  int w,h,n;
  cin >> w >> h >> n;
  int xmi = 0,xma = w,ymi = 0,yma = h;
  REP(i,n) {
    int x,y,a;
    cin >> x >> y >> a;
    if (a == 1) {
      xmi = max(xmi,x);
    } else if (a == 2) {
      xma = min(xma,x);
    } else if (a == 3) {
      ymi = max(ymi,y);
    } else {
      yma = min(yma,y);
    }
  }
  cout << max(0,yma - ymi) * max(0,xma-xmi) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
using namespace std;
typedef long long ll;
int n,h[100005],men[100005];
int dp(int i){
  if(i==1)
    return 0;
  if(i<1) 
    return INF;
  if(men[i]!=-1)
    return men[i];
  int a1=dp(i-1)+abs(h[i-1]-h[i]);
  int a2=dp(i-2)+abs(h[i-2]-h[i]);
  return men[i]=min(a1,a2);
  }
int main(){
  cin>>n;
  memset(men,-1,sizeof(men));
  for(int i=1;i<=n;i++){
    cin>>h[i];
  }
  cout<<dp(n)<<'\n';
  return(0);
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int n,m;
    cin>>n>>m;
    n--,m--;
    cout<<n*m<<endl;

    return 0;
}


Measured memory_bytes: 3560
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

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

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define memo(a,val) memset(a,val,sizeof(a))
#define NINJA ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define all(a) a.begin(),a.end()
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define dloop(i,n) for(int i=n-1;i>=0;i--)
#define iii tuple<int,int,int>
#define vi vector<int>
#define ii pair<int,int>
#define vii vector<ii>
#define int long long
#define ld long double
#define pb push_back
#define endl "\n"
#define setbits __builtin_popcountll
#define mp map<int,int>
#define F first
#define S second
#define sz(v) (int)v.size()
#define mod 1000000007
#define inf (int)1e18

int32_t main(){
	NINJA;

	int n,x,t; cin >> n >> x >> t;

	int cnt = 0;
	int tot = 0;
	while(cnt < n){
		cnt += x;
		tot += t;
	}

	cout << tot << endl;
	
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
typedef long l;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  ll n; cin>>n;
  ll m=sqrt(n);
  ll max_x=-1;
  rep(i,m){
    if(i==0) continue;
    if(n%(i+1)==0) max_x=i+1;
  }
  if(max_x==-1){
    cout<<n-1<<endl;
    return 0;
  }
  ll max_y=n/max_x;
  ll ans=max_x+max_y-2;
  cout<<ans<<endl;
}


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

using namespace std;

int main(int argc, const char *argv[]) {
  string s;
  long long k;
  cin >> s >> k;
  if (s.size() == 1) {
    cout << k / 2 << '\n';
    return 0;
  }

  if (all_of(s.begin(), s.end(), [&](char ch) { return ch == s.front(); })) {
    cout << s.size() * k / 2 << '\n';
    return 0;
  }

  long long ans = 0, a, b;
  a = distance(s.begin(), find_if(s.begin(), s.end(),
                                  [&](char c) { return c != s.front(); }));
  b = distance(s.rbegin(), find_if(s.rbegin(), s.rend(),
                                   [&](char c) { return c != s.back(); }));

  int cur = 0;
  while (cur < s.size()) {
    int cnt = 1;
    while (cur + cnt < s.size() && s[cur] == s[cur + cnt]) {
      cnt++;
    }

    ans += cnt / 2;
    cur += cnt;
  }

  ans *= k;
  if (s.front() == s.back()) {
    ans -= (a / 2 + b / 2 - (a + b) / 2) * (k - 1);
  }

  cout << ans << '\n';

  return 0;
}


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


Measured memory_bytes: 2056
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using VVV = vector<VV>;
using VVVll = vector<VVll>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
#define rep2(i, m, n) for (int i = (m); i < (n); ++i)
#define drep2(i, m, n) for (int i = (m)-1; i >= (n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) (a).begin(), (a).end()
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline int sz(T &x) { return x.size(); }
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << '(' << p.first << ", " << p.second << ')'; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int fLog2(const int x) { assert(x > 0); return 31-__builtin_clz(x); } // floor(log2(x))
inline int fLog2(const ll x) { assert(x > 0); return 63-__builtin_clzll(x); }
inline int cLog2(const int x) { assert(x > 0); return (x == 1) ? 0 : 32-__builtin_clz(x-1); } // ceil(log2(x))
inline int cLog2(const ll x) { assert(x > 0); return (x == 1) ? 0 : 64-__builtin_clzll(x-1); }
inline int popcount(const int x) { return __builtin_popcount(x); }
inline int popcount(const ll x) { return __builtin_popcountll(x); }
void fail() { puts("-1"); exit(0); }
// const int INF  = 1<<30;
// const ll INFll = 1ll<<62;
// const ld EPS   = 1e-10;
// const ld PI    = acos(-1.0);
// const int MOD  = int(1e9)+7;
// const int MOD  = 998244353;


vector<pair<char, int>> RLE(string s) {
  vector<pair<char, int>> res = {{s[0], 1}};
  for (auto c : s.substr(1)) {
    if (res.back().first == c) ++res.back().second;
    else res.emplace_back(c, 1);
  }
  return res;
}


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

  string rs = s;
  reverse(all(rs));
  string t = s + rs;

  string cm(n, 'z');
  rep(i, n+1) chmin(cm, t.substr(i, n));

  if (k == 1) {
    cout << cm << '\n';
    return 0;
  }

  auto rle = RLE(cm);
  auto [c, l] = rle[0];
  int m = l;
  rep(i, k-1) {
    l *= 2;
    if (l >= n) break;
  }
  l -= m;
  chmin(l, n);

  string ans(l, c);
  ans += cm.substr(0, n-l);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3800
#include<stdio.h>
#include<stdlib.h>

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

#define mod 109
int cnt[mod];

int main(){
  int n;
  while(n = getInt()){
    int ans = -1;
    int i;
    const int n2 = n / 2;

    for(i = 0; i < mod; i++){
      cnt[i] = 0;
    }

    for(i = 0; i < n; i++){
      int a = getInt();
      int m = a % mod;
      if(++cnt[m] > n2){
	ans = a;
	for(++i; i < n; i++)
	  getInt();
      }
    }

    if(ans == -1)
      puts("NO COLOR");
    else
      printf("%d\n", ans);
  }
  return 0;
}

Measured memory_bytes: 372
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d" "%d", &a , &b);
    if((a+b)% 2 == 0){
    	printf("%d",(a+b)/2);    
    }
	else{    
    	printf("%d",(a+b)/2 + 1);    
    }      
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

LL n, a[100000];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL x = 0;
	inc(i, n) { x += (i % 2 == 0 ? +1 : -1) * a[i]; }
	
	inc(i, n) {
		cout << x << (i == n - 1 ? "\n" : " ");
		x = 2 * a[i] - x;
	}
	
	return 0;
}


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

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

map<int, int> O, E;

int main() {

	boost;
	int n; cin>>n;
	O[-1] = 0, E[-1] = 0;

	for(int i=1; i<=n; i++) {
		int v; cin>>v;
		if(i & 1) O[v]++;
		else E[v]++;
	}

	pii o1 = pii(-1, -1), o2 = pii(-1, -1);
	for(auto it : O) {
		pii pp = pii(it.se, it.fi);
		if(pp > o1) {
			o2 = o1;
			o1 = pp;
		}
		else if(pp > o2) {
			o2 = pp;
		}
	}

	pii e1 = pii(-1, -1), e2 = pii(-1, -1);
	for(auto it : E) {
		pii pp = pii(it.se, it.fi);
		if(pp > e1) {
			e2 = e1;
			e1 = pp;
		}
		else if(pp > e2) {
			e2 = pp;
		}
	}

	int ans = 0;

	if(o1.se != e1.se) {
		ans = n - o1.fi - e1.fi;
	}
	else {
		ans = min(n - o1.fi - e2.fi, n - o2.fi - e1.fi);
	}

	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 4992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
#define FOR(i, m, n) for(ll i = m; i < (n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vii = vector<vi>;
using pii = pair<int, int>; 
using vl = vector<ll>;
using vll = vector<vl>;
using pll = pair<ll, ll>;

int main() {
    ll A;
    string B;
    cin >> A >> B;
    ll D = 100*(B[0]-'0') + 10*(B[2]-'0') + B[3]-'0';
    ll ans = A*D/100;
    cout << ans;
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
	int a,b;
	while(cin>>a>>b){
		int list[150]={0};
		while(a){
			list[a]++;
			list[b]++;
			cin>>a>>b;
		}
		bool f = (list[1]%2)&&(list[2]%2);
		for(int i = 3; i < 150; i++){
			if(list[i]%2) f = false;
		}
		cout << (f?"OK":"NG")<<endl;
	}
}

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

class E { static void Main() => new J(); }
class J
{
	int F() => int.Parse(ReadLine());
	int[] G() => ReadLine().Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
	int MOD = 1000000007;
	public J()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G();
		int N = I[0], M = I[1];
		var es = new List<int>[N];
		for (var i = 0; i < N; i++) es[i] = new List<int>();
		for (var i = 0; i < M; i++)
		{
			I = G(); I[0]--; I[1]--;
			es[I[0]].Add(I[1]);
			es[I[1]].Add(I[0]);
		}
		var ans = new List<int>{ I[0] };
		var s = new HashSet<int>{ I[0], I[1] };
		while (true)
		{
			var u = ans.Last();
			var flag = false;
			foreach (var v in es[u])
				if (!s.Contains(v))
				{
					ans.Add(v);
					s.Add(v);
					flag = true;
					break;
				}
			if (!flag) break;
		}
		var ans2 = new List<int>{ I[1] };
		while (true)
		{
			var u = ans2.Last();
			var flag = false;
			foreach (var v in es[u])
				if (!s.Contains(v))
				{
					ans2.Add(v);
					s.Add(v);
					flag = true;
					break;
				}
			if (!flag) break;
		}
		ans2.Reverse();
		ans2.AddRange(ans);
		WriteLine(ans2.Count);
		WriteLine(string.Join(" ", ans2.Select(i => i + 1)));
	}
}

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

#define fi first
#define se second
#define SZ(x) (int)x.size()
#define ll long long
#define MP make_pair
#define pb push_back
#define pq priority_queue
#define pii pair<int,int>
#define mod 1000000007
#define inf 0x3f3f3f3f
#define debug(x) cerr<<#x<<"="<<x<<'\n'
#define rep(i,a,b) for (int i=a;i<(b);i++)

const int maxn=1e6;

int n,m;
ll fac[maxn],inv[maxn];

ll p0w(ll base,int p) {
	ll res=1;
	while (p) {
		if (p%2==1) res*=base,res%=mod;
		base*=base,base%=mod;
		p>>=1;
	}
	return res;
}

ll C(int x,int y) {
	return fac[x]*inv[y]%mod*inv[x-y]%mod;
}

int main(){
	std::ios::sync_with_stdio(false);
	cin>>n>>m;
	fac[0]=inv[0]=1;
	rep(i,1,maxn) fac[i]=fac[i-1]*(ll)i%mod,inv[i]=p0w(fac[i],mod-2);
	ll ans=C(m,n)*fac[n]%mod;
	ll tmp=0;
	ll op=1;
	for (int i=0;i<n;i++) {
		tmp+=C(m-i,n-i)*fac[n-i]%mod*C(n,i)%mod*op;
		if (tmp<0) tmp+=mod;
		tmp%=mod;
		op*=-1ll;
	}
	if (n%2==0) tmp++;
	else tmp+=mod-1;
	tmp%=mod;
	cout<<ans*tmp%mod;
	return 0;
}


Measured memory_bytes: 19216
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x << "  = " << x << endl
typedef long long int ll;
#define fast                      \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

#define dbg2(x, y)                                                       \
    {                                                                    \
        cout << #x << ": " << (x) << " , " << #y << ": " << (y) << endl; \
    }
#define fo(i, n) for (int i = 0; i < n; i++)
#define fok(i, k, n) for (int i = k; i < n; i++)
#define foA(i, A) for (auto i : A)
const int mxN=3001;
int n;
double a[mxN];
double dp[mxN][mxN];

double rfun(int ind, int nh){
    //dbg2(ind, nh);
    if(ind==n and nh==0)return 1.0;
    if((n-ind)<nh or nh<0 or ind>=n)return 0.0;
    if(dp[ind][nh]<-0.9)return dp[ind][nh];
    double an=0;
    //give head at this index
    an+=a[ind]*rfun(ind+1, nh-1);
    //say tails at this index
    an+=(1-a[ind])*rfun(ind+1, nh);
    //deb(an);
    return dp[ind][nh]=an;
}

int main(){
    cin>>n;
    fo(i, n)cin>>a[i];
    double ans=0;
    /*
    memset(dp, -1, sizeof dp);
    for(int nh=n;(nh>(n/2));nh--){
        ans+=rfun(0, nh);
    }*/
    memset(dp, 0 ,sizeof dp);
    dp[0][0]=1;
    for(int nh=0;nh<=n;nh++){
        for(int j=1;j<=n;j++){
            if(j<nh)continue;
            if(nh==0){
                dp[nh][j]=dp[nh][j-1]*(1-a[j-1]);
            }
            else dp[nh][j]=dp[nh][j-1]*(1-a[j-1])+dp[nh-1][j-1]*(a[j-1]);
        }
    }
    for(int nh=(n/2+1);nh<=n;nh++){
        ans+=dp[nh][n];
    }
    cout<<fixed<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 74168
#include <bits/stdc++.h>
using namespace std;
int main() {
	long double A = 0, B= 0, C = 0, D = 0;
	cin >> A >> B >> C;
	D = sqrt(A * B);
	if(A + B + 2 * D < C){
    	cout << "Yes" << endl;
    } else {
    	cout << "No" << endl;
    }
}


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

int main() {
    int N; 
    int sum = 0;
    int ans = 100000000;
    cin>>N;
    vector<int> X(N, 0);
    REP(i, 0, N){
        cin>>X[i];
    }
    REP(P, 0, 100){
        sum = 0;
        REP(i, 0, N){
            sum += pow(X[i]-P, 2);
        }
        if(sum < ans){
            ans = sum;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

MOD = 1000000007

a = 0
b = 0
for i in range(N):
    a += A[i] % MOD
    b += (A[i] ** 2) % MOD
a = a ** 2
ans = (a - b) * pow(2, MOD - 2, MOD) % MOD
print(ans)

Measured memory_bytes: 94252
/*
       Creator - Glitched
       Yeet!!
    */

    #include "bits/stdc++.h"

    using namespace std;
    #define testcases ll t;cin>>t;while(t--)
    #define queries ll q;cin>>q;while(q--)
    #define ll long long
    #define loop(i,x,n) for(ll i=x;i<n;i++)
    #define ff first
    #define ss second
    #define pb push_back
    #define elif else if
    #define flush cout<<"\n"
    #define mod 1000000007
    #define fastio ios_base::sync_with_stdio(false);

    int main()
    {
        long long n,x,sum=0;
        cin>>n>>x;
        std::vector<ll> v(n);

        loop(i,0,n){
            cin>>v[i];            
        }

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


        loop(i,0,n-x){
            sum+=v[i];
        }
        cout<<sum;
        flush;

        
    }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007 

bool a[101][101];
bool H[101],W[101];
int main() {
	ll h,w;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char b;
			cin>>b;
			if(b=='#'){
				a[i][j]=1;
			}
		}
	}
	for(int i=0;i<h;i++){
		bool flag=true;
		for(int j=0;j<w;j++){
			if(a[i][j]==1){
				flag=false;
				break;
			}
		}
		if(flag){
			H[i]=true;
		}
	}
	for(int i=0;i<w;i++){
		bool flag=true;
		for(int j=0;j<h;j++){
			if(a[j][i]==1){
				flag=false;
				break;
			}
		}
		if(flag){
			W[i]=true;
		}
	}
	for(int i=0;i<h;i++){
		if(H[i]){
			continue;
		}
		for(int j=0;j<w;j++){
			if(W[j]){
				continue;
			}
			if(a[i][j]==1){
				cout << "#";
			}
			else{
				cout << ".";
			}
		}
		cout << endl;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n; cin >> n;
    auto func = [&](int num){ 
        int cnt = 0;
        while(num){
            num /= 10;
            cnt++;
        }
        return cnt & 1;
    };
    int ans = 0;
    for(int i = 1; i <= n; i++){
        ans += func(i);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 256
from math import gcd, sqrt
from functools import reduce

n, *A = map(int, open(0).read().split())
def f(A):
    sup = max(A)+1
    table = [i for i in range(sup)]
    for i in range(2, int(sqrt(sup))+1):
        if table[i] == i:
            for j in range(i**2, sup, i):
                table[j] = i

    D = set()
    for a in A:
        while a != 1:
            if a not in D:
                D.add(a)
                a //= table[a]
            else:
                return False
    return True

if reduce(gcd, A) == 1:
    if f(A):
        print('pairwise coprime')
    else:
        print('setwise coprime')
else:
    print('not coprime')

Measured memory_bytes: 232224
import fractions
A, B, C, D = map(int, input().split())
a = B - A + 1
b = (B//C) - ((A-1)//C)
c = (B//D) - ((A-1)//D)
d = C*D//fractions.gcd(C,D)
dd = (B//d) - ((A-1)//d)
print(a-b-c+dd)





Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

const double INF = 10000000;

typedef complex<double> P;

int main(){
    int n;
    double r;
    while(cin >> r >> n, r||n){
        double p[41] = {0};
        rep(i,n){
            double left, right, h;
            cin >> left >> right >> h;
            left+=20; right+=20 - 1;
            for(int j = left; j <= right; j++){
                p[j] = max(p[j],h);
            }
        }
        rep(i,40) if(p[i] == INF) p[i] = 0;

        P c = {20.0, -r};
        double mini = INF;
        auto pow = [](double a){return a * a; };
        rep(i,40){
            //if(i < 17 || 22 < i) continue;

            if(not (i > 20 - r && i < 20 + r)) continue;
            mini = min(mini, min(p[i], p[i - 1]) + r - sqrt(pow(r) - pow(i - 20)));
            //show(min(p[i],p[i - 1]))
            //show(sqrt(pow(r) - pow(i - 20)))
            //show(r)
            //show(mini)
            //if(i == 0){
            //    P tmp = {static_cast<double>(i), 0};
            //    mini = min(mini, abs((abs(c - p[i]) - r) * sin(arg(c / p[i]))));
            //}else if(i == n - 1){
            //    P tmp = {static_cast<double>(i), 0};
            //    mini = min(mini, abs((abs(c - p[i]) - r) * sin(arg(c / p[i]))));
            //}else{
            //    P tmp = {static_cast<double>(i),min(p[i - 1], p[i])};
            //    show(p[i])
            //    show(tmp)
            //    double dist = abs(c - tmp) -r;
            //    show(dist)
            //    mini = min(mini, abs((abs(c - tmp) - r) * sin(arg(c / tmp))));
            //}
        }
        cout << fixed << setprecision(4) << mini << endl;
    }
}

Measured memory_bytes: 3280
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 200000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;
LL a[N];
int main() {
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    LL res=0;
    while(true){
        LL maxx=a[1];
        int pos=1;
        for(int i=2;i<=n;i++){
            if(a[i]>maxx){
                maxx=a[i];
                pos=i;
            }
        }

        if(maxx<=n-1)
            break;

        for(int i=1;i<=n;i++){
            if(i==pos)
                a[i]=maxx%n;
            else
                a[i]+=maxx/n;
        }
        res+=(maxx/n);
    }
    printf("%lld\n",res);
    return 0;
}


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

using namespace std;

int main() {
    int X;
    cin >> X;
    for(int i=-120; i<=120; i++) {
        for(int j=-120; j<=120; j++) {
            if(i*i*i*i*i - j*j*j*j*j==X) {
                printf("%d %d\n", i, j);
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3728
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define int long long
#define PI 3.14159265358979l
signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a, b)<<" ";
    if (a + b - n <= 0)cout << 0 << endl;
    else cout << a + b - n << endl;
}

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

#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()
#define CERR if(false) cerr
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;

typedef long long ll;

string int2str(int n){
    vector<char> tmpv;

    if(n == 0){
        return "0";
    }else{

        while(n > 0){
            tmpv.pback('0' + (n % 10));
            n = n / 10;
        }

        reverse(ALL(tmpv));
        string tmp;

        rep(i, tmpv.size()){
            tmp = tmp + tmpv[i];
        }

        return tmp;

    }
}

int digit(int n){

    if(n == 0) return 1;

    int ans = 0;

    while(n > 0){
        n = n / 10;
        ans++;
    }

    return ans;
}

int main(){

    int n,m;
    cin >> n >> m;

    vector<pair<int,int>> v;

    rep(i, m){
        int s,c;
        cin >> s >> c;

        v.pback(mpair(s,c));
    }

    bool check = true;

    for(int i = 0; i < 1000; i++){

        if(digit(i) == n){

            string tmpn = int2str(i);

            bool ans = true;

            rep(j, m){
                int tmps, tmpc;
                tmps = v[j].first;
                tmpc = v[j].second;

                if(tmpn[tmps - 1] != ('0' + (tmpc))){
                    ans = false;
                    break;
                }
            }

            if(ans){
                cout << tmpn << endl;
                check = false;
                break;
            }

        }
    }

    if(check){
        cout << "-1" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
line = gets.split(' ').map(&:to_i)

a = line[0]
b = line[1]
c = line[2]

s1 = (c - a - b) ** 2 - 4 * a * b
s2 = c - a - b

if s1 > 0 and s2 > 0 then
  print "Yes"
else
  print "No"
end

Measured memory_bytes: 3836
#include <stdio.h>
#include <string.h>

int main(void)
{
	char yey[10001];
	int a, ans;
	int check;
	int len;
	ans = 0;
	
	while (scanf("%s", yey) != EOF) {
		check = 0;
		len = strlen(yey);
		for (a = 0; a < len; a++) {
			if (yey[a] >= '0' && yey[a] <= '9') {
				check = (check * 10) + (yey[a] - '0');
			}
			else {
				ans += check;
				check = 0;
			}
		}
		ans += check;
	}
	
	printf("%d\n", ans);
	
	return (0);
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int n,d,x,ans=0;
    cin>>n>>d>>x;
    vector<int> a(n);
    ans=n+x;
    d--;
    for(int i = 0; i < n; i++)
    {
        cin>>a[i];
        ans+=d/a[i];
    }
    
    cout<<ans<<endl;

    return 0;
}

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

int N,T,A;

int H[1010];
double Ave[1010];


int solve(){
	int ans = 0;
	for(int i=1;i<N;i++){
		if(abs(A - Ave[i]) < abs(A - Ave[ans])){
			ans = i;
		}
	}
	ans+=1;
	cout << ans << endl; 
	return 0;
}



int main(){
	cin >> N;
	cin >> T >> A;
	for(int i=0;i<N;i++){
		cin >> H[i];
		Ave[i] = T-H[i]*0.006;
	}
	solve();
	return 0;
}

Measured memory_bytes: 256