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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

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

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

int N, Ma, Mb;
int dp[41][401][401];
int main(){
    ios::sync_with_stdio(false);
    cin >> N >> Ma >> Mb;
    
    REP(k,41)REP(i,401)REP(j,401) dp[k][i][j]=INF;
    dp[0][0][0]=0;
    dp[1][0][0]=0;
    REP(k,N) {
        int a, b, c;
        cin >> a >> b >> c;
        
        REP(i,401) REP(j,401){
            dp[k+1][i][j] = min(dp[k+1][i][j], dp[k][i][j]);
            if(i+a<401&&j+b<401) {
                dp[k+1][i+a][j+b] = min(dp[k+1][i+a][j+b],dp[k][i][j]+c);
            }
        }
    }
    
    int ans = INF;
    for(int i = 1; i*Ma<=400 && i*Mb<=400; i++) ans=min(ans, dp[N][Ma*i][Mb*i]);
    
    if(ans < INF) cout << ans << endl;
    else cout << -1 << endl;
    
    return 0;
}

Measured memory_bytes: 26112
#include<cstdio>
#include<cstdlib>
#include<cstring>
 struct Node
 {
     int key;
     Node *next,*prev;
 };
 Node* nil;
 Node* listSearch(int key)
 {
     Node* cur=nil->next;
     while(cur!=nil&&cur->key!=key)
     {
         cur=cur->next;
     }
     return cur;
 }
 void init()
 {
     nil=(Node*)malloc(sizeof(Node));
     nil->next=nil;
     nil->prev=nil;
 }
 void printList()
 {
     Node* cur=nil->next;
     int isf=0;
     while(1)
     {
         if(cur==nil) break;
         if(isf++>0) printf(" ");
         printf("%d",cur->key);
         cur=cur->next;
     }
     printf("\n");
 }
 void deleteNode(Node *t)
 {
     if(t==nil) return ;
     t->prev->next=t->next;
     t->next->prev=t->prev;
     free(t);
 }
 void deleteFirst()
 {
     deleteNode(nil->next);
 }
 void deleteLast()
 {
     deleteNode(nil->prev);
 }
 void deleteKey(int key)
 {
     deleteNode(listSearch(key));
 }
 void insert(int key)
 {
     Node *x=(Node*)malloc(sizeof(Node));
     x->key=key;
     x->next=nil->next;
     nil->next->prev=x;
     nil->next=x;
     x->prev=nil;
 }
 int main()
 {
    int key,n,i;
  //  int size=0;
    char com[20];
    //int np=0,nd=0;
    scanf("%d",&n);
    init();
    for(i=0;i<n;i++)
    {
        scanf("%s%d",com,&key);
        if(com[0]=='i'){insert(key);/*np++;size++;*/}
        else if(com[0]=='d')
        {
            if(strlen(com)>6)
            {
            if(com[6]=='F') deleteFirst();
            else if(com[6]=='L') deleteLast();
            }
            else
            {
                deleteKey(key);// nd++;
            }
            //size--;
        }
    }
    printList();
    return 0;
 }



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

class AOJ
{
    static void Main(string[] args)
    {
        while (true)
        {
            string[] tmp = Console.ReadLine().Split(' ');
            int n = int.Parse(tmp[0]);
            int a = int.Parse(tmp[1]);
            int b = int.Parse(tmp[2]);
            if ((n | a | b) == 0) break;
            bool[] uc = new bool[n + 1];
            int ans = 0;
            uc[0] = true;
            for (int i = 0; i <= n; i++)
            {
                if (!uc[i]) ans++;
                else
                {
                    if (i + a <= n)
                        uc[i + a] = true;
                    if (i + b <= n)
                        uc[i + b] = true;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 7640
N = int(input())
A = [int(x) for x in input().split()]
for i in range(N):
  A[i] = [A[i],i]
A.sort()
B = A
for i in range(N):
  A[i] = [A[i],i]
A = sorted(A,key = lambda x : x[0][1])
c = N//2-1
for i in range(N):
  if A[i][1]<=c:
    print(B[N//2][0][0])
  else:
    print(B[c][0][0])

Measured memory_bytes: 128852
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(ll i = (begin); i < (end); i++)
#define rep(i, n) FOR(i, 0, n)
using ll = long long;
using namespace std;
#define all(x) (x).begin(),(x).end()
using pii = pair<int, int>;
template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; }

int main(int argc, char const *argv[])
{
    ll N, A, B;
    cin >> N >> A >> B;
    auto q = N/ (A+B) * A;
    auto r = N % (A+B);
    if (r < A) q += r;
    else q += A;
    cout << q << endl;
    return 0;
}


Measured memory_bytes: 256
/*||>>>> Praveen Ojha <<<<>>>> 10 August 2019 <<<<>>>> 17:40:23 <<<<||*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
//Read Problems Carefully & Check for corner cases N=0,1 ?
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
    int n;
    cin>>n;
    vector <string> v;
    string s;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(all(s));
        v.push_back(s);
    }
    sort(all(v));
    debug()<< imie(v);
    int ans=0;
    for(int i=0;i<n;i++){
        int val=upper_bound(all(v),v[i])-lower_bound(v.begin()+i+1,v.end(),v[i]);
        debug()<< imie(val);
        ans+=val;
    }
    cout<<ans<<"\n";
return 0;
}

Measured memory_bytes: 5748
#include <iostream>
using namespace std;
int main(void){
    int n;
    long long int a[11451],ans=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        while(1){
            if(a[i]%2!=0)break;
            a[i]/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 384
#!/usr/bin/env python3
#ABC130 B

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

L = list(map(int,input().split()))

D = 0
count = 1
for i in range(N):
    ND = D + L[i]
    if ND > X:
        break
    count += 1
    D = ND
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define cout16 cout << setprecision(16) 
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using P = std::pair<int,int>;
using vp = std::vector<P>;
using namespace std;
#define INF 1001001001
#define LL_INF 1001001001001001001
#define fi first
#define se second
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint comb(int n, int k){
	mint res = 1;
	for(int i=n; i>n-k; i--){
		res = res * i;
//		cout << res.x << endl;
	}
	for(int i=k; i>0; i--){
		res = res / i;
//		cout << res.x << endl;
	}	
	return res;
}

mint pow_kai(int _a, int n){//aのn乗を計算します。
  mint x = 1;
  mint a = _a;
  while(n > 0){//全てのbitが捨てられるまで。
    if(n&1){//1番右のbitが1のとき。
      x = x*a;
    }
    a = a*a;
    n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
  }
  return x;
}

int main(void) {
	int n,a,b; cin >> n >> a >> b;
	mint ans;
	ans = pow_kai(2,n)-1-comb(n,a)-comb(n,b);
	cout << ans.x << endl;

}




Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{

//支払金額N, 1円玉の数A,
  int N = 0;
  int A = 0;
  int a = 0;

  scanf("%d", &N);
  scanf("%d", &A);

  a = N % 500;

  if(a<=A){
    printf("Yes");
  }else{
    printf("No");
  }

}

Measured memory_bytes: 128
mod = 998244353

N, K = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(K)]
dp = [0]*(2*N+10)
dp[0] = 1
tmp = 0
for i in range(N):
    tmp += dp[i]
    tmp %= mod
    for L, R in S:
        dp[i+L] += tmp
        dp[i+R+1] -= tmp
print(dp[N-1]%mod)

Measured memory_bytes: 71096
n, m, x = map(int,input().split())

a = [[0 for i in range(m)] for _ in range(n)]
c = [0] * n
for sankousyo in range(n):
    c_and_a = list(map(int,input().split()))
    c[sankousyo] = c_and_a[0]
    a[sankousyo] = c_and_a[1:]
    
cost = [0] * (2**n)
INF = 10**12
res_cost = INF
for i in range(2**n):
    understandings = [0] * m
    cost_sum = 0
    for j in range(n):
        if (i >> j) & 1:

            cost_sum += c[j]
            
            for k in range(m):
                understandings[k] = understandings[k] + a[j][k]

    res = True
    for j in range(m):
        if understandings[j] < x:
            res = False 

    if res:
        if res_cost > cost_sum:
            res_cost = cost_sum

if res_cost == INF:
    print(-1)
else:
    print(res_cost)


Measured memory_bytes: 9152
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);
		String today = scanner.nextLine();
		if(today.equals("Sunny")){
			System.out.println("Cloudy");
		}else if(today.equals("Cloudy")){
			System.out.println("Rainy");
		}else{
			System.out.println("Sunny");
		}
	}
}

Measured memory_bytes: 21332
N = int(input())
data = {}

for i in range(N):
    S = input()
    if S in data.keys():
        data[S] += 1
    else:
        data[S] = 1

m = max(data.values())

L = []

for x in data.keys():
    if data[x] == m:
        L.append(x)

L.sort()

for i in range(len(L)):
    print(L[i])

Measured memory_bytes: 32096
import itertools
n = int(input())
l = list(map(int, input().split()))
count = 0
c_list = list(itertools.combinations(l, 3))

for c in c_list:
    if (c[0]+c[1])>c[2] and (c[1]+c[2])>c[0] and (c[2]+c[0])>c[1]:
        if len(set(c)) == 3:
            count += 1

print(count)

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

int main() {
    int N; cin >> N;
    vector<int> A(N);
    int s = 0;
    for (int i = 0 ; i < N; ++i) {
        cin >> A[i];
        s ^= A[i];
    }
    for (int i = 0; i < N; ++i) {
        cout << (int)(s ^ A[i]) << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3952
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
	"strings"
)

func main() {
	io := NewIo(os.Stdin, os.Stdout)
	defer io.Flush()
	n := io.NextInt()
	n %= 1000
	if n != 0 {
		n = 1000 - n
	}
	io.Println(n)
}

// Io is I/O object
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

// NewIo returns a new Io instance
func NewIo(r io.Reader, w io.Writer) *Io {
	return &Io{
		reader: bufio.NewReader(r),
		writer: bufio.NewWriter(w),
	}
}

// Flush flushes writer
func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

// NextLine scans a line from stdin
func (io *Io) NextLine() string {
	var buffer []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buffer = append(buffer, line...)
		if !isPrefix {
			break
		}
	}
	return string(buffer)
}

// Next return a word from stdin
func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	r := io.tokens[io.nextToken]
	io.nextToken++
	return r
}

// NextInt returns an integer from stdin
func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

// Println is a wrapper of fmt.Fprintln
func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 1776
//Partition

#include<stdio.h>

#define swap(type, x ,y)    do{type t = x; x = y; y = t;} while(0)


int partition(int a[], int p, int r){
    int x = a[r];
    int j,i = p - 1;
    for(j = p; j < r; j++){
        if(a[j] <= x){
            i++;
            swap(int, a[i], a[j]);
        }
    }
    swap(int, a[i+1], a[r]);
    return i+1;
}


int main(void){
    int n;
    int ptr;
    int i;
    int a[100001];
    
    scanf("%d", &n);
    for(i = 0; i < n; i++)  scanf("%d", &a[i]);
    
    ptr =  partition(a, 0, n-1);
   
    printf("%d", a[0]);
    for(i = 1; i < n; i++) {
        if(ptr == i) printf(" [%d]", a[i]);
        else printf(" %d", a[i]);
    }
    putchar('\n');
   
    return 0;
}

Measured memory_bytes: 992
#include<bits/stdc++.h>
using namespace std;
int main(){
int T;
  cin>>T;
  for(int i=0;i<T;i++){
  int64_t A,B,C,D;
    cin>>A>>B>>C>>D;
    if(A<B || D<B)
      cout<<"No"<<endl;
    else{
       if(B<=C)
         cout<<"Yes"<<endl;
      else{
      int64_t g=gcd(D,B);
        int64_t a=A%B;
        if(C<a)
          cout<<"No"<<endl;
        else{
        int64_t x=(C-a+g)/g;
          if(x*g+a<B)
            cout<<"No"<<endl;
          else
            cout<<"Yes"<<endl;
        }
      }
    }
   }
   return 0;
}

Measured memory_bytes: 3564
readlines.each do |l|
  xa,ya,xb,yb,xc,yc,xd,yd = l.split.map(&:to_f)
  puts (xb==xa && yd==yc || xd==xc && yb==ya) ||
       ((yb-ya)/(xb-xa) * (yd-yc)/(xd-xc))==-1 ? "YES" : "NO"
end

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

int main(){
    string s;

    cin >> s;

    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi") cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
//inline int in() { int x; scanf("%d",&x); return x;}
template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int n, r;
  cin >> n >> r;
  int ans;
  if (n >= 10) ans = r;
  else ans = r + 100*(10-n);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#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>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main()
{
	int n; cin>>n;
	ll c[1000010]={};
	for(int a=1; a<=n; a++){
		for(int b=1; b<=n/a; b++){
			c[a*b]++;
		}
	}
	ll ans=0;
	for(int x=1; x<n; x++){
		ans+=c[n-x];
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
#define INF 1e9+1
#define PI 3.1415926535897932846
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<pii, int> piii;
typedef pair<pii, pii> piiii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<ld, ld> pld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<piiii> viiii;

const int MAXN = 100100, MAXM = 10100, MAXK = 25;
const ll MOD = 1e9+7;

int n;
int par[2*MAXN];
int sz[2*MAXN];
set<int> xCoords[2*MAXN], yCoords[2*MAXN];

int parent (int a) {
    return par[a] = par[a] == a ? a : parent(par[a]);
}
bool same (int a, int b) {
    return parent(a) == parent(b);
}
void unite (int a, int b) {
    a = parent(a), b = parent(b);
    if (a==b) return;
    if (sz[b] > sz[a]) swap(a,b);
    par[b] = a;
    sz[a] += sz[b];
    for (int x : xCoords[b]) xCoords[a].insert(x);
    for (int y : yCoords[b]) yCoords[a].insert(y);
}

set<int> pars;
int x[MAXN], y[MAXN];

int main ()
{
    FAST_IO;

    int n; cin >> n;

    FOR(i, 0, MAXN) {
        par[i] = i;
        par[i+MAXN] = i+MAXN;
        sz[i] = 1;
        sz[i+MAXN] = 1;
       // xCoords[i]
    }

    FOR(i, 1, n) {
        //int x, y; cin >> x >> y;
        cin >> x[i] >> y[i];
   //     x[i] = x, y[i] = y;
        xCoords[x[i]].insert(x[i]);
        yCoords[y[i]+MAXN].insert(y[i]+MAXN);
        unite(x[i],y[i]+MAXN);
    }

    FOR(i, 1, n) {
        pars.insert(parent(x[i]));
        pars.insert(parent(y[i]+MAXN));
    }

    ll ans = 0;
    for (int p : pars) {
        ans += ((ll)xCoords[p].size())*((ll)yCoords[p].size());
    }
    ans -= n;

    cout << ans;

    return 0;
}


Measured memory_bytes: 54656
#include <iostream>
using namespace std;
int main(void){
   int a,b,c,d,e,f=0;
   cin>>a>>b>>c;
   for(int i=0; i<c; i++){
       cin>>d>>e;
       if(!(a>=e || b<=d )){
           f=1;
       }
   }
   cout<<f<<endl;
   

   return 0;
}



Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
//	freopen("input.txt","r",stdin);
  bool flag=true;
  cin>>s;
  if(s[0]!='h') {
  	flag=false;cout<<"No"<<endl;exit(0);
  }
  for(int i=0;i<s.length();i++)
  {
    if(s[i]=='h')
       {
         if(s[i+1]!='i') 
         {
           flag=false;break;
         }
       }
       if(s[i]=='i')
       {
         if(i!=s.length()-1 and s[i+1]!='h')
         {
           flag=false;break;
         }
       }
  }
       if(flag) cout<<"Yes"<<endl;
       else cout<<"No"<<endl;
       
  return 0;
}


Measured memory_bytes: 256
#pragma warning(disable:4996)
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;

int main() {
	int n, d[50];
	long long ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> d[i];
	}

	for (int i = 0; i < n - 1; ++i) {
		for (int j = i + 1; j < n; ++j) {
			ans += d[i] * d[j];
		}
	}

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

int H,W;
int board[606][606];
int tate[606][606];
int yoko[606][606];

int getTs(int i,int s,int t){
    return tate[t][i]-(s==0?0:tate[s-1][i]);
}

int getYs(int i,int s,int t){
    return yoko[i][t]-(s==0?0:yoko[i][s-1]);
}

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

  cin>>H>>W;
  vector<string> S(H);
  rep(i,H) cin>>S[i];

  rep(i,H) rep(j,W){
      if(S[i][j]=='#'){
          int x=i+j;
          int y=j-i+H-1;
          board[x][y]=1;
      }
  }

  int N=H+W;
  for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
          if(j>0)yoko[i][j]+=yoko[i][j-1];
          if(board[i][j]) yoko[i][j]++;
      }
  }
  for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
          if(j>0) tate[j][i]+=tate[j-1][i];
          if(board[j][i]) tate[j][i]++;
      }
  }

  ll ans=0;
  for(int i=0;i<N;i++){
      for(int s=0;s<N;s++) for(int t=s+1;t<N;t++){
          int l=t-s;
          if(board[i][s]&&board[i][t]){
              if(i-l>=0){
                  ans+=getYs(i-l,s,t);
                  if(board[i-l][s]) ans--;
                  if(board[i-l][t]) ans--;
              }
              if(i+l<N){
                  ans+=getYs(i+l,s,t);
                  if(board[i+l][s]) ans--;
                  if(board[i+l][t]) ans--;
              }
          }
      }
  }

  for(int i=0;i<N;i++){
      for(int s=0;s<N;s++) for(int t=s+1;t<N;t++){
          int l=t-s;
          if(board[s][i]&&board[t][i]){
              if(i-l>=0) ans+=getTs(i-l,s,t);
              if(i+l<N) ans+=getTs(i+l,s,t);
          }
      }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4608
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(i64 (i) = (s);(i) < (e);(i)++)
#define all(x) x.begin(),x.end()
#define let auto const

template<typename... Types>
struct dynarr: std::vector<Types...> {
  using std::vector<Types...>::vector;
  using size_type = typename std::vector<Types...>::size_type;
  auto&& operator[](size_type i) { return this->at(i); }
  auto&& operator[](size_type i) const { return this->at(i); }
};

int main() {
  i64 n;
  cin >> n;
  cout << fixed << setprecision(10);
  if(n & 1) {
    double d = (n / 2 + 1);
    cout << d / n << endl;
  }
  else {
    cout << 0.5 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int f[6001][12001],n,mod;
#define inc(x,y) x+=y,x>=mod?x-=mod:0
int main()
{
	read(n),n*=3,read(mod),f[0][n]=1;
	for(res i=1;i<=n;++i)
	  for(res j=n-i;j<=n+i;++j) {
	  	if(j) inc(f[i][j],f[i-1][j-1]);
	  	if(i>1&&j<2*n) inc(f[i][j],(ll)f[i-2][j+1]*(i-1)%mod);
	  	if(i>2) inc(f[i][j],(ll)f[i-3][j]*(i-1)*(i-2)%mod);
	  }
	int tot=0;
	for(res i=n;i<=2*n;++i) inc(tot,f[n][i]);
	print(tot,'\n');
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 


Measured memory_bytes: 279680
#!/usr/bin/perl
my ($n) = map { $_ - 0 } split(/\s+/,<STDIN>);
my @a = ();
for(my $i=0;$i<$n;$i++){
  my ($a) = map { $_ - 0 } split(/\s+/,<STDIN>);
  push(@a,$a);
}
my @sa = sort { $a <=> $b } @a;
my $m = int( $n / 2 );
my $v = 0;
if( $n % 2 == 0 ){ # 均等
  my @sa_min = (@sa[0..($m-1)]);
  my @sa_max = (@sa[$m..$#sa]);
  
  $v += $sa_max[0];
  if( $m>1 ){
    for(my $i=1;$i<=$#sa_max;$i++){
      $v += 2 * $sa_max[$i];
    }
  }
  $v -= $sa_min[$#sa_min];
  if( $m>1 ){
    for(my $i=$#sa_min-1;$i>=0;$i--){
      $v -= 2 * $sa_min[$i];
    }
  }
} else {
  my $v1 = 0;
  my @sa_min = (@sa[0..($m-1)]);
  my @sa_max = (@sa[$m..$#sa]);    # max 寄りの方をたくさん確保の場合
  
  $v1 += $sa_max[0] + $sa_max[1];
  if( $#sa_max > 1 ){
    for(my $i=2;$i<=$#sa_max;$i++){
      $v1 += 2 * $sa_max[$i];
    }
  }
  for(my $i=0;$i<=$#sa_min;$i++){
    $v1 -= 2 * $sa_min[$i];
  }
  my $v2 = 0;
  my @sa_min = (@sa[0..$m]); # min 寄りの方をたくさん確保の場合
  my @sa_max = (@sa[($m+1)..$#sa]);    
  
  $v2 -= $sa_min[$#sa_min-1] + $sa_min[$#sa_min];
  if( $#sa_min > 1 ){
    for(my $i=0;$i<$#sa_min-1;$i++){
      $v2 -= 2 * $sa_min[$i];
    }
  }
  for(my $i=0;$i<=$#sa_max;$i++){
    $v2 += 2 * $sa_max[$i];
  }
  $v = ( $v1 > $v2 ? $v1 : $v2 );
}
print "$v\n";


Measured memory_bytes: 15548
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int a, b;
  cin >> a >> b;
  int ans = a - 2 * b;
  if(ans < 0) cout << 0 << endl;
  else cout << ans << endl;
  return 0;
}

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

using namespace std;

#define llong long long int
#define ldouble long double
#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()
#define SZ(x) ((int)(x).size())
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define UNIQUE(x) x.erase(unique(x.begin(), x.end()), x.end())

const static llong MOD = 1000000000 + 7;
const static llong INF = 1LL << 60;
const static double eps = 1e-6;
const static int dy[] = {0, 1, 0, -1};
const static int dx[] = {1, 0, -1, 0};

const static int needed_matchsticks[9] = {2, 5, 5, 4, 5, 6, 3, 7, 6};
string dp[11000];

string comp_string(string &s1, string &s2) {
    if (SZ(s1) > SZ(s2)) {
        return s1;
    } else if (SZ(s2) > SZ(s1)) {
        return s2;
    } else {
        if (s1 > s2) return s1;
        else return s2;
    }
}

void chmax(string &a, string b) {
    if (a == "/") a = b;
    else if (a.size() < b.size()) a = b;
    else if (a.size() == b.size()) {
        if (a < b) a = b;
    }
}

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

    int n, m;
    cin >> n >> m; 
    vector<int> A(m);
    rep(i, m) cin >> A[i];

    rep(i, 11000) dp[i] = "/";

    dp[0] = "";
    rep(i, n + 1) {
        if (dp[i] == "/") continue;
        rep(j, A.size()) {
            string temp = dp[i] + to_string(A[j]);
            chmax(dp[i + needed_matchsticks[A[j] - 1]], temp);
        }
    }

    cout << dp[n] << endl;

    return 0;
}

Measured memory_bytes: 33152
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[7],e;
    bool flag = 1;
    for(int i=0; i<5; i++) cin>>a[i];
    cin>>e;

    for(int i=0; i<5; i++)
    {
        for(int j= i+1; j<5; j++)
        {
            if(abs(a[i]-a[j]) > e)
            {
                flag= 0;
                break;
            }
        }
        if( !flag) break;
    }
    if( !flag) cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
}


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

int main(){
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]!=s[s.size()-i-1]){
            cout<<"No";
            return 0;
        }
    }
    for(int i=0;i<s.size()/2;i++){
        if(s[i]!=s[s.size()/2-i-1]){
            cout<<"No";
            return 0;
        }
    }
    cout<<"Yes";
    return 0;
}

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

int main(){
    char a;
    cin >> a;
    if(isupper(a)){
        cout << "A" << endl;
    }else{
        cout << "a" << endl;
    }
}

Measured memory_bytes: 3636
#include<stdio.h>
#include<stdlib.h>

int linearSearch(int*,int);

  int n;
  
int main(){
  int i,q,*S,*T,C=0;
  scanf("%d",&n);
  S=(int*)malloc(sizeof(int)*n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  T=(int*)malloc(sizeof(int)*(q+1));
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  for(i=0;i<q;i++){
    C+=linearSearch(S,T[i]);
  }
  printf("%d\n",C);
  return 0;
}

int linearSearch(int *S,int key){
  int i=0;
  S[n]=key;
  while(S[i]!=key){
    i++;
  }
  if(i==n){
    return 0;
  }
  else
    return 1;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=2e3;
const ll MOD=998244353;
string S;
ll dp[MAX_N*2+1][MAX_N*2+1];
int rcnt[MAX_N+1],bcnt[MAX_N+1];
int main(){
	cin>>S;
	int N=(int)S.size();
	REP(i,N){
		int b=S[i]-'0';
		bcnt[i+1]=bcnt[i]+b;
		rcnt[i+1]=rcnt[i]+2-b;
	}
	dp[rcnt[N]][bcnt[N]]=1;
	for(int n=rcnt[N];n>=0;n--){
		for(int m=bcnt[N];m>=0;m--){
			if(n==rcnt[N] && m==bcnt[N])continue;
			int rlb=upper_bound(rcnt,rcnt+N+1,n)-rcnt-1,blb=upper_bound(bcnt,bcnt+N+1,m)-bcnt-1;
			if(n+m>=rlb){
				dp[n][m]+=dp[n+1][m];
			}
			if(n+m>=blb){
				dp[n][m]+=dp[n][m+1];
				dp[n][m]%=MOD;
			}
		}
	}
	cout<<dp[0][0]<<endl;
}

Measured memory_bytes: 118016
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
//#include <chrono> //1e+9で割る auto end= chrono::system_clock::now()-st;  cout<<end.count()%1e+9<<endl;
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef long double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define rrep(i,x) for(int i=x-1;i>=0;i--)
#define rrep1(i,x) for(int i=x;i>0;i--)

int main()
{
	int N,t,x,y;
	cin>>N;
	P p;
	p.fr=0; p.sc=0;
	int T=0;
	bool b=0;
	rep(i,N){
		cin>>t>>x>>y;
		if( (abs(x-p.fr)+abs(y-p.sc)>t-T)||(  t%2!= (x+y)%2  )) b=1;
		T=t;
		p.fr=x; p.sc=y;
	}
	if(b) cout<<"No"<<endl;
	else puts("Yes");
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc079/tasks/abc079_c

string ABCD;
string op;

bool dfs(int sum, string op2) {
    if (op2.length() == 3) {
        op = op2;
        return sum == 7;
    }

    if (dfs(sum + (ABCD[op2.length()+1] - '0'), op2+"+")) return true;
    if (dfs(sum - (ABCD[op2.length()+1] - '0'), op2+"-")) return true;

    return false;
}

int main() {
    cin >> ABCD;

    if (dfs(ABCD[0]-'0', "")) {
        printf("%c%c%c%c%c%c%c=7\n", ABCD[0], op[0], ABCD[1], op[1], ABCD[2], op[2], ABCD[3]);
    }

    return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO 自動生成されたメソッド・スタブ
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int k = Integer.parseInt(br.readLine());
		int a = k / 2;
		int b = k - a;

		System.out.println(a * b);

	}

}


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

int main() {
  string s;
  cin >> s;
  string ans;
  int N;
  N = s.size();
  for(int i = 0; i<N ;i+=2 ){
      ans = ans + s.at(i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
using namespace std;

int main(){
  char s[3][11];
  int l[3];
  for(int i=0;i<3;i++){
    scanf("%s",s[i]);
    l[i]=strlen(s[i]);
  }
  if(s[0][l[0]-1]==s[1][0]&&s[1][l[1]-1]==s[2][0])
    printf("YES\n");
  else
    printf("NO\n");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define all(a) a.begin(), a.end()

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

    int n;
    cin >> n;
    n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
        cout << "hon";
    }
    else if(n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon";
    else
        cout << "bon";
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3616
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Math;

class Program
{
    static void Main()
    {
        var (A, B, C) = ReadLine().Split(' ').Select(int.Parse).ToArray();
        var ans = A + B >= C ? "Yes" : "No";
        WriteLine(ans);
    }
}

static class ArrayDeconstructExtensions
{
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2) => (i1, i2) = (a[0], a[1]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3) => (i1, i2, i3) = (a[0], a[1], a[2]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4) => (i1, i2, i3, i4) = (a[0], a[1], a[2], a[3]);
    public static void Deconstruct<T>(this T[] a, out T i1, out T i2, out T i3, out T i4, out T i5) => (i1, i2, i3, i4, i5) = (a[0], a[1], a[2], a[3], a[4]);
}


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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

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

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

  ll N,M;
  string S;
  cin >> N >> M;

  vector<ll> vec(M);

  for (ll i = 0; i < M; i++) {
    cin >> vec.at(i);
  }
  ll tmp = 0;
  for (ll i = 0; i < M; i++)
  {
    tmp+=vec.at(i);
  }

  if(tmp<=N){
    cout << N - tmp << endl;
  }
  else{
    cout << -1 << endl;
  }

  
}


Measured memory_bytes: 3668
#include <vector>
#include <iostream>

using namespace std;

long long gcd(long long a, long long b){
    if( b > a) swap(a, b);

    if ( b == 0) return a;
    else return gcd(b, a%b);
}

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

    vector<long long> a(N+1);
    long long tmp_min = 1e19; 

    for(int i=0; i<N; ++i){
        cin >> a[i];
        tmp_min = min(tmp_min, abs(X-a[i]) );
    }

    vector<long long> diff(N);
    for(int i=0; i<N-1; ++i){
        diff[i] = abs(a[i+1] - a[i]);
    }

    long long ans =tmp_min;

    for(int i=0; i<N-1; ++i){
        ans = gcd( ans, diff[i] );
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  int n;cin >> n;
  int d,x;cin >> d >> x;
  int ans = 0;
  rep(i,n){
    int a;cin >> a;
    ans+=((d+a-1)/a);
  }
  cout << ans+x << endl;

}


Measured memory_bytes: 256
# define _CRT_SECURE_NO_WARNINGS
#include <list>
#include <map>
#include <set>
#include <bitset>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional> 
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <bitset>
#include <string.h>
#include <stdio.h>
#include <limits.h>
#include <array>
#include <utility>
#include <memory>
#include <future>
#include <array>
//#include <unordered_map>

using namespace std;

#define STR(X) #X

#define ABS(a)      ((a>0)?a:-(a))
#define MIN(a,b)    ((a<b)?(a):(b))
#define MAX(a,b)    ((a<b)?(b):(a))
#define FOR(i,a,n)    for ( int i = (a); i < (n); ++i)
#define FOR_(i,a,n)		for ( int i = (a); i >= (n); --i)
#define FORI(n)        for(int i = 0; i < n; ++i)
#define MEMS(a,b)    memset(a,b,sizeof(a))

#define MP(p1, p2)      std::make_pair(p1, p2)
#define RNG(container)  container.begin(), container.end()

using LL = long long;
using ULL = unsigned long long;
using UI = unsigned int;
using UC = unsigned char;
using VI = std::vector<int>;
using SI = std::set<int>;

using PI = std::pair<int, int>;
using PL = std::pair<LL, LL>;

constexpr LL		MOD = 1000000009;
constexpr double    EXP = 2.7182818284590452;
constexpr double    Pi = 3.1415926535;
constexpr long double    EPS = 1e-4;
constexpr int		INF = 1000 * 1000 * 1001;
constexpr long long	INFL = (LL)INF * (LL)INF;

inline LL gcd(LL a, LL b)
{
    if (a < b) swap(a, b);

    while (b != 0)
    {
        a %= b;
        swap(a, b);
    }

    return a;
}

inline LL lcm(LL a, LL b)
{
    return (a / gcd(a, b)) * b;
}

LL extgcd(LL a, LL b, LL & x, LL & y)
{
    if (a == 0)
    {
        x = 0; y = 1;
        return b;
    }

    LL x11, y11;
    LL d = extgcd(b % a, a, x11, y11);
    x = y11 - (b / a) * x11;
    y = x11;
    return d;
}

ULL poww(ULL v, ULL p, ULL mod)
{
    if (p == 0) return 1;

    if (p & 1)
    {
        return (poww(v, p - 1, mod) * v) % mod;
    }
    else
    {
        ULL t = poww(v, p / 2, mod);
        return (t * t) % mod;
    }
}

constexpr ULL L31018 = 3000000000000000000L;
constexpr ULL L1018 = 1000000000000000000L;

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

int const MAXN = 5000006;

int arr[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 };

void accept()
{
    int k;
    cin >> k;
    cout << arr[k-1];
}

//		||
//		||
//     \||/
//    \\||//
//   \\\\////
//    \\\///
//     \\//
//      \/

int main(void)
{

#ifdef DEBUG
    LL startTime = clock();
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    //	freopen("I.in", "r", stdin);
    //	freopen("cinema.out", "w", stdout);
#endif

    accept();

#ifdef DEBUG
    printf("\n\n\t TIME: %.5lf", double((clock() - startTime)) / 1000.0f); /// CLOCKS_PER_SEC));
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int D[N];
  for (int i = 0; i < N; i++) cin >> D[i];
  int num[13];
  for (int i = 0; i < 13; i++) {
    num[i] = 0;
  }
  for (int i = 0; i < N; i++) {
    num[D[i]]++;
  }
  vector<int> one;
  vector<int> two;
  vector<int> three;
  if (num[0] != 0) {
    cout << 0 << endl;
    return 0;
  }

  for (int i = 0; i <= 12; i++) {
    if (num[i] == 1) {
      one.push_back(i);
    } else if (num[i] == 2) {
      two.push_back(i);
    } else if (num[i] >= 3) {
      three.push_back(i);
    }
  }
  if (!three.empty()) {
    cout << 0 << endl;
    return 0;
  }
  int on = (int)one.size();
  int ans = 0;
  for (int bit = 0; bit < (1 << on); bit++) {
    vector<int> time;
    time.clear();
    for (int i = 0; i < (int)two.size(); i++) {
      time.push_back(two[i]);
      time.push_back(24-two[i]);
    }
    time.push_back(0);
    for (int i = 0; i < on; i++) {
      if ((1 << i) & bit) {
        time.push_back(one[i]);
      } else {
        time.push_back(24-one[i]);
      }
    }
    sort(time.begin(),time.end());
    int res = 99999;
    for (int i = 0; i < (int)time.size(); i++) {
      for (int j = i + 1; j < (int)time.size(); j++) {
        int a = min(time[i],time[j]);
        int b = max(time[i],time[j]);
        res = min(res,b-a);
        res = min(res,24+a-b);
      }
    }
    ans = max(ans,res);
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
using namespace std;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
 void dfs(vector<vector< bool > > &map,int x,int y){
	map[x][y]=false;
	for(int i=0;i<4;i++){
	int nx=x+dx[i];
	int ny=y+dy[i];
	if(map[nx][ny])dfs(map,nx,ny);
	}
	
	return;
 }
bool check(vector<vector<bool> > &map,int x,int y){
	if(map[x][y]){
		bool f=false;
		for(int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(map[nx][ny]){
		f=true;
		dfs(map,x,y);
		}

		}
	if(!f)return false;
	}
return true;
}
int main(){
	int h,w;
	cin>>h>>w;
vector<vector<bool> > map(h+2,vector<bool>(w+2,false));
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
	char a;
	cin>>a;
	if(a=='#'){map[i][j]=true;
	}
	
	}
	bool f=true;
	for(int i=1;i<=h;i++)for(int j=0;j<=w;j++){
	
		f=check(map,i,j);
		if(!f){
		cout<<"No"<<endl;
		return 0;
		}
		

	}
cout<<"Yes"<<endl;
return 0;
}


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

char s[100000];


int main() {
	cin >> s;
	int mode;
	int num = 0;
	if (s[0] == 'B') {
		mode = 1;
	}
	else {
		mode = 2;
	}

	int	len = strlen(s);
	for (int i = 0; i < len;i++) {
		if (s[i] == 'B') {
			if (mode == 2) {
				mode = 1;
				num++;
			}
		}
		else {
			if (mode == 1) {
				mode = 2;
				num++;
			}
		}
	}
	
	printf("%d",num);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define pb push_back
#define N 200001
#define ll long long
#define int ll 
#define pi pair<int , int>
#define pip pair<pair ,int>
#define mp make_pair 
#define f first
#define s second
#define mod 998244353
ll Mod(ll x, ll y, int p) 
{ll res = 1; x = x % p;
while (y > 0) 
{if(y & 1) res = (res*x) % p; 
y = y>>1;x = (x*x) % p; 
}return res; 
}
int* getlps(string pattern){
 int len = pattern.length();
 int * lps = new int[len];
 lps[0] = 0;
 int i = 1 , j = 0;
 while(i < len){
  if(pattern[i] == pattern[j]){
	  lps[i] = j+1;
   i++;
   j++;
  }
  else{
		if(j != 0){
		 j = lps[j-1];
		}
		else{
		 lps[i] = 0;
		 i++;
		}
  }
 }
 return lps;
}
class Triplet{
 public:
 int x ;
 int y ;
 int gcd;
};
Triplet extendedEuclid(int a , int b){
 if(b == 0){Triplet ans; ans.gcd = a;ans.x = 1;ans.y = 0;return ans;}
 Triplet smallAns = extendedEuclid(b , a%b);
 Triplet ans;
 ans.gcd = smallAns.gcd;
 ans.x = smallAns.y;
 ans.y = smallAns.x - (a/b)*smallAns.y;
 return ans;
}
int mmInverse(int a , int m){
 Triplet ans = extendedEuclid(a , m);
 return ans.x;
}
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int h , n;
cin>>h>>n;
int arr[n];
int sum = 0;
for(int i = 0 ; i < n ;i++){
 cin>>arr[i];
 sum += arr[i];
}
if(sum >= h){
 cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}


Measured memory_bytes: 1024
def main():
    n=int(input())
    x=list(map(int,input().split(' ')))
    y=list(map(int,input().split(' ')))
    ans = 0
    for i,j in zip(x,y):
        if i-j > 0:
            ans += i-j
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    rep(i,n){
        int value;
        cin >> value;
        a[i].first = value;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    rep(i,n){
        if (a[n-1].second == i) cout << a[n-2].first << endl;
        else cout << a[n-1].first << endl;
    }
    return 0;
}

Measured memory_bytes: 3200
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
typedef pair<long long,long long> p;
int z[100010],n,m,k,r;
long long x,y,d[100010];
vector<int> v[100010];
queue<p>P;
priority_queue<p,vector<p>,greater<p> >Q;
int main(){
	cin>>n>>m>>k>>r>>x>>y;
	for(int i=0;i<n;i++)z[i]=0,d[i]=1145141145141919;
	for(int i=0;i<k;i++){
		int c;cin>>c;c--;
		z[c]=2;
		P.push(make_pair(c,r));
	}
	for(int i=0;i<m;i++){
		int a,b;cin>>a>>b;a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	while(!P.empty()){
		long long a=P.front().first,b=P.front().second;P.pop();
		if(b==0)continue;
		for(int i=0;i<v[a].size();i++){
			if(z[v[a][i]]==0){
				z[v[a][i]]=1;
				P.push(make_pair(v[a][i],b-1));
			}
		}
	}
	Q.push(make_pair(0,0));
	while(!Q.empty()){
		long long a=Q.top().first,b=Q.top().second;Q.pop();//b???a
		if(d[b]>a){
			d[b]=a;
			for(int i=0;i<v[b].size();i++){
				if(z[v[b][i]]==2)continue;
				Q.push(make_pair(a+(z[v[b][i]]?y:x),v[b][i]));
			}
		}
	}
	cout<<d[n-1]-(z[n-1]?y:x)<<endl;
	return 0;
}

Measured memory_bytes: 10968