akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<int> D(13, 0);
  D[0]++;
  rep(i, N) {
    int d;
    cin >> d;
    D[d]++;
  }
  rep(i, 13) {
    if ((D[i] >= 3) || (D[i] >= 2 && (i == 0 || i == 12))) {
      cout << 0 << endl;
      return 0;
    }
  }

  int answer = 0;
  rep(i, (1 << 11)) {
    vector<int> TIME(25, 0);
    TIME[0] = 1;
    TIME[24] = 1;
    if (D[12] == 1) TIME[12] = 1;
    bool ok = true;
    rep(j, 11) {
      if (D[j + 1] == 0) continue;
      if (i & (1 << j)) {
        if (D[j + 1] == 1) {
          TIME[j + 1] = 1;
        } else {
          TIME[j + 1] = 1;
          TIME[24 - j - 1] = 1;
        }
      } else {
        if (D[j + 1] == 1) {
          TIME[24 - j - 1] = 1;
        } else {
          ok = false;  // duplicate pattern
        }
      }
    }

    if (ok) {
      int minTime = 24;
      int prev = 0;
      for (int j = 1; j <= 24; ++j) {
        if (TIME[j] == 0) continue;
        minTime = min(minTime, j - prev);
        prev = j;
      }
      answer = max(answer, minTime);
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
typedef long long int lli;

// n*m行列Aとm*l行列Bの積であるn*l行列Cを出力
int main()
{
	int iCnt1, iCnt2, iCnt3;
	int iInputN, iInputM, iInputL;
	lli** aiArrayA;
	lli** aiArrayB;
	lli** aiArrayC;
	
	scanf("%lld %lld %lld", &iInputN, &iInputM, &iInputL);
	
	// メモリ確保
	aiArrayA = (lli**)malloc(sizeof(lli*) * iInputN);
	aiArrayB = (lli**)malloc(sizeof(lli*) * iInputM);
	aiArrayC = (lli**)malloc(sizeof(lli*) * iInputN);

	// 各行のメモリ確保
	for (iCnt1 = 0; iCnt1 < iInputN; iCnt1++)
	{
		aiArrayA[iCnt1] = (lli*)malloc(sizeof(lli) * iInputM);
		aiArrayC[iCnt1] = (lli*)malloc(sizeof(lli) * iInputL);

	}
	for (iCnt1 = 0; iCnt1 < iInputM; iCnt1++)
	{
		aiArrayB[iCnt1] = (lli*)malloc(sizeof(lli) * iInputL);
	}
	
	// 行列Aの入力
	for (iCnt1 = 0; iCnt1 < iInputN; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < iInputM; iCnt2++)
		{
			scanf("%d", &aiArrayA[iCnt1][iCnt2]);
		}
	}

	// 行列Bの入力
	for (iCnt1 = 0; iCnt1 < iInputM; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < iInputL; iCnt2++)
		{
			scanf("%d", &aiArrayB[iCnt1][iCnt2]);
		}
	}

	// 行列Cの初期化
	for (iCnt1 = 0; iCnt1 < iInputN; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < iInputL; iCnt2++)
		{
			aiArrayC[iCnt1][iCnt2] = 0;
		}
	}
	
	// 行列Cの計算
	for (iCnt1 = 0; iCnt1 < iInputN; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < iInputL; iCnt2++)
		{
			for (iCnt3 = 0; iCnt3 < iInputM; iCnt3++)
			{
				aiArrayC[iCnt1][iCnt2] += aiArrayA[iCnt1][iCnt3] * aiArrayB[iCnt3][iCnt2];
			}
		}
	}

	// 行列Cの表示
	for (iCnt1 = 0; iCnt1 < iInputN; iCnt1++)
	{
		for (iCnt2 = 0; iCnt2 < iInputL - 1; iCnt2++)
		{
			printf("%lld ", aiArrayC[iCnt1][iCnt2]);
		}
		printf("%lld\n", aiArrayC[iCnt1][iCnt2]);
	}

	// メモリ解放
	for (iCnt1 = 0; iCnt1 < iInputN; iCnt1++)
	{
		free(aiArrayA[iCnt1]);
		free(aiArrayC[iCnt1]);
	}
	for (iCnt1 = 0; iCnt1 < iInputM; iCnt1++)
	{
		free(aiArrayB[iCnt1]);
	}
	free(aiArrayA);
	free(aiArrayB);
	free(aiArrayC);


	return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    int X,Y;
    cin >> X >> Y;

    string ans = "No";
    int t,k;
    rep(i,101){
        t = i;
        k = X - t;
        if(Y < (2*t + 4*k)) continue;
        if(k < 0) break;
        if((2*t + 4*k) == Y){
            ans = "Yes";
            break;
        }
    }
    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

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

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

  vector<int> A(4);
  for (int i = 0; i < 4; ++i) {
    A.at(i) = all % 10;
    all /= 10;
  }
  reverse(A.begin(), A.end());

  for (int bit = 0; bit < 1 << 3; ++bit) {
    string s = to_string(A.at(0));
    int sum = A.at(0);
    int cnt = 1;
    for (int i = 0; i < 3; ++i) {
      if (bit >> i & 1) {
        s += "+";
        sum += A.at(cnt);
      } else {
        s += "-";
        sum -= A.at(cnt);
      }
      s += to_string(A.at(cnt++));
    }
    if (sum == 7) {
      s += "=";  
      s += to_string(sum);
      puts(s.c_str());
      return 0;
    }
  }
}

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

using namespace std;
int N;
long long burger[51][2];

long long dp(int N,long long X) {
    long long res = 0;
    if(N<0)return 0;
    if(X>0)--X;
    if(burger[N-1][0]>X){
        return dp(N-1,X);
    }
    res+=burger[N-1][1];
    X-=burger[N-1][0];
    if(X==0)return res;
    ++res;
    --X;
    if(burger[N-1][0]>X){
        return res+dp(N-1,X);
    }
    res+=burger[N-1][1];
    return res;
}
// 9
//BBPPPBPBPPPBB
//B,BPPPB,P,BPPPB,B

int main() {
    int i;
    long long X;
    cin>>N>>X;
    burger[0][0]=1;
    burger[0][1]=1;
    for(i=1;i<=N;i++){
        burger[i][0]=1+burger[i-1][0]+1+burger[i-1][0]+1;
        burger[i][1]=(burger[i-1][1]*2)+1;
        // cout<<burger[i][0]<<" "<<burger[i][1]<<endl;
    }
    cout<<dp(N, X);
    return 0;
}

Measured memory_bytes: 256
n, m, p = [int(i) for i in input().split()]
e = [[int(i) for i in input().split()] for _ in range(m)]

for i in e:
    i[0] -= 1
    i[1] -= 1
    i[2] -= p

d = [-10**18] * n
ok1 = [False] * n
ok2 = [False] * n
d[0] = 0
ok1[0] = True
ok2[-1] = True

for _ in range(n):
    for a, b, c in e:
        if ok1[a]:
            d[b] = max(d[b], d[a] + c)
            ok1[b] = True
        if ok2[b]:
            ok2[a] = True
aa = d[:]

for _ in range(n):
    for a, b, c in e:
        if ok1[a]:
            d[b] = max(d[b], d[a] + c)
            ok1[b] = True
        if ok2[b]:
            ok2[a] = True

bb = d[:]

ok = False
for i in range(n):
    if ok1[i] and ok2[i]:
        if aa[i] != bb[i]:
            ok = True
if ok:
    print("-1")
else:
    print(max(aa[-1], 0))


Measured memory_bytes: 48728
D[124][101],i,j,k,t;main(n,m,s,g,h){for(;scanf("%d%d%d%d%d",&n,&m,&s,&g,&h)*n;printf("%d\n",k)){memset(D,1,5e4);for(;m--;D[i][j]=k,D[i][i]=0)scanf("%d%d%d",&i,&j,&k);for(k=n;k;k--)for(i=n;i;i--)for(j=n;j;j--)t=D[i][k]+D[k][j],t<D[i][j]?D[i][j]=t:0;k=1e9;for(i=n;i;i--)t=D[s][i]+D[i][g]+D[i][h],t<k?k=t:0;}}

Measured memory_bytes: 456
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int t;
	vector<int> a;
	int n;
	cin >> n;
	for (int i=0; i<n; i++)
	{
		cin >> t;
		t*=-1;
		int p=upper_bound(a.begin(), a.end(), t)-a.begin();
		if (p==a.size())
		{
			a.push_back(t);
		}
		else
		{
			a[p]=t;
		}
	}
	cout << a.size() << endl;
	return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define var auto
#define mod 1000000007
#define inf 2147483647
#define nil -1
typedef long long ll;

using namespace std;

inline int input(){
    int a;
    cin >> a;
    return a;
}

template <typename T>
inline void output(T a, int p) {
    if(p){
        cout << fixed << setprecision(p)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

// end of template

// union find
class union_find {
public:
    vector<int> parent, rnk;
    
    union_find(int n){
        parent.resize(n);
        rnk.resize(n, 0);
        rep(i, n){
            parent[i] = i;
        }
    }
    
    int root(int x){
        if (parent[x] == x) {
            return x;
        }
        else{
            return root(parent[x]);
        }
    }
    
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if (x == y) {
            return;
        }
        if (rnk[x] < rnk[y]) {
            parent[x] = y;
        }
        else{
            parent[y] = x;
            if (rnk[x] == rnk[y]) {
                rnk[x]++;
            }
        }
    }
    
    bool same(int x, int y){
        return root(x) == root(y);
    }
};

struct edge{
    int f, t, cost;
    // define e1.cost < e2.cost : e1 < e2
    bool operator < (const edge &e){
        return cost < e.cost;
    }
};

class kruskal{
public:
    int v; // vertices
    vector<edge> e; // edges
    
    kruskal(int vt, int eg){
        v = vt;
        e.resize(eg);
    }
    
    int mst(){
        sort(e.begin(), e.end());
        union_find uf(v);
        int min_cost = 0;
        rep(i, e.size()){
            edge &d = e[i];
            if (!uf.same(d.f, d.t)) {
                min_cost += d.cost;
                uf.unite(d.f, d.t);
            }
        }
        
        return min_cost;
    }
};


int main() {
    cin.tie(0);
    // source code
    int V, E;
    cin >> V >> E;
    kruskal ks(V, E);
    rep(i, E){
        int s, t, c;
        cin >> s >> t >> c;
        ks.e[i] = edge{s, t, c};
    }
    
    cout << ks.mst() << endl;
    
    
    return 0;
}

Measured memory_bytes: 4132
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <string>
#include <stdio.h>

using namespace std;

int main() {

	string S;
	long long K;
	cin >> S >> K;

	
	long long pos = 0;
	while (K >= 1) {

		if (pos == S.length() - 1) {
			S[pos] = ((S[pos] - 'a') + K) % 26 + 'a';
			K = 0;
		}

		if (('z' - S[pos] + 1) <= K && S[pos] != 'a') {
			K = K - ('z' - S[pos] + 1);
			S[pos] = 'a';
		}

		pos++;
	}
	

	/*
	for (int i = 0; i < S.size(); i++) {
		if (i == S.size() - 1) {
			S[i] = ((S[i] - 'a') + K) % 26 + 'a';
			K = 0;
			break;
		}else if ('z' - S[i] + 1 <= K && S[i] != 'a') {
			K -= ('z' - S[i] + 1);
			S[i] = 'a';
		}
	}
	*/

	cout << S << endl;

	return 0;
}

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

int main() {
  string S;
  cin >> S;
  int a,z;
  for (int i=0; ; i++) {
      if (S.at(i)=='A') {
          a=i;break;
      }
  }
  for (int i=a; i<S.size(); i++) {
      if (S.at(i)=='Z') {
          z=i;
      }
  }
  cout << z-a+1 << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<string>

using namespace std;

int main() {
	int x, y;

	cin >> x >> y;

	string a = "acababaababa";

	if (a[x - 1] == a[y - 1]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

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

#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##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=998244353;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n,c,k;
	cin>>n>>c>>k;
	int t[100010];
	rep(i,n)cin>>t[i];
	sort(t,t+n);
	int now=0;
	int re=0;
	while(now<n){
		//cout<<now<<endl;
		int v=upper_bound(t,t+n,t[now]+k)-t-1;
		if(v-now+1)
		if(v-now+1>c){
			now+=c;
		}else{
			now=v+1;
		}
		re++;
	}
	cout<<re<<endl;
}

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

typedef long long int llint;

int main()
{
  int dx[4] = {0, 1, -1, 0};
  int dy[4] = {1, 0, 0, -1};
  string str[51];
  int h, w;
  cin>> h >> w;

  for(int i = 0; i < h; i++)  cin>> str[i];

  bool ans = true;
  for(int i = 0; i < h; i++) {
    for(int j = 0; j < w; j++) {
      
      if(str[i][j] == '#') {
	int cnt = 0;
	for(int k = 0; k < 4; k++) {
	  int x = j + dx[k];
	  int y = i + dy[k];
	  if(x < 0 || w <= x || y < 0 || h <= y) continue;
	  if(str[y][x] == '#') cnt++;
	}
	if(cnt == 0) ans = false;
      }
      
    }
  }
  
  cout<< (ans ? "Yes" : "No") <<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
bool e[10][10];
int m,n;
int ar[8]={1,2,3,4,5,6,7,8};
bool has(){
rep(i,n-1)if(!e[ar[i]][ar[i+1]])return 0;
return 1;
}
int main(){
cin>>n>>m;
rep(i,m){
int a,b;
cin>>a>>b;
e[a][b]=e[b][a]=1;
}
int ans=0;
do{
if(has())ans++;
}while(next_permutation(ar+1,ar+n));
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<queue>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#define ll long long
#define inf  999999999
#define pa pair<int,int>
using namespace std;

int n;
int dp[1<<16][16];

int main(){
int e,s,t,wa;
cin>>n>>e;
int w[20][20];
for(int i=0;i<n+1;i++){
for(int j=0;j<n+1;j++){
w[i][j]=inf;
}
}
for(int i=0;i<e;i++){
cin>>s>>t>>wa;
w[s][t]=wa;
}
for(int i=0;i<(1>>n);i++){
for(int j=0;j<n+1;j++) dp[i][j]=inf;
}



int mini=inf;
dp[0][0]=0;
for(int k=2;k< (1<<n);k=k+2){ //a
for(int u=1;u<n;u++){ //b
mini=inf;

if(1 & (k>>u)){			 //c
//cout<<k<<endl;

if(k-(1<<u)==0) {	 //d
dp[k][u]=w[0][u];
//cout<<" w0u"<<w[0][u]<<endl;
//cout<<"dp["<<k<<" "<<u<<"]" <<dp[k][u]<<endl;
}			 //d
else if(k-(1<<u)!=0){		//e
for(int v=1;v<n;v++){		//f
//cout<<k<<" "<<v<<" "<<u<<" "<<w[v][u]<<endl;
if((1 & (k>>v)) && u != v && w[v][u]!=inf){	//g
//printf("k= %d v= %d u= %d\n",k,v,u);
mini=min(mini,dp[k-(1<<u)][v]+w[v][u]);
	}	//g
	}	//f
dp[k][u]=mini;
//cout<<"dp["<<k<<" "<<u<<"]" <<dp[k][u]<<endl;
	}	//e
}	//c

} 	//b
}	//a
mini=inf;
for(int i=1;i<n;i++){
mini=min(mini,dp[(1<<n)-2][i]+w[i][0]);

}

if(mini<inf) cout<<mini<<endl;
else cout<<"-1"<<endl;

return 0;
}

Measured memory_bytes: 5252
#include <queue>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 110;
const int INF = 0x3f3f3f3f;

int n,m;
char a[maxn][maxn];
bool vis[maxn][maxn];

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

struct node {
    int x,y;
    int dist;
    node(int _x = 0 , int _y = 0 , int _dist = 0) : x(_x),y(_y),dist(_dist){}
};
queue<node>q;

int bfs(int x,int y) {
    memset(vis,false,sizeof(vis));
    while(!q.empty()) q.pop();
    q.push(node(x,y,0));
    vis[x][y] = true;
    int ans;
    while(!q.empty()) {
        node k = q.front();
        ans = k.dist;
        q.pop();
//        cout << "k.x = " << k.x << " " << "k.y = " << k.y << " " << "k.dist = " << k.dist << endl;
        for(int i = 0 ; i < 4 ; i++) {
            int x1 = k.x + dx[i];
            int y1 = k.y + dy[i];
            if(x1 >= 0 && x1 < n && y1 >= 0 && y1 < m && !vis[x1][y1] && a[x1][y1] == '.') {
                q.push(node(x1,y1,k.dist+1));
                vis[x1][y1] = true;
            }
        }
    }
    return ans;
}

int main() {
    while(~scanf("%d%d",&n,&m)) {
        for(int i = 0 ; i < n ; i++) {
            scanf("%s",a[i]);
        }
        int ans = 0;
        for(int i = 0 ; i < n ; i++) {
            for(int j = 0 ; j < m ; j++) {
                if(a[i][j] == '.') {
//                    cout << "i = " << i << " j = " << j << " " << bfs(i,j) << endl;
                    ans = max(ans,bfs(i,j));
                }
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
	char S[11],T[12]; 
    scanf("%s %s",S,T);
    
    int cou,ans;
    for(cou=0;S[cou]!='\0';cou++){
        if(S[cou]==T[cou]){ans=0;}
        else{ans=1;}

        if(ans==1){break;}
    }

    if(ans==0){
        printf("Yes");
    }else{
        printf("No");
    }

    return 0;
}

Measured memory_bytes: 1728
#include <iostream>
#include <string>

using namespace std;

int main(){

  int h, w;
  string s[50];
  
  cin >> h >> w;

  for(int i = 0; i < h; i++){
    cin >> s[i];
    for(int j = 0; j < w; j++){
      if(s[i][j] == '.'){
        s[i][j] = '0';
      }
    }
  }

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#'){
        for(int ii = -1; ii < 2; ii++){
          for(int jj = -1; jj < 2; jj++){
            if(ii == 0 && jj == 0){
              continue;
            }
            if((i + ii < 0) || (i + ii >=h) || (j + jj < 0) || (j + jj >= w)){
              continue;
            }
            if(s[i + ii][j + jj] != '#'){
              s[i + ii][j + jj] += 1;
            }
          }
        }
      }
    }
  }
  
  for(int i = 0; i < h; i++){
    cout << s[i] << endl;
  }
  
  return 0;
}

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

#define ll long long
#define vi vector<int>
#define vc vector<char>
#define vt vector<string>
#define si set<int>
#define sc set<char>
#define st set<string>
#define pii pair<int,int>
#define fi first
#define se second

using namespace std;
int main()
{
    int a;
    cin>>a;
    int b;
    cin>>b;
    if(a<=5)cout<<0;
    else if(a>=6&&a<=12)cout<<b/2;
    else cout<<b;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main () {
	vector<string> a;
	int n, l;
	cin >> n >> l;
	string s;
	for (int i=0; i<n; i++) {
		cin >> s;
		a.push_back(s);
	}
	sort(a.begin(), a.end());
	for (int i=0; i<a.size();i++) {
		cout << a[i];
	}
	return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int mod = 1e9 + 7;


int main() {
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	ll a, b;
	cin >> a >> b;

	ll cnt = 1;
	ll n = __gcd(a, b);
	ll g = n;
	for(ll i = 2; i * i<=n; i++){
		if(g % i==0){
			cnt++;
			while(g % i == 0){
				g /= i;
			}
		}
	}


	if(g != 1){
		cnt++;
	}
	cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;
const int MOD = 1000000007;

int gcd(int a, int b){
    if(b==0) return a;
    else return gcd(b, a%b);
}

int main(){
    std::ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n; cin >> n;

    map<string, vector<pair<int,int>>> mp;
    rep(i,n){
        string city; int review;
        cin >> city >> review;
        mp[city].push_back({review, i+1});
    }

    for(auto const& x : mp){
        
        std::vector<pair<int,int>> v =x.second;

        sort(v.begin(), v.end());
        reverse(v.begin(), v.end());
        rep(i,v.size()){
            cout << v[i].second << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
int main(){
	std::vector<int> n(10);
	for(int i=0;i<=9;i++){
		std::cin>>n[i];
	}
	for(int i=0;i<9;i++){
		for(int j=i+1;j<=9;j++){
			if(n[i]<n[j]){
				int a=n[i];
				n[i]=n[j];
				n[j]=a;
			}
		}
	}
	for(int i=0;i<3;i++){
		std::cout<<n[i]<<std::endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <string>
using namespace std;
string S;
int main(){
    cin >> S;
    if(S.length() == 3){
        if(S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba"){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

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

  // ここにプログラムを追記
  int l,r,sum;
  for (int i = 0; i < n; i++) {
    cin >> l >> r;
    sum += r-l+1;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <memory.h>
 
using namespace std;
typedef long long LL;
 
const int N = 1e8;
const int maxn = 300005;
const int maxm = maxn*30;
const int inf = 1<<28;
#define clr(_) memset(_,0,sizeof _)
 
struct node {int x,y;} p[maxn];
bool comp(node a,node b) {return a.x<b.x;}
int stk1[maxn],ref1[maxn],top1;
int stk2[maxn],ref2[maxn],top2;
int W,H,n,ans,rt;
 
int _o_,o_o;
namespace ST {
	int tag[maxm],w[maxm],c[maxm][2],tot;
	#define ls c[rt][0]
	#define rs c[rt][1]
	void inc(int rt,int v)
	{
		rt?(w[rt]+=v,tag[rt]+=v):0;
	}
	void pushdown(int rt)
	{
		if (int v=tag[rt]) {
			inc(ls,v);inc(rs,v);tag[rt]=0;
		}
	}
	void insert(int &rt,int L,int R,int p,int v)
	{
		if (!rt) rt=++tot;
		if (L>=R) {w[rt]=v;return ;}
		int mid=L+R>>1;pushdown(rt);
		if (p<=mid) insert(ls,L,mid,p,v);
		else insert(rs,mid+1,R,p,v);
		w[rt]=max(w[ls],w[rs]);
	}
	void modify(int rt,int L,int R,int l,int r,int v)
	{
		if (!rt||l>r) return ;
		if (L>=l&&R<=r) {inc(rt,v);return ;}
		int mid=L+R>>1;pushdown(rt);
		if (l<=mid) modify(ls,L,mid,l,r,v);
		if (r>mid) modify(rs,mid+1,R,l,r,v); 
		w[rt]=max(w[ls],w[rs]);
	}
}
using namespace ST;
 
void solve()
{
	sort(p+1,p+n+1,comp);
	_o_=W>>1;o_o=W+1>>1;
	insert(rt,0,N,0,W);
	
	stk1[top1=1]=_o_;ref1[top1]=0;
	stk2[top2=1]=o_o;ref2[top2]=0;
	for (int i=1;i<=n;i++)
	{
		ans=max(ans,p[i].x+w[rt]);
		if (p[i].y<=_o_)
		{
			int las=p[i].x,cur=0;
			while (top1&&stk1[top1]<p[i].y)
				modify(rt,0,N,ref1[top1],las-1,-p[i].y+cur),
				las=ref1[top1],cur=stk1[top1],top1--;
			modify(rt,0,N,ref1[top1],las-1,-p[i].y+cur);
			stk1[++top1]=p[i].y;ref1[top1]=p[i].x;
		}
		if (p[i].y>=o_o)
		{
			int las=p[i].x,cur=W;
			while (top2&&stk2[top2]>p[i].y)
				modify(rt,0,N,ref2[top2],las-1,p[i].y-cur),
				las=ref2[top2],cur=stk2[top2],top2--;
			modify(rt,0,N,ref2[top2],las-1,p[i].y-cur);
			stk2[++top2]=p[i].y;ref2[top2]=p[i].x;
		}
		insert(rt,0,N,p[i].x,W-p[i].x);
	}
	
	ans=max(ans,H+w[rt]);
}
int main()
{
	#ifdef Amberframe
		freopen("arc063f.in","r",stdin);
		freopen("arc063f.out","w",stdout);
	#endif
	scanf("%d %d %d",&W,&H,&n);w[0]=-inf;
	for (int i=1;i<=n;i++)	
		scanf("%d %d",&p[i].x,&p[i].y);
	
	swap(W,H);solve();
	tot=rt=0;clr(tag);clr(c);clr(w);
	for (int i=1;i<=n;i++)
		swap(p[i].x,p[i].y);
	swap(W,H);solve();
	printf("%d",ans<<1);
	return 0;
}

Measured memory_bytes: 148476
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

template <typename T>
vector<pair<T, T>> prime_factor(T n) {
    vector<pair<T, T>> ret;
    for (T i = 2; i * i <= n; i++) {
        T tmp = 0;
        while (n % i == 0) {
            tmp++;
            n /= i;
        }
        ret.push_back(make_pair(i, tmp));
    }
    if (n != 1) ret.push_back(make_pair(n, 1));
    return ret;
}

int main() {
    ll N;
    cin >> N;
    auto pf = prime_factor(N);

    ll ans = 0;
    for (auto p : pf) {
        ll k = p.second;
        for (ll i = 1; i <= k; i++) {
            ans++;
            k -= i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19780
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    string s;
    cin >> s;
    int N = s.size();

    string t;
    int cur = 0;
    while(cur < N){
        if(s[cur] == 'A'){
            t.push_back('X');
            cur++;
        }
        else if(cur+1 < N && s[cur] == 'B' && s[cur+1] == 'C'){
            t.push_back('Y');
            cur+=2;
        }
        else{
            t.push_back('Z');
            cur++;
        }
    }
    long long ans = 0;
    long long cnt = 0;
    for(int i=0; i<t.size(); i++){
        if(t[i] == 'X') cnt++;
        if(t[i] == 'Y') ans += cnt;
        if(t[i] == 'Z') cnt = 0;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;



int main(int argc, char const *argv[]) {
    ll a, b, c;
    cin >> a >> b >> c;
    if(a==b&&b==c||a!=b&&b!=c&&a!=c){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;
#define ll long long
#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 vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
struct edge {
    int to;
    ll cost;
};

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

map<char, char> m;

int main() {
    COME_LET_THE_GAMES_BEGIN();
    m['b'] = 'd', m['d'] = 'b', m['p'] = 'q', m['q'] = 'p';
    string S, SS;
    cin >> S;
    SS = S;
    reverse(SS.begin(), SS.end());
    for (int i = 0; i < S.length(); i++) {
        if (m[S[i]] != SS[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 512
import sys
import numpy as np

N, K = map(int, sys.stdin.readline().rstrip().split())
A = np.array(sys.stdin.readline().rstrip().split(), np.int64)

# A をソートし、負／ゼロ／正　に分ける
A = np.sort(A)
zero = A[A == 0]
pos = A[A > 0]
neg = A[A < 0]


def f2(x):
    """
    積が x 以下になるペアの個数を返す

    - (i,j) と (j,i), (i,i) の重複を許して後で調整
    - A = [a_0, a_1, a_2, ... ,a_n-1] で、
         負 ～ 0 ～ 正 まで混ざった状態で
         target k と掛け合わせて x 以下になる場所 (index) を探す
    -           \__-5_-1__0_0_...__1___2
      a_0   = -5|  25  5  0 0 ... -5 -10
      a_1   = -1|   5  1  0 0 ... -1  -2
      a_2   =  0|   0  0  0 0 ...  0   0
      a_3   =  0|   0  0  0 0 ...  0   0
      a_4   =  1|  -5 -1  0 0 ...  1   2
      .....     |
      a_n-1 =  2| -10 -2  0 0 ...  2   4
    """

    cnt_tpl = 0

    # k < 0 の掛け合わせ -> 右から
    B = A.copy()
    B = -B
    B.sort()
    cnt_tpl += np.searchsorted(B, x // (-neg), side='right').sum()

    # a_2, a_3, k = 0 なら そのペアはすべて 0 (x//0になるので別扱い)
    if x >= 0:
        cnt_tpl += len(zero) * N

    # k > 0 の掛け合わせ -> 左から何番目まで, x 以下にできるか？
    cnt_tpl += np.searchsorted(A, x // pos, side='right').sum()

    # (i, i) で x 以下になったものがあれば、削除する
    cnt_tpl -= np.count_nonzero(A * A <= x)

    assert cnt_tpl % 2 == 0
    return cnt_tpl // 2


# 二分探索
left = -10 ** 18
right = 10 ** 18
while left + 1 < right:
    x = (left + right) // 2
    if f2(x) >= K:
        right = x
    else:
        left = x


print(right)

Measured memory_bytes: 49968
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
ll ans[20010];
int main(){
    cin>>N;
	if(N==3){
		cout<<"2 5 63";
		return 0;
	}
	if(N<=15000){
		ll r;
		if(N%2==0){
			if(N<=6){
				r=2;
			}
			else{
				r=(N-1)/6*6;
			}
		}else{
			r=(N-4)/6*6+3;
		}
		for(ll i=1;i<=r;i++){
			ans[i]=i*2;
		}
		for(ll i=r+1;i<=N;i++){
			ans[i]=(i-r)*6-3;
		}
	}	
	if(N>15000){
		for(ll i=1;i<=15000;i++){
			ans[i]=i*2;
		}
		for(ll i=15000+1;i<=N;i++){
			ans[i]=6*(i-15000)-3;
		}
		if(N%2==1){
			ans[3]=6*(N+1-15000)-3;
		}
	}
	for(ll i=1;i<=N;i++){
		cout<<ans[i]<<" ";
	}	
    return 0;
}

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

int main(){
  int N,M,ans=0;
  cin >> N >> M;
  uint64_t H[N+1],L[N+1];
  for(int i=1; i<N+1; i++) cin >> H[i];
  for(int i=1; i<N+1; i++) L[i] = 0;
  int A[M],B[M];
  for(int i=0; i<M; i++) cin >> A[i] >> B[i];
  for(int i=0; i<M; i++) {
    if(H[A[i]]>H[B[i]]) {
      L[B[i]]++;
    }else if(H[A[i]]<H[B[i]]){
      L[A[i]]++;
    }else{
      L[B[i]]++;
      L[A[i]]++;
    }
  }
  for(int i=1; i<N+1; i++) if(L[i]==0) ans++;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong a, b, c, d;
  cin >> a >> b >> c >> d;

  cout << min({abs((a+b)-(c+d)), abs((a+c)-(b+d)), abs((a+d)-(b+c))}) << endl;



  return 0;
}


Measured memory_bytes: 3108
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N;

int H[3][MAX_N], dp[3][MAX_N];

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

    cin >> N;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> H[j][i];
        }
    }
    for (int j = 0; j < 3; j++) {
        dp[j][0] = H[j][0];
    }

    for (int j = 1; j < N; j++) {
        for (int i = 0; i < 3; i++) {
            dp[i][j] = max(dp[(i + 1) % 3][j - 1], dp[(i + 2) % 3][j - 1]) + H[i][j];
        }
    }


    cout << max(dp[0][N - 1], max(dp[1][N - 1], dp[2][N - 1])) << "\n";

    return 0;
}

Measured memory_bytes: 5952
ways_list=[]

while True:
    by_goal=[]
    ways=0
    by_goal=input().split()
    by_goal[0]=int(by_goal[0])
    by_goal[1]=int(by_goal[1])
    if by_goal[0]==0 and by_goal[1]==0:
        break
    for i in range(1,by_goal[0]+1):
        for j in range(1,by_goal[0]+1):
            for k in range(1,by_goal[0]+1):
                if i+j+k==by_goal[1]:
                    if i != j and j!=k and k!=i:
                            ways+=1
    ways_list.append(ways//6)
for i in range(0,len(ways_list)):
    print(ways_list[i])

Measured memory_bytes: 7732
import java.util.*;
import java.text.*;

public class Main {
    public static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        long a = sc.nextLong();
        long b = sc.nextLong();
        if (a > 0 && b > 0) {
            System.out.println("Positive");
        } else if (a < 0 && b < 0) {
            if ((b-a)%2 == 0) {
                System.out.println("Negative");
            } else {
                System.out.println("Positive");
            }
        } else {
            System.out.println("Zero");
        }
    }
}

Measured memory_bytes: 9424
import java.util.Scanner;

class Main {
    public static int GCD(int a, int b){
	if(a%b==0){
	    return b;
	}

	return GCD(b, a%b);
    }
     public static void main(String[] args) {
	 Scanner sc = new Scanner(System.in);
	 int a = sc.nextInt();
	 int b = sc.nextInt();
	 
	 int gcd = GCD(a,b);

	 System.out.println(gcd);
     }

    
}



Measured memory_bytes: 26272
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    let mut it = s.split_whitespace();
    let (h, w): (usize, usize) = parse!(it, 2);
    let a = (w + 1) / 2;
    let b = w / 2;
    if h == 1 || w == 1 {
        println!("{}", 1);
    } else {
        println!("{}", (a + b) * (h / 2) + a * (h % 2));
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main(){
  int N;
  long long K;
  cin>>N>>K;
  int A[2000],B[2000],C[2000];
  for(int i=0;i<N;i++){
    cin>>A[i];
    B[i]=0;
    C[i]=0;
  }
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      if(A[i]>A[j]){
        B[i]++;
        if(i<j) C[i]++;
      }
    }
  }
  long long answer=0;
  for(int i=0;i<N;i++){
    long long k=(((K-1)*K)/2)%1000000007;
    answer=(answer+B[i]*k+C[i]*K)%1000000007;
  }
  cout<<answer<<endl;
  
  return 0;
}

Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;


	public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			String S = sc.next();
			char[] s = S.toCharArray();
			String nS = "";
			List<Integer> a = new ArrayList<Integer>();
			
			for(int i=0;i<S.length();i++) {
				if(s[i]!='B') {
					nS += s[i];
				}else if(!nS.equals("")) {
					nS = nS.substring(0, nS.length()-1);
					
				}
				
			}
			System.out.println(nS);
			
		}

	}


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

int main() {
	int N, M;
	int arr[55] = {0};
	cin >> N >> M;
	for (int i = 0; i < M; i++) {
		int ai, bi;
		cin >> ai >> bi;
		arr[ai]++;
		arr[bi]++;
	}
	for (int i = 1; i <= N; i++) {
		cout << arr[i] << endl;
	}
}

Measured memory_bytes: 256
#include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
namespace AOJ0185
{
	class Primes
	{
	public:
		static void GetPrimes(int max, vector<int> &primes)
		{
			vector<bool> flags(max + 1, true);
			for (int i = 2; i <= max; i++)
			{
				if (flags[i])
				{
					primes.push_back(i);
					for (int j = i; j <= max; j += i)
					{
						flags[j] = false;
					}
				}
			}
		}
	};

	class Solver
	{
	private:
		static const int MAX_N = 1000001;
		int Input()
		{
			int n;
			cin >> n;
			return n;
		}

		void Output(int answer)
		{
			cout << answer << endl;
		}

	public:
		void Solve()
		{
			vector<int> primes;
			Primes::GetPrimes(MAX_N, primes);

			int n;
			while (n = Input())
			{
				int answer = 0;
				for (int i = 0; i < primes.size(); i++)
				{
					int diff = n - primes[i];
					if (diff < primes[i])break;
					bool exist = binary_search(primes.begin(), primes.end(), diff);
					if (exist)answer++;
				}
				Output(answer);
			}
		}

	};
}

int main()
{
	AOJ0185::Solver().Solve();
}



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

int cnt[100000];

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

    int N; cin >> N;
    
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        cnt[d-1]++;
    }

    int d[100000]; d[0] = cnt[0];
    for (int i = 1; i <= 100000; i++) {
        d[i] = d[i-1]+cnt[i];
    }

    int ans = 0;
    for (int i = 0; i < 100000; i++) {
        if (d[i] == (N-d[i])) ans++;
    }

    cout << ans << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
using namespace std;

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

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

	int32_t res = numeric_limits<int32_t>::max();
	for (int32_t i = -100; i <= 100; i++) {
		int32_t sum = 0;
		for (int32_t j = 0; j < N; j++) {
			sum += (i - a[j]) * (i - a[j]);
		}
		res = min(res, sum);
	}
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <complex>
#include <bitset>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back

using namespace std;

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

int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    int g = a[0];
    int maxx = a[0];

    for (int i = 1; i < n; ++i) {
        g = __gcd(g, a[i]);
        maxx = max(maxx, a[i]);
    }

    if (k % g == 0 && k <= maxx) {
        cout << "POSSIBLE\n";
    } else {
        cout << "IMPOSSIBLE\n";
    }


}


Measured memory_bytes: 640
N = int(input())
dic = {}

for i in range(N):
  S = "".join(sorted(input()))
  if S in dic:
    dic[S] += 1
  else:
    dic[S] = 1

ans = 0

for val in dic.values():
  ans += val * (val - 1) / 2
print(int(ans))

Measured memory_bytes: 17852
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long LL;
const int N=100005;

int n,ans;
int a;

int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a),ans^=a;
	if(ans==0)
		printf("Yes\n");
	else printf("No\n");
	return 0;
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
   string s;cin >>s;
   ll n=s.size();
   char now=s[0];
   ll ans=0;
    for (int i = 0; i < n; ++i) {
        if(s[i]!=now){
            ans++;
            if(s[i]=='B')now='B';
            else now='W';
        }
    }
    cout <<ans <<endl;
    return 0;
}



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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;

int main(){
  ll n;
  cin>>n;
  vector<vector<ll>> a(n, vector<ll>(n,0));
  rep(i,n)rep(j,n)cin>>a[i][j];
  vector<ll> dp((1<<n),0);

  for(ll s=0;s<(1<<n);s++){
//    cout<<s<<"s"<<endl;
    ll now=0;
    rep(i,n)for (ll j=i+1;j<n;j++){
      if (((s>>i)&1) && ((s>>j)&1)){
        now+=a[i][j];
    //  cout<<"i"<<i<<"j"<<j<<endl;
    //  cout<<a[i][j]<<endl;
    }
    }
    dp[s]=now;


    for(ll t=(s-1)&s;t>0;t=(t-1)&s){
      dp[s]=max(dp[s],dp[t]+dp[s^t]);
      //cout<<"dp"<<dp[s]<<"s"<<s<<"t"<<t<<endl;
    }
//cout<<dp[s]<<"s"<<s<<endl;
  }

  cout<<dp[(1<<n)-1];
}


Measured memory_bytes: 3744
//#include <bits/stdc++.h>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

using namespace std;

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

    long double a, b, x;

    cin >> a >> b >> x;

    long double pi = M_PI;

    long double c_rad = atan2(b, a) * 180.0 / M_PI;

    long double c = a * a * b / 2;

    if(x > c) {
        long double add = atan2((b - ((x - c) / a / a * 2.0)), a) * 180.0 / M_PI;
        cout << std::setprecision(12) << add;
    } else if(x < c) {
        long double min = 90.0 - atan2((x / a / b * 2), b) * 180.0 / M_PI;
        cout << std::setprecision(12) << min;
    } else {
        cout << std::setprecision(12) << atan2(b, a) * 180.0 / M_PI;
    }
}

Measured memory_bytes: 256
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

n,m = iim()
lmax = 0
rmin = n
for i in range(m):
    l,r = iim()
    lmax = max(l,lmax)
    rmin = min(r,rmin)

print(max(rmin-lmax+1,0))

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl);
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int dp[5010][5010];

int main(){

    int n;
    string s;
    cin >> n >> s;

    for(int i = n-1; i >= 0; --i){
        for(int j = n-1; j >= 0; --j){
            if(s[i] != s[j]) dp[i][j] = 0;
            else dp[i][j] = dp[i+1][j+1] + 1;
        }
    }
    int ans = 0;
    for(int i = 0; i < n; ++i){
        for(int j = i+1; j < n; ++j){
            chmax(ans, min(dp[i][j], j-i));
        }
    }
    ppp(ans);


    return 0;
}


Measured memory_bytes: 98048
// review
#include <iostream>

using namespace std;
const int MAXN = 510;
const int MAXM = 200100;
const int MAXQ = 100100;

int N, M, Q;
int l[MAXM], r[MAXM], p[MAXQ], q[MAXQ];
int dp[MAXN][MAXN];

void solve() {
  for (int i=0;i<M;i++) {
    dp[l[i]][r[i]]++;
  }
  for (int i=0;i<=N;i++) {
    for (int j=i+1;j<=N;j++) {
      dp[i][j] += dp[i][j-1];
    }
  }

  for (int i=0;i<Q;i++) {
    int ans = 0;
    for (int j=p[i];j<=q[i];j++) {
      ans += dp[j][q[i]];
    }
    cout << ans << endl;
  }
}

int main() {
  cin >> N >> M >> Q;
  for (int i=0;i<M;i++) {
    cin >> l[i] >> r[i];
  }
  for (int i=0;i<Q;i++) {
    cin >> p[i] >> q[i];
  }
  solve();
}


Measured memory_bytes: 4224
#include<iostream>
using namespace std;
 
int main(){
 
	int a,b,c,d;
  	cin >> a >> b >> c;
 
  	if(b/a>c){
    	d = c;
    }else{
    	d = b/a;
    }
	
  	cout << d << endl;
 
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
 
int main (){
	int N,A,B;
  	cin >> N;
  	if(N == 1){
    	cout << "Hello World";
    }
  	else{
    	cin >> A >> B;
      	cout << A + B;
    }
}	

Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
num=0
for i in range(N):
    A=list(map(int,input().split()))
    k=0
    for j in range(M):
        k+=A[j]*B[j]
    if k+C>0:
        num+=1
print(num)

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+1;
int n;
long long mn;
long long ans;
long long a[N],b[N];
int main(){
    ios::sync_with_stdio(false);
    cin>>n;
    for (int i=1;i<=n;i++)cin>>a[i]>>b[i];
    bool sig=0;
    for (int i=1;i<=n;i++)
        if (a[i]!=b[i]){
            sig=1;
            break;
        }
    mn=2e9;
    if (sig)
    for (int i=1;i<=n;i++){
        if (a[i]<=b[i])ans+=b[i];
        else{
            ans+=b[i];
            mn=min(mn,b[i]);
        }
    }
    if (mn==2e9)mn=0;
    cout<<ans-mn;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
	// 解毒剤入りの美味しくないクッキーをA枚
	// 解毒剤入りの美味しいクッキーをB枚
	// 毒入りの美味しいクッキーをC
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	printf("%d\n", b + min(c, a + b + 1)); //+1は最後に毒入りを食べる
	return 0;
}

Measured memory_bytes: 3812
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
using namespace std;
using ll = long long;
using graph = std::vector<std::vector<long long>>;
int main(){
    ll N,K;
    cin >> N >> K;
        ll cand = N / K;
        //cout << cand << endl;
        ll sum = 0;
        sum += cand;
        if(cand > 1){
            sum += (cand - 1) * cand * 3;
        }
        if(cand > 2){
            sum += (cand) * (cand - 1) * (cand - 2);
        }
        if(K % 2 == 0){
            ll candB = N / (K / 2) - cand;
            sum += candB;
            if(candB > 1){
                sum += (candB - 1) * candB * 3;
            }
            if(candB > 2){
                sum += (candB) * (candB - 1) * (candB - 2);
            }
        }
        cout << sum << endl;
}

Measured memory_bytes: 256