akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using RGB = tuple<int, int, int>;

void update_map(const map<RGB, int64_t> &cnt_map,
        map<int, vector<RGB>> &r_map,
        map<int, vector<RGB>> &g_map,
        map<int, vector<RGB>> &b_map)
{
    int r, g, b;
    r_map.clear();
    g_map.clear();
    b_map.clear();
    for (auto pr : cnt_map) {
        tie(r, g, b) = pr.first;
        if (!r_map.count(r)) r_map[r] = vector<RGB>();
        if (!g_map.count(g)) g_map[g] = vector<RGB>();
        if (!b_map.count(b)) b_map[b] = vector<RGB>();
        r_map[r].push_back(pr.first);
        g_map[g].push_back(pr.first);
        b_map[b].push_back(pr.first);
    }
}

int	main()
{
    const static int64_t mod = 1000000007;
    int N;
    cin >> N;
    vector<int> A_vec(N);
    for (int i = 0; i < N; ++i)
        cin >> A_vec.at(i);
    map<int, vector<RGB>> r_map, g_map, b_map;
    vector<map<RGB, int64_t>> cnt_map(N + 1);
    cnt_map[0][make_tuple(0, 0, 0)] = 1;
    update_map(cnt_map[0], r_map, g_map, b_map);
    int r, g, b;
    for (int i = 0; i < N; ++i) {
        int A = A_vec.at(i);
        if (r_map.count(A)) {
            for (auto preb : r_map.at(A)) {
                tie(r, g, b) = preb;
                RGB key = make_tuple(r + 1, g, b);
                if (cnt_map.at(i + 1).count(key)) {
                    cnt_map.at(i + 1)[key] += cnt_map.at(i).at(preb);
                    cnt_map.at(i + 1)[key] %= mod;
                } else
                    cnt_map.at(i + 1)[key] = cnt_map.at(i).at(preb);
            }
        }
        if (g_map.count(A)) {
            for (auto preb : g_map.at(A)) {
                tie(r, g, b) = preb;
                RGB key = make_tuple(r, g + 1, b);
                if (cnt_map.at(i + 1).count(key)) {
                    cnt_map.at(i + 1)[key] += cnt_map.at(i).at(preb);
                    cnt_map.at(i + 1)[key] %= mod;
                } else
                    cnt_map.at(i + 1)[key] = cnt_map.at(i).at(preb);
            }
        }
        if (b_map.count(A)) {
            for (auto preb : b_map.at(A)) {
                tie(r, g, b) = preb;
                RGB key = make_tuple(r, g, b + 1);
                if (cnt_map.at(i + 1).count(key)) {
                    cnt_map.at(i + 1)[key] += cnt_map.at(i).at(preb);
                    cnt_map.at(i + 1)[key] %= mod;
                } else
                    cnt_map.at(i + 1)[key] = cnt_map.at(i).at(preb);
            }
        }
        update_map(cnt_map[i + 1], r_map, g_map, b_map);
    }
    int64_t cnt = 0;
    for (auto pr : cnt_map.at(N)) {
        cnt += pr.second;
        cnt %= mod;
    }
    cout << cnt << endl;
}
    


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

int solve(int x,int y,int z){
  if(x%2==1||y%2==1||z%2==1){
    return 0;
  }else{
    int a=y/2+z/2;
    int b=z/2+x/2;
    int c=x/2+y/2;
    return solve(a,b,c)+1;
  }
}

int main(){
  int A,B,C;
  cin>>A>>B>>C;
  if(A==B&&B==C&&A%2==0){
    cout<<-1<<endl;
  }else{
    cout<<solve(A,B,C)<<endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int n; cin >> n;
  while(n > 0){
    int k = n % 10;
    n /= 10;
    if(k == 9){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  system("pause");
}

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

using namespace std;

typedef long long ll;

int grundy(ll n, ll m){
    if(n==1){
        return grundy(2,m) == 0;
    }
    ll l = m/2, r = m, cnt = 0, ev = m%2, od = (m+1)%2;
    while(l >= n){
        r = l;
        l >>= 1;
        cnt++;
        if(r%2){
            if(ev == 0){
                od = 1;
                ev = 2;
            }
            else if(ev == 1){
                od = 0;
                ev = 2;
            }
            else{
                od = 0;
                ev = 1;
            }
        }
        else{
            bool used[3]{};
            int pev = ev;
            used[pev] = true;
            used[od] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    ev = i;
                    break;
                }
            }
            fill(used, used+3, false);
            used[pev] = true;
            used[ev] = true;
            for(int i=0;i<3;i++){
                if(!used[i]){
                    od = i;
                    break;
                }
            }
        }
    }
    return (n%2 ? od : ev);
}

int main(){
    ll k, allxor = 0;
    cin >> k;

    for(int i=0;i<k;i++){
        ll n, m;
        cin >> n >> m;
        allxor ^= grundy(n, m);
    }
    if(allxor == 0){
        cout << "tubuann" << endl;
    }
    else{
        cout << "mo3tthi" << endl;
    }
    return 0;
}


Measured memory_bytes: 3116
#include <stdio.h>

int main() {
    int i,j,k,h[10];
    for(i=0;i<=9;i++){     
        scanf("%d",&h[i]);
        }
    for(i=9;i>=7;i--){
        for(j=0;j<i;j++){
            if(h[j]>h[j+1])
            {
                k=h[j];
                h[j]=h[j+1];
                h[j+1]=k;                       
            }
        }
            printf("%d\n",h[i]);
    }
    return 0;
}

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

int N;
vector<vector<int> > groups; 
set<int> ans;
map<string, int> nameToId;
vector<bool> flgs;

int toId(string name){
	auto it =  nameToId.find(name);
	if(it == nameToId.end()){
		int nid = nameToId.size();
		nameToId[name] = nid;
		groups.push_back(vector<int>());
		return nid;
	}else{
		return it->second;
	}
}

void dfs(int id){
	if(flgs[id]) return;
	flgs[id] = true;
	//cout << name << endl;
	for(auto& v : groups[id]){
		//cout << v << endl;
		if(groups[v].size()){
			dfs(v);
		}else{
			ans.insert(v);
		}
	}
}

int main(){
	while(cin >> N, N){
		groups.clear();
		nameToId.clear();
		for(int i = 0; i < N; i++){
			string str;
			cin >> str;
			int idx = str.find(":");
			int g = toId(str.substr(0, idx));
			idx++;
			int idx2;
			while((idx2 = str.find(",", idx)) != string::npos){
				groups[g].push_back(toId(str.substr(idx, idx2 - idx)));
				idx = idx2 + 1;
			}
			groups[g].push_back(toId(str.substr(idx, str.size() - idx - 1)));

		}
		ans.clear();
		flgs.assign(groups.size(), false);
		dfs(0);
		cout << ans.size() << endl;
	}
}

Measured memory_bytes: 3304
#include <iostream>
using namespace std;
int main(void){
   long long int n, k;
   cin >> n >> k;
   long long int a[n];
   for(long long int i = 0; i < n; i ++){
       cin >> a[i];
   }
   long long int q = 1;
   if(n - k > 0){
       q += (n - k) / (k -1);
   }
   if((n-k)%(k-1)!=0){
       q++;
   }
   cout << q;
   
   
   
     
}

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

int main(){
  ll X, Y;
  cin >> X >> Y;
  bool check = false;
  for (int i = 0; i <= X; i++) {
    for (int j = 0; i + j <= X; j++){
      if (i * 2 + j * 4 == Y && i+j==X) check = true;
    }
  }
  if(check) cout <<"Yes" <<endl;
  else cout <<"No" << endl;
  return 0;
}

Measured memory_bytes: 3556
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
 
#define vl vector<ll>
#define vi vector<int>
 
#define ff first
#define ss second
 
#define pb push_back
#define MOD 1000000007
//const int nax = 1e6+5;
#define inf 4e18
 
#define display(v) for(int i =0;i<v.size();++i)cout << v[i] << " "
#define all(v) v.begin(),v.end()
ll sqr(ll x){return x*x;}
inline ll add(ll a, ll b){ ll c = a + b; if(c >= MOD) c -= MOD; return c; }
inline ll mul(ll a, ll b){ return (a * 1ll * b) % MOD; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += MOD; return c; }
//const int nax = 1000*1000 + 10;
#define pr pair<ll,ll>
//////////////////////*********CODE***********/////////////////////
//////////////////////////////////////////////////////////////////
class Compare
{
    public:
        bool operator() (pr &a , pr &b)
        {
            int mx1  = min(a.ff , a.ss);
            int mx2 = min(b.ff , b.ss);
            return (mx1  < mx2);
        }
};




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    priority_queue<pr,vector<pr>,Compare> pq;
    int n; cin>>n;
    vl v(n);
    for(int i =0;i<n;++i){
        cin>>v[i];
    }
    sort(all(v));
    reverse(all(v));
    ll ans = 0;
    pq.push({v[0] , v[0]});
    for(int i =1 ;i<n;++i){
        ll val = v[i];
        pr p = pq.top();
        pq.pop();
        ll ok = min(p.ff , p.ss);
        ans  += ok;
        pq.push({p.ff , val});
        pq.push({val , p.ss});
    }
    cout << ans;
    
   

    return 0;
}

// Химаншу

Measured memory_bytes: 8840
N = int(input())
L = [0]*10001
for x in range(1,101):
    for y in range(1,101):
        for z in range(1,101):
            if x**2 + y**2 + z**2 + x*y + y*z +z*x <= 10000:
                L[x**2 + y**2 + z**2 + x*y + y*z +z*x] += 1
for k in range(1,N+1):
    print(L[k])


Measured memory_bytes: 74348
#include<iostream>
#include<vector>
int n,m,q;
std::vector<int> val(11),A(10);
std::vector<int> a(50),b(50),c(50),d(50);
int ans = 0;

void dfs(std::vector<int> &enu, int h){
    if(h == n){
        int cnt = 0;
        for(int k = 0;k < q;k++){
            if(enu.at(b.at(k)) - enu.at(a.at(k)) == c.at(k)){
                cnt += d.at(k);
            }
            ans = std::max(ans,cnt);
            // for(int x = 0;x < n;x++){
            //     std::cout << enu.at(x) << ' ';
            // }
            // std::cout << std::endl;
        }
        return;
    }
    for(int i = enu.at(h);i <= m;i++){
        val.at(h+1) = i;
        dfs(enu,h+1);
    }
    return;
}

int main(){
    std::cin >> n >> m >> q;
    for(int i = 0;i < q;i++){
        std::cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
        a.at(i)--;
        b.at(i)--;
    }
    for(int j = 1;j <= m;j++){
        val.at(0) = j;
        dfs(val,0);
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 3620
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#define INF 999999999
 
using namespace std;
 
int n, s, k, ans;
int a[105000];
 
 
 
void solve()
{
 
    int ret = n + 1;
 
    int l = 0, r = 0;
    map<int,int> m;
    while (1) {
 
        while (r < n && (int)m.size()<k) {
            if (a[r] <= k) {
                m[a[r]]++;
            }
            r++;
        }
        if ((int)m.size() < k)break;
        ret = min(ret, r-l);
        if (a[l] <= k) {
            if (m[a[l]] == 1)m.erase(a[l]);
            else m[a[l]]--;
        }
        l++;
    }
 
    if (ret > n)ret = 0;
    printf("%d\n", ret);
 
}
 
 
int main()
{
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &a[i]);
         
    }
    solve();
 
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    int a[n][3];
    rep(i,n) cin >> a[i][0] >> a[i][1] >> a[i][2];
    int dp[n+1][3] = {0}; // dp[i][j] i日目にjを選ぶ時の幸福の最大値　もらうDPの練習
    rep(i,n) {
        dp[i+1][0] = max(dp[i][1], dp[i][2]) + a[i][0];
        dp[i+1][1] = max(dp[i][2], dp[i][0]) + a[i][1];
        dp[i+1][2] = max(dp[i][0], dp[i][1]) + a[i][2];
    }
    int ans = max({dp[n][0], dp[n][1], dp[n][2]});
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int n,r;
	scanf("%d",&n);
	r=n%10;
	if(r==3){
		printf("bon\n");
	}
	else if(r==0||r==1||r==6||r==8){
		printf("pon\n");
	}
	else{
		printf("hon\n");
	}
	return 0;
}

Measured memory_bytes: 1612
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
using namespace std;
using ll =long long;
const int MOD = 1000000007;

int main() {
	ll H, N;
	ll c;
	ll sum=0;
	cin >> H >> N;
	vector<ll>A;
	for (int i = 0; i < N; i++) {
		cin >> c;
		sum += c;


	}
	sum >= H ? cout << "Yes" : cout << "No";


}

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

const int mn=2e5+6;
const LL mod=1e9+7;
int n,m;
LL a[mn],ans=1;

bool cmp1(LL a,LL b) {return a>b;}
bool cmp(LL a,LL b) {return abs(a)>abs(b);}

LL poww(LL a,LL b)
{
    LL ans=1;
    while(b) {
        if(b&1) ans=ans*a%mod;
        a=a*a%mod;
        b>>=1;
    }
    return ans;
}

int main()
{
    // freopen("a.in","r",stdin);
    // freopen("a.out","w",stdout);
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i) 
        scanf("%lld",&a[i]);
    if(n==m) {
        for(int i=1;i<=n;++i) ans=ans*a[i]%mod;
        cout<<(mod+ans)%mod;
        return 0;
    }
    int f=0;
    for(int i=1;i<=n;++i) if(a[i]>0) f=1;
    if(f==0&&m%2==1) {
        sort(a+1,a+n+1,cmp1);
        for(int i=1;i<=m;++i) ans=ans*a[i]%mod;
        cout<<(mod+ans)%mod;
        return 0;
    }
    sort(a+1,a+n+1,cmp);
    for(int i=1;i<=m;++i) {
        ans=ans*a[i]%mod;
    }
    if(ans>=0) {cout<<ans%mod;return 0;}
    LL laspos=0,lasneg=0,nxtpos=0,nxtneg=0;
    for(int i=1;i<=m;++i) {
        if(a[i]>0) laspos=a[i];if(a[i]<0) lasneg=a[i];
    }
    for(int i=n;i>m;--i) {
        if(a[i]>=0) nxtpos=a[i];if(a[i]<0) nxtneg=a[i];
    }
    if(m==1) {cout<<nxtpos;return 0;}
    // cerr<<ans<<endl<<lasneg<<endl<<laspos<<endl<<nxtneg<<endl<<nxtpos<<endl;
    LL ans1=0,ans2=0;
    ans1=(abs(ans)*poww(laspos,mod-2)%mod)*abs(nxtneg)%mod;
    ans2=(abs(ans)*poww(abs(lasneg),mod-2)%mod)*nxtpos%mod;
    if(laspos==0||nxtpos==0||lasneg==0||nxtneg==0) {
        if(nxtneg==0) {
            cout<<ans2;
            return 0;
        }
        if(laspos==0) {
            cout<<ans2;
            return 0;
        }
    }
    if(laspos*nxtpos>lasneg*nxtneg) cout<<ans2;
    else cout<<ans1;
}

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

int main() {
	int n;
	cin >> n;
	vector<long long> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	long long x = a[n-1] - a[0];
	cout << x << endl;
}

Measured memory_bytes: 256
def main():
  N,K= map(int,input().split())
  h = list(map(int,input().split()))
  dp = [0]*N
  for i in range(1,N):
    dp[i] = min(dp[j] + abs(h[i] - h[j]) for j in range(max(i-K,0),i))
  print(dp[N-1])

if __name__ == '__main__':
  main()

Measured memory_bytes: 13980
import java.util.Scanner;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	int sum = 0;
	while (scan.hasNext()) {
	    String number = scan.nextLine();
	    if (number.equals("0")) {
		break;
	    }
	    System.out.println(sum(number));
	}
    }
    public static int sum (String number) {
	int sum = 0;
	for (int i = 0; i < number.length(); i++) {
	    sum += Integer.valueOf(number.substring(i, i+1));
	}
	return sum;
    }
}

Measured memory_bytes: 26872
import math

#要素の数を数えたい場合（key:数）
n=int(input())
li = list(map(int,input().split()))

dic={}
for i in li:
    if i not in dic:
        dic[i] = 1
    elif dic[i] >= 1:
        dic[i] += 1
        
#print(dic)


cnt = 0
for j in dic:
    cnt += dic[j]*(dic[j]-1)/2
    #print(math.floor(cnt))

for i in range(n):
    print(math.floor(cnt - dic[li[i]]+1))

Measured memory_bytes: 26140
N = int(input())
H = list(map(int, input().split()))

now_h = H[0]
e = 0
for h in H:
    if h - now_h == -1:
        if e > h:
            print('No')
            exit()
        else:
            e = h
            now_h -= 1
    elif h - now_h < -1:
        print('No')
        exit()
    now_h = h

print('Yes')

Measured memory_bytes: 63856
#include <iostream>
#include <string>
#include <map>

int main() {
    std::string S, T;
    std::cin >> S >> T;
    bool ok = true;
    std::map<char,char> ma, ima;
    for (int i = 0; i < S.size(); ++i) {
        char s = S[i], t = T[i];
        if (ma.count(s)) if (ma[s] != t) ok = false;
        if (ima.count(t)) if (ima[t] != s) ok = false;
        ma[s] = t; ima[t] = s;
    }
    if (ok) std::puts("Yes");
    else std::puts("No");
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    int n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>k>>a>>b;

    for(int i=a;i<=b;i++)
        if(!(i%k))cnt++;

    if(cnt)cout<<"OK\n";
    else cout<<"NG\n";

    return 0;
}


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

int main(){
    long long d, n;
    cin >> d >> n;

    if(d == 0){
        if(n <= 99){
            printf("%lld\n", n);
        }
        else{
            printf("101\n");
        }
    }
    else if(d == 1){
        if(n <= 99){
            printf("%lld\n", 100*n);
        }
        else{
            printf("10100\n");
        }
        
        
    }
    else if(d == 2){
        if(n <= 99){
            printf("%lld\n", 10000*n);
        }
        else{
            printf("1010000\n");
        }
        
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int mod=1e9+7;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long double l;cin >> l;
    long double ans=l*l*l/3/3/3;
    cout << fixed << setprecision(15) << ans << endl;
}

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

int const N = 100000;
vector<int> tr[N];
int an[N];
bool need[N];

void go(int v = 0, int p = -1){
	int w = (int)tr[v].size() - 1;
	int x = -1, y = 0;
	f(i, 0, tr[v].size()){
		int u = tr[v][i];
		if (u == p)continue;
		go(u, v);
		an[v] += an[u];
		if (an[u]){
			--w;
			x = u;
			++y;
		}
	}
	if (w > 0)an[v] += w - 1, need[v] = true;
	else {
		bool bad = false;
		f(i, 0, tr[v].size()){
			int u = tr[v][i];
			if (u == p)continue;
			if (need[u]) { if (y > 1 || y == 1 && x != u)need[u] = false; }
			if (need[u])bad = true;
		}
		need[v] = bad;
	}
	if (v == 0 && need[0])++an[0];
}

int main(){
	int n;
	scanf("%d", &n);
	f(i, 1, n){
		int a, b;
		scanf("%d%d", &a, &b);
		tr[a].push_back(b);
		tr[b].push_back(a);
	}
	go();
	printf("%d\n", max(1, an[0]));
}

Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int s = abs(A[0]) + abs(A[N-1]);
  rep(i, N-1) s += abs(A[i]-A[i+1]);
  
  rep(i, N) {
    int ss = s;
    if(i == 0) {
      ss -= abs(A[0]) + abs(A[0]-A[1]);
      ss += abs(A[1]);
    } else if(i == N-1) {
      ss -= abs(A[i]-A[i-1]) + abs(A[i]);
      ss += abs(A[i-1]);
    } else {
      ss -= abs(A[i]-A[i-1]) + abs(A[i]-A[i+1]);
      ss += abs(A[i-1]-A[i+1]);
    }
    cout << ss << endl;
  }
        

}


Measured memory_bytes: 3964
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e6 + 5;
int n;
int z[N];
unordered_map <int, int> mp;
int main()
{
    scanf("%d", &n);
    for (int i = 0; i < n; ++i)
        scanf("%d", z + i);
    int c = 0;
    for (int i = 0; i < n; ++i)
    {
        if (mp[z[i]] == 0)
            ++c;
        ++mp[z[i]];
    }
    if (c == 1)
    {
        if (z[0] == 0)
            puts("Yes");
        else
            puts("No");
        return 0;
    }
    if (n % 3 != 0)
    {
        puts("No");
        return 0;
    }
    if (c != 3)
    {
        if (c == 2 && mp[0] == n / 3)
        {
            puts("Yes");
            return 0;
        }
        puts("No");
        return 0;
    }
    int f = 1;
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        if (mp[z[i]] == 0)
            continue;
        ans ^= z[i];
        if (mp[z[i]] != n / 3)
            f = 0;
    }
    if (!f || ans != 0)
        puts("No");
    else
        puts("Yes");
    return 0;
}

Measured memory_bytes: 4004
a,b,c = map(int, input().split())
sm=a
x=a%b
sm%=b
if sm==c:
    print("YES")
    exit()

for i in range(10**5):
    sm+=a
    sm%=b
    
    if sm==c:
        print("YES")
        exit()
    elif sm==x:
        break

print("NO")


Measured memory_bytes: 61372
#include <stdio.h>

int
main(void)
{
        int n;
        int x;
        int maxv;
        int min;

        scanf("%d\n", &n);
        scanf("%d\n", &x);
        scanf("%d\n", &maxv);
        min = (x < maxv) ? x : maxv;
        maxv = maxv - x;

        for (int i = 2; i < n; i++) {
                scanf("%d\n", &x);
                int v = x - min;
                if (x < min)
                        min = x;
                else if (maxv < v)
                        maxv = v;
        }

        printf("%d\n", maxv);

        return 0;
}



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

int main(){ 
  int n, m, q;
  cin >> n >> m >> q;
  vector<int> a(q), b(q), c(q), d(q);
  rep(i,q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--;
    b[i]--;
  }

  int res = 0;
  auto dfs = [&](auto&& f, vector<int> now)->void{
    if (now.size() == n) {
      int tmp = 0;
      for (int i = 0; i < q; i++) {
        if (now[b[i]] - now[a[i]] == c[i]) tmp += d[i]; 
      }
      res = max(res, tmp);
      return ;
    }
    for (int j = 1; j <= m; j++) {
      if (!now.empty() && now.back() > j) continue;
      auto next = now;
      next.emplace_back(j);
      f(f, next);
    }
  };
  vector<int> l;
  dfs(dfs,l);
  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3632
nk=input().rstrip().split(" ")
rsp=input().rstrip().split(" ")
t=input()
n=int(nk[0])
k=int(nk[1])
r=int(rsp[0])
s=int(rsp[1])
p=int(rsp[2])
point=0
sta="neutral"

def read(l):
    global point
    global sta
    if sta=="rpointed":
        if l=="r":
            point+=p
            sta="ppointed"
        elif l=="s":
            point+=0
            sta="rskiped"
        elif l=="p":
            point+=s
            sta="spointed"
    elif sta=="spointed":
        if l=="r":
            point+=p
            sta="ppointed"
        elif l=="s":
            point+=r
            sta="rpointed"
        elif l=="p":
            point+=0
            sta="sskiped"
    elif sta=="ppointed":
        if l=="r":
            point+=0
            sta="pskiped"
        elif l=="s":
            point+=r
            sta="rpointed"
        elif l=="p":
            point+=s
            sta="spointed"
    elif sta=="rskiped" or sta=="sskiped" or sta=="pskiped":
        if l=="r":
            point+=p
            sta="ppointed"
        elif l=="s":
            point+=r
            sta="rpointed"
        elif l=="p":
            point+=s
            sta="spointed"
    elif sta=="neutral":
        if l=="r":
            point+=p
            sta="ppointed"
        elif l=="s":
            point+=r
            sta="rpointed"
        elif l=="p":
            point+=s
            sta="spointed"        
            
strs=[[] for i in range(k)]
for i in range(n):
    u=t[i:i+1]
    strs[i%k].append(u)
#print(strs)

for i in range(k):
    sta="neutral"
    for j in range(len(strs[i])):
        read(strs[i][j])
        #print(sta)
        #print(point)
print(point)

Measured memory_bytes: 13436
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int64_t cr =count(s.begin(),s.end(),'R');
    int64_t cg=count(s.begin(),s.end(),'G');
    int64_t cb=count(s.begin(),s.end(),'B');
    
    auto ans=cr*cg*cb;
    for(int j=0; j<n; j++){
        for(int i=1; i<=n/2; i++){
            if(j+2*i>=n)continue;
            if(s.at(j)!=s.at(j+i) and s.at(j+i)!=s.at(j+2*i) 
            and s.at(j+2*i)!=s.at(j))ans--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> Pl;
typedef pair<int, int> P;

int n;
vector<int> g[100000];
bool used[100000];
int ct;
void dfs(int x){
	ct++;
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]) dfs(y);
	}
}
ll dist[100000];
int sz[100000];
void dfs2(int x){
	used[x]=1;
	sz[x]=1;
	for(auto y:g[x]){
		if(!used[y]){
			dist[y]=dist[x]+1;
			dfs2(y);
			sz[x]+=sz[y];
		}
	}
}
ll d2[100000];
void dfs3(int x){
	used[x]=1;
	for(auto y:g[x]){
		if(!used[y]){
			d2[y]=d2[x]-(ll)sz[y]+(ll)(n-sz[y]);
			dfs3(y);
		}
	}
}

int main()
{
	cin>>n;
	if(n<=4){
		cout<<-1<<endl;
		return 0;
	}
	ll d[100000];
	set<Pl> st;
	for(int i=0; i<n; i++){
		cin>>d[i];
		st.insert(Pl(d[i], i));
	}
	vector<P> ans;
	int s[100000];
	fill(s, s+n, 1);
	while(!st.empty()){
		auto itr=st.end(); itr--;
		int i0=(*itr).second;
		ll d0=(*itr).first;
		st.erase(itr);
		auto itr1=st.lower_bound(Pl(d0-(ll)(n-2*s[i0]), -1));
		if(itr1==st.end() || (*itr1).first!=d0-(ll)(n-2*s[i0])) continue;
		int i1=(*itr1).second;
		ans.push_back(P(i0, i1));
		g[i0].push_back(i1);
		g[i1].push_back(i0);
		s[i1]+=s[i0];
		if(ans.size()==n-1) break;
	}
	dfs(0);
	if(ct<n){
		cout<<-1<<endl;
		return 0;
	}
	fill(used, used+n, 0);
	dfs2(0);
	ll d0=0;
	for(int i=0; i<n; i++) d0+=dist[i];
	if(d[0]!=d0){
		cout<<-1<<endl;
		return 0;
	}
	d2[0]=d[0];
	fill(used, used+n, 0);
	dfs3(0);
	for(int i=1; i<n; i++){
		if(d[i]!=d2[i]){
			cout<<-1<<endl;
			return 0;
		}
	}
	for(int i=0; i<n-1; i++){
		cout<<ans[i].first+1<<" "<<ans[i].second+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 18680
n = int(input())
counter = {}
uniqs = set()
for i in range(n):
    s = list(input())
    s.sort()
    s = ''.join(s)
    counter[s] = counter.get(s,0) + 1
    uniqs.add(s)
    #print("{}".format(s[i]))

ans = 0
for orig in uniqs:
    occurence = counter.get(orig)
    ans = ans + (occurence * (occurence -1)) // 2
print("{}".format(ans))


Measured memory_bytes: 21192
if __name__ == '__main__':
    num = int(input())
    T, A = list(map(int, input().split()))
    location = list(map(int, input().split()))
    

    ans_num = 1
    ans_temp = T - location[0] * 0.006

    for i in range(1, num):
        temp = T - location[i] * 0.006
        if abs(A - ans_temp) > abs(A - temp):
            ans_temp = temp
            ans_num = i + 1
    print(ans_num)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define fi first
#define se second
#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 rep11(i, n) for (int i = 1; i < (int)(n); ++i)
#define repo(i, o, n) for (int i = o; i < (int)(n); ++i)
#define repm(i, n) for (int i = (int)(n)-1; i >= 0; --i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1002000007
#define INF LONG_LONG_MAX

typedef pair<int, int> P;
int main() {
    int r,d,x;
    cin>>r>>d>>x;
    rep(i,10){
        x=r*x-d;
        cout<<x<<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>

using namespace std;

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

    vector<int> A(N);
    for (size_t i = 0; i < N; i++)
    {
        cin >> A[i];
    }

    int ans = 0;
    for (size_t i = 0; i < N; i++)
    {
        for (size_t j = i + 1; j < N; j++)
        {
            int diff = abs(A[i] - A[j]);
            if (ans < diff)
            {
                ans = diff;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let s = read::<String>().chars().collect::<Vec<_>>();
    let big_int = 1000_000_000 + 7i64;
    let mut coef = 1;
    for i in 1..n as i64 + 1 {
        coef *= i;
        coef %= big_int;
    }
    if s[0] == 'W' {
        println!("0");
        return;
    }
    let mut is_assigned_l = vec![false; 2 * n];
    is_assigned_l[0] = true;
    for i in 1..s.len() {
        if s[i] == s[i - 1] {
            is_assigned_l[i] = !is_assigned_l[i - 1];
        } else {
            is_assigned_l[i] = is_assigned_l[i - 1];
        }
    }
    debug!(is_assigned_l);
    let l_count = is_assigned_l
        .iter()
        .fold(0, |sum, &x| if x { sum + 1 } else { sum });

    if l_count != n || *is_assigned_l.last().unwrap() {
        println!("0");
        return;
    }
    let mut l_count = 0;
    let mut ans = 1;
    for i in 0..s.len() {
        if is_assigned_l[i] {
            l_count += 1;
        } else {
            ans *= l_count;
            ans %= big_int;
            l_count -= 1;
        }
    }
    ans *= coef;
    ans %= big_int;
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 4352
import sys
def input(): return sys.stdin.readline().strip()
mod = 10**9+7

def main():
    n, m = map(int, input().split())
    X = list(map(int, input().split()))
    Y = list(map(int, input().split()))
    """
    各長方形を１つ１つの矩形に分解することで、もともと線で区切られていた
    最小の長方形たちが個別に何回足されるかを見る。
    長方形が縦に(m-1)個、横に(n-1)個並んでいるとして、(i, j)の位置にある長方形は
        i * (m - i) * j * (n - j)
    回足される。
    これをシグマ計算するとx, y方向独立に解いてよいことがわかる。
    """
    x = 0
    for j in range(1, n):
        coeff = j * (n - j) % mod
        x += coeff * (X[j] - X[j - 1]) % mod
        x %= mod
    y = 0
    for i in range(1, m):
        coeff = i * (m - i) % mod
        y += coeff * (Y[i] - Y[i - 1]) % mod
        y %= mod
    print(x * y % mod)

if __name__ == "__main__":
    main()


Measured memory_bytes: 97668
import sys

count = 0
N = 0
K = 0
Check = []

while True:

    try:
        S = input()
        count += 1
    except:
        print(N - sum(Check))
        break
	
    if count > 1 and count % 2 == 1:
      split = S.split()
      for i in range(len(split)):
        Check[int(split[i]) - 1] = True      
      
    if count == 1:
      split = S.split()
      N = int(split[0])
      K = int(split[1])
      for i in range(N):
        Check.append(False)


Measured memory_bytes: 9228
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

using ll = long long;

int main() {
    int n;
    cin >> n;
    vector<ll> f(n + 1, 1);
    rep(i, n - 1) f[i + 2] = f[i] + f[i + 1];
    cout << f[n] << "\n";
}


Measured memory_bytes: 3092
g x = if x=='A'||x=='C'||x=='G'||x=='T' then True else False
f n k (x:l)= if null l then if g x then max (k+1) n else max n k else if g x then f n (k+1) l else if n<k then f k 0 l else f n 0 l
main=getLine>>=print.f 0 0

Measured memory_bytes: 380
N,M = map(int, input().split())  
piys = [[] for _ in range(N)]   
for i in range(M):  
    p, y = map(int, input().split())  
    piys[p-1].append((y,i))  

ans = [None]*M  
for p,iys in enumerate(piys):  
    iys.sort()  
    for k,(y,i) in enumerate(iys):  
        ans[i] = "%06d%06d" % (p+1,k+1)  

for i in ans:  
    print(i) 

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

int t;
long long a, b, c, d;

int main(){
	scanf("%d", &t);
	while(t--){
		scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
		
		if(a < b || d < b){
			printf("No\n");
			continue;
		}
		if(c + 1 >= b){
			printf("Yes\n");
			continue;
		}
		
		d = __gcd(d, b);
		a %= d;
		
		if(a > c){
			printf("No\n");
			continue;
		}
		
		long long y = (a + (c - a + d) / d * d) % b;
		
		if(y <= c)printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}



Measured memory_bytes: 3672
#include <iostream>

int main()
{
  int N, R;
  std::cin >> N >> R;

  int S; // internal rating
  if(10 < N) {
    S = R;
  } else {
    S = R + 100*(10-N);
  }

  std::cout << S << std::endl;
  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

//cin.tie(0);ios::sync_with_stdio(false);
//cout<<fixed<<setprecision(20);

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

//cin.tie(0);ios::sync_with_stdio(false);
//cout<<fixed<<setprecision(20);


template<typename T> 
struct BIT{
  int n;
  vector<T> bit;//1-indexed

  BIT():n(-1){}
  //initialization

  BIT(int n_,T d):n(n_),bit(n_+1,d){}
  //initialization2 n_要素数 d初期値
  
  T sum(int i){
    T s=bit[0];
    for(int x=i;x>0;x-=(x&-x))
      s+=bit[x];
    return s;
  }
  //1からiまでの和(1-indexed)
  
  void add(int i,T a){
    if(i==0) return;
    for(int x=i;x<=n;x+=(x&-x))
      bit[x]+=a;
  }
  //iにa加える
  
  T lower_bound(T w){
    if(w<=0) return 0;
    T x=0,r=1;//xは横の位置を管理するイメージ
    while(r<n) r<<=1;
    for(T k=r;k>0;k>>=1){//上の層から見る
      if(x+k<=n && bit[x+k]<w){
        w-=bit[x+k];
        x+=k;//右の要素に移る
      }
    }
    return x+1;
  }
  //indまでの区間和がw以上になるような最小のindを求める
  
  T sum0(int i){
    return sum(i+1);
  }
  void add0(int i,T a){
    add(i+1,a);
  }//0-index用

  T query(int l,int r){
    return sum(r-1)-sum(l-1);
  }//[l,r)の和を求める

  T query0(int l,int r){
    return sum(r)-sum(l);
  }//0-index用
};

signed main(){
    ll n,k,ans=0;cin>>n>>k;
    
    vector<ll> v(n),sum(n,0);
    rep(i,0,n){
        cin>>v[i];
        v[i]=v[i]-k;
        if(i>0)sum[i]=sum[i-1]+v[i];
        else sum[0]=v[i];

        if(sum[i]>=0)ans++;
    }

    vector<ll> ind=sum;
    sort(all(ind));
    map<ll,ll> ma;
    rep(i,0,n){
        ma[ind[i]]=i+1;
    }

    BIT<ll> b(n,0);

    rep(i,0,n){
        ans+=b.query(0,ma[sum[i]]+1);
        b.add(ma[sum[i]],1); 
        //cerr<<ans<<endl;
    }
    cout<<ans<<endl;

}   


Measured memory_bytes: 19072
#include <bits/stdc++.h>
#define MAX (ll)(1e4 + 4)
#define MOD (ll)(1e9 + 7)
#define INF (ll)(1e18)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false), cin.tie (nullptr);

using namespace std;
using ll = long long;
using ld = long double;

int main () {
	ll n, d, a;
	cin >> n >> d >> a;
	ll co[n + 1] = {};
	pair<ll, ll> ar[n];
	ll cur = 0;
	ll aa[n];
	for (ll i = 0; i < n; i++) {
		cin >> ar[i].first >> ar[i].second;
		aa[i] = ar[i].first;
	}
	sort (ar, ar + n);
	sort (aa, aa + n);
	ll ans = 0;
	for (ll i = 0; i < n; i++) {
		cur -= co[i];
		if (ar[i].second > cur) {
			ll xx = (ar[i].second - cur) / a + ((ar[i].second - cur) % a > 0);
			ll ii = upper_bound (aa, aa + n, 2 * d + ar[i].first) - aa;
			co[ii] +=  xx * a;
			cur += xx * a;
			ans += xx;
		}
	}
	cout << ans << "\n";
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  string s;
  cin>>s;
  Int n=s.size();
  if(n==1) drop(1);
  vector<Int> dp1(n+1,-n),dp2(n+1,-n);
  dp1[1]=1;
  dp2[2]=1;
  for(Int i=0;i<n;i++){
    if(i>=1){
      if(s[i]!=s[i-1])
        chmax(dp1[i+1],dp1[i]+1);
      chmax(dp2[i+2],dp1[i]+1);
    }
    if(i>=2){
      chmax(dp1[i+1],dp2[i]+1);
      if(s[i]!=s[i-2]||s[i+1]!=s[i-1])
        chmax(dp2[i+2],dp2[i]+1);
    }
  }
  cout<<max(dp1[n],dp2[n])<<endl;
  return 0;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main(){
    ll n;
  cin>>n;
  bool a=false;
  for(ll i=1;i<10;i++){
    for(ll j=i;j<10;j++){
      if(i*j==n)a=true;
    }
  }
  if(a)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int f(int *b, int N){
    int order = 0;
    for(int i=1; i<=N; i++)
    {
        if(b[i-1] != i)
        {continue;}

        order = i;
    }
    return order;
}
int main(){
    int N;
    cin >> N;

    int b[N];
    for (int i=0; i < N; i++)
    {
        cin >> b[i];
    }

/*
    for (int i=0; i < N; i++)
    {
        cout << b[i] << endl;
    }
*/
    // unsolvable
    for (int i=0; i< N; i++)
    {
        if(b[i] > i+1){
            cout << -1 << endl;
            return 0;
        }
    }

    // solvable

    // order 
    int c[N];
    for (int i=0; i< N; i++)
    {
        c[N-1-i] = f(b, N-i);
        for(int j=c[N-1-i]-1; j<N-1-i; j++)
        {
            b[j] = b[j+1];
        }
      /*
        cout << "(" << c[N-1-i] << ") : new b" << endl;
        for (int bi = 0; bi < N-1-i; bi++)
        {
            cout << b[bi] << endl;
        }
        // */
    }

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

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    A, B, C = map(int, input().split())
    if C == 0 or A % B == C:
        print("Yes")
        sys.exit()
    rem = A % B
    i = 2
    ans = "NO"
    while True:
        if (A * i) % B == rem:
            break
        elif (A * i) % B == C:
            ans = "YES"
            break
        i += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    for(int i=1; i<=3; ++i){
        if(i!=a&&i!=b) cout<<i<<endl;
    }
}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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 = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  vector<pll> a(n);
  rep(i,n){
    ll x,y; cin>>x>>y;
    a[i]=pii(x,y);
  }
  vsort(a);
  double ans=0;
  do{
    double tmp=0;
    rep(i,n-1){
      tmp+=sqrt((a[i+1].first-a[i].first)*(a[i+1].first-a[i].first)+(a[i+1].second-a[i].second)*(a[i+1].second-a[i].second));
    }
    ans+=tmp;
  }while(next_permutation(a.begin(),a.end()));
  ll tmp=1;
  reps(i,n){
    tmp*=i;
  }
  coutd(ans/tmp);
}

Measured memory_bytes: 256
n = input()
test_dif = input().split(" ")

n = int(n)
test_dif = [int(n) for n in test_dif]
test_dif2 = sorted(test_dif)
a = test_dif2[int(n/2)-1]
b = test_dif2[int(n/2)]
ans = b - a
print(ans)

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

int h, w, m, a[300001], b[300001], p1, p2;
typedef pair <int, int> pi;
set <pi> st;

int main() {
	int i, j, x, y;
	cin >> h >> w >> m;
	vector <int> l, r;

	for(i = 1; i <= m; ++i) {
		cin >> x >> y;
		st.insert(make_pair(x, y));
		a[x]++;
		b[y]++;
		if(a[x] > p1) {
			l.clear();
			p1 = a[x];
		}
		if(a[x] == p1) l.push_back(x);

		if(b[y] >p2) {
			r.clear();
			p2 = b[y];
		}
		if(b[y] == p2) r.push_back(y);
	}

	for(i = 0; i < l.size(); ++i) {
		for(j = 0; j < r.size(); ++j) {
			if(st.find(make_pair(l[i], r[j])) == st.end()) {
				cout << p1 + p2;
				return 0;
			}
		}
	}

	cout << p1 + p2 - 1;
	return 0;
}

Measured memory_bytes: 21888
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef pair<int, int> pii;

const int N = 102;

int n;
vector<int> a;

int main() {
	std::ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n;
	a.resize(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	vector<int> res;
	for (int s = 0; s < n; s++) {
		bool ok = 0;
		for (int i = SZ(a) - 1; i >= 0; i--) {
			if (a[i] == i + 1) {
				res.push_back(i + 1);
				a.erase(a.begin() + i);
				ok = 1;
				break;
			}
		}
		if (!ok) {
			cout << -1 << endl;
			return 0;
		}
	}
	reverse(res.begin(), res.end());
	for (int x : res)
		cout << x << "\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string ch;
    cin>>ch;
    int flag=0;
    for(int i=0;i<ch.size();i++)
    {
        if(ch[i]=='7')
        {
            flag=1;
        }
    }
    if(flag==0)
    {
        cout<<"No"<<endl;
    }
    else if(flag==1)
    {
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 3620
/* Great things never come from comfort zones,
"whatever the mind of a man can conceive and believe,it can achieve." */
 
#include <bits/stdc++.h>
#define ll long long
#define scf(n) scanf("%d",&n)
#define lscf(n) scanf("%lld",&n)
#define lpri(n) printf("%lld ",n)
#define pri(n) printf("%d ",(int)n)
#define prin(n) printf("%d\n",(int)n)
#define lprin(n) printf("%lld\n",n)
#define rep(i,ini,n) for(int i=ini;i<(int)n;i++)
#define pb push_back
#define pf push_front
#define mp make_pair
#define F first
#define S second
#define all(x)     x.begin(),x.end()
#define tc   int tt; scf(tt); while(tt--)
#define inf INT_MAX
#define ninf INT_MIN
#define gcd __gcd
#define bitcount(n) __builtin_popcount(n)
typedef double dd;
using namespace std;
const ll mod =1e9+7;
const int N = 1e6+7;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B) 
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

bool v[10]={0};

int main()
{

    
   // cout<<s<<endl;
    
    int n,k;
    scf(n),scf(k);
    
    rep(i,0,10)
    v[i]=0;
    
    rep(i,0,k)
    {
        int a; scf(a);
    
        v[a]=1;
    }
    
    
     bool OK=1;
     
     while(1)
     {
         int x=n;
         
         OK=1;
         
         while(x>0)
         {
             if(v[x%10])
             {
                 OK=0;
                 break;
             }
             
             x/=10;
            
         }
         
         if(OK)
         break;
        
        n++;

     }
     
     prin(n);
     

}


Measured memory_bytes: 3804
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, M;
    cin >> N;
    map<string, int> sm;
    rep(i, 0, N)
    {
        string s;
        cin >> s;
        ++sm[s];
    }
    cin >> M;
    map<string, int> tm;
    rep(i, 0, M)
    {
        string s;
        cin >> s;
        ++tm[s];
    }
    int ans = 0;
    for (const auto& it : sm)
    {
        chmax(ans, it.second - tm[it.first]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#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;
int main(void){
    int n;cin>>n;
    string s,t;cin>>s>>t;
    if(s==t){
        cout<<n<<endl;
        return 0;
    }
    int tmp=0;
    rep(i,n){
        if(s[i]==t[tmp])tmp++;
        //else tmp=0;
    }
    int res=2*n-tmp;
    cout<<res<<endl;
}

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

int main(){
  int n;
  int a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
  };
  cin >> n;
  cout << a[n-1]<<endl;
}

Measured memory_bytes: 256