akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

int main()
{
  int n; cin >> n;
  vector<int> c(n-1), s(n-1), f(n-1);
  rep(i, n-1) cin >> c[i] >> s[i] >> f[i];
  vector<int> ans(n);
  rep(i, n) {
    int now = i;
    int res = 0;
    while(now != n-1) {
      int x = max(0, (int)ceil((double)(res-s[now])/f[now]));
      res = s[now]+f[now]*x + c[now];
      ++now;
    }
    ans[i] = res;
  }
  for(auto x : ans) cout << x << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int H, W; cin >> H >> W;
    vector<vector<char>> field(H+2, vector<char>(W+2, '.'));

    for(int i=1; i<=H; i++) for(int j=1; j<=W; j++) cin >> field[i][j];

    for(int i=1; i<=H; i++){
        for(int j=1; j<=W; j++){
            if(field[i][j] == '#') cout << "#";
            else{
                int cnt = 0;
                for(int k=-1; k<=1; k++){
                    for(int l=-1; l<=1; l++){
                        if(field[i+k][j+l] == '#') cnt++;
                    }
                }
                cout << cnt;
            }
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split())) #展望台iの標高
assert len(H) == N
paths = [[] for i in range(N)]
for m in range(M):
  a, b = map(int, input().split())
  a -= 1
  b -= 1
  paths[a].append(b)
  paths[b].append(a) # 展望台AからBへの道、その逆

count = 0
for a in range(N):
  for b in paths[a]:
    if H[b] >= H[a]:
      break
  else:
    count += 1
print(count)

Measured memory_bytes: 29432
def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a.sort(reverse=True)
    all_a = sum(a)
    count = 0
    for i in range(n):
        if all_a / (4 * m) <= a[i]:
            count += 1
        else:
            break
    print("Yes" if m <= count else "No")


if __name__ == '__main__':
    main()



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

int main(){
    long long N,ai;
    cin >> N;
    long long a[N];
    long long sum, total, ans, tmp;

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

    sum=0;

    for(long long i=0; i<N-1; i++){
        sum+=a[i];
        tmp= abs(total-2*sum);
        if(i==0){
            ans=tmp;
        }else{
            ans= min(ans,tmp);
        }
        //cout << "i sum total total-sum tmp ans " << i << " " << sum << " " << total << " " << total-sum << " " << tmp << " " << ans << endl; 
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1792
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ

int main(){
	int a;scanf("%d",&a);
	long long ret=0;
	for(int i=1;i<=a;i++){
		long long n=a/i;
		ret+=i*(n*(n+1)/2);
	}
	printf("%lld\n",ret);		
}

Measured memory_bytes: 1736
n, k = map(int, input().split())
lst = list(map(int, input().split()))

count_bf = [0] * n
count_af = [0] * n

for i in range(n):
    for j in range(n):
        if j < i:
            if lst[i] > lst[j]:
                count_bf[i] += 1
        if j > i:
            if lst[i] > lst[j]:
                count_af[i] += 1
                
res = 0
for i in count_af:
    res += ((k * (k+1) // 2) * i) % (10**9 + 7)
for i in count_bf:
    res += ((k * (k-1) // 2) * i) % (10**9 + 7)
print(res % (10**9 + 7))

Measured memory_bytes: 42348
#include <cstdio>
#include <set>
#include <algorithm>
using namespace std;
int k[10000];
int main() {
	int N;
	while(scanf("%d",&N),N) {
		int maxk=0,sum=0;
		for(int i=0;i<N;i++) {
			int k;
			scanf("%d",&k);
			if(k>0) sum++;
			maxk=max(maxk,k);
		}
		if(maxk<2) {
			printf("NA\n");
		}else {
			printf("%d\n",sum+1);
		}
	}
}

Measured memory_bytes: 1040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int k;
    string s;
    int i;
    cin >> k;
    cin >> s;
    if(s.size() <= k){
        cout << s << endl;
    } else {
        for(i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..." << endl;
    }
}

Measured memory_bytes: 3624
#include <stdio.h>
int main() {
    int A, B, K, cnt = 0;
    if (scanf("%d %d %d", &A, &B, &K) == -1) return -1;
    for (int i = ((A > B) ? B : A); i >= 1; i--) {
        if (A % i == 0 && B % i == 0) cnt++;
        if (cnt == K) {
            printf("%d\n", i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 128
N,M = map(int,input().split())
lis_ac = [None] * N
lis_wa = [0] * N
ac = 0
wa = 0
for i in range(M):
    a,b = map(str,input().split())
    a = int(a)
    if b == 'AC' and lis_ac[a-1] == None:
        lis_ac[a-1] = 'AC'
        ac += 1
        wa += lis_wa[a-1]
    elif b == 'AC' and lis_ac[a-1] == 'AC':
        continue
    elif b == 'WA' and lis_ac[a-1] == 'AC':
        continue
    else:
        lis_wa[a-1] += 1
print(ac,wa)

Measured memory_bytes: 4596
#include <bits/stdc++.h>
#define FSTCIN ios::sync_with_stdio(0)
using namespace std;
typedef long long ll;

const int N = 100000 + 10;
int n, a[N], pos[N];
int main() {
  cin >> n;
  for(int i = 1; i <= n; i++) cin >> a[i], pos[a[i]] = i;

  set <int> st; st.insert(0); st.insert(n + 1);
  st.insert(-1);
  ll outans = 0;
  for(int i = n; i >= 1; i--) {
    set <int> :: iterator B = st.lower_bound(pos[i]); B--;
    set <int> :: iterator A = B; A--;
    set <int> :: iterator C = st.lower_bound(pos[i]);
    set <int> :: iterator D = C; D++;
    ll ans = 0;
    if(A != st.begin()) {
      //cout << "F1\n";
      ans += 1ll * ((*B) - (*A)) * ((*C) - pos[i]);
    }
    if(D != st.end()) {
      //cout << "F2\n";
      ans += 1ll * (*D - *C) * (pos[i] - *B);
    }
    //cout << i << " : " << ans <<endl;
    outans += 1ll * ans * i;
    st.insert(pos[i]);
  }
  cout << outans << endl;
  return 0;
}

Measured memory_bytes: 5760
#include <cstdio>
#include <vector>

using namespace std;

int d[2][100000];
vector <int> v[100000];

void dfs(int x, int y, int z, int w) {
    int i;
    
    d[w][x] = z;
    
    for (i = 0; i < v[x].size(); i++) {
        if (v[x][i] == y) continue;
        
        dfs(v[x][i], x, z + 1, w);
    }
}

int main() {
    int n, c1 = 0, c2 = 0, i;
    
    scanf("%d", &n);
    
    for (i = 0; i < n - 1; i++) {
        int x, y;
        
        scanf("%d %d", &x, &y);
        
        x--;
        y--;
        
        v[x].push_back(y);
        v[y].push_back(x);
    }
    
    dfs(0, -1, 0, 0);
    dfs(n - 1, -1, 0, 1);
    
    for (i = 0; i < n; i++) {
        if (d[0][i] <= d[1][i]) {
            c1++;
        } else {
            c2++;
        }
    }
    
    if (c1 > c2) {
        puts("Fennec");
    } else {
        puts("Snuke");
    }
    
    return 0;
}


Measured memory_bytes: 14336
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,m = li()

MOD = 10**9 + 7

from collections import Counter

def factorize(n: int):
    d = Counter()
    m = 2

    while m * m <= n:
        while n % m == 0:
            n //= m
            d[m] += 1

        m += 1

    if n > 1:
        d[n] += 1

    return d

# nの逆元のリスト
def inv_mod(n:int, mod:int) -> list:
    inv = [0,1]
    for i in range(2,n+1):
        inv.append(mod - ((mod//i)*inv[mod%i]) % mod)
    return inv

# nの階乗のリスト
def fact(n: int, mod: int) -> list:
    fac = [1, 1]
    res = 1
    for i in range(2, n + 1):
        res = res * i % mod
        fac.append(res)
    return fac


# nの階乗の逆元のリスト
def fact_inv(n: int, inv: list, mod: int) -> list:
    facInv = [1, 1]
    for i in range(2, n + 1):
        facInv.append(facInv[i - 1] * inv[i] % mod)
    return facInv


# 二項係数
def nCr(n: int, r: int, mod: int, fac: list, facInv: list) -> int:
    if not (0 <= r and r <= n):
        return 0

    return ((fac[n] * facInv[r]) % mod) * facInv[n - r] % mod


inv = inv_mod(n+100, MOD)
fac = fact(n+100, MOD)
fac_inv = fact_inv(n+100, inv, MOD)

divs = factorize(m)
ans = 1

for _, vals in divs.items():
    ans *= nCr(vals+n-1, vals, MOD, fac, fac_inv)
    ans %= MOD

print(ans)

Measured memory_bytes: 46920
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    vint s(n);
    rep(i, n) cin >> s[i];

    int sum = accumulate(all(s), 0);
    if (sum%10 != 0) {
        cout << sum << endl;
        return 0;
    }
    sort(all(s));
    rep(i, n) {
        int tmp = sum - s[i];
        if (tmp%10 != 0) {
            cout << tmp << endl;
            return 0;
        }
    }
    puts("0");
    return 0;
}

Measured memory_bytes: 256
/**
 * Queue
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_B&lang=ja
 */

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

struct Process {
  string name;
  int time;
};

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

  // プロセスの格納
  queue <Process>queues;
  for (int i = 0; i < N; i++) {
    Process p = Process();
    cin >> p.name >> p.time;
    queues.push(p);
  }

  int time = 0;
  // プロセスが残っている間は続ける
  while (queues.size() > 0) {
    // キューからプロセスをひとつ取り出す
    Process p = queues.front();
    queues.pop();

    if (p.time > q) {
      // qmsをプロセスで消費させて、キューの末尾で順番待ちさせる
      time += q;
      p.time -= q;
      queues.push(p);
    } else {
      time += p.time;
      cout << p.name << ' ' << time << endl;
    }
  }

  return 0;
}



Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, d, a;
  cin >> N >> K;
  
  int s[N], cnt = 0;
  
  for (int i = 0; i < K; i++){
    cin >> d;
    for(int j = 0; j < d; j++){
	  cin >> a;
      s[a-1] = 1;
    }
  }
  
  for (int i = 0; i < N; i++){
    if(s[i] != 1){
      cnt++;
    }
  }
  cout << cnt;

}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<set>
#include<string>
#include<iomanip>
#include<math.h>
#include<bitset>
#include<functional>
#include<map>
using namespace std;
typedef long long ll;
#define lscan(x) scanf("%I64d",&x);
#define lprint(x) printf("%I64d",x);
ll gcd(ll a, ll b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
long long extGCD(long long a, long long b, long long &x, long long &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a%b, y, x);
	y -= a / b * x;
	return d;
}
struct UnionFind {
	vector<int> par;

	UnionFind(int N) : par(N) {
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) {
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		if (rx == ry) return;
		par[rx] = ry;
	}

	bool same(int x, int y) {
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};

ll M = 1000000007;

vector<ll> fac(1000001); //n!(mod M)
vector<ll> ifac(1000001); //k!^{M-2} (mod M)

ll mpow(ll x, ll n) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}
ll mpow2(ll x, ll n, ll mod) {
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}
void setcomb() {
	fac[0] = 1;
	ifac[0] = 1;
	for (ll i = 0; i < 1000000; i++) {
		fac[i + 1] = fac[i] * (i + 1) % M; // n!(mod M)
	}
	ifac[1000000] = mpow(fac[1000000], M - 2);
	for (ll i = 1000000; i > 0; i--) {
		ifac[i - 1] = ifac[i] * i%M;
	}
}
ll comb(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
ll perm(ll a, ll b) {
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	return fac[a] * ifac[a - b] % M;
}
long long modinv(long long a) {
	long long b = M, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= M;
	if (u < 0) u += M;
	return u;
}

vector<vector<ll>> li(222222);
int main() {
	char s[111],t[111];
  cin>>s>>t;
  cout<<t<<s<<endl;
}


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

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

  int K, X;
  cin >> K >> X;
  string ans = "No";
  if (K * 500 >= X) ans = "Yes";
  cout << ans << '\n';
  return 0;
}

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
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; }

template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }


struct UnionFind {
    vector<int> par;
    vector<bool> is_namori;
    
    UnionFind(int n) : par(n, -1), is_namori(n, 0) {}
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    void set_namori(int x) { is_namori[root(x)] = true; }
    bool get_namori(int x) { return is_namori[root(x)]; }

    int size(int x) {
        return -par[root(x)];
    }
};

ostream& operator << (ostream& s, UnionFind uf) {
    map<int, vector<int> > res;
    for (int i = 0; i < uf.par.size(); ++i) {
        int r = uf.root(i);
        res[r].push_back(i);
    }
    for (map<int, vector<int> >::iterator it = res.begin(); it != res.end(); ++it) {
        s << endl;
        for (int j = 0; j < (int)it->second.size(); ++j) {
            s << it->second[j] << ", ";
        }
    }
    return s << endl;
}

using pint = pair<int,int>;
using Edge = pair<long long, pint>;

int main() {
    int N, H, W; cin >> N >> H >> W;
    vector<Edge> edges;
    for (int i = 0; i < N; ++i) {
        int r, c, a; cin >> r >> c >> a; --r, --c;
        c += H;
        edges.push_back(Edge(a, pint(r, c)));
    }
    sort(edges.begin(), edges.end(), greater<Edge>());

    UnionFind uf(H + W);
    long long res = 0;
    for (auto e : edges) {
        int u = e.second.first;
        int v = e.second.second;
        long long w = e.first;

        // u と v が同じ連結成分の場合は、ツリーなら OK、なもりは NG
        if (uf.issame(u, v)) {
            // なもり
            if (uf.get_namori(u)) continue;

            // ツリー
            else {
                uf.set_namori(u);
                res += w;
            }
        }
        // u と v が同じ連結成分でない場合は、両方がなもりはダメ
        else {
            if (uf.get_namori(u) && uf.get_namori(v)) continue;
            else if (uf.get_namori(u) || uf.get_namori(v)) {
                uf.merge(u, v);
                uf.set_namori(u);
                res += w;
            }
            else {
                uf.merge(u, v);
                res += w;
            }
        }
    }   
    cout << res << endl;
}


Measured memory_bytes: 2672
fun main(args: Array<String>) {
    var (n, k) = readLine()!!.split(" ").map{it.toInt()}
    var nmin = 0L
    var nmax = 0L
    for (i in 0..k-2) {
        nmin += i
        nmax += n-i
    }
    var ans = 0L
    for (i in k-1..n) {
        nmin += i
        nmax += n-i
        ans += nmax - nmin + 1
        ans %= 1_000_000_000 + 7
    }
    println(ans)
}


Measured memory_bytes: 36428
import numpy as np

N = int(input())
Stu = list(input().split())
Stu2 = [int(i) for i in Stu]

x = np.argsort(Stu2)
for i in range(N):
    Stu[i] = x[i] + 1

print(' '.join(map(str, Stu)))


Measured memory_bytes: 27476
#include<bits/stdc++.h>
#include <vector>
#include <iostream>
#include <cmath>
#include <math.h>
#include <string>
using namespace std;
const int MAX = 1000001; 
  
// array to store prime factors 
int factor[MAX] = { 0 }; 
  
// function to generate all prime factors 
// of numbers from 1 to 10^6 
void generatePrimeFactors() 
{ 
    factor[1] = 1; 
  
    // Initializes all the positions with their value. 
    for (int i = 2; i < MAX; i++) 
        factor[i] = i; 
  
    // Initializes all multiples of 2 with 2 
    for (int i = 4; i < MAX; i += 2) 
        factor[i] = 2; 
  
    // A modified version of Sieve of Eratosthenes to 
    // store the smallest prime factor that divides 
    // every number. 
    for (int i = 3; i * i < MAX; i++) { 
        // check if it has no prime factor. 
        if (factor[i] == i) { 
            // Initializes of j starting from i*i 
            for (int j = i * i; j < MAX; j += i) { 
                // if it has no prime factor before, then 
                // stores the smallest prime divisor 
                if (factor[j] == j) 
                    factor[j] = i; 
            } 
        } 
    } 
} 
int calculateNoOFactors(int n) 
{ 
    if (n == 1) 
        return 1; 
  
    int ans = 1; 
  
    // stores the smallest prime number 
    // that divides n 
    int dup = factor[n]; 
  
    // stores the count of number of times 
    // a prime number divides n. 
    int c = 1; 
  
    // reduces to the next number after prime 
    // factorization of n 
    int j = n / factor[n]; 
  
    // false when prime factorization is done 
    while (j != 1) { 
        // if the same prime number is dividing n, 
        // then we increase the count 
        if (factor[j] == dup) 
            c += 1; 
  
        /* if its a new prime factor that is factorizing n,  
           then we again set c=1 and change dup to the new  
           prime factor, and apply the formula explained  
           above. */
        else { 
            dup = factor[j]; 
            ans = ans * (c + 1); 
            c = 1; 
        } 
  
        // prime factorizes a number 
        j = j / factor[j]; 
    } 
  
    // for the last prime factor 
    ans = ans * (c + 1); 
  
    return ans; 
} 
int main() 
{ 
    // generate prime factors of number 
    // upto 10^6 
    generatePrimeFactors(); 
  
    int n;
    cin>>n; 
    long long int s=0;
  
    for (int i = 2; i < n; i++) 
        s+= (calculateNoOFactors(i)/1) ; 
        s++;
        cout<<s<<endl;
  
    return 0; 
} 

Measured memory_bytes: 7540
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	vector<int> v(n);
	int f=1,var=0;
	map<int,int> mp;
	FOR(i,0,n){
		cin>>v[i];
		if(v[i]!=0)f=0;
		if(mp[v[i]]==0)var++;
		mp[v[i]]++;
	}
	if(f){
		cout<<"Yes"<<endl;
		return 0;
	}
	if(mp[0]!=0){
		if(var!=2){
			cout<<"No"<<endl;
			return 0;
		}else{
			int t=0;
			for(auto x:mp){
				if(x.ST!=0)t=x.ST;
			}
			if(mp[t]==mp[0]*2){
				cout<<"Yes"<<endl;
			}else{
				cout<<"No"<<endl;
			}
			return 0;
		}
	}else{
		cerr<<"test"<<endl;
		if(var!=3){
			cout<<"No"<<endl;
			return 0;
		}else{
			cerr<<"test2"<<endl;

			int lst[3]={};
			int idx=0,t=0;
			for(auto x:mp){
				if(x.ST==0)continue;
				lst[idx]=x.ST;
				t=x.ND;
				idx++;
			}
			for(auto x:mp){
				if(x.ST!=0&&x.ND!=t){
					cout<<"No"<<endl;
					return 0;
				}
			}
			cerr<<"test2"<<endl;
			FOR(i,0,31){
				int cnt[2]={};
				FOR(j,0,3){
					int tt=lst[j];
					cnt[(tt>>i)&1]++;
				}
				if(cnt[1]==0||(cnt[0]*2==cnt[1])){

				}else{
					cout<<"No"<<endl;
					return 0;
				}
			}
			cout<<"Yes"<<endl;
		}
	}


	return 0;
}


Measured memory_bytes: 4224
#include<stdio.h>
#include<iostream>
#include<vector>

void swap( int &a, int &b )
{
 	int t;
	t = a;
	a = b;
	b = t;
	
	return;
}

int main()
{
	int w, n;
	int ans[30];
	std::vector<std::pair<int,int> > vec;
	
	scanf( "%d", &w );
	scanf( "%d", &n );
	for( int i = 0; i < n; i++ ){
		int a, b;
		scanf( "%d,%d", &a, &b );
		vec.push_back( std::make_pair<int,int>( a, b ) );
	}
	
	for( int i = 0; i < w; i++ ) ans[i] = i + 1;
	
	for( std::vector<std::pair<int,int> >::iterator it = vec.begin(); it != vec.end(); it++ ){
		swap( ans[ it->first - 1 ], ans[ it->second - 1 ] );	
	}
	
	for( int i = 0; i < w; i++ ){
	 	std::cout << ans[i] << std::endl;
	}

 	return 0;
}

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

// to increase precision
// std::cout<<std::fixed;
// 	std::cout<<std::setprecision(6)<<z;
//clock_t tStart = clock();
//printf("Time taken: %.9fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define maxn 100007

#define ll long long int

ll mod=998244353;
int main(){
	int n;
	cin>>n;
	if(n%1000)
	cout<<1000-n%1000;
else
	cout<<0<<endl;
}

Measured memory_bytes: 3596
program atcoder
    implicit none
    integer(8) :: i,j,k,n
    integer(8),allocatable,dimension(:,:) :: dp
    integer(8),allocatable,dimension(:) :: a,sum
    read*,n
    allocate(dp(0:n,0:n))
    allocate(a(0:n))
    allocate(sum(0:n))

    ! dp(i,j) := i番目のスライムからj番目のスライムを合体させるための最小コスト
    dp = lshift( 1_8, 50 ) ! // 最小を求めたいので、初期値は大きい値にしておく
    sum = 0_8
    a = 0_8
    read(*,*)(a(i),i=1,n) ! スライムの大きさを受け取る
    do i=1,n
        sum(i) = sum(i-1) + a(i) ! 累積和を計算しておく -> 合体のコストを高速に計算するため
        dp(i,i) = 0_8 ! i==jではスライムが1体しかいないので合体コストは0,この情報からどのようにループをすればいいか考える
        ! 1体の次は2体の結合、次は3体の結合...と求められそう
        !    -> 考える区間が大きくなっていく
    enddo
    
    do i = 1,n ! i := 幅 -> 区間の幅が小さいものから決まっていくから
        do j = 1,n-i ! j := 左端 -> [j,j+i]の区間を考える
            do k = j,j+i-1 ! [j,k]と[k+1,j]の合体を考える , それぞれ今考えている区間の長さより短いので計算済みである
                dp(j,j+i) = min(dp(j,j+i) , dp(j,k)+dp(k+1,j+i)+sum(j+i)-sum(j-1))
                ! [i,j+i]のコストは[i,k],[k+1,j+i]にそれぞれかかったコストと今回かかるコストの和
                ! それぞれのkでminを取る
            enddo
        enddo
    enddo
    write(*,'(I0)')dp(1,n)

    stop 
contains
end program atcoder


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
ll loop(ll h){
    if(h==1) return 1;
    ll x=2*loop(h/2)+1;
    return x;
}
int main() {
    ll h,cnt; cin>>h;
    cnt=loop(h);
    cout<<cnt;
}

Measured memory_bytes: 3632
use proconio::input;
use proconio::marker::{Chars, Usize1};
use std::iter::Iterator;
use std::collections::*;
use std::cmp::*;
use itertools::Itertools;

#[allow(unused_macros)]
macro_rules! max {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      max($x,max!($($xs)+))
    };
  }
  
  #[allow(unused_macros)]
  macro_rules! min {
    ($x:expr) => {
      $x
    };
    ($x:expr, $($xs:tt)+) => {
      min($x,min!($($xs)+))
    };
  }

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    input! {
    l: i64,
    r: i64,
    d: i64,
    }

    let mut cnt = 0;

    for i in l..=r {
      if i % d == 0 {
        cnt += 1;
      }
    }

     println!("{}", cnt);
}


Measured memory_bytes: 2136
#include<iostream>
using namespace std;
int main()
{
	int cost,change;
	int sum;
	int a,b,c,d,e,f;
	while(cin >>cost){
		if(cost==0) break;
		change=1000-cost;

		a=change%500%100%50%10%5;
		b=(change%500%100%50%10-a)/5;
		c=(change%500%100%50-a-5*b)/10;
		d=(change%500%100-a-5*b)/50;
		e=(change%500-a-5*b-10*c-50*d)/100;
		f=(change-a-5*b-10*c-50*d-100*e)/500;

		sum=a+b+c+d+e+f;
		cout <<sum<< endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
#define INF32 1'050'000'000
#define INF64 4'000'000'000'000'000'000
using ll = long long;
using namespace std;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

class Warshall_floyd {
  private:
    int vertex;
    const int INF = 1'050'000'000;
    vector<vector<int>> cost;

  public:
    Warshall_floyd(int N) {
        vertex = N;
        cost.resize(N, vector<int>(N, INF));
        for (int i = 0; i < vertex; i++) {
            cost[i][i] = 0;
        }
    }
    void update(int x, int y, int weight) {
        cost[x][y] = weight;
        cost[y][x] = weight;
    }
    void calc() {
        for (int k = 0; k < vertex; k++) {
            for (int i = 0; i < vertex; i++) {
                for (int j = 0; j < vertex; j++) {
                    cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
                }
            }
        }
    }
    int dist(int x, int y) { return cost[x][y]; }
};

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

    int N, M;
    cin >> N >> M;
    auto wf = Warshall_floyd(N);
    vector<int> a(M), b(M), c(M);
    REP(i, M) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--;
        b[i]--;
        wf.update(a[i], b[i], c[i]);
    }
    wf.calc();
    int ans = 0;
    REP(i, M) {
        if (wf.dist(a[i], b[i]) != c[i])
            ans++;
    }
    std::cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    priority_queue<int> pq;
    
    for(int i=0;i<10;i++){
        int x;cin>>x;
        pq.push(x);
    }
    
    for(int i=0;i<3;i++){
        cout<<pq.top()<<endl;pq.pop();
    }
}


Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c;
int main()
{
	cin>>n;
	a=n%10;
	b=n/100;
	c=n/10%10;
	if(a==7||b==7||c==7)cout<<"Yes";
	else cout<<"No";
    return 0;
}

Measured memory_bytes: 3640
import java.util.*;
import java.util.Map.Entry;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int C = Integer.parseInt(sc.next());
        int[][] D = new int[C][C];
        int[][] c = new int[N][N];
        for (int i=0;i<C;i++) {
            for (int j=0;j<C;j++) {
                D[i][j] = Integer.parseInt(sc.next());
            }
        }
        for (int i=0;i<N;i++) {
            for (int j=0;j<N;j++) {
                c[i][j] = Integer.parseInt(sc.next());
            }
        }

        ArrayList<HashMap<Integer, Integer>> map_list = new ArrayList<HashMap<Integer, Integer>>();
        for (int i=0;i<3;i++) {
            HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
            for (int j=0;j<N;j++) {
                for (int k=0;k<N;k++) {
                    if ((j+k)%3==i) {
                        if (!map.containsKey(c[j][k])) {
                            map.put(c[j][k], 1);
                        } else {
                            map.put(c[j][k], map.get(c[j][k])+1);
                        }
                    }
                }
            }
            map_list.add(map);
        }

        long ans = Integer.MAX_VALUE;
        for (int i=0;i<C;i++) {
            for (int j=0;j<C;j++) {
                for (int k=0;k<C;k++) {
                    if (i==j || i==k || j==k) {
                        continue;
                    }
                    // System.out.println("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
                    long tmp = 0L;
                    for (int l=0;l<3;l++) {
                        for (Entry<Integer, Integer> entry : map_list.get(l).entrySet()) {
                            int key = entry.getKey();
                            int value = entry.getValue();
                            // System.out.println(entry.getKey() + " " + entry.getValue());
                            int index;
                            if (l==0) {
                                index = i;
                            } else if (l==1) {
                                index = j;
                            } else {
                                index = k;
                            }
                            tmp += value*D[key-1][index];
                            // System.out.println("value index key-1 " + value + " " + index + " " + (key-1));
                        }
                    }
                    ans = Math.min(ans, tmp);
                }
            }
        }
        // System.out.println(map_list);
        System.out.println(ans);
    }
}

Measured memory_bytes: 63452
#include<iostream>
#include<queue>

using namespace  std;

int main() {
	queue<pair<string, int> > que;
	int n, q,time;
	string name;
	cin >> n >> q;
	for (int i = 0;i < n;i++) {
		cin >> name >> time;
		que.push(make_pair(name, time));
	}
	int count = 0;
	while (!que.empty()) {
		time = (que.front()).second;
		if (time <= q) {
			count += time;
			cout << que.front().first << " " << count << endl;
		}
		else {
			count += q;
			que.push(make_pair(que.front().first, que.front().second - q));
		}
		que.pop();
	}
}


Measured memory_bytes: 6324
#include <stdio.h>
#include <iostream>
#include <algorithm>
using namespace std;

int main() {

	for(int i = 1; i <= 9; i++) {
		for(int j = 1; j <= 9; j++) {
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
	
    return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    
    // 入力処理
    ll h, w; cin >> h >> w;
    vvi a(h, vi(w, 0));

    // 入力処理＋移動処理
    vi y, x, yd, xd;
    rep(i, h) rep(j, w){
        // 入力値を受け付けて、移動値と合算する
        ll in; cin >> in;
        a[i][j] += in;

        // 入力値＋移動値が偶数なら移動操作は不要なので移動処理を飛ばす
        if(a[i][j]%2 == 0) continue;
        
        // 入力値＋移動値が奇数の場合はまず右に動かせるか確認する
        if(j != w-1){
            // 現在位置から-1し右に+1する
            a[i][j]--; a[i][j+1]++;
            // 移動結果を1-Basedで記録する
            y.push_back(i+1); x.push_back(j+1);
            yd.push_back(i+1); xd.push_back(j+2);
        }

        // 右に動かせない場合は下に動かせるか確認する
        else if(i != h-1){
            // 現在位置から-1し下に+1する
            a[i][j]--; a[i+1][j]++;
            // 移動結果を1-Basedで記録する
            y.push_back(i+1); x.push_back(j+1);
            yd.push_back(i+2); xd.push_back(j+1);
        }
    }

    // 出力処理
    cout << y.size() << endl;
    rep(i, y.size()) cout << y[i] << " " << x[i] << " " << yd[i] << " " << xd[i] << endl;
}

Measured memory_bytes: 8148
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int p[100005];
ll w;

int root(int x) {
    return p[x] < 0 ? x : p[x] = root(p[x]);
}

void mer(int x, int y) {
    if ((x = root(x)) == (y = root(y))) return;
    if (p[x] > p[y]) swap(x, y);
    ll a = -p[x], b = -p[y];
    w -= a * a;
    w -= b * b;
    w += (a + b) * (a + b);
    p[x] += p[y];
    p[y] = x;
}

int main() {
    ios::sync_with_stdio(false);
    int n, m, u[100005] = {}, v[100005] = {};
    ll z[100005] = {};
    cin >> n >> m;
    for (int i = 1; i <= n; i++) p[i] = -1;
    w = n;
    for (int i = 1; i <= m; i++) cin >> u[i] >> v[i];
    for (int i = m; i; i--) {
        z[i] = w;
        mer(u[i], v[i]);
    }
    for (int i = 1; i <= m; i++) cout << (1ll * n * n - z[i]) / 2 << ' ';
}


Measured memory_bytes: 3328
s = gets.split
h = Hash.new
h.default = 0
s.each do |i|
  h[i] += 1
end
k = h.to_a.sort{|a, b| b[1] <=> a[1]}
l = h.sort{|a, b| b[0].length <=> a[0].length}
puts "#{k[0][0]} #{l[0][0]}"

Measured memory_bytes: 6104
import math
import collections
import fractions
import itertools
import functools
import  operator

def solve():
    n = int(input())
    s = ["".join(sorted(input())) for _ in range(n)]
    cnt = 0
    past = {}
    for i in range(n):
        si = s[i]
        if si in past:
            past[si] += 1
        else:
            past[si] = 1
    for i in past.values():
        cnt += i*(i-1)//2
    print(cnt)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 114388
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin>>s>>t;
  for (int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i)){
    cout<<"No"<<endl;
    break;
  }
  if(i==(s.size()-1)) cout<<"Yes"<<endl;
  }
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF 1e9+7
#define LLINF 1e18
// #define int ll
using namespace std;
const int MOD = 1e9 +7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,m,l[100010],r[100010],a=-INF,b=INF;
    cin>>n>>m;
    rep(i,m) cin>>l[i]>>r[i];
    rep(i,m){
        a=max(a,l[i]);
        b=min(b,r[i]);
    }
    if(b>=a){
        cout<<b-a+1<<endl;
    }
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<Integer>();

        int n = sc.nextInt();
        for (int i=1; i<=n; i++) {
            int x = i;
            if (x % 3 == 0) {
                System.out.print(" ");
                System.out.print(x);
            }
            else {
                while (x != 0) {
                    if (x % 10 == 3) {
                        System.out.print(" ");
                        System.out.print(i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        System.out.println();
    }
}


Measured memory_bytes: 32764
#include <iostream>
#include <queue>
#include <vector>
using namespace std;
int w,h;
char map[200][200];
class Node{
public:
	int x,y;
	int c;
	Node(int _x,int _y,int _c):x(_x),y(_y),c(_c){

	}
};
void show(){
	for(int i=0;i<h*2-1;i++){
		for(int j=0;j<w*2-1;j++)cout<<map[i][j];
		cout<<endl;
	}
	cout<<endl;
}
bool visited[200][200];
int dx[]={1,0,-1,0};
int dy[]={0,-1,0,1};
int bfs(){
	for(int i=0;i<100;i++)fill(visited[i],visited[i]+100,false);
	queue<Node> q;
	q.push(Node(0,0,1));
	visited[0][0]=true;
	int gw=2*w-2;
	int gh=2*h-2;
	while(!q.empty()){
		Node cur=q.front();q.pop();
//		cout<<"("<<cur.x<<","<<cur.y<<")"<<endl;
		map[cur.y][cur.x]='1';
//		show();
		if(cur.x==gw&&cur.y==gh)return cur.c;
		for(int i=0;i<4;i++){
			int nx=cur.x+dx[i];
			int ny=cur.y+dy[i];
//			cout<<"next("<<nx<<","<<ny<<")"<<endl;
			if(nx<0||ny<0||nx>gw||ny>gh||map[ny][nx]=='1')continue;
			nx=nx+dx[i];
			ny=ny+dy[i];
			if(nx<0||ny<0||nx>gw||ny>gh||map[ny][nx]=='1')continue;
//			map[ny+dy[i]][nx+dx[i]]=='1')continue;
			if(visited[ny][nx])continue;
			visited[ny][nx]=true;
			q.push(Node(nx,ny,cur.c+1));
		}
	}
	return 0;
}
void solve(){
	cout<<bfs()<<endl;
}
int main(){
	while(cin>>w>>h&&(w||h)){
		for(int i=0;i<100;i++)for(int j=0;j<100;j++)map[i][j]='0';
		int hline=h*2-1;
		for(int i=0;i<hline;i++){
			if(i%2){
				for(int j=0;j<w;j++)cin>>map[i][2*j];
			}
			else {
				for(int j=0;j<w-1;j++)cin>>map[i][1+2*j];

			}
		}
//		show();
		solve();
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main() {
	fast;
	ll t;
	cin>>t;
	string s="";
	while(t--)
		s+="ACL";
	cout<<s;
	return 0;
}

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

using namespace std;

int n, dx[100005], dy[100005];
pair <int, int> a[100005];
char s[5];

double solve(double t) {
	double xmx = -1e18;
	double xmn = 1e18;
	double ymx = -1e18;
	double ymn = 1e18;
	
	for (int i = 0; i < n; i++) {
		double x = t * dx[i] + a[i].first;
		double y = t * dy[i] + a[i].second;
		xmx = max(xmx, x);
		xmn = min(xmn, x);
		ymx = max(ymx, y);
		ymn = min(ymn, y);
	}
	
	return (xmx - xmn) * (ymx - ymn);
}

int main() {
	scanf("%d", &n);
	
	for (int i = 0; i < n; i++) {
		scanf("%d%d%s", &a[i].first, &a[i].second, s);
		if (s[0] == 'U') dy[i] = 1;
		else if (s[0] == 'D') dy[i] = -1;
		else if (s[0] == 'L') dx[i] = -1;
		else dx[i] = 1;
	}
	
	double lb = 0.0;
	double ub = 1e9;
	double res = 1e18;
	
	for (int i = 0; i < 200; i++) {
		double lmid = (lb * 2 + ub) / 3;
		double rmid = (lb + ub * 2) / 3;
		double lv = solve(lmid);
		double rv = solve(rmid);
		
		res = min(res, lv);
		res = min(res, rv);
		
		if (lv < rv) ub = rmid;
		else lb = lmid;
	}
	
	printf("%.12lf\n", res);
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <cstdio>
#include <ctime>
#include <assert.h>
#include <chrono>
#include <random>
#include <numeric>
#include <set>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;

// 1-indexed
template<typename T>
struct BIT{
    int n;
    vector<T> bit;
    BIT(int n_=0):n(n_),bit(n+1){}
    T sum(int i){
        T res=0;
        for(;i>0;i-=(i&-i))res+=bit[i];
        return res;
    }
    void add(int i,T a){
        if(i==0)return;
        for(;i<=n;i+=(i&-i)){bit[i]+=a;}
    }
    int lower_bound(T k){ // k<=sum(res)
        if(k<=0)return 0;
        int res=0,i=1;
        while((i<<1)<=n)i<<=1;
        for(;i;i>>=1){
            if(res+i<=n&&bit[res+i]<k)k-=bit[res+=i];
        }
        return res+1;
    }
};

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,k; cin >> n >> k;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i]-=k;
    }
    vector<ll> sum(n+1);
    for(int i=0;i<n;i++){
        sum[i+1]=sum[i]+a[i];
    }
    vector<ll> v;
    for(int i=0;i<=n;i++){
        v.push_back(sum[i]);
    }
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()),v.end());
    for(int i=0;i<=n;i++){
        sum[i]=lower_bound(v.begin(), v.end(),sum[i])-v.begin()+1;
    }
    ll res=0;
    BIT<int> bit(n+2);
    for(int i=0;i<=n;i++){
        res+=bit.sum(sum[i]);
        bit.add(sum[i],1);
    }
    cout << res << endl;
}


Measured memory_bytes: 7920
#include <iostream>

using namespace std;

int main ()
{
    int A[5];
    for(int i=0;i<5;i++)
    {
        cin>>A[i];
    }
    int k;
    cin>>k;
    bool t=true;
    for(int i=0;i<4;i++)
    {
        for(int j=i+1;j<5;j++)
        {
            if(A[j]-A[i]>k)
            {
                t=false;
            }
        }
    }
    if(t==false)
        cout<<":("<<endl;
    else
        cout<<"Yay!"<<endl;
    return 0;
}


Measured memory_bytes: 256