akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
const ll N=13,mod=1000000007;
ll dp[N][100001]={0};
signed main()
{
    fast;
    ll pro=1,temp,t,n,i,m,k,j,l,r,mid,x,y,z,rem,carry=0,ind,ans=0,mx=-llinf,mn=llinf,cnt=0,curr=0,prev,sum=0,flag=1,i1=-1,i2=-1;
    string s;
    cin>>s;
    n=s.length();
    dp[0][0]=1;
    rep(i,0,n-1)
    {
        if(s[i]=='?')
        {
            rep(j,0,9)
            {
                rep(k,0,12)
                {
                    temp=k*10+j;
                    rem=temp%13;
                    dp[rem][i+1]=(dp[rem][i+1]+dp[k][i])%mod;
                }
            }
        }
        else
        {
            x=s[i]-'0';
            for(j=0;j<13;j++)
            {
                temp=j*10+x;
                rem=temp%13;
                dp[rem][i+1]=dp[j][i];
            }
        }
    }
    cout<<dp[5][n];
    return 0;
} 

Measured memory_bytes: 10604
class Stack
  def initialize(max)
    @top = 0
    @max = max
    @s = Array.new(max)
  end

  def is_empty?
    @top == 0
  end

  def is_full?
    @top >= (@max -1)
  end

  def push(x)
    if is_full?
      raise "オーバーフローしました"
    end
    @top += 1
    @s[@top] = x
  end

  def pop
    if is_empty?
      raise "アンダーフローしました"
    end
    @top -=1
    @s[@top+1]
  end

  # def dump
  #   puts @s
  # end

  def answer
    @s[0]
  end
end

def calc_reverse_polish_notation(stack, x)
  if x == "+"
    a = stack.pop()
    b = stack.pop()
    stack.push(b + a)
  elsif x == "-"
    a = stack.pop()
    b = stack.pop()
    stack.push(b - a)
  elsif x == "*"
    a = stack.pop()
    b = stack.pop()
    stack.push(b * a)
  else
    x = x.to_i
    stack.push(x)
  end
end

stack = Stack.new(200)
arr = gets.split
arr.each do |x|
  calc_reverse_polish_notation(stack, x)
  # stack.dump
end
puts stack.pop


Measured memory_bytes: 8924
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
 
using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs
 
struct E { lli i, j, c; };
 
lli n;
vector<lli> x, y;
vector<E> e;
vector<lli> uf;
 
lli root(lli i) {
  if (uf[i] < 0) return i;
  return uf[i] = root(uf[i]);
}
 
bool same(lli i, lli j) {
  return root(i) == root(j);
}
 
void unite(lli i, lli j) {
  if (!same(i, j)) uf[root(i)] = root(j);
}
 
int main() {
  cin >> n;
  init_n(x, n); init_n(y, n);
  for (lli i=0; i<n; ++i) cin >> x[i] >> y[i];
 
  vector<lli> ix(n); iota(begin(ix), end(ix), 0);
  sort(begin(ix), end(ix), [&](lli i, lli j) { return x[i] < x[j]; });
  for (lli i=0; i<n-1; ++i) 
    e.push_back({ix[i], ix[i+1], abs(x[ix[i+1]] - x[ix[i]])});
  vector<lli> iy(n); iota(begin(iy), end(iy), 0);
  sort(begin(iy), end(iy), [&](lli i, lli j) { return y[i] < y[j]; });
  for (lli i=0; i<n-1; ++i) 
    e.push_back({iy[i], iy[i+1], abs(y[iy[i+1]] - y[iy[i]])});
 
  sort(begin(e), end(e), [](E& e, E& f) { return e.c < f.c; });
 
  init_n(uf, n, -1);
  lli ans = 0;
  for (E& f : e) {
    // cout << f.i << ',' << f.j << ' ' << f.c << endl;
    if (!same(f.i, f.j)) {
      unite(f.i, f.j);
      ans += f.c;
    }
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 11504
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
ll from, to, cost;
bool operator<(const E &b) const { return cost < b.cost; }
bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
		h = "";
		i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
ld dp[301][301][301];
bool used[301][301][301];
ld solve(int x, int y, int z) {
	if (!x && !y && !z) return 0;
	if (used[x][y][z]) return dp[x][y][z];
	ld sum = 0;
	if (x) sum += solve(x - 1, y, z)*x;
	if (y) sum += solve(x + 1, y - 1, z)*y;
	if (z) sum += solve(x, y + 1, z - 1)*z;
	sum += n;
	sum *= (1. / (x + y + z));
	used[x][y][z] = 1;
	return dp[x][y][z] = sum;
}
signed main() {
	cin >> n;
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < n; i++) {
		int u = read();
		if (u == 1) a++;
		if (u == 2) b++;
		if (u == 3) c++;
	}
	printf("%.20LF\n", solve(a, b, c));
}

Measured memory_bytes: 452864
#include <stdio.h>
int main(void)
{
 char S[11];
 char T[11];
 char U[11];
 int A,B;
 scanf("%s %s",S,T);
 scanf("%d %d",&A,&B);
 scanf("%s",U);
 if(strcmp(S,U)==0) printf("%d %d\n",A-1,B);
 else printf("%d %d\n",A,B-1);
 return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#define endl '\n'
#define ll long long
#define mod 1000000007
#define NCONS 1000000000
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
inline ll gcd(ll a, ll b) { if(a < b) swap(a, b); if(b <= 0) return a; return gcd(b, a % b); }

int main(void)
{
    cin.tie(NULL); ios_base::sync_with_stdio(false);
    ll r, D, x; cin >> r >> D >> x;
    
    for(int i = 0; i < 10; i++)
    {
        x = r * x - D;
        cout << x << endl;
    }
    
   
    return 0;
}


Measured memory_bytes: 256
n,a,b = gets.chomp.split.map(&:to_i)
if n+1 < a+b || a*b < n
  printf("%d\n",-1)
  exit
end

result = []
min = 1
max = n
possible = true

b -= 1
while min <= max
  if max-a+1 <= min
    result.concat((min..max).to_a)
    break
  else
    result.concat(((max-a+1)..max).to_a)
  end
  max -= a
  a -= 1
  
  if max <= min+b-1
    result.concat((min..max).to_a.reverse)
    break
  else
    result.concat((min..(min+b-1)).to_a.reverse)
  end
  min += b
  b -= 1
end

printf("%s\n",result.join(" "))

Measured memory_bytes: 10568
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	void run() {
		String[][] num = {{".", ",", "!", "?", " "},
		{"a", "b", "c"},
		{"d", "e", "f"},
		{"g", "h", "i"},
		{"j", "k", "l"},
		{"m", "n", "o"},
		{"p", "q", "r", "s"},
		{"t", "u", "v"},
		{"w", "x", "y", "z"}};
		int n = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < n; i++) {
			sb.delete(0, sb.length());
			String number = sc.next();
			int prev = 0, count = 0;
			for (int j = 0; j < number.length(); j++) {
				int k = Integer.parseInt(""+number.charAt(j));
				if (prev != 0 && k == prev) {
					count++;
				} else if (prev != 0 && k == 0) {
					sb.append(num[prev-1][count%num[prev-1].length]);
					count = 0;
					prev = 0;
				} else if (prev == 0 && k != 0) {
					prev = k;
				}
			}
			out.println(sb);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 31200
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

int a[10010];
int n, m, s;

int main() {
    read(n), read(m);
    for (int i = 1; i <= m; ++i)    read(a[i]), s += a[i];
    if (s <= n) printf("%d\n", n - s);
    else    printf("-1\n");
    return 0;
}

Measured memory_bytes: 3728
#include <iostream>

using namespace std;

int main()
{
    int a[100000] ,n ;
    cin>>n;
    int i , c=0;
    for(i=1;i<=n;i++){cin>>a[i];}
    for(i=1;i<=n;i++){
        if(i%2!=0){
            if(a[i]%2!=0){c=c+1;}
        }}
        cout<<c;
    return 0;
}



Measured memory_bytes: 3560
n = int(input())
for i in range(n):
  l = [1,0,0,0]
  c = 0
  o_c = 0
  while True:
    s = input()
    if s == 'HIT':
      if l[3] == 1:
        c += 1
      for i in range(4):
        if i == 3:
          l[3-i] == 1
        else:
          l[3-i] = l[2-i]
    elif s == 'HOMERUN':
      c += sum(l)
      l = [1,0,0,0]
    else:
      o_c += 1
      if o_c == 3:
        print(c)
        break

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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec[i];
  }
  vector<int> ans(N);
  for(int i=0; i < N; i++){
      ans[vec[i]-1] = i + 1;
  }
  for(int i=0; i < N-1; i++){
      cout << ans[i] << " ";
  }
  cout << ans[N-1] << endl;
}

Measured memory_bytes: 1664
#include <stdio.h>
#define MIN(x, y) (((x) > (y)) ? (y) : (x))
#define ABS(x) ((x) >= 0 ? (x) : (-(x)))

// int m[10000];
int main()
{
  int a, b, c, d;
  scanf("%d %d %d %d", &a, &b, &c, &d);

  while (1)
  {
    c -= b;
    if (c <= 0)
    {
      printf("Yes");
      return 0;
    }
    a -= d;
    if (a <= 0)
    {
      printf("No");
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 2144
#include<iostream>

using namespace std;

int main(){
  int k,a,b,c,mx=0,sm=0;
  cin >> a >>b >>c>>k;
  mx = max(a, max(b,c));
  sm+=a+b+c-mx;
  for(int i=0;i<k;i++){
    mx*=2;
  }
  cout << sm+mx << endl;
}

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

#define N 100000

int main(void){
    unsigned long long sum = 0;
    int n;
    cin >> n;
    vector<int> nums(N+1);
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
        sum += a.at(i);
        nums.at(a.at(i)) += 1;
    }
    int q;
    cin >> q;
    int b, c;
    for(int i = 0; i < q; i++){
        cin >> b >> c;
        if(nums.at(b) != 0){
            int dif = c - b;
            sum += nums.at(b) * dif;
            nums.at(c) += nums[b];
            nums[b] = 0;
        }
        cout << sum << endl;
    }
}


Measured memory_bytes: 3980
n, k, q = map(int, input().split())
a = [int(x) for x in input().split()]
m = None
for x in a:
    b = []
    c = []
    for y in a:
        if y < x:
            if len(c) >= k:
                c.sort()
                b.extend(c[:len(c) - k + 1])
            c = []
        else:
            c.append(y)
    if len(c) >= k:
        c.sort()
        b.extend(c[:len(c) - k + 1])
    if len(b) >= q:
        b.sort()
        if m is None or m > b[q - 1] - x: m = b[q - 1] - x
print(m)


Measured memory_bytes: 3316
#include<cstdio>
#include<algorithm>
using namespace std;

int main()
{
	int N,T[101],M,P,X,sum,m;
	scanf("%d",&N);
	for(int i=1; i<=N; i++)
	{
		scanf("%d",&T[i]);
	}
	scanf("%d",&M);
	for(int i=1; i<=M; i++)
	{   
        sum=0;
		scanf("%d %d",&P,&X);
		m=T[P];
		T[P]=X;
		for(int j=1; j<=N; j++)
		{
			sum+=T[j];
		}
		printf("%d\n",sum);
		T[P]=m;
	}	
return 0;
}

Measured memory_bytes: 128
// Aizu Vol-5 0549: A Traveler
// 2017.8.31 bal4u@uu

#include <stdio.h>

#define abs(a) ((a)>=0?(a):-(a))

int s[100003];

int main()
{
	int n, m, i, k, p1, p2, ans;

	scanf("%d%d", &n, &m);
	for (s[1] = 0, i = 2; i <= n; i++) scanf("%d", &k), s[i] = s[i-1] + k;
	for (ans = 0, p1 = 1, i = 1; i <= m; i++, p1 = p2)	{
		scanf("%d", &k);
		p2 = p1 + k;
		ans += abs(s[p2] - s[p1]), ans %= 100000;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 984
mod = 1000000007
from collections import defaultdict
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
d1 = defaultdict(lambda:0)
d2 = defaultdict(lambda:0)
ca = 0
cb = 0
cc = 0
for i in range(N):
    a,b = AB[i]
    if a==0 and b!=0:
        ca += 1
        continue
    elif a!=0 and b==0:
        cb += 1
        continue
    elif a==0 and b==0:
        cc += 1
        continue
    a_ = abs(a)
    b_ = abs(b)
    d = gcd(a,b)
    if d != 0:
        a //= d
        b //= d
    if a < 0:
        a *= -1
        b *= -1
    if b>0:
        d1[(a,b)] += 1
    else:
        d2[(a,b)] += 1
        d1[(-b,a)] += 0

ans = pow(2,ca)+pow(2,cb)-1
for a,b in d1:
    x = d1[(a,b)]
    y = d2[(b,-a)]
    ans *= pow(2,x,mod)+pow(2,y,mod)-1
    ans %= mod
ans -= 1
ans += cc
ans %= mod
print(ans)

Measured memory_bytes: 183280
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;

  if(N<1000){
    cout << "ABC" << endl;
  }else{
    cout << "ABD" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main() {
string a;
  
 
  cin >> a ;

  for(int i=0;i<a.size();i++){
    if(((1+i)%2 ==0)&&(a[i] == 'R')){
      cout << "No" << endl;
      
      return 0;
    }
    if(((1+i)%2 == 1)&&(a[i] == 'L')){
      cout << "No" << endl;
      
      return 0;
    }
  }
  
  cout <<"Yes" << endl;
}
    


Measured memory_bytes: 256
def resolve():
	n, k = map(int, input().split())
	arr = [0]*(10**5+1)
	for i in range(n):
		a, b = map(int, input().split())
		arr[a] += b
	for i in range(len(arr)):
		if arr[i] >= k:
			print(i)
			break
		k -= arr[i]
resolve()

Measured memory_bytes: 45400
#include <stdio.h>

int main(){
    double a;
    double b[1001];
    double c;
    double d=0;
    
    scanf("%lf",&a);
    
    for(int i=0;i<a;i++){
        scanf("%lf",&b[i]);
    }
    for(int i=0;i<a;i++){
        c=1/b[i];
        d+=c;
    }
    d=1/d;
    printf("%lf",d);
    return 0;
}



Measured memory_bytes: 128
N,A,B,C = map(int,input().split())
l = [int(input()) for i in range(N)]
def dfs(k,a,b,c):
    global N,A,B,C,l
    if k == N:
        return abs(a-A)+abs(b-B)+abs(c-C)-30 if min(a,b,c)>0 else 1000000
    det0 = dfs(k+1, a+l[k], b, c)+10
    det1 = dfs(k+1, a, b+l[k], c)+10
    det2 = dfs(k+1, a, b, c+l[k])+10
    det3 = dfs(k+1, a, b, c)
    return min(det0, det1, det2, det3)
print(dfs(0,0,0,0))

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		String s = scn.next();
      	int k = scn.nextInt();
      	String[] list = s.split("");
      	String x = list[k-1];
      	for(int i=0; i<s.length(); ++i){
          if(!(list[i].equals(x))){
            list[i] = "*";
          }
          System.out.print(list[i]);
        }
	}
}

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

int a[200005];

int main() {
	cin.tie(NULL); cout.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	int N; cin >> N;

	int all = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
		all ^= a[i];
	}

	for (int i = 1; i <= N; i++) {
		int ans = 0;
		for (int l = 0; (1 << l) <= a[i] || (1 << l) <= all; l++) {
			if (((1 << l) & a[i]) ^ ((1 << l) & all)) ans += (1 << l);
		}
		cout << ans << ' ';
	}

	return 0;
}

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

int main() {
    int n,x,y;
    cin>>n;
    vector<pair<long long,long long> >co(n);
    for(int i=0;i<n;i++) {
        cin>>x>>y;
        co[i].first=x;
        co[i].second=y;
    }
    sort(co.begin(), co.end());
    long long mini1=co[0].first-co[0].second,mini2=co[0].first+co[0].second,maxi1=co[0].first-co[0].second,maxi2=co[0].first+co[0].second;
    for(int i=1;i<n;i++) {
        mini1 = min(mini1, co[i].first-co[i].second);
        mini2 = min(mini2, co[i].first+co[i].second);
        maxi1 = max(maxi1, co[i].first-co[i].second);
        maxi2 = max(maxi2, co[i].first+co[i].second);
    }
    cout<<max(maxi2-mini2,maxi1-mini1)<<endl;
    return 0;
}

Measured memory_bytes: 6344
N=input()
T=[]
A=[]
for i in range(N):
    Ti,Ai=map(int,raw_input().split())
    T.append(Ti)
    A.append(Ai)

Tn=1
An=1

for i in range(N):
    T_res=Tn%T[i]
    A_res=An%A[i]
    if T_res==0:
        T_q=Tn/T[i]
    else:
        T_q=(Tn+T[i]-T_res)/T[i]
    if A_res==0:
        A_q=An/A[i]
    else:
        A_q=(An+A[i]-A_res)/A[i]

    q=max(T_q,A_q)

    Tn=q*T[i]
    An=q*A[i]
        
        
print Tn+An


Measured memory_bytes: 2696
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		String S=s.next(),T=s.next();
		int A=s.nextInt(),B=s.nextInt();
		String U=s.next();
		System.out.println(U.equals(S)?(A-1)+" "+B:A+" "+(B-1));
	}
}

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

using namespace std;

int main() {
	int N, K;
  	int a;
  	cin >> N >> K;
  	vector<int> arr;
  	for(int i = 0; i < N; i++) {
      	cin >> a;
      	arr.push_back(a);
    }
    
  	vector<bool> dp(K+1, false);
  	
  	for(int stones = 0; stones <= K; stones++) {
		for(int x : arr) {
			if(stones >= x && !dp[stones - x]) {
				dp[stones] = true;
			}
		}
	}
  	
  	bool ans = dp[K];
  	
  	if(ans == true) {
		cout << "First" << endl;
	} else {
		cout << "Second" << endl;
	}
}

Measured memory_bytes: 3648
N, K = map(int,input().split())
An = list(map(int,input().split()))
f_count = 0
r_count = 0

for i in range(N):
    for j in range(N):
        if i < j:
            if An[i] < An[j]:
                f_count += 1
            elif An[i] > An[j]:
                r_count += 1

Ans = (f_count * K*(K-1)//2 + r_count * (K*(K+1)//2)) % (10**9+7)

print(int(Ans))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
const int mxN=100001;

vector<int> adj[100001];
bool vis[100001];

void dfs(int node){
	vis[node]=true;
	for(int child : adj[node]){
		if(vis[child]==false){
			dfs(child);
		}
	}
}

void solve(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int a,b;
		cin>>a>>b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	int count=0;
	for(int i=1;i<=n;i++){
		if(vis[i]==false){
			dfs(i);
			count++;
		}
	}
	cout<<count-1<<endl;
}

int main(){
	solve();
}

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

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;
const long long MOD = (ll)1e9+7;
// const long long MOD = (ll)1e6+3;
const long long MAX = (ll)1e5+10;

ll N,M,V,P;
vector<ll> A;

bool Judge(ll ind) {
   if (ind >= N-P) return true;
   if (A[ind]+M < A[N-P]) return false;
   // ll area = M * V;
   // area -= M * (P-1);
   // if (area <=0) return true;
   // area -= M * (ind+1);
   if (V - P - ind <= 0) return true;
   ll area = M * (V - P + 1 - ind - 1);
   if (area <=0) return true;
   rep(i,ind+1,N-P+1) {
      // cout<<ind<<" "<<i<<" "<<area<<endl;
      area -= (A[ind]+M - A[i]);
      if (area <= 0) return true;
   }
   if (area <=0) return true;
   else return false;
}

int main(void) {
   cin>>N>>M>>V>>P;
   A.resize(N);
   rep(i,0,N) cin>>A[i];
   sort(A.begin(),A.end());
   // rep(i,0,N) cout<<Judge(i)<<endl;

   ll re = N-1;
   ll le = 0;
   while(1) {
      ll ne = (le+re)/2;
      if (le == ne || re == ne) break;
      if(Judge(ne)) re = ne;
      else le = ne;
   }
   if (le != re) {
      if (Judge(le)) re = le;
   }
   ll ans = 0;
   if (Judge(0)) ans = N;
   else ans = N - re;
   cout<<ans<<endl;






   return 0;
}

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

const int maxn = 401;
ll dp[maxn][maxn];

int main() {
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++)
            dp[i][j] = (i == j) ? 0 : 1e13;
    }
    vector<ll> cumsum(n+1); cumsum[0] = 0;
    rep(i, n) cumsum[i+1] = cumsum[i] + a[i];

    for(int i = n - 2; i >= 0; i--) {
        for(int j = i + 1; j < n; j++) {
            for(int k = i; k < j; k++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k + 1][j] + cumsum[j+1] - cumsum[i]);
            }
        }
    }
    cout << dp[0][n-1] << endl;
    return 0;
}


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

typedef long long ll;

ll gcd(ll a, ll b){
    return (a%b ? gcd(b,a%b) : b);
}

int main(){
    ll a,b;
    while(std::cin >> a >> b){
        ll c = gcd(a,b);
        std::cout << c << " " << a/c*b << std::endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <algorithm>
#include <functional>
#include <iostream>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

using vll = vector<ll>;

void solve();

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

  solve();

  return 0;
}

#define ini(...)   \
  int __VA_ARGS__; \
  in(__VA_ARGS__)

#define inl(...)  \
  ll __VA_ARGS__; \
  in(__VA_ARGS__)

#define ins(...)      \
  string __VA_ARGS__; \
  in(__VA_ARGS__);

void in() {}
template <typename T, class... U>
void in(T& t, U&... u) {
  cin >> t;
  in(u...);
}

void out() {
  cout << endl;
}
template <typename T, class... U>
void out(const T& t, const U&... u) {
  cout << t;
  if (sizeof...(u))
    cout << " ";
  out(u...);
}

#define rep(i, n) for (long long i = 0; i < n; i++)

void solve();
#ifndef ONLINE_JUDGE
#include "./lib.hpp"
#endif

const ll MOD = 1000000007;

void solve() {
    ini(N);
    vll A(N);
    rep(i, N) cin >> A[i];

    sort(A.begin(), A.end(), greater<ll>());
    rep(i, N / 2) {
        if (A[2 * i] != N - 2 * i - 1 || A[2 * i + 1] != N - 2 * i - 1) {
            out(0);
            return;
        }
    }
    if (N % 2 == 1 && A[N - 1] != 0) {
        out(0);
        return;
    }

    ll ret = 1;
    rep(i, N / 2)
        ret = (ret * 2) % MOD;
    out(ret);
}


Measured memory_bytes: 3928
#include<stdio.h>
int main()
{
    int w,a,b,t;
    while(scanf("%d%d%d",&w,&a,&b)==3)
    {
        if(b<a)
        {
            t=b;
            b=a;
            a=t;
        }
        t=b-w-a;
        if(t<=0)
            printf("0\n");
        else
            printf("%d\n",t);
    }
    return 0;
}



Measured memory_bytes: 128
def main():
    n = iread()
    t = sread()
    s = t[:int(n/2)]
    if s == t[int(n/2):]:
        print("Yes")
    else:
        print("No")


def iread():
    return int(input())


def sread():
    return input()


def aread(t="int"):
    if t == "int":
        ret = [int(i) for i in input().split()]
    elif t == "str":
        ret = list(input().split())
    return ret


def scan():
    return list(map(int, input().split()))


if __name__ == '__main__':
    main()


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

int dp[101][4][4][4];
int mod = 1000000007;

int main(){
  dp[0][3][3][3]=1;
  int i,j,k,l,m;
  int n;cin>>n;


  for(i=0;i<n;i++){
    for(j=0;j<4;j++){
      for(k=0;k<4;k++){
        for(l=0;l<4;l++){
          if(dp[i][j][k][l]==0) continue;
            for(m=0;m<4;m++){
              if(k==0 && l==1 && m==2) continue;
              if(k==0 && l==2 && m==1) continue;
              if(k==1 && l==0 && m==2) continue;
              if(j==0 && k==1 && m==2) continue;
              if(j==0 && l==1 && m==2) continue;

              dp[i+1][k][l][m] += dp[i][j][k][l];
              dp[i+1][k][l][m] %= mod;

          }
        }
      }
    }
  }

  int ans=0;

  for(i=0;i<4;i++){
    for(j=0;j<4;j++){
      for(k=0;k<4;k++){
        //if(dp[n][i][j][k]) cout<<i<<" "<<j<<" "<<k<<endl;
        ans+=dp[n][i][j][k];
        ans%=mod;
      }
    }
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

const int inf = 1e9;
const int maxN = 4005;
int p[2][maxN];
int cost[2][maxN][maxN];
int dp[maxN][maxN];

int main() {
	int N; cin >> N; 
	for(int i = 1; i <= 2 * N; ++i) {
		char c; int x; cin >> c >> x;
		p[c == 'W'][x] = i;
	}
	for(int k = 0; k < 2; ++k) {
		for(int i = 1; i <= N; ++i) {
			for(int j = 1; j < i; ++j) cost[k][i][0] += (p[k][j] > p[k][i]);
			for(int j = 1; j <= N; ++j) cost[k][i][j] = cost[k][i][j - 1] + (p[1 - k][j] > p[k][i]); 
		}
	}
	for(int i = 0; i <= N; ++i) for(int j = 0; j <= N; ++j) dp[i][j] = inf;
	dp[0][0] = 0;
	for(int i = 0; i <= N; ++i) {
		for(int j = 0; j <= N; ++j) {
			if(i == N && j == N) continue;
			if(i < N) dp[i + 1][j] = min(dp[i + 1][j], dp[i][j] + cost[0][i + 1][j]);
			if(j < N) dp[i][j + 1] = min(dp[i][j + 1], dp[i][j] + cost[1][j + 1][i]);
		}
	}
	cout << dp[N][N] << endl;
}

Measured memory_bytes: 98176
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
	string n;
	int i;
	cin>>n;
	bool flg=true;
	//int flg1=0;
	int cnt=0,x;
	if(n[0]!='A'){
		flg=false;
		//flg1=1;
	}
	else{
		for(i=2;i<n.size()-1;i++){
			if(n[i]=='C'){
				cnt++;
				x=i;
			}
		}
		if(cnt!=1){
			flg=false;
		//	flg1=2;
		}
		else{
			for(i=1;i<n.size();i++){
				if(x!=i){
					if(!(n[i]>='a'&&n[i]<='z')){
						flg=false;
					//	flg1=3;
					}
				}
			}
		}
	}
	cout<<((flg)?"AC":"WA")<<endl;
	//cout<<flg1<<endl;
	return 0;
}	

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

int main(){
string S;
cin >> S;
string SS =S;
int N = S.size()-1  ;
int64_t ans=0;

for(int tmp=0;tmp<(1 << 9);tmp++){
  bitset<9> op(tmp);

  if(tmp >= (1<<N)) break;
  int64_t num=0;
  S = SS;
  for (int i=0; i<N;i++){
    if(op.test(i) == 1){
      S.insert(N-i,"+");
    }
  }
  
 
  for(int i =0;i<S.size();i++){
    
      if(S.at(i) != '+'){
        num = num*10+S.at(i)-'0';
      
       }
       else if(S.at(i)=='+') {
           
           ans += num;
 
           num = 0;
       }
    }
    ans += num;
    
 
}  

  cout << ans <<endl;
  
    

}

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

using namespace std;

const int M = 1e5;

int n, mod = 1e9 + 7, memo[M];
bool broken[M];

int solve(int i) {
    if (i > n)
        return 0;
    if (i == n)
        return 1;
    if (broken[i])
        return 0;

    int &r = memo[i];

    if (r == -1)
        r = (1ll * solve(i + 1) + solve(i + 2)) % mod;
    return r;
}

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

    memset(memo, -1, sizeof memo);
    int m;
    cin >> n >> m;
    while (m--) {
        int b;
        cin >> b;
        broken[b] = 1;
    }

    cout << solve(0) << '\n';

    return 0;
}

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

int h, w, a, b, f[200001], mod = 1e9 + 7;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }






int bk(int h, int w) {
    return mul(f[h + w - 2], inv(mul(f[h - 1], f[w - 1])));
}

int main() {
    f[0] = 1;
    for(int i = 1; i < 200001; ++i)
        f[i] = mul(f[i - 1], i);
    cin >> h >> w >> a >> b;
    int sum = 0;
    for(int i = b + 1; i <= w; ++i)
        adds(sum, mul(bk(i, h - a), bk(w - i + 1, a)));
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  ll N;
  cin >> N;
  string ans="";
  while(N>0) {
    N--;
    int k = N%26;
    ans += 'a'+k;
    N /= 26;
  }
  reverse(rng(ans));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
using Graphl = vector<vector<ll>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define FOR(itr, v) for (auto itr = (v).begin(); itr != (v).end(); ++itr)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> void PrintVector(const vector<T> &vec) {for (auto val : vec) cout << val << " "; cout << endl;}
const long long INF = 1LL << 60;
const long long minusINF = -(1LL << 40);
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    int x, n; cin >> x >> n;
    set<int> p;
    rep(i, n)
    {
        int a; cin >> a; p.insert(a);
    }

    int mini = MOD;
    int ans = 0;
    Rep(i, 0, 102)
    {
        if (p.count(i)) continue;
        int a = abs(i - x);
        if (a < mini)
        {
            mini = min(a, mini);
            ans = i;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, Z;
  cin >> a >> b;

  Z = a * b;

  if (Z % 2 == 0){
      cout << "Even" << endl;
  }
  else {
      cout << "Odd" << endl;
  } 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,W;
	cin>>n>>W;
	int w[n],v[n];
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	long long dp[n][W+1];
	for(int i=0;i<n;i++){
		for(int j=0;j<=W;j++){
			dp[i][j]=INT_MIN;
		}
	}
	for(int i=0;i<n;i++){
		dp[i][0]=0;
	}
	dp[0][w[0]]=v[0];
	for(int i=1;i<n;i++){
		for(int j=1;j<=W;j++){
			if(w[i]<=j){
				dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i]]+v[i]);
			}else{
				dp[i][j]=dp[i-1][j];
			}
			if(dp[i][j]<0){
				dp[i][j]=INT_MIN;
			}
			//cout<<dp[i][j]<<" "<<i<<" "<<j<<" ";
		}
	}
	long long ans=0;
	for(int i=1;i<=W;i++){
		ans=max(ans,dp[n-1][i]);
	}
	if(ans<0){
		cout<<-1;
	}else{
	
	cout<<ans;}
}

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

int main() {
    int N, L, i;
    cin >> N;
    cin >> L;
    vector<string> s(N);
    
    for (i=0; i<N; i++){
        cin >> s[i];
    }

    sort(s.begin(), s.end());

    for(i=0; i<N; i++){
        cout << s[i];
    }

    return 0;
}

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

int main(){
  vector<int> v;
  for(int i=0;i<10;i++){
    int m;
    cin >> m;
    v.push_back(m);
  }


  sort(v.begin(), v.end(), greater<int>());

  cout << v.at(0) << endl;
  cout << v.at(1) << endl;
  cout << v.at(2) << endl;

  return 0;
}



Measured memory_bytes: 3140
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<cmath>
#include<iomanip>
using namespace std;
	int main(){
		int N,M,D,x,y,yoko,tate,kazu;
		char map[1000][1000];
		kazu=0;
		cin>>N>>M>>D;
		for(y=0;y<N;y++){
			for(x=0;x<M;x++){
				cin>>map[x][y];
			}
		}
		for(y=0;y<N;y++){
			for(x=0;x<M;x++){
				for(tate=0;tate<D;tate++){
					if(map[x][y+tate]!='.'){
						break;
					}if(tate==D-1){
						kazu++;
					}
				}
				for(yoko=0;yoko<D;yoko++){
					if(map[x+yoko][y]!='.'){
						break;
					}if(yoko==D-1){
						kazu++;
					}
				}
			}
		}cout<<kazu<<endl;
		return 0;
	}







Measured memory_bytes: 3180
#include <stdio.h>

int main(void){
    int h, w;
    char a[100+5][100+5];
    scanf("%d %d", &h, &w);
    for(int i=0; i<h; i++)scanf("%s", a[i]);
    // check bit
    for(int i=0; i<h; i++)a[i][w]='o';
    for(int i=0; i<w; i++)a[h][i]='o';
    
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(a[i][j]=='#')break;
            if(j==w-1)a[i][w]='x';
        }
    }
    for(int i=0; i<w; i++){
        for(int j=0; j<h; j++){
            if(a[j][i]=='#')break;
            if(j==h-1)a[h][i]='x';
        }
    }
    
    for(int i=0; i<h; i++){
        if(a[i][w]=='o'){
            for(int j=0; j<w; j++){
                if(a[h][j]=='o')printf("%c", a[i][j]);
            }
            printf("\n");
        }
    }
    return 0;
}


Measured memory_bytes: 1644
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const int N = 3e5+6;
const int M = 998244353;
const ll inf = 1e16;
ll iv[N],f1[N],f2[N];
ll nck(int n, int k) {
	return f1[n]*f2[k]%M*f2[n-k]%M;
}
void solve(){
    iv[1]=1;
	for(int i=2; i<N; ++i)
		iv[i]=M-M/i*iv[M%i]%M;
	f1[0]=f2[0]=1;
	for(int i=1; i<N; ++i) {
		f1[i]=f1[i-1]*i%M;
		f2[i]=f2[i-1]*iv[i]%M;
	}
	ll ans = 0;
	ll n,m,k;
	cin>>n>>m>>k;
	ll trt = m;
	for(int i=n-1;i>k;i--){
        trt*=(m-1);
        trt%=M;
	}
    for(int i=k;i>=0;i--){
        ll tmp = nck(n-1,i);
        ans+=(trt*tmp)%M;
        ans%=M;
        trt*=(m-1);
        trt%=M;
    }
    cout<<ans<<endl;
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
//    cin>>t;
    while(t--)solve();
    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<string> v;
    map<string,int> m;
    for(int i=0;i<n;i++)
    {
        string s;
        cin >> s;
        v.push_back(s);
        sort(s.begin(),s.end());
        if(m[s]>=1)  m[s]++;
        else    m[s]=1;
    }
    long long sm=0;
    for(map<string,int>::iterator it=m.begin();it!=m.end();++it)
    {
        if(it->second>1)
        {
            //cout << it->second << " ";
            long long ss = (it->second*1LL*(it->second-1))/2;
            //cout << ss << "\n";
            sm+=ss;
        }
    }
    cout << sm;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    map<string,int> kuji_map;
    for(int i=0;i<n;i++){
        string str;
        cin >> str;
        if(kuji_map.count(str)){
            continue;
        }else{
            kuji_map[str] = 1;
        }
    }

    cout << kuji_map.size() << endl;
}

Measured memory_bytes: 19184
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():

    s = S()
    cur_c = s[0]
    ans = "Good"
    for c in s[1:]:
        if c == cur_c:
            ans = "Bad"
        cur_c = c
    print(ans)
main()



Measured memory_bytes: 7748
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
ans=0
for i in range(N):
    A=list(map(int,input().split()))
    all=0
    for j in range(M):
        all+=B[j]*A[j]
    if all+C>0:
        ans+=1
print(ans)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
using namespace std;
int main(){
  long long n,m;cin>>n>>m;
  long long ans = 0;
  for(long long i = 1; m >= i*i; i++){
    if(!(m%i)){
      if(m/i >= n){
        ans = max(ans,i);
      }
      if(i >= n){
        ans = max(ans,m/i);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n, m = gets.strip.split.map(&:to_i)
ab = readlines.map {|line| line.strip.split.map(&:to_i) }

ab = ab.sort_by(&:last)

#p ab

result=0
until ab.empty?
  cf, ct = c = ab.shift
  ab = ab.reject{|f, t| f < ct }
  result+=1
end

p result


Measured memory_bytes: 86116
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;

class segmentTree{
public:
  int size; //要素数
  int* seg; //実際に値を格納する配列(初期化の際は大きさをsize*2-1で)

  //コンストラクタ segの大きさに注意
  segmentTree(int n){
    size=1;
    while(size<n) size *= 2;
    seg = new int[size*2-1];

    for(int i=0; i<size*2-1; i++) seg[i]=0;
  }

  //k番目にaを加算
  void add(int k, int a){
    k += size-1;
    seg[k] += a;
    //木を登りながら更新
    while(k>0){
      k = (k-1)/2;
      seg[k] = seg[k*2+1] + seg[k*2+2];
    }
  }

  //クエリから求める和を計算する関数
  //[a, b)の和をを節点番号k, 区間[l, r)を指定して返す
  int getSum(int a, int b, int k, int l, int r){
    //もし指定した範囲が[a, b)の範囲外ならばINT_MAXを返しておく
    if(r <= a || b <= l) return 0;

    //[a, b)が[l, r)を完全に含むならば、その節点の値を返す
    if(a <= l && r <= b) return seg[k];

    else{
      int vl = getSum(a, b, k*2+1, l, (l+r)/2);
      int vr = getSum(a, b, k*2+2, (l+r)/2, r);
      return vl+vr;
    }
  }

  void print(){
    cout << "size: " << size << endl;
    for(int i=0; i<2*size-1; i++) cout << i << ": " << seg[i] << " ";
    cout << endl;
  }

  //デストラクタ
  ~segmentTree(){
    delete[] seg;
  }
};

int main(){
  int n, q; cin >> n >> q;
  segmentTree st(n+1);

  int ope, x, y;
  int ans[q]; int j=0;
  for(int i=0; i<q; i++){
    cin >> ope >> x >> y;
    if(ope==0) st.add(x-1, y);
    else ans[j++] = st.getSum(x-1, y, 0, 0, st.size);
  }

  for(int i=0; i<j; i++) cout << ans[i] << endl;

  return 0;
}



Measured memory_bytes: 4124
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cstring>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };
 
int MOD = 1000000007;

int main() {
	vector<int> a(3); cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[0] << ' ' << a[1] << ' ' << a[2] << endl;
}

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

using namespace std;


// Bismilahir Rahmanir Rahim


typedef unsigned int ui;
typedef long long int lli;
typedef unsigned long long int ulli;
typedef short int si;
typedef unsigned short int usi;
typedef pair <int, int> pii;


#define CASE false
#define TEST false
#define BUFFER true
#define TIME false
#define DEBUG true
#define SET_GEN false
#define _ << " " <<
#define __ << "\n"
#define ff first
#define ss second
#define RANGE(a, b) (rand() % (b-a+1) + a)


const double pi = acos(-1.);
const double eps = 1e-7;
const int high = 2e9;
const int inf = 2147483647;
const int _inf = -2147483648;
const lli INF = 1e18;
const int mod = 1e9+7;


void delay(int sec); // DEBUG


void solution(void)
{	
	int n, w;
	
	cin >> n >> w;
	
	vector <ulli> dp(w+1);
	
	for(int i = 0; i < n; ++i) {
		int weight, val;
		cin >> weight >> val;
		
		for(int j = w-weight; j >= 0; --j) {
			dp[j+weight] = max(dp[j+weight], dp[j] + val);
		}	
	}
	
	
	cout << dp[w] __;
	

    return ;
}

int main(int argc, char *arv[])
{
    #if BUFFER
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #endif

    #if SET_GEN
    srand((unsigned int) time(0));
    #endif

    int t = 1;

    #if CASE
    int cnt = 1;
    #endif

    #if TEST
    cin >> t;
    #endif

    #if TIME
    clock_t start_time, end_time;
    double time_elapsed;
    #endif


    while(t--) {

        #if TIME
        start_time = clock();
        #endif

        #if CASE
        cout << "Case " << cnt++ << ": ";
        #endif

        solution();

        #if TIME
        end_time = clock();

        time_elapsed = (double) (end_time - start_time) / CLOCKS_PER_SEC;

        cout << "\nRuntime: " << fixed << setprecision(7) << time_elapsed << "\n";
        #endif
    }


    return 0;
}

void delay(int sec)
{
    int mili_sec = 1000 * sec;

    clock_t start_time = clock();

    while (clock() < start_time + mili_sec);

    return ;
}


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

int main() {
int N;
cin >>N;
bool A=false;
for(int i=0;i<=9;i++){
for(int j=0;j<=9;j++){
if(N==i*j){A=true;break;}
}
}

if(A){
cout << "Yes"<< endl;}
else{cout << "No"<<endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define pi 3.1415926535897932384
#define INF 2147483647
#define EPS 1e-8
#define MOD 1000000007
#define MAX 300005
using namespace std;

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

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    #ifdef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ll n;

    cin>>n;
    if(n & 1){
        cout<<0<<endl;
        return 0;
    }

    ll p = 10, cnt = 1;
    ll sum = 0;
    while(p <= n){
        sum += (n / p);
        p *= 5;
    }

    cout<<sum<<endl;

    return 0;
}


Measured memory_bytes: 256
import math
from collections import defaultdict
def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

'''D'''
n=r()
a=rl()
ma=max(a)
b=[0]*(ma+1)
a.sort()
for i in a:
    if b[i]!=0:
        b[i]+=1
        continue
    else:
        b[i]+=1
    for j in range(2*i,ma+1,i):
        b[j]+=1
ans=0
for i in a:
    if b[i]==1:
        ans+=1
print(ans)

Measured memory_bytes: 134976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define loop(n)      for(int i=0;i<(n);i++)
#define lp(x,s,e)    for(int x=(s);x<(e);x++)
#define lpe(x,s,e)    for(int x=(s);x<=(e);x++)
#define endl '\n'
using namespace std;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
   long long n,m;
   cin>>n>>m;
   long long a[m];
   ll sum=0;
   for(int i=0;i<m;i++){
    cin>>a[i];
    sum+=a[i];
   }
   if(sum<=n)
    cout<<n-sum;
   else
    cout<<-1;
}

Measured memory_bytes: 3688
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	long long n,cnt=1;
	long long ans=0;
    cin>>n;
    vector<string> s(n);
    rep(i,n)cin>>s[i];
    rep(k,n)sort(s[k].begin(),s[k].end());
    sort(s.begin(),s.end());
    s.push_back("");
    rep(l,n){
        if(s[l+1]==s[l])cnt++;
        else{
            ans+=cnt*(cnt-1)/2;
            cnt=1;
        }
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 8064