akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const int INF = 1 << 28;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    for (int i = 1; i <= b; ++i) {
        if (i * a % b == c) {
            cout << "YES"
                 << "\n";
            return 0;
        }
    }
    cout << "NO"
         << "\n";
    return 0;
}

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

int main() {
  
int N;
cin >> N;
string S;
cin >> S;
int count = 0;
for(int i = 0;i < N-2;i++){
  if (S.at(i) == 'A' && S.at(i+1) == 'B' && S.at(i+2) == 'C') {
    count++;
  }
}

cout << count << endl;
return 0;

}

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

using namespace std ;

const int N=2e5+10 ;
const int B1=131 , B2=13331 ;

char s[N] ;
int n ;
int main ()
{
	int i ;
	scanf(" %s ",s+1),n=strlen(s+1);
	int lH1=0 , lH2=0 , H1=0 , H2=0 , res=0 ;
	for ( i=1 ; i<=n ; i++ )
	{
		H1=H1*B1+s[i],H2=H2*B2+s[i];
		if ( H1!=lH1 && H2!=lH2 ) res++,lH1=H1,lH2=H2,H1=H2=0;
	}
	printf("%d\n",res);
	return 0 ;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

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

  char c;cin>>c;c++;
  cout<<c<<endl;
  
  return 0;
}


Measured memory_bytes: 256
for(r={I:1,V:5,X:10,L:50,C:100,D:500,M:1000},k=n=s=0;p=n,i=require("fs").readFileSync("/dev/stdin","utf8")[k++];)(n=r[i])?n>p?s+=n-2*p:s+=n:(console.log(s),s=0)

Measured memory_bytes: 10148
require 'prime'

MOD = 10**9 + 7
N, M = gets.chomp.split.map(&:to_i)

fact = [1]
30.times do |i|
  fact << fact[i] * (i + 1)
end

ans = 1

M.prime_division.each do |k, v|
  mul = 1
  (v + N - 1).downto(N).each do |n|
    mul *= n
  end
  mul /= fact[v]
  ans *= mul % MOD
  ans %= MOD
end

puts ans

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

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

  int t2 = 0;
  int t1 = 0;
  int t0 = 0;
  if (N == 3) {
    vector<int> T2;
    vector<int> T1;
    vector<int> T0;
    for (int i = 0; i < M; i++) {
      if (s[i] == 1) T2.push_back(c[i]);
      if (s[i] == 2) T1.push_back(c[i]);
      if (s[i] == 3) T0.push_back(c[i]);
    }

    sort(T2.begin(), T2.end());
    T2.erase(unique(T2.begin(), T2.end()), T2.end());
    sort(T1.begin(), T1.end());
    T1.erase(unique(T1.begin(), T1.end()), T1.end());
    sort(T0.begin(), T0.end());
    T0.erase(unique(T0.begin(), T0.end()), T0.end());

    if (T2.size() > 1 || T1.size() > 1 || T0.size() > 1) {
      cout << -1;
      return 0;
       }
    if (T2.size() == 1) {
      if (T2.at(0) == 0) {
        cout << -1;
        return 0;
      } else {
        t2 = T2.at(0);
      }
    }
    if (T1.size() == 1) t1 = T1.at(0);
    if (T0.size() == 1) t0 = T0.at(0);
    if (t2 == 0) t2 = 1;
    cout << 100 * t2 + 10 * t1 + t0;
    return 0;
  }

  if (N == 2) {
    vector<int> T1;
    vector<int> T0;
    for (int i = 0; i < M; i++) {
      if (s[i] == 1) T1.push_back(c[i]);
      if (s[i] == 2) T0.push_back(c[i]);
    }

    sort(T1.begin(), T1.end());
    T1.erase(unique(T1.begin(), T1.end()), T1.end());
    sort(T0.begin(), T0.end());
    T0.erase(unique(T0.begin(), T0.end()), T0.end());

    if (T1.size() > 1 || T0.size() > 1) {
      cout << -1;
      return 0;
    }
    if (T1.size() == 1) {
      if (T1.at(0) == 0) {
        cout << -1;
        return 0;
        } else {
        t1 = T1.at(0);
      }
    }
    if (T0.size() == 1) t0 = T0.at(0);
    if (t1 == 0) t1 = 1;
    cout << 10 * t1 + t0;
    return 0;
  }

  if (N == 1) {
    vector<int> T0;
    for (int i = 0; i < M; i++) {
      if (s[i] == 1) T0.push_back(c[i]);
    }
    if (T0.size() > 1) {
      cout << -1;
      return 0;
    }
    if (T0.size() == 1) t0 = T0.at(0);
    cout << t0;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <string.h>
#include <vector>
#include <algorithm>
#define ll long long

using namespace std;

const long long mod = 1e9+7;

int main(){
	int n;
    int* a;
    cin >> n;
    a = new int[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int m = 0;
    vector<int> b;
    for(int i = n; i > 0; i--){
        int t = i * 2;
        int sum = 0;
        for(int j = 3; t <= n; j++){
            if(a[t-1]&1) sum++;
            t = i * j;
        }
        if((sum&1) != a[i-1]){
            a[i-1] = 1;
            m++;
            b.push_back(i);
        }else{
            a[i-1] = 0;
        }
    }

    cout << m << endl;
    for(int i = 0; i < b.size(); i++){
        cout << b[i] << " ";
    }

    cout << endl;
}

Measured memory_bytes: 2424
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
from decimal import *

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

H = input()
S = 1
ans = 0
while H > 0:
    ans += S
    H /= 2
    S *= 2
print ans

Measured memory_bytes: 4268
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<list>
#include<queue>
#include<string.h>
#include<functional>
#include<stack>
#include<deque>
#include<limits.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
using namespace std;

int x[100000], y[100000];
vector<int>rinsetu[100000];
void DFS(int a) {
	for (int b : rinsetu[a]) {
		if (x[b] == -1) {
			x[b] = x[a] + 1;
			DFS(b);
		}
	}
}
void dFS(int a) {
	for (int b : rinsetu[a]) {
		if (y[b] == -1) {
			y[b] = y[a] + 1;
			dFS(b);
		}
	}
}
signed main() {
	memset(x, -1, sizeof(x));
	memset(y, -1, sizeof(y));
	int n; cin >> n;
	for (int i = 1; i < n; i++) {
		int a, b; cin >> a >> b; a--; b--;
		rinsetu[a].push_back(b);
		rinsetu[b].push_back(a);
	}
	x[0] = 0; y[n - 1] = 0;
	DFS(0);
	dFS(n - 1);
	int X = 0, Y = 0;
	for (int i = 0; i < n; i++) {
		if (x[i] <= y[i])X++;
		else Y++;
	}
	if (X > Y)puts("Fennec");
	else puts("Snuke");
}

Measured memory_bytes: 9600
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
int main(){
ll n;
cin>>n;
ll count1=0,count2=0,count3=0,count4=0;
for(ll i=0;i<n;i++){
	string s;
	cin>>s;
	if(s=="AC"){
		count1++;
	}
	else if(s=="WA"){
		count2++;
	}
	else if(s=="TLE"){
		count3++;
	}
	else if(s=="RE"){
		count4++;
	}
}
cout<<"AC x "<<count1<<endl;
cout<<"WA x "<<count2<<endl;
cout<<"TLE x "<<count3<<endl;
cout<<"RE x "<<count4<<endl;
}

Measured memory_bytes: 3212
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#define mod 1000000007
typedef long long ll;
using namespace std;

int main(){
  int N,K; cin >> N >> K;
  vector<ll> plus;
  vector<ll> minus;
  int plus_cnt = 0;
  int minus_cnt = 0;
  for(int i=0;i<N;i++){
    ll x; cin >> x;
    if(x>=0){
      plus.push_back(x);
      plus_cnt++;
    }else{
      minus.push_back(x);
      minus_cnt++;
    }
  }
  sort(plus.begin(),plus.end());
  sort(minus.rbegin(),minus.rend());
  ll ans = 100000000000;
  if(plus_cnt>=K) ans = min(ans,abs(plus[K-1]));
  if(minus_cnt>=K) ans = min(ans,abs(minus[K-1]));
  for(int i=1;i<=K-1;i++){
    if(K-i>minus_cnt || i>plus_cnt) continue;
    ll d = min((abs(plus[i-1])*2+abs(minus[K-i-1])),(abs(minus[K-i-1])*2+abs(plus[i-1])));
    ans = min(ans,d);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1656
#include<stdio.h>
#include<stdlib.h>
void main(void)
{
  int N,M,*A,*B,tmp=0;
  scanf("%d",&N);
  A=(int*)malloc(sizeof(int)*(N+1));
  B=(int*)malloc(sizeof(int)*(N+1));
  
  for(int i=1;i<=N;i++){
    B[i]=0;
  }
  
  for(int i=2;i<=N;i++){
    scanf("%d",&A[i]);
    B[A[i]]++;
  }
  
  for(int i=1;i<=N;i++){
    printf("%d\n",B[i]);
  }
 
}

Measured memory_bytes: 3296
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize
    }
    if n == 2 {
        input! {
        a: usize,
        b: usize
        }
        println!("{}", a + b)
    } else {
        print!("Hello World")
    }
}


Measured memory_bytes: 2180
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] x = new int[n];
        int sumX = 0;
        for(int i=0; i<n; i++) {
            x[i] = in.nextInt();
            sumX += x[i];
        }
        // abs(X-P) の総和が最小のとき、 (X-P)^2 の総和が最小である、はず（未証明）
        int p = (int)Math.round((double)sumX / (double)n);
        long sum = 0;
        for(int i=0; i<n; i++) {
            sum += (x[i] - p) * (x[i] - p);
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 23764
import itertools
import math
 
n,d = map(int, input().split())
x = [[0 for x in range(d)] for y in range(n)]

for i in range(n):
    x[i] = list(map(int, input().split()))

cnt = 0
for i in itertools.combinations(x, 2):
    y = i[0]
    z = i[1]
    res = 0
    for j in range(d):
        res +=(y[j]-z[j])**2

    res = math.sqrt(res)
    if res.is_integer():
        cnt+=1

print (cnt)

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

int main() {
  vector<int> x(6);
  for (int i = 1; i <= 5; i++) {
    cin >> x.at(i);
  }
  int result;
  for (int i = 1; i <= 5; i++) {
    if(x.at(i) == 0) {
      result = i;
      break;
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 3572
#include <iostream>

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

const long long INF = 1LL<<60;

int main () {
    int n, w;
    std::cin >> n >> w;
    int max_v = 1;
    int weight[n], value[n];
    for (int i = 0; i < n; ++i) {
        std::cin >> weight[i] >> value[i];
        max_v += value[i];
    }
    long long dp[n+1][max_v];
    for(int i = 0; i < n+1; ++i) {
        for(int j = 0; j < max_v; ++j){
            dp[i][j]=INF;
        }
    }

    dp[0][0]=0;
    
    for(int i = 0; i < n; ++i) {
        for(int sum_v = 0; sum_v < max_v; ++sum_v){
            if(sum_v - value[i] >= 0) {
                chmin(dp[i+1][sum_v], dp[i][sum_v - value[i]] + weight[i]);
            }
            chmin(dp[i+1][sum_v], dp[i][sum_v]);
        }
    }

    long long ans = 0;

    for (int sum_v = 0; sum_v < max_v; ++sum_v) {
        if(dp[n][sum_v] <= w) {
            ans = sum_v;
        }
    }

    std::cout << ans << std::endl;
}

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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

int main(){
    int s, w;
    cin >> s >> w;
    if (w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip> 
#include <complex> 
#include <string>
#include <vector> 
#include <list>
#include <deque> 
#include <stack> 
#include <queue> 
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <utility>
#include <algorithm> 
#include <numeric> 
#include <typeinfo> 
#include <cstdio>
#include <cstdlib> 
#include <cstring>
#include <cmath>
#include <climits> 
#include <ctime>

using namespace std;
long long int sum[10001];

int main(void){
	int i,n;
	sum[0]=1;
	for(i=1;i<=10000;i++){
		sum[i]=sum[i-1]+i;
	}
	while(~scanf("%d",&n)){
		printf("%d\n",sum[n]);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
long long sum[1000000],kq,tmp,n,a[1000000];
int main(){
    //freopen("dd.inp","r",stdin);
   // freopen("dd.out","w",stdout);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        sum[i]=sum[i-1]+a[i];

    }
    kq=1e12;
    for (int i=1;i<=n-1;i++){
        //tmp=min(sum[i],sum[n]-sum[i]);
        kq=min(kq,abs(sum[n]-2*sum[i]));
    }
    cout<<kq;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

template<typename T>
class tRMQ {
  vector<T> data;
  T unit;

public:
  static const long long INF = 100000000000;
  int n;
  function<T(const T &, const T &)> f;

  tRMQ(int _, T u, function<T(T, T)> bi) {
    unit = u;
    f = bi;
    n = 1;
    while (n < _) {
      n <<= 1;
    }
    data.resize(n * 4);
    for (int i = 0; i < n * 4; i++)
      data[i] = unit;
  }

  void update(int index, T val) {
    int i = index + n - 1;
    data[i] = val;
    while (i > 0) {
      i = (i - 1) / 2;
      data[i] = f(data[i * 2 + 1], data[i * 2 + 2]);
    }
  }

  // [a, b)
  T query(int a, int b, int k, int l, int r) {
    if (a < 0 || r <= a || b <= l)
      return unit;
    if (a <= l && r <= b)
      return data[k];
    else
      return f(query(a, b, k * 2 + 1, l, (l + r) / 2),
               query(a, b, k * 2 + 2, (r + l) / 2, r));
  }

  T query(int a, int b) { return query(a, b, 0, 0, n); }
};

tRMQ<ll> minrmq(int n) {
  return tRMQ<ll>(n, 10000000000000000LL, [](ll r, ll l) { return min(l, r); });
}

tRMQ<ll> maxrmq(int n) {
  return tRMQ<ll>(n, -10000000000000000LL,
                  [](ll r, ll l) { return max(l, r); });
}

tRMQ<ll> sumrmq(int n) {
  return tRMQ<ll>(n, 0, [](ll l, ll r) { return l + r; });
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  map<int, vector<int>> mp;
  map<int, pair<int, int>> ps;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    mp[s[i] - 'a'].push_back(i);
  }
  int c = 0;
  for (auto &v : mp) {
    if (v.second.size() % 2) c++;
    ps[v.first] = make_pair(0, v.second.size() - 1);
  }
  if (c > 1) {
    cout << -1 << endl;
    return 0;
  }
  auto r = sumrmq(n);
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    r.update(i, 1);
  }
  int offset = 0;
  for (int i = 0; i < n; i++) {
    while (r.query(i + offset, i + offset + 1) == 0 && i + offset < n) {
      offset++;
    }
    if (i + offset >= n) break;
    if (ps[s[i + offset] - 'a'].first == ps[s[i + offset] - 'a'].second) {
      continue;
    }
    r.update(mp[s[i + offset] - 'a'][ps[s[i + offset] - 'a'].second], 0);
    r.update(mp[s[i + offset] - 'a'][ps[s[i + offset] - 'a'].first], 0);
    ans += r.query(0, mp[s[i + offset] - 'a'][ps[s[i + offset] - 'a'].first]) +
           r.query(mp[s[i + offset] - 'a'][ps[s[i + offset] - 'a'].second], n);
    ps[s[i + offset] - 'a'].first++;
    ps[s[i + offset] - 'a'].second--;
  }

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


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

using namespace std;

int main(){
  long n;
  cin >> n;
  vector<long> a(n);
  long sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  long b=0;
  if(sum%2==0){
    for(int i=0;i<n;i++){
      b+=a[i];
      if(2*b==sum){
        cout << 0 << endl;
        return 0;
      }
      else if(2*b>sum){
        cout << min(2*b-sum,sum-2*(b-a[i])) << endl;
        return 0;
      }
    }
  }
  else{
    for(int i=0;i<n;i++){
      b+=a[i];
      if(2*b>sum){
        cout << min(2*b-sum,sum-2*(b-a[i])) << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 1920
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.AGC026
{
    class A
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] input = Console.ReadLine().Split(' ');
            int[] array = new int[n];
            for (int i = 0; i < n; i++)
            {
                array[i] = int.Parse(input[i]);
            }

            int count = 0;
            for(int i = 1; i < n; i++)
            {
                if (array[i - 1] == array[i])
                {
                    array[i]++;
                    count++;
                    if (i < n - 1 && array[i] == array[i + 1])
                    {
                        array[i] += array[i + 1];
                    }
                }
            }

            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <tuple>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

using namespace std;

static const int64_t kRem = 1000000007;

tuple<int64_t, int64_t, int64_t> gcd(int64_t x, int64_t y)
{
	assert(0 <  x);
	assert(0 <= y);

	if (x < y) swap(x, y);

	if (y == 0) return make_tuple(x, 1, 0);

	tuple<int64_t, int64_t, int64_t> ret = gcd(y, x % y);

	return make_tuple(get<0>(ret), get<2>(ret),  get<1>(ret) - (x/y)*get<2>(ret));
}

int64_t divide_rem(int64_t val, int64_t rem)
{
	int64_t ret = get<2>(gcd(rem, val));
	while (ret < 0) ret += rem;

	return ret;
}

int64_t calc_z(int64_t x, int64_t y)
{
	int64_t val = y;
	val *= divide_rem(x, kRem);
	val %= kRem;
	return val;
}

int main()
{
	int b, w; cin >> b >> w;

	int64_t wl_case = 0;
	int64_t bl_case = 0;
	int64_t wl_seed = 0;
	int64_t bl_seed = 0;
	int64_t all_case = 1;
	for (int i = 0; i < (b + w); i++) {
		all_case *= 2;
		all_case %= kRem;

		if (i == w) {
			wl_case = 1;
			wl_seed = w;
		}
		if (w < i) {
			wl_case = wl_case * 2 + wl_seed;
			wl_case %= kRem;
			wl_seed  = wl_seed * i;
			wl_seed %= kRem;
			wl_seed *= divide_rem(i - w + 1, kRem);
			wl_seed %= kRem;
		}

		if (i == b) {
			bl_case = 1;
			bl_seed = b;
		}
		if (b < i) {
			bl_case = bl_case * 2 + bl_seed;
			bl_case %= kRem;
			bl_seed  = bl_seed * i;
			bl_seed %= kRem;
			bl_seed *= divide_rem(i - b + 1, kRem);
			bl_seed %= kRem;
		}

		int64_t even_case = all_case - (wl_case * 2) - (bl_case * 2);
		while (even_case < 0) even_case += kRem;

		int64_t z = calc_z((all_case * 2) % kRem, (even_case + wl_case * 4) % kRem);
		cout << z << endl;
	}

	return 0;
}

Measured memory_bytes: 2176
s=list(input())
a='No'
if s[1]==s[2] and s[3]==s[0] and s[1]!=s[3] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[3] and s[2]==s[0] and s[1]!=s[2] and s[1]!=s[0]:
  a='Yes'
elif s[1]==s[0] and s[2]==s[3] and s[1]!=s[2] and s[1]!=s[3]:
  a='Yes'
print(a)

Measured memory_bytes: 3064
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	N := getStdinInt()
	fInit(N)
	for i := 1; i <= N; i++ {
		fmt.Printf("%d\n", f(i))
	}
}

var fAns []int

func fInit(n int) {
	fAns = make([]int, n+1)
	nsqrt := int(math.Sqrt(float64(n)))
	for x := 1; x < nsqrt; x++ {
		for y := 1; y < nsqrt; y++ {
			for z := 1; z < nsqrt; z++ {
				ans := x*x + y*y + z*z + x*y + y*z + z*x
				if ans <= n {
					fAns[ans]++
				}
			}
		}
	}
}

func f(n int) int {
	return fAns[n]
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2368
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
int main() {
  int N;
  cin >> N;
  string s;
  cin >> s;
  bool boo = false;
  if(N%2 == 0){
    if(s.substr(0,N/2) == s.substr(N/2,N/2)){
      boo = true;
    }
  }
  if(boo) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

const string YES = "Yes";
const string NO = "No";

void solve(long long N)
{
    cout << (to_string(N).find('7') != string::npos ? YES : NO) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
// clang-format off
#pragma GCC diagnostic ignored "-Wunused-result"
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3772
import math

a, b, h, m = map(int, input().split())

s = 360 * (m / 60)
l = 360 * ((60 * h + m) / 720)

theta = math.fabs(s - l)

ans = math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(math.radians(theta)))

print(ans)


Measured memory_bytes: 62520
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxN = 1e5 + 13;
int n, arr[maxN], a[maxN], m, k;
void pw (int b) {
    int ret[maxN], tmp[maxN];
    for (int i = 0; i < n - 1; i++)
	ret[i] = arr[i];
    for (; b; b >>= 1) {
	if (b & 1) {
	    for (int i = 0; i < n - 1; i++)
		tmp[i] = ret[i];
	    for (int i = 0; i < n - 1; i++) 
		ret[i] = tmp[arr[i]];
	    
	}
	for (int i = 0; i < n - 1; i++)
	    tmp[i] = arr[i];
	for (int i = 0; i < n - 1; i++)
	    arr[i] = tmp[arr[i]];
    }

    for (int i = 0; i < n - 1; i++)
	arr[i] = ret[i];
}

int32_t main () {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) {
	cin >> a[i];
    }
    iota(arr, arr + n - 1, 0);
    cin >> m >> k;;
    for (int i = 0; i < m; i++) {
	int x;
	cin >> x;
	x--;
	swap(arr[x], arr[x - 1]);
    }
    pw(k - 1);
    int lst = a[0];
    for (int i = 0; i < n; i++) {
	cout << lst << '\n';
	lst += a[arr[i] + 1] - a[arr[i]];
    }
    
}
					  


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 333;
ll M, n, k;
ll F[N], I[N], C[N][N], dp[N][N], ps[N][N];
ll mul(ll a, ll b) {
	return (a * b) % M;
}
ll sum(ll a, ll b) {
	return (a + b + M) % M;
}
ll Pow(ll a, ll b) {
	ll res = 1;
	for (; b; b >>= 1, a = mul(a, a))
		if (b & 1)
		   res = mul(res, a);
  return res;
}



int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    cin >> n >> k >> M;
   	for (int i = 0; i < N; i ++)
	   	C[0][i] = 1;
	for (int i = 1; i < N; i ++) {
		for (int j = 1; j < N; j ++) {
			C[i][j] = sum(C[i - 1][j - 1], C[i][j - 1]);
		}
		}
	for (int i = 0; i < N; i ++) {
		dp[0][i] = 1, ps[0][i] = i;
	}
		for (int i = 1; i < N; i ++) {
			for (int j = 0; j < N; j ++) {
				for (int x = 0; x < i; x ++) {
					dp[i][j] = sum(dp[i][j], mul(C[x][i - 1], mul(dp[i - x - 1][j], sum(ps[x][k], -ps[x][j]))));
					if (j)ps[i][j] = sum(ps[i][j - 1], dp[i][j]);
				}
			}
		}
	cout << dp[n][0];
    return (0);
}

Measured memory_bytes: 2816
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <bitset>
#include <cmath>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
const double PI=3.141592653589793238462643383279;
//
int N,MA,MB;
int X[41],Y[41],C[41];
int DP[41][401][401];
int main(){
  cin>>N;
  cin>>MA>>MB;
  FOR(i,0,N){
    cin>>X[i]>>Y[i]>>C[i];
  }
  FOR(i,0,N+1){
    FOR(j,0,401){
      FOR(k,0,401){
        DP[i][j][k]=INF;
      }
    }
  }
  DP[0][0][0]=0;
  FOR(i,0,N){
    FOR(j,0,401){
      FOR(k,0,401){
        if(DP[i][j][k]==INF){
          continue;
        }
        DP[i+1][j][k]=min(DP[i+1][j][k],DP[i][j][k]);
        DP[i+1][j+X[i]][k+Y[i]]=min(DP[i+1][j+X[i]][k+Y[i]],DP[i][j][k]+C[i]);
      }
    }
  }
  int ans=INF;
  FOR(i,1,401){
    FOR(j,1,401){
      if(i*MB==j*MA){
        ans=min(ans,DP[N][i][j]);
      }
    }
  }
  if(ans==INF){
    ans=-1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 25984
N=int(input())
L=[int(input()) for i in range(N)]
tl=sorted(L)
index1=L.index(tl[-1])
index2=L.index(tl[-2])
for i in range(N):
	if i==index1:
		print(L[index2])
	else:
		print(L[index1])

Measured memory_bytes: 70360
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n < 1000) {
			System.out.println("ABC");
		} else {
			System.out.println("ABD");
		}

	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,k;
  cin >> n >> k;
  ll ans=0;
  FOR(i,k+1,n+1){
    ans +=(n/i)*(i-k);
    ans +=max((ll)0,n%i-k+1);
    if(k==0){
      ans--;
    }
    //cout << i << " " << ans << endl;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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;
}

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

template<class T>
void dcomb(T n,T m, string s){
    if(n==0) cout << s << endl;
    else {
        for(T i=0; i<m; ++i){
            dcomb(n-1,m,s+to_string(i));
        }
    }
}

int  INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h){
        rep(j,w) cin >> a[i][j];
    }
    vector<vector<int>> dp(h,vector<int>(w,0));
    dp[0][0] = 1;
    rep(i,h){
        rep(j,w){
            if(j<w-1 && a[i][j+1]!='#'){
                dp[i][j+1] += dp[i][j];
                dp[i][j+1] %=INF;
            }
            if(i<h-1 && a[i+1][j]!='#'){
                dp[i+1][j] += dp[i][j];
                dp[i+1][j] %=INF;
            }
        }
    }
    cout << dp[h-1][w-1] << endl;
}

Measured memory_bytes: 5248
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<ll>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vi a(n);
    rep(i, n) {
        cin >> a[i];
    }

    ll sum = 0, ans = LINF, now = 0;
    int x = 1, x_ = -1;
    int *y, *y_;
    y = &x;
    y_ = &x_;
    rep(qq, 2) {
        rep(i, n) {
            if(*y == 1) {
                if(a[i]+sum <= 0) {
                    now += 1-sum-a[i];
                    sum = 1;
                } else {
                    sum += a[i];
                }
            } else {
                if(a[i]+sum >= 0) {
                    now += a[i]+sum+1;
                    sum = -1;
                } else {
                    sum += a[i];
                }
            }
            swap(y, y_);
        }
        if(*y == 1) swap(y, y_);
        ans = min(ans, now);
        sum = 0;
        now = 0;
    }

    cout << ans << endl;
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  char s[n];
  cin >> s[0];
  int count = 1;
  for(int i=1; i<n ;i++){
    cin >> s[i];
    count++;
    if(s[i] == s[i-1])
      count--;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 1016
n = int(input())
d = {}
ans = 0

for i in range(n):
    s = ''.join(sorted(input()))
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
#print(d)
for k, v in d.items():
  ans += v * (v - 1) / 2

print(int(ans))



Measured memory_bytes: 17852
#include <stdio.h>

class eat{
public:
	int ID,t,s,tn,kcal;

	void scan(){
		scanf("%d%d%d%d",&ID,&t,&s,&tn);
		kcal = t*4 + s*9 + tn*4;
	}
	bool isOK(int P,int Q,int R,int C){
		return (t <= P && s <= Q && tn <= R && kcal <= C);
	}
	void print(){
		printf("%d\n",ID);
	}
};

int main()
{
	eat in[1000];
	int n,P,Q,R,C;
	int i,j;

	scanf("%d",&n);
	while(n != 0){
		bool isNA = true;
		for(i = 0; i < n; i++){
			in[i].scan();
		}
		scanf("%d%d%d%d",&P,&Q,&R,&C);
		
		for(i = 0; i < n; i++){
			if(in[i].isOK(P,Q,R,C)){
				in[i].print();
				isNA = false;
			}
		}
		if(isNA)	printf("NA\n");

		scanf("%d",&n);
	}

	return 0;
}

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

int main() {
	long long H, W;
	cin >> H >> W;

	if (H == 1 || W == 1) {
		cout << 1 << endl;
	}
	else {
		cout << (H * W + 1) / 2 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }

signed main() {
	int n,p;
	std::cin >> n >> p;
	MOD = p;
	std::string s;
	std::cin >> s;
	if(p==2) {
		int count = 0;
		rep(i,n) {
			if((s[i]-'0')%2==0) {
				count+=i+1;
			}
		}
		print(count);
		return 0;
	}
	if(p==5) {
		int count = 0;
		rep(i,n) {
			if((s[i]-'0')%5==0) {
				count+=i+1;
			}
		}
		print(count);
		return 0;
	}
	std::vector<mint> dp(n);
	std::map<int,std::vector<int> > map;
	mint curr = 0;
	for(int i=n-1;i>=0;i--) {
		curr+=mint(s[i]-'0')*mint(10).pow(n-i-1);
		dp[i]=curr;
		map[curr.v].emplace_back(i);
	}
	debug(dp);
	int count = 0;
	for(auto x:dp) if(x==0) count++;
	for(int i=1;i<n;i++) {
		auto lb = std::lower_bound(map[dp[i].v].rbegin(),map[dp[i].v].rend(),i);
		count += std::max(0ll,(int)(lb-map[dp[i].v].rbegin()));
	}
	print(count);
	return 0;
}


Measured memory_bytes: 5764
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner scan = new Scanner(System.in);

    double x1 = scan.nextDouble();
    double y1 = scan.nextDouble();
    double x2 = scan.nextDouble();
    double y2 = scan.nextDouble();

    System.out.println(Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2)));

  }

}



Measured memory_bytes: 27940
#include<iostream>
#include<cstring>
using namespace std;
int main(){
  char c[1001];
  int ans;
  while(cin>>c){
    if(c[0]=='0') break;
    ans = 0;
    for(int i=0;i<strlen(c);i++) ans += (c[i]-'0');
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1140
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
#include <stack>

using namespace std;

const int dx[]={0,0,-1,1};
const int dy[]={-1,1,0,0};

int x[25],y[25],r[25],c[25];
int on[25];

bool check(int i,int j){
	int d1=(x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
	int d2=(r[i]+r[j])*(r[i]+r[j]);
	return d2>d1;
}

int main(){
	
	int n;
	while(cin>>n,n){
		for(int i=0;i<n;i++){
			cin>>x[i]>>y[i]>>r[i]>>c[i];
			on[i]=0;			
		}
		
		//j???????????????i???????????????????????£????????????
		for(int i=0;i<n;i++){
			for(int j=i+1;j<n;j++){
				if(check(i,j)) on[j]|=(1<<i);
			}
		}

		//int??§???MLE
		vector<char> dp(1<<n,-1);
		dp[0]=0;
		
		//0:???????????????????????? 1:????????????????????????
		for(int bit=0;bit<(1<<n);bit++){
			if(dp[bit] == -1) continue;

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

				//??¢??????????????????????????? or ?????????????????????(on[i]???1????????¨bit???0??????????¢???£?????????)
				if(bit&(1<<i) || (bit&on[i])!=on[i]) continue;
				
				for(int j=i+1;j<n;j++){
					if(c[i]!=c[j] || bit&(1<<j) || (bit&on[j])!=on[j]) continue;
					
					//i??¨j????????????????????¶????????´??°
					int next=bit | (1<<i) | (1<<j);
					dp[next]=max(dp[next],(char)(dp[bit]+2));

				}
			}
		}
		
		cout<<(int)*max_element(dp.begin(),dp.end())<<endl;
		
		
	}
	
	return 0;
};

Measured memory_bytes: 17588
n = int(input())
a = list(map(int, input().split()))
import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
lcm = lcm(*a)
li = []
for i in range(n):
    li.append(lcm // a[i])
print(lcm/sum(li))

Measured memory_bytes: 66028
#include"bits/stdc++.h"
using namespace std;

#define ll long long int
#define f(i,x,n)  for(int i=x;i<n;i++)
#define FASTIO cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
#define sz(a) int((a).size())
#define mod 1000000007
#define inf LLONG_MAX
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
template <typename T>
inline T gcd(T a, T b)
{
    while (b != 0) swap(b, a %= b);
    return a;
}

template <typename T>
inline void seethis(vector<T>vect)
{
    for(T x : vect)
        cout << x << " ";
    cout << "\n";
}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

//Top down:
int dp[100005];
int solve(int current, int n, vector<int> &vect)
{
    //Base Case:


    dp[1] = 0;
    dp[2] = abs(vect[2] - vect[1]);



    for(int i = 3; i <= n; i++)
    {
        int res = INT_MAX;

        res = min(res, dp[i - 1] + abs(vect[i] - vect[i - 1]));
        res = min(res, dp[i - 2] + abs(vect[i] - vect[i - 2]));

        dp[i] = res;
    }



    return dp[n];

}



int main()
{
    FASTIO;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int n;
    cin >> n;

    vector<int>vect(n + 1);
    memset(dp, -1, sizeof dp);

    f(i, 1, n + 1)
    cin >> vect[i];

    cout << solve(n, n, vect) << "\n";

    return 0;
}

Measured memory_bytes: 4036
#include<cstdio>

int main(void)
{
	int m;
	int i,j,k;
	int first,year,kind;
	int tanhuku,tesuu;
	double nenri;
	int a,b,sum,temp;
	int max=0;
	
	for(;;)
	{
		scanf("%d", &m);
		for(i=0; i<m; i++)
		{
			scanf("%d",&first);
			scanf("%d",&year);
			scanf("%d",&kind);
			max=0;
			for(j=0; j<kind; j++)
			{
				scanf("%d %lf %d",&tanhuku,&nenri,&tesuu);
				a=first,b=0,sum=0,temp=0;
				for(k=0; k<year; k++)
				{
					if(tanhuku==1) //複利
					{
						b=a*nenri;
						sum=a+b-tesuu;
						a=sum;
					}
					else //単利
					{
						b=a*nenri;
						sum=a-tesuu;
						a=sum;
						temp+=b;
						if(k==year-1)
						{
							sum+=temp;
						}
					}
				}
				if(sum>max) max=sum;
			}
			printf("%d\n",max);
		}
		if(i==m) break;
	}
	
	return 0;
}

Measured memory_bytes: 1060
// #include C/C++ {
#include <bits/stdc++.h>
// }
using namespace std;
// #typedef {
typedef long long int64;
typedef pair <int, int> PII;
typedef pair <int64, int64> PLL;
// }

// #parameter{
#ifdef _DEBUG

#define TYPE decltype
#define RF(filename) {freopen((filename), "r", stdin);}
#define WF(filename) {freopen((filename), "w", stdout);}
#define DF(filename) {freopen((filename), "w", stderr);}
#define eprintf printf

#else

#define TYPE __typeof
#define RF(filename) {;}
#define WF(filename) {;}
#define DF(filename) {;}
#define eprintf(...)
#define fprintf(...)

#endif

// #define {
#define SZ(a) ((int)(a).size())
#define X first
#define Y second
#define MP make_pair
#define L(x) ((x)<<1)
#define R(x) ((x)<<1 | 1)
#define max3(x, y, z) (max(max((x), (y)), (z)))
#define min3(x, y, z) (min(min((x), (y)), (z)))
#define BIT(x, i) (((x) >> (i)) & 1)
#define ALL(it) (it).begin(), (it).end()
#define FILL(__space, __val) memset(__space, __val, sizeof(__space))
#define MOVE(__spaceTo, __spaceFrom) memmove(__spaceTo, __spaceFrom, sizeof(__spaceTo))
#define UNIQUE(__vector) sort(ALL(__vector)), __vector.resize(unique(ALL(__vector)) - __vector.begin())
#define FOR(it, c) for( TYPE((c).begin()) it = (c).begin(); it != (c).end(); it++)
/////////////////////////////////////////////////////////////
const double PI = acos(-1.0);
const double EPS = 1e-6;

#define MAX_N 105
#define MAX_M 55
#define MOD (int)(1e9+7)
#define INF ((1 << 30) - 1)
#define BINF ((1LL << 62) - 1LL)
#define NONE -1
#define NIL 0
// }

/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
int main() {
	RF("input.txt");
	// WF("output.txt");
	DF("err.txt");

	int N, D;
	scanf("%d %d", &N, &D);
	printf("%d\n", (int)ceil(N / (2.0 * D + 1.0)));
	return 0;
}

Measured memory_bytes: 256
//Author: Fuadul Hasan(fuadul202@gmail.com)
#include<bits/stdc++.h>
using namespace std;

#define ll long long
const int N   = 2e5 + 5;

int main(){
	
	
	int a,b;
	cin>>a>>b;
	if(a< b){
		cout<<0<<endl;
	}else{
		cout<<10<<endl;
	}

	

	return 0;
}

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

int main() {
  int a,b,x;
  cin>>a>>b>>x;

  double theta;
  if(2*x >= a*a*b) {
    theta = 2*(double(a)*b-double(x)/a)/a/a;
  }
  else {
    theta = double(a)*b*b/2/x;
  }
  double rad = atan(theta);
  double dosu = rad*180/M_PI;

  cout<<fixed<<setprecision(10)<<dosu<<endl;

  return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
    #define int long long
    using namespace std;
    template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T>bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    
    signed main()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    
        int N,K; cin>>N>>K;
        int ans=0;
        for(int i=0;i<N;i++){
            int h; cin>>h;
            if(h>=K) ans++;
        }    
        cout<<ans<<endl;
        return 0;
    }

Measured memory_bytes: 256
"""
ABC044 A 高橋君とホテルイージー
https://kenkoooo.com/atcoder/#/table/Tsukumo
"""

n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n > k:
    ans = k*x + (n-k)*y
else:
    ans = n*x
print(ans)


Measured memory_bytes: 9028
#include <stdio.h>
#include <string.h>

int main(){
    int dice[7];
    int i;
    for(i=1; i<=6; i++)
        scanf("%d", &dice[i]);
    getchar();    
    char direction_command[105];
    fgets(direction_command, sizeof(direction_command), stdin);
    direction_command[strlen(direction_command) - 1] = '\0';
    
    int temp;
    for(i=0; i<strlen(direction_command); i++){
        switch(direction_command[i]){
            case 'N':
                temp = dice[1];   
                dice[1] = dice[2];
                dice[2] = dice[6];
                dice[6] = dice[5];
                dice[5] = temp;
            break;

            case 'S':
                temp = dice[1];   
                dice[1] = dice[5];
                dice[5] = dice[6];
                dice[6] = dice[2];
                dice[2] = temp;
            break;

            case 'E':
                temp = dice[1];
                dice[1] = dice[4];
                dice[4] = dice[6];
                dice[6] = dice[3];
                dice[3] = temp;
            break;
            
            case 'W':
                temp = dice[1];
                dice[1] = dice[3];
                dice[3] = dice[6];
                dice[6] = dice[4];
                dice[4] = temp;
            break;
        }
    }
    printf("%d\n", dice[1]);
}



Measured memory_bytes: 2056
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

const int mod = 998244353;
struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    if (d[0] != 0) {
        cout << 0 << endl;
        return 0;
    }
    vi cnt(n);
    rep(i, n) cnt[d[i]]++;
    mint ans = 1;
    for (int i = 0, now = 0; i < n && now < n; ++i) {
        if (i == 0) {
            if (cnt[i] != 1) {
                cout << 0 << endl;
                return 0;
            }
        } else if (i == 1) {
            if (cnt[i] == 0) {
                cout << 0 << endl;
                return 0;
            }
        } else {
            if (cnt[i] == 0) {
                cout << 0 << endl;
                return 0;
            }
            ans *= mint(cnt[i-1]).pow(cnt[i]);
        }
        now += cnt[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
arr = [list(map(int, input().split())) for i in range(n)]

arr.sort()
ans = 0
for i, j in arr:
    for k in range(j):
        if m > 0:
            ans += i
            m -= 1
        else:
            break
print(ans)


Measured memory_bytes: 27884
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
typedef long long ll;
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
typedef unordered_map<ll,ll> umap;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
const ll mod = 1e9+7;
ll n,a[200005];
vc dp(200005);
ll ans[200005];
vc g[200005];
vector<pr> ks[200005];

void dfs(ll now, ll pr, ll dpt){
    auto it = lower_bound(dp.begin(), dp.end(), a[now]);
    ks[now].pb({it - dp.begin(), dp[it - dp.begin()]});
    *it = a[now];
    ans[now] = lower_bound(dp.begin(),dp.end(),1e17) - dp.begin();
    for(auto to: g[now]){
        if(to==pr) continue;
        dfs(to, now, dpt+1);
    }
    for(auto key: ks[now]){
        dp[key.first] = key.second;
    }
    ks[now].clear();
}

int main() {
    // your code goes here
    cin >> n;
    ll x,y;
    rep(i,1,n){
        cin >> a[i];
    }
    rep(i,1,n-1){
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    rep(i,0,dp.size()-1){
        dp[i] = 1e17;
    }
    dfs(1,0,1);
    rep(i,1,n){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 49832
#include<stdio.h>

int main() {

	int seqLen=0;
	scanf("%d", &seqLen);

	int seq[100];

	int min, max = 0;
	
	scanf("%d", &seq[0]);
	max = seq[0];
	min = seq[0];
	int i = 1;
	for (i = 1 ; i < seqLen; i++) {
		scanf("%d", &seq[i]);
		if (seq[i] > max) max = seq[i];
		else if (seq[i] < min )min = seq[i];
	}
	printf("%d", max - min);

	return 0;
}

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

int main() {
	int n; string s; cin >> n >> s;
	bool a1[26];
	bool a2[26];
	int count = 0,ans = 0;
	for (int i = 1; i < n - 1; i++) {
		for (int i = 0; i < 26; i++) {
			a1[i] = false;
			a2[i] = false;
		}
		for (int j = 0; j < 26; j++) {
			for (int k = 0; k < i; k++) {
				if (s[k] == char('a' + j)) {
					a1[j] = true;
				}
			}
			for (int k = i; k < n; k++) {
				if (s[k] ==char( 'a' + j)) {
					a2[j] = true;
				}
			}
		}
		for (int j = 0; j < 26; j++) {
			if (a1[j] == true&&a2[j]==true) {
				count++;
			}
		}
		ans = max(ans, count);
		count = 0;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256