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

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


// std::vector Declaration
template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
   return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

// std::vector Initialization
template<typename T>
void fill_all(T& arr, const T& v) { arr = v; }
template<typename T, typename U>
void fill_all(T& arr, const U& v) { for (auto& i : arr) fill_all(i, v); }

// std::vector Debug
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
   os << "[";
   bool a = 1;
   for (auto e : v ) {
      os << (a ? "" : " "); 
      os << e;
      a = 0;
   }
   os << "]";
   return os;
}

// std::pair Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
   os << "(" << p.first << " " << p.second << ")";
   return os;
}

// std::set Debug
template<typename T>
ostream& operator<<(ostream& os, const set<T>& st) {
   os << "{";
   bool a = 1;
   for (auto e : st) {
      os << (a ? "" : " ");
      os << e;
      a = 0;
   }
   os << "}";
   return os;
}

// std::map Debug
template<typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& mp) {
   os << "{";
   bool a = 1;
   for (auto e : mp) {
      os << (a ? "" : " ");
      os << e.first << ":" << e.second;
      a = 0;
   }
   os << "}";
   return os;
}

// std::tuple Debug
template<int N,class Tuple>
void out(ostream &os,const Tuple &t){}
template<int N,class Tuple,class H,class ...Ts>
void out(ostream &os,const Tuple &t){
   if(N)os<<" ";
   os<<get<N>(t);
   out<N+1,Tuple,Ts...>(os,t);
}
template<class ...Ts>
ostream& operator<<(ostream &os, const tuple<Ts...> &t){
   os<<"(";
   out<0,tuple<Ts...>,Ts...>(os,t);
   os<<")";
   return os;
}

// Debug
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl

struct edge { int to, cost; };

const LL LINF = 1LL<<60;
const int IINF = 1<<30;
const LL MOD = 1e9+7;

int main()
{
   int r, g, b, n; cin >> r >> g >> b >> n;
   int sum = 0;
   for (int i = 0; r*i <= n; ++i) {
      for (int j = 0; r*i + g*j <= n; ++j) {
         if ((n - (r*i + g*j)) % b == 0) {
            ++sum;
         }
      }
   }
   cout << sum << endl;

   return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

int pow(int x,int n){
	int res = 1;
	for(int i = 0; i < n; i++) res *= x;
	return res;
}

int main(){
	int n;
	cin >> n;
	vector<int> dp(100010,INF),num6,num9;
	num6.emplace_back(0),num9.emplace_back(0);
	for(int i = 1; pow(6,i) < 100010; i++) num6.emplace_back(pow(6,i));
	for(int i = 1; pow(9,i) < 100010; i++) num9.emplace_back(pow(9,i));
	dp[0] = 0;
	for(int i = 0; i < 100010; i++){
		if(dp[i] != INF){
			for(int j = 0; j < num6.size(); j++){
				if(i+num6[j] >= 100010) break;
				dp[i+num6[j]] = min(dp[i+num6[j]],dp[i]+1);
			}
			for(int j = 0; j < num9.size(); j++){
				if(i+num9[j] >= 100010) break;
				dp[i+num9[j]] = min(dp[i+num9[j]],dp[i]+1);
			}
		}
	}
	for(int i = 1; i <= n; i++) dp[i] = min(dp[i],dp[i-1]+1);
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 640
# 最大公約数
from collections import Counter


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def resolve():
    k = int(input())
    l = [None] * k ** 2
    for i in range(k):
        for j in range(k):
            l[i * k + j] = gcd(i + 1, j + 1)
    c = Counter(l)
    ans = 0
    for key, v in c.items():
        for i in range(k):
            ans += gcd(i + 1, key) * v
    print(ans)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9644
#include <bits/stdc++.h>
    using namespace std;
    
    int main(){
        char a , b;
        cin >> a >> b;
        if(a == 'H'){
            if(b == 'H'){
                cout << 'H' << endl;
            }else{
                cout << 'D' << endl;
            }
        }else{
            if(b == 'H'){
                cout << 'D' << endl;
            }else{
                cout << 'H' << endl;
            }
        }
        
        return 0;
    }

Measured memory_bytes: 256
def dfs(i, f, sum):
    if i == 3:
        if sum == 7:
            print(f + "=7")
            exit()
    
    else:
        dfs(i+1, f + "-" + s[i+1], sum - int(s[i+1]))
        dfs(i+1, f + "+" + s[i+1], sum + int(s[i+1]))


s = input()
dfs(0,s[0], int(s[0]))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	int a, b;
	while (cin >> a >> b, a)
	{
		vs p(a), q(b);
		REP(i, a) cin >> p[i];
		REP(i, b) cin >> q[i];
		vi dot(a), group[3];
		REP(i, 3) group[i].resize(a);
		REP(i, a)
		{
			REP(j, p[i].size())
			{
				if (p[i][j] != '.')
				{
					dot[i] = j;
					break;
				}
			}
		}
		REP(i, a)
		{
			if (i != 0)
			{
				REP(j, 3) group[j][i] = group[j][i - 1];
			}
			REP(j, p[i].size())
			{
				if (p[i][j] == '(') group[0][i]++;
				if (p[i][j] == ')') group[0][i]--;
				if (p[i][j] == '{') group[1][i]++;
				if (p[i][j] == '}') group[1][i]--;
				if (p[i][j] == '[') group[2][i]++;
				if (p[i][j] == ']') group[2][i]--;
			}
		}

		vi groupb[3];
		REP(i, 3) groupb[i].resize(b);
		REP(i, b)
		{
			if (i != 0)
			{
				REP(j, 3) groupb[j][i] = groupb[j][i - 1];
			}
			REP(j, q[i].size())
			{
				if (q[i][j] == '(') groupb[0][i]++;
				if (q[i][j] == ')') groupb[0][i]--;
				if (q[i][j] == '{') groupb[1][i]++;
				if (q[i][j] == '}') groupb[1][i]--;
				if (q[i][j] == '[') groupb[2][i]++;
				if (q[i][j] == ']') groupb[2][i]--;
			}
		}

		vector<set<int>> ans(b);

		FOR(i, 1, 21)FOR(j, 1, 21)FOR(k, 1, 21)
		{
			bool f = true;
			FOR(l, 1, a)
			{
				if (dot[l] != group[0][l - 1] * i + group[1][l - 1] * j + group[2][l - 1] * k) f = false;
			}
			if (f)
			{
				REP(l, b - 1)
				{
					int res = groupb[0][l] * i + groupb[1][l] * j + groupb[2][l] * k;
					ans[l].insert(res);
				}
			}
		}
		cout << 0 << " ";
		REP(i, ans.size()-1)
		{
			int res;
			if (ans[i].size() == 1) res = *ans[i].begin();
			else res = -1;
			cout << res << (i == ans.size() - 2 ? "\n" : " ");
		}

	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    ll a[n];
    rep(i,n) cin >> a[i];
    ll ans = 0;
    rep(i,n){
        ll c = a[i]/2;
        ans += c; a[i] -= c*2;
        if(i < n-1){
            ll b = min(a[i],a[i+1]);
            ans += b; a[i] -= b; a[i+1] -= b;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var n = Read();
        long a = Read();
        long b = Read();
        long c = Read();
        long d = Read();

        //   987654321098765432101234567890123456789
        //1 :                   |
        //2 :             -|         |-
        //3 :       --|        -|-        |--
        //4 : ---|       --|-       -|--       |--- 
        var diff = Abs(b - a);
        
        var cand1 = (diff + ((n + 1) % 2) * c) / (c * 2) * 2 - ((n + 1) % 2);
        var cand2 = cand1 + 2;
        var cand3 = n - 1;

        var cand1Margin = (((n - 1) + cand1) / 2);
        var cand2Margin = (n - 2) - cand1Margin;
        var cand3Margin = n - 1;
        Console.WriteLine(
            (cand1 <= (n - 1) && diff <= cand1 * c + cand1Margin * (d - c)) || 
            (cand2 <= (n - 1) && cand2 * c - cand2Margin * (d - c) <= diff) ||
            (cand3 * c <= diff && diff <= cand3 * c + cand3Margin * (d - c)) ? "YES" : "NO");
    }

    static readonly TextReader In = Console.In;
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    static int Read()
    {
        int res = 0;
        int next = In.Read();
        while (48 > next || next > 57) next = In.Read();
        while (48 <= next && next <= 57)
        {
            res = res * 10 + next - 48;
            next = In.Read();
        }
        return res;
    }
}


Measured memory_bytes: 13140
import math

def check_intersect(x1,y1,r1,x2,y2,r2):
    d = math.sqrt((x2-x1)**2 + (y2-y1)**2)    

    if d > r1+r2:
        print('0')
    elif d < math.sqrt((r1-r2)**2):
        if r1 > r2:
            print('2')
        else:print('-2')
    else:
        print('1')
        
n = int(input())
for i in range(n):
    x1,y1,r1,x2,y2,r2 = map(float,input().split())
    check_intersect(x1,y1,r1,x2,y2,r2)

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

class Card{
public:
	int f,t;

	Card(int from,int to){
		f = from;
		t = to;
	}
};

int n,m,p,q,r;
deque<Card> d;

deque<Card> removeCard(int x){
	deque<Card> res;

	while(1){
		Card tmp = d.front(); d.pop_front();
		x -= tmp.t - tmp.f + 1;

		if(x <= 0){
			if(x != 0){
				d.push_front(Card(tmp.t + x + 1, tmp.t));
				tmp.t += x;
			}
			res.push_back(tmp);
			break;
		}
		res.push_back(tmp);
	}
	return res;
}

void shuffle(int x,int y){
	deque<Card> A = removeCard(x);
	deque<Card> B = removeCard(y-x);
	for(int i=0;i<B.size();i++) d.push_back(B[i]);
	for(int i=0;i<A.size();i++) d.push_back(A[i]);
}

int main(void){
	while(cin>>n,n){
		cin>>m>>p>>q>>r;
		d.clear();
		d.push_back(Card(1,n));
		while(m--){
			int x,y;
			cin>>x>>y;
			shuffle(x,y);
		}

		int ans = 0;
		removeCard(p-1);
		deque<Card> rem = removeCard(q-p+1);
		for(int i=0;i<rem.size();i++){
			if(rem[i].f <= r) ans += r - rem[i].f - (rem[i].t < r ? r-rem[i].t : 0) + 1;
		}
		cout<<ans<<endl;
	}

	return 0;
}

Measured memory_bytes: 1008
h,w = map(int,input().split())
a = []
hh = 0
for _ in range(h):
  x = [xx for xx in input()]
  if x.count("#") > 0:
    a.append(x)
    hh += 1
b = []

count = 0
if hh > 1:
  wlist = []
  for i in range(w):
    for j in range(hh):
      b.append(a[j][i])
    if b.count("#") == 0:
      wlist.append(i)
    b = []
  for k in wlist:
    for l in range(hh):
      a[l].pop(k-count)
    count += 1
  for m in range(len(a)):
    print("".join(a[m]))
else:
  a = list(*a)
  ans = [aa for aa in a if aa == "#"]
  print("".join(ans))

Measured memory_bytes: 9240
#include<bits/stdc++.h>
using namespace std;
int main()
{

  long long int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++)
  {
    a[i] = 0;
  }
  for(int x=1;x<=sqrt(n);x++)
  {
    for(int y=1;y<=sqrt(n);y++)
    {
      for(int z=1;z<=sqrt(n);z++)
      {
        int temp = (x*x)+(y*y)+(z*z)+(x*y)+(y*z)+(z*x);
        temp--;
        if(temp < n)
          a[temp]++;
      }
    }
  }
  for(int i=0;i<n;i++)
  {
    cout << a[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3532
#include <iostream>
#include <vector>
#include <set>
#include <functional>
template <typename T>
struct Line
{
    T a, b;  // (a,b) <=> f(x)=ax+b
    bool query;
    mutable const Line* next = nullptr;
    bool operator<(const Line& l) const
    {
        if (not l.query) { return a > l.a; }
        if (not next) { return false; }
        return next->b - b < (a - next->a) * l.a;
    }
};
template <typename T>
class DynamicCHT : public std::multiset<Line<T>>
{
    bool needless(const typename DynamicCHT<T>::iterator y) const
    {
        const auto z = std::next(y);
        if (y == this->begin()) { return z != this->end() and y->a == z->a and y->b >= z->b; }
        const auto x = std::prev(y);
        return z == this->end() ? y->a == x->a and y->b >= x->b : (x->b - y->b) * (z->a - y->a) >= (y->b - z->b) * (y->a - x->a);
    }

public:
    void add(const T a, const T b)
    {
        auto y = this->insert({a, b, false});
        if (needless(y)) { return (void)this->erase(y); }
        auto z = std::next(y);
        while (z != this->end() and needless(z)) { z = this->erase(z); }
        if (z != this->end()) { y->next = &*z; }
        while (y != this->begin() and needless(z = std::prev(y))) { this->erase(z); }
        if (y != this->begin()) { z->next = &*y; }
    }
    T query(const T x) const
    {
        const auto l = *this->lower_bound(Line<T>{x, 0, true});
        return l.a * x + l.b;
    }
};
using ll = long long;
int main()
{
    std::size_t N;
    ll C;
    std::cin >> N >> C;
    std::vector<ll> h(N), dp(N);
    for (std::size_t i = 0; i < N; i++) { std::cin >> h[i]; }
    DynamicCHT<ll> cht;
    cht.add(-2 * h[0], dp[0] + h[0] * h[0]);
    for (std::size_t i = 0; i < N; i++) {
        dp[i] = cht.query(h[i]) + h[i] * h[i] + C;
        cht.add(-2 * h[i], dp[i] + h[i] * h[i]);
    }
    std::cout << dp[N - 1] << std::endl;
    return 0;
}


Measured memory_bytes: 18944
#include <bits/stdc++.h>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

typedef long long ll;

ll ans = LLONG_MAX;

void relax (ll a, ll b) {
  // by - ax = 1
  ll r = b - inv_mod(a % b, b);
  assert(r);
  ans = min(ans, a * r);
}

int main() {
  ll n; cin >> n; n <<= 1;
  for (ll i = 1; i * i <= n; ++i) {
    if (n % i) continue;
    ll j = n / i;
    if (__gcd(i, j) == 1) {
      relax(i, j); relax(j, i);
    }
  }
  cout << ans << '\n';
  return 0;
}



Measured memory_bytes: 3660
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}

ll grp[200010];
int vis[200010];

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

    int n,k;
    cin>>n>>k;

    for(int i=1;i<=n;i++){
        grp[i%k]++;
    }
    ll ans=0;
    for(int j=1;j<=n;j++){
        int i=j%k;
        if(vis[i]) continue;
        int b=((k-i)%k+k)%k;
        int c=b;
        //cout<<i<<" "<<b<<" "<<c<<"\n";
        if((b+c)%k==0){
            ans+=(grp[i]*grp[b]*grp[c]);
        }
        //cout<<ans<<"\n";
        vis[i]=1;
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
 
using namespace std;
 
template< class t>
long long int gcd( t g,t h )
{
    return ( h==0 ? g : gcd(h,g%h) );
}
 
 
struct Comp {
  bool operator()(const std::pair<int, int> &a, const std::pair<int, int> &b) {
    if (a.first != b.first) {
      return a.first < b.first;
    }
    return a.second > b.second;
  }
 
}comp_functor;

 
int main() 
{
    ios_base::sync_with_stdio(false) ; cin.tie(0) ;
    
    long long int i,j,t,n,l,c=0,q,ans=0,a[200005]={0},f=0,x,temp,h[200005]={0};
    
    string s1,s2;
    
    vector<long long>v1,v2;
    
   cin>>s1>>s2;
    
    l = s1.length();
    
    //cout<<l
    
    for(i=0;i<l;i++)
    {
        v1.push_back((s1[i]-'a'));
        v2.push_back((s2[i]-'a'));
        //cout<<v1[i]<<" ";
    }
   // cout<<endl;
    
    for(i=0;i<l;i++)
    {
        rotate(v1.begin(),v1.begin()+1,v1.end());
        temp=0;
        for(j=0;j<l;j++)
        {
           // cout<<v1[j];
            if(v1[j]==v2[j])
            {
                temp++;
            }
        }
        
        if(temp==l)
        {
            ans=1;
        }
        
    }
    
    if(ans==1)
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
t = [0]
x = [0]
y = [0]
for i in range(N):
    ti, xi, yi = map(int, input().split())
    t.append(ti)
    x.append(xi)
    y.append(yi)

def judge():
    for i in range(N):
        dt = t[i + 1] - t[i]
        diff = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i])
        if diff > dt or (dt - diff) % 2 != 0:
            return False
    return True

print('Yes' if judge() else 'No')


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

const long long MOD=1000000007;

int tmp[32][100010]={};

long long pat(int x, int N){
  if(tmp[x][N]>0){
    return tmp[x][N];
  }else{
    if(N==1){
      return 1;
      tmp[x][N]=1;
    }else{
      long long r=0;
      for(int i=0; i<=x; i++){
        r+=pat(x-i,N-1);
        r%=MOD;
      }
      tmp[x][N]=r;
      return r;
    }
  }
}

int main(){
  int N,M;
  cin >> N >> M;
  
  map<int,int> f;
  int d=2;
  while(M>1&&d<=sqrt(M)){
    while(M%d==0){
      if(f.count(d)==0){
        f[d]=1;
      }else{
        f[d]++;
      }
      M/=d;
    }
    d++;
  }
  if(M>1){
    if(f.count(M)==0){
      f[M]=1;
    }else{
      f[M]++;
    }
  }
  
  long long result=1;
  for(auto a:f){
    int x=a.second;
    result*=pat(x,N);
    result%=MOD;
  }
  cout << result << endl;
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
typedef long long LL;
using Graph = vector<vector<int>>;

static long long INF = (1LL<<62);

long long N, M;
string S;

static long long P = 1000000000LL + 7;

// base**kのmodを求める
LL modpow(LL base, LL k, LL mod){
	if(k == 0){ return 1; }
	if(k == 1){ return (base % mod); }
	if(k == 2){ return ((base*base) % mod); }

	LL q = k / 2;
	LL r = k % 2;
	// k = q*2 + r
	LL u = modpow((base*base)%mod, q, mod);
	LL v = modpow(base, r, mod);

	return ( (u * v ) % mod );
}

//dp[i][j]は、Sの末尾i+1桁を13で割ったあまりがjになる数の個数(modP)
long long dp[100000+2][13] = {0};

int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;
	cin >> S;
	long long N = S.size();

	//まず末尾から
	char tmp[2] = {0};
	int c = 0;
	if(S[N-1] == '?'){
		for(int j=0; j<10; j++){
			dp[0][j] = 1;
		}
	}
	else{
		tmp[0] = S[N-1];
		c = atoi(tmp);
		dp[0][c] = 1;
	}

	for(int i = 1; i < N; i++){
		int j = N - 1 - i;
		LL e = modpow(10, i, 13);
		if(S[j] == '?'){
			for(c = 0; c < 10; c++){
				int r = (e * c) % 13;
				for(int k = 0; k < 13; k++){
					dp[i][(r+k)%13] += (dp[i-1][k] % P);
					dp[i][(r+k)%13] %= P;
				}
			}
		}
		else{
			tmp[0] = S[j];
			c = atoi(tmp);
			int r = (e * c) % 13;
			for(int k = 0; k < 13; k++){
				dp[i][(r + k)%13] = dp[i-1][k] % P;
			}
		}
	}
	long long ans = dp[N-1][5];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 14040
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>
#include <string.h>
#include <bitset>
#include <stack>

using namespace std;
typedef long long ll;

struct UnionFind {
  vector<int> par; // 親ノード
  vector<int> size; // ランク
  ll ans;
  
  UnionFind(int n = 1) {
    init(n);
  }
  
  void init(int n = 1) {
    par.resize(n); size.resize(n);
    for (int i = 0; i < n; ++i) {
      par[i] = i;
      size[i] = 1;
    }
    ans = (ll) n * (n - 1) / 2;
  }
  
  int root(int x) {
    if (par[x] == x) {
      return x;
    }
    else {
      int r = root(par[x]);
      return par[x] = r;
    }
  }
  
  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;
    ans -= size[x] * size[y];
    if (size[x] < size[y]) {
      par[x] = y;
      size[y] += size[x];
    } else {
      par[y] = x;
      size[x] += size[y];
    }
    return true;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<pair<int, int>> vec(M);
  for (int i = 0; i < M; i++) {
    cin >> vec[i].first >> vec[i].second;
    vec[i].first--;
    vec[i].second--;
  }

  UnionFind uf(N);
  vector<ll> his(M);
  for (int i = M - 1; i >= 0; i--) {
    his[i] = uf.ans;
    uf.merge(vec[i].first, vec[i].second);
  }

  for (int i = 0; i < M; i++) {
    cout << his[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 3712
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static int Solve(int N, int[] A)
        {
            var dic = new Dictionary<int, int>();
            foreach (int a in A)
            {
                if (!dic.ContainsKey(a)) { dic[a] = 0; }
                ++dic[a];
            }
            int sum = 0;
            foreach (var pair in dic)
            {
                if (pair.Value > pair.Key) { sum += pair.Value - pair.Key; }
                if (pair.Value < pair.Key) { sum += pair.Value; }
            }
            return sum;
        }
        
        static void Main(string[] args)
        {
            int N = ReadInt();
            int[] a = ReadInts();
            Console.WriteLine(Solve(N, a));
        }
    }
}


Measured memory_bytes: 27228
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//namespaces
using namespace __gnu_pbds; 
using namespace std;

//MACROS
#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long 
#define For(i,s,e) for (int i=(s); i<(e); i++)
#define Fod(i,s,e) for (int i=(s); i>=(e); i--)
#define pii pair<ll,ll>
#define f first
#define s second
#define endl "\n"
#define all(container) container.begin(), container.end()
#define mp make_pair
#define int ll

//debug
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//Templates
template <typename T>
using ordered_set =tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

//globals
ll const prime1 = 304933;
ll const prime2 = 15486277;
ll const mod = 1e9+7;
ll const inf = 1e18;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE

signed main(){
    IOS
    ll k;cin >> k;
    if(k%2 == 1) cout << 0 << endl;
    else{
        ll power2 = k/2ll;
        k /= 2ll;
        ll m = k;
        ll p = 2ll;
        while(m >= p){
            power2 += m/p;
            p *= 2ll;
        } 
        ll power5 = 0;  
        p = 5;
        while(m >= p){
            power5 += m/p;
            // trace(power5);
            p*= 5ll;
        }
        // trace(m);
        // trace(power5);
        cout << min(power5,power2) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int t;
ll n,arr[10005];


int main()
{
    cin>>n;
    for(int i=0;i<n;i++) cin>>arr[i];
    int cnt=0;
    sort(arr,arr+n);
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            for(int k=j+1;k<n;k++){
                ll a=arr[i],b=arr[j],c=arr[k];
                if(a!=b&&b!=c&&c!=a){

                    if ((a+b)>c){
                            cnt++;
                        }
                    }
                }
            }
        }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>
using namespace std;
#define m long long
#define r(s,i,n) for(m i=s;i<n;i++)
m w[555][555],p[1234];
int main(){m n;cin>>n;m t=0,k=555;r(2,i,9999){bool a=true;r(2,j,i){if(i%j==0)a=false;}if(a)p[t]=i,t++;}r(0,i,k)r(0,j,k)if(i%2==j%2)w[i][j]=p[(i+j)/2]*p[(i+k*3-j)/2];r(0,i,k)r(0,j,k)if(w[i][j]==0&&i>0&&i<554)w[i][j]=w[i-1][j]*w[i+1][j]+1;r(0,i,n)r(0,j,n)cout<<w[i+1][j+1]<<" ";}

Measured memory_bytes: 5960
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define inf 2147483647 //int値の最大値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define debug(x) cerr << #x << ": " << x << "\n"
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;
}
int gcd(int a, int b) {
    if (b==0) return a;
    else return gcd(b, a%b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int two(int n){
	ll ans=1;
	rep(i,n){
		ans*=2;
	}
	return ans;
}
int AI(int n,int x){
    int cnt=0;
    for(int i=1;i<=n-2;i++){
        for(int j=i+1;j<=n-1;j++){
            for(int k=j+1;k<=n;k++){
               if( i + j + k ==x)cnt++;
            }
        }
    }
    return cnt;
}

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

   int n,m;
  // int sum=0;
  
   while(1){
         cin >> n>>m;
       if(n==0 && m ==0)break;

       
       cout<<AI(n,m)<<endl;

  
   }
}


Measured memory_bytes: 3216
def fun(a,k,n): ## k different steps can be taken
    if n==1:
        return 0
    dp = [0]*n
    dp[1]=dp[0]+abs(a[0]-a[1])
    for i in range(2,len(a)):
        t = 0
        min_ = float('inf')
        for j in range(i-1,-1,-1):
            if t==k:
                break
            else:
                t+=1
            if dp[j]+abs(a[i]-a[j]) < min_ :
                   min_ = dp[j]+abs(a[i]-a[j])
        dp[i]=min_
    return dp[-1]
from sys import stdin , stdout
n,k = map(int , stdin.readline().split())
a = list(map(int , stdin.readline().split()))
print(fun(a,k,n))

Measured memory_bytes: 20372
use std::io::*;
use std::str::FromStr;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::cmp::{min, max};

macro_rules! dump (
    ($($arg:tt)*) => { {
        if cfg!(local) {
            let r = writeln!(&mut ::std::io::stderr(), $($arg)*);
            r.expect("failed printing to stderr");
        }
    } }
);

#[allow(dead_code)]
struct Chrono {
    st: std::time::SystemTime,
}

#[allow(dead_code)]
impl Chrono {
    fn new() -> Chrono {
        Chrono { st: std::time::SystemTime::now() }
    }

    fn elapsed_ms(&self) -> i64 {
        let elapsed = self.st.elapsed().unwrap();
        elapsed.as_secs() as i64 * 1000 + elapsed.subsec_nanos() as i64 / 1_000_000
    }

    fn reset(&mut self) {
        self.st = std::time::SystemTime::now();
    }
}

struct Scanner<R: Read> {
    reader: R,
    buffer: String,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader, buffer: String::new() }
    }

    pub fn line(&mut self) -> String {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|&c| c == '\n' || c == '\r')
            .take_while(|&c| !(c == '\n' || c == '\r'))
            .collect::<String>();
        self.buffer.clone()
    }

    pub fn read_buffer(&mut self) {
        self.buffer = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
    }

    pub fn safe_read<T: FromStr>(&mut self) -> Option<T> {
        self.read_buffer();
        if self.buffer.is_empty() {
            None
        } else {
            self.buffer.parse::<T>().ok()
        }
    }

    pub fn read<T: FromStr>(&mut self) -> T {
        if let Some(s) = self.safe_read() {
            s
        } else {
            if cfg!(local) {
                writeln!(std::io::stderr(), "Terminated with EOF").unwrap();
            }
            std::process::exit(0);
        }
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.read()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }
}

trait Joinable {
    fn join(self, sep: &str) -> String;
}

impl<U: ToString, T: Iterator<Item=U>> Joinable for T {
    fn join(self, sep: &str) -> String {
        self.map(|x| x.to_string()).collect::<Vec<_>>().join(sep)
    }
}

fn main() {
    std::thread::Builder::new()
        .stack_size(104_857_600)
        .spawn(solve)
        .unwrap()
        .join()
        .unwrap();
}

fn solve() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    loop {
        let n: u32 = sc.read();
        let a: u32 = sc.read();
        let ans = if n % 500 <= a {
            "Yes"
        } else {
            "No"
        };
        println!("{}", ans);
    }
}


Measured memory_bytes: 8572
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int dp[100010] = { 0 };
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		dp[i] = 1000000007;
	}
	dp[0] = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j *= 6) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + 1);
			}
		}
		for (int j = 9; j <= n; j *= 9) {
			if (i - j >= 0) {
				dp[i] = min(dp[i], dp[i - j] + 1);
			}
		}
	}
	cout << dp[n] << endl;
	return 0;
}

Measured memory_bytes: 4028
#include <iostream>

using namespace std;

class dice {
public:
    int face[6];
    void rotate(char dir) {
        int temp;
        switch(dir) {
        case 'N':
            temp = face[0];
            face[0] = face[1];
            face[1] = face[5];
            face[5] = face[4];
            face[4] = temp;
            break;
        case 'E':
            temp = face[0];
            face[0] = face[3];
            face[3] = face[5];
            face[5] = face[2];
            face[2] = temp;
            break;
        case 'W':
            temp = face[0];
            face[0] = face[2];
            face[2] = face[5];
            face[5] = face[3];
            face[3] = temp;
            break;
        case 'S':
            temp = face[0];
            face[0] = face[4];
            face[4] = face[5];
            face[5] = face[1];
            face[1] = temp;
            break;
        }
    }
    bool operator==(const dice &d) {
        for(int i=0; i<6; i++) {
            if(face[i] != d.face[i]) return false;
        }
        return true;
    }
    bool isSame(dice &d) {
        const char *dir = "EEENWWWS";
        for(int i=0; i<24; i++) {
            if(*this == d) return true;
            d.rotate(dir[i%8]);
        }
        return false;
    }
};

int main()
{
    ios::sync_with_stdio(false);
    dice d1, d2;
    for(int i=0; i<6; i++) {
        cin >> d1.face[i];
    }
    for(int i=0; i<6; i++) {
        cin >> d2.face[i];
    }
    if(d1.isSame(d2)) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define repi(i, a, b) for (int i = (a); i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ull << (b))

using namespace std;
using i32 = long long;
using u32 = unsigned long long;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
using vi32 = vector<i32>;
using vu32 = vector<u32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf64 = vector<f64>;
using vstr = vector<string>;
using vvi32 = vector<vi32>;
using vvu32 = vector<vu32>;
using vvi64 = vector<vi64>;
using vvu64 = vector<vu64>;
using vvf64 = vector<vf64>;

template<typename T, typename S> void amax(T &x, S y) { if (x < y) x = y; }
template<typename T, typename S> void amin(T &x, S y) { if (y < x) x = y; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(16);
  int n, q;
  string s;
  cin >> n >> q;
  cin >> s;
  vi32 sums(n + 1);
  rep(i, n - 1) {
    if (s.substr(i, 2) == "AC") sums[i + 2] = 1;
  }
  rep(i, n) sums[i + 1] += sums[i];
  rep(_, q) {
    int l, r;
    cin >> l >> r;
    cout << sums[r] - sums[l] << endl;
  }
  return 0; 
}


Measured memory_bytes: 1872
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1e5 + 5;
int a[N];
vector<int> g[N];
bool vis[N];
set<int> v1, v2;
void dfs(int u){
	v1.insert(u);
	v2.insert(a[u]);
	vis[u] = 1;
	for(int v : g[u]){
		if(!vis[v]){
			dfs(v);
		}
	}
}
void solve(){
	int n, m;
	cin >> n >> m;
	fr(i, 1, n){
		cin >> a[i];
	}
	fr(i, 1, m){
		int u, v;
		cin >> u >> v;
		g[u].pb(v);
		g[v].pb(u);
	}
	int ans = 0;
	fr(i, 1, n){
		v1.clear();
		v2.clear();
		if(!vis[i])
		{
			dfs(i);
			for(int x : v1){
				ans += v2.count(x);
			}
		}
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 19072
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  tmp=1000
  for i in reversed(range(-1,102)):
    if i not in a:
      if tmp >= abs(i-x):
        tmp=abs(i-x)
        ans=i
  print(ans)

Measured memory_bytes: 9188
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
//typedef long long int LL;
//typedef __int64 LL;

stack<char> S;
char X[200005];

int main()
{
	scanf("%s", X);
	int len = strlen(X);
	for (int i = 0; i < len; i++) {
		if (X[i] == 'S') S.push('S');
		else {
			if (!S.empty() && S.top() == 'S') S.pop();
			else S.push('T');
		}
	}

	printf("%d\n", S.size());

	return 0;
}


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, a);
  in(string, s);
  if (a >= 3200) {
    out(s);
  } else {
    out("red");
  }
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(){
  int n,i,j,f,c,p[168];
  while(scanf("%d",&n) != EOF){
    if(n<2) printf("0\n");
    else if(n == 2) printf("1\n");
    else{
    c = 0;
    p[c++] = 2;
    p[c++] = 3;
    for(i=5;i<=n;i += 2){
      f = 0;
     for(j = 1;p[j]*p[j] <= i;j++){
       if(i % p[j] == 0){f = 1;break;}
     }
      if(f==0){c++;if(i <= 1000) p[c-1] = i;}
    }
    printf("%d\n",c);
    }
  }
  return 0;
}

Measured memory_bytes: 412
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a, b, c;
    cin >> a >> b >> c;
    if (a == b && b == c) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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

public class Main {

	/**
	 * AOJ 0006 Reverse Sequence
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader bufferedReader = new BufferedReader(
				new InputStreamReader(System.in));

		String input = bufferedReader.readLine();
		StringBuilder builder = new StringBuilder();
		for (int i = input.length() - 1; i >= 0; i--) {
			builder.append(input.charAt(i));
		}
		System.out.println(builder);
	}
}

Measured memory_bytes: 16860
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll MAX=1e5+3;
vector<ll>ed[MAX];

int main() {
    ll n,m;
    cin>>n>>m;
    pair<ll,ll> a[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].first>>a[i].second;
        ed[a[i].first].push_back(a[i].second);
    }
    priority_queue<ll>pq;
    ll ans=0;
    for(ll i=m-1;i>=0;i--)
    {                                          
        for(ll x:ed[m-i])
        {
            pq.push(x);             
        }
        if(!pq.empty())
        {
            ll top=pq.top();
            pq.pop();
            ans+=top;        //   cout<<top<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 7296
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, K = in_nn()
    a = in_nl()
    a_sum = [0] * (N + 1)

    b = set()
    for i in range(N):
        a_sum[i + 1] = a_sum[i] + a[i]

    for i in range(N + 1):
        for j in range(i + 1, N + 1):
            b.add(a_sum[j] - a_sum[i])

    b = sorted(list(b))
    bit = max(b).bit_length()

    ans = 0
    select = set(b)
    for x in range(bit, 0, -1):

        cnt = 0
        t_select = set()
        for tb in select:
            # print(x, tb, (tb >> (x - 1)) & 1)
            if (tb >> (x - 1)) & 1:
                cnt += 1
                t_select.add(tb)

        # print(cnt, select)
        if cnt >= K:
            ans += (1 << (x - 1))
            select = t_select

    print(ans)


if __name__ == '__main__':
    main()


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

int main(){
    string word;
    int n;
    while(1){
        cin >> word;
        if (word == "-") break;
        int n;
        cin >> n;
        for (int i = 0; i < n; i++){
            int a;
            cin >> a;
            word = word.substr(a) + word.substr(0, a);
        }
        cout << word << endl;
    }
}


Measured memory_bytes: 3172
#include<bits/stdc++.h>
#include<boost/algorithm/string/replace.hpp>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::algorithm;
using namespace boost::multiprecision;
 
#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int mINF = 1e9;
const int MOD = 1e9+7;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

template<typename T>//文字列の置換/Boost:replace_all()
T replace_str(T str, string target, string str_to) {
    string::size_type pos = 0;
    while (pos = str.find(target, pos), pos != string::npos) {
        str.replace(pos, target.length(), str_to);
        pos += str_to.length();
    }
    return str;
}

int main(){
    int n;cin >> n;
    vector<int> d(n);
    rep(i,n)cin >> d[i];
    int ans = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans += d[i]*d[j];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256