akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int n;
  int *a;
  int i,j,k;
  int v;
  
  scanf("%d",&n);

  a = (int *)malloc(sizeof(int) * n);

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

  for(i=1; i<n; i++){

    for(k=0; k<n; k++){
      printf("%d",a[k]);
      if(k != (n-1)){
	printf(" ");
      }
    }
    puts("");
    
    v=a[i];
    j=i-1;
    while((j>=0) && (a[j] > v)){
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
  }

  for(k=0; k<n; k++){
    printf("%d",a[k]);
    if(k != (n-1)){
      printf(" ");
    }
  }
  puts("");

  free(a);
  
  return(0);
}

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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

auto solve() {
    int A, B, K;
    cin >> A >> B >> K;

    int c = 0;
    vi ds;
    FOR(i, 1, min(A, B) + 1) {
        if (A % i == 0 && B % i == 0) {
            ds.push_back(i);
        }
    }

    return ds[ds.size()-K];
}


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

//    cout << (solve() ? "Heisei" : "TBD") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  ll N,M,X,i,j,k,ans=-1;
  cin>>N>>M>>X;
  ll C[N],A[N][M];
  REP(i,N){
    cin>>C[i];REP(j,M)cin>>A[i][j];
  }
  REP(k,1<<N){
    ll money=0,O[M];bool OK=1;
    REP(j,M)O[j]=0;
    REP(i,N)if(k&(1<<i)){
      money+=C[i];
      REP(j,M)O[j]+=A[i][j];
    }
    REP(j,M)if(O[j]<X)OK=0;
    if(OK&&(ans==-1||ans>money))ans=money;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;

int main(){
	cin>>N;
	int M;
	cin>>M;
	REP(i,M){
		int a;
		cin>>a;
		N-=a;
	}
	cout<<max(N,-1)<<endl;
	return 0;
}

Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args) {
		SC sc = new SC(System.in);
		int W=sc.nextInt();
		int H=sc.nextInt();
		int x=sc.nextInt();
		int y=sc.nextInt();
		double ans=((double)H*W)/2;
		//当然だが、二等分線が中心を通るときに対称性が生まれる（それ以外はない）（ただし、通らないといけない点のX、Yのざひょうが中心に一致するとない）
		if(2*x==W && 2*y==H) {//通らないといけないのが中心
			pl(ans+" "+1);
		}
		else if(W*y==x*H || W*(H-y)==(W-x)*H|| x*2==W || y*2==H) {//通らないといけないのが中心以外の対称軸上
			pl(ans+" "+0);
		}
		else {
			double difx=Math.abs((double)W/2-((double)x));
			double dify=Math.abs((double)H/2-((double)y));
			if(((double)W/2)-((double)H/2)/dify*difx<0) {
				if(((double)H/2)-((double)W/2)/difx*dify<0) {
					pl(ans+" "+0);
				}
				else {
					pl(ans+" "+0);
				}
			}
			else if(((double)W/2)-((double)H/2)/dify*difx>=0) {
				if(((double)H/2)-((double)W/2)/difx*dify<0) {
					pl(ans+" "+0);
				}
				else {
						pl(ans+" "+1);
				}
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
//priority_queue<ll, vector<ll>, std::greater<ll> > q;
#define ull 		unsigned long long
#define ll 			long long
#define M 			1000000007
#define pb 			emplace_back
#define p_q 		priority_queue
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) // gcd((a),(b))
#define ios	    	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mp 			make_pair
#define lb 			lower_bound
#define ub			upper_bound
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ini(a,n,b)	for(ll int i=0;i<n;i++) a[i]=0;
#define hell 		(ull)1e9
#define DB(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl
using namespace std;
void boost()
{
    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
    cout.tie(NULL);
}





int main(void)
{
    boost();
    ll n;
    cin>>n;
    vector < double > v(n);
    rep(i,0,n)
        cin>>v[i];
    double a[n+1][n+1];
    
    rep(i,0,n+1){
        rep(j,0,n+1)
            a[i][j] = 0;
    }
    a[0][0] = 1.0;
    rep(i,0,n){
        rep(j,0,n){
            a[i+1][j+1] = a[i+1][j+1] + a[i][j]*(v[i]);
            a[i+1][j] = a[i+1][j] + a[i][j]*(1 - v[i]);
        }
    }
    double ans = 0;
    // rep(i,0,n+1){
    //     cout<<a[n][i]<<" ";
    // }
    rep(i,(n+1)/2,n+1){
        ans = ans + a[n][i];
    }
    cout<<setprecision(9)<<ans;

}   

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

#define chmin(x,y) x = min(x,y)
using namespace std;

const int INF = 1001001001;

int main(){
  int n, m, l;
  cin >> n >> m >> l;
  vector<vector<int>> dist(n,vector<int>(n,INF));
  rep(i,n) dist[i][i] = 0;

  int a, b, c;

  rep(i,m) {
    cin >> a >> b >> c;
    --a; --b;
    dist[b][a] = dist[a][b] = c;
  }

  rep(k,n)rep(i,n)rep(j,n) chmin(dist[i][j],dist[i][k] + dist[k][j]);
  vector<vector<int>> dist2(n,vector<int>(n,INF));
  rep(i,n)rep(j,n) {
    if (dist[i][j] <= l) dist2[i][j] = 1;
  }
  rep(k,n)rep(i,n)rep(j,n) chmin(dist2[i][j],dist2[i][k] + dist2[k][j]);
  int q, s, t;
  cin >> q;

  rep(qi,q){
    cin >> s >> t;
    --s; --t;
    int ans = dist2[s][t] - 1;
    if(dist2[s][t] == INF) ans = -1;
    cout << ans << endl;
  }


  return 0;
}


Measured memory_bytes: 1280
n = int(input())
a = [int(i) for i in input().split(' ')]
_a = [-1*i for i in a]

def func(l):
    _ans = 0
    product = 0
    for i in range(n):
        product += l[i]
        if i%2 == 0:
            if product<=0:
                _ans += abs(product) + 1
                product = 1
        elif i%2 == 1:
            if product>=0:
                _ans += abs(product) + 1
                product = -1
    return _ans

ans = min(func(a), func(_a))
print(ans)

Measured memory_bytes: 14332
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI 3.1415926525
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

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

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int n;ll y;cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(i+j>n)continue;
      if(i*10000+j*5000+(n-i-j)*1000==y){
        cout<<i<<" "<<j<<" "<<n-i-j<<"\n";
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<"\n";
  return 0;
}


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

int main() {
    int N, K;
    cin >> N >> K;

    double ans = 0;
    for (int i = 1; i <= N; i++) {
        int x = i;
        double score = 1.0 / N;
        while (x < K) {
            score /= 2.0;
            x *= 2;
        }
        ans += score;
    }

    cout << fixed << setprecision(15) << ans << endl;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<Pi,int> Pii;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

ll a[100001];

int main() {
	ll n;
	ll total=0;

	cin>>n;
	for(ll i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a,a+n);

	ll o=1;
	rep(i,n-1){
		if(a[i]==a[i+1]){
			o++;
		}else{
			if(o%2==1){
				total++;
			}
			o=1;
		}
	}
	if(o%2==1){
		total++;
	}
	cout<<total<<endl;

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N, K;
  cin >> N >> K;
  vl A(N);
  rep(i, N) cin >> A[i];

  rep2(i, K, N){
    if(A[i - K] < A[i])
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  
  return 0;
}


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


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

    int W,H,w,h;
    cin >> W >> H >> w >> h;
    cout << (W-w)*(H-h) << endl;
    return 0;
}

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

int main(){
	#ifdef LOCAL_DEFINE
		freopen("../a.in","r",stdin);
		freopen("../a.out", "w",stdout);
	#endif
	int a,b;
	cin >> a >> b;
	if(b%a==0){
		cout << a+b << endl;
	} else {
		cout << b-a << endl;
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main()
{
	int K,S;
	int counter = 0;
	cin >> K >> S;

	for(int X = 0;X <= K;X++)
	{
		for(int Y = 0;Y <= K;Y++)
		{	
			int tmp = S - (X+Y);
			if(  tmp <= K && tmp >= 0)
			{
				counter++;
			}
		}
	}

	cout << counter << endl;

	return 0;
}

Measured memory_bytes: 256
import numpy as np
import networkx as nx
g = nx.Graph()

n,m = map(int, input().split())

for _ in range(m):
    a, b = map(int, input().split())
    g.add_edge(a, b)

res = np.array([0] * 2 + [-1] * (n-1))

from collections import deque
q = deque([1])

while q:
    vis = q.popleft() # visit
    #     print(vis)
    cands = list(nx.all_neighbors(g, vis)) # next visit

    if cands:
        for c in cands:
            if res[c] == -1:
                res[c] = vis # mark
                q.append(c) # should append

if (res == -1).sum():
    print('No')
else:
    print('Yes')
    for i in res[2:]:
        print(i)

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

using namespace std;

bool ispallindrome(string &s, int l, int r){
	for(int i=l; i<=(l+r)/2; i++){
		if(s[i] != s[r-i+l]){
			return false;
		}
	}
	return true;
}

int main()
{
	string s;
	cin>>s;
	// int mid = (s.length()) / 2;
	if (ispallindrome(s, 0, s.length()-1) 
		&& 	ispallindrome(s, 0, (s.length())/2-1) 
		&& 	ispallindrome(s, (s.length() + 1)/2, s.length()-1))
	{
		cout << "Yes\n";
	}
	else{
		cout<<"No\n";
	}

	return 0;
}


Measured memory_bytes: 256
import sys
def main():
    input = sys.stdin.readline
    X,Y = map(int, input().split())

    t = X//2
    a = b = 0
    while t <= X:
        b = X - t
        a = t - b
        if 2*a + b == Y: break
        t += 1
    else:
        print(0)
        exit()

    fu = FactorialUtils(t)
    print(Mint(1) * fu.fac[t] * fu.ifac[a] * fu.ifac[b])

class FactorialUtils:
    def __init__(self, n, mod=10**9+7):
        self.__mod = mod
        self.fac = [1] * (n+1)
        self.ifac = [1] * (n+1)
        for i in range(2, n+1): self.fac[i] = self.fac[i-1] * i % mod
        self.ifac[n] = pow(self.fac[n], mod-2, mod)
        for i in range(n, 1, -1): self.ifac[i-1] = self.ifac[i] * i % mod

    def choose(self, n, r):
        if r < 0 or r > n: return 0
        return (self.fac[n] * self.ifac[n-r] % self.__mod) * self.ifac[r] % self.__mod

    def multichoose(self, u, k):
        return (self.fac[u+k-1] * self.ifac[u-1] % self.__mod) * self.ifac[k] %self.__mod

class Mint:
    def __init__(self, value=0, mod=10**9+7):
        self.value = ((value % mod) + mod) % mod
        self.mod = mod

    @staticmethod
    def get_value(x): return x.value if isinstance(x, Mint) else x

    def inverse(self):
        a, b = self.value, self.mod
        u, v = 1, 0
        while b:
            t = a // b
            b, a = a - t * b, b
            v, u = u - t * v, v
        return (u + self.mod) % self.mod

    def __repr__(self): return str(self.value)
    def __eq__(self, other): return self.value == other.val
    def __neg__(self): return Mint(-self.value, self.mod)
    def __hash__(self): return hash(self.value)
    def __bool__(self): return self.value != 0

    def __iadd__(self, other):
        self.value = (self.value + Mint.get_value(other)) % self.mod
        return self
    def __add__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj += other
        return new_obj
    __radd__ = __add__

    def __isub__(self, other):
        self.value = (self.value - Mint.get_value(other) + self.mod) % self.mod
        return self
    def __sub__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj -= other
        return new_obj
    def __rsub__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj -= self
        return new_obj

    def __imul__(self, other):
        self.value = self.value * Mint.get_value(other) % self.mod
        return self
    def __mul__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj *= other
        return new_obj
    __rmul__ = __mul__

    def __ifloordiv__(self, other):
        other = other if isinstance(other, Mint) else Mint(other, self.mod)
        self *= other.inverse
        return self
    def __floordiv__(self, other):
        new_obj = Mint(self.value, self.mod)
        new_obj //= other
        return new_obj
    def __rfloordiv__(self, other):
        new_obj = Mint(Mint.get_value(other), self.mod)
        new_obj //= self
        return new_obj


if __name__ == '__main__':
    main()

Measured memory_bytes: 49264
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8931145141919364364,LMOD=998244353;
// const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

const int VMAX=100010;
int V,E,start,goal;
vector<pair<long long,int>> edge[VMAX];
long long dist[VMAX];
bool used[VMAX];

void dijkstra(){
    // 距離をLINFで初期化
    rep(to,VMAX) dist[to]=LINF;
    // 始点は0
    dist[start]=0;
    // フラグを下げる
    rep(v,VMAX) used[v]=false;
    // 優先度付きキュー:[距離,頂点]←距離の昇順
    priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> q;
    // 距離0,始点
    q.push({0,start});
    // dijkstra
    while(q.size()){
        // 取り出してd=距離,v=頂点
        pair<long long,int> p=q.top(); q.pop();
        long long d=p.first;
        int from=p.second;
        if(used[from]) continue;
        used[from]=true;
        // 頂点から出る辺すべてについて
        for(auto e:edge[from]){
            long long cost=e.first,to=e.second;
            // 短縮できるとき
            if(d+cost<dist[to]){
                dist[to]=d+cost;
                q.push({dist[to],to});
            }
        }
    }
}

int main(){
    cin>>V;
    rep(i,V){
        int u,k; cin>>u>>k;
        rep(j,k){
            int to,distance;
            cin>>to>>distance;
            edge[u].push_back({distance,to});
        }
    }
    start=0;
    dijkstra();
    rep(i,V){
        cout<<i<<" "<<dist[i]<<endl;
    }
    return 0;
}



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

int main(){
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
  }
  
  int count = 0;
  while(true){
    rep(i, N){
      if(A[i]%2 != 0){//偶数判定
        cout << count << endl;
        return 0;
      }
      else{
        A[i] /= 2;
      }
    }
    count++;
  }
  
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
x = list(map(int, input().split()))
ans = 0
while x[0] != x[1] or x[1] != x[2]:
    ans += 1
    m = min(x)
    if x.count(m) == 1:
        for i in range(3):
            if x[i] == m:
                x[i] += 2
                break
    else:
        for i in range(3):
            if x[i] == m:
                x[i] += 1
print(ans)


Measured memory_bytes: 3060
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ASecurity {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        string s;
        cin >> s;

        bool ok = true;
        REP(i, s.size() -1) {
            if (s[i] == s[i+1]) {
                ok = false;
            }
        }
        cout << (ok ? "Good" : "Bad") << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ASecurity solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
def sum_list(i):
    return int((i*(i+1))/2)

n = int(input())
ls = []
for i in range(n):
    ls.append(''.join(sorted(input())))

ls.sort()
ans = 0
count = 0

for i in range(len(ls)):
    if (ls[i] == ls[i+1]):
        count += 1
    else:
        ans += sum_list(count)
        count = 0
    if (i == n-2):
      ans += sum_list(count)
      break

print(ans)

Measured memory_bytes: 57688
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main  (){
  int x,y,z;
  cin >>x>>y>>z;
  cout <<z<<" "<<x<<" "<<y<<endl;
}

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

int main() {
  int N, a, b, c, d;
  cin >> N;
  
  a = N / 1000;
  b = (N - a * 1000) / 100;
  c = (N - a * 1000 - b * 100) / 10;
  d = (N - a * 1000 - b * 100 - c * 10);
  
  if ((a == b && b == c) || (b == c  && c == d)) {
      cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define pii pair<int, int>
#define endl '\n'
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define vpii vector<pii>
typedef long long ll;
typedef long double ld;
using namespace std;
template<class T> using minheap = priority_queue<T, vector<T>, greater<T>>;


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

  ll n;
  cin >> n;
  ll ans = n - 1;
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      ans = min(ans, i + n / i - 2);
    }
  }

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

Measured memory_bytes: 256
#include <stdio.h>
int judge(int x){
	int f = 0,y=x;
	while(y>=1){
		f+=y%10;
		y/=10;
	}
	if(x%f == 0)	return 1;
	return -1;
}

int main(void){
	int N;
	scanf("%d",&N);
	if(judge(N)==1) printf("Yes");
	else	printf("No");
	
	return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i,n) for(ll i=1;i<=(ll)(n);i++)
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 2e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);


int main() {
  while (true) {
    int n;
    cin >> n;
    if (!n) {
      return 0;
    }
    vi cnt(26);
    bool flag = false;
    vector<char> c(n);
    rep (i, n) {
      cin >> c[i];
    }
    rep (i, n) {
      cnt[c[i] - 'A']++;
      int nokori = n - i - 1;
      int ma1 = -1, ma2 = -2;
      int idx = -1;
      rep (j, 26) {
        if (ma1 < cnt[j]) {
          ma2 = ma1;
          ma1 = cnt[j];
          idx = j;
        }
        else if (ma2 < cnt[j]) {
          ma2 = cnt[j];
        }
      }
      if (ma1 > ma2 + nokori) {
        flag = true;
        cout << (char)('A' + idx) << " " << i + 1 << endl;
        break;
      }
    }
    if (!flag) {
      cout << "TIE" << endl;
    }
  }
}



Measured memory_bytes: 3012
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

string s;
int cnt,ans;

void strReplace (std::string& str, const std::string& from, const std::string& to) {
    std::string::size_type pos = 0;
    while(pos = str.find(from, pos), pos != std::string::npos) {
        str.replace(pos, from.length(), to);
        pos += to.length();
    }
}

signed main() {
    cin >> s;
    const string agct = "AGCT";
    for (auto it = begin(agct); it != end(agct); it++) {
        strReplace(s, {*it}, "#");
        // cout << s << endl;
    }

    for (auto it = begin(s); it != end(s); it++) {
        if(*it == '#') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
#define int long long
#define P pair<int, int>
typedef long long ll;
ll dp[3005][3005];

#define NUM 1000000007
const int INF = -1;

struct _chunk {
	int connect;
	int dist;
	int color;
};

signed main(void) {
  int N, M;
  cin >> N >> M;
  vector<vector<int> > graph(N+1);
  rep(i, M) {
  	int u, v;
  	cin >> u >> v;
  	graph[u].pb(v);
  }
  int S, T;
  cin >> S >> T;

  // the distance from start position
  int dist[N+1][3];
  rep(i, N+1) rep(j, 3) dist[i][j] = INF;
  queue<P> que;
  // P(position, step)
  que.push(P(S, 0));
  dist[S][0] = 0;
  while(que.size()) {
  	int now = que.front().first;
  	int now_step = que.front().second;
  	que.pop();
  	for (int i=0; i<graph[now].size(); i++) {
  		int next = graph[now][i];
  		int next_step = (now_step + 1)%3;
  		// if != INF, that is shorter distance since we start from shorter distance
  		if (dist[next][next_step] != INF) continue;
  		que.push(P(next, next_step));
  		dist[next][next_step] = dist[now][now_step] + 1;
  	}
  }

  if (dist[T][0] == INF) {
  	cout << INF << endl;
  } else {
  	cout << dist[T][0]/3 << endl;
  }

  return 0;
}


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

int main(){
    int x, y;
    cin >> x >> y;
    if(y%2 != 0){
        cout << "No" << endl;
        return 0;
    }
    if(2*x <= y && y <= 4*x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

#define fi first
#define se second

const int N = 100100;
const int mod = 998244353;

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int a, b;
    cin >> a >> b;
    if(a <= 0 && b >= 0){
        cout << "Zero" << "\n";
    } else if(a > 0){
        cout << "Positive" << "\n";
    } else{
        if((-a + b) & 1){
            cout << "Positive" << "\n";
        } else{
            cout << "Negative" << "\n";
        }
    }
}



Measured memory_bytes: 256
#include<iostream>
#include<bitset>
using namespace std;
int main() {
    int T;
    cin >> T;
    bitset<64> bs;
    while (T--) {
        int x;
        cin >> x;
        if (x==0) {
            int i;
            cin >> i;
            cout << bs.test(i) << endl;
        }
        if (x==1) {
            int i;cin >> i;
            bs.set(i);
        }
        if (x==2) {
            int i;cin >> i;
            bs.reset(i);
        }
        if (x==3) {
            int i;cin >> i;
            bs.flip(i);
        }
        if (x==4) {
            cout << bs.all() << endl;
        }
        if (x==5) {
            cout << bs.any() << endl;
        }
        if (x==6) {
            cout << bs.none() << endl;
        }
        if (x==7) {
            cout << bs.count() << endl;
        }
        if (x==8) {
            cout << bs.to_ullong() << endl;
        }
    }
    return 0;
}


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

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

const int INF = 1e9;
const int mod = 1e9+7;

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> p(m),y(m),z[n];
    for(int i = 0; i < m; i++){
        cin >> p[i] >> y[i];
        z[p[i]-1].push_back(y[i]);
    }

    for(int i = 0; i < n; i++) sort(z[i].begin(),z[i].end());

    for(int i = 0; i < m; i++){
        printf("%06d%06d\n",p[i],lower_bound(z[p[i]-1].begin(),z[p[i]-1].end(),y[i])-z[p[i]-1].begin()+1);
    }

    return 0;
}

Measured memory_bytes: 7808
#include <stdio.h>

int main() {
	int N;
	scanf("%d", &N);
	int T[100000] = { 1 }, Ans[100000];
	for (int i = 0; i < N; i++) {
		scanf("%d", &T[i]);
		Ans[T[i] - 1] = i + 1;
	}
	for (int i = 0; i < N; i++) {
		printf("%d ", Ans[i]);
	}

	return 0;
}

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

using ll = long long;
using ld = long double;

const int MOD = 1e9 + 7;
const int N = 1e5;

int fact[N + 69], ifact[N + 69], pos[N + 69];
int n;
pair<int, int> lol;

int C(int x, int y) {
  if(x < 0 || y < 0 || x < y)
    return 0;
  int ret = 1;
  ret = (1LL * ret * fact[x]) % MOD;
  ret = (1LL * ret * ifact[y]) % MOD;
  ret = (1LL * ret * ifact[x - y]) % MOD;
  return ret;
}

int calc(int x) {
  int ret = 0, q = lol.first, p = lol.second;
  ret = (1LL * ret + C(n - 1, x)) % MOD;
  cerr << ret << '\n';
  ret = (1LL * ret + 2LL * C(n - 1, x - 1)) % MOD; 
  cerr << ret << '\n';
  ret = (1LL * ret - C(n - q + p, x - 1)) % MOD;
  cerr << ret << '\n';
  ret = (1LL * ret + C(n - 1, x - 2)) % MOD;
  if(ret < 0)
    ret += MOD;
  cerr << ret << '\n';
  return ret;
}

int modpow(int a, int b) {
  int ret = 1;
  while(b) {
    if(b & 1) ret = (1LL * ret * a) % MOD;
    a = (1LL * a * a) % MOD;
    b >>= 1;
  }
  return ret;
}

int inv(int a) {
  return modpow(a, MOD - 2);
}

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

  fact[0] = 1;
  for(int i = 1; i <= N; i++) {
    fact[i] = (1LL * i * fact[i - 1]) % MOD;
  }
  // cerr << ifact[N] << ' ' << fact[N];
  ifact[N] = inv(fact[N]);
  // cerr << ifact[N] << ' ' << fact[N];
  for(int i = N - 1; i >= 0; i--) {
    ifact[i] = (1LL * (i + 1) * ifact[i + 1]) % MOD;
  }

  // for(int i = 1; i <= 50; i++) cerr << fact[i] << '\n';

  cin >> n;
  for(int i = 1; i <= n + 1; i++) {
    int x;
    cin >> x;
    if(!pos[x])
      pos[x] = i;
    else
      lol = make_pair(i, pos[x]);
  }
  for(int i = 1; i <= n + 1; i++) {
    // if(i != 2) continue;
    cout << calc(i) << '\n';
  }
  return 0;
}

Measured memory_bytes: 6556
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    k: usize,
    a: [Usize1; n]
    }
    let mut used = vec![false; n];
    let mut l = vec![0];
    let mut k = k;
    used[0] = true;
    let mut i = 0;
    loop {
        let ni = a[i];
        if used[ni] {
            let mut s = 0;
            for k in 0..n{
                if l[k] == ni{
                    s = k;
                    break;
                }
            }
            if k < s {break}
            else {k -= s}
            l = l.split_off(s);
            break;
        }
        l.push(ni);
        used[ni] = true;
        i = ni;
    }
    let r = l.len();
    let b = k % r;
    let ans = l[b] + 1;
    println!("{}", ans);

}


Measured memory_bytes: 7484
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define endl '\n'
#define N 200005
int a[N],dp[N];
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    cin>>a[i];
    dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    for(int i=3;i<=n;i++)
    dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    cout<<dp[n]<<endl;
}


Measured memory_bytes: 4428
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

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

void Ok()
{
    long long int a,b,c,d,e,f,g,h,t,i,j,k,l,m,n,sum,ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag,div,rcv,temp;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa[1013],bbb[1013],ccc[1013],alpbt;
    long long int sum_again;
    string spc;

    cin>>a>>b;
    aa = a;
    bb = b;
    flag = 0;
    for(i=1;i<=10000;i++)
    {
        c = i*0.08;
        d = i*0.1;
        if(c==a && d==b)
        {
            e = i;
            flag = 1;
            cout<<e<<endl;
            break;
        }
    }
    if(flag==0)
    {
        cout<<"-1"<<endl;
    }

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
bool isprime(int n,int k=2){if(n==1){return false;}if(n<k*k){return true;}if(n%k==0){return false;}return isprime(n,k+1);}int main(){int a,d,n,c;while(true){std::cin>>a>>d>>n;if(n==0){break;}c=0;while(c<n){if(isprime(a)){c++;}a+=d;}std::cout<<a-d<<std::endl;}}

Measured memory_bytes: 3016
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
constexpr auto INF = 1000000000;
constexpr auto LLINF = 1LL << 60;
constexpr auto 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; }

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

    int n, m;
    cin >> n >> m;
    vector<pair<int, int>> ab(n);
    FOR(i, 0, n)cin >> ab[i].first >> ab[i].second;

    SORT(ab);
    priority_queue<ll> queue;
    ll ans = 0;
    int itr = 0;
    eFOR(i, 1, m) {
        while (itr < n && ab[itr].first <= i)queue.push(ab[itr++].second);
        if (queue.empty())continue;
        ans += queue.top();
        queue.pop();
    }

    cout << ans << "\n";
}

Measured memory_bytes: 2168
n = int( input())
A = []
B = []

for i in range( n ):
  a, b = map( int, input().split() )
  A.append( a )
  B.append( b )

A = sorted( A )
B = sorted( B )

if n % 2 == 0:
  i1 = n // 2 - 1
  i2 = n // 2
  print( B[ i2 ] + B[ i1 ] - ( A[ i2 ] + A[ i1 ] ) + 1 )
else:
  i = ( n + 1 ) // 2 - 1
  print( B[ i ] - A[ i ] + 1 )
  


Measured memory_bytes: 27024
import java.io.*;
import java.util.*;
class Main{
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int n = saori.saori_hayami();
		int k = saori.saori_hayami();
		int[] h = new int[n+1];
		for(int i = 1;i <= n;i++){
			h[i] = saori.saori_hayami();
		}
		int[] dp = new int[n+1];
		boolean[] seen = new boolean[n+1];
		for(int i = 1;i <= n;i++){
			for(int j = 1;j <= k;j++){
				if(i == 1){
					dp[i] = 0;
				} else if(i-j > 0){
					if(seen[i]){
						dp[i] = Math.min(dp[i], Math.abs(h[i] - h[i-j]) + dp[i-j]);
					} else {
						dp[i] = Math.abs(h[i] - h[i-j]) + dp[i-j];
						seen[i] =true;
					}					
				}
			}
		}
		System.out.println(dp[n]);
		
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

void fnInput(int64_t& rnNum)
{
  cin >> rnNum;
}

int fnDigitsCheck(int64_t nDivisor)
{
  int nDigitCnt = 0;
  while (nDivisor)
  {
    nDigitCnt++;
    nDivisor /= 10;
  }

  return nDigitCnt;
}

int fnMultiplCheck(int64_t nNum)
{
  int nMinDigit = fnDigitsCheck(nNum);
                                           
  for (int64_t n = 2; n * n <= nNum; n++)  // int型 n では n * n が int型の範囲を
  {                                        // 超えて桁落ちが発生し TLE となる
    if (nNum % n != 0)  continue;          // nNum の平方根を超えない整数～nNum
    int64_t nOtr = nNum / n;               // で左記検査を行うと TLE となる
    nMinDigit = min(nMinDigit, fnDigitsCheck(nOtr));
  }
  return nMinDigit;
}

int main()
{
  int64_t nNum;
  
  fnInput(nNum);
  cout << fnMultiplCheck(nNum) << endl;

  return 0;
}

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

using namespace std;

#define int long long

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

int N = 5;

signed main()
{
    cin >> N;

    vector<int> A(N);

    long long sum = 0;
    rep(i, N) cin >> A[i], sum += A[i];

    long long s = N * (N + 1) / 2;

    if (sum % s) {
        cout << "NO\n";
        return 0;
    }

    int times = sum / s;

    vector<int> diff;

    rep(i, N) diff.push_back(A[(i + 1) % N] - A[i] - times);

    int cnt = 0;

    rep(i, N) {
        if (diff[i] > 0 || (-diff[i] % N)) {
            cout << "NO\n";
            return 0;
        }

        cnt += -diff[i] / N;
    }

    cout << (cnt == times ? "YES" : "NO") << endl;
}


Measured memory_bytes: 2168
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner s = new Scanner(System.in);
    int N=s.nextInt();
    int M=s.nextInt();
    int X=N*(N-1)/2;
    int Y=M*(M-1)/2;
    System.out.println(X+Y);
}}

Measured memory_bytes: 23124
import java.io.PrintWriter

fun main() {
    PrintWriter(System.out).use { out ->
        solve(out)
        out.flush()
    }
}

fun solve(out: PrintWriter) {
    val (h1, m1, h2, m2, k) = readIntegerList()
    val time1 = h1 * 60 + m1
    val time2 = h2 * 60 + m2
    println(time2 - time1 - k)
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
fun readDoubleList() = readStringList().map(String::toDouble)


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

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

    string s;
    cin >> s;

    cout << s.substr(0, 4) << " " << s.substr(4) << endl;

    return 0;
}


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

int main(){

    string s, t, u;
    int a, b;

    cin >> s >> t >> a >> b >> u;

    if(u == s)
        a -= 1;
    else
        b -= 1;
    

    cout << a << ' ' << b << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))

s = [0]*(n+1)
for x in a:
    s[x] += 1
    

p = 0
for i in range(1,n+1):
    if s[i] >= 2:
        p += s[i]*(s[i]-1)//2

for i in range(n):
    ans = p - s[a[i]]*(s[a[i]]-1)//2 + (s[a[i]]-2)*(s[a[i]]-1)//2
    print(ans)

Measured memory_bytes: 32224
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
  int n = ri();
  if (n < 105) wi(0);
  else if (n < 135) wi(1);
  else if (n < 165) wi(2);
  else if (n < 189) wi(3);
  else if (n < 195) wi(4);
  else wi(5);
  
  return 0;
}


Measured memory_bytes: 256
h,w,d=map(int, input().split())
m=[list(map(int, input().split())) for i in range(h)]
b=[0]*(h*w)
for i in range(h):
    for j in range(w):
        b[m[i][j]-1]=[i,j]
dp=[0]*(h*w)
for i in range(d,h*w):
    dp[i]=dp[i-d]+abs(b[i][0]-b[i-d][0])+abs(b[i][1]-b[i-d][1])
n=int(input())
for i in range(n):
    x,y=map(int, input().split())
    print(dp[y-1]-dp[x-1])

Measured memory_bytes: 22432
h,w,a,b=map(int,input().split())
#コンビネーション逆元
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )
ans=cmb(h+w-2,h-1,mod)
for i in range(h-a+1,h+1):
    ans-=cmb(i+b-2,i-1,mod)*cmb(h-i+w-b-1,w-b-1,mod)
    ans%=mod
print(ans)

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

int main(){
  int a,b;
  cin>>a>>b;
  int N;
  cin>>N;
  int tmp_s,tmp_e;
  bool flag=false;
  for(int i=0;i<N;i++){
    cin>>tmp_s>>tmp_e;
    if(a<tmp_e&&b>tmp_s)flag=true;
    else if(a==tmp_e&&b==tmp_s)flag=true;
  }
  cout<<flag<<endl;
}



Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <string>
using namespace std;
int main(void){
  string n;
  cin>>n;
  cout<<"ABC"+n<<endl;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
ka = []
for i in range(N):
    ka.append(list(map(int,input().split())))

ans = 0
k = []

for i in range(1,M+1):
    k.append(i)
for i in range(N):
    for j in range(1,M+1):
        if j not in ka[i][1:] and j in k:
            k.remove(j)
print(len(k))


Measured memory_bytes: 3064
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <set>
#include <math.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;
const ll mod = 1000000007;
const ll INF = 1000000000000000;

ll bit[200010];
ll n;

ll sum(ll i)
{
	ll s = 0;
	while (i > 0)
	{
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(ll i, ll x)
{
	while (i <= n)
	{
		bit[i] += x;
		i += i & -i;
	}
}

ll pow_mod(ll x, ll y)
{
	ll res = 1;
	while (y > 0)
	{
		if (y % 2 == 1)
		{
			(res *= x) %= mod;
		}
		(x *= x) %= mod;
		y /= 2;
	}
	return res;
}

ll div(ll x)
{
	return pow_mod(x, mod - 2);
}



int main(void)
{
	
	cin >> n;
	ll b = (n + 1) / 2;
	double ans = (double)b / n;

	cout << ans << endl;

	int www;
	cin >> www;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1e9 + 7;
const ll INF = LLONG_MAX;
using Tree = vector<pair<int, int>>;

int main()
{
    int n;
    cin >> n;
    vector<int> h(n);
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    bool ans = true;
    for (int i = n - 1; i > 0; i--)
    {
        int tmp = h[i] - h[i - 1];
        if (tmp == -1)
        {
            h[i - 1]--;
        }
        else if (tmp < -1)
        {
            ans = false;
            break;
        }
    }
    cout << (ans ? "Yes" : "No") << endl;
}

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

int main(){
  int a,b,c,p=0;
  cin>>a>>b>>c;
  if(a==1 or b==1 or c==1) {
       cout << 0 ;
       return 0;
   } 
  if(a==b and b==c){
    cout<<-1;
    return 0;
  }
  while(a%2==0 && b%2==0 && c%2==0)
  {
    int x=(a/2)+(b/2);
    int y=(b/2)+(c/2);
    int z=(a/2)+(c/2);
    a=y;
    b=z;
    c=x;
    p++;
  }
  cout<<p<<endl;
  return 0;
}

Measured memory_bytes: 256
k,n=map(int,input().split())
a=list(map(int,input().split()))

x=k-a[-1]+a[0] #A1とANの距離
for i in range(n-1):
    if x<=a[i+1]-a[i]:
        x=a[i+1]-a[i]

print(k-x)

Measured memory_bytes: 77260
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h,l=l,l>>1;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)

Measured memory_bytes: 64164