akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;
#define dTolerance 1.0e-10

int main(){
    double x1,x2,y1,y2,r1,r2;
    scanf("%lf %lf %lf", &x1, &y1, &r1);
    scanf("%lf %lf %lf", &x2, &y2, &r2);
    double dDist = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
    double xPoint = ( dDist * dDist * (x1 + x2) + (r1 * r1 - r2 * r2) * (x2 - x1) ) / (2 * dDist * dDist);
    double yPoint = ( dDist * dDist * (y1 + y2) + (r1 * r1 - r2 * r2) * (y2 - y1) ) / (2 * dDist * dDist);
    if(fabs(r1 - r2) < dTolerance){
        xPoint = (x1 + x2) / 2;
        yPoint = (y1 + y2) / 2;
    }
    double xAns1,xAns2,yAns1,yAns2;
    
    if(fabs(r1 + r2 - dDist) < dTolerance){
        xAns1 = xPoint;
        xAns2 = xPoint;
        yAns1 = yPoint;
        yAns2 = yPoint;
    } else if(fabs(fabs(r1 - r2) - dDist) < dTolerance){
        xAns1 = xPoint;
        xAns2 = xPoint;
        yAns1 = yPoint;
        yAns2 = yPoint;
    } else if(fabs(r1 - r2) < dTolerance){
        xAns1 = xPoint + (y2 - y1) * sqrt(4 * r1 * r1 - dDist * dDist) / (2 * dDist);
        yAns1 = yPoint - (x2 - x1) * sqrt(4 * r1 * r1 - dDist * dDist) / (2 * dDist);
        xAns2 = xPoint - (y2 - y1) * sqrt(4 * r1 * r1 - dDist * dDist) / (2 * dDist);
        yAns2 = yPoint + (x2 - x1) * sqrt(4 * r1 * r1 - dDist * dDist) / (2 * dDist);
    } else {
        xAns1 = xPoint + ( (y2 - y1) * sqrt( (2 * r1 * r1 + 2 * r2 * r2 - dDist * dDist) * dDist * dDist - (r1 * r1 - r2 * r2) * (r1 * r1 - r2 * r2) ) )/ (2 * dDist * dDist);
        yAns1 = yPoint - ( (x2 - x1) * sqrt( (2 * r1 * r1 + 2 * r2 * r2 - dDist * dDist) * dDist * dDist - (r1 * r1 - r2 * r2) * (r1 * r1 - r2 * r2) ) )/ (2 * dDist * dDist);
        xAns2 = xPoint - ( (y2 - y1) * sqrt( (2 * r1 * r1 + 2 * r2 * r2 - dDist * dDist) * dDist * dDist - (r1 * r1 - r2 * r2) * (r1 * r1 - r2 * r2) ) )/ (2 * dDist * dDist);
        yAns2 = yPoint + ( (x2 - x1) * sqrt( (2 * r1 * r1 + 2 * r2 * r2 - dDist * dDist) * dDist * dDist - (r1 * r1 - r2 * r2) * (r1 * r1 - r2 * r2) ) )/ (2 * dDist * dDist);
    }
    
    if(xAns1 > xAns2){
        swap(xAns1, xAns2);
        swap(yAns1, yAns2);
    }
    if(fabs(xAns1 - xAns2) < dTolerance && yAns1 > yAns2){
        swap(xAns1, xAns2);
        swap(yAns1, yAns2);
    }    
    printf("%.10lf %.10lf %.10lf %.10lf", xAns1, yAns1, xAns2, yAns2);
    return 0;
}


Measured memory_bytes: 2808
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int n,k;
string s;

int main()
{
  cin >> s;
  cin >> n;
  unsigned int i =0;
  while(n > 0)
  {
      if(i == (s.length()-1))
      {
          n=n%26;
          if(n > ('z' - s[i]))
          {
              n-=('z' - s[i] + 1);
              s[i]='a';
          }
          s[i]=char(s[i]+n);
          break;
      }
      if (s[i] == 'a')
      {
          ++i;
          continue;
      }
      else
      {
          if(n > ('z' - s[i]))
          {
              n-=('z' - s[i] + 1);
              s[i]='a';
              
          }
          ++i;
          continue;
      }
  }

  cout << s;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};
long long modpow(long long a, long long n){
  long long r = 1;
  while (n) {
    r = r * ( (n%2)?a:1 ) %mod;
    a = a * a % mod;
    n >>= 1;
  }
  return r;
}

int main(void){
    ll k;string s;cin>>k>>s;
    ll n=s.size();
    combination c(2000010);
    mint res=0;
    rep1(i,n+k){
        if(i<n)continue;
        //cout<<i-1<<" "<<n-1<<endl;
        res+=c(i-1,n-1)*modpow(26,n+k-i)*modpow(25,i-n);
    }
    cout<<res.x<<endl;
}

Measured memory_bytes: 35652
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<LL, LL> pii;
vector<LL> fact(LL n) {
    vector<LL> ret;
    for (LL i = 1 ; i * i < 1e12 + 5 ; i++) {
        if (n % i == 0)
            ret.push_back(i);
    }
    return ret;
}
bool go(LL n, LL k) {
    if (k == 1)
        return false;
    while (n >= k) {
        if (n % k == 0)
            n /= k;
        else
            n %= k;
    }
    return n == 1;
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL n; cin >> n;
    vector<LL> a = fact(n);
    vector<LL> b = fact(n-1);
    unordered_set<LL> pool;
    for (auto &v : b) {
        pool.insert(v);
        pool.insert((n - 1) / v);
    }
    for (auto &v : a) {
        if (go(n, v))
            pool.insert(v);
        if (go(n, n / v))
            pool.insert(n / v);
    }
    pool.insert(1);
    cout << pool.size() - 1 << '\n';
}


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scan = new Scanner(System.in)) {
			scan.nextInt();
			int cnt = scan.nextInt();
			List<Integer> prices = new ArrayList<>();
			while(scan.hasNext()) {
				prices.add(scan.nextInt());
			}
			System.out.print(prices.stream().mapToInt(Integer::intValue).sorted().limit(cnt).sum());
		}
	}
}

Measured memory_bytes: 33956
#include<iostream>
#include<cstdio>
#include<cstring>
#include<stdio.h>
#include<algorithm>
#include<string.h>
#include <math.h>
#include<vector>
#include<stack>
#include<math.h>
#include<malloc.h>
#define INF 0x3f3f3f3f
#define maxn 2000006
#define ll long long
using namespace std;
int a[100005];
int n,m;

int main()
{      int  maxs=0,s,mod;
       int i,j;
    cin>>n>>m;
    for(i=m/n;i>=1;i--)
    {
        if(m%i==0)
            break;
    }
    cout<<i<<endl;




}


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

int main () {
  long long N;
  cin >> N;
  
  if (N % 2 == 1){
    cout << 0 << endl;
    return 0;
  }
  
  long long ans = 0;
  N /= 10;
  ans += N;
 
  for (int i = 0; i < 30; i++) {
    N /= 5;
    ans += N;
    if (N == 0){
      cout << ans << endl;
      return 0;
    }
  }
}
    
    
    

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;
int main() {
    long long N; cin >> N;
    vector<long long>A(N);
    long long sum = 0;
    for (long long i = 0; i < N; i++) {
        cin >> A.at(i);
        sum += A.at(i);
    }
    if (sum % 10 != 0) cout << sum << endl;
    else {
        sort(A.begin(), A.end());
        for (int i = 0; i < N; i++) {
            if ((sum - A.at(i)) % 10 != 0) {
                cout << sum - A.at(i) << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <stdio.h>
using namespace std;


int main(){
    int i, N;
    double x;
    string u;
    double ans=0;
    cin >> N;
    for (i=0;i<N;i++){
        cin >> x;
        cin >> u;
        if (u=="JPY") ans+=x;
        else if(u=="BTC") ans+=380000.0*x;
    }

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

Measured memory_bytes: 256
INF=10**18
N,M=map(int,input().split())

a,c=[],[]
for i in range(M):
    A,B=map(int,input().split())  
    C=list(map(int,input().split()))
    tmp=0
    for j in range(B):
      tmp+=1<<(C[j]-1)
    a.append(A)
    c.append(tmp)
    
dp=[[INF]*(1<<N) for i in range(M+1)]
dp[0][0]=0
for i in range(M):
    for j in range(1<<N):
        dp[i+1][j]=min(dp[i+1][j],dp[i][j])
        o=(j | c[i])
        dp[i+1][o]=min(dp[i+1][o],dp[i][j]+a[i])
ans=dp[M][2**N-1]
print(ans if ans!=INF else -1)

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

lint gcd(lint x, lint y) {
  if(x == 0) { return y; }
  else { return gcd(y%x,x); }
}

lint lcm(lint x, lint y) { return x/gcd(x,y)*y; }

lint C(lint n, lint k) {
  if(n == k) { return 1; }
  else if(n < k) { return 0; }
  else if(k == 0) { return 1; }
  else if(k == 1) { return n; }
  else return C(n-1,k-1) + C(n-1,k);
}

lint P(lint n, lint k) {
  if(k == 1) { return n; }
  return (n*(P(n-1,k-1)%1000000007)%1000000007);
}


int main() {
  lint x,k,d; cin >> x >> k >> d;

  lint ans;
  if(abs(x)/d >= k) { ans = abs(x)-k*d; }
  else {
    if( (abs(x)/d)%2 == k%2 ) { ans = abs(x)%d; }
    else { ans = d-abs(x)%d; }
  }

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


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
  string s;
  int k;
  cin >> s >> k;
  set<char> ana;
  for(const char& c : s) ana.insert(c);

  vector<string> subset;
  for(const char c : ana)
  {
    for(int i = 0; i < s.length(); ++i)
    {
      if (s[i] == c)
      {
        for(int j = 1; i + j <= min((int)s.length(), i + k); ++j)
        {
          subset.emplace_back(s.substr(i, j));
        }
      }
    }
    if (subset.size() >= k)
    {
      sort(subset.begin(), subset.end());
      subset.erase( unique(subset.begin(), subset.end()), subset.end() );

      if (subset.size() >= k)
      {
        cout << subset[k - 1];
        return;
      }
    }
  }



}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 4260
X = int(input())
 
score =0
half_x = round(X/2)
 
answer = 0
 
if X < 3:
    print(1)
 
elif X <= 7:
    print(4)
 
else:
    while 1 < half_x:
        half_x -= 1
        
        for p in range(2, 10):
            
            score = pow(half_x,p)
            if score > X:
                continue
        
            if answer < score:
                answer = score
                
    print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s.length()!=6){
        cout<<"No";
        return 0;
    }
    if(s[2]==s[3] && s[4]==s[5]){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<map> 
using namespace std;
using ll = long long;

#define REP(i, n) for (ll i=0; i < n; i++)
ll N, K, L;
ll p, q, r, s;

class UnionFind 
{
    public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1)
    {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    void init(ll sz_) 
    {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) 
    { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) 
    {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) 
    { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x)
    { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main() 
{
    cin >> N >> K >> L;
    UnionFind Road(N), Rail(N);
    
    REP(i, K) 
    {
        cin >>  p >> q; p--; q--;
        Road.merge(p, q);
    }

    REP(i, L)
    {
        cin >> r >> s; r--; s--;
        Rail.merge(r, s);
    }

    map<pair<ll, ll>, ll> mp;
    REP(i, N) mp[{Road.root(i), Rail.root(i)}]++;
    REP(i, N) cout << mp[{Road.root(i), Rail.root(i)}] << " ";
    cout << endl;
}

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

long X, A, B;

int main(void) {

    cin >> X;

    for (A = -1000; A <= 1000; A++) {
        for (B = -1000; B <= 1000; B++) {
            if (A*A*A*A*A - B*B*B*B*B == X) {
                cout << A << " " << B << endl;
                return 0;
            }
        }
    }


    return 0;

}

Measured memory_bytes: 3628
// clang-format

#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;

using lli = long long int;
bool used[200005] = {};
lli cost[200005] = {};
lli color[200005] = {};
vector<int> e[100005];
map<int, map<int, int>> id;
map<int, set<int>> nodes;
void solve(long long N, long long M, std::vector<long long> D,
           std::vector<long long> U, std::vector<long long> V) {
  int n = N;
  vector<pair<lli, lli>> L;
  rep(i, N) L.emplace_back(D[i], i), nodes[D[i]].insert(i);
  // sort(L.begin(), L.end());
  // queue<int> que;
  for (auto s : nodes) {
    auto &hoge = s.first;
    auto &vs = s.second;
    for (auto v : vs) {
      bool flag = false;
      if (color[v] != -1)
        continue;
      for (auto to : e[v]) {
        if (used[to] && !flag) {
          color[v] = color[to];
          cost[id[to][v]] = D[v] - D[to];
          flag = true;
        }
        if (D[v] == D[to] && !flag) {
          if (color[to] != -1) {
            color[v] = 1 - color[to];
            cost[id[to][v]] = D[v];
          } else {
            color[v] = 0;
            color[to] = 1;
            cost[id[to][v]] = D[v];
          }
          flag = true;
        }
      }
      if (!flag) {
        cout << -1 << endl;
        exit(0);
      }
    }
    for (auto v : vs)
      used[v] = true;
  }
  rep(i, n) {
    assert(color[i] != -1);
    cout << (color[i] ? "B" : "W");
  }
  cout << endl;
  rep(i, M) {
    if (cost[i] == -1) {
      cout << 1000000000 << endl;
    } else {
      cout << cost[i] << endl;
    }
  }
  // lli tmp = L[0].first;
  // lli til = 0;
  // rep(i, n) {
  //   if (L[i].first != tmp) {
  //     break;
  //   }
  //   til++;
  // }
  // rep(i, til) used[L[i].second] = true;
  // rep(i, til) {
  //   lli cur = L[i].second;
  //   bool flag = false;
  //   for (auto s : e[cur]) {
  //     if (used[s]) {
  //       flag = true;
  //       cost[id[s][i]] = tmp;
  //     }
  //   }
  //   if (!flag) {
  //   }
  // }
}

int main() {
  int a;
  long long N;
  scanf("%lld", &N);
  long long M;
  scanf("%lld", &M);
  std::vector<long long> D(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &D[i]);
  }
  rep(i, 200005) cost[i] = -1, color[i] = -1;
  std::vector<long long> U(M);
  std::vector<long long> V(M);
  for (int i = 0; i < M; i++) {
    scanf("%lld", &U[i]);
    scanf("%lld", &V[i]);
    U[i]--, V[i]--;
    id[U[i]][V[i]] = i;
    id[V[i]][U[i]] = i;
    e[U[i]].push_back(V[i]);
    e[V[i]].push_back(U[i]);
  }
  solve(N, M, std::move(D), std::move(U), std::move(V));
  return 0;
}


Measured memory_bytes: 58864
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		List<Integer>list = new LinkedList<>();

		for(int i = 1;;i++){
			int num = A * i % B;
			if(num == 0)break;
			list.add(num);
		}

		Collections.sort(list);


		boolean flag = false;

		for(int i = list.size() - 1;0 <= i;i--){
			int num = C % list.get(i);
			if(num == 0){
				flag = true;
				break;
			}
			C = num;
		}

		if(flag){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}

		sc.close();
	}
}


Measured memory_bytes: 23636
#include <iostream>

int main() {
    std::string line;
    std::getline(std::cin, line);
    
    for (char c : line) {
        if (std::isupper(c)) {
            std::cout << (char)std::tolower(c);
        } else if (std::islower(c)) {
            std::cout << (char)std::toupper(c);
        } else {
            std::cout << c;
        }
    }
    std::cout << std::endl;
}



Measured memory_bytes: 3148
#include<stdio.h>
#include<string.h>
int main()
{
	int k,i,len;
	char s[101];
	scanf("%d %s",&k,s);
	len=strlen(s);
	if(len>k){
		for(i=0;i<k;i++){
			printf("%c",s[i]);
		}
		printf("...\n");
	}
	else printf("%s",s); 
	return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define per(i,a,n) for(int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define FI first
#define SE second
#define maxn 200000
#define mod 1000000007
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef double db;

int a[maxn+5];

int main()
{
    int n; scanf("%d",&n);
    rep(i,1,n) scanf("%d",&a[i]);
    sort(a+1,a+n+1,greater<int>());
    ll ans=-a[1];
    rep(i,1,n) ans+=a[(i+1)/2];
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4604
/* 
	Author: ankrypt
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int
#define ff first
#define ss second
#define all(x) x.begin(), x.end() 
#define ub upper_bound
#define lb lower_bound
#define MAX_INT 200005
#define fi(a, b, c, d) for(int a = b; i < c; i += d)
#define fl(a, b, c, d) for(ll a = b; i < c; i += d)
#define quit exit(0)

ll N, M, A, B, C;
ll arr[MAX_INT], arr1[MAX_INT], data[MAX_INT];
vector<ll> V;


int main() {
	scanf("%lld %lld", &N, &M);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	ll ans = 0;
	for(int i = 1; i < N; i++) {
		ans += min(M, arr[i] - arr[i - 1]);
	}
	ans += M;
	printf("%lld\n", ans);
	
	return 0;
}
/*
	Powered by Buggy Plugin
*/




Measured memory_bytes: 2944
/*A - Remaining Balls*/

#include <bits/stdc++.h>

using namespace std;

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

	vector <pair <string, int> > balls(2);

	cin >> balls[0].first >> balls[1].first;
	cin >> balls[0].second >> balls[1].second;

	string cad;

	cin >> cad;

	if(cad == balls[0].first)
		balls[0].second--;
	else
		balls[1].second--;

	cout << balls[0].second << ' ' << balls[1].second;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

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

ll conv(string num) { stringstream ss; ss << num << flush; ll n; ss>>n; return n; }

string conv(ll n) { stringstream ss; ss << n << flush; return ss.str(); }

vector<string> split(string s, string delim) {
    vector<string> res;
    int pos = 0;
    while(true) {
        int found = s.find(delim, pos);
        if(found >= 0) {
            res.push_back(s.substr(pos, found - pos));
        }
        else {
            res.push_back(s.substr(pos));
            break;
        }
        pos = found + delim.size();
    }
    return res;
}
int ALPH_SIZE = 26;
char ALPH_L[] = {'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'};
char ALPH_U[] = {'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 par[MAXN];
int rnk[MAXN];

void init(int n) {
    for(int i=0; i<n; i++) {
        par[i] = i; // 自分自身が親 = representative
        rnk[i] = 0;
    }
}

int find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]); // parx[x] =  で親を付け替え 再帰的にrootを検索
}

bool same(int x, int y) {
    return find(x) == find(y);
}

void unite(int x, int y) {
    //find representatives
    x = find(x);
    y = find(y);
    
    if (x == y) return;

    if (rnk[x] < rnk[y]) {
        par[x] = y; //xの方がrank低い => xをyを親として付け足す
    } else { 
        par[y] = x;
        if (rnk[x] == rnk[y]) ++rnk[x];
    }
}

int main() {
    int n, q, a, b, com;

    cin >> n >> q;

    init(n);
    for(int i=0; i<q; i++) {
        cin >> com >> a >> b;
        if (com == 0) {
            unite(a, b);
        } else {
            if (same(a, b)) cout << 1 << endl;
            else cout << 0 << endl;
        }
    }
}



Measured memory_bytes: 3172
#include <iostream>
using namespace std;
int main()
{
    int x,y;
    cin >> x >> y;
    string s[x];
    for (int i=0;i<x;i++){
        cin >> s[i];
    }
    for (int i=0;i<x;i++){
        for (int j=0;j<2;j++){
            cout << s[i] << endl;
        }
    }
    return 0;
  }


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

//深さ優先探索を行い、条件を満たす物が何通りあるか調べる関数
int counter(vector<vector<int>> &board, vector<bool> &seen, int &count, int N, int before, int just){
    seen[just] = true;

    bool all_seen = true;

    for(int i=1; i<=N; i++){
        if(seen[i] == false) all_seen = false;
    }

    if(all_seen){
        count++;
        seen[just] = false;
        return 0;
    }

    seen[just] = false;

    for(int i : board[just]){
        if(i == before || seen[i]) continue;

        seen[just] = true;

        counter(board, seen, count, N, just, i);

        seen[just] = false; 
    }

    return 0;
}

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

    vector<vector<int>> board(N + 1);
    for(int i=0; i<M; i++){
        int a, b;
        cin >> a >> b;

        board[a].push_back(b);
        board[b].push_back(a);
    }

    vector<bool> seen(N+1, false);
    seen[0] = true;

    int count = 0;

    counter(board, seen, count, N, 0, 1);

    cout << count << endl;

}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	char a,b;
	cin>>a>>b;
	if((a=='H'&&b=='H')||(a=='D'&&b=='D'))
	cout<<"H";
	else
	if((a=='H'&&b=='D')||(a=='D'&&b=='H'))
	cout<<"D";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// typedef long long int;
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
int MOD=1e9+7;
const int maxn=3e5+5;

int r[maxn], c[maxn];
vi matrix[maxn];

int32_t main(){
    // fast_io;
    int n, m;
    cin >> n >> m;
    int t;
    cin >> t;
    vector<pair<int, int> > v;
    while(t--){
    	int x, y;
    	scanf("%d%d",&x, &y);
    	// cin >> x >> y;
    	matrix[x].emplace_back(y);
    	v.emplace_back(x,y);
    	r[x]++;
    	c[y]++;
    }
    int ans = 0;
    for(const auto &it:v){
    	ans = max(ans, r[it.first] + c[it.second] - 1);
    }
    set<pair<int, int> > s;
    for (int i = 1; i <= m; ++i)
    {
    	if(c[i] > 0) {
    		s.insert({c[i], i});
    		// update(i, c[i]);
    	}
    }
    for (int i = 1; i < n+1; ++i)
    {
    	for(const auto &it:matrix[i]){
    		// update(it, -c[it]);
    		s.erase(s.find({c[it], it}));
    	}

    	if(! s.empty()) 	ans = max(ans, r[i] + (*(s.rbegin())).first);
    	for(const auto &it:matrix[i]){
    		// update(it, c[it]);
    		s.insert({c[it], it});
    	}
    }
    show(ans);
    return 0;
}

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

#define ll long long
#define int long long
#define MOD 1000000007
#define MAX 100001
#define debugStart cout << "\n[DEBUG START]\n"
#define debugStop cout << "\n[DEBUG STOP]\n"
#define KHATAM cout << std::endl;


auto solve ( int* arr, int size, int K ) -> int {

        int DP[size];
        memset(DP,0, sizeof(DP));
        DP[0] = 0;
        DP[1] = abs( arr[0] - arr[1] );
        for ( int i = 2; i < size; ++i ) {
                int minimum = INT32_MAX;
                for ( int j = 1; j <= K; ++j ) {
                        if ( (i-j)>=0 ) {
                                minimum = std::min( minimum , DP[i-j] + abs(arr[i] - arr[i-j]) );
                        }
                }
                DP[i] = minimum;
        }        
        return DP[size - 1];
}


signed
main() {

        ios_base::sync_with_stdio(0);
        cin.tie(0);
        int T = 1; 
        // cin >> T;
        for ( int testcase = 1; testcase <= T; ++testcase ) {
                
                int size, K;
                std::cin >> size >> K; 
                int arr[size];
                for ( int i = 0; i < size; ++i ) {
                        std::cin >> arr[i];
                }
                std::cout << solve(arr, size, K); 
                std::cout << '\n';
        }
        return 0;
}

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

int A, B, C, D;

int main() {
  cin >> A >> B >> C >> D;
  cout << (abs(A - C) <= D || (abs(A - B) <= D && abs(B - C) <= D) ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
rectArray = []

h, w = input().split()
h = int(h)
w = int(w)

while h != 0 and w != 0:
    rectArray.append([h, w])
    h, w = input().split()
    h = int(h)
    w = int(w)



for x in rectArray:
    for i in range(x[0]):
        if i == 0 or i%2 == 0:
            lever = True
        else:
            lever = False
        for j in range(x[1]):
            if lever == True:
                print("#", end = '')
                lever = False
            else:
                print(".", end ='')
                lever = True
        print("")
    print("")

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

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int H,W;
    cin >> H >> W;
    vector<vector<string>> S(H,vector<string>(W));
    rep(i,H)rep(j,W){
        cin >> S[i][j];
    }
    rep(i,H)rep(j,W){
        if(S[i][j]=="snuke"){
            cout << (char)(j + 'A') << i+1 << endl;
            return 0;
        }
    }
}

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

template <typename T>
vector<pair<T, int>> factorize(T x) {
	vector<pair<T, int>> res;
	for (T i = 2; i * i <= x; i++) {
		if (x % i == 0) {
			res.emplace_back(i, 0);
			while (x % i == 0) {
				res.back().second++;
				x /= i;
			}
		}
	}
	if (x > 1) {
		if (!res.empty() && res.back().first == x)
			res.back().second++;
		else
			res.emplace_back(x, 1);
	}
	return res;
}

int main()
{
	ll N, P;
	cin >> N >> P;
	ll res = 1;
	for (auto p : factorize(P)) {
		p.second /= N;
		for (int i = 0; i < p.second; ++i) res *= p.first;
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=500+10;
char s[maxn][maxn];
int p[maxn][maxn],q[maxn][maxn];
int main(){
	int n=read(),m=read();
	REP(i,1,n) scanf("%s",s[i]+1);
	REP(i,1,n){
		p[i][1]=1;
		if(i&1) REP(j,1,m-1) p[i][j]=1;
	}
	REP(i,1,n){
		q[i][m]=1;
		if(i%2==0) REP(j,2,m) q[i][j]=1;
	}
	REP(i,1,n){
		REP(j,1,m)
			if(p[i][j] || s[i][j]=='#') putchar('#');
			else putchar('.');
		putchar('\n');
	}
	REP(i,1,n){
		REP(j,1,m)
			if(q[i][j] || s[i][j]=='#') putchar('#');
			else putchar('.');
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
using namespace std;
int main (void) {
    string S, T;
    cin >> S >> T;

    int a = 0;

    for (int i = 0; i < 3; i++)
    {
        if (S[i] == T[i])
        {
            a++;
        }
        
    }

    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int i,j,k;
    int n,x,count;
    
    while(1){
        count=0;
        scanf("%d %d", &n, &x);
        if(n == 0 && x == 0)break;
        for(i=1; i<=n; i++){
            for(j=i+1; j<=n; j++){
                for(k=j+1; k<=n; k++){
                    if(i+j+k == x)count++;
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}



Measured memory_bytes: 2104
MOD = 10**9 + 7
def mod_pow(p, q):
    res = 1
    while q > 0:
        if q & 1:
            res = (res * p) % MOD
        q //= 2
        p = (p * p) % MOD
    return res

def solve(n, k):
    dp = [0] * (k+1)
    ans = 0
    for x in range(k, 0, -1):
        dp[x] = mod_pow((k // x), n) - sum(dp[y] for y in range(2*x, k+1, x))
        dp[x] %= MOD
        ans += dp[x] * x
    return ans % MOD

n, k = map(int, input().split())
print(solve(n, k))

Measured memory_bytes: 11212
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin


def ii(): return int(stdin.readline())


def fi(): return float(stdin.readline())


def mi(): return map(int, stdin.readline().split())


def fmi(): return map(float, stdin.readline().split())


def li(): return list(mi())


def lsi():
    x=list(stdin.readline())
    x.pop()
    return x


def si(): return stdin.readline()


def sieve(x):
    a=[True]*(x+1)
    sq=floor(sqrt(x))
    for i in range(3, sq+1, 2):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]=False
    if x>1:
        p=[2]
    else:
        p=[]
    for i in range(3, x+1, 2):
        if a[i]:
            p.append(i)
    return p
#vowel={'a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'}
#pow=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808]
############# CODE STARTS HERE #############
a=lsi()
s, e=0, len(a)-1
c=0
while s<e:
    if a[s]!=a[e]:
        c+=1
    s+=1
    e-=1
print(c)

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

using namespace std;

#define N 4005

const int mod=1000000007;
int n,m,p,f[N][N],ans;

void upd(int &x,int y){x=(x+y)%mod;}

int main(){
	scanf("%d%d%d",&n,&m,&p); --p;
	f[0][0]=1;
	for (int i=1;i<=(n+m)/p;++i){
		for (int j=0;j<=(i-1)*p;++j)
			for (int k=0;k<=p;++k)
				upd(f[i][j+k],f[i-1][j]);
		for (int j=0;j<=(i-1)*p;++j)
			for (int k=1;k<=p;++k){
				int s1=j+k,s2=(i-1)*p-j+p+1-k;
				if (s1<=n&&s2<=m&&s1%p==n%p&&s2%p==m%p) upd(ans,f[i-1][j]);
			}
	}
	printf("%d\n",ans);
	
	return 0;
}
			

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

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;

const long long INF = 1LL << 60;
typedef pair<int, int> P;

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

    vector<vector<int>> tv(C, vector<int>(200002, 0));
    vector<int> res(200002, 0);
    rep(i, N) {
        int s, t, c;
        cin >> s >> t >> c;
        tv[c - 1][(s * 2) - 1] = 1;
        tv[c - 1][t * 2] = 1;
    }

    rep(i, C) {
        int fl = 0;
        rep(j, 200002) {
            if (tv[i][j] == 1) {
                if (fl == 0) fl = 1;
                else fl = 0;
            }
            else {
                tv[i][j] = fl;
            } 
        }
    }

    int ans = 0;
    rep(i, 200002) {
        int tmp = 0;
        rep(j, C) {
            tmp += tv[j][i];
        }
        ans = max(ans, tmp);
    }

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

Measured memory_bytes: 24576
#include<stdio.h>
int main(void){
    int N;
    long long x = 2;
    long long y = 1;
    long long z;
    scanf("%d",&N);
    if(N==1){
        printf("%d",1);
    }
    else{
    for(int i = 0 ; i < N - 1 ; i++){
    z = y + x;
    x = y;
    y = z;
    }
    printf("%lld",z);
    }
}

Measured memory_bytes: 1732
from functools import lru_cache

@lru_cache(maxsize=100000)
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 15880
/******************************************
* AUTHOR : RAJAGOPALAN *
* NICK : ARNO *
* INSTITUTION : VIT *
******************************************/
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define alli(a, n, k) (a+k),(a+n+k)
#define REP(i, a, b, k) for(__typeof(a) i = a;i < b;i += k)
#define REPI(i, a, b, k) for(__typeof(a) i = a;i > b;i -= k)
#define REPITER(it, a) for(__typeof(a.begin()) it = a.begin();it != a.end(); ++it)

#define eps 1e-6
#define pi 3.141592653589793
using namespace std;
template<class T> inline T gcd(T x, T y) { if (!y) return x; return gcd(y, x%y);}
typedef vector<int> VII;
typedef vector<ll> VLL;
typedef pair<int, int> PII;
typedef vector< pair<int, int> > VPII;
typedef vector< pair<int, PII > > VPPI;
const int MOD = 1e9 + 7;
const int INF = 1e9;
string LCS(string s,string t,int i,int j,string res)
{
    if(i>=s.size() || j>=t.size())
    return res;

    string a1,a2,a3;
    if(s[i]==t[j])
    {
        a1=LCS(s,t,i+1,j+1,res+s[i]);
    }

    else
    {
        a2=LCS(s,t,i+1,j,res);
        a3=LCS(s,t,i,j+1,res);
    }
    if(a1.size()>=a2.size() && a1.size()>=a3.size())
    return a1;
    else if (a2.size() >= a1.size() && a2.size() >= a3.size())
    return a2;
    else
    return a3;
}
int main(int argc, char* argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    int u=s.size(),v=t.size();
    int dp[u+1][v+1];
    for(int i=0;i<=u;++i)
    {
        for(int j=0;j<=v;++j)
        {
            if(i==0 || j==0)
            dp[i][j]=0;

            else if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];

            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    string ans="";
    int i=u,j=v;
    while(i>0 && j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans+=s[i-1];
            i--;
            j--;
        }
        else if(dp[i-1][j]>dp[i][j-1])
        i--;
        else
        j--;
    }
    reverse(ans.begin(),ans.end());
    cout<<ans;
    return 0;
}

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

typedef long long ll; // -9,223,372,036,854,775,808 から 9,223,372,036,854,775,807

template <class T> using vec = std::vector<T>;
template <class T> using vec2 = vec<vec<T>>;
template <class T> using vec3 = vec<vec<vec<T>>>;

// #define DEBUG

void solve(long long N, long long X, long long Y){
    // シフト
    X--;
    Y--;
    // 表つくる
    vec2<ll> dists(N, vec<ll>(N, N+1));
    vec<ll> nums(N+1, 0);
    // i,jをなめる
    for(int i=0; i < N; i++){
        for(int j=i+1; j < N; j++){
            ll first = j - i;
            ll second = abs(X - i) + 1 + abs(Y - j);
            #ifdef DEBUG
            printf("*START: hoge\n");
            cout << min(first, second) << endl;
            printf("*END: hoge\n");
            #endif
            dists[i][j] = min(first, second);
            nums[dists[i][j]]++;
        }
    }


    for(int i=1; i <= N-1; i++){
        cout << nums[i] << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long X;
    scanf("%lld",&X);
    long long Y;
    scanf("%lld",&Y);
    solve(N, X, Y);
    return 0;
}


Measured memory_bytes: 31616
import numpy as np
q = input()

n = np.zeros((q, 2), dtype=np.int64)
for i in range(0, q):    
    n[i, :] = map(int, raw_input().split())

for i in range(0, q):


    s = n[i, 0] * n[i, 1]
    m = int(np.floor(np.sqrt(s)))

    # print m, s

    if n[i, 0] == n[i, 1]:        #equal
        print m * 2 - 2
    elif m ** 2 == s:         # square
        print m * 2 - 3
    # elif m ** 2 == s - 1:         # square - 1
    #     print m * 2 - 3
    elif m ** 2 < s - m:         # square - 1
        print m * 2 - 1
    else:
        print m * 2 - 2


    # mmm = []
    # for j in range(2, M + 1):
    #     # print mmm
    #     mm = M / j
    #     # print mm
    #     if mm in mmm or mm < 1:
    #         print len(mmm)
    #         break
    #     else:
    #         mmm.append(mm)







Measured memory_bytes: 16136
#include <bits/stdc++.h>
#define sz(arr) (int)(arr).size()
#define rng(arr) arr.begin(), arr.end()
#define show(x) cout << #x << " = " << x << endl;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
typedef long long int ll;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

#define Cins(T, n, xs) \
  vector<T> xs(n);     \
  for (int i = 0; i < n; ++i) cin >> xs[i]

void Main();
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(15);
  Main();
  return 0;
}

void Main() {
  Cin(int, n, k);
  map<int, int> mp;
  rep(_, n) {
    Cin(int, a);
    mp[a]++;
  }

  using pii = pair<int, int>;
  vector<pii> v;
  for (auto e : mp) v.push_back(e);

  sort(rng(v), [](pii a, pii b) { return a.second < b.second; });

  int kind = 0;
  for (auto e : v) kind += e.second > 0;

  int ans = 0;
  for (auto& e : v) {
    if (kind <= k) break;
    ans += e.second;
    kind--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 11764
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
const int MAXN = 2*1e5;
vector<int> pri(2*(int)1e5,true);

void prim(){
	pri[1] = false;
	for(int i=2;i*i<MAXN;i++){
		if(pri[i])
			for(int j=2*i;j<MAXN;j+=i)
				if(pri[j])pri[j] = false;
	}
}
int main(){
	int n,p;
	prim();
	while(cin >>n>>p,n!=-1){
		vector<int> twop;
		int limitt = n+ n/100 +p*10;
		for(int i=n+1;i<limitt;i++){
			if(pri[i])
				for(int j=i;j<limitt;j++){
					if(pri[j])twop.push_back(i+j);
				}
		}
		sort(twop.begin(),twop.end());
		cout << twop[p-1] << endl;
	}
	return 0;
}

Measured memory_bytes: 3432
#include<queue>
#include<algorithm>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
using namespace std;


int a[100005];

int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    int l=a[1];
    int now=0;
    int ans=0;
    for(int i=2;i<=n;i++)
        {
            if(a[i]<=l)
            ans++;
            else
            {
                now=max(now,ans);
                ans=0;
            }
            l=a[i];
        }
    now=max(now,ans);
    cout<<now<<endl;
    return 0;
}
///*
//
//4 6 0
//0 1 2
//1 2 2
//1 3 1
//0 2 5
//1 3 3
//0 3 4
//
//
//
//*/


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

#define l 	long
#define ll 	long long
#define vll vector<ll> 
#define vi 	vector<int>
#define pb push_back
#define pi 3.14159265358979323846264338327950L

// #define rep(j,n,s)  for(long i=j;i<=n;i+=s)
#define forn(j,n,s) for(long i=j; i<n; i+=s)
#define rep(i,n,s) 	for(		; i<n; i+=s)

#define read(k)		ll k; cin>>k;
#define range(v)	begin(v), end(v)
#define X first
#define Y second

void solve() 
{
    //Answer here.
    read(a); read(b);	read(H);	read(M);

    double t1 = 2*pi*H/12.0, t2 = 2*pi*M/60, t3 = 2*pi/12 * M/60;

    double angleH = t1+t3, angleM = t2;

    double x = a*sin(angleH) - b*sin(angleM);
    double y = a*cos(angleH) - b*cos(angleM);

    cout<<fixed<<setprecision(12)<<sqrt(x*x + y*y)<<endl;

    // // cout<<angleH<<" "<<angleM<<endl;
    // cout<<sin(angH)<<" "<<cos(angH)<<endl;

    // double xH = a * sin(angH), yH = a*cos(angH);

    // // cout<<xH<<" "<<yH<<endl;

    // double xM = b * sin(angM), yM = b*cos(angM);

    // // cout<<sin(angM)<<" "<<cos(angM)<<endl;

    // // cout<<xM<<" "<<yM<<endl;

    // double xd = abs(xM - xH), yd = abs(yH - yM);

    // cout<<sqrt(xd*xd + yd*yd)<<endl;
    

}

int main(){

	#ifndef ONLINE_JUDGE
			freopen("input", "r", stdin);
			freopen("output","w",stdout);
	#endif

	ios_base::sync_with_stdio(0);	cin.tie(NULL);	cout.tie(0);
    int t=1;  //cin>>t;
    while(t--)  solve();

    return 0;
}


Measured memory_bytes: 3948
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)

class UnionFind(n: Int) {
    data class Node(var parent: Int, var size: Int)
    val nodes = Array<Node>(n) { Node(parent = it, size = 1) }
    fun findRoot(x: Int): Int {
        if (x == nodes[x].parent) return x
        nodes[x].parent = findRoot(nodes[x].parent)
        return nodes[x].parent
    }
    fun unite(x: Int, y: Int) {
        var xRoot = findRoot(x)
        var yRoot = findRoot(y)
        if (xRoot == yRoot) return
        if (getSize(xRoot) < getSize(yRoot)) {
            nodes[xRoot].parent = yRoot
            nodes[yRoot].size += nodes[xRoot].size
        } else {
            nodes[yRoot].parent = xRoot
            nodes[xRoot].size += nodes[yRoot].size
        }
    }
    fun getSize(x: Int) = nodes[findRoot(x)].size
    fun isSame(x: Int, y: Int) = findRoot(x) == findRoot(y)
}

fun solve(N: Int, M: Int, p: IntArray, x: IntArray, y: IntArray){
    val uf = UnionFind(N)
    repeat(M){
        uf.unite(x[it]-1, y[it]-1)
    }
    var ans = 0
    for ( i in 0 until N ){
        if ( uf.isSame(i, p[i] - 1) ){ ans++ }
    }
    pw.println(ans)
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val N = sc.next().toInt()
    val M = sc.next().toInt()
    val p = IntArray(N)
    for (i in 0 until N) {
        p[i] = sc.next().toInt()
    }
    val x = IntArray(M)
    val y = IntArray(M)
    for (i in 0 until M) {
        x[i] = sc.next().toInt()
        y[i] = sc.next().toInt()
    }
    solve(N, M, p, x, y)
}



Measured memory_bytes: 50536
from sys import stdin
#from collections import deque
#from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin, tan


def ii(): return int(stdin.readline())


def fi(): return float(stdin.readline())


def mi(): return map(int, stdin.readline().split())


def fmi(): return map(float, stdin.readline().split())


def li(): return list(mi())


def lsi():
    x=list(stdin.readline())
    x.pop()
    return x


def si(): return stdin.readline()


def sieve(x):
    a=[True]*(x+1)
    sq=floor(sqrt(x))
    for i in range(3, sq+1, 2):
        if a[i]:
            for j in range(i*i, x+1, i):
                a[j]=False
    if x>1:
        p=[2]
    else:
        p=[]
    for i in range(3, x+1, 2):
        if a[i]:
            p.append(i)
    return p
def prime_factor(x):
    c=1
    i=0
    while p[i]*p[i]<=x:
        if not x%p[i]:
            c+=1
            while not x%p[i]:
                x//=p[i]
        i+=1
    if x>1:
        c+=1
    return c
res=['APPROVED', 'DENIED']
#vowel={'a', 'e', 'i', 'o', 'u', 'y', 'A', 'E', 'I', 'O', 'U', 'Y'}
#pow=[1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 67108864, 134217728, 268435456, 536870912, 1073741824, 2147483648, 4294967296, 8589934592, 17179869184, 34359738368, 68719476736, 137438953472, 274877906944, 549755813888, 1099511627776, 2199023255552, 4398046511104, 8796093022208, 17592186044416, 35184372088832, 70368744177664, 140737488355328, 281474976710656, 562949953421312, 1125899906842624, 2251799813685248, 4503599627370496, 9007199254740992, 18014398509481984, 36028797018963968, 72057594037927936, 144115188075855872, 288230376151711744, 576460752303423488, 1152921504606846976, 2305843009213693952, 4611686018427387904, 9223372036854775808]
############# CODE STARTS HERE #############
ii()
a=li()
f=0
for i in a:
    if not i%2:
        if i%3 and i%5:
            f=1
            break
print(res[f])

Measured memory_bytes: 3064
def sign(p1, p2, p3):
    return (p1[0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[1] - p3[1])


def check(triangle, pt):
    v1 = [triangle[0], triangle[1]]
    v2 = [triangle[2], triangle[3]]
    v3 = [triangle[4], triangle[5]]

    b1 = sign(pt, v1, v2)
    if b1 > 0:
        flag1 = 1
    else:
        flag1 = 0

    b2 = sign(pt, v2, v3)
    if b2 > 0:
        flag2 = 1
    else:
        flag2 = 0

    b3 = sign(pt, v3, v1)
    if b3 > 0:
        flag3 = 1
    else:
        flag3 = 0

    return ((flag1 == flag2) and (flag2 == flag3))


n = int(input())

for _ in range(n):
    query = list(map(int, input().split()))
    triangle = query[0:6]
    hikoboshi = query[6:8]
    orihime = query[8:10]

    check1 = check(triangle, hikoboshi)
    check2 = check(triangle, orihime)
    if check1 == check2:
        print("NG")
    else:
        print("OK")


Measured memory_bytes: 5624