akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main(int argc, char *argv[]){
  int n, m, l;
  while(cin >> l, l){
    int sum = 0, month = 13;
    for (int i = 0; i < 12; i++) {
      cin >> n >> m;
      sum += n - m;
      if(sum >= l && month > i){
        month = i + 1;
      }
    }
    if(month <= 12){
      std::cout << month << std::endl;
    }else{
      std::cout << "NA" << std::endl;
    }
  }
  return 0;
}

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

long long dmax;
long long a, b;

void damage(long long l);

int main()
{

    long long x, p;
    int n;
    cin >> n >> a >> b >> x;

    while (--n) {
        p = x;
        cin >> x;
        damage(x - p);
    }

    cout << dmax;
    return 0;
}

void damage(long long l)
{
    dmax += min(b, l * a);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define       M                        1000000007
  #define       ll                       long long
  #define       FIO                      ios_base::sync_with_stdio(false);cin.tie(NULL)
  #define       ifor(st,lim)             for(int i=st;i<lim;i++)
  #define       jfor(stt,llim)           for(int j=stt;j<llim;j++)
  #define       eifor(st,lim)            for(int i=st;i<=lim;i++)
  #define       ejfor(stt,llim)          for(int j=stt;j<=llim;j++)
  #define       blank                    cout<<'\n' 

  void solve()
  {
     float d,t,s; cin>>d>>t>>s;
     float x = d/s;
     if(x <= t) { cout<<"Yes"; return; }
     else cout<<"No";
  }

  int main()
  {
  #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
  int t=1; 
    while(t--){
      solve();
     } 
  }

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

int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	for(auto &i:P)cin >> i;
	int ans=0;
	for(int i=1;i<N-1;i++){
		if(P[i-1]<P[i] && P[i]<P[i+1])ans++;
		else if(P[i-1]>P[i] && P[i]>P[i+1])ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

bool next_va(vector<int> &va, int m) {
  int i = va.size() - 1;
  while (i >= 0 && va[i] >= m) {
    i--;
  }

  if (i < 0) {
    return false;
  }

  va[i]++;
  fill(va.begin() + i, va.end(), va[i]);
  return true;
}

int calc_rank(vector<int> &va, vector<array<int, 4>> &requirements) {
  int ans = 0;
  for (auto [a, b, c, d] : requirements) {
    if (va[b] - va[a] == c) {
      ans += d;
    }
  }

  return ans;
}

int main(int argc, const char *argv[]) {
  int n, m, q;
  cin >> n >> m >> q;

  vector<array<int, 4>> requirements(q);
  for (auto &r : requirements) {
    cin >> r[0] >> r[1] >> r[2] >> r[3];
    r[0]--;
    r[1]--;
  }

  vector<int> va(n, 1);
  int ans = 0;
  do {
    ans = max(ans, calc_rank(va, requirements));
  } while (next_va(va, m));

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

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main()
{	
  int n;
  cin>>n;
  int a[n];
  for(int i=0;i<n;i++)
  {	cin>>a[i];
    if(a[i]%2==1)
    {	
      cout<<"first";
      return 0;
    }
  }
  cout<<"second";
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const bool debug =0;

inline void read(long long &x){
    char ch;
    bool flag=false;
    for (ch=getchar();!isdigit(ch);ch=getchar())if (ch=='-') flag=true;
    for (x=0;isdigit(ch);x=x*10+ch-'0',ch=getchar());
    x=flag?-x:x;
}

inline void write(long long x){
    static const long long maxlen=100;
    static char s[maxlen];
    if (x<0) {   putchar('-'); x=-x;}
    if(!x){ putchar('0'); return; }
    long long len=0; for(;x;x/=10) s[len++]=x % 10+'0';
    for(long long i=len-1;i>=0;--i) putchar(s[i]);
}

const long long MAXN = 1100000;

long long a[ MAXN ];
long long b[ MAXN ];
long long n;

typedef pair<long long,long long> PII;
priority_queue< PII > Q;

int main(){
    read(n);
    for (long long i=0;i<n;i++)
        read(a[i]);

    for (long long i=0;i<n;i++)
    {
        read(b[i]);
        Q.push( make_pair( b[i] , i  ) );
    }

    long long cnt=0;
    while (Q.size())
    {
        PII tmp=Q.top();
        Q.pop();

        long long val=tmp.first;
        long long id=tmp.second;
        if ( val == a[id] )
            continue;

        if ( val < b[ (id+n-1)%n ] + b[ (id+1)%n ] + a[id] )
        {
            puts("-1");
            exit(0);
        }

        long long sum=b[ (id+n-1)%n ] + b[ (id+1)%n ];

        long long kkk=( val - a[id] ) / sum ;
        cnt+=kkk;
        val = val - kkk*sum ;

        b[id]=val;
        Q.push( make_pair( val , id ) );
    }

    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 9584
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string x, y;
	cin >> x;
	cin >> y;
	for (int i = 0; i < x.size(); i++){
		cout << x[i];
		if (i==y.size()){
			break;
		}
		cout << y[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <numeric>
#include <vector>
	#include<math.h>
	//#include <algorithm>
	//#include <functional>
	#include <numeric>
	//#include<cmath>
//#include <stdio.h> 
#include <cstdint>
	#include <string>
	//#include <cstdlib>
	//#define pi 3.14159265359
#include <iomanip>
//#include <bits/stdc++.h>
using namespace std;


int main() {

	int a;
    cin >> a;
	int num = 0;
    vector<int> b(a);
    for (int i = 0; i < a; i++) {
    	cin >> b[i];
		if (b[i] % 2 == 0) {
			if (b[i] % 3 != 0 && b[i] % 5 != 0) {
				num = 1;
			}
		}
    }

	if (num == 0) {
		cout << "APPROVED";
	}
	else {
		cout << "DENIED";
	}

	return 0;

}

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

int main() {
    ll N; cin >> N;
    vector<ll> a(3*N);
    for (int i = 0; i < 3*N; i++) {
        cin >> a[i];
    }
    vector<ll> S(2*N+1, 0), T(2*N+1, 0); 
    //S[i]は先頭からi個の要素の内大きいものからN個
    //T[i]は末尾からi個の要素のうち大きいものからN個選んだ時の総和
    //ans = S[i]-T[3N-i] i = N-1...2N-1
    ll ans = -(1LL << 60);
    priority_queue<ll, vector<ll>, greater<ll>> que1;
    //左からi個の内大きい順にn個を選ぶ
    for (int i = 0; i < N; i++) {
        que1.push(a[i]);
        S[i+1] = S[i]+a[i];
    } 
    for (int i = N; i < 2*N; i++) {
        ll mi = que1.top();
        if (a[i] >mi) {
            S[i+1] = S[i] - mi + a[i];
            que1.pop();
            que1.push(a[i]);
        }
        else S[i+1] = S[i];
    }
    
    priority_queue<ll> que2;
    for (int i = 0; i < N; i++) {
        que2.push(a[3*N-1-i]);
        T[i+1] = T[i]+a[3*N-1-i];
    }
    for (int i = N; i < 2*N; i++) {
        ll ma = que2.top();
        if (a[3*N-1-i] < ma) {
            T[i+1] = T[i] - ma + a[3*N-1-i];
            que2.pop();
            que2.push(a[3*N-1-i]);
        }
        else T[i+1] = T[i];
    }

    for (int i = N; i <= 2*N; i++) {
        ans = max(ans, S[i]-T[3*N-i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 8052
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
#include <iomanip>
#include <numeric>
using namespace std;

#define INF 1e18
#define int long long

template<typename T>
void printVec(vector<T> &v) {
    for(int i = 0; i < v.size(); i++) {
        cout << v[i] << " ";
    }
    cout << endl;
}

signed main() {
    int r;
    cin >> r;

    cout << pow(r, 2) << endl;
    return 0;
}


Measured memory_bytes: 256
import Data.List

check :: [[Int]] -> [Bool]
check x
  | x == [] = []
  | ((head x) !! 0)^2 +	((head x) !! 1)^2 == ((head x) !! 2)^2 = True :	check (tail x)
  | otherwise = False :	check (tail x)

solve :: [Int] -> [String]
solve (x:y:z:xs)
  | xs == [] = []
  | or $ check $ permutations [x,y,z] = "YES"	: solve	xs
  | otherwise	= "NO" : solve xs

main = getContents >>= mapM_ putStrLn . solve . (++[-1,-1,-1]) . map read . tail . words

Measured memory_bytes: 4268
NM = input().split()
N = int(NM[0])
M = int(NM[1])
L = input().split()
H_list = list(map(int, L))

lower_set = set() #低いものに属すもの最後に全体から引き算

for i in range(M):
    AB = input().split()
    A_offset = int(AB[0]) - 1
    B_offset = int(AB[1]) - 1

    if H_list[A_offset] - H_list[B_offset] > 0:
        lower_set.add(AB[1])
    elif H_list[A_offset] - H_list[B_offset] == 0:
        lower_set.add(AB[0])
        lower_set.add(AB[1])
    else:
        lower_set.add(AB[0])

print(N - len(lower_set))


Measured memory_bytes: 26496
n, m, x = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(n)]
ans = 193934993409409
for mask in range(2 ** n):
    C = [0] * m
    cst = 0
    for i in range(n):
        if (mask >> i) & 1:
            cst += X[i][0]
            for j in range(1, m + 1):
                C[j - 1] += X[i][j]
    if min(C) >= x:
        ans = min(ans, cst)
if ans < 91912922191:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 9220
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
D = Counter(A)
ans = 0
cnt = 0
for i in D.values():
    if i % 2 == 0:
        ans += (i-2)//2
        cnt += 1
    else:
        if i == 1:
            continue
        ans += (i-3)//2+1
print(n-ans*2-2*((cnt+1)//2))

Measured memory_bytes: 18648
#include<bits/stdc++.h>
#define ll long long
#define maxN 100100
using namespace std;
vector<ll> a[maxN];
vector <ll> ::iterator it;
ll d[maxN],c[maxN],n,m,i,p,y;
string chuyen(ll x)
{
	string s="";
	while(x)
	{
		s=(char)(x%10+'0')+s;
		x/=10;
	}
	while(s.length()<6) s='0'+s;
	return s;
}
int main()
{
//	freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    cin>>n>>m;
    for(i=1;i<=m;i++) 
      {
      	 cin>>p>>y;
      	 a[p].push_back(y);
      	 d[i]=p;
      	 c[i]=y;
	  }
	for (i=1;i<=n;i++) 
		if (a[i].size()) sort(a[i].begin(),a[i].end());
	for (i=1;i<=m;i++)
	{
		cout<<chuyen(d[i]);
		it=lower_bound(a[d[i]].begin(),a[d[i]].end(),c[i]);
		cout<<chuyen(it-a[d[i]].begin()+1)<<endl;	
	}
	return 0;
}


Measured memory_bytes: 8576
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MOD 1000000007

struct Edge {
  int src, dest;
  ll weight;
};
bool operator>(const Edge& a, const Edge& b){
  return a.weight > b.weight;
}

#define INF 100000000000000000LL

int N, M;
int S, T;
vector<Edge> G[100005];
ll costS[100005];
ll costT[100005];
ll dpS[100005];
ll dpT[100005];

void dijkstra(int start, int goal, ll* cost){
  rep(i,N+1){
    cost[i] = INF;
  }
  priority_queue<Edge,vector<Edge>,greater<Edge>> q;
  q.push((Edge){-1,start,0});
  
  ll min_time = 0;
  while(!q.empty()){
    Edge e=q.top();
    q.pop();
    if(cost[e.dest] != INF) continue;
    cost[e.dest]=e.weight;
    FOR(it,G[e.dest])
      if(cost[it->dest]==INF) q.push((Edge){it->src,it->dest,e.weight+it->weight});
  }
}

int dfs(int node, ll* cost, ll* dp){
  if(dp[node] != -1) return dp[node];
  if(cost[node] == 0) return dp[node] = 1;
  int ret = 0;
  FOR(it,G[node]){
    int dest = it->dest;
    ll weight = it->weight;

    if(cost[dest] + weight == cost[node]){
      ret += dfs(dest, cost, dp);
      ret %= MOD;
    }
  }
  return dp[node] = ret;
}


int main(){
  cin >> N >> M;
  cin >> S >> T;
  rep(i,M){
    int u, v;
    ll d;
    cin >> u >> v >> d;
    G[u].push_back((Edge){u,v,d});
    G[v].push_back((Edge){v,u,d});
  }

  rep(i,100005){
    dpS[i] = dpT[i] = -1;
  }
  
  dijkstra(S, T, costS);
  dijkstra(T, S, costT);

  dfs(T, costS, dpS);
  dfs(S, costT, dpT);

  ll ans1 = (dpS[T]%MOD) * (ll)(dpS[T]%MOD);
  ans1 %= MOD;
  ll ans2 = 0;
  
  rep(i,N){
    int node = i+1;

    if(2LL * costS[node] == costS[T]){
      ans2 += (((dpS[node]%MOD * (ll)(dpS[node]%MOD))%MOD) *
        ((dpT[node]%MOD * (ll)(dpT[node]%MOD))%MOD))%MOD;
      ans2 %= MOD;
    }
    
    FOR(it,G[node]){
      int dest = it->dest;
      ll weight = it->weight;
      if(costS[dest] + weight != costS[node]) continue;
      if(dpS[dest] == -1 || dpS[node] == -1) continue;
      if(dpT[dest] == -1 || dpT[node] == -1) continue;
      if(2LL * costS[dest] < costS[T] && costS[T] < 2LL * costS[node]){
        ans2 += (((dpS[dest]%MOD * (ll)(dpS[dest]%MOD))%MOD) *
                 ((dpT[node]%MOD * (ll)(dpT[node]%MOD))%MOD))%MOD;
        ans2 %= MOD;
      }
    }
  }

  ans1 += MOD - ans2;
  ans1 %= MOD;

  cout << ans1 << endl;
  return 0;
}



Measured memory_bytes: 24000
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   double t,x;
   cin >> t >> x;

   printf("%.10f\n",t/x);




   return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include<string>
#include<iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    if(s=="Sunny"){
        cout << "Cloudy";
    }
    if(s=="Cloudy"){
        cout << "Rainy";
    }
    if(s=="Rainy"){
        cout << "Sunny";
    }    return 0;
}

Measured memory_bytes: 256
# 谷の発生→ans += (直前の山の高さ - 谷の高さ)
# 最後に残っている直前の山の高さをansに加える

N = gets.to_i
arr = gets.split.map(&:to_i)
pre = arr[0]
ans = 0
1.upto(N-1) do |i|
  if arr[i] > arr[i-1]
    if pre > arr[i-1]
      ans += pre - arr[i-1]
    end
    pre = arr[i]
  end
end
ans += pre
puts ans

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

using namespace std;
 

int main()
{
  int N; cin >> N;
  vector<int> v;
  for (int i=0; i<N; i++) 
  {
    int a; cin >> a;
    v.push_back(a);
  }

  vector<int> ans(N);
  int count = 0;
  stringstream ss;
  for (int i=v.size()-1; i >= 0; i--) 
  {
    
    int sum = 0;
    for (int j=i; j<N; j += i+1) sum += ans[j];
    
    if (v.at(i) == sum%2) continue;      
    
    ans[i]++;
    count++;
    ss << i+1 << " ";
    
  }
  
  cout << count << endl;
  cout << ss.str() << endl;
  
}


Measured memory_bytes: 4216
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int h, w;
char c[510][510];

int main(){
    scanf("%d%d", &h, &w);
    rep(i, h)rep(j, w) scanf(" %c", &c[i][j]);
    set<pii> S;
    int ans = 0;
    while(true){
        bool flag = false;
        rep(x, h)rep(y, w)if(c[x][y] == '.' && S.find({x, y}) == S.end()){
            vector<pii> v;
            for(int i=x-1; i>=0; --i)if(c[i][y] != '.'){
                v.emplace_back(i, y);
                break;
            }
            for(int i=x+1; i<h; ++i)if(c[i][y] != '.'){
                v.emplace_back(i, y);
                break;
            }
            for(int j=y-1; j>=0; --j)if(c[x][j] != '.'){
                v.emplace_back(x, j);
                break;
            }
            for(int j=y+1; j<w; ++j)if(c[x][j] != '.'){
                v.emplace_back(x, j);
                break;
            }
            if(v.size() <= 1){
                S.emplace(x, y);
                continue;
            }
            int cnt = 0;
            rep(i, v.size()){
                auto p = v[i];
                For(j, i+1, v.size()){
                    auto q = v[j];
                    if(c[p.fi][p.se] == c[q.fi][q.se] && c[p.fi][p.se] != '.'){
                        cnt += 2;
                        c[p.fi][p.se] = c[q.fi][q.se] = '.';
                        flag = true;
                    }
                }
            }
            ans += cnt;
        }
        if(!flag) break;
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 15184
#include <stdio.h>

int main() {
	int A, B, K, i, tmp;

	scanf("%d %d %d", &A, &B, &K);

	if (A > B) {
		tmp = A;
		A = B;
		B = tmp;
	}

	for (i = A; K > 0 && i > 0; i--) {
		if (A % i == 0 && B % i == 0) {
			K--;
		}
	}

	i++;

	printf("%d", i);

	return 0;
}

Measured memory_bytes: 128
from typing import List, Callable
# verified @AOJ ALDS1_6_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_A&lang=jp
def counting_sort_destructive(L: List[int], k: int, key: Callable[[int], int] =lambda x: x) -> None:
    """
    counting_sort() の破壊関数版

    Args:
        L (list)
        k (int): L の要素は 0 to k であると仮定する
        key (function): key が指定されている場合、key を L の各要素に適用してからソートを行う

    Raises:
        ValueError: L の要素のいずれかが 0 <= x <= k を満たしていなかった場合

    Examples:
        >>> seq = [1, 3, 5, 10, 4, 6, 15, 7, 2, 0] 
        >>> counting_sort_destructive(seq, 15)    # 0 to 15
        >>> seq
        [0, 1, 2, 3, 4, 5, 6, 7, 10, 15]
    """
    if any(map(lambda x: key(x) < 0 or key(x) > k, L)):
        raise ValueError(f"counting_sort_destructive(): key(x) (x: element of L) should be 0 <= key(x) <= k. got k: {k}")

    n = len(L)
    accum_sum_memo = [0] * (k + 1)    # 0 to k なので

    for i in range(n):
        accum_sum_memo[key(L[i])] += 1
    for i in range(1, k+1):
        accum_sum_memo[i] += accum_sum_memo[i-1]
    
    tmp = tuple(L)    # もとの L のメモは変更されてはならない！
    for j in range(n-1, -1, -1):
        L[accum_sum_memo[key(tmp[j])] - 1] = tmp[j]
        accum_sum_memo[key(tmp[j])] -= 1    # 同じ値のものが来た時、一つ前の位置におさまるように調節してやる



# partially verified @AOJ ALDS1_6_A
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_6_A&lang=jp
def radix_sort(L: List[int], bucket_bit_size: int=8) -> None:
    """
    bucket_size = 2 ** bucket_bit_size とする (除算を避けビットシフトのみで実装するため、bucket_size は 2 の冪を仮定している)
    O(digit_length * (n + bucket_size)) で L を安定的かつ破壊的に基数ソートする (digit_length = log(n, bucket_size) である)
    
    Args:
        L (list)
        bucket_bit_size (int): L の各値を何 bit ごとに分けて基数ソートを行うかの値
    
    Raises:
        ValueError: L に負の値が含まれているとき

    Examples:
        >>> seq = [4321, 5500, 8686, 5586, 1234, 1235, 0, 24, 7, 1000000007]
        >>> radix_sort(seq, bucket_bit_size=8)
        >>> seq
        [0, 7, 24, 1234, 1235, 4321, 5500, 5586, 8686, 1000000007]
    """
    if any(map(lambda x: x < 0, L)):
        raise ValueError(f"radix_sort(): element of L should be positive. got L: {L}")
    if L:
        M = max(L)
        # 各整数を bucket_bit_size ビットごとに区切ると最大で何個のかたまりになりうるか
        max_digit_chank = (M.bit_length() + bucket_bit_size - 1) // bucket_bit_size
        # bucket_bit_size ビット分が 1 埋めされた bit mask
        mask = (1 << bucket_bit_size) - 1    # bit shift は +, - より優先度が低いので注意
        for i in range(max_digit_chank):
            key_func = lambda x: (x >> (i * bucket_bit_size)) & mask
            counting_sort_destructive(L, mask, key_func)




if __name__ == "__main__":
    n = int(input())
    L = list(map(int, input().split()))
    radix_sort(L, 16)
    print(*L, sep=' ')


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

const int DIM = 1e2 + 5;

int arr[DIM];

int main( void ) {
    
    int n;
    cin >> n;
    
    for( int i = 1; i <= n; i ++ )
        cin >> arr[i];
    
    int ans = INT_MAX;
    for( int k = -DIM; k <= +DIM; k ++ ) {
        int cst = 0;
        
        for( int i = 1; i <= n; i ++ )
            cst += (arr[i] - k) * (arr[i] - k);
        
        ans = min( ans, cst );
    }
    
    cout << ans << endl;
    return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var sc = new Scanner();

        var n = sc.nextInt();
        var w = new int[n];
        long sum = 0;
        for (int i = 0; i < n; i++)
        {
            w[i] = sc.nextInt();
            sum += w[i];
        }

        long gap = sum;
        long ans = long.MaxValue;
        for (int i = 0; i < n; i++)
        {
            gap = gap -= w[i] * 2;
            ans = Math.Min(ans, Math.Abs(gap));
        }

        Console.WriteLine(ans);
    }
}

// chokudai's Scanner
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

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

using namespace std;

int main() {
	string max = "";
	string mode;
	map <string, int> str;
	int count = 0;
	string a;
	while(cin >> a) {
		if(a == "EOF") {
			break;
		}
		if(a.size() > max.size()) {
			max = a;
		}
		str[a]++;
		if(str[a] > count) {
			count = str[a];
			mode = a;
		}
	}
	cout << mode << " " << max << endl;

	return 0;
}

Measured memory_bytes: 1200
# AtCoder Beginner Contest 138 D - Ki　
import sys
sys.setrecursionlimit(10 ** 9)

N, Q = map(int, sys.stdin.readline().strip().split())

M = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, sys.stdin.readline().strip().split())
    M[a - 1].append(b - 1)
    M[b - 1].append(a - 1)

X = [0] * N
for _ in range(Q):
    p, x = map(int, sys.stdin.readline().strip().split())
    X[p - 1] += x


fp = [True] * N  # 探索可能な点か記録する。
ans = [0] * N


def dfs(u, x):
    ans[u] += x
    fp[u] = False
    for v in M[u]:
        if fp[v]:
            dfs(v, x + X[v])


dfs(0, X[0])
print(' '.join([str(i) for i in ans]))


Measured memory_bytes: 245688
package main

import "fmt"

type dice struct {
	sur [6]int8
}

func (d *dice) Scan() {
	for i := 0; i < 6; i++ {
		fmt.Scan(&d.sur[i])
	}
	return
}

func (d *dice) Move(dir rune) {
	nd := *d
	switch dir {
	case 'E':
		d.sur[0] = nd.sur[3]
		d.sur[2] = nd.sur[0]
		d.sur[3] = nd.sur[5]
		d.sur[5] = nd.sur[2]
	case 'N':
		d.sur[0] = nd.sur[1]
		d.sur[1] = nd.sur[5]
		d.sur[4] = nd.sur[0]
		d.sur[5] = nd.sur[4]
	case 'S':
		d.sur[0] = nd.sur[4]
		d.sur[1] = nd.sur[0]
		d.sur[4] = nd.sur[5]
		d.sur[5] = nd.sur[1]
	case 'W':
		d.sur[0] = nd.sur[2]
		d.sur[2] = nd.sur[5]
		d.sur[3] = nd.sur[0]
		d.sur[5] = nd.sur[3]
	}
	return
}

func (d *dice) Judge(target *dice) bool {
	for i := 0; i < 6; i++ {
		if d.sur[i] != target.sur[i] {
			return false
		}
	}
	return true
}

func (d *dice) Roll(target *dice, depth int) bool {
	if depth >= 4 {
		return false
	}
	for i := 0; i < 4; i++ {
		nd := *d
		switch i {
		case 0:
			nd.Move('E')
		case 1:
			nd.Move('N')
		case 2:
			nd.Move('W')
		case 3:
			nd.Move('S')
		}
		if nd.Judge(target) || nd.Roll(target, depth+1) {
			return true
		}
	}
	return false
}

func main() {
	var n int8
	fmt.Scan(&n)
	dices := make([]dice, n)
	for i := int8(0); i < n; i++ {
		dices[i].Scan()
	}
	for i := int8(1); i < n; i++ {
		if dices[i].Roll(&dices[0], 0) {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
	return
}



Measured memory_bytes: 1420
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new MyInputStream(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(MyInputStream cin)
        {
            var N = cin.ReadInt();
            var A = cin.ReadInt();
            if (N % 500 <= A) WriteLine("Yes");
            else WriteLine("No");
        }
    }

    public class MyInputStream
    {
        private readonly System.IO.TextReader _stream;
        private char separator = ' ';
        private Queue<string> inputStream;
        public MyInputStream(System.IO.TextReader s, char separator = ' ')
        {
            this.separator = separator;
            this._stream = s;
            inputStream = new Queue<string>();
        }
        public string Read()
        {
            if (inputStream.Count != 0) return inputStream.Dequeue();
            string[] tmp = _stream.ReadLine().Split(separator);
            for (int i = 0; i < tmp.Length; ++i)
                inputStream.Enqueue(tmp[i]);
            return inputStream.Dequeue();
        }
        public string ReadLine() { return _stream.ReadLine(); }
        public int ReadInt() { return int.Parse(Read()); }
        public long ReadLong() { return long.Parse(Read()); }
        public double ReadDouble() { return double.Parse(Read()); }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read(); return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt(); return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong(); return ret;}
    }
}


Measured memory_bytes: 11220
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 1e5 + 20, mod = 1e9 + 7;

int n, k, dp_suffix[MAX_N], dp_prefix[MAX_N], seq[MAX_N];

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

    for (int i = 1; i <= n; i++)
        scanf("%d", &seq[i]);
    long long answer = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = i + 1; j <= n; j++)
            if (seq[i] > seq[j])
                dp_suffix[i]++;
        for (int j = 1; j < i; j++)
            if (seq[i] > seq[j])
                dp_prefix[i]++;
        int coe = ((1LL * k * (k + 1)) >> 1) % mod;
        answer = (answer + 1LL * coe * dp_suffix[i] % mod + 1LL * (coe - k + mod) % mod * dp_prefix[i] % mod) % mod;
    }
    printf("%lld", answer);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <stack>
#include <queue>
using namespace std;

int a, b;

signed main() {
	cin >> a >> b;
	
	int i, num = 1;
	for (i = 0; num < b; i++) {
		num += a - 1;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;


int main(void){
  int n,m,i,x[100005],ans=0;
  vector<int> d;
  
  cin >> n >> m;
  for (i=0;i<m;i++) cin >> x[i];
  
  sort(x,x+m);
  
  for (i=0;i<m-1;i++) d.push_back(x[i+1]-x[i]);
  
  sort(d.begin(),d.end());
  
  for (i=0;i<m-n;i++) ans+=d[i];
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

ll power(ll n, ll p, ll mod) {
    ll ans = 1;
    while (p > 0) {
        if (p & 1) ans = ans * n % mod;
        n = n * n % mod;
        p >>= 1;
    }
    return ans;
}

int main() {
    int n, a, b; cin >> n >> a >> b;

    ll fac[max(a, b)];
    fac[0] = 0; fac[1] = n;
    REP(i, 2, max(a, b) + 1) fac[i] = fac[i - 1] * (n - i + 1) % MOD;

    ll ca = fac[a];
    REP(i, 1, a + 1) ca = ca * power(i, MOD - 2, MOD) % MOD;
    ll cb = fac[b];
    REP(i, 1, b + 1) cb = cb * power(i, MOD - 2, MOD) % MOD;
    ll ans = power(2, n, MOD) - 1 - ca - cb;
    if (ans >= 0) cout << ans % MOD << endl;
    else cout << ans % MOD + MOD << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}


int main(){
    ll h,w; cin >> h >> w;
    ll k; cin >> k;
    vector<vector<ll>> dp(h+3,vector<ll>(w+3,0));
    ll fib[10];
    fib[0] = 1;fib[1] = 2;
    for(int i = 2;i < 10;i++)fib[i] = fib[i-1] + fib[i-2];

    auto count = [&](int x){
        if(x < 0)return fib[0];
        else return fib[x];
    };
    dp[0][1] = 1;
    rep(i,h+1){
        if(i < 1)continue;
        rep(j,w+1){
            if(j == 0)continue;
            // if(i == 1)
            dp[i][j] += (dp[i-1][j-1] * count(j-3) * count(w-j-1))%MOD;
            dp[i][j] += (dp[i-1][j] * count(j-2) * count(w-j-1))%MOD;
            dp[i][j] += (dp[i-1][j+1] * count(j-2) * count(w-j-2)) % MOD;
            dp[i][j] %= MOD;
        }
    }

    // print(dp);
    cout << dp[h][k] << endl;
    return 0;
}

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

int main(){
    int n,k;
    cin>>n>>k;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    int dp[n];
    dp[0] = 0;
    for(int i=1;i<n;i++){
        int t = min(i,k);
        int mindiff = INT32_MAX;
        for(int j=t;j>0;j--){
            int diff = abs(h[i]-h[i-j]) + dp[i-j];
            mindiff = min(mindiff,diff);
        }
        // cout<<dp[i]<<" ";
        dp[i] = mindiff;
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1024
# include<iostream>
# include <cstdio>
# include <cstring>
using namespace std;
typedef struct Node{
    long long h,u;
} AA;


int main(void){
    // freopen("aaa.in","r",stdin);
    long long N;
    int ans = 0;
    scanf("%lld",&N);
    AA A[20];
    for (int i=1,a;i<=N;i++){
        scanf("%d",&a);
        A[i].u = A[i].h = 0;
        for (int j=1,x,y;j<=a;j++){
            scanf("%d%d",&x,&y);
            if (y==1) A[i].h|=(1<<(x-1));
            else A[i].u|=1<<(x-1);
        }
        // cout<<A[i].h<<" "<<A[i].u<<endl;
    }
    long long K = (1<<N)-1;
    // cout<<K<<endl;
    for (long long i=0;i<(1<<N);i++)
    {
        bool flag = true;
        for (int j=1;j<=N;j++){
            if ((i&(1<<(j-1)))==0) continue;    
            if ((A[j].h|i)>i) {flag = false;break;}  
            // cout<<i<<"  "<<j<<endl;
            long long zz = (~i)&K;
            if ((A[j].u|zz)>zz) {flag = false;break;} 
            // cout<<i<<" "<<zz<<endl;
        }
        // cout<<flag<<endl;
        if (!flag) continue;
        int temp = 0;
        for (int j=0;j<N;j++) if ((1<<j)&i) temp++;
        ans = max(ans,temp);
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, K, Q; cin >> N >> K >> Q;
  int surv[N] = {}, A, thr = Q - K;
  for(int i = 0; i < Q; i++){
    cin >> A;
    surv[A - 1] += 1;
  }
  for(int i = 0; i < N; i++){
    if(surv[i] > thr) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 1024
import sys
sys.setrecursionlimit(2**31-1)
input = sys.stdin.readline
write = lambda x: sys.stdout.write(str(x))
LMIIS = lambda : list(map(int,input().split()))
II = lambda : int(input())
dbg = lambda *something : print(*something) if DEBUG is True else 0
DEBUG = False

def main():

    N = II()
    t = [-1] * N


    E = [  [] for _ in range(N)]
 
    reached = [False] * N
    for _ in range(N-1):
        u,v,w = LMIIS()
        u -=1
        v -=1
        E[u].append((v,w))
        E[v].append((u,w))
    dbg(E)
    t[E[0][0][0]] = 0

     
    def search(u):
        for v,w in E[u]:
            if t[v] == -1:
                t[v] = t[u] if w % 2 == 0 else t[u]^1
                search(v)
                

    search(E[0][0][0])

    for i in t:
        write(i)
        write(' ')






    pass
if __name__ == '__main__':
    main()

Measured memory_bytes: 93676
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main(){
    cin>>S;
    bool yes = true;
    if(S[0] != 'A') yes = false;
    bool C = false;
    reps(i,1,S.size()){
        //cout<<i<<' '<<S[i] - 'a'<<endl;
        if(S[i] - 'a' < 0){
            if((!C) && (i > 1) && (i < S.size() - 1)){
                C = true;
            }else{
                yes = false;
            }
        }
    }
    cout<<(yes&&C ? "AC" : "WA")<<endl;
}


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

using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> X(N);
    rep(i, N) cin >> X[i];
    int ans = INFINITY;
    for (int i = 1; i <= 100; ++i) {
        int temp = 0;
        for(auto &&x: X) {
            temp += pow(x - i, 2);
        }
        chmin(ans, temp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int H, W, N; cin >> H >> W >> N;
	vector<int> a(N, 0), b(N, 0);
	rep (i, N){
		cin >> a[i] >> b[i];
		--a[i], --b[i];
	} // end rep

	map<P,int> cnt;cnt.clear();
	rep (i, N){
		int p = a[i], q = b[i];
		rep (k, 3){
			rep (l, 3){
				if (p - k < 0 || q - l < 0 || p - k + 2 >= H || q - l + 2 >= W) continue;
				++cnt[P((p - k),(q - l))];
			} // end rep
		} // end rep
	} // end rep

	vector<ll> res(10,0LL);
	ll total = 0LL;
	map<P,int>::iterator it = cnt.begin();
	for(; it != cnt.end(); ++it){
		P p = (*it).first;
		int c = (*it).second;
//		cerr << "pos:(" << (p/W) << ',' << (p%W) << ")" << " c: " << c << endl;
		++res[c];
		++total;
	} // end for

	res[0] = ((ll)H - 2LL)*((ll)W - 2LL) - total;
	rep (i, 10){
		cout << res[i] << endl;
	} // end rep

	return 0;
}

Measured memory_bytes: 57344
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n;
    cin >> n;
    cout << ((n>=1000) ? "ABD" : "ABC") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN=100000+5;
long long dp[MAXN];
int n,w,m,v;

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;++i){
		cin>>w>>v;
		for(int j=m;j>=w;--j) dp[j]=max(dp[j],dp[j-w]+v);
	}
	cout<<dp[m]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <numeric>
#include <set>
#include <iomanip>
#include <functional>
#define FOR(i, a, n) for (long long i = (a); i < (n); i++)
#define REP(i, n) for(long long i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
using namespace std;
typedef long long ll;

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

	int H, N, tmp;
	int atk = 0;

	cin >> H >> N;

	REP(i, N)
	{
		cin >> tmp;
		atk += tmp;
	}

	if (H <= atk)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Security.Principal;

class Program
{
    public static void Main()
    {
        double[] killer = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
        double[] hinder = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
        double distance = Math.Abs(killer[0] - hinder[0]);
        double perClose = Math.Abs(killer[1] - hinder[1]);
        double time = double.Parse(Console.ReadLine());
        if (killer[1] <= hinder[1])
        {
            Console.WriteLine("NO");
        } else if (distance / perClose <= time)
        {
            Console.WriteLine("YES");
        } else
        {
            Console.WriteLine("NO");
        }
    }
}

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

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define pb push_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    int x,y,z;
    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << "\n";

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


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

int main(){
	double r, m, e;
	const double p = M_PI;
	cin >> r;
	m = r*r*p;
	e = 2*r*p;
	cout << fixed;
	cout << setprecision(10) << m << " " << e << endl;
	return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
int main(){
  int r, g, b, n;
  cin >> r >> g >> b >> n;
  long long cnt = 0;
  for(int i = 0; i * r <= n; ++i){
    for(int j = 0; i * r + j * g <= n; ++j){
      if((n - ( i * r + j * g)) % b == 0) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
    int H[10000],W[10000],i,j,l;
    
    for(i = 0;i < 10000;i++){
        H[i] = -1;
        W[i] = -1;
        
        cin >>H[i] >>W[i];
        if(H[i] == 0 && W[i] == 0){
            i = 10000;
        }
    }
    
    for(i = 0;i < 10000;i++){
        for(j = 0;j < H[i];j++){
            for(l = 0;l < W[i];l++){
                printf("#");
            }
            printf("\n");
        }
        if(H[i] == 0 && W[i] == 0)
        break;
        printf("\n");
        
    }
    
    return 0;

}



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

int main(){
    int n;
    string s1,s2;
    int a = 0,b=0;
    cin >> n;
    
    for (int i =0; i<n ; i++){
        cin >> s1 >> s2;
        if (s1 >s2 ) a+=3;
        else if (s1 < s2) b+=3;
        else{
            a++ ; b++;
        }
    }
    
    cout << a << " " << b << endl;
    return 0;
}


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

using namespace std;

int main(void){
  std::ios_base::sync_with_stdio(false);
  map<long long, long long> s;
  long long ans = 0;
  long long N;
  cin >> N;
  for(long long i = 1; i <= N; i++){
    long long A;
    cin >> A;
    ans += s[i - A];
    s[i + A]++;
  }
  cout << ans << endl;
  return 0;
}


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

int main(void) {
    int input, ans = 0, flag;
    cin >> input;

    vector<int> side(input);
    for (int i = 0; i < input; i++) {
        cin >> side.at(i);
    }

    sort(side.begin(), side.end());
    reverse(side.begin(), side.end());

    vector<int> num;
    num.push_back(0);
    for (int i = 0; i < input; i++) {
        flag = 0;
        for (int j = i + 1; j < input; j++) {
            for (int k = j + 1; k < input; k++) {
                if (side.at(i) < side.at(j) + side.at(k) && side.at(j) < side.at(k) + side.at(i) && side.at(k) < side.at(i) + side.at(j)) {
                    ans++;
                    int temp = num[0];
                }
                else {
                    break;
                    flag++;
                }
            }
            if (flag != 0) {
                break;
            }
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 3580
#include <stdio.h>
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <cmath>
#pragma warning(disable:4996)
using namespace std;
int i, j, k, n, m, b, c, d, f, g, w, h, q, x, y;
long long ret[100005];
int a[100005], o[100005], e[100005], om, os, em, es;


int main(){
	scanf("%d",&n );
	for(i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
		if (i & 1) {
			o[a[i]]++;
			if (o[a[i]] > o[om] ) {
				os = om;
				om = a[i];
			}
			else if (o[a[i]] > o[os] && om != a[i]) {
				os = a[i];
			}
		}
		else {
			e[a[i]]++;
			if (e[a[i]] > e[em] ) {
				es = em;
				em = a[i];
			}
			else if (e[a[i]] > e[es] && em != a[i]) {
				es = a[i];
			}
		}
	}
	if (om == em) o[om] - o[os] > e[em] - e[es] ? em = es : om = os;
	printf("%d", n - o[om] - e[em]);
}

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

int main() {
   int N,K;int n=1;int i=0;
   cin>>N;
   cin>>K;
   while(n<=K&&i<N){
       n=n*2;
       i++;
 }while(n>K&&i<N){
       n=n+K;
       i++;
 }cout<<n<<endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(){
 long long A,B,N;
 std::cin>>A>>B>>N;

 long long x=0;
 if(B<=N){
  x=B-1;
 }else{
  x=N;
 }
 long long ans=(A*x)/B;
 ans-=(x/B)*A;

 std::cout<<ans<<std::endl;
}

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

ll inf=1e18;

int main() {
  ll h,n;
  cin >> h >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  for(int i=0;i<n;i++) {
    cin >> a[i] >> b[i];
  }
  vector<vector<ll>> dp(n+1,vector<ll>(h+1,inf));
  dp[0][0]=0;
  for(ll i=0;i<n;i++) {
    for(ll j=0;j<=h;j++) {
      if(j-a[i]>-1) {
        dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i]]+b[i]);
      }
      else {
        dp[i+1][j]=min(dp[i][j],b[i]);
      }
    }
  }
  cout << dp[n][h] << endl;
}

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

signed main(){
  int n;cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int ans=0;
  bool f=1;
  while(f){
    f=0;
    for(int j=n-1;j>=1;j--){
      if(v[j]<v[j-1])swap(v[j],v[j-1]),ans++,f=1;
    }
  }
  for(int i=0;i<n;i++){
    if(i)cout<<" ";
    cout<<v[i];
  }
  cout<<endl;
  cout<<ans<<endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int c[256] = {};
    char ch;
    while(cin >> ch){
        c[(int)ch]++;
    }

    rep(i,26){
        cout << (char)(i + 97) << " : " << c[i + 65] + c[i + 97] << endl;
    }
    return 0;
}
 
 



Measured memory_bytes: 3120
/*
 * cpp_filepath
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>

using namespace std;

#define ll long long

#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

ll A, B;

void input() {
  cin >> A >> B;
}

void solve() {
  if ((A+B)%2==0) cout << ((A+B)/2) << endl;
  else cout << "IMPOSSIBLE" << endl;
}

int main() {
  // cout.precision(15);
  input();
  solve();
  return 0;
}


Measured memory_bytes: 256
from collections import defaultdict,deque
from sys import stdin,setrecursionlimit
import heapq,bisect,math,itertools,string,queue,copy
setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, stdin.readline().split()))

N = int(input())
Als = inpl()

count= 0
for i,item in enumerate(Als):
    if (i%2 == 0) and (item % 2 != 0):
        count += 1
print(count)


Measured memory_bytes: 10480
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(H, N, AB):
    INF = 10**9
    dp = [INF] * (H + 1)
    dp[H] = 0
    for h in reversed(range(H + 1)):
        for i, (a, b) in enumerate(AB):
            nh = max(0, h - a)
            dp[nh] = min(dp[nh], dp[h] + b)
    print(dp[0])

if __name__ == '__main__':
    input = sys.stdin.readline
    H, N = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(N)]
    main(H, N, AB)


Measured memory_bytes: 73904
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def main():
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    S = input().strip()
    T = input().strip()

    diff = 0
    for s, t in zip(S, T):
        if s != t:
            diff += 1
    print(diff)


if __name__ == '__main__':
    main()


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

int main(){
  int N,M,K;
  cin >> N >> M >> K;
  set<int> s;
  for(int i=0;i<=N;i++){
    for(int j=0;j<=M;j++){
      s.insert(N*j+M*i-i*j*2);
    }
  }
  if(s.count(K)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


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

int main(){
	int a,b; cin >> a >> b;
	if((a+b)%2==0){
		cout << (a+b)/2 << endl;
	}
	else{
		cout << "IMPOSSIBLE" << endl;
	}
}

Measured memory_bytes: 256