akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

using ll = long long;
using ull = unsigned long long;

map<ll, int> cnt;

void prime_factor(ll n) {
    for (ll i = 2; i * i <= n; ++i) {
        if (n % i == 0) {
            cnt[i]++;
            while (n % i == 0)
                n /= i;
        }
    }
    if (n != 1)
        cnt[n]++;
}

int main() {
    ll a, b;
    cin >> a >> b;
    prime_factor(a);
    prime_factor(b);
    int ans = 1;
    for (auto t : cnt) {
        if (t.second == 2)
            ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }

    static void Main() {
        var ab = ReadInts();
        int ans = (ab[0] + ab[1]) % 24;
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

    ll n;
    cin >> n;
    string s;
    map<string, ll> mp;
    REP(i, n) {
        cin >> s;
        mp[s]++;
    }
    ll res = mp.size();
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 19180
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;cin >> s;
  int n=s.size();
  int cnt=0;
  for(int i=0;i<n/2;i++){
    if(s[i]!=s[n-1-i]){
      cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int[] v=new int[N];
		for(int i=0; i<N; i++) {
			v[i]=sc.nextInt();
		}
		for(int i=0; i<N; i++) {
			for(int j=0; j<i; j++) {
				if(i!=j) {
					if(Math.abs(v[i]-v[j])>0 && Math.abs(v[i]-v[j])%(N-1)==0) {
						pl(v[i]+" "+v[j]);
						System.exit(0);
					}
				}
			}
		}
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


Measured memory_bytes: 25172
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<59;
const double pi=acos(-1);
const double eps=1e-7;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll k,a,b;

int main(){
	cin>>k>>a>>b;
	ll res;
	if(a<k&&a<=b) res=-1;
	else if(a>=k) res=1;
	else res=(k-b-1)/(a-b)*2+1;
	cout<<res<<endl;
}

Measured memory_bytes: 256
f = lambda:map(int,input().split())
_,m = f()
l = list(map(lambda x:-x,f()))
import heapq as hq
hq.heapify(l)
for i in range(m):
  p = -hq.heappop(l)//2
  hq.heappush(l,-p)
print(-sum(l))

Measured memory_bytes: 14252
import std.algorithm;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.meta;
import std.random;
import std.range;
import std.stdio;
import std.string;
import std.traits;
import std.typecons;

auto solve(long N, long[] v){
    return v.sort().map!(to!double).reduce!"(a + b) / 2";
}

void main(){
    auto input = stdin.byLine.map!split.joiner;

    long N;
    N = input.front.to!long;
    input.popFront;

    long[] v = new long[](cast(size_t) (N));
    foreach (i; 0 .. cast(size_t) (N)) {
        v[i] = input.front.to!long;
        input.popFront;
    }

    static if (is(ReturnType!solve == void))
        solve(N, v);
    else
        solve(N, v).writeln;
}


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

int a[100000];

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

  map<int, int> mp;
  for (int i = 0; i < n; i++) mp[a[i]]++;

  int ans = 0;
  for (const auto& p : mp) {
    int x = p.first;
    int n = p.second;
    if (n < x)
      ans += n;
    else
      ans += n - x;
  }

  cout << ans << endl;
}


Measured memory_bytes: 5120
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
#include <random>
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
using namespace std;

#define INF 100000000

#define EPS 1e-9


int main() {
	int n, l;
	cin >> n >> l;
	int a[210];
	int sum=0;
	for(int i = 1; i <=n;++i) {
		a[i] = l + i - 1;
		sum += a[i];
	}
	int ans = INF;
	for (int i = 1; i <= n; ++i) {
		int temp = abs(sum - (sum - a[i]));
		if (ans > temp) {
			ans = temp;
		}
		
	}
	if (sum < 0) {
		cout << sum + ans << endl;
	}
	else {
		cout << sum - ans << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  d = N % 10;
  c = (N % 100 - d) / 10;
  b = (N % 1000 - c * 10 - d) / 100;
  a = (N - b * 100 - c * 10 - d) / 1000;
  if (a == b && b == c && c == d) {
    cout << "Yes" << endl;
  }
  
  else if (a == b && b == c && c != d) {
    cout << "Yes" << endl;
  }
  
  else if (a != b && b == c && c == d) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N=int(input())
W=[input() for i in range(N)]

for i in range(1, N):
  if W[i][0]!=W[i-1][-1]:
    print('No')
    exit()
    
for i in range(N-1):
  for j in range(i+1, N):
    if W[i]==W[j]:
      print('No')
      exit()
      
print('Yes')

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cstring>
using namespace std;

vector<int> graph[100001];
int dp[100001]; // dp[i] : Length Of Longest Path Starting At Node 'i'.

int longestPath(int src) {
    if(dp[src] != -1) return dp[src];
    bool leaf = 1;
    int bestChild = 0;
    for(int child : graph[src]) {
        leaf = 0;
        bestChild = max(bestChild, longestPath(child));
    }
    return (dp[src] = (leaf ? 0 : (1 + bestChild)));
}

int main() {
    int n, m;
    cin >> n >> m;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < m; i++) {
        int u, v;
        cin >> u >> v;
        graph[u].push_back(v);
    }
    int ans = 0;
    for(int i = 1; i <= n; i++) ans = max(ans, longestPath(i));
    cout << ans;
    return 0; 
}

Measured memory_bytes: 11496
#include<iostream>
#include<string>
using namespace std;
int main()
{
    string s;
  	cin >> s;
      
    if (s == "Sunny") cout << "Cloudy" << endl;
    if (s == "Cloudy") cout << "Rainy" << endl;
    if (s == "Rainy") cout << "Sunny" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
class Graph {
private:
  const static int INF = 1000000; 
  std::vector<std::vector<int> > edge_;
  unsigned int size_;
public:
  Graph(unsigned int size);
  Graph& connect(int from, int to, int weight);
  std::vector<int> neighbours(int node) const;
  unsigned int size() const;
};

const int Graph::INF;

Graph::Graph(unsigned int size) {
  size_ = size;
  edge_ = std::vector<std::vector<int> > (size_, std::vector<int>(size_, INF));
}

Graph& Graph::connect(int from, int to, int weight = 1) {
  edge_[from][to] = weight;
  return *this;
}

std::vector<int> Graph::neighbours(int node) const {
  std::vector<int> neighbours;
  for (int i = 0; i < static_cast<int>(size_); ++i)
    if (edge_[node][i] < INF) neighbours.push_back(i);

  return neighbours;
}

unsigned int Graph::size() const {
  return size_;
}


Graph creat_graph(int n, int m);
int search_prim(Graph prim, int n);

vector<int> ans;
vector<vector<int>> cost(100,vector<int>(100,0));

int main(){
  int n,m;
 
  
  while(cin >> n >> m, n){     
    Graph prim = creat_graph(n,m);   /*creat graph*/
    ans.push_back(search_prim(prim,n));   /*make answer*/
  }
  
  for(int i: ans){
    cout << i << endl;
  }
  return 0;
}


 Graph creat_graph(int n,int m){
    Graph prim(n);
    int a,b,cost_t;

    for(int i=0; i<m; i++){
      cin >> a >> b >> cost_t;
      prim.connect(a,b);
prim.connect(b,a);
      cost[a][b] = cost_t;
      cost[b][a] = cost_t;
    }
    return prim;
  }
    
int search_prim(Graph prim, int n){
  int current,cost_sum;
  typedef pair<int, int> PII;
  vector<bool> frag(n,false);
  priority_queue < PII, vector < pair <int, int> >, greater < pair <int, int> > > que;
  /*cost,next_node*/
  
  cost_sum = 0;
  current = 0;
  frag[0] = true;
  for(int k=0; k<n-1; ++k){
     vector<int> near = prim.neighbours(current);

     for(int j:near){
       que.push(PII(cost[current][j],j));
     }

     while(1){
       auto top = que.top();
       que.pop();
       if(frag[top.second] == false){
	 cost_sum += top.first;
	 frag[top.second] = true;
	 current = top.second;
	 break;
	 }
     }  
  }
  return cost_sum;
}
       
       
       
     
     
     
     

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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int i, j;
  for (i = 0; i < n; i++) {
    cin >> a[i];
  }
  map<int, int> a_list;
  for (i = 0; i < 11; i++) {
    a_list.insert(make_pair(i, 0));
  }
  for (i = 0; i < k; i++) {
    a_list[a[i]]++;
  }
  int index = 0;
  string result = "";
  for (i = k; i < n; i++) {
    a_list[a[i]]++;
    for (j = 9; j >= 0; j--) {
      if (a_list[j]) {
        while (a[index] != j) {
          a_list[a[index]]--;
          index++;
        }
        result += j + '0';
        a_list[j]--;
        index++;
        break;
      }
    }
  }
  cout << result << endl;
  return 0;
}



Measured memory_bytes: 3944
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX + 1];

void maxHeapify(int i)
{
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    if (l <= H && A[l] > A[i])
    {
        largest = l;
    }
    else
    {
        largest = i;
    }

    if (r <= H && A[r] > A[largest])
    {
        largest = r;
    }

    if (largest != i)
    {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract()
{
    int maxv;
    if (H < 1) return -INFTY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key)
{
    if (key < A[i]) return;
    A[i] = key;
    while (i > 1 && A[i / 2] < A[i])
    {
        swap(A[i], A[i / 2]);
        i = i / 2;
    }
}

void insert(int key)
{
    H++;
    A[H] = -INFTY;
    increaseKey(H, key);
}

int main()
{
    int key;
    char com[10];

    while (1)
    {
        scanf("%s", com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i')
        {
            scanf("%d", &key);
            insert(key);
        }
        else
        {
            printf("%d\n", extract());

        }
    }

    return 0;
}


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

typedef struct treeNode{
  int key;
  struct treeNode *p;
  struct treeNode *left;
  struct treeNode *right;
}Node;

void printPreorder(Node *);
void printInorder(Node *);
void insert(Node *);

Node *T = NULL;

int main(){
  int m, i, root, k;
  Node *temp;
  char s[7];

  scanf("%d", &m);

  for(i=0; i<m; i++){
    scanf("%s", s);
    //printf("%s\n", s);
    if(s[0] == 'i'){
      temp = malloc(sizeof(Node));
      scanf("%d", &(temp->key));
      temp->left = NULL;
      temp->right = NULL;
      insert(temp);
      //printf("i = %d m = %d\n",i,m);
      //fflush(stdout);
    }else{
      //printf("%d\n",i);
      printInorder(T);
      printf("\n");
      printPreorder(T);
      printf("\n");
    }
  }
  
  return 0;
}

void printPreorder(Node *N){
  printf(" %d", N->key);

  if(N->left != NULL){
    printPreorder(N->left);
  }

  if(N->right != NULL){
    printPreorder(N->right);
  }

}

void printInorder(Node *N){

  if(N->left != NULL){
    printInorder(N->left);
  }

  printf(" %d", N->key);

  if(N->right != NULL){
    printInorder(N->right);
  }

}

void insert(Node *z){
  Node *x, *y;

  y = NULL; // xの親
  x = T;

  while(x != NULL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->p = y;
  
  if( y == NULL){
    T = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }

}

Measured memory_bytes: 24036
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
//# define int long long
struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

LL n, m, l;
LL d[303][303];
LL d2[303][303];
int q;
int main(){
    cin >> n >> m >> l;
    REP(i, 303)REP(j, 303)if(i != j) d[i][j] = d2[i][j] = HINF<LL>();
    REP(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        d[a][b] = d[b][a] = c;
    }
    REP(k, n)REP(i, n)REP(j, n)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
    REP(i, n)REP(j, n)if(d[i][j] <= l)d2[i][j] = d2[j][i] = 1;
    REP(k, n)REP(i, n)REP(j, n)d2[i][j] = min(d2[i][j], d2[i][k] + d2[k][j]);
    cin >> q;
    REP(i, q){
        int s, t;
        cin >> s >> t;
        s--, t--;
        cout << (d2[s][t] == HINF<LL>() ? -1 : d2[s][t] - 1) << endl;
    }
}

Measured memory_bytes: 2048
n = int(input())
l = list(map(int,input().split(' ')))

l = sorted(l)

ans = 0
for i in range (0,n-2):
	for j in range (i + 1,n-1):
		for k in range (j + 1,n):
			if l[i] != l[j] and l[j] != l[k] and l[i] != l[k] and l[i] + l[j] > l[k]:
				ans += 1

print(ans)

Measured memory_bytes: 9096
import java.io.*;
import java.util.*;
import java.util.stream.Stream;

public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
		int elemsCount = Integer.parseInt(stdin.readLine());
		int[] elems = Stream.of(stdin.readLine().split(" ")).mapToInt(Integer::parseInt).toArray();
		TreeMap<Integer, Integer> numCount = new TreeMap<Integer, Integer>();
		Arrays.stream(elems).forEach(num -> {
			if(numCount.containsKey(num)) {
				numCount.put(num, numCount.get(num) + 1);
			}else {
				numCount.put(num, 1);
			}
		});
		int ans = 0;
		for(Map.Entry<Integer, Integer> entry: numCount.entrySet()) {
			int num = entry.getKey();
			int count = entry.getValue();
			if(num != count) {
				if (num < count) ans += count - num;
				else ans += count;
			}
		}
		System.out.println(ans);
	}

}

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

int main(){
  string s,t;
  cin >> s >> t;
  
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(s < t)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  vector<int> count(26, 0); 
  for(int i = 0; i < S.size(); i++) {
    int n = S.at(i) - 'a';
    count[n]++;
  }
  bool finished = false;
  for(int i = 0; i < 26; i++) {
    if(count[i] % 2 == 1) {
      finished = true;
      break;
    }
  }
  if(finished) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

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

int main() {
  int x, y;
  cin >> x >> y;
  int a[] = {1, 3, 5, 7, 8, 10, 12};
  int b[] = {4, 6, 9, 11};
  for(int i = 0; i < 7; ++i) {
    if(a[i] == x) {
      x = 10;
    }

    if(a[i] == y) {
      y = 10;
    }
  }
  for(int i = 0; i < 4; ++i) {
    if(b[i] == x) {
      x = 20;
    }

    if(b[i] == y) {
      y = 20;
    }
  }

  if(x == 2) x = 30;
  if(y == 2) y = 30;
  if(x == y) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;

bool is_prime(int n) {
	if (n < 2) {
			return false;
	}
	if (n==2||n==3) {
		return true;
	}
	for (int i = 3; i < n; i = i+2) {
		if (n%i==0) {
			return false;
		}
	}
	return true;
}

int check_ind(std::vector<int> v, int n) {
	int ind = 0;
	for (std::vector<int>::iterator itr = v.begin(); itr != v.end(); ++itr) {
		if (*itr > n) {
			return ind;
		}
		ind++;
	}
	return 0;
}

int main(void) {
	int n = 101000;
	std::vector<bool> prime(n);
	std::vector<int> p;
	for (int i = 0; i < n+2; i++) {
		prime[i] = true;
	}
	prime[0] = false;
	prime[1] = false;
	for (int i = 2; i <= sqrt(n); i++) {
		if (is_prime(i)) {
			for (int j = 2; i*j < n+2; j++) {
				prime[i*j] = false;
			}
		}
	}
	for (int i = 2; i < n+2; i++) {
		if (prime[i]) {
			p.push_back(i);
		}
	}

	int N,P;
	cin >> N;
	cin >> P;

	while (N != -1 || P != -1) {
		int ind = check_ind(p, N);
		std::vector<int> sum;

		for (int i = ind; i < ind+(2*sqrt(P))+10; i++) {
			for (int j = i; j < i+(2*sqrt(P))+10; j++) {
				sum.push_back(p[i]+p[j]);
			}
		}

		std::sort(sum.begin(), sum.end());

		cout << sum[P-1] << endl;

		cin >> N;
		cin >> P;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;

#define MOD (long long)(1e9+7)
#define REP(i,n) for(ll i = 0; i < n; i++)
#define REP1(i,n) for(ll i = 1; i <= n; i++)

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

void solve()
{
  // ll n; cin >> n;
  ll a, b, c, k; cin >> a >> b >> c >> k;
  // string s; cin >> s;
  // vector<ll> a(n); REP(i, n) cin >> a[i];
  ll ans = 0;
  // bool ok = false;
  if(k <= a) {
    ans = k;
  } else if( k <= a + b) {
    ans = a;
  } else {
      ans = a - (k - a - b);
  }
    
  cout << ans << endl;
  // cout << (ok?"Yes":"No") << endl;}
}


int main(void)
{
  // ll t; cin >> t; REP(i, t)
  solve();
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int gi() {
	char ch='!'; int res=0, f=0;
	while(ch<'0' || ch>'9') { ch=getchar(); if(ch == '-') f=1; }
	while(ch>='0' && ch<='9') res=res*10+ch-'0', ch=getchar();
	return f?-res:res;
}
const int N=1e5+100;
int n,m,fa[N],deg[N],head[N],ce;
struct edge { int to,nxt; } e[N<<1];
void lnk(int a,int b) { e[++ce]=(edge){b,head[a]}, head[a]=ce; }
int getfa(int x) { return x == fa[x]?x:fa[x]=getfa(fa[x]); }
void dfs(int u,int lst) {
	for(int i=head[u];i;i=e[i].nxt) {
		int v=e[i].to;
		if(v == lst) continue;
		dfs(v,u);
	}
	if(!lst) return;
	if(deg[u]&1)
		++deg[u], printf("%d %d\n",u,lst);
	else
		++deg[lst], printf("%d %d\n",lst,u);
}
int main() {
	n=gi(), m=gi();
	if(m&1) { puts("-1"); return 0; }
	for(int i=1;i<=n;++i) fa[i]=i;
	for(int i=1,u,v,fu,fv;i<=m;++i) {
		u=gi(), v=gi(), fu=getfa(u), fv=getfa(v);
		if(fu == fv) { printf("%d %d\n",u,v); ++deg[u]; continue; }
		fa[fu]=fv, lnk(u,v), lnk(v,u);
	}
	dfs(1,0);
	return 0;
}

Measured memory_bytes: 10328
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;

int main(){
    ll a,b,h,m;
    cin>>a>>b>>h>>m;
    double th=abs(2*M_PI/12*h+M_PI/6/60*m-2*M_PI/60*m);
    double ans=sqrt(a*a+b*b-2*a*b*cos(th));
    printf("%.9lf\n",ans);
    return 0;
}

Measured memory_bytes: 4188
using System;
using System.Collections.Generic;
using System.Linq;

namespace Cards
{
    class Program
    {
        static void Main(string[] args)
        {
            List<string> cards = new List<string>();

            foreach(char m in new char[4]{ 'S', 'H', 'C', 'D' })
            {
                foreach(int n in Enumerable.Range(1, 13))
                {
                    cards.Add(m + " " + n.ToString());
                }
            }

            List<string> input = new List<string>();

            int limit = int.Parse(Console.ReadLine());

            for(int i = 0; i < limit; i++)
            {
                input.Add(Console.ReadLine().Trim('\n'));
            }

            List<string> ans = new List<string>();

            foreach(string card in cards)
            {
                if(!input.Contains(card))
                    ans.Add(card);
            }

            ans.ForEach(e => Console.WriteLine(e));
        }
    }
}

Measured memory_bytes: 9536
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef double db;

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

const int N=2e4+5;
int n,a[N],b[N],p[N],k;

int main() {
//	file_put();
	
	scanf("%d",&n),a[1]=b[1]=1;
	rep(i,1,n+1) scanf("%d",&p[i]);
	rep(i,2,n+1) a[i]=b[i]=a[i-1]+n;
	reverse(b+1,b+n+1);
	rep(i,2,n+1) a[p[i]]+=i-1;
	rep(i,1,n+1) printf("%d%c",a[i]," \n"[i==n]);
	rep(i,1,n+1) printf("%d%c",b[i]," \n"[i==n]);
	
	return 0;
}



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

int main(){
  int bgn, ed;
  string str;
  cin >> str;
  
  for(int i=0; i<str.size(); i++){
    if(str[i] == 'A'){
      bgn = i;
      break;
    }
  }
  for(int i=0; i<str.size(); i++){
    if(str[i] == 'Z') ed = i;
  }
  cout << ed-bgn+1 << endl;
  return 0;
}


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

int main() {
	int n,a[1000];
	int ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int x=0;
	for (int i = 0; i < n; i++) {
		if (a[i]%2==0) {
			x++;
			if (a[i] % 3 == 0) {
				ans++;
			}
			else if (a[i] % 5 == 0) {
				ans++;
			}
		}
	}
	if (ans == x) {
		cout << "APPROVED" << endl;
	}
	else cout << "DENIED" << endl;

	return 0;

}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Kishan Sairam Adapa
 */

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long int
#define MOD ((int)(1e9) + 7)

using namespace std;

class ACandyDistributionAgain {
public:
    void solve(istream& cin, ostream& cout) {
        ll n, x;
        cin >> n >> x;
        vector<int> a;
        for(int i=0; i<n; i++) {
            int tp;
            cin >> tp;
            a.push_back(tp);
        }
        sort(a.begin(), a.end());
        int i;
        for( i=0; i<n; i++) {
            if(x < a[i]) break;
            x -= a[i];
        }
        if(x > 0 && i==n) i--;
        cout << i << '\n';
    }
};


int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    ACandyDistributionAgain solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int a,b,c;
		Scanner sc = new Scanner(System.in);
		a = sc.nextInt();
		b = sc.nextInt();
		c = sc.nextInt();

		if(a<b && b<c){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}
		sc.close();
	}

}

Measured memory_bytes: 26104
# coding: utf-8
N,M = map(int,input().split())

par = [i for i in range(N+1)]
rank = [0 for i in range(N+1)]
 
def find(x):
    if x==par[x]:
        return x
    else:
        par[x]=find(par[x])
        return par[x]
 
 
def unite(x,y):
    rx=find(x)
    ry=find(y)

    if rx==ry:
        return
    
    
    if rank[rx]<rank[ry]:
        par[rx]=ry
    else:
        par[ry]=rx

    if rank[rx]==rank[ry]:
        rank[rx]+=1
 

def some(x,y):
    return find(x)==find(y)
 
for i in range(M):
    a,b=map(int,input().split())
    unite(a,b)

for i in range(N):
    find(i+1)

cnt = [0 for i in range(N+1)]

for i in range(N+1):
    cnt[par[i]]+=1

print(max(cnt))
    
    
    
    
    
    


Measured memory_bytes: 20092
#include <bits/stdc++.h>
using namespace std;
#define SC               scanf
#define PF               printf
#define ull              unsigned long long
#define ld               long double
#define D                double
#define F                first
#define S                second
#define pb               push_back
#define pf               push_front
#define MP               make_pair
#define sort_a(a)        sort(a.begin(),a.end());
#define sort_d(a)        sort(a.rbegin(),a.rend());
#define READ(f)          freopen(f, "r", stdin)
#define WRITE(f)         freopen(f, "w", stdout)
#define rev(s)           reverse(s.begin(),s.end())
#define it(it,mp)        for(auto it=mp.begin() ; it!=mp.end() ; it++)
#define IOS              ios_base :: sync_with_stdio(false); cin.tie(NULL);
const int N = 1e5 + 5;
const int inf = 1e9 + 1;
const double eps = 1e-15;
const double EPS = 1e-9;
const double PI = acos(-1.0);
typedef long long int                   ll;
typedef pair<int,int>                   PII;

const int mx = 1000005;

bool prime[mx];
vector <int> primeList;
int dp[mx];
void init()
{
    int n, i, j;

    for (i = 0; i < mx; i++)
    {
        prime[i] = 1;
    }

    for (i = 4; i < mx; i += 2)
    {
        prime[i] = 0;
    }

    int sq = sqrt(mx);

    for (i = 3; i <= sq; i += 2)
    {
        if (prime[i])
        {
            for (j = i * i; j < mx; j += i)
            {
                prime[j] = 0;
            }
        }
    }
}
int main()
{
    IOS
    // READ("test.txt");
    //WRITE("");
    init() ;
    dp[0] = 0;
    for(int i=1 ; i<=100005 ; i++){
        (prime[i] && prime[(i+1)/2] && i&1 && i!=1)?dp[i]=1:dp[i]=0;
        dp[i]+=dp[i-1] ;
    }
   // for(int i=0 ; i<10 ; i++)cout<<dp[i]<<" ";
    int n , l , r;
    cin >> n ;
    while(n--){
        cin >> l >> r ;
        cout<<dp[r]-dp[l-1]<<endl;
    }
}



Measured memory_bytes: 3840
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <iomanip>
//#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<char,int> P;

int n,m;
int table[10][10];
int search(int i, int j, int done)
{
	int ret=0;
	int dx=1;
	int dy=0;
	for(int k=0;k<4;k++,swap(dx,dy),dx=-dx){
		int x=i+dx;
		int y=j+dy;
		while(0<=x&&x<n&&0<=y&&y<m){
			if(table[x][y]>=0){
				if(done&(1<<table[x][y])){
					ret+=search(x,y,done^(1<<table[x][y]));
					break;
				}
			}
			else if(done==0&&table[x][y]==-1){
				ret++;
				break;
			}
			x+=dx;
			y+=dy;
		}
	}
	return ret;
}
int main() {
while(1){
	cin >> m >> n;
	if(m==0)return 0;
	int s=0,t=0;
	int c=0;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			int v;
			cin >> v;
			if(v==1){
				table[i][j]=c++;
			}
			else if(v==2)
			{
				s=i;
				t=j;
				table[i][j]=-1;
			}
			else{
				table[i][j]=-2;
			}
		}
	}
	int ret=search(s,t,(1<<c)-1);
	cout << ret << endl;
}
}

Measured memory_bytes: 1160
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main(){
  ll N; cin>>N;
  cout<<(10000-N)%1000<<endl;
}

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

int main()
{
	using namespace std;
	int N;
	cin >> N;
	vector<int> delicious;
	delicious.resize(N);
	for (auto &x : delicious) {
		cin >> x;
	}

	int sumOfHeal = 0;
	for (int i = 0; i < N; i++) {
		for (int j = i+1; j < N; j++) {
			sumOfHeal += delicious[i] * delicious[j];
		}
	}

	cout << sumOfHeal << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
using namespace std;
#define ll long long
#define INF 1000000007
using P = pair<int, int>;
int main(){
    int n;
    cin>>n;
    string name[114514];
    for(int i=0;i<n;i++)cin>>name[i];
    ll c[5]={};
    for(int i=0;i<n;i++){
        if(name[i][0]=='M')c[0]++;
        if(name[i][0]=='A')c[1]++;
        if(name[i][0]=='R')c[2]++;
        if(name[i][0]=='C')c[3]++;
        if(name[i][0]=='H')c[4]++;
    }
    ll ans=0;
    ans+=c[0]*c[1]*c[2]+c[0]*c[1]*c[3]+c[0]*c[1]*c[4]+c[0]*c[2]*c[3]+c[0]*c[2]*c[4]+c[0]*c[3]*c[4]+
    c[1]*c[2]*c[3]+c[1]*c[2]*c[4]+c[1]*c[3]*c[4]+c[2]*c[3]*c[4];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);

  ll X, K, D; cin >> X >> K >> D;

  X = abs(X);

  ll t = min(K, X/D);
  K -= t;
  X -= t * D;

  if(K%2 == 0){
    cout << X << endl;
  }else{
    cout <<D-X << endl;
  }
  

  return 0;
}

Measured memory_bytes: 3660
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#define REP(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 1
#ifdef LOCAL
#define DEBUG(s) cout << (s) << endl
#define dump(x)  cerr << #x << " = " << (x) << endl
#define BR cout << endl;
#else
#define DEBUG(s) do{}while(0)
#define dump(x) do{}while(0)
#define BR
#endif


//改造
typedef long long int ll;
using namespace std;


//ここから編集する


int main() {
    int H,W;
    cin >> H >> W;
    vector<vector<int> > v(H,vector<int>(W));
    int N;
    cin >> N;
    vector<int> a(N+1);
    REP(i,1,N+1){
        cin >> a[i];
    }
    int cc = 1;
    REP(i,0,H){
        REP(j,0,W){
//            cin >> v[i][j];
            if(a[cc] > 0){
                v[i][j] = cc;
                a[cc]--;
            }
            if(a[cc] == 0){
                cc++;
            }
        }
    }

    REP(i,0,H){
        if(i % 2 == 1){
            reverse(v[i].begin(),v[i].end());
        }
    }

    REP(i,0,H){
        REP(j,0,W){
            cout << v[i][j];
            if(j < W - 1) cout << " ";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;


int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n){ cin >> a[i]; }
  sort(a.rbegin(),a.rend());
  int al=0, bo=0;
  rep(i,n){
    if(i%2==0){ al+=a[i]; } else { bo+=a[i]; }
  }
  
  cout << al-bo << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
  int n;
  while(cin >> n) {
      if(n==0) {
          return 0;
      }
      int a;
      for(int i=0; i<9; i++) {
        cin >> a;
          n-=a;
      }
      cout << n << endl;
  }
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
ll ans=0;
int N,M,Q;
vector<int> a,b,c,d;
int A[10];
void dfs(int now=0, int last=1){
  if(now==N){
    ll k=0;
    rep(i,0,Q){
      if(A[b[i]]-A[a[i]]==c[i]) k += d[i];
    }
    chmax(ans, k);
    return;
  }
  for(int i=last ; i<=M ; i++){
    A[now] = i;
    dfs(now+1, i);
  }
}
int main(){
  cin>>N>>M>>Q;
  a.resize(Q);  b.resize(Q);  c.resize(Q);  d.resize(Q);
  rep(i,0,Q){
    cin>>a[i]>>b[i]>>c[i]>>d[i];
    --a[i]; --b[i];
  }
  dfs();
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3576
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = (int)(1e6) + 5;
vector < pii > g[N];
const int oo = 1e9 + 69;
int D[N];
int main(void)
{
    int n,m;
    ios_base :: sync_with_stdio(0);
    cin>>n>>m;
    vector < vi > v(m,vi(3,0));
    for (auto & it : v)
        for (int i = 0;i < 3;++i)
            cin>>it[i];
    for (auto it : v)
        g[it[0]].pb(mp(it[1],it[2])),
        g[it[1]].pb(mp(it[0],-it[2]));
  for (int i = 1;i <= n;++i)
        D[i] = -oo;
    for (int i = 1;i <= n;++i)
        if (D[i] == -oo)
        {
            D[i] = 0;
            queue < int > Q;
            Q.push(i);
            while (!Q.empty())
            {
                int node = Q.front();
                Q.pop();
                for (auto it : g[node])
                    if (D[it.fi] == -oo)
                        D[it.fi] = D[node] + it.se,Q.push(it.fi);
            }
        }
    for (auto it : v)
        if (D[it[1]] - D[it[0]] != it[2])
            return puts("No") * 0;
    puts("Yes");
    return 0;
}


Measured memory_bytes: 43264
#include <iostream>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

int main() {
    ll n, q;
    ll a[100002], b[100000], c[100000];
    ll ans[100002];
    cin >> n;
    rep (i, n) {
        a[i] = 0;
    }
    ans[0] = 0;
    rep (i, n) {
        int k;
        cin >> k;
        a[k]++;
        ans[0]+=k;
    }
    cin >> q;
    rep (i, q) {
        cin >> b[i];
        cin >> c[i];
    }

    rep (i, q) {
        ans[i+1] = ans[i] - b[i] * a[b[i]] + c[i] * a[b[i]];
        a[c[i]] += a[b[i]];
        a[b[i]] = 0;
    }

    rep (i, q) {
        cout << ans[i+1] << endl;
    }
    return 0;
}

Measured memory_bytes: 6316
N = int(input())
a = list(map(int, input().split()))

res = []
for start in [1, -1]:

    ans = 0
    _a = []
    prev_sign = start
    for i in range(0, N):
        c = a[i]
        if c >= 0 and prev_sign > 0:
            ans += abs(c - (-1))
            c = -1
        elif c <= 0 and prev_sign < 0:
            ans += abs(c - 1)
            c = 1
        if c > 0:
            prev_sign = 1
        else:
            prev_sign = -1
        _a.append(c)

    __a = [_a[0]]
    acm_sum = _a[0]
    for i in range(1, N):
        c = _a[i]
        if abs(acm_sum) >= abs(c):
            if c < 0:
                c = -1*(abs(acm_sum)+1)
            else:
                c = abs(acm_sum)+1
        acm_sum += c
        ans += abs(c - _a[i])
        __a.append(c)
    res.append(ans)

print(min(res))

Measured memory_bytes: 14468
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N, A, B; cin >> N >> A >> B;
    int ans = min(B, N * A);
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define int long long
using namespace std;
int dp[105][105][305];

int w[105],v[105];
int32_t main() {

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

    int n,m;

    cin>>n>>m;

    for(int i=1;i<=n;i++){
        cin>>w[i]>>v[i];
    }
    int w1 = w[1];
    for(int i=1;i<=n;i++){
        w[i]-=w1;
    }

    for(int i=1;i<=n;i++){
        for(int j=0;j<=n;j++){
            for(int k=0;k<=n*3;k++){
                if(w1+w[i]<=j*w1+k&&k>=w[i]&&j){
                    dp[i][j][k] = max(dp[i-1][j][k],dp[i-1][j-1][k-w[i]]+v[i]);
                }
                else dp[i][j][k] = dp[i-1][j][k];
            }
        }
    }
    int ans = 0;

    for(int i=0;i<=n;i++){
        for(int j=0;j<=3*n;j++){
            if(i*w1+j<=m){
                ans = max(ans,dp[n][i][j]);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(void){
    int N,*a;
    double s=0;
    scanf("%d",&N);
    a = malloc(sizeof(int)*N);
    for(int i=0;i<N;i++){
        scanf("%d",&a[i]);
        s +=(double) 1/a[i];
    }
    printf("%g",1/s);
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int T = scan.nextInt();
        int[] time = new int[6001];
        List<Pair> list = new ArrayList<>();
        for (int i = 0; i < N; i++) {
            Pair p = new Pair(scan.nextInt(), scan.nextInt());
            list.add(p);
        }
        list.sort(new PairComparator());
        Arrays.fill(time, Integer.MIN_VALUE);
        time[0] = 0;
        for (int i = 0; i < N; i++) {
            int[] next_time = Arrays.copyOfRange(time, 0, time.length);
            Pair p = list.get(i);
            for (int j = 0; j < T; j++) {
                if (time[j] == Integer.MIN_VALUE) {
                    continue;
                }
                next_time[j+p.A] = Math.max(next_time[j+p.A], time[j]+p.B);
            }
            time = next_time;
        }
        int ans = 0;
        for (int i = 0; i < 6001; i++) {
            ans = Math.max(ans, time[i]);
        }
        System.out.println(ans);
    }
    class Pair {
        int A;
        int B;
        Pair(int A, int B) {
            this.A = A;
            this.B = B;
        }
    }
    class PairComparator implements Comparator<Pair> {
        @Override
        public int compare(Pair o1, Pair o2) {
            if (o1.A != o2.A) {
                return Integer.compare(o1.A, o2.A);
            }
            return Integer.compare(o1.B, o2.B);
        }
    }
}


Measured memory_bytes: 57696