akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>

using ll = long long;

int main(){
    ll N, A, B;
    std::cin >> N >> A >> B;
    ll AB = A + B;
    if(AB == 0){
        std::cout << 0 << std::endl;
        return 0;
    }
    ll cnt = N / AB;
    N -= cnt * AB;
    if(N >= A){
        std::cout << cnt * A + A << std::endl;
    }else{
        std::cout << cnt * A + N << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
using namespace std;
 
typedef long long ll;
 
 
int main(){
	int n,k;
	cin >> n >> k;
	int h;
	int res = 0;
	for(int i=0;i<n;++i){
		cin >> h;
		if(h >= k) res++;
	}
	cout << res <<endl;
	
	return 0;
}



Measured memory_bytes: 256
// #include<bits/stdc++.h>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#define pb emplace_back
#define LOCAL
  
using namespace std;
  
const int mod = 1e9+7;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5+5;
typedef long long ll;
typedef pair<int,int> Pii;
 
template <typename T>inline void read(T& t){
    char c=getchar();t=0;
    int f=1;
    while(!isdigit(c)){
       if(c=='-')f=-1;
        c=getchar();
    }
    while(isdigit(c))t=t*10+c-48,c=getchar();
    t=f*t;
}
  
template <typename T,typename... Args> inline void read(T& t,Args&... args){
    read(t);read(args...);
}
 
int main(){
    int t=1;
    // read(t);
    while(t--){
        ll n,d;
        read(n,d);
        int ans=0;
        for(int i=1;i<=n;i++){
            ll x,y;
            read(x,y);
            if(x*x+y*y<=d*d){
                ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

Measured memory_bytes: 3212
import java.io.*;

class Main{
   public static void main(String[] args)throws IOException{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      String str = br.readLine();
      
      String[] s = str.split(" ");
      
      int a = Integer.parseInt(s[0]);
      int b = Integer.parseInt(s[1]);
      
      if(a>b)
        System.out.println("a > b");
        else if(a<b)
         System.out.println("a < b");
          else if(a == b)
            System.out.println("a == b");
      }
}

Measured memory_bytes: 24180
import queue
while 1:
    n,k=map(int,input().split())
    if n==0:break
    a=queue.deque(int(input()) for _ in range(k))
    m=b=sum(a)
    for i in range(n-k):
        c=a.popleft()
        d=int(input())
        a.append(d)
        b+=d-c
        m=max(b,m)        
    print(m)

Measured memory_bytes: 10364
n, k = map(int, input().split())
h = list(map(int, input().split()))

ans = [0]

for i in range(1, n):
    j = 0 if i-k<0 else i-k
    min_cost = float('inf')
    for l in range(j, i):
        min_cost = min(min_cost, (abs(h[i] - h[l]) + ans[l]))
    
    ans.append(min_cost)

print(int(ans[-1]))

Measured memory_bytes: 58464
#include <stdio.h>
/* light fly	48.00kg 以下
fly	48.00kg 超51.00kg 以下
bantam	51.00kg 超54.00kg 以下
feather	54.00kg 超57.00kg 以下
light	57.00kg 超60.00kg 以下
light welter	60.00kg 超64.00kg 以下
welter	64.00kg 超69.00 kg 以下
light middle	69.00kg 超75.00 kg 以下
middle	75.00kg 超81.00 kg 以下
light heavy	81.00kg 超91.00 kg 以下
heavy	91.00kg 超
*/

int main(void) {
	double w;
	while(scanf("%lf\n", &w)==1) {
		if(w <= 48.00) {
			printf("light fly\n");
		} else if(w <= 51.00) {
			printf("fly\n");
		} else if(w <= 54.00) {
			printf("bantam\n");
		} else if(w <= 57.00) {
			printf("feather\n");
		} else if(w <= 60.00) {
			printf("light\n");		
		} else if(w <= 64.00) {
			printf("light welter\n");		
		} else if(w <= 69.00) {
			printf("welter\n");
		} else if(w <= 75.00) {
			printf("light middle\n");		
		} else if(w <= 81.00) {
			printf("middle\n");		
		} else if(w <= 91.00) {
			printf("light heavy\n");		
		} else {
			printf("heavy\n");
		}
	}

	return 0;
}

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

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

int main() {
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,n) cin>>a[i];
  vector<int> l(n), r(n);
  rep(i,n-1) l[i+1] = gcd(l[i], a[i]);  //累積和 log(N)
  for (int i = n-1; i >= 1; i--) r[i-1] = gcd(r[i], a[i]);
  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i],r[i]));
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <set>
#include <functional>
#include <map>
#include <queue>
#include <cstring>
#include <stack>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cassert>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define show(x) cout << #x << " = " << x << endl;
typedef long long ll;
typedef pair<int,int> pii;
struct edge{
    int to;
    ll w;
};
vector<edge>G[200005];
bool used[200005];
ll min_r,min_c;
ll cost[200005];
void dfs(int s){
    used[s] = true;
    rep(i,G[s].size()){
        if(!used[G[s][i].to]){
            cost[G[s][i].to] = G[s][i].w - cost[s];
            if(G[s][i].to >100000){
                min_c = min(min_c, cost[G[s][i].to]);
            }else{
                min_r = min(min_r, cost[G[s][i].to]);
            }
            dfs(G[s][i].to);
        }else{
            if(cost[G[s][i].to] != G[s][i].w - cost[s]){
                cout << "No" << endl;
                exit(0);
            }
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> r(n), c(n);
    vector<ll> a(n);
    rep(i,n){
        cin >> r[i] >> c[i] >> a[i];
        c[i] += 100000;
        G[r[i]].push_back(edge{c[i], a[i]});
        G[c[i]].push_back(edge{r[i], a[i]});
    }
    rep(i,n){
        if(!used[r[i]]){
            min_r = 0;
            min_c = 1LL<<60;
            dfs(r[i]);
            if(min_r + min_c < 0){
                cout <<"No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 18176
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};

typedef struct node * NodePointer;

NodePointer nil;

NodePointer listSearch(int key){
  NodePointer cur = nil->next;
  while(cur != nil && cur->key != key){
    cur = cur->next;
  }
  return cur;
  /* your code */
}

void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}

void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}

void deleteNode(NodePointer t){
  /* your code */
  if(t == nil)return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst(){
  deleteNode(nil->next);
}

void deleteLast(){
  /* your code */
  deleteNode(nil->prev);
}

void delete(int key){
  /* your code */
  deleteNode(listSearch(key));
}


void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct 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 {
	delete(key); nd++; 
      }
      size--;
    }
  }

  printList();
  return 0;
}



Measured memory_bytes: 32992
using System;
using System.Linq;//リストの使用
using System.Collections.Generic;
class Program
{

static string[] input = Console.ReadLine().Split(' ');
static long n = long.Parse(input[0]);
static long k = long.Parse(input[1]);
static long l = long.Parse(input[2]);
static long[][] parents = new long[n][];//親、親、値、元の番号
static long[] answers = new long[n];
  
	static void Main()
	{
    for(long i = 0; i < n; i++)
    {
      parents[i] = new long[4];
      parents[i][0] = i;
      parents[i][1] = i;
      parents[i][3] = i;
    }
    
    for(long i = 0; i < k; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      if(whatParentA(nums[0]-1) != whatParentA(nums[1]-1))
        parents[whatParentA(nums[0]-1)][0] = whatParentA(nums[1]-1);//親を結合して統一。親が2人できることはない。
    }

    for(long i = 0; i < l; i++)
    {
      long[] nums = Array.ConvertAll(Console.ReadLine().Split(' '),long.Parse);
      if(whatParentB(nums[0]-1) != whatParentB(nums[1]-1))
        parents[whatParentB(nums[0]-1)][1] = whatParentB(nums[1]-1);//親を結合して統一。親が2人できることはない。
    }

    for(long i = 0; i < n; i++)
    {
      parents[i][2] = whatParentA(i)*10000000+whatParentB(i);
      //Console.WriteLine(parents[i][2]);
    }

    Array.Sort(parents, (a, b) => a[2].CompareTo(b[2]));
    parents[0][0] = 1;
    long memo = 1;
    for(long i = 1; i < n; i++)
    {
      if(parents[i][2] == parents[i-1][2])
      {
        memo++;
        parents[i][0] = memo;
      }else
      {
        memo = 1;
        parents[i][0] = memo;
      }
      //Console.WriteLine(parents[i][0]);
    }
    parents[n-1][1] = parents[n-1][0];
    for(long i = n-2; i >= 0; i--)
    {
      if(parents[(int)(i+1)][0] != 1) parents[(int)(i)][1] = parents[(int)(i+1)][1];
      else parents[(int)(i)][1] = parents[i][0];
    }

    Array.Sort(parents, (a, b) => a[3].CompareTo(b[3]));//番号でソート
    for(long i = 0; i < n; i++)
    {
      answers[i] = parents[i][1];
    }
    Console.WriteLine(string.Join(" ", answers));
	}

  static long whatParentA(long child)
  {
    if(parents[child][0] == child) return child;
    else return parents[child][0] = whatParentA(parents[child][0]);
  }

  static long whatParentB(long child)
  {
    if(parents[child][1] == child) return child;
    else return parents[child][1] = whatParentB(parents[child][1]);
  }
  
}

Measured memory_bytes: 35220
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li      int32_t
#define lli     long long
#define ulli unsigned long long

#define pn           printf("\n")
#define nl           cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)  for(i=a;i<b;i++)
#define repr(i,a,b) for(i=a;i>b;i--)
#define elif        else if
#define mset(a,b)   memset(a,b,sizeof(a))

#define pb      push_back
#define pob     pop_back
#define itr     iterator
#define sz()    size()
#define szof    sizeof
#define lb      lower_bound
#define ub      upper_bound
#define mp      make_pair
#define vlli    vector<lli>
#define plli    pair<lli,lli>
#define vplli   vector<plli >
#define F       first
#define S       second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define mod     1000000007
#define Inf     1000000000000000
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    lli N,i,K;
    cin>>N>>K;

    vlli V(N);
    rep(i,0,N)
    {
        cin>>V[i];
    }

    sort(V.begin(),V.end(),greater<lli>());

    lli Sum=0;
    rep(i,0,K)
    {
        Sum+=V[i];
    }

    cout<<Sum;












 return 0;
}


Measured memory_bytes: 256
import functools
N = int(input())
T = []
for i in range(N):
  T.append(int(input()))

def gcd(a, b):
  if a < b:
    a, b = b, a
  if b == 0:
    return a
  return gcd(b, a % b)
 
def lcm(A, B):
  return A * B // gcd(A, B)
 
print(functools.reduce(lcm, T))


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  
  else {cout << "No" << endl; }
  
}

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

constexpr ll INF = 1e15;

int main()
{
    int i, j, k;
    int N, M, L; cin >> N >> M >> L;
    vector<vector<ll>> G(N+1, vector<ll>(N+1, INF));
    for (i = 0; i < M; i++)
    {
        int A, B, C; 
        cin >> A >> B >> C;
        G[A][B] = C;
        G[B][A] = C;
    }
    for (k = 1; k <= N; k++) 
    {
        for (i = 1; i <= N; i++) 
        {
            for (j = 1; j <= N; j++) 
            {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    for (i = 0; i <= N; i++)
    {
        for (j = 0; j <= N; j++)
        {
            if (G[i][j] <= L) G[i][j] = 1;
            else G[i][j] = INF;
        }
    }
    for (k = 1; k <= N; k++) 
    {
        for (i = 1; i <= N; i++) 
        {
            for (j = 1; j <= N; j++) 
            {
                G[i][j] = min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }
    int Q; cin >> Q;
    while (Q--)
    {
        int s, t; cin >> s >> t;
        if (G[s][t] == INF) cout << -1 << endl;
        else cout << G[s][t] - 1 << endl;
    }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef pair<double,double> PDD;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main() {
	string t; cin>>t;
	rep(i,t.size()){
		if(t[i]=='?') cout<<'D';
		else cout<<t[i];
	}
	cout<<endl;

	return 0;
}


Measured memory_bytes: 3784
#define DBG 0 //submission 0
#if DBG==1
    #include <algorithm>
    #include <ctime>
    #include <cstdlib>
    #include <string>
    #include <vector>
    #include <iostream>
#else
    #include <bits/stdc++.h>
#endif

using namespace std;

int main(){
    int ans = 0;
    int X,A,N,i,j,k;

    cin >> X >> A;
    
    cout << ((X<A)?0:10) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, A;
void input() {
  int x, y, z;
  cin >> N;
  cin >> A;
  ;
}
void solve() {
  cout << N * N - A << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():
    X = int(input())
    if X >= 1800:
        print(1)
    elif X >= 1600:
        print(2)
    elif X >= 1400:
        print(3)
    elif X >= 1200:
        print(4)
    elif X >= 1000:
        print(5)
    elif X >= 800:
        print(6)
    elif X >= 600:
        print(7)
    else:
        print(8)           
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 9120
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(...) ;
#else
#define debug(...) cerr << __LINE__ << " : " << #__VA_ARGS__ << " = " << _tostr(__VA_ARGS__) << endl;

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v);

template<typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}

void _tostr_rec(ostringstream &oss) {
  oss << "\b\b \b";
}

template<typename Head, typename... Tail>
void _tostr_rec(ostringstream &oss, Head &&head, Tail &&... tail) {
  oss << head << ", ";
  _tostr_rec(oss, forward<Tail>(tail)...);
}

template<typename... T>
string _tostr(T &&... args) {
  ostringstream oss;
  int size = sizeof...(args);
  if (size > 1) oss << "{";
  _tostr_rec(oss, forward<T>(args)...);
  if (size > 1) oss << "}";
  return oss.str();
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N;
  int counter[SIZE] = {};

  cin >> N;

  for (int x = 1; x * x <= N; x++) {
    for (int y = 1; y * y <= N; y++) {
      for (int z = 1; z * z <= N; z++) {
        int s = x * x + y * y + z * z + x * y + y * z + z * x;
        counter[s]++;
      }
    }
  }

  for (int i = 1; i <= N; i++) {
    printf("%d\n", counter[i]);
  }

  return 0;
}

Measured memory_bytes: 4372
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;

using namespace std;


const long long MOD = 1000000007;

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

	int n, r;
	cin >> n >> r;

	if (n >= 10) {
		cout << r << "\n";
	}
	else {
		cout << 100 * (10 - n) + r << "\n";
	}

	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner (System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();
		if (a == 1 && b == 1) {
			System.out.println("Draw");
		}
		else if (a==1) {
			System.out.println("Alice");
		} else if (b == 1) {
			System.out.println("Bob");
		} else if (a>b) {
			System.out.println("Alice");
		} else if (b>a) {
			System.out.println("Bob");
		} else if (a == b) {
			System.out.println("Draw");
		}
	}
}


Measured memory_bytes: 35628
import numpy as np

def checker(n ,da):
    mx = max(da)
    mi = min(da)
    if n == 2:
        return (da == [1, 1])
    if mx < 2 or n <= mx: return False
    arr = np.zeros(mx + 1, dtype=int)
    for i in range(n):
        arr[da[i]] += 1
    if mx % 2:
        if arr[mi] > 2 or (mx + 1) // 2 != mi:
            return False
    else:
        if arr[mi] > 1 or mx // 2 != mi:
            return False
    for i in range(mi, mx):
        if arr[i + 1] < 2:
            return False
    return True

    

def main():
    n = int(input())
    da = list(map(int,input().split()))
    print('Possible') if checker(n, da) else print('Impossible')
    return

if __name__ == "__main__":
    main()

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

/*
vector<int> primes={};

bool is_prime(int m){
	if(m==2){
		primes.push_back(2);
		return true;
	}
	int M=(int)sqrt(m)+1;
	for(int i=0; i<(int)primes.size();++i){
		if(m%primes[i]==0){
			return false;
		}
		if(primes[i]<M){
			return true;
		}
	}
	int max_prime=primes.back();
	for(int k=max_prime+1; k<M; ++k){
		if(is_prime(k)){
			primes.push_back(k);
			if(m%k==0){
				return false;
			}
		}
	}
	return true;
}
*/

bool is_prime(int m){
	int M=(int)sqrt(m);
	for(int i=2; i<=M; ++i){
		if(m%i==0){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	int result=0;
	for(int i=0; i<n; i++){
		int m;
		cin>>m;
		if(is_prime(m)){
			result++;
		}
	}
	cout<<result<<endl;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;
  cin >> N >> M;
  vector<int> A(N);
  
  for(int i=0; i<N; i++) {
    cin >> A.at(i);
  }

  int sum = 0;
  for(Ai : A) {
    sum += Ai;
  }

  int chosen = 0;
  for(Ai : A) {
    if(Ai * 4*M >= sum) chosen += 1;
  }

  if(chosen >= M) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


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

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

    vector<pair<long long int, int>> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());

    vector<vector<long long int>> dp(n+1, vector<long long int>(n+1));
    for(int i=0; i<n; i++){
        //cout << i << endl;
        for(int j=0; j<=i; j++){
            //cout << j << " : " << endl;
            dp[i+1][j]   = max(dp[i+1][j]  , dp[i][j] + a[i].first * (((n-1)-(i-j)) - a[i].second));
            dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j] + a[i].first * (a[i].second - j));
            //cout << "dp[" << i+1 << "][" << j << "] = " << dp[i+1][j] << endl;
            //cout << "dp[" << i+1 << "][" << j+1 << "] = " << dp[i+1][j+1] << endl;
        }
        //cout << endl;
    }
    long long int ans = 0;
    for(int i=0; i<=n; i++){
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 34680
#! /usr/bin/env python3
# -*- coding: utf-8 -*-

import sys, os

def main():
    sun = "Sunny"
    clo = "Cloudy"
    rin = "Rainy"
    today = input()
    if today == sun:
        ans = clo
    elif today == clo:
        ans = rin
    elif today == rin:
        ans = sun

    print(ans)    
if __name__ == "__main__" :
    main()



Measured memory_bytes: 2940
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
  string s;
  cin >> s;
  if(s[0] == s[2] )
    Yes;
  else
    No;
  ret 0;
}

Measured memory_bytes: 256
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


def main():
	n = int(input())
	h = list(map(int,input().split()))
	ans=0
	while sum(h)>0:
		mx = max(h)
		t = zip(h)
		ans+=t.count(mx)
		for i in range(n):
			if(h[i]==mx):
				h[i]-=1
	print(ans)

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(l):
	x = l.pop()
	y = l.pop()
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	l.append(min(x,y))
	return gcd(l) if len(l) > 1 else l[0]

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Measured memory_bytes: 64620
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>

using namespace std;

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  int x = 0;
  int ma = x;
  for(int i = 0; i < N; i++) {
    if(S[i] == 'I') x++;
    else x--;
    ma = max(ma,x);
  }
  cout << ma << endl;


}


Measured memory_bytes: 256
#include <stdio.h>

int main(){

    long long N, A, B;
    scanf("%lld %lld %lld", &N, &A, &B);

    long long x = N / (A+B);
    long long y = N % (A+B);
    long long z;
    if(y > A){
        z = A;
    }else{
        z = y;
    }
    printf("%lld\n", x*A+z);
    return 0;
}

Measured memory_bytes: 128
X = int(input())
if X < 600:
    print(8)
elif X < 800:
    print(7)
elif X < 1000:
    print(6)
elif X < 1200:
    print(5)
elif X < 1400:
    print(4)
elif X < 1600:
    print(3)
elif X < 1800:
    print(2)
else:
    print(1)


Measured memory_bytes: 61608
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define ll long long
#define int long long
#define f(i,x,n) for(int i=x;i<n;i++)
#define ld long double
const int mod=1000000007;
const int INF=1e18;
vector <int> gp[200005];
int vis[200005];
int dfs(int i) {
    int ret=0;
    if(vis[i]==1)
        return 0;
    ret++;
    vis[i]=1;
    for(auto j: gp[i])
    {
        ret+=dfs(j);
    }
    return ret;
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m,ans=0;
    cin>>n>>m;
    f(i,0,m) {
        int u,v;
        cin>>u>>v;
        gp[u].push_back(v);
        gp[v].push_back(u);
    }
    f(i,1,n+1) {
        if(vis[i]==0) {
            ans=max(ans,dfs(i));
        }
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 22360
package main

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

func main() {
	sc := NewScanner()
	S := sc.Next()
	mx := 0
	cnt := 0
	if S[0] == 'R' {
		cnt++
		mx++
	}
	for i := 1; i < len(S); i++ {
		if S[i] == 'R' {
			cnt++
			if mx < cnt {
				mx = cnt
			}
		} else {
			cnt = 0
		}
	}
	fmt.Println(mx)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 1772
#include<iostream>
using namespace std;
typedef long long LL;

int main()
{
	int n; cin>>n;
	int v=0;
	LL res=0;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		if(x<v) res+=v-x;
		else v=x;
	}
	cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3668
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var result = new int[4];

            for (var i = 0; i < n; i++)
            {
                var str = Console.ReadLine();
                switch (str)
                {
                    case "AC":
                        result[0]++;
                        break;
                    case "WA":
                        result[1]++;
                        break;
                    case "TLE":
                        result[2]++;
                        break;
                    case "RE":
                        result[3]++;
                        break;
                }
            }
            Console.WriteLine($"AC x {result[0]}");
            Console.WriteLine($"WA x {result[1]}");
            Console.WriteLine($"TLE x {result[2]}");
            Console.WriteLine($"RE x {result[3]}");
        }
    }
}

Measured memory_bytes: 30632
#include <iostream>
#include <algorithm>
using namespace std;
const int MAX = 100;
int main()
{
	int n;
	cin >> n;
	int a[MAX];
	for(int i=0;i<n;i++) {
cin >> a[i];
if(i>0) cout << ' ';
cout << a[i];
}
cout << '\n';
	for(int i=1;i<n;i++){
		int key=a[i];
		/*insert A[i] into the sorted sequence A[0, ...,j-1]*/
		int j = i-1;
		while(j >= 0 && a[j] > key){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = key;
		for(int k=0;k<n;k++){
                        if(k>0) cout << ' ';
			cout << a[k];
		}
		cout << endl;
	}
	return 0;	
}

Measured memory_bytes: 1160
n=int(input())
ans=0
a=[]
for i in range(n):
  a.append(list(map(int,input().split())))
for i in reversed(range(n)):
  if a[i][1] != 1 and a[i][0] != 0:
    a[i][0] += ans
    if a[i][0] % a[i][1] != 0:
      ans += a[i][1] - a[i][0] % a[i][1]
print(ans)

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

int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  int count=0;
  for(int i=0;i<n;i++){
    if(a[i]%2==1){
      count++;
    }
  }
  cout << (count%2==0?"YES":"NO") << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next(), b = sc.next();
        String ans;
        if (a.equals("H")) {
            ans = b;
        } else {
            if (b.equals("H")) {
                ans = "D";
            } else {
                ans = "H";
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP2(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

ll gcd(ll x, ll y)
{
  return y ? gcd(y, x % y) : x;
}
ll lcm(ll x, ll y)
{
  return x * y / gcd(x, y);
}
bool is_prime(int x)
{
  for (int i = 2; i * i <= x; i++)
  {
    if (x % i == 0)
      return 0;
  }
  return true;
}
vector<bool> prime_table(int n)
{
  vector<bool> prime(n + 1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for (int i = 2; i * i <= n; i++)
  {
    if (!prime[i])
      continue;
    for (int j = i * i; j <= n; j++)
      prime[j] = 0;
  }
  return prime;
}
map<int, int> prime_factor(int n)
{
  map<int, int> res;
  for (int i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      res[i]++;
      n /= i;
    }
  }
  if (n != 1)
    res[n]++;
  return res;
}

ll modpow(ll a,ll n,ll mod){
  ll ret=1;
  while(n>0){
    if(n&1) ret=ret*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return ret;
}

int main()
{
  string s,t,u;
  int a,b;
  cin>>s>>t>>a>>b>>u;

  if(s==u) cout<<a-1<<" "<<b<<endl;
  else cout<<a<<" "<<b-1<<endl;
  
  return 0;
}


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

vector<string> meiro(50);
vector<vector<int>> visited(50, vector<int>(50, 0));
queue<tuple<int, int, int>> q;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int h, w, gx, gy, x, y, d, X, Y;


int bfs()
{
  q.push(tuple<int, int, int>(0, 0, 0));
  while(q.size())
  {
    tie(y, x, d) = q.front();
    q.pop();
    if(x==gx && y==gy) return d;
    for (int i = 0; i < 4; i++) {
      X = x + dx[i];
      Y = y + dy[i];
      if(X>=0 && X<w && Y>=0 && Y<h && meiro[Y][X] != '#' && visited[Y][X]==0)
      {
        q.push(tuple<int, int, int>(Y, X, d+1));
        visited[Y][X] = 1;
      }
    }
  }
  return 0; 
}

int main(int argc, char const* argv[])
{
  cin >> h >> w;
  gy = h;
  gx = w;
  gy--;gx--;
  int cnt = 0;
  for (int i = 0; i < h; i++) {
    cin >> meiro[i];
    for (int j = 0; j < w; j++) {
      if(meiro[i][j] == '#') cnt++;
    }
  }
  int sht = bfs();
  if(sht != 0)
    cout << h*w - (sht + 1 + cnt) << endl;
  else
    cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <random>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define loop(i,a,b) for(ll i=a;i<=b;i++)
#define inputv(arr,n) for(ll i=0;i<n;i++){ll value;cin>>value;arr.pb(value);}
#define sz(a) ((ll)(a).size())
#define len(a) ((ll)(a).length())
#define precise cout<<fixed<<setprecision(0); 
#define F first
#define S second
#define vi vector <int> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vs vector <string>
#define vc vector <char>
#define vl vector <ll>
#define all(c) (c).begin(),(c).end()
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
inline ll max(ll a,ll b)
{return ((a>b)?a:b);}
inline ll min(ll a,ll b)
{return ((a>b)?b:a);}
inline ll gcd(ll a ,ll b)
{if(b==0) return a;a%=b;return gcd(b,a);}
#define nl cout<<"\n"
using namespace std;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll modInverse(ll a){return power(a,mod-2);}
const int N=500023;
// hashing for pairs
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return hash<long long>()(((long long)x.first)^(((long long)x.second)<<32));
  }
};
//sort in reverse order
bool compare(ll x, ll y){
    return x>y;
}
void solve()
{
  ll n;
  cin>>n;
  ll val= ceil((1.0*n)/1000);
  cout<<val*1000-n;nl;
  return;
}
int main()
{
    IOS;
    int T=1;
   // cin>>T;
    int t=0;
    while(t++<T)
    {
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3892
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;

const int MOD=1000000007;
int INF=100100100100100;

vector<int> g[10010];
int depth[10010];
int c[10010];
int ans[10010];
int sum=0;
priority_queue<P> que;
void dfs(int v,int p=-1){
  //par[v]=p;
  if(p<0){
    depth[v]=0;
    que.push(P(depth[v],v));
  }
  else {
    depth[v]=depth[p]+1;
    que.push(P(depth[v],v));
  }
    
  int res=0;
  for(int w:g[v]){
    if(w!=p){
      dfs(w,v);
    }
  }
}
signed main(){
  int n;cin>>n;
  rep(i,n-1){
    int a,b;cin>>a>>b;
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }
  rep(i,n)cin>>c[i];
  sort(c,c+n);
  dfs(0);
  int ima=0;
  while(!que.empty()){
    P p=que.top();que.pop();
    ans[p.S]=c[ima];
    if(p.F!=0)sum+=c[ima];
    ima++;
  }
  cout<<sum<<endl;
  rep(i,n)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  rep(x, 50000) {
    ll yen = x + 8 * x / 100;
    if(yen != n) continue;
    cout << x << endl;
    return 0;
  }
  cout << ":(" << endl;
}

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

#define trav(a, A) for (auto & a : A)
#define f first
#define s second

typedef long long ll;

ll MOD = 1e+9+7;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const int INF = 0x3f3f3f3f;
const ll MAXN = 1e+5+7;

int main ()
{
	ios_base::sync_with_stdio (0);
	cin.tie (0);
	ll i, j, n, x, k, d;
	cin >> x >> k >> d;
	x = abs (x);
	if (d <= x)
		if (x/d <= k)
			k -= x/d,
			x = x%d;
		else x -= k*d, k = 0;
	if (k%2) cout << abs (x - d);
	else cout << abs (x);
	cout << '\n';

	return 0;
}



Measured memory_bytes: 3644
using System;
using System.Linq;

namespace AtCoder.Beginner142
{
    public class ABC142C
    {
        public static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var nums = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

            var ranks = nums
                .Select((num, i) => new {num, i})
                .OrderBy(numi => numi.num)
                .Select(numi => numi.i + 1);

            Console.Write(String.Join(" ", ranks));
        }
    }
}

Measured memory_bytes: 31708
#include<iostream>
#include<algorithm>
using lint=long long;
using namespace std;

class info
{
	public:
	lint a,b,c;
};

bool cmp(const info &a,const info &b)
{
	return a.c>b.c;
}

int main()
{
	lint N;
	lint A[100010]={},B[100010]={};
	info ins[100010]={};
	info tmp;
	lint AA=0,BB=0;
	
	cin >> N;
	for(lint i=0;i<N;i++)
	{
		cin >> A[i] >> B[i];
		tmp.a=A[i];
		tmp.b=B[i];
		tmp.c=A[i]+B[i];
		ins[i]=tmp;
	}
	
	sort(ins,ins+N,cmp);
	
	for(lint i=0;i<N;i+=2)
	{
		AA+=ins[i].a;
	}
	for(lint i=1;i<N;i+=2)
	{
		BB+=ins[i].b;
	}
	
	cout << AA-BB << endl;
	return 0;
}



Measured memory_bytes: 4096
n, Y = map(int, input().split())
Y //= 1000
for z in range(Y//10+1):
    for y in range((Y-z*10)//5+1):
        x = Y - z*10 - y*5
        if x < 0:
            break
        if x + y + z == n:
            print(z, y, x)
            exit(0)
print(-1, -1, -1)


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

using namespace std;
#define X first
#define Y second
#define pb push_back
#define debug(x) cerr<<#x<<"="<<x<<endl;
typedef double db;
typedef long long ll;
typedef pair<int,int> P;
const int MAXN=1e5+10;
int q[MAXN],l,r;
ll d[MAXN],dp[MAXN];int n,E,T;

int main()
{
	scanf("%d%d%d",&n,&E,&T);
	for(int i=1;i<=n;i++) 
		scanf("%d",&d[i]),dp[i]=1ll<<60;
	ll mn=1ll<<60;l=r=1;
	for(int i=1;i<=n;i++)
	{
		while(l<=r&&2*(d[i]-d[q[l]+1])>T)
			mn=min(mn,dp[q[l]]-d[q[l]]-2*d[q[l]+1]),l++;
		dp[i]=min(dp[i],3*d[i]+mn);
		if(l<=r)dp[i]=min(dp[i],d[i]+T+dp[q[l]]-d[q[l]]);
		
		while(l<=r&&dp[i]-d[i]<=dp[q[r]]-d[q[r]]) r--;
		q[++r]=i;
	}
	printf("%lld",dp[n]+E-d[n]);
	return 0;
}

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

int main(){
  int K,N,mx=0,ans;
  cin>>K>>N;
  vector<int> a(N);
  
  for(int i=0;i<N;i++){
    cin>>a.at(i);
  }
  
  sort(a.begin(),a.end());
  
  for(int i=0;i<N;i++){
    if(i==N-1){mx=max(K-a.at(N-1)+a.at(0),mx);}
    else{mx=max(a.at(i+1)-a.at(i),mx);}
  }
  
  ans=K-mx;
  cout<<ans;
}

Measured memory_bytes: 1024
/**
 * Sum of Consecutive Integers
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {
			int n = parseInt(line);
			if (n == 0) break;

			int[] nums = new int[n / 2 + 2];
			for (int i = 1; i < nums.length; i++) {
				nums[i] = nums[i - 1] + i;
			}

			int count = 0;
			for (int i = 1; i < nums.length - 1; i++) {
				for (int j = i + 1; j < nums.length; j++) {
					int sum = nums[j] - nums[i - 1];
					if (sum == n) {
						count++;
					} else if (sum > n) {
						break;
					}
				}
			}
			System.out.println(count);
		} //end while
	} //end main
}

Measured memory_bytes: 17856
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

ll gcd(ll a, ll b) {return (!b ? a : gcd(b, a % b));}
bool cmp(int a,int b){return a>b;}

const ll mod = 1e9 + 7;
const int INF32 = 1<<30;
const ll INF64 = 1LL<<60;
const ld pi = 3.141592653589793;
const int N = 5e5 + 10;

void solve(){
     int n;cin >> n;
     vector<string>s(n);
     for(int i = 0;i<n;i++) cin >> s[i];
     for(int i = 0;i<n-1;i++)
     for(int j = i+1;j<n;j++){
        if(s[i]==s[j]) {cout << "No";return;}
     }
     for(int i = 0;i<n-1;i++){
     char c = s[i][s[i].size()-1];
     if(s[i+1][0]!=c){cout <<"No";return;}
     }
     cout << "Yes";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    solve();
    return 0;
}


Measured memory_bytes: 3576
import itertools
import numpy as np
n = int(input())
points = np.array([list(map(int,input().split())) for _ in range(n)])

if n == 1:
    print(1)
else:
    # print(points)
    vectors_count = {}
    for vec1,vec2 in itertools.permutations(points,2):
        relative_vec = vec1 - vec2
        str_vec = (str(relative_vec))
        # print(type(relative_vec))
        if str_vec in vectors_count:
            vectors_count[str_vec] += 1
        else:
            vectors_count[str_vec] = 1

    # print(vectors_count)
    # # print(max(vectors_count.values()))
    max_vec = max(vectors_count.values())
    ans = n - max_vec
    print(ans)

Measured memory_bytes: 18652
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> d(n);
  for(int i=0;i<n;i++){
    cin>>d[i];
  }
  sort(d.begin(),d.end());
  int half=n/2;
  int half2=n/2-1;
  if(d[half]==d[half2]){
    cout<<0<<endl;
    return 0;
  }
  cout<<d[half]-d[half2]<<endl;
}

Measured memory_bytes: 3768
#include<iostream>
#include<vector>
#include<algorithm>

#define REP(i, n) for (int i=0;i<int(n);++i)
#define FOR(i, a, b) for (int i=int(a);i<int(b);++i)
#define EACH(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

struct HeavyLight {
  int pathCount,n;
  vector<int>size,parent,in,out,path,pathSize,pathPos,pathRoot;
  vector<vector<int> > len,tree;

  HeavyLight(int n,vector<vector<int> > t)
    :pathCount(0),n(n),size(n),parent(n),in(n),out(n),
     path(n),pathSize(n),pathPos(n),pathRoot(n),tree(t){
    int time=0;
    dfs(0,-1,time);
    buildPaths(0,newPath(0));
  }

  void dfs(int u, int p, int &k){
    in[u]=k++, parent[u]=p, size[u]=1;
    EACH(v,tree[u])if(*v!=p)dfs(*v, u, k),size[u]+=size[*v];
    out[u]=k++;
  }

  int newPath(int u){ pathRoot[pathCount]=u; return pathCount++; }

  void buildPaths(int u, int pt){
    path[u]=pt, pathPos[u]=pathSize[pt]++;
    EACH(v,tree[u])if(*v != parent[u])
      buildPaths(*v, 2*size[*v] >= size[u] ? pt : newPath(*v));
  }

  bool isAncestor(int p, int ch){
    return in[p] <= in[ch] && out[ch] <= out[p];
  }

  int lca(int a,int b){
    for(int root; !isAncestor(root=pathRoot[path[a]],b);a=parent[root]);
    for(int root; !isAncestor(root=pathRoot[path[b]],a);b=parent[root]);
    return isAncestor(a,b)?a:b;
  }
};

//Usage: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_5_C
int main(void){
  ios::sync_with_stdio(false);

  int n;
  cin >> n;
  vector<vector<int> >tree(n);
  
  REP(i,n){
    int k;
    cin >> k;
    REP(j,k){
      int ch;
      cin >> ch;
      tree[i].push_back(ch);
    }
  }

  HeavyLight hl = HeavyLight(n,tree);

  int q;
  cin >> q;
  while(q--){
    int u,v;
    cin >> u >> v;
    cout << hl.lca(u,v) << "\n";
  }
  
  return 0;
}

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

using namespace std;
using ll = long long;
#define rep(i, n) for(ll i = 0; i < (ll)(n); ++i)
#define REP(i, n) for(ll i = n-1; i >= 0; i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr << #x << " = " << x << endl
#define mp make_pair
#define pb push_back

const long long MOD = 1000000007;
const long long INF = 1LL<<60;


int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(12);

    string s;
    cin >> s;
    if(s=="ABC"){
        cout << "ARC" << endl;
    }else{
        cout << "ABC" << endl;
    }

    return 0;
}


Measured memory_bytes: 3580