akhauriyash/Code-Regression huggingface dataset:
#pragma GCC diagnostic ignored "-Wincompatible-pointer-types"
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>
#include <time.h>

#define BIG 2000000007
#define VERYBIG 20000000000000007LL
typedef uint64_t ull;
typedef  int64_t sll;

#define N_MAX 1048576

ull n, k;
sll a[N_MAX + 5];
sll b[N_MAX + 5];

int cnt[1005][1005];

int more0[2005][2005], more1[2005][2005], more2[2005][2005];
int find0 (ull ld, ull rd, ull h, ull w) {
	return more0[ld + h - 1][rd + w - 1]
		- (ld ? more0[ld - 1][rd + w - 1] : 0)
		- (rd ? more0[ld + h - 1][rd - 1] : 0)
		+ ((ld && rd) ? more0[ld - 1][rd - 1] : 0);
}
int find1 (ull ld, ull rd, ull h, ull w) {
	return more1[ld + h - 1][rd + w - 1]
		- (ld ? more1[ld - 1][rd + w - 1] : 0)
		- (rd ? more1[ld + h - 1][rd - 1] : 0)
		+ ((ld && rd) ? more1[ld - 1][rd - 1] : 0);
}
int find2 (ull ld, ull rd, ull h, ull w) {
	return more2[ld + h - 1][rd + w - 1]
		- (ld ? more2[ld - 1][rd + w - 1] : 0)
		- (rd ? more2[ld + h - 1][rd - 1] : 0)
		+ ((ld && rd) ? more2[ld - 1][rd - 1] : 0);
}
bool func (sll x) {
	sll i, j;
	ull sup0 = (x / k + 1) * (x / k + 1);
	ull sup1 = (x / k) * (x / k + 1);
	ull sup2 = (x / k) * (x / k);
	for (i = 0; i < k; i++) {
		for (j = 0; j < k; j++) {
			more0[i][j] = more1[i][j] = more2[i][j] = 0;

			if (cnt[i][j] > sup2) {
				more2[i][j] = cnt[i][j];
				if (cnt[i][j] > sup1) {
					more1[i][j] = cnt[i][j];
					if (cnt[i][j] > sup0) {
						more0[i][j] = cnt[i][j];
					}
				}
			}
		}
	}
	for (i = 0; i < k; i++) {
		for (j = 0; j < k; j++) {
			more0[i + k][j + k] = more0[i + k][j] = more0[i][j + k] = more0[i][j];
			more1[i + k][j + k] = more1[i + k][j] = more1[i][j + k] = more1[i][j];
			more2[i + k][j + k] = more2[i + k][j] = more2[i][j + k] = more2[i][j];
		}
	}

	for (i = 0; i < k * 2; i++) {
		for (j = 1; j < k * 2; j++) {
			more0[i][j] += more0[i][j - 1];
			more1[i][j] += more1[i][j - 1];
			more2[i][j] += more2[i][j - 1];
		}
	}
	for (j = 0; j < k * 2; j++) {
		for (i = 1; i < k * 2; i++) {
			more0[i][j] += more0[i - 1][j];
			more1[i][j] += more1[i - 1][j];
			more2[i][j] += more2[i - 1][j];
		}
	}

	ull m = x % k;
	for (i = 0; i < k; i++) {
		for (j = 0; j < k; j++) {
			if (find0(        i,         j,     m,     m)) continue;
			if (find1(i + m,         j, k - m,     m)) continue;
			if (find1(        i, j + m,     m, k - m)) continue;
			if (find2(i + m, j + m, k - m, k - m)) continue;

			return true;
		}
	}

	return false;
}

ull solve () {
	sll i, j, ki, li;
	sll result = 0;
	double dresult = 0;
	sll maybe = 0;
	sll sum = 0;
	sll item;
	sll *dpcell;

	for (i = 0; i < n; i++) {
		cnt[a[i] % k][b[i] % k]++;
	}

	sll ok = BIG, ng = 0;
	while (ng + 1 < ok) {
		sll med = (ok + ng) / 2;
		if (func(med)) {
			ok = med;
		} else {
			ng = med;
		}
	}
	result = ok - 1;

	printf("%lld\n", result);
	return 0;
}

int32_t main (int argc, char *argv[]) {
	int32_t i, j;

	scanf("%llu%llu", &n, &k);
	for (i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		scanf("%lld", &b[i]);
	}

	solve();

	return 0;
}


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

// n個の重複しない整数(min ~ max)の和としてsを表す組み合わせの数
int ci(int n, int s, int min, int max) {
  // 特殊なパターンを処理
  if (s < min || n < 1) return 0;
  if (n == 1) return (s > max)? 0: 1;
  
  // 最も小さい数で場合分けし再帰処理
  int r = 0;
  for (int i=min; i<s && i<=max; i++) r += ci(n - 1, s - i, i + 1, max);
  return r;
}

int main() {
  while (true) {
    int n, s;
    cin >> n >> s;
    if (!n && !s) break;
    cout << ci(n, s, 0, 9) << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <cctype>
#include <queue>
#include <vector>

using namespace std;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}
	while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
	return x*f;
}

int main()
{
	int n=read();
	if (!(n&(n-1))) 
		puts("No");
	else
	{
		puts("Yes");
		puts("1 2");
		puts("2 3");
		cout << 3 << " " << n+1 << endl;
		cout << n+1 << " " << n+2 << endl;
		cout << n+2 << " " << n+3 << endl;
		for (int i=4;i+1<=n;i+=2)
		{
			int j=i+1;
			cout << 1 << " " << i << endl;
			cout << 1 << " " << j << endl;
			cout << i << " " << j+n << endl;
			cout << j << " " << i+n << endl;
		}
		if (n%2==0)
		{
			for (int i=4;i<=n;i++)
			{
				int j=n^i^1;
				if (j!=3 && j<n)
				{
					cout << i << " " << n << endl;
					cout << j << " " << 2*n << endl;
					return 0;
				}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2304
a=int(input())
b=int(input())
c=int(input())
d=int(input())
p=int(input())
x=p*a
if p<=c:
  if x<=b:
    print(x)
  else:
    print(b)
else:
  z=b+(p-c)*d
  if x<=z:
    print(x)
  else:
    print(z)


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

int main()
{
  int N,i,j,key,k;
  int *array;

  /* 入力 */
  scanf("%d",&N);
  if(N >100 || N < 1) exit(0);
  array = (int *)malloc(sizeof(int) * N);
  if(array == NULL) exit(0);
  for(i = 0;i < N;i++){
    scanf("%d",&array[i]);
  }

  /* 出力 */
  for(k = 0;k < N;k++){
    printf("%d",array[k]);
    if (k != N-1) printf(" ");
  }
  printf("\n");
 
  /* sort */
  for(i = 1;i <= N-1;i++){
    key = array[i];
    j = i - 1;
    while(j >= 0 && array[j] > key){
      array[j+1] = array[j];
      j--;
    }
    array[j+1] = key;
    /* 出力 */
    for(k = 0;k < N;k++){
      printf("%d",array[k]);
      if (k != N-1) printf(" ");
    }
    printf("\n");
  }
    
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <functional>
#include <bitset>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";}
template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";}
template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 1e9+7;

int main() {
  string s; cin>>s;
  int n=s.size();
  for(int i=0;i<n;i++) {
    if (s[i]=='?') s[i]='D';
  }
  cout<<s<<endl;
}
// Thank you for making problems and running the contest

Measured memory_bytes: 3752
x=list(input())
y=list(input())
z=list(input())
st=x[0]
x.pop(0)
flag=True
ans=""
while flag:
  if st == "a":
    if len(x)==0:
      flag=False
      ans="A"
    else:
      st=x[0]
      x.pop(0)
  if st == "b":
    if len(y)==0:
      flag=False
      ans="B"
    else:
      st=y[0]
      y.pop(0)
  if st == "c":
    if len(z)==0:
      flag=False
      ans="C"
    else:
      st=z[0]
      z.pop(0)
print(ans)

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

int main(){
    string s;
    cin>>s;
    int cnt=0;
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }else{
        for(int i=2;i<s.size()-1;i++){
            if(isupper(s[i])){
                cnt+=1;
            }

        }
        if(cnt!=1){
            cout<<"WA"<<endl;
            return 0;
        }
    }
    int cnt2=0;
    rep(i,s.size()){
        if(isupper(s[i]))cnt2+=0;
        else cnt2+=1;

    }
    if(cnt2==s.size()-2)cout<<"AC"<<endl;
    else cout<<"WA"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define clr(x) memset(x,0,sizeof (x))
#define For(i,a,b) for (int i=(a);i<=(b);i++)
#define Fod(i,b,a) for (int i=(b);i>=(a);i--)
#define fi first
#define se second
#define kill _z_kill
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define outval(x) cerr<<#x" = "<<x<<endl
#define outv(x) cerr<<#x" = "<<x<<"  "
#define outtag(x) cerr<<"--------------"#x"---------------"<<endl
#define outarr(a,L,R) cerr<<#a"["<<L<<".."<<R<<"] = ";\
	For(_x,L,R) cerr<<a[_x]<<" ";cerr<<endl;
#define User_Time ((double)clock()/CLOCKS_PER_SEC)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned uint;
typedef long double LD;
typedef vector <int> vi;
typedef pair <int,int> pii;
LL read(){
	LL x=0,f=0;
	char ch=getchar();
	while (!isdigit(ch))
		f=ch=='-',ch=getchar();
	while (isdigit(ch))
		x=(x<<1)+(x<<3)+(ch^48),ch=getchar();
	return f?-x:x;
}
const int mod=1e9+7;
int Pow(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=(LL)x*x%mod)
		if (y&1)
			ans=(LL)ans*x%mod;
	return ans;
}
void Add(int &x,int y){
	if ((x+=y)>=mod)
		x-=mod;
}
void Del(int &x,int y){
	if ((x-=y)<0)
		x+=mod;
}
int Add(int x){
	return x>=mod?x-mod:x;
}
int Del(int x){
	return x<0?x+mod:x;
}
const int N=5005;
int n,m;
int Fac[N],Inv[N];
int C(int n,int m){
	if (m<0||m>n)
		return 0;
	return (LL)Fac[n]*Inv[m]%mod*Inv[n-m]%mod;
}
LL dp[N][N];
int main(){
	n=read(),m=read();
	Fac[0]=1;
	For(i,1,m)
		Fac[i]=(LL)Fac[i-1]*i%mod;
	Inv[m]=Pow(Fac[m],mod-2);
	Fod(i,m,1)
		Inv[i-1]=(LL)Inv[i]*i%mod;
	dp[0][1]=1;
	For(i,1,n){
		For(j,1,m){
			int v=dp[i-1][j];
			LL val=(LL)v*(j+1);
			dp[i][j]+=val;
			dp[i][j+1]-=val;
			dp[i][j+1]+=2LL*v*j;
		}
		For(j,1,m)
			dp[i][j]=(dp[i][j]+dp[i][j-1])%mod;
	}
	int ans=0;
	For(i,1,m)
		Add(ans,(LL)dp[n][i]*C(m-1,i-1)%mod);
	cout<<ans<<endl;
	return 0;
}

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

int N;
map <int, int> cnt;

int main() {
	scanf("%d", &N);
	while (N--) {
		int x;
		scanf("%d", &x);
		cnt[x]++;
	}
	
	int sol = 0;
	for (auto it : cnt)
		sol += it.second >= it.first ? it.second - it.first : it.second;
	
	printf("%d\n", sol);
	
	return 0;
}

Measured memory_bytes: 4736
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> m;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  tmp = (sum + 4 * m - 1) / (4 * m);
  rep(i, n) {
    if (a[i] >= tmp) cnt++;
  }
  if (cnt >= m)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

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

    int max = 1;
    string maxstr;
    bool f = false;
    for (int i = 0; i < N; ++i) {
        for (int j = i + max; j < N; ++j) {
            while (S.substr(i, max) == S.substr(j, max) && i + max <= j) {
                f = true;
                if (S.substr(i, max+1) == S.substr(j, max+1) && i + max + 1 <= j) {
                    max++;
                } else {
                    break;
                }
            }
        }
    }
    if (f) {
        cout << max << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define emb emplace_back
#define fcout cout << fixed << setprecision(15)

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

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

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

  int n = s.length();
  ll ans = 0;
  rep(i,1<<(n-1)) {
    int now = 0;
    rep(j,n-1) if(i>>j&1) {
      /*cout << "in" << endl;
      cout << now << endl;
      cout << j << endl;
      cout << s.substr(now,j+1-now) << endl;*/
      ans += stoll(s.substr(now,j+1-now));
      now = j+1;
    }
    /*cout << "out" << endl;
    cout << now << endl;;
    cout << stoll(s.substr(now,n-now)) << endl;*/
    ans += stoll(s.substr(now,n-now));
  }

  cout << ans << endl;
  return 0;
}


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

string S;
string T;

int main(){
  
  cin>>S>>T;
  
  bool miss = false;
  
  for(int i = 0;i < S.length();i++){
    if(S[i]!=T[i])miss = true;
  
  }
  
  if(miss){
    cout<<"No";
  }else{
    cout<<"Yes";
  }


	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<pair<int, ll>, int>;
#define rep(i,n) for(int i=0;i<n;i++)
inline ll in() { ll x; cin >> x; return x; }

const int N = 305;
const int INF = 1001001001;
const ll LINF = 1LL<<60;

vector<vector<ll>> g(N, vector<ll>(N, LINF));
vector<vector<pair<int, ll>>> d(N, vector<pair<int, ll>>(N, {INF, LINF}));

int main() {
  int n = in(), m = in();
  ll l = in();

  rep(i,m) {
    int a = in() - 1, b = in() - 1;
    g[a][b] = g[b][a] = in();
  }

  rep(s,n) {
    d[s][s] = {0, 0};
    priority_queue<P, vector<P>, greater<P>> q;
    q.push({d[s][s], s});
    while (!q.empty()) {
      auto p = q.top();
      q.pop();

      ll v = p.second;
      ll kaisuu = p.first.first;
      ll used = p.first.second;
      
      if (p.first > d[s][v]) continue;
      rep(nv,n) {
        if (nv == v) continue;
        if (g[v][nv] > l) continue;
        ll nused = used + g[v][nv];
        pair<int, ll> np = {0, 0};
        if (nused > l) np = {kaisuu + 1, g[v][nv]};
        else np = {kaisuu, nused};

        if (d[s][nv] > np) {
          d[s][nv] = np;
          q.push({np, nv});
        }
      }
    }
  }

  int q = in();
  rep(i, q) {
    int s = in() - 1, t = in() - 1;
    if (d[s][t].first == INF) cout << -1 << endl;
    else cout << d[s][t].first << endl;        
  }
  return 0;
}

Measured memory_bytes: 3964
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long MOD = 1000000007;
const long long INF = 0x3f3f3f3f;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int S = 0, ans = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] == 'S')S++;
		else ans += (S == 0), S = max((ll)0, S - 1);
	}
	cout << S + ans << endl;
	return 0;
}

Measured memory_bytes: 720
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    x = list(map(int, input().split()))
    for i in range(5):
        if x[i] == 0:
            print(i + 1)
            return


if __name__ == "__main__":
    main()


Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;

int main(){    
    ll D,G;
    cin>>D>>G;
    vector<pair<ll,ll>> P(D);
    for(ll i=0;i<D;i++)cin>>P[i].first>>P[i].second;
    ll res = inf;
    for(ll i=0;i<(1<<D);i++){
        ll score=0;
        ll q=0;
        bool solve[11];
        for(ll d=0;d<D;d++){
            solve[d]=false;
            if(i>>d&1){
                solve[d]=true;
                score+=P[d].first*(d+1)*100+P[d].second;
                q+=P[d].first;
            }
        }
        if(score>=G)res=min(res,q);
        else{
            for(ll d=D-1;d>=0;d--){
                if(solve[d])continue;
                ll tmp=(G-score+(d+1)*100-1)/((d+1)*100);
                if(tmp>=P[d].first)continue;
                res=min(res,q+tmp);
            }
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int max(int a, int b){
  if(a > b) return a;
  else return b;
}

int min(int a, int b){
  if(a < b) return a;
  else return b;
}

int main(){

  int a,b,c,x,y;
  scanf("%d %d %d %d %d",&a,&b,&c,&x,&y);

  int pay_a = 0;
  int pay_b = 0;
  int pay_c = 0;
  int pay = 0;

  pay_a = a*x+b*y;

  if(x>y){
    pay_b = 2*c*y + a*(x-y);
  }else{
    pay_b = 2*c*x + b*(y-x);
  }

  pay_c = 2*c*max(x,y);

  pay = min(pay_a,pay_b);
  pay = min (pay,pay_c);

  printf("%d",pay);

  return 0;
}

Measured memory_bytes: 128
#include<math.h>
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define    ll   long long int
#define    py   printf("Yes\n")
#define    pn   printf("No\n")
#define    in   cin>>
using namespace std;

int main()
{
  int n,ans=0;
  in n;

  for(int i=1;i<=n;i+=2)
  {
    int count=0;
    for(int j=1;j<=n;j++)if(i%j==0)count++;
    if(count==8)ans++;
    count=0;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,N,M;

int main() {
  ios::sync_with_stdio(false);
  int a[10];
  int b[10];
  int c[10];
  int min = 100000;
  int id = -1;
  for(int i = 0; i < 5; i++) {
    cin >> a[i];
    b[i] = a[i] % 10;
    c[i] = a[i] / 10;
    if(b[i] < min && b[i] != 0) {
      id = i;
      min = b[i];
    }
  }
int sum = 0;
  for(int i = 0; i < 5; i++) {
    if(i == id) {
      sum += c[i]*10;
  sum += b[id];
      continue;
    }
    else if(a[i] % 10 == 0) sum += a[i];
    else sum += c[i]*10+10;
  }
  cout << sum;



  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

  vector<int> a(n), x(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    x[i] = a[i] - (i + 1);
  }
  sort(x.begin(), x.end());
  int mid = (n & 1 ? x[n / 2] : (x[n / 2 - 1] + x[n / 2]) / 2);
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    ans += abs(x[i] - mid);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int input = Integer.parseInt(br.readLine());

            System.out.println(input * input * input);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.first << ' ' << p.second << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define ll long long
#define ld long double
#define ull unsigned long long
#define pii pair<int,int>
#define MOD 1000000007
#define zeros(x) x&(x-1)^x
#define fi first
#define se second
#define NMAX 105
const long double PI = acos(-1);

int n,ans[NMAX][NMAX],P[NMAX];

void circ(){
  int aux = P[n];
  for (int i=n;i>1;i--){
    P[i] = P[i-1];
  }
  P[1] = aux;
}

int main(){
  ios::sync_with_stdio(false);
  cin >> n;
  if (n<=2){
    cout << "-1\n";
    return 0;
  }
  for (int i=1;i<=n;i++){
    P[i] = i;
  }
  for (int i=1;i<=n;i++){
    if (n%2==1){
      int nr = 0;
      for (int j=i+1;j<=n;j++){
        nr++;
        // if (ans[j][nr] == i)
          // cout << "NUU\n";
        ans[i][nr] = j;
      }

      for (int j=1;j<i;j++){
        nr++;
        // if (ans[j][nr] == i)
          // cout << "NUU\n";
        ans[i][nr] = j;
      }
    }
    else{
      int nr = 0;
      if (P[1] == i && i != 1) circ();
      for (int j=1;j<=n;j++){
        if (P[j] == i) continue;
        nr++;
        // if (ans[P[j]][nr] == i)
          // cout << "NU\n";
        ans[i][nr] = P[j];
      }
      circ();
    }
  }

  for (int i=1;i<=n;i++){
    for (int j=1;j<n;j++){
      cout << ans[i][j] << ' ';
    }
    cout << '\n';
  }
  return 0;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(abs(c-a)<=d){
        cout << "Yes" << endl;
    }
    else if(abs(c-a)>d && abs(b-a)<=d && abs(c-b)<=d){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int a,b;
char op;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	while (true) {
		cin >> a >> op >> b;

		if (op == '?')	break;
		if (op == '+') {
			cout << a + b << "\n";
		}
		else if (op == '-') {
			cout << a - b << "\n";
		}
		else if (op == '*') {
			cout << a*b << "\n";
		}
		else if (op == '/') {
			cout << a / b << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 3168
#include<bits/stdc++.h>
using namespace std;
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int x,n;
    cin>>x>>n;
 
    int a[n];
    unordered_map<int,int>mp;
   // int mp[100001]={0};
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    for(int i=0;i<100;i++)
    {
       if(mp[x-i]==0) 
        {
         cout<<x-i<<endl; 
       	 break;
       	}
       if(mp[x+i]==0)
       {
        cout<<x+i<<endl;
        break;
       }
 
    }
    return 0;
    }

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
         int a,b,c;
         int count = 0;
         a = scan.nextInt();
         b = scan.nextInt();
         c  = scan.nextInt();

	     for(int x = a;x <= b;x++){
	    	 if(c%x == 0){
	    		 count++;
	    	 }
	     }

	     System.out.println(count);

	}

}

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

int main(){
	int n, m;
	cin >> n >> m;
	int a[m], b[m], num[n] = {0};
	for(int i=0; i<m; i++) cin >> a[i] >> b[i];
	for(int i=0; i<m; i++){
		num[a[i]-1]++;
		num[b[i]-1]++;
	}
	for(int i=0; i<n; i++){
		cout << num[i] << endl;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//BEGIN CUT HERE
template <typename T,typename E>
struct SegmentTree{
  using F = function<T(T,T)>;
  using G = function<T(T,E)>;
  using H = function<E(E,E)>;
  int n,height;
  F f;
  G g;
  H h;
  T ti;
  E ei;
  vector<T> dat;
  vector<E> laz;
  SegmentTree(int n_,F f,G g,H h,T ti,E ei):
    f(f),g(g),h(h),ti(ti),ei(ei){init(n_);}
  void init(int n_){
    n=1;height=0;
    while(n<n_) n<<=1,height++;
    dat.assign(2*n,ti);
    laz.assign(2*n,ei);
  }
  void build(int n_, vector<T> v){
    for(int i=0;i<n_;i++) dat[n+i]=v[i];
    for(int i=n-1;i;i--)
      dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
  }
  T reflect(int k){
    return g(dat[k],laz[k]);
  }
  inline void eval(int k){
    if(laz[k]==ei) return;
    laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
    laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
    dat[k]=reflect(k);
    laz[k]=ei;
  }
  void update(int a,int b,E x){
    a+=n;b+=n-1;
    for(int i=height;i;i--) eval(a>>i);
    for(int i=height;i;i--) eval(b>>i);
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
      if(l&1) laz[l]=h(laz[l],x),l++;
      if(r&1) --r,laz[r]=h(laz[r],x);
    }
    while(a>>=1)
      dat[a]=f(reflect((a<<1)|0),reflect((a<<1)|1));
    while(b>>=1)
      dat[b]=f(reflect((b<<1)|0),reflect((b<<1)|1));
  }
  T query(int a,int b){
    a+=n;b+=n-1;
    for(int i=height;i;i--) eval(a>>i);
    for(int i=height;i;i--) eval(b>>i);
    T vl=ti,vr=ti;
    for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
      if(l&1) vl=f(vl,reflect(l++));
      if(r&1) vr=f(reflect(--r),vr);
    }
    return f(vl,vr);
  }
};
//END CUT HERE
signed DSL_2_G(){
  int n,q;
  scanf("%d %d",&n,&q);
  using P = pair<Int, Int>;
  auto f=[](P a,P b){return P(a.first+b.first,a.second+b.second);};
  auto g=[](P a,Int b){return P(a.first+b*a.second,a.second);};
  auto h=[](Int a,Int b){return a+b;};
  
  SegmentTree<P,Int> ch(n,f,g,h,P(0,0),0);  
  ch.build(n,vector<P>(n,P(0,1)));
  for(int i=0;i<q;i++){
    int c,s,t,x;
    scanf("%d",&c);
    if(c){
      scanf("%d %d",&s,&t);
      printf("%lld\n",ch.query(s-1,t).first);
    }else{
      scanf("%d %d %d",&s,&t,&x);
      ch.update(s-1,t,x);
    }
  }
  return 0;
}

/*
  verified on 2018/08/21
  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_2_G&lang=jp
*/

signed main(){
  DSL_2_G();
  return 0;
}



Measured memory_bytes: 10488
n = int(input())
A = sorted(list(map(int,input().split())),reverse=True)
from collections import defaultdict
dic = defaultdict(int)
for i in range(len(A)):
    dic[A[i]] += 1
rec = False
ans = 0
nya = []
for k,v in dic.items():
    nya.append([k,v])
nya = sorted(nya,key = lambda x:x[0],reverse = True)
#print(nya)
for k,v in nya:
    if v // 2 >= 1 and not rec:
        if v//4 >= 1:
            ans = k**2
            break
        else:
            po = k
            rec = True
    elif rec:
        if v // 2 >=1:
            ans = po * k
            break
print(ans)


Measured memory_bytes: 26504
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int[] P = new int[N];
            for (int i = 0; i < N; i++) {
                P[i] = sc.nextInt();
            }

            int count = 0;
            int min = (int) 1e9;
            for (int i = 0; i < N; i++) {
                if (P[i] < min) {
                    min = P[i];
                    count++;
                }
            }

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

Measured memory_bytes: 50388
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <map>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SUPAML 101
#define SUPBML 101

struct M{
	int h, r, i;
	bool operator<(const M& m) const{
		return h<m.h;
	}
};

int aml,bml;
int ml;
M ams[SUPAML],bms[SUPBML];
M ms[SUPAML+SUPBML];
int rs[SUPAML+SUPBML];

int main(){
	while(true){
		cin >> aml;			if(!aml) return 0;
		FOR(ami,0,aml){
			int h,r;
			cin >> h >> r;
			ams[ami].h=h; ams[ami].r=r;
		}
		cin >> bml;
		FOR(bmi,0,bml){
			int h,r;
			cin >> h >> r;
			bms[bmi].h=h; bms[bmi].r=r;
		}
		
		ml = aml+bml;
		FOR(ami,0,aml) ms[ami]=ams[ami];
		FOR(bmi,0,bml) ms[aml+bmi]=bms[bmi];
		sort(ms,ms+ml);

		int ret=0;
		fill(rs,rs+ml,1);
		FOR(mi,0,ml){	M m=ms[mi];
			FOR(ni,0,mi){	M n=ms[ni];
				if(n.h<m.h&&n.r<m.r) rs[mi] = max(rs[mi],rs[ni]+1);
			}
			ret = max(ret,rs[mi]);
		}


		cout << ret << endl;
	}
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int main(int argc, char *argv[])
{
	int a, b, c;
	cin >> a >> b >> c;

	if (b / a < c) {
		cout << b / a;
	} else {
		cout << c;
	}

	cout << endl;
	
	return 0;
}


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

int main() {
  int N, min, ans;
  cin >> N;
  vector<int> vec(N);
  for (int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  
  min = vec.at(0);
  ans = 0;
  for (int i=0; i<N; i++){
    if(min>=vec.at(i)){
      min = vec.at(i);
      ans += 1;
    }
  }
  cout << ans << endl;
}

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

#define ull unsigned long long

int isPrime(ull num){
    ull i,sqroot;
    if(num<=3) return 1;
    if(num%2==0 || num%3==0) return 0;
    sqroot = (ull)sqrt(num);
    for(i=5;i<=sqroot;i+=6){
        if(num%i==0 || (num%(i+2))==0) return 0;
    }
    return 1;
}

int main(){
    ull values;
    int n,count=0;
    scanf("%d",&n);
    while(n--){
        scanf("%llu",&values);
        if(isPrime(values)) count++;
    }
    printf("%d\n",count);
    return 0;
}

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

int main(void)
{
	int n, m, remain;
	int i, count;
	char num[1000 + 1];
	
	while (1){
		scanf("%d%d", &n, &m);
		
		if (!n && !m){
			break;
		}
		
		memset(num, '1', sizeof(num));
		
		i = 1;
		remain = n;
		count = 0;
		while (remain - 1){
			count++;
			
			while (num[i % n] == '0'){
				i = (i + 1) % n;
			}
			
			if (count == m){
				while (num[i] == '0'){
					i = (i + 1) % n;
				}
				num[i] = '0';
				count = 0;
				remain--;
			}
			i = (i + 1) % n;
		}
		
		for (i = 0; i < n; i++){
			if (num[i] == '1'){
				printf("%d\n", i == 0 ? n : i);
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
import java.io.IOException;
import java.io.InputStream;
import java.math.BigDecimal;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		BigDecimal a = new BigDecimal(sc.next());
		BigDecimal b = new BigDecimal(sc.next());

		System.out.println(a.multiply(b).setScale(0 , BigDecimal.ROUND_FLOOR));
	}

}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

Measured memory_bytes: 25576
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
int mod=998244353;
int32_t main()
{
    IOS;
    int n,w;
    cin>>n>>w;
    int arr[n+1][2];
    for(int i=1;i<=n;i++)
        cin>>arr[i][0]>>arr[i][1];
        int dp[n+1][w+1]={};
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
        {
            if(i==0)
            dp[i][j]=0;
            else if(j==0)
            dp[i][j]=0;
            else if((j-arr[i][0])>=0)
            {
                dp[i][j]=max(dp[i-1][j-arr[i][0]]+arr[i][1],dp[i-1][j]);
            }
            else
                dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][w];
}


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

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

const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const int int_inf = 100000000;
const double eps = 1e-9;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
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; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}



Measured memory_bytes: 3640
nums = int(input())
ary = list(map(int,input().split()))
dp = [0 for i in range(nums)]
for i in range(1,nums):
    dp[i] = float("inf")
jump_min = 0
for i in range(1,nums):
    for x in range(1,3):
        jump = i-x
        if i-x < 0: continue
        jump = dp[i-x] + abs(ary[i-x] - ary[i])
        if jump < dp[i]:
            dp[i] = jump
print(dp[nums-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k;
	cin>>n>>k;
	vector<int> h(n);
	for(int i =0;i<n;i++)
		cin>>h[i];
	vector<int> dp(n,INT_MAX);
	dp[0]=0;
	for(int i =0;i<n-1;i++)
	{
		for(int j = 1;j<=k;j++)
		{
			if(i+j>=n)
				break;
			dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
		}
	}
	cout<<dp[n-1]<<'\n';
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define meow(args...) fprintf(stderr, args)
template<class T1, class T2> inline bool cmin(T1 &a, const T2 &b) {return b<a?(a=b, true):false;}
template<class T1, class T2> inline bool cmax(T1 &a, const T2 &b) {return a<b?(a=b, true):false;}
template<class Type> Type read() {
	Type a;
	bool b;
	unsigned char c;
	while(c=getchar()-48, (c>9)&(c!=253));
	for(a=(b=c==253)?0:c; (c=getchar()-48)<=9; a=a*10+c);
	return b?-a:a;
}
int (*rd)()=read<int>;
typedef unsigned u32;
typedef long long s64;
typedef unsigned long long u64;
const u32 P=998244353;
u32 &inc(u32 &a, u32 b) {return (a+=b)<P?a:(a-=P);}
u32 &dec(u32 &a, u32 b) {return (a-=b)&0x80000000?(a+=P):a;}
u32 sum(u32 a, u32 b) {return inc(a, b);}
u32 dif(u32 a, u32 b) {return dec(a, b);}
u64 power(u64 a, int b) {
	u64 ans=1;
	for(; b; a=a*a%P, b/=2) if(b&1) ans=ans*a%P;
	return ans;
}

const int N=5e5+1;
u32 fac[N], ifac[N], pwn[N], pwm[N];
int main() {
	int n=rd(), m=rd();
	u32 ans=0;
	if(n<m) std::swap(n, m);
	fac[0]=1;
	for(int i=1; i<=n; ++i) fac[i]=(u64)fac[i-1]*i%P;
	ifac[n]=power(fac[n], P-2);
	for(int i=n; i--; ) ifac[i]=(i+1llu)*ifac[i+1]%P;
	pwn[0]=pwm[0]=1;
	for(int i=1; i<=m; ++i) pwn[i]=pwn[i-1]*(n+1llu)%P;
	for(int i=1; i<=n; ++i) pwm[i]=pwm[i-1]*(m+1llu)%P;
	for(int r=0; r<=m; ++r) {
		u32 cur=(u64)fac[n]*ifac[n-r]%P*ifac[r]%P*fac[m]%P*ifac[m-r]%P*pwm[n-r]%P*pwn[m-r]%P;
		if(r&1) dec(ans, cur); else inc(ans, cur);
	}
	printf("%u\n", ans);
	return 0;
}


Measured memory_bytes: 8064
A, B = [int(_) for _ in input().split()]

"""
r = 0
for i in range(17):
    r ^= i
    print(i, ("0000" + bin(r)[2:])[-5:])
"""

def calc(n):
    rs = []
    rs.append((n + 1) // 2 % 2)
    for i in range(1, 41):
        d = 1 << i
        x = n // d
        if x % 2 == 0:
            r = 0
        else:
            r = n % 2 ^ 1
        rs.append(r)
    return rs

b1 = calc(A - 1)
b2 = calc(B)

#print(b1)
#print(b2)

result = 0
for i in range(41):
    result |= (b1[i] ^ b2[i]) << i

print(result)


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second

ll a[2000005];

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

    ll n,k;
    cin >> n >> k;

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

    sort(a+1 , a+n+1);
    ll mn = 1e18;
    for(int i=1; i+k-1<=n; i++)
    {
        mn = min(mn , a[i+k-1]-a[i]);
    }

//
    cout << mn << "\n";

    return 0;
}

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

ll choose2 (ll n) {
    return n * (n-1) / 2;
}
int main() {
    int n;
    cin >> n;
    int a[n+100];
    
    vector<int>  record(n+10, 0);
    rep(i, n)  cin >> a[i];//ボールに書いてある番号
    rep(i, n)  {
        a[i]--;
        record[a[i]]++;
    }
    ll allcounts = 0;
    //すべてのボールを使ったときの場合の数
    rep(i, n)  allcounts += choose2(record[i]);
    rep(k, n) {
        ll ans = allcounts;
        ans -= record[a[k]] - 1;
        cout << ans << endl;
    }    
    return 0;
}


Measured memory_bytes: 4096
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    map<int,int> mp;
    REP(i,N) {
        int tmp;
        cin >> tmp;
        mp[tmp]++;
    }

    int M; cin >> M;
    VL T(M); REP(i,M) {
        int tmp;
        cin >> tmp;
        if(mp[tmp] == 0){
            cout << "NO" << endl;
            return 0;
        }
        else{
            mp[tmp]--;
        }
    }
    cout << "YES" << endl;



}

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

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    vec x(3,0);
    rep(i,3) cin>>x[i];
    cout<<x[0]*x[1]/2<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>

using std::abs;
using std::sort;

const int MAXN=1e5+5;
int a[MAXN];

int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<n;++i){
		if(abs((ans<<1)-a[n])>abs((a[i]<<1)-a[n]))
			ans=a[i];
	}
	printf("%d %d",a[n],ans);
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc =  new Scanner(System.in);
		int num = sc.nextInt();
		int min;
		long sum = 0;
		int  input = sc.nextInt();
		int minus = input > 0 ? 0: 1;
		input *= input > 0 ? 1: -1;
		min = input;
		sum += input;
		for(int i=1;i<num;i++) {
			input = sc.nextInt();
			if(input < 0) {
				++minus;
				input *= -1;
			}
			if(input < min)
				min = input;
			sum += input;
		}
			
		sc.close();
		System.out.println(minus%2==0?sum:sum-2*min);
	}
}

Measured memory_bytes: 48576
n,m,q = map(int,input().split())
li2=[input() for i in range(q)]
abcd = []
for i in range(q):
    abcd.append([int(x.strip()) for x in li2[i].split()])

ans = 0

import itertools
l = list(range(1,m+1))

for v in itertools.combinations_with_replacement(l, n):
    memo = 0
    for i in range(q):
        a = abcd[i][0]
        b = abcd[i][1]
        c = v[b-1] - v[a-1]
        if c == abcd[i][2]:
            memo += abcd[i][3]

    ans = max(ans,memo)

print(ans)

Measured memory_bytes: 68028
H, W = map(int, input().split())
S = [list(input()) for i in range(H)]


for i in range(H):
    for j in range(W):
        if S[i][j] == "#":
            continue
        cnt = 0
        for dx in [-1,0,1]:
            for dy in [-1,0,1]:
                if 0 <= i + dx < H and 0 <= j + dy < W:
                    if S[i+dx][j+dy] == "#":
                        cnt += 1
                else:
                    continue
        S[i][j] = str(cnt)

for k in S:
    print("".join(k))

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

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

	static int M[101][101];
	int n;
	cin >> n;

	int u, k, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			M[u][v] = 1;
		}	
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j != 1) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	string S;
	cin >> S;
	ll res = 0;
	stack<char> st;
	REP(i, S.size()){
		if(st.empty()){
			st.push(S[i]);
		}else{
			if(st.top()==S[i]){
				st.push(S[i]);
			}else{
				st.pop();
				res += 2;
			}
		}
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int o = 2000, N = (o << 1) + 5, mo = 1000000007 ;
using namespace std ;

int n, a[N][N], b[N][N], fac[N << 2], inv[N << 2] ;

int mul(int a, int b) {
	int ans = 1, w = a % mo ;
	for ( ; b; b /= 2) {
		if (b & 1) ans = (ll) ans * w % mo ;
		w = (ll) w * w % mo ;  
	}
	return ans ;
} 

int main() {
	scanf("%d", &n) ;
	int ans = 0, x, y ;
	fac[0] = inv[0] = 1 ;
	rep(i, 1, o * 4) {
		fac[i] = (ll) fac[i - 1] * i % mo ;
	}
	inv[o * 4] = mul(fac[o * 4], mo - 2) ;
	for (int i = o * 4 - 1 ; i; -- i) {
		inv[i] = (ll) inv[i + 1] * (i + 1) % mo ; 
	}
	memset(a, 0, sizeof(a)) ;
	memset(b, 0, sizeof(b)) ;
	rep(i, 1, n) {
		scanf("%d%d", &x, &y) ;
		++ a[o - x][o - y] ;
		++ b[o + x][o + y] ;
		ans = (ans - (ll) fac[x + y + x + y] * inv[x << 1] % mo * inv[x + y + x + y - (x << 1)] % mo) % mo ;
	}
	rep(i, 0, 2 * o) rep(j, 0, 2 * o) {
		if (i) a[i][j] = (a[i][j] + a[i - 1][j]) % mo ;
		if (j) a[i][j] = (a[i][j] + a[i][j - 1]) % mo ;
 		ans = (ans + (ll) a[i][j] * b[i][j] % mo) % mo ;
	}
	ans = (ll) ans * inv[2] % mo ;
	printf("%d\n", (ans + mo) % mo) ;
	return 0 ; 
}

Measured memory_bytes: 125568
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int M = -2100000000;
  int m = 2100000000;
  for (int i = 0; i < n; i++){
    int R;
    cin >> R;
    M = max(M, R - m);
    m = min(m, R);
  }
  cout << M << endl;
}


Measured memory_bytes: 3112
def main():
    buf = input()
    N = int(buf)
    # N / m = i % i
    # m * i + i = N
    total = 0
    i = 1
    while i * i < N:
        if N % i == 0:
            div = N // i - 1
            if N // div == N % div:
                total += div
        i += 1
    print(total)


if __name__ == '__main__':
    main()


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

using namespace std;

int main()
{
    string s, t;
    cin >> s >> t;
    //cout << s << "\n";
    // cout << t << "\n";
    int dp[s.size()][t.size()];
    memset(dp, 0, sizeof(dp));
    for (int j = 0; j < t.size(); j++)
    {
        if (s[0] == t[j])
        {
            dp[0][j] = 1;
        }
        else
        {
            if (j > 0)
                dp[0][j] = dp[0][j - 1];
        }
    }
    for (int i = 0; i < s.size(); i++)
    {
        if (t[0] == s[i])
        {
            dp[i][0] = 1;
        }
        else
        {
            if (i > 0)
                dp[i][0] = dp[i - 1][0];
        }
    }
    for (int i = 1; i < s.size(); i++)
    {
        for (int j = 1; j < t.size(); j++)
        {

            if (s[i] == t[j])
            {
                dp[i][j] = max(1 + dp[i - 1][j - 1], dp[i][j]);
            }
            else
            {
                dp[i][j] = max(dp[i][j], dp[i - 1][j]);
                dp[i][j] = max(dp[i][j], dp[i][j - 1]);
            }
        }
    }

    string str = "";
    int i = s.size() - 1, j = t.size() - 1;
    //cout << "ff : " << dp[i][j] << "\n";
    while (i >= 0 && j >= 0 && dp[i][j] > 0)
    {
        //cout << "ii " << i << " " << j << " " << dp[i][j] << "\n";
        //cout << str << "\n";
        if (s[i] == t[j])
        {
            str += s[i];
            i--;
            j--;
        }
        else
        {
            if (i > 0 && dp[i][j] == dp[i - 1][j])
            {
                i--;
            }
            else if (j > 0 && dp[i][j] == dp[i][j - 1])
            {
                j--;
            }
        }
        // cout << "ii " << i << " " << j << " " << dp[i][j] << "\n";
    }
    reverse(str.begin(), str.end());
    cout << str << "\n";
    return 0;
}


Measured memory_bytes: 35456