akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

const int N = 1e3+3;


int cnt[N][N];
pair< int, int > edge[N*200];
int n, m;
vector<int> g[N];

#define u first
#define v second

bool kappa[N][N];

void dothething(int root) {
	vector< pair<int, int> > lel;
	queue< pair<int, int> > q;
	int k = 0;
	for (auto c : g[root]) {
		k++;
		q.push({c, k});
		lel.push_back({c, k});
		kappa[c][k] = 1;
		cnt[root][c] = 1;
	} 
	while (q.empty() == false) {
		int u = q.front().u;
		int e = q.front().v; q.pop();
		for (auto v : g[u]) {
			if (v == root) continue;
			if (cnt[root][v] == 2) continue;
			if (!kappa[v][e]) {
				lel.push_back({v, e});
				kappa[v][e] = 1;
				cnt[root][v]++;
				q.push({v, e});
			}
		}
	}
	for (auto i : lel) {
		kappa[i.u][i.v] = 0;
	}
}

signed main() {
	memset(cnt, 0, sizeof(cnt));
	memset(kappa, 0, sizeof(kappa));
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &edge[i].u, &edge[i].v);
		g[edge[i].u].push_back(edge[i].v);
	}
	for (int i = 1; i <= n; i++) {
		dothething(i);
	}
	for (int i = 1; i <= m; i++) {
		if (cnt[edge[i].u][edge[i].v] == 1) {
			if (cnt[edge[i].v][edge[i].u] >= 1) {
				cout << "diff\n";
			}
			else {
				cout << "same\n";
			}
		} 
		else {
			if (cnt[edge[i].v][edge[i].u] >= 1) {
				cout << "same\n";
			}
			else {
				cout << "diff\n";
			}
		}
	}
}

Measured memory_bytes: 9344
/*...................bismillahir rahmanir rahim.....................*/
#include<bits/stdc++.h>
 
#define m_p make_pair
#define PB push_back
#define FF first
#define SS second
#define PII pair<int,int>
#define PSS pair<string,string>
#define MX 1000007
#define MOD 1000000007
#define SI(a)({ ;scanf("%d",&a);a;})
#define SC(a)({ ;scanf("%c",&a);a;})
#define SL(a)({ ;scanf("%lld",&a);a;})
#define SD(a)({ ;scanf("%lf",&a);a;})
#define FI freopen("input.txt","r+",stdin);
#define FO freopen("output.txt","w+",stdout);
using namespace std;
 
typedef long long LL; 
 
/*............start.............*/

void solve()
{
    int res=0;
    string s;
    cin>>s;
    for(int i=0;i*2<s.size();i++)
    {
        if(s[i]!=s[s.size()-i-1]) res++;
    }
    cout<<res<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    int q=1;
    // cin>>q;
    for(int kase=1;kase<=q;kase++)
    {
        //cout<<"Case "<<kase<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <deque>
#include <cassert>
#define pb push_back
#define x first
#define y second
#define files(FileName) read(FileName); write(FileName)
#define read(FileName) freopen((FileName + ".in").c_str(), "r", stdin)
#define write(FileName) freopen((FileName + ".out").c_str(), "w", stdout)
using namespace std;
template<typename T1, typename T2>inline void chkmin(T1 &x, T2 y) { if (x > y) x = y; }
template<typename T1, typename T2>inline void chkmax(T1 &x, T2 y) { if (x < y) x = y; }

const string FILENAME = "input";
const int MAXN = 301, BLOCK = 2048, LOG = 11;

typedef pair <int, int> point;

int n, m;
int prior[MAXN][MAXN], it[MAXN];
bool alive[MAXN];
int cnt[MAXN];

int main() {
	ios::sync_with_stdio(false);
	srand(time(0));
	//read(FILENAME);
	cin >> n >> m; 
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			cin >> prior[i][j];
			--prior[i][j];
			if (j == 0) 
				++cnt[prior[i][j]];
		}
	}
	for (int i = 0; i < m; ++i)
		alive[i] = true;
	int ans = 1e9;
	for (int t = m; t >= 1; --t) {
		int maxid = 0;
		for (int i = 0; i < m; ++i) {
			if (cnt[i] > cnt[maxid]) {
				maxid = i;
			}
		}
		chkmin(ans, cnt[maxid]);
		if (t != 1) {
			alive[maxid] = false;
			for (int i = 0; i < n; ++i) {
				while (!alive[prior[i][it[i]]]) {
					--cnt[prior[i][it[i]]];
					++it[i];
					++cnt[prior[i][it[i]]];
				}
			}
		}
	} 
	cout << ans << endl;
}

/*
3 0 1
2 0 2
2 0 3
3 1 2
2 1 3
3 2 3
15
*/

Measured memory_bytes: 640
import numpy as np
# 複数個格納
# A B = map(int, input().split())
# 行列化
# A = np.array(A)
# A=A.reshape(1,-1)
# A=A.T

N = int(input())
A = list(map(int, input().split()))
A = np.array(A)
A=A.reshape(1,-1)
vector0=A*0
count=0
i=0
flg=False

for i in range(100):
    B=A%2
    C=((A%2 == vector0).all())
    if C == False:
        break
    count=count+1
    A=A/2

print(count)

Measured memory_bytes: 12480
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
using namespace std;

int main()
{
  int cases; cin >> cases;
  while(cases--) {
    int a, b, c; cin >> a >> b >> c;
    if (a*a == b*b + c*c ||
        b*b == c*c + a*a ||
        c*c == a*a + b*b)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
const int N = 14;
string s; int n,pw[N];vector<char> w; vector<vector<char> > f,g; vector<int> h,p;
inline int get(int x,int l){ return x % pw[l]; }
inline void add(vector<char> &s,char c) {
	if (c == 'R') s.push_back(c);
	else if (s.size() && s[s.size()-1] == 'S') s.pop_back();
	else s.push_back(c);
}
int main(){
	int i;
	cin >> n >> s;
	for (pw[0] = i = 1; i <= 12 ; ++i) pw[i] = pw[i-1]*3;
	for (i = 0; i < s.size(); ++i) w.push_back(s[i]);
	f.push_back(w),h.push_back(0);
    for (i = 1; i <= n; ++i){
		g.resize(pw[i]),p.resize(pw[i]);
        for(int now = 0; now < pw[i] ; ++now) {
			int cur = get(now,i-1);
			p[now] = h[cur];
			int d = now/pw[i-1]%3;
			for (auto v : f[cur]){
				if(v == 'S') d = (d<<1)%3,add(g[now],v);
				else if(d == 2) d = 0,add(g[now],v);
				else d += 1;
			}
			p[now] += d*pw[i-1];
		}
		h.clear(),f.clear(),swap(f,g),swap(h,p);
	}
	for (i = 0; i < pw[n]; ++i) cout << h[i] << ((i<pw[n]-1) ? (' ') : ('\n'));
	return 0;
}

Measured memory_bytes: 45976
#include<stdio.h>

int main()
{
       int n,b,min = 1000000,max = -1000000;
       long  sum=0;
       scanf("%d\n",&n);
       int a[n];
      for(int i =0;i<n;i++){
            scanf("%d ",&b);
            a[i] = b;
      }
       for(int j = 0;j<n;j++){
            if(min > a[j])
                min = a[j];
            if(max < a[j])
                max = a[j];
            sum += a[j];
       }
       printf("%d %d %ld\n",min,max,sum);
       return 0;
}


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

template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }

typedef vector<vector<int>> graph;

constexpr int MAX_N = 900;

enum {ESCAPE, LOOP, CATCH};
enum {Q, A, NUM};

const string message[3] = {
	"Queen can escape.",
	"Queen can not escape and Army can not catch Queen.",
	"Army can catch Queen.",
};

int dp[MAX_N][MAX_N][NUM];

inline void add_edge(int a, int b, graph &G) {
	G[a].emplace_back(b);
	G[b].emplace_back(a);
}

inline string solve(int q, int a, const vector<int> &g, const graph &G) {
	const int n = G.size();
	for(int v = 0; v < n; ++v) {
		for(int u = 0; u < n; ++u) {
			dp[v][u][Q] = dp[v][u][A] = LOOP;
		}
	}

	for(int v = 0; v < n; ++v) {
		dp[v][v][Q] = dp[v][v][A] = CATCH;
	}

	for(const auto &e : g) {
		for(int v = 0; v < n; ++v) {
			if(e != v) dp[e][v][Q] = ESCAPE;
		}
	}

	while(true) {
		bool update = false;

		for(int v = 0; v < n; ++v) {
			for(int u = 0; u < n; ++u) {
				if(v == u) continue;

				// queen turn
				if(dp[v][u][Q] != ESCAPE) {
					const int prev = dp[v][u][Q];
					dp[v][u][Q] = CATCH;
					for(const auto &to : G[v]) {
						chmin(dp[v][u][Q], dp[to][u][A]);
					}
					if(dp[v][u][Q] != prev) update = true;
				}

				// army turn
				{
					const int prev = dp[v][u][A];
					dp[v][u][A] = ESCAPE;
					for(const auto &to : G[u]) {
						chmax(dp[v][u][A], dp[v][to][Q]);
					}
					if(dp[v][u][A] != prev) update = true;
				}
			}
		}

		if(!update) break;
	}

	return message[dp[q][a][Q]];
}

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

	for(int w, h; cin >> w >> h && w;) {
		vector<string> field(h);
		for(auto &e : field) cin >> e;

		int next_label = 0;
		vector<vector<int>> label(h, vector<int>(w, -1));
		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				if(field[i][j] != '#') label[i][j] = next_label++;
			}
		}

		int q, a;
		vector<int> g;

		graph G(next_label);

		for(int i = 0; i < h; ++i) {
			for(int j = 0; j < w; ++j) {
				if(field[i][j] == '#') continue;

				const int v = label[i][j];

				switch(field[i][j]) {
				case 'Q': q = v; break;
				case 'A': a = v; break;
				case 'E': g.emplace_back(v); break;
				}

				add_edge(v, v, G);

				if(i < h - 1) {
					if(field[i + 1][j] != '#') {
						add_edge(v, label[i + 1][j], G);
					}
				}

				if(j < w - 1) {
					if(field[i][j + 1] != '#') {
						add_edge(v, label[i][j + 1], G);
					}
				}
			}
		}

		cout << solve(q, a, g, G) << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2040
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int min = sc.nextInt();
        int max = sc.nextInt();

        int count = 0;
        for (int i = min; i <= max; i++) {
            String str = String.valueOf(i);
            if (str.charAt(0) == str.charAt(4)
                    && str.charAt(1) == str.charAt(3)) {
                count ++;
            }
        }

        System.out.println(count);
        sc.close();
    }

}


Measured memory_bytes: 28500
while 1:
    try:
        w = float(input())

        if w <= 48:
            print("light fly")
        elif 48 < w <= 51:
            print("fly")
        elif 51 < w <= 54:
            print("bantam")
        elif 54 < w <= 57:
            print("feather")
        elif 57 < w <= 60:
            print("light")
        elif 60 < w <= 64:
            print("light welter")
        elif 64 < w <= 69:
            print("welter")
        elif 69 < w <= 75:
            print("light middle")
        elif 75 < w <= 81:
            print("middle")
        elif 81 < w <= 91:
            print("light heavy")
        else:
            print("heavy")
    except:
        break


Measured memory_bytes: 5580
import numpy as np

x = int(input())
k = 0
A = 0
B = 0
for i in range(0, 1000):
    I = i**5
    j = I - x
    J = abs(j)
    k = 0
    while k <= J**(0.2):
        if k**5 == J:
            A = i
            B = k*(np.sign(j))
            break
        k += 1
print(str(A) + ' ' + str(B))

Measured memory_bytes: 27120
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int timetoint(char str[]){
  int i, j, h, s;
  char tmp1[12], tmp2[12];

  for(i = 0; str[i]!=':'; i++){
    tmp1[i] = str[i];
  }
  tmp1[i] = '\0';
  h = atoi(tmp1) * 60;

  for(j = 0, i++; str[i]!='\0'; i++, j++){
    tmp2[j] = str[i];
  }
  tmp2[j] = '\0';
  s = atoi(tmp2);

  return h + s;
}

int main(void){
  int i, n, t, count = 0;
  char stname[52], arname[52], sttime[52], artime[52];
  int sttime_i, artime_i, artime_b = 0;
  int timelist[10];
  char namelist[10][51];

  scanf("%d%d", &n, &t);

  for(i = 0; i < n; i++){
    scanf("%s%s%s%s", sttime, stname, artime, arname);
    sttime_i = timetoint(sttime);
    artime_i = timetoint(artime);
    //if(i != 0) printf("%d\n", sttime_i- artime_b);


    if(i != 0 && sttime_i - artime_b >= t){
      strcpy(namelist[count], stname);
      //namelist[count] = stname;
      timelist[count] = sttime_i - artime_b;
      count++;
      //printf("%s %d\n", stname, sttime_i - artime_b);
    }
    artime_b = artime_i;
  }

  printf("%d\n", count);
  for(i = 0; i < count; i++){
    printf("%s %d\n", namelist[i], timelist[i]);
  }

  return 0;
}

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

#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
typedef long long ll;
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}
inline void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
inline void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N,M; cin >> N>>M;
    vector<int> ans(N);
    int a, b;
    for (int i=0; i<M; i++) {
        cin >> a >> b;
        ans[a - 1]++;
        ans[b - 1]++;
    }
    for (const auto& r : ans)
        cout << r << endl;
    
}


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

bool is_war(vector<int> x, vector<int> y) {
    for (int Z = -100; Z <= 100; Z++) {
        bool is_ok = true;
        for (int i = 0; i < x.size(); i++) {
            if (x[i] >= Z) is_ok = false;
        }
        for (int i = 0; i < y.size(); i++) {
            if (y[i] < Z) is_ok = false;
        }
        if (is_ok) return false;
    }
    return true;
}
int main() {
    int N, M; cin >> N >> M;
    vector<int> x(N + 1), y(M + 1);
    cin >> x[0] >> y[0];
    for (int i = 0; i < N; i++) {
        cin >> x[i + 1];
    }
    for (int i = 0; i < M; i++) {
        cin >> y[i + 1];
    }
    if (is_war(x, y)) {
        cout << "War" << endl;
    } else {
        cout << "No War" << endl;
    }
    return 0;
}

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


int main(){
    int n;
    double sum=0;
    cin >> n;
    rep(i,n){
        double x;
        string u;
        cin >> x >> u;
        if(u=="BTC") sum+=x*380000.0;
        else sum+=x;
    }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n,t,l,s;
    cin>>n;
    for(int i=sqrt(n);i>=1;i--)
    {
        if(n%i==0){
             t=i;
			 l=n/i;
             s=1;
            while(l>=10){
                s++;
                l/=10;
            }
        cout<<s;
        return 0;
        }
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        boolean[] A = new boolean[N+1];
        for (int i = 1; i <= N; i++) {
            int n  = sc.nextInt();
            A[i]= n==1 ? true:false;//true=odd, false=even
        }

        boolean[] ans  = new boolean[N+1];
        int count=0;
        for (int i = N; i >=1; i--) {
//            if( i <= N/2){
                int j = i*2;
                boolean b = A[i];
                while(j<=N){
                    b = b ^ ans[j];
                    j+=i;
                }
                ans[i] = b;
//            }else{
//                ans[i] = A[i];
//            }

            if(ans[i] == true) count++;

        }
        System.out.println(count);
        for (int i = 1; i <= N; i++) {
            if(ans[i]) System.out.print(i +" ");
        }
    }

}


Measured memory_bytes: 64236
n, a, b = map(int ,input().split())

if (b-a) % 2 == 0:
	ans = (b-a) // 2
else:
	ans_2_1 = b-1
	ans_2_2 = n-a

	if b-a == 1:
		ans = min(ans_2_1, ans_2_2)
	else:


		ans_3_1 = (a-1) + 1 + (b-a+1-1-1)//2
		ans_3_2 = (n-b) + 1 + (n-(a+n-b+1))//2

		ans = min(ans_2_1,ans_2_2,ans_3_1,ans_3_2)

print(ans)

Measured memory_bytes: 3064
n=int(input())
s=input()
ans=0
for i in range(10):
  a=s.find(str(i))
  if a == -1:
    continue
  for j in range(10):
    b=s.find(str(j),a+1)
    if b == -1:
      continue
    for k in range(10):
      if s.find(str(k),b+1) != -1:
        ans+=1
print(ans)


Measured memory_bytes: 62520
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;
ll dp[55][55][5000];

signed main(){
	//cout << fixed << setprecision(10);
	ll n,A; cin>>n>>A;
	vl vec(n);
	rep(i,0,n)cin>>vec[i];
	dp[0][0][0]=1;
	rep(i,0,n){
		rep(j,0,n+1){
			rep(k,0,3000){
				dp[i+1][j][k]+=dp[i][j][k];
				if(k+vec[i]<5000)dp[i+1][j+1][k+vec[i]]+=dp[i][j][k];
			}
		}
	}
	ll ans=0;
	rep(i,1,n+1)ans+=dp[n][i][A*i];
	cout<<ans<<endl;

	return 0;
}

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

int main() {
  string s,t;
  int ans = 0;
  cin >> s >> t;
  for (int i=0; i<3; i++){
    if (s.at(i) == t.at(i)){
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define ANTHRO(x...) cerr << "[" << #x << "] = [", _print(x)
#else
#define ANTHRO(x...)
#endif


#define ll long long
#define MOD 1000000007
#define INF (int)1e9
#define EPS 1e-9
/*
    This is 4.cpp
*/
#define cond (ll)2e3+17
/*vector<ll> ed[cond];
ll med(ll u,ll v, ll n){
    vector<bool> vis(n,0);
    vector<ll> dis(n,0);
    queue<ll> q;
    q.push(u);
    vis[u] = true;
    while (!q.empty())
    {
        int x = q.front();
        q.pop();

        for (int i=0; i<ed[x].size(); i++)
        {
            if (vis[ed[x][i]])
                continue;
            dis[ed[x][i]] = dis[x] + 1;
            q.push(ed[x][i]);
            vis[ed[x][i]] = 1;
        }
    }
    return dis[v];
}*/
/*void aE(ll u,ll v){
    ed[u].push_back(v);
    ed[v].push_back(u);//Undirected graph
}*/
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,y; cin>>n>>x>>y;
    vector<ll> dis(n+1,0);
    /*for(ll i=1;i<=n-1;i++){
        aE(i,i+1);
    }
    aE(x,y);*/
    for(ll i=1;i<n;i++){
        for(ll j=i+1;j<=n;j++){
            dis[min(abs(j-i),min((abs(x-i)+1+abs(y-j)),(abs(y-i)+1+abs(x-j))))]++;
        }
    }
    for(ll i=1;i<n;i++){
        cout<<dis[i]<<"\n";
    }
    return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <functional>

#define REP(i,n) for(int i=0;i<n;i++)

using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;

int main() {
    int n;
    scanf("%d", &n);
    printf("%d\n", n*(n+1)/2);
}


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

int n, a, b, c, toppings[100], value, cal;

int main()
{
  cin >> n >> a >> b >> c;
  for(int i = 0; i < n; i++)
  {
    cin >> toppings[i];
  }
  value = a;
  cal = c;
  sort(toppings, toppings + n);
  for(int i = n - 1; i >= 0; i--)
  {
    if(cal / value <= (cal + toppings[i]) / (value + b))
    {
      value += b;
      cal += toppings[i];
    }
  }
  cout << cal / value << endl;
}

Measured memory_bytes: 1176
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#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 gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("-1"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define bn(x) ((1<<x)-1)
#define newline puts("")
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;

ll dp[101][305];

int main() {
  int n,w;
  scanf("%d%d",&n,&w);
  int ws = 0, sum = 0;
  rep(i,n) {
    int a,b;
    scanf("%d%d",&a,&b);
    if (!i) {
      ws = a;
    }
    a -= ws;
    drep(j,i+1)drep(k,sum+1) {
      maxs(dp[j+1][k+a], dp[j][k]+b);
    }
    sum += a;
  }
  ll ans = 0;
  rep(i,n+1)rep(j,sum+1) {
    ll x = (ll)ws*i+j;
    if (x <= w) {
      maxs(ans,dp[i][j]);
    }
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 512
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanRunes() []rune { return []rune(scanString()) }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	h := scanInt()
	w := scanInt()

	if h == 1 || w == 1 {
		fmt.Fprintln(wr, 1)
		return
	}

	fmt.Fprintln(wr, (w+1)/2*((h+1)/2)+w/2*(h/2))
}


Measured memory_bytes: 640
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);
    while (true) {
        int a = sc.nextInt();
        String op = sc.next();
        int b = sc.nextInt();
        if ("?".equals(op)) break;
        Map<String, Integer> result = new HashMap<>();
        result.put("+", a + b);
        result.put("-", a - b);
        result.put("*", a * b);
        result.put("/", b != 0 ? a / b : 0);
        pw.append(String.valueOf(result.get(op)));
        pw.append("\n");
    }
    pw.flush();
  }
}


Measured memory_bytes: 26288
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pairs;

#define MOD 998244353


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

bool primeNumber(ll n){
    if(n < 2) return false;
    else{
        for(ll i = 2; i * i <= n; i++){
            if(n % i == 0) return false;
        }
        return true;
    }
}


int main(){
    ll n; cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}
 
    
    



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

int main(){

  string s;
  cin >> s;

  for(int i=0;i<s.size();i++){
    if(s[i] == '1') s[i] = '9';
    else if(s[i] == '9') s[i] = '1';
  }

  cout << s << endl;

}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**13
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    s = S()
    if len(s) == 2:
        return s

    return s[::-1]


print(main())


Measured memory_bytes: 5460
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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 namespace std;

// 辺（方向と重み）
struct edge{ ll to, cost; };

// 幅優先探索
void bfs(vector<vector<edge>> &g, ll n, ll node, vi &color, vi &dst, bool &ans, ll cost){
    if(color[node] == 1){
        if(dst[node] != cost) ans = false;
    }
    else{
        color[node] = 1;
        dst[node] = cost;
        rep(i, g[node].size()){
            bfs(g, n, g[node][i].to, color, dst, ans, cost + g[node][i].cost);
        }
    }
}

int main(){
    Init();
    ll n, m; cin >> n >> m;
    vector<vector<edge>> g(n, vector<edge>(0));

    // グラフの生成
    rep(i, m){
        ll l, r, d; cin >> l >> r >> d;
        l--; r--; // 0-based
        // 双方向に辺を張る（逆向きはコストもマイナスにする）
        g[l].push_back((edge){r, d});
        g[r].push_back((edge){l, -d});
    }

    // 回答出力用
    bool ans = true;

    // グラフ巡回確認
    vi color(n, 0);
    vi dst(n, -INFLL);

    // 矛盾がないか確認
    rep(i, n){
        if(color[i] == 0){
            dst[i] = 0;
            bfs(g, n, i, color, dst, ans, 0LL);
        }
    }

    // 結果出力
    (ans) ? Yes() : No();
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int H,N;
    Scd2(H,N);
    int a;
    int hh = 0;
    Rep(i,N){
        Scd(a);
        hh += a;
    }

    YesNo(hh>=H);

    return 0;
}



Measured memory_bytes: 256
import numpy as np

H, W, *M = open(0).read().split()
H = int(H)
W = int(W)
M = np.array([list(r) for r in M])

del_rows = []

M_ans = M

for i in range(H):
    if "#" not in M_ans[i]:
         del_rows.append(i)
            
M_ans = np.delete(M_ans, del_rows, 0)

del_cols = []

for j in range(len(M_ans.T)):
    if "#" not in M_ans.T[j]:
         del_cols.append(j)
            
M_ans = np.delete(M_ans, del_cols, 1)

print(*["".join(r) for r in M_ans], sep="\n")

Measured memory_bytes: 27172
n,m=map(int,input().split())
e=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    e.append([a-1,b-1,-c])
M=10**18
d=[0]+[M]*~-n
k=0
v=0
while k<n*2:
    k+=1
    if k==n:v=d[-1]
    f=0
    for a,b,c in e:
        if d[b]>d[a]+c:
            d[b]=d[a]+c
            f=1
    if not f:
        break
if not v or v==d[-1]:
    print(-d[-1])
else:
    print('inf')

Measured memory_bytes: 3440
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    // char ;
    ll n;
    scanf("%lld",&n);
    ll a[n],x[n-1],y[n-1],r=0;
    rep(i,0,n){
        scanf("%lld",&a[i]);
        if(a[i]>=0) r++;
    }

    if(n==2){
        printf("%lld\n",ABS(a[0]-a[1]));
        printf("%lld %lld\n",max2(a[0],a[1]),min2(a[0],a[1]));
        return 0;
    }

    sortup(a,n);
    // rep(i,0,n){
    //     printf("%lld ",a[i]);
    // }
    PN;
    if(r<2){
        x[0]=a[n-1];
        y[0]=a[0];
        rep(i,1,n-1){
            x[i]=x[i-1]-y[i-1];
            y[i]=a[i];
        }
    }else if(r==n || r==n-1){
        x[0]=a[0];
        y[0]=a[1];
        rep(i,1,n-2){
            x[i]=x[i-1]-y[i-1];
            y[i]=a[i+1];
        }
        x[n-2]=a[n-1];
        y[n-2]=x[n-3]-y[n-3];
    }else if(r!=2){
        x[0]=a[0];
        y[0]=a[n-r];
        rep(i,0,r-2){
            x[i+1]=x[i]-y[i];
            y[i+1]=a[n-r+1+i];
        }
        rep(i,0,n-r){
            x[r-1+i]= i? x[r-2+i]-y[r-2+i] : a[n-1];
            y[r-1+i]= i? a[i] : x[r-2+i]-y[r-2+i];
        }
    }


    printf("%lld\n",x[n-2]-y[n-2]);
    rep(i,0,n-1){
        printf("%lld %lld\n",x[i],y[i]);
    }
    return 0;
}


Measured memory_bytes: 4212
#if __has_include("../library/Basic/Debug.hpp")

#include "../library/Basic/Debug.hpp"

#else

/* ----- Header Files ----- */
// IO
#include <cstdio>
#include <iomanip>
#include <ios>
#include <iostream>

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

// container
#include <vector>
#include <string>
#include <tuple>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>

// others
#include <random>
#include <limits>
#include <functional>
#include <ctime>
#include <cassert>
#include <cstdint>


/* ----- Type Alias ----- */
using Bool = bool;
using Int = long long int;
using Real = long double;
using Char = char;
using String = std::string;
template <class T, class U>
using Pair = std::pair<T, U>;
template <class... Ts>
using Tuple = std::tuple<Ts...>;

template <class T>
using Vector = std::vector<T>;
template <size_t N>
using Bits = std::bitset<N>;
template <class T>
using Queue = std::queue<T>;
template <class T>
using Stack = std::stack<T>;
template <class T>
using Deque = std::deque<T>;

template <class T>
using MaxHeap = std::priority_queue<T>;
template <class T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template <class T>
using Set = std::set<T>;
template <class T, class U>
using Map = std::map<T, U>;

template <class T, class... Us>
using Func = std::function<T(Us...)>;

template <class T>
T genv(T v) { return v; }

template <class T, class... Ts>
auto genv(size_t l, Ts... ts) {
    return Vector<decltype(genv<T>(ts...))>(l, genv<T>(ts...));
}

template <class Cost = Int>
struct Edge {
    Int src, dst;
    Cost cost;
    Edge(Int src = -1, Int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = Int>
using Edges = Vector<Edge<Cost>>;
template <class Cost = Int>
using Graph = Vector<Vector<Edge<Cost>>>;

#endif

/* ----- Misc ----- */
void fastio() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
}

struct Fout {
    Int precision;
    Fout(Int precision) : precision(precision) {}
};
std::ostream& operator<<(std::ostream& os, const Fout& fio) {
    os << std::fixed << std::setprecision(fio.precision);
    return os;
}


/* ----- Constants ----- */
// constexpr Int INF = std::numeric_limits<Int>::max() / 3;
// constexpr Int MOD = 1000000007;
// constexpr Real PI = acos(-1);
// constexpr Real EPS = 1e-10;
// std::mt19937 mt(int(std::time(nullptr)));

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


Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
ans = 0
L.sort()
for i in range(N):
    for j in range(i+1, N):
        for k in range(j+1, N):
            if L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
                if L[k] < L[i] + L[j]:
                    ans += 1
print(ans)

Measured memory_bytes: 9208
#include<iostream>
#include<string>
#include<cmath>
#include<array>
#include<algorithm>
//#include<deque>
#include<vector>
//#include<utility>
#include<set>
//#include<map>
//#include<list>

using namespace std;
using LLI = long long int;

//class UnionFind {
//public:
//	vector<int>data;
//	UnionFind(int size) :data(size, -1) {};
//	bool unionset(int x, int y) {
//		x = root(x), y = root(y);
//		if (x != y) {
//			if (data[y] < data[x]) {
//				swap(x, y);
//			}
//			data[x] += data[y];
//			data[y] = x;
//		}
//		return x != y;
//	}
//	bool findset(int x, int y) {
//		return root(x) == root(y);
//	}
//	int root(int x) {
//		return data[x] < 0 ? x : data[x] = root(data[x]);
//	}
//	int size(int x) {
//		return -data[root(x)];
//	}
//};

//int gcd(int x, int y) {
//	int tmp, r;
//	if (x < y) {
//		tmp = x;
//		x = y;
//		y = tmp;
//	}
//	r = x % y;
//	while (r != 0) {
//		x = y;
//		y = r;
//		r = x % y;
//	}
//	return y;
//}

//vector<vector<int>>sub;
//int dfs(int id) {
//	if (sub[id].size() == 0) {
//		return 1;
//	}
//	int minP = (int)1e9;
//	int maxP = 0;
//	for (int i : sub[id]) {
//		int P = dfs(i);
//		minP = min(minP, P);
//		maxP = max(maxP, P);
//	}
//	return minP + maxP + 1;
//}

//const int n_max = 8;
//array<array<bool, n_max>, n_max>graph;
//int dfs(int v,int N,array<bool,n_max>visited) {
//	int ret = 0;
//	bool all_visited = true;
//	for (int i = 0; i < N;i++) {
//		if (visited[i] == false) {
//			all_visited = false;
//		}
//	}	
//	if (all_visited) {
//		return 1;
//	}
//	for (int i = 0; i < N;i++) {
//		if (graph[v][i] == false) {
//			continue;
//		}
//		if (visited[i] == true) {
//			continue;
//		}
//		visited[i] = true;
//		ret += dfs(i,N,visited);
//		visited[i] = false;
//	}
//	return ret;
//}

//long nCr(int n,int r) {
//	long ans = 1;
//	for (int i = n; i > n - r;i--) {
//		ans = ans * i;
//	}
//	for (int i = 1; i < r + 1;i++) {
//		ans = ans / i;
//	}
//	return ans;
//}

int main(void) {
	LLI N, M, A, B, res = 0, j = 0;
	vector<pair<LLI, LLI>>vec;
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> A >> B;
		vec.push_back(make_pair(A, B));
	}
	sort(vec.begin(), vec.end());
	for (int i = 0; i < M; i++) {
		if (vec[j].second > 0) {
			res += vec[j].first;
			vec[j].second -= 1;
		}
		else {
			j++;
			i--;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 2420
import java.util.*;
import java.io.*;

public class Main {
    
    public static void main(String[] args) {
        Main main = new Main();
        main.solv();
    }
    
    private void solv() {
        Scanner input = new Scanner(System.in);
        Tree t = new Tree();
        int n = input.nextInt();
        while (n-- > 0) {
            String op = input.next();
            String str = input.next();
            if ("insert".equals(op)) {
                t.add(str);
            } else if ("find".equals(op)) {
                if (t.contains(str)) {
                    System.out.println("yes");
                } else {
                    System.out.println("no");
                }
            }
        }
    }
    
    private void print(Object[] xs) {
        StringBuilder sb = new StringBuilder();
        for (Object x : xs) sb.append(x.toString()).append(' ');
        System.out.println(sb.toString().trim());
    }
    
    private static class Tree {
        String value;
        Tree left;
        Tree right;
        
        public void add(String s) {
            if (value == null) {
                value = s;
                return;
            }
            if (value.compareTo(s) <= 0) {
                if (left == null) left = new Tree();
                left.add(s);
            } else {
                if (right == null) right = new Tree();
                right.add(s);
            }
        }
        public boolean contains(String s) {
            if (s == null || value == null) return false;
            if (value.equals(s)) return true;
            if (value.compareTo(s) <= 0) return left == null ? false : left.contains(s);
            else return right == null ? false : right.contains(s);
        }
    }
    
    private static class Scanner {
        BufferedReader r;
        StreamTokenizer st;
        
        public Scanner(InputStream in) {
            r = new BufferedReader(new InputStreamReader(in));
            st = new StreamTokenizer(r);
        }
        
        public String next() {
            nextToken();
            return st.sval;
        }
        
        public Integer nextInt() {
            nextToken();
            return (int)st.nval;
        }
        
        private int nextToken() {
            int token = st.TT_EOF;
            try {
                token = st.nextToken();
            } catch (IOException e) {
            }
            return token;
        }
    }
}

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

int main(){
    int N; cin >> N;
    map<string, long> m;
    for (int i = 0; i < N; i++)
    {
        string s; cin >> s;
        sort(s.begin(), s.end());
        m[s]++;
    }
    long ans = 0;
    for(auto i : m){
        ans += i.second * (i.second -1) / 2;
    }    
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include<string>
using namespace std; 


int main() 
{
    long long int a,b,k,count=0;
     cin>>k>>a>>b;
     for(int i=a;i<=b;i++)
     {
          if(i%k==0)
          count++;
     }
     if(count==0)
     cout<<"NG";
     else
     cout<<"OK";
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#define pq priority_queue
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;

const int iinf = 1 << 29;
const long long linf = 1ll << 61;


int main(){
  int h,w;
  cin>>h>>w;
  char c[h][w];
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin>>c[i][j];
    }
  }
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if(c[i][j]=='#'){
        if(i!=0&&c[i-1][j]=='#') continue;
        if(i!=h-1&&c[i+1][j]=='#') continue;
        if(j!=0&&c[i][j-1]=='#') continue;
        if(j!=w-1&&c[i][j+1]=='#') continue;
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sqr(x) (x)*(x)
#define int long long
using namespace std;

signed main() {
#ifdef _DEBUG
	freopen("_in" , "r", stdin );
	freopen("_out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int n, s = 0; cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i], s += a[i];
	if(s > 0) s += n / 2;
	if(s < 0) s -= n / 2;
	s /= n;
	int ans = 0;
	for (int i = 0; i < n; i++) ans += sqr(s - a[i]);
	cout << ans << '\n';
}


Measured memory_bytes: 256
//
//  main.cpp
//  atcoder
//
//  Created by Hisaki Kobayashi on 2020/04/14.
//  Copyright © 2020 Hisaki Kobayashi. All rights reserved.
//

#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
const int MAX_N = 200000;

int ctoi(const char c){
  switch(c){
    case '0': return 0;
    case '1': return 1;
    case '2': return 2;
    case '3': return 3;
    case '4': return 4;
    case '5': return 5;
    case '6': return 6;
    case '7': return 7;
    case '8': return 8;
    case '9': return 9;
    default : return -1;
  }
}



int main(int argc, const char * argv[]) {
    int K; cin >> K;
    int A,B; cin >> A >> B;
    
    for(int i=A;i<=B;i++){
        if(i%K==0){
            cout << "OK" << endl;
            return 0;
        }
    }
    
    
    cout << "NG" << endl;
    return 0;
}




Measured memory_bytes: 3624
s=input()
l=0
r=len(s)-1
ans=0
while r>l:
    if s[l]==s[r]:
        l+=1
        r-=1
    elif s[l]=='x':
        l+=1
        ans+=1
    elif s[r]=='x':
        r-=1
        ans+=1
    else:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i <= (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(ll i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

ll n, m;
string s;

int main(){
	cin.tie(0); ios::sync_with_stdio(false);
	ll x;
	cin >> x;
	ll hurui[200008];
	memset(hurui, 0, sizeof(hurui));
	
	rep(i, 2, x){
		if(!hurui[i]){
			for(ll j = 2; j*i <= 2*x; j++){
				hurui[j*i] = true;
			}
		}
	}
	rep(i, x, 2*x){
		if(!hurui[i]){
			print(i)
			return 0;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
 
#define PB push_back
#define MP make_pairA
#define REP(i,n) for(int i=0;i<(n);i++)
int main()
{
    int n,k;
    cin>>n>>k;
    n-=k;
    if(k==1)cout<<0<<endl;
    else cout<<n<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int n;
	cin >> n;
    string s;
  int ans=0;
  cin >> s;
    fr(i,10){
      fr(j,10){
        fr(k,10){
          int ban[3]={i,j,k};
          int now=0;
          fr(x,n){
            if(s[x]-48==ban[now])now++;
            if(now==3){
              ans++;
              break;
            }
          }
        }
      }
    }
      cout << ans << endl;
}

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

using namespace std;

int count(string str, char c)
{
    int n = 0;
    for (auto itr = str.begin(); itr != str.end(); ++itr)
    {
        if (*itr == c)
            ++n;
    }
    return n;
}

int main()
{
    string str;
    getline(cin, str);
    bool ret = true;
    for (char c = 'a'; c <= 'z'; ++c)
    {
        ret &=
            (count(str, c) % 2 == 0);
        if (!ret)
        {
            break;
        }
    }

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

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

int main(){
    int A,B,C; cin >> A >> B >> C;
    int X; cin >> X;
    
    int ans=0;
    rep(i,A){//500
        rep(j,B){//100
            rep(k,C){//50
                if(500*i+100*j+50*k == X) ans++;
            }
        }
    }
    cout << ans;
}

Measured memory_bytes: 256