akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long N = long.Parse(str[0]);
		long K = long.Parse(str[1]);
		long mod = 1000000007;
		var B = new List<long>();
		B.Add(0);
		B.Add(1);
		long s = N;
		long t = 1;
		while(t<N){
			t += 1;
			long s2 = N/t;
			t = N/s2;
			B.Add(t);
		}
      	var E = new long [B.Count];
		var D = new long [K+1,B.Count];
		for(var i=1;i<B.Count;i++){
			D[1,i] = B[i]-B[i-1];
          	E[i] = D[1,i];
		}
        //for(var j=0;j<B.Count;j++){
        //   Console.Error.Write(D[1,j]+" ");
        //}
      	Console.Error.WriteLine();
		for(var i=2;i<=K;i++){
          	long t1 = 0;
        	for(var j=B.Count-1;j>=1;j--){
              	t1 = (t1 + D[i-1,B.Count-j]) % mod;
              	D[i,j] = t1 * E[j];
              	
			}
			//for(var j=1;j<B.Count;j++){
			//	D[j] = D[j] * (N / B[j]) % mod;
			//}
          	//for(var j=0;j<B.Count;j++){
            //  Console.Error.Write(D[i,j]+" ");
            //}
          	//Console.Error.WriteLine();
		}
		long ans = 0;
		for(var i=0;i<B.Count;i++){
			ans = (ans + D[K,i]) % mod;
		}
      	Console.WriteLine(ans);
	}
}

Measured memory_bytes: 59872
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int d[105][105], graph[105][105];
int main(int argc, const char * argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      graph[i][j] = inf;
      d[i][j] = inf;
    }
  }
  
  for (int i = 0; i < m; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--, c;
    graph[a][b] = c;
    graph[b][a] = c;
    d[a][b] = c;
    d[b][a] = c;
  }
  
  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (graph[i][j] == inf) {
        continue;
      }
      if (graph[i][j] != d[i][j]) {
        ans++;
      }
    }
  }
  cout << ans / 2 << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}

class Dijkstra {
public:
    struct edge { ll v, dist; };

    struct state {
        ll v, cost;
        bool operator>(const state s) const { return cost > s.cost; }
    };

    const ll INF = (1LL << 60);
    ll N;
    ll MOD = 1e9+7;
    vector< vector<edge> > E;

    Dijkstra(ll n): N(n), E(n) {}

    //有効グラフの時はこっち。u→vに距離dで結ぶ
    void add_directed_edge(ll u, ll v, ll d) {
        E[u].push_back((edge) { v, d });
    }

    //無向グラフの時はこっち。uとvを双方向に距離dで結ぶ
    void add_undirected_edge(ll u, ll v, ll d) {
        E[u].push_back((edge) { v, d });
        E[v].push_back((edge) { u, d });
    }

    //Sを始点として、他の頂点への最短経路を探す
    vector<long long> shortest_path(long long S) {
        vector<long long> dp(E.size(), INF);
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        while(!q.empty()) {
            long long v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v] <= cost) continue;
            dp[v] = cost;
            for(int i=0;i < E[v].size() ; i++) {
            long long nv = E[v][i].v, ncost = cost + E[v][i].dist;
            if(dp[nv] > ncost) q.push((state) { nv, ncost });
            }
        }
        return dp;
    }

    //Sを始点として、他の頂点への最短経路と経路数のを調べる
    vector<pair<ll,ll>> path_count(ll S) {
        vector<pair<ll,ll>> dp(E.size(), {INF,0});
        priority_queue<state, vector<state>, greater<state> > q;
        q.push((state) { S, 0 });
        dp[S].first = 0;
        dp[S].second = 1;
        while(!q.empty()) {
            ll v = q.top().v, cost = q.top().cost;
            q.pop();
            if(dp[v].first < cost) continue;
            for(int i=0;i < E[v].size() ; i++) {
                ll nv = E[v][i].v, ncost = cost + E[v][i].dist;
                if(dp[nv].first > ncost){
                    dp[nv].first = ncost;
                    dp[nv].second = dp[v].second;
                    q.push((state) { nv, ncost });
                }
                else if(dp[nv].first == ncost){
                    dp[nv].second += dp[v].second;
                    dp[nv].second %= MOD;
                }
            }
        }
        return dp;
    }
};

Dijkstra d(2001);

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

    ll n,x,y;
    cin>>n>>x>>y;
    x--,y--;
    //Dijkstra d(n);
    for(int i=0;i<n;i++){
        d.add_undirected_edge(i,i+1,1);
    }
    d.add_undirected_edge(x,y,1);
    ll ans[n+1]={};
    for(int i=0;i<n;i++){
        vector<ll> v = d.shortest_path(i);
        for(int j=i+1;j<n;j++){
            ans[v[j]]++;
        }
    }
    for(int i=1;i<n;i++){
        cout << ans[i] << "\n";
    }

}

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

int n,m,a[N][N],k;

int main()
{
	scanf("%d",&k);
	if(k==1) return printf("1\n1"),0;
	printf("%d\n",n=2*((k-1)/4+1));
	for(int i=0;i<n;++i)
		for(int j=0;j<n;++j)
			a[i][j]=(i&1)?(i+j)%n+1+n:(i+j)%n+1;
	for(int i=0;i<n;++i)
		for(int j=0;j<n;j++)
			if(a[i][j]>k) a[i][j]-=n;
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j) printf("%d ",a[i][j]);puts("");
	}
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define double long double
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define vout(v) for(int i=0;i<(int)v.size()-1;i++){cout<<v[i]<<" ";}cout<<v[v.size()-1]<<"\n";
#define debg(a) cout<<#a<<" "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> V;
const long long MOD=1000000007;
const long long INF = 1e18;
vector <ll> dp;

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
    regex re("(dreamer|dream|eraser|erase)*");
    if(regex_match(S, re)){
        cout << YES << "\n";
    }else{
        cout << NO << "\n";
    }
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

int		main(void)
{
	char	a, b, c;
	cin >> a >> b >> c;
	string	tmp;
	tmp += a;
	tmp += b;
	tmp += c;
	int		abc = stoi(tmp);
	cout << (abc % 4 == 0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
H, W, A, B = map(int, input().split())
h = {}
p = 10**9+7
q = p - 2
for x in range(H+W-1):
    if h.get(x-1):
        a = (x * h[x-1][0]) % p
    else:
        a = 1
    b = pow(a,q,p)
    h[x] = (a,b)

def C(n, r):
    return h[n][0] * h[r][1] * h[n-r][1]

ans = 0
for i in range(B, W):
    ans += C(i+H - A - 1, i) * C(W - 1 - i + A - 1, W - 1 - i)
    ans %= p
print(ans % p)

Measured memory_bytes: 49384
#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
char _;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	if(n<=599) cout << 8 << endl;
	else if(n<=799) cout << 7  << endl;
	else if(n<=999) cout << 6 << endl;
	else if(n<=1199) cout << 5 << endl;
	else if(n<=1399) cout << 4 << endl;
	else if(n<=1599) cout << 3 << endl;
	else if(n<=1799) cout << 2 << endl;
	else if(n<=1999) cout << 1 << endl;
	
	return 0;
}


Measured memory_bytes: 3660
#pragma GCC optimize(2)
#include<cstdio>
#include<algorithm>
using namespace std;
int main() 
{
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    printf("%s\n",c%__gcd(a,b)==0?"YES":"NO");
    return 0;
}

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

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

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

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

    int n,t;
    int sum = 0;
    vector <int> v;

    cin >> n;

    v.push_back(0);
    for(int i=0;i<n;i++)
    {
        cin >> t;
        v.push_back(t);
    }
    v.push_back(0);

    for(int i=1;i<v.size();i++)
    {
        sum += abs(v[i] - v[i-1]);
    }

    for(int i=1;i<=n;i++)
    {
        int temp = sum;
        temp -= abs(v[i] - v[i-1]);
        temp -= abs(v[i+1] - v[i]);
        temp += abs(v[i+1] - v[i-1]);
        cout << temp << '\n';
    }
    
    return 0;
}


Measured memory_bytes: 1784
from sys import stdin

input = stdin.buffer.readline

n, x, d = map(int, input().split())

if d == 0:
    if x == 0:
        print(1)
    else:
        print(n + 1)
    exit(0)

m = {}
for i in range(n + 1):
    t = i * x % d
    start = i * x // d
    l = (i - 1) * i // 2
    r = (2 * n - i - 1) * i // 2
    if m.get(t):
        m[t].append([start + l, start + r])
    else:
        m[t] = [[start + l, start + r]]
inf = float('inf')
ans = 0
for x in m:
    now = m[x]
    now.sort()
    pl = -inf
    for l, r in now:
        if r <= pl:
            continue
        if l > pl:
            ans += r - l + 1
        else:
            ans += r - pl
        pl = r

print(ans)

Measured memory_bytes: 92376
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
int main() {
  ll N;
  cin >> N;
  vector<ll> A(0);
  for (int i = 2; i <= N / i; i++) {
    if (i == N / i) {
      A.push_back(i);
      continue;
    }
    if (N % i == 0) {
      A.push_back(i);
      A.push_back(N / i);
    }
  }
  A.push_back(N);
  ll ans = 0;
  REP(i, A.size()) {
    ll tmp = A[i] - 1;
    if (tmp == 0) continue;
    if (floor(N / tmp) == N % tmp) ans += tmp;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
#define taskname "VirtualACM"
#define int long long
using namespace std;

int tt, nT = 1;

template<typename T>
void Read(T &x)
{
    bool neg = false;
    char c;
    for (c = getchar(); !isdigit(c); c = getchar())
        if (c == '-') neg = true;
    x = c - '0';
    for (c = getchar(); isdigit(c); c = getchar())
        x = x * 10 + c - '0';
    if (neg) x = -x;
}

template<typename T>
void Write(T x)
{
    if (x < 0)
    {
        putchar('-');
        Write(-x);
        return;
    }
    if (x > 9) Write(x / 10);
    putchar(x % 10 + '0');
}

void Enter()
{
    int n;  cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
        if (i) a[i] += a[i - 1];
    }
    int ans1 = 0, ans2 = 0;
    // a[0] > 0
    {
        vector<int> b(n, 0);
        if (a[0] <= 0) ans1 = b[0] = abs(a[0]) + 1;
        for (int i = 1; i < n; ++i)
        {
            b[i] = b[i - 1];
            if (i & 1 && a[i] + b[i] >= 0)
            {
                ans1 += a[i] + b[i] + 1;
                b[i] -= a[i] + b[i] + 1;
            }
            else if (!(i & 1) && a[i] + b[i] <= 0)
            {
                ans1 += abs(a[i] + b[i]) + 1;
                b[i] += abs(a[i] + b[i]) + 1;
            }
        }
    }
    // a[0] < 0
    {
        vector<int> b(n, 0);
        if (a[0] >= 0)
        {
            ans2 += a[0] + 1;
            b[0] -= a[0] + 1;
        }
        for (int i = 1; i < n; ++i)
        {
            b[i] = b[i - 1];
            if (i & 1 && a[i] + b[i] <= 0)
            {
                ans2 += abs(a[i] + b[i]) + 1;
                b[i] += abs(a[i] + b[i]) + 1;
            }
            else if (!(i & 1) && a[i] + b[i] >= 0)
            {
                ans2 += a[i] + b[i] + 1;
                b[i] -= a[i] + b[i] + 1;
            }
        }
    }
    cout << min(ans1, ans2);
}

void Init()
{

}

void Solve()
{

}

void PrintRes()
{

}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);   cout.tie(nullptr);
    if (ifstream("test.inp"))
    {
        freopen("test.inp", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }

    //Read(nT);
    for (tt = 1; tt <= nT; ++tt)
    {
        Enter();
        Init();
        Solve();
        PrintRes();
    }
}


Measured memory_bytes: 1804
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
  	cin>>n;
  	puta((n+1)/2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
int main(){
	int N;
	cin>>N;
	int res = __builtin_popcount(N);
	rep(i,31){
		if((1<<i)-1 <= N) chmax(res,i);
	}
	cout<<res<<endl;
}



Measured memory_bytes: 3100
#include <algorithm>
#include <climits>
#include <cmath>
#include <iostream>
#include <numeric>
#include <unordered_map>
#include <vector>

const int mod = 1e9 + 7;
const int kmax = 510000;

long long fact[kmax], fact_inv[kmax], inv[kmax];

void init_comb()
{
    fact[0] = fact[1] = 1;
    fact_inv[0] = fact_inv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < kmax; i++) {
        fact[i] = fact[i - 1] * i % mod;
        inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        fact_inv[i] = fact_inv[i - 1] * inv[i] % mod;
    }
}

long long comb(int n, int r)
{
    if (n < r) {
        return 0;
    }

    if (n < 0 || r < 0) {
        return 0;
    }

    return fact[n] * (fact_inv[r] * fact_inv[n - r] % mod) % mod;
}

int main()
{
    int n, m;
    std::cin >> n >> m;

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

    std::sort(a.begin(), a.end(), std::greater<int>());

    std::vector<int> num_matches = { 0, 2, 5, 5, 4, 5, 6, 3, 7, 6 };

    std::vector<int> dp_num(n + 1, 0);
    for (int i = 0; i <= n; i++) {
        for (auto num : a) {
            if (i + num_matches[num] <= n) {
                dp_num[i + num_matches[num]] = std::max(dp_num[i + num_matches[num]], dp_num[i] + 1);
            }
        }
    }

    std::vector<std::string> dp(n + 1, "");

    for (auto num : a) {
        if (n - num_matches[num] >= 0) {
            dp[n - num_matches[num]] = std::max(dp[n - num_matches[num]], std::to_string(num));
        }
    }

    for (int i = n; i >= 0; i--) {
        if (dp[i] == "") {
            continue;
        }
        for (auto num : a) {
            if (i - num_matches[num] < 0) {
                continue;
            }
            if (dp[i - num_matches[num]].length() <= dp[i].length()) {
                dp[i - num_matches[num]] = dp[i] + std::to_string(num);
            } else if (dp[i - num_matches[num]].length() - 1 == dp[i].length()) {
                dp[i - num_matches[num]] = std::max(dp[i] + std::to_string(num), dp[i - num_matches[num]]);
            }
        }
    }
    std::cout << dp[0] << std::endl;
}


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

#define MAX 200

void input(int*, int n);
int work(int*, int, int);

int main()
{
	int number[MAX];
	int x, n;

	//for (int i = 0; i < 100; i++) printf("%d ", i + 1);

	scanf("%d %d", &x, &n);
	input(number, n);

	printf("%d\n", work(number, x, n));

	return 0;
}

void input(int* number, int n)
{
	int a;

	for (int i = 0; i < MAX; i++) 
		number[i] = i;

	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		number[a] = 0;
	}

}

int work(int* number, int x, int n)
{
	int r = x;
	int min = MAX;

	if (n != 0) {
		for (int i = 0; i <MAX; i++) {
			if (min > abs(number[i] - x)) {
				min = abs(number[i] - x);
				r = i;
			}
			//printf("%d\n", number[i]);
		}
	}

	return r;
}


Measured memory_bytes: 1736
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n; cin >> n;
    int a[101]; INITA(a, 0, 100, 0);
    REP(i, n) {
        cin >> a[i];
    }

    ll res = INF;
    FOR(t, -100, 100) {
        ll tmp = 0;
        REP(i, n) {
            tmp += pow((a[i] - t), 2);
        }
        res = min(res, tmp);
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;

int main(int argc,char const* argv[])
{
  int n,i;
  cin >> n >> i;
  cout << n-i+1 << endl;
  return 0;
}


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

int main(void){
    int sh, h, lsh;
    while(1){
        char cards[200], tmp[200];
        scanf("%s", cards);
        if(cards[0]=='-') break;
        lsh = strlen(cards);
        scanf("%d", &sh);
        for(int i=0; i<sh; i++){
            scanf("%d", &h);
            for(int j=0; j<h; j++) tmp[j] = cards[j];
            for(int j=h; j<lsh; j++) cards[j-h] = cards[j];
            for(int j=0; j<h; j++) cards[lsh-h+j] = tmp[j];
        }
        printf("%s\n", cards);
    }
    return 0;
}


Measured memory_bytes: 2028
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
//int f[9]={0,1800,1600,1400,1200,1000,800,600,400};
int main()
{
	int a,b,c,cnt=0,k;
	scanf("%d%d%d",&a,&b,&c);
	scanf("%d",&k);
	for(int i=1;i<=7;i++)
	{
		if(b>a)
			break;
		b*=2;
		cnt++;
	}
	for(int i=1;i<=7;i++)
	{
		if(c>b)
			break;
		c*=2;
		cnt++;
	}
	if(c<=b || b<=a || cnt>k)
		printf("No\n");
	else
		printf("Yes\n");
	return 0;
 } 

Measured memory_bytes: 3768
N,A,B=map(int,input().split())
p=list(map(int,input().split()))
p=[p[i]-1 for i in range(N)]

dp=[[0 for i in range(N+1)] for j in range(N)]

for j in range(N+1):
    if p[0]<=j:
        dp[0][j]=0
    else:
        dp[0][j]=A

for i in range(1,N):
    for j in range(N+1):
        if p[i]<=j:
            dp[i][j]=min(dp[i-1][p[i]],dp[i-1][j]+B)
        else:
            dp[i][j]=dp[i-1][j]+A

print(dp[-1][N])


Measured memory_bytes: 286132
import java.io.PrintWriter
import java.util.*

val pw = PrintWriter(System.out)
val sc = Scanner(System.`in`)

fun main(args: Array<String>) {
    val n = sc.nextInt()
    val m = sc.nextInt()
    val a = Array(n){sc.nextDouble()}
    abc161b(n,m,a)
}

fun abc161b(n:Int, m:Int, a:Array<Double>) {
    val summ4 = a.sum()/(4*m)
    val fila = a.filter{num -> num >= summ4}
    if(fila.size >= m) println("Yes") else println("No")
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextListOfString() = next().split(" ")
fun nextListOfInt() = nextListOfString().map { it.toInt() }
fun nextListOfLong() = nextListOfString().map { it.toLong() }
fun nextListOfDouble() = nextListOfString().map { it.toDouble() }



Measured memory_bytes: 35908
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }


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

	ll n, k;
	cin >> n >> k;
	vector<ll> a(n), f(n);
	rep(i, n) cin >> a[i];
	sort(all(a));
	rep(i, n) cin >> f[i];
	sort(all(f)); reverse(all(f));
	ll ng = -1, ok = 1000ll * inf;
	while (ok - ng > 1) {
		ll mid = (ng + ok) / 2;
		ll cnt = 0;
		rep(i, n) cnt += max(a[i] - mid / f[i], 0ll);
		if (cnt <= k) ok = mid;
		else ng = mid;
	}
	cout << ok << '\n';
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include<complex>
#include<numeric>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int n, m;
Int x[110000];

struct Matrix{
    vector<vector<Int>> val;
    int n, m;
    Matrix(int n, int m):n(n),m(m),val(n, vector<Int>(m)){}
    vector<Int> &operator[](int x){
        return val[x];
    }
    Matrix operator+(Matrix other){
        Matrix res(n, m);
        for(int i = 0;i < n;i++)
            for(int j = 0;j < m;j++)
                res[i][j] = (val[i][j] + other[i][j]) % MOD;
        return res;
    }
    Matrix operator-(Matrix other){
        Matrix res(n, m);
        for(int i = 0;i < n;i++)
            for(int j = 0;j < m;j++)
                res[i][j] = (MOD + val[i][j] - other[i][j]) % MOD;
        return res;
    }
};

Matrix operator*(Int k, Matrix m){
    for(int i = 0;i < m.n;i++){
        for(int j = 0;j < m.m;j++){
            m[i][j] *= k;
        }
    }
    return m;
}

Matrix operator*(Matrix a, Matrix b){
    Matrix ans(a.n, b.m);
    for(int i = 0;i < a.n;i++){
        for(int j = 0;j < b.m;j++){
            for(int k = 0;k < a.m;k++){
                (ans[i][j] += a[i][k] * b[k][j] % MOD) %= MOD;
            }
        }
    }
    return ans;
}

Matrix eye(int n){
    Matrix res(n, n);
    for(int i = 0;i < n;i++)res[i][i] = 1;
    return res;
}

Matrix mat_pow(Matrix &a, int x){
    if(x == 0)return eye(a.n);
    if(x % 2)return a * mat_pow(a, x-1);
    auto tmp = mat_pow(a, x/2);
    return tmp * tmp;
}

Matrix go(3,3), start(3,1), rev(3,3);
void init(){
    go[0][1] = 1;
    go[1][2] = 1;
    go[2][0] = 1;
    go[2][1] = -2;
    go[2][2] = 4;
    
    rev[0][0] = 2;
    rev[0][1] = -4;
    rev[0][2] = 1;
    rev[1][0] = 1;
    rev[2][1] = 1;

    start[1][0] = 1;
    start[2][0] = 5;
}

Int calc(int x){
    auto m = start * mat_pow(go, x);
    return m[0][0];
}

auto even_sum = eye(3);
auto odd_sum = Matrix(3,3);
auto diff_sum = eye(3) - Matrix(3,3);

int main(){
    cin >> n >> m;
    init();
    for(int i = 0;i < m;i++){
        cin >> x[i];
        diff_sum = diff_sum - diff_sum * mat_pow(go, x[i]) * start * mat_pow(rev, x[i]);
    }
    auto diff = diff_sum * mat_pow(go, n) * start;
    auto all = diff[0][0];
    all %= MOD;
    if(all < 0)all += MOD;
    cout << all << endl;
       
    return 0;
}

Measured memory_bytes: 3940
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

#define size_t int

long r = 0;

void f(long p, long n) {
  long m = 4 * pow(2, n - 1) - 1;
  if (n == 0) {
    r += p;
    return;
  }
  if (p == 1 || p == 0) {
    return;
  } else if (p == m) {
    r += pow(2, n);
    return;
  } else if (p == m*2 - 1) {
    r += pow(2, n + 1) - 1;
    return;
  } else if (p < m) {
    f(p - 1, n - 1);
  } else if (p > m) {
    r += pow(2, n);
    f(p - m, n - 1);
  }
}

int main(int argc, char const *argv[]) {
  long N, X;
  scanf("%ld %ld", &N, &X);
  f(X, N);
  printf("%ld\n", r);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

        int a[]=new int[n];
        int b[]=new int[n];
        int c[]=new int[n-1];

        for (int i = 0; i < n; i++)
            a[i] = scanner.nextInt();

        for (int i = 0; i < n; i++)
            b[i] = scanner.nextInt();

        for (int i = 0; i < n-1; i++)
            c[i] = scanner.nextInt();

        int satisfaction=0;
        for (int i = 0; i < n; i++) {
            satisfaction += b[a[i]-1];

            if(i>0 && a[i]-a[i-1]==1)
                satisfaction += c[a[i-1]-1];
        }

        System.out.println(satisfaction);
    }
}

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

using lld = long long int;
const lld LIM = 1000000000000000000LL;

bool overflow(lld a, lld b) {
  return a > LIM / b;
}

int32_t main() {
  int n;
  scanf("%d", &n);

  std::vector<lld> a(n);
  for (lld &ai : a) {
    scanf("%lld", &ai);

    if (!ai) {
      return puts("0"), 0;
    }
  }

  lld ans = 1LL;

  for (lld ai : a) {
    if (overflow(ans, ai)) {
      printf("-1\n");
      return 0;
    }

    ans *= ai;
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 4068
#include<iostream>
#include<cstring>
#include<map>
#include<deque>
#include<set>
#include<stack>
#include<string>
#include<algorithm>
using namespace std;
int main()
{
	int t;
	long long s=0;
	cin>>t;
	for(int i=1;i<=t;i++)
		s+=i;
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a[100005],ans[100005];
	for (int i=1;i<=n;i++) {
		cin>>a[i];
		a[i]*=2;
	}
	long long sum=0;
	for (int i=1;i<=n;i++) {
		if (i%2==1) sum+=a[i];
		else sum-=a[i];
	}
	ans[1]=sum/2;
	for (int i=2;i<=n;i++) {
		ans[i]=a[i-1]-ans[i-1];
	}
	for (int i=1;i<=n;i++)
		cout<<ans[i]<<" ";
	return 0;
}

Measured memory_bytes: 2048
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }


int main()
{
	while (true)
	{
		INT(n); if (!n)break;
		vs a;
		FOR(i, n)
		{
			string st; cin >> st;
			for (int j = st.size() - 1; j >= 0; j--)
			{
				if (st[j] == '.')
				{

					st[j] = '+';
					break;
				}
			}
			a.push_back(st);
		}
		FOR(i, n)
		{
			FOR(j, a[i].size())
			{
				if (a[i][j] == '+')
				{
					int p = -1;
					FORI(k, i+1, n)
					{
						if (a[k].size() <= j)break;
						if (a[k][j] == '+')
						{
							p = k; break;
						}
						else if (a[k][j] == '.')
						{
							continue;
						}
						else break;
					}
					FORI(k, i + 1, p)a[k][j] = '|';
				}
			}
		}
		FOR(i, n)FOR(j, a[i].size())if (a[i][j] == '.')a[i][j] = ' ';
		FOR(i, n)cout << a[i] << endl;
	}
}

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

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    rep(i, N) cin >> V[i];
    vector<ll> lcumsum(N + 1, 0), rcumsum(N + 1, 0);
    rep(i, N) {
        lcumsum[i + 1] = lcumsum[i] + V[i];
        rcumsum[i + 1] = rcumsum[i] + V[N - i - 1];
    }
    // cout << 1 << endl;
    ll mx = 0, score;
    rep(l, min(N, K) + 1) {
        rep(r, min(N, K) + 1 - l) {
            ll CD = K - (l + r);
            vector<ll> minus;
            rep(i, l) if (V[i] < 0) minus.push_back(V[i]);
            rep(i, r) if (V[N - i - 1] < 0) minus.push_back(V[N - i - 1]);
            sort(minus.begin(), minus.end());
            score = lcumsum[l] + rcumsum[r];
            rep(i, min(CD, ll(minus.size()))) score -= minus[i];
            mx = max(mx, score);
        }
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int a[6];
int main()
{
	int i,s=0;
	for(i=1;i<=5;i++)
	{
		cin>>a[i];
		if(a[i]<40)s+=40;
		else s+=a[i];
	}
	cout<<s/5<<endl;
	return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

ll Pow(ll n,ll p){
	ll r=1;
	for(;p>0;p>>=1){
		if(p&1) r=(r*n)%mod;
		n=(n*n)%mod;
	}
	return r;
}

const int M=100005;
ll F[M];

void Init(){
	F[0]=1;
	for(int i=1;i<M;i++) F[i]=F[i-1]*i%mod;
}

ll Div(ll n,ll m){
	return n*Pow(m,mod-2)%mod;
}

int n;
vvi g;
vvl dp;

ll f(int x){
	return Div(F[x],Pow(2,x/2)*F[x/2]%mod);
}

int dfs(int v,int p){
	int S=1,B=0;
	vl DP;
	for(auto u:g[v]) if(u!=p){
		int N=dfs(u,v);
		S+=N;
		vl DP_(S+1);
		if(!B){
			for(int i=1;i<=N;i++){
				DP_[i+1]=dp[u][i]%mod;
				if(i%2==0) (DP_[1]+=dp[u][i]*f(i)%mod*(mod-1))%=mod;
			}
			B=1;
		}
		else{
			for(int i=1;i<=S-N;i++) for(int j=1;j<=N;j++){
				(DP_[i+j]+=DP[i]*dp[u][j])%=mod;
				if(j%2==0) (DP_[i]+=DP[i]*dp[u][j]%mod*f(j)%mod*(mod-1))%=mod;
			}
		}
		DP=DP_;
	}
	if(S==1){
		DP=vl(2);
		DP[1]++;
	}
	dp[v]=DP;
	return S;
}

int main(){
	Init();
	cin>>n;
	g=vvi(n);
	dp=vvl(n,vl(n+1));
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	dfs(0,-1);
	ll res=0;
	for(int i=2;i<=n;i++) if(i%2==0) (res+=dp[0][i]*f(i))%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 199680
#include<bits/stdc++.h>
using namespace std;
#define reg register
#define ll long long
inline ll read()
{
	ll x=0,w=0;char ch=getchar();
	while(!isdigit(ch))w|=ch=='-',ch=getchar();
	while(isdigit(ch))x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return w?-x:x;
}
int n;
int G[205][205],a[205],tot;
queue<int>q;
inline int bfs(int u)
{
    q.push(u);a[u]=1;reg int res=0,x,i;
    while(!q.empty())
    {
        x=q.front();q.pop();res=max(res,a[x]);
        for(i=1;i<=n;++i)
        {
            if(G[x][i])
            {
                if(a[i]!=0)
                {
                    if(abs(a[i]-a[x])!=1){return 1000;}
                }
                else
                {
                    a[i]=a[x]+1;q.push(i);
                }
            }
        }
    }
    return res;
}
int main()
{
    n=read();reg int i,j,ans=0;
    for(i=1;i<=n;++i)
        for(j=1;j<=n;++j)
            scanf("%1d",&G[i][j]);
    for(i=1;i<=n;++i)
    {
        memset(a,0,sizeof a);
        ans=max(ans,bfs(i));
    }
    if(ans>n){cout<<"-1\n";}
    else cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 600
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define irep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
using namespace std;
int main() {
    int n,m;
    cin>>n>>m;
    vector<string> a(n),b(m);
    rep(i,n) cin>>a.at(i);
    rep(i,m) cin>>b.at(i);
    
    string ans="No";
    rep(i,n-m+1){
        rep(j,n-m+1){
            bool check=true;
            rep(k,m){
                rep(l,m) {
                    if(b.at(k).at(l)!=a.at(i+k).at(j+l)) check=false;
                }
            }
            if(check) ans="Yes";
        }
    }
    cout<<ans<<endl;
}


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

int main(void)
{
    long n,k;

    scanf("%ld %ld",&n,&k);

    if (k%2==1)
    {
        long p=n/k;
        printf("%ld",p*p*p);
    }
    else if(k%2==0)
    {
        long l=k/2;
        long p=((n/l)+1)/2,q=(n/l)/2;
        printf("%ld",p*p*p+q*q*q);
    }

    return 0;
}

Measured memory_bytes: 128
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		
		int n = int.Parse(Console.ReadLine());
		string s = Console.ReadLine();
		int counter = 1;
		
		for(int i=0;i!=n-1;i++){
			
			if(s.Substring(i, 1) != s.Substring(i+1,1)){
				counter++;
			}
			
		}
		
		Console.WriteLine(counter);
		
	}
}

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

vector<int> factorize (int x) {
    vector<int> ret;
    for (long long i = 2; i * i <= x; i++) {
        while (x % i == 0) {
            ret.push_back(i);
            x /= i;
        }
    }
    if (x > 1) ret.push_back(x);
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<int> ans = factorize(n);
    cout << n << ':';
    for (auto e : ans) cout << ' ' << e; cout << '\n';
    return 0;
}


Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD=1000000007;

int main() {
    int N=0,M; cin>>N>>M;
    vector<int> S(N,-1);
    bool can=true;
    for(int i=0;i<M;i++){
        int s,c; cin>>s>>c;
        if(S[s-1]==-1 || S[s-1]==c){
            S[s-1]=c;
        }
        else{
            can=false;
        }
    }
    if(M==0){
        if(N==1)cout<<0;
    }

    int keta=2;
    if(N>1 && S[0]==-1)S[0]=1;
    for(int i=0;i<N;i++){
        if(S[i]!=-1)keta=min(keta,i);
    }
    if(keta<N-1 && S[keta]==0)can=false;

    if(can){
        for(int i=keta;i<N;i++){
            cout<<max(S[i],0);
        }
    }
    else{
        cout<<-1;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        x: i64,
    }
    for a in 0..=1000 as i64 {
        for b in -1000..=1000 as i64 {
            if a.pow(5) - b.pow(5) == x {
                println!("{} {}", a, b);
                return;
            }
        }
    }
}


Measured memory_bytes: 2168
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <climits>

typedef long long ll;

using namespace std;

void solve(){
    int h, w;
    while(cin >> h >> w){
        if(h == 0 && w == 0){
            return;
        }
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i%2 == 0){
                    if(j%2 == 0){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }else{
                    if(j%2 != 0){
                        printf("#");
                    }else{
                        printf(".");
                    }
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <map>
#include <string>

using namespace std;

int main() {
    map<string, int> m;
    int n;  cin >> n;
    string s;   
    for (int i = 0; i < n; i++) {
        cin >> s;
        m[s]++;
    }

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

    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define si(X) scanf("%d", &(X))
#define sll(X) scanf("%lld",&(X))
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int mod = 1e9+7;
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll expo(ll base,ll pow){ll ans = 1;
   while(pow!=0){if(pow&1==1){ans = ans*base;ans = ans%mod;}
   base *= base;base%=mod;pow/=2;}return ans;}
ll inv(ll x){return expo(x,mod-2);}
ull llrand() {ull r = 0;for(int i = 0; i < 5; ++i){r = (r << 15)|(rand() & 0x7FFF);}return r & 0xFFFFFFFFFFFFFFFFULL;}
int dx[8] = {1 , 0 , -1 , 0 , 1 , -1 , -1 , 1};    // last 4 diagonal
int dy[8] = {0 , 1 , 0 , -1 , 1 , 1 , -1 , -1};
/*---------------------------------------------------------------------------------------------------------------------*/

const int M = 100001;

int main(){
    int r;
    si(r);

    if(r < 1200){
        cout<<"ABC";
        return 0;
    }

    if(r < 2800){
        cout<<"ARC";
        return 0;
    }


        cout<<"AGC";
      //  return;


}


Measured memory_bytes: 256
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
#Union Find
N,M,K = inputlist()
graph = [[] for _ in range(N)]
#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]
#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)

    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

#初期化
#根なら-size,子なら親の頂点
par = [-1]*(N)
for i in range(M):
    A,B = inputlist()
    graph[A-1].append(B-1)
    graph[B-1].append(A-1)
    unite(A-1,B-1)
bgraph = [[] for _ in range(N)]
for i in range(K):
    C,D = inputlist()
    if same(C-1,D-1):
        bgraph[C-1].append(D-1)
        bgraph[D-1].append(C-1)
li = [0]*N
for i in range(N):
    k = size(i)
    n = len(graph[i])
    m = len(bgraph[i])
    li[i] = k-n-m-1
print(*li)

Measured memory_bytes: 118816
#include <bits/stdc++.h>  // include all standard C++ libraries

using namespace std;

// Loops
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define _rrep(i,n) rrepi(i,n,0)
#define rrepi(i,a,b) for(int i=int(a)-1;i>=int(b);--i)

#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(xi, x) for (auto&& xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)


// typedef
using ll = long long;
template <class T> using vec = vector<T>;
using vi   = vector<int>;
using vvi  = vector<vi>;
using vvvi = vector<vvi>;
using pii  = pair<int, int>;


// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second


// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase( unique(all(v)), v.end() )
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

template<class T> pair<T, size_t> max(vector<T> &x){ auto it = max_element(all(x)); return mp(*it, it-x.begin()); }
template<class T> pair<T, size_t> min(vector<T> &x){ auto it = min_element(all(x)); return mp(*it, it-x.begin()); }

template<class T> inline bool chmax(T &maxval, const T &newval) { if (maxval<newval) { maxval=newval; return 1; } return 0; }
template<class T> inline bool chmin(T &minval, const T &newval) { if (minval>newval) { minval=newval; return 1; } return 0; }

// Utilities
// Grid world utilities
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
#define inside(H,W,y,x) 0<=(x) && (x)<(W) && 0<=(y) && (y)<(H)

inline int in() {int x; cin >> x; return x;} // read int from cin
inline  ll IN() {ll x; cin >> x; return x;}  // read ll from cin



// Debug
#ifdef LOCAL
  #include "dump.hpp"
  #define debug(x) cerr << #x << ": " << x << '\n'
#else
  #define dump(...)
  #define debug(x)
#endif

// Paste snippets here!!

// 

int main(){
  cin.tie(0); ios::sync_with_stdio(false);    // Magic for faster cin
  string s, t;
  cin >> s >> t;
  int n = s.size();
  vi ss(n);
  vi tt(n);
  unordered_map<char,int> ds, dt;

  bool ans = true;
  rep(i,n){
    if(ds.find(s[i])==ds.end()) ds[s[i]] = ds.size();
    if(dt.find(t[i])==dt.end()) dt[t[i]] = dt.size();
    ss[i] = ds[s[i]];
    tt[i] = dt[t[i]];
    if(ss[i] != tt[i]){ ans = false; break; }
  }
  //if(ans){

  //}

  cout << (ans?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 2452
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, loop = 1;
    cin >> n;
    for(int i = 1; i <= n; ++i) loop *= i;
    vector<int> p(n), q(n), a(n);
    for(int i = 0; i < n; ++i) cin >> p.at(i);
    for(int i = 0; i < n; ++i) cin >> q.at(i);
    for(int i = 0; i < n; ++i) a.at(i) = i + 1;
    int cnt = 0, pa = 0, qb = 0;
    do{
        if(a == p) pa = cnt;
        if(a == q) qb = cnt;
        cnt++;
    }while(next_permutation(a.begin(), a.end()));
    cout << abs(pa - qb) << endl;
    return 0;
}

Measured memory_bytes: 3528
package main

import "fmt"

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

	heights := make([]int, N+1)
	for i := 1; i <= N; i++ {
		var h int
		fmt.Scan(&h)
		heights[i] = h
	}

	goodTowers := make(map[int]bool)
	for i := 1; i <= N; i++ {
		goodTowers[i] = true
	}

	for i := 0; i < M; i++ {
		var a, b int
		fmt.Scan(&a, &b)
		if heights[a] == heights[b] {
			delete(goodTowers, a)
			delete(goodTowers, b)
		}
		if heights[a] > heights[b] {
			delete(goodTowers, b)
		}
		if heights[a] < heights[b] {
			delete(goodTowers, a)
		}
	}

	fmt.Println(len(goodTowers))
}


Measured memory_bytes: 8072
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<map>
using namespace std;

int s[100];

int main(){
	s[1] = 1;
	s[3] = 1;
	s[5] = 1;
	s[7] = 1;
	s[8] = 1;
	s[10] = 1;
	s[12] = 1;
	s[4] = 2;
	s[6] = 2;
	s[9] = 2;
	s[11] = 2;
	s[2] = 3;
	int x,y;
	scanf("%d %d",&x,&y);
	if(s[x] == s[y]) printf("Yes");
	else printf("No");
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>

using namespace std;

const int nmax = 105;
int v[nmax];

int main() {
    int n;
    cin >> n;
    int s = 0;
    for(int i = 1;i <=n;i ++) {
        cin >> v[i];
        s += v[i];
    }
    sort(v+1,v+n+1);
    int i = 1;
    if(s % 10 == 0) {
        while(i <= n && v[i] % 10 == 0)
            i ++;
        if(i <= n)
            s -= v[i];
        if(s  % 10 == 0)
            s = 0;
    }
    cout << s;
    return 0;
}


Measured memory_bytes: 256