akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define int ll
#define double ld
#define INF 987654321
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, mx = 0;
    cin >> n;
    map<string, int> rec;
    while (n--)
    {
        string str;
        cin >> str;
        rec[str]++;
        mx = max(mx, rec[str]);
    }
    vector<string> res;
    for (auto &x : rec)
        if (x.second == mx) res.push_back(x.first);
    sort(all(res));
    for (auto &x : res) cout << x << "\n";
    return 0;
}

Measured memory_bytes: 25840
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  n=pI(readline())
  dp=Array[[0,0,0] for i=1:n]
  dp[1]=pM(split(readline()))
  for i=2:n
    a,b,c=pM(split(readline()))
    dp[i][1]=max(dp[i-1][2],dp[i-1][3])+a
    dp[i][2]=max(dp[i-1][1],dp[i-1][3])+b
    dp[i][3]=max(dp[i-1][1],dp[i-1][2])+c
  end
  println(maximum(dp[n]))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 171428
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "C"
int f[101][10];
int n;
int s[101];
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    FOR(i, 1, n) read(s[i]);
    FOR(i, 0, n) FOR(j, 0, 9) f[i][j]=-1;
    f[0][0]=0;
    FFOR(i, 0, n) FOR(j, 0, 9) if(f[i][j]!=-1){
        f[i+1][j]=max(f[i+1][j], f[i][j]);
        f[i+1][(j+s[i+1])%10]=max(f[i+1][(j+s[i+1])%10], f[i][j]+s[i+1]);
    }
    int ans=0;
    FOR(i, 1, 9) ans=max(ans, f[n][i]);
    writeln(ans);
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn read_line<T>() -> Vec<T>
where
    T: FromStr,
    <T as std::str::FromStr>::Err: std::fmt::Debug,
{
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect()
}

fn main() {
    let in_vec: Vec<usize> = read_line();
    let a = in_vec[0];
    let b = in_vec[1];

    let mut res = (b - 1) / (a - 1);
    if (b - 1) % (a - 1) != 0 {
        res += 1;
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<stack>
#include<iostream>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define vec(a) vector<int>a
using namespace std;


int main()
{
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
	fastio
	ll n,i,j,k,l,m,z;
	cin>>n;
	vector<string> vec;
	for(i=0;i<n;i++)
	{
		string str;
		cin>>str;
		sort(str.begin(),str.end());
		vec.push_back(str);
	}
	sort(vec.begin(),vec.end());
	z=0;
	k=0;
	l=0;
	for(i=0;i<vec.size()-1;i++)
	{
		if(vec[i]==vec[i+1])
		{
			z++;
			l++;
		}
		else
		{
			k+=z*(z+1)/2;
			z=0;
			l=0;
		}
		if(i==vec.size()-2 && l!=0)
		{
			k+=z*(z+1)/2;
		}
	}
	cout<<k<<"\n";
	return 0;
}

Measured memory_bytes: 7344
#include <cstdio>
#include <stack>
using namespace std;

#define start first
#define end second

static const int NOT   = false;
static const int WHITE = 1;
static const int GRAY  = 2;
static const int BLACK = 3;
static const int N	   = 101;

int  n;
int  VisitedInfo[N];
bool Graph[N][N];
pair< int, int > Time[N];

void dfs( int u );
int  nextNode( int u );

int main()
{

	int u, k, v;

	for( int i = 0; i < N; i++ ) {
		for( int j = 0; j < N; j++ ) Graph[i][j] = NOT;
		VisitedInfo[i] = WHITE;
	}

	scanf( "%d", &n );
	for( int i = 0; i < n; i++ ) {
		
		scanf( "%d %d", &u, &k );
		for( int j = 0; j < k; j++ ) {

			scanf( "%d", &v );
			Graph[u][v] = true;

		}

	}

	dfs( 1 );

	for( int i = 1; i <= n; i++ ) printf( "%d %d %d\n", i, Time[i].start, Time[i].end );

	return 0;

}

void dfs( int u )
{

	int  time = 1, pos, ppos;
	bool brkUpNodeFlg = false;
	stack< int > dfsInfo;

	dfsInfo.push( u );
	Time[u].start  = time;
	VisitedInfo[u] = GRAY;

	while( !dfsInfo.empty() ) {

		ppos = dfsInfo.top();

		if( !brkUpNodeFlg ) pos = nextNode( ppos );

		brkUpNodeFlg = false;

		if( pos != 0 ) {
			if( VisitedInfo[pos] == WHITE ) {

				dfsInfo.push( pos );
				Time[pos].start  = ++time;
				VisitedInfo[pos] = GRAY;

			}
		}
		if( pos == 0 && VisitedInfo[ppos] != WHITE ){

			dfsInfo.pop();
			Time[ppos].end	  = ++time;
			VisitedInfo[ppos] = BLACK;


		}

		if( dfsInfo.empty() ) {
			for( int i = 1; i <= n; i++ ) {
				if( VisitedInfo[i] == WHITE ) {

					pos = i;
					dfsInfo.push( pos );
					Time[pos].start  = ++time;
					VisitedInfo[pos] = GRAY;
					brkUpNodeFlg     = true;
					break;

				}
			}
		}

	}

}

int nextNode( int now )
{

	for( int i = 1; i <= n; i++ ) {
		if( Graph[now][i] && VisitedInfo[i] == WHITE ) return i;
	}

	return 0;

}

Measured memory_bytes: 1044
import collections
import itertools

n = int(input())
l = []
for i in range(n):
    l.append(input())

c = collections.Counter(l)
l = c.most_common()
x = c.most_common()[0][1]

ans = []
ans.append(l[0][0])
for i in range(len(l)-1):
    if l[i+1][1] == x:
        ans.append(l[i+1][0])
    else:
        break

ans.sort()

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 57812
import sys
input = sys.stdin.readline


def solve():
  n = int(input())
  s = str(n)
  if n%2 == 1:
    print(0)
  else:
    ans = 0
    n //= 2
    for i in range(1,35):
      tmp = 5**i
      ans += n//tmp
    
       
    print(ans)

solve()

Measured memory_bytes: 2940
#include <complex>
#include <iostream>
using namespace std;
typedef complex<double> P;

double cross(P a, P b) {
  return (a.real() * b.imag() - a.imag() * b.real());
}

int main() {
  double x1, y1, x2, y2, x3, y3, xp, yp;
  while (cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> xp >> yp) {
    P a(x1, y1), b(x2, y2), c(x3, y3), p(xp, yp);
    double d1 = cross(b - a, p - a);
    double d2 = cross(c - b, p - b);
    double d3 = cross(a - c, p - c);
    if (((d1 < 0) && (d2 < 0) && (d3 < 0)) || ((d1 > 0) && (d2 > 0) && (d3 > 0))) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}


Measured memory_bytes: 3132
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29)
#define MAX 16
using namespace std;

int n;
int cost[MAX][MAX];
string s[MAX];
int dp[1<<MAX][MAX];

int getCost(string a,string b)
{//from a to b
  int res = inf;
  for(int i=a.size()-1,st = 0;i>=0 && st < b.size();i--,st++)
    {
      string ca = a.substr(i,a.size()-i);      
      string cb = b.substr(0,st+1);
      if(ca == cb)res = st+1; 
    }
  return res;
}

int main()
{
  while(1)
    {
      scanf("%d",&n);
      if(n == 0)break;
      rep(i,n)rep(j,n)cost[i][j] = inf;
      rep(i,n)cin >> s[i];
      vector<string> ss;
      rep(i,n)
	{
	  bool contain = false;
	  rep(j,n)
	    {
	      if(i == j)continue;
	      if(s[j].find(s[i]) != string::npos)
		{

		  contain = true;
		  break;
		}
	    }
	  if(!contain)ss.push_back(s[i]);
	}

      n = ss.size();
      rep(i,n)
	{
	  rep(j,n)
	    {
	      if(i == j)
		{
		  cost[i][j] = ss[i].size();
		  continue;
		}
	      int ct = getCost(ss[i],ss[j]);
	      if(ct == inf)cost[i][j] = ss[j].size();
	      else cost[i][j] = ss[j].size() - ct;
	    }
	}
      rep(i,1<<n)rep(j,n)dp[i][j] = inf;
      rep(i,n)dp[1<<i][i] = ss[i].length();

      rep(S,(1<<n))
	{
	  rep(from,n)
	    {
	      if(!((S>>from) & 1))continue;
	      rep(to,n)
		{
		  if((S>>to) & 1)continue;
		  dp[S|(1<<to)][to] = min(dp[S|(1<<to)][to],
					  dp[S][from] + cost[from][to]);
		}
	    }
	}
      int ans = inf;
      rep(i,n)ans = min(ans,dp[(1<<n)-1][i]);

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

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 100001


int main() {
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;

    int dx = tx-sx, dy = ty-sy;

    cout << string(dy, 'U') << string(dx, 'R');
    cout << string(dy, 'D') << string(dx, 'L');

    cout << 'L' << string(dy+1, 'U') << string(dx+1, 'R') << 'D';
    cout << 'R' << string(dy+1, 'D') << string(dx+1, 'L') << 'U';
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <math.h>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <ctime>
#include <iomanip>
#include <fstream>
#include <array>
using namespace std;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define IN(x,c) (find(c.begin(),c.end(),x) != (c).end())
#define REP(i,n) for (int i=0;i<(int)(n);i++)
#define FOR(i,a,b) for (int i=(a);i<=(b);i++)
#define INIT(a,v) memset(a,v,sizeof(a))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
template<class A, class B> A cvt(B x) { stringstream ss; ss<<x; A y; ss>>y; return y; }

#define SPC << " " <<
#define DEBUG(x) cerr << #x << " = "; cerr << x << endl;
#define DEBUG_ITER(x) cerr << #x << " = "; for (auto _ : x) cerr << _ << ' '; cerr << endl;

typedef pair<int,int> PII;
typedef long long int64;
typedef vector<int> VI;

struct Query {
	int l,r,id,ans;
};

bool decL(Query a, Query b) { return a.l>b.l; }
bool incId(Query a, Query b) { return a.id<b.id; }

int n,q,c[500001];
Query qs[500001];

int first[500001];
int bit[500001];

void add(int i, int d) {
	for (int x=i;x<=500000;x+=x&-x) bit[x]+=d;
}

int get(int i) {
	int r=0;
	for (int x=i;x>0;x-=x&-x) r+=bit[x];
	return r;
}

int main() {
	//freopen("test.in","r",stdin);
	int n,q;
	scanf("%d %d",&n,&q);
	FOR (i,1,n) {
		scanf("%d",&c[i]);
		first[i]=-1;
	}
	REP (i,q) {
		qs[i].id=i;
		qs[i].ans=0;
		scanf("%d %d",&qs[i].l,&qs[i].r);
	}
	sort(qs,qs+q,decL);
	int qi=0;
	for (int i=n;i>=1;i--) {
		if (first[c[i]]!=-1) {
			add(first[c[i]], -1);
		}
		add(i,1);
		first[c[i]]=i;
		while (qi<q && qs[qi].l==i) {
			qs[qi].ans=get(qs[qi].r);
			qi++;
		}
	}
	sort(qs,qs+q,incId);
	REP (i,q) printf("%d\n",qs[i].ans);
	return 0;
}


Measured memory_bytes: 17388
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <numeric>
#include <string>
#include <bitset>
#include <functional>

using ld = long double;
using vld = std::vector<ld>;
using vvld = std::vector<vld>;
using vvvld = std::vector<vvld>;
using ll = long long;
using vll = std::vector<ll>;
using vvll = std::vector<vll>;
using vvvll = std::vector<vvll>;
using pll = std::pair<ll, ll>;
using vpll = std::vector<pll>;
using str = std::string;
using vstr = std::vector<str>;

template<typename T> bool chmin(T a, T &b) {
    return a < b ? b = a, true : false;
}
template<typename T> bool chmax(T a, T &b) {
    return a > b ? b = a, true : false;
}

constexpr ld PI = 3.141592653589793L;
constexpr ld EPS = std::numeric_limits<ld>::epsilon();

ll gcd(ll n, ll m) { return m ? gcd(m, n % m) : n; }
ll lcm(ll n, ll m) { return n / gcd(n, m) * m; }
bool isprime(ll n) {
    if (n < 2) return false;
    for (ll i = 2; i * i <= n; i++)
        if (n % i == 0) return false;
    return true;
}
vll sieve(ll n) {
    str flg(n + 1, '1');
    for (ll i = 2; i * i <= n; i++) {
        if (flg[i] == '0') continue;
        for (ll j = i * i; j <= n; j += i)
            flg[j] = '0';
    }
    vll res;
    for (ll i = 2; i <= n; i++)
        if (flg[i] == '1') res.push_back(i);
    return res;
}
ll rpow(ll x, ll n) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) k *= x;
        x *= x;
    }
    return k * x;
}
ll modpow(ll x, ll n, ll mod) {
    if (n == 0) return 1;
    ll k = 1;
    for (; n > 1; n /= 2) {
        if (n & 1) (k *= x) %= mod;
        (x *= x) %= mod;
    }
    return k * x % mod;
}
ll modcomb(ll n, ll r, ll mod) {
    if (r < 0 || n < r) return 0;
    chmin(n - r, r);
    ll mul = 1, div = 1;
    for (ll i = 0; i < r; i++) {
        (mul *= n - i) %= mod;
        (div *= i + 1) %= mod;
    }
    return mul * modpow(div, mod - 2, mod) % mod;
}

/*----------------------------------------------------------------*/

void solve();

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

    solve();
}
void solve() {
    str s;
    std::cin >> s;

    ll n = s.length();

    vll ans(n, 0);
    for (ll i = 0, j; i < n; i++)
        s[i] == 'R' ? j = i : ans[j + (i - j) % 2]++;
    for (ll i = n - 1, j; i >= 0; i--)
        s[i] == 'L' ? j = i : ans[j - (j - i) % 2]++;

    for (ll i = 0; i < n; i++)
        std::cout << ans[i] << (i < n - 1 ?  ' ' : '\n');
}


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

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


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

    int n = s.size();

    int l = 0, r = 0, others = 0;
    REP(i, n){
        if(s[i] == s[0]) ++l;
        if(s[i] == s[n-1]) ++r;
        if(s[i] != s[0] and s[i] != s[n-1]) ++others;
    }

    vector<bool> T_win(n, false); // i+1 文字の時に高橋くんが勝つか
    if(s[0] == s[n-1]){
        if(n%2 == 0) cout << "First" << endl;
        else cout << "Second" << endl;
    }else{
        if(n%2 == 1) cout << "First" << endl;
        else cout << "Second" << endl;
    }
    return 0;
}

Measured memory_bytes: 512
N, K = map(int, input().split())
A = list(map(int, input().split()))
over = [N]*N

for k in range(K):
    data = [0] * N
    for i in range(N):
        l = max(0, i-A[i])
        r = min(N-1, i+A[i])
        data[l] += 1
        if r+1 != N:
            data[r+1] -= 1
    ruiseki = [0] * N
    ruiseki[0] = data[0]
    for i in range(1, N):
        ruiseki[i] = ruiseki[i-1] + data[i]
    A = ruiseki
    if A == over:
        print(*A)
        exit()

print(*A)

Measured memory_bytes: 170756
import bisect as bi

N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

a.sort()
c.sort()
#print(a)
#print(c)

ans=0
for i in b:
  ans+=bi.bisect_left(a,i)*(N-bi.bisect_right(c,i))
print(ans)

Measured memory_bytes: 23328
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE

struct T{
  map<string, Int> ms;
  T(){}
  T(string s, Int c){
    sort(s.begin(),s.end());
    ms[s]+=c;
  }

  T operator+=(const T &a){
    for(auto p:a.ms)
      ms[p.first]+=p.second;
    return *this;
  }
  
  T operator-=(const T &a){
    for(auto p:a.ms)
      ms[p.first]-=p.second;
    return *this;
  }
  
  T operator+(const T &a) const{
    T res(*this);
    return res+=a;
  }
  
  T operator-(const T &a) const{
    T res(*this);
    return res-=a;
  }
  
  T operator*(const T &a) const{
    T res;
    for(auto p:ms)
      for(auto q:a.ms)
        res+=T(p.first+q.first,p.second*q.second);
    return res;
  }

  T pow(Int k) const{
    assert(k>=1);
    T res(*this);
    for(Int i=1;i<k;i++) res=res*(*this);
    return res;
  }

  map<string, Int> norm(){
    map<string, Int> res;
    for(auto p:ms)
      if(p.second) res[p.first]=p.second;
    return res;
  }
};

using V = vector<string>; 
T expr  (const V &vs,Int &p);
T term  (const V &vs,Int &p);
T factor(const V &vs,Int &p);
T power (const V &vs,Int &p);
Int number(const V &vs,Int &p);

T expr  (const V &vs,Int &p){
  T res=term(vs,p);
  while(p<(Int)vs.size()){
    if(vs[p]=="+"s){
      p++;
      res=res+term(vs,p);
      continue;
    }
    if(vs[p]=="-"s){
      p++;
      res=res-term(vs,p);
      continue;
    }
    break;
  }
  return res;
}

T term  (const V &vs,Int &p){  
  T res=factor(vs,p);
  while(p<(Int)vs.size()){
    if(vs[p]=="+"s) break;
    if(vs[p]=="-"s) break;
    if(vs[p]=="^"s) break;
    if(vs[p]==")"s) break;
    res=res*factor(vs,p);
  }
  return res;
}

T factor(const V &vs,Int &p){  
  T res=power(vs,p);
  if(p<(Int)vs.size()&&vs[p]=="^"s){
    p++;
    Int k=number(vs,p);
    return res.pow(k);
  }  
  return res;
}

T power (const V &vs,Int &p){
  if(vs[p]=="("s){
    p++;
    T res=expr(vs,p);
    assert(vs[p]==")"s);
    p++;
    return res;
  }
  if(isalpha(vs[p][0])) return T(vs[p++],1);
  return T(""s, number(vs,p));
}

Int number(const V &vs,Int &p){
  return stoll(vs[p++]);
}

T tran(string s){
  Int n=s.size();
  string t;
  for(Int i=0;i<n;i++){
    if(!isdigit(s[i])) t+=' ';
    t+=s[i];
    if(!isdigit(s[i])) t+=' ';
  }  
  V vs;
  stringstream ss(t);
  while(ss>>t) vs.emplace_back(t);
  Int p=0;
  return expr(vs,p);
}

signed main(){
  string s;
  while(getline(cin,s)){
    if(s=="."s) break;
    auto vs=tran(s);
    while(1){
      string t;
      getline(cin,t);      
      if(t=="."s) break;
      auto vt=tran(t);
      cout<<(vs.norm()==vt.norm()?"yes":"no")<<endl;
    }    
    cout<<"."<<endl;
  }
  return 0;
}



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

using namespace std;

int p[15] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
int dp[15];
int mycombi(int a){
	if(a<=1) return 0;
	return (a*(a-1))/2;
}
int main(void)
{
	int n; scanf("%d",&n);
	int arr[5]={0,};
	const int arr2[5]={2,4,14,24,74};
	for(int i=0;i<15;i++){
		int nn = n;
		while(nn){
			nn/=p[i];
			dp[i]+=nn;
		}
		for(int j=0;j<5;j++){
			if(dp[i]>=arr2[j]) arr[j]++;
		}
	}
	int ans = 0;
	ans += ((arr[0]-arr[1])*mycombi(arr[1])+arr[1]*mycombi(arr[1]-1));
	ans += arr[2]*(arr[1]-1);
	ans += arr[3]*(arr[0]-1);
	ans += arr[4];
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 764
class Dice:
    def __init__(self, default = [0, 1, 2, 3, 4, 5]):
        self.d = default

    def e(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[3], self.d[0], self.d[5], self.d[2]

    def w(self):
        self.d[0], self.d[2], self.d[3], self.d[5] = self.d[2], self.d[5], self.d[0], self.d[3]

    def n(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[1], self.d[5], self.d[0], self.d[4]

    def s(self):
        self.d[0], self.d[1], self.d[4], self.d[5] = self.d[4], self.d[0], self.d[5], self.d[1]

    def top(self):
        return self.d[0]


def main():
    dice = Dice([int(i) for i in input().split()])
    for o in input():
        if o == 'E':
            dice.e()
        elif o == 'W':
            dice.w()
        elif o == 'S':
            dice.s()
        else:
            dice.n()

    print(dice.top())

main()



Measured memory_bytes: 5612
x,y = map(int,input().split())

l = []
flag = False

for i in range(x+1):
    l.append((i,x-i))

for xx,yy in l:
    if y == (xx*2+yy*4):
        flag = True
        break
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007

#define INF 100000000


int main() {
    int n; cin >> n;
    for(int i = 1; i < 10; i++) {
        for(int j = 1; j < 10; j++) {
            if(i*j == n) {
                cout << "Yes\n";
                return 0;
            }

        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
while 1:
    m = int(input())
    if m == 0:
        break

    target = []
    for _ in range(m):
        x, y = map(int, input().split())
        target.append([x, y])
    tx = target[0][0]
    ty = target[0][1]

    n = int(input())
    stars = []
    for _ in range(n):
        x, y = map(int, input().split())
        stars.append([x, y])

    for star in stars:
        off_x = star[0] - tx
        off_y = star[1] - ty
        for t in target:
            x = t[0] + off_x
            y = t[1] + off_y
            if [x, y] not in stars:
                break
        else:
            print(off_x, off_y)
            break



Measured memory_bytes: 5784
#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;
typedef long long ll;
typedef pair<int,ll> P;

vector<int> color;
vector<vector<P>> a;

int rev(int c) {
  if (c == 1) return 0;
  else return 1;
}

void dfs(int v, int c) {
  color[v] = c;
  for (int i = 0; i < a[v].size(); ++i) {
    if (color[a[v][i].first] != -1) continue;
    if (a[v][i].second%2 == 1) dfs(a[v][i].first, rev(c));
    else dfs(a[v][i].first, c);
  }
}

int main() {
  int n;
  cin >> n;
  a.resize(n, vector<P>(0));
  color.resize(n, -1);
  rep(i,n-1) {
    int u, v;
    ll w;
    cin >> u >> v >> w;
    u--;
    v--;
    a[u].push_back(P(v,w));
    a[v].push_back(P(u,w));
  }
  dfs(0,1);
  rep(i,n) cout << color[i] << endl;
  return 0;
}

Measured memory_bytes: 8832
#include <stdio.h>
#define MAX(x,y) x>y?x:y
typedef long long int ll;

ll N,C,x[100002],v[100002];

ll Solve(){
	ll lg=0,tem=0;
        ll max[100001];
        max[0]=0;
	for(ll i=0;i<N;i++)
	{
		lg+=v[i+1]+x[i]-x[i+1];
		max[i+1]=MAX(max[i],lg);
                //printf("f(%lld)=%lld\n",i+1,max[i+1]);
	}
	ll ans=max[N];
	for(ll i=N;i>1;i--)
	{
		tem+=v[i]+x[i]-x[i+1];
		ans=MAX(tem+x[i]-C+max[i-1],ans);
	}
        //printf("ans: %lld\n",ans);
	return ans;
}

int main(){
	scanf("%lld %lld",&N,&C);
	for(ll i=0;i<N;i++) scanf("%lld %lld",&x[i+1],&v[i+1]);
	x[N+1]=C;
        x[0]=0;
	ll Ans1=Solve();
	for(ll i=1;i<=N;i++) x[i]=C-x[i];
        for(ll i=1;i<=N/2;i++) {
            ll t=x[i];
            x[i]=x[N+1-i];
            x[N+1-i]=t;
            t=v[i];
            v[i]=v[N+1-i];
            v[N+1-i]=t;
        }
       /*for(ll i=1;i<=N;i++) printf("x[%lld]=%lld\n",i,x[i]);
        for(ll i=1;i<=N;i++) printf("v[%lld]=%lld\n",i,v[i]);*/
	ll Ans2=Solve();
	printf("%lld",MAX(Ans1,Ans2));
	return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
int main(){
  int M, N;
  cin >> M >> N;
  vector<vector<int>> mn(M, vector<int>(N, 0));
  vector<vector<int>> mx(M, vector<int>(N, 100));
  for (int i = 0; i < M; i++){
    int K;
    cin >> K;
    for (int j = 0; j < K; j++){
      int s;
      string cond;
      int t;
      cin >> s >> cond >> t;
      s--;
      if (cond == "<="){
        mx[i][s] = min(mx[i][s], t);
      }
      if (cond == ">="){
        mn[i][s] = max(mn[i][s], t);
      }
    }
  }
  bool ok = true;
  for (int i = 0; i < M; i++){
    for (int j = 0; j < N; j++){
      if (mn[i][j] > mx[i][j]){
        ok = false;
      }
    }
  }
  vector<vector<int>> E(M);
  for (int i = 0; i < M; i++){
    for (int j = 0; j < M; j++){
      if (i != j){
        bool edge = false;
        for (int k = 0; k < N; k++){
          if (mx[i][k] < mn[j][k]){
            edge = true;
          }
        }
        if (edge){
          E[i].push_back(j);
        }
      }
    }
  }
  vector<int> deg(M, 0);
  for (int i = 0; i < M; i++){
    for (int j : E[i]){
      deg[j]++;
    }
  }
  queue<int> Q;
  for (int i = 0; i < M; i++){
    if (deg[i] == 0){
      Q.push(i);
    }
  }
  while (!Q.empty()){
    int v = Q.front();
    Q.pop();
    for (int w : E[v]){
      deg[w]--;
      if (deg[w] == 0){
        Q.push(w);
      }
    }
  }
  for (int i = 0; i < M; i++){
    if (deg[i] != 0){
      ok = false;
    }
  }
  if (ok){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3360
#include<stdio.h>
int main()
{
    int n,d,i,j;
    scanf("%d %d",&d,&n);
    if(d==0)
    {
        if(n!=100)
            printf("%d\n",n);
        else
            printf("101\n");
    }
    else if(d==1)
    {
        if(n!=100)
            printf("%d\n",n*100);
        else
            printf("10100\n");
    }
    else
    {
        if(n!=100)
            printf("%d\n",n*10000);
        else
            printf("1010000\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define ld long double
#define PB push_back
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const ll maxn = 2e5 + 50 , N = 60000 + 20 , mod = 1e9 + 7 , INF = 1e9 + 1 , lg = 32;

ll a[maxn];

int main() {
	FAST
	int n;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}
	ll curr = 0 , ans = 0;
	for (int i = 0; i < n; ++i) {
		if(a[i] < curr) {
			ans += curr - a[i];
		}
		curr = max(curr , a[i]);
	}
	cout << ans << endl;
}


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

int main() {
  int N, B0, ans, p;
  cin >> N >> B0;
  ans = B0 * 2;
  // B[i] <= B[i+1]ならans += B[i+1]
  // B[i] > B[i+1]ならans += -B[i]+B[i+1]+B[i+1]
  p = B0;
  for (int i = 0; i < N - 2; i++) {
    int q;
    cin >> q;
    if (p <= q) ans += q;
    else ans += q * 2 - p;
    p = q;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<ctype.h>
int main(void)
{
	int N, K;
	char S[100];
	scanf("%d", &N); scanf("%d", &K);
	for (int i = 0; i <= N; i++) {
		scanf("%c", &S[i]);
	}
	S[K]=tolower(S[K]);
	for (int i = 0; i <= N; i++) {
		printf("%c", S[i]);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		if(n==0) break;
		int zero=0,a=n;
		while(a>=5){
			a /= 5;
			zero += a;
		}
		cout<<zero<<endl;
	}
	return 0;
}

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

using namespace std;

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

int F(ll a, ll b){
	int res = 0;
	while(a > 0LL || b > 0LL){
		++res;
		a /= 10LL, b /= 10LL;
	} // end while
	return res;
}

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

	int res = 1000;
	for (ll i = 1LL; i <= (ll)sqrt(N); ++i){
		ll curr = N / i;
		if (i * curr == N){
			res = min(res, F(i, curr));
		} // end if
	} // end for
	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
	Scanner sc = new Scanner(System.in);

	int N = sc.nextInt();

	int D = sc.nextInt();

	if(N%(2*D+1) !=0) {
		System.out.print(N/(2*D+1) +1);
	}

	else {System.out.print(N/(2*D+1));}


}
}

Measured memory_bytes: 21940
N, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0
for i in range(len(a)):
    if i < len(a) - 1 and a[i] <= x:
        count += 1
        x -= a[i]
    elif i == len(a) - 1 and a[i] == x:
        count += 1
    else:
        break
print(count)

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

void addEdge(int* count, int** list, int to) {
	int* newList = realloc(*list, sizeof(int) * (*count + 1));
	if (newList == NULL) exit(2);
	newList[(*count)++] = to;
	*list = newList;
}

int N;
int edgeCount[271828];
int* edges[271828];

int ufParent[271828];

void ufInit(void) {
	int i;
	for (i = 1; i <= N; i++) ufParent[i] = i;
}

int ufRoot(int node) {
	if (ufParent[node] == node) return node;
	return ufParent[node] = ufRoot(ufParent[node]);
}

void ufMerge(int a, int b) {
	int aRoot = ufRoot(a);
	int bRoot = ufRoot(b);
	if (aRoot != bRoot) ufParent[aRoot] = bRoot;
}

int currentGeneration;
int countGeneration[271828];
int count[271828];
int visited[271828];

int visitedCount;
int visitedList[271828];

int answer[271828];

void dfs(int node) {
	if (visited[node] != currentGeneration) {
		int root = ufRoot(node);
		int i;
		visited[node] = currentGeneration;
		visitedList[visitedCount++] = node;
		if (countGeneration[root] != currentGeneration) {
			countGeneration[root] = currentGeneration;
			count[root] = 0;
		}
		count[root]++;
		for (i = 0; i < edgeCount[node]; i++) {
			dfs(edges[node][i]);
		}
	}
}

int main(void) {
	int i;
	int K, L;
	if (scanf("%d%d%d", &N, &K, &L) != 3) return 1;
	for (i = 0; i < K; i++) {
		int p, q;
		if (scanf("%d%d", &p, &q) != 2) return 1;
		addEdge(&edgeCount[p], &edges[p], q);
		addEdge(&edgeCount[q], &edges[q], p);
	}
	ufInit();
	for (i = 0; i < L; i++) {
		int r, s;
		if (scanf("%d%d", &r, &s) != 2) return 1;
		ufMerge(r, s);
	}

	for (i = 1; i <= N; i++) {
		if (answer[i] == 0) {
			int j;
			currentGeneration++;
			visitedCount = 0;
			dfs(i);
			for (j = 0; j < visitedCount; j++) {
				answer[visitedList[j]] = count[ufRoot(visitedList[j])];
			}
		}
	}

	for (i = 1; i <= N; i++) {
		printf("%d%c", answer[i], i == N ? '\n' : ' ');
	}
	return 0;
}


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

int Exp(long long int exp_n,long long int exp_e, long long exp_mod);


int main(){
  int a,O;
  cin >> a;
  O = a+a*a+a*a*a;
  
  cout << O;
  
  return 0;
}


int Exp(long long int exp_n,long long int exp_e, long long int exp_mod){
  long long int exp_o = 1;
  long long int exp_x=exp_n;
  long long int exp_tmp;
  
  while(0<exp_e){
    exp_tmp = exp_e/2;
    if(exp_e - exp_tmp*2 == 1){
      exp_o = exp_o*exp_x;
      if(exp_o>exp_mod){
        exp_o=exp_o%exp_mod;
      }
    }
    
    exp_x = exp_x*exp_x;
    if(exp_x>exp_mod){
      exp_x=exp_x%exp_mod;
    }
    exp_e = exp_tmp;
  }
  return exp_o;
}


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

using namespace std;

int main() {
  #ifdef _OFFLINE_
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif

  int n;
  cin >> n;
  vector<int> arr(n), res(n);
  for(int i = 0; i < n; ++i) {
    cin >> arr[i];
  }

  int l = 0, r = n - 1;
  int index = n - 1;
  while(true) {
    res[l] = arr[index];
    --index;
    if(index < 0) {
      break;
    }
    res[r] = arr[index];
    --index;
    ++l; --r;
    if(l > r || index < 0) {
      break;
    }
  }

  for(int i = 0; i < n; ++i) {
    cout << res[i] << ' ';
  }
}

Measured memory_bytes: 3712
N = int(input())
playlist = []
for i in range(N):
  playlist.append([x for x in input().split()])
M = input()
ans = 0
sleep = 0
for i in range(N):
  if sleep == 0:
    if playlist[i][0] == M:
      sleep = 1
  else:
    ans += int(playlist[i][1])
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,a[(int)1e5+10];
int cnt[2][(int)1e5+10];

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

    int i,j;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        if(i%2)
        {
            cnt[0][i]=cnt[0][i-1]+a[i];
            cnt[1][i]=cnt[1][i-1]-a[i];
        }
        else
        {
            cnt[0][i]=cnt[0][i-1]-a[i];
            cnt[1][i]=cnt[1][i-1]+a[i];
        }
    cout<<cnt[0][n]<<' ';
    for(i=2;i<=n;i++)
        if(i%2)
            cout<<cnt[0][n]-cnt[0][i-1]+cnt[1][i-1]<<' ';
        else
            cout<<cnt[1][n]-cnt[1][i-1]+cnt[0][i-1]<<' ';
    cout<<endl;
    return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;

class unionFind {
public:
  vector<ll> data;
  
  unionFind(ll size) {
    data.assign(size, -1);
  }
  
  bool same(ll x, ll y) {
    return find(x)==find(y);
  }
  
  void unite(ll x, ll y) {
    x=find(x);
    y=find(y);
    if(x==y) return;
    if(data[x]>data[y]) swap(x, y);
    data[x]+=data[y];
    data[y]=x;
  }
  
  ll find(ll k) {
    if(data[k]<0) return k;
    return data[k]=find(data[k]);
  }
  
  ll size(ll k) {
    return -data[find(k)];
  }
  
};

ll N, M, K;

int main(void) {
  cin >> N >> M >> K;
  ll cnt[MAX]={};
  unionFind uf=unionFind(N);
  ll i;
  
  for(i=0; i<M; i++) {
    ll a, b;
    cin >> a >> b;
    a--; b--;
    
    cnt[a]++;
    cnt[b]++;
    uf.unite(a, b);
  }
  
  for(i=0; i<K; i++) {
    ll c, d;
    cin >> c >> d;
    c--; d--;
    
    if(uf.same(c, d)) {
      cnt[c]++;
      cnt[d]++;
    }
  }
  
  for(i=0; i<N; i++) {
    pt(uf.size(i)-1-cnt[i]); //-1:自分
  }
  
  
}




Measured memory_bytes: 2432
/* When Talent doesn't work, Hard work beats Talent*/

#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")

#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(2);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define sp " "
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI=3.141592653589793;

void solve()
{
	int n,k;
	cin >> n >>k;
	int ans=k;
	n--;
	while(n--)
	{
		ans*=(k-1);
	}
	cout << ans << nl;
}

int32_t main()
{
	FastIO;
	Fast_D;
	int T;
	T=1;
	while(T--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 3676
import copy

n = int(input())
s = input()

ans = copy.copy(s)

lens = 0
while lens != len(s):
    lens = len(s)
    for i in range(len(s)):
        if s[i:i+2] == '()':
            s = s[:i] + s[i+2:]

ans = '(' * s.count(')') + ans + ')' * s.count('(')

print(ans)


Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main()
{
  int t, n, h;
  int max = 0;
  int min = 0;
  int last_h = -1;
  
  cin >> t;
  while (t--) {
    max = 0;
    min = 0;
    last_h = -1;
    cin >> n;
    while (n--) {
      cin >> h;
      int diff_h;
      last_h < 0 ? diff_h = 0 : diff_h = h - last_h;
      if (diff_h >= max) max = diff_h;
      if (diff_h <= min) min = diff_h;
      last_h = h;
    }
    cout << max << " " << -min << endl;
  }
}



Measured memory_bytes: 3004
/*
       Hi there <3 
──────▄▀▄─────▄▀▄
─────▄█░░▀▀▀▀▀░░█▄
─▄▄──█░░░░░░░░░░░█──▄▄
█▄▄█─█░░▀░░┬░░▀░░█─█▄▄█

*/
#include <bits/stdc++.h>
#define MOD 1000000007
#define re return
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) ((int)(x).size())
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repa(i,a,n) for(int i=a;i<n;i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define rrepa(i,a,n) for (int i = n; i >= a; i--)
#define fill(x, y) memset(x, y, sizeof(x))
#define sqr(x) ((x) * (x))
#define sqrt(x) sqrt(abs(x))
#define unq(x) (x.resize(unique(all(x)) - x.begin()))
#define ba back()
#define popcount __builtin_popcountll
#define fastIO()                 \
    {                            \
        ios::sync_with_stdio(0); \
        cin.tie(0);              \
        cout.tie(0);             \
    }
#define in(x) \
    int x;    \
    cin >> x;
#define in1(x) \
    int x;     \
    cin >> x;  \
    x--;
#define inll(x) \
    ll x;       \
    cin >> x;
#define ins(x) \
    string x;  \
    cin >> x;

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef pair<double, double> pdd;
typedef long double LD;
typedef double D;

void Solve()
{
     int n;
     cin>>n;
     map<string,int> m;
     rep(i,n)
    {
        string s;
        cin>>s;
        m[s]++;

    }
    cout<<"AC x "<<m["AC"]<<endl;
    cout<<"WA x "<<m["WA"]<<endl;
    cout<<"TLE x "<<m["TLE"]<<endl;
    cout<<"RE x "<<m["RE"]<<endl;


}

int main()
{
    fastIO();
    int t;
    t=1;
    while (t--)
    {
        Solve();
    }
    return 0;
}

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

int main() {
    int n, d;
    cin >> n >> d;
    vector< vector<int> > x(n, vector<int>(d));
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> x[i][j];
        }
    }

    int ans = 0;
    for(int i=0; i<n-1; i++){
        for(int j=i+1; j<n; j++){
            double sum = 0;
            for(int k=0; k<d; k++){
                sum += pow(x[i][k] - x[j][k], 2);
            }
            sum = pow(sum, 0.5);

            if(ceil(sum)==int(sum)){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    int N;
    int ans;
    cin>>N;
    for (int i=1;i<11; i++){
        if (N<=1000*i){
            ans = 1000*i - N;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;
    cin>>n>>m;
    cout << ((n-m)*100+m*1900)*pow(2,m)<<endl;
    return 0;
}




Measured memory_bytes: 256
//om namah shivaaay//
#include <bits/stdc++.h>
#define Om_namah_Shivaay ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
 #define ll long long
 using namespace std;
 int main()
 {
    Om_namah_Shivaay;
    string s;
    cin>>s;
    if (s=="ABC")
    {
		cout<<"ARC";
		}
		else{
			cout<<"ABC";
			}}
    


Measured memory_bytes: 3592
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val N = sc.nextInt()
    val M = sc.nextInt()
    val X = sc.nextInt()
    val Y = sc.nextInt()
    val x = (1..N).map { sc.nextInt() }.plus(X)
    val y = (1..M).map { sc.nextInt() }.plus(Y)
    println(if (x.max()!! < y.min()!!) "No War" else "War")
}

Measured memory_bytes: 31384
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    string s;
    cin >> s;
    int i;
    int mina=-1,maxz=-1;
    i=0;
    while(mina==-1){
      if(s[i]=='A')mina=i;
      i++;
    }
    i=s.size()-1;
    while(maxz==-1){
      if(s[i]=='Z')maxz=i;
      i--;
    }
    cout<<maxz-mina+1;
    return 0;
}


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

int main(){
    string s;
    cin>>s;
    int n=s.length();
    int zero=0;
    int one=0;
    rep(i,n){
        if(s[i]=='0'){
            zero++;
        }else{
            one++;
        }
    }
    int k = abs(zero-one);
    cout<<n-k<<endl;
    return 0;
}

Measured memory_bytes: 512
import sys
from math import log10

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 19 + 7
EPS = 10 ** -10

def bisearch_min(mn, mx, func):
    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            ok = mid
        else:
            ng = mid
    return ok

def mat_pow(mat, init, K, MOD):
    """ 行列累乗 """

    def mat_dot(A, B, MOD):
        """ 行列の積 """

        if not isinstance(A[0], list) and not isinstance(A[0], tuple):
            A = [A]
        if not isinstance(B[0], list) and not isinstance(A[0], tuple):
            B = [[b] for b in B]
        n1 = len(A)
        n2 = len(A[0])
        _ = len(B)
        m2 = len(B[0])
        res = list2d(n1, m2, 0)
        for i in range(n1):
            for j in range(m2):
                for k in range(n2):
                    res[i][j] += A[i][k] * B[k][j]
                    res[i][j] %= MOD
        return res

    def _mat_pow(mat, k, MOD):
        """ 行列matをk乗する """

        n = len(mat)
        res = list2d(n, n, 0)
        for i in range(n):
            res[i][i] = 1
        while k > 0:
            if k & 1:
                res = mat_dot(res, mat, MOD)
            mat = mat_dot(mat, mat, MOD)
            k >>= 1
        return res

    res = _mat_pow(mat, K, MOD)
    res = mat_dot(res, init, MOD)
    return [a[0] for a in res]

L, a, b, M = MAP()

A = [0] * 20
for i in range(1, 20):
    x = 10 ** i
    res = bisearch_min(-1, L, lambda m: ceil(x-a, b) <= m)
    A[i] = res
C = [0] * 20
for i in range(1, 20):
    C[i] = A[i] - A[i-1]

init = [0, a, 1]
for d in range(1, 20):
    K = C[d]
    if K == 0:
        continue
    mat = [
        # dp0[i] = dp0[i-1]*10^d + dp1[i-1]*1 + 1*0
        [pow(10, d, M), 1, 0],
        # dp1[i] = dp0[i-1]*0 + dp1[i-1]*1 + 1*b
        [0, 1, b],
        # 1 = dp0[i-1]*0 + dp1[i-1]*0 + 1*1
        [0, 0, 1],
    ]
    res = mat_pow(mat, init, K, M)
    init[0] = res[0]
    init[1] = res[1]
ans = res[0]
print(ans)

# dp0 = [0] * (L+1)
# dp1 = [0] * (L+1)
# dp0[0] = 0
# dp1[0] = a
# for i in range(1, L+1):
#     dp0[i] = (dp0[i-1]*pow(10, int(log10(dp1[i-1]))+1, M) + dp1[i-1]) % M
#     dp1[i] = dp1[i-1] + b
# ans = dp0[-1]
# print(ans)


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

using lnt = long long;
using Real = long double;

#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(lnt i=0;i<(n);++i)
#define RANGE(i, a, b) for(lnt i=(a);i<(b);++i)
#define RREP(i, n) for(lnt i=(n)-1;i>= 0;--i)

#define ln '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define dcout cout<<fixed<<setprecision(20)
#define summon_tourist cin.tie(0);ios::sync_with_stdio(false)

constexpr int dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr Real eps = 1e-9; const Real pi = acosl(-1);
constexpr lnt BIG = INT_MAX/10, BBIG = LLONG_MAX/10;

template<class T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<class T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<class T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<class T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
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;}

using pint = pair<int, int>; using plnt = pair<lnt, lnt>;
using vint = vector<int>; using vlnt = vector<lnt>;
constexpr lnt MOD = 1e9+7;

int main(){
	summon_tourist;

	int N, A[100000]; cin >> N;
	REP(i, N) cin >> A[i];

	sort(A, A+N);
	vint plus, minus;
	if(A[0] >= 0){
		minus.eb(A[0]);
		RANGE(i, 1, N) plus.eb(A[i]);
	} else if(A[N-1] < 0){
		plus.eb(A[N-1]);
		REP(i, N-1) minus.eb(A[i]);
	} else {
		REP(i, N){
			if(A[i] >= 0) plus.eb(A[i]);
			else minus.eb(A[i]);
		}
	}

	int num = minus[0];
	vector<pint> ans;
	REP(i, plus.size()-1){
		ans.eb(num, plus[i]);
		num -= plus[i];
	}
	ans.eb(plus.back(), num);
	num = plus.back() - num;
	RANGE(i, 1, minus.size()){
		ans.eb(num, minus[i]);
		num -= minus[i];
	}

	cout << num << ln;
	for(auto p: ans){
		cout << p.first << ' ' << p.second << ln;
	}
}

Measured memory_bytes: 3828
class Problem
  attr_accessor *(?a..?z).to_a.map(&:to_sym)
  def initialize
    @n = gets.to_s.to_i
    @a = gets.to_s.split.map{ |v| v.to_i }
    @h = a.tally
    @t = h.map{|k,v|v*(v-1)/2}.sum
  end

  def solve
    n.times.map do |i|
      t - h[a[i]] + 1
    end
  end

  def show(ans)
    ans.each do |v|
      puts v
    end
  end
end

Problem.new.instance_eval do
  show(solve)
  # pp self
end

# n * (n-1) / 2
# - (n-1) * (n-2) / 2
# = n-1

Measured memory_bytes: 38544
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
const int maxm=2e5+5;
vector<PI>g[maxm];
int mark[maxm];
int d[maxm];
int k;
int S;
void spfa(){
    queue<int>q;
    q.push(S);
    for(int i=0;i<=k;i++){
        d[i]=1e18;
    }
    d[S]=0;
    mark[S]=1;
    while(!q.empty()){
        int x=q.front();q.pop();
        mark[x]=0;
        for(auto i:g[x]){
            int v=i.first,w=i.second;
            if(d[v]>d[x]+w){
                d[v]=d[x]+w;
                if(!mark[v]){
                    mark[v]=1;
                    q.push(v);
                }
            }
        }
    }
}
signed main(){
    cin>>k;
    S=k;
    for(int i=1;i<10;i++){//[1,9]
        g[S].push_back({i%k,i});
    }
    for(int i=1;i<k;i++){
        for(int j=0;j<10;j++){
            g[i].push_back({(i*10+j)%k,j});
        }
    }
    spfa();
    cout<<d[0]<<endl;
    return 0;
}
/*
考虑构造每一位的数字,
一开始为空,如果下一位为x,那么数位和+x,
因为要是k的倍数,那么在模k意义下计算数位和,
那么最后一定是%k=0.

对于[0,k-1]的每个点x:
x向x*10%k建立一条边权为0的边,表示下一位选择0,
x向(x*10+1)%k建立一条边权为1的边,表示下一位选择1,
...

第一个数只能选[1,9]不能选0,否则就是前导零了,
建立新源点S,对[1,9]连边,
那么S到0的最短路就是答案,
因为模k意义下等于0的就是0的倍数,边权和就是最小数位和.
*/


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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  int X, Y;
  cin >> X >> Y;
  for(int i = 0; i < 100; i++){
    if(i * 2 >= 0 && (X-i)*4 >= 0 && i * 2 + (X - i) * 4 == Y){
      cout << "Yes" <<endl;
      return 0;
   }
  }
   cout << "No" <<endl;
}


Measured memory_bytes: 3684