akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
using namespace std;
 
//const int MOD=1e9+7;
 
const int MOD=998244353;


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    long long a,b,g;
    cin>>a>>b;
    
    g=__gcd(a,b);
    
    vector<bool> isP(1000001,1);
    
    for(int i=2; i<=1000000; i++){
        if(isP[i]){
            for(int j=2*i; j<=1000000; j+=i) isP[j]=0;
        }
    }
    
    vector<int> pr;
    int ans=1;
    for(int i=2; i<=1000000; i++){
        if(isP[i]){
            if(!(g%i)){
                ans++;
                g/=i;
                while(!(g%i)){
                    g/=i;
                }
            }
        }
    }
    ans+=(g!=1);
    cout<<ans;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include <cassert>
#include <vector>

template <typename SemiLattice> class SparseTable {
public:
	using value_type = SemiLattice;
	using container_type = std::vector<value_type>;
	using size_type = typename container_type::size_type;

private:
	static size_type clz32(size_type c) {
#ifdef __GNUC__
		return 31 ^ __builtin_clz(c);
#else
		size_type ret = 0;
		if (c & 0xFFFF0000)
			c &= 0xFFFF0000, ret |= 16;
		if (c & 0xFF00FF00)
			c &= 0xFF00FF00, ret |= 8;
		if (c & 0xF0F0F0F0)
			c &= 0xF0F0F0F0, ret |= 4;
		if (c & 0xCCCCCCCC)
			c &= 0xCCCCCCCC, ret |= 2;
		if (c & 0xAAAAAAAA)
			ret |= 1;
		return ret;
#endif
	}
	std::vector<container_type> matrix;

public:
	SparseTable(const container_type &a)
		: matrix(a.empty() ? 0 : clz32(a.size()) + 1) {
		if (!a.empty())
			matrix[0].reserve(a.size());
		for (size_type i = 0; i < a.size(); ++i)
			matrix[0].emplace_back(a[i]);
		for (size_type i = 1; i < matrix.size(); ++i) {
			const size_type msiz = a.size() + 1 - (static_cast<size_type>(1) << i);
			matrix[i].reserve(msiz);
			for (size_type j = 0; j < msiz; ++j)
				matrix[i].emplace_back(
					matrix[i - 1][j] +
					matrix[i - 1][j + (static_cast<size_type>(1) << (i - 1))]);
		}
	}
	value_type range(const size_type begin, const size_type end) const {
		assert(begin < end);
		assert(begin < size());
		assert(end <= size());
		const size_type t = clz32(end - begin);
		return matrix[t][begin] + matrix[t][end - (static_cast<size_type>(1) << t)];
	}
	size_type size() const noexcept { return empty() ? 0 : matrix[0].size(); }
	bool empty() const noexcept { return matrix.empty(); }
};
#include <algorithm>
#include <limits>
template <typename T> struct Mini {
	using value_type = T;
	T a;
	explicit Mini(const T &x = std::numeric_limits<T>::max()) : a(x) {}
	Mini operator+(const Mini &o) const { return Mini(std::min(a, o.a)); }
};
#include<cstdio>
#include<vector>
int main() {
	using M = Mini<int>;
	int n, l;
	scanf("%d %d", &n, &l);
	std::vector<M> a(n);
	for (auto &x : a)scanf("%d", &x.a);
	SparseTable<M> T(a);
	for (int i = 0;i <= n - l;++i)
		printf("%d%c", T.range(i, i + l).a, " \n"[i == n - l]);
	return 0;
}


Measured memory_bytes: 80276
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,s1;
  	getline(cin,s);
  getline(cin,s1);
  int n=s1.length();
  if(s==s1.substr(0,n-1)){
  	cout<<"Yes\n";
  }
  else{
    cout<<"No";
  }
  return 0;
}

Measured memory_bytes: 3608
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        int a = int.Parse(input[0]);
        int b = 2+int.Parse(input[1]);
        for(int i=0;i<b;i++){
            Write("#");
        }
        WriteLine("");
        
        for(int i=0;i<a;i++){
            string temp = ReadLine();
            WriteLine("#"+temp+"#");
        }
        
        for(int i=0;i<b;i++){
            Write("#");
        }
        WriteLine("");
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    vector<int>rem(4,0);
    for(int i=0;i<n;i++)
    {
        rem[v[i]%4]++;
    }
    int countzero=rem[0];
    int countone=rem[1];
    int counttwo=rem[2]>0?1:0;
    int countthree=rem[3];
    if(countzero+1>=countone+counttwo+countthree){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

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

int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> ans(n+1);
	for(int i=1; i<n+1; i++){
		ans.at(i)=ans.at(i-1);
		if(s.at(i-1)=='D') ans.at(i)--;
		if(s.at(i-1)=='I') ans.at(i)++;
	}
	sort(ans.begin(), ans.end());
	reverse(ans.begin(), ans.end());
	cout << ans.at(0) << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string S;
	cin >> S;

	long long K;
	cin >> K;

	long long cnt1 = 0;

	long long same_char = 1;
	for (int i = 0; i < S.size() - 1; i++)
	{
		if (S[i] == S[i + 1])
		{
			same_char++;
		}
		else
		{
			cnt1 += same_char / 2;
			same_char = 1;
		}
	}

	if (same_char == S.size())
	{
		cout << (S.size() * K) / 2;
		return 0;
	}

	cnt1 += same_char / 2;
	same_char = 1;

	string S2 = S + S;

	long long cnt2 = 0;

	for (int i = 0; i < S2.size() - 1; i++)
	{
		if (S2[i] == S2[i + 1])
		{
			same_char++;
		}
		else
		{
			cnt2 += same_char / 2;
			same_char = 1;
		}
	}

	cnt2 += same_char / 2;

	cout << (cnt2 - cnt1) * (K - 1) + cnt1;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int cnt = 0;
    rep(i, n)
    {
        cin >> p[i];
    }
    p.push_back(0);
    rep(i, n)
    {
        if(p[i]==i+1){
            cnt++;swap(p[i + 1], p[i]);
        }
    }
    cout << cnt << endl;

}

Measured memory_bytes: 1024
fun main(argv: Array<String>) {
  var count = 0

  val inputs = readLine()!!.split(' ').map{x->x.toInt()}
  val a = inputs[0]
  val b = inputs[1]
  val c = inputs[2]

  for (i in a..b) {
    if (c % i == 0) {
      count++
    }
  }
  println("${count}")
}



Measured memory_bytes: 32184
#include <stdio.h>
#define M 10000000
int name[M];

int main(void){
    long int N;
    scanf("%ld", &N);

    int i;  i=0;
    int tmp;
    N--;
    while(N>=0){
        name[i] = N%26;
        i++;
        N = N/26 - 1;
    }

    for(int j=i-1; j>=0; j--){
        printf("%c", name[j]+'a');
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 1624
#include<stdio.h>
int main()
{
    int a[5], i;
    for (i = 0; i < 5; i++)
        scanf("%d", &a[i]);
    int ans = 0, max = 0;
    for (i = 0; i < 5; i++)
    {
        if (a[i] % 10 == 0)
            ans += a[i];
        else
        {
            ans += a[i] + 10 - (a[i] % 10);
            if (max < 10 - (a[i] % 10))
                max = 10 - (a[i] % 10);
        }
    }
    printf("%d\n", ans - max);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <unistd.h>
#define ll long long
#define inf 1000000007
#define inf16 0x3f3f3f3f
#define INF 1000000000000000007LL
#define VI vector<int>
#define VPII vector<pair<int, int> >
#define VLL vector<ll>
#define PII pair<int, int>
#define st first
#define nd second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define endl '\n'
#define ALL(c) (c).begin(), (c).end()
using namespace std;

#define int ll

int h, w, n, k, ans;

int pot[50*50];

int query(int y1, int y2, int x1, int x2)
{
	cout << "? " << y1 << " " << x1 << " " << y2 << " " << x2 << endl;
	int ans;
	cin >> ans;
	return ans;
}

void solve(int y1, int y2, int x1, int x2, int cnt = -1)
{
	if(cnt==-1)
		cnt = query(y1, y2, x1, x2);

	if(cnt==0)
		return;

	if(cnt==(y2-y1+1)*(x2-x1+1))
	{
		for(int i = y1; i <= y2; ++i)
		{
			for(int j = x1; j <= x2; ++j)
			{
				ans += pot[i*w+j];
				ans %= k;
			}
		}

		return;
	}

	if(x1==x2)//y1!=y2)
	{
		int m = (y1+y2)/2;
		int h = query(y1, m, x1, x2);
		solve(y1, m, x1, x2, h);
		solve(m+1, y2, x1, x2, cnt-h);
	}
	else
	{
		int m = (x1+x2)/2;
		int h = query(y1, y2, x1, m);
		solve(y1, y2, x1, m, h);
		solve(y1, y2, m+1, x2, cnt-h);
	}
}

int32_t main()
{
	cin >> h >> w >> n >> k;

	pot[0] = 1;

	for(int i = 1; i < 50*50; ++i)
	{
		pot[i] = pot[i-1]*2%k;
	}

	solve(0, w-1, 0, 31);
	solve(0, w-1, 32, 47);
	solve(0, w-1, 48, 49);

	/*for(int i = 0; i < h; i += 5)
	{
		for(int j = 0; j < w; j += 5)
		{
			solve(i, i+4, j, j+4, query(i, i+4, j, j+4), 1);
		}
	}*/

	//solve(0, h-1, 0, w-1, n, 1);

	cout << "! " << ans << endl;
}

Measured memory_bytes: 720
array=[]
5.times do
  array << gets.chomp.to_i
end
k=gets.chomp.to_i
out = 0
5.times do |i|
  i+1.times do |j|
    if array[i] - array[j] > k
      out += 1
    end
  end
end
puts out == 0 ? 'Yay!' : ':('

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <memory.h>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <set>
#include <map>
#include <cctype>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <numeric>
#include <fstream>
#include <cmath>
using namespace std;

#define rep(i, n) for(int i = 0; i< (int)(n); i++)
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define pb(e) push_back(e)
#define foreach(c, i) for(iter(c) i = (c).begin(); i != c.end(); ++i)

typedef long long ll;
typedef pair<ll, ll> P;
const ll mod  = 1000 * 1000 * 1000 + 7;
const double EPS = 1e-10;

const int maxn = 210;
const int sz = 1000;
ll p10[sz];
ll comb[maxn][maxn];
ll perm[maxn];
ll pattern[maxn];
vector<ll> card_size;
ll memo[maxn * maxn * maxn];

int digits(int n){
  int res = 0;
  do{ 
    res++;
    n /= 10;
  }while(n > 0);
  return res;
}

ll recur(vector<ll> num){
  
  
  if(*max_element(num.begin(), num.end()) == 0) return 1;
  
  ll h = 0;
  rep(i, num.size())   h = h * card_size[i] + num[i];
  
  if(memo[h] != -1) return memo[h];
  
  ll &res = memo[h] = 0;
  rep(i, num.size()){
    if(num[i] > 0){
      num[i]--;
      res = (res + recur(num) * (num[i] + 1)) % mod;
      num[i]++;
    }
  }
  return res;
} 

ll pattern_num(const vector<ll> &rest){
  int n = accumulate(rest.begin(), rest.end(), 0);
  return pattern[n];
}

ll dfs(vector<ll> cnt, const vector<ll> &num, ll sum, int c){
  ll res = 0;
  if(c == (int)num.size()){
    int len = 0;
    vector<ll> rest(cnt.size(), 0);
    rep(i, cnt.size()){
      rest[i] = num[i] - cnt[i];
      len += cnt[i] * (i + 1);
    }
    
    ll p = recur(cnt) * pattern_num(rest) % mod;
    rep(i, cnt.size()) p = (p * comb[num[i]][cnt[i]]) % mod;
    p = (p * p10[len]) % mod;
    return sum * p % mod;
  }
  
  rep(i, num[c] + 1){
    cnt[c] = i;
    res = (res + dfs(cnt, num, sum, c + 1)) % mod;
  }
  return res;
}

ll calc(vector<int> v){
  vector<ll> sum(4, 0), cnt(4, 0), num(4, 0);
  
  rep(i, v.size()){
    sum[digits(v[i])-1] += v[i];
    num[digits(v[i])-1]++;
  }
  
  memset(memo, -1, sizeof(memo));
  
  ll res = 0;
  card_size = num;
  rep(i, card_size.size()) card_size[i]++;
  rep(i, num.size()){
    num[i]--;
    res = (res + dfs(cnt, num, sum[i], 0)) % mod;
    num[i]++;
  }
  return res;
}

void init(){
  p10[0] = 1;
  rep(i, sz - 1) p10[i+1] = p10[i] * 10 % mod;
  rep(n, maxn)rep(r, maxn){
    if(n < r) comb[n][r] = 0;
    else if(r == 0) comb[n][r] = 1;
    else comb[n][r] = (comb[n-1][r] + comb[n-1][r-1]) % mod;
  }
  
  perm[0] = 1;
  rep(i, maxn - 1) perm[i+1] = perm[i] * (i + 1) % mod;
  rep(i, maxn){
    rep(j, i + 1){
      pattern[i] = (pattern[i] + comb[i][j] * perm[j]) % mod;
    }
  }
}

int main(){
  int n, a;
  ll res = 0;
  vector<int> v;
  init();
  cin >> n;
  rep(i, n){
    cin >> a;
    v.push_back(a);
  }
  sort(v.begin(), v.end());
  res = calc(v);
  if(v[0] == 0) res = (res + mod - calc(vector<int>(v.begin() + 1, v.end()))) % mod;
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 73936
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1LL<<60;
long double pi=3.14159265358979323846L;
double eps=1e-12;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;cin>>n;
    vector<int> v[n+1];
    rep(i,0,n-1){
        int a,b;cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    int par[n+1];
    par[1]=0;
    queue<int> q;
    q.push(1);
    v[1].push_back(0);
    int dis[n+1];
    dis[1]=0;
    while(q.size()>0){
        int now=q.front();q.pop();
        rep(i,0,v[now].size()){
            int ne=v[now][i];
            if(ne==par[now])continue;
            par[ne]=now;
            q.push(ne);
            dis[ne]=dis[now]+1;
        }
    }
    int dp[n+1];
    fill(dp,dp+n+1,0);
    rep(i,1,n+1){
        if(v[i].size()==1)q.push(i);
    }
    int cnt[n+1];
    fill(cnt,cnt+n+1,0);
    while(q.size()>0){
        int now=q.front();q.pop();
        dp[now]++;
        if(now==1)break;
        int pp=par[now];
        cnt[pp]++;
        dp[pp]+=dp[now];
        if(cnt[pp]==v[pp].size()-1)q.push(pp);
    }
    int kai=(dis[n]-1)/2;
    int now=n;
    rep(i,0,kai)now=par[now];
    int wh=dp[now];
    //cout<<now<<endl;
    int bl=n-wh;
    if(wh>=bl)cout<<"Snuke"<<endl;
    else cout<<"Fennec"<<endl;
}



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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

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

    int n;
    cin >> n;

    vector<pair<int, int>> d(n);
    for (int i = 0; i < n; i++) cin >> d[i].first >> d[i].second;

    bool occ = false;
    for (int i = 0; i < n - 2; i++) {
        if (d[i].first == d[i].second and d[i + 1].first == d[i + 1].second and d[i + 2].first == d[i + 2].second) {
            occ = true;
        }
    }

    cout << (occ ? "Yes" : "No") << '\n';
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
using namespace std;
#define NILL -1
#define MAX 100000
struct Node {
	int id,parent,roots;
	int *rootlist;
};
Node T[MAX];
int deep(int u) {
	int d = 0;
	while (T[u].parent != NILL) {
		d += 1;
		u=T[u].parent;
	}
	return d;
}
void print(int x) {
	cout << "node "<< T[x].id << ": ";
	cout << "parent = " << T[x].parent << ", ";
	cout << "depth = " << deep(x) << ", ";
	if (T[x].parent == NILL) cout << "root, ";
	else if (T[x].roots<=0) cout << "leaf, ";
	else cout << "internal node, ";
	cout << "[";
	for(int i=0;i<=T[x].roots-1;i++){
	    if(i>0){
	        cout<<", ";
	    }
	    cout<<T[x].rootlist[i];
	}
	cout << "]" << endl;

}
int main() {
	int n, k,c,intid;
	cin >> n;
	for (int i = 0; i < n; i++) {
		T[i].parent =NILL;
	}
	for (int i = 0; i < n; i++) {
		cin >> intid>> k;
		int count=0;
		T[intid].id=intid;
		T[intid].rootlist= new int[k];
		for (int j = 0; j < k; j++) {
			cin>>c;
			T[intid].rootlist[j]=c;
			T[T[intid].rootlist[j]].parent=intid;
			count+=1;
		}
		T[intid].roots=count;
	}
	for (int i = 0; i < n; i++) {
		print(i);
	}
	return 0;
}


Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
int main(){
    // Your code here!
    int n;
    cin >> n;
    string str;
    if(n % 10 == 3) str = "bon";
    else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        str = "pon";
    }else{
        str = "hon";
    }
    cout << str << endl;
    return 0;
}


Measured memory_bytes: 3620
n,m = input().split(" ")
a = list(map(int,input().split()))
n = int(n)
m = int(m)
#print(m)
max = sum(a)

#print(a)
a = sorted(a, reverse=True)
count = 0
for i in range(m):
    if a[i] < max/(4*m):
        #print(a[i])
        print("No")
        break
    else:
        count += 1
if count == m:
        print("Yes")

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

public class MainClass
{
	public const long Giri = 1000000007;

	public static void Main(string[] args)
	{
		var p = Console.ReadLine();
		Console.WriteLine((char)(p[0]+1));
	}
	

	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(' '); }
	public static int Clamp(int val, int max, int min = 0) { return Math.Min(max, Math.Max(min, val)); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt();
		return r;
	 }
}


Measured memory_bytes: 11092
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	for i, r := range s {
		if i%2 == 0 {
			switch r {
			case 'R', 'U', 'D':
			default:
				fmt.Println("No")
				return
			}
		} else {
			switch r {
			case 'L', 'U', 'D':
			default:
				fmt.Println("No")
				return
			}
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 512
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <unordered_map>
#include <vector>

long solve(int n, const std::vector<long>& heights)
{
  std::unordered_map<long, std::vector<int>> m1;
  std::unordered_map<long, std::vector<int>> m2;

  for (int i = 0; i < n; ++i) {
    m1[i + 1 + heights.at(i)].push_back(i);
    m2[i + 1 - heights.at(i)].push_back(i);
  }

  long result = 0;
  for (const auto& p : m1) {
    auto it = m2.find(p.first);
    if (it == m2.end()) continue;
    result += p.second.size() * it->second.size();
  }

  return result;
}

int main()
{
  int n;
  std::cin >> n;
  std::vector<long> heights(n);
  for (auto& h : heights) {
    std::cin >> h;
  }

  std::cout << std::setprecision(20);
  std::cout << solve(n, heights) << std::endl;
}


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

set1={1,3,5,7,8,10,12}
set2={4,6,9,11}
set3={2}

if x in set1 and y in set1:
  print("Yes")
elif x in set2 and y in set2:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<stdio.h>

int main(void){
  int a, b, c;
  int min, minmin;
  int t;
  scanf("%d %d %d", &a, &b, &c);
  min = a;
  minmin = b;
  if ( min > minmin) {
    t = min;
    min = minmin;
    minmin = t;
  }
  if ( c < min ) {
    minmin = min;
    min = c;
  } else if ( c < minmin ) {
    minmin = c;
  }
  printf("%d\n", min + minmin);
  return 0;
}

Measured memory_bytes: 128
while 1:
  h,w = map(int, raw_input().split())
  if h==w==0: break
  H = range(h)
  C = [0]*(h+1)
  M = C[:]
  a=[0]*w
  for i in H:
    x = list(raw_input())
    b=[0]*w
    sp=-1
    C = [-1]*(h+1)
    for j in range(w):
      if x[j]=="*":
        c=0
      elif x[j]==".":
        c=a[j]+1
      b[j]=c
      if c>sp:
        C[sp+1:c+1]=[j]*(c-sp)
      elif c<sp:
        for k in range(c+1,sp+1):
          M[k]=max(M[k],j-C[k])
          C[k]=-1
      sp=c
    for k in range(1,sp+1):
      if C[k]>=0:
        M[k]=max(M[k],w-C[k])
    a=b[:]
  s=0
  for i in range(h+1):
    s=max(s,M[i]*i)
  print s

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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;
typedef pair<int, int>             pii;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};


set<int> loc[27];
int main(){
    fIO

    int n, q;
    cin >> n;

    string s;
    cin >> s;

    for(int i = 0; i < n; i++) {
        loc[s[i] - 'a'].insert(i);
    }

    cin >> q;

    int idx, l, r;
    for(int i = 0; i < q; i++) {
        cin >> idx >> l;

        if(idx == 1) {
            char c;
            cin >> c;
            if(s[l - 1] == c) continue;
            loc[s[l - 1] - 'a'].erase(l - 1);
            loc[c - 'a'].insert(l - 1);
            s[l - 1] = c;
        }else {
            cin >> r;

            l--; r--;
            int cnt = 0;
            for(int j = 0; j < 26; j++) {
                auto it = loc[j].lower_bound(l);

                if(it == loc[j].end()) continue;

                if((*it) > r) continue;
                cnt++;
            }
            cout << cnt << "\n";
        }
    }

}








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

int main(){
    int A,B;
    scanf("%d",&A);
    scanf("%d",&B);

    int s = A + B;
    int d = A - B;
    int m = A*B;

    vector<int> X(3);
    X.at(0) = s;
    X.at(1) = d;
    X.at(2) = m;

     std::sort(X.begin(),X.end(),std::greater<int>());


     printf("%d\n",X.at(0));

     return 0;
}

Measured memory_bytes: 256
def main():
    from math import gcd
    import sys
    sys.setrecursionlimit(10**9)
    input = sys.stdin.readline

    mod = 1000000007

    N = int(input())
    A = list(map(int, input().split()))

    lcm = 1
    for i in A:
        lcm = lcm * i // gcd(lcm, i)
    lcm %= mod

    ans = 0
    for i in A:
        ans += lcm * pow(i, mod-2, mod)
        ans %= mod

    print(ans)


main()

Measured memory_bytes: 10152
#include <iostream>
#include <vector>
#include <bitset>
#include <string>
#define VE vector<int>
#define PB push_back
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
int main(){
    bitset<20000> bx,by;
    string s; cin>>s;
    bx[10000]=by[10000]=1;
    int t=-1;//t=1->x t=-1->y
    int k=1;
    VE v; v.PB(0);
    FOR(i,0,s.size()){
        if(s[i]=='F') v[v.size()-1]++;
        else v.PB(0);
    }
    bx<<=v[0];
    FOR(i,1,v.size()){
        if(t==1) bx=(bx<<v[i])|(bx>>v[i]);
        else by=(by<<v[i])|(by>>v[i]);
        t*=-1;
    }
    int x,y; cin>>x>>y;
    Yes(bx[x+10000]==1&&by[y+10000]==1);
}

Measured memory_bytes: 384
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <bitset>
#include <iostream>
#include <deque>
#include <functional>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <string>
#include <vector>
#include <vector>

using namespace std;

#define int long long

#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

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

#define debug(x) cerr << #x << ": " << x << endl;

const int MOD = 1e9 + 7;

signed main(void)
{
  int num;
  int M = 2019;
  int l, r;
  cin >> l >> r;

  int a = l % M;
  int b = r % M;

  num = 2018;
  if (l + M <= r) {
    num = 0;
  }
  else if (l + M > r) {
    if (a < b) {
      for (int i = a; i < b; ++i) {
        for (int j = a + 1; j <= b; ++j) {
          num = min(num, (i * j) % 2019);
        }
      }
    } else {
      for (int i = a; i != b; i = (i + 1) % 2019) {
        for (int j = (i + 1) % 2019; j != b + 1; j = (j + 1) % 2019) {
          num = min(num, (i * j) % 2019);
        }
      }
    }
  }
  cout << num << endl;
  
}


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

int main(){
    int n;
    cin >> n;
    int debt = 100000;
    for(int i=0;i<n;++i){
        debt *= 1.05;
        if(debt % 1000 != 0)debt = debt - (debt % 1000) + 1000;
    }
    cout << debt << endl;

    return 0;
}


Measured memory_bytes: 2980
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
const ll MOD = 1000000007;

void _main()
{
    int N, M;
    cin >> N >> M;
    vector<int> A(N), B(M);
    rep(i, 0, N) cin >> A[i];
    rep(i, 0, M) cin >> B[i];
    sort(A.begin(), A.end(), greater<int>());
    sort(B.begin(), B.end(), greater<int>());
    A.push_back(-1);
    B.push_back(-1);

    int apt = 0, bpt = 0, num = N * M;
    ll ans = 1;
    while (num > 0)
    {
        if (A[apt] == num && B[bpt] == num)
        {
            ++apt;
            ++bpt;
        }
        else if (A[apt] == num)
        {
            ++apt;
            ans = (ans * bpt) % MOD;
        }
        else if (B[bpt] == num)
        {
            ++bpt;
            ans = (ans * apt) % MOD;
        }
        else
        {
            ans = (ans * (apt * bpt - (N * M - num))) % MOD;
        }
        --num;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
from itertools import combinations
from collections import defaultdict

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

d = defaultdict(int)
left = set()

for r in range(n + 1):
	for j in combinations(range(n), r):
		sl = ""
		sr = ""
		for i in range(n):
			if i in j:
				sl += s[i]
			else:
				sr += s[i]
		left.add(sl + "," + sr)
		d[sl + "," + sr] += 1
res = 0
for r in range(n + 1):
	for j in combinations(range(n, 2 * n), r):
		sl = ""
		sr = ""
		for i in range(n, 2 * n):
			if i in j:
				sl = s[i] + sl
			else:
				sr = s[i] + sr
		if sr + "," + sl in left:
			res += d[sr + "," + sl]
print(res)

Measured memory_bytes: 123100
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String c1 = sc.next();
		String c2 = new StringBuffer(sc.next()).reverse().toString();
		System.out.println((c1.equals(c2))? "YES" : "NO");
	}
}

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

int main() {

int N;
cin >>N;

int M;
cin >>M;

int X;
cin >>X;

int Y;
cin >>Y;

int maxA=X;//Aの領域の最大
int minB=Y;//Bの領域の最小

int x;
int y;

for(int i=0; i<N; i++){

cin >>x;
if(x>maxA){maxA=x;}

}

for(int i=0; i<M; i++){

cin >>y;
if(y<minB){minB=y;}

}

if(maxA<minB){ cout<<"No War";}
if(maxA>=minB){ cout<<"War";}

}

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

using namespace std;

typedef long long lli;
typedef double lld;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<double> vdl;
typedef vector<vector<lli>> mat;
typedef vector<vdl> mad;
typedef unordered_map<lli,unordered_map<lli,lli>> graph;
typedef complex<double> cmp;
typedef vector<cmp> vcl;

const lli e5 = 1 << 20;
const lli mod = 1000000007;
const lli e3 = 1 << 13;
const lli INF = 1ll << 62;

lli n,m;
vll ba[e5];
lli ans;

int main(){
  cin >> n >> m;
  for(lli i = 0;i < n;i++){ba[i] = vll(2);cin >> ba[i][0] >> ba[i][1];}
  sort(ba,ba+n);
  lli i = 0;
  while(m > 0){
    ans += ba[i][0]*min(m,ba[i][1]);
    m -= ba[i][1];
    i++;
  }
  cout << ans << endl;

}


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

using namespace std;

int main()
{
	int suretu[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

	int K;

	cin >> K;

	cout << suretu[K - 1] << endl;

}

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

using namespace std;

const int INF = 1 << 29;
using int64 = long long;

const int N = 1e5 + 10;
int a[N];

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  pair<int64, int64> ret;
  int64 max_v = *max_element(a, a + n);
  int64 low = max_v - 1, high = 1LL << 60;
  while (low != high) {
    int64 mid = (low + high + 1) / 2;
    int64 cur = mid;
    for (int i = 0; i < n; ++i) {
      cur = cur / a[i] * a[i];
    }
    if (cur > 2) {
      high = mid - 1;
    } else {
      low = mid;
    }
  }
  ret.second = high;
  low = max_v - 1, high = 1LL << 60;
  while (low != high) {
    int64 mid = (low + high) / 2;
    int64 cur = mid;
    for (int i = 0; i < n; ++i) {
      cur = cur / a[i] * a[i];
    }
    if (cur < 2) {
      low = mid + 1;
    } else {
      high = mid;
    }
  }
  ret.first = high;
  if (ret.first > ret.second) {
    puts("-1");
  } else {
    printf("%lld %lld\n", ret.first, ret.second);
  }
  return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
char s[200010];
int main(){
	int i,ans=0,n;
	scanf("%s",s+1);
	n=strlen(s+1);
	for(i=1;i<=n;i++)ans+=s[i]-'0';
	if(ans%9)printf("No\n");
	else printf("Yes\n");
	return 0;
}


Measured memory_bytes: 1812
#include <bits/stdc++.h>
#define rep(i, a, b) for (register int i = a; i <= b; i++)

using namespace std;

const int N = 1e5 + 10;
char str[N];
int ans, len;

int main() {
    scanf("%s", str + 1);
    len = strlen(str + 1);
    char last = str[1] - '0';
    rep(i, 2, len) {
        int tmp = str[i] - '0';
        if (tmp == last) {
            ans++;
            last ^= 1;
        } else {
            last = tmp;
        }
    }
    printf("%d", ans);
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define DO long double
#define pb push_back
#define pfr push_front
#define eb emplace_back
#define ef emplace_front
#define gc getchar_unlocked
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vi vector<int>
#define vll vector<ll>
#define fr(i,j,k) for(i = j; i < k; i++)
#define bck(i,j,k) for(i = j; i > k; i--)
#define all(x) x.begin(), x.end()

//////////////////////////////////////////////////////////////////////////////////////////
#define error(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); cerr << '\n'; }
vector<string> split(const string& s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c))
		v.emplace_back(x);
	return move(v);
}
void err(vector<string>::iterator it) { }
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\t';
	err(++it, args...);
}
////////////////////////////////////////////////////////////////////////////////////////////

int main()
{
    int a, b, c, d;
    cin>>a>>b>>c>>d;
    if(a+b == c+d)
        cout << "Balanced";
    else if(a+b < c+d)
        cout<<"Right";
    else
        cout << "Left";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())
 
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
 
template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}
 
template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}
 
template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}
 
#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
 
constexpr ll INF = TEN(18);
 
int main() {
    int N, K;
    cin >> N >> K;
    V<int> P(N), C(N);
    rep(i, N) cin >> P[i], --P[i];
    rep(i, N) cin >> C[i];
 
    ll ans = -INF;
 
    rep(i, N) {
        int v = i;
        ll cycle_sum = 0;
        int cycle_cnt = 0;
 
        while (true) {
            cycle_cnt++;
            cycle_sum += C[v];
            v = P[v];
            if (v == i) break;
        }
 
        ll path = 0;
        int cnt = 0;
 
        while (true) {
            cnt++;
            path += C[v];
 
            if (cnt > K) break;
 
            int num = (K - cnt) / cycle_cnt;
            ll score = path + max(0ll, cycle_sum) * num;
            chmax(ans, score);
 
            v = P[v];
            if (v == i) break;
        }
    }
 
    cout << ans << endl;
 
    return 0;
}

Measured memory_bytes: 3648
#dt = {} for i in x: dt[i] = dt.get(i,0)+1
import sys
input = sys.stdin.readline
ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda :int(input())
ip = lambda :[int(w) for w in input().split()]

n = inp()
x = ip()
q = inp()
dt = {}
for i in x: dt[i] = dt.get(i,0)+1
sm = sum(x)
for i in range(q):
    b,c = ip()
    ct = dt.get(b,0)
    if ct == 0:
        print(sm)
        continue
    sm -= ct*b
    sm += ct*c
    print(sm)
    dt[b] = 0
    dt[c] = dt.get(c,0) + ct
    
    

Measured memory_bytes: 83696
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static final int MAX_BIT = 60;
        static final long BIGX = (1L << (MAX_BIT - 1));
        static final long BIGY = (1L << MAX_BIT);

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            long[] x = new long[n];
            long[] y = new long[n];
            for (int i = 0; i < n; ++i) {
                x[i] = in.nextLong();
                y[i] = in.nextLong();
            }
            long res = BIGX;
            for (int bit = 0; bit < MAX_BIT; ++bit) {
                long y0 = -(BIGY + (BIGY - 1) - (1L << bit));
                long x0 = BIGX;
                long r = 0;
                for (int i = 0; i < n; ++i) {
                    long dy = y[i] - y0;
                    long dx = x0 - x[i];
                    if ((dy & dx) == dx) {
                        r ^= 1;
                    }
                }
                if (r == 0) res -= (1L << bit);
            }
            out.println(res);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



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

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  if (A == B && B != C)
    cout << "Yes" << endl;
  else if (B == C && C != A)
    cout << "Yes" << endl;
  else if (C == A && A != B)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def main():

    A, B, C, K = map(int, input().split())
    num = 0

    if K > A:
        num += A
        K -= A
        if K > B:
            K -= B
            num -= K
    else:
        num+=K

    print(num)

if __name__ == '__main__':
    main()


Measured memory_bytes: 61640
#include <bits/stdc++.h>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

typedef pair<double, int> PD;

 
const ll MOD=1e9+7;
const ll INF=1e18;
 
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};


int main(){
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		int k,p;
		cin >> k >> p;
		int pp = 0;
		while(k - (pp+p) > 0){
			pp += p;
		}
		if(k <= p){
			cout << k << endl;
		}else{
			cout << k - pp << endl;
		}
	}
}


Measured memory_bytes: 3100
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 567890;
int C[MAXN];
int bit[MAXN], ans[MAXN];
int cnt[MAXN], pos[MAXN];

struct Query {
    int l, r, idx;
    Query(int _l, int _r, int _i) : l(_l), r(_r), idx(_i) {}
    bool operator < (const Query &a) const {
        return r < a.r;
    }
};

int query(int x) {
    int res = 0;
    while (x >= 1) {
        res += bit[x];
        x -= (x & -x);
    }
    return res;
}

void add(int x, int val, int N) {
    while (x <= N) {
        bit[x] += val;
        x += (x & -x);
    }
}

int main() {
    int N, Q;
    scanf("%d %d", &N, &Q);
    for (int i = 1; i <= N; i++)
        scanf("%d", &C[i]);
    vector<Query> V;
    for (int i = 0; i < Q; i++) {
        int l, r;
        scanf("%d %d", &l, &r);
        V.push_back(Query(l, r, i));
    }
    sort(V.begin(), V.end());
    int cur = 1;
    for (auto q : V) {
        int l = q.l, r = q.r, idx = q.idx;
        while (cur <= r) {
            int num = C[cur];
            if (cnt[num]) add(pos[num], -1, N);
            cnt[num]++;
            pos[num] = cur;
            add(cur, 1, N);
            cur++;
        }
        ans[idx] = query(r) - query(l - 1);
    }
    for (int i = 0; i < Q; i++) {
        printf("%d\n", ans[i]);
    }
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
by Benq;
*/


Measured memory_bytes: 19556
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountll
#define m_p make_pair
#define inf 1e18+1
#define eps 0.000000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
 
//////////////
auto clk=clock();
#define all(x) x.begin(),x.end()
#define se second
#define fi first
#define sz(x) ((long long)x.size())
#define int long long  
#define f80 __float128
#define pii pair<int,int>
/////////////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	map<int,int> m;
	int a[n+1];
	int ans=0;
	for(int i=1;i<=n;++i){
		cin>>a[i];
		ans+=m[a[i]];
		m[a[i]]++;
	}
	for(int i=1;i<=n;++i)
	{
		cout<<ans-m[a[i]]+1<<"\n";
	}
	#ifdef ANIKET_GOYAL
		cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
	#endif
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
int main(){
	ll k,a,b,ans=1;
	cin>>k>>a>>b;
	bool flag=false;
	if(a+2<=b)flag=true;
	while(k>0){
		if(flag&&ans>=a&&k>=2){//コインの交換条件を満たしてる時
			ll hoge=k/2;
			ans-=a*hoge;
			ans+=b*hoge;
			k-=hoge*2;			
		}
		else if(flag&&k>=(a-ans)&&ans<a){//多分初期状態
			k-=a-ans;
			ans+=a-ans;		
		}
		else{
			ans+=k;
			k=0;
		}	
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
from collections import deque
h,w = map(int,input().split())
sss = [list(input()) for i in range(h)]


def dfs(a,b):
    d = deque([])
    d.append([a,b])
    n = [1,0,-1,0]
    m = [0,1,0,-1]
    l = [[-1]*w for _ in range(h)]
    l[a][b]=0
    while len(d)!=0:
        #print(l)
        s = d.popleft()
        s1,s2 = s[0],s[1]
        for i in range(4):
            if 0<=s1+m[i] and s1+m[i]<=h-1 and 0<=s2+n[i] and s2+n[i]<=w-1:
                if sss[s1+m[i]][s2+n[i]]=="." and l[s1+m[i]][s2+n[i]]==-1:
                    d.append([s1+m[i],s2+n[i]])
                    l[s1+m[i]][s2+n[i]] = l[s1][s2]+1
    t = 0
    for j in l:
      for m in j:
        t = max(t,m)
    return t
t = 0
for i in range(w):
    for j in range(h):
      if sss[j][i]==".":
        t = max(t,dfs(j,i))
print(t)


Measured memory_bytes: 3956
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t A, B, C;
  cin >> A >> B >> C;
  // const int64_t L = static_cast<int64_t>(T.length());
  bool is_okay = ((A == B) && (B == C));
  if (is_okay) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
pub struct Scanner<R> {
    reader: R,
}

impl<R> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader }
    }
}

fn is_whitespace(b: u8) -> bool {
    b == b' ' || b == b'\n' || b == b'\r' || b == b'\t'
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        let buf = std::io::Read::bytes(self.reader.by_ref())
            .map(|b| b.expect("Read failed"))
            .skip_while(|&b| is_whitespace(b))
            .take_while(|&b| !is_whitespace(b))
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error")
    }

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

    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

fn main() {
    let stdin = std::io::stdin();
    let mut sc = Scanner::new(stdin.lock());
    loop {
        let n: usize = sc.read();
        if n == 0 {
            break;
        }
        let mut a: Vec<i64> = sc.read_vec(n);
        a.sort();
        let ans = (0..n - 1).map(|i| a[i + 1] - a[i]).min().unwrap();
        println!("{}", ans);
    }
}



Measured memory_bytes: 5060
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
int r,g,b,n,ans;
int main(){
	cin>>r>>g>>b>>n;
	for(int i=0;i<=n/r;i++)
		for(int j=0;j<=n/g;j++)
		{
			int num=n-i*r-j*g;
			if(num/b<0)
				continue;
			if(num%b==0)
				ans++;
		}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
d={}

for i in range(n):
    w=list(input())
    w.sort()
    s="".join(w)
    if s in d:
        d[s]+=1
    else:
        d[s]=1
ans=0
for i in d:
    ans+=d[i]*(d[i]-1)//2
print(ans)

Measured memory_bytes: 60504
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#define ll long long int
#define inf 100000000000
using namespace std;
int main(){
    int n;
    cin>>n;
    ll ma=inf;
    ll x,y;
    while(n--){
        cin>>x>>y;
        ma=min(x+y,ma);
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 256