akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define m_p make_pair
#define sz(x) (int)x.size()
#define out(x) cerr<<#x<<" = "<<x<<" "
#define outln(x) cerr<<#x<<" = "<<x<<endl
#define outarr(x,l,r) cerr<<#x"["<<l<<"-"<<r<<"] = "; for (int _i=l;_i<=r;++_i) cerr<<x[_i]<<" ";cerr<<endl;
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned int ui;
#define gc() getchar()
//char buf[1<<23],*p1=buf,*p2=buf;
//#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <class T> void read(T &x)
{
    x=0; char c=gc(); int flag=0;
    while (c<'0'||c>'9') flag|=(c=='-'),c=gc();
    while (c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=gc();
    if (flag) x=-x;
}
template <class T> T _max(T a,T b){return a>b ? a : b;}
template <class T> T _min(T a,T b){return a<b ? a : b;}
template <class T> bool checkmax(T &a,T b){return b>a ? a=b,1 : 0;}
template <class T> bool checkmin(T &a,T b){return b<a ? a=b,1 : 0;}
const int N=200005;
int n,a[N],m;
void init()
{
	read(n); read(m);
	for (int i=1;i<=n+n;++i) 
	{
		read(a[i]);
	}
	sort(a+1,a+n+n+1);
}

bool check(int mid)
{
	for (int i=1;i<=n-mid;++i)
	{
		if (a[mid+mid+i]+a[n+n+1-i]<m) 
		{
			return 0;
		}
	}
	return 1;
}

void solve()
{
	int l=0,r=n,mid,best=-1;
	while (l<=r)
	{
		mid=(l+r)/2;
		if (check(mid))
		{
			best=mid;
			r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	int ans=0;
	for (int i=1;i<=best;++i)
	{
		checkmax(ans,(a[i]+a[best+best+1-i])%m);
	}
	for (int i=1;i<=n-best;++i)
	{
		checkmax(ans,(a[best+best+i]+a[n+n+1-i])%m);
	}
	printf("%d\n",ans);
}

#undef int
int main()
{
	init();
	solve();
    return 0;
}


Measured memory_bytes: 4392
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1e9 + 10;//10^9
ll MOD  = 1000000007;
int dy[] = {0,0,1,-1};
int dx[] = {1,-1,0,0};

int k[11][11];
int main(void){
    int N,M;
    cin >> N >> M;
    for(int i = 0; i < M; i++){
        int x;
        cin >> x;
        for(int j = 0; j < x; j++){
            int s;
            cin >> s;
            k[i][s] = 1;
        }
    }
    
    
    vector<int> p(M);
    for(int i = 0; i < M; i++) cin >> p[i];
    
    ll ans = 0;
    for(int i = 0; i < pow(2, N); i++){
        vector<int> S(N);
        int I = i;
        for(int j = 0; j < N; j++){
            if(I % 2 == 1){
                S[j] = 1;
            }else{
                S[j] = 0;
            }
            I /= 2;
        }
        bool l = 1;
        for(int j = 0; j < M; j++){
            int cnt = 0;
            for(int m = 0; m < N; m++){
                if(k[j][m+1] && S[m]){
                    cnt++;
                }
            }
            if(cnt % 2 != p[j]) l = 0;
        }
        if(l) ans ++;
        
        
    }
    cout << ans << endl;
    
}



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

typedef int i32;
typedef long long i64;
typedef unsigned int u32;
typedef unsigned long long u64;


template<typename First, typename Second, typename Third>
struct triple {
   First first;
   Second second;
   Third third;
};


#define debug(x)  cerr<<x<<"\n";
#define loop(i,n) for(i32 i = 0; i < n; ++i)
#define pi  pair<i32,i32>
#define ti  triple<i32,i32,i32>
#define mk  make_pair
#define vi  vector<i32>
#define vll vector<i64>
#define fastInOut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pr(a) for(auto x:a) cout<<x<<" ";
#define prmap(m) for(auto x:m) cout<<x.first<<" "<<x.second<<"\n";
using namespace std;

bool isPrime(i64 x){
	
	for(i64 i=2;i*i<=x;i++)
		if(x%i==0)
			return false;
	return true;
}

vi V;
const i32 N=7e7+9;
bool prime[N]; 
void SieveOfEratosthenes(){ 
    for (int  p=2; p*p<=N; p++){ 
        if (prime[p] == false){ 
            for (int  i=p*p; i<=N; i += p) 
                prime[i] = true; 
        } 
    } 
    int u=0,mx=0;
    for (int p=2; p<=N; p++){ 
      if (!prime[p]) {
          V.push_back(p);
      }
    }
   
}

i64 n,d,c;
int main(){
    fastInOut
    cin>>n>>d;
    cout<<ceil((double)n/d);         
    return 0;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
double a[5],dp[301][301][301];
int n;
double expected_turns(double c3,double c2, double c1)
{
	double n1 = n;
	if(!(c3 || c2 || c1))
	{
		return 0;
	}
	if(dp[int(c3)][int(c2)][int(c1)]!=-1)
	{
		return dp[int(c3)][int(c2)][int(c1)];
	}
	double a=0;
	if(c3>0)
	{
		a = (c3/n1) *(1 + expected_turns(c3-1,c2+1,c1));
	}
	if(c2>0)
	{
		a += (c2/n1) *(1 + expected_turns(c3,c2-1,c1+1));

	}
	if(c1>0)
	{
		a += (c1/n1) *(1 + expected_turns(c3,c2,c1-1));
	}
	double d = (n1-c1-c2-c3);
	a += (double)d/n1;
	a /= (1-d/n1);

	dp[int(c3)][int(c2)][int(c1)] = a;
	return a;


}
int main()
{
	int x;
	cin>>n;
	for (double i = 0; i < n; ++i)
	{
		cin>>x;
		a[x]++;
	}
	for (int i = 0; i < 301; ++i)
	{
		for(int j = 0; j < 301 ;j++)
		{
			for (int v = 0; v < 301; ++v)
			{
				dp[i][j][v] = -1;
			}
		}
	}
	printf("%.10f\n", expected_turns(a[3],a[2],a[1]));


	
	return 0;
}

Measured memory_bytes: 213376
ss = list(input())
ss = [int(ii) for ii in ss]
nn = len(ss)
bw = list()
wb = list()
while True:
    if len(bw)+2<=nn:
        bw.append(0)
        bw.append(1)
        wb.append(1)
        wb.append(0)
        continue
    elif len(bw)+1==nn:
        bw.append(0)
        wb.append(1)
        continue
    else:
        break

counter_bw = 0
counter_wb = 0
for ii in range(nn):
    if ss[ii] == bw[ii]:
        counter_bw += 1
    if ss[ii] == wb[ii]:
        counter_wb += 1

answer = min(counter_bw, counter_wb)
print(answer)

Measured memory_bytes: 6680
#include <iostream>

using namespace std;

int main()
{
	int n, m;
	cin >> n >> m;
	int a;
	int sum = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		sum += a;
	}

	cout << (sum > n ? -1 : n - sum) << endl;

	return 0;
}


Measured memory_bytes: 3676
/*		     ___
			(._.)
			<|>         HELLO IT'S ME! KINGSLEY ZHONG!
			_/\_
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          ___   ____
        /' --;^/ ,-_\     \ | /
       / / --o\ o-\ \\   --(_)--
      /-/-/|o|-|\-\\|\\   / | \
       '`  ` |-|   `` '
             |-|
             |-|O                    2020 @ CodeForces, CodeChef, CCC & More!
             |-(\,__
          ...|-|\--,\_....
      ,;;;;;;;;;;;;;;;;;;;;;;;;,.
~~,;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;,  ______   ---------   _____     ------
 */


//Optimisation
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)\
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")\
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")


//Imports
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <map>
#include <string>
#include <stack>
#include <set>
#include <sstream>
#include <queue>
#include <vector>

using namespace std;

//Macros
#define el '\n'
#define elc << el;
#define debug(x) cout << ">>" << x << el;
#define rep(i, c) for(int i = 0; i <(c); ++i)
#define fora(i, s, c) for(int i = (s); i < (c); ++i)
#define forr(i, s, c) for(int i = (s); i > (c); --i)
#define pb push_back
#define eb emplace_back
#define ff first;
#define ss second;
#define mp make_pair;
#define all(p) p.begin(),p.end()
#define max(x,y) (x>y)?x:y
#define min(x,y) (x<y)?x:y
#define mid(s,e) (s+(e-s)/2)
#define absv(a) (a<0)?(-1*a):a
#define negv(a) (a>0)?(-1*a):a
#define arrset(a,b,v) rep(i, b) a[i]=v //Sets array to a value, where a is the array, b is the count, and v is the value

//Typedefs
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;

//Random Stuff
#define Pi 3.141592653589793
#define space << ' ' <<
const ll mod = 1000000007;

//Functions
inline int twop(int n) { return 1 << n; }
template<class T> T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<class T> T lcm(T a, T b ){return (a*b)/gcd(a,b);}

//Testcase start
#define tcs() int testcases; cin >> testcases; while(testcases--)

int main() {
	//Fast io for cin / cout
	ios_base::sync_with_stdio(false);
	cin.tie(0); //Comment out if there is large exchange of cin / cout
	cout.tie(0);

	//USE FOR TESTCASE PROBLEMS
	ll n , m;
	cin >> n >> m;

	cout << n*(n-1)/2+m*(m-1)/2 << el;


	return 0;
}


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

int main() {
  int N,Y,k;
  vector <int> count(3);
  bool result = false;
  cin>>N>>Y;
  
  Y /= 1000;

  for (int i = 0; i <= N; i++)
  {
    for (int j = 0; j <=N-i; j++)
    {
      k=N-i-j;
      if(Y == 10*i+5*j+k){
        result = true;
        count.at(0)=i;
        count.at(1)=j;
        count.at(2)=k;
      }
      if(result==true)break;
    }
    if(result==true)break;
  }
  
  if(result==true)cout<<count.at(0)<<" "<<count.at(1)<<" "<<count.at(2)<<endl;;
  if(result==false)cout<<-1<<" "<<-1<<" "<<-1<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <complex>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::to_string;
using std::vector;
using std::set;
using std::queue;
using std::priority_queue;

using std::min;
using std::max;
using std::sort;
using std::abs;

int div2(int n) {
    int cnt = 0;
    while (n % 2 == 0) {
        n /= 2;
        cnt++;
    }
    return cnt;
}

int main(void) {
    int n;
    cin >> n;

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

    int m = div2(a[0]);
    for(int i = 0; i < n; i++){
        m = min(m, div2(a[i]));
    }

    cout << m << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main()
{
  int n;
  cin >> n;
  int num[60][26] = {};
  for (int i = 0; i < n; ++i)
  {
    string s;
    cin >> s;
    for (int j = 0; j < s.size(); ++j)
    {
      num[i][s[j] - 'a']++;
    }
  }
  string ans = "";
  for (int i = 0; i < 26; ++i)
  {
    int cnt = 100;
    for (int j = 0; j < n; ++j)
    {
      cnt = min(cnt, num[j][i]);
    }
    for (int j = 0; j < cnt; ++j)
    {
      ans += char(i + 'a');
    }
  }

  cout << ans << endl;

  return 0;
}


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

#define FASTIO  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ll long long int
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vl(p) vector<p>
#define w while
#define For(i,s,x) for(i=s;i<x;i++)
#define Fore(i,s,x) for(i=s;i<=x;i++)
#define FOR(i,x) for(i=0;i<x;i++)
#define Rof(i,s,x) for(i=s;i>=x;i--)
#define all(v) v.begin(),v.end()
#define it(r,v) for(auto r=v.begin();r!=v.end();r++)
#define pb push_back
#define in insert
#define sz size()
#define F first
#define S second
#define nl cout<<"\n"
#define pr(a) cout<<a<<" "
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define pr3(a,b,c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define mod 1000000007
int main()
{
    FASTIO;
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0)
    {
        c=c-b;
        if(c<=0)
        {
            cout<<"Yes"<<"\n";
            break;
        }
        a=a-d;
        if(a<=0)
        {
            cout<<"No"<<"\n";
            break;
        }
    }
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
#include <sys/types.h>
#include <unistd.h>

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

const pid_t pid = getpid();
// Problem Specific Parameter:

const int offset = 300;
char board[600][600];
int hsum[610][610];
int vsum[610][610];
using B = bitset<610>;

int main(void){
	int h,w;
	cin >> h >> w;

	const int n = 601;
	rep(i,n)rep(j,n) board[i][j] = '.';

	rep(y,h)rep(x,w){
		char tmp;
		cin >> tmp;
		const int ny = x + y + 1;
		const int nx = x - y + offset + 1;
		board[ny][nx] = tmp;
	}

	rep(y,n){
		rep(x,1,n){
			hsum[y][x] = (board[y][x] == '#');
			hsum[y][x] += hsum[y][x-1]; 
		}
	}

	rep(x,n){
		rep(y,1,n){
			vsum[y][x] = (board[y][x] == '#');
			vsum[y][x] += vsum[y-1][x]; 
		}
	}

	ll ans = 0LL;
	rep(y,n){
		rep(x2,n)rep(x,x2){
			if(board[y][x] == '.') continue;
			if(board[y][x2] == '.') continue;
			const int d = abs(x2 - x);
			
			if(y - d > 0){
				ans += 1LL * (hsum[y - d][x2] - hsum[y - d][x - 1]);
			}

			if(y + d < n){
				ans += 1LL * (hsum[y + d][x2] - hsum[y + d][x - 1]);
			}
		} 
	}

	rep(x,n){
		rep(y2,n)rep(y,y2){
			if(board[y][x] == '.') continue;
			if(board[y2][x] == '.') continue;
			const int d = abs(y2 - y);
			
			if(x - d > 0){
				ans += 1LL * (vsum[y2 - 1][x - d] - vsum[y][x - d]);
			}

			if(x + d < n){
				ans += 1LL * (vsum[y2 - 1][x + d] - vsum[y][x + d]);
			}
		} 
	}


	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3456
#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, m; cin >> n >> m;
    vector<int> to[100];
    rep(i, m) {
        int a, b; cin >> a >> b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    for(int i=1;i<=n;i++) {
        cout << to[i].size()<< endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
const int M = 1000000007;

int n,s,w[300];
int dp[2][201][10001];

int main(){
  cin >> n >> s;
  for(int i=0;i<n;i++)cin >> w[i];
  sort(w,w+n);

  memset(dp,0,sizeof(dp));
  dp[0][0][0] = 1;

  for(int i=0;i<n;i++){
    int now = i&1, nxt = 1-now;
    for(int j=0;j<=i;j++)
      for(int k=0;k<=s;k++)dp[nxt][j][k] = 0;

    for(int j=0;j<=i;j++){
      for(int k=0;k<=s;k++){
	if(j)(dp[nxt][j][k] += dp[now][j][k]) %= M;
	else (dp[nxt][i+1][k] += dp[now][j][k]) %= M;
	if(k+w[i]<=s){
	  (dp[nxt][j][k+w[i]] += dp[now][j][k]) %= M;
	}
      }
    }
  }

  int ans = 0;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=s;j++){
      //cout << dp[n&1][i][j] << " ";
      if(i==0)(ans += dp[n&1][i][j]) %= M;
      else if(j+w[i-1]>s)(ans += dp[n&1][i][j]) %= M;
    }
    //cout << endl;
  }

  cout << ans << endl;
}

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

using namespace std;
#define ll long long int

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

    vector<int> L(N);

    for (int i = 0; i < N; i++)
    {
        cin >> L[i];
    }

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

    int countErg = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < i; j++)
        {
            for (int k = 0; k < j; k++)
            {
                if (L[i]!=L[j] and L[j]!=L[k] and L[k]+L[j]>L[i])
                countErg++;
            }
        }
    }
   
   cout << countErg;

    return 0;
}


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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int n, k; cin >> n >> k;
    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;
    }

    vector<pii> es;
    REP(i,1,n) es.emplace_back(i, n);
    int cnt = (n-1)*(n-2)/2 - k;
    REP(i,1,n-1){
        REP(j,i+1,n){
            if(cnt == 0) break;
            es.emplace_back(i, j);
            cnt--;
        }
        if(cnt == 0) break;
    }
    printf("%d\n", es.size());
    for(auto e : es) printf("%d %d\n", e.fi, e.se);
    return 0;
}

Measured memory_bytes: 3696
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int n;
	cin >> n;
	string* s = new string[n];
	rep(i, n) cin >> s[i];

	map<string, int> m;
	rep(i, n) {
		m[s[i]] += 1;
	}

	cout << "AC x " << m["AC"] << "\n";
	cout << "WA x " << m["WA"] << "\n";
	cout << "TLE x " << m["TLE"] << "\n";
	cout << "RE x " << m["RE"] << "\n";

	return 0;
}


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

int n;
long long  int sum;
long long int a[10000];
int b = 0;
int c = 0;

int main() {
  cin >> n;
  for (; b < n; ++b ) {
    cin >> a[b];
  }

  sort(a,a+n);

  for (; c < n; ++c ) {
    sum = sum + a[c];
  }
  n = n-1;
  cout << a[0] << " " << a[n] << " " << sum << endl;

}

Measured memory_bytes: 3216
#include "bits/stdc++.h"
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/rational.hpp>
using namespace std;

#define ll long long
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()



// substr(start, len)

int main(){
  string s;
  cin >> s;

  if(s.size() % 2 != 0){
    cout << "No";
    return 0;
  }

  for(int i = 0; i < s.size()/2; i++){
    if(s.substr(2*i, 2) != "hi"){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";

// CHECK if it's possible to overflow!!
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ll long long
using namespace std;
ll ma(ll a,ll b){
	if(a>b)return a;
	else return b;
}
int main(){
	int i,o,t,j,l,s,z;
	cin>>i>>o>>t>>j>>l>>s>>z;
	ll eff = 0;
	eff += o;
	eff += (i/2) *2;
	eff += (j/2) *2;
	eff += (l/2) *2;
	if(i%2 == 1 && j%2==1 && l%2==1)eff+=3;
	
	ll eff2 = 0;
	eff2 += o;
	eff2 += ( (i-1)/2 ) *2;
	eff2 += ( (j-1)/2 ) *2;
	eff2 += ( (l-1)/2 ) *2;
	if(i>0 && j>0 && l>0)eff2 += 3;
	cout<<ma(eff,eff2)<<endl;
	return 0;
}

Measured memory_bytes: 256
#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; }

const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> x(n);
	rep(i,n) cin >> x[i];
	ll ans = INF;
	for(int i = k-1; i < n; i++){
		ll cmp;
		if(x[i] >= 0 && x[i-k+1] >= 0) cmp = x[i];
		else if(x[i] >= 0 && x[i-k+1] < 0) cmp = (ll)max(abs(x[i]), abs(x[i-k+1])) + (ll)min(abs(x[i]), abs(x[i-k+1]))*2LL;
		else if(x[i] < 0) cmp = abs(x[i-k+1]);
		chmin(ans, cmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <cstdio>

using namespace std;

long long a[500][500];
long long sum[501][501];

int main() {
    int H, W, h, w, i, j;
    long long x, y;
    
    scanf("%d %d %d %d", &H, &W, &h, &w);
    
    if (h * w == 1) {
        puts("No");
        
        return 0;
    }
    
    x = (1e9 - 1) / (h * w - 1);
    y = - x * (h * w - 1) - 1;
    
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {
            if (i % h == h - 1 && j % w == w - 1) {
                a[i][j] = y;
            } else {
                a[i][j] = x;
            }
            
            sum[i + 1][j + 1] = sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + a[i][j];
        }
    }
    
    if (sum[H][W] <= 0) {
        puts("No");
        return 0;
    }
    
    for (i = 0; i + h <= H; i++) {
        for (j = 0; j + w <= W; j++) {
            if (sum[i + h][j + w] - sum[i + h][j] - sum[i][j + w] + sum[i][j] >= 0) {
                puts("No");
                return 0;
            }
        }
    }
    
    puts("Yes");
    
    for (i = 0; i < H; i++) {
        for (j = 0; j < W; j++) {
            if (j > 0) putchar(' ');
            
            printf("%lld", a[i][j]);
        }
        puts("");
    }
    
    return 0;
}


Measured memory_bytes: 6784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string S;
    int n;

    cin >> n;
    cin >> S;
    int len = S.size();
    for(int i = 0; i < len; i++)
    {
        /*while(n--)
        {
            S[i] = S[i]+ 1;
            if(S[i] == 'Z')
            {
                S[i]
            }
        }*/
        S[i] = S[i] + n;
        if(S[i] <= 'Z')
        {
            cout << S[i];
        }
        else
        {
            int x = S[i] - 'Z';
            S[i] = 64 + x;
            cout << S[i];
        }
        
    }
    cout << endl;
}




Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    struct Direction
    {
        internal int l, u, lu, ru;
    }

    class Grid
    {
        readonly int n;

        char[,] map;
        Direction[,] memo;

        public Grid(int n)
        {
            this.n = n;
            map = new char[n + 2, n + 2];
            memo = new Direction[n + 2, n + 2];
        }

        public void MakeMap()
        {
            for (int i = 1; i <= n; i++)
            {
                string input = Console.ReadLine();

                for (int j = 0; j < n; j++)
                {
                    map[i, j + 1] = input[j];
                }
            }
        }

        public int SearchMax()
        {
            int ret = 0;

            for (int i = 1; i <= n; i++)
            {
                for (int j = 1; j <= n; j++)
                {
                    if (map[i, j] == '1')
                    {
                        memo[i, j].l = memo[i, j - 1].l + 1;
                        memo[i, j].u = memo[i - 1, j].u + 1;
                        memo[i, j].lu = memo[i - 1, j - 1].lu + 1;
                        memo[i, j].ru = memo[i - 1, j + 1].ru + 1;

                        ret = Math.Max(ret, memo[i, j].l);
                        ret = Math.Max(ret, memo[i, j].u);
                        ret = Math.Max(ret, memo[i, j].lu);
                        ret = Math.Max(ret, memo[i, j].ru);
                    }
                }
            }
            return ret;
        }
    }

    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            while (true)
            {
                int n = int.Parse(Console.ReadLine());

                if (n == 0) break;

                Grid g = new Grid(n);
                g.MakeMap();
                sb.AppendLine(g.SearchMax().ToString());
            }
            Console.Write(sb);
        }
    }
}

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

int main(){
	int n;
	while(cin >> n,n){
		int sum = 0;
		for(int i = 0; i < n/4; i++){
			int a;
			cin >> a;
			sum += a;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<vector>
#include<queue>
#include<cmath>
using namespace std;

int main()
{
    int x;
    int check[1000] = {0};
    int i, j, judge;
    
    cin >> x;
    
    check[1] = 1;
    
    for(i = 2; i <= 31; i++) {
        judge = 0;
        for(j = 2; judge == 0; j++) {
            if(int(pow(i, j)) <= 1000) { check[int(pow(i, j))] = 1; }
            else { judge = 1; }
        }
    }
    
    i = x;
    
    while(check[i] == 0) { i--; }
    
    cout << i << endl;
    
    return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

  if ((A+B)==(C+D))
    cout << "Balanced" << endl;
  else {
    if ((A+B)>(C+D))
      cout << "Left" << endl;
    else 
      cout << "Right" << endl; }
}

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

int main() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
	int dx = tx - sx, dy = ty - sy;

	cout << string(dy, 'U') << string(dx, 'R') << string(dy, 'D') << string(dx, 'L');
	cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D' << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String a = in.next();
        int c = 0;int s = 0;
        for (int i=0;i<a.length();i++){
            char next = a.charAt(i);
            if (c==0){
                if(next == 'p'){
                    s--;
                }
            }
            else {
                if(next=='g'){
                    s++;
                }
            }
            c^=1;
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 24404
#include <bits/stdc++.h> // Tomasz Nowak
using namespace std;     // XIII LO Szczecin
using LL = long long;    // Poland
#define FOR(i, l, r) for(int i = (l); i <= (r); ++i)
#define REP(i, n) FOR(i, 0, (n) - 1)
template<class T> int size(T &&x) {
	return int(x.size());
}
template<class A, class B> ostream& operator<<(ostream &out, const pair<A, B> &p) {
	return out << '(' << p.first << ", " << p.second << ')';
}
template<class T> auto operator<<(ostream &out, T &&x) -> decltype(x.begin(), out) {
	out << '{';
	for(auto it = x.begin(); it != x.end(); ++it)
		out << *it << (it == prev(x.end()) ? "" : ", ");
	return out << '}';
}
void dump() {}
template<class T, class... Args> void dump(T &&x, Args... args) {
	cerr << x << ";  ";
	dump(args...);
}
#ifdef DEBUG
  struct Nl{~Nl(){cerr << '\n';}};
# define debug(x...) cerr << (strcmp(#x, "") ? #x ":  " : ""), dump(x), Nl(), cerr << ""
#else
# define debug(...) 0 && cerr
#endif
mt19937_64 rng(0);
int rd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}
// end of templates

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;

	/*vector<int> dp_end(n), dp_start(n);
	REP(i, n) {
		if(i > 0)
			dp_end[i] = dp_end[i - 1];
		if(i - c >= 0 and s[i - c] != 'x')
			dp_end[i] = max(dp_end[i], (i - c == 0 ? 0 : dp_end[i - c - 1]) + 1);
	}
	debug(dp_end);

	for(int i = n - 1; i >= 0; --i) {
		if(i != n - 1)
			dp_start[i] = dp_start[i + 1];
		if(s[i] != 'x')
			dp_start[i] = max(dp_start[i], (i + c + 1 < n ? dp_start[i + c + 1] : 0) + 1);
	}
	debug(dp_start);

	vector<int> out;
	REP(i, n) {
		int left = dp_end[i],
			right = (i == n - 1 ? 0 : dp_start[i + 1]);
		debug(left, right);
		if(left + right < k)
			out.emplace_back(i);
	}*/

	vector<int> earliest;
	int can_since = 0;
	REP(i, n)
		if(can_since <= i and s[i] == 'o') {
			can_since = i + c + 1;
			earliest.emplace_back(i);
		}

	vector<int> most_late;
	can_since = n - 1;
	for(int i = n - 1; i >= 0; --i)
		if(i <= can_since and s[i] == 'o') {
			can_since = i - c - 1;
			most_late.emplace_back(i);
		}

	assert(size(earliest) >= k and size(most_late) >= k);
	earliest.resize(k);
	most_late.resize(k);
	reverse(most_late.begin(), most_late.end());
	debug(earliest);
	debug(most_late);

	REP(i, k)
		if(earliest[i] == most_late[i])
			cout << earliest[i] + 1 << '\n';
}


Measured memory_bytes: 3468
#include <stdio.h>
#include <math.h>

int main(void){
    int a;
    int b;
    double s=0.0;
    double t=0.0;
    int f=0;
    scanf("%d %d",&a,&b);
    for(int i=1; i<=1000; i++){
        s=(double)i*0.08;
        t=(double)i*0.1;
        if(floor(s)==a&&floor(t)==b){
            printf("%d\n",i);
            break;
        }
        if(i==1000){
            f=1;
        }
    }
    if(f==1){
        printf("-1");
    }
	return 0;
}

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

int main() {

    int N;
    string S, T;
    cin >> N >> S >> T;

    rep(i, N) cout << S[i] << T[i];

    cout << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>
#include <algorithm>

int popcnt(int x) {
	x = (x & 0x55555555) + ((x >> 1) & 0x55555555);
	x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
	x = (x & 0x0f0f0f0f) + ((x >> 4) & 0x0f0f0f0f);
	x = (x & 0x00ff00ff) + ((x >> 8) & 0x00ff00ff);
	x = (x & 0x0000ffff) + ((x >> 16) & 0x0000ffff);
	return x;
}
int log2(int x) {
	return popcnt((x & -x) - 1);
}

int n;
char a[1000100];
int solve(int div = 1) {
	int mod = 0, one = div == 2, exp = 0;
	for (int i = 0; i < n; i++) {
		mod ^= (a[i] / div % 2) & (!(bool)exp);
		one |= (a[i] / div) == 1;
		exp += log2(n - i - 1) - log2(i + 1);
	}
	if (mod & 1)
		return 1;
	if (one)
		return 0;
	return solve(2) * 2;
}
int main() {
	scanf("%d", &n);
	scanf("%s", a);
	for (int i = 0; i < n; i++)
		a[i] = a[i] - '0' - 1;
	printf("%d\n", solve());
}

Measured memory_bytes: 1152
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    long X = sc.nextLong();
    long ans = X / 11 * 2;
    X -= X / 11 * 11;
    ans += X > 6 ? 2 : X > 0 ? 1 : 0;
    System.out.println(ans);
  }

}


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


int main() {
	cin >> N;
	int MIN = INT_MAX;
	int MAX = INT_MIN;
	for (int i = 0; i < N; ++i) {
		int temp = 0; cin >> temp;
		MIN = min(temp, MIN);
		MAX = max(temp, MAX);
	}
	cout << MAX - MIN << endl;
	return 0;
}

Measured memory_bytes: 256
import std.stdio, std.algorithm;

int[111][111] cost, time;
int n, m, a, b, c, t, p, q, r, k;

void main(){
	while (readf("%d %d\n", &n, &m), n|m) {
		m++;
		foreach (i; 0..m) {
			cost[i] = time[i] = 999999999;
			cost[i][i] = 0;
			time[i][i] = 0;
		}

		foreach (i; 0..n) {
			readf("%d %d %d %d\n", &a, &b, &c, &t);
			cost[a][b] = cost[b][a] = c;
			time[a][b] = time[b][a] = t;
		}

		warshall_floyd();

		readf("%d\n", &k);
		foreach (i; 0..k) {
			readf("%d %d %d\n", &p, &q, &r);
			if (r) writeln(time[p][q]);
			else writeln(cost[p][q]);
		}
	}
}

void warshall_floyd(){
	for (int k = 0; k < m; k++) {
		for (int i = 0; i < m; i++) {
			for (int j = 0; j < m; j++) {
				cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
				time[i][j] = min(time[i][j], time[i][k] + time[k][j]);
			}
		}
	}
}

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

int main(){


  ll a,b,c;
  cin>>a>>b>>c;
 
  if((c-a-b)>0 && 4*a*b<(c-a-b)*(c-a-b)){cout<<"Yes"<<endl;return 0;}
  cout<<"No"<<endl;

}


Measured memory_bytes: 256
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  # ignore trailing spaces

n, m = na()
h = set()
mi = 0
for i in range(m):
    if n-i-mi-(i+1) in h:
        mi += 1
    if (n-i-mi) -(i+1) == (i+1+n) - (n-i-mi):
        mi += 1
    print(i+1, n-i-mi)
    h.add(n+i+1 - (n-i-mi))


Measured memory_bytes: 83532
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
const int MAX_N = 100000;
int parent[MAX_N];
int depth[MAX_N];
int N;
vector<int> G[MAX_N];

void dfs(int v, int p, int d) {
    depth[v] = d;
    parent[v] = p;

    for (int next : G[v]) {
        if (next == p) continue;
        dfs(next, v, d + 1);
    }
}

int dfs_cnt(int v, int p) {
    int ret = 1;
    for (int next : G[v]) {
        if (next == p) continue;
        ret += dfs_cnt(next, v);
    }
    return ret;
}

signed main() {
    cin >> N;

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    dfs(0, -1, 0);

    int node_num = depth[N-1] - 1;

    int node1 = N-1;
    for (int i = 0; i < node_num / 2; i++) node1 = parent[node1];
    int node2 = parent[node1];

    vector<int> :: iterator it;
    for (it = G[node1].begin(); it != G[node1].end(); it++) {
        if (*it == node2) {
            G[node1].erase(it);
            break;
        }
    }
    for (it = G[node2].begin(); it != G[node2].end(); it++) {
        if (*it == node1) {
            G[node2].erase(it);
            break;
        }
    }

    int black_cnt = dfs_cnt(0, -1);
    int white_cnt = N - black_cnt;

    if (black_cnt > white_cnt) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }

    return 0;
}

Measured memory_bytes: 11904
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] a = sc.next().split("");
        String[] x = sc.next().split("");
        String[] c = sc.next().split("");

        System.out.println("A" + x[0] + "C");
    }
}


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


#define li			long long int
#define rep(i,to)	for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)	for(li i=(li)(start);i<((li)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)		idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)		idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)	for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)		idp p2((x).F, (x).S)
#define dump(x,n)	idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)	idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)	idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)	idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)	rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)	rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li a[1010];
li n;

inline li calc(li x) {
	li res = 0;
	rin{
		li tmp = a[i] - x;
		res += tmp * tmp;
	}
	return res;
}

int main() {
	cin >> n;
	rin{cin >> a[i];}
	li res = INF;
	repp(i, -100, 101) {
		res = min(res, calc(i));
	}
	cout << res << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pri;
const int INF = 1e9 + 7;
const ll LINF = 1LL<<61;

const int N = 10005, P = 1000000007;

int n, ans ,a[N], f[1000005];

int Pow(ll x){
	int y = P-2;
	int ans = 1;
	for(; y; y>>=1, x=x*x%P){
		if(y&1) ans = ans*x%P;
	}
	return ans;
}

int main(){
	scanf("%d",&n);
	for(int i = 1; i <= n; i++){
		scanf("%d", a+i);
		int x = a[i];
		for(int j = 2; j*j <= x; j++){
			if( x%j == 0){
				int cnt = 1;
				while((x /= j)%j==0) cnt++;
				f[j] = max(f[j],cnt);
			}
		}
		if( x > 1 ) f[x] = max(f[x], 1);
	}
	int s = 1;
	for( int i = 1; i <= 1000000; i++){
		while(f[i]--) s = (ll)s*i%P;
	}
	for(int i = 1; i <= n; i++) ans = (ans + (ll)s*Pow(a[i]))%P;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

const int MAX_N=1<<17;
const ll INF=(1ll<<31)-1;
//Range Sum Query
class Lz_segtree{
public:
    int n;
    ll e=0;
    ll init=0;
    vector<ll> dat,lz;
    Lz_segtree(int n_):n(n_){
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2,0);
        lz.resize(n*2,e);
    }
    void update_f(ll& d,ll x){
        d+=x;
    }
    void dat_propergatef(ll& d,ll x){
        d=x;
    }
    void lz_propergatef(ll& l,ll& r,ll x){
        l+=x,r+=x;
    }
    ll q_func(ll l,ll r){
        return min(l,r);
    }
    void eval(int len,int k){
        if(lz[k]!=e) update_f(dat[k],lz[k]);
        if(len>1){
            lz_propergatef(lz[k*2+1],lz[k*2+2],lz[k]);
        }
        lz[k]=e;
    }
    //range [a,b)
    void update(int a,int b,int k,int l,int r,ll x){
        eval(r-l,k);
        if(r<=a||b<=l) return;
        if(a<=l&&r<=b){
            update_f(lz[k],x);
            eval(r-l,k);
        }
        else{
            update(a,b,k*2+1,l,(l+r)/2,x);
            update(a,b,k*2+2,(l+r)/2,r,x);
            dat_propergatef(dat[k],min(dat[2*k+1],dat[2*k+2]));
        }
    }
    //range [a,b)
    ll query(int a,int b,int k,int l,int r){
        eval(r-l,k);
        if(r<=a||b<=l) return INF;
        if(a<=l&&r<=b) return dat[k];
        else{
            ll vl=query(a,b,k*2+1,l,(l+r)/2);
            ll vr=query(a,b,k*2+2,(l+r)/2,r);
            return q_func(vl,vr);
        }
    }
    void update(int a,int b,ll x){
        return update(a,b,0,0,n,x);
    }
    ll query(int a,int b){
        return query(a,b,0,0,n);
    }
};

int main(){
    int n,q,c,s,t,x;
    cin>>n>>q;
    Lz_segtree seg(n);
    //seg.update(0,n,-INF);
    rep(i,q){
        cin>>c;
        if(c==0){
            cin>>s>>t>>x;
            seg.update(s,t+1,x);
        }
        else{
            cin>>s>>t;
            ll ans=seg.query(s,t+1);
            cout<<ans<<endl;
        }
    }
    return 0;
}



Measured memory_bytes: 7060
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    char c;
    cin >> c;
    switch (c) {
        case 'a':
        case 'i':
        case 'u':
        case 'e':
        case 'o':
            cout << "vowel" << endl;
            break;
        default:
            cout << "consonant" << endl;
    }
    return 0;
}

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

int main() {
	int n;
	cin>>n;
	long long int a[n+1];
	for(int i=0;i<n+1;i++)
		a[i]=1;
		
	a[0] = 0;
	
	for(int i=2;i<n+1;i++) {
		for(int j=i;j<n+1;j+=i) {
			a[j]+=1;
		}
	}
	
	long long int res=0;
	
	for(int i=1;i<n+1;i++) {
		res+= i*a[i];
	}
	
	cout<<res<<endl;
	return 0;
}

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

constexpr int INF       = 1000000000;/* 1e+9a */
constexpr int MODULO    = 1000000007;

typedef int64_t ll;

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

#define SPRE(x) setprecision(x) // 精度を指定


int main()
{
	cin.tie(0);
    ios::sync_with_stdio(false);
	int N,M;
	cin >> N >> M;
	vector<set<int> > ff(N, set<int>());
	for (int i = 0; i < M; i++) {
		int ta, tb;
		cin >> ta >> tb;
		ta--;tb--;
		ff[ta].insert(tb);
		ff[tb].insert(ta);
	}

	cout << ([&](){
		int i;
		for (auto&& t : ff[0]) {
			if(ff[N-1].count(t))
				return true;
		}
		return false;
	}() ? "POSSIBLE\n" : "IMPOSSIBLE\n");


}



Measured memory_bytes: 28416
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    ll N; cin >> N;

    ll ans = N%2==0 ? N : 2*N;
    
    cout << ans << endl;

    return 0;
}

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

int main(){
int a,n[100],f=0;
cin>>a;

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


}

for(int i=0;i<a;i++){
    if(n[i]%2==0){
        if(n[i]%3 ==0 || n[i]%5==0){
            f=0;
            //break;
        }
        else
        {
            f=1;
            break;
        }
    }
}
if(f==0){
        cout<<"APPROVED"<<endl;
   }
   else{
    cout<<"DENIED"<<endl;
   }


}



Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int n=0,x=0,count,i,j,k;
	while(1){
		scanf("%d %d",&n,&x);
		if(n==0&&x==0) break;
		count=0;	//roop nai deno syokika ga hituyo
		for(i=1;i<=n-2;i++){
			for(j=i+1;j<=n-1;j++){
				for(k=j+1;k<=n;k++){
					if((i+j+k)==x) count++;
				}
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main()
{
	char tmp = 'A', cup1, cup2, t;
	
	while (cin >> cup1 >> t >> cup2) {
		if (cup1 == tmp)
			tmp = cup2;
		else if (cup2 == tmp)
			tmp = cup1;
	}
	
	cout << tmp << endl;

	return 0;
}

Measured memory_bytes: 1132
//Self-control leads to consistency.
#include <bits/stdc++.h> 
using namespace std; 
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define flash ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define ve vector<ll>
#define dos pair<ll,ll>
#define vedos vector<dos>
#define rand mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define EPS 0.000001
struct greateri
{
    template<class T>
    bool operator()(T const &a, T const &b) const { return a > b; }
};
void setIO(string s) {
  ios_base::sync_with_stdio(0); cin.tie(0); 
  freopen((s+".in").c_str(),"r",stdin);
  freopen((s+".out").c_str(),"w",stdout);
}
int main()
{
  //flash;
  ll k;
  cin>>k;
  ll ans=1;
  ll cur=7%k;
  ll dar=7%k;
  map<ll,ll>g;
  while(dar!=0){
    if(g.find(dar)!=g.end()){
      cout<<-1;
      exit(0);
    }
    g[dar]=1;
    ans++;
    cur=(cur*10)%k;
    dar+=cur;
    dar%=k;
  }
  cout<<ans;
  return 0;
}

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

int main() {
	int n,k;

	cin >> n >> k ;
	
	int now = 1;
	
	for (int i = 0; i < n; i++)
	{
		if (now * 2 < now + k) {
			now *= 2;
		}
		else
		{
			now += k;
		}
	}
	
	cout << now << endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int mp[105][105];
int X, Y, h, w, n;
void pnt(int x) {
    mp[X][Y] = x;
    if (X % 2 == 0) {
        Y++;
        if (Y == w) {
            Y--;
            X++;
        }
    }
    else {
        Y--;
        if (Y < 0) {
            Y++;
            X++;
        }
    }
}
int main() {
    int x;
    scanf("%d%d%d", &h, &w, &n);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &x);
        for (int j = 0; j < x; j++) {
            pnt(i);
        }
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            printf("%d%c", mp[i][j], j == w - 1 ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 384